Esempio n. 1
0
 private void handleConvert() {
   try {
     // remove listeners of Info section before we convert.  If we don't
     // we may get a model changed event while disposing the page.  Bug 156414
     fInfoSection.removeListeners();
     PDEFormEditor editor = getPDEEditor();
     IPluginModelBase model = (IPluginModelBase) editor.getAggregateModel();
     IRunnableWithProgress op = new CreateManifestOperation(model);
     IProgressService service = PlatformUI.getWorkbench().getProgressService();
     editor.doSave(null);
     service.runInUI(service, op, PDEPlugin.getWorkspace().getRoot());
     updateBuildProperties();
     editor.doSave(null);
   } catch (InvocationTargetException e) {
     MessageDialog.openError(
         PDEPlugin.getActiveWorkbenchShell(),
         PDEUIMessages.OverviewPage_error,
         e.getCause().getMessage());
     // if convert failed and this OverviewPage hasn't been removed from the editor, reattach
     // listeners
     if (!fDisposed) fInfoSection.addListeners();
   } catch (InterruptedException e) {
     // if convert failed and this OverviewPage hasn't been removed from the editor, reattach
     // listeners
     if (!fDisposed) fInfoSection.addListeners();
   }
 }
Esempio n. 2
0
  private void createContentSection(
      IManagedForm managedForm, Composite parent, FormToolkit toolkit) {
    String sectionTitle;
    //		if (isFragment()) {
    //			sectionTitle = PDEUIMessages.ManifestEditor_ContentSection_ftitle;
    //		} else {
    //			sectionTitle = PDEUIMessages.ManifestEditor_ContentSection_title;
    //		}
    sectionTitle = PDEUIMessages.MonitorEditor_ContentSection_title;

    Section section = createStaticSection(toolkit, parent, sectionTitle);

    Composite container = createStaticSectionClient(toolkit, section);

    FormText text =
        createClient(
            container,
            isFragment() ? PDEUIMessages.OverviewPage_fContent : PDEUIMessages.OverviewPage_content,
            toolkit);
    PDELabelProvider lp = PDEPlugin.getDefault().getLabelProvider();
    text.setImage(
        "page", lp.get(PDEPluginImages.DESC_PAGE_OBJ, SharedLabelProvider.F_EDIT)); // $NON-NLS-1$

    if (!isBundle() && isEditable()) {
      String content;
      if (isFragment()) {
        content = PDEUIMessages.OverviewPage_fOsgi;
      } else {
        content = PDEUIMessages.OverviewPage_osgi;
      }
      text = createClient(container, content, toolkit);
    }
    section.setClient(container);
  }
Esempio n. 3
0
 protected void createFormContent(IManagedForm managedForm) {
   super.createFormContent(managedForm);
   ScrolledForm form = managedForm.getForm();
   FormToolkit toolkit = managedForm.getToolkit();
   if (isFragment()) {
     form.setImage(
         PDEPlugin.getDefault().getLabelProvider().get(PDEPluginImages.DESC_FRAGMENT_MF_OBJ));
   } else {
     form.setImage(
         PDEPlugin.getDefault().getLabelProvider().get(PDEPluginImages.DESC_PLUGIN_MF_OBJ));
   }
   form.setText(PDEUIMessages.MonitorEditor_OverviewPage_title);
   fillBody(managedForm, toolkit);
   PlatformUI.getWorkbench()
       .getHelpSystem()
       .setHelp(form.getBody(), IHelpContextIds.MONITOR_PLUGIN_OVERVIEW);
 }
Esempio n. 4
0
 protected void createFormContent(final IManagedForm managedForm) {
   super.createFormContent(managedForm);
   ScrolledForm form = managedForm.getForm();
   FormToolkit toolkit = managedForm.getToolkit();
   form.setText(PDEUIMessages.OverviewPage_title);
   PDELabelProvider labelProvider = PDEPlugin.getDefault().getLabelProvider();
   ImageDescriptor description = PDEPluginImages.DESC_PRODUCT_DEFINITION;
   form.setImage(labelProvider.get(description));
   fillBody(managedForm, toolkit);
   IWorkbenchHelpSystem helpSystem = PlatformUI.getWorkbench().getHelpSystem();
   String contextId = WARProductConstants.HELP_CONTEXT_OVERVIEW_PAGE;
   helpSystem.setHelp(form.getBody(), contextId);
 }
Esempio n. 5
0
 /*
  * (non-Javadoc)
  *
  * @see org.eclipse.ui.forms.events.HyperlinkListener#linkActivated(org.eclipse.ui.forms.events.HyperlinkEvent)
  */
 public void linkActivated(HyperlinkEvent e) {
   String href = (String) e.getHref();
   // try page references
   if (href.equals("dependencies")) // $NON-NLS-1$
   getEditor().setActivePage(DependenciesPage.PAGE_ID);
   else if (href.equals("runtime")) // $NON-NLS-1$
   getEditor().setActivePage(RuntimePage.PAGE_ID);
   else if (href.equals("extensions")) { // $NON-NLS-1$
     if (getEditor().setActivePage(ExtensionsPage.PAGE_ID) == null)
       activateExtensionPages(ExtensionsPage.PAGE_ID);
   } else if (href.equals("ex-points")) { // $NON-NLS-1$
     if (getEditor().setActivePage(ExtensionPointsPage.PAGE_ID) == null)
       activateExtensionPages(ExtensionPointsPage.PAGE_ID);
   } else if (href.equals("build")) { // $NON-NLS-1$
     if (!getPDEEditor().hasInputContext(BuildInputContext.CONTEXT_ID)) {
       if (!MessageDialog.openQuestion(
           PDEPlugin.getActiveWorkbenchShell(),
           PDEUIMessages.OverviewPage_buildTitle,
           PDEUIMessages.OverviewPage_buildQuestion)) return;
       IFile file = PDEProject.getBuildProperties(getPDEEditor().getCommonProject());
       WorkspaceBuildModel model = new WorkspaceBuildModel(file);
       model.save();
       IEditorInput in = new FileEditorInput(file);
       getPDEEditor()
           .getContextManager()
           .putContext(in, new BuildInputContext(getPDEEditor(), in, false));
     }
     getEditor().setActivePage(BuildPage.PAGE_ID);
   } else if (href.equals("export")) { // $NON-NLS-1$
     getExportAction().run();
   } else if (href.equals("action.convert")) { // $NON-NLS-1$
     handleConvert();
   } else if (href.equals("organize")) { // $NON-NLS-1$
     getEditor().doSave(null);
     OrganizeManifestsAction organizeAction = new OrganizeManifestsAction();
     organizeAction.selectionChanged(
         null, new StructuredSelection(getPDEEditor().getCommonProject()));
     organizeAction.run(null);
   } else if (href.equals("externalize")) { // $NON-NLS-1$
     getEditor().doSave(null);
     GetNonExternalizedStringsAction externalizeAction = new GetNonExternalizedStringsAction();
     externalizeAction.selectionChanged(
         null, new StructuredSelection(getPDEEditor().getCommonProject()));
     externalizeAction.run(null);
   } else super.linkActivated(e);
 }
  private void openSchemaFile(final IFile file) {
    final IWorkbenchWindow ww = PDEPlugin.getActiveWorkbenchWindow();

    Display d = ww.getShell().getDisplay();
    d.asyncExec(
        new Runnable() {
          @Override
          public void run() {
            try {
              String editorId = IPDEUIConstants.SCHEMA_EDITOR_ID;
              ww.getActivePage().openEditor(new FileEditorInput(file), editorId);
            } catch (PartInitException e) {
              PDEPlugin.logException(e);
            }
          }
        });
  }
Esempio n. 7
0
 private void activateExtensionPages(String activePageId) {
   MessageDialog mdiag =
       new MessageDialog(
           PDEPlugin.getActiveWorkbenchShell(),
           PDEUIMessages.OverviewPage_extensionPageMessageTitle,
           null,
           PDEUIMessages.OverviewPage_extensionPageMessageBody,
           MessageDialog.QUESTION,
           new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL},
           0);
   if (mdiag.open() != Window.OK) return;
   try {
     MonitorEditor manifestEditor = (MonitorEditor) getEditor();
     manifestEditor.addExtensionTabs();
     manifestEditor.setShowExtensions(true);
     manifestEditor.setActivePage(activePageId);
   } catch (PartInitException e) {
   } catch (BackingStoreException e) {
   }
 }
Esempio n. 8
0
  private void createExtensionSection(
      IManagedForm managedForm, Composite parent, FormToolkit toolkit) {
    String sectionTitle = PDEUIMessages.ManifestEditor_ExtensionSection_title;
    Section section = createStaticSection(toolkit, parent, sectionTitle);

    Composite container = createStaticSectionClient(toolkit, section);

    FormText text =
        createClient(
            container,
            isFragment()
                ? PDEUIMessages.OverviewPage_fExtensionContent
                : PDEUIMessages.OverviewPage_extensionContent,
            toolkit);
    PDELabelProvider lp = PDEPlugin.getDefault().getLabelProvider();
    text.setImage(
        "page", lp.get(PDEPluginImages.DESC_PAGE_OBJ, SharedLabelProvider.F_EDIT)); // $NON-NLS-1$

    section.setClient(container);
  }
Esempio n. 9
0
  private void createTestingSection(
      IManagedForm managedForm, Composite parent, FormToolkit toolkit) {
    Section section =
        createStaticSection(toolkit, parent, PDEUIMessages.ManifestEditor_TestingSection_title);
    PDELabelProvider lp = PDEPlugin.getDefault().getLabelProvider();

    Composite container = createStaticSectionClient(toolkit, section);

    String prefixText =
        (!((MonitorEditor) getEditor()).showExtensionTabs())
            ? PDEUIMessages.OverviewPage_OSGiTesting
            : isFragment()
                ? PDEUIMessages.OverviewPage_fTesting
                : PDEUIMessages.OverviewPage_testing;
    FormText text =
        createClient(container, getLauncherText(getLauncherHelper().isOSGi(), prefixText), toolkit);
    text.setImage("run", lp.get(PDEPluginImages.DESC_RUN_EXC)); // $NON-NLS-1$
    text.setImage("debug", lp.get(PDEPluginImages.DESC_DEBUG_EXC)); // $NON-NLS-1$
    text.setImage("profile", lp.get(PDEPluginImages.DESC_PROFILE_EXC)); // $NON-NLS-1$
    section.setClient(container);
  }
  @Override
  public void createContents(Composite parent) {
    parent.setLayout(FormLayoutFactory.createDetailsGridLayout(false, 1));
    FormToolkit toolkit = getManagedForm().getToolkit();
    Section section =
        toolkit.createSection(parent, Section.DESCRIPTION | ExpandableComposite.TITLE_BAR);
    section.clientVerticalSpacing = FormLayoutFactory.SECTION_HEADER_VERTICAL_SPACING;
    section.setText(PDEUIMessages.ExtensionPointDetails_title);
    section.setDescription(PDEUIMessages.ExtensionPointDetails_desc);
    section.setLayout(FormLayoutFactory.createClearGridLayout(false, 1));
    section.setLayoutData(
        new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));

    Composite client = toolkit.createComposite(section);
    client.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 3));
    client.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    fIdEntry = new FormEntry(client, toolkit, PDEUIMessages.ExtensionPointDetails_id, null, false);
    fIdEntry.setFormEntryListener(
        new FormEntryAdapter(this) {
          @Override
          public void textValueChanged(FormEntry entry) {
            if (fInput != null) {
              try {
                fInput.setId(fIdEntry.getValue());
              } catch (CoreException e) {
                PDEPlugin.logException(e);
              }
            }
          }
        });
    fNameEntry =
        new FormEntry(client, toolkit, PDEUIMessages.ExtensionPointDetails_name, null, false);
    fNameEntry.setFormEntryListener(
        new FormEntryAdapter(this) {
          @Override
          public void textValueChanged(FormEntry entry) {
            if (fInput != null)
              try {
                fInput.setName(fNameEntry.getValue());
              } catch (CoreException e) {
                PDEPlugin.logException(e);
              }
          }
        });
    boolean editable = getPage().getModel().isEditable();
    fSchemaEntry =
        new FormEntry(
            client,
            toolkit,
            PDEUIMessages.ExtensionPointDetails_schema,
            PDEUIMessages.ExtensionPointDetails_browse,
            editable); //
    fSchemaEntry.setFormEntryListener(
        new FormEntryAdapter(this) {
          @Override
          public void textValueChanged(FormEntry entry) {
            if (fInput != null) {
              try {
                fInput.setSchema(fSchemaEntry.getValue());
              } catch (CoreException e) {
                PDEPlugin.logException(e);
              }
              updateRichText();
            }
          }

          @Override
          public void linkActivated(HyperlinkEvent e) {
            IProject project = getPage().getPDEEditor().getCommonProject();
            if (fSchemaEntry.getValue() == null || fSchemaEntry.getValue().length() == 0) {
              generateSchema();
              return;
            }
            IFile file = project.getFile(fSchemaEntry.getValue());
            if (file.exists()) openSchemaFile(file);
            else generateSchema();
          }

          @Override
          public void browseButtonSelected(FormEntry entry) {
            final IProject project = getPage().getPDEEditor().getCommonProject();
            ElementTreeSelectionDialog dialog =
                new ElementTreeSelectionDialog(
                    PDEPlugin.getActiveWorkbenchShell(),
                    new WorkbenchLabelProvider(),
                    new WorkbenchContentProvider());
            dialog.setTitle(
                PDEUIMessages.ManifestEditor_ExtensionPointDetails_schemaLocation_title);
            dialog.setMessage(
                PDEUIMessages.ManifestEditor_ExtensionPointDetails_schemaLocation_desc);
            dialog.setDoubleClickSelects(false);
            dialog.setAllowMultiple(false);
            dialog.addFilter(
                new ViewerFilter() {
                  @Override
                  public boolean select(Viewer viewer, Object parent, Object element) {
                    if (element instanceof IFile) {
                      String ext = ((IFile) element).getFullPath().getFileExtension();
                      return "exsd".equals(ext) || "mxsd".equals(ext); // $NON-NLS-1$ //$NON-NLS-2$
                    } else if (element instanceof IContainer) { // i.e. IProject, IFolder
                      try {
                        IResource[] resources = ((IContainer) element).members();
                        for (IResource resource : resources) {
                          if (select(viewer, parent, resource)) return true;
                        }
                      } catch (CoreException e) {
                        PDEPlugin.logException(e);
                      }
                    }
                    return false;
                  }
                });
            dialog.setValidator(
                new ISelectionStatusValidator() {
                  @Override
                  public IStatus validate(Object[] selection) {
                    IPluginModelBase model =
                        (IPluginModelBase) getPage().getPDEEditor().getAggregateModel();
                    String pluginName = model.getPluginBase().getId();

                    if (selection == null
                        || selection.length != 1
                        || !(selection[0] instanceof IFile))
                      return new Status(
                          IStatus.ERROR,
                          pluginName,
                          IStatus.ERROR,
                          PDEUIMessages.ManifestEditor_ExtensionPointDetails_validate_errorStatus,
                          null);
                    IFile file = (IFile) selection[0];
                    String ext = file.getFullPath().getFileExtension();
                    if ("exsd".equals(ext) || "mxsd".equals(ext)) // $NON-NLS-1$ //$NON-NLS-2$
                    return new Status(IStatus.OK, pluginName, IStatus.OK, "", null); // $NON-NLS-1$
                    return new Status(
                        IStatus.ERROR,
                        pluginName,
                        IStatus.ERROR,
                        PDEUIMessages.ManifestEditor_ExtensionPointDetails_validate_errorStatus,
                        null);
                  }
                });
            dialog.setDoubleClickSelects(true);
            dialog.setStatusLineAboveButtons(true);
            dialog.setInput(project);
            dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
            String filePath = fSchemaEntry.getValue();
            if (filePath != null && filePath.length() != 0 && project.exists(new Path(filePath)))
              dialog.setInitialSelection(project.getFile(new Path(filePath)));
            else dialog.setInitialSelection(null);
            dialog.create();
            PlatformUI.getWorkbench()
                .getHelpSystem()
                .setHelp(dialog.getShell(), IHelpContextIds.BROWSE_EXTENSION_POINTS_SCHEMAS);
            if (dialog.open() == Window.OK) {
              Object[] elements = dialog.getResult();
              if (elements.length > 0) {
                IResource elem = (IResource) elements[0];
                fSchemaEntry.setValue(elem.getProjectRelativePath().toString());
              }
            }
          }
        });
    createSpacer(toolkit, client, 2);

    Composite container = toolkit.createComposite(parent, SWT.NONE);
    container.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 1));
    container.setLayoutData(
        new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));

    fRichText = toolkit.createFormText(container, true);
    fRichText.setImage(
        "open",
        PDEPlugin.getDefault()
            .getLabelProvider()
            .get( //$NON-NLS-1$
                PDEPluginImages.DESC_SCHEMA_OBJ));
    fRichText.setImage(
        "desc",
        PDEPlugin.getDefault()
            .getLabelProvider()
            .get( //$NON-NLS-1$
                PDEPluginImages.DESC_DOC_SECTION_OBJ));
    fRichText.setImage(
        "search",
        PDEPlugin.getDefault()
            .getLabelProvider()
            .get( //$NON-NLS-1$
                PDEPluginImages.DESC_PSEARCH_OBJ));
    fRichText.addHyperlinkListener(
        new HyperlinkAdapter() {
          @Override
          public void linkActivated(HyperlinkEvent e) {
            IBaseModel model = getPage().getPDEEditor().getAggregateModel();
            String pointID = null;
            IPluginBase base = ((IPluginModelBase) model).getPluginBase();
            String pluginID = base.getId();
            String schemaVersion = base.getSchemaVersion();
            if (schemaVersion != null && Double.parseDouble(schemaVersion) >= 3.2) {
              if (fInput.getId().indexOf('.') != -1) pointID = fInput.getId();
            }
            if (pointID == null) pointID = pluginID + "." + fInput.getId(); // $NON-NLS-1$
            IPluginExtensionPoint extPoint =
                PDECore.getDefault().getExtensionsRegistry().findExtensionPoint(pointID);
            if (e.getHref().equals("search")) { // $NON-NLS-1$
              new FindReferencesAction(fInput, pluginID).run();
            } else if (e.getHref().equals("open")) { // $NON-NLS-1$
              if (extPoint == null) {
                IProject project = getPage().getPDEEditor().getCommonProject();
                IFile file = project.getFile(fSchemaEntry.getValue());
                if (file.exists()) openSchemaFile(file);
                else generateSchema();
                return;
              }
              OpenSchemaAction action = new OpenSchemaAction();
              action.setInput(pointID);
              action.setEnabled(true);
              action.run();
            } else {
              if (extPoint == null) {
                IProject project = getPage().getPDEEditor().getCommonProject();
                IFile file = project.getFile(fSchemaEntry.getValue());
                URL url;
                try {
                  url = file.getLocationURI().toURL();
                } catch (MalformedURLException e1) {
                  return;
                }
                SchemaDescriptor schemaDesc = new SchemaDescriptor(pointID, url);
                Schema schema = new Schema(schemaDesc, url, false);
                schema.setPluginId(pluginID);
                schema.setPointId(fInput.getId());
                schema.setName(fNameEntry.getValue());
                new ShowDescriptionAction(schema).run();
                return;
              }
              new ShowDescriptionAction(pointID).run();
            }
          }
        });

    fIdEntry.setEditable(isEditable());
    fNameEntry.setEditable(isEditable());
    fSchemaEntry.setEditable(isEditable());
    toolkit.paintBordersFor(client);
    section.setClient(client);
    IPluginModelBase model = (IPluginModelBase) getPage().getModel();
    model.addModelChangedListener(this);
    markDetailsPart(section);
  }