Пример #1
0
  private void initializeState() {
    fLaunchConfigCombo.setEnabled(false);
    if (fLaunchConfigCombo.getItemCount() > 0)
      fLaunchConfigCombo.setText(fLaunchConfigCombo.getItem(0));

    if (fModel != null && fModel.getPluginBase().getId() != null) {
      IPluginExtension[] extensions = fModel.getPluginBase().getExtensions();
      for (int i = 0; i < extensions.length; i++) {
        String point = extensions[i].getPoint();
        if ("org.eclipse.core.runtime.products".equals(point)) { // $NON-NLS-1$
          String id = extensions[i].getId();
          if (id != null) {
            String full = fModel.getPluginBase().getId() + "." + id; // $NON-NLS-1$
            if (fProductCombo.indexOf(full) != -1) {
              fProductCombo.setText(full);
              fProductButton.setSelection(true);
              return;
            }
          }
        }
      }
    }

    fBasicButton.setSelection(true);

    fProductCombo.setEnabled(false);
    if (fProductCombo.getItemCount() > 0) fProductCombo.setText(fProductCombo.getItem(0));
  }
Пример #2
0
  public ILaunchConfiguration getSelectedLaunchConfiguration() {
    if (!fLaunchConfigButton.getSelection()) return null;

    String configName = fLaunchConfigCombo.getText();
    try {
      ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
      ILaunchConfigurationType type =
          manager.getLaunchConfigurationType(EclipseLaunchShortcut.CONFIGURATION_TYPE);
      ILaunchConfigurationType type2 =
          manager.getLaunchConfigurationType(IPDELauncherConstants.OSGI_CONFIGURATION_TYPE);
      ILaunchConfiguration[] configs = manager.getLaunchConfigurations(type);
      ILaunchConfiguration[] configs2 = manager.getLaunchConfigurations(type2);
      ILaunchConfiguration[] configurations =
          new ILaunchConfiguration[configs.length + configs2.length];
      System.arraycopy(configs, 0, configurations, 0, configs.length);
      System.arraycopy(configs2, 0, configurations, configs.length, configs2.length);
      for (int i = 0; i < configurations.length; i++) {
        if (configurations[i].getName().equals(configName)
            && !DebugUITools.isPrivate(configurations[i])) return configurations[i];
      }
    } catch (CoreException e) {
      PDEPlugin.logException(e);
    }
    return null;
  }
Пример #3
0
  /* (non-Javadoc)
   * @see org.eclipse.ui.dialogs.WizardNewFileCreationPage#createAdvancedControls(org.eclipse.swt.widgets.Composite)
   */
  protected void createAdvancedControls(Composite parent) {
    fGroup = new Group(parent, SWT.NONE);
    fGroup.setText(PDEUIMessages.ProductFileWizadPage_groupTitle);
    fGroup.setLayout(new GridLayout(2, false));
    fGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    fBasicButton = new Button(fGroup, SWT.RADIO);
    GridData gd = new GridData();
    gd.horizontalSpan = 2;
    fBasicButton.setLayoutData(gd);
    fBasicButton.setText(PDEUIMessages.ProductFileWizadPage_basic);

    fProductButton = new Button(fGroup, SWT.RADIO);
    fProductButton.setText(PDEUIMessages.ProductFileWizadPage_existingProduct);
    fProductButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            fProductCombo.setEnabled(fProductButton.getSelection());
          }
        });

    fProductCombo = new Combo(fGroup, SWT.SINGLE | SWT.READ_ONLY);
    fProductCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    fProductCombo.setItems(TargetPlatform.getProducts());

    fLaunchConfigButton = new Button(fGroup, SWT.RADIO);
    fLaunchConfigButton.setText(PDEUIMessages.ProductFileWizadPage_existingLaunchConfig);
    fLaunchConfigButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            fLaunchConfigCombo.setEnabled(fLaunchConfigButton.getSelection());
          }
        });

    fLaunchConfigCombo = new Combo(fGroup, SWT.SINGLE | SWT.READ_ONLY);
    fLaunchConfigCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    fLaunchConfigCombo.setItems(getLaunchConfigurations());

    initializeState();
  }
 protected void updateJREWidgets() {
   fNamedJREsCombo.setEnabled(fNamedJREButton.getSelection());
   fExecEnvsCombo.setEnabled(fExecEnvButton.getSelection());
 }
  private void createJREGroup(Composite container) {
    Group group =
        SWTFactory.createGroup(
            container, PDEUIMessages.EnvironmentBlock_jreTitle, 2, 1, GridData.FILL_HORIZONTAL);

    initializeJREValues();

    SWTFactory.createWrapLabel(group, PDEUIMessages.JRESection_description, 2);

    fDefaultJREButton = SWTFactory.createRadioButton(group, PDEUIMessages.JRESection_defaultJRE, 2);
    fDefaultJREButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            updateJREWidgets();
            getTargetDefinition().setJREContainer(JavaRuntime.newDefaultJREContainerPath());
          }
        });

    fNamedJREButton = SWTFactory.createRadioButton(group, PDEUIMessages.JRESection_JREName);
    fNamedJREButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            updateJREWidgets();
            getTargetDefinition()
                .setJREContainer(
                    JavaRuntime.newJREContainerPath(
                        VMUtil.getVMInstall(fNamedJREsCombo.getText())));
          }
        });

    fNamedJREsCombo =
        SWTFactory.createCombo(
            group, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY, 1, VMUtil.getVMInstallNames());
    fNamedJREsCombo.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            getTargetDefinition()
                .setJREContainer(
                    JavaRuntime.newJREContainerPath(
                        VMUtil.getVMInstall(fNamedJREsCombo.getText())));
          }
        });

    fExecEnvButton = SWTFactory.createRadioButton(group, PDEUIMessages.JRESection_ExecutionEnv);
    fExecEnvButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            updateJREWidgets();
            getTargetDefinition()
                .setJREContainer(
                    JavaRuntime.newJREContainerPath(
                        VMUtil.getExecutionEnvironment(fExecEnvsCombo.getText())));
          }
        });

    fExecEnvsCombo =
        SWTFactory.createCombo(
            group,
            SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY,
            1,
            fExecEnvChoices.toArray(new String[fExecEnvChoices.size()]));
    fExecEnvsCombo.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            getTargetDefinition()
                .setJREContainer(
                    JavaRuntime.newJREContainerPath(
                        VMUtil.getExecutionEnvironment(fExecEnvsCombo.getText())));
          }
        });
  }
  private void createTargetEnvironmentGroup(Composite container) {
    Group group =
        SWTFactory.createGroup(
            container, PDEUIMessages.EnvironmentBlock_targetEnv, 2, 1, GridData.FILL_HORIZONTAL);

    initializeChoices();

    SWTFactory.createWrapLabel(group, PDEUIMessages.EnvironmentSection_description, 2);

    SWTFactory.createLabel(group, PDEUIMessages.Preferences_TargetEnvironmentPage_os, 1);

    fOSCombo =
        SWTFactory.createCombo(
            group, SWT.SINGLE | SWT.BORDER, 1, fOSChoices.toArray(new String[fOSChoices.size()]));
    fOSCombo.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            getTargetDefinition().setOS(getModelValue(fOSCombo.getText()));
          }
        });

    SWTFactory.createLabel(group, PDEUIMessages.Preferences_TargetEnvironmentPage_ws, 1);

    fWSCombo =
        SWTFactory.createCombo(
            group, SWT.SINGLE | SWT.BORDER, 1, fWSChoices.toArray(new String[fWSChoices.size()]));
    fWSCombo.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            getTargetDefinition().setWS(getModelValue(fWSCombo.getText()));
          }
        });

    SWTFactory.createLabel(group, PDEUIMessages.Preferences_TargetEnvironmentPage_arch, 1);

    fArchCombo =
        SWTFactory.createCombo(
            group,
            SWT.SINGLE | SWT.BORDER,
            1,
            fArchChoices.toArray(new String[fArchChoices.size()]));
    fArchCombo.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            getTargetDefinition().setArch(getModelValue(fArchCombo.getText()));
          }
        });

    SWTFactory.createLabel(group, PDEUIMessages.Preferences_TargetEnvironmentPage_nl, 1);

    fNLCombo =
        SWTFactory.createCombo(
            group, SWT.SINGLE | SWT.BORDER, 1, fNLChoices.toArray(new String[fNLChoices.size()]));
    fNLCombo.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            String value = fNLCombo.getText();
            int index = value.indexOf("-"); // $NON-NLS-1$
            if (index > 0) value = value.substring(0, index);
            getTargetDefinition().setNL(getModelValue(value));
          }
        });
  }
  /* (non-Javadoc)
   * @see org.eclipse.pde.internal.ui.wizards.target.TargetDefinitionPage#targetChanged()
   */
  protected void targetChanged(ITargetDefinition definition) {
    super.targetChanged(definition);
    if (definition != null) {
      // When  If the page isn't open yet, try running a UI job so the dialog has time to finish
      // opening
      new UIJob(PDEUIMessages.TargetDefinitionContentPage_0) {
        public IStatus runInUIThread(IProgressMonitor monitor) {
          ITargetDefinition definition = getTargetDefinition();
          if (!definition.isResolved()) {
            try {
              getContainer()
                  .run(
                      true,
                      true,
                      new IRunnableWithProgress() {
                        public void run(IProgressMonitor monitor)
                            throws InvocationTargetException, InterruptedException {
                          getTargetDefinition().resolve(new ResolutionProgressMonitor(monitor));
                          if (monitor.isCanceled()) {
                            throw new InterruptedException();
                          }
                        }
                      });
            } catch (InvocationTargetException e) {
              PDECore.log(e);
            } catch (InterruptedException e) {
              fContentTree.setCancelled();
              return Status.CANCEL_STATUS;
            }
          }
          fContentTree.setInput(definition);
          fLocationTree.setInput(definition);
          if (definition.isResolved() && definition.getStatus().getSeverity() == IStatus.ERROR) {
            fLocationTab.setImage(
                PlatformUI.getWorkbench()
                    .getSharedImages()
                    .getImage(ISharedImages.IMG_OBJS_ERROR_TSK));
          } else {
            fLocationTab.setImage(null);
          }
          return Status.OK_STATUS;
        }
      }.schedule();
      String name = definition.getName();
      if (name == null) {
        name = EMPTY_STRING;
      }

      if (name.trim().length() > 0) fNameText.setText(name);
      else setMessage(PDEUIMessages.TargetDefinitionContentPage_8);

      fLocationTree.setInput(definition);
      fContentTree.setInput(definition);

      String presetValue = (definition.getOS() == null) ? EMPTY_STRING : definition.getOS();
      fOSCombo.setText(presetValue);
      presetValue = (definition.getWS() == null) ? EMPTY_STRING : definition.getWS();
      fWSCombo.setText(presetValue);
      presetValue = (definition.getArch() == null) ? EMPTY_STRING : definition.getArch();
      fArchCombo.setText(presetValue);
      presetValue =
          (definition.getNL() == null)
              ? EMPTY_STRING
              : LocaleUtil.expandLocaleName(definition.getNL());
      fNLCombo.setText(presetValue);

      IPath jrePath = definition.getJREContainer();
      if (jrePath == null || jrePath.equals(JavaRuntime.newDefaultJREContainerPath())) {
        fDefaultJREButton.setSelection(true);
      } else {
        String ee = JavaRuntime.getExecutionEnvironmentId(jrePath);
        if (ee != null) {
          fExecEnvButton.setSelection(true);
          fExecEnvsCombo.select(fExecEnvsCombo.indexOf(ee));
        } else {
          String vm = JavaRuntime.getVMInstallName(jrePath);
          if (vm != null) {
            fNamedJREButton.setSelection(true);
            fNamedJREsCombo.select(fNamedJREsCombo.indexOf(vm));
          }
        }
      }

      if (fExecEnvsCombo.getSelectionIndex() == -1)
        fExecEnvsCombo.setText(fExecEnvChoices.first().toString());

      if (fNamedJREsCombo.getSelectionIndex() == -1)
        fNamedJREsCombo.setText(VMUtil.getDefaultVMInstallName());

      updateJREWidgets();

      presetValue =
          (definition.getProgramArguments() == null)
              ? EMPTY_STRING
              : definition.getProgramArguments();
      fProgramArgs.setText(presetValue);
      presetValue =
          (definition.getVMArguments() == null) ? EMPTY_STRING : definition.getVMArguments();
      fVMArgs.setText(presetValue);

      fElementViewer.refresh();
    }
  }
Пример #8
0
 public String getSelectedProduct() {
   return fProductButton.getSelection() ? fProductCombo.getText() : null;
 }
  @Override
  protected void createClient(Section section, FormToolkit toolkit) {

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

    section.setText(PDEUIMessages.ArgumentsSection_title);
    section.setDescription(PDEUIMessages.ArgumentsSection_desc);

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

    fTabFolder = new CTabFolder(client, SWT.FLAT | SWT.TOP);
    toolkit.adapt(fTabFolder, true, true);
    GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    fTabFolder.setLayoutData(gd);
    gd.heightHint = 2;
    toolkit.getColors().initializeSectionToolBarColors();
    Color selectedColor = toolkit.getColors().getColor(IFormColors.TB_BG);
    fTabFolder.setSelectionBackground(
        new Color[] {selectedColor, toolkit.getColors().getBackground()}, new int[] {100}, true);

    fTabFolder.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if (fProgramArgs.isDirty()) fProgramArgs.commit();
            if (fVMArgs.isDirty()) fVMArgs.commit();
            refresh();
            fArchCombo.select(fLastArch[fLastTab]);
          }
        });
    createTabs();

    Composite archParent = toolkit.createComposite(client);
    archParent.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 2));
    archParent.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    toolkit.createLabel(archParent, PDEUIMessages.ArgumentsSection_architecture);
    fArchCombo = new ComboViewerPart();
    fArchCombo.createControl(archParent, toolkit, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY);
    fArchCombo.getControl().setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));
    fArchCombo.setItems(TAB_ARCHLABELS);
    Control archComboControl = fArchCombo.getControl();
    if (archComboControl instanceof Combo) ((Combo) archComboControl).select(fLastArch[fLastTab]);
    else ((CCombo) archComboControl).select(fLastArch[fLastTab]);
    fArchCombo.addSelectionChangedListener(
        new ISelectionChangedListener() {
          @Override
          public void selectionChanged(SelectionChangedEvent event) {
            if (fProgramArgs.isDirty()) fProgramArgs.commit();
            if (fVMArgs.isDirty()) fVMArgs.commit();
            // remember the change in combo for currently selected platform
            Control fArchComboControl = fArchCombo.getControl();
            if (fArchComboControl instanceof Combo)
              fLastArch[fLastTab] = ((Combo) fArchComboControl).getSelectionIndex();
            else fLastArch[fLastTab] = ((CCombo) fArchComboControl).getSelectionIndex();

            refresh();
          }
        });

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

    fProgramArgs =
        new FormEntry(
            client, toolkit, PDEUIMessages.ArgumentsSection_program, SWT.MULTI | SWT.WRAP);
    fProgramArgs.getText().setLayoutData(new GridData(GridData.FILL_BOTH));
    fProgramArgs.setFormEntryListener(
        new FormEntryAdapter(this, actionBars) {
          @Override
          public void textValueChanged(FormEntry entry) {
            IArgumentsInfo info = getLauncherArguments();
            info.setProgramArguments(entry.getValue().trim(), fLastTab, fLastArch[fLastTab]);
            updateArgumentPreview(info);
          }
        });
    fProgramArgs.setEditable(isEditable());

    fVMArgs =
        new FormEntry(client, toolkit, PDEUIMessages.ArgumentsSection_vm, SWT.MULTI | SWT.WRAP);
    fVMArgs.getText().setLayoutData(new GridData(GridData.FILL_BOTH));
    fVMArgs.setFormEntryListener(
        new FormEntryAdapter(this, actionBars) {
          @Override
          public void textValueChanged(FormEntry entry) {
            IArgumentsInfo info = getLauncherArguments();
            info.setVMArguments(entry.getValue().trim(), fLastTab, fLastArch[fLastTab]);
            updateArgumentPreview(info);
          }
        });
    fVMArgs.setEditable(isEditable());

    fPreviewArgs =
        new FormEntry(
            client, toolkit, PDEUIMessages.ArgumentsSection_preview, SWT.MULTI | SWT.WRAP);
    fPreviewArgs.getText().setLayoutData(new GridData(GridData.FILL_BOTH));
    fPreviewArgs.setEditable(false);

    toolkit.paintBordersFor(client);
    section.setClient(client);
    // Register to be notified when the model changes
    getModel().addModelChangedListener(this);
  }