コード例 #1
0
  private void createLabels(Composite pageContent) {
    Label label = new Label(pageContent, SWT.LEFT);
    label.setText(Messages._UI_LABEL_SOURCE_FILES);

    GridData data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    data.horizontalSpan = 2;
    label.setLayoutData(data);

    label = new Label(pageContent, SWT.LEFT);
    label.setText(Messages._UI_LABEL_SELECTED_FILES);
  }
コード例 #2
0
  private void createSelectedListBox(Composite parent) {
    selectedListBox = new List(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    selectedListBox.addSelectionListener(
        new SelectionListener() {
          public void widgetDefaultSelected(SelectionEvent event) {}

          public void widgetSelected(SelectionEvent event) {

            if (selectedListBox.getSelectionCount() > 0) setRemoveButtonEnabled(true);
            else setRemoveButtonEnabled(false);
            return;
          }
        });

    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.widthHint = SIZING_LISTS_WIDTH;
    gd.heightHint = SIZING_LISTS_HEIGHT;
    selectedListBox.setLayoutData(gd);
  }
コード例 #3
0
  void createImportButton(Composite parent) {
    importButton = new Button(parent, SWT.PUSH);
    importButton.setText(Messages._UI_IMPORT_BUTTON);

    GridData gridData = new GridData();
    gridData.horizontalAlignment = GridData.CENTER;
    importButton.setLayoutData(gridData);
    importButton.addSelectionListener(
        new SelectionListener() {
          public void widgetDefaultSelected(SelectionEvent e) {}

          public void widgetSelected(SelectionEvent e) {
            FileSystemImportWizard importWizard = new FileSystemImportWizard();
            importWizard.init(workbench, selection);
            Shell shell = Display.getCurrent().getActiveShell();
            WizardDialog wizardDialog = new WizardDialog(shell, importWizard);
            wizardDialog.create();
            wizardDialog.open();
            sourceFileViewer.refresh();
          }
        });
    importButton.setToolTipText(Messages._UI_IMPORT_BUTTON_TOOL_TIP);
  }
コード例 #4
0
  private void createSourceViewer(Composite parent) {
    sourceFileViewer =
        new TreeViewer(new Tree(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER));
    sourceFileViewer.setContentProvider(new WorkbenchContentProvider());
    sourceFileViewer.setLabelProvider(new WorkbenchLabelProvider());
    sourceFileViewer.addSelectionChangedListener(
        new ISelectionChangedListener() {
          public void selectionChanged(SelectionChangedEvent event) {
            java.util.List list;
            ISelection selection = event.getSelection();
            boolean newFilesSelected = false;

            if (selection instanceof IStructuredSelection) {
              list = ((IStructuredSelection) selection).toList();
              for (Iterator i = list.iterator(); i.hasNext(); ) {
                IResource resource = (IResource) i.next();
                if (resource instanceof IFile) {
                  if (checkIfFileInTarget((IFile) resource) == false) newFilesSelected = true;
                }
              }
              setAddButtonEnabled(newFilesSelected);
            }
          }
        });
    sourceFileViewer.addDoubleClickListener(
        new IDoubleClickListener() {
          public void doubleClick(DoubleClickEvent event) {
            addSelectedFilesToTargetList();
          }
        });

    Control treeWidget = sourceFileViewer.getTree();
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.widthHint = SIZING_LISTS_WIDTH;
    gd.heightHint = SIZING_LISTS_HEIGHT;
    treeWidget.setLayoutData(gd);
  }
コード例 #5
0
  private void createButtonPanel(Composite pageContent) {
    Composite buttonPanel = new Composite(pageContent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    buttonPanel.setLayout(layout);

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

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

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

    removeAllButton = new Button(buttonPanel, SWT.PUSH);
    removeAllButton.setText(Messages._UI_REMOVE_ALL_BUTTON);
    gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.verticalAlignment = GridData.CENTER;
    removeAllButton.setLayoutData(gridData);
    removeAllButton.addSelectionListener(new ButtonSelectListener());
    removeAllButton.setToolTipText(Messages._UI_REMOVE_ALL_BUTTON_TOOL_TIP);
    removeAllButton.setEnabled(false);
  }
コード例 #6
0
  @Override
  public void createControl(final Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    GridLayout layout = new GridLayout();
    container.setLayout(layout);
    layout.numColumns = 3;
    layout.verticalSpacing = 9;
    Label label = new Label(container, SWT.NULL);
    label.setText("&Container:");

    containerText = new Text(container, SWT.BORDER | SWT.SINGLE);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    containerText.setLayoutData(gd);
    containerText.addModifyListener(
        new ModifyListener() {

          @Override
          public void modifyText(final ModifyEvent e) {
            dialogChanged();
          }
        });

    Button button = new Button(container, SWT.PUSH);
    button.setText("Browse...");
    button.addSelectionListener(
        new SelectionAdapter() {

          @Override
          public void widgetSelected(final SelectionEvent e) {
            handleBrowse();
          }
        });

    label = new Label(container, SWT.NULL);
    label.setText("&Choose a model:");

    Composite middleComposite = new Composite(container, SWT.NULL);
    FillLayout fillLayout = new FillLayout();
    middleComposite.setLayout(fillLayout);

    emptyModelButton = new Button(middleComposite, SWT.RADIO);
    emptyModelButton.setText("Empty");
    emptyModelButton.setSelection(true);
    skeletonModelButton = new Button(middleComposite, SWT.RADIO);
    skeletonModelButton.setText("Skeleton");
    exampleModelButton = new Button(middleComposite, SWT.RADIO);
    exampleModelButton.setText("Example");
    emptyModelButton.addSelectionListener(
        new SelectionAdapter() {

          @Override
          public void widgetSelected(final SelectionEvent se) {
            typeOfModel = "empty";
            radioChanged();
          }
        });
    exampleModelButton.addSelectionListener(
        new SelectionAdapter() {

          @Override
          public void widgetSelected(final SelectionEvent se) {
            typeOfModel = "example";
            radioChanged();
          }
        });
    skeletonModelButton.addSelectionListener(
        new SelectionAdapter() {

          @Override
          public void widgetSelected(final SelectionEvent se) {
            typeOfModel = "skeleton";
            radioChanged();
          }
        });

    /* Need to add empty label so the next controls are pushed to the next line in the grid. */
    label = new Label(container, SWT.NULL);
    label.setText("");

    label = new Label(container, SWT.NULL);
    label.setText("&File name:");

    fileText = new Text(container, SWT.BORDER | SWT.SINGLE);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    fileText.setLayoutData(gd);
    fileText.addModifyListener(
        new ModifyListener() {

          @Override
          public void modifyText(final ModifyEvent e) {
            Text t = (Text) e.getSource();
            String fname = t.getText();
            int i = fname.lastIndexOf(".gaml");
            if (i > 0) {
              // model title = filename less extension less all non alphanumeric characters
              titleText.setText(fname.substring(0, i).replaceAll("[^\\p{Alnum}]", ""));
            } /*
               * else if (fname.length()>0) {
               * int pos = t.getSelection().x;
               * fname = fname.replaceAll("[[^\\p{Alnum}]&&[^_-]&&[^\\x2E]]", "_");
               * t.setText(fname+".gaml");
               * t.setSelection(pos);
               * } else {
               * t.setText("new.gaml");
               * }
               */
            dialogChanged();
          }
        });

    /* Need to add empty label so the next two controls are pushed to the next line in the grid. */
    label = new Label(container, SWT.NULL);
    label.setText("");

    label = new Label(container, SWT.NULL);
    label.setText("&Author:");

    authorText = new Text(container, SWT.BORDER | SWT.SINGLE);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    authorText.setLayoutData(gd);
    authorText.setText(getComputerFullName());
    authorText.addModifyListener(
        new ModifyListener() {

          @Override
          public void modifyText(final ModifyEvent e) {
            dialogChanged();
          }
        });

    /* Need to add empty label so the next two controls are pushed to the next line in the grid. */
    label = new Label(container, SWT.NULL);
    label.setText("");

    label = new Label(container, SWT.NULL);
    label.setText("&Model name:");

    titleText = new Text(container, SWT.BORDER | SWT.SINGLE);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    titleText.setLayoutData(gd);
    titleText.setText("new");
    titleText.addModifyListener(
        new ModifyListener() {

          @Override
          public void modifyText(final ModifyEvent e) {
            dialogChanged();
          }
        });

    /* Need to add empty label so the next two controls are pushed to the next line in the grid. */
    label = new Label(container, SWT.NULL);
    label.setText("");

    label = new Label(container, SWT.NULL);
    label.setText("&Model description:");

    descriptionText =
        new Text(container, SWT.WRAP | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    descriptionText.setBounds(0, 0, 250, 100);
    gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    gd.verticalSpan = 4;
    descriptionText.setLayoutData(gd);

    /*
     * Need to add seven empty labels in order to push next controls after the descriptionText
     * box.
     */
    // TODO Dirty!! Change the way to do this
    for (int i = 0; i < 7; i++) {
      label = new Label(container, SWT.NULL);
      label.setText("");
    }

    label = new Label(container, SWT.NULL);
    label.setText("&Create a html template \nfor the model description ?");

    middleComposite = new Composite(container, SWT.NULL);
    fillLayout = new FillLayout();
    middleComposite.setLayout(fillLayout);

    yesButton = new Button(middleComposite, SWT.RADIO);
    yesButton.setText("Yes");
    yesButton.setSelection(true);
    Button noButton = new Button(middleComposite, SWT.RADIO);
    noButton.setText("No");
    yesButton.addSelectionListener(
        new SelectionAdapter() {

          @Override
          public void widgetSelected(final SelectionEvent se) {
            dialogChanged();
          }
        });

    /* Finished adding the custom control */
    initialize();
    dialogChanged();
    setControl(container);
  }