Exemplo n.º 1
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.º 2
0
 private void setAndTest(String themeId, IPropertyChangeListener listener) {
   JFaceResources.getFontRegistry().addListener(listener);
   JFaceResources.getColorRegistry().addListener(listener);
   fManager.setCurrentTheme(themeId);
   ITheme theme = fManager.getTheme(themeId);
   assertEquals(theme, fManager.getCurrentTheme());
   {
     FontRegistry jfaceFonts = JFaceResources.getFontRegistry();
     FontRegistry themeFonts = theme.getFontRegistry();
     // don't test for equality - other tests (or clients) may be pushing
     // new items into jface
     assertTrue(jfaceFonts.getKeySet().containsAll(themeFonts.getKeySet()));
     for (Iterator i = themeFonts.getKeySet().iterator(); i.hasNext(); ) {
       String key = (String) i.next();
       assertArrayEquals(themeFonts.getFontData(key), jfaceFonts.getFontData(key));
     }
   }
   {
     ColorRegistry jfaceColors = JFaceResources.getColorRegistry();
     ColorRegistry themeColors = theme.getColorRegistry();
     assertTrue(jfaceColors.getKeySet().containsAll(themeColors.getKeySet()));
     for (Iterator i = themeColors.getKeySet().iterator(); i.hasNext(); ) {
       String key = (String) i.next();
       assertEquals(themeColors.getRGB(key), jfaceColors.getRGB(key));
     }
   }
   JFaceResources.getFontRegistry().removeListener(listener);
   JFaceResources.getColorRegistry().removeListener(listener);
 }
  /**
   * 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);
      }
    }
  }
  /**
   * 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));
     */
  }
 /**
  * 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.º 6
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.º 7
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);
  }
  /**
   * 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;
  }
  /** @see org.eclipse.jface.viewers.ColumnLabelProvider#getFont(java.lang.Object) */
  @Override
  public Font getFont(final Object element) {
    if (element.equals(m_targetScenario))
      return JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT);

    return null;
  }
Exemplo n.º 10
0
  public void createPartControl(Composite parent) {
    Composite top = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    top.setLayout(layout);
    // top banner
    Composite banner = new Composite(top, SWT.NONE);
    banner.setLayoutData(
        new GridData(
            GridData.HORIZONTAL_ALIGN_FILL, GridData.VERTICAL_ALIGN_BEGINNING, true, false));
    layout = new GridLayout();
    layout.marginHeight = 5;
    layout.marginWidth = 10;
    layout.numColumns = 2;
    banner.setLayout(layout);

    // setup bold font
    Font boldFont = JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT);

    Label l = new Label(banner, SWT.WRAP);
    l.setText("Subject:");
    l.setFont(boldFont);
    l = new Label(banner, SWT.WRAP);
    l.setText("This is a message about the cool Eclipse RCP!");

    l = new Label(banner, SWT.WRAP);
    l.setText("From:");
    l.setFont(boldFont);

    final Link link = new Link(banner, SWT.NONE);
    link.setText("<a>[email protected]</a>");
    link.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            MessageDialog.openInformation(
                getSite().getShell(),
                "Not Implemented",
                "Imagine the address book or a new message being created now.");
          }
        });

    l = new Label(banner, SWT.WRAP);
    l.setText("Date:");
    l.setFont(boldFont);
    l = new Label(banner, SWT.WRAP);
    l.setText("10:34 am");
    // message contents
    Text text = new Text(top, SWT.MULTI | SWT.WRAP);
    text.setText(
        "This RCP Application was generated from the PDE Plug-in Project wizard. This sample shows how to:\n"
            + "- add a top-level menu and toolbar with actions\n"
            + "- add keybindings to actions\n"
            + "- create views that can't be closed and\n"
            + "  multiple instances of the same view\n"
            + "- perspectives with placeholders for new views\n"
            + "- use the default about dialog\n"
            + "- create a product definition\n");
    text.setLayoutData(new GridData(GridData.FILL_BOTH));
  }
Exemplo n.º 11
0
  /**
   * Return a bold font if the given element matches the given pattern. Clients can opt to call this
   * method from a Viewer's label provider to get a bold font for which to highlight the given
   * element in the tree.
   *
   * @param element element for which a match should be determined
   * @param tree FilteredTree in which the element resides
   * @param filter PatternFilter which determines a match
   * @return bold font
   */
  public static Font getBoldFont(
      Object element, FilteredTable tree, NQueryTablePatternFilter filter) {
    String filterText = tree.getFilterString();

    if (filterText == null) {
      return null;
    }

    // Do nothing if it's empty string
    String initialText = tree.getInitialText();
    if (!("".equals(filterText) || initialText.equals(filterText))) { // $NON-NLS-1$
      boolean initial = initialText != null && initialText.equals(filterText);
      if (initial) {
        filter.setPattern(null);
      } else if (filterText != null) {
        filter.setPattern(filterText);
      }

      if (filter.isElementVisible(tree.getViewer(), element)
          && filter.isLeafMatch(tree.getViewer(), element)) {
        return JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT);
      }
    }
    return null;
  }
Exemplo n.º 12
0
 @Override
 public Font getFont(Object element) {
   if (isDefaultTask((TodoTask) element)) {
     return JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT);
   }
   return null;
 }
Exemplo n.º 13
0
  public RElementInfoControl(final Shell shell, final String message) {
    super(shell, message);
    fMode = MODE_SIMPLE;

    JFaceResources.getFontRegistry().addListener(this);
    create();
  }
Exemplo n.º 14
0
  @Override
  public void dispose() {
    if (copyAction != null) {
      copyAction.dispose();
      copyAction = null;
    }

    if (clipboard != null) {
      clipboard.dispose();
      clipboard = null;
    }

    if (goToMarkerAction != null) {
      goToMarkerAction.dispose();
      goToMarkerAction = null;
    }

    if (fontPropertyChangeListener != null) {
      JFaceResources.getFontRegistry().removeListener(fontPropertyChangeListener);
      fontPropertyChangeListener = null;
    }

    MarkersChangeService.getService().removeListener(this);

    super.dispose();
  }
Exemplo n.º 15
0
 /**
  * Return a FontAwesome font for SWT.
  *
  * @param size
  * @return
  */
 public static Font getFont(int size) {
   String name = FONTAWESOME + size;
   if (!JFaceResources.getFontRegistry().hasValueFor(name)) {
     // GetFont() may return null, so handle this case.
     Font font = getFont();
     if (font == null) {
       return null;
     }
     FontData[] data = font.getFontData();
     for (FontData d : data) {
       d.setHeight(size);
     }
     JFaceResources.getFontRegistry().put(name, data);
   }
   return JFaceResources.getFontRegistry().get(name);
 }
  @Override
  protected Control createContents(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    GridLayoutFactory.fillDefaults().applyTo(container);

    if (studyParameters.getCustomizingPlugin() != null) {
      Label label = new Label(parent, SWT.NULL);
      label.setText(studyParameters.getCustomizedByMessage());
      label.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT));

      if (studyParameters.getMoreInformationUrl() != null) {
        ImageHyperlink link = new ImageHyperlink(parent, SWT.NONE);
        link.setText(Messages.UsageDataPreferencePage_Learn_More);
        link.setForeground(CommonColors.HYPERLINK_WIDGET);
        link.addHyperlinkListener(
            new HyperlinkAdapter() {
              @Override
              public void linkActivated(HyperlinkEvent e) {
                openMoreInformaionInBrowser();
              }
            });
      }
    }

    createLogFileSection(container);
    createUsageSection(container);
    updateEnablement();

    Dialog.applyDialogFont(container);
    return container;
  }
Exemplo n.º 17
0
  public RElementInfoControl(final Shell shell, final int mode) {
    super(shell, ""); // $NON-NLS-1$
    assert ((mode & MODE_FOCUS) == 0);
    this.mode = mode;

    JFaceResources.getFontRegistry().addListener(this);
    create();
  }
Exemplo n.º 18
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);
 }
Exemplo n.º 19
0
                @Override
                public void getCellData(Object element, Object[] data) {
                  Long amount = (Long) getCellValue(element);

                  data[FONT] = JFaceResources.getFontRegistry().getBold("");
                  data[TEXT] = Long.toString(amount);
                  if (amount > 0) data[FOREGROUND] = Colors.getColor(DARK_GREEN);
                  else if (amount < 0) data[FOREGROUND] = Colors.getColor(DARK_RED);
                  else data[FOREGROUND] = null;
                }
Exemplo n.º 20
0
  /**
   * Creates an Erlang source preview updater for the given viewer, configuration and preference
   * store.
   *
   * @param viewer the viewer
   * @param configuration the configuration
   * @param preferenceStore the preference store
   */
  public ErlangSourceViewerUpdater(
      final ISourceViewer viewer,
      final ErlangSourceViewerConfiguration configuration,
      final IPreferenceStore preferenceStore) {
    Assert.isNotNull(viewer);
    Assert.isNotNull(configuration);
    Assert.isNotNull(preferenceStore);
    final IPropertyChangeListener fontChangeListener =
        new IPropertyChangeListener() {

          /*
           * @see
           * org.eclipse.jface.util.IPropertyChangeListener#propertyChange
           * (org.eclipse.jface.util.PropertyChangeEvent)
           */
          public void propertyChange(final PropertyChangeEvent event) {
            if (PreferenceConstants.EDITOR_TEXT_FONT.equals(event.getProperty())) {
              final Font font = JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
              viewer.getTextWidget().setFont(font);
            }
          }
        };
    final IPropertyChangeListener propertyChangeListener =
        new IPropertyChangeListener() {

          /*
           * @see
           * org.eclipse.jface.util.IPropertyChangeListener#propertyChange
           * (org.eclipse.jface.util.PropertyChangeEvent)
           */
          public void propertyChange(final PropertyChangeEvent event) {
            // if (configuration.affectsTextPresentation(event)) {
            // configuration.handlePropertyChangeEvent(event);
            // viewer.invalidateTextPresentation();
            // }
          }
        };
    viewer
        .getTextWidget()
        .addDisposeListener(
            new DisposeListener() {

              /*
               * @see
               * org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse
               * .swt.events.DisposeEvent)
               */
              public void widgetDisposed(final DisposeEvent e) {
                preferenceStore.removePropertyChangeListener(propertyChangeListener);
                JFaceResources.getFontRegistry().removeListener(fontChangeListener);
              }
            });
    JFaceResources.getFontRegistry().addListener(fontChangeListener);
    preferenceStore.addPropertyChangeListener(propertyChangeListener);
  }
Exemplo n.º 21
0
  private void initialize() {
    setRequestFocusEnabled(true);
    setFocusTraversable(true);

    if (uncheckedImage != null) {
      org.eclipse.swt.graphics.Rectangle r = uncheckedImage.getBounds();
      setBounds(new Rectangle(0, 0, r.width, r.height));
      prefSize = new Dimension(r.width, r.height);
    } else {
      setForegroundColor(ColorConstants.black);
      setBackgroundColor(ColorConstants.white);
      calculatePreferredSize();
      setBounds(new Rectangle(0, 0, prefSize.width, prefSize.height));
    }
    setCursor(Cursors.ARROW);
    setBorder(null);
    setFont(JFaceResources.getFontRegistry().get(JFaceResources.DEFAULT_FONT));

    addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            setState(!state);
          }
        });
    this.addMouseMotionListener(
        new MouseMotionListener() {

          public void mouseDragged(MouseEvent me) {
            // TODO Auto-generated method stub

          }

          public void mouseEntered(MouseEvent me) {
            hilite = true;
            repaint();
          }

          public void mouseExited(MouseEvent me) {
            hilite = false;
            repaint();
          }

          public void mouseHover(MouseEvent me) {
            // TODO Auto-generated method stub

          }

          public void mouseMoved(MouseEvent me) {
            // TODO Auto-generated method stub

          }
        });
  }
Exemplo n.º 22
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;
 }
 /**
  * Computes the size of the color image displayed on the button.
  *
  * <p>This is an internal method and should not be called by clients.
  *
  * @param window the window to create a GC on for calculation.
  * @return Point The image size
  */
 protected Point computeImageSize(Control window) {
   // Make the image height as high as a corresponding character. This
   // makes sure that the button has the same size as a "normal" text
   // button.
   GC gc = new GC(window);
   Font f = JFaceResources.getFontRegistry().get(JFaceResources.DEFAULT_FONT);
   gc.setFont(f);
   int height = gc.getFontMetrics().getHeight();
   gc.dispose();
   Point p = new Point(height * 3 - 6, height);
   return p;
 }
Exemplo n.º 24
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;
   }
 }
 protected ExpandableComposite createStyleSection(Composite parent, String label, int nColumns) {
   ExpandableComposite excomposite =
       new ExpandableComposite(
           parent, SWT.NONE, ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT);
   excomposite.setText(label);
   excomposite.setExpanded(false);
   excomposite.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT));
   excomposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, nColumns, 1));
   excomposite.addExpansionListener(
       new ExpansionAdapter() {
         public void expansionStateChanged(ExpansionEvent e) {
           expandedStateChanged((ExpandableComposite) e.getSource());
         }
       });
   fExpandables.add(excomposite);
   makeScrollableCompositeAware(excomposite);
   return excomposite;
 }
Exemplo n.º 26
0
 protected VirtualSourceViewer createViewer(
     Composite parent, IVerticalRuler vertRuler, IOverviewRuler ovRuler) {
   int styles = SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION;
   VirtualSourceViewer viewer =
       new VirtualSourceViewer(parent, fVerticalRuler, fOverviewRuler, true, styles);
   viewer.getControl().setLayoutData(parent.getLayoutData());
   viewer.setEditable(false);
   viewer
       .getTextWidget()
       .setFont(JFaceResources.getFont(IInternalCDebugUIConstants.DISASSEMBLY_FONT));
   viewer.setRangeIndicator(new DefaultRangeIndicator());
   getSourceViewerDecorationSupport(viewer);
   viewer.configure(new SourceViewerConfiguration());
   JFaceResources.getFontRegistry().addListener(this);
   JFaceResources.getColorRegistry().addListener(this);
   getEditorPreferenceStore().addPropertyChangeListener(this);
   return viewer;
 }
Exemplo n.º 27
0
    public InterceptorsFigure() {
      ToolbarLayout layout = new ToolbarLayout();
      setLayoutManager(layout);
      setBorder(new LineBorder(ColorConstants.black, 1));

      /* Header Label */
      Label constantLabel = new Label("Interceptors");
      constantLabel.setLabelAlignment(PositionConstants.LEFT);
      constantLabel.setIcon(
          S2EditorUI.getImageDescriptor("icons/arraypartition_obj.gif").createImage());
      constantLabel.setBackgroundColor(new Color(null, 0xb7, 0xe4, 0xa8));
      constantLabel.setOpaque(true);
      constantLabel.setForegroundColor(ColorConstants.titleForeground);
      constantLabel.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT));
      add(constantLabel);

      bodyFigure = new BodyFigure();
      add(bodyFigure);
    }
Exemplo n.º 28
0
  /**
   * Updates the change font button and the previewer to reflect the newly selected font.
   *
   * @param font The FontData[] to update with.
   */
  private void updateFont(FontData font[]) {
    FontData[] bestFont =
        JFaceResources.getFontRegistry().filterData(font, valueControl.getDisplay());

    // if we have nothing valid do as best we can
    if (bestFont == null) {
      bestFont = getDefaultFontData();
    }

    // Now cache this value in the receiver
    this.chosenFont = bestFont;

    if (valueControl != null) {
      valueControl.setText(StringConverter.asString(chosenFont[0]));
    }
    if (previewer != null) {
      previewer.setFont(bestFont);
    }
  }
  /**
   * Installs the given font in the preference store and optionally the font registry.
   *
   * @param definition the font definition
   * @param registry the font registry
   * @param store the preference store from which to set and obtain font data
   * @param setInRegistry whether the color should be put into the registry as well as having its
   *     default preference set
   */
  private static void installFont(
      FontDefinition definition, ITheme theme, IPreferenceStore store, boolean setInRegistry) {
    FontRegistry registry = theme.getFontRegistry();

    String id = definition.getId();
    String key = createPreferenceKey(theme, id);
    FontData[] prefFont = store != null ? PreferenceConverter.getFontDataArray(store, key) : null;
    FontData[] defaultFont = null;
    if (definition.getValue() != null) {
      defaultFont = definition.getValue();
    } else if (definition.getDefaultsTo() != null) {
      defaultFont =
          registry.filterData(
              registry.getFontData(definition.getDefaultsTo()),
              Workbench.getInstance().getDisplay());
    } else {
      // values pushed in from jface property files.  Very ugly.
      Display display = Workbench.getInstance().getDisplay();

      // If in high contrast, ignore the defaults in jface and use the default (system) font.
      // This is a hack to address bug #205474. See bug #228207 for a future fix.
      FontData[] fontData =
          JFaceResources.getFontRegistry()
              .getFontData(display.getHighContrast() ? JFaceResources.DEFAULT_FONT : id);
      defaultFont = registry.bestDataArray(fontData, display);
    }

    if (setInRegistry) {
      if (prefFont == null || prefFont == PreferenceConverter.FONTDATA_ARRAY_DEFAULT_DEFAULT) {
        prefFont = defaultFont;
      }

      if (prefFont != null) {
        registry.put(id, prefFont);
      }
    }

    if (defaultFont != null && store != null) {
      PreferenceConverter.setDefault(store, key, defaultFont);
    }
  }
Exemplo n.º 30
0
  protected Composite createNoteComposite(
      Font font, Composite composite, String title, String message) {
    Composite messageComposite = new Composite(composite, SWT.NONE);
    GridLayout messageLayout = new GridLayout();
    messageLayout.numColumns = 2;
    messageLayout.marginWidth = 0;
    messageLayout.marginHeight = 0;
    messageComposite.setLayout(messageLayout);
    messageComposite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
    messageComposite.setFont(font);

    final Label noteLabel = new Label(messageComposite, SWT.BOLD);
    noteLabel.setText(title);
    noteLabel.setFont(JFaceResources.getBannerFont());
    noteLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));

    final IPropertyChangeListener fontListener =
        new IPropertyChangeListener() {

          public void propertyChange(PropertyChangeEvent event) {
            if (JFaceResources.BANNER_FONT.equals(event.getProperty())) {
              noteLabel.setFont(JFaceResources.getFont(JFaceResources.BANNER_FONT));
            }
          }
        };
    JFaceResources.getFontRegistry().addListener(fontListener);
    noteLabel.addDisposeListener(
        new DisposeListener() {

          public void widgetDisposed(DisposeEvent event) {
            JFaceResources.getFontRegistry().removeListener(fontListener);
          }
        });

    Label messageLabel = new Label(messageComposite, SWT.WRAP);
    messageLabel.setText(message);
    messageLabel.setFont(font);
    return messageComposite;
  }