@Override
  public final void createContents(Composite parent) {
    // This is a hacked fix to ensure that the label columns on every details
    // page have the same width. SchemaDetails_translatable plus 11 pixels
    // represents the longest label on any field on any details page. This
    // occurs on SchemaStringAttributeDetails and 11 is the size of the
    // horizontal indent that contributes to the label's width.
    GC gc = new GC(parent);
    minLabelWeight = gc.textExtent(PDEUIMessages.SchemaDetails_translatable).x + 11;
    gc.dispose();
    gc = null;

    parent.setLayout(FormLayoutFactory.createDetailsGridLayout(false, 1));
    FormToolkit toolkit = getManagedForm().getToolkit();
    fSection = toolkit.createSection(parent, Section.DESCRIPTION | ExpandableComposite.TITLE_BAR);
    fSection.clientVerticalSpacing = FormLayoutFactory.SECTION_HEADER_VERTICAL_SPACING;
    fSection.setLayout(FormLayoutFactory.createClearGridLayout(false, 1));

    GridData gd;
    if (fShowDescription) gd = new GridData(GridData.FILL_BOTH);
    else gd = new GridData(GridData.FILL_HORIZONTAL);
    fSection.setLayoutData(gd);

    // Align the master and details section headers (misalignment caused
    // by section toolbar icons)
    getPage().alignSectionHeaders(fElementSection.getSection(), fSection);

    Composite client = toolkit.createComposite(fSection);
    client.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 3));

    createDetails(client);

    if (fShowDescription) createDescription(client, toolkit);

    // If the DTD Approximation section was requested, instantiate it and create it's contents
    // on the same parent Composite
    if (fShowDTD) {
      fDtdSection = new SchemaDtdDetailsSection();
      fDtdSection.initialize(getManagedForm());
      fDtdSection.createContents(parent);
    }

    toolkit.paintBordersFor(client);
    fSection.setClient(client);
    markDetailsPart(fSection);

    if (fShowDescription) fDescriptionViewer.createUIListeners();
    hookListeners();
  }
  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);
    }
  }
  public void createFileNamePanel(Shell dialog, String fileName) {
    Composite fileNamePanel = new Composite(dialog, SWT.NONE);
    GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
    fileNamePanel.setLayoutData(gridData);
    fileNamePanel.setLayout(new GridLayout(2, false));
    Label fileNameLabel = new Label(fileNamePanel, SWT.NONE);
    fileNameLabel.setText(Messages.getString("VfsFileChooserDialog.fileName")); // $NON-NLS-1$
    gridData = new GridData(SWT.FILL, SWT.CENTER, false, false);
    fileNameLabel.setLayoutData(gridData);
    fileNameText = new Text(fileNamePanel, SWT.BORDER);
    if (fileName != null) {
      fileNameText.setText(fileName);
    }
    gridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
    fileNameText.setLayoutData(gridData);
    fileNameText.addKeyListener(
        new KeyListener() {

          public void keyPressed(KeyEvent arg0) {}

          public void keyReleased(KeyEvent event) {
            if (event.keyCode == SWT.CR || event.keyCode == SWT.KEYPAD_CR) {
              okPressed();
            }
          }
        });
  }
  public Composite create(Composite parentComp) {

    Composite comp = new Composite(parentComp, SWT.EMBEDDED);
    comp.setLayout(new MigLayout());
    createGroup(comp, "车站信息浏览", "pos 0.5al 0.2al", null);
    return comp;
  }
  @Override
  public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 3;
    layout.makeColumnsEqualWidth = false;
    layout.horizontalSpacing = 5;
    layout.verticalSpacing = 10;
    container.setLayout(layout);

    createScrollArea(container);
    createAvailableList(container).setLayoutData(new GridData(GridData.FILL_BOTH));
    createButtonArea(container);
    createImportList(container).setLayoutData(new GridData(GridData.FILL_BOTH));
    updateCount();

    // create container for buttons
    Composite optionComp =
        SWTFactory.createComposite(container, 1, 3, GridData.FILL_HORIZONTAL, 5, 0);
    createComputationsOption(optionComp);
    createFilterOptions(optionComp);

    addViewerListeners();
    initialize();
    addFilters();
    setControl(container);
    Dialog.applyDialogFont(container);
    PlatformUI.getWorkbench()
        .getHelpSystem()
        .setHelp(container, IHelpContextIds.PLUGIN_IMPORT_SECOND_PAGE);
  }
  private Composite createAvailableList(Composite parent) {
    Composite container = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    container.setLayout(layout);
    container.setLayoutData(new GridData());

    Label label = new Label(container, SWT.NONE);
    label.setText(PDEUIMessages.ImportWizard_DetailedPage_availableList);

    Table table = new Table(container, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL);
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.heightHint = 200;
    gd.widthHint = 225;
    table.setLayoutData(gd);

    fAvailableListViewer = new TableViewer(table);
    fAvailableListViewer.setLabelProvider(new PluginImportLabelProvider());
    fAvailableListViewer.setContentProvider(new ContentProvider());
    fAvailableListViewer.setInput(PDECore.getDefault().getModelManager());
    fAvailableListViewer.setComparator(ListUtil.PLUGIN_COMPARATOR);

    return container;
  }
Exemple #7
0
  public SpinnerFieldEditor(
      String name,
      String labelText,
      Composite parent,
      int min,
      int max,
      int increment,
      int pageIncrement) {
    init(name, labelText);

    GridLayout layout = new GridLayout();
    layout.numColumns = getNumberOfControls();
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    layout.horizontalSpacing = HORIZONTAL_GAP;
    parent.setLayout(layout);

    // create label control
    getLabelControl(parent);

    spinner = new BigDecimalSpinner(parent, SWT.NONE, 0, min, max, increment, pageIncrement);

    spinner.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent event) {
            valueChanged();
          }
        });

    doFillIntoGrid(parent, layout.numColumns);
  }
  public void createControl(Composite parent) {

    Composite pageContent = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 3;
    pageContent.setLayout(layout);
    pageContent.setLayoutData(new GridData(GridData.FILL_BOTH));

    // variable never used ... is pageContent.getLayoutData() needed?
    // GridData outerFrameGridData = (GridData)
    pageContent.getLayoutData();

    //		outerFrameGridData.horizontalAlignment = GridData.HORIZONTAL_ALIGN_FILL;
    //		outerFrameGridData.verticalAlignment = GridData.VERTICAL_ALIGN_FILL;

    //    WorkbenchHelp.setHelp(
    //        pageContent,
    //        B2BGUIContextIds.BTBG_SELECT_MULTI_FILE_PAGE);

    createLabels(pageContent);
    createSourceViewer(pageContent);
    createButtonPanel(pageContent);
    createSelectedListBox(pageContent);
    createImportButton(pageContent);

    setControl(pageContent);
    if (isFileMandatory) setPageComplete(false);
  }
  protected Composite createMaxOccurComp(Composite parent, FormToolkit toolkit) {
    fMaxLabel = toolkit.createLabel(parent, PDEUIMessages.AbstractSchemaDetails_maxOccurLabel);
    fMaxLabel.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
    Composite comp = toolkit.createComposite(parent);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    GridLayout layout = new GridLayout(3, false);
    layout.marginHeight = layout.marginWidth = 0;
    comp.setLayout(layout);
    comp.setLayoutData(gd);

    fMaxOccurSpinner = new Spinner(comp, SWT.BORDER);
    fMaxOccurSpinner.setMinimum(1);
    fMaxOccurSpinner.setMaximum(999);
    fMaxOccurSpinner.setIncrement(1);

    fUnboundSelect =
        toolkit.createButton(comp, PDEUIMessages.AbstractSchemaDetails_unboundedButton, SWT.CHECK);
    gd = new GridData();
    gd.horizontalIndent = 10;
    fUnboundSelect.setLayoutData(gd);
    fUnboundSelect.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if (blockListeners()) return;
            fMaxOccurSpinner.setEnabled(!fUnboundSelect.getSelection() && isEditableElement());
          }
        });

    return comp;
  }
  public Control createControl(Composite parent) {
    Composite comp = new Composite(parent, SWT.NONE);
    comp.setLayout(new GridLayout(3, false));
    comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    fButton = new Button(comp, SWT.CHECK);
    fButton.setText(PDEUIMessages.AdvancedPluginExportPage_signButton);
    GridData gd = new GridData();
    gd.horizontalSpan = 3;
    fButton.setLayoutData(gd);
    fButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            updateGroup(fButton.getSelection());
            fPage.pageChanged();
          }
        });

    fKeystoreLabel = createLabel(comp, PDEUIMessages.AdvancedPluginExportPage_keystore);
    fKeystoreText = createText(comp, 1);

    fBrowseButton = new Button(comp, SWT.PUSH);
    fBrowseButton.setText(PDEUIMessages.ExportWizard_browse);
    fBrowseButton.setLayoutData(new GridData());
    SWTUtil.setButtonDimensionHint(fBrowseButton);
    fBrowseButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            FileDialog dialog = new FileDialog(fPage.getShell(), SWT.OPEN);
            String path = fKeystoreText.getText();
            if (path.trim().length() == 0)
              path = PDEPlugin.getWorkspace().getRoot().getLocation().toString();
            dialog.setFileName(path);
            String res = dialog.open();
            if (res != null) {
              fKeystoreText.setText(res);
            }
          }
        });

    fKeypassLabel = createLabel(comp, PDEUIMessages.JARSigningTab_keypass);
    fKeypassText = createText(comp, 2);
    fKeypassText.setEchoChar('*');

    fAliasLabel = createLabel(comp, PDEUIMessages.AdvancedPluginExportPage_alias);
    fAliasText = createText(comp, 2);

    fPasswordLabel = createLabel(comp, PDEUIMessages.AdvancedPluginExportPage_password);
    fPasswordText = createText(comp, 2);
    fPasswordText.setEchoChar('*');

    Dialog.applyDialogFont(comp);
    PlatformUI.getWorkbench().getHelpSystem().setHelp(comp, IHelpContextIds.ADVANCED_PLUGIN_EXPORT);
    return comp;
  }
Exemple #11
0
  public TermWinUI(Shell parent) {
    self = new Shell(parent, SWT.SHELL_TRIM);
    self.setLayout(new GridLayout());

    mainPane = new Composite(self, SWT.NONE);
    mainPane.setLayout(new GridLayout(3, false));
    mainPane.setLayoutData(new GridData(GridData.FILL_BOTH));

    createContent();
  }
  protected Control createContents(Composite parent) {
    initializeValues();
    Composite composite = new Composite(parent, SWT.NULL);
    composite.setLayout(new GridLayout(1, false));
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));

    createControls(composite);

    return getControl();
  }
Exemple #13
0
 public static Composite createPlaceholder(Composite parent, int columns, int spacing) {
   Composite ph = new Composite(parent, SWT.NONE);
   GridLayout gl = new GridLayout(columns, false);
   gl.verticalSpacing = spacing;
   gl.horizontalSpacing = spacing;
   gl.marginHeight = 0;
   gl.marginWidth = 0;
   ph.setLayout(gl);
   return ph;
 }
 public void createContents(Composite parent) {
   shell = parent.getShell();
   parent.setLayout(new FillLayout());
   folder = new TabFolder(shell, SWT.BORDER);
   labelTab();
   directoryDialogTab();
   buttonTab();
   sliderTab();
   scribbleTab();
   browserTab();
 }
  private Control createImplicitTabContents(Composite parent) {
    Composite container = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(2, false);
    container.setLayout(layout);
    container.setLayoutData(new GridData(GridData.FILL_BOTH));
    container.setFont(parent.getFont());

    createImpLabel(container);
    createImpTable(container);
    createImpButtons(container);
    return container;
  }
  private void createProgressBarConfig(Composite parent) {
    fAddBarButton = createButton(parent, fToolkit, PDEUIMessages.SplashSection_progressBar);
    fAddBarButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            boolean enable = fAddBarButton.getSelection();
            getSplashInfo().addProgressBar(enable, false);
            updateFieldEnablement();
          }
        });
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.verticalIndent = 5;
    data.horizontalSpan = F_NUM_COLUMNS;
    fAddBarButton.setLayoutData(data);
    fAddBarButton.setEnabled(isEditable());

    Color foreground = fToolkit.getColors().getColor(IFormColors.TITLE);

    fBarControls[0] =
        createLabel(parent, fToolkit, foreground, PDEUIMessages.SplashSection_progressX);
    fBarControls[1] = fBarSpinners[0] = createSpinner(parent, fToolkit);
    fBarControls[2] =
        createLabel(parent, fToolkit, foreground, PDEUIMessages.SplashSection_progressY);
    fBarControls[3] = fBarSpinners[1] = createSpinner(parent, fToolkit);
    fBarControls[4] =
        createLabel(parent, fToolkit, foreground, PDEUIMessages.SplashSection_progressWidth);
    fBarControls[5] = fBarSpinners[2] = createSpinner(parent, fToolkit);
    fBarControls[6] =
        createLabel(parent, fToolkit, foreground, PDEUIMessages.SplashSection_progressHeight);
    fBarControls[7] = fBarSpinners[3] = createSpinner(parent, fToolkit);
    // Add tooltips to coordinate controls
    addOffsetTooltips(fBarControls);

    for (Spinner spinner : fBarSpinners) {
      spinner.setEnabled(isEditable());
      spinner.addModifyListener(
          new ModifyListener() {
            @Override
            public void modifyText(ModifyEvent e) {
              applySpinners(true);
            }
          });
    }

    Composite filler = fToolkit.createComposite(parent);
    filler.setLayout(new GridLayout());
    GridData gd = new GridData();
    gd.horizontalSpan = 2;
    filler.setLayoutData(gd);
  }
 protected Composite createMinOccurComp(Composite parent, FormToolkit toolkit) {
   fMinLabel = toolkit.createLabel(parent, PDEUIMessages.AbstractSchemaDetails_minOccurLabel);
   fMinLabel.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
   Composite comp = toolkit.createComposite(parent);
   GridData gd = new GridData(GridData.FILL_HORIZONTAL);
   gd.horizontalSpan = 2;
   GridLayout layout = new GridLayout();
   layout.marginHeight = layout.marginWidth = 0;
   comp.setLayout(layout);
   comp.setLayoutData(gd);
   fMinOccurSpinner = new Spinner(comp, SWT.BORDER);
   fMinOccurSpinner.setMinimum(0);
   fMinOccurSpinner.setMaximum(999);
   return comp;
 }
 public static void sliderTab() {
   TabItem tab = new TabItem(folder, SWT.CLOSE);
   tab.setText("Sliders and Progress bars");
   tab.setToolTipText("Tied Slider to ProgressBar");
   Composite composite = new Composite(folder, SWT.NONE);
   composite.setLayout(new GridLayout(2, true));
   final Slider slider = new Slider(composite, SWT.HORIZONTAL);
   final ProgressBar progress = new ProgressBar(composite, SWT.HORIZONTAL);
   slider.addSelectionListener(
       new SelectionAdapter() {
         public void widgetSelected(SelectionEvent event) {
           progress.setSelection(slider.getSelection());
         }
       });
   tab.setControl(composite);
 }
 protected Button[] createTrueFalseButtons(Composite parent, FormToolkit toolkit, int colSpan) {
   Composite comp = toolkit.createComposite(parent, SWT.NONE);
   GridLayout gl = new GridLayout(2, false);
   gl.marginHeight = gl.marginWidth = 0;
   comp.setLayout(gl);
   GridData gd = new GridData(GridData.FILL_HORIZONTAL);
   gd.horizontalSpan = colSpan;
   gd.horizontalIndent = FormLayoutFactory.CONTROL_HORIZONTAL_INDENT;
   comp.setLayoutData(gd);
   Button tButton = toolkit.createButton(comp, BOOLS[0], SWT.RADIO);
   Button fButton = toolkit.createButton(comp, BOOLS[1], SWT.RADIO);
   gd = new GridData();
   gd.horizontalIndent = 20;
   fButton.setLayoutData(gd);
   return new Button[] {tButton, fButton};
 }
 public static void buttonTab() {
   TabItem tab = new TabItem(folder, SWT.CLOSE);
   tab.setText("Buttons");
   tab.setToolTipText("Different kinds of Buttons");
   Composite composite = new Composite(folder, SWT.NONE);
   composite.setLayout(new GridLayout(4, true));
   for (int dir : new int[] {SWT.UP, SWT.RIGHT, SWT.LEFT, SWT.DOWN}) {
     Button b = new Button(composite, SWT.ARROW | dir);
     b.addListener(SWT.MouseDown, listener);
   }
   newButton(composite, SWT.CHECK, "Check button");
   newButton(composite, SWT.PUSH, "Push button");
   newButton(composite, SWT.RADIO, "Radio button");
   newButton(composite, SWT.TOGGLE, "Toggle button");
   newButton(composite, SWT.FLAT, "Flat button");
   tab.setControl(composite);
 }
 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 createButtonPanel(Composite pageContent) {
    Composite buttonPanel = new Composite(pageContent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    buttonPanel.setLayout(layout);

    GridData gridData = new GridData();
    gridData.grabExcessHorizontalSpace = false;
    gridData.grabExcessVerticalSpace = true;
    gridData.verticalAlignment = GridData.CENTER;
    gridData.horizontalAlignment = GridData.CENTER;
    buttonPanel.setLayoutData(gridData);

    addButton = new Button(buttonPanel, SWT.PUSH);
    addButton.setText(Messages._UI_ADD_BUTTON);
    gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.verticalAlignment = GridData.CENTER;
    addButton.setLayoutData(gridData);
    addButton.addSelectionListener(new ButtonSelectListener());
    addButton.setToolTipText(Messages._UI_ADD_BUTTON_TOOL_TIP);
    addButton.setEnabled(false);

    removeButton = new Button(buttonPanel, SWT.PUSH);
    removeButton.setText(Messages._UI_REMOVE_BUTTON);
    gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.verticalAlignment = GridData.CENTER;
    removeButton.setLayoutData(gridData);
    removeButton.addSelectionListener(new ButtonSelectListener());
    removeButton.setToolTipText(Messages._UI_REMOVE_BUTTON_TOOL_TIP);
    removeButton.setEnabled(false);

    removeAllButton = new Button(buttonPanel, SWT.PUSH);
    removeAllButton.setText(Messages._UI_REMOVE_ALL_BUTTON);
    gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.verticalAlignment = GridData.CENTER;
    removeAllButton.setLayoutData(gridData);
    removeAllButton.addSelectionListener(new ButtonSelectListener());
    removeAllButton.setToolTipText(Messages._UI_REMOVE_ALL_BUTTON_TOOL_TIP);
    removeAllButton.setEnabled(false);
  }
  /**
   * Builds the SWT controls for the three areas of a compare/merge viewer.
   *
   * <p>Calls the hooks <code>createControls</code> and <code>createToolItems</code> to let
   * subclasses build the specific content areas and to add items to an enclosing toolbar.
   *
   * <p>This method must only be called in the constructor of subclasses.
   *
   * @param parent the parent control
   * @return the new control
   */
  protected final Control buildControl(Composite parent) {

    fComposite =
        new Composite(parent, fStyles | SWT.LEFT_TO_RIGHT) { // we
          // force
          // a
          // specific
          // direction
          public boolean setFocus() {
            return ContentMergeViewer.this.handleSetFocus();
          }
        };
    fComposite.setData(CompareUI.COMPARE_VIEWER_TITLE, getTitle());

    hookControl(fComposite); // hook help & dispose listener

    fComposite.setLayout(new ContentMergeViewerLayout());

    int style = SWT.SHADOW_OUT;
    fAncestorLabel = new CLabel(fComposite, style | Window.getDefaultOrientation());

    fLeftLabel = new CLabel(fComposite, style | Window.getDefaultOrientation());
    new Resizer(fLeftLabel, VERTICAL);

    fDirectionLabel = new CLabel(fComposite, style);
    fDirectionLabel.setAlignment(SWT.CENTER);
    new Resizer(fDirectionLabel, HORIZONTAL | VERTICAL);

    fRightLabel = new CLabel(fComposite, style | Window.getDefaultOrientation());
    new Resizer(fRightLabel, VERTICAL);

    if (fCenter == null || fCenter.isDisposed()) fCenter = createCenterControl(fComposite);

    createControls(fComposite);

    fHandlerService =
        CompareHandlerService.createFor(
            getCompareConfiguration().getContainer(), fComposite.getShell());

    initializeToolbars(parent);

    return fComposite;
  }
 @Override
 protected Control createCustomArea(Composite parent) {
   Composite composite = new Composite(parent, SWT.NONE);
   composite.setLayout(new GridLayout());
   buttons = new Button[3];
   for (int i = 0; i < 3; i++) {
     buttons[i] = new Button(composite, SWT.RADIO);
     buttons[i].addSelectionListener(selectionListener);
     buttons[i].setText(
         NLS.bind(
             TeamUIMessages.SelectAncestorDialog_option,
             theResources[i].getFullPath().toPortableString()));
     buttons[i].setFont(parent.getFont());
     // set initial state
     buttons[i].setSelection(i == 0);
   }
   pickAncestor(0);
   return composite;
 }
  @Override
  protected Control createPageControl(Composite parent) {
    final Composite composite = new Composite(parent, SWT.NONE);

    GridLayout layout = new GridLayout(1, false);
    composite.setLayout(layout);

    createInstallationDirectoryGroup(composite);
    createStartMenuGroupGroup(composite);

    if (INSISVersions.VERSION_2_35.compareTo(NSISPreferences.getInstance().getNSISVersion()) <= 0) {
      createMultiUserGroup(composite);
    } else {
      mWizard.getSettings().setMultiUserInstallation(false);
    }

    createLanguagesGroup(composite);

    validatePage(VALIDATE_ALL);
    return composite;
  }
  /** @param composite */
  private void createInstallationDirectoryGroup(Composite parent) {
    Group instDirGroup =
        NSISWizardDialogUtil.createGroup(
            parent, 2, "installation.directory.group.label", null, false); // $NON-NLS-1$

    NSISWizardSettings settings = mWizard.getSettings();

    ((GridData)
                NSISWizardDialogUtil.createLabel(
                        instDirGroup, "installation.directory.label", true, null, isScriptWizard())
                    .getLayoutData())
            .horizontalSpan =
        1; //$NON-NLS-1$

    final Composite instDirComposite = new Composite(instDirGroup, SWT.NONE);
    instDirComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    final StackLayout instDirLayout = new StackLayout();
    instDirComposite.setLayout(instDirLayout);
    final Combo instDirCombo =
        NSISWizardDialogUtil.createCombo(
            instDirComposite,
            1,
            NSISWizardUtil.getPathConstantsAndVariables(settings.getTargetPlatform()),
            settings.getInstallDir(),
            false,
            true,
            null);
    final Text instDirText =
        NSISWizardDialogUtil.createText(instDirComposite, settings.getInstallDir(), 1, true, null);
    instDirLayout.topControl = instDirCombo;

    Runnable r =
        new Runnable() {
          private String mInstDirParent = ""; // $NON-NLS-1$

          private void updateInstDir(NSISWizardSettings settings) {
            Control topControl;
            if (isMultiUser()) {
              if (settings.getInstallDir().startsWith(mInstDirParent)) {
                String instDir = settings.getInstallDir().substring(mInstDirParent.length());
                settings.setInstallDir(instDir);
                instDirText.setText(instDir);
              }
              topControl = instDirText;
            } else {
              if (!settings.getInstallDir().startsWith(mInstDirParent)) {
                String instDir = mInstDirParent + settings.getInstallDir();
                settings.setInstallDir(instDir);
                instDirCombo.setText(instDir);
              }
              topControl = instDirCombo;
            }
            if (instDirLayout.topControl != topControl) {
              instDirLayout.topControl = topControl;
              instDirComposite.layout(true);
            }
            validateField(INSTDIR_CHECK);
          }

          public void run() {
            final PropertyChangeListener propertyListener =
                new PropertyChangeListener() {
                  public void propertyChange(PropertyChangeEvent evt) {
                    if (NSISWizardSettings.INSTALLER_TYPE.equals(evt.getPropertyName())
                        || NSISWizardSettings.MULTIUSER_INSTALLATION.equals(
                            evt.getPropertyName())) {
                      updateInstDir(mWizard.getSettings());
                    } else if (NSISWizardSettings.INSTALL_DIR.equals(evt.getPropertyName())) {
                      if (!isMultiUser()) {
                        setInstDirParent(mWizard.getSettings());
                      }
                    }
                  }
                };
            final INSISWizardSettingsListener settingsListener =
                new INSISWizardSettingsListener() {
                  public void settingsChanged(
                      NSISWizardSettings oldSettings, final NSISWizardSettings newSettings) {
                    if (oldSettings != null) {
                      oldSettings.removePropertyChangeListener(propertyListener);
                    }
                    setInstDirParent(newSettings);
                    if (newSettings != null) {
                      newSettings.addPropertyChangeListener(propertyListener);
                    }
                    updateInstDir(newSettings);
                  }
                };
            mWizard.addSettingsListener(settingsListener);
            mWizard.getSettings().addPropertyChangeListener(propertyListener);
            instDirCombo.addDisposeListener(
                new DisposeListener() {
                  public void widgetDisposed(DisposeEvent e) {
                    mWizard.getSettings().removePropertyChangeListener(propertyListener);
                    mWizard.removeSettingsListener(settingsListener);
                  }
                });
            setInstDirParent(mWizard.getSettings());
            updateInstDir(mWizard.getSettings());
          }

          private void setInstDirParent(NSISWizardSettings settings) {
            mInstDirParent = ""; // $NON-NLS-1$
            if (settings != null) {
              String instDir = settings.getInstallDir();
              if (!Common.isEmpty(instDir)) {
                int n = instDir.lastIndexOf('\\');
                if (n > 0 && n < instDir.length() - 1) {
                  mInstDirParent = instDir.substring(0, n + 1);
                }
              }
            }
          }
        };

    r.run();

    GridData gd = (GridData) instDirCombo.getLayoutData();
    gd.horizontalAlignment = GridData.FILL;
    gd.grabExcessHorizontalSpace = true;
    instDirCombo.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            String text = ((Combo) e.widget).getText();
            mWizard.getSettings().setInstallDir(text);
            validateField(INSTDIR_CHECK);
          }
        });
    instDirText.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            String text = ((Text) e.widget).getText();
            mWizard.getSettings().setInstallDir(text);
            validateField(INSTDIR_CHECK);
          }
        });

    final Button changeInstDir =
        NSISWizardDialogUtil.createCheckBox(
            instDirGroup,
            "change.installation.directory.label", //$NON-NLS-1$
            settings.isChangeInstallDir(),
            (settings.getInstallerType() != INSTALLER_TYPE_SILENT),
            null,
            false);
    changeInstDir.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            mWizard.getSettings().setChangeInstallDir(((Button) e.widget).getSelection());
          }
        });

    addPageChangedRunnable(
        new Runnable() {
          public void run() {
            if (isCurrentPage()) {
              NSISWizardSettings settings = mWizard.getSettings();
              instDirCombo.setText(settings.getInstallDir());
              changeInstDir.setEnabled(settings.getInstallerType() != INSTALLER_TYPE_SILENT);
            }
          }
        });

    final PropertyChangeListener propertyListener =
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent evt) {
            if (NSISWizardSettings.TARGET_PLATFORM.equals(evt.getPropertyName())) {
              NSISWizardDialogUtil.populateCombo(
                  instDirCombo,
                  NSISWizardUtil.getPathConstantsAndVariables(
                      ((Integer) evt.getNewValue()).intValue()),
                  ((NSISWizardSettings) evt.getSource()).getInstallDir());
            }
          }
        };
    settings.addPropertyChangeListener(propertyListener);
    final INSISWizardSettingsListener listener =
        new INSISWizardSettingsListener() {
          public void settingsChanged(
              NSISWizardSettings oldSettings, NSISWizardSettings newSettings) {
            if (oldSettings != null) {
              oldSettings.removePropertyChangeListener(propertyListener);
            }
            instDirCombo.setText(newSettings.getInstallDir());
            changeInstDir.setSelection(newSettings.isChangeInstallDir());
            changeInstDir.setEnabled(newSettings.getInstallerType() != INSTALLER_TYPE_SILENT);
            newSettings.addPropertyChangeListener(propertyListener);
          }
        };
    mWizard.addSettingsListener(listener);

    instDirGroup.addDisposeListener(
        new DisposeListener() {
          public void widgetDisposed(DisposeEvent e) {
            mWizard.removeSettingsListener(listener);
            mWizard.getSettings().removePropertyChangeListener(propertyListener);
          }
        });
  }
  @Override
  protected Control createControl(Composite parent) {
    Composite propertyComposite = new Composite(parent, SWT.BORDER);
    GridLayout layout = new GridLayout(1, false);
    layout.marginWidth = layout.marginHeight = 0;
    propertyComposite.setLayout(layout);
    if (mPage instanceof Page) {
      ((Page) mPage)
          .init(
              new IPageSite() {
                public void registerContextMenu(
                    String menuId, MenuManager menuManager, ISelectionProvider selectionProvider) {}

                public IActionBars getActionBars() {
                  return null;
                }

                public IWorkbenchPage getPage() {
                  return getWorkbenchWindow().getActivePage();
                }

                public ISelectionProvider getSelectionProvider() {
                  return null;
                }

                public Shell getShell() {
                  return getWorkbenchWindow().getShell();
                }

                public IWorkbenchWindow getWorkbenchWindow() {
                  return PlatformUI.getWorkbench().getActiveWorkbenchWindow();
                }

                public void setSelectionProvider(ISelectionProvider provider) {}

                @SuppressWarnings("unchecked")
                public Object getAdapter(Class adapter) {
                  return null;
                }

                @SuppressWarnings("unchecked")
                public Object getService(Class api) {
                  return null;
                }

                @SuppressWarnings("unchecked")
                public boolean hasService(Class api) {
                  return false;
                }
              });
    }
    if (mPage instanceof PropertySheetPage) {
      ((PropertySheetPage) mPage).setPropertySourceProvider(this);
    }
    mPage.createControl(propertyComposite);
    mPage.setActionBars(new DummyActionBars());
    final Control control = mPage.getControl();
    GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
    if (control instanceof Tree) {
      final Tree tree = (Tree) control;
      data.heightHint =
          tree.getItemHeight() * 13
              + (tree.getLinesVisible() ? 12 * tree.getGridLineWidth() : 0)
              + (tree.getHeaderVisible() ? tree.getHeaderHeight() : 0)
              + 2 * tree.getBorderWidth()
              + (tree.getHorizontalBar() != null ? tree.getHorizontalBar().getSize().x : 0);
      tree.addControlListener(
          new ControlAdapter() {
            @Override
            public void controlResized(ControlEvent e) {
              Rectangle area = tree.getClientArea();
              TreeColumn[] columns = tree.getColumns();
              if (area.width > 0) {
                columns[0].setWidth(area.width * 40 / 100);
                columns[1].setWidth(area.width - columns[0].getWidth() - 4);
              }
            }
          });
    } else if (control instanceof Composite) {
      control.addControlListener(
          new ControlAdapter() {
            @Override
            public void controlResized(ControlEvent e) {
              ((Composite) control).layout(true, true);
            }
          });
    }
    control.setLayoutData(data);
    ISelection selection;
    if (mCurrentWidget == null) {
      Collection<InstallOptionsModelTypeDef> typeDefs =
          InstallOptionsModel.INSTANCE.getControlTypeDefs();
      if (typeDefs.size() > 0) {
        InstallOptionsModelTypeDef typeDef = typeDefs.iterator().next();
        InstallOptionsElementFactory factory =
            InstallOptionsElementFactory.getFactory(typeDef.getType());
        mCurrentWidget = (InstallOptionsWidget) factory.getNewObject();
        mDialog.addChild(mCurrentWidget);
      }
    }

    if (mCurrentWidget != null) {
      mCurrentWidget.addModelCommandListener(InstallOptionsWidgetEditorDialog.this);
      mCurrentWidget.addPropertyChangeListener(InstallOptionsWidgetEditorDialog.this);
      if (mCurrentWidget.getParent() != null) {
        mCurrentWidget.getParent().addPropertyChangeListener(InstallOptionsWidgetEditorDialog.this);
      }
      selection = new StructuredSelection(mCurrentWidget);
    } else {
      selection = StructuredSelection.EMPTY;
    }

    mPage.selectionChanged(null, selection);
    PlatformUI.getWorkbench().getHelpSystem().setHelp(mPage.getControl(), HELP_CONTEXT);
    PlatformUI.getWorkbench().getHelpSystem().setHelp(propertyComposite, HELP_CONTEXT);

    return propertyComposite;
  }
  private Composite createButtonArea(Composite parent) {
    ScrolledComposite comp = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL);
    GridLayout layout = new GridLayout();
    layout.marginWidth = layout.marginHeight = 0;
    comp.setLayoutData(new GridData(GridData.FILL_VERTICAL));
    Composite container = new Composite(comp, SWT.NONE);
    layout = new GridLayout();
    layout.marginWidth = 0;
    container.setLayout(layout);
    GridData gd = new GridData(GridData.FILL_VERTICAL);
    gd.verticalIndent = 15;
    container.setLayoutData(gd);

    Button button = new Button(container, SWT.PUSH);
    button.setText(PDEUIMessages.ImportWizard_DetailedPage_existing);
    button.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    button.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            handleExistingProjects();
          }
        });
    SWTUtil.setButtonDimensionHint(button);

    button = new Button(container, SWT.PUSH);
    button.setText(PDEUIMessages.ImportWizard_DetailedPage_existingUnshared);
    button.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    button.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            handleExistingUnshared();
          }
        });
    SWTUtil.setButtonDimensionHint(button);

    fAddButton = new Button(container, SWT.PUSH);
    fAddButton.setText(PDEUIMessages.ImportWizard_DetailedPage_add);
    fAddButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    fAddButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            handleAdd();
          }
        });
    SWTUtil.setButtonDimensionHint(fAddButton);

    fAddAllButton = new Button(container, SWT.PUSH);
    fAddAllButton.setText(PDEUIMessages.ImportWizard_DetailedPage_addAll);
    fAddAllButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    fAddAllButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            handleAddAll();
          }
        });
    SWTUtil.setButtonDimensionHint(fAddAllButton);

    fRemoveButton = new Button(container, SWT.PUSH);
    fRemoveButton.setText(PDEUIMessages.ImportWizard_DetailedPage_remove);
    fRemoveButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    fRemoveButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            handleRemove();
          }
        });
    SWTUtil.setButtonDimensionHint(fRemoveButton);

    fRemoveAllButton = new Button(container, SWT.PUSH);
    fRemoveAllButton.setText(PDEUIMessages.ImportWizard_DetailedPage_removeAll);
    fRemoveAllButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    fRemoveAllButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            handleRemoveAll();
          }
        });
    SWTUtil.setButtonDimensionHint(fRemoveAllButton);

    button = new Button(container, SWT.PUSH);
    button.setText(PDEUIMessages.ImportWizard_DetailedPage_swap);
    button.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    button.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            handleSwap();
          }
        });
    SWTUtil.setButtonDimensionHint(button);

    fAddRequiredButton = new Button(container, SWT.PUSH);
    fAddRequiredButton.setText(PDEUIMessages.ImportWizard_DetailedPage_addRequired);
    fAddRequiredButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    fAddRequiredButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            handleAddRequiredPlugins();
          }
        });
    SWTUtil.setButtonDimensionHint(fAddRequiredButton);

    fCountLabel = new Label(container, SWT.NONE);
    fCountLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
    comp.setContent(container);
    comp.setMinHeight(250);
    comp.setExpandHorizontal(true);
    comp.setExpandVertical(true);
    return container;
  }
  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();
          }
        });
  }
  private void createLanguagesGroup(Composite parent) {
    final Group langGroup =
        NSISWizardDialogUtil.createGroup(
            parent, 1, "language.support.group.label", null, false); // $NON-NLS-1$
    GridData data = (GridData) langGroup.getLayoutData();
    data.verticalAlignment = SWT.FILL;
    data.grabExcessVerticalSpace = true;
    data.horizontalAlignment = SWT.FILL;
    data.grabExcessHorizontalSpace = true;

    NSISWizardSettings settings = mWizard.getSettings();

    final Button enableLangSupport =
        NSISWizardDialogUtil.createCheckBox(
            langGroup,
            "enable.language.support.label",
            settings.isEnableLanguageSupport(),
            true,
            null,
            false); //$NON-NLS-1$
    enableLangSupport.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            boolean selection = enableLangSupport.getSelection();
            mWizard.getSettings().setEnableLanguageSupport(selection);
            validateField(LANG_CHECK);
          }
        });

    final MasterSlaveController m = new MasterSlaveController(enableLangSupport);

    final Composite listsComposite = new Composite(langGroup, SWT.NONE);
    data = new GridData(SWT.FILL, SWT.FILL, true, true);
    listsComposite.setLayoutData(data);

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

    java.util.List<NSISLanguage> selectedLanguages = settings.getLanguages();
    if (selectedLanguages.isEmpty()) {
      NSISLanguage defaultLanguage = NSISLanguageManager.getInstance().getDefaultLanguage();
      if (defaultLanguage != null) {
        selectedLanguages.add(defaultLanguage);
      }
    }
    java.util.List<NSISLanguage> availableLanguages =
        NSISLanguageManager.getInstance().getLanguages();
    availableLanguages.removeAll(selectedLanguages);

    Composite leftComposite = new Composite(listsComposite, SWT.NONE);
    leftComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    layout = new GridLayout(2, false);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    leftComposite.setLayout(layout);

    ((GridData)
                NSISWizardDialogUtil.createLabel(
                        leftComposite,
                        "available.languages.label", //$NON-NLS-1$
                        true,
                        m,
                        false)
                    .getLayoutData())
            .horizontalSpan =
        2;

    final List availableLangList =
        new List(leftComposite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI);
    data = new GridData(SWT.FILL, SWT.FILL, true, true);
    Dialog.applyDialogFont(availableLangList);
    data.heightHint = Common.calculateControlSize(availableLangList, 0, 12).y;
    availableLangList.setLayoutData(data);
    m.addSlave(availableLangList);

    final ListViewer availableLangViewer = new ListViewer(availableLangList);
    CollectionContentProvider collectionContentProvider = new CollectionContentProvider();
    availableLangViewer.setContentProvider(collectionContentProvider);
    availableLangViewer.setInput(availableLanguages);
    availableLangViewer.setSorter(new ViewerSorter(cLanguageCollator));

    final Composite buttonsComposite1 = new Composite(leftComposite, SWT.NONE);
    layout = new GridLayout(1, false);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    buttonsComposite1.setLayout(layout);
    data = new GridData(SWT.FILL, SWT.CENTER, false, false);
    buttonsComposite1.setLayoutData(data);

    final Button allRightButton = new Button(buttonsComposite1, SWT.PUSH);
    data = new GridData(SWT.FILL, SWT.CENTER, true, false);
    allRightButton.setLayoutData(data);
    allRightButton.setImage(
        EclipseNSISPlugin.getImageManager()
            .getImage(EclipseNSISPlugin.getResourceString("all.right.icon"))); // $NON-NLS-1$
    allRightButton.setToolTipText(
        EclipseNSISPlugin.getResourceString("all.right.tooltip")); // $NON-NLS-1$

    final Button rightButton = new Button(buttonsComposite1, SWT.PUSH);
    data = new GridData(SWT.FILL, SWT.CENTER, true, false);
    rightButton.setLayoutData(data);
    rightButton.setImage(
        EclipseNSISPlugin.getImageManager()
            .getImage(EclipseNSISPlugin.getResourceString("right.icon"))); // $NON-NLS-1$
    rightButton.setToolTipText(EclipseNSISPlugin.getResourceString("right.tooltip")); // $NON-NLS-1$

    final Button leftButton = new Button(buttonsComposite1, SWT.PUSH);
    data = new GridData(SWT.FILL, SWT.CENTER, true, false);
    leftButton.setLayoutData(data);
    leftButton.setImage(
        EclipseNSISPlugin.getImageManager()
            .getImage(EclipseNSISPlugin.getResourceString("left.icon"))); // $NON-NLS-1$
    leftButton.setToolTipText(EclipseNSISPlugin.getResourceString("left.tooltip")); // $NON-NLS-1$

    final Button allLeftButton = new Button(buttonsComposite1, SWT.PUSH);
    data = new GridData(SWT.FILL, SWT.CENTER, true, false);
    allLeftButton.setLayoutData(data);
    allLeftButton.setImage(
        EclipseNSISPlugin.getImageManager()
            .getImage(EclipseNSISPlugin.getResourceString("all.left.icon"))); // $NON-NLS-1$
    allLeftButton.setToolTipText(
        EclipseNSISPlugin.getResourceString("all.left.tooltip")); // $NON-NLS-1$

    Composite rightComposite = new Composite(listsComposite, SWT.NONE);
    rightComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    layout = new GridLayout(2, false);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    rightComposite.setLayout(layout);

    ((GridData)
                NSISWizardDialogUtil.createLabel(
                        rightComposite,
                        "selected.languages.label", //$NON-NLS-1$
                        true,
                        m,
                        isScriptWizard())
                    .getLayoutData())
            .horizontalSpan =
        2;

    final List selectedLangList =
        new List(rightComposite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI);
    data = new GridData(SWT.FILL, SWT.FILL, true, true);
    Dialog.applyDialogFont(selectedLangList);
    data.heightHint = Common.calculateControlSize(selectedLangList, 0, 12).y;
    selectedLangList.setLayoutData(data);
    m.addSlave(selectedLangList);

    final ListViewer selectedLangViewer = new ListViewer(selectedLangList);
    selectedLangViewer.setContentProvider(collectionContentProvider);
    selectedLangViewer.setInput(selectedLanguages);

    final ListViewerUpDownMover<java.util.List<NSISLanguage>, NSISLanguage> mover =
        new ListViewerUpDownMover<java.util.List<NSISLanguage>, NSISLanguage>() {
          @Override
          @SuppressWarnings("unchecked")
          protected java.util.List<NSISLanguage> getAllElements() {
            return (java.util.List<NSISLanguage>) ((ListViewer) getViewer()).getInput();
          }

          @Override
          protected void updateStructuredViewerInput(
              java.util.List<NSISLanguage> input,
              java.util.List<NSISLanguage> elements,
              java.util.List<NSISLanguage> move,
              boolean isDown) {
            (input).clear();
            (input).addAll(elements);
          }
        };

    mover.setViewer(selectedLangViewer);

    final Composite buttonsComposite2 = new Composite(rightComposite, SWT.NONE);
    layout = new GridLayout(1, false);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    buttonsComposite2.setLayout(layout);
    data = new GridData(SWT.FILL, SWT.CENTER, false, false);
    buttonsComposite2.setLayoutData(data);

    final Button upButton = new Button(buttonsComposite2, SWT.PUSH);
    data = new GridData(SWT.FILL, SWT.CENTER, true, false);
    upButton.setLayoutData(data);
    upButton.setImage(
        EclipseNSISPlugin.getImageManager()
            .getImage(EclipseNSISPlugin.getResourceString("up.icon"))); // $NON-NLS-1$
    upButton.setToolTipText(EclipseNSISPlugin.getResourceString("up.tooltip")); // $NON-NLS-1$
    m.addSlave(upButton);

    final Button downButton = new Button(buttonsComposite2, SWT.PUSH);
    data = new GridData(SWT.FILL, SWT.CENTER, true, false);
    downButton.setLayoutData(data);
    downButton.setImage(
        EclipseNSISPlugin.getImageManager()
            .getImage(EclipseNSISPlugin.getResourceString("down.icon"))); // $NON-NLS-1$
    downButton.setToolTipText(EclipseNSISPlugin.getResourceString("down.tooltip")); // $NON-NLS-1$
    m.addSlave(downButton);

    Composite langOptions = langGroup;
    boolean showSupportedLangOption =
        NSISPreferences.getInstance().getNSISVersion().compareTo(INSISVersions.VERSION_2_26) >= 0;
    if (showSupportedLangOption) {
      langOptions = new Composite(langGroup, SWT.None);
      layout = new GridLayout(2, false);
      layout.marginHeight = 0;
      layout.marginWidth = 0;
      langOptions.setLayout(layout);
      data = new GridData(SWT.FILL, SWT.FILL, true, false);
      langOptions.setLayoutData(data);
    }

    final Button selectLang =
        NSISWizardDialogUtil.createCheckBox(
            langOptions,
            "select.language.label",
            settings.isSelectLanguage(),
            true,
            m,
            false); //$NON-NLS-1$

    final Button displaySupported;
    if (showSupportedLangOption) {
      ((GridData) selectLang.getLayoutData()).horizontalSpan = 1;
      displaySupported =
          NSISWizardDialogUtil.createCheckBox(
              langOptions,
              "display.supported.languages.label",
              settings.isDisplaySupportedLanguages(), // $NON-NLS-1$
              true,
              m,
              false);
      ((GridData) displaySupported.getLayoutData()).horizontalSpan = 1;
      displaySupported.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              mWizard.getSettings().setDisplaySupportedLanguages(displaySupported.getSelection());
            }
          });
    } else {
      displaySupported = null;
    }

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

          @SuppressWarnings("unchecked")
          public boolean canEnable(Control control) {
            NSISWizardSettings settings = mWizard.getSettings();

            if (control == allRightButton) {
              return settings.isEnableLanguageSupport()
                  && availableLangViewer.getList().getItemCount() > 0;
            } else if (control == rightButton) {
              return settings.isEnableLanguageSupport()
                  && !availableLangViewer.getSelection().isEmpty();
            } else if (control == allLeftButton) {
              return settings.isEnableLanguageSupport()
                  && selectedLangViewer.getList().getItemCount() > 0;
            } else if (control == leftButton) {
              return settings.isEnableLanguageSupport()
                  && !selectedLangViewer.getSelection().isEmpty();
            } else if (control == upButton) {
              return settings.isEnableLanguageSupport() && mover.canMoveUp();
            } else if (control == downButton) {
              return settings.isEnableLanguageSupport() && mover.canMoveDown();
            } else if (control == selectLang) {
              java.util.List<NSISLanguage> selectedLanguages =
                  (java.util.List<NSISLanguage>) selectedLangViewer.getInput();
              return settings.getInstallerType() != INSTALLER_TYPE_SILENT
                  && settings.isEnableLanguageSupport()
                  && selectedLanguages.size() > 1;
            } else if (control == displaySupported && displaySupported != null) {
              java.util.List<NSISLanguage> selectedLanguages =
                  (java.util.List<NSISLanguage>) selectedLangViewer.getInput();
              return settings.getInstallerType() != INSTALLER_TYPE_SILENT
                  && settings.isEnableLanguageSupport()
                  && selectedLanguages.size() > 1
                  && selectLang.getSelection();
            } else {
              return true;
            }
          }
        };
    m.addSlave(rightButton, mse);
    m.addSlave(allRightButton, mse);
    m.addSlave(leftButton, mse);
    m.addSlave(allLeftButton, mse);
    m.setEnabler(upButton, mse);
    m.setEnabler(downButton, mse);
    m.setEnabler(selectLang, mse);
    if (displaySupported != null) {
      m.setEnabler(displaySupported, mse);
    }

    selectLang.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            mWizard.getSettings().setSelectLanguage(selectLang.getSelection());
            if (displaySupported != null) {
              displaySupported.setEnabled(mse.canEnable(displaySupported));
            }
          }
        });

    final Runnable langRunnable =
        new Runnable() {
          public void run() {
            availableLangViewer.refresh(false);
            selectedLangViewer.refresh(false);
            allRightButton.setEnabled(mse.canEnable(allRightButton));
            allLeftButton.setEnabled(mse.canEnable(allLeftButton));
            rightButton.setEnabled(mse.canEnable(rightButton));
            leftButton.setEnabled(mse.canEnable(leftButton));
            upButton.setEnabled(mse.canEnable(upButton));
            downButton.setEnabled(mse.canEnable(downButton));
            selectLang.setEnabled(mse.canEnable(selectLang));
            if (displaySupported != null) {
              displaySupported.setEnabled(mse.canEnable(displaySupported));
            }
            setPageComplete(validateField(LANG_CHECK));
          }
        };

    rightButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent se) {
            moveAcross(
                availableLangViewer,
                selectedLangViewer,
                Common.makeGenericList(
                    NSISLanguage.class,
                    ((IStructuredSelection) availableLangViewer.getSelection()).toList()));
            langRunnable.run();
          }
        });
    allRightButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          @SuppressWarnings("unchecked")
          public void widgetSelected(SelectionEvent se) {
            moveAcross(
                availableLangViewer,
                selectedLangViewer,
                (java.util.List<NSISLanguage>) availableLangViewer.getInput());
            langRunnable.run();
          }
        });
    leftButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent se) {
            moveAcross(
                selectedLangViewer,
                availableLangViewer,
                Common.makeGenericList(
                    NSISLanguage.class,
                    ((IStructuredSelection) selectedLangViewer.getSelection()).toList()));
            langRunnable.run();
          }
        });
    allLeftButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          @SuppressWarnings("unchecked")
          public void widgetSelected(SelectionEvent se) {
            moveAcross(
                selectedLangViewer,
                availableLangViewer,
                (java.util.List<NSISLanguage>) selectedLangViewer.getInput());
            langRunnable.run();
          }
        });
    upButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent se) {
            mover.moveUp();
            langRunnable.run();
          }
        });
    downButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent se) {
            mover.moveDown();
            langRunnable.run();
          }
        });

    availableLangViewer.addSelectionChangedListener(
        new ISelectionChangedListener() {
          public void selectionChanged(SelectionChangedEvent event) {
            rightButton.setEnabled(mse.canEnable(rightButton));
            allRightButton.setEnabled(mse.canEnable(allRightButton));
          }
        });
    availableLangViewer
        .getList()
        .addSelectionListener(
            new SelectionAdapter() {
              @Override
              public void widgetDefaultSelected(SelectionEvent event) {
                IStructuredSelection sel =
                    (IStructuredSelection) availableLangViewer.getSelection();
                if (!sel.isEmpty()) {
                  moveAcross(
                      availableLangViewer,
                      selectedLangViewer,
                      Common.makeGenericList(NSISLanguage.class, sel.toList()));
                  selectedLangViewer.reveal(sel.getFirstElement());
                  langRunnable.run();
                }
              }
            });
    selectedLangViewer.addSelectionChangedListener(
        new ISelectionChangedListener() {
          public void selectionChanged(SelectionChangedEvent event) {
            leftButton.setEnabled(mse.canEnable(leftButton));
            allLeftButton.setEnabled(mse.canEnable(allLeftButton));
            upButton.setEnabled(mse.canEnable(upButton));
            downButton.setEnabled(mse.canEnable(downButton));
            selectLang.setEnabled(mse.canEnable(selectLang));
            if (displaySupported != null) {
              displaySupported.setEnabled(mse.canEnable(displaySupported));
            }
          }
        });
    selectedLangViewer
        .getList()
        .addSelectionListener(
            new SelectionAdapter() {
              @Override
              public void widgetDefaultSelected(SelectionEvent event) {
                IStructuredSelection sel = (IStructuredSelection) selectedLangViewer.getSelection();
                if (!sel.isEmpty()) {
                  moveAcross(
                      selectedLangViewer,
                      availableLangViewer,
                      Common.makeGenericList(NSISLanguage.class, sel.toList()));
                  availableLangViewer.reveal(sel.getFirstElement());
                  langRunnable.run();
                }
              }
            });

    m.updateSlaves();

    listsComposite.addListener(
        SWT.Resize,
        new Listener() {
          boolean init = false;

          public void handleEvent(Event e) {
            if (!init) {
              // Stupid hack so that the height hint doesn't get changed
              // on the first resize,
              // i.e., when the page is drawn for the first time.
              init = true;
            } else {
              Point size = listsComposite.getSize();
              GridLayout layout = (GridLayout) listsComposite.getLayout();
              int heightHint = size.y - 2 * layout.marginHeight;
              ((GridData) availableLangList.getLayoutData()).heightHint = heightHint;
              ((GridData) selectedLangList.getLayoutData()).heightHint = heightHint;
              int totalWidth = size.x - 2 * layout.marginWidth - 3 * layout.horizontalSpacing;
              int listWidth = (int) (totalWidth * 0.4);
              int buttonWidth = (int) (0.5 * (totalWidth - 2 * listWidth));
              size = availableLangList.computeSize(listWidth, SWT.DEFAULT);
              int delta = 0;
              if (size.x > listWidth) {
                delta = size.x - listWidth;
                listWidth = listWidth - delta;
              }
              ((GridData) availableLangList.getLayoutData()).widthHint = listWidth;
              ((GridData) buttonsComposite1.getLayoutData()).widthHint =
                  totalWidth - 2 * (listWidth + delta) - buttonWidth;
              ((GridData) selectedLangList.getLayoutData()).widthHint = listWidth;
              ((GridData) buttonsComposite2.getLayoutData()).widthHint = buttonWidth;
              listsComposite.layout();
            }
          }
        });

    addPageChangedRunnable(
        new Runnable() {
          public void run() {
            if (isCurrentPage()) {
              selectLang.setEnabled(mse.canEnable(selectLang));
              if (displaySupported != null) {
                displaySupported.setEnabled(mse.canEnable(displaySupported));
              }
            }
          }
        });

    mWizard.addSettingsListener(
        new INSISWizardSettingsListener() {
          public void settingsChanged(
              NSISWizardSettings oldSettings, NSISWizardSettings newSettings) {
            enableLangSupport.setSelection(newSettings.isEnableLanguageSupport());
            m.updateSlaves();
            selectLang.setSelection(newSettings.isSelectLanguage());
            if (displaySupported != null) {
              displaySupported.setSelection(newSettings.isDisplaySupportedLanguages());
            }
            java.util.List<NSISLanguage> selectedLanguages = newSettings.getLanguages();
            java.util.List<NSISLanguage> availableLanguages =
                NSISLanguageManager.getInstance().getLanguages();
            if (selectedLanguages.isEmpty()) {
              NSISWizardWelcomePage welcomePage =
                  (NSISWizardWelcomePage) mWizard.getPage(NSISWizardWelcomePage.NAME);
              if (welcomePage != null) {
                if (!welcomePage.isCreateFromTemplate()) {
                  NSISLanguage defaultLanguage =
                      NSISLanguageManager.getInstance().getDefaultLanguage();
                  if (defaultLanguage != null && availableLanguages.contains(defaultLanguage)) {
                    selectedLanguages.add(defaultLanguage);
                  }
                }
              }
            }
            selectedLangViewer.setInput(selectedLanguages);
            availableLanguages.removeAll(selectedLanguages);
            availableLangViewer.setInput(availableLanguages);
          }
        });
  }