protected void createDefaultActions() { toolBarManager.removeAll(); if ((gridStyle & IGridViewer.NoToolBar) == 0) { if ((gridStyle & IGridViewer.fullEditable) != 0) { Element element = null; try { // element = // LoadSchemaManager.getSchemaManager().getElement( // data); element = CompositeMapUtil.getElement(data); } catch (Exception e) { // do nothing } if (element != null && element.isArray()) { final QualifiedName qName = element.getElementType().getQName(); Action addAction = new AddElementAction(this, data, qName, ActionListener.NONE); addAction.setText(""); addAction.setHoverImageDescriptor( AuroraPlugin.getImageDescriptor(LocaleMessage.getString("add.icon"))); Action removeAction = new RemoveElementAction(this, ActionListener.DefaultImage); Action refreshAction = new RefreshAction(this, ActionListener.DefaultImage); toolBarManager.add(createActionContributionItem(addAction)); toolBarManager.add(createActionContributionItem(refreshAction)); toolBarManager.add(createActionContributionItem(removeAction)); toolBarManager.update(true); tableViewer .getTable() .addKeyListener( new KeyListener() { public void keyPressed(KeyEvent e) { if (e.keyCode == SWT.DEL) { removeElement(); } } public void keyReleased(KeyEvent e) {} }); } } } if ((gridStyle & IGridViewer.isMulti) != 0) { Action allCheckAction = new Action( LocaleMessage.getString("all.checed"), AuroraPlugin.getImageDescriptor(LocaleMessage.getString("checked.icon"))) { public void run() { setAllChecked(tableViewer.getTable(), true); } }; Action unAllCheckAction = new Action( LocaleMessage.getString("non.checed"), AuroraPlugin.getImageDescriptor(LocaleMessage.getString("unchecked.icon"))) { public void run() { setAllChecked(tableViewer.getTable(), false); } }; toolBarManager.add(createActionContributionItem(allCheckAction)); toolBarManager.add(createActionContributionItem(unAllCheckAction)); toolBarManager.update(true); } }
@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(); }