@Override
  public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    final GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 1;
    container.setLayout(gridLayout);
    setControl(container);

    GridLayout projGridLayout = new GridLayout();
    projGridLayout.numColumns = 1;

    Group configGroup = new Group(container, SWT.NONE);
    configGroup.setText("");
    GridData gridData = new GridData(GridData.FILL_BOTH);
    gridData.horizontalSpan = 2;
    gridData.verticalSpan = 3;

    configGroup.setLayoutData(gridData);
    configGroup.setLayout(projGridLayout);

    GridData gridData2 = new GridData(GridData.FILL_BOTH);
    gridData2.horizontalSpan = 1;
    gridData2.verticalSpan = 3;

    optionsLabel = new Label(configGroup, 0);
    optionsLabel.setText("Options: ");
    optionsText = new Text(configGroup, SWT.BORDER | SWT.MULTI);
    optionsText.setText(options);
    optionsText.setLayoutData(gridData2);
    optionsText.addKeyListener(new KeyPressedListener());

    updatePage();
  }
Пример #2
0
  /** Method for creating Length Limit Label and Text */
  protected void createLengthLimit(
      int horizontalSpanLabel,
      int verticalSpanLabel,
      int horizontalSpanText,
      int verticalSpanText,
      int minTextWidth) {
    // Length Limit Label

    lengthLimitLabel = new Label(shell, SWT.NONE);
    lengthLimitLabel.setText("Length limit");
    GridData gridData = new GridData(GridData.END, GridData.CENTER, false, false);
    gridData.horizontalSpan = horizontalSpanLabel;
    gridData.verticalSpan = verticalSpanLabel;
    lengthLimitLabel.setLayoutData(gridData);

    // Length Limit Text

    lengthLimit = new Text(shell, SWT.BORDER);
    lengthLimit.addKeyListener(keyAdapter);
    gridData = new GridData(GridData.BEGINNING, GridData.CENTER, false, false);
    gridData.horizontalSpan = horizontalSpanText;
    gridData.verticalSpan = verticalSpanText;
    gridData.widthHint = minTextWidth;
    lengthLimit.setLayoutData(gridData);
  }
Пример #3
0
  protected void createLimitTypesGroup() {
    GridData gridData; // Group for lengthLimitButton and shortestPlusKButton

    Group limitTypeGroup = new Group(shell, SWT.NONE);
    limitTypeGroup.setText("Stop distance");
    gridData = new GridData(GridData.FILL, GridData.BEGINNING, false, false);
    gridData.horizontalSpan = 2;
    gridData.verticalSpan = 2;
    limitTypeGroup.setLayoutData(gridData);
    limitTypeGroup.setLayout(new GridLayout(2, true));

    // Length limit radio button

    lengthLimitLabel = new Label(limitTypeGroup, SWT.NONE);
    lengthLimitLabel.setText("Length limit");
    gridData = new GridData(GridData.BEGINNING, GridData.CENTER, false, false);
    lengthLimitLabel.setLayoutData(gridData);

    // Length limit text

    lengthLimit = new Text(limitTypeGroup, SWT.BORDER);
    lengthLimit.addKeyListener(keyAdapter);
    gridData = new GridData(GridData.FILL, GridData.CENTER, false, false);
    lengthLimit.setLayoutData(gridData);

    // Shortest+k radio button

    shortestPlusKButton = new Button(limitTypeGroup, SWT.CHECK);
    shortestPlusKButton.setText("Shortest+k");
    gridData = new GridData(GridData.BEGINNING, GridData.CENTER, false, false);
    shortestPlusKButton.setLayoutData(gridData);
    shortestPlusKButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent arg0) {
            shortestPlusK.setEnabled(shortestPlusKButton.getSelection());
          }
        });

    // Shortest+k text

    shortestPlusK = new Text(limitTypeGroup, SWT.BORDER);
    shortestPlusK.addKeyListener(keyAdapter);
    gridData = new GridData(GridData.FILL, GridData.CENTER, false, false);
    shortestPlusK.setLayoutData(gridData);

    // Strict check box

    strictButton = new Button(shell, SWT.CHECK | SWT.WRAP);
    strictButton.setText("Ignore source-source/target-target paths");
    gridData = new GridData(GridData.CENTER, GridData.CENTER, false, false);
    gridData.verticalSpan = 2;
    gridData.horizontalSpan = 4;
    strictButton.setLayoutData(gridData);
  }
Пример #4
0
  /**
   * Fills this field editor's basic controls into the given parent.
   *
   * <p>The string field implementation of this <code>FieldEditor</code> framework method
   * contributes the text field. Subclasses may override but must call <code>super.doFillIntoGrid
   * </code>.
   */
  protected void doFillIntoGrid(Composite parent, int numColumns) {
    getLabelControl(parent);

    textField = getTextControl(parent);
    GridData gd = new GridData();
    gd.horizontalSpan = numColumns - 1;
    if (widthInChars != UNLIMITED) {
      GC gc = new GC(textField);
      try {
        Point extent = gc.textExtent("X"); // $NON-NLS-1$
        gd.widthHint = widthInChars * extent.x;
      } finally {
        gc.dispose();
      }
    } else {
      //            System.out.println("fill");
      gd.horizontalAlignment = GridData.FILL_BOTH;
      gd.verticalSpan = 4;
      gd.horizontalSpan = 1;
      gd.grabExcessVerticalSpace = true;
      gd.widthHint = 400;
      gd.heightHint = 60;
      //            gd.grabExcessHorizontalSpace = true;
    }
    textField.setLayoutData(gd);
  }
Пример #5
0
  /**
   * Creates a table.
   *
   * @param panel parent composite.
   */
  private void createTable(Composite panel) {
    GridData gridData = new GridData(GridData.FILL_BOTH);
    gridData.grabExcessVerticalSpace = true;
    gridData.verticalSpan = VERTICAL_SPAN;
    gridData.heightHint = HEIGHT_HINT;
    gridData.horizontalSpan = 2;
    table =
        new Table(
            panel, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
    table.setLayoutData(gridData);
    table.setHeaderVisible(true);

    TableColumn column = new TableColumn(table, SWT.CENTER, 0);
    column.setText(Messages.RequirementDialog_NameLabelText);
    column.setWidth(COLUMN_WIDTH_SELECT);

    column = new TableColumn(table, SWT.LEFT, 1);
    column.setText(Messages.RequirementDialog_DescriptionLabelText);
    column.setWidth(COLUMN_WIDTH_PARAMETER);

    // create a table viewer.
    tableViewer = new TableViewer(table);
    tableViewer.setUseHashlookup(true);
    tableViewer.setColumnProperties(
        new String[] {
          Messages.RequirementDialog_NameLabelText, Messages.RequirementDialog_DescriptionLabelText
        });

    tableViewer.setContentProvider(this);
    tableViewer.setLabelProvider(new RequirementLabeProvider());
    tableViewer.setInput(requirements);
  }
  private void createLabel(Composite c, int span, String content, Image image, LabelAttributes la) {
    if (content == null && image == null) return;

    Label l = new Label(c, la.getFontStyle());
    GridData gd = new GridData();
    gd.verticalSpan = span;
    gd.horizontalIndent = 5;
    if (content != null) l.setText(content);

    if (image != null) l.setImage(image);
    if (la.getForegroundColor() != null)
      l.setForeground(new Color(DisplayManager.getDefaultDisplay(), la.getForegroundColor()));

    Font initialFont = l.getFont();
    FontData[] fontData = initialFont.getFontData();
    for (int i = 0; i < fontData.length; i++) {
      fontData[i].setHeight(la.getFontSize());
      fontData[i].setStyle(la.getFontStyle());
    }
    Font newFont = new Font(DisplayManager.getDefaultDisplay(), fontData[0]);
    l.setFont(newFont);
    l.pack();

    l.setBackground(c.getBackground());
    l.setLayoutData(gd);
  }
Пример #7
0
  /** Method for creating Stream Direction Group */
  protected void createStreamDirectionGroup(
      int horizontalSpan, int verticalSpan, boolean isBothButton) {
    streamDirectionGroup = new Group(shell, SWT.NONE);
    streamDirectionGroup.setText("Stream direction");
    GridData gridData = new GridData(GridData.FILL, GridData.BEGINNING, false, false);
    gridData.horizontalSpan = horizontalSpan;
    gridData.verticalSpan = verticalSpan;
    streamDirectionGroup.setLayoutData(gridData);
    streamDirectionGroup.setLayout(new GridLayout());

    // Downstream Radio Button

    downstreamButton = new Button(streamDirectionGroup, SWT.RADIO);
    downstreamButton.setText("Downstream");
    gridData = new GridData(GridData.BEGINNING, GridData.CENTER, false, false);
    downstreamButton.setLayoutData(gridData);

    // Upstream Radio Button

    upstreamButton = new Button(streamDirectionGroup, SWT.RADIO);
    upstreamButton.setText("Upstream");
    gridData = new GridData(GridData.BEGINNING, GridData.CENTER, false, false);
    upstreamButton.setLayoutData(gridData);

    // Downstream & Upstream Radio Button
    if (isBothButton) {
      bothButton = new Button(streamDirectionGroup, SWT.RADIO);
      bothButton.setText("Both");
      gridData = new GridData(GridData.BEGINNING, GridData.CENTER, false, false);
      bothButton.setLayoutData(gridData);
    }
  }
 private Control createEmptyLabel(Composite parent, int verticalSpan) {
   Label emptyLabel = new Label(parent, SWT.NONE);
   GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
   gd.horizontalSpan = 2;
   gd.verticalSpan = verticalSpan;
   gd.widthHint = 0;
   emptyLabel.setLayoutData(gd);
   return emptyLabel;
 }
Пример #9
0
    public void init(String labelText) {
      GridLayout lay = new GridLayout();
      lay.numColumns = 1;

      this.setLayout(lay);

      label = new Label(this, SWT.NONE);
      label.setText(labelText == null ? "Gene symbols:" : labelText);
      GridData gridData = new GridData(GridData.FILL, GridData.FILL, true, false);
      gridData.verticalSpan = 1;
      gridData.horizontalSpan = 1;
      label.setLayoutData(gridData);

      symbolText = new Text(this, SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.V_SCROLL);
      gridData = new GridData(GridData.FILL, GridData.FILL, true, true);
      gridData.verticalSpan = 1;
      gridData.horizontalSpan = 1;
      symbolText.setLayoutData(gridData);
    }
Пример #10
0
 /** Method for creating a list */
 protected void createList(
     int horizontalSpan, int verticalSpan, int widthHint, int numberOfItems) {
   entityList = new List(shell, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.HORIZONTAL);
   GridData gridData = new GridData(GridData.FILL, GridData.FILL, true, true);
   gridData.verticalSpan = verticalSpan;
   gridData.horizontalSpan = horizontalSpan;
   gridData.heightHint = entityList.getItemHeight() * numberOfItems;
   gridData.widthHint = widthHint;
   entityList.setLayoutData(gridData);
 }
Пример #11
0
 /** This method initializes filteredTree. */
 private void createModelFilteredTree() {
   GridData gridData3 = new GridData();
   gridData3.horizontalAlignment = GridData.FILL;
   gridData3.grabExcessHorizontalSpace = true;
   gridData3.grabExcessVerticalSpace = true;
   gridData3.verticalSpan = 3;
   gridData3.verticalAlignment = GridData.FILL;
   modeFilteredTree = new FilteredTree(treeViewcomposite, SWT.BORDER, new PatternFilter(), true);
   modeFilteredTree.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
   modeFilteredTree.setLayoutData(gridData3);
 }
 private Text createTextWithLabel(Composite parent, String label) {
   GridData gd = new GridData();
   gd.horizontalAlignment = GridData.FILL;
   gd.verticalAlignment = GridData.FILL;
   gd.verticalSpan = 10;
   Label searchLabel = new Label(parent, SWT.NONE);
   searchLabel.setText(label);
   Text t = new Text(parent, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
   t.setLayoutData(gd);
   return t;
 }
Пример #13
0
  /**
   * Create shell for query dialogs
   *
   * @param opt
   */
  protected void createContents(QueryOptionsPack opt) {
    shell = new Shell(getParent(), SWT.RESIZE | SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);

    // Information is added as the first thing into each query dialog.
    infoLabel = new Label(shell, SWT.NONE);
    GridData gridData = new GridData(GridData.FILL, GridData.FILL, false, false);
    // Maximum span within all different query dialogs
    gridData.horizontalSpan = 8;
    gridData.verticalSpan = 6;
    infoLabel.setLayoutData(gridData);
    if (forSIF) selectedTypes = opt.getSifTypes();
  }
  public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    // Create the layout.
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 3;
    // gridLayout.makeColumnsEqualWidth = true;
    shell.setLayout(gridLayout);
    // Create the children of the composite.

    Button button1 = new Button(shell, SWT.PUSH);
    button1.setText("B1");
    GridData gridData = new GridData();
    gridData.verticalAlignment = GridData.FILL;
    button1.setLayoutData(gridData);

    new Button(shell, SWT.PUSH).setText("Wide Button 2");

    Button button3 = new Button(shell, SWT.PUSH);
    button3.setText("Button 3");
    gridData = new GridData();
    gridData.verticalAlignment = GridData.FILL;
    gridData.verticalSpan = 2;
    gridData.grabExcessVerticalSpace = true;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    button3.setLayoutData(gridData);

    Button button4 = new Button(shell, SWT.PUSH);
    button4.setText("B4");
    gridData = new GridData();
    gridData.verticalAlignment = GridData.FILL;
    button4.setLayoutData(gridData);

    new Button(shell, SWT.PUSH).setText("Button 5");

    String path = System.getProperty("user.dir") + "/util/";
    Image img = new Image(display, path + "grooveshark.ico");

    // row 1 column 1
    //		Label emptyLabel11 = new Label(shell, SWT.NONE);
    //		emptyLabel11.setImage(img);
    //		Color color = new Color(display , 22, 22, 22);
    //		emptyLabel11.setBackground(color);

    shell.pack();
    shell.open();

    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
  }
 private void createContents(final Shell shell) {
   GridLayout gridLayout1 = new GridLayout();
   GridData gridData2 = new GridData(GridData.FILL_HORIZONTAL);
   GridData gridData3 = new GridData(GridData.FILL_HORIZONTAL);
   GridData gridData4 = new GridData(GridData.FILL_HORIZONTAL);
   GridData gridData5 = new GridData(GridData.FILL_HORIZONTAL);
   GridData gridData6 = new GridData(GridData.FILL_HORIZONTAL);
   GridData gridData7 = new GridData(GridData.FILL_HORIZONTAL);
   GridData gridData8 = new GridData(GridData.FILL_HORIZONTAL);
   GridData gridData9 = new GridData(GridData.FILL_HORIZONTAL);
   header = new Label(shell, SWT.NONE);
   textArea = new Text(shell, SWT.MULTI | SWT.READ_ONLY | SWT.BORDER | SWT.V_SCROLL);
   Display disp = shell.getDisplay();
   textArea.setBackground(disp.getSystemColor(SWT.COLOR_WHITE));
   trailer = new Label(shell, SWT.NONE);
   button = createButton(shell, IMQSCScriptsConstants.RUN_SCRIPT_RUN_BUTTON, "Run", false);
   button1 = createButton(shell, IMQSCScriptsConstants.RUN_SCRIPT_SKIP_BUTTON, "Skip", false);
   button2 = createButton(shell, IMQSCScriptsConstants.RUN_SCRIPT_RUNALL_BUTTON, "Run All", false);
   button3 =
       createButton(shell, IMQSCScriptsConstants.RUN_SCRIPT_SKIPALL_BUTTON, "Skip All", false);
   button4 = createButton(shell, IMQSCScriptsConstants.RUN_SCRIPT_ABORT_BUTTON, "Abort", false);
   shell.setLayout(gridLayout1);
   header.setLayoutData(gridData2);
   trailer.setLayoutData(gridData4);
   gridLayout1.numColumns = 5;
   gridData2.horizontalSpan = 5;
   gridData3.horizontalSpan = 5;
   gridData3.verticalSpan = 25;
   textArea.setLayoutData(gridData3);
   gridData4.horizontalSpan = 5;
   gridData5.grabExcessHorizontalSpace = true;
   button.setLayoutData(gridData5);
   gridData6.grabExcessHorizontalSpace = true;
   button1.setLayoutData(gridData6);
   gridData7.grabExcessHorizontalSpace = true;
   button2.setLayoutData(gridData7);
   gridData8.grabExcessHorizontalSpace = true;
   button3.setLayoutData(gridData8);
   gridData9.grabExcessHorizontalSpace = true;
   button4.setLayoutData(gridData9);
   shell.setSize(new org.eclipse.swt.graphics.Point(350, 225));
   shell.setText("Invalid MQSC Command Found");
   header.setText("The following command appears to be invalid MQSC.");
   textArea.setText(fText);
   trailer.setText(
       "Do you want to Run this command, Skip it, Run All invalid commands, or Skip All invalid commands?");
   shell.pack();
 }
  /* (non-Javadoc)
   * @see org.eclipse.pde.internal.ui.editor.PDESection#createClient(org.eclipse.ui.forms.widgets.Section, org.eclipse.ui.forms.widgets.FormToolkit)
   */
  protected void createClient(Section section, FormToolkit toolkit) {

    section.setLayout(FormLayoutFactory.createClearGridLayout(false, 1));
    GridData sectionData = new GridData(GridData.FILL_BOTH);
    sectionData.verticalSpan = 2;
    section.setLayoutData(sectionData);

    Composite container = createClientContainer(section, 2, toolkit);
    createViewerPartControl(container, SWT.MULTI, 2, toolkit);
    container.setLayoutData(new GridData(GridData.FILL_BOTH));

    createOptionalDependenciesButton(container);

    TablePart tablePart = getTablePart();
    fPluginTable = tablePart.getTableViewer();
    fPluginTable.setContentProvider(new ContentProvider());
    fPluginTable.setLabelProvider(PDEPlugin.getDefault().getLabelProvider());
    fPluginTable.setComparator(
        new ViewerComparator() {
          public int compare(Viewer viewer, Object e1, Object e2) {
            IProductPlugin p1 = (IProductPlugin) e1;
            IProductPlugin p2 = (IProductPlugin) e2;
            return super.compare(viewer, p1.getId(), p2.getId());
          }
        });
    GridData data = (GridData) tablePart.getControl().getLayoutData();
    data.minimumWidth = 200;
    fPluginTable.setInput(getProduct());

    tablePart.setButtonEnabled(0, isEditable());
    tablePart.setButtonEnabled(1, isEditable());
    tablePart.setButtonEnabled(2, isEditable());

    // remove buttons will be updated on refresh

    tablePart.setButtonEnabled(5, isEditable());

    toolkit.paintBordersFor(container);
    section.setClient(container);

    section.setText(PDEUIMessages.Product_PluginSection_title);
    section.setDescription(PDEUIMessages.Product_PluginSection_desc);
    getModel().addModelChangedListener(this);
    createSectionToolbar(section, toolkit);
  }
Пример #17
0
  /**
   * Constructs an axis canvas with the specified axis and layout.
   *
   * @param axis the axis to associate with the canvas.
   * @param layout the plot layout.
   */
  public AxisRangeCanvas(
      final Composite parent,
      final IPlot plot,
      final IAxis axis,
      final AxisPlacement placement,
      final CanvasLayoutModel layoutModel) {
    super(parent, plot, SWT.NONE);
    _renderer = new DefaultAxisRangeRenderer(this, plot, axis, placement, layoutModel);
    _axis = axis;
    _placement = placement;
    Font font = new Font(null, "SansSerif", 8, SWT.NORMAL);
    _textProperties.setFont(font);
    font.dispose();

    GridData constraints = new GridData();
    constraints.horizontalSpan = 1;
    constraints.verticalSpan = 1;
    constraints.horizontalAlignment = SWT.FILL;
    constraints.verticalAlignment = SWT.FILL;
    if (placement.equals(AxisPlacement.TOP)) {
      constraints.grabExcessHorizontalSpace = true;
      constraints.grabExcessVerticalSpace = false;
      constraints.heightHint = layoutModel.getTopAxisHeight();
    } else if (placement.equals(AxisPlacement.LEFT)) {
      constraints.grabExcessHorizontalSpace = false;
      constraints.grabExcessVerticalSpace = true;
      constraints.widthHint = layoutModel.getLeftAxisWidth();
    } else if (placement.equals(AxisPlacement.RIGHT)) {
      constraints.grabExcessHorizontalSpace = false;
      constraints.grabExcessVerticalSpace = true;
      constraints.widthHint = layoutModel.getRightAxisWidth();
    } else if (placement.equals(AxisPlacement.BOTTOM)) {
      constraints.grabExcessHorizontalSpace = true;
      constraints.grabExcessVerticalSpace = false;
      constraints.heightHint = layoutModel.getBottomAxisHeight();
    } else {
      throw new IllegalArgumentException("Invalid axis placement: " + placement);
    }
    setLayoutData(constraints);
    //    _formatter.setMaximumIntegerDigits(1);
    //    _formatter.setMinimumIntegerDigits(1);
    //    _formatter.setMaximumIntegerDigits(5);
    //    _formatter.setMinimumIntegerDigits(1);
  }
  @Override
  protected void createClient(Section section, FormToolkit toolkit) {
    section.setText(PDEUIMessages.ExportPackageSection_title);
    if (isFragment()) section.setDescription(PDEUIMessages.ExportPackageSection_descFragment);
    else section.setDescription(PDEUIMessages.ExportPackageSection_desc);

    Composite container = createClientContainer(section, 2, toolkit);
    createViewerPartControl(container, SWT.MULTI, 2, toolkit);
    TablePart tablePart = getTablePart();
    fPackageViewer = tablePart.getTableViewer();
    fPackageViewer.setContentProvider(new ExportPackageContentProvider());
    fPackageViewer.setLabelProvider(PDEPlugin.getDefault().getLabelProvider());
    fPackageViewer.setComparator(
        new ViewerComparator() {
          @Override
          public int compare(Viewer viewer, Object e1, Object e2) {
            String s1 = e1.toString();
            String s2 = e2.toString();
            if (s1.indexOf(" ") != -1) // $NON-NLS-1$
            s1 = s1.substring(0, s1.indexOf(" ")); // $NON-NLS-1$
            if (s2.indexOf(" ") != -1) // $NON-NLS-1$
            s2 = s2.substring(0, s2.indexOf(" ")); // $NON-NLS-1$
            return super.compare(viewer, s1, s2);
          }
        });
    toolkit.paintBordersFor(container);
    section.setClient(container);
    GridData gd = new GridData(GridData.FILL_BOTH);
    if (((ManifestEditor) getPage().getEditor()).isEquinox()) {
      gd.verticalSpan = 2;
      gd.minimumWidth = 300;
    }
    section.setLayout(FormLayoutFactory.createClearGridLayout(false, 1));
    section.setLayoutData(gd);
    makeActions();

    IBundleModel model = getBundleModel();
    fPackageViewer.setInput(model);
    model.addModelChangedListener(this);
    updateButtons();
  }
  /**
   * {@inheritDoc}
   *
   * @see
   *     org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#createControls(org.eclipse.swt.widgets.Composite,
   *     org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage)
   */
  @Override
  public void createControls(
      final Composite parent, final TabbedPropertySheetPage aTabbedPropertySheetPage) {
    super.createControls(parent, aTabbedPropertySheetPage);

    final Composite composite = getWidgetFactory().createFlatFormComposite(parent);
    composite.setLayout(new GridLayout(3, false));

    final Composite choiceComposite = createChoiceComposite(composite);

    choiceTable = getWidgetFactory().createTable(choiceComposite, SWT.MULTI | SWT.BORDER);
    choiceTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    availableElementsTableViewer = new TableViewer(choiceTable);

    final Composite controlButtons = getWidgetFactory().createComposite(composite, SWT.NONE);
    controlButtons.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));

    final GridLayout controlsButtonGridLayout = new GridLayout();
    controlButtons.setLayout(controlsButtonGridLayout);

    new Label(controlButtons, SWT.NONE);

    addButton = getWidgetFactory().createButton(controlButtons, "Add >", SWT.PUSH);
    addButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));

    removeButton = getWidgetFactory().createButton(controlButtons, "< Remove", SWT.PUSH);
    removeButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));

    final Label spaceLabel = new Label(controlButtons, SWT.NONE);
    final GridData spaceLabelGridData = new GridData();
    spaceLabelGridData.verticalSpan = 2;
    spaceLabel.setLayoutData(spaceLabelGridData);

    final Composite featureComposite = createFeatureComposite(composite);

    featureTable = getWidgetFactory().createTable(featureComposite, SWT.MULTI | SWT.BORDER);
    featureTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    selectedElementsTableViewer = new TableViewer(featureTable);
  }
  private void createDoctypeContents(Composite parent) {
    // create description of implicit DOCTYPE
    Text doctypeLabel = new Text(parent, SWT.READ_ONLY);
    doctypeLabel.setText(HTMLUIMessages.UI_Description_of_role_of_following_DOCTYPE);
    GridData data = new GridData(GridData.FILL, GridData.FILL, true, false);
    data.horizontalIndent = 0;
    data.horizontalSpan = 2;
    doctypeLabel.setLayoutData(data);

    // document type
    Label languageLabel = new Label(parent, SWT.NONE);
    languageLabel.setText(HTMLUIMessages.UI_Default_HTML_DOCTYPE_ID___1);
    fDocumentTypeCombo = new Combo(parent, SWT.READ_ONLY);
    data = new GridData(GridData.FILL, GridData.FILL, true, false);
    data.horizontalIndent = 0;
    fDocumentTypeCombo.setLayoutData(data);

    // public ID
    Label publicIdLabel = new Label(parent, SWT.NONE);
    publicIdLabel.setText(HTMLUIMessages.UI_Public_ID);
    fPublicIdText = new Text(parent, SWT.READ_ONLY | SWT.BORDER);
    data = new GridData(GridData.FILL, GridData.FILL, true, false);
    data.horizontalIndent = 0;
    fPublicIdText.setLayoutData(data);

    // system ID
    Label systemIdLabel = new Label(parent, SWT.NONE);
    systemIdLabel.setText(HTMLUIMessages.UI_System_ID);
    fSystemIdText = new Text(parent, SWT.READ_ONLY | SWT.BORDER);
    data = new GridData(GridData.FILL, GridData.FILL, true, false);
    data.horizontalIndent = 0;
    fSystemIdText.setLayoutData(data);

    // create separator
    Label label = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL);
    data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    data.horizontalSpan = 2;
    data.verticalSpan = 8;
    label.setLayoutData(data);
  }
  public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);

    {
      GridLayout layout = new GridLayout();
      layout.numColumns = 2;
      container.setLayout(layout);
    }

    {
      m_table = new Table(container, SWT.CHECK | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
      for (IMethod element : m_elements) {
        TableItem item = new TableItem(m_table, SWT.NONE);
        item.setText(toSignature(element));
        item.setData(element);
      }
      GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
      gd.verticalSpan = 2;
      m_table.setLayoutData(gd);
    }

    {
      Composite cb = new Composite(container, SWT.NULL);
      GridLayout layout = new GridLayout();
      //      cb.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_BLUE));
      cb.setLayout(layout);

      Button selectAll = new Button(cb, SWT.NONE);
      selectAll.setText("Select all");
      selectAll.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true));
      selectAll.addSelectionListener(new Listener(true /* select */));

      Button deselectAll = new Button(cb, SWT.NONE);
      deselectAll.setText("Deselect all");
      deselectAll.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true));
      deselectAll.addSelectionListener(new Listener(false /* deselect */));
    }

    setControl(container);
  }
Пример #22
0
  /** Method for creating Result View Group */
  protected void createResultViewGroup(int horizontalSpan, int verticalSpan) {
    resultViewGroup = new Group(shell, SWT.NONE);
    resultViewGroup.setText("Show result in");
    GridData gridData = new GridData(GridData.FILL, GridData.BEGINNING, false, false);
    gridData.horizontalSpan = horizontalSpan;
    gridData.verticalSpan = verticalSpan;
    resultViewGroup.setLayoutData(gridData);
    resultViewGroup.setLayout(new GridLayout());

    // Current View Radio Button

    currentViewButton = new Button(resultViewGroup, SWT.RADIO);
    currentViewButton.setText("Current view");
    gridData = new GridData(GridData.BEGINNING, GridData.CENTER, false, false);
    currentViewButton.setLayoutData(gridData);

    // New View Radio Button

    newViewButton = new Button(resultViewGroup, SWT.RADIO);
    newViewButton.setText("New view");
    gridData = new GridData(GridData.BEGINNING, GridData.CENTER, false, false);
    newViewButton.setLayoutData(gridData);
  }
  public void createControls(Composite parent) {
    parent.setLayout(new GridLayout(2, false));

    Table variableTable =
        new Table(parent, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER | SWT.CHECK);
    variableTable.setHeaderVisible(true);

    TableColumn nameColumn = new TableColumn(variableTable, SWT.NONE);
    nameColumn.setText("Variable Name");
    nameColumn.setWidth(150);

    TableColumn typeColumn = new TableColumn(variableTable, SWT.NONE);
    typeColumn.setText("Type");
    typeColumn.setWidth(150);

    GridData gd = new GridData(GridData.FILL_VERTICAL);
    gd.verticalSpan = 2;
    gd.widthHint = 505;
    gd.heightHint = 200;
    variableTable.setLayoutData(gd);
    variableViewer = new CheckboxTableViewer(variableTable);
    variableViewer.addCheckStateListener(
        new ICheckStateListener() {

          public void checkStateChanged(CheckStateChangedEvent event) {
            exportedVars.remove(((Variable) event.getElement()).getName());
            if (event.getChecked()) exportedVars.add(((Variable) event.getElement()).getName());
          }
        });
    variableViewer.setColumnProperties(new String[] {"Name", "Type", "Value"});
    variableViewer.setContentProvider(new VariableContentProvider());
    variableViewer.setLabelProvider(new VariableLabelProvider());
    variableViewer.setInput(this);
    for (Variable vd : variables) {
      variableViewer.setChecked(vd, exportedVars.contains(vd.getName()));
    }
  }
Пример #24
0
  @Override
  public void createPartControl(Composite parent) {
    // TODO Auto-generated method stub
    toolkit = new FormToolkit(parent.getDisplay());
    form = toolkit.createForm(parent);
    form.setText("MetaData Editor:");

    toolkit.decorateFormHeading(form);

    GridData gridData = new GridData();
    gridData.grabExcessHorizontalSpace = true;
    gridData.minimumWidth = 200;
    //		FormLayout gridLayout = new FormLayout();
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 2;
    gridLayout.horizontalSpacing = 5;
    form.getBody().setLayout(gridLayout);

    FormData formDate = new FormData();
    formDate.height = 250;
    formDate.width = 300;

    FormData formDate0 = new FormData();
    formDate0.height = 150;
    formDate0.width = 300;
    FormData formDate2 = new FormData();
    formDate2.height = 550;
    formDate2.width = 550;

    Section section = toolkit.createSection(form.getBody(), Section.TITLE_BAR);
    section.setText("Attribute Modifier");
    Composite sectionClient = toolkit.createComposite(section);
    sectionClient.setLayout(new FormLayout());
    section.setClient(sectionClient);

    GridData gridData2 = new GridData();
    gridData2.verticalSpan = 2;
    section.setLayoutData(gridData2);

    Section section2 = toolkit.createSection(form.getBody(), Section.TITLE_BAR);
    section2.setText("Collector");
    Composite sectionClient2 = toolkit.createComposite(section2);
    sectionClient2.setLayout(new FormLayout());
    section2.setClient(sectionClient2);

    Section section3 = toolkit.createSection(form.getBody(), Section.TITLE_BAR); // printStackTrace
    section3.setText("Collection Code");
    Composite sectionClient3 = toolkit.createComposite(section3);
    sectionClient3.setLayout(new FormLayout());
    section3.setClient(sectionClient3);

    final Table table2 =
        toolkit.createTable(
            sectionClient2, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.NONE);
    table2.setHeaderVisible(true);

    final Button submitCollectionCode = toolkit.createButton(sectionClient2, "submit", SWT.None);

    TableColumn column01 = new TableColumn(table2, SWT.NONE);
    column01.setWidth(25);
    column01.setText("#");
    TableColumn column02 = new TableColumn(table2, SWT.NONE);
    column02.setWidth(100);
    column02.setText("Name");
    TableColumn column03 = new TableColumn(table2, SWT.NONE);
    column03.setWidth(100);
    column03.setText("Collection No");
    table2.setLayoutData(formDate);
    int index = 1;
    for (SpecCollectorMap map : spec.getSpecCollectorMaps()) {
      Collector c = map.getCollector();
      TableItem item = new TableItem(table2, SWT.FULL_SELECTION);
      item.setData("collector", c);
      item.setText(0, index + "");
      index++;
      item.setText(1, c.getCollectorFullName()); // c.exe
      if (spec.getRecordNumber() == null) {
        item.setText(2, "");
      } else item.setText(2, spec.getRecordNumber());

      table2.setSelection(index);
    }

    table2.addListener(
        SWT.MouseDoubleClick,
        new Listener() {
          @Override
          public void handleEvent(Event arg0) {
            Point pt = new Point(arg0.x, arg0.y);
            int ret;
            for (final TableItem item : table2.getItems()) {

              for (int i = 0; i < table2.getColumnCount(); i++) {
                Rectangle rect = item.getBounds(i);
                if (rect.contains(pt)) {
                  Collector c = (Collector) item.getData("collector");
                  CollectorModDialog dialog =
                      new CollectorModDialog(Display.getDefault().getActiveShell(), c);
                  ret = dialog.open();
                }
              }
            }
          }
        });
    final Table table3 =
        toolkit.createTable(
            sectionClient3, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.NONE);
    table3.setHeaderVisible(true);

    TableColumn column31 = new TableColumn(table3, SWT.NONE);
    column31.setWidth(25);
    column31.setText("#");
    TableColumn column32 = new TableColumn(table3, SWT.NONE);
    column32.setWidth(50);
    column32.setText("Collection Code");
    TableColumn column33 = new TableColumn(table3, SWT.NONE);
    column33.setWidth(150);
    column33.setText("Collection Info");
    table3.setLayoutData(formDate0);

    Collection ccc = this.spec.getCollection();

    TableItem item31 = new TableItem(table3, SWT.NONE);
    item31.setText(0, "1");
    if (ccc != null) {
      if (ccc.getCollectionCode() == null) ccc.setCollectionCode("");
      if (ccc.getCollectionInfo() == null) ccc.setCollectionInfo("");
      item31.setText(1, ccc.getCollectionCode());
      item31.setText(2, ccc.getCollectionInfo());
    }

    final TableEditor collectionEditor = new TableEditor(table3);
    collectionEditor.horizontalAlignment = SWT.LEFT;
    collectionEditor.grabHorizontal = true;
    collectionEditor.minimumWidth = 50;
    collectionSelectionListener =
        new SelectionListener() {
          @Override
          public void widgetDefaultSelected(SelectionEvent arg0) {
            // TODO Auto-generated method stub

          }

          @Override
          public void widgetSelected(SelectionEvent arg0) {
            // TODO Auto-generated method stub
            Control oldEditor = collectionEditor.getEditor();
            if (oldEditor != null) oldEditor.dispose();
          }
        };

    table3.addSelectionListener(collectionSelectionListener);
    tableListener2 =
        new Listener() {
          @Override
          public void handleEvent(Event arg0) {
            // TODO Auto-generated method stub
            Point pt = new Point(arg0.x, arg0.y);
            for (final TableItem item : table.getItems()) {
              String editable = (String) item.getData("editable");
              if (editable.equals("true")) {}
            }
          }
        };

    tableListener2 =
        new Listener() {
          @Override
          public void handleEvent(Event arg0) {
            Point pt = new Point(arg0.x, arg0.y);
            for (final TableItem item : table3.getItems()) {

              for (int i = 0; i < table3.getColumnCount(); i++) {
                Rectangle rect = item.getBounds(i);
                if (rect.contains(pt)) {
                  Control oldEditor = collectionEditor.getEditor();
                  if (oldEditor != null) oldEditor.dispose();

                  final Combo newEditor = new Combo(table3, SWT.NONE);
                  DataUtilsService service = new DataUtilsService();
                  DataUtilsDelegate delegate = service.getDataUtilsPort();
                  final List<Collection> collections = delegate.getCollections();
                  for (Collection col : collections) {
                    newEditor.add(col.getCollectionCode());
                  }

                  newEditor.addDisposeListener(
                      new DisposeListener() {
                        @Override
                        public void widgetDisposed(DisposeEvent e) {
                          // TODO Auto-generated method stub
                          Combo combo = (Combo) collectionEditor.getEditor();
                          Collection collection = collections.get(combo.getSelectionIndex());
                          collectionEditor.getItem().setText(1, collection.getCollectionCode());
                          collectionEditor.getItem().setText(2, collection.getCollectionInfo());
                          collectionEditor
                              .getItem()
                              .setBackground(new Color(Display.getCurrent(), 255, 250, 160));

                          String methodName = (String) item.getData();
                        }
                      });

                  newEditor.setFocus();
                  collectionEditor.setEditor(newEditor, item, 1);
                }
              }
            }
          }
        };
    table3.addListener(SWT.MouseDoubleClick, tableListener2);

    final Table table =
        toolkit.createTable(sectionClient, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION);
    table.setHeaderVisible(true);
    table.setLayoutData(formDate2);
    TableColumn column = new TableColumn(table, SWT.NONE);
    column.setWidth(200);
    column.setText("Name");
    TableColumn column2 = new TableColumn(table, SWT.NONE);
    column2.setWidth(250);
    column2.setText("Data");
    TableColumn column3 = new TableColumn(table, SWT.NONE);
    column3.setWidth(100);

    //		table.setLayoutData(gridData);
    /*
    		final TableItem itemName = new TableItem(table,SWT.NONE);
    		itemName.setText(0,"Scientific Name:");
    		final TableItem itemFamily = new TableItem(table, SWT.NONE);
    		itemFamily.setText(0, "Family:");
    		itemFamily.setData("setFamily");
    		final TableItem itemGenus = new TableItem(table, SWT.NONE);
    		itemGenus.setText(0, "Genus:");
    		itemGenus.setData("setGenus");
    		final TableItem itemSpecies = new TableItem(table, SWT.NONE);
    		itemSpecies.setText(0, "Species:");
    		itemSpecies.setData("setSpecies");
    		final TableItem itemCollectAt = new TableItem(table, SWT.NONE);
    		itemCollectAt.setText(0, "Collect At:");
    		itemCollectAt.setData("setCountry");
    		final TableItem itemCollectAtDarwin = new TableItem(table, SWT.NONE);
    		itemCollectAtDarwin.setText(0, "Name in Darwin's time:");
    		itemCollectAtDarwin.setData("setDcountry");
    		final TableItem itemSheetNote = new TableItem(table, SWT.NONE);
    		itemSheetNote.setText(0, "Sheet Notes:");
    		itemSheetNote.setData("setSheetNotes");
    		final TableItem itemState = new TableItem(table, SWT.NONE);
    		itemState.setText(0, "State:");
    		itemState.setData("setStateProvince");
    		final TableItem itemTown = new TableItem(table, SWT.NONE);
    		itemTown.setText(0, "Town:");
    		itemTown.setData("setTown");


    		itemName.setText(1,spec.getScientificName());
    		itemFamily.setText(1, spec.getFamily());
    		itemGenus.setText(1, spec.getGenus());
    		itemSpecies.setText(1, spec.getSpecificEpithet());
    		itemCollectAt.setText(1, spec.getCountry());
    		itemCollectAtDarwin.setText(1, spec.getDarwinCountry());
    		itemSheetNote.setText(1, spec.getSheetNotes());
    		itemState.setText(1, spec.getStateProvince());
    		itemTown.setText(1, spec.getTown());
    */

    try {
      Element root = this.configXml.selectElement("system/editor");
      for (int i = 0; i < root.getChildNodes().getLength(); i++) {
        if (root.getChildNodes().item(i).getNodeType() == Element.ELEMENT_NODE) {
          Element child = (Element) root.getChildNodes().item(i);
          System.out.println("child name = " + child.getAttribute("field"));
          if (child.getAttribute("display").equals("true")) {
            final TableItem itemName = new TableItem(table, SWT.NONE);
            System.out.println(itemName);
            itemName.setData("set" + child.getAttribute("field"));
            itemName.setData("editable", child.getAttribute("editable"));
            itemName.setData("type", child.getAttribute("type"));
            itemName.setText(0, child.getAttribute("name"));
            if (child.getAttribute("field").equals("RecordNumber")) {
              System.out.println(child.getAttribute("editable"));
            }
            Method m;

            try {
              m = spec.getClass().getMethod("get" + child.getAttribute("field"));
              System.out.println("function name = " + m.getName());
              if (child.getAttribute("type").equals("date")) {
                XMLGregorianCalendar cal = (XMLGregorianCalendar) m.invoke(spec);

                String calstr = "";
                if (cal != null) {
                  calstr = cal.toString();
                  itemName.setText(1, calstr);
                  itemName.setData("date", cal);
                }
              } else if (child.getAttribute("type").equals("string")) {
                String str = (String) m.invoke(spec);
                if (str == null) {
                  str = "";
                }
                itemName.setText(1, str);
              } else if (child.getAttribute("type").equals("int")) {
                Integer inte = (Integer) m.invoke(spec);
                itemName.setText(1, inte + "");
              }
            } catch (NoSuchMethodException e) {
              // TODO Auto-generated catch block
              System.out.println("field==" + child.getAttribute("field"));
              //						e.printStackTrace();
            } catch (SecurityException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            } catch (IllegalAccessException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            } catch (IllegalArgumentException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            } catch (InvocationTargetException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            }
          }
        }
      }
    } catch (XmlToolException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    }

    final TableEditor editor = new TableEditor(table);
    // The editor must have the same size as the cell and must
    // not be any smaller than 50 pixels.
    editor.horizontalAlignment = SWT.LEFT;
    editor.grabHorizontal = true;
    editor.minimumWidth = 50;
    // editing the second column
    final int EDITABLECOLUMN = 1;
    tableSelectionListener =
        new SelectionListener() {
          @Override
          public void widgetDefaultSelected(SelectionEvent arg0) {
            // TODO Auto-generated method stub

          }

          @Override
          public void widgetSelected(SelectionEvent arg0) {
            // TODO Auto-generated method stub
            Control oldEditor = editor.getEditor();
            if (oldEditor != null) oldEditor.dispose();
          }
        };

    final Button submitButton = toolkit.createButton(form.getBody(), "submit", SWT.None);
    submitButton.setEnabled(false);
    final Label label2 = new Label(form.getBody(), SWT.NONE);
    label2.setData("name", "label2");
    label2.setText("Modification Save Successfully");
    label2.setFont(new Font(Display.getCurrent(), "Arial", 10, SWT.BOLD));
    label2.setForeground(new Color(Display.getCurrent(), 0, 128, 64));
    label2.setVisible(false);

    final Label label3 = new Label(form.getBody(), SWT.NONE);
    label3.setData("name", "label2");
    label3.setText("Modification Save Error!");
    label3.setFont(new Font(Display.getCurrent(), "Arial", 10, SWT.BOLD));
    label3.setForeground(new Color(Display.getCurrent(), 128, 0, 0));
    label3.setVisible(false);

    final Label label4 = new Label(form.getBody(), SWT.NONE);
    label4.setData("name", "label4");
    label4.setFont(new Font(Display.getCurrent(), "Arial", 10, SWT.BOLD));
    label4.setForeground(new Color(Display.getCurrent(), 200, 0, 0));
    label4.setVisible(false);

    final TableEditor edit = new TableEditor(table);
    // The editor must have the same size as the cell and must
    // not be any smaller than 50 pixels.
    edit.horizontalAlignment = SWT.LEFT;
    edit.grabHorizontal = true;
    edit.minimumWidth = 50;
    // editing the second column
    tableSelectionListener =
        new SelectionListener() {
          @Override
          public void widgetDefaultSelected(SelectionEvent arg0) {
            // TODO Auto-generated method stub

          }

          @Override
          public void widgetSelected(SelectionEvent arg0) {
            // TODO Auto-generated method stub
            Control oldEditor = editor.getEditor();
            if (oldEditor != null) oldEditor.dispose();
          }
        };
    table.addSelectionListener(tableSelectionListener);
    tableListener =
        new Listener() {
          @Override
          public void handleEvent(Event arg0) {
            // TODO Auto-generated method stub
            Point pt = new Point(arg0.x, arg0.y);
            for (final TableItem item : table.getItems()) {
              String editable = (String) item.getData("editable");
              if (editable.equals("true")) {
                for (int i = 0; i < table.getColumnCount(); i++) {
                  Rectangle rect = item.getBounds(i);
                  if (rect.contains(pt)) {
                    Control oldEditor = editor.getEditor();
                    if (oldEditor != null) oldEditor.dispose();

                    if (item.getData("type").equals("int")) {
                      Text newEditor = new Text(table, SWT.NONE);
                      newEditor.setText(item.getText(EDITABLECOLUMN));
                      newEditor.addDisposeListener(
                          new DisposeListener() {
                            @Override
                            public void widgetDisposed(DisposeEvent arg0) {
                              // TODO Auto-generated method stub
                              Text text = (Text) editor.getEditor();
                              editor.getItem().setText(EDITABLECOLUMN, text.getText());
                              String methodName = (String) item.getData();
                              for (Method m : spec.getClass().getMethods()) {
                                if (m.getName().equals(methodName)) {
                                  try {
                                    m.invoke(spec, new Object[] {Integer.parseInt(text.getText())});
                                  } catch (IllegalArgumentException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                  } catch (IllegalAccessException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                  } catch (InvocationTargetException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                  }
                                  break;
                                }
                              }

                              item.setBackground(new Color(Display.getCurrent(), 255, 250, 160));
                              item.setData("modified", "true");
                              submitButton.setEnabled(true);
                            }
                          });
                      newEditor.selectAll();
                      newEditor.setFocus();
                      editor.setEditor(newEditor, item, EDITABLECOLUMN);
                      break;
                    }

                    if (item.getData("type").equals("string")) {
                      Text newEditor = new Text(table, SWT.NONE);
                      newEditor.setText(item.getText(EDITABLECOLUMN));
                      newEditor.addDisposeListener(
                          new DisposeListener() {
                            @Override
                            public void widgetDisposed(DisposeEvent arg0) {
                              // TODO Auto-generated method stub
                              Text text = (Text) editor.getEditor();
                              editor.getItem().setText(EDITABLECOLUMN, text.getText());
                              String methodName = (String) item.getData();
                              for (Method m : spec.getClass().getMethods()) {
                                if (m.getName().equals(methodName)) {
                                  try {
                                    m.invoke(spec, new Object[] {text.getText()});
                                  } catch (IllegalArgumentException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                  } catch (IllegalAccessException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                  } catch (InvocationTargetException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                  }
                                  break;
                                }
                              }

                              item.setBackground(new Color(Display.getCurrent(), 255, 250, 160));
                              item.setData("modified", "true");
                              submitButton.setEnabled(true);
                            }
                          });
                      newEditor.selectAll();
                      newEditor.setFocus();
                      editor.setEditor(newEditor, item, EDITABLECOLUMN);
                      break;
                    } else if (item.getData("type").equals("date")) {
                      CalendarCombo calendar = new CalendarCombo(table, SWT.CALENDAR);
                      XMLGregorianCalendar cal = (XMLGregorianCalendar) item.getData("date");
                      if (cal == null) {
                        calendar.setDate(new Date(System.currentTimeMillis()));
                      } else {
                        GregorianCalendar ca = cal.toGregorianCalendar();
                        calendar.setDate(ca.getTime());
                      }
                      //
                      calendar.addDisposeListener(
                          new DisposeListener() {
                            @Override
                            public void widgetDisposed(DisposeEvent arg0) {
                              // TODO Auto-generated method stub
                              CalendarCombo cc = (CalendarCombo) editor.getEditor();
                              editor.getItem().setText(EDITABLECOLUMN, cc.getDateAsString());

                              String methodName = (String) item.getData();
                              for (Method m : spec.getClass().getMethods()) {
                                if (m.getName().equals(methodName)) {
                                  try {
                                    GregorianCalendar gc = new GregorianCalendar();
                                    gc.setTime(cc.getDate().getTime());
                                    XMLGregorianCalendar date2 =
                                        DatatypeFactory.newInstance().newXMLGregorianCalendar(gc);
                                    m.invoke(spec, new Object[] {date2});
                                  } catch (IllegalArgumentException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                  } catch (IllegalAccessException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                  } catch (InvocationTargetException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                  } catch (DatatypeConfigurationException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                  }
                                  break;
                                }
                              }

                              item.setBackground(new Color(Display.getCurrent(), 255, 250, 160));
                              item.setData("modified", "true");
                              submitButton.setEnabled(true);
                            }
                          });

                      calendar.setFocus();
                      editor.setEditor(calendar, item, EDITABLECOLUMN);
                      break;
                    }
                  }
                } // for
              }
            }
          }
        };
    table.addListener(SWT.MouseDoubleClick, tableListener);
    submitButton.setLayoutData(gridData);
    buttonSelectionListener =
        new SelectionListener() {
          @Override
          public void widgetDefaultSelected(SelectionEvent arg0) {
            // TODO Auto-generated method stub

          }

          @Override
          public void widgetSelected(SelectionEvent arg0) {
            // TODO Auto-generated method stub
            try {
              //					Specimen speca = null;
              //					for(IWorkbenchPage p : pages){
              //						IViewReference ivrs [] = p.getViewReferences();
              //						for(IViewReference ivr : ivrs){
              //							if(ivr.getId().equals("TestView.view")){
              //								View v = (View)ivr.getView(true);
              //								speca = v.getGallery().getSelection()[0].getData("spec", spec);
              //								if(spec.getMissingInfo()==0){
              //									v.getGallery().getSelection()[0].setBackground(new
              // Color(Display.getCurrent(), 255,255,255));
              //								}
              //								break;
              //							}
              //						}
              //					}
              DataUtilsService service = new DataUtilsService(); // Missing
              DataUtilsDelegate delegate = service.getDataUtilsPort();
              //					Specimen ss = delegate.getSpecimenById(spec.getSpecimenId());//getView

              List<SpecCollectorMap> scms = delegate.getScms(spec.getSpecimenId());
              //					System.out.println(ss.getSpecimenId()+"***"+scms.size());
              if (spec == null) {
                System.out.println("NULL ID!");
              }
              if (scms == null) {
                System.out.println("NULL SCMS!");
              }
              String scmIds = "";
              int index = 0;
              for (SpecCollectorMap scm : scms) {
                if (index == 0) {
                  scmIds += scm.getSpecCollectorMapId();
                } else {
                  scmIds += ("-" + scm.getSpecCollectorMapId());
                }
                index++;
              }
              System.out.println("scmIds = " + scmIds);
              System.out.println("specimen Id = " + spec.getSpecimenId());
              if (scmIds.equals("")) scmIds = "0";
              Specimen updatedSpecimen = delegate.updateSpecimen(spec, scmIds);
              for (TableItem item : table.getItems()) {
                item.setBackground(new Color(Display.getCurrent(), 255, 255, 255));
                submitButton.setEnabled(false);
              }
              IWorkbenchPage pages[] = getEditorSite().getWorkbenchWindow().getPages();
              for (IWorkbenchPage p : pages) {
                IViewReference ivrs[] = p.getViewReferences();
                for (IViewReference ivr : ivrs) {
                  if (ivr.getId().equals("TestView.view")) {
                    View v = (View) ivr.getView(true);
                    v.getGallery().getSelection()[0].setData(updatedSpecimen);
                    if (spec.getMissingInfo() == 0) {
                      v.getGallery()
                          .getSelection()[0]
                          .setBackground(new Color(Display.getCurrent(), 255, 255, 255));
                    }
                    spec = updatedSpecimen;
                    break;
                  }
                }
              }
              label2.setVisible(true);
              label3.setVisible(false);
              label4.setVisible(false);
            } catch (Exception e) {
              label2.setVisible(false);
              label3.setVisible(true);
              //					label4.setText(e.getMessage());
              label4.setVisible(true);
              e.printStackTrace();
            }
          }
        }; // scientific name inserting
    submitButton.addSelectionListener(buttonSelectionListener);
    System.out.println(Platform.getInstallLocation().getURL().getPath());
    System.out.println(Platform.getInstanceLocation().getURL().getPath());
    Image image = ImageFactory.loadImage(Display.getCurrent(), ImageFactory.ACTION_SYNC);
    IStatusLineManager manager = this.getEditorSite().getActionBars().getStatusLineManager();
    Action toggleBotton =
        new SyncIDropAction("Sync with iDrop", ImageDescriptor.createFromImage(image), manager);
    if (spec.getIdropSync() == null || spec.getIdropSync() == 0) {
      toggleBotton.setEnabled(true);
    } else toggleBotton.setEnabled(true);
    form.getToolBarManager().add(toggleBotton);
    form.getToolBarManager().update(true);
  }
Пример #25
0
  /**
   * Creates the UI of this page. It consists of 2 buttons, a textfield and a label (for filetype
   * errors). Also adds listeners to the buttons that call dialogs upon clicking on them.
   */
  @Override
  public void createControl(Composite parent) {
    final Composite container = new Composite(parent, SWT.NULL);
    GridLayout layout = new GridLayout();
    container.setLayout(layout);
    layout.numColumns = 3;
    Label label = new Label(container, SWT.NULL);
    label.setText("Resource URIs:");

    Button button1 = new Button(container, SWT.PUSH);
    button1.setText("Browse Registered Packages...");
    button1.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent event) {
            // Call the dialog that shows the registered EPackages
            // Multiplicity?
            //
            setErrorMessage(null);
            RegisteredPackageDialog registeredPackageDialog =
                new RegisteredPackageDialog(getShell());
            registeredPackageDialog.open();
            // Save the result
            //
            Object[] result = registeredPackageDialog.getResult();
            if (result != null) {
              saveSelection(result);
            }
          }

          /**
           * Saves the chosen metamodel to the global variable <code>eP</code> . It also makes sure
           * to choose a metamodel not having a 'super'metamodel as the Builder can't handle it. If
           * that is the case the 'super'metamodel is assigned to the local variable <code>eP</code>
           * . The method also sets the nsURI field in the ProjectInfo instance.
           */
          private void saveSelection(Object[] result) {
            List<?> nsURIs = Arrays.asList(result);
            ResourceSet resourceSet = new ResourceSetImpl();
            resourceSet.getURIConverter().getURIMap().putAll(EcorePlugin.computePlatformURIMap());
            Map<String, URI> ePackageNsURItoGenModelLocationMap =
                EcorePlugin.getEPackageNsURIToGenModelLocationMap();
            for (int i = 0, length = result.length; i < length; i++) {
              URI location = ePackageNsURItoGenModelLocationMap.get(result[i]);
              try {
                Resource resource = resourceSet.getResource(location, true);
                setMMBundleName(location);
                EcoreUtil.resolveAll(resource);
              } catch (WrappedException e) {
                setErrorMessage("URI " + location + " could not be resolved.");
                uriField.setText("");
                resourceSet.getResources().clear();
              }
            }
            for (Resource resource : resourceSet.getResources()) {
              for (EPackage ePackage : getAllPackages(resource)) {
                if (nsURIs.contains(ePackage.getNsURI())) {
                  // Save the EPackage to global var eP
                  // var name?
                  EPackage outerMostPackage = getOuterMostEPackage(ePackage);
                  seteP(outerMostPackage);
                  pi.setNsURI(outerMostPackage.getNsURI());
                  uriField.setText(resource.getURI().toString());
                  break;
                }
              }
            }
          }

          private void setMMBundleName(URI location) {
            if (location.isPlatformPlugin()) {
              pi.setMMBundleName(location.toString().split("/")[2]);
            }
          }

          private boolean isMetamodelPackage(EPackage p) {
            for (EObject object : p.eContents()) {
              if (object instanceof EClass) {
                return true;
              }
            }
            return false;
          }

          private EPackage getOuterMostEPackage(EPackage p) {
            EObject container = p.eContainer();
            if (container instanceof EPackage) {
              EPackage ePackage = (EPackage) container;
              if (isMetamodelPackage(ePackage)) {
                return getOuterMostEPackage(ePackage);
              }
            }
            return p;
          }
        });

    Button button3 = new Button(container, SWT.PUSH);
    button3.setText("Browse Workspace...");
    button3.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent event) {
            setErrorMessage(null);
            // This filter filters out all non .ecore files.
            //
            class EcoreFilter extends ViewerFilter {

              @Override
              public boolean select(Viewer viewer, Object parentElement, Object element) {
                if (element instanceof IFolder || element instanceof IProject) {
                  return true;
                }
                if (element instanceof IFile) {
                  IFile file = (IFile) element;
                  if (file.getFileExtension().matches("ecore")) {
                    return true;
                  }
                }

                return false;
              }
            }
            List<ViewerFilter> filters = new ArrayList<ViewerFilter>();
            EcoreFilter filter = new EcoreFilter();
            filters.add(filter);
            // Open a dialog showing the workspace tree allowing one to
            // select a .ecore file from there
            //
            IFile[] files =
                WorkspaceResourceDialog.openFileSelection(
                    getShell(),
                    "Choose Metamodel",
                    "Select the desired Metamodel an click OK.",
                    false,
                    null,
                    filters);
            if (files.length > 0) {
              // Set the appropriate values in ProjectInfo and eP
              //
              pi.setModelPath(files[0].getFullPath().toString());
              pi.setMMBundleName(files[0].getProject().getName());
              try {
                seteP(fileToEPack(files[0]));
              } catch (CodeGenerationException e) {
                MessageDialog.openError(getShell(), "Error", e.getMessage());
              }
              pi.setNsURI(geteP().getNsURI());
              // Not really necessary, as it's not used.
              //
              uriField.setText(
                  URI.createPlatformResourceURI(files[0].getFullPath().toString(), true)
                      .toString());
            }
          }
        });
    GridData gd = new GridData();
    gd.horizontalAlignment = GridData.FILL;
    gd.horizontalSpan = 4;
    uriField = new Text(container, SWT.NULL | SWT.BORDER);
    uriField.setLayoutData(gd);
    uriField.setEditable(false);
    uriField.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            dialogChanged();
          }
        });
    gd = new GridData();
    gd.horizontalAlignment = GridData.FILL;
    gd.verticalAlignment = GridData.FILL;
    gd.horizontalSpan = 4;
    gd.verticalSpan = 2;
    gd.grabExcessHorizontalSpace = true;
    wrongType = new Label(container, SWT.WRAP);
    wrongType.setText("You will only be able to choose .ecore files.");
    wrongType.setLayoutData(gd);
    setErrorMessage(null);
    setControl(container);
  }
Пример #26
0
  private void initIcons(ApplicationFactory factory) {
    Composite center = null;
    if (Application.LICENSE == Install.PERSONAL) {
      center = new Composite(this, SWT.TRANSPARENCY_ALPHA);
      GridData gridData = new GridData(GridData.FILL_BOTH);
      center.setLayoutData(gridData);

      GridLayout gridLayout = new GridLayout(2, false);
      center.setLayout(gridLayout);

      Browser widget = null;

      //      ClientLog.getInstance().setMessage(getShell(), new Exception( "buoc 1 da chay vao day
      // roi " + widget.toString()));

      try {
        widget = new Browser(center, SWT.NONE);
        //        ClientLog.getInstance().setMessage(getShell(), new Exception( " da chay vao day
        // roi " + widget.toString()));
      } catch (Exception e) {
        widget = new Browser(center, SWT.NONE);
        ClientLog.getInstance().setException(null, e);
      }
      gridData = new GridData(GridData.FILL_BOTH);
      gridData.verticalSpan = 2;
      widget.setLayoutData(gridData);
      if (Application.GROUPS.length > 0 && Application.GROUPS[0].equals("XML")) {
        widget.setUrl("http://vietspider.org/webextractor/");
        toolbar.setText("http://vietspider.org/webextractor/");
      } else {
        widget.setUrl("http://nik.vn/tin/");
        //      widget.setUrl("http://*****:*****@SuppressWarnings("unused")
          public void linkActivated(HyperlinkEvent e) {
            BrowserWidget browser = workspace.getTab().createItem();
            browser.viewPage();
          }
        };
    browserImageLink.addHyperlinkListener(listener);
    //    browserLink.addHyperlinkListener(listener);

    composite = createItem(top);
    final ImageHyperlink creatorImageLink =
        new ImageHyperlink(composite, SWT.CENTER | SWT.TRANSPARENCY_ALPHA);
    creatorImageLink.setImage(factory.loadImage("large.createsource.png"));
    //    creatorImageLink.setBackground(getBackground());
    creatorImageLink.setToolTipText(factory.getLabel("creatorLink"));
    //    final Hyperlink creatorLink = createLink(composite);
    //    creatorLink.setText(factory.getLabel("creatorLink"));
    //    creatorLink.setForeground(color);
    listener =
        new HyperlinkAdapter() {
          @SuppressWarnings("unused")
          public void linkEntered(HyperlinkEvent e) {
            //        creatorLink.setUnderlined(true);
          }

          @SuppressWarnings("unused")
          public void linkExited(HyperlinkEvent e) {
            //        creatorLink.setUnderlined(false);
          }

          @SuppressWarnings("unused")
          public void linkActivated(HyperlinkEvent e) {
            //        creatorLink.setUnderlined(false);
            try {
              ChannelWizard wizard =
                  (ChannelWizard)
                      workspace.getTab().createTool(ChannelWizard.class, false, SWT.CLOSE);
            } catch (Exception exp) {
              ClientLog.getInstance().setException(null, exp);
            }
            //        try {
            //          Creator creator = (Creator)workspace.getTab().createTool(
            //              Creator.class, false,  SWT.CLOSE);
            //          creator.selectData(new Worker[0], null, null);
            //        } catch (Exception exp) {
            //          ClientLog.getInstance().setException(null, exp);
            //        }
          }
        };
    creatorImageLink.addHyperlinkListener(listener);
    //    creatorLink.addHyperlinkListener(listener);

    ////////////////////////////////////////////////////////////////////////////////////////////////

    Composite bottom = new Composite(center, SWT.TRANSPARENCY_ALPHA);
    if (Application.LICENSE == Install.PERSONAL) {
      gridData = new GridData();
      gridData.widthHint = 350;
    } else {
      gridData = new GridData(GridData.FILL_BOTH);
    }
    bottom.setLayoutData(gridData);
    //    bottom.setBackground(getBackground());

    rowLayout = new RowLayout();
    rowLayout.wrap = true;
    rowLayout.pack = true;
    rowLayout.justify = true;
    rowLayout.type = SWT.HORIZONTAL;
    rowLayout.marginLeft = 5;
    rowLayout.marginTop = 5;
    rowLayout.marginRight = 5;
    rowLayout.marginBottom = 5;
    rowLayout.spacing = 20;
    bottom.setLayout(rowLayout);

    if (Application.LICENSE != Install.PERSONAL) {
      composite = createItem(top);
    } else {
      composite = createItem(bottom);
    }
    final ImageHyperlink crawlerImageLink =
        new ImageHyperlink(composite, SWT.CENTER | SWT.TRANSPARENCY_ALPHA);
    crawlerImageLink.setImage(factory.loadImage("large.crawler.png"));
    //    crawlerImageLink.setBackground(getBackground());
    crawlerImageLink.setToolTipText(factory.getLabel("crawlerLink"));
    //    final Hyperlink crawlerLink = createLink(composite);
    //    crawlerLink.setText(factory.getLabel("crawlerLink"));
    //    crawlerLink.setForeground(color);
    listener =
        new HyperlinkAdapter() {
          @SuppressWarnings("unused")
          public void linkEntered(HyperlinkEvent e) {
            //        crawlerLink.setUnderlined(true);
          }

          @SuppressWarnings("unused")
          public void linkExited(HyperlinkEvent e) {
            //        crawlerLink.setUnderlined(false);
          }

          @SuppressWarnings("unused")
          public void linkActivated(HyperlinkEvent e) {
            //        crawlerLink.setUnderlined(false);
            try {
              workspace.getTab().createTool(Crawler.class, true, SWT.CLOSE);
            } catch (Exception exp) {
              ClientLog.getInstance().setException(getShell(), exp);
            }
          }
        };
    crawlerImageLink.addHyperlinkListener(listener);
    //    crawlerLink.addHyperlinkListener(listener);

    if (Application.LICENSE != Install.PERSONAL) {
      composite = createItem(bottom);
      final ImageHyperlink monitorImageLink =
          new ImageHyperlink(composite, SWT.CENTER | SWT.TRANSPARENCY_ALPHA);
      monitorImageLink.setImage(factory.loadImage("large.log.png"));
      //      monitorImageLink.setBackground(getBackground());
      monitorImageLink.setToolTipText(factory.getLabel("logLink"));
      //      final Hyperlink monitorLink = createLink(composite);
      //      monitorLink.setText(factory.getLabel("monitorLink"));
      //      monitorLink.setForeground(color);
      listener =
          new HyperlinkAdapter() {
            @SuppressWarnings("unused")
            public void linkActivated(HyperlinkEvent e) {
              try {
                workspace.getTab().createTool(LogViewer2.class, true, SWT.CLOSE);
              } catch (Exception exp) {
                ClientLog.getInstance().setException(workspace.getShell(), exp);
              }
            }
          };
      monitorImageLink.addHyperlinkListener(listener);
      //      monitorLink.addHyperlinkListener(listener);
    }

    /*if(Application.LICENSE  != Install.PERSONAL) {
          composite = createItem(bottom);
          final ImageHyperlink userImageLink =
            new ImageHyperlink(composite, SWT.CENTER | SWT.TRANSPARENCY_ALPHA);
          userImageLink.setImage(factory.loadImage("large.userfolder.png"));
    //      userImageLink.setBackground(getBackground());
          userImageLink.setToolTipText(factory.getLabel("userLink"));
    //      final Hyperlink userLink = createLink(composite);
    //      userLink.setText(factory.getLabel("userLink"));
    //      userLink.setForeground(color);
          listener = new HyperlinkAdapter() {
            @SuppressWarnings("unused")
            public void linkEntered(HyperlinkEvent e) {
    //          userLink.setUnderlined(true);
            }

            @SuppressWarnings("unused")
            public void linkExited(HyperlinkEvent e) {
    //          userLink.setUnderlined(false);
    //          userLink.setFont(UIDATA.FONT_9VB);
            }
            @SuppressWarnings("unused")
            public void linkActivated(HyperlinkEvent e) {
    //          userLink.setUnderlined(false);
              try {
                workspace.getTab().createTool(Organization.class, true,  SWT.CLOSE);
              }catch (Exception exp) {
                ClientLog.getInstance().setException(workspace.getShell(), exp);
              }
            }
          };
          userImageLink.addHyperlinkListener(listener);
    //      userLink.addHyperlinkListener(listener);
        }*/

    composite = createItem(bottom);

    final ImageHyperlink configImageLink =
        new ImageHyperlink(composite, SWT.CENTER | SWT.TRANSPARENCY_ALPHA);
    configImageLink.setImage(factory.loadImage("large.settingsfolder.png"));
    //    configImageLink.setBackground(getBackground());
    configImageLink.setToolTipText(factory.getLabel("configLink"));
    //    final Hyperlink configLink = createLink(composite);
    //    configLink.setText(factory.getLabel("configLink"));
    //    configLink.setForeground(color);
    listener =
        new HyperlinkAdapter() {
          @SuppressWarnings("unused")
          public void linkEntered(HyperlinkEvent e) {
            //        configLink.setUnderlined(true);
          }

          @SuppressWarnings("unused")
          public void linkExited(HyperlinkEvent e) {
            //        configLink.setUnderlined(false);
          }

          @SuppressWarnings("unused")
          public void linkActivated(HyperlinkEvent e) {
            //        configLink.setUnderlined(false);
            try {
              workspace.getTab().createTool(Config.class, true, SWT.CLOSE);
            } catch (Exception exp) {
              ClientLog.getInstance().setException(workspace.getShell(), exp);
            }
          }
        };
    configImageLink.addHyperlinkListener(listener);
  }
  /**
   * Construct a new {@link GridLayoutConfigComposite}.
   *
   * @param parent The parent Composite.
   * @param style The style to apply to the new Composite.
   */
  public GridLayoutConfigComposite(Composite parent, int style) {
    super(parent, style);
    propertyChangeSupport = new PropertyChangeSupport(this);
    XComposite layoutWrapper =
        new XComposite(
            this, SWT.NONE, LayoutMode.TIGHT_WRAPPER, LayoutDataMode.GRID_DATA_HORIZONTAL);
    layoutWrapper.getGridLayout().numColumns = 2;
    layoutWrapper.getGridLayout().makeColumnsEqualWidth = false;
    Label numColLabel = new Label(layoutWrapper, SWT.NONE);
    numColLabel.setText(
        Messages.getString(
            "org.nightlabs.clientui.ui.layout.GridLayoutConfigComposite.label.numberOfColumns.text")); //$NON-NLS-1$

    Button previewButton = new Button(layoutWrapper, SWT.PUSH);
    GridData previewGD = new GridData();
    previewGD.verticalSpan = 3;
    previewGD.verticalAlignment = SWT.END;
    previewButton.setLayoutData(previewGD);
    previewButton.setText(
        Messages.getString(
            "org.nightlabs.clientui.ui.layout.GridLayoutConfigComposite.button.preview.text")); //$NON-NLS-1$
    previewButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if (gridLayoutConfig != null) {
              gridDataEntryConfigComposite.updateGridDataEntry();
              updateGridLayout();
              GridLayoutConfigPreviewDialog dlg =
                  new GridLayoutConfigPreviewDialog(getShell(), null, gridLayoutConfig);
              dlg.open();
            }
          }
        });

    numColText = new Text(layoutWrapper, getBorderStyle());
    GridData gd = new GridData();
    gd.widthHint = 80;
    numColText.setLayoutData(gd);
    numColText.addModifyListener(textListener);

    colsEqualWidthCB = new Button(layoutWrapper, SWT.CHECK);
    colsEqualWidthCB.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    colsEqualWidthCB.setText(
        Messages.getString(
            "org.nightlabs.clientui.ui.layout.GridLayoutConfigComposite.button.columnsEqualWidth.text")); //$NON-NLS-1$
    colsEqualWidthCB.addSelectionListener(cbListener);

    XComposite bottomWrapper = new XComposite(this, SWT.NONE, LayoutMode.TIGHT_WRAPPER);
    bottomWrapper.getGridLayout().numColumns = 2;
    bottomWrapper.getGridLayout().makeColumnsEqualWidth = false;

    gridDataEntryTable = new GridDataEntryTable(bottomWrapper, SWT.NONE);
    gridDataEntryTable.addSelectionChangedListener(selectionChangeListener);

    XComposite buttonWrapper = new XComposite(bottomWrapper, SWT.NONE);

    addEntryButton = new Button(buttonWrapper, SWT.PUSH);
    addEntryButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    addEntryButton.setText(
        Messages.getString(
            "org.nightlabs.clientui.ui.layout.GridLayoutConfigComposite.button.add.text")); //$NON-NLS-1$
    addEntryButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if (gridLayoutConfig != null) {
              IGridDataEntry entry = gridLayoutConfig.addGridDataEntry();
              if (entry != null) {
                refreshEntryTable();
                gridDataEntryTable.setSelection(new StructuredSelection(entry), true);
                fireGridLayoutConfigChanged();
              }
            }
          }
        });

    removeEntryButton = new Button(buttonWrapper, SWT.PUSH);
    removeEntryButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    removeEntryButton.setText(
        Messages.getString(
            "org.nightlabs.clientui.ui.layout.GridLayoutConfigComposite.button.remove.text")); //$NON-NLS-1$
    removeEntryButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if (gridLayoutConfig != null) {
              int index = gridDataEntryTable.getSelectionIndex();

              Collection<IGridDataEntry> entries = gridDataEntryTable.getSelectedElements();
              for (IGridDataEntry entry : entries) {
                gridLayoutConfig.removeGridDataEntry(entry);
              }
              refreshEntryTable();

              if (!gridDataEntryTable.getElements().isEmpty()) {
                gridDataEntryTable.select(index);
              }
              fireGridLayoutConfigChanged();
            }
          }
        });

    moveEntryUpButton = new Button(buttonWrapper, SWT.PUSH);
    moveEntryUpButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    moveEntryUpButton.setText(
        Messages.getString(
            "org.nightlabs.clientui.ui.layout.GridLayoutConfigComposite.button.up.text")); //$NON-NLS-1$
    moveEntryUpButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if (gridLayoutConfig != null) {
              Collection<IGridDataEntry> entries = gridDataEntryTable.getSelectedElements();
              for (IGridDataEntry entry : entries) {
                if (!gridLayoutConfig.moveEntryUp(entry)) {
                  break;
                }
              }
              refreshEntryTable();
              fireGridLayoutConfigChanged();
            }
          }
        });

    moveEntryDownButton = new Button(buttonWrapper, SWT.PUSH);
    moveEntryDownButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    moveEntryDownButton.setText(
        Messages.getString(
            "org.nightlabs.clientui.ui.layout.GridLayoutConfigComposite.button.down.text")); //$NON-NLS-1$
    moveEntryDownButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if (gridLayoutConfig != null) {
              List<IGridDataEntry> entries =
                  new ArrayList<IGridDataEntry>(gridDataEntryTable.getSelectedElements());
              Collections.reverse(entries);
              for (IGridDataEntry entry : entries) {
                if (!gridLayoutConfig.moveEntryDown(entry)) {
                  break;
                }
              }
              refreshEntryTable();
              fireGridLayoutConfigChanged();
            }
          }
        });

    gridDataEntryConfigComposite =
        new GridDataEntryConfigComposite(buttonWrapper, SWT.NONE, LayoutDataMode.NONE);
    GridData gdEntry = new GridData(GridData.FILL_VERTICAL);
    gdEntry.horizontalAlignment = SWT.FILL;
    gdEntry.widthHint = 50;
    gridDataEntryConfigComposite.setLayoutData(gdEntry);
    gridDataEntryConfigComposite.addPropertyChangeListener(entryListener);
  }
  /* (non-Javadoc)
   * @see org.eclipse.vtp.desktop.editors.core.elements.PrimitivePropertiesPanel#createControls(org.eclipse.swt.widgets.Composite)
   */
  public void createControls(Composite parent) {
    parent.setLayout(new GridLayout(2, false));
    parent.setBackgroundMode(SWT.INHERIT_DEFAULT);

    Composite nameComp = new Composite(parent, SWT.NONE);
    nameComp.setBackground(parent.getBackground());
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    nameComp.setLayoutData(gd);
    nameComp.setLayout(new GridLayout(2, false));

    Label nameLabel = new Label(nameComp, SWT.NONE);
    nameLabel.setText("Entry Name:");
    nameLabel.setLayoutData(new GridData());
    nameText = new Text(nameComp, SWT.BORDER | SWT.SINGLE);
    nameText.setText(getElement().getName());
    nameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    Label defaultBrandLabel = new Label(nameComp, SWT.NONE);
    defaultBrandLabel.setText("Default Brand");
    defaultBrandLabel.setLayoutData(new GridData());
    defaultBrandCombo = new Combo(nameComp, SWT.READ_ONLY | SWT.DROP_DOWN);
    defaultBrandCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    for (IBrand b : brands) {
      defaultBrandCombo.add(getLabel(b));
    }
    String currentDefault =
        ((BeginInformationProvider) ((PrimitiveElement) getElement()).getInformationProvider())
            .getDefaultBrand();
    for (int i = 0; i < brands.size(); i++) {
      if (brands.get(i).getId().equals(currentDefault)) {
        defaultBrandCombo.select(i);
        break;
      }
    }
    if (defaultBrandCombo.getSelectionIndex() == -1) defaultBrandCombo.select(0);

    Table variableTable = new Table(parent, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER);
    variableTable.setHeaderVisible(true);

    TableColumn secureColumn = new TableColumn(variableTable, SWT.NONE);
    secureColumn.setImage(Activator.getDefault().getImageRegistry().get("ICON_LOCK"));
    secureColumn.setAlignment(SWT.CENTER);
    secureColumn.setWidth(23);

    TableColumn nameColumn = new TableColumn(variableTable, SWT.NONE);
    nameColumn.setText("Variable Name");
    nameColumn.setWidth(150);

    TableColumn typeColumn = new TableColumn(variableTable, SWT.NONE);
    typeColumn.setText("Type");
    typeColumn.setWidth(150);

    TableColumn valueColumn = new TableColumn(variableTable, SWT.NONE);
    valueColumn.setText("Value");
    valueColumn.setWidth(200);

    gd = new GridData(GridData.FILL_BOTH);
    gd.verticalSpan = 2;
    gd.widthHint = 505;
    gd.heightHint = 200;
    variableTable.setLayoutData(gd);
    valueEditor = new TextCellEditor(variableTable);
    secureEditor = new CheckboxCellEditor(variableTable);
    variableViewer = new TableViewer(variableTable);
    variableViewer.setColumnProperties(new String[] {"Secure", "Name", "Type", "Value"});
    variableViewer.setCellEditors(new CellEditor[] {secureEditor, null, null, valueEditor});
    variableViewer.setCellModifier(new ValueCellModifier());
    variableViewer.setContentProvider(new VariableContentProvider());
    variableViewer.setLabelProvider(new VariableLabelProvider());
    variableViewer.setInput(this);
    variableViewer.setComparator(
        new ViewerComparator() {

          @Override
          public int compare(Viewer viewer, Object e1, Object e2) {
            VariableDeclaration v1 = (VariableDeclaration) e1;
            VariableDeclaration v2 = (VariableDeclaration) e2;
            return v1.getName().compareTo(v2.getName());
          }
        });
    variableViewer.addSelectionChangedListener(
        new ISelectionChangedListener() {
          public void selectionChanged(SelectionChangedEvent event) {
            removeButton.setEnabled(!event.getSelection().isEmpty());
          }
        });
    variableViewer
        .getControl()
        .addKeyListener(
            new KeyListener() {
              public void keyPressed(KeyEvent e) {}

              public void keyReleased(KeyEvent e) {
                if (e.keyCode == SWT.DEL || e.keyCode == SWT.BS) removeVariable();
              }
            });
    Composite buttonComp = new Composite(parent, SWT.NONE);
    buttonComp.setLayout(new GridLayout(1, false));
    buttonComp.setLayoutData(new GridData());
    addButton = new Button(buttonComp, SWT.PUSH);
    addButton.setText("Add");
    addButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    addButton.addSelectionListener(
        new SelectionListener() {
          public void widgetSelected(SelectionEvent e) {
            List<String> reservedNames = new ArrayList<String>();
            for (VariableDeclaration vd : declarations) {
              reservedNames.add(vd.getName());
            }
            NewVariableDialog nvd =
                new NewVariableDialog(
                    addButton.getShell(),
                    reservedNames,
                    getElement().getDesign().getDocument().getProject().getBusinessObjectSet());

            if (nvd.open() == SWT.OK) {
              declarations.add(new VariableDeclaration(nvd.name, nvd.type, 0, null, nvd.secure));
              updateVariables();
            }
          }

          public void widgetDefaultSelected(SelectionEvent e) {}
        });
    removeButton = new Button(buttonComp, SWT.PUSH);
    removeButton.setText("Remove");
    removeButton.setEnabled(false);
    removeButton.setLayoutData(new GridData());
    removeButton.addSelectionListener(
        new SelectionListener() {
          public void widgetSelected(SelectionEvent e) {
            removeVariable();
          }

          public void widgetDefaultSelected(SelectionEvent e) {}
        });
  }
  /** Create GUI elements in the dialog. */
  protected Control createContents(Composite parent) {

    GridLayout layout = new GridLayout();
    layout.numColumns = 3;

    GridData gridLabel = new GridData(GridData.FILL_BOTH);
    gridLabel.verticalSpan = 1;
    gridLabel.horizontalSpan = 1;
    gridLabel.widthHint = 250;
    gridLabel.heightHint = 20;

    GridData gridText = new GridData(GridData.FILL_BOTH);
    gridText.verticalSpan = 1;
    gridText.horizontalSpan = 2;
    gridText.widthHint = 150;
    gridText.heightHint = 20;

    parent.getShell().setLayout(layout);
    parent.getShell().setText("Messagebox View Options");

    Label lblRefreshTime = new Label(parent, SWT.NONE);
    lblRefreshTime.setText("Refresh Time (ms):");
    lblRefreshTime.setLayoutData(gridLabel);

    final Text txtRefreshTime = new Text(parent, SWT.BORDER);
    txtRefreshTime.setText(String.format("%d", getRefreshTime()));
    txtRefreshTime.setLayoutData(gridText);

    Label lblNMsg = new Label(parent, SWT.NONE);
    lblNMsg.setText(
        String.format(
            "Number of Messages (of %d):",
            ResourceCenter.getInstance()
                .getPersistence()
                .count(mbv.getSelectedAdapter(), mbv.getSelectedReader())));
    lblNMsg.setLayoutData(gridLabel);

    final Text txtNMsg = new Text(parent, SWT.BORDER);
    txtNMsg.setText(String.format("%d", getNumberOfMessages()));
    txtNMsg.setLayoutData(gridText);

    // we need to create a special grid data object for the check-box
    // without width-hint as otherwise the check-box will not be displayed
    // in *nix ...
    GridData gridNoWidthHint = new GridData();
    gridNoWidthHint.horizontalSpan = 3;

    final Button allMsg = new Button(parent, SWT.CHECK);
    allMsg.setText("display all messages");
    allMsg.setLayoutData(gridNoWidthHint);
    allMsg.setSelection(false);
    if (Persistence.RETRIEVE_ALL == getNumberOfMessages()) {
      allMsg.setSelection(true);
    }
    // add a selection listener that changes the value of the
    // number of messages field whenever the selection is changed.
    allMsg.addSelectionListener(
        new SelectionListener() {
          public void widgetDefaultSelected(SelectionEvent arg0) {
            // ignore ...
          }

          public void widgetSelected(SelectionEvent arg0) {
            if (allMsg.getSelection()) {
              txtNMsg.setText(String.format("%d", Persistence.RETRIEVE_ALL));
            } else {
              txtNMsg.setText(String.format("%d", ResourceCenter.GET_MAX_MESSAGES));
            }
          }
        });

    final Button btnOK = new Button(parent, SWT.PUSH);
    btnOK.setText("OK");
    btnOK.setFocus();
    btnOK.setLayoutData(gridLabel);

    btnOK.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            setRefreshTime(Long.parseLong(txtRefreshTime.getText()));
            setNumberOfMessages(Integer.parseInt(txtNMsg.getText()));

            setReturnCode(Window.OK);
            close();
          }
        });

    txtRefreshTime.addListener(
        SWT.Modify,
        new Listener() {
          public void handleEvent(Event event) {
            try {
              if ((txtRefreshTime.getText() == null) || (txtRefreshTime.getText().length() < 3)) {
                btnOK.setEnabled(false);
              } else {
                btnOK.setEnabled(true);
                setRefreshTime(Long.parseLong(txtRefreshTime.getText()));
              }
            } catch (Exception e) {
              btnOK.setEnabled(false);
            }
          }
        });

    txtNMsg.addListener(
        SWT.Modify,
        new Listener() {
          public void handleEvent(Event event) {
            try {
              final int n = (new Integer(txtNMsg.getText())).intValue();
              btnOK.setEnabled(true);
              setNumberOfMessages(n);
              if (Persistence.RETRIEVE_ALL != n) {
                allMsg.setSelection(false);
              } else {
                allMsg.setSelection(true);
              }
            } catch (Exception e) {
              btnOK.setEnabled(false);
            }
          }
        });

    final Button btnCancel = new Button(parent, SWT.PUSH);
    btnCancel.setText("Cancel");
    btnCancel.setLayoutData(gridLabel);
    btnCancel.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            setReturnCode(Window.CANCEL);
            close();
          }
        });

    parent.pack();
    return parent;
  }
Пример #30
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);
  }