Java Code Examples for org.eclipse.swt.widgets.Link#addSelectionListener()
The following examples show how to use
org.eclipse.swt.widgets.Link#addSelectionListener() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CodeAssistAdvancedConfigurationBlock.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void createKeysLink(Composite composite, int h_span) { Link link= new Link(composite, SWT.NONE | SWT.WRAP); link.setText(PreferencesMessages.CodeAssistAdvancedConfigurationBlock_key_binding_hint); link.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { PreferencesUtil.createPreferenceDialogOn(getShell(), e.text, null, null); } }); PixelConverter pixelConverter= new PixelConverter(composite); int width= pixelConverter.convertWidthInCharsToPixels(40); // limit the size of the Link as it would take all it can get GridData gd= new GridData(GridData.FILL, GridData.FILL, false, false, h_span, 1); gd.widthHint= width; link.setLayoutData(gd); }
Example 2
Source File: CoreUtil.java From codewind-eclipse with Eclipse Public License 2.0 | 6 votes |
public static Control addLinkToDialog(Composite parent, String linkLabel, String linkUrl) { Link link = new Link(parent, SWT.WRAP); link.setText("<a>" + linkLabel + "</a>"); //$NON-NLS-1$ //$NON-NLS-2$ link.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { try { IWorkbenchBrowserSupport browserSupport = PlatformUI.getWorkbench().getBrowserSupport(); IWebBrowser browser = browserSupport.getExternalBrowser(); URL url = new URL(linkUrl); browser.openURL(url); } catch (Exception e) { Logger.logError("An error occurred trying to open an external browser at: " + link, e); //$NON-NLS-1$ } } }); return link; }
Example 3
Source File: NewJavaProjectWizardPageOne.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public Control createControl(Composite composite) { fGroup= new Group(composite, SWT.NONE); fGroup.setFont(composite.getFont()); fGroup.setLayout(initGridLayout(new GridLayout(2, false), true)); fGroup.setText(NewWizardMessages.NewJavaProjectWizardPageOne_JREGroup_title); fUseEEJRE.doFillIntoGrid(fGroup, 1); Combo eeComboControl= fEECombo.getComboControl(fGroup); eeComboControl.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false)); fUseProjectJRE.doFillIntoGrid(fGroup, 1); Combo comboControl= fJRECombo.getComboControl(fGroup); comboControl.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false)); fUseDefaultJRE.doFillIntoGrid(fGroup, 1); fPreferenceLink= new Link(fGroup, SWT.NONE); fPreferenceLink.setFont(fGroup.getFont()); fPreferenceLink.setText(NewWizardMessages.NewJavaProjectWizardPageOne_JREGroup_link_description); fPreferenceLink.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false)); fPreferenceLink.addSelectionListener(this); updateEnableState(); return fGroup; }
Example 4
Source File: JavaEditorPropertyPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override protected Control createContents(Composite parent) { final Composite composite= new Composite(parent, SWT.NONE); composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); composite.setLayout(new GridLayout()); Link link= new Link(composite, SWT.WRAP); GridData data= new GridData(SWT.FILL, SWT.BEGINNING, true, false); data.widthHint= 300; link.setLayoutData(data); link.setText(PreferencesMessages.JavaEditorPropertyPage_SaveActionLink_Text); link.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { IWorkbenchPreferenceContainer container= (IWorkbenchPreferenceContainer)getContainer(); container.openPage(SaveParticipantPreferencePage.PROPERTY_PAGE_ID, null); } }); noDefaultAndApplyButton(); Dialog.applyDialogFont(composite); return composite; }
Example 5
Source File: DebugPreferencePage.java From corrosion with Eclipse Public License 2.0 | 6 votes |
@Override protected Control createContents(Composite parent) { parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); Composite container = new Composite(parent, SWT.NONE); container.setLayout(new GridLayout(4, false)); container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1)); gdbInput = new InputComponent(container, Messages.DebugPreferencePage_defaultGDB, e -> isPageValid()); gdbInput.createComponent(); gdbInput.createFileSelection(); gdbInput.setValue(store.getString(CorrosionPreferenceInitializer.DEFAULT_GDB_PREFERENCE)); Link gdbLink = new Link(container, SWT.NONE); gdbLink.setText(Messages.DebugPreferencePage_seeGDBPage); gdbLink.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { IPreferencePageContainer prefContainer = getContainer(); if (prefContainer instanceof IWorkbenchPreferenceContainer) { ((IWorkbenchPreferenceContainer) prefContainer).openPage("org.eclipse.cdt.dsf.gdb.ui.preferences", //$NON-NLS-1$ null); } })); gdbLink.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 4, 1)); return parent; }
Example 6
Source File: StatusWidget.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
protected void createControls() { setLayout(new GridLayout(2, false)); imageLabel = new Label(this, SWT.NONE); imageLabel.setText(" "); GridData imgLabelLayoutData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); imgLabelLayoutData.widthHint = 20; imageLabel.setLayoutData(imgLabelLayoutData); link = new Link(this, SWT.NONE); GridData linkLayoutData = new GridData(GridData.FILL_HORIZONTAL); linkLayoutData.heightHint = 40; link.setLayoutData(linkLayoutData); link.setFont(getFont()); link.setText("\n\n\n"); link.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { super.widgetSelected(e); quickFix.apply(); } }); }
Example 7
Source File: PropToPrefLinkArea.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
public PropToPrefLinkArea(Composite parent, int style, final String pageId, String message, final Shell shell, final Object pageData) { /* * breaking new ground yet again - want to link between property and preference paes. ie: project specific debug * engine options to general debugging options */ pageLink = new Link(parent, style); IPreferenceNode node = getPreferenceNode(pageId); String result; if (node == null) { result = NLS.bind(WorkbenchMessages.PreferenceNode_NotFound, pageId); } else { result = MessageFormat.format(message, node.getLabelText()); // only add the selection listener if the node is found pageLink.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { PreferencesUtil.createPreferenceDialogOn(shell, pageId, new String[] { pageId }, pageData).open(); } }); } pageLink.setText(result); }
Example 8
Source File: BrowserMenuPopulator.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
/** * Find a browser to open url */ private void findBrowser() { MessageDialog md = new MessageDialog(SWTUtilities.getShell(), "No browsers found", null, null, MessageDialog.ERROR, new String[] { "Ok" }, 0) { @Override protected Control createMessageArea(Composite parent) { super.createMessageArea(parent); Link link = new Link(parent, SWT.NONE); link.setText("There are no browsers defined, please add one (Right-click on URL -> " + "Open with -> Add a Browser, or <a href=\"#\">Window -> Preferences -> General -> Web Browser</a>)."); link.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { PreferenceDialog dialog = PreferencesUtil .createPreferenceDialogOn(Display.getCurrent().getActiveShell(), "org.eclipse.ui.browser.preferencePage", new String[] { "org.eclipse.ui.browser.preferencePage" }, null); if (dialog != null) { dialog.open(); } } }); return parent; } }; md.open(); }
Example 9
Source File: SWTFactory.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
/** * Creates a new link widget * @param parent the parent composite to add this link widget to * @param text the text for the link * @param hspan the horizontal span to take up in the parent composite * @return the new link */ public static Link createLink(Composite parent, String text, int hspan, SelectionAdapter listener) { Link l = new Link(parent, SWT.NONE); l.setFont(parent.getFont()); l.setText(text); GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = hspan; gd.grabExcessHorizontalSpace = false; l.setLayoutData(gd); l.addSelectionListener(listener); return l; }
Example 10
Source File: MessageDialogWithLink.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override protected Control createMessageArea(final Composite composite) { // create composite // create image final Image image = getImage(); if (image != null) { imageLabel = new Label(composite, SWT.NULL); image.setBackground(imageLabel.getBackground()); imageLabel.setImage(image); GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.BEGINNING) .applyTo(imageLabel); } // create message if (message != null) { final Link messageLabel = new Link(composite, getMessageLabelStyle()); messageLabel.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final org.eclipse.swt.events.SelectionEvent e) { try { java.awt.Desktop.getDesktop().browse(uri); } catch (final IOException e1) { BonitaStudioLog.error(e1); } }; }); messageLabel.setText(message); GridDataFactory .fillDefaults() .align(SWT.FILL, SWT.BEGINNING) .grab(true, false) .hint( convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH), SWT.DEFAULT).applyTo(messageLabel); } return composite; }
Example 11
Source File: WinBuildStatusHandler.java From thym with Eclipse Public License 1.0 | 5 votes |
protected Control createDialogArea(Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); GridLayout layout = (GridLayout) composite.getLayout(); layout.numColumns = 1; Link desc = new Link(composite, SWT.NONE); desc.setText(Messages.WinBuildStatusHandler_Message); desc.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { Program.launch(WinConstants.SDK_DOWNLOAD_URL); } }); getShell().setText(Messages.WinBuildStatusHandler_Title); return composite; }
Example 12
Source File: EditboxPreferencePage.java From gama with GNU General Public License v3.0 | 5 votes |
@Override protected Control createContents(final Composite parent) { noDefaultAndApplyButton(); final Composite c = new Composite(parent, SWT.NONE); c.setLayout(new GridLayout(1, false)); final Link link = new Link(c, SWT.NONE); link.setText("Turn off current line highlighting <A>here</A>."); final FontData[] fontData = link.getFont().getFontData(); for (final FontData fd : fontData) { fd.setHeight(10); fd.setStyle(SWT.BOLD); } link.setFont(new Font(getShell().getDisplay(), fontData)); link.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { final IWorkbenchPreferenceContainer container = (IWorkbenchPreferenceContainer) getContainer(); container.openPage("org.eclipse.ui.preferencePages.GeneralTextEditor", null); } }); folder = new TabFolder(c, SWT.NONE); folder.setLayoutData(new GridData(GridData.FILL_BOTH)); final TabItem ti = new TabItem(folder, SWT.NONE); ti.setText("Themes"); ti.setControl(createCategoryControl(folder)); folder.pack(); return c; }
Example 13
Source File: ClasspathFixSelectionDialog.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private Link createLink(Composite composite, ListenerMix listener) { Link link= new Link(composite, SWT.WRAP); GridData layoutData= new GridData(SWT.FILL, SWT.CENTER, true, false); layoutData.widthHint= convertWidthInCharsToPixels(80); link.setLayoutData(layoutData); link.addSelectionListener(listener); return link; }
Example 14
Source File: CompletionProposalComputerRegistry.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Log the status and inform the user about a misbehaving extension. * * @param descriptor the descriptor of the misbehaving extension * @param status a status object that will be logged */ void informUser(CompletionProposalComputerDescriptor descriptor, IStatus status) { JavaPlugin.log(status); String title= JavaTextMessages.CompletionProposalComputerRegistry_error_dialog_title; CompletionProposalCategory category= descriptor.getCategory(); IContributor culprit= descriptor.getContributor(); Set<String> affectedPlugins= getAffectedContributors(category, culprit); final String avoidHint; final String culpritName= culprit == null ? null : culprit.getName(); if (affectedPlugins.isEmpty()) avoidHint= Messages.format(JavaTextMessages.CompletionProposalComputerRegistry_messageAvoidanceHint, new Object[] {culpritName, category.getDisplayName()}); else avoidHint= Messages.format(JavaTextMessages.CompletionProposalComputerRegistry_messageAvoidanceHintWithWarning, new Object[] {culpritName, category.getDisplayName(), toString(affectedPlugins)}); String message= status.getMessage(); // inlined from MessageDialog.openError MessageDialog dialog = new MessageDialog(JavaPlugin.getActiveWorkbenchShell(), title, null /* default image */, message, MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, 0) { @Override protected Control createCustomArea(Composite parent) { Link link= new Link(parent, SWT.NONE); link.setText(avoidHint); link.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { PreferencesUtil.createPreferenceDialogOn(getShell(), "org.eclipse.jdt.ui.preferences.CodeAssistPreferenceAdvanced", null, null).open(); //$NON-NLS-1$ } }); GridData gridData= new GridData(SWT.FILL, SWT.BEGINNING, true, false); gridData.widthHint= this.getMinimumMessageWidth(); link.setLayoutData(gridData); return link; } }; dialog.open(); }
Example 15
Source File: EmulatorsStatusHandler.java From thym with Eclipse Public License 1.0 | 5 votes |
protected Control createDialogArea(Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); GridLayout layout = (GridLayout) composite.getLayout(); layout.numColumns = 1; Link desc = new Link(composite, SWT.NONE); desc.setText(Messages.EmulatorsStatusHandler_Message); desc.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { Program.launch(WPConstants.SDK_DOWNLOAD_URL); } }); getShell().setText(Messages.EmulatorsStatusHandler_Title); return composite; }
Example 16
Source File: TypeFilterPreferencePage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void createPreferencePageLink(Composite composite, String label, final Map<String, String> targetInfo) { final Link link= new Link(composite, SWT.NONE); link.setText(label); link.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, true, false, 2, 1)); link.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { PreferencesUtil.createPreferenceDialogOn(link.getShell(), e.text, null, targetInfo); } }); }
Example 17
Source File: AbstractPopupSheet.java From birt with Eclipse Public License 1.0 | 5 votes |
private Link createHelpLink( Composite parent ) { Link link = new Link( parent, SWT.WRAP | SWT.NO_FOCUS ); link.setLayoutData( new GridData( GridData.HORIZONTAL_ALIGN_CENTER ) ); link.setText( "<a>" + IDialogConstants.HELP_LABEL + "</a>" ); //$NON-NLS-1$ //$NON-NLS-2$ link.setToolTipText( IDialogConstants.HELP_LABEL ); link.addSelectionListener( new SelectionAdapter( ) { public void widgetSelected( SelectionEvent e ) { helpPressed( ); } } ); return link; }
Example 18
Source File: AppEngineDeployPreferencesPanel.java From google-cloud-eclipse with Apache License 2.0 | 4 votes |
private void createProjectIdSection() { Label projectIdLabel = new Label(this, SWT.LEAD); projectIdLabel.setText(Messages.getString("project")); projectIdLabel.setToolTipText(Messages.getString("tooltip.project.id")); GridDataFactory.swtDefaults().align(SWT.BEGINNING, SWT.BEGINNING).span(1, 2) .applyTo(projectIdLabel); Composite linkComposite = new Composite(this, SWT.NONE); Link createNewProject = new Link(linkComposite, SWT.WRAP); createNewProject.setText(Messages.getString("projectselector.createproject", CREATE_GCP_PROJECT_URL)); createNewProject.setToolTipText(Messages.getString("projectselector.createproject.tooltip")); FontUtil.convertFontToItalic(createNewProject); createNewProject.addSelectionListener(new OpenUriSelectionListener( () -> accountSelector.getSelectedEmail().isEmpty() ? Collections.emptyMap() : Collections.singletonMap("authuser", accountSelector.getSelectedEmail()), new ErrorDialogErrorHandler(getShell()))); GridDataFactory.fillDefaults().applyTo(linkComposite); GridLayoutFactory.fillDefaults().generateLayout(linkComposite); Composite projectSelectorComposite = new Composite(this, SWT.NONE); GridLayoutFactory.fillDefaults().numColumns(2).spacing(0, 0).applyTo(projectSelectorComposite); GridDataFactory.fillDefaults().grab(true, false).applyTo(projectSelectorComposite); final Text filterField = new Text(projectSelectorComposite, SWT.BORDER | SWT.SEARCH | SWT.ICON_SEARCH | SWT.ICON_CANCEL); filterField.setMessage(Messages.getString("projectselector.filter")); GridDataFactory.fillDefaults().applyTo(filterField); new Label(projectSelectorComposite, SWT.NONE); // spacer projectSelector = new ProjectSelector(projectSelectorComposite); GridDataFactory.fillDefaults().grab(true, false).hint(SWT.DEFAULT, 200) .applyTo(projectSelector); final Button refreshProjectsButton = new Button(projectSelectorComposite, SWT.NONE); refreshProjectsButton.setImage(refreshIcon); GridDataFactory.swtDefaults().align(SWT.END, SWT.BEGINNING).applyTo(refreshProjectsButton); refreshProjectsButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { refreshProjectsForSelectedCredential(); } }); accountSelector.addSelectionListener( new RefreshProjectOnAccountSelection(refreshProjectsButton)); projectSelector.addSelectionChangedListener( new ProjectSelectorSelectionChangedListener(accountSelector, projectRepository, projectSelector)); filterField.addModifyListener(event -> { projectSelector.setFilter(filterField.getText()); }); }
Example 19
Source File: ChromeExecutableTab.java From wildwebdeveloper with Eclipse Public License 2.0 | 4 votes |
@Override public void createControl(Composite parent) { Composite res = new Composite(parent, SWT.NONE); res.setLayout(new GridLayout(2, false)); new Label(res, SWT.NONE).setText(Messages.ChromeAttachTab_runWith); browserToUse = new ComboViewer(res, SWT.VERTICAL | SWT.DROP_DOWN | SWT.BORDER | SWT.READ_ONLY); browserToUse.setContentProvider(new ArrayContentProvider()); browserToUse.setLabelProvider(new BrowserLabelProvider()); proposals = new LinkedList<>(); proposals.add(""); //$NON-NLS-1$ proposals.addAll(BrowserManager.getInstance().getWebBrowsers().stream().filter(ChromeExecutableTab::isChrome).collect(Collectors.toList())); browserToUse.setInput(proposals); browserToUse.addPostSelectionChangedListener(e -> { setDirty(true); updateLaunchConfigurationDialog(); }); Link link = new Link(res, SWT.NONE); link.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false, 2, 1)); link.setText(Messages.ChromeAttachTab_browserPreferences); link.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { Dialog dialog = PreferencesUtil.createPreferenceDialogOn(link.getShell(), "org.eclipse.ui.browser.preferencePage", null, null); //$NON-NLS-1$ dialog.open(); List<IBrowserDescriptor> previous = proposals.stream().filter(IBrowserDescriptor.class::isInstance).map(IBrowserDescriptor.class::cast).collect(Collectors.toList()); List<IBrowserDescriptor> next = BrowserManager.getInstance().getWebBrowsers(); List<IBrowserDescriptor> toRemove = new LinkedList<>(previous); toRemove.removeAll(next); proposals.removeAll(toRemove); List<IBrowserDescriptor> toAdd = new LinkedList<>(next); toAdd.removeAll(previous); toAdd.removeIf(browser -> !isChrome(browser)); proposals.addAll(toAdd); if (!(toAdd.isEmpty() && toRemove.isEmpty())) { browserToUse.refresh(); if (browserToUse.getSelection().isEmpty()) { browserToUse.setSelection(new StructuredSelection("")); //$NON-NLS-1$ } } })); setControl(res); }
Example 20
Source File: NewTypeWizardPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 3 votes |
/** * Creates the controls for the preference page links. Expects a <code>GridLayout</code> with * at least 3 columns. * * @param composite the parent composite * @param nColumns number of columns to span * * @since 3.1 */ protected void createCommentControls(Composite composite, int nColumns) { Link link= new Link(composite, SWT.NONE); link.setText(NewWizardMessages.NewTypeWizardPage_addcomment_description); link.addSelectionListener(new TypeFieldsAdapter()); link.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false, nColumns, 1)); DialogField.createEmptySpace(composite); fAddCommentButton.doFillIntoGrid(composite, nColumns - 1); }