/** Open an appropriate directory browser */
  private void handleLocationBrowseButtonPressed() {
    DirectoryDialog dialog = new DirectoryDialog(locationPathField.getShell(), SWT.SHEET);
    dialog.setMessage(DataTransferMessages.WizardExternalProjectImportPage_directoryLabel);

    String dirName = getProjectLocationFieldValue();
    if (dirName.length() == 0) {
      dirName = previouslyBrowsedDirectory;
    }

    if (dirName.length() == 0) {
      dialog.setFilterPath(getWorkspace().getRoot().getLocation().toOSString());
    } else {
      File path = new File(dirName);
      if (path.exists()) {
        dialog.setFilterPath(new Path(dirName).toOSString());
      }
    }

    String selectedDirectory = dialog.open();
    if (selectedDirectory != null) {
      previouslyBrowsedDirectory = selectedDirectory;
      locationPathField.setText(previouslyBrowsedDirectory);
      setProjectName(projectFile(previouslyBrowsedDirectory));
    }
  }
Esempio n. 2
0
 private File getFile() {
   FileDialog fileDialog = new FileDialog(textArea.getShell(), SWT.SAVE);
   String path = fileDialog.open();
   if (path == null || path.length() < 1) {
     return null;
   }
   return new File(path);
 }
Esempio n. 3
0
    public void keyPressed(KeyEvent e) {
      Text portsText = (Text) e.getSource();

      if (e.keyCode == SWT.TAB) {
        portsText.getShell().traverse(SWT.TRAVERSE_TAB_NEXT);
        e.doit = false;
        return;
      } else if (e.keyCode == SWT.CR) {
        if ((e.stateMask & SWT.MOD1) > 0) {
          // allow ctrl+enter to insert newlines
          e.stateMask = 0;
        } else {
          // single-enter will traverse
          portsText.getShell().traverse(SWT.TRAVERSE_RETURN);
          e.doit = false;
          return;
        }
      } else if (Character.isISOControl(e.character)) {
        return;
      }

      e.doit = validateChar(e.character, portsText.getText(), portsText.getCaretPosition());
    }
Esempio n. 4
0
 private void selectBuff() {
   ChooseDataObjectDialog dlg =
       new ChooseDataObjectDialog(textID.getShell(), BuffConfig.class, "选择Buff");
   if (dlg.open() == Dialog.OK) {
     if (dlg.getSelectedDataObject() != null) {
       BuffConfig buff = (BuffConfig) dlg.getSelectedDataObject();
       List<String> levelNames = new ArrayList<String>();
       for (int i = 1; i <= buff.maxLevel; i++) {
         levelNames.add(i + "级");
       }
       GenericChooseDialog dlg2 =
           new GenericChooseDialog(textID.getShell(), "选择Buff等级", levelNames);
       if (dlg2.open() == Dialog.OK) {
         String levelName = (String) dlg2.getSelection();
         int level = Integer.parseInt(levelName.substring(0, levelName.length() - 1));
         setBuff(buff.id, level);
       } else {
         setBuff(-1, 1);
       }
     } else {
       setBuff(-1, 1);
     }
   }
 }
  /** Opens a path variable selection dialog */
  private void handleVariablesButtonPressed() {
    int variableTypes = IResource.FOLDER;

    // allow selecting file and folder variables when creating a
    // linked file
    if (type == IResource.FILE) {
      variableTypes |= IResource.FILE;
    }

    PathVariableSelectionDialog dialog =
        new PathVariableSelectionDialog(linkTargetField.getShell(), variableTypes);
    if (dialog.open() == IDialogConstants.OK_ID) {
      String[] variableNames = (String[]) dialog.getResult();
      if ((variableNames != null) && (variableNames.length == 1)) {
        linkTargetField.setText(variableNames[0]);
      }
    }
  }
  /** Opens a file or directory browser depending on the link type. */
  private void handleLinkTargetBrowseButtonPressed() {
    IFileStore store = null;
    String selection = null;
    FileSystemConfiguration config = getSelectedConfiguration();
    @SuppressWarnings("unused")
    boolean isDefault =
        (config == null)
            || (FileSystemSupportRegistry.getInstance().getDefaultConfiguration()).equals(config);

    if (linkTarget.length() > 0) {
      store = IDEResourceInfoUtils.getFileStore(linkTarget);
      if (!store.fetchInfo().exists()) {
        store = null;
      }
    }
    if (type == IResource.FILE) {
      // if (isDefault) {
      // FileDialog dialog = new FileDialog(linkTargetField.getShell());
      // dialog.setText(IDEWorkbenchMessages.CreateLinkedResourceGroup_targetSelectionTitle);
      // if (store != null) {
      // if (store.fetchInfo().isDirectory()) {
      // dialog.setFilterPath(linkTarget);
      // } else {
      // dialog.setFileName(linkTarget);
      // }
      // }
      // selection = dialog.open();
      // } else {
      @SuppressWarnings("null")
      URI uri = config.getContributor().browseFileSystem(linkTarget, linkTargetField.getShell());
      if (uri != null) {
        selection = uri.toString();
        // }
      }
    } else {
      String filterPath = null;
      if (store != null) {
        IFileStore path = store;
        if (!store.fetchInfo().isDirectory()) {
          path = store.getParent();
        }
        if (path != null) {
          filterPath = store.toString();
        }
      }

      // if (isDefault) {
      // DirectoryDialog dialog = new DirectoryDialog(linkTargetField
      // .getShell());
      // dialog
      // .setMessage(IDEWorkbenchMessages.CreateLinkedResourceGroup_targetSelectionLabel);
      // if (filterPath != null)
      // dialog.setFilterPath(filterPath);
      // selection = dialog.open();
      // } else {
      String initialPath = IDEResourceInfoUtils.EMPTY_STRING;
      if (filterPath != null) {
        initialPath = filterPath;
      }
      if (config != null) {
        URI uri = config.getContributor().browseFileSystem(initialPath, linkTargetField.getShell());
        if (uri != null) {
          selection = uri.toString();
        }
      }
      // }
    }
    if (selection != null) {
      linkTargetField.setText(selection);
    }
  }
Esempio n. 7
0
 /*
  * Return whether the popup has focus.
  */
 boolean hasFocus() {
   if (text == null || text.isDisposed()) {
     return false;
   }
   return text.getShell().isFocusControl() || text.isFocusControl();
 }