예제 #1
0
  protected void initialize(String[] keywords) {
    ColorRegistry registry = JFaceResources.getColorRegistry();

    IToken keyword = new Token(new TextAttribute(registry.get(KEYWORD_COLOR), null, SWT.BOLD));
    IToken string = new Token(new TextAttribute(registry.get(STRING_COLOR)));
    IToken number = new Token(new TextAttribute(registry.get(NUMBER_COLOR)));
    IToken annotation = new Token(new TextAttribute(registry.get(ANNOTATION_COLOR)));
    IToken defaultToken = new Token(new TextAttribute(registry.get(DEFAULT_COLOR)));

    List<IRule> rules = new ArrayList<IRule>();

    // strings
    rules.add(new SingleLineRule("\"", "\"", string, '\\'));

    // annotations
    rules.add(new MultiLineRule("[", "]", annotation));

    // numbers
    rules.add(new NumberRule(number));

    // keywords and normal (default) text
    WordRule wordRule = new WordRule(new WordDetector(), defaultToken);
    for (int i = 0; i < keywords.length; i++) {
      wordRule.addWord(keywords[i], keyword);
    }
    rules.add(wordRule);

    setRules(rules.toArray(new IRule[rules.size()]));
  }
예제 #2
0
  private void updateWlanLibraryStatus() {
    if (!wlanLibrary.isReady()) {
      for (Label ssidStatus : toolbarSsidLibraryLabels) {
        ssidStatus.setText("エラー");
        ssidStatus.setForeground(colorRegistry.get(COLOR_NG));

        ssidStatus.getParent().getParent().layout();
      }
    } else if (wlanLibrary instanceof WlanProxyLibrary) {
      for (Label ssidStatus : toolbarSsidLibraryLabels) {
        ssidStatus.setText("プロキシ");
        ssidStatus.setForeground(colorRegistry.get(COLOR_NG));

        ssidStatus.getParent().getParent().layout();
      }
    } else if (wlanLibrary.isSSIDEnabled()) {
      for (Label ssidStatus : toolbarSsidLibraryLabels) {
        ssidStatus.setText("On");
        ssidStatus.setForeground(colorRegistry.get(COLOR_APP_NUMBER));

        ssidStatus.getParent().getParent().layout();
      }
    } else {
      for (Label ssidStatus : toolbarSsidLibraryLabels) {
        ssidStatus.setText("Off");
        ssidStatus.setForeground(colorRegistry.get(COLOR_OK));

        ssidStatus.getParent().getParent().layout();
      }
    }
  }
예제 #3
0
 private void refreshDiffColors() {
   ColorRegistry reg =
       PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry();
   this.addBackgroundColor = reg.get(THEME_DiffAddBackgroundColor);
   this.addForegroundColor = reg.get(THEME_DiffAddForegroundColor);
   this.removeBackgroundColor = reg.get(THEME_DiffRemoveBackgroundColor);
   this.removeForegroundColor = reg.get(THEME_DiffRemoveForegroundColor);
   this.hunkBackgroundColor = reg.get(THEME_DiffHunkBackgroundColor);
   this.hunkForegroundColor = reg.get(THEME_DiffHunkForegroundColor);
 }
 @Override
 public void applyStyles(TextStyle textStyle) {
   ColorRegistry colorRegistry = JFaceResources.getColorRegistry();
   if (fForegroundColorName != null) {
     textStyle.foreground = colorRegistry.get(fForegroundColorName);
   }
   if (fBackgroundColorName != null) {
     textStyle.background = colorRegistry.get(fBackgroundColorName);
   }
 }
예제 #5
0
 public CssBlockScanner(ColorRegistry colorRegistry) {
   setRules(
       new IRule[] {
         //
         new CommentRule(new Token(new TextAttribute(colorRegistry.get(Colors.KEY_COMMENT)))),
         new PropertyNameRule(
             new Token(new TextAttribute(colorRegistry.get(Colors.KEY_PROPERTY_NAME)))),
         new PropertyValueRule(
             new Token(new TextAttribute(colorRegistry.get(Colors.KEY_PROPERTY_VALUE)))),
         new WhitespaceRule(new CssWhitespaceDetector())
       });
 }
예제 #6
0
파일: CCWPlugin.java 프로젝트: karaatli/ccw
 /**
  * Not thread safe, but should only be called from the UI Thread, so it's not really a problem.
  *
  * @param rgb
  * @return The <code>Color</code> instance cached for this rgb value, creating it along the way if
  *     required.
  */
 public static Color getColor(RGB rgb) {
   ColorRegistry r = getDefault().getColorCache();
   String rgbString = StringConverter.asString(rgb);
   if (!r.hasValueFor(rgbString)) {
     r.put(rgbString, rgb);
   }
   return r.get(rgbString);
 }
예제 #7
0
  /*
   * I do not know where to put this static method. It is used by all ProfFields
   */
  public static Color getBackground(Object element) {
    ColorRegistry colorRegistry = JFaceResources.getColorRegistry();

    // FIXME: Not sure if color1-color4 are ever used...picked colors found in JFacesResources
    // ColorRegistry
    // not tied to any particular language (e.g. didn't choose CDT or Java colors)
    // Color5 seems to work ok as bg in the one dark theme I tried (Nissl-Adwaita-dark-4) and as
    // well
    // in default light adwaita, but it is much simpler to just return null and let the table color
    // default
    // appropriately.
    Color color1 = colorRegistry.get("org.eclipse.ui.editors.currentLineColor"); // $NON-NLS-1$
    Color color2 =
        colorRegistry.get("org.eclipse.ui.workbench.INACTIVE_TAB_BG_START"); // $NON-NLS-1$
    Color color3 =
        colorRegistry.get("org.eclipse.ui.workbench.ACTIVE_NOFOCUS_TAB_BG_END"); // $NON-NLS-1$
    Color color4 = colorRegistry.get("org.eclipse.ui.workbench.ACTIVE_TAB_BG_END"); // $NON-NLS-1$
    //        Color color5 = colorRegistry.get("org.eclipse.ui.workbench.INACTIVE_TAB_BG_START");
    // //$NON-NLS-1$

    if (element instanceof CGCategory) {
      CGCategory cat = (CGCategory) element;
      if (CGCategory.CHILDREN.equals(cat.category)) {
        return color1 == null ? BLUE1 : color1;
      } else {
        return color2 == null ? GREEN1 : color2;
      }
    } else if (element instanceof CGArc) {
      CGArc arc = (CGArc) element;
      CGCategory cat = (CGCategory) arc.getParent();
      if (CGCategory.CHILDREN.equals(cat.category)) {
        return color3 == null ? BLUE2 : color3;
      } else {
        return color4 == null ? GREEN2 : color4;
      }
    }
    return null; // default background
    //        return color5 == null ? DEFAULT_BG : color5;
  }
예제 #8
0
 @Override
 protected void createTitle(Composite parent) {
   ColorRegistry colorRegistry = JFaceResources.getColorRegistry();
   Color background =
       colorRegistry.get("org.eclipse.ui.workbench.INACTIVE_TAB_BG_START"); // $NON-NLS-1$
   label = new Label(parent, SWT.WRAP);
   if (background != null) label.setBackground(background);
   GridData data = new GridData(SWT.FILL, SWT.BEGINNING, true, false, 1, 1);
   label.setLayoutData(data);
   fFilterText =
       new Text(parent, SWT.BORDER | SWT.SINGLE | SWT.SEARCH | SWT.ICON_SEARCH | SWT.ICON_CANCEL);
   fFilterText.setMessage(Messages.GmonView_type_filter_text);
   fFilterText.setToolTipText(Messages.GmonView_filter_by_name);
   fFilterText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
   fFilterText.addModifyListener(
       new ModifyListener() {
         @Override
         public void modifyText(ModifyEvent e) {
           String text = fFilterText.getText();
           fViewerFilter.setMatchingText(text);
         }
       });
 }
예제 #9
0
  public void createToolBar(final Composite parent, IAppWindow window) {
    GridLayout gridLayout;

    Composite container = new Composite(parent, SWT.NONE);
    gridLayout = new GridLayout(2, false);
    gridLayout.horizontalSpacing = 0;
    gridLayout.verticalSpacing = 0;
    gridLayout.marginWidth = 3;
    gridLayout.marginHeight = 1;
    container.setLayout(gridLayout);

    ToolBar toolBar = new ToolBar(container, SWT.FLAT | SWT.RIGHT);
    toolBar.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));

    IAppWindow.Type type = window.getType();
    if (type != IAppWindow.Type.ARENA) {
      ToolItem arenaWindowItem = new ToolItem(toolBar, SWT.PUSH);
      arenaWindowItem.setText("アリーナ");
      arenaWindowItem.setToolTipText("部屋の検索やロビーのチャット");
      arenaWindowItem.setImage(imageRegistry.get(ICON_TOOLBAR_ARENA));
      arenaWindowItem.addListener(
          SWT.Selection,
          new Listener() {
            @Override
            public void handleEvent(Event event) {
              arenaWindow.show();
            }
          });
    }
    if (type != IAppWindow.Type.ROOM) {
      ToolItem roomWindowItem = new ToolItem(toolBar, SWT.PUSH);
      roomWindowItem.setText("ルーム");
      roomWindowItem.setToolTipText("ルーム内で通信プレイができます");
      roomWindowItem.setImage(imageRegistry.get(ICON_TOOLBAR_ROOM));
      roomWindowItem.addListener(
          SWT.Selection,
          new Listener() {
            @Override
            public void handleEvent(Event event) {
              getRoomWindow().show();
            }
          });
    }

    ToolItem configWindowItem = new ToolItem(toolBar, SWT.PUSH);
    configWindowItem.setText("設定");
    configWindowItem.setToolTipText("アプリケーションの設定をします");
    configWindowItem.setImage(imageRegistry.get(ICON_TOOLBAR_CONFIG));
    configWindowItem.addListener(
        SWT.Selection,
        new Listener() {
          @Override
          public void handleEvent(Event event) {
            if (openConfigDialog(parent.getShell(), null)) {
              if (arenaWindow != null) arenaWindow.settingChanged();
              if (roomWindow != null) roomWindow.settingChanged();
            }
          }
        });

    ToolItem wikiItem = new ToolItem(toolBar, SWT.PUSH);
    wikiItem.setText("Wiki");
    wikiItem.setToolTipText(AppConstants.APP_NAME + "のWikiページを表示します");
    wikiItem.setImage(imageRegistry.get(ICON_TOOLBAR_WIKI));
    wikiItem.addListener(
        SWT.Selection,
        new Listener() {
          @Override
          public void handleEvent(Event event) {
            Program.launch("http://wiki.team-monketsu.net/");
          }
        });

    ToolItem exitItem = new ToolItem(toolBar, SWT.PUSH);
    exitItem.setText("終了");
    exitItem.setToolTipText(AppConstants.APP_NAME + "を終了します");
    exitItem.setImage(imageRegistry.get(ICON_TOOLBAR_EXIT));
    exitItem.addListener(
        SWT.Selection,
        new Listener() {
          @Override
          public void handleEvent(Event event) {
            if (openShutdownConfirmDialog(parent.getShell())) {
              isRunning = false;
            }
          }
        });

    Composite appVersionContainer = new Composite(container, SWT.NONE);
    appVersionContainer.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false));
    RowLayout rowLayout = new RowLayout();
    rowLayout.center = true;
    rowLayout.marginTop = 0;
    rowLayout.marginBottom = 0;
    rowLayout.marginLeft = 0;
    rowLayout.marginRight = 0;
    appVersionContainer.setLayout(rowLayout);

    Label statusApplicationVersionLabel = new Label(appVersionContainer, SWT.NONE);
    statusApplicationVersionLabel.setText("バージョン:");
    initControl(statusApplicationVersionLabel);

    Label statusApplicationVersionNumber = new Label(appVersionContainer, SWT.NONE);
    statusApplicationVersionNumber.setText(AppConstants.VERSION);
    statusApplicationVersionNumber.setForeground(colorRegistry.get(COLOR_APP_NUMBER));
    initControl(statusApplicationVersionNumber);

    Label statusApplicationProtocolLabel = new Label(appVersionContainer, SWT.NONE);
    statusApplicationProtocolLabel.setText("プロトコル:");
    initControl(statusApplicationProtocolLabel);

    Label statusApplicationProtocolNumber = new Label(appVersionContainer, SWT.NONE);
    statusApplicationProtocolNumber.setText(IProtocol.NUMBER);
    statusApplicationProtocolNumber.setForeground(colorRegistry.get(COLOR_APP_NUMBER));
    initControl(statusApplicationProtocolNumber);

    Label statusApplicationSsidLabel = new Label(appVersionContainer, SWT.NONE);
    statusApplicationSsidLabel.setText("SSID機能:");
    initControl(statusApplicationSsidLabel);

    Label statusApplicationSsidLibrary = new Label(appVersionContainer, SWT.NONE);
    toolbarSsidLibraryLabels.add(statusApplicationSsidLibrary);
    initControl(statusApplicationSsidLibrary);

    updateWlanLibraryStatus();
  }
 public Color getColorForName(String symbolicName) {
   return fColorRegisty.get(symbolicName);
 }
예제 #11
0
  public void createPartControl(Composite parent) {
    SashForm sash = new SashForm(parent, SWT.VERTICAL | SWT.SMOOTH);

    queryViewer = new SourceViewer(sash, null, SWT.MULTI | SWT.WRAP);
    queryString = queryViewer.getTextWidget();
    queryString.setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT));
    Color background = queryString.getBackground();
    IThemeManager themeManager = PlatformUI.getWorkbench().getThemeManager();
    ITheme current = themeManager.getCurrentTheme();
    ColorRegistry colorRegistry = current.getColorRegistry();
    commentCol = colorRegistry.get(ColorProvider.COMMENT_COLOR_PREF);
    keywordCol = colorRegistry.get(ColorProvider.KEYWORD_COLOR_PREF);
    IDocument d = createDocument();
    d.set(Messages.OQLPane_F1ForHelp);

    queryViewer.addSelectionChangedListener(
        new ISelectionChangedListener() {
          public void selectionChanged(SelectionChangedEvent event) {
            updateActions();
          }
        });

    queryViewer.setDocument(d);
    queryViewer.configure(new OQLTextViewerConfiguration(getSnapshot(), commentCol, keywordCol));
    // Eclipse 4 seems to need this otherwise in high contrast mode the background is white
    queryString.setBackground(background);
    queryString.selectAll();

    PlatformUI.getWorkbench()
        .getHelpSystem()
        .setHelp(queryString, "org.eclipse.mat.ui.help.oql"); // $NON-NLS-1$
    queryString.addKeyListener(
        new KeyAdapter() {
          public void keyPressed(KeyEvent e) {
            if (e.keyCode == '\r' && (e.stateMask & SWT.MOD1) != 0) {
              executeAction.run();
              e.doit = false;
            } else if (e.keyCode == ' ' && (e.stateMask & SWT.CTRL) != 0) {
              // ctrl space combination for content assist
              contentAssistAction.run();
            } else if (e.keyCode == SWT.F5) {
              executeAction.run();
              e.doit = false;
            }
          }
        });

    queryString.addFocusListener(
        new FocusListener() {

          public void focusGained(FocusEvent e) {
            IActionBars actionBars = getEditor().getEditorSite().getActionBars();
            actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), copyQueryStringAction);
            actionBars.updateActionBars();
          }

          public void focusLost(FocusEvent e) {}
        });
    queryString.setFocus();

    createContainer(sash);

    sash.setWeights(new int[] {1, 4});

    makeActions();
    hookContextMenu();
  }