/**
   * Method updateComponents.
   *
   * @param aParticipant - R4EParticipant
   */
  private void updateComponents(R4EParticipant aParticipant) {
    // Add item to the participants table
    final TableItem item = new TableItem(fAddedParticipantsTable, SWT.NONE);
    item.setText(0, aParticipant.getId());
    if (null != aParticipant.getEmail() && !("".equals(aParticipant.getEmail()))) {
      item.setFont(JFaceResources.getFontRegistry().get(JFaceResources.DEFAULT_FONT));
      item.setText(1, aParticipant.getEmail());
    } else {
      // Mark table item as not complete
      item.setFont(JFaceResources.getFontRegistry().getItalic(JFaceResources.DEFAULT_FONT));
    }
    fAddedParticipantsTable.showItem(item);

    if (fParticipants.size() > 0) {
      fClearParticipantsButton.setEnabled(true);
      fRemoveUserButton.setEnabled(true);
      if (fUserToAddCombo instanceof CCombo) {
        ((CCombo) fUserToAddCombo).setText("");
      } else {
        ((Text) fUserToAddCombo).setText("");
      }
      getButton(IDialogConstants.OK_ID).setEnabled(true);
      getButton(IDialogConstants.OK_ID).setSelection(false);
    } else {
      if (fReviewSource) {
        getButton(IDialogConstants.OK_ID).setEnabled(false);
      }
    }
  }
 /**
  * Save the values specified in the pages.
  *
  * <p>The default implementation of this framework method saves all pages of type <code>
  * PreferencePage</code> (if their store needs saving and is a <code>PreferenceStore</code>).
  *
  * <p>Subclasses may override.
  */
 protected void handleSave() {
   Iterator<IPreferenceNode> nodes =
       preferenceManager.getElements(PreferenceManager.PRE_ORDER).iterator();
   while (nodes.hasNext()) {
     IPreferenceNode node = nodes.next();
     IPreferencePage page = node.getPage();
     if (page instanceof PreferencePage) {
       // Save now in case tbe workbench does not shutdown cleanly
       IPreferenceStore store = ((PreferencePage) page).getPreferenceStore();
       if (store != null && store.needsSaving() && store instanceof IPersistentPreferenceStore) {
         try {
           ((IPersistentPreferenceStore) store).save();
         } catch (IOException e) {
           String message =
               JFaceResources.format(
                   "PreferenceDialog.saveErrorMessage",
                   page.getTitle(), // $NON-NLS-1$
                   e.getMessage());
           Policy.getStatusHandler()
               .show(
                   new Status(IStatus.ERROR, Policy.JFACE, message, e),
                   JFaceResources.getString("PreferenceDialog.saveErrorTitle")); // $NON-NLS-1$
         }
       }
     }
   }
 }
  /** @param args */
  public static void main(String[] args) {
    Display display = new Display();
    JFaceResources.getImageRegistry()
        .put(
            "IMG_1",
            ImageDescriptor.createFromURL(
                Snippet033CellEditorPerRowPre33.class
                    .getClassLoader()
                    .getResource("org/eclipse/jface/snippets/dialogs/cancel.png")));
    JFaceResources.getImageRegistry()
        .put(
            "IMG_2",
            ImageDescriptor.createFromURL(
                Snippet033CellEditorPerRowPre33.class
                    .getClassLoader()
                    .getResource("org/eclipse/jface/snippets/dialogs/filesave.png")));
    Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());
    new Snippet033CellEditorPerRowPre33(shell);
    shell.open();

    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }

    display.dispose();
  }
Exemplo n.º 4
0
 public static int getTableHeightHint(Table table, int rows) {
   if (table.getFont().equals(JFaceResources.getDefaultFont()))
     table.setFont(JFaceResources.getDialogFont());
   int result = table.getItemHeight() * rows + table.getHeaderHeight();
   if (table.getLinesVisible()) result += table.getGridLineWidth() * (rows - 1);
   return result;
 }
Exemplo n.º 5
0
    /**
     * Validates the entered file name.
     *
     * @return <tt>true</tt> if the entered file name is valid
     */
    boolean validate() {

      // check if agent is loaded
      String message = Util.ZERO_LENGTH_STRING;
      Image image = null;
      if (!isAgentLoaded) {
        message = Messages.transferingHprofFileNotSupportedMsg;
        image = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_INFO);
      }

      // check if text is empty
      String newText = fileNameField.getText();
      if (newText.isEmpty()) {
        message = Messages.fileNameEmptyMsg;
        image = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR);
      }

      // check if invalid characters are contained
      for (char c : INVALID_CHARACTERS) {
        if (fileNameField.getText().indexOf(c) != -1) {
          message = Messages.pathContainsInvalidCharactersMsg;
          image = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR);
          break;
        }
      }

      imageLabel.setImage(image);
      messageLabel.setText(message);

      getButton(IDialogConstants.OK_ID).setEnabled(message.isEmpty());
      return true;
    }
 private void updateIcons() {
   if (this.widget instanceof MenuItem) {
     final MenuItem item = (MenuItem) this.widget;
     final LocalResourceManager m = new LocalResourceManager(JFaceResources.getResources());
     try {
       item.setImage(this.icon == null ? null : m.createImage(this.icon));
     } catch (final DeviceResourceException e) {
       this.icon = ImageDescriptor.getMissingImageDescriptor();
       item.setImage(m.createImage(this.icon));
       // as we replaced the failed icon, log the message once.
       StatusManager.getManager()
           .handle(
               new Status(
                   IStatus.ERROR,
                   SharedUIResources.PLUGIN_ID,
                   "Failed to load image",
                   e)); //$NON-NLS-1$
     }
     disposeOldImages();
     this.localResourceManager = m;
   } else if (this.widget instanceof ToolItem) {
     final ToolItem item = (ToolItem) this.widget;
     final LocalResourceManager m = new LocalResourceManager(JFaceResources.getResources());
     item.setDisabledImage(this.disabledIcon == null ? null : m.createImage(this.disabledIcon));
     item.setHotImage(this.hoverIcon == null ? null : m.createImage(this.hoverIcon));
     item.setImage(this.icon == null ? null : m.createImage(this.icon));
     disposeOldImages();
     this.localResourceManager = m;
   }
 }
  public void createControl(Composite parent) {
    Composite composite = new Composite(parent, SWT.NULL);
    composite.setLayout(new GridLayout());
    composite.setLayoutData(
        new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL));
    setControl(composite);

    initializeDialogUnits(parent);

    // Actual contents
    Composite appSettings = new Composite(composite, SWT.NULL);
    appSettings.setLayout(new GridLayout(2, false));

    Label label = new Label(appSettings, SWT.NONE);
    label.setText(Messages.HerokuDeployWizardPage_ApplicationNameLabel);

    appName = new Text(appSettings, SWT.SINGLE | SWT.BORDER);
    appName.setLayoutData(new GridData(250, SWT.DEFAULT));
    // Set default name to project name
    appName.setText(getProjectName());
    appName.addModifyListener(
        new ModifyListener() {

          public void modifyText(ModifyEvent e) {
            getContainer().updateButtons();
          }
        });

    publishButton = new Button(composite, SWT.CHECK);
    publishButton.setText(Messages.HerokuDeployWizardPage_PublishApplicationLabel);
    publishButton.setSelection(
        Platform.getPreferencesService()
            .getBoolean(
                HerokuPlugin.getPluginIdentifier(),
                IPreferenceConstants.HEROKU_AUTO_PUBLISH,
                true,
                null));

    if (doesntHaveGitRepo()) {
      Label note = new Label(composite, SWT.WRAP);
      // We need this italic, we may need to set a font explicitly here to get it
      Font dialogFont = JFaceResources.getDialogFont();
      FontData[] data = SWTUtils.italicizedFont(JFaceResources.getDialogFont());
      final Font italic = new Font(dialogFont.getDevice(), data);
      note.setFont(italic);
      note.addDisposeListener(
          new DisposeListener() {
            public void widgetDisposed(DisposeEvent e) {
              if (!italic.isDisposed()) {
                italic.dispose();
              }
            }
          });

      note.setLayoutData(new GridData(400, SWT.DEFAULT));
      note.setText(Messages.HerokuDeployWizardPage_NoGitRepoNote);
    }

    Dialog.applyDialogFont(composite);
  }
Exemplo n.º 8
0
  private static void init() {
    BOLD = JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT);
    ITALIC = JFaceResources.getFontRegistry().getItalic(JFaceResources.DEFAULT_FONT);
    BOLD_ITALIC =
        new Font(
            Display.getCurrent(), getModifiedFontData(ITALIC.getFontData(), SWT.BOLD | SWT.ITALIC));

    Font defaultFont = JFaceResources.getFontRegistry().get(JFaceResources.DEFAULT_FONT);
    FontData[] defaultData = defaultFont.getFontData();
    if (defaultData != null && defaultData.length == 1) {
      FontData data =
          new FontData(
              defaultData[0].getName(), defaultData[0].getHeight(), defaultData[0].getStyle());

      if ("win32".equals(SWT.getPlatform())) { // $NON-NLS-1$
        // NOTE: Windows only, for: data.data.lfStrikeOut = 1;
        try {
          Field dataField = data.getClass().getDeclaredField("data"); // $NON-NLS-1$
          Object dataObject = dataField.get(data);
          Class<?> clazz = dataObject.getClass().getSuperclass();
          Field strikeOutFiled = clazz.getDeclaredField("lfStrikeOut"); // $NON-NLS-1$
          strikeOutFiled.set(dataObject, (byte) 1);
          CommonFonts.STRIKETHROUGH = new Font(Display.getCurrent(), data);
        } catch (Throwable t) {
          // ignore
        }
      }
    }
    if (CommonFonts.STRIKETHROUGH == null) {
      CommonFonts.HAS_STRIKETHROUGH = false;
      CommonFonts.STRIKETHROUGH = defaultFont;
    } else {
      CommonFonts.HAS_STRIKETHROUGH = true;
    }
  }
Exemplo n.º 9
0
  /**
   * Create a new instance of the receiver on a status.
   *
   * @param status The status to display.
   */
  SafeRunnableDialog(IStatus status) {

    super(
        null,
        JFaceResources.getString("error"),
        status.getMessage(), // $NON-NLS-1$
        status,
        IStatus.ERROR);

    setShellStyle(
        SWT.DIALOG_TRIM | SWT.MODELESS | SWT.RESIZE | SWT.MIN | SWT.MAX | getDefaultOrientation());

    setStatus(status);
    statuses.add(status);

    setBlockOnOpen(false);

    String reason =
        JFaceResources.getString("SafeRunnableDialog_checkDetailsMessage"); // $NON-NLS-1$
    if (status.getException() != null) {
      reason =
          status.getException().getMessage() == null
              ? status.getException().toString()
              : status.getException().getMessage();
    }
    this.message =
        JFaceResources.format(
            "SafeRunnableDialog_reason",
            new Object[] { // $NON-NLS-1$
              status.getMessage(), reason
            });
  }
 /** 添加帮助按钮,备注,这里的配置与其他的不一样 robert 2012-09-06 */
 protected Control createHelpToolItem(Composite parent) {
   // ROBERTHELP xml 转换器配置
   String language = CommonFunction.getSystemLanguage();
   final String helpUrl =
       MessageFormat.format(
           "/net.heartsome.cat.ts.ui.help/html/{0}/ch08.html#configure-xml-converter", language);
   Image helpImage = JFaceResources.getImage(DLG_IMG_HELP);
   ToolBar toolBar = new ToolBar(parent, SWT.FLAT | SWT.NO_FOCUS);
   toolBar.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
   final Cursor cursor = new Cursor(parent.getDisplay(), SWT.CURSOR_HAND);
   toolBar.setCursor(cursor);
   toolBar.addDisposeListener(
       new DisposeListener() {
         public void widgetDisposed(DisposeEvent e) {
           cursor.dispose();
         }
       });
   ToolItem helpItem = new ToolItem(toolBar, SWT.NONE);
   helpItem.setImage(helpImage);
   helpItem.setToolTipText(JFaceResources.getString("helpToolTip")); // $NON-NLS-1$
   helpItem.addSelectionListener(
       new SelectionAdapter() {
         public void widgetSelected(SelectionEvent e) {
           PlatformUI.getWorkbench().getHelpSystem().displayHelpResource(helpUrl);
         }
       });
   return toolBar;
 }
 /** Shows the "Page Flipping abort" dialog. */
 void showPageFlippingAbortDialog() {
   MessageDialog.open(
       MessageDialog.ERROR,
       getShell(),
       JFaceResources.getString("AbortPageFlippingDialog.title"), // $NON-NLS-1$
       JFaceResources.getString("AbortPageFlippingDialog.message"),
       SWT.SHEET); //$NON-NLS-1$
 }
Exemplo n.º 12
0
 /**
  * Fetches image descriptor by path.
  *
  * @param path path
  * @return {@link ImageDescriptor}
  */
 public static ImageDescriptor getImageDescriptor(String path) {
   final String key = path;
   ImageDescriptor regImage = JFaceResources.getImageRegistry().getDescriptor(key);
   if (regImage == null) {
     regImage = Activator.getImageDescriptor("icons/merge/" + path);
     JFaceResources.getImageRegistry().put(key, regImage);
   }
   return regImage;
 }
Exemplo n.º 13
0
  /*
   * (non-Javadoc)
   * @see org.eclipse.jface.viewers.IFontProvider#getFont(java.lang.Object)
   */
  public Font getFont(Object element) {
    Font font = JFaceResources.getFont(IThemeManager.VIEW_FONT_NAME);

    if (font == null) {
      font = JFaceResources.getTextFont();
    }

    return font;
  }
Exemplo n.º 14
0
 @Override
 public void applyStyles(TextStyle textStyle) {
   Font boldFont = JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT);
   textStyle.font = boldFont;
   textStyle.underline = true;
   textStyle.underlineStyle = SWT.UNDERLINE_SQUIGGLE;
   textStyle.foreground =
       JFaceResources.getColorRegistry().get(JFacePreferences.ERROR_COLOR);
 }
  /**
   * Constructor for TabbedPropertyTitle.
   *
   * @param parent the parent composite.
   * @param factory the widget factory for the tabbed property sheet
   */
  public TabbedPropertyTitle(Composite parent, TabbedPropertySheetWidgetFactory factory) {
    super(parent, SWT.NO_FOCUS);
    this.factory = factory;

    // RAP not suppported
    //		this.addPaintListener(new PaintListener() {
    //
    //			public void paintControl(PaintEvent e) {
    //				if (image == null && (text == null || text.equals(BLANK))) {
    //					label.setVisible(false);
    //				} else {
    //					label.setVisible(true);
    //					drawTitleBackground(e);
    //				}
    //			}
    //		});
    // /RAP

    factory.getColors().initializeSectionToolBarColors();
    setBackground(factory.getColors().getBackground());
    setForeground(factory.getColors().getForeground());

    FormLayout layout = new FormLayout();
    layout.marginWidth = 1;
    layout.marginHeight = 2;
    setLayout(layout);

    Font font;
    if (!JFaceResources.getFontRegistry().hasValueFor(TITLE_FONT)) {
      FontData[] fontData =
          JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT).getFontData();
      /* title font is 2pt larger than that used in the tabs. */
      fontData[0].setHeight(fontData[0].getHeight() + 2);
      JFaceResources.getFontRegistry().put(TITLE_FONT, fontData);
    }
    font = JFaceResources.getFont(TITLE_FONT);

    label = factory.createCLabel(this, BLANK);
    //		label.setBackground(new Color[] {
    //				factory.getColors().getColor(IFormColors.H_GRADIENT_END),
    //				factory.getColors().getColor(IFormColors.H_GRADIENT_START) },
    //				new int[] { 100 }, true);
    label.setFont(font);
    label.setForeground(factory.getColors().getColor(IFormColors.TITLE));
    FormData data = new FormData();
    data.left = new FormAttachment(0, 0);
    data.top = new FormAttachment(0, 0);
    data.right = new FormAttachment(100, 0);
    data.bottom = new FormAttachment(100, 0);
    label.setLayoutData(data);

    /*
     * setImage(PlatformUI.getWorkbench().getSharedImages().getImage(
     * ISharedImages.IMG_OBJ_ELEMENT));
     */
  }
 public Image getImage(Object element) {
   if (element instanceof MyModel3) {
     if (((MyModel3) element).checked) {
       return JFaceResources.getImage("IMG_1");
     } else {
       return JFaceResources.getImage("IMG_2");
     }
   }
   return super.getImage(element);
 }
 /**
  * Method decorateFont.
  *
  * @param aElement Object
  * @return Font
  * @see org.eclipse.jface.viewers.IFontDecorator#decorateFont(Object)
  */
 public Font decorateFont(Object aElement) { // $codepro.audit.disable
   if (null != R4EUIModelController.getActiveReview()
       && R4EUIModelController.getActiveReview().equals(aElement)) {
     return JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT);
   }
   if (isMyReview((IR4EUIModelElement) aElement)) {
     return JFaceResources.getFontRegistry().getItalic(JFaceResources.DEFAULT_FONT);
   }
   return null;
 }
Exemplo n.º 18
0
    @Override
    public void createControl(final Composite parent) {
      final Composite composite = new Composite(parent, SWT.NONE);
      composite.setLayout(LayoutUtil.applyDialogDefaults(new GridLayout(), 2));
      setControl(composite);

      final int count = getRefactoring().getAllOccurrencesCount();

      {
        final Label label = new Label(composite, SWT.NONE);
        label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1));
        label.setText(Messages.ExtractTemp_Wizard_header);
        label.setFont(JFaceResources.getBannerFont());
      }

      LayoutUtil.addSmallFiller(composite, false);

      {
        final Label label = new Label(composite, SWT.NONE);
        label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
        label.setText(Messages.ExtractTemp_Wizard_VariableName_label);

        fVariableNameControl = new Text(composite, SWT.BORDER);
        fVariableNameControl.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
        fVariableNameControl.setFont(JFaceResources.getTextFont());
      }

      LayoutUtil.addSmallFiller(composite, false);

      {
        if (count > 0) {
          final Label label = new Label(composite, SWT.WRAP);
          label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
          if (count == 1) {
            label.setText("No other occurrences of the selected expression found.");
          } else {
            label.setText(
                NLS.bind("{0} other occurrences of the selected expression found.", count - 1));
          }
        }

        fReplaceAllControl = new Button(composite, SWT.CHECK);
        fReplaceAllControl.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
        fReplaceAllControl.setText(Messages.ExtractTemp_Wizard_ReplaceAll_label);
        if (count <= 1) {
          fReplaceAllControl.setEnabled(false);
        }
      }

      LayoutUtil.addSmallFiller(composite, false);
      Dialog.applyDialogFont(composite);

      initBindings();
      //			PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(),);
    }
Exemplo n.º 19
0
  /**
   * Gets the default small font from the JFace font registry.
   *
   * @return default small font
   */
  public static Font getDefaultSmallFont() {
    Font small = JFaceResources.getFontRegistry().get(SMALL_FONT);
    if (small != null) {
      return small;
    }

    Font f = JFaceResources.getDefaultFont();
    FontData[] smaller = resizeFont(f, -2);
    JFaceResources.getFontRegistry().put(SMALL_FONT, smaller);
    return JFaceResources.getFontRegistry().get(SMALL_FONT);
  }
Exemplo n.º 20
0
 /**
  * Return a FontAwesome font for SWT.
  *
  * @return the font or null.
  */
 public static Font getFont() {
   if (JFaceResources.getFontRegistry().hasValueFor(FONTAWESOME)) {
     return JFaceResources.getFontRegistry().get(FONTAWESOME);
   }
   if (!loadFont()) {
     return null;
   }
   FontData[] data = new FontData[] {new FontData("fontawesome", 14, SWT.NORMAL)};
   JFaceResources.getFontRegistry().put(FONTAWESOME, data);
   return JFaceResources.getFontRegistry().get(FONTAWESOME);
 }
Exemplo n.º 21
0
 @Override
 public void applyStyles(TextStyle textStyle) {
   ColorRegistry colorRegistry = JFaceResources.getColorRegistry();
   Font font = JFaceResources.getFontRegistry().getBold(fontName);
   if (fForegroundColorName != null) {
     textStyle.foreground = colorRegistry.get(fForegroundColorName);
   }
   if (fBackgroundColorName != null) {
     textStyle.background = colorRegistry.get(fBackgroundColorName);
   }
   textStyle.font = font;
 }
Exemplo n.º 22
0
  public static Image getImage(String pluginId, String path) {
    Image image = JFaceResources.getImageRegistry().get(path);
    if (image == null) {
      ImageDescriptor descriptor = AbstractUIPlugin.imageDescriptorFromPlugin(pluginId, path);
      if (descriptor == null) {
        descriptor = ImageDescriptor.getMissingImageDescriptor();
      }
      JFaceResources.getImageRegistry().put(path, image = descriptor.createImage());
    }

    return image;
  }
Exemplo n.º 23
0
 public void dispose() {
   getEditorPreferenceStore().removePropertyChangeListener(this);
   JFaceResources.getFontRegistry().removeListener(this);
   JFaceResources.getColorRegistry().removeListener(this);
   if (fSourceViewerDecorationSupport != null) {
     fSourceViewerDecorationSupport.dispose();
     fSourceViewerDecorationSupport = null;
   }
   if (fActions != null) {
     fActions.clear();
     fActions = null;
   }
 }
Exemplo n.º 24
0
 protected Image getImageImage(String path) {
   Image image = JFaceResources.getImageRegistry().get(path);
   if (image == null) {
     ImageDescriptor descriptor =
         AbstractUIPlugin.imageDescriptorFromPlugin(
             "org.reuseware.application.taipan", path); // $NON-NLS-1$
     if (descriptor == null) {
       descriptor = ImageDescriptor.getMissingImageDescriptor();
     }
     JFaceResources.getImageRegistry().put(path, image = descriptor.createImage());
   }
   return image;
 }
Exemplo n.º 25
0
 /** Get image descriptors for the clear button. */
 static {
   ImageDescriptor descriptor =
       AbstractUIPlugin.imageDescriptorFromPlugin(
           PlatformUI.PLUGIN_ID, "$nl$/icons/full/etool16/clear_co.gif"); // $NON-NLS-1$
   if (descriptor != null) {
     JFaceResources.getImageRegistry().put(CLEAR_ICON, descriptor);
   }
   descriptor =
       AbstractUIPlugin.imageDescriptorFromPlugin(
           PlatformUI.PLUGIN_ID, "$nl$/icons/full/dtool16/clear_co.gif"); // $NON-NLS-1$
   if (descriptor != null) {
     JFaceResources.getImageRegistry().put(DCLEAR_ICON, descriptor);
   }
 }
  /**
   * Creates the wizard's title area.
   *
   * @param parent the SWT parent for the title area composite.
   * @return the created title area composite.
   */
  protected Composite createTitleArea(Composite parent) {
    // Create the title area which will contain
    // a title, message, and image.
    int margins = 2;
    titleArea = new Composite(parent, SWT.NONE);
    FormLayout layout = new FormLayout();
    layout.marginHeight = 0;
    layout.marginWidth = margins;
    titleArea.setLayout(layout);

    GridData layoutData = new GridData(GridData.FILL_HORIZONTAL);
    layoutData.verticalAlignment = SWT.TOP;
    titleArea.setLayoutData(layoutData);

    // Message label
    messageArea = new DialogMessageArea();
    messageArea.createContents(titleArea);

    titleArea.addControlListener(
        new ControlAdapter() {
          @Override
          public void controlResized(ControlEvent e) {
            updateMessage();
          }
        });

    final IPropertyChangeListener fontListener =
        event -> {
          if (JFaceResources.BANNER_FONT.equals(event.getProperty())) {
            updateMessage();
          }
          if (JFaceResources.DIALOG_FONT.equals(event.getProperty())) {
            updateMessage();
            Font dialogFont = JFaceResources.getDialogFont();
            updateTreeFont(dialogFont);
            Control[] children = ((Composite) buttonBar).getChildren();
            for (int i = 0; i < children.length; i++) {
              children[i].setFont(dialogFont);
            }
          }
        };

    titleArea.addDisposeListener(
        event -> JFaceResources.getFontRegistry().removeListener(fontListener));
    JFaceResources.getFontRegistry().addListener(fontListener);
    messageArea.setTitleLayoutData(createMessageAreaData());
    messageArea.setMessageLayoutData(createMessageAreaData());
    return titleArea;
  }
Exemplo n.º 27
0
 /**
  * Create the status list if required.
  *
  * @param parent the Control to create it in.
  */
 private void createStatusList(Composite parent) {
   if (isMultipleStatusDialog()) {
     if (statusListViewer == null) {
       // The job list doesn't exist so create it.
       setMessage(
           JFaceResources.getString("SafeRunnableDialog_MultipleErrorsMessage")); // $NON-NLS-1$
       getShell()
           .setText(
               JFaceResources.getString("SafeRunnableDialog_MultipleErrorsTitle")); // $NON-NLS-1$
       createStatusListArea(parent);
       showDetailsArea();
     }
     refreshStatusList();
   }
 }
Exemplo n.º 28
0
  public RElementInfoControl(final Shell shell, final String message) {
    super(shell, message);
    fMode = MODE_SIMPLE;

    JFaceResources.getFontRegistry().addListener(this);
    create();
  }
Exemplo n.º 29
0
  /**
   * Given a label figure object, this will calculate the correct Font needed to display into screen
   * coordinates, taking into account the current mapmode. This will typically be used by direct
   * edit cell editors that need to display independent of the zoom or any coordinate mapping that
   * is taking place on the drawing surface.
   *
   * @param label the label to use for the font calculation
   * @return the <code>Font</code> that is scaled to the screen coordinates. Note: the returned
   *     <code>Font</code> should not be disposed since it is cached by a common resource manager.
   */
  protected Font getScaledFont(IFigure label) {
    Font scaledFont = label.getFont();
    FontData data = scaledFont.getFontData()[0];
    Dimension fontSize = new Dimension(0, MapModeUtil.getMapMode(label).DPtoLP(data.getHeight()));
    label.translateToAbsolute(fontSize);

    if (Math.abs(data.getHeight() - fontSize.height) < 2) fontSize.height = data.getHeight();

    try {
      FontDescriptor fontDescriptor = FontDescriptor.createFrom(data);
      cachedFontDescriptors.add(fontDescriptor);
      return getResourceManager().createFont(fontDescriptor);
    } catch (DeviceResourceException e) {
      Trace.catching(
          DiagramUIPlugin.getInstance(),
          DiagramUIDebugOptions.EXCEPTIONS_CATCHING,
          getClass(),
          "getScaledFont",
          e); //$NON-NLS-1$
      Log.error(
          DiagramUIPlugin.getInstance(),
          DiagramUIStatusCodes.IGNORED_EXCEPTION_WARNING,
          "getScaledFont",
          e); //$NON-NLS-1$
    }
    return JFaceResources.getDefaultFont();
  }
  private Control createPreviewer(Composite parent) {
    IPreferenceStore generalTextStore = EditorsUI.getPreferenceStore();
    IPreferenceStore store =
        new ChainedPreferenceStore(new IPreferenceStore[] {getPreferenceStore(), generalTextStore});
    fPreviewViewer =
        new CSourceViewer(
            parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER, store);
    SimpleCSourceViewerConfiguration configuration =
        new SimpleCSourceViewerConfiguration(
            fColorManager, store, null, ICPartitions.C_PARTITIONING, false);
    fPreviewViewer.configure(configuration);
    Font font = JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
    fPreviewViewer.getTextWidget().setFont(font);
    CSourcePreviewerUpdater.registerPreviewer(fPreviewViewer, configuration, store);
    fPreviewViewer.setEditable(false);

    String content = loadPreviewContentFromFile("ColorSettingPreviewCode.txt"); // $NON-NLS-1$
    IDocument document = new Document(content);
    CUIPlugin.getDefault()
        .getTextTools()
        .setupCDocumentPartitioner(document, ICPartitions.C_PARTITIONING, null);
    fPreviewViewer.setDocument(document);

    installSemanticHighlighting();

    return fPreviewViewer.getControl();
  }