/*
  * (non-Javadoc)
  *
  * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
  */
 protected Control createContents(Composite parent) {
   Text text = new Text(parent, SWT.MULTI | SWT.READ_ONLY | SWT.WRAP);
   text.setForeground(JFaceColors.getErrorText(text.getDisplay()));
   text.setBackground(text.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
   text.setText(WorkbenchMessages.ErrorPreferencePage_errorMessage);
   return text;
 }
Пример #2
0
 private void statusMessage(boolean error, String message) {
   fStatusLabel.setText(message);
   if (error) {
     fStatusLabel.setForeground(JFaceColors.getErrorText(fStatusLabel.getDisplay()));
   } else {
     fStatusLabel.setForeground(null);
   }
 }
Пример #3
0
 @Override
 protected void createButtonsForButtonBar(Composite parent) {
   GridData gd = new GridData(GridData.FILL_HORIZONTAL);
   gd.horizontalAlignment = GridData.CENTER;
   parent.setLayoutData(gd);
   parent.setBackground(JFaceColors.getBannerBackground(parent.getDisplay()));
   Button button = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
   button.setFocus();
 }
  /**
   * Updates the message label widget.
   *
   * @since 3.0
   */
  private void updateMessageLabel() {
    if (fLabel != null && !fLabel.isDisposed()) {
      Display display = fLabel.getDisplay();
      if ((fErrorText != null && fErrorText.length() > 0) || fErrorImage != null) {
        String escapedErrorText = escape(fErrorText);
        fLabel.setForeground(JFaceColors.getErrorText(display));
        fLabel.setText(escapedErrorText);
        fLabel.setImage(fErrorImage);
        if (fToolTipText != null) fLabel.setToolTipText(escape(fToolTipText));
        else if (fErrorText.length() > fWidthInChars) fLabel.setToolTipText(escapedErrorText);
        else fLabel.setToolTipText(null);

      } else {
        String escapedText = escape(fText);
        fLabel.setForeground(fLabel.getParent().getForeground());
        fLabel.setText(escapedText);
        fLabel.setImage(fImage);
        if (fToolTipText != null) fLabel.setToolTipText(escape(fToolTipText));
        else if (fText != null && fText.length() > fWidthInChars)
          fLabel.setToolTipText(escapedText);
        else fLabel.setToolTipText(null);
      }
    }
  }
 /**
  * The Constructor.
  *
  * @param parent the parent
  */
 public AppliedStereotypeCompositeWithView(Composite parent) {
   super(parent);
   this.setBackground(JFaceColors.getBannerBackground(parent.getDisplay()));
 }
Пример #6
0
  @Override
  protected Control createDialogArea(Composite parent) {
    Color background = JFaceColors.getBannerBackground(parent.getDisplay());
    // Color foreground = JFaceColors.getBannerForeground(parent.getDisplay());
    parent.setBackground(background);

    Composite group = new Composite(parent, SWT.NONE);
    group.setBackground(background);
    GridLayout layout = new GridLayout(1, false);
    layout.marginHeight = 20;
    layout.marginWidth = 20;
    group.setLayout(layout);

    GridData gd;

    IProduct product = Platform.getProduct();
    String productVersion = DBeaverCore.getVersion().toString();

    Label titleLabel = new Label(group, SWT.NONE);
    titleLabel.setBackground(background);
    titleLabel.setFont(TITLE_FONT);
    titleLabel.setText(product.getProperty(PRODUCT_PROP_SUB_TITLE));
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalAlignment = GridData.CENTER;
    titleLabel.setLayoutData(gd);
    titleLabel.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseDoubleClick(MouseEvent e) {
            BusyIndicator.showWhile(
                getShell().getDisplay(),
                new Runnable() {
                  @Override
                  public void run() {
                    // Do not create InstallationDialog directly
                    // but execute "org.eclipse.ui.help.installationDialog" command
                    IWorkbenchWindow workbenchWindow =
                        PlatformUI.getWorkbench().getActiveWorkbenchWindow();
                    IHandlerService service = workbenchWindow.getService(IHandlerService.class);
                    if (service != null) {
                      try {
                        service.executeCommand(
                            "org.eclipse.ui.help.installationDialog", null); // $NON-NLS-1$
                      } catch (Exception e1) {
                        // just ignore error
                      }
                    }
                  }
                });
          }
        });

    Label imageLabel = new Label(group, SWT.NONE);
    imageLabel.setBackground(background);

    gd = new GridData();
    gd.verticalAlignment = GridData.BEGINNING;
    gd.horizontalAlignment = GridData.CENTER;
    gd.grabExcessHorizontalSpace = true;
    imageLabel.setLayoutData(gd);
    imageLabel.setImage(ABOUT_IMAGE);

    Label versionLabel = new Label(group, SWT.NONE);
    versionLabel.setBackground(background);
    versionLabel.setText(CoreMessages.dialog_about_label_version + productVersion);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalAlignment = GridData.CENTER;
    versionLabel.setLayoutData(gd);

    Label authorLabel = new Label(group, SWT.NONE);
    authorLabel.setBackground(background);
    authorLabel.setText(product.getProperty(PRODUCT_PROP_COPYRIGHT));
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalAlignment = GridData.CENTER;
    authorLabel.setLayoutData(gd);

    Link siteLink =
        UIUtils.createLink(
            group,
            UIUtils.makeAnchor(product.getProperty(PRODUCT_PROP_WEBSITE)),
            new SelectionAdapter() {
              @Override
              public void widgetSelected(SelectionEvent e) {
                UIUtils.launchProgram(e.text);
              }
            });
    siteLink.setBackground(background);
    gd = new GridData();
    gd.horizontalAlignment = GridData.CENTER;
    siteLink.setLayoutData(gd);

    Link emailLink =
        UIUtils.createLink(
            group,
            UIUtils.makeAnchor(product.getProperty(PRODUCT_PROP_EMAIL)),
            new SelectionAdapter() {
              @Override
              public void widgetSelected(SelectionEvent e) {
                UIUtils.launchProgram("mailto:" + e.text); // $NON-NLS-1$
              }
            });
    emailLink.setBackground(background);
    gd = new GridData();
    gd.horizontalAlignment = GridData.CENTER;
    emailLink.setLayoutData(gd);

    return parent;
  }
  @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));
            }
          }
        });
  }
Пример #8
0
  public Control createControl(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginHeight = 3;
    layout.marginWidth = 3;
    composite.setLayout(layout);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));

    Label description = new Label(composite, SWT.WRAP);
    description.setText(BeansUIPlugin.getResourceString(DESCRIPTION));
    description.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    Composite tableAndButtons = new Composite(composite, SWT.NONE);
    tableAndButtons.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.numColumns = 2;
    tableAndButtons.setLayout(layout);

    // Create table and viewer for Spring bean config files
    configsTable =
        new Table(
            tableAndButtons,
            SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.widthHint = TABLE_WIDTH;
    data.heightHint = TABLE_WIDTH;
    configsTable.setLayoutData(data);
    configsTable.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            handleTableSelectionChanged();
          }
        });
    configsViewer = new TableViewer(configsTable);
    configsViewer.setContentProvider(new ConfigFilesContentProvider(project));
    configsViewer.setLabelProvider(new PropertiesModelLabelProvider());
    configsViewer.setInput(this); // activate content provider
    configsViewer.setSorter(new ConfigFilesSorter());

    if (this.selectedElement != null) {
      configsViewer.setSelection(new StructuredSelection(selectedElement), true);
    }

    if (BeansConfigLocatorFactory.hasEnabledBeansConfigLocatorDefinitions(project.getProject())) {
      Label note = new Label(composite, SWT.WRAP);
      note.setText(BeansUIPlugin.getResourceString(NOTE_LABEL));
      note.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    }

    Label options = new Label(composite, SWT.WRAP);
    options.setText("Options:");
    options.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    // Create enable import checkbox
    enableImportText =
        SpringUIUtils.createCheckBox(
            composite, BeansUIPlugin.getResourceString(ENABLE_IMPORT_LABEL));
    enableImportText.setSelection(project.isImportsEnabled());
    enableImportText.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            handleImportEnabledChanged();
          }
        });

    // Create ignore missing namespace handler checkbox
    ignoreMissingNamespaceHandlerText =
        SpringUIUtils.createCheckBox(
            composite, BeansUIPlugin.getResourceString(IGNORE_MISSING_NAMESPACEHANDLER_LABEL));
    ignoreMissingNamespaceHandlerText.setSelection(
        SpringCorePreferences.getProjectPreferences(project.getProject(), BeansCorePlugin.PLUGIN_ID)
            .getBoolean(
                BeansCorePlugin.IGNORE_MISSING_NAMESPACEHANDLER_PROPERTY,
                BeansCorePlugin.IGNORE_MISSING_NAMESPACEHANDLER_PROPERTY_DEFAULT));
    ignoreMissingNamespaceHandlerText.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            hasUserMadeChanges = true;
          }
        });

    // Create suffix text field
    suffixesText =
        SpringUIUtils.createTextField(composite, BeansUIPlugin.getResourceString(SUFFIXES_LABEL));
    suffixesText.setText(StringUtils.collectionToDelimitedString(project.getConfigSuffixes(), ","));
    suffixesText.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            handleSuffixesTextModified();
          }
        });

    // Create error label
    errorLabel = new Label(composite, SWT.NONE);
    errorLabel.setLayoutData(
        new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
    errorLabel.setForeground(JFaceColors.getErrorText(parent.getDisplay()));
    errorLabel.setBackground(JFaceColors.getErrorBackground(parent.getDisplay()));
    // Create button area
    Composite buttonArea = new Composite(tableAndButtons, SWT.NONE);
    layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    buttonArea.setLayout(layout);
    buttonArea.setLayoutData(new GridData(GridData.FILL_VERTICAL));
    addButton =
        SpringUIUtils.createButton(
            buttonArea, BeansUIPlugin.getResourceString(ADD_BUTTON), buttonListener);
    removeButton =
        SpringUIUtils.createButton(
            buttonArea, BeansUIPlugin.getResourceString(REMOVE_BUTTON), buttonListener, 0, false);
    scanButton = SpringUIUtils.createButton(buttonArea, "Scan...", buttonListener);
    model.addChangeListener(modelChangeListener);
    handleSuffixesTextModified();
    hasUserMadeChanges = false;
    // handleSuffixTextModified() has set this to true

    handleTableSelectionChanged();
    return composite;
  }
  private Composite fillInWorkArea(Composite workArea) {
    if (workArea.isDisposed()) System.err.println("fillInWorkArea:  workArea is disposed!!!");
    GridLayout workLayout = new GridLayout();
    workLayout.marginHeight = 0;
    workLayout.marginWidth = 0;
    workLayout.verticalSpacing = 0;
    workLayout.horizontalSpacing = 0;
    workArea.setLayout(workLayout);
    workArea.setLayoutData(new GridData(GridData.FILL_BOTH));

    // page group
    Color background = JFaceColors.getBannerBackground(parent.getDisplay());
    Color foreground = JFaceColors.getBannerForeground(parent.getDisplay());
    Composite top = (Composite) super.createDialogArea(workArea);

    // override any layout inherited from createDialogArea
    GridLayout layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.verticalSpacing = 0;
    layout.horizontalSpacing = 0;
    top.setLayout(layout);
    top.setLayoutData(new GridData(GridData.FILL_BOTH));
    top.setBackground(background);
    top.setForeground(foreground);

    // the image & text
    Composite topContainer = new Composite(top, SWT.NONE);
    topContainer.setBackground(background);
    topContainer.setForeground(foreground);

    layout = new GridLayout();
    layout.numColumns = (1);
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    layout.verticalSpacing = 0;
    layout.horizontalSpacing = 0;
    topContainer.setLayout(layout);
    GridData data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    data.grabExcessHorizontalSpace = true;
    topContainer.setLayoutData(data);

    String levelString = null;
    if (field.getPreferencesLevel() == null) {
      levelString = "Details as currently applicable";
      if (preferencesService.getProject() != null) {
        levelString += " (including project preferences):  ";
      } else {
        levelString += " (not including any project preferences):  ";
      }
    } else if (field.getPreferencesLevel().equals(IPreferencesService.INSTANCE_LEVEL))
      levelString = PreferenceDialogConstants.INSTANCE_LEVEL_STRING;
    else if (field.getPreferencesLevel().equals(IPreferencesService.CONFIGURATION_LEVEL))
      levelString = PreferenceDialogConstants.CONFIGURATION_LEVEL_STRING;
    else if (field.getPreferencesLevel().equals(IPreferencesService.DEFAULT_LEVEL))
      levelString = PreferenceDialogConstants.DEFAULT_LEVEL_STRING;
    else if (field.getPreferencesLevel().equals(IPreferencesService.PROJECT_LEVEL))
      levelString = PreferenceDialogConstants.PROJECT_LEVEL_STRING;
    else levelString = PreferenceDialogConstants.UNKNOWN_LEVEL_STRING + field.getPreferencesLevel();

    Label label = null;

    label = new Label(topContainer, SWT.LEAD);
    label.setText(levelString);
    label.setBackground(PreferencesUtilities.colorWhite);

    label = new Label(topContainer, SWT.LEAD);
    label.setText("\tCurrent value:  '" + field.getStringValue() + "'");
    label.setBackground(PreferencesUtilities.colorWhite);

    label = new Label(topContainer, SWT.LEAD);
    String level = PreferenceDialogConstants.getLevelName(field.getLevelFromWhichLoaded());
    label.setText("\tLevel at which set:  " + level);
    label.setBackground(PreferencesUtilities.colorWhite);

    label = new Label(topContainer, SWT.LEAD);
    //	        if (field.isEmptyStringAllowed()) {
    //		        label.setText(PreferenceDialogConstants.EMPTY_OK	);
    //	        } else {
    //		        label.setText(PreferenceDialogConstants.EMPTY_NOT_OK);
    //	        }
    label.setBackground(PreferencesUtilities.colorWhite);

    if ((field.getPreferencesLevel() != null)
        && field.getPreferencesLevel().equals(field.getLevelFromWhichLoaded())) {
      label = new Label(topContainer, SWT.LEAD);
      if (field.isRemovable()) {
        label.setText(PreferenceDialogConstants.IS_REMOVABLE);
      } else {
        label.setText(PreferenceDialogConstants.NOT_REMOVABLE);
      }
    }
    label.setBackground(PreferencesUtilities.colorWhite);

    label = new Label(top, SWT.LEAD);
    label.setText("~~~");
    label.setVisible(false);

    this.workArea = workArea;
    return workArea;
  }