Search in sources :

Example 16 with Hyperlink

use of org.eclipse.ui.forms.widgets.Hyperlink in project bndtools by bndtools.

the class GeneralInfoPart method createSection.

private void createSection(Section section, FormToolkit toolkit) {
    section.setText("Basic Information");
    KeyStroke assistKeyStroke = null;
    try {
        assistKeyStroke = KeyStroke.getInstance("Ctrl+Space");
    } catch (ParseException x) {
    // Ignore
    }
    FieldDecoration contentAssistDecoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
    Composite composite = toolkit.createComposite(section);
    section.setClient(composite);
    toolkit.createLabel(composite, "Version:");
    txtVersion = toolkit.createText(composite, "", SWT.BORDER);
    ToolTips.setupMessageAndToolTipFromSyntax(txtVersion, Constants.BUNDLE_VERSION);
    Hyperlink linkActivator = toolkit.createHyperlink(composite, "Activator:", SWT.NONE);
    txtActivator = toolkit.createText(composite, "", SWT.BORDER);
    ToolTips.setupMessageAndToolTipFromSyntax(txtActivator, Constants.BUNDLE_ACTIVATOR);
    // Content Proposal for the Activator field
    ContentProposalAdapter activatorProposalAdapter = null;
    ActivatorClassProposalProvider proposalProvider = new ActivatorClassProposalProvider();
    activatorProposalAdapter = new ContentProposalAdapter(txtActivator, new TextContentAdapter(), proposalProvider, assistKeyStroke, UIConstants.autoActivationCharacters());
    activatorProposalAdapter.addContentProposalListener(proposalProvider);
    activatorProposalAdapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
    activatorProposalAdapter.setLabelProvider(new JavaContentProposalLabelProvider());
    activatorProposalAdapter.setAutoActivationDelay(1000);
    // Decorator for the Activator field
    ControlDecoration decorActivator = new ControlDecoration(txtActivator, SWT.LEFT | SWT.CENTER, composite);
    decorActivator.setImage(contentAssistDecoration.getImage());
    decorActivator.setMarginWidth(3);
    if (assistKeyStroke == null) {
        decorActivator.setDescriptionText("Content Assist is available. Start typing to activate");
    } else {
        decorActivator.setDescriptionText(MessageFormat.format("Content Assist is available. Press {0} or start typing to activate", assistKeyStroke.format()));
    }
    decorActivator.setShowOnlyOnFocus(true);
    decorActivator.setShowHover(true);
    // Listeners
    txtVersion.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            lock.ifNotModifying(new Runnable() {

                @Override
                public void run() {
                    addDirtyProperty(Constants.BUNDLE_VERSION);
                }
            });
        }
    });
    txtActivator.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent ev) {
            lock.ifNotModifying(new Runnable() {

                @Override
                public void run() {
                    addDirtyProperty(Constants.BUNDLE_ACTIVATOR);
                }
            });
        }
    });
    linkActivator.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        public void linkActivated(HyperlinkEvent ev) {
            String activatorClassName = txtActivator.getText();
            if (activatorClassName != null && activatorClassName.length() > 0) {
                try {
                    IJavaProject javaProject = getJavaProject();
                    if (javaProject == null)
                        return;
                    IType activatorType = javaProject.findType(activatorClassName);
                    if (activatorType != null) {
                        JavaUI.openInEditor(activatorType, true, true);
                    }
                } catch (PartInitException e) {
                    ErrorDialog.openError(getManagedForm().getForm().getShell(), "Error", null, new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, MessageFormat.format("Error opening an editor for activator class '{0}'.", activatorClassName), e));
                } catch (JavaModelException e) {
                    ErrorDialog.openError(getManagedForm().getForm().getShell(), "Error", null, new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, MessageFormat.format("Error searching for activator class '{0}'.", activatorClassName), e));
                }
            }
        }
    });
    activatorProposalAdapter.addContentProposalListener(new IContentProposalListener() {

        @Override
        public void proposalAccepted(IContentProposal proposal) {
            if (proposal instanceof JavaContentProposal) {
                String selectedPackageName = ((JavaContentProposal) proposal).getPackageName();
                if (!model.isIncludedPackage(selectedPackageName)) {
                    model.addPrivatePackage(selectedPackageName);
                }
            }
        }
    });
    // Layout
    GridLayout layout = new GridLayout(2, false);
    layout.horizontalSpacing = 15;
    composite.setLayout(layout);
    GridData gd = new GridData(SWT.FILL, SWT.TOP, true, false);
    txtVersion.setLayoutData(gd);
    txtActivator.setLayoutData(gd);
}
Also used : JavaModelException(org.eclipse.jdt.core.JavaModelException) HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) ModifyListener(org.eclipse.swt.events.ModifyListener) FieldDecoration(org.eclipse.jface.fieldassist.FieldDecoration) TextContentAdapter(org.eclipse.jface.fieldassist.TextContentAdapter) IType(org.eclipse.jdt.core.IType) ModifyEvent(org.eclipse.swt.events.ModifyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) ControlDecoration(org.eclipse.jface.fieldassist.ControlDecoration) JavaContentProposal(bndtools.utils.JavaContentProposal) PartInitException(org.eclipse.ui.PartInitException) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) Composite(org.eclipse.swt.widgets.Composite) JavaContentProposalLabelProvider(bndtools.utils.JavaContentProposalLabelProvider) ContentProposalAdapter(org.eclipse.jface.fieldassist.ContentProposalAdapter) IContentProposal(org.eclipse.jface.fieldassist.IContentProposal) IJavaProject(org.eclipse.jdt.core.IJavaProject) KeyStroke(org.eclipse.jface.bindings.keys.KeyStroke) GridData(org.eclipse.swt.layout.GridData) IContentProposalListener(org.eclipse.jface.fieldassist.IContentProposalListener) ParseException(org.eclipse.jface.bindings.keys.ParseException) Hyperlink(org.eclipse.ui.forms.widgets.Hyperlink) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter)

Example 17 with Hyperlink

use of org.eclipse.ui.forms.widgets.Hyperlink in project bndtools by bndtools.

the class JPMBrowserView method createPartControl.

@Override
public void createPartControl(Composite parent) {
    StackLayout stack = new StackLayout();
    parent.setLayout(stack);
    JpmPreferences prefs = new JpmPreferences();
    if (prefs.getBrowserSelection() == JpmPreferences.PREF_BROWSER_EXTERNAL) {
        external = true;
        Composite composite = new Composite(parent, SWT.NONE);
        composite.setLayout(new GridLayout(2, false));
        new Label(composite, SWT.NONE).setText("Searchable Repository is configured to open in an external browser.");
        Hyperlink linkToPrefs = new Hyperlink(composite, SWT.NONE);
        linkToPrefs.setText("Open Preference Page");
        linkToPrefs.setUnderlined(true);
        linkToPrefs.addHyperlinkListener(new HyperlinkAdapter() {

            @Override
            public void linkActivated(HyperlinkEvent e) {
                PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(getViewSite().getShell(), "bndtools.prefPages.jpm", new String[] { "bndtools.prefPages.jpm" }, null);
                dialog.open();
            }
        });
        // linkToPrefs.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, false));
        stack.topControl = composite;
    } else {
        if (prefs.getBrowserSelection() == JpmPreferences.PREF_BROWSER_PLATFORM_DEFAULT) {
            browser = new Browser(parent, SWT.NONE);
            stack.topControl = browser;
        } else if (prefs.getBrowserSelection() == JpmPreferences.PREF_BROWSER_WEBKIT) {
            browser = new Browser(parent, SWT.WEBKIT);
            stack.topControl = browser;
        } else if (prefs.getBrowserSelection() == JpmPreferences.PREF_BROWSER_MOZILLA) {
            browser = new Browser(parent, SWT.MOZILLA);
            stack.topControl = browser;
        }
        createActions();
        // Prevent navigation away from JPM4J.org, and redirect from HTTP back to HTTPS
        browser.addLocationListener(new LocationAdapter() {

            @Override
            public void changing(LocationEvent event) {
                setContentDescription(event.location);
            /*
                     * if (event.location.startsWith(HTTPS_URL)) return; if (event.location.startsWith(HTTP_URL))
                     * event.location = event.location.replaceFirst(HTTP_URL, HTTP_URL); else event.doit = false;
                     */
            }
        });
    }
    selectionService = getViewSite().getWorkbenchWindow().getSelectionService();
    selectionService.addSelectionListener(this);
    handleWorkbenchSelection(selectionService.getSelection());
}
Also used : HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) Composite(org.eclipse.swt.widgets.Composite) JpmPreferences(bndtools.preferences.JpmPreferences) LocationAdapter(org.eclipse.swt.browser.LocationAdapter) Label(org.eclipse.swt.widgets.Label) GridLayout(org.eclipse.swt.layout.GridLayout) PreferenceDialog(org.eclipse.jface.preference.PreferenceDialog) StackLayout(org.eclipse.swt.custom.StackLayout) LocationEvent(org.eclipse.swt.browser.LocationEvent) Hyperlink(org.eclipse.ui.forms.widgets.Hyperlink) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter) Browser(org.eclipse.swt.browser.Browser)

Example 18 with Hyperlink

use of org.eclipse.ui.forms.widgets.Hyperlink in project tdi-studio-se by Talend.

the class NotificationsTab method createMessagePage.

/**
     * Creates the message page.
     */
private void createMessagePage() {
    messagePage = new Composite(this, SWT.NONE);
    messagePage.setLayout(new GridLayout(3, false));
    FormToolkit toolkit = new FormToolkit(Display.getDefault());
    toolkit.createLabel(messagePage, Messages.notificationsNotSubscribedMsg);
    Hyperlink hyperlink = toolkit.createHyperlink(messagePage, Messages.subscribeLinkLabel, SWT.NONE);
    toolkit.createLabel(messagePage, Messages.notificationsLabel);
    hyperlink.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        public void linkActivated(HyperlinkEvent e) {
            subscribeAction.run();
        }
    });
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) Composite(org.eclipse.swt.widgets.Composite) FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) Hyperlink(org.eclipse.ui.forms.widgets.Hyperlink) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter)

Example 19 with Hyperlink

use of org.eclipse.ui.forms.widgets.Hyperlink in project tmdm-studio-se by Talend.

the class StoredProcedureMainPage method createCharacteristicsContent.

@Override
protected void createCharacteristicsContent(FormToolkit toolkit, Composite charComposite) {
    try {
        WSStoredProcedure wsStoredProcedure = (WSStoredProcedure) (getXObject().getWsObject());
        // description
        Label descriptionLabel = toolkit.createLabel(charComposite, Messages.StoredProcedureMainPage_4, SWT.NULL);
        descriptionLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false, 1, 1));
        // $NON-NLS-1$
        descriptionText = toolkit.createText(charComposite, "", SWT.BORDER);
        descriptionText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
        // $NON-NLS-1$
        descriptionText.setText(wsStoredProcedure.getDescription() == null ? "" : wsStoredProcedure.getDescription());
        descriptionText.addModifyListener(this);
        // Procedure
        Group storedProcedureGroup = new Group(charComposite, SWT.SHADOW_NONE);
        storedProcedureGroup.setText(Messages.StoredProcedureMainPage_5);
        storedProcedureGroup.setLayout(new GridLayout(1, true));
        storedProcedureGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
        ((GridData) storedProcedureGroup.getLayoutData()).minimumHeight = 100;
        procedureViewer = new SourceViewer(storedProcedureGroup, new VerticalRuler(10), SWT.V_SCROLL);
        procedureViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
        procedureViewer.addTextListener(this);
        WidgetUtils.initRedoUndo(procedureViewer);
        refreshCacheBtn = toolkit.createButton(charComposite, Messages.StoredProcedureMainPage_6, SWT.CHECK);
        refreshCacheBtn.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
        refreshCacheBtn.addSelectionListener(new SelectionListener() {

            public void widgetSelected(SelectionEvent e) {
                markDirty();
            }

            public void widgetDefaultSelected(SelectionEvent e) {
                markDirty();
            }
        });
        /**
         **********************************************************
         * Execute Stored Procedure
         ***********************************************************
         */
        createCompDropTarget();
        Composite resultsGroup = this.getNewSectionComposite(Messages.StoredProcedureMainPage_7);
        resultsGroup.setLayout(new GridLayout(4, false));
        // data cluster
        Hyperlink dataClusterLink = toolkit.createHyperlink(resultsGroup, Messages.StoredProcedureMainPage_8, SWT.NULL);
        dataClusterLink.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true, 1, 1));
        dataClusterLink.addHyperlinkListener(new IHyperlinkListener() {

            public void linkEntered(org.eclipse.ui.forms.events.HyperlinkEvent e) {
            }

            public void linkExited(org.eclipse.ui.forms.events.HyperlinkEvent e) {
            }

            public void linkActivated(org.eclipse.ui.forms.events.HyperlinkEvent e) {
                if (!isLocalInput()) {
                    TreeParent serverRoot = StoredProcedureMainPage.this.getXObject().getServerRoot();
                    TreeObject iaObject = new TreeObject(StoredProcedureMainPage.this.dataClusterCombo.getText(), serverRoot, TreeObject.DATA_CLUSTER, new WSDataClusterPK(StoredProcedureMainPage.this.dataClusterCombo.getText()), null);
                    (new EditXObjectAction(iaObject, StoredProcedureMainPage.this.getSite().getPage())).run();
                }
            }
        });
        dataClusterCombo = new Combo(resultsGroup, SWT.READ_ONLY | SWT.DROP_DOWN | SWT.SINGLE);
        dataClusterCombo.setLayoutData(new GridData(SWT.BEGINNING, SWT.NONE, false, false, 1, 1));
        Button executeButton = new Button(resultsGroup, SWT.PUSH);
        executeButton.setText(Messages.StoredProcedureMainPage_9);
        executeButton.addMouseListener(new MouseListener() {

            public void mouseUp(MouseEvent e) {
                executeProcedure();
            }

            public void mouseDoubleClick(MouseEvent e) {
            }

            public void mouseDown(MouseEvent e) {
            }
        });
        resultsLabel = toolkit.createLabel(resultsGroup, // $NON-NLS-1$
        "                                                                                                           ", SWT.NULL);
        resultsLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false, 1, 1));
        resultsViewer = new TableViewer(resultsGroup);
        resultsViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1));
        ((GridData) resultsViewer.getControl().getLayoutData()).heightHint = 300;
        resultsViewer.setContentProvider(new ArrayContentProvider());
        resultsViewer.setLabelProvider(new XMLTableLabelProvider());
        resultsViewer.addDoubleClickListener(new IDoubleClickListener() {

            public void doubleClick(DoubleClickEvent event) {
                resultsViewer.setSelection(event.getSelection());
                new ResultsViewAction(StoredProcedureMainPage.this.getSite().getShell(), resultsViewer).run();
            }
        });
        hookContextMenu();
        refreshData();
        dataClusterCombo.select(0);
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
}
Also used : Group(org.eclipse.swt.widgets.Group) SourceViewer(org.eclipse.jface.text.source.SourceViewer) TreeParent(com.amalto.workbench.models.TreeParent) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) GridLayout(org.eclipse.swt.layout.GridLayout) WSDataClusterPK(com.amalto.workbench.webservices.WSDataClusterPK) MouseListener(org.eclipse.swt.events.MouseListener) Button(org.eclipse.swt.widgets.Button) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IHyperlinkListener(org.eclipse.ui.forms.events.IHyperlinkListener) WSStoredProcedure(com.amalto.workbench.webservices.WSStoredProcedure) VerticalRuler(org.eclipse.jface.text.source.VerticalRuler) MouseEvent(org.eclipse.swt.events.MouseEvent) Composite(org.eclipse.swt.widgets.Composite) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) EditXObjectAction(com.amalto.workbench.actions.EditXObjectAction) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) TreeObject(com.amalto.workbench.models.TreeObject) TableViewer(org.eclipse.jface.viewers.TableViewer) SelectionListener(org.eclipse.swt.events.SelectionListener) Hyperlink(org.eclipse.ui.forms.widgets.Hyperlink)

Example 20 with Hyperlink

use of org.eclipse.ui.forms.widgets.Hyperlink in project eclipse-integration-commons by spring-projects.

the class DashboardExtensionsPage method createFormContent.

@Override
protected void createFormContent(final IManagedForm managedForm) {
    Composite body = managedForm.getForm().getBody();
    body.setLayout(new GridLayout(5, false));
    discoveryViewer = new DashboardDiscoveryViewer(getSite(), this);
    initialize(discoveryViewer);
    discoveryViewer.setDirectoryUrl(ResourceProvider.getUrl(RESOURCE_DISCOVERY_DIRECTORY).replace("%VERSION%", IdeUiUtils.getShortVersion()));
    discoveryViewer.setShowConnectorDescriptorKindFilter(false);
    discoveryViewer.createControl(body);
    FormToolkit toolkit = managedForm.getToolkit();
    adaptRecursively(discoveryViewer.getControl(), toolkit);
    GridDataFactory.fillDefaults().span(5, 1).grab(true, true).applyTo(discoveryViewer.getControl());
    findUpdatesButton = toolkit.createButton(body, "&Find Updates", SWT.NONE);
    findUpdatesButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent event) {
            IHandlerService handlerService = (IHandlerService) getSite().getService(IHandlerService.class);
            try {
                handlerService.executeCommand("org.eclipse.equinox.p2.ui.sdk.update", new Event());
            } catch (Exception e) {
                StatusManager.getManager().handle(new Status(IStatus.ERROR, IdeUiPlugin.PLUGIN_ID, "Find updates failed with an unexpected error.", e), StatusManager.SHOW | StatusManager.LOG);
            }
        }
    });
    Hyperlink configureLink = toolkit.createHyperlink(body, "Configure Extensions...", SWT.NONE);
    configureLink.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        public void linkActivated(HyperlinkEvent event) {
            PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(getSite().getShell(), ID_PREFERENCE_PAGE, new String[] { ID_PREFERENCE_PAGE }, null);
            dialog.open();
        }
    });
    progressMonitorPart = new ProgressMonitorPart(body, null);
    monitor.attach(progressMonitorPart);
    progressMonitorPart.addDisposeListener(new DisposeListener() {

        public void widgetDisposed(DisposeEvent e) {
            monitor.setCanceled(true);
            monitor.detach(progressMonitorPart);
        }
    });
    adaptRecursively(progressMonitorPart, toolkit);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(progressMonitorPart);
    // Button refreshButton = toolkit.createButton(body, "Refresh",
    // SWT.NONE);
    // refreshButton.addSelectionListener(new SelectionAdapter() {
    // @Override
    // public void widgetSelected(SelectionEvent e) {
    // pane.updateDiscovery();
    // }
    // });
    cancelButton = toolkit.createButton(body, "&Cancel", SWT.NONE);
    cancelButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            cancelButton.setEnabled(false);
            progressMonitorPart.setCanceled(true);
        }
    });
    installButton = toolkit.createButton(body, "&Install", SWT.NONE);
    installButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            // check for conflicts
            List<ConnectorDescriptor> selection = discoveryViewer.getInstallableConnectors();
            IStatus conflictStatus = new MultiStatus(IdeUiPlugin.PLUGIN_ID, -1, new IStatus[] { checkForConflicts(SVN_FEATURES, " Please select only one SVN team provider.", selection), checkForConflicts(M2E_EXTENSION_IDS, " Please select only one m2e version to install.", selection) }, "Could not perform install due to conflicts.", null);
            if (!conflictStatus.isOK()) {
                StatusManager.getManager().handle(conflictStatus, StatusManager.SHOW | StatusManager.BLOCK);
                return;
            }
            // now, if m2e is going to be installed, ensure that all other
            // versions of m2e are uninstalled first.
            Set<String> featuresToUninstall = chooseUnwantedFeatures(selection);
            if (!featuresToUninstall.isEmpty()) {
                IStatus uninstallResult = uninstallFeatures(featuresToUninstall);
                if (!uninstallResult.isOK()) {
                    if (uninstallResult.getSeverity() != IStatus.CANCEL) {
                        StatusManager.getManager().handle(uninstallResult, StatusManager.SHOW | StatusManager.LOG | StatusManager.BLOCK);
                    }
                    return;
                }
            }
            DiscoveryUi.install(discoveryViewer.getInstallableConnectors(), DashboardExtensionsPage.this);
        }

        private IStatus uninstallFeatures(final Set<String> featuresToUninstall) {
            String allInstalled = findFeaturesToUninstall(featuresToUninstall, discoveryViewer.getInstalledFeatures());
            if (allInstalled.length() == 0) {
                return Status.OK_STATUS;
            }
            boolean res = MessageDialog.openQuestion(getPartControl().getShell(), "Perform uninstall?", "In order to switch versions of m2eclipse, the following features will be uninstalled:\n" + allInstalled + "Do you want to continue?");
            if (!res) {
                return Status.CANCEL_STATUS;
            }
            // uninstall previous Maven tooling
            AbstractInstallJob job = DiscoveryUi.createInstallJob();
            try {
                return job.uninstall(new UninstallRequest() {

                    /**
                     * Uninstall all features that are somehow related to
                     * m2eclipse
                     */
                    @Override
                    public boolean select(InstalledItem item) {
                        String featureId = item.getId();
                        return isRelatedToM2e(featuresToUninstall, featureId);
                    }
                }, new NullProgressMonitor());
            } catch (Exception e) {
                return new Status(IStatus.ERROR, IdeUiPlugin.PLUGIN_ID, NLS.bind("Could not uninstall features:\n{0},\n try uninstalling manually.", featuresToUninstall), e);
            }
        }

        private String findFeaturesToUninstall(Set<String> featuresToUninstall, Set<String> installedFeatures) {
            StringBuilder sb = new StringBuilder();
            for (String featureId : installedFeatures) {
                if (isRelatedToM2e(featuresToUninstall, featureId)) {
                    if (featureId.endsWith(".feature.group")) {
                        featureId = featureId.substring(0, featureId.length() - ".feature.group".length());
                    }
                    sb.append("   " + featureId + "\n");
                }
            }
            return sb.toString();
        }

        private Set<String> chooseUnwantedFeatures(List<ConnectorDescriptor> selection) {
            boolean uninstallOld = false;
            boolean uninstallNew = false;
            for (ConnectorDescriptor feature : selection) {
                // first and vice versa
                if (feature.getId().equals(NEW_M2E_EXTENSION_ID)) {
                    uninstallOld = true;
                } else if (feature.getId().equals(OLD_M2E_EXTENSION_ID)) {
                    uninstallNew = true;
                }
            }
            Set<String> maybeUninstall;
            if (uninstallOld) {
                maybeUninstall = OLD_M2E_FEATURES;
            } else if (uninstallNew) {
                maybeUninstall = NEW_M2E_FEATURES;
            } else {
                maybeUninstall = Collections.emptySet();
            }
            Set<String> installedFeatures = DashboardExtensionsPage.this.discoveryViewer.getInstalledFeatures();
            Set<String> definitelyUninstall = new HashSet<String>();
            for (String feature : maybeUninstall) {
                if (installedFeatures.contains(feature)) {
                    definitelyUninstall.add(feature);
                }
            }
            if (definitelyUninstall.size() > 0) {
                IdeUiPlugin.log(new Status(IStatus.INFO, IdeUiPlugin.PLUGIN_ID, "To make way for a new version of m2eclipse, we will uninstall these features: " + definitelyUninstall));
            }
            return definitelyUninstall;
        }

        /**
         * This method checks for conflicts with requested installs. If a
         * conflict is found, this method will pop up a dialog explaining
         * the conflict and it will return true.
         * @param featuresToCheck set of features of which only one can be
         * installed at once.
         * @param message message to add if there is an error
         * @param selection
         *
         * @return true iff there is a conflict.
         */
        public IStatus checkForConflicts(Set<String> featuresToCheck, String prependedMessage, List<ConnectorDescriptor> selection) {
            StringBuilder message = new StringBuilder();
            List<ConnectorDescriptor> conflicting = new ArrayList<ConnectorDescriptor>();
            for (ConnectorDescriptor descriptor : selection) {
                if (featuresToCheck.contains(descriptor.getId())) {
                    conflicting.add(descriptor);
                    if (message.length() > 0) {
                        message.append(", ");
                    }
                    message.append(descriptor.getName());
                }
            }
            if (conflicting.size() > 1) {
                return new Status(IStatus.WARNING, IdeUiPlugin.PLUGIN_ID, NLS.bind("The following extensions can not be installed at the same time: {0}.", message.toString()));
            } else {
                return Status.OK_STATUS;
            }
        }
    });
    Display.getCurrent().asyncExec(new Runnable() {

        public void run() {
            if (!managedForm.getForm().isDisposed()) {
                discoveryViewer.updateDiscovery();
            }
        }
    });
    discoveryViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            installButton.setEnabled(discoveryViewer.isComplete());
        }
    });
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IStatus(org.eclipse.core.runtime.IStatus) HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) Set(java.util.Set) HashSet(java.util.HashSet) FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) MultiStatus(org.eclipse.core.runtime.MultiStatus) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) DisposeEvent(org.eclipse.swt.events.DisposeEvent) InstalledItem(org.eclipse.mylyn.internal.discovery.ui.InstalledItem) UninstallRequest(org.eclipse.mylyn.internal.discovery.ui.UninstallRequest) GridLayout(org.eclipse.swt.layout.GridLayout) PreferenceDialog(org.eclipse.jface.preference.PreferenceDialog) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ProgressMonitorPart(org.eclipse.jface.wizard.ProgressMonitorPart) List(java.util.List) ArrayList(java.util.ArrayList) MultiStatus(org.eclipse.core.runtime.MultiStatus) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) InvocationTargetException(java.lang.reflect.InvocationTargetException) ConnectorDescriptor(org.eclipse.mylyn.internal.discovery.core.model.ConnectorDescriptor) IHandlerService(org.eclipse.ui.handlers.IHandlerService) DisposeEvent(org.eclipse.swt.events.DisposeEvent) HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent) AbstractInstallJob(org.eclipse.mylyn.internal.discovery.ui.AbstractInstallJob) Hyperlink(org.eclipse.ui.forms.widgets.Hyperlink) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter)

Aggregations

Hyperlink (org.eclipse.ui.forms.widgets.Hyperlink)28 HyperlinkEvent (org.eclipse.ui.forms.events.HyperlinkEvent)18 Composite (org.eclipse.swt.widgets.Composite)17 HyperlinkAdapter (org.eclipse.ui.forms.events.HyperlinkAdapter)16 GridLayout (org.eclipse.swt.layout.GridLayout)12 GridData (org.eclipse.swt.layout.GridData)11 Label (org.eclipse.swt.widgets.Label)8 FormToolkit (org.eclipse.ui.forms.widgets.FormToolkit)7 IStatus (org.eclipse.core.runtime.IStatus)6 Status (org.eclipse.core.runtime.Status)6 SelectionEvent (org.eclipse.swt.events.SelectionEvent)6 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)5 ArrayList (java.util.ArrayList)4 EntityNameCombo (org.eclipse.jpt.jpa.ui.internal.details.EntityNameCombo)4 IdClassChooser (org.eclipse.jpt.jpa.ui.internal.details.IdClassChooser)4 HibernateTableComposite (org.jboss.tools.hibernate.jpt.ui.internal.details.HibernateTableComposite)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 AccessTypeComboViewer (org.eclipse.jpt.jpa.ui.internal.details.AccessTypeComboViewer)3 PartInitException (org.eclipse.ui.PartInitException)3 ExpandableComposite (org.eclipse.ui.forms.widgets.ExpandableComposite)3