@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;
  }
  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);
  }
  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());
          }
        });
  }
  @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();
  }
  /** Create contents of the dialog. */
  private void createContents() {
    shlBusyboxSelector = new Shell(getParent(), getStyle());
    shlBusyboxSelector.setSize(168, 434);
    shlBusyboxSelector.setText("Busybox Selector");
    shlBusyboxSelector.setLayout(new FormLayout());

    btnCancel = new Button(shlBusyboxSelector, SWT.NONE);
    FormData fd_btnCancel = new FormData();
    fd_btnCancel.right = new FormAttachment(100, -10);
    btnCancel.setLayoutData(fd_btnCancel);
    btnCancel.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            result = null;
            shlBusyboxSelector.dispose();
          }
        });
    btnCancel.setText("Cancel");
    ListViewer listBusyboxViewer = new ListViewer(shlBusyboxSelector, SWT.BORDER | SWT.V_SCROLL);
    listBusybox = listBusyboxViewer.getList();
    fd_btnCancel.top = new FormAttachment(listBusybox, 6);
    FormData fd_listBusybox = new FormData();
    fd_listBusybox.bottom = new FormAttachment(100, -41);
    fd_listBusybox.top = new FormAttachment(0, 10);
    fd_listBusybox.right = new FormAttachment(100, -10);
    fd_listBusybox.left = new FormAttachment(0, 10);
    listBusybox.setLayoutData(fd_listBusybox);
    listBusybox.addListener(
        SWT.DefaultSelection,
        new Listener() {
          public void handleEvent(Event e) {
            int selected = listBusybox.getSelectionIndex();
            String string = listBusybox.getItem(selected);
            result = string;
            shlBusyboxSelector.dispose();
          }
        });

    listBusyboxViewer.setContentProvider(
        new IStructuredContentProvider() {
          public Object[] getElements(Object inputElement) {
            Vector v = (Vector) inputElement;
            return v.toArray();
          }

          public void dispose() {}

          public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
        });

    listBusyboxViewer.setLabelProvider(
        new LabelProvider() {
          public Image getImage(Object element) {
            return null;
          }

          public String getText(Object element) {
            return ((File) element).getName();
          }
        });
    Vector<File> folders = new Vector();
    File srcdir =
        new File(OS.getWorkDir() + File.separator + "devices" + File.separator + "busybox");
    File[] chld = srcdir.listFiles();
    for (int i = 0; i < chld.length; i++) {
      if (chld[i].isDirectory()) folders.add(chld[i]);
    }
    listBusyboxViewer.setInput(folders);
  }
  /**
   * Create the composite
   *
   * @param parent
   * @param style
   */
  public AnimateEdgeEditor(Composite parent, int style, AnimateEditor oo, PipAnimateSet aset) {
    super(parent, style);
    this.owner = oo;
    this.animateSet = aset;
    final GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 2;
    setLayout(gridLayout);

    buttonFlag = new Button(this, SWT.CHECK);
    buttonFlag.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(final SelectionEvent e) {
            owner.setDirty(true);
          }
        });
    buttonFlag.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
    buttonFlag.setText("包含轮廓定义");

    borderListViewer = new ListViewer(this, SWT.BORDER);
    borderListViewer.addSelectionChangedListener(
        new ISelectionChangedListener() {
          public void selectionChanged(final SelectionChangedEvent arg0) {
            edgeSelectionChanged();
          }
        });
    borderListViewer.setLabelProvider(new ListLabelProvider());
    borderListViewer.setContentProvider(new ContentProvider());
    borderList = borderListViewer.getList();
    final GridData gd_borderList = new GridData(SWT.FILL, SWT.FILL, false, true);
    gd_borderList.widthHint = 237;
    borderList.setLayoutData(gd_borderList);

    final Composite composite = new Composite(this, SWT.NONE);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    final GridLayout gridLayout_1 = new GridLayout();
    gridLayout_1.numColumns = 4;
    composite.setLayout(gridLayout_1);

    final Label label = new Label(composite, SWT.NONE);
    label.setText("起始动画ID:");

    textFirstAnimate = new Text(composite, SWT.BORDER);
    textFirstAnimate.addModifyListener(
        new ModifyListener() {
          public void modifyText(final ModifyEvent arg0) {
            if (updating) {
              return;
            }
            try {
              EdgeExtension.Edge edge = getEditingEdge();
              int value = Integer.parseInt(textFirstAnimate.getText());
              if (value == -1 || (value >= 0 && value < animateSet.getAnimateCount())) {
                edge.beginAnimateIndex = value;
                owner.setDirty(true);
                textFirstAnimate.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
                return;
              }
            } catch (Exception e) {
            }
            textFirstAnimate.setForeground(SWTResourceManager.getColor(SWT.COLOR_RED));
          }
        });
    final GridData gd_textFirstAnimate = new GridData(SWT.FILL, SWT.CENTER, true, false);
    textFirstAnimate.setLayoutData(gd_textFirstAnimate);

    final Label label_1 = new Label(composite, SWT.NONE);
    label_1.setText("结束动画ID:");

    textLastAnimate = new Text(composite, SWT.BORDER);
    textLastAnimate.addModifyListener(
        new ModifyListener() {
          public void modifyText(final ModifyEvent arg0) {
            if (updating) {
              return;
            }
            try {
              EdgeExtension.Edge edge = getEditingEdge();
              int value = Integer.parseInt(textLastAnimate.getText());
              if (value == -1 || (value >= 0 && value <= animateSet.getAnimateCount())) {
                edge.endAnimateIndex = value;
                owner.setDirty(true);
                textLastAnimate.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
                return;
              }
            } catch (Exception e) {
            }
            textLastAnimate.setForeground(SWTResourceManager.getColor(SWT.COLOR_RED));
          }
        });
    final GridData gd_textLastAnimate = new GridData(SWT.FILL, SWT.CENTER, true, false);
    textLastAnimate.setLayoutData(gd_textLastAnimate);

    final Composite editViewerContainer = new Composite(composite, SWT.NONE);
    editViewerContainer.setLayout(new FillLayout());
    final GridData gd_editViewerContainer = new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1);
    editViewerContainer.setLayoutData(gd_editViewerContainer);

    editViewer = new EdgeEditViewer(editViewerContainer, SWT.NONE);
    editViewer.setImageViewerListener(this);

    MenuManager mgr = new MenuManager();
    mgr.add(
        new Action("添加") {
          public void run() {
            onAddEdge();
          }
        });
    mgr.add(
        new Action("删除") {
          public void run() {
            onDeleteEdge();
          }
        });

    Menu menu = mgr.createContextMenu(borderList);
    borderList.setMenu(menu);

    // 设置初始值
    borderListViewer.setInput(new Object());
    EdgeExtension ext = (EdgeExtension) animateSet.findExtension("EDGE");
    if (ext == null) {
      buttonFlag.setSelection(false);
    } else {
      buttonFlag.setSelection(true);
    }
    edgeSelectionChanged();
  }
  @Override
  protected Control createDialogArea(Composite parent) {
    Composite control = (Composite) super.createDialogArea(parent);

    Composite container = new Composite(control, SWT.NONE);
    GridLayout layout = new GridLayout();
    container.setLayout(layout);
    container.setLayoutData(new GridData(GridData.FILL_BOTH));

    // port name
    Label lblTemp = new Label(container, SWT.LEFT);
    lblTemp.setText("Port Name:");
    textPortName = new Text(container, SWT.SINGLE | SWT.BORDER);
    textPortName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    textPortName.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            validate();
          }
        });

    // port family
    lblTemp = new Label(container, SWT.LEFT);
    lblTemp.setText("Port Family:");
    familyList = new ListViewer(container);
    familyList.getList().setLayoutData(new GridData(GridData.FILL_BOTH));
    familyList.setContentProvider(new ListContentProvider<Integer>(family));
    familyList.setLabelProvider(
        new LabelProvider() {
          @Override
          public String getText(Object element) {
            return Util.getProtocolString((Integer) element);
          }
        });
    familyList.addSelectionChangedListener(
        new ISelectionChangedListener() {
          public void selectionChanged(SelectionChangedEvent event) {
            validate();
          }
        });

    // server address
    lblTemp = new Label(container, SWT.LEFT);
    lblTemp.setText("Server Address");
    chkUdp = new Button(container, SWT.CHECK);
    chkUdp.setText("UDP Server");
    chkUdp.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            validate();
          }
        });
    Composite comp = new Composite(container, SWT.NONE);
    comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    layout = new GridLayout(4, false);
    layout.marginHeight = layout.marginWidth = 0;
    comp.setLayout(layout);
    lblTemp = new Label(comp, SWT.LEFT);
    lblTemp.setText("Server Address:");
    textServerAddress = new Text(comp, SWT.SINGLE | SWT.BORDER);
    textServerAddress.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    textServerAddress.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            validate();
          }
        });
    lblTemp = new Label(comp, SWT.LEFT);
    lblTemp.setText("Server Port:");
    textServerPort = new Text(comp, SWT.SINGLE | SWT.BORDER);
    GridData gd = new GridData();
    gd.widthHint = 80;
    textServerPort.setLayoutData(gd);
    textServerPort.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            validate();
          }
        });

    // proxy type
    lblTemp = new Label(container, SWT.LEFT);
    lblTemp.setText("Proxy Type:");
    comboProxyType = new CCombo(container, SWT.DROP_DOWN | SWT.BORDER);
    comboProxyType.add("None");
    comboProxyType.add("Http");
    comboProxyType.add("Socks");
    comboProxyType.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            validate();
          }
        });
    comboProxyType.select(0);

    // proxy address
    lblTemp = new Label(container, SWT.LEFT);
    lblTemp.setText("Proxy:");
    comp = new Composite(container, SWT.NONE);
    comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    layout = new GridLayout(4, false);
    layout.marginHeight = layout.marginWidth = 0;
    comp.setLayout(layout);
    lblTemp = new Label(comp, SWT.LEFT);
    lblTemp.setText("Proxy Address:");
    textProxyAddress = new Text(comp, SWT.SINGLE | SWT.BORDER);
    textProxyAddress.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    textProxyAddress.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            validate();
          }
        });
    lblTemp = new Label(comp, SWT.LEFT);
    lblTemp.setText("Proxy Port:");
    textProxyPort = new Text(comp, SWT.SINGLE | SWT.BORDER);
    gd = new GridData();
    gd.widthHint = 80;
    textProxyPort.setLayoutData(gd);
    textProxyPort.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            validate();
          }
        });

    // proxy username and password
    comp = new Composite(container, SWT.NONE);
    comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    layout = new GridLayout(4, false);
    layout.marginHeight = layout.marginWidth = 0;
    comp.setLayout(layout);
    lblTemp = new Label(comp, SWT.LEFT);
    lblTemp.setText("Proxy Username:"******"Proxy Password:"******"Before create a port, some arguments must be decided");
    setTitle("Select port argument");

    return control;
  }
  /**
   * Create contents of the dialog.
   *
   * @param parent
   */
  @Override
  protected Control createDialogArea(Composite parent) {
    super.setMessage(message, IMessageProvider.INFORMATION);
    super.setTitle(title);

    Composite area = (Composite) super.createDialogArea(parent);
    Composite container = new Composite(area, SWT.NONE);
    container.setLayout(new GridLayout(3, false));
    container.setLayoutData(new GridData(GridData.FILL_BOTH));

    Label nameLabel = new Label(container, SWT.NONE);
    nameLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    nameLabel.setText("Name:");

    nameText = new Text(container, SWT.BORDER);
    nameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    nameText.setText(configName);
    nameText.addModifyListener(getModifyListener());
    nameText.setEnabled(nameEditable);

    defaultButton = new Button(container, SWT.CHECK);
    defaultButton.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
    defaultButton.setAlignment(SWT.CENTER);
    defaultButton.setText("Default");
    defaultButton.setSelection(isDefault);
    defaultButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            setOkButtonEnabled(true);
          }
        });

    Label initNodeLabel = new Label(container, SWT.NONE);
    initNodeLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    initNodeLabel.setText("Initial Node:");

    initNodeText = new Text(container, SWT.BORDER);
    initNodeText.setText(initNodeName);
    initNodeText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    initNodeText.addModifyListener(getModifyListener());

    Button initNodeButton = new Button(container, SWT.NONE);
    initNodeButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 0, 1));
    initNodeButton.setText("Find ...");
    initNodeButton.addSelectionListener(
        new ClassSelectionAdapter(getParentShell(), initNodeText, project.getSearchScope()));

    Label classpathLabel = new Label(container, SWT.NONE);
    classpathLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    classpathLabel.setText("Classpath:");

    listViewer = new ListViewer(container, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    listViewer.getList().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    listViewer.setContentProvider(new ArrayContentProvider());
    listViewer.setLabelProvider(new LabelProvider());

    listViewer.setInput(cpEntries);

    Composite classpathComposite = new Composite(container, SWT.NONE);
    classpathComposite.setLayout(new GridLayout(1, true));

    Button btnAddFile = new Button(classpathComposite, SWT.NONE);
    btnAddFile.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    btnAddFile.setText("Add Files ...");
    btnAddFile.addSelectionListener(new ResourceSelectionAdapter(DialogType.RESOURCE, this));

    Button btnAddFolder = new Button(classpathComposite, SWT.NONE);
    btnAddFolder.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    btnAddFolder.setText("Add Binary Folder ...");
    btnAddFolder.addSelectionListener(new ResourceSelectionAdapter(DialogType.CONTAINER, this));

    Button btnAddAbsolute = new Button(classpathComposite, SWT.NONE);
    btnAddAbsolute.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    btnAddAbsolute.setText("Add Entry ...");
    btnAddAbsolute.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            InputDialog dialog = new InputDialog(getParentShell(), "Add Entry...", "", "", null);
            dialog.setBlockOnOpen(true);

            if (dialog.open() == Dialog.OK) {
              cpEntries.add(dialog.getValue());
              setOkButtonEnabled(true);
              listViewer.refresh();
            }
          }
        });

    Composite composite = new Composite(classpathComposite, SWT.NONE);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));

    final Button btnRemove = new Button(classpathComposite, SWT.NONE);
    btnRemove.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    btnRemove.setText("Remove");
    btnRemove.setEnabled(false);

    btnRemove.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            String selectedString =
                ViewerUtils.getSelection(listViewer.getSelection(), String.class);
            if (selectedString != null && !selectedString.equals("")) {
              int oldIndex = cpEntries.indexOf(selectedString);

              cpEntries.remove(selectedString);
              listViewer.refresh();

              int size = cpEntries.size();
              if (size == 0) {
                btnRemove.setEnabled(false);
              } else {
                int select = Math.min(oldIndex, size - 1);
                listViewer.setSelection(new StructuredSelection(cpEntries.get(select)));
              }

              setOkButtonEnabled(true);
            }
          }
        });

    new Label(container, SWT.NONE);

    Label lblNoteToAdd = new Label(container, SWT.NONE);
    lblNoteToAdd.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
    lblNoteToAdd.setText("Note: To add Java archives (*.jar) use 'Add Files ...' ");
    new Label(container, SWT.NONE);

    Composite spacer = new Composite(container, SWT.NONE);
    GridData gd_spacer = new GridData(SWT.FILL, SWT.CENTER, false, false, 3, 1);
    gd_spacer.heightHint = 30;
    spacer.setLayoutData(gd_spacer);

    listViewer.addSelectionChangedListener(
        new ISelectionChangedListener() {
          @Override
          public void selectionChanged(SelectionChangedEvent event) {
            boolean enable = false;
            String selectedString = ViewerUtils.getSelection(event.getSelection(), String.class);
            if (selectedString != null && !selectedString.equals("")) {
              enable = true;
            }

            btnRemove.setEnabled(enable);
          }
        });

    return area;
  }
Exemple #10
0
  /** Create contents of the dialog. */
  private void createContents() {
    shlBundler = new Shell(getParent(), getStyle());
    shlBundler.setSize(626, 447);
    shlBundler.setText("Bundler");
    shlBundler.setLayout(new FormLayout());

    listViewerFiles = new ListViewer(shlBundler, SWT.BORDER | SWT.V_SCROLL | SWT.MULTI);
    list = listViewerFiles.getList();
    FormData fd_list = new FormData();
    fd_list.left = new FormAttachment(0, 10);
    list.setLayoutData(fd_list);
    listViewerFiles.setContentProvider(
        new IStructuredContentProvider() {
          public Object[] getElements(Object inputElement) {
            Vector v = (Vector) inputElement;
            return v.toArray();
          }

          public void dispose() {}

          public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
        });
    listViewerFiles.setLabelProvider(
        new LabelProvider() {
          public Image getImage(Object element) {
            return null;
          }

          public String getText(Object element) {
            return ((File) element).getName();
          }
        });
    listViewerFiles.setSorter(
        new ViewerSorter() {
          public int compare(Viewer viewer, Object e1, Object e2) {
            return ((File) e1).getName().compareTo(((File) e2).getName());
          }
        });
    lblNewLabel_3 = new Label(shlBundler, SWT.NONE);
    fd_list.top = new FormAttachment(lblNewLabel_3, 6);
    fd_lblNewLabel = new FormData();
    fd_lblNewLabel.left = new FormAttachment(0, 10);
    lblNewLabel_3.setLayoutData(fd_lblNewLabel);
    lblNewLabel_3.setText("folder list :");

    composite_5 = new Composite(shlBundler, SWT.NONE);
    fd_list.bottom = new FormAttachment(composite_5, 0, SWT.BOTTOM);
    composite_5.setLayout(new TreeColumnLayout());
    FormData fd_composite_5 = new FormData();
    fd_composite_5.top = new FormAttachment(lblNewLabel_3, 6);
    fd_composite_5.right = new FormAttachment(100, -10);
    composite_5.setLayoutData(fd_composite_5);

    treeViewerCategories = new TreeViewer(composite_5, SWT.BORDER | SWT.MULTI);
    Tree treeCategories = treeViewerCategories.getTree();
    treeCategories.setHeaderVisible(true);
    treeCategories.setLinesVisible(true);
    treeViewerCategories.setContentProvider(new CategoriesContentProvider());
    treeViewerCategories.setLabelProvider(new SinfilesLabelProvider());
    treeViewerCategories.setSorter(
        new ViewerSorter() {
          public int compare(Viewer viewer, Object e1, Object e2) {
            int cat1 = category(e1);
            int cat2 = category(e2);
            if (cat1 != cat2) return cat1 - cat2;
            if ((e1 instanceof Category) && (e2 instanceof Category))
              return ((Category) e1).getName().compareTo(((Category) e2).getName());
            else return ((File) e1).getName().compareTo(((File) e2).getName());
          }
        });
    // Expand the tree
    treeViewerCategories.setAutoExpandLevel(2);
    // Provide the input to the ContentProvider
    treeViewerCategories.setInput(new CategoriesModel(meta));
    treeViewerCategories.refresh();

    Button btnCancel = new Button(shlBundler, SWT.NONE);
    fd_composite_5.bottom = new FormAttachment(btnCancel, -5);
    fd_composite_5.bottom = new FormAttachment(btnCancel, -5);
    btnCancel.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            result = new String("Cancel");
            shlBundler.dispose();
          }
        });
    FormData fd_btnCancel = new FormData();
    fd_btnCancel.right = new FormAttachment(100, -10);
    fd_btnCancel.bottom = new FormAttachment(100, -10);
    btnCancel.setLayoutData(fd_btnCancel);
    btnCancel.setText("Cancel");

    Button btnCreate = new Button(shlBundler, SWT.NONE);
    btnCreate.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if (sourceFolder.getText().length() == 0) {
              showErrorMessageBox("You must point to a folder containing sin files");
              return;
            }
            if ((device.getText().length() == 0)
                || (version.getText().length() == 0)
                || (branding.getText().length() == 0)) {
              showErrorMessageBox("Device, Versio, Branding : all fields must be set");
              return;
            }
            File f =
                new File(
                    OS.getWorkDir()
                        + File.separator
                        + "firmwares"
                        + File.separator
                        + _variant
                        + "_"
                        + version.getText()
                        + "_"
                        + branding.getText()
                        + ".ftf");
            if (f.exists()) {
              showErrorMessageBox("This bundle name already exists");
              return;
            }
            Bundle b = new Bundle();
            b.setMeta(meta);
            b.setDevice(_variant);
            b.setVersion(version.getText());
            b.setBranding(branding.getText());
            b.setCmd25(btnNoFinalVerification.getSelection() ? "true" : "false");
            if (!b.hasLoader()) {
              String result = Devices.getIdFromVariant(_variant);
              DeviceEntry ent = new DeviceEntry(result);
              System.out.println(ent.getLoader());
              if (ent.hasUnlockedLoader()) {
                String res = WidgetTask.openLoaderSelect(shlBundler);
                if (res.equals("U")) b.setLoader(new File(ent.getLoaderUnlocked()));
                else if (res.equals("L")) b.setLoader(new File(ent.getLoader()));
                else {
                  showErrorMessageBox("This bundle must contain a loader");
                  return;
                }

              } else {
                b.setLoader(new File(ent.getLoader()));
              }
            }
            createFTFJob j = new createFTFJob("Create FTF");
            j.setBundle(b);
            j.schedule();
            shlBundler.dispose();
          }
        });
    FormData fd_btnCreate = new FormData();
    fd_btnCreate.bottom = new FormAttachment(btnCancel, 0, SWT.BOTTOM);
    fd_btnCreate.right = new FormAttachment(btnCancel, -6);
    btnCreate.setLayoutData(fd_btnCreate);
    btnCreate.setText("Create");

    btnNewButton_1 = new Button(shlBundler, SWT.NONE);
    fd_list.right = new FormAttachment(btnNewButton_1, -6);
    fd_composite_5.left = new FormAttachment(btnNewButton_1, 6);
    btnNewButton_1.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            IStructuredSelection selection = (IStructuredSelection) listViewerFiles.getSelection();
            Iterator i = selection.iterator();
            while (i.hasNext()) {
              File f = (File) i.next();
              files.remove(f);
              try {
                meta.process(f.getName(), f.getAbsolutePath());
                model.refresh(meta);
                treeViewerCategories.setInput(model);
              } catch (Exception ex) {
                ex.printStackTrace();
              }
              treeViewerCategories.setAutoExpandLevel(2);
              treeViewerCategories.refresh();
              listViewerFiles.refresh();
            }
          }
        });
    fd_btnNewButton_1 = new FormData();
    fd_btnNewButton_1.left = new FormAttachment(0, 353);
    fd_btnNewButton_1.right = new FormAttachment(100, -224);
    btnNewButton_1.setLayoutData(fd_btnNewButton_1);
    btnNewButton_1.setText("->");

    Button btnNewButton_2 = new Button(shlBundler, SWT.NONE);
    fd_btnNewButton_1.bottom = new FormAttachment(100, -143);
    btnNewButton_2.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            IStructuredSelection selection =
                (IStructuredSelection) treeViewerCategories.getSelection();
            Iterator i = selection.iterator();
            while (i.hasNext()) {
              Object o = i.next();
              if (o instanceof Category) {
                Category c = (Category) o;
                Iterator<File> j = c.getSinfiles().iterator();
                while (j.hasNext()) {
                  File f = j.next();
                  files.add(f);
                  meta.remove(f.getName());
                  model.refresh(meta);
                  treeViewerCategories.setAutoExpandLevel(2);
                  treeViewerCategories.refresh();
                  listViewerFiles.refresh();
                }
              }
              if (o instanceof File) {
                String internal = ((File) o).getName();
                files.add(new File(meta.getPath(internal)));
                meta.remove(internal);
                model.refresh(meta);
                treeViewerCategories.setAutoExpandLevel(2);
                treeViewerCategories.refresh();
                listViewerFiles.refresh();
              }
            }
          }
        });
    FormData fd_btnNewButton_2 = new FormData();
    fd_btnNewButton_2.top = new FormAttachment(btnNewButton_1, 23);
    fd_btnNewButton_2.right = new FormAttachment(btnNewButton_1, 0, SWT.RIGHT);
    fd_btnNewButton_2.left = new FormAttachment(0, 353);
    btnNewButton_2.setLayoutData(fd_btnNewButton_2);
    btnNewButton_2.setText("<-");
    Composite composite = new Composite(shlBundler, SWT.NONE);
    composite.setLayout(new GridLayout(3, false));
    FormData fd_composite = new FormData();
    fd_composite.left = new FormAttachment(0, 10);
    fd_composite.right = new FormAttachment(100, -10);
    fd_composite.top = new FormAttachment(0, 10);
    composite.setLayoutData(fd_composite);

    lblSelectSourceFolder = new Label(composite, SWT.NONE);
    GridData gd_lblSelectSourceFolder = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_lblSelectSourceFolder.widthHint = 121;
    lblSelectSourceFolder.setLayoutData(gd_lblSelectSourceFolder);
    lblSelectSourceFolder.setText("Select source folder :");

    sourceFolder = new Text(composite, SWT.BORDER);
    sourceFolder.setEditable(false);
    GridData gd_sourceFolder = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_sourceFolder.widthHint = 428;
    sourceFolder.setLayoutData(gd_sourceFolder);

    btnNewButton = new Button(composite, SWT.NONE);
    btnNewButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    btnNewButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            DirectoryDialog dlg = new DirectoryDialog(shlBundler);

            // Set the initial filter path according
            // to anything they've selected or typed in
            dlg.setFilterPath(sourceFolder.getText());

            // Change the title bar text
            dlg.setText("Directory chooser");

            // Customizable message displayed in the dialog
            dlg.setMessage("Select a directory");

            // Calling open() will open and run the dialog.
            // It will return the selected directory, or
            // null if user cancels
            String dir = dlg.open();
            if (dir != null) {
              // Set the text box to the new selection
              if (!sourceFolder.getText().equals(dir)) {
                sourceFolder.setText(dir);
                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);
              }
            }
          }
        });
    btnNewButton.setText("...");

    Composite composite_1 = new Composite(shlBundler, SWT.NONE);
    fd_lblNewLabel.top = new FormAttachment(0, 154);
    composite_1.setLayout(new GridLayout(3, false));
    FormData fd_composite_1 = new FormData();
    fd_composite_1.bottom = new FormAttachment(lblNewLabel_3, -6);
    fd_composite_1.right = new FormAttachment(composite_5, 0, SWT.RIGHT);
    fd_composite_1.top = new FormAttachment(composite, 2);
    fd_composite_1.left = new FormAttachment(0, 10);
    composite_1.setLayoutData(fd_composite_1);

    lblNewLabel = new Label(composite_1, SWT.NONE);
    GridData gd_lblNewLabel = new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1);
    gd_lblNewLabel.widthHint = 68;
    lblNewLabel.setLayoutData(gd_lblNewLabel);
    lblNewLabel.setText("Device :");

    device = new Text(composite_1, SWT.BORDER);
    device.setToolTipText("Double click to get list of devices");
    device.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseDoubleClick(MouseEvent e) {
            String result = WidgetTask.openDeviceSelector(shlBundler);
            if (result.length() > 0) {
              DeviceEntry ent = new DeviceEntry(result);
              String variant = WidgetTask.openVariantSelector(ent.getId(), shlBundler);
              device.setText(ent.getName() + " (" + variant + ")");
              _variant = variant;
            }
          }
        });
    device.setEditable(false);
    GridData gd_device = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_device.widthHint = 355;
    device.setLayoutData(gd_device);
    new Label(composite_1, SWT.NONE);

    lblNewLabel_2 = new Label(composite_1, SWT.NONE);
    lblNewLabel_2.setText("Branding :");

    branding = new Text(composite_1, SWT.BORDER);
    GridData gd_branding = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_branding.widthHint = 355;
    branding.setLayoutData(gd_branding);

    btnNoFinalVerification = new Button(composite_1, SWT.CHECK);
    btnNoFinalVerification.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false, 1, 1));
    btnNoFinalVerification.setText("No final verification");

    Label lblNewLabel_1 = new Label(composite_1, SWT.NONE);
    lblNewLabel_1.setText("Version :");

    version = new Text(composite_1, SWT.BORDER);
    GridData gd_version = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_version.widthHint = 355;
    version.setLayoutData(gd_version);
    new Label(composite_1, SWT.NONE);
    Label lblFirmwareContent = new Label(shlBundler, SWT.NONE);
    fd_lblNewLabel.right = new FormAttachment(lblFirmwareContent, -67);
    FormData fd_lblFirmwareContent = new FormData();
    fd_lblFirmwareContent.right = new FormAttachment(composite_5, 0, SWT.RIGHT);
    fd_lblFirmwareContent.bottom = new FormAttachment(composite_5, -6);
    fd_lblFirmwareContent.left = new FormAttachment(composite_5, 0, SWT.LEFT);
    lblFirmwareContent.setLayoutData(fd_lblFirmwareContent);
    lblFirmwareContent.setText("Firmware content :");

    branding.setText(_branding);
    version.setText(_version);
    if (_deviceName.length() > 0) device.setText(_deviceName + " (" + _variant + ")");
  }
Exemple #11
0
  /** Create contents of the dialog. */
  private void createContents() {
    shlDecruptWizard = new Shell(getParent(), getStyle());
    shlDecruptWizard.setSize(539, 497);
    shlDecruptWizard.setText("ROM Cleaner");
    shlDecruptWizard.setLayout(new FormLayout());

    listViewerInstalled = new ListViewer(shlDecruptWizard, SWT.BORDER | SWT.V_SCROLL | SWT.MULTI);
    listInstalled = listViewerInstalled.getList();
    listViewerInstalled.setSorter(new ViewerSorter());
    FormData fd_listInstalled = new FormData();
    fd_listInstalled.bottom = new FormAttachment(0, 229);
    fd_listInstalled.right = new FormAttachment(0, 223);
    fd_listInstalled.top = new FormAttachment(0, 71);
    fd_listInstalled.left = new FormAttachment(0, 10);
    listInstalled.setLayoutData(fd_listInstalled);

    listViewerInstalled.setContentProvider(
        new IStructuredContentProvider() {
          public Object[] getElements(Object inputElement) {
            Vector v = (Vector) inputElement;
            return v.toArray();
          }

          public void dispose() {}

          public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
        });
    listViewerInstalled.setLabelProvider(
        new LabelProvider() {
          public Image getImage(Object element) {
            return null;
          }

          public String getText(Object element) {
            return (String) element;
          }
        });

    Label lblInstalled = new Label(shlDecruptWizard, SWT.NONE);
    FormData fd_lblInstalled = new FormData();
    fd_lblInstalled.right = new FormAttachment(0, 173);
    fd_lblInstalled.top = new FormAttachment(0, 51);
    fd_lblInstalled.left = new FormAttachment(0, 10);
    lblInstalled.setLayoutData(fd_lblInstalled);
    lblInstalled.setText("Installed on device :");

    listViewerToRemove = new ListViewer(shlDecruptWizard, SWT.BORDER | SWT.V_SCROLL);
    listViewerToRemove.setSorter(new ViewerSorter());
    listToRemove = listViewerToRemove.getList();
    FormData fd_listToRemove = new FormData();
    fd_listToRemove.bottom = new FormAttachment(listInstalled, 0, SWT.BOTTOM);
    fd_listToRemove.top = new FormAttachment(listInstalled, 0, SWT.TOP);
    fd_listToRemove.right = new FormAttachment(0, 522);
    fd_listToRemove.left = new FormAttachment(0, 282);
    listToRemove.setLayoutData(fd_listToRemove);

    listViewerToRemove.setContentProvider(
        new IStructuredContentProvider() {
          public Object[] getElements(Object inputElement) {
            Vector v = (Vector) inputElement;
            return v.toArray();
          }

          public void dispose() {}

          public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
        });

    listViewerToRemove.setLabelProvider(
        new LabelProvider() {
          public Image getImage(Object element) {
            return null;
          }

          public String getText(Object element) {
            return (String) element;
          }
        });

    Label lbltoremove = new Label(shlDecruptWizard, SWT.NONE);
    FormData fd_lbltoremove = new FormData();
    fd_lbltoremove.right = new FormAttachment(0, 415);
    fd_lbltoremove.top = new FormAttachment(0, 51);
    fd_lbltoremove.left = new FormAttachment(0, 282);
    lbltoremove.setLayoutData(fd_lbltoremove);
    lbltoremove.setText("To be removed :");

    btnCancel = new Button(shlDecruptWizard, SWT.NONE);
    FormData fd_btnCancel = new FormData();
    fd_btnCancel.bottom = new FormAttachment(100, -10);
    fd_btnCancel.right = new FormAttachment(100, -10);
    btnCancel.setLayoutData(fd_btnCancel);
    btnCancel.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            apps = null;
            shlDecruptWizard.dispose();
          }
        });
    btnCancel.setText("Cancel");

    Button btnClean = new Button(shlDecruptWizard, SWT.NONE);
    FormData fd_btnClean = new FormData();
    fd_btnClean.bottom = new FormAttachment(100, -10);
    fd_btnClean.right = new FormAttachment(btnCancel, -6);
    btnClean.setLayoutData(fd_btnClean);
    btnClean.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            apps.saveProfile();
            shlDecruptWizard.dispose();
          }
        });
    btnClean.setText("Clean");

    Composite compositeProfile = new Composite(shlDecruptWizard, SWT.NONE);
    compositeProfile.setLayout(new GridLayout(2, false));
    FormData fd_compositeProfile = new FormData();
    fd_compositeProfile.bottom = new FormAttachment(lblInstalled, -6);
    fd_compositeProfile.top = new FormAttachment(0, 10);
    fd_compositeProfile.left = new FormAttachment(listInstalled, 0, SWT.LEFT);
    fd_compositeProfile.right = new FormAttachment(listToRemove, 0, SWT.RIGHT);
    compositeProfile.setLayoutData(fd_compositeProfile);

    Label lblProfile = new Label(compositeProfile, SWT.NONE);
    GridData gd_lblProfile = new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1);
    gd_lblProfile.widthHint = 92;
    lblProfile.setLayoutData(gd_lblProfile);
    lblProfile.setText("Profile :");

    comboProfile = new Combo(compositeProfile, SWT.READ_ONLY);
    comboProfile.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if (!apps.getCurrentProfile().equals(comboProfile.getText())) {
              apps.setProfile(comboProfile.getText());
              init();
              listViewerInstalled.refresh();
              listViewerToRemove.refresh();
              listViewerToInstall.refresh();
              listViewerAvailable.refresh();
            }
          }
        });
    comboProfile.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    comboProfile.setText("default");

    Iterator<String> itprofiles = apps.getProfiles().iterator();
    while (itprofiles.hasNext()) {
      comboProfile.add(itprofiles.next());
    }
    comboProfile.select(comboProfile.indexOf("default"));

    compositeButtongroup1 = new Composite(shlDecruptWizard, SWT.NONE);
    compositeButtongroup1.setLayout(new GridLayout(1, false));
    FormData fd_compositeButtongroup1 = new FormData();
    fd_compositeButtongroup1.bottom = new FormAttachment(listInstalled, -36, SWT.BOTTOM);
    fd_compositeButtongroup1.top = new FormAttachment(compositeProfile, 61);
    fd_compositeButtongroup1.right = new FormAttachment(listToRemove, -6);
    fd_compositeButtongroup1.left = new FormAttachment(listInstalled, 5);
    compositeButtongroup1.setLayoutData(fd_compositeButtongroup1);

    Button btnAddToRemove = new Button(compositeButtongroup1, SWT.NONE);
    GridData gd_btnAddToRemove = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1);
    gd_btnAddToRemove.heightHint = 26;
    gd_btnAddToRemove.widthHint = 40;
    btnAddToRemove.setLayoutData(gd_btnAddToRemove);
    btnAddToRemove.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            IStructuredSelection selection =
                (IStructuredSelection) listViewerInstalled.getSelection();
            Iterator i = selection.iterator();
            while (i.hasNext()) {
              String f = (String) i.next();
              installed.remove(f);
              toremove.add(f);
              apps.setSafe(apps.getApkName(f));
              listViewerInstalled.refresh();
              listViewerToRemove.refresh();
            }
          }
        });
    btnAddToRemove.setText("->");
    new Label(compositeButtongroup1, SWT.NONE);

    Button btnAddToInstalled = new Button(compositeButtongroup1, SWT.NONE);
    GridData gd_btnAddToInstalled = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1);
    gd_btnAddToInstalled.heightHint = 26;
    gd_btnAddToInstalled.widthHint = 40;
    btnAddToInstalled.setLayoutData(gd_btnAddToInstalled);
    btnAddToInstalled.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            IStructuredSelection selection =
                (IStructuredSelection) listViewerToRemove.getSelection();
            Iterator i = selection.iterator();
            while (i.hasNext()) {
              String f = (String) i.next();
              toremove.remove(f);
              installed.add(f);
              apps.setUnsafe(apps.getApkName(f));
              listViewerInstalled.refresh();
              listViewerToRemove.refresh();
            }
          }
        });
    btnAddToInstalled.setText("<-");
    Label lblAvailable = new Label(shlDecruptWizard, SWT.NONE);
    FormData fd_lblAvailable = new FormData();
    fd_lblAvailable.top = new FormAttachment(listInstalled, 6);
    fd_lblAvailable.left = new FormAttachment(0, 10);
    lblAvailable.setLayoutData(fd_lblAvailable);
    lblAvailable.setText("Available for installation :");

    Label lblToInstall = new Label(shlDecruptWizard, SWT.NONE);
    FormData fd_lblToInstall = new FormData();
    fd_lblToInstall.top = new FormAttachment(listToRemove, 6);
    fd_lblToInstall.left = new FormAttachment(listToRemove, 0, SWT.LEFT);
    lblToInstall.setLayoutData(fd_lblToInstall);
    lblToInstall.setText("To be installed :");

    listViewerAvailable = new ListViewer(shlDecruptWizard, SWT.BORDER | SWT.V_SCROLL);
    listViewerAvailable.setSorter(new ViewerSorter());
    List listAvailable = listViewerAvailable.getList();
    FormData fd_listAvailable = new FormData();
    fd_listAvailable.top = new FormAttachment(lblAvailable, 6);
    fd_listAvailable.right = new FormAttachment(listInstalled, 0, SWT.RIGHT);
    fd_listAvailable.left = new FormAttachment(0, 10);
    listAvailable.setLayoutData(fd_listAvailable);
    listViewerAvailable.setContentProvider(
        new IStructuredContentProvider() {
          public Object[] getElements(Object inputElement) {
            Vector v = (Vector) inputElement;
            return v.toArray();
          }

          public void dispose() {}

          public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
        });

    listViewerAvailable.setLabelProvider(
        new LabelProvider() {
          public Image getImage(Object element) {
            return null;
          }

          public String getText(Object element) {
            return (String) element;
          }
        });

    listViewerToInstall = new ListViewer(shlDecruptWizard, SWT.BORDER | SWT.V_SCROLL);
    listViewerToInstall.setSorter(new ViewerSorter());
    List listToInstall = listViewerToInstall.getList();
    fd_listAvailable.bottom = new FormAttachment(listToInstall, 0, SWT.BOTTOM);
    FormData fd_listToInstall = new FormData();
    fd_listToInstall.bottom = new FormAttachment(btnCancel, -6);
    fd_listToInstall.top = new FormAttachment(lblToInstall, 6);
    fd_listToInstall.left = new FormAttachment(listToRemove, 0, SWT.LEFT);
    fd_listToInstall.right = new FormAttachment(100, -11);
    listToInstall.setLayoutData(fd_listToInstall);

    listViewerToInstall.setContentProvider(
        new IStructuredContentProvider() {
          public Object[] getElements(Object inputElement) {
            Vector v = (Vector) inputElement;
            return v.toArray();
          }

          public void dispose() {}

          public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
        });

    listViewerToInstall.setLabelProvider(
        new LabelProvider() {
          public Image getImage(Object element) {
            return null;
          }

          public String getText(Object element) {
            return (String) element;
          }
        });

    Composite compositeButtongroup2 = new Composite(shlDecruptWizard, SWT.NONE);
    compositeButtongroup2.setLayout(new GridLayout(1, false));
    FormData fd_compositeButtongroup2 = new FormData();
    fd_compositeButtongroup2.bottom = new FormAttachment(100, -89);
    fd_compositeButtongroup2.right = new FormAttachment(compositeButtongroup1, 0, SWT.RIGHT);
    compositeButtongroup2.setLayoutData(fd_compositeButtongroup2);

    Button btnAddToBeInstalled = new Button(compositeButtongroup2, SWT.NONE);
    GridData gd_btnAddToBeInstalled = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1);
    gd_btnAddToBeInstalled.widthHint = 40;
    gd_btnAddToBeInstalled.heightHint = 26;
    btnAddToBeInstalled.setLayoutData(gd_btnAddToBeInstalled);
    btnAddToBeInstalled.setText("->");
    new Label(compositeProfile, SWT.NONE);
    btnAddToBeInstalled.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            IStructuredSelection selection =
                (IStructuredSelection) listViewerAvailable.getSelection();
            Iterator i = selection.iterator();
            while (i.hasNext()) {
              String f = (String) i.next();
              toinstall.add(f);
              available.remove(f);
              apps.setUnsafe(apps.getApkName(f));
              listViewerToInstall.refresh();
              listViewerAvailable.refresh();
            }
          }
        });

    Button btnAddToAvailable = new Button(compositeButtongroup2, SWT.NONE);
    GridData gd_btnAddToAvailable = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1);
    gd_btnAddToAvailable.widthHint = 40;
    gd_btnAddToAvailable.heightHint = 26;
    btnAddToAvailable.setLayoutData(gd_btnAddToAvailable);
    btnAddToAvailable.setText("<-");
    new Label(compositeProfile, SWT.NONE);
    btnAddToAvailable.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            IStructuredSelection selection =
                (IStructuredSelection) listViewerToInstall.getSelection();
            Iterator i = selection.iterator();
            while (i.hasNext()) {
              String f = (String) i.next();
              toinstall.remove(f);
              available.add(f);
              apps.setSafe(apps.getApkName(f));
              listViewerToInstall.refresh();
              listViewerAvailable.refresh();
            }
          }
        });
    listViewerInstalled.setInput(installed);
    listViewerToRemove.setInput(toremove);
    listViewerToInstall.setInput(toinstall);
    listViewerAvailable.setInput(available);
  }
  private void createContent() {
    GridData gridData;

    Composite composite = new Composite(this, SWT.NONE);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    composite.setLayout(new GridLayout(3, false));

    FontRegistry fontRegistry = new FontRegistry(shell.getDisplay());
    fontRegistry.put(
        "WidgetTitle",
        new FontData[] {new FontData("Arial", 10, SWT.BOLD)}); // $NON-NLS-1$ //$NON-NLS-2$

    Label label = new Label(composite, SWT.NONE);
    label.setFont(fontRegistry.get("WidgetTitle")); // $NON-NLS-1$
    label.setText(Messages.getString("RTCTypeToRTTypeWidget.3")); // $NON-NLS-1$
    gridData = new GridData(SWT.BEGINNING, SWT.CENTER, false, false, 3, 1);
    label.setLayoutData(gridData);

    Label titleBarSeparator = new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR);
    titleBarSeparator.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));

    Label currentTerminoRelationTypeLabel = new Label(composite, SWT.NONE);
    currentTerminoRelationTypeLabel.setText(
        Messages.getString("RTCTypeToRTTypeWidget.4") + " :"); // $NON-NLS-1$ //$NON-NLS-2$

    currentTerminoRelationTypeText = new Text(composite, SWT.SINGLE | SWT.BORDER);
    currentTerminoRelationTypeText.setLayoutData(
        new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));

    Label associatedTypeLabel = new Label(composite, SWT.NONE);
    associatedTypeLabel.setLayoutData(
        new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false, 1, 2));
    associatedTypeLabel.setText(
        Messages.getString("RTCTypeToRTTypeWidget.6") + " :"); // $NON-NLS-1$ //$NON-NLS-2$

    rtTypeListViewer = new ListViewer(composite, SWT.BORDER | SWT.V_SCROLL);
    rtTypeListViewer.setContentProvider(new RTTypeContentProvider());
    rtTypeListViewer.setLabelProvider(new RTLabelProvider());
    gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 2);
    gridData.heightHint = 100;
    rtTypeListViewer.getList().setLayoutData(gridData);

    rtTypeListViewer.addSelectionChangedListener(
        new ISelectionChangedListener() {

          public void selectionChanged(SelectionChangedEvent event) {

            IStructuredSelection selection = (IStructuredSelection) event.getSelection();

            if (selection.getFirstElement() != null) {

              unlinkAction.setEnabled(true);

              currentRTType = (ITypeRelationTermino) selection.getFirstElement();

              propertyChangeSupport.firePropertyChange(
                  rtTypeSelectionEventType, null, currentRTType);

            } else {

              unlinkAction.setEnabled(false);
            }
          }
        });

    Label newRTTypeLabel = new Label(composite, SWT.NONE);
    gridData = new GridData();
    gridData.verticalAlignment = SWT.CENTER;
    newRTTypeLabel.setLayoutData(gridData);
    newRTTypeLabel.setText(
        Messages.getString("RTCTypeToRTTypeWidget.8") + " :"); // $NON-NLS-1$ //$NON-NLS-2$

    newRTTypeText = new Text(composite, SWT.SINGLE | SWT.BORDER | SWT.WRAP);
    gridData = new GridData();
    gridData.horizontalAlignment = SWT.FILL;
    gridData.widthHint = 150;
    gridData.grabExcessHorizontalSpace = true;
    newRTTypeText.setLayoutData(gridData);

    Button newRTTypeButton = new Button(composite, SWT.NONE);
    String imageId = org.dafoe.terminologiclevel.Activator.NEW_IMG_ID;
    ImageDescriptor imgDesc =
        org.dafoe.terminologiclevel.Activator.getDefault()
            .getImageRegistry()
            .getDescriptor(imageId);
    Image imageAdd = imgDesc.createImage();
    newRTTypeButton.setImage(imageAdd);
    newRTTypeButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false));

    newRTTypeButton.addSelectionListener(
        new SelectionAdapter() {

          public void widgetSelected(SelectionEvent e) {

            String newRTTypeLabel = newRTTypeText.getText().trim();
            ;

            if (newRTTypeLabel.compareTo("") != 0) { // $NON-NLS-1$

              ITypeRelationTermino testRTType = DatabaseAdapter.getRTTypeByLabel(newRTTypeLabel);

              // there isn't another RT type with the same label
              if (testRTType == null) {

                ITypeRelationTermino newRTType = DatabaseAdapter.createRelationType(newRTTypeLabel);

                org.dafoe.terminoontologiclevel.common.DatabaseAdapter.linkRTCTypeWithRTType(
                    currentRTCType, newRTType);

                newRTTypeText.setText(""); // $NON-NLS-1$

                updateContent(currentRTCType);

                propertyChangeSupport.firePropertyChange(newRTEventType, null, newRTType);

              } else {

                String msg =
                    Messages.getString("RTCTypeToRTTypeWidget.12")
                        + newRTTypeLabel
                        + Messages.getString(
                            "RTCTypeToRTTypeWidget.13"); //$NON-NLS-1$ //$NON-NLS-2$
                msg += Messages.getString("RTCTypeToRTTypeWidget.14"); // $NON-NLS-1$

                MessageDialog.openWarning(
                    shell, Messages.getString("RTCTypeToRTTypeWidget.15"), msg); // $NON-NLS-1$

                newRTTypeText.selectAll();
              }
            }
          }
        });

    composite.addListener(
        SWT.Resize,
        new Listener() {
          public void handleEvent(Event event) {
            Rectangle rect = RTCTypeToRTTypeWidget.this.getClientArea();
            Image newImage = new Image(shell.getDisplay(), Math.max(1, rect.width), 1);
            GC gc = new GC(newImage);
            gc.setForeground(terminologic_level_color);
            gc.setBackground(terminoontologic_level_color);
            gc.fillGradientRectangle(rect.x, rect.y, rect.width, 1, false);
            gc.dispose();
            RTCTypeToRTTypeWidget.this.setBackgroundImage(newImage);
            if (oldImage != null) {
              oldImage.dispose();
            }
            oldImage = newImage;
          }
        });

    makeActions();

    hookPopupMenu();
  }
  @Override
  public void create() {
    super.create();
    super.getShell().setText(Messages.CustomizationDialog_customization);
    super.getShell().setImage(Activator.getDefault().getImage("/icons/papyrus.png")); // $NON-NLS-1$

    Composite contents = new Composite(getDialogArea(), SWT.NONE);
    contents.setLayout(new GridLayout(2, false));
    contents.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    Label label = new Label(contents, SWT.NONE);
    label.setText(Messages.CustomizationDialog_selectContextToEdit);
    label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));

    Collection<Context> contexts = ConfigurationManager.instance.getContexts();

    availableContexts = new List(contents, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    availableContexts.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    availableContextsViewer = new ListViewer(availableContexts);
    availableContextsViewer.setContentProvider(CollectionContentProvider.instance);
    availableContextsViewer.setLabelProvider(
        new LabelProvider() {

          @Override
          public String getText(final Object element) {
            if (element != null && element instanceof Context) {
              Context context = (Context) element;
              return context.getName()
                  + (ConfigurationManager.instance.isPlugin(context)
                      ? Messages.CustomizationDialog_plugin
                      : ""); //$NON-NLS-1$
            }
            return super.getText(element);
          }
        });
    availableContextsViewer.setInput(contexts);
    availableContexts.addSelectionListener(this);

    Composite controls = new Composite(contents, SWT.NONE);
    controls.setLayout(new FillLayout(SWT.VERTICAL));

    copyContext = new Button(controls, SWT.PUSH);
    copyContext.setText(Messages.CustomizationDialog_copy);
    copyContext.setToolTipText(Messages.CustomizationDialog_createNewCopyByCopy);
    copyContext.setEnabled(false);
    copyContext.addSelectionListener(this);

    editContext = new Button(controls, SWT.PUSH);
    editContext.setText(Messages.CustomizationDialog_edit);
    editContext.setToolTipText(Messages.CustomizationDialog_editSelectedContext);
    editContext.setEnabled(false);
    editContext.addSelectionListener(this);

    removeContext = new Button(controls, SWT.PUSH);
    removeContext.setText(Messages.CustomizationDialog_delete);
    removeContext.setToolTipText(Messages.CustomizationDialog_removeSelectedContext);
    removeContext.setEnabled(false);
    removeContext.addSelectionListener(this);

    availableContextsViewer.addSelectionChangedListener(
        new ISelectionChangedListener() {

          public void selectionChanged(final SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            boolean activate = false;

            if (!selection.isEmpty()) {
              Context context = (Context) selection.getFirstElement();
              activate = !ConfigurationManager.instance.isPlugin(context);
            }

            editContext.setEnabled(activate);
            copyContext.setEnabled(!selection.isEmpty());
            removeContext.setEnabled(activate);
          }
        });

    //		generateContext = new Button(controls, SWT.PUSH);
    //		generateContext.setText("Generate");
    //		generateContext.setToolTipText("Generates a new Context from a Metamodel");
    //		generateContext.setEnabled(false);

    getShell().pack();
  }
  /**
   * This is the method used by the framework to install your own controls.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public void createPages() {
    // Creates the model from the editor input
    //
    createModel();

    // Create a page for the selection tree view.
    //
    {
      ViewerPane viewerPane =
          new ViewerPane(getSite().getPage(), ProvervisualEditor.this) {
            public Viewer createViewer(Composite composite) {
              Tree tree = new Tree(composite, SWT.MULTI);
              TreeViewer newTreeViewer = new TreeViewer(tree);
              return newTreeViewer;
            }

            public void requestActivation() {
              super.requestActivation();
              setCurrentViewerPane(this);
            }
          };
      viewerPane.createControl(getContainer());

      selectionViewer = (TreeViewer) viewerPane.getViewer();
      selectionViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));

      selectionViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
      selectionViewer.setInput(editingDomain.getResourceSet());
      viewerPane.setTitle(editingDomain.getResourceSet());

      new AdapterFactoryTreeEditor(selectionViewer.getTree(), adapterFactory);

      createContextMenuFor(selectionViewer);
      int pageIndex = addPage(viewerPane.getControl());
      setPageText(pageIndex, getString("_UI_SelectionPage_label"));
    }

    // Create a page for the parent tree view.
    //
    {
      ViewerPane viewerPane =
          new ViewerPane(getSite().getPage(), ProvervisualEditor.this) {
            public Viewer createViewer(Composite composite) {
              Tree tree = new Tree(composite, SWT.MULTI);
              TreeViewer newTreeViewer = new TreeViewer(tree);
              return newTreeViewer;
            }

            public void requestActivation() {
              super.requestActivation();
              setCurrentViewerPane(this);
            }
          };
      viewerPane.createControl(getContainer());

      parentViewer = (TreeViewer) viewerPane.getViewer();
      parentViewer.setAutoExpandLevel(30);
      parentViewer.setContentProvider(new ReverseAdapterFactoryContentProvider(adapterFactory));
      parentViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));

      createContextMenuFor(parentViewer);
      int pageIndex = addPage(viewerPane.getControl());
      setPageText(pageIndex, getString("_UI_ParentPage_label"));
    }

    // This is the page for the list viewer
    //
    {
      ViewerPane viewerPane =
          new ViewerPane(getSite().getPage(), ProvervisualEditor.this) {
            public Viewer createViewer(Composite composite) {
              return new ListViewer(composite);
            }

            public void requestActivation() {
              super.requestActivation();
              setCurrentViewerPane(this);
            }
          };
      viewerPane.createControl(getContainer());
      listViewer = (ListViewer) viewerPane.getViewer();
      listViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
      listViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));

      createContextMenuFor(listViewer);
      int pageIndex = addPage(viewerPane.getControl());
      setPageText(pageIndex, getString("_UI_ListPage_label"));
    }

    // This is the page for the tree viewer
    //
    {
      ViewerPane viewerPane =
          new ViewerPane(getSite().getPage(), ProvervisualEditor.this) {
            public Viewer createViewer(Composite composite) {
              return new TreeViewer(composite);
            }

            public void requestActivation() {
              super.requestActivation();
              setCurrentViewerPane(this);
            }
          };
      viewerPane.createControl(getContainer());
      treeViewer = (TreeViewer) viewerPane.getViewer();
      treeViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
      treeViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));

      new AdapterFactoryTreeEditor(treeViewer.getTree(), adapterFactory);

      createContextMenuFor(treeViewer);
      int pageIndex = addPage(viewerPane.getControl());
      setPageText(pageIndex, getString("_UI_TreePage_label"));
    }

    // This is the page for the table viewer.
    //
    {
      ViewerPane viewerPane =
          new ViewerPane(getSite().getPage(), ProvervisualEditor.this) {
            public Viewer createViewer(Composite composite) {
              return new TableViewer(composite);
            }

            public void requestActivation() {
              super.requestActivation();
              setCurrentViewerPane(this);
            }
          };
      viewerPane.createControl(getContainer());
      tableViewer = (TableViewer) viewerPane.getViewer();

      Table table = tableViewer.getTable();
      TableLayout layout = new TableLayout();
      table.setLayout(layout);
      table.setHeaderVisible(true);
      table.setLinesVisible(true);

      TableColumn objectColumn = new TableColumn(table, SWT.NONE);
      layout.addColumnData(new ColumnWeightData(3, 100, true));
      objectColumn.setText(getString("_UI_ObjectColumn_label"));
      objectColumn.setResizable(true);

      TableColumn selfColumn = new TableColumn(table, SWT.NONE);
      layout.addColumnData(new ColumnWeightData(2, 100, true));
      selfColumn.setText(getString("_UI_SelfColumn_label"));
      selfColumn.setResizable(true);

      tableViewer.setColumnProperties(new String[] {"a", "b"});
      tableViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
      tableViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));

      createContextMenuFor(tableViewer);
      int pageIndex = addPage(viewerPane.getControl());
      setPageText(pageIndex, getString("_UI_TablePage_label"));
    }

    // This is the page for the table tree viewer.
    //
    {
      ViewerPane viewerPane =
          new ViewerPane(getSite().getPage(), ProvervisualEditor.this) {
            public Viewer createViewer(Composite composite) {
              return new TreeViewer(composite);
            }

            public void requestActivation() {
              super.requestActivation();
              setCurrentViewerPane(this);
            }
          };
      viewerPane.createControl(getContainer());

      treeViewerWithColumns = (TreeViewer) viewerPane.getViewer();

      Tree tree = treeViewerWithColumns.getTree();
      tree.setLayoutData(new FillLayout());
      tree.setHeaderVisible(true);
      tree.setLinesVisible(true);

      TreeColumn objectColumn = new TreeColumn(tree, SWT.NONE);
      objectColumn.setText(getString("_UI_ObjectColumn_label"));
      objectColumn.setResizable(true);
      objectColumn.setWidth(250);

      TreeColumn selfColumn = new TreeColumn(tree, SWT.NONE);
      selfColumn.setText(getString("_UI_SelfColumn_label"));
      selfColumn.setResizable(true);
      selfColumn.setWidth(200);

      treeViewerWithColumns.setColumnProperties(new String[] {"a", "b"});
      treeViewerWithColumns.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
      treeViewerWithColumns.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));

      createContextMenuFor(treeViewerWithColumns);
      int pageIndex = addPage(viewerPane.getControl());
      setPageText(pageIndex, getString("_UI_TreeWithColumnsPage_label"));
    }

    setActivePage(0);

    getContainer()
        .addControlListener(
            new ControlAdapter() {
              boolean guard = false;

              public void controlResized(ControlEvent event) {
                if (!guard) {
                  guard = true;
                  hideTabs();
                  guard = false;
                }
              }
            });
  }