示例#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));
  }
 protected void initializeServerControl(ILaunchConfiguration configuration) {
   try {
     String serverName = configuration.getAttribute(Server.NAME, ""); // $NON-NLS-1$
     if (serverName != null && !serverName.equals("")) { // $NON-NLS-1$
       server = ServersManager.getServer(serverName);
       if (server == null) { // server no longer exists
         setErrorMessage(
             PHPServerUIMessages.getString("ServerTab.invalidServerError")); // $NON-NLS-1$
         selectDefaultServer(configuration);
       } else {
         serverCombo.setText(server.getName());
       }
     } else {
       selectDefaultServer(configuration);
     }
     // flag should only be set if launch has been attempted on the
     // config
     if (configuration.getAttribute(READ_ONLY, false)) {
       serverCombo.setEnabled(false);
     }
     boolean enabled = configuration.getAttribute(SERVER_ENABLED, true);
     serverCombo.setEnabled(enabled);
     createNewServer.setEnabled(enabled);
   } catch (Exception e) {
   }
 }
 private void createUICategoryCombo(Composite parent) {
   int style = SWT.READ_ONLY | SWT.BORDER;
   fCategoryCombo = new Combo(parent, style);
   GridData data = new GridData(GridData.FILL_HORIZONTAL);
   fCategoryCombo.setLayoutData(data);
   fCategoryCombo.add(CSWizardMessages.RegisterCSWizardPage_none);
   fCategoryCombo.setText(CSWizardMessages.RegisterCSWizardPage_none);
 }
示例#4
0
 /**
  * @param combo
  * @param itemList
  * @return Array of combo items
  */
 public static String[] setComboItems(Combo combo, List<String> itemList, String defaultItemText) {
   String[] itemArray = itemList.toArray(new String[itemList.size()]);
   Arrays.sort(itemArray);
   combo.setItems(itemArray);
   if (defaultItemText != null && defaultItemText.length() > 0) {
     combo.setText(defaultItemText);
   }
   return itemArray;
 }
 /**
  * Process cheatsheet elements with a category attribute
  *
  * @param parentElement
  */
 private void updateUICategoryComboAttribute(IPluginElement element) {
   // Get the category attribute
   IPluginAttribute categoryAttribute = element.getAttribute(F_CS_ELEMENT_CATEGORY);
   // Process the category attribute
   if ((categoryAttribute != null) && PDETextHelper.isDefined(categoryAttribute.getValue())) {
     String id = categoryAttribute.getValue();
     // Check to see if the category ID has been defined
     if (fCategoryTrackerUtil.containsCategoryID(id)) {
       // Update the category combo selection
       String name = fCategoryTrackerUtil.getCategoryName(id);
       fCategoryCombo.setText(name);
     } else {
       // Add the category ID to the combo box (no assoicated name)
       // This can only happen if the category is defined outside of
       // the plug-in the cheat sheet is stored in
       fCategoryCombo.add(id);
       fCategoryCombo.setText(id);
       fCategoryTrackerUtil.associate(id, id, CSCategoryTrackerUtil.F_TYPE_OLD_CATEGORY);
     }
   }
 }
示例#6
0
文件: FindTool.java 项目: URMC/i2b2
  private void setCategories(Combo categoryCombo) {
    // set default category for combo box
    categoryCombo.add("Any Category");
    categoryCombo.setText("Any Category");
    categoryKey = "any";

    categories = getCategories();

    if (categories != null) {
      Iterator categoriesIterator = categories.iterator();
      while (categoriesIterator.hasNext()) {
        ConceptType category = (ConceptType) categoriesIterator.next();
        String name = category.getName();
        categoryCombo.add(name);
      }
    }
    return;
  }
  private void handleWidgetSelectedCategoryButton() {
    // Create a dialog allowing the user to input the category name
    NewCategoryNameDialog dialog =
        new NewCategoryNameDialog(PDEUserAssistanceUIPlugin.getActiveWorkbenchShell());
    dialog.create();
    dialog.getShell().setText(CSWizardMessages.RegisterCSWizardPage_descTooltip);

    if (dialog.open() == Window.OK) {
      String newCategoryName = dialog.getNameText();

      if (PDETextHelper.isDefinedAfterTrim(newCategoryName)) {
        String trimmedText = newCategoryName.trim();
        fCategoryCombo.add(trimmedText);
        fCategoryCombo.setText(trimmedText);
        fCategoryCombo.setFocus();
        String id = generateCategoryID(trimmedText);
        fCategoryTrackerUtil.associate(id, trimmedText, CSCategoryTrackerUtil.F_TYPE_NEW_CATEGORY);
      }
    }
  }
示例#8
0
  /**
   * Init with listener
   *
   * @param azureus_core
   * @param parent
   * @param linkURL
   * @param referrer
   * @param listener
   */
  public OpenUrlWindow(
      final Shell parent,
      String linkURL,
      boolean default_magnet,
      final String referrer,
      final TorrentDownloaderCallBackInterface listener) {

    final Shell shell =
        ShellFactory.createShell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.RESIZE);
    shell.setText(MessageText.getString("openUrl.title"));
    Utils.setShellIcon(shell);

    GridData gridData;
    GridLayout layout = new GridLayout();
    layout.numColumns = 3;
    shell.setLayout(layout);

    // URL field

    Label label = new Label(shell, SWT.NULL);
    label.setText(MessageText.getString("openUrl.url"));
    gridData = new GridData();
    label.setLayoutData(gridData);

    final Text url = new Text(shell, SWT.BORDER);

    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.widthHint = 400;
    gridData.horizontalSpan = 2;
    url.setLayoutData(gridData);
    if (linkURL == null) Utils.setTextLinkFromClipboard(shell, url, true, default_magnet);
    else url.setText(linkURL);
    url.setSelection(url.getText().length());

    // help field
    Label help_label = new Label(shell, SWT.NULL);
    help_label.setText(MessageText.getString("openUrl.url.info"));
    gridData = new GridData();
    gridData.horizontalSpan = 3;
    help_label.setLayoutData(gridData);

    Label space = new Label(shell, SWT.NULL);
    gridData = new GridData();
    gridData.horizontalSpan = 3;
    space.setLayoutData(gridData);

    // referrer field

    Label referrer_label = new Label(shell, SWT.NULL);
    referrer_label.setText(MessageText.getString("openUrl.referrer"));
    gridData = new GridData();
    referrer_label.setLayoutData(gridData);

    final Combo referrer_combo = new Combo(shell, SWT.BORDER);

    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.widthHint = 150;
    gridData.grabExcessHorizontalSpace = true;
    referrer_combo.setLayoutData(gridData);

    final StringList referrers =
        COConfigurationManager.getStringListParameter("url_open_referrers");
    StringIterator iter = referrers.iterator();
    while (iter.hasNext()) {
      referrer_combo.add(iter.next());
    }

    if (referrer != null && referrer.length() > 0) {

      referrer_combo.setText(referrer);

    } else if (last_referrer != null) {

      referrer_combo.setText(last_referrer);
    }

    Label referrer_info = new Label(shell, SWT.NULL);
    referrer_info.setText(MessageText.getString("openUrl.referrer.info"));

    // line

    Label labelSeparator = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL);
    gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_END);
    gridData.horizontalSpan = 3;
    labelSeparator.setLayoutData(gridData);

    // buttons

    Composite panel = new Composite(shell, SWT.NULL);
    layout = new GridLayout();
    layout.numColumns = 3;
    panel.setLayout(layout);
    gridData =
        new GridData(
            GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_END | GridData.VERTICAL_ALIGN_END);
    gridData.horizontalSpan = 3;
    gridData.grabExcessHorizontalSpace = true;
    panel.setLayoutData(gridData);

    new Label(panel, SWT.NULL);

    Button ok = new Button(panel, SWT.PUSH);
    gridData =
        new GridData(
            GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_END | GridData.VERTICAL_ALIGN_END);
    gridData.widthHint = 70;
    gridData.grabExcessHorizontalSpace = true;
    ok.setLayoutData(gridData);
    ok.setText(MessageText.getString("Button.ok"));
    ok.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event e) {
            last_referrer = referrer_combo.getText().trim();

            if (!referrers.contains(last_referrer)) {
              referrers.add(last_referrer);
              COConfigurationManager.setParameter("url_open_referrers", referrers);
              COConfigurationManager.save();
            }

            COConfigurationManager.setParameter(CONFIG_REFERRER_DEFAULT, last_referrer);
            COConfigurationManager.save();

            String url_str = url.getText();

            url_str = UrlUtils.parseTextForURL(url_str, true);

            if (url_str == null) {
              url_str = UrlUtils.parseTextForMagnets(url.getText());
            }

            if (url_str == null) {

              url_str = url.getText();
            }

            new FileDownloadWindow(parent, url_str, last_referrer, null, null, listener);
            shell.dispose();
          }
        });

    shell.setDefaultButton(ok);

    Button cancel = new Button(panel, SWT.PUSH);
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_END);
    gridData.grabExcessHorizontalSpace = false;
    gridData.widthHint = 70;
    cancel.setLayoutData(gridData);
    cancel.setText(MessageText.getString("Button.cancel"));
    cancel.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event e) {
            shell.dispose();
          }
        });

    shell.addListener(
        SWT.Traverse,
        new Listener() {

          public void handleEvent(Event e) {

            if (e.character == SWT.ESC) {
              shell.dispose();
            }
          }
        });

    Point p = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT);

    if (p.x > 800) {

      p.x = 800;
    }

    shell.setSize(p);

    Utils.createURLDropTarget(shell, url);

    Utils.centreWindow(shell);

    shell.open();
  }
  public void widgetSelected(SelectionEvent se) {
    if (se.widget == openFileCombo) {
      // String filePath = parentFoldersCombo.getItem(parentFoldersCombo.getSelectionIndex());
      // vfsBrowser.selectTreeItemByName(filePath, true);

      try {
        // resolve the selected folder (without displaying access/secret keys in plain text)
        //        FileObject newRoot =
        // rootFile.getFileSystem().getFileSystemManager().resolveFile(folderURL.getFolderURL(openFileCombo.getText()));
        FileObject newRoot = currentPanel.resolveFile(getSelectedFile().getName().getURI());
        vfsBrowser.resetVfsRoot(newRoot);
      } catch (FileSystemException e) {
      }

    } else if (se.widget == okButton) {
      okPressed();
    } else if (se.widget == folderUpButton) {
      try {
        FileObject newRoot = vfsBrowser.getSelectedFileObject().getParent();
        if (newRoot != null) {
          vfsBrowser.resetVfsRoot(newRoot);
          vfsBrowser.setSelectedFileObject(newRoot);
          // make sure access/secret keys not displayed in plain text
          //          String str = folderURL.setFolderURL(newRoot.getName().getURI());
          openFileCombo.setText(newRoot.getName().getURI());
        }
      } catch (Exception e) {
        // top of root
      }
    } else if (se.widget == newFolderButton) {
      promptForNewFolder();
    } else if (se.widget == deleteFileButton) {
      MessageBox messageDialog =
          new MessageBox(se.widget.getDisplay().getActiveShell(), SWT.YES | SWT.NO);
      messageDialog.setText(Messages.getString("VfsFileChooserDialog.confirm")); // $NON-NLS-1$
      messageDialog.setMessage(
          Messages.getString("VfsFileChooserDialog.deleteFile")); // $NON-NLS-1$
      int status = messageDialog.open();
      if (status == SWT.YES) {
        try {
          vfsBrowser.deleteSelectedItem();
        } catch (FileSystemException e) {
          MessageBox errorDialog = new MessageBox(se.widget.getDisplay().getActiveShell(), SWT.OK);
          errorDialog.setText(Messages.getString("VfsFileChooserDialog.error")); // $NON-NLS-1$
          errorDialog.setMessage(e.getMessage());
          errorDialog.open();
        }
      }
      // } else if (se.widget == changeRootButton) {
      // promptForNewVfsRoot();
    } else if (se.widget == fileFilterCombo) {

      Runnable r =
          new Runnable() {
            public void run() {
              String filter = fileFilters[fileFilterCombo.getSelectionIndex()];
              vfsBrowser.setFilter(filter);
              try {
                vfsBrowser.applyFilter();
              } catch (FileSystemException e) {
                MessageBox mb = new MessageBox(newFolderButton.getShell(), SWT.OK);
                mb.setText(
                    Messages.getString("VfsFileChooserDialog.errorApplyFilter")); // $NON-NLS-1$
                mb.setMessage(e.getMessage());
                mb.open();
              }
            }
          };
      BusyIndicator.showWhile(fileFilterCombo.getDisplay(), r);
    } else {
      okPressed = false;
      hideCustomPanelChildren();
      dialog.dispose();
    }
  }
  public FileObject open(
      Shell applicationShell,
      String[] schemeRestrictions,
      String initialScheme,
      boolean showFileScheme,
      String fileName,
      String[] fileFilters,
      String[] fileFilterNames,
      boolean returnUserAuthenticatedFile,
      int fileDialogMode,
      boolean showLocation,
      boolean showCustomUI) {

    this.fileDialogMode = fileDialogMode;
    this.fileFilters = fileFilters;
    this.fileFilterNames = fileFilterNames;
    this.applicationShell = applicationShell;
    this.showFileScheme = showFileScheme;
    this.initialScheme = initialScheme;
    this.schemeRestrictions = schemeRestrictions;
    this.showLocation = showLocation;
    this.showCustomUI = showCustomUI;

    FileObject tmpInitialFile = initialFile;

    if (defaultInitialFile != null && rootFile == null) {
      try {
        rootFile = defaultInitialFile.getFileSystem().getRoot();
        initialFile = defaultInitialFile;
      } catch (FileSystemException ignored) {
        // well we tried
      }
    }

    createDialog(applicationShell);

    if (!showLocation) {
      comboPanel.setParent(fakeShell);
    } else {
      comboPanel.setParent(customUIPanel);
    }

    if (!showCustomUI) {
      customUIPanel.setParent(fakeShell);
    } else {
      customUIPanel.setParent(dialog);
    }

    // create our file chooser tool bar, contains parent folder combo and various controls
    createToolbarPanel(dialog);
    // create our vfs browser component
    createVfsBrowser(dialog);
    populateCustomUIPanel(dialog);
    if (fileDialogMode == VFS_DIALOG_SAVEAS) {
      createFileNamePanel(dialog, fileName);
    } else {
      // create file filter panel
      createFileFilterPanel(dialog);
    }
    // create our ok/cancel buttons
    createButtonPanel(dialog);

    initialFile = tmpInitialFile;
    // set the initial file selection
    try {
      if (initialFile != null || rootFile != null) {
        vfsBrowser.selectTreeItemByFileObject(initialFile != null ? initialFile : rootFile, true);
        updateParentFileCombo(initialFile != null ? initialFile : rootFile);
        setSelectedFile(initialFile != null ? initialFile : rootFile);
        openFileCombo.setText(
            initialFile != null ? initialFile.getName().getURI() : rootFile.getName().getURI());
      }
    } catch (FileSystemException e) {
      MessageBox box = new MessageBox(dialog.getShell());
      box.setText(Messages.getString("VfsFileChooserDialog.error")); // $NON-NLS-1$
      box.setMessage(e.getMessage());
      box.open();
    }

    // set the size and show the dialog
    int height = 550;
    int width = 800;
    dialog.setSize(width, height);
    Rectangle bounds = dialog.getDisplay().getPrimaryMonitor().getClientArea();
    int x = (bounds.width - width) / 2;
    int y = (bounds.height - height) / 2;
    dialog.setLocation(x, y);
    dialog.open();

    if (rootFile != null && fileDialogMode == VFS_DIALOG_SAVEAS) {
      if (!rootFile.getFileSystem().hasCapability(Capability.WRITE_CONTENT)) {
        MessageBox messageDialog = new MessageBox(dialog.getShell(), SWT.OK);
        messageDialog.setText(Messages.getString("VfsFileChooserDialog.warning")); // $NON-NLS-1$
        messageDialog.setMessage(
            Messages.getString("VfsFileChooserDialog.noWriteSupport")); // $NON-NLS-1$
        messageDialog.open();
      }
    }

    vfsBrowser.fileSystemTree.forceFocus();
    while (!dialog.isDisposed()) {
      if (!dialog.getDisplay().readAndDispatch()) dialog.getDisplay().sleep();
    }

    // we just woke up, we are probably disposed already..
    if (!dialog.isDisposed()) {
      hideCustomPanelChildren();
      dialog.dispose();
    }
    if (okPressed) {
      FileObject returnFile = vfsBrowser.getSelectedFileObject();
      if (returnFile != null && fileDialogMode == VFS_DIALOG_SAVEAS) {
        try {
          if (returnFile.getType().equals(FileType.FILE)) {
            returnFile = returnFile.getParent();
          }
          returnFile = returnFile.resolveFile(enteredFileName);
        } catch (FileSystemException e) {
          e.printStackTrace();
        }
      }

      // put user/pass on the filename so it comes out in the getUri call.
      if (!returnUserAuthenticatedFile) {
        // make sure to put the user/pass on the url if it's not there
        if (returnFile != null && returnFile.getName() instanceof URLFileName) {
          URLFileName urlFileName = (URLFileName) returnFile.getName();
          if (urlFileName.getUserName() == null || urlFileName.getPassword() == null) {
            // set it
            String user = "";
            String pass = "";

            UserAuthenticator userAuthenticator =
                DefaultFileSystemConfigBuilder.getInstance()
                    .getUserAuthenticator(returnFile.getFileSystem().getFileSystemOptions());

            if (userAuthenticator != null) {
              UserAuthenticationData data =
                  userAuthenticator.requestAuthentication(AUTHENTICATOR_TYPES);
              user = String.valueOf(data.getData(UserAuthenticationData.USERNAME));
              pass = String.valueOf(data.getData(UserAuthenticationData.PASSWORD));
              try {
                user = URLEncoder.encode(user, "UTF-8");
                pass = URLEncoder.encode(pass, "UTF-8");
              } catch (UnsupportedEncodingException e) {
                // ignore, just use the un encoded values
              }
            }

            // build up the url with user/pass on it
            int port = urlFileName.getPort();
            String portString = (port < 1) ? "" : (":" + port);
            String urlWithUserPass =
                urlFileName.getScheme()
                    + "://"
                    + user
                    + ":"
                    + pass
                    + "@"
                    + urlFileName.getHostName()
                    + portString
                    + urlFileName.getPath();

            try {
              returnFile = currentPanel.resolveFile(urlWithUserPass);
            } catch (FileSystemException e) {
              // couldn't resolve with user/pass on url??? interesting
              e.printStackTrace();
            }
          }
        }
      }
      return returnFile;
    } else {
      return null;
    }
  }
  /* (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();
    }
  }
示例#12
0
  /** Creates the "Control" widget children. */
  void createControlWidgets() {

    /* Create the combo */
    String[] strings = {
      ControlExample.getResourceString("ColorDialog"),
      ControlExample.getResourceString("DirectoryDialog"),
      ControlExample.getResourceString("FileDialog"),
      ControlExample.getResourceString("FontDialog"),
      ControlExample.getResourceString("PrintDialog"),
      ControlExample.getResourceString("MessageBox"),
    };
    dialogCombo = new Combo(dialogStyleGroup, SWT.READ_ONLY);
    dialogCombo.setItems(strings);
    dialogCombo.setText(strings[0]);
    dialogCombo.setVisibleItemCount(strings.length);

    /* Create the create dialog button */
    createButton = new Button(dialogStyleGroup, SWT.NONE);
    createButton.setText(ControlExample.getResourceString("Create_Dialog"));
    createButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));

    /* Create a group for the various dialog button style controls */
    Group buttonStyleGroup = new Group(controlGroup, SWT.NONE);
    buttonStyleGroup.setLayout(new GridLayout());
    buttonStyleGroup.setLayoutData(
        new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
    buttonStyleGroup.setText(ControlExample.getResourceString("Button_Styles"));

    /* Create the button style buttons */
    okButton = new Button(buttonStyleGroup, SWT.CHECK);
    okButton.setText("SWT.OK");
    cancelButton = new Button(buttonStyleGroup, SWT.CHECK);
    cancelButton.setText("SWT.CANCEL");
    yesButton = new Button(buttonStyleGroup, SWT.CHECK);
    yesButton.setText("SWT.YES");
    noButton = new Button(buttonStyleGroup, SWT.CHECK);
    noButton.setText("SWT.NO");
    retryButton = new Button(buttonStyleGroup, SWT.CHECK);
    retryButton.setText("SWT.RETRY");
    abortButton = new Button(buttonStyleGroup, SWT.CHECK);
    abortButton.setText("SWT.ABORT");
    ignoreButton = new Button(buttonStyleGroup, SWT.CHECK);
    ignoreButton.setText("SWT.IGNORE");

    /* Create a group for the icon style controls */
    Group iconStyleGroup = new Group(controlGroup, SWT.NONE);
    iconStyleGroup.setLayout(new GridLayout());
    iconStyleGroup.setLayoutData(
        new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
    iconStyleGroup.setText(ControlExample.getResourceString("Icon_Styles"));

    /* Create the icon style buttons */
    iconErrorButton = new Button(iconStyleGroup, SWT.RADIO);
    iconErrorButton.setText("SWT.ICON_ERROR");
    iconInformationButton = new Button(iconStyleGroup, SWT.RADIO);
    iconInformationButton.setText("SWT.ICON_INFORMATION");
    iconQuestionButton = new Button(iconStyleGroup, SWT.RADIO);
    iconQuestionButton.setText("SWT.ICON_QUESTION");
    iconWarningButton = new Button(iconStyleGroup, SWT.RADIO);
    iconWarningButton.setText("SWT.ICON_WARNING");
    iconWorkingButton = new Button(iconStyleGroup, SWT.RADIO);
    iconWorkingButton.setText("SWT.ICON_WORKING");
    noIconButton = new Button(iconStyleGroup, SWT.RADIO);
    noIconButton.setText(ControlExample.getResourceString("No_Icon"));

    /* Create a group for the modal style controls */
    Group modalStyleGroup = new Group(controlGroup, SWT.NONE);
    modalStyleGroup.setLayout(new GridLayout());
    modalStyleGroup.setLayoutData(
        new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
    modalStyleGroup.setText(ControlExample.getResourceString("Modal_Styles"));

    /* Create the modal style buttons */
    primaryModalButton = new Button(modalStyleGroup, SWT.RADIO);
    primaryModalButton.setText("SWT.PRIMARY_MODAL");
    applicationModalButton = new Button(modalStyleGroup, SWT.RADIO);
    applicationModalButton.setText("SWT.APPLICATION_MODAL");
    systemModalButton = new Button(modalStyleGroup, SWT.RADIO);
    systemModalButton.setText("SWT.SYSTEM_MODAL");

    /* Create a group for the file dialog style controls */
    Group fileDialogStyleGroup = new Group(controlGroup, SWT.NONE);
    fileDialogStyleGroup.setLayout(new GridLayout());
    fileDialogStyleGroup.setLayoutData(
        new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
    fileDialogStyleGroup.setText(ControlExample.getResourceString("File_Dialog_Styles"));

    /* Create the file dialog style buttons */
    openButton = new Button(fileDialogStyleGroup, SWT.RADIO);
    openButton.setText("SWT.OPEN");
    saveButton = new Button(fileDialogStyleGroup, SWT.RADIO);
    saveButton.setText("SWT.SAVE");
    multiButton = new Button(fileDialogStyleGroup, SWT.CHECK);
    multiButton.setText("SWT.MULTI");

    /* Create the orientation group */
    if (RTL_SUPPORT_ENABLE) {
      createOrientationGroup();
    }

    /* Add the listeners */
    dialogCombo.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent event) {
            dialogSelected(event);
          }
        });
    createButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent event) {
            createButtonSelected(event);
          }
        });
    SelectionListener buttonStyleListener =
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent event) {
            buttonStyleSelected(event);
          }
        };
    okButton.addSelectionListener(buttonStyleListener);
    cancelButton.addSelectionListener(buttonStyleListener);
    yesButton.addSelectionListener(buttonStyleListener);
    noButton.addSelectionListener(buttonStyleListener);
    retryButton.addSelectionListener(buttonStyleListener);
    abortButton.addSelectionListener(buttonStyleListener);
    ignoreButton.addSelectionListener(buttonStyleListener);

    /* Set default values for style buttons */
    okButton.setEnabled(false);
    cancelButton.setEnabled(false);
    yesButton.setEnabled(false);
    noButton.setEnabled(false);
    retryButton.setEnabled(false);
    abortButton.setEnabled(false);
    ignoreButton.setEnabled(false);
    iconErrorButton.setEnabled(false);
    iconInformationButton.setEnabled(false);
    iconQuestionButton.setEnabled(false);
    iconWarningButton.setEnabled(false);
    iconWorkingButton.setEnabled(false);
    noIconButton.setEnabled(false);
    saveButton.setEnabled(false);
    openButton.setEnabled(false);
    openButton.setSelection(true);
    multiButton.setEnabled(false);
    noIconButton.setSelection(true);
  }
示例#13
0
文件: FindTool.java 项目: URMC/i2b2
  public Control getFindTabControl(TabFolder tabFolder) {
    // Find Composite
    Composite compositeFind = new Composite(tabFolder, SWT.NULL);
    GridLayout gridLayout = new GridLayout(2, false);
    compositeFind.setLayout(gridLayout);
    /*		GridData fromTreeGridData = new GridData (GridData.FILL_BOTH);
    		fromTreeGridData.grabExcessHorizontalSpace = true;
    		fromTreeGridData.grabExcessVerticalSpace = true;
    	//	fromTreeGridData.widthHint = 300;
    		compositeFind.setLayoutData(fromTreeGridData);
    */

    //	First Set up the match combo box
    final Combo matchCombo = new Combo(compositeFind, SWT.READ_ONLY);

    matchCombo.add("Starting with");
    matchCombo.add("Ending with");
    matchCombo.add("Containing");
    matchCombo.add("Exact");

    // set default category
    matchCombo.setText("Containing");
    match = "Containing";

    matchCombo.addSelectionListener(
        new SelectionListener() {
          public void widgetSelected(SelectionEvent e) {
            // Item in list has been selected
            match = matchCombo.getItem(matchCombo.getSelectionIndex());
          }

          public void widgetDefaultSelected(SelectionEvent e) {
            // this is not an option (text cant be entered)
          }
        });

    // Then set up the Find text combo box
    final Combo findCombo = new Combo(compositeFind, SWT.DROP_DOWN);
    GridData findComboData = new GridData(GridData.FILL_HORIZONTAL);
    findComboData.widthHint = 200;
    findComboData.horizontalSpan = 1;
    findCombo.setLayoutData(findComboData);
    findCombo.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            // Text Item has been entered
            // Does not require 'return' to be entered
            findText = findCombo.getText();
          }
        });

    findCombo.addSelectionListener(
        new SelectionListener() {
          public void widgetSelected(SelectionEvent e) {}

          public void widgetDefaultSelected(SelectionEvent e) {
            findText = findCombo.getText();
            if (findCombo.indexOf(findText) < 0) {
              findCombo.add(findText);
            }
            if (findButton.getText().equals("Find")) {
              slm.setMessage("Performing search");
              slm.update(true);
              browser.flush();
              ModifierComposite.getInstance().disableComposite();
              System.setProperty("statusMessage", "Calling WebService");

              TreeNode placeholder = new TreeNode(1, "placeholder", "working...", "C-UNDEF");
              browser.rootNode.addChild(placeholder);
              browser.refresh();

              browser.getFindData(categoryKey, categories, findText, match).start();
              findButton.setText("Cancel");

            } else {
              System.setProperty("statusMessage", "Canceling WebService call");
              browser.refresh();
              browser.stopRunning = true;
              findButton.setText("Find");
            }
          }
        });

    // Next include 'Find' Button
    findButton = new Button(compositeFind, SWT.PUSH);
    findButton.setText("Find");
    GridData findButtonData = new GridData();
    if (OS.startsWith("mac")) findButtonData.widthHint = 80;
    else findButtonData.widthHint = 60;
    findButton.setLayoutData(findButtonData);
    findButton.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseDown(MouseEvent e) {
            // Add item to findCombo drop down list if not already there
            if (findText == null) {
              return;
            }
            if (findCombo.indexOf(findText) < 0) {
              findCombo.add(findText);
            }
            if (findButton.getText().equals("Find")) {
              ModifierComposite.getInstance().disableComposite();
              browser.flush();
              System.setProperty("statusMessage", "Calling WebService");
              TreeNode placeholder = new TreeNode(1, "placeholder", "working...", "C-UNDEF");
              browser.rootNode.addChild(placeholder);
              browser.refresh();

              browser.getFindData(categoryKey, categories, findText, match).start();
              findButton.setText("Cancel");
            } else {
              System.setProperty("statusMessage", "Canceling WebService call");
              browser.refresh();
              browser.stopRunning = true;
              findButton.setText("Find");
            }
          }
        });
    // Next set up the category combo box
    final Combo categoryCombo = new Combo(compositeFind, SWT.READ_ONLY);
    setCategories(categoryCombo);

    categoryCombo.addSelectionListener(
        new SelectionListener() {
          public void widgetSelected(SelectionEvent e) {
            // Item in list has been selected
            if (categoryCombo.getSelectionIndex() == 0) categoryKey = "any";
            else {
              ConceptType concept =
                  (ConceptType) categories.get(categoryCombo.getSelectionIndex() - 1);
              categoryKey = StringUtil.getTableCd(concept.getKey());
            }
          }

          public void widgetDefaultSelected(SelectionEvent e) {
            // this is not an option (text cant be entered)
          }
        });
    ModifierComposite.setInstance(compositeFind);
    browser = new NodeBrowser(compositeFind, 1, findButton, slm);

    return compositeFind;
  }