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);
 }
  private void createMultiUserGroup(Composite parent) {
    final Group multiUserGroup =
        NSISWizardDialogUtil.createGroup(
            parent, 2, "MultiUser Installation", null, false); // $NON-NLS-1$
    GridData data = (GridData) multiUserGroup.getLayoutData();
    data.verticalAlignment = SWT.FILL;
    data.horizontalAlignment = SWT.FILL;
    data.grabExcessHorizontalSpace = true;

    NSISWizardSettings settings = mWizard.getSettings();

    Composite composite = new Composite(multiUserGroup, SWT.NONE);
    data = new GridData(SWT.FILL, SWT.FILL, true, true);
    composite.setLayoutData(data);

    GridLayout layout = new GridLayout(2, false);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    composite.setLayout(layout);

    final Button multiUser =
        NSISWizardDialogUtil.createCheckBox(
            composite,
            EclipseNSISPlugin.getResourceString("enable.multiuser.label"), // $NON-NLS-1$
            settings.isMultiUserInstallation(),
            settings.getInstallerType() == INSTALLER_TYPE_MUI2,
            null,
            false);
    multiUser.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            boolean selection = multiUser.getSelection();
            mWizard.getSettings().setMultiUserInstallation(selection);
            validateField(MULTIUSER_CHECK);
          }
        });

    final MasterSlaveController m = new MasterSlaveController(multiUser);

    boolean enabled = multiUser.isEnabled() && multiUser.getSelection();

    final Combo execLevel =
        NSISWizardDialogUtil.createCombo(
            composite,
            NSISWizardDisplayValues.MULTIUSER_EXEC_LEVELS,
            settings.getMultiUserExecLevel(),
            true,
            EclipseNSISPlugin.getResourceString("multiuser.exec.level.label"), // $NON-NLS-1$
            enabled,
            m,
            false);
    ((GridData) execLevel.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) execLevel.getLayoutData()).grabExcessHorizontalSpace = true;

    final Group instModeGroup =
        NSISWizardDialogUtil.createGroup(
            multiUserGroup, 1, "Installation Mode", m, false); // $NON-NLS-1$
    data = (GridData) instModeGroup.getLayoutData();
    data.verticalAlignment = SWT.FILL;
    data.horizontalAlignment = SWT.FILL;
    data.grabExcessHorizontalSpace = true;
    data.horizontalSpan = 1;

    MasterSlaveEnabler mse =
        new MasterSlaveEnabler() {
          public void enabled(Control control, boolean flag) {}

          public boolean canEnable(Control c) {
            return isMultiUser();
          }
        };
    m.addSlave(execLevel, mse);

    enabled = enabled && execLevel.getSelectionIndex() != MULTIUSER_EXEC_LEVEL_STANDARD;

    mse =
        new MasterSlaveEnabler() {
          public void enabled(Control control, boolean flag) {}

          public boolean canEnable(Control c) {
            return isMultiUser()
                && mWizard.getSettings().getMultiUserExecLevel() != MULTIUSER_EXEC_LEVEL_STANDARD;
          }
        };

    execLevel.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            mWizard.getSettings().setMultiUserExecLevel(execLevel.getSelectionIndex());
            m.updateSlaves();
            validateField(MULTIUSER_CHECK);
          }
        });

    final Combo instMode =
        NSISWizardDialogUtil.createCombo(
            instModeGroup,
            NSISWizardDisplayValues.MULTIUSER_INSTALL_MODES,
            settings.getMultiUserInstallMode(),
            true,
            EclipseNSISPlugin.getResourceString("multiuser.install.mode.label"),
            enabled,
            m,
            false); //$NON-NLS-1$
    ((GridData) instMode.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) instMode.getLayoutData()).horizontalAlignment = SWT.FILL;
    instMode.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            mWizard.getSettings().setMultiUserInstallMode(instMode.getSelectionIndex());
            validateField(MULTIUSER_CHECK);
          }
        });
    m.addSlave(instMode, mse);

    composite = new Composite(instModeGroup, SWT.NONE);
    data = new GridData(SWT.FILL, SWT.FILL, true, true);
    composite.setLayoutData(data);

    layout = new GridLayout(2, true);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    composite.setLayout(layout);

    final Button instModeRemember =
        NSISWizardDialogUtil.createCheckBox(
            composite,
            EclipseNSISPlugin.getResourceString("multiuser.install.mode.remember.label"),
            settings.isMultiUserInstallModeRemember(), // $NON-NLS-1$
            enabled,
            m,
            false);
    ((GridData) instModeRemember.getLayoutData()).horizontalSpan = 1;
    instModeRemember.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            mWizard.getSettings().setMultiUserInstallModeRemember(instModeRemember.getSelection());
            validateField(MULTIUSER_CHECK);
          }
        });
    m.addSlave(instModeRemember, mse);

    final Button instModeAsk =
        NSISWizardDialogUtil.createCheckBox(
            composite,
            EclipseNSISPlugin.getResourceString("multiuser.install.mode.ask.label"),
            settings.isMultiUserInstallModeAsk(), // $NON-NLS-1$
            enabled,
            m,
            false);
    ((GridData) instModeAsk.getLayoutData()).horizontalSpan = 1;
    instModeAsk.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            mWizard.getSettings().setMultiUserInstallModeAsk(instModeAsk.getSelection());
            validateField(MULTIUSER_CHECK);
          }
        });
    m.addSlave(instModeAsk, mse);

    m.updateSlaves();
    addPageChangedRunnable(
        new Runnable() {
          public void run() {
            if (isCurrentPage()) {
              NSISWizardDialogUtil.setEnabled(
                  multiUser, mWizard.getSettings().getInstallerType() == INSTALLER_TYPE_MUI2);
              m.updateSlaves();
            }
          }
        });

    mWizard.addSettingsListener(
        new INSISWizardSettingsListener() {
          public void settingsChanged(
              NSISWizardSettings oldSettings, NSISWizardSettings newSettings) {
            NSISWizardSettings settings = mWizard.getSettings();

            multiUser.setSelection(settings.isMultiUserInstallation());
            execLevel.select(settings.getMultiUserExecLevel());
            instMode.select(settings.getMultiUserInstallMode());
            instModeRemember.setSelection(settings.isMultiUserInstallModeRemember());
            instModeAsk.setSelection(settings.isMultiUserInstallModeAsk());
            NSISWizardDialogUtil.setEnabled(
                multiUser, settings.getInstallerType() == INSTALLER_TYPE_MUI2);
            m.updateSlaves();
          }
        });
  }
  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);
  }
  public void createCustomUIPanel(final Shell dialog) {
    customUIPanel = new Composite(dialog, SWT.NONE);
    GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
    customUIPanel.setLayoutData(gridData);
    customUIPanel.setLayout(new GridLayout(1, false));

    comboPanel = new Composite(customUIPanel, SWT.NONE);
    comboPanel.setLayoutData(gridData);
    comboPanel.setLayout(new GridLayout(2, false));
    comboPanel.setData("donotremove");

    Label lookInLabel = new Label(comboPanel, SWT.NONE);
    lookInLabel.setText(Messages.getString("VfsFileChooserDialog.LookIn"));
    gridData = new GridData(SWT.LEFT, SWT.CENTER, false, false);
    lookInLabel.setLayoutData(gridData);

    customUIPicker = new Combo(comboPanel, SWT.READ_ONLY);
    gridData = new GridData(SWT.LEFT, SWT.CENTER, true, false);
    customUIPicker.setLayoutData(gridData);

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

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

    customUIPicker.addSelectionListener(
        new SelectionListener() {

          public void widgetSelected(SelectionEvent event) {
            selectCustomUI();
          }

          public void widgetDefaultSelected(SelectionEvent event) {
            selectCustomUI();
          }
        });
    customUIPicker.addKeyListener(
        new KeyListener() {

          public void keyReleased(KeyEvent arg0) {
            selectCustomUI();
          }

          public void keyPressed(KeyEvent arg0) {
            selectCustomUI();
          }
        });

    boolean createdLocal = false;
    for (CustomVfsUiPanel panel : customUIPanels) {
      if (panel.getVfsScheme().equals("file")) {
        createdLocal = true;
      }
    }

    if (!createdLocal) {
      CustomVfsUiPanel localPanel =
          new CustomVfsUiPanel("file", "Local", this, SWT.None) {
            public void activate() {
              try {
                File startFile = new File(System.getProperty("user.home"));
                if (startFile == null || !startFile.exists()) {
                  startFile = File.listRoots()[0];
                }
                FileObject dot = fsm.resolveFile(startFile.toURI().toURL().toExternalForm());
                rootFile = dot.getFileSystem().getRoot();
                selectedFile = rootFile;
                setInitialFile(selectedFile);
                openFileCombo.setText(selectedFile.getName().getURI());
                resolveVfsBrowser();
              } catch (Throwable t) {
              }
            }
          };
      addVFSUIPanel(localPanel);
    }
  }
Exemplo n.º 5
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);
  }