@Override
  protected Viewer createViewer(final Composite parent) {
    listViewer = new ListViewer(parent, SWT.BORDER);
    listViewer.setLabelProvider(new ModuleItemLabelProvider());
    contentProvider = new InterpretedModuleListContentProvider();
    listViewer.setContentProvider(contentProvider);
    getSite().setSelectionProvider(listViewer);
    listViewer.addDoubleClickListener(
        new IDoubleClickListener() {

          @Override
          public void doubleClick(final DoubleClickEvent event) {
            final IStructuredSelection ss = (IStructuredSelection) event.getSelection();
            for (final Object o : ss.toArray()) {
              try {
                EditorUtility.openInEditor(o);
              } catch (final PartInitException e) {
                ErlLogger.warn(e);
              }
            }
          }
        });
    DebugUITools.getDebugContextManager().addDebugContextListener(this);
    DebugPlugin.getDefault().addDebugEventListener(this);
    return listViewer;
  }
 @SuppressWarnings("unchecked")
 private void moveAcross(ListViewer fromLV, ListViewer toLV, java.util.List<NSISLanguage> move) {
   java.util.List<NSISLanguage> from = (java.util.List<NSISLanguage>) fromLV.getInput();
   java.util.List<NSISLanguage> to = (java.util.List<NSISLanguage>) toLV.getInput();
   to.addAll(move);
   from.removeAll(move);
   fromLV.refresh(false);
   toLV.refresh(false);
 }
  /**
   * Create contents of the dialog
   *
   * @param parent
   */
  protected Control createDialogArea(Composite parent) {
    Composite container = (Composite) super.createDialogArea(parent);
    final GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 2;
    container.setLayout(gridLayout);

    final Label label = new Label(container, SWT.NONE);
    label.setText("查找:");

    text = new Text(container, SWT.BORDER);
    text.addModifyListener(
        new ModifyListener() {
          public void modifyText(final ModifyEvent e) {
            searchCondition = text.getText();
            StructuredSelection sel = (StructuredSelection) listViewer.getSelection();
            Object selObj = sel.isEmpty() ? null : sel.getFirstElement();
            listViewer.refresh();
            if (selObj != null) {
              sel = new StructuredSelection(selObj);
              listViewer.setSelection(sel);
            }
          }
        });
    text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

    listViewer = new ListViewer(container, SWT.BORDER | SWT.V_SCROLL | SWT.MULTI);
    listViewer.setContentProvider(new ListContentProvider());
    list = listViewer.getList();
    list.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
    listViewer.addDoubleClickListener(
        new IDoubleClickListener() {
          public void doubleClick(final DoubleClickEvent event) {
            StructuredSelection sel = (StructuredSelection) event.getSelection();
            if (sel.isEmpty()) {
              return;
            }
            buttonPressed(IDialogConstants.OK_ID);
          }
        });
    listViewer.setInput(ProjectData.getActiveProject());

    List<SkillConfig> selObjs = new ArrayList<SkillConfig>();
    for (int id : selectedSkills) {
      try {
        SkillConfig q =
            (SkillConfig) ProjectData.getActiveProject().findObject(SkillConfig.class, id);
        if (q != null) {
          selObjs.add(q);
        }
      } catch (Exception e) {
      }
    }
    StructuredSelection sel = new StructuredSelection(selObjs);
    listViewer.setSelection(sel);

    return container;
  }
Exemplo n.º 4
0
  private void hookPopupMenu() {
    MenuManager menuMgr = new MenuManager("#PopupMenu"); // $NON-NLS-1$
    Menu menu = menuMgr.createContextMenu(rtTypeListViewer.getList());
    rtTypeListViewer.getControl().setMenu(menu);

    Action act = this.unlinkAction;
    act.setText(Messages.getString("RTCTypeToRTTypeWidget.24")); // $NON-NLS-1$
    act.setEnabled(false);
    menuMgr.add(act);
  }
  private void selectAndContinueWizard() {
    boolean okPressed;
    list.clear();
    //        okPressed = openFileDialog(comp);
    viewer.setInput(list);
    getContainer().updateButtons();

    //        /*
    //         * XXX I'm not liking this. I think the workflow should be used to drive the pages
    // because
    //         * by trying to put the buttons it is dependent the implementation of
    //         * ConnectionPageDecorator's isPageComplete method as well as what order the
    //         * WorkflowWizard's canFinish method is implemented. IE if canFinish does not call
    //         * isPageComplete before calling dryRun() the finish button will not be activated.
    //         */
    //        if (okPressed) {
    //            if (findButton(getShell().getChildren(), IDialogConstants.FINISH_ID).isEnabled())
    // {
    //                pushButton(IDialogConstants.FINISH_ID);
    //            } else {
    //                pushButton(IDialogConstants.NEXT_ID);
    //            }
    //        } else {
    //            pushButton(IDialogConstants.BACK_ID);
    //        }
  }
Exemplo n.º 6
0
  protected void validate() {
    boolean fail = true;
    if (textPortName.getText().trim().equals("")) setErrorMessage("Connection name can't be empty");
    else if (client.getConnectionPool().hasConnection(textPortName.getText().trim()))
      setErrorMessage("Connection name has already been used by other port");
    else if (familyList.getSelection().isEmpty())
      setErrorMessage("Should select at least one family");
    else if (textServerAddress.getText().trim().equals(""))
      setErrorMessage("Server address can't be empty");
    else if (Util.getInt(textServerPort.getText().trim(), 0) == 0)
      setErrorMessage("The server port format is incorrect");
    else if (chkUdp.getSelection() && comboProxyType.getSelectionIndex() == 1)
      setErrorMessage("Can't use Http proxy with UDP mode");
    else if (comboProxyType.getSelectionIndex() != 0
        && textProxyAddress.getText().trim().equals(""))
      setErrorMessage("Proxy address can't be empty");
    else if (comboProxyType.getSelectionIndex() != 0
        && Util.getInt(textProxyPort.getText().trim(), 0) == 0)
      setErrorMessage("The proxy port format is incorrect");
    else {
      setErrorMessage(null);
      fail = false;
    }

    getButton(IDialogConstants.OK_ID).setEnabled(!fail);
  }
  public void createControl(Composite parent) {
    comp = new Composite(parent, SWT.NONE);
    comp.setLayout(new GridLayout(1, true));

    Label label = new Label(comp, SWT.NONE);
    GridDataFactory.swtDefaults().applyTo(label);
    label.setText("Dateien wählen...");

    createUpload(comp);

    viewer = new ListViewer(comp, SWT.BORDER | SWT.READ_ONLY | SWT.H_SCROLL | SWT.V_SCROLL);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new UploadItemLabelProvider());
    GridDataFactory.fillDefaults().grab(true, true).applyTo(viewer.getControl());

    setControl(comp);
  }
 private void loadFileContentsViewers() {
   fileContentsViewer.getList().removeAll();
   for (String row : this.dataFileInfo.getCachedFirstLines()) {
     if (row != null) {
       this.fileContentsViewer.add(row);
     }
   }
 }
  protected void initGUI() {
    getGridLayout().numColumns = 2;
    //		fileExtList = new List(this, SWT.BORDER);
    //		fileExtList.setLayoutData(new GridData(GridData.FILL_BOTH));

    fileExtListViewer = new ListViewer(this, SWT.BORDER | SWT.V_SCROLL);
    fileExtListViewer.setContentProvider(new ListViewerContentProvider());
    fileExtListViewer.setLabelProvider(new ListViewerLabelProvider());
    fileExtListViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));

    buttonWrapper = new XComposite(this, SWT.NONE, LayoutMode.TIGHT_WRAPPER, LayoutDataMode.NONE);
    buttonWrapper.setLayoutData(new GridData(GridData.FILL_VERTICAL));

    addDelegation = new Button(buttonWrapper, SWT.PUSH);
    addDelegation.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    addDelegation.setText(
        Messages.getString(
            "org.nightlabs.base.ui.print.pref.EditDocumentPrinterTypeRegsComposite.addDelegation.text")); //$NON-NLS-1$
    addDelegation.addSelectionListener(
        new SelectionListener() {
          public void widgetDefaultSelected(SelectionEvent arg0) {}

          public void widgetSelected(SelectionEvent arg0) {
            String fileExt = openFileExtDlg();
            if (fileExt != null && !"".equals(fileExt)) { // $NON-NLS-1$
              addTypeReg(fileExt);
              // TODO: Removed, as the SelectionListener does not get notified. Why not?
              //					fileExtList.setSelection(new String[]{fileExt});
            }
          }
        });

    removeDelegation = new Button(buttonWrapper, SWT.PUSH);
    removeDelegation.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    removeDelegation.setText(
        Messages.getString(
            "org.nightlabs.base.ui.print.pref.EditDocumentPrinterTypeRegsComposite.removeDelegation.text")); //$NON-NLS-1$
    removeDelegation.addSelectionListener(
        new SelectionListener() {
          public void widgetDefaultSelected(SelectionEvent arg0) {}

          public void widgetSelected(SelectionEvent arg0) {
            removeTypeReg(getSelectedFileExt());
          }
        });
  }
  public String getSelectedFileExt() {
    //		String[] selection = fileExtList.getSelection();
    //		if (selection.length > 0)
    //			return selection[0];
    //		else
    //			return null;

    if (fileExtListViewer.getSelection() instanceof IStructuredSelection) {
      IStructuredSelection structuredSelection =
          (IStructuredSelection) fileExtListViewer.getSelection();
      if (structuredSelection.getFirstElement() instanceof String) {
        String selection = (String) structuredSelection.getFirstElement();
        System.out.println("selected entry: " + selection); // $NON-NLS-1$
        return selection;
      }
    }
    return null;
  }
  public void updateList() {

    //		String[] selection = fileExtList.getSelection();
    //		fileExtList.removeAll();
    //		SortedSet<String> keys = new TreeSet<String>();
    //		keys.addAll(delegateConfigs.keySet());
    //		for (String fileExt : keys) {
    //			fileExtList.add(fileExt);
    //		}
    //		fileExtList.setSelection(selection);

    // does only remember the first selection out of a (possible larger) set of selections
    /*		String selection = "";
    if (fileExtListViewer.getSelection() instanceof IStructuredSelection) {
    	IStructuredSelection structuredSelection = (IStructuredSelection) fileExtListViewer.getSelection();
    	if (structuredSelection.getFirstElement() instanceof String) {
    		selection = (String)structuredSelection.getFirstElement();
    	}
    }*/

    String[] selections = null; // = new String[];

    if (fileExtListViewer.getSelection() instanceof IStructuredSelection) {
      IStructuredSelection structuredSelection =
          (IStructuredSelection) fileExtListViewer.getSelection();
      int amountOfChosenEntries = structuredSelection.toList().size();
      selections = new String[amountOfChosenEntries];
      for (int j = 0; j < amountOfChosenEntries; j++) {
        selections[j] = (String) structuredSelection.toList().get(j);
      }
    }

    fileExtListViewer.setInput(null);
    SortedSet<String> keys = new TreeSet<String>();
    keys.addAll(delegateConfigs.keySet());
    for (String fileExt : keys) {
      fileExtListViewer.add(fileExt);
    }

    if (selections != null) {
      fileExtListViewer.getList().setSelection(selections);
    }
  }
Exemplo n.º 12
0
  protected void copyAction() {
    CopyContextAction action = new CopyContextAction();
    IStructuredSelection selection = (IStructuredSelection) availableContextsViewer.getSelection();
    if (selection.isEmpty()) {
      return;
    }

    Object element = selection.getFirstElement();
    if (element instanceof Context) {
      Context sourceContext = (Context) element;
      try {

        InputDialog dialog =
            new InputDialog(
                getShell(),
                Messages.CustomizationDialog_enterConfigurationName,
                Messages.CustomizationDialog_enterConfigurationName,
                Messages.CustomizationDialog_copyOf + sourceContext.getName(),
                new IInputValidator() {

                  public String isValid(final String newText) {
                    if (newText.trim().equals("")) { // $NON-NLS-1$
                      return Messages.CustomizationDialog_configurationNameNotEmpty;
                    }
                    if (ConfigurationManager.instance.getContext(newText) != null) {
                      return Messages.CustomizationDialog_configurationWithSameNameExists;
                    }
                    return null;
                  }
                });
        dialog.setTitle(Messages.CustomizationDialog_configurationName);
        int result = dialog.open();
        if (result == Window.OK) {
          String targetName = dialog.getText();
          action.copy(sourceContext, targetName, false);
          availableContextsViewer.setInput(ConfigurationManager.instance.getContexts());
        }
      } catch (IOException ex) {
        Activator.log.error(ex);
      }
    }
  }
Exemplo n.º 13
0
 protected void buttonPressed(int buttonId) {
   if (buttonId == IDialogConstants.OK_ID) {
     StructuredSelection sel = (StructuredSelection) listViewer.getSelection();
     Object[] objs = sel.toArray();
     selectedSkills = new int[objs.length];
     for (int i = 0; i < objs.length; i++) {
       selectedSkills[i] = ((SkillConfig) objs[i]).id;
     }
   }
   super.buttonPressed(buttonId);
 }
Exemplo n.º 14
0
 protected void onDeleteEdge() {
   EdgeExtension ext = (EdgeExtension) animateSet.findExtension("EDGE");
   if (ext == null) {
     return;
   }
   int sel = borderList.getSelectionIndex();
   ext.edges.remove(sel);
   owner.setDirty(true);
   borderListViewer.refresh();
   edgeSelectionChanged();
 }
Exemplo n.º 15
0
 @Override
 public void addScenarioListener(final ScenarioSelected listener) {
   listScenarioViewer.addDoubleClickListener(
       new IDoubleClickListener() {
         public void doubleClick(DoubleClickEvent event) {
           ISelection sel = event.getSelection();
           StructuredSelection ss = (StructuredSelection) sel;
           LightScenario scenario = (LightScenario) ss.getFirstElement();
           listener.selected(scenario);
         }
       });
 }
Exemplo n.º 16
0
 @Override
 public void addServerListener(final ServerSelected listener) {
   listServerViewer.addDoubleClickListener(
       new IDoubleClickListener() {
         public void doubleClick(DoubleClickEvent event) {
           ISelection sel = event.getSelection();
           StructuredSelection ss = (StructuredSelection) sel;
           InetAddress address = (InetAddress) ss.getFirstElement();
           listener.selected(address);
         }
       });
 }
Exemplo n.º 17
0
 protected void doRemove(TestModelChange change) {
   if (fViewer instanceof ListViewer) {
     ((ListViewer) fViewer).remove(change.getChildren());
   } else if (fViewer instanceof TableViewer) {
     ((TableViewer) fViewer).remove(change.getChildren());
   } else if (fViewer instanceof AbstractTreeViewer) {
     ((AbstractTreeViewer) fViewer).remove(change.getChildren());
   } else if (fViewer instanceof ComboViewer) {
     ((ComboViewer) fViewer).remove(change.getChildren());
   } else {
     Assert.isTrue(false, "Unknown kind of viewer");
   }
 }
  private void contextActivated(final ISelection selection) {
    if (!isAvailable() || !isVisible()) {
      return;
    }
    erlangDebugTarget = null;
    if (selection instanceof IStructuredSelection) {
      final IStructuredSelection structuredSelection = (IStructuredSelection) selection;
      final Object o = structuredSelection.getFirstElement();
      if (o instanceof ErlangDebugElement) {
        final ErlangDebugElement e = (ErlangDebugElement) o;
        erlangDebugTarget = e.getErlangDebugTarget();
      } else if (o instanceof ILaunch) {
        final ILaunch launch = (ILaunch) o;
        final IDebugTarget target = launch.getDebugTarget();
        if (target instanceof IErlangDebugNode) {
          final IErlangDebugNode edn = (IErlangDebugNode) target;
          erlangDebugTarget = edn.getErlangDebugTarget();
        }
      } else if (o instanceof RuntimeProcess) {
        final RuntimeProcess ep = (RuntimeProcess) o;
        final ILaunch launch = ep.getLaunch();
        final IDebugTarget target = launch.getDebugTarget();
        if (target instanceof IErlangDebugNode) {
          final IErlangDebugNode edn = (IErlangDebugNode) target;
          erlangDebugTarget = edn.getErlangDebugTarget();
        }
      }
      if (erlangDebugTarget == null) {
        ErlLogger.debug("no debug target found for " + selection);
        return;
      }
      final ILaunchConfiguration launchConfiguration =
          erlangDebugTarget.getLaunch().getLaunchConfiguration();
      setViewerInput(launchConfiguration);
      try {
        final EnumSet<ErlDebugFlags> debugFlags =
            ErlDebugFlags.makeSet(
                launchConfiguration.getAttribute(
                    ErlRuntimeAttributes.DEBUG_FLAGS,
                    ErlDebugFlags.getFlag(ErlDebugFlags.DEFAULT_DEBUG_FLAGS)));
        distributed = debugFlags.contains(ErlDebugFlags.DISTRIBUTED_DEBUG);
      } catch (final CoreException e1) {
        distributed = false;
      }
    }
    listViewer.refresh();
    showViewer();

    // updateAction(VARIABLES_FIND_ELEMENT_ACTION);
    // updateAction(FIND_ACTION);
  }
Exemplo n.º 19
0
 public void widgetDefaultSelected(final SelectionEvent e) {
   if (e.widget == availableContexts) {
     IStructuredSelection selection =
         (IStructuredSelection) availableContextsViewer.getSelection();
     if (!selection.isEmpty()) {
       Context context = (Context) selection.getFirstElement();
       if (ConfigurationManager.instance.isPlugin(context)) {
         copyAction();
       } else {
         editAction();
       }
     }
   }
 }
Exemplo n.º 20
0
  protected void deleteAction() {
    RemoveContextAction action = new RemoveContextAction();
    IStructuredSelection selection = (IStructuredSelection) availableContextsViewer.getSelection();
    if (selection.isEmpty()) {
      return;
    }

    Object element = selection.getFirstElement();
    if (element instanceof Context) {
      Context sourceContext = (Context) element;
      if (ConfigurationManager.instance.isPlugin(sourceContext)) {
        Activator.log.warn(Messages.CustomizationDialog_cannotDeletePluginContext);
        // Plugin context cannot be deleted
        return;
      }

      MessageDialog dialog =
          new MessageDialog(
              getShell(),
              Messages.CustomizationDialog_deleteContext,
              null,
              Messages.CustomizationDialog_deleteContextConfirmation1
                  + sourceContext.getName()
                  + Messages.CustomizationDialog_deleteContextConfirmation2,
              MessageDialog.CONFIRM,
              new String[] {
                IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL
              },
              2);
      int result = dialog.open();
      if (result == 0) { // 0 is "Yes" (It is *not* the same 0 as Window.OK)
        action.removeContext(sourceContext);
        availableContextsViewer.setInput(ConfigurationManager.instance.getContexts());
      }
    }
  }
Exemplo n.º 21
0
 protected void doInsert(TestModelChange change) {
   if (fViewer instanceof ListViewer) {
     if (change.getParent() != null && change.getParent().equals(fViewer.getInput())) {
       ((ListViewer) fViewer).add(change.getChildren());
     }
   } else if (fViewer instanceof TableViewer) {
     if (change.getParent() != null && change.getParent().equals(fViewer.getInput())) {
       ((TableViewer) fViewer).add(change.getChildren());
     }
   } else if (fViewer instanceof AbstractTreeViewer) {
     ((AbstractTreeViewer) fViewer).add(change.getParent(), change.getChildren());
   } else if (fViewer instanceof ComboViewer) {
     ((ComboViewer) fViewer).add(change.getChildren());
   } else {
     Assert.isTrue(false, "Unknown kind of viewer");
   }
 }
Exemplo n.º 22
0
 private void makeContextMenu(ListViewer listMB3) {
   MenuManager manager = new MenuManager("#PopupMenu"); // $NON-NLS-1$
   Control contr = listMB3.getControl();
   manager.addMenuListener(
       new IMenuListener() {
         public void menuAboutToShow(IMenuManager manager) {
           manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
         }
       });
   Menu menu = manager.createContextMenu(contr);
   contr.setMenu(menu);
   if (_site != null) {
     _site.registerContextMenu(manager, listMB3);
   } else {
     // org.csstudio.diag.IOCremoteManagement.Activator.errorPrint ("Wrong site");
     System.out.println("Wrong site");
   }
 }
Exemplo n.º 23
0
 protected void onAddEdge() {
   EdgeExtension ext = (EdgeExtension) animateSet.findExtension("EDGE");
   if (ext == null) {
     ext = new EdgeExtension();
     animateSet.addExtension(ext);
   }
   EdgeExtension.Edge newEdge = new EdgeExtension.Edge();
   newEdge.beginAnimateIndex = -1;
   newEdge.endAnimateIndex = -1;
   newEdge.beginY = 0;
   newEdge.height = 0;
   newEdge.beginX = new int[0];
   newEdge.endX = new int[0];
   ext.edges.add(newEdge);
   owner.setDirty(true);
   borderListViewer.refresh();
   edgeSelectionChanged();
 }
  private void handleZipFile(File f, File uploadDir) throws IOException {
    ZipFile zipFile = new ZipFile(f, "UTF-8", true);
    Enumeration entries = zipFile.getEntries();

    while (entries.hasMoreElements()) {
      ZipEntry entry = (ZipEntry) entries.nextElement();

      InputStream zipin = zipFile.getInputStream(entry);
      File dest = new File(uploadDir, entry.getName());
      OutputStream fileout = new FileOutputStream(dest);
      StreamUtils.copyThenClose(zipin, fileout);

      viewer.add(new UploadItem(zipin, "", dest.getName(), ""));
      if (dest.getName().endsWith("shp")) {
        list.add(dest.toURI().toURL());
      }
    }
    f.delete();
  }
Exemplo n.º 25
0
  protected void editAction() {
    EditContextAction action = new EditContextAction();
    IStructuredSelection selection = (IStructuredSelection) availableContextsViewer.getSelection();
    if (selection.isEmpty()) {
      return;
    }

    Object element = selection.getFirstElement();
    if (element instanceof Context) {
      Context sourceContext = (Context) element;
      try {
        action.openEditor(sourceContext);
        close();
      } catch (Exception ex) {
        Activator.log.error(
            "An error occured while initializing the customization editor", ex); // $NON-NLS-1$
        return;
      }
    }
  }
Exemplo n.º 26
0
 public Object open(String folder) {
   createContents();
   WidgetsTool.setSize(shlBundler);
   sourceFolder.setText(folder);
   meta.clear();
   files = new Vector();
   File srcdir = new File(sourceFolder.getText());
   File[] chld = srcdir.listFiles();
   for (int i = 0; i < chld.length; i++) {
     if (chld[i].getName().toUpperCase().endsWith("SIN")
         || (chld[i].getName().toUpperCase().endsWith("TA")
             && !chld[i].getName().toUpperCase().contains("SIMLOCK"))
         || (chld[i].getName().toUpperCase().endsWith("XML")
             && !chld[i].getName().toUpperCase().contains("UPDATE"))) {
       files.add(chld[i]);
     }
   }
   srcdir = new File(sourceFolder.getText() + File.separator + "boot");
   if (srcdir.exists()) {
     chld = srcdir.listFiles();
     for (int i = 0; i < chld.length; i++) {
       if (chld[i].getName().toUpperCase().endsWith("XML")) {
         files.add(chld[i]);
       }
     }
   }
   model.refresh(meta);
   treeViewerCategories.setInput(model);
   listViewerFiles.setInput(files);
   shlBundler.open();
   shlBundler.layout();
   Display display = getParent().getDisplay();
   while (!shlBundler.isDisposed()) {
     if (!display.readAndDispatch()) {
       display.sleep();
     }
   }
   return result;
 }
  @Override
  public void createControl(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(GridLayoutFactory.fillDefaults().create());
    composite.setLayoutData(GridDataFactory.fillDefaults().create());

    // Create list viewer
    listViewer = new ListViewer(composite, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    GridData data = new GridData(GridData.FILL_BOTH);
    data.heightHint = convertHeightInCharsToPixels(LIST_HEIGHT);
    data.widthHint = convertWidthInCharsToPixels(LIST_WIDTH);
    listViewer.getList().setLayoutData(data);
    listViewer.getList().setFont(parent.getFont());
    // Set the label provider
    listViewer.setLabelProvider(
        new LabelProvider() {
          public String getText(Object element) {
            // Return the features's label.
            return element == null ? "" : ((CommPortIdentifier) element).getName(); // $NON-NLS-1$
          }
        });

    // Set the content provider
    ArrayContentProvider cp = new ArrayContentProvider();
    listViewer.setContentProvider(cp);
    listViewer.setInput(availableCommPortIdentifiers);

    listViewer.addSelectionChangedListener(
        new ISelectionChangedListener() {
          @Override
          public void selectionChanged(SelectionChangedEvent event) {
            if (event.getSelection() instanceof IStructuredSelection) {
              ((ArduinoConnectionSelectionWizard) getWizard())
                  .cfg.setUsbComm(
                      (CommPortIdentifier)
                          ((IStructuredSelection) event.getSelection()).getFirstElement());
            }
          }
        });

    listViewer.setSelection(new StructuredSelection(availableCommPortIdentifiers.get(0)));

    setControl(composite);
  }
  /**
   * Create the composite
   *
   * @param parent
   * @param style
   */
  public PigCategoryComposite(Composite parent, int style, CategoryManager manager) {
    super(parent, style);
    this.manager = manager;
    setLayout(new FillLayout());

    final SashForm sashForm = new SashForm(this, SWT.NONE);
    final SashForm sashForm1 = new SashForm(sashForm, SWT.HORIZONTAL);

    final Composite composite = new Composite(sashForm1, SWT.BORDER);
    final GridLayout gridLayout = new GridLayout();
    gridLayout.marginWidth = 0;
    gridLayout.marginHeight = 0;
    gridLayout.verticalSpacing = 0;
    gridLayout.horizontalSpacing = 0;
    composite.setLayout(gridLayout);

    final CLabel categoryLabel = new CLabel(composite, SWT.SHADOW_OUT);
    categoryLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    categoryLabel.setText(Messages.getString("CategoryComposite.category")); // $NON-NLS-1$

    final ListViewer categoryViewer = new ListViewer(composite, SWT.V_SCROLL | SWT.H_SCROLL);
    categoryViewer.setLabelProvider(
        new LabelProvider() {

          @Override
          public String getText(Object element) {
            return ((Category) element).getName();
          }
        });
    categoryViewer.setContentProvider(new ArrayContentProvider());
    categoryViewer.setSorter(new ViewerSorter());
    categoryList = categoryViewer.getList();
    categoryList.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    final Composite composite1 = new Composite(sashForm1, SWT.BORDER);
    final GridLayout gridLayout1 = new GridLayout();
    gridLayout1.verticalSpacing = 0;
    gridLayout1.horizontalSpacing = 0;
    gridLayout1.marginWidth = 0;
    gridLayout1.marginHeight = 0;
    composite1.setLayout(gridLayout1);

    final CLabel functionLabel = new CLabel(composite1, SWT.SHADOW_OUT);
    functionLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    functionLabel.setText(Messages.getString("CategoryComposite.functions")); // $NON-NLS-1$

    functionViewer = new ListViewer(composite1, SWT.V_SCROLL | SWT.H_SCROLL);
    functionViewer.setContentProvider(new ArrayContentProvider());
    functionViewer.setLabelProvider(
        new LabelProvider() {

          @Override
          public String getText(Object element) {
            return ((Function) element).getName();
          }
        });
    functionViewer.setSorter(new ViewerSorter());
    functionList = functionViewer.getList();
    functionList.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    // create DND in Expression Editor. This is CategoryComposite drag.
    DragSource source = new DragSource(functionList, DND.DROP_MOVE | DND.DROP_COPY);
    source.setTransfer(new Transfer[] {textTransfer});
    source.addDragListener(
        new DragSourceListener() {

          @Override
          public void dragStart(DragSourceEvent event) {
            if (functionList.getSelection().equals("")) {
              event.doit = false;
            }
          }

          @Override
          public void dragSetData(DragSourceEvent event) {
            if (textTransfer.isSupportedType(event.dataType)) {
              Function function =
                  (Function)
                      ((IStructuredSelection) functionViewer.getSelection()).getFirstElement();
              VirtualMetadataColumn column = new VirtualMetadataColumn();
              column.setTalendType(function.getTalendType().getName());
              column.setFunction(function);
              if (function.isUserDefined()) {
                event.data = (JavaUtils.JAVA_PIGUDF_DIRECTORY + "." + function.getName() + "()");
              } else {
                event.data = (FunctionManagerExt.getOneColData(column, false));
              }
            }
          }

          @Override
          public void dragFinished(DragSourceEvent event) {}
        });

    sashForm1.setWeights(new int[] {1, 1});

    Composite docComposite = new Composite(sashForm, SWT.BORDER);
    GridLayout docLayout = new GridLayout();
    docLayout.marginTop = 0;
    docLayout.marginBottom = 0;
    docLayout.marginHeight = 0;
    docLayout.marginLeft = 0;
    docLayout.marginWidth = 0;
    docLayout.marginHeight = 0;
    docComposite.setLayout(docLayout);

    Label docLabel = new Label(docComposite, SWT.NONE);
    docLabel.setText(Messages.getString("CategoryComposite.Help")); // $NON-NLS-1$

    if (TalendPropertiesUtil.isEnabledUseBrowser()) {
      final Browser docDisplayer = new Browser(docComposite, SWT.BORDER);
      docDisplayer.setText(
          Messages.getString("CategoryComposite.SelectCategoryAndFunction")); // $NON-NLS-1$
      docDisplayer.setLayoutData(new GridData(GridData.FILL_BOTH));
      sashForm.setWeights(new int[] {2, 1});
      new UIRelationShipLinker(categoryViewer, functionViewer, docDisplayer);
    } else {
      final Text descriptionText = new Text(docComposite, SWT.BORDER | SWT.WRAP);
      descriptionText.setText(
          Messages.getString("CategoryComposite.SelectCategoryAndFunction")); // $NON-NLS-1$
      GridData gd = new GridData(GridData.FILL_BOTH);
      descriptionText.setLayoutData(gd);
      sashForm.setWeights(new int[] {2, 1});
      new UIRelationShipLinker(categoryViewer, functionViewer, descriptionText);
    }
    initializeData(categoryViewer);
    categoryViewer.getList().setFocus();
  }
 private void initializeData(ListViewer categoryViewer) {
   categoryViewer.setInput(manager.getInputCategory(JavaUtils.JAVA_PIG_DIRECTORY));
 }
  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);
          }
        });
  }