Search in sources :

Example 96 with WizardDialog

use of org.eclipse.jface.wizard.WizardDialog in project bndtools by bndtools.

the class RunRequirementsPart method doResolve.

private void doResolve() {
    // Make sure all the parts of this editor page have committed their
    // dirty state to the model
    IFormPart[] parts = getManagedForm().getParts();
    for (IFormPart part : parts) {
        if (part.isDirty())
            part.commit(false);
    }
    final IFormPage page = (IFormPage) getManagedForm().getContainer();
    final IEditorInput input = page.getEditorInput();
    final IEditorPart editor = page.getEditor();
    final IFile file = ResourceUtil.getFile(input);
    final Shell parentShell = page.getEditor().getSite().getShell();
    // Create the wizard and pre-validate
    final ResolveJob job = new ResolveJob(model);
    IStatus validation = job.validateBeforeRun();
    if (!validation.isOK()) {
        ErrorDialog errorDialog = new ErrorDialog(parentShell, "Validation Problem", null, validation, IStatus.ERROR | IStatus.WARNING) {

            @Override
            protected void createButtonsForButtonBar(Composite parent) {
                // create OK, Cancel and Details buttons
                createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false);
                createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, true);
                createDetailsButton(parent);
            }
        };
        int response = errorDialog.open();
        if (Window.CANCEL == response || validation.getSeverity() >= IStatus.ERROR) {
            btnResolveNow.setEnabled(true);
            return;
        }
    }
    // Add the operation to perform at the end of the resolution job (i.e.,
    // showing the result)
    final Runnable showResult = new Runnable() {

        @Override
        public void run() {
            ResolutionWizard wizard = new ResolutionWizard(model, file, job.getResolutionResult());
            WizardDialog dialog = new WizardDialog(parentShell, wizard);
            boolean dirtyBeforeResolve = editor.isDirty();
            if (dialog.open() == Dialog.OK && !dirtyBeforeResolve) {
                // only save the editor, when no unsaved changes happened before resolution
                editor.getEditorSite().getPage().saveEditor(editor, false);
            }
            btnResolveNow.setEnabled(true);
        }
    };
    job.addJobChangeListener(new JobChangeAdapter() {

        @Override
        public void done(IJobChangeEvent event) {
            Outcome outcome = job.getResolutionResult().getOutcome();
            if (outcome != Outcome.Cancelled)
                parentShell.getDisplay().asyncExec(showResult);
        }
    });
    job.setUser(true);
    job.schedule();
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) IFile(org.eclipse.core.resources.IFile) Composite(org.eclipse.swt.widgets.Composite) ResolutionWizard(org.bndtools.core.resolve.ui.ResolutionWizard) JobChangeAdapter(org.eclipse.core.runtime.jobs.JobChangeAdapter) ErrorDialog(org.eclipse.jface.dialogs.ErrorDialog) IFormPage(org.eclipse.ui.forms.editor.IFormPage) IEditorPart(org.eclipse.ui.IEditorPart) ResolveJob(org.bndtools.core.resolve.ResolveJob) IJobChangeEvent(org.eclipse.core.runtime.jobs.IJobChangeEvent) Shell(org.eclipse.swt.widgets.Shell) Outcome(org.bndtools.core.resolve.ResolutionResult.Outcome) IFormPart(org.eclipse.ui.forms.IFormPart) WizardDialog(org.eclipse.jface.wizard.WizardDialog) IEditorInput(org.eclipse.ui.IEditorInput)

Example 97 with WizardDialog

use of org.eclipse.jface.wizard.WizardDialog in project bndtools by bndtools.

the class RunRequirementsPart method doAddBundle.

private void doAddBundle() {
    try {
        RepoBundleSelectionWizard wizard = new RepoBundleSelectionWizard(new ArrayList<VersionedClause>(), DependencyPhase.Run);
        wizard.setSelectionPageTitle("Add Bundle Requirement");
        WizardDialog dialog = new WizardDialog(getSection().getShell(), wizard);
        if (Window.OK == dialog.open()) {
            List<VersionedClause> result = wizard.getSelectedBundles();
            Set<Requirement> adding = new LinkedHashSet<Requirement>(result.size());
            for (VersionedClause bundle : result) {
                Filter filter = new SimpleFilter(IdentityNamespace.IDENTITY_NAMESPACE, bundle.getName());
                String versionRange = bundle.getVersionRange();
                if (versionRange != null && !"latest".equals(versionRange)) {
                    filter = new AndFilter().addChild(filter).addChild(new LiteralFilter(Filters.fromVersionRange(versionRange)));
                }
                Requirement req = new CapReqBuilder(IdentityNamespace.IDENTITY_NAMESPACE).addDirective(Namespace.REQUIREMENT_FILTER_DIRECTIVE, filter.toString()).buildSyntheticRequirement();
                adding.add(req);
            }
            updateViewerWithNewRequirements(adding);
        }
    } catch (Exception e) {
        ErrorDialog.openError(getSection().getShell(), "Error", null, new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Error selecting bundles.", e));
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) CapReqBuilder(aQute.bnd.osgi.resource.CapReqBuilder) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) VersionedClause(aQute.bnd.build.model.clauses.VersionedClause) RepoBundleSelectionWizard(bndtools.wizards.repo.RepoBundleSelectionWizard) LiteralFilter(aQute.libg.filters.LiteralFilter) Requirement(org.osgi.resource.Requirement) AndFilter(aQute.libg.filters.AndFilter) SimpleFilter(aQute.libg.filters.SimpleFilter) AndFilter(aQute.libg.filters.AndFilter) Filter(aQute.libg.filters.Filter) LiteralFilter(aQute.libg.filters.LiteralFilter) SimpleFilter(aQute.libg.filters.SimpleFilter) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Example 98 with WizardDialog

use of org.eclipse.jface.wizard.WizardDialog in project bndtools by bndtools.

the class RunBlacklistPart method doAddBundle.

private void doAddBundle() {
    try {
        RepoBundleSelectionWizard wizard = new RepoBundleSelectionWizard(new ArrayList<VersionedClause>(), DependencyPhase.Run);
        wizard.setSelectionPageTitle("Add Bundle Blacklist");
        WizardDialog dialog = new WizardDialog(getSection().getShell(), wizard);
        if (Window.OK == dialog.open()) {
            List<VersionedClause> result = wizard.getSelectedBundles();
            Set<Requirement> adding = new LinkedHashSet<Requirement>(result.size());
            for (VersionedClause bundle : result) {
                Filter filter = new SimpleFilter(IdentityNamespace.IDENTITY_NAMESPACE, bundle.getName());
                String versionRange = bundle.getVersionRange();
                if (versionRange != null && !"latest".equals(versionRange)) {
                    filter = new AndFilter().addChild(filter).addChild(new LiteralFilter(Filters.fromVersionRange(versionRange)));
                }
                Requirement req = new CapReqBuilder(IdentityNamespace.IDENTITY_NAMESPACE).addDirective(Namespace.REQUIREMENT_FILTER_DIRECTIVE, filter.toString()).buildSyntheticRequirement();
                adding.add(req);
            }
            updateViewerWithNewBlacklist(adding);
        }
    } catch (Exception e) {
        ErrorDialog.openError(getSection().getShell(), "Error", null, new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Error selecting bundles for blacklist.", e));
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) CapReqBuilder(aQute.bnd.osgi.resource.CapReqBuilder) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) VersionedClause(aQute.bnd.build.model.clauses.VersionedClause) RepoBundleSelectionWizard(bndtools.wizards.repo.RepoBundleSelectionWizard) LiteralFilter(aQute.libg.filters.LiteralFilter) Requirement(org.osgi.resource.Requirement) AndFilter(aQute.libg.filters.AndFilter) SimpleFilter(aQute.libg.filters.SimpleFilter) AndFilter(aQute.libg.filters.AndFilter) Filter(aQute.libg.filters.Filter) LiteralFilter(aQute.libg.filters.LiteralFilter) SimpleFilter(aQute.libg.filters.SimpleFilter) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Example 99 with WizardDialog

use of org.eclipse.jface.wizard.WizardDialog in project bndtools by bndtools.

the class MissingWorkspaceMarkerResolutionGenerator method getResolutions.

@Override
public IMarkerResolution[] getResolutions(IMarker marker) {
    return new IMarkerResolution[] { new IMarkerResolution() {

        @Override
        public void run(IMarker marker) {
            IWorkbench workbench = PlatformUI.getWorkbench();
            IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
            WorkspaceSetupWizard wizard = new WorkspaceSetupWizard();
            wizard.init(workbench, StructuredSelection.EMPTY);
            WizardDialog dialog = new WizardDialog(window.getShell(), wizard);
            dialog.open();
        }

        @Override
        public String getLabel() {
            return "Open 'New Bnd OSGi Workspace' Wizard";
        }
    } };
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IMarkerResolution(org.eclipse.ui.IMarkerResolution) IMarker(org.eclipse.core.resources.IMarker) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Example 100 with WizardDialog

use of org.eclipse.jface.wizard.WizardDialog in project bndtools by bndtools.

the class ProjectTemplateSelectionWizardPage method createHeaderControl.

@Override
protected Control createHeaderControl(Composite parent) {
    Composite composite;
    Workspace workspace = Central.getWorkspaceIfPresent();
    if (workspace == null || workspace.isDefaultWorkspace()) {
        composite = new Composite(parent, SWT.NONE);
        GridLayout layout = new GridLayout(2, false);
        layout.marginWidth = 0;
        layout.marginHeight = 0;
        layout.marginBottom = 15;
        layout.verticalSpacing = 15;
        composite.setLayout(layout);
        Label lblWarning = new Label(composite, SWT.NONE);
        warningImg = Icons.desc("warning.big").createImage(parent.getDisplay());
        lblWarning.setImage(warningImg);
        Link link = new Link(composite, SWT.NONE);
        link.setText("WARNING! The bnd workspace has not been configured. <a href=\"#workspace\">Create a workspace first</a> \n or configure a <a href=\"#prefs\">Template Repository</a> in Bndtools Preferences.");
        link.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent ev) {
                WizardDialog dialog = (WizardDialog) getContainer();
                dialog.close();
                if ("#workspace".equals(ev.text)) {
                    // We are going to open the New Workspace wizard in a new dialog.
                    // If that wizard completes successfully then we can reopen the New Project wizard.
                    WorkspaceSetupWizard workspaceWizard = new WorkspaceSetupWizard();
                    workspaceWizard.init(PlatformUI.getWorkbench(), StructuredSelection.EMPTY);
                    dialog = new WizardDialog(dialog.getShell(), workspaceWizard);
                    if (Window.OK == dialog.open()) {
                        try {
                            NewBndProjectWizard projectWizard = new NewBndProjectWizardFactory().create();
                            projectWizard.init(PlatformUI.getWorkbench(), StructuredSelection.EMPTY);
                            new WizardDialog(dialog.getShell(), projectWizard).open();
                        } catch (CoreException e) {
                            Plugin.getDefault().getLog().log(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Unable to open New Bnd Project wizard", e));
                        }
                    }
                } else if ("#prefs".equals(ev.text)) {
                    // Open the preference dialog with the template repositories page open.
                    // We can't reopen the New Project wizard after because we don't know that the user changed anything.
                    PreferenceDialog prefsDialog = PreferencesUtil.createPreferenceDialogOn(getShell(), "bndtools.prefPages.repos", null, null);
                    prefsDialog.open();
                }
            }
        });
        GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
        link.setLayoutData(gd);
        //            ControlDecoration decor = new ControlDecoration(link, SWT.LEFT, composite);
        //            decor.setImage(FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_WARNING).getImage());
        Label separator = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
        separator.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
    } else {
        // There is a workspace, just return null (no controls will be inserted into the panel).
        composite = null;
    }
    return composite;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) WorkspaceSetupWizard(bndtools.wizards.workspace.WorkspaceSetupWizard) GridLayout(org.eclipse.swt.layout.GridLayout) CoreException(org.eclipse.core.runtime.CoreException) PreferenceDialog(org.eclipse.jface.preference.PreferenceDialog) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridData(org.eclipse.swt.layout.GridData) WizardDialog(org.eclipse.jface.wizard.WizardDialog) Link(org.eclipse.swt.widgets.Link) Workspace(aQute.bnd.build.Workspace)

Aggregations

WizardDialog (org.eclipse.jface.wizard.WizardDialog)115 ISelection (org.eclipse.jface.viewers.ISelection)26 Shell (org.eclipse.swt.widgets.Shell)26 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)25 IWorkbench (org.eclipse.ui.IWorkbench)14 IRepositoryNode (org.talend.repository.model.IRepositoryNode)13 RepositoryNode (org.talend.repository.model.RepositoryNode)13 IPath (org.eclipse.core.runtime.IPath)12 IStatus (org.eclipse.core.runtime.IStatus)10 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)10 IFile (org.eclipse.core.resources.IFile)9 Status (org.eclipse.core.runtime.Status)7 PartInitException (org.eclipse.ui.PartInitException)7 ArrayList (java.util.ArrayList)6 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)6 Composite (org.eclipse.swt.widgets.Composite)6 CoreException (org.eclipse.core.runtime.CoreException)5 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)5 File (java.io.File)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)4