private void styleViewer() {
    IPreferenceStore store = EditorsUI.getPreferenceStore();
    Color foreground = null;
    if (!store.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT))
      foreground = getEditorColor(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND);

    Color background = null;
    if (!store.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT))
      background = getEditorColor(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND);

    Color selectionForeground = null;
    if (!store.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND_SYSTEM_DEFAULT))
      selectionForeground =
          getEditorColor(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND);

    Color selectionBackground = null;
    if (!store.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND_SYSTEM_DEFAULT))
      selectionBackground =
          getEditorColor(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND);

    StyledText text = getTextWidget();
    text.setForeground(foreground);
    text.setBackground(background);
    text.setSelectionForeground(selectionForeground);
    text.setSelectionBackground(selectionBackground);
    text.setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT));
    if (lineNumberRuler != null) {
      lineNumberRuler.setFont(text.getFont());
      lineNumberRuler.setForeground(foreground);
      lineNumberRuler.setBackground(background);
    }
  }
 /** Sets the font related data to be applied to the text in page 2. */
 void setFont() {
   FontDialog fontDialog = new FontDialog(getSite().getShell());
   fontDialog.setFontList(text.getFont().getFontData());
   FontData fontData = fontDialog.open();
   if (fontData != null) {
     if (font != null) font.dispose();
     font = new Font(text.getDisplay(), fontData);
     text.setFont(font);
   }
 }
 @Inject
 void trackFontSize(
     @Preference(
             nodePath = RelationsConstants.PREFERENCE_NODE,
             value = RelationsConstants.KEY_TEXT_FONT_SIZE)
         final int inFontSize) {
   if (textWidget == null || textWidget.isDisposed()) {
     fontSizeToUse = inFontSize;
   } else {
     final FontData lData = textWidget.getFont().getFontData()[0];
     if (inFontSize != lData.getHeight()) {
       lData.setHeight(inFontSize);
       final Font lNewFont = new Font(Display.getCurrent(), lData);
       textWidget.setFont(lNewFont);
     }
   }
 }
Beispiel #4
0
  public CommandLineUIFactory(StyledText parentText) {
    parent = parentText;

    StyledText widget = new StyledText(parent, SWT.ON_TOP);
    widget.setFont(parent.getFont());
    widget.setMargins(COMMAND_CHAR_INDENT, 3, 3, 3);
    widget.setSize(5, 5);
    widget.setBackground(parent.getBackground());
    widget.setForeground(parent.getForeground());
    widget.setWordWrap(true);
    widget.setEnabled(true);
    //        widget.setCaretOffset(2);
    widget.moveAbove(parent);
    widget.setVisible(false);
    widget.addPaintListener(new BorderPaintListener());
    commandLineText = widget;

    parent.addPaintListener(new TextEditorPaintListener());
    parent.addFocusListener(
        new FocusAdapter() {
          @Override
          public void focusGained(FocusEvent e) {
            if (commandLineUI != null && commandLineUI.isOpen()) {
              commandLineText.forceFocus();
            }
          }
        });
    parent.addDisposeListener(
        new DisposeListener() {
          @Override
          public void widgetDisposed(DisposeEvent e) {
            commandLineText.dispose();
            if (commandLineUI != null) {
              commandLineUI.dispose();
            }
          }
        });
  }
 /**
  * Returns the current font of the ascii text.
  *
  * @return the current font
  * @see #setAsciiFont(Font)
  */
 public Font getAsciiFont() {
   return asciiText.getFont();
 }
 /**
  * Returns the current font of the braille text.
  *
  * @return the current font
  * @see #setBrailleFont(Font)
  */
 public Font getBrailleFont() {
   return brailleText.getFont();
 }