Search in sources :

Example 21 with IFormPage

use of org.eclipse.ui.forms.editor.IFormPage 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 22 with IFormPage

use of org.eclipse.ui.forms.editor.IFormPage in project bndtools by bndtools.

the class RunBundlesPart method initialize.

@Override
public void initialize(IManagedForm form) {
    super.initialize(form);
    IFormPage page = (IFormPage) form.getContainer();
    IFile file = ResourceUtil.getFile(page.getEditorInput());
    if (file != null) {
        if (Project.BNDFILE.equals(file.getName())) {
            loadBuilders(file.getProject());
        }
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) IFormPage(org.eclipse.ui.forms.editor.IFormPage)

Aggregations

IFormPage (org.eclipse.ui.forms.editor.IFormPage)22 IFile (org.eclipse.core.resources.IFile)12 LinkedList (java.util.LinkedList)3 IJavaProject (org.eclipse.jdt.core.IJavaProject)3 IJavaSearchScope (org.eclipse.jdt.core.search.IJavaSearchScope)3 IEditorInput (org.eclipse.ui.IEditorInput)3 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)3 IPackageFilter (bndtools.internal.pkgselection.IPackageFilter)2 JavaSearchScopePackageLister (bndtools.internal.pkgselection.JavaSearchScopePackageLister)2 PackageSelectionDialog (bndtools.internal.pkgselection.PackageSelectionDialog)2 HashSet (java.util.HashSet)2 IProject (org.eclipse.core.resources.IProject)2 IResource (org.eclipse.core.resources.IResource)2 ExportedPackage (aQute.bnd.build.model.clauses.ExportedPackage)1 Attrs (aQute.bnd.header.Attrs)1 IPriority (bndtools.editor.common.IPriority)1 ITestCaseFilter (bndtools.internal.testcaseselection.ITestCaseFilter)1 JavaSearchScopeTestCaseLister (bndtools.internal.testcaseselection.JavaSearchScopeTestCaseLister)1 TestCaseSelectionDialog (bndtools.internal.testcaseselection.TestCaseSelectionDialog)1 BndPreferences (bndtools.preferences.BndPreferences)1