private void fillBody(IManagedForm managedForm, FormToolkit toolkit) {
    Composite body = managedForm.getForm().getBody();
    body.setLayout(FormLayoutFactory.createFormTableWrapLayout(true, 2));

    Composite left = toolkit.createComposite(body);
    left.setLayout(FormLayoutFactory.createFormPaneTableWrapLayout(false, 1));
    left.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
    //		if (isFragment())
    //		fInfoSection = new FragmentMonitorInfoSection(this, left);
    //		else
    //		fInfoSection = new PluginMonitorInfoSection(this, left);

    fInfoSection = new SimpleMonitorInfoSection(this, left);
    //		fInfoSection = new PluginMonitorInfoSection(this, left);
    managedForm.addPart(fInfoSection);
    if (isBundle()) managedForm.addPart(new MonitorExecutionEnvironmentSection(this, left));

    Composite right = toolkit.createComposite(body);
    right.setLayout(FormLayoutFactory.createFormPaneTableWrapLayout(false, 1));
    right.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
    createContentSection(managedForm, right, toolkit);
    if (isEditable() || getPDEEditor().hasInputContext(PluginInputContext.CONTEXT_ID))
      createExtensionSection(managedForm, right, toolkit);
    if (isEditable()) {
      createTestingSection(managedForm, isBundle() ? right : left, toolkit);
    }
    if (isEditable()) createExportingSection(managedForm, right, toolkit);
  }
  @Override
  public final void createContents(Composite parent) {
    // This is a hacked fix to ensure that the label columns on every details
    // page have the same width. SchemaDetails_translatable plus 11 pixels
    // represents the longest label on any field on any details page. This
    // occurs on SchemaStringAttributeDetails and 11 is the size of the
    // horizontal indent that contributes to the label's width.
    GC gc = new GC(parent);
    minLabelWeight = gc.textExtent(PDEUIMessages.SchemaDetails_translatable).x + 11;
    gc.dispose();
    gc = null;

    parent.setLayout(FormLayoutFactory.createDetailsGridLayout(false, 1));
    FormToolkit toolkit = getManagedForm().getToolkit();
    fSection = toolkit.createSection(parent, Section.DESCRIPTION | ExpandableComposite.TITLE_BAR);
    fSection.clientVerticalSpacing = FormLayoutFactory.SECTION_HEADER_VERTICAL_SPACING;
    fSection.setLayout(FormLayoutFactory.createClearGridLayout(false, 1));

    GridData gd;
    if (fShowDescription) gd = new GridData(GridData.FILL_BOTH);
    else gd = new GridData(GridData.FILL_HORIZONTAL);
    fSection.setLayoutData(gd);

    // Align the master and details section headers (misalignment caused
    // by section toolbar icons)
    getPage().alignSectionHeaders(fElementSection.getSection(), fSection);

    Composite client = toolkit.createComposite(fSection);
    client.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 3));

    createDetails(client);

    if (fShowDescription) createDescription(client, toolkit);

    // If the DTD Approximation section was requested, instantiate it and create it's contents
    // on the same parent Composite
    if (fShowDTD) {
      fDtdSection = new SchemaDtdDetailsSection();
      fDtdSection.initialize(getManagedForm());
      fDtdSection.createContents(parent);
    }

    toolkit.paintBordersFor(client);
    fSection.setClient(client);
    markDetailsPart(fSection);

    if (fShowDescription) fDescriptionViewer.createUIListeners();
    hookListeners();
  }
 protected Composite createStaticSectionClient(FormToolkit toolkit, Composite parent) {
   Composite container = toolkit.createComposite(parent, SWT.NONE);
   container.setLayout(FormLayoutFactory.createSectionClientTableWrapLayout(false, 1));
   TableWrapData data = new TableWrapData(TableWrapData.FILL_GRAB);
   container.setLayoutData(data);
   return container;
 }
Exemple #4
0
 private void fillBody(final IManagedForm managedForm, final FormToolkit toolkit) {
   Composite body = managedForm.getForm().getBody();
   body.setLayout(FormLayoutFactory.createFormTableWrapLayout(true, 2));
   GeneralInfoSection generalSection = new GeneralInfoSection(this, body);
   managedForm.addPart(generalSection);
   if (getModel().isEditable()) {
     createExportingSection(body, toolkit);
   }
 }
Exemple #5
0
  /* (non-Javadoc)
   * @see org.eclipse.pde.internal.ui.editor.PDESection#createClient(org.eclipse.ui.forms.widgets.Section, org.eclipse.ui.forms.widgets.FormToolkit)
   */
  protected void createClient(Section section, FormToolkit toolkit) {
    section.setText(PDEUIMessages.GeneralInfoSection_title);
    section.setDescription(PDEUIMessages.GeneralInfoSection_desc);
    section.setLayout(FormLayoutFactory.createClearTableWrapLayout(false, 1));
    TableWrapData data = new TableWrapData(TableWrapData.FILL_GRAB);
    data.colspan = 2;
    section.setLayoutData(data);

    Composite client = toolkit.createComposite(section);
    client.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, NUM_COLUMNS));

    IActionBars actionBars = getPage().getPDEEditor().getEditorSite().getActionBars();

    // general section
    createIdEntry(client, toolkit, actionBars);
    createVersionEntry(client, toolkit, actionBars);
    createNameEntry(client, toolkit, actionBars);
    createLaunchersOption(client, toolkit);

    toolkit.paintBordersFor(client);
    section.setClient(client);

    getModel().addModelChangedListener(this);
  }
  @Override
  public void createClient(Section section, FormToolkit toolkit) {

    section.setLayout(FormLayoutFactory.createClearGridLayout(false, 1));
    GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
    section.setLayoutData(data);

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

    String editLabel = PDEUIMessages.SiteEditor_PortabilitySection_edit;

    fOsText =
        new FormEntry(
            container, toolkit, PDEUIMessages.SiteEditor_PortabilitySection_os, editLabel, false);
    fOsText.setFormEntryListener(
        new FormEntryAdapter(this) {

          @Override
          public void browseButtonSelected(FormEntry entry) {
            BusyIndicator.showWhile(
                fOsText.getText().getDisplay(),
                new Runnable() {
                  @Override
                  public void run() {
                    Choice[] choices = getOSChoices();
                    openPortabilityChoiceDialog(IEnvironment.P_OS, fOsText, choices);
                  }
                });
          }

          @Override
          public void textValueChanged(FormEntry text) {
            try {
              applyValue(IEnvironment.P_OS, text.getValue());
            } catch (CoreException e) {
              PDEPlugin.logException(e);
            }
          }
        });
    limitTextWidth(fOsText);
    fOsText.setEditable(fCurrentInput != null && isEditable());

    fWsText =
        new FormEntry(
            container, toolkit, PDEUIMessages.SiteEditor_PortabilitySection_ws, editLabel, false);
    fWsText.setFormEntryListener(
        new FormEntryAdapter(this) {

          @Override
          public void browseButtonSelected(FormEntry entry) {
            BusyIndicator.showWhile(
                fWsText.getText().getDisplay(),
                new Runnable() {
                  @Override
                  public void run() {
                    Choice[] choices = getWSChoices();
                    openPortabilityChoiceDialog(IEnvironment.P_WS, fWsText, choices);
                  }
                });
          }

          @Override
          public void textValueChanged(FormEntry text) {
            try {
              applyValue(IEnvironment.P_WS, text.getValue());
            } catch (CoreException e) {
              PDEPlugin.logException(e);
            }
          }
        });
    limitTextWidth(fWsText);
    fWsText.setEditable(fCurrentInput != null && isEditable());

    fNlText =
        new FormEntry(
            container, toolkit, PDEUIMessages.SiteEditor_PortabilitySection_nl, editLabel, false);

    fNlText.setFormEntryListener(
        new FormEntryAdapter(this) {

          @Override
          public void browseButtonSelected(FormEntry entry) {
            BusyIndicator.showWhile(
                fNlText.getText().getDisplay(),
                new Runnable() {
                  @Override
                  public void run() {
                    Choice[] choices = getNLChoices();
                    openPortabilityChoiceDialog(IEnvironment.P_NL, fNlText, choices);
                  }
                });
          }

          @Override
          public void textValueChanged(FormEntry text) {
            try {
              applyValue(IEnvironment.P_NL, text.getValue());
            } catch (CoreException e) {
              PDEPlugin.logException(e);
            }
          }
        });
    limitTextWidth(fNlText);
    fNlText.setEditable(fCurrentInput != null && isEditable());

    fArchText =
        new FormEntry(
            container, toolkit, PDEUIMessages.SiteEditor_PortabilitySection_arch, editLabel, false);
    fArchText.setFormEntryListener(
        new FormEntryAdapter(this) {

          @Override
          public void browseButtonSelected(FormEntry entry) {
            BusyIndicator.showWhile(
                fArchText.getText().getDisplay(),
                new Runnable() {
                  @Override
                  public void run() {
                    Choice[] choices = getArchChoices();
                    openPortabilityChoiceDialog(IEnvironment.P_ARCH, fArchText, choices);
                  }
                });
          }

          @Override
          public void textValueChanged(FormEntry text) {
            try {
              applyValue(IEnvironment.P_ARCH, text.getValue());
            } catch (CoreException e) {
              PDEPlugin.logException(e);
            }
          }
        });
    limitTextWidth(fArchText);
    fArchText.setEditable(fCurrentInput != null && isEditable());

    toolkit.paintBordersFor(container);
    section.setClient(container);
  }
  public void createClient(Section section, FormToolkit toolkit) {

    section.setLayout(FormLayoutFactory.createClearGridLayout(false, 1));
    GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
    section.setLayoutData(data);

    Composite container = toolkit.createComposite(section);
    container.setLayout(FormLayoutFactory.createSectionClientTableWrapLayout(false, 2));

    fNameText =
        new FormEntry(
            container,
            toolkit,
            MDEUIMessages.SiteEditor_IncludedFeaturesDetailsSection_featureLabel,
            null,
            false);
    fNameText.setFormEntryListener(
        new FormEntryAdapter(this) {
          public void textValueChanged(FormEntry text) {
            if (fInput != null)
              try {
                fInput.setName(text.getValue());
              } catch (CoreException e) {
                MDEPlugin.logException(e);
              }
          }
        });
    fNameText.setEditable(isEditable());

    fVersionText =
        new FormEntry(
            container, toolkit, MDEUIMessages.FeatureEditor_SpecSection_version, null, false);
    fVersionText.setFormEntryListener(
        new FormEntryAdapter(this) {
          public void textValueChanged(FormEntry text) {
            if (fInput != null)
              try {
                fInput.setVersion(text.getValue());
              } catch (CoreException e) {
                MDEPlugin.logException(e);
              }
          }
        });
    fVersionText.setEditable(isEditable());

    fOptionalButton =
        toolkit.createButton(
            container, MDEUIMessages.SiteEditor_IncludedFeaturesDetailsSection_optional, SWT.CHECK);

    TableWrapData gd = new TableWrapData(TableWrapData.FILL);
    gd.colspan = 2;
    fOptionalButton.setLayoutData(gd);
    fOptionalButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            if (!fBlockNotification) {
              try {
                fInput.setOptional(fOptionalButton.getSelection());
              } catch (CoreException ce) {
              }
            }
          }
        });
    Label fSearchLocationDescLabel =
        toolkit.createLabel(
            container,
            MDEUIMessages.SiteEditor_IncludedFeaturesDetailsSection_searchLocation,
            SWT.WRAP);
    gd = new TableWrapData(TableWrapData.FILL);
    gd.colspan = 2;
    fSearchLocationDescLabel.setLayoutData(gd);

    fSearchRootButton =
        toolkit.createButton(
            container, MDEUIMessages.SiteEditor_IncludedFeaturesDetailsSection_root, SWT.RADIO);
    fSearchRootButton.setSelection(true);
    gd = new TableWrapData(TableWrapData.FILL);
    gd.colspan = 2;
    gd.indent = 5;
    fSearchRootButton.setLayoutData(gd);
    fSearchRootButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            if (!fBlockNotification) {
              try {
                if (fSearchRootButton.getSelection()) fInput.setSearchLocation(IFeatureChild.ROOT);
              } catch (CoreException ce) {
              }
            }
          }
        });

    fSearchSelfButton =
        toolkit.createButton(
            container, MDEUIMessages.SiteEditor_IncludedFeaturesDetailsSection_self, SWT.RADIO);
    fSearchSelfButton.setSelection(true);
    gd = new TableWrapData(TableWrapData.FILL);
    gd.colspan = 2;
    gd.indent = 5;
    fSearchSelfButton.setLayoutData(gd);
    fSearchSelfButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            if (!fBlockNotification) {
              try {
                if (fSearchSelfButton.getSelection()) fInput.setSearchLocation(IFeatureChild.SELF);
              } catch (CoreException ce) {
              }
            }
          }
        });

    fSearchBothButton =
        toolkit.createButton(
            container, MDEUIMessages.SiteEditor_IncludedFeaturesDetailsSection_both, SWT.RADIO);
    fSearchBothButton.setSelection(true);
    gd = new TableWrapData(TableWrapData.FILL);
    gd.colspan = 2;
    gd.indent = 5;
    fSearchBothButton.setLayoutData(gd);
    fSearchBothButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            if (!fBlockNotification) {
              try {
                if (fSearchBothButton.getSelection()) fInput.setSearchLocation(IFeatureChild.BOTH);
              } catch (CoreException ce) {
              }
            }
          }
        });

    toolkit.paintBordersFor(container);
    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);
  }