/** {@inheritDoc} */ @Override public void createPartControl(Composite parent, FormToolkit toolkit) { main = toolkit.createComposite(parent, SWT.BORDER); main.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); GridLayout gl = new GridLayout(8, false); main.setLayout(gl); toolkit .createLabel(main, null) .setImage(InspectIT.getDefault().getImage(InspectITImages.IMG_DATABASE)); totalSql = toolkit.createFormText(main, false); totalSql.setToolTipText("Total amount of SQL Statements executed in the invocation"); totalSql.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); toolkit .createLabel(main, null) .setImage(InspectIT.getDefault().getImage(InspectITImages.IMG_TIME)); totalDuration = toolkit.createFormText(main, false); totalDuration.setToolTipText("Duration sum of all SQL Statements executed in the invocation"); totalDuration.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); toolkit .createLabel(main, null) .setImage(InspectIT.getDefault().getImage(InspectITImages.IMG_INVOCATION)); percentageOfDuration = toolkit.createFormText(main, false); percentageOfDuration.setToolTipText( "Percentage of the time spent in the invocation on SQL Statements execution"); percentageOfDuration.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); toolkit .createLabel(main, null) .setImage(InspectIT.getDefault().getImage(InspectITImages.IMG_HELP)); slowestCount = toolkit.createFormText(main, false); slowestCount.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); slowestCount.setToolTipText( "Amount of slowest SQL Statements that take 80%/20% time of total SQL execution duration"); // remove left and right margins from the parent Layout parentLayout = parent.getLayout(); if (parentLayout instanceof GridLayout) { ((GridLayout) parentLayout).marginWidth = 0; ((GridLayout) parentLayout).marginHeight = 0; } setDefaultText(); slowestHyperlinkSettings = new HyperlinkSettings(parent.getDisplay()); slowestHyperlinkSettings.setHyperlinkUnderlineMode(HyperlinkSettings.UNDERLINE_HOVER); slowestCount.setHyperlinkSettings(slowestHyperlinkSettings); slowestCount.addHyperlinkListener(getHyperlinkAdapter()); }
public void createControl(Composite parent) { toolkit = new FormToolkit(parent.getDisplay()); int borderStyle = toolkit.getBorderStyle() == SWT.BORDER ? SWT.NULL : SWT.BORDER; container = new Composite(parent, borderStyle); FillLayout flayout = new FillLayout(); flayout.marginWidth = 1; flayout.marginHeight = 1; container.setLayout(flayout); formText = new ScrolledFormText(container, SWT.V_SCROLL | SWT.H_SCROLL, false); if (borderStyle == SWT.NULL) { formText.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TREE_BORDER); toolkit.paintBordersFor(container); } FormText ftext = toolkit.createFormText(formText, false); formText.setFormText(ftext); formText.setExpandHorizontal(true); formText.setExpandVertical(true); formText.setBackground(toolkit.getColors().getBackground()); formText.setForeground(toolkit.getColors().getForeground()); ftext.marginWidth = 2; ftext.marginHeight = 2; ftext.setHyperlinkSettings(toolkit.getHyperlinkGroup()); formText.addDisposeListener( new DisposeListener() { public void widgetDisposed(DisposeEvent e) { if (toolkit != null) { toolkit.dispose(); toolkit = null; } } }); if (text != null) formText.setText(text); }
@Override public void createPartControl(Composite parent) { Composite container = new Composite(parent, SWT.NONE); container.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE)); container.setLayout(new FormLayout()); FormToolkit toolkit = new FormToolkit(container.getDisplay()); Form form = toolkit.createForm(container); FormData data = new FormData(); data.top = new FormAttachment(0, 20); data.left = new FormAttachment(50, -100); data.right = new FormAttachment(50, 100); data.bottom = new FormAttachment(100, -20); form.setLayoutData(data); // form.setText(Messages.IntroTitle); FillLayout layout = new FillLayout(); layout.marginHeight = layout.marginWidth = 5; form.getBody().setLayout(layout); FormText text = toolkit.createFormText(form.getBody(), true); StringBuilder buf = new StringBuilder(); buf.append("<form>"); // $NON-NLS-1$ buf.append("<p><img href=\"logo\"/></p>"); // $NON-NLS-1$ buf.append("<p><span color=\"header\" font=\"header\">") // $NON-NLS-1$ .append(Messages.IntroTitle) // .append("</span></p>"); // $NON-NLS-1$ addLink(buf, "action:open", Messages.IntroOpenFile, Messages.IntroOpenFileText); // $NON-NLS-1$ addLink(buf, "action:new", Messages.IntroNewFile, Messages.IntroNewFileText); // $NON-NLS-1$ addLink( buf, "action:sample", Messages.IntroOpenSample, Messages.IntroOpenSampleText); // $NON-NLS-1$ addLink( buf, "action:daxsample", Messages.IntroOpenDaxSample, Messages.IntroOpenDaxSampleText); // $NON-NLS-1$ addLink( buf, "http://buchen.github.com/portfolio/new_and_noteworthy.html", //$NON-NLS-1$ Messages.IntroReadNews, Messages.IntroReadNewsText); buf.append("</form>"); // $NON-NLS-1$ text.setText(buf.toString(), true, false); text.setImage("logo", PortfolioPlugin.image(PortfolioPlugin.IMG_LOGO)); // $NON-NLS-1$ text.setColor("header", toolkit.getColors().getColor(IFormColors.TITLE)); // $NON-NLS-1$ text.setFont("header", JFaceResources.getHeaderFont()); // $NON-NLS-1$ text.addHyperlinkListener(this); }
public ConversionReportView(Composite parent, final TopLevelEditor editor) { FormToolkit toolkit = new FormToolkit(parent.getDisplay()); message = toolkit.createFormText(parent, true); message.setFont("code", JFaceResources.getTextFont()); message.setColor("light", parent.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY)); message.addHyperlinkListener( new HyperlinkAdapter() { @Override public void linkActivated(HyperlinkEvent e) { if (e.getHref().toString().equals(ConversionReport.HREF_CONFIRM)) { editor.confirmConversionReport(); } } }); }
/** * Create widgets to display the recent entries when using the SWT presentation * * <p>XXX not tested, how to make eclipse use the SWT version? * * @see org.eclipse.ui.intro.config.IIntroContentProvider#createContent(String, Composite, * FormToolkit) */ @Override public void createContent(String id, Composite parent, FormToolkit toolkit) { if (disposed) return; FormText formText = toolkit.createFormText(parent, true); formText.addHyperlinkListener( new HyperlinkAdapter() { @Override public void linkActivated(HyperlinkEvent e) { new LoadProjectAction().execute(true, (String) e.getHref()); } }); StringBuffer buffer = new StringBuffer(); buffer.append("<form>"); // $NON-NLS-1$ RecentProjectsService.Entry[] entries = getRecentFiles(); if (entries.length > 0) { for (int i = entries.length - 1; i >= 0; i--) { RecentProjectsService.Entry entry = entries[i]; buffer.append("<li style=\"none\">"); // $NON-NLS-1$ if (entry.getProjectName() != null) { buffer.append(entry.getProjectName()); buffer.append("<br>"); // $NON-NLS-1$ } buffer.append("<a href=\""); // $NON-NLS-1$ buffer.append(entry.getFile()); buffer.append("\">"); // $NON-NLS-1$ buffer.append( RecentProjectsMenu.shorten( entry.getFile(), MAX_LENGTH, new File(entry.getFile()).getName().length())); buffer.append("</a>"); // $NON-NLS-1$ buffer.append("</li>"); // $NON-NLS-1$ } } else { buffer.append("<p>"); // $NON-NLS-1$ buffer.append("No recently opened projects."); buffer.append("</p>"); // $NON-NLS-1$ } buffer.append("</form>"); // $NON-NLS-1$ String text = buffer.toString(); text = text.replaceAll("&{1}", "&"); // $NON-NLS-1$ //$NON-NLS-2$ formText.setText(text, true, false); }
/** @param breadcrumbComposite2 */ private void createBreadCrumb(Composite parent) { this.formText = toolkit.createFormText(parent, false); formText.addHyperlinkListener(new BreadCrumbListener()); formText.setBackground(parent.getBackground()); }
/** * @param parent * @param toolkit * @param style */ public DynamicHelpPart(Composite parent, FormToolkit toolkit) { super(parent, toolkit, Section.EXPANDED | Section.TWISTIE | Section.TITLE_BAR); // configure section Section section = getSection(); section.setText(Messages.SearchPart_title); section.marginWidth = 5; section.addExpansionListener( new IExpansionListener() { public void expansionStateChanging(ExpansionEvent e) {} public void expansionStateChanged(ExpansionEvent e) { if (e.getState()) { refilter(); } } }); // create 'clear' hyperlink on the section tool bar // ImageHyperlink clearLink = new ImageHyperlink(section, SWT.NULL); // toolkit.adapt(clearLink, true, true); /* clearLink.setToolTipText(HelpUIResources .getString("SearchPart.clearResults")); //$NON-NLS-1$ clearLink.setImage(HelpUIResources .getImage(IHelpUIConstants.IMAGE_CLEAR)); clearLink.setBackground(section.getTitleBarGradientBackground()); clearLink.addHyperlinkListener(new HyperlinkAdapter() { public void linkActivated(HyperlinkEvent e) { clearResults(); } }); section.setTextClient(clearLink); */ resultSorter = new SorterByScore(); searchResults = toolkit.createFormText(section, false); section.setClient(searchResults); searchResults.setColor(IFormColors.TITLE, toolkit.getColors().getColor(IFormColors.TITLE)); String topicKey = IHelpUIConstants.IMAGE_FILE_F1TOPIC; String nwKey = IHelpUIConstants.IMAGE_NW; String searchKey = IHelpUIConstants.IMAGE_HELP_SEARCH; searchResults.setImage(topicKey, HelpUIResources.getImage(topicKey)); searchResults.setImage(nwKey, HelpUIResources.getImage(nwKey)); searchResults.setImage(searchKey, HelpUIResources.getImage(searchKey)); searchResults.addHyperlinkListener( new IHyperlinkListener() { public void linkActivated(HyperlinkEvent e) { Object href = e.getHref(); if (href.equals(CANCEL_HREF)) { if (runningJob != null) { runningJob.cancel(); runningJob = null; } clearResults(); } else if (href.equals(MORE_HREF)) { doMore(); } else doOpenLink(e.getHref()); } public void linkEntered(HyperlinkEvent e) { DynamicHelpPart.this.parent.handleLinkEntered(e); } public void linkExited(HyperlinkEvent e) { DynamicHelpPart.this.parent.handleLinkExited(e); } }); searchResults.setText("", false, false); // $NON-NLS-1$ jobListener = new JobListener(); Job.getJobManager().addJobChangeListener(jobListener); }
@Override protected Control createMessageArea(Composite composite) { // create composite // create image Image image = getImage(); if (image != null) { imageLabel = new Label(composite, SWT.NULL); image.setBackground(imageLabel.getBackground()); imageLabel.setImage(image); addAccessibleListeners(imageLabel, image); GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.BEGINNING).applyTo(imageLabel); } // create message if (message != null) { FormToolkit toolkit = new FormToolkit(Display.getDefault()); Composite toolkitComp = toolkit.createComposite(composite); toolkitComp.setLayout(new FillLayout(SWT.HORIZONTAL | SWT.VERTICAL)); FormText text = toolkit.createFormText(toolkitComp, false); text.setText(message, true, true); text.setBackground(composite.getBackground()); GridDataFactory.fillDefaults() .align(SWT.FILL, SWT.BEGINNING) .grab(true, false) .hint( convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH), SWT.DEFAULT) .applyTo(toolkitComp); text.addHyperlinkListener( new HyperlinkAdapter() { public void linkActivated(HyperlinkEvent event) { try { URI uri = URI.create((String) event.data); if ("pref".equals(uri.getScheme())) { // $NON-NLS-1$ Map<String, String> para = new HashMap<String, String>(); para.put( IWorkbenchCommandConstants.WINDOW_PREFERENCES_PARM_PAGEID, uri.getAuthority()); Command prefCommand = PlatformUI.getWorkbench() .getActiveWorkbenchWindow() .getService(ICommandService.class) .getCommand(IWorkbenchCommandConstants.WINDOW_PREFERENCES); prefCommand.executeWithChecks(new ExecutionEvent(prefCommand, para, null, null)); } } catch (ExecutionException e) { Platform.getLog(Platform.getBundle(Constants.Bundle_ID)) .log(new Status(IStatus.ERROR, Constants.Bundle_ID, e.getMessage(), e)); } catch (NotDefinedException e) { Platform.getLog(Platform.getBundle(Constants.Bundle_ID)) .log(new Status(IStatus.ERROR, Constants.Bundle_ID, e.getMessage(), e)); } catch (NotEnabledException e) { Platform.getLog(Platform.getBundle(Constants.Bundle_ID)) .log(new Status(IStatus.ERROR, Constants.Bundle_ID, e.getMessage(), e)); } catch (NotHandledException e) { Platform.getLog(Platform.getBundle(Constants.Bundle_ID)) .log(new Status(IStatus.ERROR, Constants.Bundle_ID, e.getMessage(), e)); } } }); } return composite; }
@Override public void createContents(Composite parent) { parent.setLayout(FormLayoutFactory.createDetailsGridLayout(false, 1)); FormToolkit toolkit = getManagedForm().getToolkit(); Section section = toolkit.createSection(parent, Section.DESCRIPTION | ExpandableComposite.TITLE_BAR); section.clientVerticalSpacing = FormLayoutFactory.SECTION_HEADER_VERTICAL_SPACING; section.setText(PDEUIMessages.ExtensionPointDetails_title); section.setDescription(PDEUIMessages.ExtensionPointDetails_desc); section.setLayout(FormLayoutFactory.createClearGridLayout(false, 1)); section.setLayoutData( new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING)); Composite client = toolkit.createComposite(section); client.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 3)); client.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); fIdEntry = new FormEntry(client, toolkit, PDEUIMessages.ExtensionPointDetails_id, null, false); fIdEntry.setFormEntryListener( new FormEntryAdapter(this) { @Override public void textValueChanged(FormEntry entry) { if (fInput != null) { try { fInput.setId(fIdEntry.getValue()); } catch (CoreException e) { PDEPlugin.logException(e); } } } }); fNameEntry = new FormEntry(client, toolkit, PDEUIMessages.ExtensionPointDetails_name, null, false); fNameEntry.setFormEntryListener( new FormEntryAdapter(this) { @Override public void textValueChanged(FormEntry entry) { if (fInput != null) try { fInput.setName(fNameEntry.getValue()); } catch (CoreException e) { PDEPlugin.logException(e); } } }); boolean editable = getPage().getModel().isEditable(); fSchemaEntry = new FormEntry( client, toolkit, PDEUIMessages.ExtensionPointDetails_schema, PDEUIMessages.ExtensionPointDetails_browse, editable); // fSchemaEntry.setFormEntryListener( new FormEntryAdapter(this) { @Override public void textValueChanged(FormEntry entry) { if (fInput != null) { try { fInput.setSchema(fSchemaEntry.getValue()); } catch (CoreException e) { PDEPlugin.logException(e); } updateRichText(); } } @Override public void linkActivated(HyperlinkEvent e) { IProject project = getPage().getPDEEditor().getCommonProject(); if (fSchemaEntry.getValue() == null || fSchemaEntry.getValue().length() == 0) { generateSchema(); return; } IFile file = project.getFile(fSchemaEntry.getValue()); if (file.exists()) openSchemaFile(file); else generateSchema(); } @Override public void browseButtonSelected(FormEntry entry) { final IProject project = getPage().getPDEEditor().getCommonProject(); ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog( PDEPlugin.getActiveWorkbenchShell(), new WorkbenchLabelProvider(), new WorkbenchContentProvider()); dialog.setTitle( PDEUIMessages.ManifestEditor_ExtensionPointDetails_schemaLocation_title); dialog.setMessage( PDEUIMessages.ManifestEditor_ExtensionPointDetails_schemaLocation_desc); dialog.setDoubleClickSelects(false); dialog.setAllowMultiple(false); dialog.addFilter( new ViewerFilter() { @Override public boolean select(Viewer viewer, Object parent, Object element) { if (element instanceof IFile) { String ext = ((IFile) element).getFullPath().getFileExtension(); return "exsd".equals(ext) || "mxsd".equals(ext); // $NON-NLS-1$ //$NON-NLS-2$ } else if (element instanceof IContainer) { // i.e. IProject, IFolder try { IResource[] resources = ((IContainer) element).members(); for (IResource resource : resources) { if (select(viewer, parent, resource)) return true; } } catch (CoreException e) { PDEPlugin.logException(e); } } return false; } }); dialog.setValidator( new ISelectionStatusValidator() { @Override public IStatus validate(Object[] selection) { IPluginModelBase model = (IPluginModelBase) getPage().getPDEEditor().getAggregateModel(); String pluginName = model.getPluginBase().getId(); if (selection == null || selection.length != 1 || !(selection[0] instanceof IFile)) return new Status( IStatus.ERROR, pluginName, IStatus.ERROR, PDEUIMessages.ManifestEditor_ExtensionPointDetails_validate_errorStatus, null); IFile file = (IFile) selection[0]; String ext = file.getFullPath().getFileExtension(); if ("exsd".equals(ext) || "mxsd".equals(ext)) // $NON-NLS-1$ //$NON-NLS-2$ return new Status(IStatus.OK, pluginName, IStatus.OK, "", null); // $NON-NLS-1$ return new Status( IStatus.ERROR, pluginName, IStatus.ERROR, PDEUIMessages.ManifestEditor_ExtensionPointDetails_validate_errorStatus, null); } }); dialog.setDoubleClickSelects(true); dialog.setStatusLineAboveButtons(true); dialog.setInput(project); dialog.setComparator(new ResourceComparator(ResourceComparator.NAME)); String filePath = fSchemaEntry.getValue(); if (filePath != null && filePath.length() != 0 && project.exists(new Path(filePath))) dialog.setInitialSelection(project.getFile(new Path(filePath))); else dialog.setInitialSelection(null); dialog.create(); PlatformUI.getWorkbench() .getHelpSystem() .setHelp(dialog.getShell(), IHelpContextIds.BROWSE_EXTENSION_POINTS_SCHEMAS); if (dialog.open() == Window.OK) { Object[] elements = dialog.getResult(); if (elements.length > 0) { IResource elem = (IResource) elements[0]; fSchemaEntry.setValue(elem.getProjectRelativePath().toString()); } } } }); createSpacer(toolkit, client, 2); Composite container = toolkit.createComposite(parent, SWT.NONE); container.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 1)); container.setLayoutData( new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING)); fRichText = toolkit.createFormText(container, true); fRichText.setImage( "open", PDEPlugin.getDefault() .getLabelProvider() .get( //$NON-NLS-1$ PDEPluginImages.DESC_SCHEMA_OBJ)); fRichText.setImage( "desc", PDEPlugin.getDefault() .getLabelProvider() .get( //$NON-NLS-1$ PDEPluginImages.DESC_DOC_SECTION_OBJ)); fRichText.setImage( "search", PDEPlugin.getDefault() .getLabelProvider() .get( //$NON-NLS-1$ PDEPluginImages.DESC_PSEARCH_OBJ)); fRichText.addHyperlinkListener( new HyperlinkAdapter() { @Override public void linkActivated(HyperlinkEvent e) { IBaseModel model = getPage().getPDEEditor().getAggregateModel(); String pointID = null; IPluginBase base = ((IPluginModelBase) model).getPluginBase(); String pluginID = base.getId(); String schemaVersion = base.getSchemaVersion(); if (schemaVersion != null && Double.parseDouble(schemaVersion) >= 3.2) { if (fInput.getId().indexOf('.') != -1) pointID = fInput.getId(); } if (pointID == null) pointID = pluginID + "." + fInput.getId(); // $NON-NLS-1$ IPluginExtensionPoint extPoint = PDECore.getDefault().getExtensionsRegistry().findExtensionPoint(pointID); if (e.getHref().equals("search")) { // $NON-NLS-1$ new FindReferencesAction(fInput, pluginID).run(); } else if (e.getHref().equals("open")) { // $NON-NLS-1$ if (extPoint == null) { IProject project = getPage().getPDEEditor().getCommonProject(); IFile file = project.getFile(fSchemaEntry.getValue()); if (file.exists()) openSchemaFile(file); else generateSchema(); return; } OpenSchemaAction action = new OpenSchemaAction(); action.setInput(pointID); action.setEnabled(true); action.run(); } else { if (extPoint == null) { IProject project = getPage().getPDEEditor().getCommonProject(); IFile file = project.getFile(fSchemaEntry.getValue()); URL url; try { url = file.getLocationURI().toURL(); } catch (MalformedURLException e1) { return; } SchemaDescriptor schemaDesc = new SchemaDescriptor(pointID, url); Schema schema = new Schema(schemaDesc, url, false); schema.setPluginId(pluginID); schema.setPointId(fInput.getId()); schema.setName(fNameEntry.getValue()); new ShowDescriptionAction(schema).run(); return; } new ShowDescriptionAction(pointID).run(); } } }); fIdEntry.setEditable(isEditable()); fNameEntry.setEditable(isEditable()); fSchemaEntry.setEditable(isEditable()); toolkit.paintBordersFor(client); section.setClient(client); IPluginModelBase model = (IPluginModelBase) getPage().getModel(); model.addModelChangedListener(this); markDetailsPart(section); }