public void createActions(CommonViewer tableViewer, ISelectionProvider provider) { action = new Action() { @Override public void run() { new Job("Fetching Welcome Page URL") { public IStatus run(IProgressMonitor monitor) { // Get the url in a background thread to not freeze the UI String url2 = null; try { url2 = getUrl(); } catch (CoreException ce) { return ce.getStatus(); } final String url = url2; if (url != null) { Display.getDefault() .asyncExec( new Runnable() { public void run() { JBTWebLaunchableClient.checkedCreateInternalBrowser( url, getServer().getName(), JBossServerUIPlugin.PLUGIN_ID, JBossServerUIPlugin.getDefault().getLog()); } }); } return Status.OK_STATUS; } }.schedule(); } }; action.setText(ServerActionMessages.OpenWithBrowser); action.setDescription(ServerActionMessages.OpenWithBrowserDescription); action.setImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_INTERNAL_BROWSER)); }
@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(); }