Search in sources :

Example 1 with RunFrameworkPart

use of bndtools.editor.project.RunFrameworkPart in project bndtools by bndtools.

the class ProjectRunPage method createFormContent.

@Override
protected void createFormContent(IManagedForm managedForm) {
    managedForm.setInput(model);
    FormToolkit tk = managedForm.getToolkit();
    final ScrolledForm form = managedForm.getForm();
    form.setText("Resolve/Run");
    Central.onWorkspaceInit(new Success<Workspace, Void>() {

        @Override
        public Promise<Void> call(Promise<Workspace> resolved) throws Exception {
            final Deferred<Void> completion = new Deferred<>();
            Display.getDefault().asyncExec(new Runnable() {

                @Override
                public void run() {
                    try {
                        updateFormImage(form);
                        completion.resolve(null);
                    } catch (Exception e) {
                        completion.fail(e);
                    }
                }
            });
            return completion.getPromise();
        }
    });
    tk.decorateFormHeading(form.getForm());
    form.getForm().addMessageHyperlinkListener(new MessageHyperlinkAdapter(getEditor()));
    // Toolbar Actions
    RunAction runAction = new RunAction(this, "run");
    runAction.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Plugin.PLUGIN_ID, "icons/run.gif"));
    runAction.setText("Run OSGi");
    ActionContributionItem runContrib = new ActionContributionItem(runAction);
    runContrib.setMode(ActionContributionItem.MODE_FORCE_TEXT);
    form.getToolBarManager().add(runContrib);
    RunAction debugAction = new RunAction(this, "debug");
    debugAction.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Plugin.PLUGIN_ID, "icons/debug.gif"));
    debugAction.setText("Debug OSGi");
    ActionContributionItem debugContrib = new ActionContributionItem(debugAction);
    debugContrib.setMode(ActionContributionItem.MODE_FORCE_TEXT);
    form.getToolBarManager().add(debugContrib);
    ExportAction exportAction = new ExportAction(getEditorSite().getShell(), getEditor(), model);
    exportAction.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Plugin.PLUGIN_ID, "icons/run_export.png"));
    exportAction.setText("Export");
    ActionContributionItem exportContrib = new ActionContributionItem(exportAction);
    exportContrib.setMode(ActionContributionItem.MODE_FORCE_TEXT);
    if (exportAction.shouldEnable())
        form.getToolBarManager().add(exportContrib);
    form.getToolBarManager().update(true);
    GridLayout gl;
    GridData gd;
    // Create Controls
    final Composite body = form.getBody();
    MDSashForm sashForm = new MDSashForm(body, SWT.HORIZONTAL, managedForm);
    sashForm.setSashWidth(6);
    tk.adapt(sashForm);
    final Composite left = tk.createComposite(sashForm);
    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    left.setLayoutData(gd);
    gl = new GridLayout(1, true);
    left.setLayout(gl);
    final Composite right = tk.createComposite(sashForm);
    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    right.setLayoutData(gd);
    gl = new GridLayout(1, true);
    right.setLayout(gl);
    // First column
    RepositorySelectionPart reposPart = new RepositorySelectionPart(getEditor(), left, tk, Section.TITLE_BAR | Section.TWISTIE);
    managedForm.addPart(reposPart);
    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    gd.widthHint = 50;
    gd.heightHint = 50;
    reposPart.getSection().setLayoutData(PageLayoutUtils.createCollapsed());
    AvailableBundlesPart availableBundlesPart = new AvailableBundlesPart(left, tk, Section.TITLE_BAR | Section.EXPANDED);
    managedForm.addPart(availableBundlesPart);
    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    gd.widthHint = 50;
    gd.heightHint = 50;
    availableBundlesPart.getSection().setLayoutData(PageLayoutUtils.createExpanded());
    RunFrameworkPart runFwkPart = new RunFrameworkPart(left, tk, Section.TITLE_BAR | Section.TWISTIE | Section.EXPANDED);
    managedForm.addPart(runFwkPart);
    gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    runFwkPart.getSection().setLayoutData(gd);
    RunPropertiesPart runPropertiesPart = new RunPropertiesPart(left, tk, Section.TITLE_BAR | Section.TWISTIE);
    managedForm.addPart(runPropertiesPart);
    gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    runPropertiesPart.getSection().setLayoutData(gd);
    // SECOND COLUMN
    if (supportsResolve) {
        RunRequirementsPart requirementsPart = new RunRequirementsPart(right, tk, Section.TITLE_BAR | Section.TWISTIE | Section.EXPANDED | Section.DESCRIPTION);
        managedForm.addPart(requirementsPart);
        requirementsPart.getSection().setLayoutData(PageLayoutUtils.createExpanded());
        requirementsPart.getSection().addExpansionListener(new ResizeExpansionAdapter(requirementsPart.getSection()));
        RunBlacklistPart blacklistPart = new RunBlacklistPart(right, tk, Section.TITLE_BAR | Section.TWISTIE | Section.COMPACT | Section.DESCRIPTION);
        managedForm.addPart(blacklistPart);
        blacklistPart.getSection().setLayoutData(PageLayoutUtils.createCollapsed());
        blacklistPart.getSection().addExpansionListener(new ResizeExpansionAdapter(blacklistPart.getSection()));
        RunBundlesPart runBundlesPart = new RunBundlesPart(right, tk, Section.TITLE_BAR | Section.TWISTIE);
        managedForm.addPart(runBundlesPart);
        runBundlesPart.getSection().setLayoutData(PageLayoutUtils.createCollapsed());
        runBundlesPart.getSection().addExpansionListener(new ResizeExpansionAdapter(runBundlesPart.getSection()));
    } else {
        RunBundlesPart runBundlesPart = new RunBundlesPart(right, tk, Section.TITLE_BAR | Section.TWISTIE | Section.EXPANDED);
        managedForm.addPart(runBundlesPart);
        runBundlesPart.getSection().setLayoutData(PageLayoutUtils.createExpanded());
        runBundlesPart.getSection().addExpansionListener(new ResizeExpansionAdapter(runBundlesPart.getSection()));
    }
    // Listeners
    model.addPropertyChangeListener(BndEditModel.PROP_WORKSPACE, new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            Display.getDefault().asyncExec(new Runnable() {

                @Override
                public void run() {
                    updateFormImage(form);
                }
            });
        }
    });
    sashForm.setWeights(new int[] { 1, 1 });
    sashForm.hookResizeListener();
    body.setLayout(new FillLayout());
}
Also used : RunBundlesPart(bndtools.editor.project.RunBundlesPart) FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) RunPropertiesPart(bndtools.editor.project.RunPropertiesPart) PropertyChangeListener(java.beans.PropertyChangeListener) AvailableBundlesPart(bndtools.editor.project.AvailableBundlesPart) Deferred(org.osgi.util.promise.Deferred) ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) GridLayout(org.eclipse.swt.layout.GridLayout) RunFrameworkPart(bndtools.editor.project.RunFrameworkPart) PropertyChangeEvent(java.beans.PropertyChangeEvent) MessageHyperlinkAdapter(bndtools.utils.MessageHyperlinkAdapter) Composite(org.eclipse.swt.widgets.Composite) MDSashForm(bndtools.editor.common.MDSashForm) RunBlacklistPart(bndtools.editor.project.RunBlacklistPart) FillLayout(org.eclipse.swt.layout.FillLayout) Promise(org.osgi.util.promise.Promise) ScrolledForm(org.eclipse.ui.forms.widgets.ScrolledForm) GridData(org.eclipse.swt.layout.GridData) RepositorySelectionPart(bndtools.editor.project.RepositorySelectionPart) Workspace(aQute.bnd.build.Workspace) RunRequirementsPart(bndtools.editor.project.RunRequirementsPart)

Aggregations

Workspace (aQute.bnd.build.Workspace)1 MDSashForm (bndtools.editor.common.MDSashForm)1 AvailableBundlesPart (bndtools.editor.project.AvailableBundlesPart)1 RepositorySelectionPart (bndtools.editor.project.RepositorySelectionPart)1 RunBlacklistPart (bndtools.editor.project.RunBlacklistPart)1 RunBundlesPart (bndtools.editor.project.RunBundlesPart)1 RunFrameworkPart (bndtools.editor.project.RunFrameworkPart)1 RunPropertiesPart (bndtools.editor.project.RunPropertiesPart)1 RunRequirementsPart (bndtools.editor.project.RunRequirementsPart)1 MessageHyperlinkAdapter (bndtools.utils.MessageHyperlinkAdapter)1 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1 ActionContributionItem (org.eclipse.jface.action.ActionContributionItem)1 FillLayout (org.eclipse.swt.layout.FillLayout)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 FormToolkit (org.eclipse.ui.forms.widgets.FormToolkit)1 ScrolledForm (org.eclipse.ui.forms.widgets.ScrolledForm)1 Deferred (org.osgi.util.promise.Deferred)1