コード例 #1
0
 public void promptForNewFolder() {
   boolean done = false;
   String defaultText = "New Folder";
   String text = defaultText;
   while (!done) {
     if (text == null) {
       text = defaultText;
     }
     TextInputDialog textDialog =
         new TextInputDialog(
             Messages.getString("VfsBrowser.enterNewFolderName"), text, 500, 160); // $NON-NLS-1$
     text = textDialog.open();
     if (text != null && !"".equals(text)) { // $NON-NLS-1$
       try {
         vfsBrowser.createFolder(text); // $NON-NLS-1$
         done = true;
       } catch (FileSystemException e) {
         MessageBox errorDialog = new MessageBox(newFolderButton.getShell(), SWT.OK);
         errorDialog.setText(Messages.getString("VfsBrowser.error")); // $NON-NLS-1$
         if (e.getCause() != null) {
           errorDialog.setMessage(e.getCause().getMessage());
         } else {
           errorDialog.setMessage(e.getMessage());
         }
         errorDialog.open();
       }
     } else {
       done = true;
     }
   }
 }
コード例 #2
0
  public void createButtonPanel(Shell dialog) {
    Composite buttonPanel = new Composite(dialog, SWT.NONE);
    GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
    buttonPanel.setLayoutData(gridData);
    buttonPanel.setLayout(new GridLayout(4, false));

    String buttonAlign =
        System.getProperty("org.pentaho.di.buttonPosition", "right")
            .toLowerCase(); //$NON-NLS-1$ //$NON-NLS-2$

    if (!"left".equals(buttonAlign)) { // $NON-NLS-1$
      Label emptyLabel = new Label(buttonPanel, SWT.NONE);
      gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
      emptyLabel.setLayoutData(gridData);
    }
    okButton = new Button(buttonPanel, SWT.PUSH);
    okButton.setText(Messages.getString("VfsFileChooserDialog.ok")); // $NON-NLS-1$
    gridData = new GridData(SWT.FILL, SWT.FILL, false, false);
    gridData.widthHint = 90;
    okButton.setLayoutData(gridData);
    okButton.addSelectionListener(this);
    cancelButton = new Button(buttonPanel, SWT.PUSH);
    cancelButton.setText(Messages.getString("VfsFileChooserDialog.cancel")); // $NON-NLS-1$
    cancelButton.addSelectionListener(this);
    gridData = new GridData(SWT.FILL, SWT.FILL, false, false);
    gridData.widthHint = 90;
    cancelButton.setLayoutData(gridData);
    if ("center".equals(buttonAlign)) { // $NON-NLS-1$
      Label emptyLabel = new Label(buttonPanel, SWT.NONE);
      gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
      emptyLabel.setLayoutData(gridData);
    }
  }
コード例 #3
0
  public void createToolbarPanel(Shell dialog) {
    Composite chooserToolbarPanel = new Composite(dialog, SWT.NONE);
    chooserToolbarPanel.setLayout(new GridLayout(6, false));
    GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
    chooserToolbarPanel.setLayoutData(gridData);

    // changeRootButton = new Button(chooserToolbarPanel, SWT.PUSH);
    // changeRootButton.setToolTipText(Messages.getString("VfsFileChooserDialog.changeVFSRoot"));
    // //$NON-NLS-1$
    // changeRootButton.setImage(new Image(chooserToolbarPanel.getDisplay(),
    // getClass().getResourceAsStream("/icons/network.gif"))); //$NON-NLS-1$
    // gridData = new GridData(SWT.CENTER, SWT.CENTER, false, false);
    // changeRootButton.setLayoutData(gridData);
    // changeRootButton.addSelectionListener(this);

    Label parentFoldersLabel = new Label(chooserToolbarPanel, SWT.NONE);
    if (fileDialogMode != VFS_DIALOG_SAVEAS) {
      parentFoldersLabel.setText(
          Messages.getString("VfsFileChooserDialog.openFromFolder")); // $NON-NLS-1$
    } else {
      parentFoldersLabel.setText(
          Messages.getString("VfsFileChooserDialog.saveInFolder")); // $NON-NLS-1$
    }
    gridData = new GridData(SWT.FILL, SWT.CENTER, false, false);
    parentFoldersLabel.setLayoutData(gridData);
    openFileCombo = new Combo(chooserToolbarPanel, SWT.BORDER);
    gridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
    openFileCombo.setLayoutData(gridData);
    openFileCombo.addSelectionListener(this);
    openFileCombo.addKeyListener(
        new KeyListener() {

          public void keyPressed(KeyEvent event) {
            // UP :
            //
            if ((event.keyCode == SWT.ARROW_UP)
                && ((event.stateMask & SWT.CONTROL) == 0)
                && ((event.stateMask & SWT.ALT) == 0)) {
              resolveVfsBrowser();
              vfsBrowser.selectPreviousItem();
            }

            // DOWN:
            //
            if ((event.keyCode == SWT.ARROW_DOWN)
                && ((event.stateMask & SWT.CONTROL) == 0)
                && ((event.stateMask & SWT.ALT) == 0)) {
              resolveVfsBrowser();
              vfsBrowser.selectNextItem();
            }
          }

          public void keyReleased(KeyEvent event) {
            if (event.keyCode == SWT.CR || event.keyCode == SWT.KEYPAD_CR) {
              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 =
                // rootFile.getFileSystem().getFileSystemManager().resolveFile(getSelectedFile().getName().getURI());
                FileObject newRoot = currentPanel.resolveFile(openFileCombo.getText());

                vfsBrowser.resetVfsRoot(newRoot);
              } catch (FileSystemException e) {
                MessageBox errorDialog =
                    new MessageBox(vfsBrowser.getDisplay().getActiveShell(), SWT.OK);
                errorDialog.setText(
                    Messages.getString("VfsFileChooserDialog.error")); // $NON-NLS-1$
                errorDialog.setMessage(e.getMessage());
                errorDialog.open();
              }
            }
          }
        });
    folderUpButton = new Button(chooserToolbarPanel, SWT.PUSH);
    folderUpButton.setToolTipText(
        Messages.getString("VfsFileChooserDialog.upOneLevel")); // $NON-NLS-1$
    folderUpButton.setImage(getFolderUpImage(chooserToolbarPanel.getDisplay()));
    gridData = new GridData(SWT.CENTER, SWT.CENTER, false, false);
    folderUpButton.setLayoutData(gridData);
    folderUpButton.addSelectionListener(this);
    deleteFileButton = new Button(chooserToolbarPanel, SWT.PUSH);
    deleteFileButton.setToolTipText(
        Messages.getString("VfsFileChooserDialog.deleteFile")); // $NON-NLS-1$
    deleteFileButton.setImage(getDeleteImage(chooserToolbarPanel.getDisplay()));
    gridData = new GridData(SWT.CENTER, SWT.CENTER, false, false);
    deleteFileButton.setLayoutData(gridData);
    deleteFileButton.addSelectionListener(this);
    newFolderButton = new Button(chooserToolbarPanel, SWT.PUSH);
    newFolderButton.setToolTipText(
        Messages.getString("VfsFileChooserDialog.createNewFolder")); // $NON-NLS-1$
    newFolderButton.setImage(getNewFolderImage(chooserToolbarPanel.getDisplay()));
    gridData = new GridData(SWT.CENTER, SWT.CENTER, false, false);
    newFolderButton.setLayoutData(gridData);
    newFolderButton.addSelectionListener(this);
  }