Exemplo n.º 1
0
 public static Combo createEncodingCombo(Composite parent, String curCharset) {
   if (curCharset == null) {
     curCharset = GeneralUtils.getDefaultFileEncoding();
   }
   Combo encodingCombo = new Combo(parent, SWT.DROP_DOWN);
   encodingCombo.setVisibleItemCount(30);
   SortedMap<String, Charset> charsetMap = Charset.availableCharsets();
   int index = 0;
   int defIndex = -1;
   for (String csName : charsetMap.keySet()) {
     Charset charset = charsetMap.get(csName);
     encodingCombo.add(charset.displayName());
     if (charset.displayName().equalsIgnoreCase(curCharset)) {
       defIndex = index;
     }
     if (defIndex < 0) {
       for (String alias : charset.aliases()) {
         if (alias.equalsIgnoreCase(curCharset)) {
           defIndex = index;
         }
       }
     }
     index++;
   }
   if (defIndex >= 0) {
     encodingCombo.select(defIndex);
   } else {
     log.warn("Charset '" + curCharset + "' is not recognized"); // $NON-NLS-1$ //$NON-NLS-2$
   }
   return encodingCombo;
 }
  protected void createServerSelectionControl(Composite parent) {
    Group group = new Group(parent, SWT.NONE);
    group.setText(PHPServerUIMessages.getString("ServerTab.server")); // $NON-NLS-1$
    GridLayout ly = new GridLayout(1, false);
    ly.marginHeight = 0;
    ly.marginWidth = 0;
    group.setLayout(ly);
    group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    Composite phpServerComp = new Composite(group, SWT.NONE);
    phpServerComp.setLayout(new GridLayout(4, false));
    phpServerComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    phpServerComp.setFont(parent.getFont());

    Label label = new Label(phpServerComp, SWT.WRAP);
    GridData data = new GridData(GridData.BEGINNING);
    data.widthHint = 100;
    label.setLayoutData(data);
    label.setFont(parent.getFont());
    label.setText(PHPServerUIMessages.getString("ServerLaunchConfigurationTab.0")); // $NON-NLS-1$

    serverCombo = new Combo(phpServerComp, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY);
    serverCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    serverCombo.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            handleServerSelection();
          }
        });

    createNewServer =
        createPushButton(
            phpServerComp, PHPServerUIMessages.getString("ServerTab.new"), null); // $NON-NLS-1$
    createNewServer.addSelectionListener(fListener);

    configureServers =
        createPushButton(
            phpServerComp,
            PHPServerUIMessages.getString("ServerTab.configure"),
            null); //$NON-NLS-1$
    configureServers.addSelectionListener(fListener);

    servers = new ArrayList<Server>();
    populateServerList(servers);

    // initialize the servers list
    if (!servers.isEmpty()) {
      for (int i = 0; i < servers.size(); i++) {
        Server svr = servers.get(i);
        serverCombo.add(svr.getName());
      }
    }

    // select first item in list
    if (serverCombo.getItemCount() > 0) {
      serverCombo.select(0);
    }

    serverCombo.forceFocus();
  }
Exemplo n.º 3
0
 private void loadPreferences() {
   pingerRegistry.checkSelectedPinger();
   maxThreadsText.setText(Integer.toString(scannerConfig.maxThreads));
   threadDelayText.setText(Integer.toString(scannerConfig.threadDelay));
   String[] pingerNames = pingerRegistry.getRegisteredNames();
   for (int i = 0; i < pingerNames.length; i++) {
     if (scannerConfig.selectedPinger.equals(pingerNames[i])) {
       pingersCombo.select(i);
     }
   }
   pingingCountText.setText(Integer.toString(scannerConfig.pingCount));
   pingingTimeoutText.setText(Integer.toString(scannerConfig.pingTimeout));
   deadHostsCheckbox.setSelection(scannerConfig.scanDeadHosts);
   skipBroadcastsCheckbox.setSelection(scannerConfig.skipBroadcastAddresses);
   portTimeoutText.setText(Integer.toString(scannerConfig.portTimeout));
   adaptTimeoutCheckbox.setSelection(scannerConfig.adaptPortTimeout);
   minPortTimeoutText.setText(Integer.toString(scannerConfig.minPortTimeout));
   minPortTimeoutText.setEnabled(scannerConfig.adaptPortTimeout);
   portsText.setText(scannerConfig.portString);
   addRequestedPortsCheckbox.setSelection(scannerConfig.useRequestedPorts);
   notAvailableText.setText(scannerConfig.notAvailableText);
   notScannedText.setText(scannerConfig.notScannedText);
   displayMethod[guiConfig.displayMethod.ordinal()].setSelection(true);
   showInfoCheckbox.setSelection(guiConfig.showScanStats);
   askConfirmationCheckbox.setSelection(guiConfig.askScanConfirmation);
 }
 /*
  * Select the default server.
  */
 private void selectDefaultServer(ILaunchConfiguration configuration) throws CoreException {
   if (serverCombo != null && serverCombo.getItemCount() > 0) {
     // Select the default server
     String projectName =
         configuration.getAttribute(IPHPDebugConstants.PHP_Project, (String) null);
     IProject project = null;
     if (projectName != null) {
       project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
     }
     Server defaultServer = ServersManager.getDefaultServer(project);
     int nameIndex = serverCombo.indexOf(defaultServer.getName());
     if (nameIndex > -1) {
       serverCombo.select(nameIndex);
     } else {
       serverCombo.select(0);
     }
     server = ServersManager.getServer(serverCombo.getText());
   }
 }
Exemplo n.º 5
0
  /** This method initializes main controls of the main window */
  private void initControlsArea(
      final Composite controlsArea,
      final Combo feederSelectionCombo,
      final Button startStopButton,
      final StartStopScanningAction startStopScanningAction,
      final ToolsActions.Preferences preferencesListener,
      final ToolsActions.ChooseFetchers chooseFetchersListsner) {
    controlsArea.setLayoutData(
        LayoutHelper.formData(
            new FormAttachment(feederArea),
            new FormAttachment(100),
            new FormAttachment(0),
            new FormAttachment(feederArea, 0, SWT.BOTTOM)));
    controlsArea.setLayout(LayoutHelper.formLayout(7, 3, 3));

    // steal the height from the second child of the FeederGUI - this must be the first edit box.
    // this results in better visual alignment with FeederGUIs
    Control secondControl = feederRegistry.current().getChildren()[1];
    // initialize global standard button height
    buttonHeight = secondControl.getSize().y + 2;

    // feeder selection combobox
    this.feederSelectionCombo = feederSelectionCombo;
    feederSelectionCombo.pack();
    IPFeederSelectionListener feederSelectionListener = new IPFeederSelectionListener();
    feederSelectionCombo.addSelectionListener(feederSelectionListener);
    // initialize the selected feeder GUI
    feederSelectionCombo.select(guiConfig.activeFeeder);
    feederSelectionCombo.setToolTipText(Labels.getLabel("combobox.feeder.tooltip"));

    // start/stop button
    this.startStopButton = startStopButton;
    shell.setDefaultButton(startStopButton);
    startStopButton.addSelectionListener(startStopScanningAction);

    // traverse the button before the combo (and don't traverse other buttons at all)
    controlsArea.setTabList(new Control[] {startStopButton, feederSelectionCombo});

    prefsButton = new ToolBar(controlsArea, SWT.FLAT);
    prefsButton.setCursor(prefsButton.getDisplay().getSystemCursor(SWT.CURSOR_HAND));
    ToolItem item = new ToolItem(prefsButton, SWT.PUSH);
    item.setImage(new Image(null, Labels.getInstance().getImageAsStream("button.preferences.img")));
    item.setToolTipText(Labels.getLabel("title.preferences"));
    item.addListener(SWT.Selection, preferencesListener);

    fetchersButton = new ToolBar(controlsArea, SWT.FLAT);
    fetchersButton.setCursor(fetchersButton.getDisplay().getSystemCursor(SWT.CURSOR_HAND));
    item = new ToolItem(fetchersButton, SWT.PUSH);
    item.setImage(new Image(null, Labels.getInstance().getImageAsStream("button.fetchers.img")));
    item.setToolTipText(Labels.getLabel("title.fetchers.select"));
    item.addListener(SWT.Selection, chooseFetchersListsner);

    feederSelectionListener.widgetSelected(null);
  }
Exemplo n.º 6
0
 public static boolean setComboSelection(Combo combo, String value) {
   if (value == null) {
     return false;
   }
   int count = combo.getItemCount();
   for (int i = 0; i < count; i++) {
     if (value.equals(combo.getItem(i))) {
       combo.select(i);
       return true;
     }
   }
   return false;
 }
Exemplo n.º 7
0
 protected void fillProjectDropDownMenue(String name) {
   List<String> projectNames = getProjectNames();
   int selectedProjectName = 0;
   projectDropDown.removeAll();
   for (int i = 0; i < projectNames.size(); i++) {
     String projectName = projectNames.get(i);
     if (projectName.equals(name)) {
       selectedProjectName = i;
     }
     projectDropDown.add(projectName);
   }
   projectDropDown.select(selectedProjectName);
 }
 public void createFileFilterPanel(Shell dialog) {
   Composite filterPanel = new Composite(dialog, SWT.NONE);
   GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
   filterPanel.setLayoutData(gridData);
   filterPanel.setLayout(new GridLayout(3, false));
   // create filter label
   Label filterLabel = new Label(filterPanel, SWT.NONE);
   filterLabel.setText(Messages.getString("VfsFileChooserDialog.filter")); // $NON-NLS-1$
   gridData = new GridData(SWT.FILL, SWT.CENTER, false, false);
   filterLabel.setLayoutData(gridData);
   // create file filter combo
   fileFilterCombo = new Combo(filterPanel, SWT.READ_ONLY);
   gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
   fileFilterCombo.setLayoutData(gridData);
   fileFilterCombo.setItems(fileFilterNames);
   fileFilterCombo.addSelectionListener(this);
   fileFilterCombo.select(0);
 }
 protected void handleConfigureButtonSelected() {
   int selectionIndex = serverCombo.getSelectionIndex();
   Server server = servers.get(selectionIndex);
   String serverName = server.getName();
   Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
   NullProgressMonitor monitor = new NullProgressMonitor();
   ServerEditDialog dialog = new ServerEditDialog(shell, server);
   if (dialog.open() == Window.CANCEL) {
     monitor.setCanceled(true);
     return;
   }
   ServersManager.save();
   String newName = server.getName();
   if (!newName.equals(serverName)) {
     serverCombo.remove(selectionIndex);
     serverCombo.add(newName, selectionIndex);
     serverCombo.select(selectionIndex);
   }
   saveWorkingCopy = true;
   handleServerSelection();
 }
Exemplo n.º 10
0
  /**
   * Creates a combo that controls whether a cursor is set on the registered controls.
   *
   * @return the created combo
   */
  protected Combo createCursorCombo() {
    Composite group = new Composite(styleComp, SWT.NONE);
    group.setLayout(new GridLayout(2, false));
    new Label(group, SWT.NONE).setText("Cursor");
    final Combo combo = new Combo(group, SWT.READ_ONLY);
    combo.setItems(SWT_CURSORS);
    combo.select(0);
    combo.addSelectionListener(
        new SelectionAdapter() {

          public void widgetSelected(final SelectionEvent e) {
            String selection = null;
            int index = combo.getSelectionIndex();
            if (index > 0) {
              selection = combo.getItem(index);
            }
            updateCursor(selection);
          }
        });
    return combo;
  }
  public void populateCustomUIPanel(Shell dialog) {
    ArrayList<String> customNames = new ArrayList<String>();
    for (int i = 0; i < customUIPanels.size(); i++) {
      CustomVfsUiPanel panel = customUIPanels.get(i);
      if (panel.getVfsScheme().equalsIgnoreCase("file")
          || schemeRestrictions == null
          || isRestrictedTo(panel.getVfsScheme())) {
        if (panel.getVfsScheme().equalsIgnoreCase("file") && !showFileScheme) {
          continue;
        }
        customNames.add(panel.getVfsSchemeDisplayText());
      }
    }

    customUIPicker.setItems(customNames.toArray(new String[] {}));
    hideCustomPanelChildren();

    // hide entire panel if no customizations
    if (customNames.size() == 0) {
      customUIPanel.setParent(fakeShell);
    } else {
      if (customNames.size() == 1 && "file".equals(customNames.get(0))) {
        customUIPanel.setParent(fakeShell);
      } else {
        String initialSchemeDisplayText = initialScheme;
        for (int i = 0; i < customUIPanels.size(); i++) {
          if (customUIPanels.get(i).getVfsScheme().equalsIgnoreCase(initialScheme)) {
            initialSchemeDisplayText = customUIPanels.get(i).getVfsSchemeDisplayText();
            break;
          }
        }
        for (int i = 0; i < customUIPicker.getItemCount(); i++) {
          if (customUIPicker.getItem(i).equalsIgnoreCase(initialSchemeDisplayText)) {
            customUIPicker.select(i);
            customUIPicker.notifyListeners(SWT.Selection, null);
          }
        }
      }
    }
  }
  public void updateParentFileCombo(FileObject selectedItem) {
    try {
      List<FileObject> parentChain = new ArrayList<FileObject>();
      // are we a directory?
      try {
        if (selectedItem.getType() == FileType.FOLDER && selectedItem.getType().hasChildren()) {
          // we have real children....
          parentChain.add(selectedItem);
        }
      } catch (Exception e) {
        // we are not a folder
      }
      FileObject parentFileObject;
      parentFileObject = selectedItem.getParent();
      while (parentFileObject != null) {
        parentChain.add(parentFileObject);
        parentFileObject = parentFileObject.getParent();
      }

      File roots[] = File.listRoots();
      if (currentPanel != null) {
        for (int i = 0; i < roots.length; i++) {
          parentChain.add(currentPanel.resolveFile(roots[i].getAbsolutePath()));
        }
      }

      String items[] = new String[parentChain.size()];
      int idx = 0;
      for (int i = parentChain.size() - 1; i >= 0; i--) {
        items[idx++] = ((FileObject) parentChain.get(i)).getName().getURI();
      }

      openFileCombo.setItems(items);
      openFileCombo.select(items.length - 1);
    } catch (Exception e) {
      e.printStackTrace();
      // then let's not update the GUI
    }
  }
Exemplo n.º 13
0
 /**
  * Lists all products in the current project's module, incl. a "<base>" product if no particular
  * product is selected.
  *
  * @param preSelected The product that should be preselected, or null for <base>.
  */
 protected void fillProductDropDownMenue(String preSelected) {
   productDropDown.removeAll();
   productDropDown.add("<base>");
   IProject proj = getSelectedProject();
   if (proj == null) {
     return;
   }
   AbsNature n = UtilityFunctions.getAbsNature(proj);
   Model m = n.getCompleteModel();
   if (m == null) return;
   Collection<Product> prods = m.getProducts();
   if (prods == null) return;
   int i = 1; /* base comes first */
   int selected = 0;
   for (Product p : prods) {
     final String name = p.qualifiedName();
     productDropDown.add(name);
     if (name.equals(preSelected)) {
       selected = i;
     }
     i++;
   }
   productDropDown.select(selected);
 }
  /* (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();
    }
  }
Exemplo n.º 15
0
  /** This method initializes scanningTab */
  private void createScanningTab() {
    RowLayout rowLayout = createRowLayout();
    scanningTab = new Composite(tabFolder, SWT.NONE);
    scanningTab.setLayout(rowLayout);

    GridLayout groupLayout = new GridLayout();
    groupLayout.numColumns = 2;
    Group threadsGroup = new Group(scanningTab, SWT.NONE);
    threadsGroup.setText(Labels.getLabel("preferences.threads"));
    threadsGroup.setLayout(groupLayout);

    GridData gridData = new GridData(80, SWT.DEFAULT);

    Label label;

    label = new Label(threadsGroup, SWT.NONE);
    label.setText(Labels.getLabel("preferences.threads.delay"));
    threadDelayText = new Text(threadsGroup, SWT.BORDER);
    threadDelayText.setLayoutData(gridData);

    label = new Label(threadsGroup, SWT.NONE);
    label.setText(Labels.getLabel("preferences.threads.maxThreads"));
    maxThreadsText = new Text(threadsGroup, SWT.BORDER);
    maxThreadsText.setLayoutData(gridData);
    //		new Label(threadsGroup, SWT.NONE);
    //		Button checkButton = new Button(threadsGroup, SWT.NONE);
    //		checkButton.setText(Labels.getLabel("button.check"));
    //		checkButton.setLayoutData(gridData);
    //		checkButton.addListener(SWT.Selection, new CheckButtonListener());

    Group pingingGroup = new Group(scanningTab, SWT.NONE);
    pingingGroup.setLayout(groupLayout);
    pingingGroup.setText(Labels.getLabel("preferences.pinging"));

    label = new Label(pingingGroup, SWT.NONE);
    label.setText(Labels.getLabel("preferences.pinging.type"));
    pingersCombo = new Combo(pingingGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
    pingersCombo.setLayoutData(gridData);
    String[] pingerNames = pingerRegistry.getRegisteredNames();
    for (int i = 0; i < pingerNames.length; i++) {
      pingersCombo.add(Labels.getLabel(pingerNames[i]));
      // this is used by savePreferences()
      pingersCombo.setData(Integer.toString(i), pingerNames[i]);
    }
    pingersCombo.select(0);

    label = new Label(pingingGroup, SWT.NONE);
    label.setText(Labels.getLabel("preferences.pinging.count"));
    pingingCountText = new Text(pingingGroup, SWT.BORDER);
    pingingCountText.setLayoutData(gridData);

    label = new Label(pingingGroup, SWT.NONE);
    label.setText(Labels.getLabel("preferences.pinging.timeout"));
    pingingTimeoutText = new Text(pingingGroup, SWT.BORDER);
    pingingTimeoutText.setLayoutData(gridData);

    GridData gridDataWithSpan = new GridData();
    gridDataWithSpan.horizontalSpan = 2;
    deadHostsCheckbox = new Button(pingingGroup, SWT.CHECK);
    deadHostsCheckbox.setText(Labels.getLabel("preferences.pinging.deadHosts"));
    deadHostsCheckbox.setLayoutData(gridDataWithSpan);

    Group skippingGroup = new Group(scanningTab, SWT.NONE);
    skippingGroup.setLayout(groupLayout);
    skippingGroup.setText(Labels.getLabel("preferences.skipping"));

    skipBroadcastsCheckbox = new Button(skippingGroup, SWT.CHECK);
    skipBroadcastsCheckbox.setText(Labels.getLabel("preferences.skipping.broadcast"));
    GridData gridDataWithSpan2 = new GridData();
    gridDataWithSpan2.horizontalSpan = 2;
    skipBroadcastsCheckbox.setLayoutData(gridDataWithSpan2);
  }
  /**
   * Creates the buttons in this group inside a new composite
   *
   * @param parent parent composite
   * @param toolkit toolkit to give form style or <code>null</code> for dialog style
   */
  private void createButtons(Composite parent, FormToolkit toolkit) {
    if (toolkit != null) {
      Composite buttonComp = toolkit.createComposite(parent);
      GridLayout layout = new GridLayout();
      layout.marginWidth = layout.marginHeight = 0;
      buttonComp.setLayout(layout);
      buttonComp.setLayoutData(new GridData(GridData.FILL_VERTICAL));

      fSelectButton = toolkit.createButton(buttonComp, Messages.IncludedBundlesTree_0, SWT.PUSH);
      fSelectButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
      fDeselectButton = toolkit.createButton(buttonComp, Messages.IncludedBundlesTree_1, SWT.PUSH);
      fDeselectButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

      Label emptySpace = new Label(buttonComp, SWT.NONE);
      GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
      gd.widthHint = gd.heightHint = 5;
      emptySpace.setLayoutData(gd);

      fSelectAllButton = toolkit.createButton(buttonComp, Messages.IncludedBundlesTree_2, SWT.PUSH);
      fSelectAllButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
      fDeselectAllButton =
          toolkit.createButton(buttonComp, Messages.IncludedBundlesTree_3, SWT.PUSH);
      fDeselectAllButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

      emptySpace = new Label(buttonComp, SWT.NONE);
      gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
      gd.widthHint = gd.heightHint = 5;
      emptySpace.setLayoutData(gd);

      fSelectRequiredButton =
          toolkit.createButton(buttonComp, Messages.TargetContentsGroup_4, SWT.PUSH);
      fSelectRequiredButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

      Composite filterComp = toolkit.createComposite(buttonComp);
      layout = new GridLayout();
      layout.marginWidth = layout.marginHeight = 0;
      filterComp.setLayout(layout);
      filterComp.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, true, true));

      fModeLabel = toolkit.createLabel(filterComp, Messages.TargetContentsGroup_ManageUsing);

      fPluginModeButton =
          toolkit.createButton(filterComp, Messages.TargetContentsGroup_PluginMode, SWT.RADIO);
      fPluginModeButton.setSelection(true);
      fFeaureModeButton =
          toolkit.createButton(filterComp, Messages.TargetContentsGroup_FeatureMode, SWT.RADIO);
      fFeaureModeButton.setSelection(true);

      emptySpace = new Label(filterComp, SWT.NONE);
      gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
      gd.widthHint = gd.heightHint = 5;
      emptySpace.setLayoutData(gd);

      fShowLabel = toolkit.createLabel(filterComp, Messages.BundleContainerTable_9);

      fShowPluginsButton =
          toolkit.createButton(filterComp, Messages.BundleContainerTable_14, SWT.CHECK);
      fShowPluginsButton.setSelection(true);
      fShowSourceButton =
          toolkit.createButton(filterComp, Messages.BundleContainerTable_15, SWT.CHECK);
      fShowSourceButton.setSelection(true);

      emptySpace = new Label(filterComp, SWT.NONE);
      gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
      gd.widthHint = gd.heightHint = 5;
      emptySpace.setLayoutData(gd);

      fGroupLabel = toolkit.createLabel(filterComp, Messages.TargetContentsGroup_0);

      fGroupComboPart = new ComboPart();
      fGroupComboPart.createControl(filterComp, toolkit, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY);
      gd = new GridData(GridData.FILL_HORIZONTAL);
      gd.horizontalIndent = 10;
      fGroupComboPart.getControl().setLayoutData(gd);
      fGroupComboPart.setItems(
          new String[] {
            Messages.TargetContentsGroup_1,
            Messages.TargetContentsGroup_2,
            Messages.TargetContentsGroup_3
          });
      fGroupComboPart.setVisibleItemCount(30);
      fGroupComboPart.addSelectionListener(
          new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
              handleGroupChange();
            }
          });
      fGroupComboPart.select(0);

    } else {
      Composite buttonComp = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_VERTICAL, 0, 0);
      fSelectButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_0, null);
      fDeselectButton =
          SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_1, null);

      Label emptySpace = new Label(buttonComp, SWT.NONE);
      GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
      gd.widthHint = gd.heightHint = 5;
      emptySpace.setLayoutData(gd);

      fSelectAllButton =
          SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_2, null);
      fDeselectAllButton =
          SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_3, null);

      emptySpace = new Label(buttonComp, SWT.NONE);
      gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
      gd.widthHint = gd.heightHint = 5;
      emptySpace.setLayoutData(gd);

      fSelectRequiredButton =
          SWTFactory.createPushButton(buttonComp, Messages.TargetContentsGroup_4, null);

      Composite filterComp = SWTFactory.createComposite(buttonComp, 1, 1, SWT.NONE, 0, 0);
      filterComp.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, true, true));

      fModeLabel = SWTFactory.createLabel(filterComp, Messages.TargetContentsGroup_ManageUsing, 1);

      fPluginModeButton =
          SWTFactory.createRadioButton(filterComp, Messages.TargetContentsGroup_PluginMode);
      fFeaureModeButton =
          SWTFactory.createRadioButton(filterComp, Messages.TargetContentsGroup_FeatureMode);

      emptySpace = new Label(filterComp, SWT.NONE);
      gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
      gd.widthHint = gd.heightHint = 5;
      emptySpace.setLayoutData(gd);

      fShowLabel = SWTFactory.createLabel(filterComp, Messages.BundleContainerTable_9, 1);

      fShowPluginsButton =
          SWTFactory.createCheckButton(filterComp, Messages.BundleContainerTable_14, null, true, 1);
      fShowSourceButton =
          SWTFactory.createCheckButton(filterComp, Messages.BundleContainerTable_15, null, true, 1);

      emptySpace = new Label(filterComp, SWT.NONE);
      gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
      gd.widthHint = gd.heightHint = 5;
      emptySpace.setLayoutData(gd);

      fGroupLabel = SWTFactory.createLabel(filterComp, Messages.TargetContentsGroup_0, 1);
      fGroupCombo =
          SWTFactory.createCombo(
              filterComp,
              SWT.READ_ONLY,
              1,
              new String[] {
                Messages.TargetContentsGroup_1,
                Messages.TargetContentsGroup_2,
                Messages.TargetContentsGroup_3
              });
      gd = new GridData(GridData.FILL_HORIZONTAL);
      gd.horizontalIndent = 10;
      fGroupCombo.setLayoutData(gd);
      fGroupCombo.addSelectionListener(
          new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
              handleGroupChange();
            }
          });
      fGroupCombo.select(0);
    }

    fSelectButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            if (!fTree.getSelection().isEmpty()) {
              Object[] selected = ((IStructuredSelection) fTree.getSelection()).toArray();
              for (int i = 0; i < selected.length; i++) {
                fTree.setChecked(selected[i], true);
              }
              saveIncludedBundleState();
              contentChanged();
              updateButtons();
              fTree.update(
                  fTargetDefinition.getBundleContainers(),
                  new String[] {IBasicPropertyConstants.P_TEXT});
            }
          }
        });

    fDeselectButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            if (!fTree.getSelection().isEmpty()) {
              Object[] selected = ((IStructuredSelection) fTree.getSelection()).toArray();
              for (int i = 0; i < selected.length; i++) {
                fTree.setChecked(selected[i], false);
              }
              saveIncludedBundleState();
              contentChanged();
              updateButtons();
              fTree.update(
                  fTargetDefinition.getBundleContainers(),
                  new String[] {IBasicPropertyConstants.P_TEXT});
            }
          }
        });

    fSelectAllButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            fTree.setAllChecked(true);
            saveIncludedBundleState();
            contentChanged();
            updateButtons();
            fTree.update(
                fTargetDefinition.getBundleContainers(),
                new String[] {IBasicPropertyConstants.P_TEXT});
          }
        });

    fDeselectAllButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            fTree.setAllChecked(false);
            saveIncludedBundleState();
            contentChanged();
            updateButtons();
            fTree.update(
                fTargetDefinition.getBundleContainers(),
                new String[] {IBasicPropertyConstants.P_TEXT});
          }
        });

    fSelectRequiredButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            Object[] allChecked = fTree.getCheckedLeafElements();
            Object[] required = null;
            if (fFeaureModeButton.getSelection()) {
              required = getRequiredFeatures(fTargetDefinition.getAllFeatures(), allChecked);
            } else {
              required = getRequiredPlugins(fAllBundles, allChecked);
            }
            for (int i = 0; i < required.length; i++) {
              fTree.setChecked(required[i], true);
            }
            saveIncludedBundleState();
            contentChanged();
            updateButtons();
            fTree.update(
                fTargetDefinition.getBundleContainers(),
                new String[] {IBasicPropertyConstants.P_TEXT});
          }
        });

    fPluginModeButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            // Moving from feature based filtering to plug-in based, need to update storage
            ((TargetDefinition) fTargetDefinition).setUIMode(TargetDefinition.MODE_PLUGIN);
            contentChanged();
            fTargetDefinition.setIncluded(null);

            fGroupLabel.setEnabled(true);
            if (fGroupCombo != null) {
              fGroupCombo.setEnabled(true);
            } else {
              fGroupComboPart.getControl().setEnabled(true);
            }

            fTree.getControl().setRedraw(false);
            fTree.refresh(false);
            fTree.expandAll();
            updateCheckState();
            updateButtons();
            fTree.getControl().setRedraw(true);
          }
        });
    fPluginModeButton.setSelection(true);
    GridData gd = new GridData();
    gd.horizontalIndent = 10;
    fPluginModeButton.setLayoutData(gd);

    fFeaureModeButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            // Moving from plug-in based filtering to feature based, need to update storage
            ((TargetDefinition) fTargetDefinition).setUIMode(TargetDefinition.MODE_FEATURE);
            contentChanged();
            fTargetDefinition.setIncluded(null);

            fGroupLabel.setEnabled(false);
            if (fGroupCombo != null) {
              fGroupCombo.setEnabled(false);
            } else {
              fGroupComboPart.getControl().setEnabled(false);
            }

            fTree.getControl().setRedraw(false);
            fTree.refresh(false);
            fTree.expandAll();
            updateCheckState();
            updateButtons();
            fTree.getControl().setRedraw(true);
          }
        });
    fFeaureModeButton.setSelection(false);
    gd = new GridData();
    gd.horizontalIndent = 10;
    fFeaureModeButton.setLayoutData(gd);

    fShowPluginsButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            if (!fShowPluginsButton.getSelection()) {
              fTree.addFilter(fPluginFilter);
            } else {
              fTree.removeFilter(fPluginFilter);
              fTree.expandAll();
              updateCheckState();
            }
            updateButtons();
          }
        });
    fShowPluginsButton.setSelection(true);
    gd = new GridData();
    gd.horizontalIndent = 10;
    fShowPluginsButton.setLayoutData(gd);

    fShowSourceButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            if (!fShowSourceButton.getSelection()) {
              fTree.addFilter(fSourceFilter);
            } else {
              fTree.removeFilter(fSourceFilter);
              fTree.expandAll();
              updateCheckState();
            }
            updateButtons();
          }
        });
    fShowSourceButton.setSelection(true);
    gd = new GridData();
    gd.horizontalIndent = 10;
    fShowSourceButton.setLayoutData(gd);
  }
Exemplo n.º 17
0
  @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);
  }
Exemplo n.º 18
0
  /** @see OpenGLTab#createControls(Composite) */
  void createControls(Composite composite) {
    Group movementGroup = new Group(composite, SWT.NONE);
    movementGroup.setText("Translation");
    movementGroup.setLayout(new GridLayout(2, false));

    new Label(movementGroup, SWT.NONE).setText("X:");
    final Slider xMove = new Slider(movementGroup, SWT.NONE);
    xMove.setIncrement(1);
    xMove.setMaximum(12);
    xMove.setMinimum(0);
    xMove.setThumb(2);
    xMove.setPageIncrement(2);
    xMove.setSelection(5);
    xMove.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event e) {
            xPos = xMove.getSelection() - 5;
          }
        });

    new Label(movementGroup, SWT.NONE).setText("Y:");
    final Slider yMove = new Slider(movementGroup, SWT.NONE);
    yMove.setIncrement(1);
    yMove.setMaximum(12);
    yMove.setMinimum(0);
    yMove.setThumb(2);
    yMove.setPageIncrement(2);
    yMove.setSelection(5);
    yMove.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event e) {
            yPos = yMove.getSelection() - 5;
          }
        });

    new Label(movementGroup, SWT.NONE).setText("Z:");
    final Slider zMove = new Slider(movementGroup, SWT.NONE);
    zMove.setIncrement(1);
    zMove.setMaximum(24);
    zMove.setMinimum(0);
    zMove.setThumb(4);
    zMove.setPageIncrement(2);
    zMove.setSelection(10);
    zMove.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event e) {
            zPos = zMove.getSelection() - 25;
          }
        });

    Composite fogTypesGroup = new Composite(composite, SWT.NONE);
    GridLayout layout = new GridLayout(2, false);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    fogTypesGroup.setLayout(layout);
    fogTypesGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));

    new Label(fogTypesGroup, SWT.NONE).setText("Fog Types:");
    final Combo fogTypeCombo = new Combo(fogTypesGroup, SWT.READ_ONLY);
    GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    data.grabExcessHorizontalSpace = true;
    fogTypeCombo.setLayoutData(data);
    fogTypeCombo.setItems(FOG_NAMES);
    fogTypeCombo.select(0);

    new Label(composite, SWT.NONE).setText("Fog Density:");
    final Slider fogDensitySlider = new Slider(composite, SWT.NONE);
    fogDensitySlider.setIncrement(1);
    fogDensitySlider.setMaximum(32);
    fogDensitySlider.setMinimum(0);
    fogDensitySlider.setThumb(2);
    fogDensitySlider.setPageIncrement(5);
    fogDensitySlider.setSelection(0);
    fogDensitySlider.setEnabled(false);
    fogDensitySlider.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event e) {
            float fogDensity = ((float) fogDensitySlider.getSelection()) / 100;
            GL.glFogf(GL.GL_FOG_DENSITY, fogDensity);
          }
        });
    fogTypeCombo.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event e) {
            int currentSelection = fogTypeCombo.getSelectionIndex();
            // fog type GL.GL_LINEAR does not utilize fogDensity, but the other fog types do
            fogDensitySlider.setEnabled(currentSelection != 0);
            GL.glFogf(GL.GL_FOG_MODE, FOG_TYPES[currentSelection]);
          }
        });
  }
Exemplo n.º 19
0
  /**
   * Constructor to create an editor to update/create an ontology entry
   *
   * @param display - points back to the display
   * @param oureditOntEntry - the entry being edited
   * @param ontParent - the edited item's parent in the hierarchy
   * @param newItem - true if this is a new item
   */
  public EditOntEntry(
      Display display, OntEntry oureditOntEntry, OntEntry ontParent, boolean newItem) {
    super();
    shell = new Shell(display, SWT.DIALOG_TRIM | SWT.PRIMARY_MODAL);
    shell.setText("OntEntry Information");
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 3;
    gridLayout.marginHeight = 5;
    gridLayout.makeColumnsEqualWidth = true;
    shell.setLayout(gridLayout);

    ourOntEntry = oureditOntEntry;
    ourParent = ontParent;

    if (newItem) {
      ourOntEntry.setName("");
      ourOntEntry.setImportance(Importance.MODERATE);
    }

    new Label(shell, SWT.NONE).setText("Name:");

    nameField = new Text(shell, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL);
    nameField.setText(ourOntEntry.getName());
    GridData gridData =
        new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING);
    DisplayUtilities.setTextDimensions(nameField, gridData, 75);
    gridData.horizontalSpan = 2;
    nameField.setLayoutData(gridData);

    new Label(shell, SWT.NONE).setText("Description:");

    descArea = new Text(shell, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL);
    descArea.setText(ourOntEntry.getDescription());
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    DisplayUtilities.setTextDimensions(descArea, gridData, 75, 5);
    gridData.horizontalSpan = 2;
    gridData.heightHint = descArea.getLineHeight() * 3;
    descArea.setLayoutData(gridData);

    new Label(shell, SWT.NONE).setText("Importance:");
    importanceBox = new Combo(shell, SWT.DROP_DOWN | SWT.READ_ONLY);
    Enumeration impEnum = Importance.elements();
    int l = 0;
    Importance itype;
    while (impEnum.hasMoreElements()) {
      itype = (Importance) impEnum.nextElement();
      importanceBox.add(itype.toString());
      if (itype.toString().compareTo(ourOntEntry.getImportance().toString()) == 0) {
        importanceBox.select(l);
      }
      l++;
    }
    // Error checking: if no such selection is valid, set it to select index 0
    if (importanceBox.getSelectionIndex() == -1) {
      importanceBox.select(0);
    }
    importanceBox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));

    new Label(shell, SWT.NONE).setText(" ");
    new Label(shell, SWT.NONE).setText(" ");

    addButton = new Button(shell, SWT.PUSH);
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING);
    addButton.setLayoutData(gridData);
    if (newItem) {
      addButton.setText("Add");
      addButton.addSelectionListener(
          new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
              canceled = false;
              if (!nameField.getText().trim().equals("")) {
                ConsistencyChecker checker =
                    new ConsistencyChecker(ourOntEntry.getID(), nameField.getText(), "OntEntries");

                if (ourOntEntry.getName() == nameField.getText() || checker.check()) {
                  ourParent.addChild(ourOntEntry);
                  ourOntEntry.setLevel(ourParent.getLevel() + 1);
                  ourOntEntry.setName(nameField.getText());
                  ourOntEntry.setDescription(descArea.getText());
                  ourOntEntry.setImportance(
                      Importance.fromString(
                          importanceBox.getItem(importanceBox.getSelectionIndex())));

                  // comment before this made no sense...
                  ourOntEntry.setID(ourOntEntry.toDatabase(ourParent.getID()));
                  System.out.println("Name of added item = " + ourOntEntry.getName());

                  shell.close();
                  shell.dispose();
                }
              } else {
                MessageBox mbox = new MessageBox(shell, SWT.ICON_ERROR);
                mbox.setMessage("Need to provide the OntEntry name");
                mbox.open();
              }
            }
          });

    } else {
      addButton.setText("Save");
      addButton.addSelectionListener(
          new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
              canceled = false;

              ConsistencyChecker checker =
                  new ConsistencyChecker(ourOntEntry.getID(), nameField.getText(), "OntEntries");

              if (ourOntEntry.getName() == nameField.getText() || checker.check()) {
                ourOntEntry.setName(nameField.getText());
                ourOntEntry.setDescription(descArea.getText());
                ourOntEntry.setImportance(
                    Importance.fromString(
                        importanceBox.getItem(importanceBox.getSelectionIndex())));
                // since this is a save, not an add, the type and parent are ignored
                ourOntEntry.setID(ourOntEntry.toDatabase(0));

                //			RationaleDB db = RationaleDB.getHandle();
                //			db.addOntEntry(ourOntEntry);

                shell.close();
                shell.dispose();
              }
            }
          });
    }

    cancelButton = new Button(shell, SWT.PUSH);
    cancelButton.setText("Cancel");
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING);
    cancelButton.setLayoutData(gridData);
    cancelButton.addSelectionListener(
        new SelectionAdapter() {

          public void widgetSelected(SelectionEvent event) {
            canceled = true;
            shell.close();
            shell.dispose();
          }
        });

    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
  }