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);
    //        }
  }
  /**
   * 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;
  }
  @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);
  }
  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);
    }
  }
  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);
      }
    }
  }
Example #6
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;
 }
  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());
      }
    }
  }
 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);
          }
        });
  }
Example #10
0
  /** 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);
  }
 private void setViewerInput(final ILaunchConfiguration launchConfiguration) {
   listViewer.setInput(launchConfiguration);
 }
  /**
   * 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();
  }
Example #13
0
 private void initializeViewer() {
   familyList.setInput(this);
 }
  /**
   * 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;
  }
Example #15
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);
  }
Example #16
0
  protected Control bindListOfValues(FormToolkit toolkit, Composite parent, final Object id) {
    final Composite panel = toolkit.createComposite(parent);
    panel.setLayoutData(new GridData(GridData.FILL_BOTH));
    GridLayout layout = new GridLayout(3, false);
    zeroMargins(layout);
    panel.setLayout(layout);

    final Text name = toolkit.createText(panel, "");
    name.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    final Button add = new Button(panel, SWT.PUSH | SWT.BORDER);
    add.setText("Add");
    add.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));

    final Button delete = new Button(panel, SWT.PUSH | SWT.BORDER);
    delete.setText("Delete");
    // delete.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));

    final ListViewer viewer = new ListViewer(panel, SWT.BORDER);
    viewer.setContentProvider(new ObservableListContentProvider());

    final Control control = viewer.getControl();
    control.setLayoutData(new GridData(GridData.FILL_BOTH));
    if (control instanceof org.eclipse.swt.widgets.List) {
      org.eclipse.swt.widgets.List list = (org.eclipse.swt.widgets.List) control;
      list.setSize(400, 300);
    }

    List<String> listData;
    Object value = node.getPropertyValue(id);
    if (value instanceof List) {
      listData = (List<String>) value;
    } else {
      listData = new ArrayList<String>();
    }
    final WritableList input = new WritableList(listData, String.class);
    node.setPropertyValue(id, input);
    viewer.setInput(input);

    final Runnable addAction =
        new Runnable() {
          @Override
          public void run() {
            String p = name.getText();
            name.setText("");
            if (!input.contains(p)) {
              input.add(p);
              fireNodePropertyChangedEvent(id);

              // lets layout to make things a bit bigger if need be
              if (control instanceof org.eclipse.swt.widgets.List) {
                org.eclipse.swt.widgets.List list = (org.eclipse.swt.widgets.List) control;
                list.pack(true);
              }
              panel.layout(true, true);
              layoutForm();
            }
          }
        };
    final Runnable deleteAction =
        new Runnable() {
          @Override
          public void run() {
            if (!viewer.getSelection().isEmpty()) {
              IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
              Iterator iter = selection.iterator();
              while (iter.hasNext()) {
                String p = (String) iter.next();
                input.remove(p);
              }
              fireNodePropertyChangedEvent(id);
            }
          }
        };

    // return on entry field adds
    name.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyReleased(KeyEvent e) {
            if (e.stateMask == 0 && e.keyCode == '\r') {
              addAction.run();
            }
          }
        });
    // backspace on list to delete
    control.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyReleased(KeyEvent e) {
            if ((e.stateMask == 0 && e.keyCode == SWT.BS)
                || (e.stateMask == 0 && e.keyCode == SWT.DEL)) {
              deleteAction.run();
            }
          }
        });

    // enable / disable buttons
    add.setEnabled(false);
    delete.setEnabled(false);
    name.addModifyListener(
        new ModifyListener() {
          @Override
          public void modifyText(ModifyEvent e) {
            add.setEnabled(name.getText().length() > 0);
          }
        });
    viewer.addSelectionChangedListener(
        new ISelectionChangedListener() {
          @Override
          public void selectionChanged(SelectionChangedEvent event) {
            delete.setEnabled(!event.getSelection().isEmpty());
          }
        });

    delete.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            deleteAction.run();
          }
        });

    add.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            addAction.run();
          }
        });

    toolkit.adapt(control, true, true);
    return control;
  }
  @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();
  }