Пример #1
0
 private void onMouseEnter(Event e) {
   Hyperlink link = (Hyperlink) e.widget;
   previousBackground = link.getBackground();
   previousForeground = link.getForeground();
   if (isActiveBackgroundSet) link.setBackground(getActiveBackground());
   if (isActiveForegroundSet) link.setForeground(getActiveForeground());
   if (getHyperlinkUnderlineMode() == UNDERLINE_HOVER) link.setUnderlined(true);
   link.setCursor(getHyperlinkCursor());
 }
Пример #2
0
 /**
  * Sets the group foreground and also sets the background of all the currently managed links.
  *
  * @param fg the new foreground
  */
 @Override
 public void setForeground(Color fg) {
   super.setForeground(fg);
   isForegroundSet = true;
   if (links != null) {
     for (int i = 0; i < links.size(); i++) {
       Hyperlink label = links.get(i);
       label.setForeground(fg);
     }
   }
 }
  /*
   * (non-Javadoc)
   * @see org.eclipse.ice.viz.service.widgets.PlotComposite#createInfoContent(org.eclipse.swt.widgets.Composite, int)
   */
  @Override
  protected Composite createInfoContent(Composite parent, int style) {
    // Get the info Composite and its child with the message label.
    final Composite infoComposite = super.createInfoContent(parent, style);
    final Composite msgComposite = (Composite) infoComposite.getChildren()[1];

    // Get a Display and Shell used to create the hyperlink.
    final Display display = infoComposite.getDisplay();
    final Shell shell = infoComposite.getShell();

    // Set the text to display in the hyperlink.
    final String linkText = "Click here to update the connection " + "preferences.";

    // Create a link to the preference page.
    link = new Hyperlink(msgComposite, SWT.NONE);
    link.setText(linkText);
    link.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
    link.setUnderlined(true);
    link.setForeground(display.getSystemColor(SWT.COLOR_LINK_FOREGROUND));
    // Add the listener to redirect the user to the preferences.
    link.addHyperlinkListener(
        new IHyperlinkListener() {
          @Override
          public void linkActivated(HyperlinkEvent e) {
            // Open up the viz service connection preferences.
            PreferencesUtil.createPreferenceDialogOn(
                    shell, getConnectionPreferencePageID(), null, null)
                .open();
          }

          @Override
          public void linkEntered(HyperlinkEvent e) {
            // Nothing to do yet.
          }

          @Override
          public void linkExited(HyperlinkEvent e) {
            // Nothing to do yet.
          }
        });

    return infoComposite;
  }
Пример #4
0
 private void onMouseExit(Event e) {
   Hyperlink link = (Hyperlink) e.widget;
   if (isActiveBackgroundSet) link.setBackground(previousBackground);
   if (isActiveForegroundSet) link.setForeground(previousForeground);
   if (getHyperlinkUnderlineMode() == UNDERLINE_HOVER) link.setUnderlined(false);
 }
Пример #5
0
 /**
  * Adds a hyperlink to the group to be jointly managed. Hyperlink will be managed until it is
  * disposed. Settings like colors, cursors and modes will affect all managed hyperlinks.
  *
  * @param link
  */
 public void add(Hyperlink link) {
   if (isBackgroundSet) link.setBackground(getBackground());
   if (isForegroundSet) link.setForeground(getForeground());
   if (getHyperlinkUnderlineMode() == UNDERLINE_ALWAYS) link.setUnderlined(true);
   hook(link);
 }
  @Override
  public void createControl(Composite parent) {
    GridData gd;

    Composite composite = new Composite(parent, SWT.NULL);
    setControl(composite);

    composite.setLayout(new GridLayout(1, false));

    new Label(composite, SWT.NONE).setText("Select Template:");

    tree = new Tree(composite, SWT.BORDER | SWT.FULL_SELECTION);
    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    gd.heightHint = 100;
    tree.setLayoutData(gd);

    viewer = new TreeViewer(tree);
    contentProvider = new RepoTemplateContentProvider(false);
    viewer.setContentProvider(contentProvider);
    viewer.setLabelProvider(new RepoTemplateLabelProvider(loadedImages));
    viewer.addFilter(latestFilter);
    setTemplates(Collections.singletonList(emptyTemplate));

    btnLatestOnly = new Button(composite, SWT.CHECK);
    btnLatestOnly.setText("Show latest versions only");
    btnLatestOnly.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false));
    btnLatestOnly.setSelection(true);

    new Label(composite, SWT.NONE).setText("Description:");

    Composite cmpDescription = new Composite(composite, SWT.BORDER);
    cmpDescription.setBackground(tree.getBackground());

    txtDescription = new ScrolledFormText(cmpDescription, SWT.V_SCROLL | SWT.H_SCROLL, false);
    FormText formText = new FormText(txtDescription, SWT.NO_FOCUS);
    txtDescription.setFormText(formText);
    txtDescription.setBackground(tree.getBackground());
    formText.setBackground(tree.getBackground());
    formText.setForeground(tree.getForeground());
    formText.setFont("fixed", JFaceResources.getTextFont());
    formText.setFont("italic", JFaceResources.getFontRegistry().getItalic(""));

    GridData gd_cmpDescription = new GridData(SWT.FILL, SWT.FILL, true, true);
    gd_cmpDescription.heightHint = 100;
    cmpDescription.setLayoutData(gd_cmpDescription);

    GridLayout layout_cmpDescription = new GridLayout(1, false);
    cmpDescription.setLayout(layout_cmpDescription);

    GridData gd_txtDescription = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    gd_txtDescription.heightHint = 100;
    txtDescription.setLayoutData(gd_txtDescription);

    Hyperlink linkRetina = new Hyperlink(composite, SWT.NONE);
    linkRetina.setText("Why is this text blurred?");
    linkRetina.setUnderlined(true);
    linkRetina.setForeground(JFaceColors.getHyperlinkText(getShell().getDisplay()));
    linkRetina.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false));

    viewer.addSelectionChangedListener(
        new ISelectionChangedListener() {
          @Override
          public void selectionChanged(SelectionChangedEvent event) {
            Object element = ((IStructuredSelection) viewer.getSelection()).getFirstElement();
            setTemplate(element instanceof Template ? (Template) element : null);
            getContainer().updateButtons();
          }
        });
    viewer.addOpenListener(
        new IOpenListener() {
          @Override
          public void open(OpenEvent event) {
            Object element = ((IStructuredSelection) viewer.getSelection()).getFirstElement();
            setTemplate(element instanceof Template ? (Template) element : null);
            getContainer().updateButtons();
            IWizardPage nextPage = getNextPage();
            if (nextPage != null) getContainer().showPage(nextPage);
          }
        });
    btnLatestOnly.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            boolean latestOnly = btnLatestOnly.getSelection();
            if (latestOnly) viewer.addFilter(latestFilter);
            else viewer.removeFilter(latestFilter);
          }
        });
    linkRetina.addHyperlinkListener(
        new HyperlinkAdapter() {
          @Override
          public void linkActivated(HyperlinkEvent ev) {
            try {
              IWorkbenchBrowserSupport browser = PlatformUI.getWorkbench().getBrowserSupport();
              browser
                  .getExternalBrowser()
                  .openURL(
                      new URL(
                          "https://github.com/bndtools/bndtools/wiki/Blurry-Form-Text-on-High-Resolution-Displays"));
            } catch (Exception e) {
              log.log(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Browser open error", e));
            }
          }
        });
  }