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(); } } }
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()])); }
/** * Installs the given color in the preference store and optionally the color registry. * * @param definition the color definition * @param theme the theme defining the color * @param store the preference store from which to set and obtain color data * @param setInRegistry whether the color should be put into the registry */ private static void installColor( ColorDefinition definition, ITheme theme, IPreferenceStore store, boolean setInRegistry) { // TODO: store shouldn't be null, should assert instead of checking null all over ColorRegistry registry = theme.getColorRegistry(); String id = definition.getId(); String key = createPreferenceKey(theme, id); RGB prefColor = store != null ? PreferenceConverter.getColor(store, key) : null; RGB defaultColor = (definition.getValue() != null) ? definition.getValue() : registry.getRGB(definition.getDefaultsTo()); if (prefColor == null || prefColor == PreferenceConverter.COLOR_DEFAULT_DEFAULT) { prefColor = defaultColor; } // if the preference value isn't the default then retain that pref value RGB colorToUse = !store.isDefault(key) ? prefColor : defaultColor; if (setInRegistry) { registry.put(id, colorToUse); } if (store != null) { PreferenceConverter.setDefault(store, key, defaultColor); } }
/** * 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); }
public static void registerEditorColors(IPreferenceStore store, RGB foregroundColor) { final ColorRegistry colorCache = getDefault().getColorCache(); for (Keyword token : PreferenceConstants.colorizableTokens) { PreferenceConstants.ColorizableToken tokenStyle = PreferenceConstants.getColorizableToken(store, token, foregroundColor); colorCache.put(tokenStyle.rgb.toString(), tokenStyle.rgb); } }
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); } }
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()) }); }
@Override public void initialize(IWorkbenchConfigurer configurer) { // 윈도우 위치와 크기 저장 configurer.setSaveAndRestore(true); // 색상변경 IThemeManager themeManager = PlatformUI.getWorkbench().getThemeManager(); ITheme currentTheme = themeManager.getCurrentTheme(); ColorRegistry colorRegistry = currentTheme.getColorRegistry(); colorRegistry.put(IWorkbenchThemeConstants.ACTIVE_TAB_BG_START, new RGB(16, 86, 100)); colorRegistry.put(IWorkbenchThemeConstants.ACTIVE_TAB_BG_END, new RGB(219, 238, 241)); colorRegistry.put(IWorkbenchThemeConstants.ACTIVE_TAB_TEXT_COLOR, new RGB(0, 0, 255)); colorRegistry.put(IWorkbenchThemeConstants.ACTIVE_TAB_PERCENT, new RGB(255, 0, 0)); super.initialize(configurer); }
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); }
private void inititalizeColors() { if (getSite().getShell().isDisposed()) return; Display display = getSite().getShell().getDisplay(); if (display == null || display.isDisposed()) return; setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND)); ColorRegistry registry = JFaceResources.getColorRegistry(); registry.addListener(this); fBackgroundColorRGB = registry.getRGB(getBackgroundColorKey()); Color bgColor; if (fBackgroundColorRGB == null) { bgColor = display.getSystemColor(SWT.COLOR_INFO_BACKGROUND); fBackgroundColorRGB = bgColor.getRGB(); } else { bgColor = new Color(display, fBackgroundColorRGB); fBackgroundColor = bgColor; } setBackground(bgColor); }
public void installColoredLabels(StructuredViewer viewer) { if (fManagedViewers.containsKey(viewer)) { return; // already installed } if (fManagedViewers.isEmpty()) { // first viewer installed PreferenceConstants.getPreferenceStore().addPropertyChangeListener(this); fColorRegisty.addListener(this); } fManagedViewers.put(viewer, new ManagedViewer(viewer)); }
static { // initialize colors ColorRegistry registry = JFaceResources.getColorRegistry(); registry.put(KEYWORD_COLOR, new RGB(128, 0, 128)); registry.put(STRING_COLOR, new RGB(0, 0, 255)); registry.put(NUMBER_COLOR, new RGB(215, 107, 0)); registry.put(COMMENT_COLOR, new RGB(0, 128, 0)); registry.put(DEFAULT_COLOR, new RGB(0, 0, 0)); registry.put(ANNOTATION_COLOR, new RGB(0, 150, 150)); }
public void uninstallColoredLabels(StructuredViewer viewer) { ManagedViewer mv = fManagedViewers.remove(viewer); if (mv == null) { return; // not installed } if (fManagedViewers.isEmpty()) { PreferenceConstants.getPreferenceStore().removePropertyChangeListener(this); fColorRegisty.removeListener(this); // last viewer uninstalled } }
/* * 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; }
@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); } }); }
public Color getColorForName(String symbolicName) { return fColorRegisty.get(symbolicName); }
private synchronized void createColorCache() { if (colorCache == null) { colorCache = new ColorRegistry(getWorkbench().getDisplay()); colorCache.put("ccw.repl.expressionBackground", new RGB(0xf0, 0xf0, 0xf0)); } }
public PlayClient() throws IOException { iniSettingFile = new IniFile(INI_SETTING_FILE_NAME); iniAppDataFile = new IniFile(INI_APPDATA_FILE_NAME); iniSettings = new IniSettings(iniSettingFile.getSection(IniSettings.SECTION), new WlanProxyLibrary(this)); iniUserProfile = new IniUserProfile(iniSettingFile.getSection(IniUserProfile.SECTION)); iniAppearance = new IniAppearance(iniSettingFile.getSection(IniAppearance.SECTION)); iniAppData = new IniAppData(iniAppDataFile.getSection(null)); ArrayList<String> pendingLogs = new ArrayList<String>(); if (JnetPcapWlanDevice.LIBRARY.isReady()) { pendingLogs.add("PcapインストールOK"); } else { pendingLogs.add("Pcapがインストールされていません"); } if (NativeWlanDevice.LIBRARY.isReady()) { pendingLogs.add("Windowsワイヤレスネットワーク機能OK"); } else { pendingLogs.add("Windowsワイヤレスネットワーク機能がインストールされていません"); } wlanLibrary = iniSettings.getWlanLibrary(); ILogger logger = new ILogger() { @Override public void log(String message) { getArenaWindow().appendToSystemLog(message, true); } }; tcpClient = new AsyncTcpClient(logger, 1000000, 0); udpClient = new AsyncUdpClient(logger); imageRegistry = new ImageRegistry(SwtUtils.DISPLAY); colorRegistry = new ColorRegistry(SwtUtils.DISPLAY); clipboard = new Clipboard(SwtUtils.DISPLAY); try { Image icon16 = new Image(SwtUtils.DISPLAY, new ImageData("icon/blue16.png")); Image icon32 = new Image(SwtUtils.DISPLAY, new ImageData("icon/blue32.png")); Image icon48 = new Image(SwtUtils.DISPLAY, new ImageData("icon/blue48.png")); Image icon96 = new Image(SwtUtils.DISPLAY, new ImageData("icon/blue96.png")); imageRegistry.put(ICON_APP16, icon16); imageRegistry.put(ICON_APP32, icon32); imageRegistry.put(ICON_APP48, icon48); imageRegistry.put(ICON_APP96, icon96); shellImages = new Image[] {icon16, icon32, icon48, icon96}; Image toolArena = new Image(SwtUtils.DISPLAY, new ImageData("icon/toolbar/search.png")); Image toolRoom = new Image(SwtUtils.DISPLAY, new ImageData("icon/toolbar/lobby4.png")); Image toolConfig = new Image(SwtUtils.DISPLAY, new ImageData("icon/toolbar/config.png")); Image toolLog = new Image(SwtUtils.DISPLAY, new ImageData("icon/toolbar/log.png")); Image toolWiki = new Image(SwtUtils.DISPLAY, new ImageData("icon/toolbar/wiki.png")); Image toolExit = new Image(SwtUtils.DISPLAY, new ImageData("icon/toolbar/lobby3.png")); imageRegistry.put(ICON_TOOLBAR_ARENA, toolArena); imageRegistry.put(ICON_TOOLBAR_ROOM, toolRoom); imageRegistry.put(ICON_TOOLBAR_LOG, toolLog); imageRegistry.put(ICON_TOOLBAR_WIKI, toolWiki); imageRegistry.put(ICON_TOOLBAR_CONFIG, toolConfig); imageRegistry.put(ICON_TOOLBAR_EXIT, toolExit); Image tabLobby = new Image(SwtUtils.DISPLAY, new ImageData("icon/tab/lobby.png")); Image tabLobbyNotify = new Image(SwtUtils.DISPLAY, new ImageData("icon/tab/lobby2.png")); Image tabSystem = new Image(SwtUtils.DISPLAY, new ImageData("icon/tab/log.png")); Image tabSystemNotify = new Image(SwtUtils.DISPLAY, new ImageData("icon/tab/log2.png")); Image tabPm = new Image(SwtUtils.DISPLAY, new ImageData("icon/tab/pm.png")); Image tabPmNotify = new Image(SwtUtils.DISPLAY, new ImageData("icon/tab/pm2.png")); Image tabCircle = new Image(SwtUtils.DISPLAY, new ImageData("icon/tab/circle.png")); Image tabCircleNotify = new Image(SwtUtils.DISPLAY, new ImageData("icon/tab/circle2.png")); imageRegistry.put(ICON_TAB_LOBBY, tabLobby); imageRegistry.put(ICON_TAB_LOBBY_NOTIFY, tabLobbyNotify); imageRegistry.put(ICON_TAB_LOG, tabSystem); imageRegistry.put(ICON_TAB_LOG_NOTIFY, tabSystemNotify); imageRegistry.put(ICON_TAB_PM, tabPm); imageRegistry.put(ICON_TAB_PM_NOTIFY, tabPmNotify); imageRegistry.put(ICON_TAB_CIRCLE, tabCircle); imageRegistry.put(ICON_TAB_CIRCLE_NOTIFY, tabCircleNotify); } catch (SWTException e) { } colorRegistry.put(COLOR_OK, new RGB(0, 140, 0)); colorRegistry.put(COLOR_NG, new RGB(200, 0, 0)); colorRegistry.put(COLOR_APP_NUMBER, new RGB(0, 0, 220)); colorRegistry.put(COLOR_TAB_NOTIFY, new RGB(0, 0, 220)); arenaWindow = new ArenaWindow(this); try { Tray systemTray = SwtUtils.DISPLAY.getSystemTray(); if (systemTray != null) { trayItem = new TrayItem(systemTray, SWT.NONE); trayItem.setImage(imageRegistry.get(ICON_APP16)); trayItem.addListener( SWT.Selection, new Listener() { @Override public void handleEvent(Event event) { arenaWindow.show(); if (roomWindow != null) roomWindow.show(); } }); toolTip = new ToolTip(arenaWindow.getShell(), SWT.BALLOON | SWT.ICON_INFORMATION); trayItem.setToolTip(toolTip); trayItem.setToolTipText(AppConstants.APP_NAME); final Menu menu = new Menu(arenaWindow.getShell()); MenuItem itemArena = new MenuItem(menu, SWT.PUSH); itemArena.setText("アリーナ"); itemArena.addListener( SWT.Selection, new Listener() { @Override public void handleEvent(Event event) { getArenaWindow().show(); } }); MenuItem itemRoom = new MenuItem(menu, SWT.PUSH); itemRoom.setText("ルーム"); itemRoom.addListener( SWT.Selection, new Listener() { @Override public void handleEvent(Event event) { getRoomWindow().show(); } }); MenuItem itemShutdown = new MenuItem(menu, SWT.PUSH); itemShutdown.setText("アプリを終了"); itemShutdown.addListener( SWT.Selection, new Listener() { @Override public void handleEvent(Event event) { isRunning = false; } }); trayItem.addMenuDetectListener( new MenuDetectListener() { @Override public void menuDetected(MenuDetectEvent e) { menu.setVisible(true); } }); } } catch (SWTException e) { } try { serverRegistry = new IniPublicServerRegistry(); } catch (IOException e) { serverRegistry = IServerRegistry.NULL; arenaWindow.appendToSystemLog(Utility.stackTraceToString(e), true); } portalServerList = serverRegistry.getPortalRotator(); String software = String.format("%s プレイクライアント バージョン: %s", AppConstants.APP_NAME, AppConstants.VERSION); arenaWindow.appendToSystemLog(software, false); arenaWindow.appendToSystemLog("プロトコル: " + IProtocol.NUMBER, false); for (String log : pendingLogs) { arenaWindow.appendToSystemLog(log, false); } Thread cronThread = new Thread( new Runnable() { @Override public void run() { try { while (!SwtUtils.DISPLAY.isDisposed()) { arenaWindow.cronJob(); if (roomWindow != null) roomWindow.cronJob(); Thread.sleep(1000); } } catch (InterruptedException e) { } catch (SWTException e) { } } }, "CronThread"); cronThread.setDaemon(true); cronThread.start(); try { IPlugin plugin = (IPlugin) Class.forName(BouyomiChanPlugin.class.getName()).newInstance(); plugin.initPlugin(this); pluginList.add(plugin); } catch (InstantiationException e) { } catch (IllegalAccessException e) { } catch (ClassNotFoundException e) { } arenaWindow .getShell() .addShellListener( new ShellListener() { @Override public void shellActivated(ShellEvent e) {} @Override public void shellIconified(ShellEvent e) {} @Override public void shellDeiconified(ShellEvent e) {} @Override public void shellDeactivated(ShellEvent e) {} @Override public void shellClosed(ShellEvent e) { if (roomWindow == null || !roomWindow.getShell().getVisible()) { checkApplicationShutdown(arenaWindow.getShell(), e); } else { e.doit = false; arenaWindow.hide(); } } }); if (Utility.isEmpty(iniUserProfile.getUserName())) { TextDialog dialog = new TextDialog( null, AppConstants.APP_NAME + " - ユーザー名が設定されていません", "ユーザー名を入力してください", null, 300, SWT.NONE); switch (dialog.open()) { case IDialogConstants.OK_ID: iniUserProfile.setUserName(dialog.getUserInput()); break; default: iniUserProfile.setUserName("未設定"); } } if (iniSettings.isStartupWindowArena()) { arenaWindow.show(); } else { getRoomWindow().show(); } }
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 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(); }