protected void createToolBarActions(IManagedForm managedForm) { final ScrolledForm form = managedForm.getForm(); Action haction = new Action("hor", IAction.AS_RADIO_BUTTON) { // $NON-NLS-1$ public void run() { sashForm.setOrientation(SWT.HORIZONTAL); form.reflow(true); } }; haction.setChecked(true); haction.setToolTipText(PDEUIMessages.DetailsBlock_horizontal); haction.setImageDescriptor(PDEPluginImages.DESC_HORIZONTAL); haction.setDisabledImageDescriptor(PDEPluginImages.DESC_HORIZONTAL_DISABLED); Action vaction = new Action("ver", IAction.AS_RADIO_BUTTON) { // $NON-NLS-1$ public void run() { sashForm.setOrientation(SWT.VERTICAL); form.reflow(true); } }; vaction.setChecked(false); vaction.setToolTipText(PDEUIMessages.DetailsBlock_vertical); vaction.setImageDescriptor(PDEPluginImages.DESC_VERTICAL); vaction.setDisabledImageDescriptor(PDEPluginImages.DESC_VERTICAL_DISABLED); form.getToolBarManager().add(haction); form.getToolBarManager().add(vaction); }
/** Create the actions for navigation. */ private void createActions() { // Only do this once. if (homeAction != null) { return; } // Home. homeAction = new Action(Messages.GoHome_text) { public void run() { goHome(); } }; homeAction.setToolTipText(Messages.GoHome_toolTip); homeAction.setImageDescriptor( ImageDescriptor.createFromImage(pool.getImageUnchecked(SharedImageKeys.IMG_TOOL_HOME_NAV))); // Back. backAction = new Action(Messages.GoBack_text) { public void run() { goBack(); } }; backAction.setToolTipText(Messages.GoBack_toolTip); backAction.setImageDescriptor( ImageDescriptor.createFromImage(pool.getImageUnchecked(SharedImageKeys.IMG_TOOL_BACK))); backAction.setDisabledImageDescriptor( ImageDescriptor.createFromImage( pool.getImageUnchecked(SharedImageKeys.IMG_TOOL_BACK_DISABLED))); // Forward. forwardAction = new Action(Messages.GoInto_text) { public void run() { goInto(); } }; forwardAction.setToolTipText(Messages.GoInto_toolTip); forwardAction.setImageDescriptor( ImageDescriptor.createFromImage(pool.getImageUnchecked(SharedImageKeys.IMG_TOOL_FORWARD))); forwardAction.setDisabledImageDescriptor( ImageDescriptor.createFromImage( pool.getImageUnchecked(SharedImageKeys.IMG_TOOL_FORWARD_DISABLED))); // Update the buttons when a selection change occurs. fChildTree.addSelectionChangedListener(this); updateNavigationButtons(); }
@Override protected void configureAction(Action action) { action.setText(Messages.HideReturnTypesAction_title); action.setToolTipText(Messages.HideReturnTypesAction_tooltip); action.setDescription(Messages.HideReturnTypesAction_description); action.setImageDescriptor(Activator.getImageDescriptor("icons/filter_rule.gif")); action.setDisabledImageDescriptor(Activator.getImageDescriptor("icons/filter_rule.gif")); }
@Override protected void configureAction(Action action) { action.setText(Messages.FilterTerminalRulesContribution_title); action.setDescription(Messages.FilterTerminalRulesContribution_description); action.setToolTipText(Messages.FilterTerminalRulesContribution_tooltip); action.setImageDescriptor(Activator.getImageDescriptor("icons/filter_rule.gif")); action.setDisabledImageDescriptor(Activator.getImageDescriptor("icons/filter_rule.gif")); }
protected void makeActions(final IWorkbenchWindow window) { // Creates the actions and registers them. // Registering is needed to ensure that key bindings work. // The corresponding commands keybindings are defined in the plugin.xml // file. // Registering also provides automatic disposal of the actions when // the window is closed. this.window = window; exitAction = ActionFactory.QUIT.create(window); register(exitAction); { closeAction = ActionFactory.CLOSE.create(window); register(closeAction); } { closeAllAction = ActionFactory.CLOSE_ALL.create(window); register(closeAllAction); } { saveAction = ActionFactory.SAVE.create(window); register(saveAction); } { saveAsAction = ActionFactory.SAVE_AS.create(window); register(saveAsAction); } { saveAllAction = ActionFactory.SAVE_ALL.create(window); register(saveAllAction); } sizeAction1 = new Action("176x208") { public void run() { Settings.setScreenSize(176, 208); } }; sizeAction2 = new Action("240x320") { public void run() { Settings.setScreenSize(240, 320); } }; sizeAction3 = new Action("320x240") { public void run() { Settings.setScreenSize(320, 240); } }; sizeAction4 = new Action("480x320") { public void run() { Settings.setScreenSize(480, 320); } }; sizeAction5 = new Action("640x360") { public void run() { Settings.setScreenSize(640, 360); } }; sizeAction6 = new Action("960x640") { public void run() { Settings.setScreenSize(960, 640); } }; undoAction = new Action("&Undo") { public void run() { this.firePropertyChange("chosen", this, this); } }; undoAction.setEnabled(false); undoAction.setImageDescriptor( ResourceManager.getPluginImageDescriptor( WorkshopPlugin.getDefault(), "icons/undo_edit(1).gif")); undoAction.setDisabledImageDescriptor( ResourceManager.getPluginImageDescriptor( WorkshopPlugin.getDefault(), "icons/undo_edit.gif")); undoAction.setAccelerator(SWT.CTRL | 'z'); redoAction = new Action("&Redo") { public void run() { this.firePropertyChange("chosen", this, this); } }; redoAction.setEnabled(false); redoAction.setImageDescriptor( ResourceManager.getPluginImageDescriptor( WorkshopPlugin.getDefault(), "icons/redo_edit(1).gif")); redoAction.setDisabledImageDescriptor( ResourceManager.getPluginImageDescriptor( WorkshopPlugin.getDefault(), "icons/redo_edit.gif")); redoAction.setAccelerator(SWT.CTRL | 'y'); { newWizardDropDownAction = ActionFactory.NEW_WIZARD_DROP_DOWN.create(window); register(newWizardDropDownAction); } chooseImageEditorAction = new Action("工具设置...") { public void run() { onChooseImageEditor(); } }; viewDirectoryAction = new Action("Resource Explorer") { public void run() { try { window.getActivePage().showView(DirectoryView.ID); } catch (Exception e) { } } }; viewDirectoryAction.setImageDescriptor( ResourceManager.getPluginImageDescriptor(WorkshopPlugin.getDefault(), "icons/items.gif")); viewTileLibraryAction = new Action("Tile Library") { public void run() { try { window.getActivePage().showView(TileLibView.ID); } catch (Exception e) { e.printStackTrace(); } } }; viewTileLibraryAction.setImageDescriptor( ResourceManager.getPluginImageDescriptor(WorkshopPlugin.getDefault(), "icons/tilelib.gif")); viewTileViewAction = new Action("Tile Viewer") { public void run() { try { window.getActivePage().showView(TileView.ID); // window.getActivePage().showView("org.eclipse.swt.sleak.views.SleakView"); } catch (Exception e) { e.printStackTrace(); } } }; viewTileViewAction.setImageDescriptor( ResourceManager.getPluginImageDescriptor(WorkshopPlugin.getDefault(), "icons/tiles.gif")); optimizeColorsAction = new Action("Optimize PNG Colors...") { public void run() { new PNGColorOptimizer().run(window.getShell()); } }; openLogDirAction = new Action("打开日志目录") { public void run() { String dir = Settings.logDir; String cmd = "explorer.exe \"" + dir + "\""; try { Runtime.getRuntime().exec(cmd); } catch (Exception e) { } } }; projectViewAction = new Action("ProjectView") { public void run() { try { window.getActivePage().showView(ProjectView.ID); } catch (Exception e) { e.printStackTrace(); } } }; projectViewAction.setImageDescriptor( ResourceManager.getPluginImageDescriptor(WorkshopPlugin.getDefault(), "icons/project.gif")); frameDelayAction5 = new Action("20毫秒") { public void run() { Settings.animateFrameDelay = 20; } }; frameDelayAction6 = new Action("10毫秒") { public void run() { Settings.animateFrameDelay = 10; } }; frameDelayAction1 = new Action("40毫秒") { public void run() { Settings.animateFrameDelay = 40; } }; frameDelayAction2 = new Action("60毫秒") { public void run() { Settings.animateFrameDelay = 60; } }; frameDelayAction3 = new Action("80毫秒") { public void run() { Settings.animateFrameDelay = 80; } }; frameDelayAction4 = new Action("100毫秒") { public void run() { Settings.animateFrameDelay = 100; } }; limitPIPAction = new Action("限制PIP图片大小", IAction.AS_CHECK_BOX) { public void run() { PipImage.limitSize = !PipImage.limitSize; } }; limitPIPAction.setChecked(PipImage.limitSize); allowMultiCompAction = new Action("允许一个PIP包含多个压缩纹理", IAction.AS_CHECK_BOX) { public void run() { PipImage.allowMultiCompressTexturesInOneFile = !PipImage.allowMultiCompressTexturesInOneFile; } }; allowMultiCompAction.setChecked(PipImage.allowMultiCompressTexturesInOneFile); actionFontTool = new Action("字体工具...") { public void run() { FontViewDialog dlg = new FontViewDialog(window.getShell()); dlg.open(); } }; openglAction = new Action("OpenGL模式", IAction.AS_CHECK_BOX) { public void run() { GLUtils.glEnabled = !GLUtils.glEnabled; } }; openglAction.setImageDescriptor( ResourceManager.getPluginImageDescriptor(WorkshopPlugin.getDefault(), "icons/gl.gif")); openglAction.setToolTipText("开启/关闭OpenGL模式"); openglAction.setChecked(GLUtils.glEnabled); optimizeImageAction = new Action("图片优化工具...") { public void run() { try { IFileStore fileStore = EFS.getLocalFileSystem().getStore(new Path(".")); FileStoreEditorInput input = new FileStoreEditorInput(fileStore); window.getActivePage().openEditor(input, ImageOptimizeEditor.ID); } catch (Exception e) { e.printStackTrace(); } } }; comparePipAction = new Action("比较PIP图片...") { public void run() { try { IFileStore fileStore = EFS.getLocalFileSystem().getStore(new Path(".")); FileStoreEditorInput input = new FileStoreEditorInput(fileStore); window.getActivePage().openEditor(input, ImageCompareEditor.ID); } catch (Exception e) { e.printStackTrace(); } } }; batchConvertAction = new Action("批量格式转换...") { public void run() { DirectoryDialog dlg = new DirectoryDialog(window.getShell()); dlg.setMessage("请选择源目录:"); String dir = dlg.open(); if (dir == null) { return; } dlg.setMessage("请选择目标目录:"); String targetDir = dlg.open(); if (targetDir == null) { return; } BatchConvertDialog dlg2 = new BatchConvertDialog(window.getShell()); try { dlg2.setDirectory(dir, targetDir); dlg2.open(); } catch (Exception e1) { SWTUtils.showError(window.getShell(), "错误", e1); } } }; testAction = new Action("test") { public void run() { // new TestPathDialog(null).open(); } }; }
protected void createActions() { ISharedImages sharedImages = getViewSite().getWorkbenchWindow().getWorkbench().getSharedImages(); zoomInAction = new Action(Messages.ChartViewPart_ZoomInAction) { @Override public void run() { int factor = viewer.getZoomFactor(); viewer.setZoomFactor(factor + 1); zoomOutAction.setEnabled(true); zoomResetAction.setEnabled(true); } }; zoomInAction.setId("zoomIn"); // $NON-NLS-1$ zoomInAction.setActionDefinitionId("org.eclipsetrader.ui.charts.zoomIn"); // $NON-NLS-1$ zoomOutAction = new Action(Messages.ChartViewPart_ZoomOutAction) { @Override public void run() { int factor = viewer.getZoomFactor(); if (factor > 0) { viewer.setZoomFactor(factor - 1); } zoomOutAction.setEnabled(factor != 1); zoomResetAction.setEnabled(factor != 1); } }; zoomOutAction.setId("zoomOut"); // $NON-NLS-1$ zoomOutAction.setActionDefinitionId("org.eclipsetrader.ui.charts.zoomOut"); // $NON-NLS-1$ zoomResetAction = new Action(Messages.ChartViewPart_NormalSizeAction) { @Override public void run() { viewer.setZoomFactor(0); zoomOutAction.setEnabled(false); zoomResetAction.setEnabled(false); } }; zoomResetAction.setId("zoomReset"); // $NON-NLS-1$ zoomResetAction.setActionDefinitionId("org.eclipsetrader.ui.charts.zoomReset"); // $NON-NLS-1$ zoomOutAction.setEnabled(false); zoomResetAction.setEnabled(false); periodAllAction = new Action(Messages.ChartViewPart_AllPeriodAction, IAction.AS_RADIO_BUTTON) { @Override public void run() { setPeriod(null, TimeSpan.days(1)); } }; cutAction = new Action(Messages.ChartViewPart_CutAction) { @Override public void run() {} }; cutAction.setId("cut"); // $NON-NLS-1$ cutAction.setActionDefinitionId("org.eclipse.ui.edit.cut"); // $NON-NLS-1$ cutAction.setImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_CUT)); cutAction.setDisabledImageDescriptor( sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_CUT_DISABLED)); cutAction.setEnabled(false); copyAction = new Action(Messages.ChartViewPart_CopyAction) { @Override public void run() {} }; copyAction.setId("copy"); // $NON-NLS-1$ copyAction.setActionDefinitionId("org.eclipse.ui.edit.copy"); // $NON-NLS-1$ copyAction.setImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_COPY)); copyAction.setDisabledImageDescriptor( sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED)); copyAction.setEnabled(false); pasteAction = new Action(Messages.ChartViewPart_PasteAction) { @Override public void run() {} }; pasteAction.setId("copy"); // $NON-NLS-1$ pasteAction.setActionDefinitionId("org.eclipse.ui.edit.paste"); // $NON-NLS-1$ pasteAction.setImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE)); pasteAction.setDisabledImageDescriptor( sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE_DISABLED)); pasteAction.setEnabled(false); deleteAction = new Action(Messages.ChartViewPart_DeleteAction) { @Override public void run() { IStructuredSelection selection = (IStructuredSelection) getViewSite().getSelectionProvider().getSelection(); if (!selection.isEmpty()) { if (MessageDialog.openConfirm( getViewSite().getShell(), getPartName(), Messages.ChartViewPart_DeleteConfirmMessage)) { ChartViewItem viewItem = (ChartViewItem) selection.getFirstElement(); ChartRowViewItem rowViewItem = (ChartRowViewItem) viewItem.getParent(); if (rowViewItem.getItemCount() == 1) { rowViewItem.getParentView().removeRow(rowViewItem); } else { rowViewItem.removeChildItem(viewItem); } } } } }; deleteAction.setId("delete"); // $NON-NLS-1$ deleteAction.setActionDefinitionId("org.eclipse.ui.edit.delete"); // $NON-NLS-1$ deleteAction.setImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE)); deleteAction.setDisabledImageDescriptor( sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE_DISABLED)); deleteAction.setEnabled(false); updateAction = new Action(Messages.ChartViewPart_UpdateAction) { @Override public void run() { doUpdate(); } }; updateAction.setId("update"); // $NON-NLS-1$ updateAction.setImageDescriptor( UIActivator.getImageDescriptor("icons/etool16/refresh.gif")); // $NON-NLS-1$ updateAction.setEnabled(true); propertiesAction = new PropertyDialogAction( new SameShellProvider(getViewSite().getShell()), getSite().getSelectionProvider()) { @Override public void run() { PreferenceDialog dialog = createDialog(); if (dialog != null) { if (dialog.open() == Window.OK) { IStructuredSelection selection = (IStructuredSelection) getSite().getSelectionProvider().getSelection(); ChartViewItem viewItem = (ChartViewItem) selection.getFirstElement(); ((ChartRowViewItem) viewItem.getParent()).refresh(); refreshChart(); setDirty(); } } } }; propertiesAction.setId(ActionFactory.PROPERTIES.getId()); propertiesAction.setActionDefinitionId("org.eclipse.ui.file.properties"); // $NON-NLS-1$ propertiesAction.setEnabled(false); currentPriceLineAction = new Action(Messages.ChartViewPart_ShowCurrentPriceAction, IAction.AS_CHECK_BOX) { @Override public void run() { currentPriceLineFactory.setEnable(isChecked()); dialogSettings.put(K_SHOW_CURRENT_PRICE, isChecked()); } }; currentBookAction = new Action(Messages.ChartViewPart_ShowBookAction, IAction.AS_CHECK_BOX) { @Override public void run() { currentBookFactory.setEnable(isChecked()); dialogSettings.put(K_SHOW_CURRENT_BOOK, isChecked()); } }; }
@Override protected void createBundleContent(Composite parent) { mform = new ManagedForm(parent); setManagedForm(mform); sform = mform.getForm(); FormToolkit toolkit = mform.getToolkit(); sform.setText("Server Console"); sform.setImage(ServerUICore.getLabelProvider().getImage(getServer())); sform.setExpandHorizontal(true); sform.setExpandVertical(true); toolkit.decorateFormHeading(sform.getForm()); Composite body = sform.getBody(); GridLayout layout = new GridLayout(1, false); layout.marginLeft = 6; layout.marginTop = 6; layout.marginRight = 6; body.setLayout(layout); Section manifestSection = toolkit.createSection(sform.getBody(), ExpandableComposite.TITLE_BAR | Section.DESCRIPTION); manifestSection.setText("Commands"); manifestSection.setDescription("Execute commands on server."); layout = new GridLayout(); manifestSection.setLayout(layout); manifestSection.setLayoutData(new GridData(GridData.FILL_BOTH)); Composite manifestComposite = toolkit.createComposite(manifestSection); layout = new GridLayout(); layout.marginLeft = 6; layout.marginTop = 6; layout.numColumns = 3; manifestComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); manifestComposite.setLayout(layout); manifestSection.setClient(manifestComposite); Label commandLabel = toolkit.createLabel(manifestComposite, "Command:"); commandLabel.setForeground(toolkit.getColors().getColor(IFormColors.TITLE)); GridDataFactory.fillDefaults().grab(true, false).span(3, 1).applyTo(commandLabel); commandText = toolkit.createText(manifestComposite, "", SWT.CANCEL | SWT.SEARCH); GridDataFactory.fillDefaults().grab(true, false).applyTo(commandText); commandText.addKeyListener( new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.character == SWT.CR || e.character == SWT.LF) { history.add(commandText.getText()); String cmdLine = commandText.getText(); executeCommand(cmdLine); } else if (e.keyCode == SWT.ARROW_UP) { String command = history.back(); commandText.setText(command); commandText.setSelection(command.length()); e.doit = false; } else if (e.keyCode == SWT.ARROW_DOWN) { String command = history.forward(); commandText.setText(command); commandText.setSelection(command.length()); e.doit = false; } } }); Button commandButton = toolkit.createButton(manifestComposite, "Execute", SWT.PUSH); commandButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { history.add(commandText.getText()); String cmdLine = commandText.getText(); executeCommand(cmdLine); } }); Button clearButton = toolkit.createButton(manifestComposite, "Clear", SWT.PUSH); clearButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { manifestText.setText(""); } }); manifestText = new StyledText(manifestComposite, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); manifestText.setWordWrap(false); manifestText.setFont(JFaceResources.getTextFont()); GridData data = new GridData(GridData.FILL_BOTH); data.horizontalSpan = 3; manifestText.setLayoutData(data); Label helpLabel = toolkit.createLabel(manifestComposite, "Type 'help' to get a list of supported commands."); GridDataFactory.fillDefaults().grab(true, false).span(3, 1).applyTo(helpLabel); toolBarManager = sform.getToolBarManager(); backAction = new Action("Back") { @Override public void run() { commandText.setText(history.back()); String cmdLine = commandText.getText(); executeCommand(cmdLine); } }; backAction.setImageDescriptor( ImageResource.getImageDescriptor( org.eclipse.ui.internal.browser.ImageResource.IMG_ELCL_NAV_BACKWARD)); backAction.setHoverImageDescriptor( ImageResource.getImageDescriptor(ImageResource.IMG_CLCL_NAV_BACKWARD)); backAction.setDisabledImageDescriptor( ImageResource.getImageDescriptor(ImageResource.IMG_DLCL_NAV_BACKWARD)); backAction.setEnabled(false); toolBarManager.add(backAction); forwardAction = new Action("Forward") { @Override public void run() { commandText.setText(history.forward()); String cmdLine = commandText.getText(); executeCommand(cmdLine); } }; forwardAction.setImageDescriptor( ImageResource.getImageDescriptor(ImageResource.IMG_ELCL_NAV_FORWARD)); forwardAction.setHoverImageDescriptor( ImageResource.getImageDescriptor(ImageResource.IMG_CLCL_NAV_FORWARD)); forwardAction.setDisabledImageDescriptor( ImageResource.getImageDescriptor(ImageResource.IMG_DLCL_NAV_FORWARD)); forwardAction.setEnabled(false); toolBarManager.add(forwardAction); refreshAction = new Action( "Refresh from server", ImageResource.getImageDescriptor(ImageResource.IMG_ELCL_NAV_REFRESH)) { @Override public void run() { String cmdLine = history.current(); if (cmdLine != null) { executeCommand(cmdLine); } } }; toolBarManager.add(refreshAction); sform.updateToolBar(); }