/**
   * Adds columns to the provided <code>TableViewer</code>.
   *
   * @param tableViewer
   */
  protected void addTableViewerColumns(TableViewer tableViewer) {

    if (tableViewer != null) {
      TableColumn column;
      ICellContentProvider contentProvider;

      // ---- Create the name column. ---- //
      nameColumn = new TableViewerColumn(tableViewer, SWT.LEFT);
      column = nameColumn.getColumn();
      column.setText("Name");
      column.setToolTipText("The name of the property");
      column.setResizable(true);
      // Create an ICellContentProvider, then use it to generate the
      // column labels and provide editing support for the name column.
      contentProvider =
          new NameCellContentProvider() {
            @Override
            public boolean setValue(Object element, Object value) {
              boolean changed = super.setValue(element, value);
              // If the value changed, mark the associated ICEFormEditor
              // as dirty.
              if (changed && editor != null) {
                editor.setDirty(true);
              }
              return changed;
            }
          };
      nameColumn.setLabelProvider(new CellColumnLabelProvider(contentProvider));
      nameColumn.setEditingSupport(new TextCellEditingSupport(tableViewer, contentProvider));
      // --------------------------------- //

      // ---- Create the value column. ---- //
      valueColumn = new TableViewerColumn(tableViewer, SWT.LEFT);
      column = valueColumn.getColumn();
      column.setText("Value");
      column.setToolTipText("The value of the property");
      column.setResizable(true);
      // Create an ICellContentProvider, then use it to generate the
      // column labels and provide editing support for the value column.
      contentProvider =
          new ValueCellContentProvider() {
            @Override
            public boolean setValue(Object element, Object value) {
              boolean changed = super.setValue(element, value);
              // If the value changed, mark the associated ICEFormEditor
              // as dirty.
              if (changed && editor != null) {
                editor.setDirty(true);
              }
              return changed;
            }
          };
      valueColumn.setLabelProvider(new CellColumnLabelProvider(contentProvider));
      valueColumn.setEditingSupport(
          new ComboCellEditingSupport(tableViewer, (IComboCellContentProvider) contentProvider));
      // ---------------------------------- //
    }

    return;
  }
Example #2
0
  private void createHeaderTableColumns(TableViewer viewer, TableColumnLayout layout) {
    final String[] titles = {
      "Name", "Value",
    };
    final ColumnLayoutData[] layoutData = {
      new ColumnPixelData(120, true, true), new ColumnWeightData(100, 100, true),
    };
    final EditingSupport editorList[] = {
      new HeaderNameEditingSupport(viewer), new HeaderValueEditingSupport(viewer),
    };
    final ColumnLabelProvider providerList[] = {
      new ColumnLabelProvider() {
        @Override
        public String getText(Object element) {
          return ((IHttpHeaderBuilder) element).getName();
        }
      },
      new ColumnLabelProvider() {
        @Override
        public String getText(Object element) {
          return ((IHttpHeaderBuilder) element).getValue();
        }
      },
    };

    for (int i = 0; i < titles.length; i++) {
      final TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
      final TableColumn c = column.getColumn();
      layout.setColumnData(c, layoutData[i]);
      c.setText(titles[i]);
      c.setMoveable(true);
      column.setEditingSupport(editorList[i]);
      column.setLabelProvider(providerList[i]);
    }
  }
Example #3
0
  private TableViewer createPropertiesSection(Composite parent) {
    TableViewer viewer =
        new TableViewer(
            parent, SWT.SINGLE | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);

    Table table = viewer.getTable();
    setLayout(table);
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    table.setFont(parent.getFont());

    TableViewerColumn nameColumn = new TableViewerColumn(viewer, SWT.NONE);
    nameColumn.setLabelProvider(new NameLabelProvider());
    nameColumn.getColumn().setText("Name");
    nameColumn.getColumn().setResizable(true);
    nameColumn.getColumn().setMoveable(true);

    TableViewerColumn valueColumn = new TableViewerColumn(viewer, SWT.NONE);
    valueColumn.setLabelProvider(new ValueLabelProvider());
    valueColumn.getColumn().setText("Value");
    valueColumn.getColumn().setResizable(true);
    valueColumn.getColumn().setMoveable(true);
    valueColumn.setEditingSupport(new RedDeerEditingSupport(viewer));

    viewer.setContentProvider(new ArrayContentProvider());

    return viewer;
  }
  /**
   * Creates the table layout
   *
   * @param viewer
   */
  public void createColumns(final TableViewer viewer) {
    TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
    column.getColumn().setWidth(300);
    column
        .getColumn()
        .setText(Messages.getString("PatientIdDialog.column_header.type")); // $NON-NLS-1$
    column.getColumn().setMoveable(true);
    column.setLabelProvider(
        new ColumnLabelProvider() {

          @Override
          public String getText(Object element) {
            PatientIdentifier content = (PatientIdentifier) element;
            return content.getType().getName();
          }
        });

    TableViewerColumn column1 = new TableViewerColumn(viewer, SWT.NONE);
    column1.getColumn().setWidth(200);
    column1
        .getColumn()
        .setText(Messages.getString("PatientIdDialog.column_header.number")); // $NON-NLS-1$
    column1.getColumn().setMoveable(true);
    column1.setEditingSupport(new PatientIdentifierEditingSupport(viewer));
    column1.setLabelProvider(
        new ColumnLabelProvider() {

          @Override
          public String getText(Object element) {
            PatientIdentifier content = (PatientIdentifier) element;
            return content.getValueEdit();
          }
        });
  }
Example #5
0
  /**
   * Handle game finished.
   *
   * @param player the player
   */
  private void handleGameFinished(IPlayer player) {
    TableViewerColumn column;
    column = this.playerColumn.get(player);
    column.getColumn().setImage(ProtoPlugin.getImage(ISharedImages.IMG_TICK_DECO));
    // remove edition
    for (Text inputTxt : this.playerScoreInput.values()) {
      inputTxt.setEnabled(false);

      inputTxt.setBackground(
          OpenDartsFormsToolkit.getToolkit()
              .getColors()
              .getColor(OpenDartsFormsToolkit.COLOR_INACTIVE));
    }
    for (TableViewerColumn col : this.playerColumn.values()) {
      col.setEditingSupport(null);
    }

    // End Game dialog
    if (!this.game.getParentSet().isFinished()) {
      String title = MessageFormat.format("{0} finished", this.game);
      String message = this.game.getWinningMessage();
      Shell shell = this.getSite().getShell();
      MessageDialog.open(MessageDialog.INFORMATION, shell, title, message, SWT.SHEET);
    }
    this.dirty = false;
    this.mForm.dirtyStateChanged();
  }
  private void createDependencyViewer(Composite parent) {
    dependencyViewer =
        new TableViewer(
            parent, SWT.SINGLE | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.heightHint = 80;
    dependencyViewer.getTable().setLayoutData(gd);
    // viewer.setLabelProvider(new TableLabelProvider());
    dependencyViewer.setContentProvider(new TableContentProvider());
    Table table = dependencyViewer.getTable();
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    table.setFont(parent.getFont());

    String[] columnHeaders = {
      Messages.MavenUserLibraryProviderInstallPanel_GroupId,
      Messages.MavenUserLibraryProviderInstallPanel_ArtifactId,
      Messages.MavenUserLibraryProviderInstallPanel_Version,
      Messages.MavenUserLibraryProviderInstallPanel_Scope,
      Messages.MavenUserLibraryProviderInstallPanel_Type
    };

    for (int i = 0; i < columnHeaders.length; i++) {
      TableViewerColumn column = new TableViewerColumn(dependencyViewer, SWT.NONE);
      column.setLabelProvider(new DependencyColumnLabelProvider(i));
      column.getColumn().setText(columnHeaders[i]);
      column.getColumn().setResizable(true);
      column.getColumn().setMoveable(true);
      column.setEditingSupport(new DependencyEditingSupport(dependencyViewer, i));
    }

    TableLayout layout = new AutoResizeTableLayout(table);
    for (int i = 0; i < dependencyTableColumnLayouts.length; i++) {
      layout.addColumnData(dependencyTableColumnLayouts[i]);
    }

    dependencyViewer.getTable().setLayout(layout);
    dependencyViewer.setInput(dependencies);
    createDependencyButtons(parent);
  }
  public Snippet034CellEditorPerRowNewAPI(Shell shell) {
    final Table table = new Table(shell, SWT.BORDER | SWT.FULL_SELECTION);

    final TableViewer v = new TableViewer(table);
    v.getTable().setLinesVisible(true);

    TableViewerColumn column = new TableViewerColumn(v, SWT.NONE);
    column.getColumn().setWidth(200);
    column.setLabelProvider(
        new ColumnLabelProvider() {

          @Override
          public String getText(Object element) {
            return element.toString();
          }
        });

    column.setEditingSupport(new MyEditingSupport(v));

    v.setContentProvider(new MyContentProvider());

    MyModel[] model = createModel();
    v.setInput(model);
  }
  /** Create the tableViewer Panel */
  @SuppressWarnings("unused")
  private void createTableViewerPanel(Composite theParent) {
    Composite tablePanel = new Composite(theParent, SWT.NONE);

    // Set the layout
    GridLayout gridLayout = new GridLayout();
    tablePanel.setLayout(gridLayout);

    GridData gridData = new GridData(GridData.FILL_BOTH);
    tablePanel.setLayoutData(gridData);

    // Add header panel

    HEADER_PANEL:
    {
      Composite headerPanel = WidgetFactory.createPanel(tablePanel);
      // ------------------------------
      // Set layout for the Composite
      // ------------------------------
      headerPanel.setLayout(new GridLayout());
      ((GridLayout) headerPanel.getLayout()).numColumns = 3;
      headerPanel.setLayoutData(new GridData(GridData.FILL_BOTH));
      ((GridData) headerPanel.getLayoutData()).minimumHeight = 80;
      // ((GridData)headerPanel.getLayoutData()).grabExcessHorizontalSpace = true;

      // Add general info/instructions text box
      {
        helpText = new Text(headerPanel, SWT.WRAP | SWT.READ_ONLY);
        helpText.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));
        helpText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_BLUE));
        helpText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
        ((GridData) helpText.getLayoutData()).horizontalSpan = 3;
        ((GridData) helpText.getLayoutData()).heightHint = 40;
        ((GridData) helpText.getLayoutData()).widthHint = 360;

        helpText.setText(Messages.datatypeReconciler_helpText);
      }

      // Add button bar containing:
      // [CHANGE ALL COLUMN DATATYPES] - or - [CONVERT ALL SQL SYMBOLS]
      this.convertAllSqlSymbolsButton =
          WidgetFactory.createButton(
              headerPanel, Messages.datatypeReconciler_convertAllSqlSymbolsLabel);
      this.convertAllSqlSymbolsButton.setToolTipText(
          Messages.datatypeReconciler_convertAllSqlSymbolsTooltip);
      this.convertAllSqlSymbolsButton.setImage(
          UiPlugin.getDefault().getImage(PluginConstants.Images.ARROW_LEFT_ICON));

      this.convertAllSqlSymbolsButton.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent event) {
              changeAllColumnDatatypesButtonPressed();
            }
          });

      WidgetFactory.createLabel(headerPanel, "   - or -   "); // $NON-NLS-1$

      this.changeAllColumnDatatypesButton =
          WidgetFactory.createButton(
              headerPanel, Messages.datatypeReconciler_convertAllColumnDatatypesLabel);
      this.changeAllColumnDatatypesButton.setToolTipText(
          Messages.datatypeReconciler_convertAllColumnDatatypesTooltip);
      this.changeAllColumnDatatypesButton.setImage(
          UiPlugin.getDefault().getImage(PluginConstants.Images.ARROW_RIGHT_ICON));
      this.changeAllColumnDatatypesButton.setEnabled(false);
      this.changeAllColumnDatatypesButton.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent event) {
              changeAllColumnDatatypesPressed();
            }
          });
    }

    BINDING_TABLE:
    {
      table = new Table(tablePanel, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
      table.setHeaderVisible(true);
      table.setLinesVisible(true);
      table.setLayout(new TableLayout());
      GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
      gd.heightHint = 200;
      table.setLayoutData(gd);

      this.bindingTableViewer = new TableViewer(table);
      this.bindingTableViewer.getControl().setLayoutData(gd);

      this.bindingContentProvider = new BindingContentProvider();

      // create columns

      // | status icon | Source SQL Symbol | <-- | Matched Datatype | ->  | Target Column

      // COLUMN 0 :  STATUS ICON Button
      TableViewerColumn column = new TableViewerColumn(this.bindingTableViewer, SWT.LEFT);
      column.setLabelProvider(new TheBindingColumnLabelProvider(0));
      column.getColumn().setText(getSpaces(8));
      column.getColumn().pack();

      // COLUMN 1 : SOURCE SQL SYMBOL
      column = new TableViewerColumn(this.bindingTableViewer, SWT.LEFT);
      column.getColumn().setText(Messages.datatypeReconciler_sourceSqlSymbolLabel + getSpaces(100));
      column.setLabelProvider(new TheBindingColumnLabelProvider(1));
      column.getColumn().pack();

      // COLUMN 2 :  LEFT ARROW Button
      column = new TableViewerColumn(this.bindingTableViewer, SWT.LEFT);
      column.getColumn().setText(getSpaces(8));
      column.setLabelProvider(new TheBindingColumnLabelProvider(2));
      column.setEditingSupport(new ConvertSymbolEditingSupport(this.bindingTableViewer));
      column.getColumn().pack();
      column.getColumn().setToolTipText(Messages.datatypeReconciler_convertSourceDatatypeTooltip);

      // COLUMN 3 : Matched datatype
      column = new TableViewerColumn(this.bindingTableViewer, SWT.LEFT);
      column.getColumn().setText(Messages.datatypeReconciler_matchedTypeLabel + getSpaces(60));
      column.setLabelProvider(new TheBindingColumnLabelProvider(3));
      column.setEditingSupport(new ChangeProposedDatatypeEditingSupport(this.bindingTableViewer));
      column.getColumn().pack();
      column.getColumn().setToolTipText(Messages.datatypeReconciler_matchedDatatypeTooltip);

      // COLUMN 4 : RIGHT ARROW Button
      column = new TableViewerColumn(this.bindingTableViewer, SWT.LEFT);
      column.getColumn().setText(getSpaces(8));
      column.setLabelProvider(new TheBindingColumnLabelProvider(4));
      column.setEditingSupport(new ChangeDatatypeEditingSupport(this.bindingTableViewer));
      column.getColumn().pack();
      column.getColumn().setToolTipText(Messages.datatypeReconciler_changeTargetDatatypeTooltip);

      // COLUMN 5 :  Target Column Definition
      column = new TableViewerColumn(this.bindingTableViewer, SWT.LEFT);
      column.getColumn().setText(Messages.datatypeReconciler_targetColumnLabel + getSpaces(25));
      column.setLabelProvider(new TheBindingColumnLabelProvider(5));
      column.getColumn().pack();

      bindingTableViewer.setUseHashlookup(true);
      bindingTableViewer.setContentProvider(this.bindingContentProvider);
      bindingTableViewer.setInput(this.bindingListInput);

      updateRowColors();
    }

    // Panel to display selection details
    SELECTION_STATUS_PANEL:
    {
      Composite selectionPanel =
          WidgetFactory.createGroup(
              tablePanel, Messages.datatypeReconciler_selectionPanelInfoLabel);
      // ------------------------------
      // Set layout for the Composite
      // ------------------------------
      selectionPanel.setLayout(new GridLayout());
      ((GridLayout) selectionPanel.getLayout()).numColumns = 2;
      selectionPanel.setLayoutData(new GridData(GridData.FILL_BOTH));
      ((GridData) selectionPanel.getLayoutData()).minimumHeight = 80;

      //			Label selectedSymbolLabel = new Label(selectionPanel, SWT.NONE);
      //			selectedSymbolLabel.setText("Selected Symbol: ");

      symbolConversionLabel = new Label(selectionPanel, SWT.NONE);
      symbolConversionLabel.setText(PluginConstants.EMPTY_STRING);
      symbolConversionLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
      symbolConversionLabel.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_BLUE));

      Label messageLabel = new Label(selectionPanel, SWT.NONE);
      //			messageLabel.setText("Status: ");

      symbolWarningLabel = new Label(selectionPanel, SWT.NONE);
      symbolWarningLabel.setText(PluginConstants.EMPTY_STRING);
      symbolWarningLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
      symbolWarningLabel.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_BLUE));
    }
  }
  /**
   * Create contents of the dialog.
   *
   * @param parent
   */
  @Override
  protected Control createDialogArea(Composite parent) {
    Composite container = (Composite) super.createDialogArea(parent);
    GridLayout gridLayout = (GridLayout) container.getLayout();
    gridLayout.verticalSpacing = 2;
    gridLayout.horizontalSpacing = 2;
    gridLayout.marginHeight = 2;
    gridLayout.marginWidth = 2;

    Composite compositeBody = new Composite(container, SWT.NONE);
    GridLayout gl_compositeBody = new GridLayout(1, false);
    gl_compositeBody.verticalSpacing = 2;
    gl_compositeBody.horizontalSpacing = 2;
    gl_compositeBody.marginHeight = 2;
    gl_compositeBody.marginWidth = 2;
    compositeBody.setLayout(gl_compositeBody);
    compositeBody.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

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

    lblTableName = new Label(compositeTable, SWT.NONE);
    lblTableName.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblTableName.setText(tableDAO.getName());

    Label lblAs = new Label(compositeTable, SWT.NONE);
    lblAs.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblAs.setText(" as "); // $NON-NLS-1$

    textTableAlias = new Text(compositeTable, SWT.BORDER);
    textTableAlias.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent event) {
            if (tableViewer.getInput() != null) {
              for (ExtendTableColumnDAO dao : (List<ExtendTableColumnDAO>) tableViewer.getInput()) {

                dao.setTableAlias(textTableAlias.getText());
              }
              tableViewer.refresh();
              queryGenetation();
            }
          }
        });
    textTableAlias.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    new Label(compositeTable, SWT.NONE);
    new Label(compositeTable, SWT.NONE);

    Text textTBNameCmt = new Text(compositeTable, SWT.BORDER | SWT.WRAP | SWT.MULTI);
    GridData gd_textTBNameCmt = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    gd_textTBNameCmt.heightHint = 33;
    textTBNameCmt.setLayoutData(gd_textTBNameCmt);
    textTBNameCmt.setText(tableDAO.getComment());

    Composite compositeDML = new Composite(compositeBody, SWT.NONE);
    compositeDML.setLayout(new GridLayout(5, false));
    compositeDML.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    Label lblDml = new Label(compositeDML, SWT.NONE);
    lblDml.setText("DML"); // $NON-NLS-1$

    rdoSelect = new Button(compositeDML, SWT.RADIO);
    rdoSelect.setSelection(true);
    rdoSelect.setText("SELECT"); // $NON-NLS-1$

    rdoUpdate = new Button(compositeDML, SWT.RADIO);
    rdoUpdate.setText("UPDATE"); // $NON-NLS-1$

    rdoInsert = new Button(compositeDML, SWT.RADIO);
    rdoInsert.setText("INSERT"); // $NON-NLS-1$

    rdoDelete = new Button(compositeDML, SWT.RADIO);
    rdoDelete.setText("DELETE"); // $NON-NLS-1$

    assignSelectionAdapter(rdoSelect);
    assignSelectionAdapter(rdoUpdate);
    assignSelectionAdapter(rdoInsert);
    assignSelectionAdapter(rdoDelete);

    tableViewer = new TableViewer(compositeBody, SWT.BORDER | SWT.FULL_SELECTION);
    Table table = tableViewer.getTable();
    table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    table.setLinesVisible(true);
    table.setHeaderVisible(true);

    TableViewerColumn tvColumnName = new TableViewerColumn(tableViewer, SWT.NONE);
    TableColumn tcColumnName = tvColumnName.getColumn();
    tcColumnName.setWidth(130);
    tcColumnName.setText(Messages.GenerateStatmentDMLDialog_8);
    tvColumnName.setEditingSupport(new DMLColumnEditingSupport(tableViewer, 0, this));

    TableViewerColumn tvColumnDataType = new TableViewerColumn(tableViewer, SWT.LEFT);
    TableColumn tcDataType = tvColumnDataType.getColumn();
    tcDataType.setWidth(85);
    tcDataType.setText(Messages.GenerateStatmentDMLDialog_9);

    TableViewerColumn tvColumnKey = new TableViewerColumn(tableViewer, SWT.CENTER);
    TableColumn tcKey = tvColumnKey.getColumn();
    tcKey.setWidth(50);
    tcKey.setText(Messages.GenerateStatmentDMLDialog_10);

    TableViewerColumn tvColumnAlias = new TableViewerColumn(tableViewer, SWT.NONE);
    TableColumn tcAlias = tvColumnAlias.getColumn();
    tcAlias.setWidth(100);
    tcAlias.setText(Messages.GenerateStatmentDMLDialog_11);
    tvColumnAlias.setEditingSupport(new DMLColumnEditingSupport(tableViewer, 3, this));

    TableViewerColumn tvColumnCmt = new TableViewerColumn(tableViewer, SWT.LEFT);
    TableColumn tcCmt = tvColumnCmt.getColumn();
    tcCmt.setWidth(300);
    tcCmt.setText(Messages.GenerateStatmentDMLDialog_12);

    Composite composite_3 = new Composite(compositeBody, SWT.NONE);
    composite_3.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    GridLayout gl_composite_3 = new GridLayout(2, false);
    gl_composite_3.verticalSpacing = 2;
    gl_composite_3.horizontalSpacing = 2;
    gl_composite_3.marginHeight = 2;
    gl_composite_3.marginWidth = 2;
    composite_3.setLayout(gl_composite_3);

    final Button btnAllCheck = new Button(composite_3, SWT.CHECK);
    btnAllCheck.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            for (ExtendTableColumnDAO dao : (List<ExtendTableColumnDAO>) tableViewer.getInput()) {
              if ("*".equals(dao.getField())) { // $NON-NLS-1$
                dao.setCheck(!btnAllCheck.getSelection());
              } else {
                dao.setCheck(btnAllCheck.getSelection());
              }
            }
            tableViewer.refresh();
            queryGenetation();
          }
        });
    btnAllCheck.setText(Messages.GenerateStatmentDMLDialog_14);

    chkComment = new Button(composite_3, SWT.CHECK);
    chkComment.setText(Messages.GenerateStatmentDMLDialog_15);
    assignSelectionAdapter(chkComment);

    Composite previewComposite = new Composite(compositeBody, SWT.BORDER);
    previewComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    GridLayout gl_previewComposite = new GridLayout(1, false);
    gl_previewComposite.verticalSpacing = 2;
    gl_previewComposite.horizontalSpacing = 2;
    gl_previewComposite.marginHeight = 2;
    gl_previewComposite.marginWidth = 2;
    previewComposite.setLayout(gl_previewComposite);

    textQuery =
        new Text(
            previewComposite,
            SWT.BORDER | SWT.WRAP | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CANCEL | SWT.MULTI);
    GridData gd_textQuery = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    gd_textQuery.minimumHeight = 120;
    textQuery.setLayoutData(gd_textQuery);

    tableViewer.setContentProvider(new ArrayContentProvider());
    tableViewer.setLabelProvider(new GenerateLabelProvider());

    initData();
    queryGenetation();

    // google analytic
    AnalyticCaller.track(this.getClass().getName());

    textTableAlias.setFocus();

    return container;
  }
    /*
     * create the panel
     * @param parent the parent composite
     */
    private void createPanel(Composite parent) {
      Composite panel =
          WidgetFactory.createGroup(
              parent,
              UTIL.getString("ExtraPropertiesPanel_groupTitle"),
              SWT.FILL,
              2,
              1); //$NON-NLS-1$
      // GridDataFactory.swtDefaults().grab(true, true).applyTo(panel);
      GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false);
      gd.horizontalSpan = 2;
      panel.setLayoutData(gd);

      propertiesViewer =
          new TableViewer(panel, (SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.BORDER));
      ColumnViewerToolTipSupport.enableFor(propertiesViewer);
      propertiesViewer.setContentProvider(
          new IStructuredContentProvider() {
            /**
             * {@inheritDoc}
             *
             * @see org.eclipse.jface.viewers.IContentProvider#dispose()
             */
            @Override
            public void dispose() {
              // nothing to do
            }

            /**
             * {@inheritDoc}
             *
             * @see
             *     org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
             */
            @Override
            public Object[] getElements(Object inputElement) {
              Properties props = extraProperties;

              if (props.isEmpty()) {
                return new Object[0];
              }

              List<SimpleProperty> properties = new ArrayList<SimpleProperty>();

              for (Object key : props.keySet()) {
                String keyStr = (String) key;
                properties.add(new SimpleProperty(keyStr, (String) props.get(keyStr)));
              }
              return properties.toArray(new SimpleProperty[0]);
            }

            /**
             * {@inheritDoc}
             *
             * @see
             *     org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer,
             *     java.lang.Object, java.lang.Object)
             */
            @Override
            public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
              // nothing to do
            }
          });

      // sort the table rows by display name
      propertiesViewer.setComparator(
          new ViewerComparator() {
            /**
             * {@inheritDoc}
             *
             * @see
             *     org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer,
             *     java.lang.Object, java.lang.Object)
             */
            @Override
            public int compare(Viewer viewer, Object e1, Object e2) {
              SimpleProperty prop1 = (SimpleProperty) e1;
              SimpleProperty prop2 = (SimpleProperty) e2;

              return super.compare(viewer, prop1.getName(), prop2.getName());
            }
          });

      Table table = propertiesViewer.getTable();
      table.setHeaderVisible(true);
      table.setLinesVisible(true);
      table.setLayout(new TableLayout());
      table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
      ((GridData) table.getLayoutData()).horizontalSpan = 2;
      ((GridData) table.getLayoutData()).heightHint = table.getItemHeight() * 6;

      // create columns
      TableViewerColumn column = new TableViewerColumn(propertiesViewer, SWT.LEFT);
      column
          .getColumn()
          .setText(
              UTIL.getString("ExtraPropertiesPanel_name")
                  + "                   "); //$NON-NLS-1$ //$NON-NLS-2$
      column.setLabelProvider(new PropertyLabelProvider(0));
      // column.setEditingSupport(new PropertyNameEditingSupport(propertiesViewer, 0));
      column.getColumn().pack();

      column = new TableViewerColumn(propertiesViewer, SWT.LEFT);
      column.getColumn().setText(UTIL.getString("ExtraPropertiesPanel_value")); // $NON-NLS-1$
      column.setLabelProvider(new PropertyLabelProvider(1));
      column.setEditingSupport(new PropertyNameEditingSupport(propertiesViewer, 1));
      column.getColumn().pack();

      propertiesViewer.addSelectionChangedListener(
          new ISelectionChangedListener() {
            /**
             * {@inheritDoc}
             *
             * @see
             *     org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
             */
            @Override
            public void selectionChanged(SelectionChangedEvent event) {
              handlePropertySelected();
            }
          });

      //
      // add toolbar below the table
      //

      Composite toolbarPanel =
          WidgetFactory.createPanel(panel, SWT.NONE, GridData.VERTICAL_ALIGN_BEGINNING, 1, 2);

      this.addPropertyButton = WidgetFactory.createButton(toolbarPanel, GridData.FILL);
      this.addPropertyButton.setImage(
          DatatoolsUiPlugin.getDefault().getImage(Images.ADD_PROPERTY_ICON));
      this.addPropertyButton.setToolTipText(
          UTIL.getString("HeaderPropertiesPanel_addNewPropertyButton_tooltip")); // $NON-NLS-1$
      this.addPropertyButton.addSelectionListener(
          new SelectionListener() {

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

            @Override
            public void widgetDefaultSelected(SelectionEvent e) {}
          });

      this.removePropertyButton = WidgetFactory.createButton(toolbarPanel, GridData.FILL);
      this.removePropertyButton.setImage(
          DatatoolsUiPlugin.getDefault().getImage(Images.REMOVE_PROPERTY_ICON));
      this.removePropertyButton.setToolTipText(
          UTIL.getString("HeaderPropertiesPanel_removePropertyButton_tooltip")); // $NON-NLS-1$
      this.removePropertyButton.addSelectionListener(
          new SelectionListener() {

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

            @Override
            public void widgetDefaultSelected(SelectionEvent e) {}
          });
      this.removePropertyButton.setEnabled(false);

      propertiesViewer.setInput(this);
    }
Example #11
0
  @Override
  public void createPartControl(Composite parent) {
    final IActionBars actionBars = getViewSite().getActionBars();
    IToolBarManager toolbar = actionBars.getToolBarManager();
    mSymbolEntryText = new TextContributionItem(""); // $NON-NLS-1$
    toolbar.add(mSymbolEntryText);
    toolbar.add(new AddSymbolAction(mSymbolEntryText, this));

    final Table table =
        new Table(parent, SWT.MULTI | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.BORDER);
    table.setHeaderVisible(true);
    mViewer = new TableViewer(table);
    GridDataFactory.defaultsFor(table).applyTo(table);

    final MarketDataItemComparator comparator = new MarketDataItemComparator();
    mViewer.setComparator(comparator);

    SelectionListener listener =
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            // determine new sort column and direction
            TableColumn sortColumn = table.getSortColumn();
            TableColumn currentColumn = (TableColumn) e.widget;
            final int index = table.indexOf(currentColumn);
            int dir = table.getSortDirection();
            if (sortColumn == currentColumn) {
              dir = dir == SWT.UP ? SWT.DOWN : SWT.UP;
            } else {
              table.setSortColumn(currentColumn);
              dir = SWT.UP;
            }
            table.setSortDirection(dir);
            comparator.setSort(dir == SWT.UP ? 1 : -1);
            comparator.setIndex(index);
            mViewer.refresh();
          }
        };

    // create columns, using FIXFieldLocalizer to preserve backwards
    // compatibility
    TableViewerColumn symbolColumn =
        new TableViewerColumn(
            mViewer,
            createColumn(
                table,
                FIXFieldLocalizer.getLocalizedFIXFieldName(Symbol.class.getSimpleName()),
                SWT.LEFT,
                listener));
    symbolColumn.setEditingSupport(new SymbolEditingSupport());
    createColumn(
        table,
        FIXFieldLocalizer.getLocalizedFIXFieldName(LastPx.class.getSimpleName()),
        SWT.RIGHT,
        listener);
    createColumn(
        table,
        FIXFieldLocalizer.getLocalizedFIXFieldName(LastQty.class.getSimpleName()),
        SWT.RIGHT,
        listener);
    createColumn(
        table,
        FIXFieldLocalizer.getLocalizedFIXFieldName(BidSize.class.getSimpleName()),
        SWT.RIGHT,
        listener);
    createColumn(
        table,
        FIXFieldLocalizer.getLocalizedFIXFieldName(BidPx.class.getSimpleName()),
        SWT.RIGHT,
        listener);
    createColumn(
        table,
        FIXFieldLocalizer.getLocalizedFIXFieldName(OfferPx.class.getSimpleName()),
        SWT.RIGHT,
        listener);
    createColumn(
        table,
        FIXFieldLocalizer.getLocalizedFIXFieldName(OfferSize.class.getSimpleName()),
        SWT.RIGHT,
        listener);

    // restore table state if it exists
    if (mViewState != null) {
      ColumnState.restore(table, mViewState);
      for (TableColumn column : table.getColumns()) {
        if (column.getWidth() == 0) {
          column.setResizable(false);
        }
      }
    }

    registerContextMenu();
    getSite().setSelectionProvider(mViewer);

    ObservableListContentProvider content = new ObservableListContentProvider();
    mViewer.setContentProvider(content);
    IObservableSet domain = content.getKnownElements();
    IObservableMap[] maps =
        new IObservableMap[] {
          BeansObservables.observeMap(domain, MarketDataViewItem.class, "symbol"), // $NON-NLS-1$
          createCompositeMap(
              domain, "latestTick", MDPackage.Literals.MD_LATEST_TICK__PRICE), // $NON-NLS-1$
          createCompositeMap(
              domain, "latestTick", MDPackage.Literals.MD_LATEST_TICK__SIZE), // $NON-NLS-1$
          createCompositeMap(
              domain, "topOfBook", MDPackage.Literals.MD_TOP_OF_BOOK__BID_SIZE), // $NON-NLS-1$
          createCompositeMap(
              domain, "topOfBook", MDPackage.Literals.MD_TOP_OF_BOOK__BID_PRICE), // $NON-NLS-1$
          createCompositeMap(
              domain, "topOfBook", MDPackage.Literals.MD_TOP_OF_BOOK__ASK_PRICE), // $NON-NLS-1$
          createCompositeMap(
              domain, "topOfBook", MDPackage.Literals.MD_TOP_OF_BOOK__ASK_SIZE) // $NON-NLS-1$
        };
    mViewer.setLabelProvider(new ObservableMapLabelProvider(maps));
    mViewer.setUseHashlookup(true);
    mItems = WritableList.withElementType(MarketDataViewItem.class);
    mViewer.setInput(mItems);
  }
Example #12
0
  public void createControl(Composite parent) {

    Composite container = new Composite(parent, SWT.NULL);
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    container.setLayout(layout);

    GridData gridData = new GridData();
    gridData.grabExcessHorizontalSpace = true;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.verticalAlignment = GridData.FILL;
    gridData.grabExcessVerticalSpace = true;

    tableViewer =
        new TableViewer(container, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL | SWT.FULL_SELECTION);
    tableViewer.getTable().setLayoutData(gridData);

    TableViewerColumn column = new TableViewerColumn(tableViewer, SWT.CENTER);
    column.getColumn().setText("Import");
    column.getColumn().setWidth(50);
    column.setEditingSupport(new AccountEditingSupport(tableViewer, 0));

    column = new TableViewerColumn(tableViewer, SWT.NONE);
    column.getColumn().setText("Nickname");
    column.getColumn().setWidth(300);
    column.setEditingSupport(new AccountEditingSupport(tableViewer, 1));

    column = new TableViewerColumn(tableViewer, SWT.NONE);
    column.getColumn().setText("Account #");
    column.getColumn().setWidth(200);

    tableViewer.getTable().setFont(RcpConstants.STANDARD_FONT);
    tableViewer.getTable().setHeaderVisible(true);
    tableViewer.getTable().setLinesVisible(true);

    tableViewer.setContentProvider(new AccountContentProvider());
    tableViewer.setLabelProvider(new AccountLabelProvider());

    ColumnViewerEditorActivationStrategy actSupport =
        new ColumnViewerEditorActivationStrategy(tableViewer) {
          protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) {
            return event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL
                || event.eventType == ColumnViewerEditorActivationEvent.MOUSE_CLICK_SELECTION
                || event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC;
          }
        };

    TableViewerEditor.create(
        tableViewer,
        actSupport,
        ColumnViewerEditor.TABBING_HORIZONTAL
            | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR
            | ColumnViewerEditor.TABBING_VERTICAL
            | ColumnViewerEditor.KEYBOARD_ACTIVATION);

    setControl(tableViewer.getTable());

    ((WizardDialog) getWizard().getContainer())
        .addPageChangedListener(
            new IPageChangedListener() {

              public void pageChanged(PageChangedEvent event) {
                if (event.getSelectedPage() == AvailableAccountsPage.this) {
                  availableAccounts.clear();
                  final FinancialInstitution fi =
                      ((NewAccountWizard) getWizard()).getFinancialInstitution();
                  try {
                    getContainer()
                        .run(
                            false,
                            false,
                            new IRunnableWithProgress() {

                              public void run(IProgressMonitor monitor)
                                  throws InvocationTargetException, InterruptedException {
                                progressMonitor = monitor;
                                monitor.beginTask(
                                    "Fetching Available accounts from " + fi.getName(), 100);
                                monitor.worked(5);
                                running = true;
                                exception = null;
                                Thread progressWorker = new Thread(AvailableAccountsPage.this);
                                progressWorker.start();
                                while (running) {
                                  progressMonitor.worked(5);
                                  Thread.sleep(1000);
                                }
                              }
                            });
                  } catch (Exception e) {
                    e.printStackTrace();
                  } finally {
                    progressMonitor = null;
                  }

                  if (exception != null) {
                    if (exception instanceof NoOFXResponseException) {
                      MessageDialog.openError(
                          getShell(), "Download Error", "No response from " + fi.getName());
                    } else if (exception instanceof OFXRequestException) {
                      MessageDialog.openError(
                          getShell(),
                          "Download Error",
                          "Invalid request to "
                              + fi.getName()
                              + ". Check your username and password and try again.");
                    } else {
                      MessageDialog.openError(
                          getShell(),
                          "Download Error",
                          "Unknown error from "
                              + fi.getName()
                              + ". Verify (with "
                              + fi.getName()
                              + ") that you have access to download transactions.");
                    }
                    ((NewAccountWizard) getWizard()).getContainer().showPage(getPreviousPage());
                  } else {
                    tableViewer.setInput(availableAccounts);
                    setPageComplete(true);
                  }
                }
              }
            });

    List<Account> dummyAccountList = new LinkedList<Account>();

    for (int i = 0; i < 10; i++) {
      dummyAccountList.add(new Account());
    }
    tableViewer.setInput(dummyAccountList);

    setPageComplete(false);
  }
  @Override
  public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    container.setLayout(layout);

    layersTable = new TableViewer(container, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    layersTable.getTable().setLayoutData(new GridData(GridData.FILL_BOTH));
    layersTable.setContentProvider(ArrayContentProvider.getInstance());
    layersTable.getTable().setHeaderVisible(true);
    layersTable.getTable().setLinesVisible(true);

    TableViewerColumn layerColumn = new TableViewerColumn(layersTable, SWT.NONE);
    layerColumn.getColumn().setText("Layer");
    layerColumn.getColumn().setWidth(300);
    layerColumn.setLabelProvider(
        new ColumnLabelProvider() {
          @Override
          public String getText(Object element) {
            LayerDescriptor layer = (LayerDescriptor) element;
            return layer.getName();
          }
        });

    TableViewerColumn namePatternColumn = new TableViewerColumn(layersTable, SWT.NONE);
    namePatternColumn.getColumn().setWidth(300);
    namePatternColumn.getColumn().setText("Exception super type");
    namePatternColumn.setLabelProvider(
        new ColumnLabelProvider() {

          @Override
          public String getText(Object element) {
            LayerDescriptor layer = (LayerDescriptor) element;
            return layer.getExceptionSuperType();
          }
        });
    namePatternColumn.setEditingSupport(
        new EditingSupport(layersTable) {

          @Override
          protected boolean canEdit(Object element) {
            return true;
          }

          @Override
          protected CellEditor getCellEditor(Object element) {
            TypeSelectionExtension extension =
                new TypeSelectionExtension() {

                  @Override
                  public ISelectionStatusValidator getSelectionValidator() {
                    return new ISelectionStatusValidator() {
                      @Override
                      public IStatus validate(Object[] selection) {
                        if (selection.length == 1) {
                          try {
                            IType type = (IType) selection[0];
                            ITypeHierarchy hierarchy =
                                type.newSupertypeHierarchy(new NullProgressMonitor());
                            IType curr = type;
                            while (curr != null) {
                              if ("java.lang.Throwable"
                                  .equals(curr.getFullyQualifiedName('.'))) { // $NON-NLS-1$
                                return Status.OK_STATUS;
                              }
                              curr = hierarchy.getSuperclass(curr);
                            }
                          } catch (JavaModelException e) {
                            Status status =
                                new Status(
                                    IStatus.ERROR,
                                    JQAEclipsePlugin.PLUGIN_ID,
                                    e.getLocalizedMessage(),
                                    e);
                            JQAEclipsePlugin.getDefault().getLog().log(status);
                            return Status.CANCEL_STATUS;
                          }
                        }
                        return new Status(
                            IStatus.ERROR,
                            JQAEclipsePlugin.PLUGIN_ID,
                            "Selected item is not an exception");
                      }
                    };
                  }
                };
            return new TypeCellEditor(
                layersTable.getTable(),
                ThrowingDefinitionWizardPage.this.getContainer(),
                IJavaSearchConstants.CLASS,
                "*Exception",
                extension);
          }

          @Override
          protected Object getValue(Object element) {
            return ((LayerDescriptor) element).getExceptionSuperType();
          }

          @Override
          protected void setValue(Object element, Object value) {
            ((LayerDescriptor) element).setExceptionSuperType((String) value);
            layersTable.refresh(element, true);
          }
        });
    layersTable.setInput(getArchitectureDescriptor().getLayers());
    setControl(container);
    ((WizardDialog) getContainer()).addPageChangedListener(this);
  }
  /** {@inheritDoc} */
  @Override
  public void createColumns() {
    final TableViewer tableViewer = getTableViewer();

    tableViewer.setContentProvider(new ArrayContentProvider());

    TableViewerColumn tvc;

    tvc = new TableViewerColumn(tableViewer, SWT.NONE);
    tvc.getColumn().setText("R-Typ");
    tvc.getColumn().setWidth(50);
    tvc.setLabelProvider(
        new ColumnLabelProvider() {
          /** {@inheritDoc} */
          @Override
          public String getText(Object element) {
            if (element instanceof List) {
              @SuppressWarnings("unchecked")
              List<String> parameterList = (List<String>) element;
              if (parameterList.size() > 1) {
                return parameterList.get(0);
              }
            }
            return super.getText(element);
          }
        });
    tvc.setEditingSupport(
        new EditingSupport(tableViewer) {

          @Override
          protected void setValue(Object element, Object value) {
            @SuppressWarnings("unchecked")
            List<String> propertList = (List<String>) element;
            propertList.set(0, (String) value);
            tableViewer.refresh(element);
          }

          @Override
          protected Object getValue(Object element) {
            @SuppressWarnings("unchecked")
            List<String> propertList = (List<String>) element;
            return propertList.get(0);
          }

          @Override
          protected CellEditor getCellEditor(Object element) {
            return new TextCellEditor(tableViewer.getTable());
          }

          @Override
          protected boolean canEdit(Object element) {
            return true;
          }
        });

    tvc = new TableViewerColumn(tableViewer, SWT.NONE);
    tvc.getColumn().setText("Faceplate Path");
    tvc.getColumn().setWidth(250);
    tvc.setLabelProvider(
        new ColumnLabelProvider() {
          /** {@inheritDoc} */
          @Override
          public String getText(Object element) {
            if (element instanceof List) {
              @SuppressWarnings("unchecked")
              List<String> propertList = (List<String>) element;
              if (propertList.size() > 1) {
                return propertList.get(1);
              }
            }
            return super.getText(element);
          }
        });

    tvc.setEditingSupport(
        new EditingSupport(tableViewer) {

          @Override
          protected void setValue(Object element, Object value) {
            @SuppressWarnings("unchecked")
            List<String> propertList = (List<String>) element;
            switch (propertList.size()) {
              case 0:
                propertList.add("");
                // $FALL-THROUGH$
              case 1:
                propertList.add((String) value);
                break;
              default:
                propertList.set(1, (String) value);
            }
            tableViewer.refresh(element);
          }

          @Override
          protected Object getValue(Object element) {
            @SuppressWarnings("unchecked")
            List<String> propertList = (List<String>) element;
            String path = "";
            if (propertList.size() > 1) {
              path = propertList.get(1);
            }
            return path;
          }

          @Override
          protected CellEditor getCellEditor(Object elem) {
            return new DialogCellEditor(tableViewer.getTable()) {

              @Override
              protected Object openDialogBox(Control cellEditorWindow) {
                final ElementTreeSelectionDialog dialog =
                    new ElementTreeSelectionDialog(
                        cellEditorWindow.getShell(),
                        new WorkbenchLabelProvider(),
                        new WorkbenchContentProvider());
                IWorkspace workspace = ResourcesPlugin.getWorkspace();
                dialog.setInput(workspace.getRoot());
                dialog.setTitle("Select Maintence Display");
                dialog.setAllowMultiple(false);
                dialog.setBlockOnOpen(true);
                dialog.setMessage("Choose the Maintence Display:");
                dialog.setStatusLineAboveButtons(true);
                String stringValue = (String) getValue();
                IResource findMember = workspace.getRoot().findMember(stringValue);
                dialog.setInitialSelection(findMember);
                dialog.setValidator(
                    new ISelectionStatusValidator() {

                      @Override
                      public IStatus validate(Object[] selection) {
                        if (selection != null && selection.length > 0) {
                          Object object = selection[0];
                          if (object instanceof IFile) {
                            return Status.OK_STATUS;
                          }
                        }
                        return new Status(
                            IStatus.ERROR, "org.csstudio.sds.ui", "Please select a SDS-File");
                      }
                    });

                dialog.addFilter(
                    new ViewerFilter() {

                      @Override
                      public boolean select(Viewer viewer, Object parentElement, Object element) {
                        if (element instanceof IFile) {
                          IFile file = (IFile) element;
                          if (file != null && file.getFileExtension() != null) {
                            return file.getFileExtension().toLowerCase().equals("css-sds");
                          }
                          return false;
                        }
                        return true;
                      }
                    });

                int open = dialog.open();
                switch (open) {
                  case Window.OK:
                    IFile firstResult = (IFile) dialog.getFirstResult();
                    IPath fullPath = firstResult.getFullPath();
                    String string = fullPath.toString();
                    return string;
                }
                return null;
              }
            };
          }

          @Override
          protected boolean canEdit(Object element) {
            return true;
          }
        });
  }
  /**
   * Create the composite.
   *
   * @param parent
   * @param style
   * @param wizardPage
   */
  public DefaultDataAdapterEditorComposite(
      Composite parent, int style, WizardPage wizardPage, JasperReportsContext jrContext) {

    /*
     * UI ELEMENTS
     */
    super(parent, style, jrContext);
    setLayout(new GridLayout(2, false));

    // data model init
    rows = new ArrayList<String[]>();

    // wizardPage init
    this.wizardPage = wizardPage;

    tableViewer = new TableViewer(this, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
    tableViewer.setContentProvider(new DefaultContentProvider());
    tableViewer.setInput(rows);

    table = tableViewer.getTable();
    GridData gd_table = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    gd_table.minimumWidth = 200;
    table.setLayoutData(gd_table);
    table.setLinesVisible(true);
    table.setHeaderVisible(true);

    propertyViewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
    propertyViewerColumn.getColumn().setMoveable(true);
    propertyViewerColumn.getColumn().setWidth(100);
    propertyViewerColumn
        .getColumn()
        .setText(Messages.DefaultDataAdapterEditorComposite_properyLabel);
    propertyViewerColumn.setLabelProvider(new ColumnPropertyValueLabelProvider(0));
    propertyViewerColumn.setEditingSupport(new PropertyValueEditingSupport(tableViewer, 0));

    valueViewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
    valueViewerColumn.getColumn().setMoveable(true);
    valueViewerColumn.getColumn().setWidth(100);
    valueViewerColumn.getColumn().setText(Messages.DefaultDataAdapterEditorComposite_valueLabel);
    valueViewerColumn.setLabelProvider(new ColumnPropertyValueLabelProvider(1));
    valueViewerColumn.setEditingSupport(new PropertyValueEditingSupport(tableViewer, 1));

    Composite buttonComposite = new Composite(this, SWT.NONE);
    GridLayout gl_buttonComposite = new GridLayout(1, false);
    gl_buttonComposite.marginWidth = 0;
    gl_buttonComposite.marginHeight = 0;
    buttonComposite.setLayout(gl_buttonComposite);
    buttonComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1));

    addButton = new Button(buttonComposite, SWT.NONE);
    GridData gd_addButton = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
    gd_addButton.widthHint = 100;
    addButton.setLayoutData(gd_addButton);
    addButton.setText(Messages.DefaultDataAdapterEditorComposite_addButton);

    deleteButton = new Button(buttonComposite, SWT.NONE);
    GridData gd_deleteButton = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
    gd_deleteButton.widthHint = 100;
    deleteButton.setLayoutData(gd_deleteButton);
    deleteButton.setText(Messages.DefaultDataAdapterEditorComposite_deleteButton);
    deleteButton.setEnabled(false);

    /*
     * UI ELEMENTS LISTENERS
     */
    // add an entry and set selection on it
    addButton.addSelectionListener(
        new SelectionAdapter() {

          @Override
          public void widgetSelected(SelectionEvent e) {
            rows.add(createDataModelEntry());

            // tableViewer.addPostSelectionChangedListener can't cover
            // the first row added, so we need to manually set delete
            // button enabled for this case.
            if (rows.size() == 1) {
              deleteButton.setEnabled(true);
            }

            tableViewer.refresh();
            setTableSelection(-1);
          }
        });

    // delete selected entries and set selection on last table item
    deleteButton.addSelectionListener(
        new SelectionAdapter() {

          @Override
          public void widgetSelected(SelectionEvent e) {

            removeEntries();
          }
        });

    // keyboard listener
    table.addKeyListener(
        new KeyListener() {

          public void keyReleased(KeyEvent e) {
            // nothing
          }

          public void keyPressed(KeyEvent e) {

            if (e.character == SWT.DEL) {
              removeEntries();
            }
          }
        });

    // When no table items,
    // turns the delete button disabled
    tableViewer.addPostSelectionChangedListener(
        new ISelectionChangedListener() {

          public void selectionChanged(SelectionChangedEvent event) {
            if (rows.size() <= 0) {
              deleteButton.setEnabled(false);
            } else {
              deleteButton.setEnabled(true);
            }
          }
        });
  }
    public void createControl(final Composite parent) {

      DataBindingContext dbc = new DataBindingContext();

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

      setControl(container);

      tableViewer = new TableViewer(container, SWT.BORDER | SWT.FULL_SELECTION);
      tableViewer.getTable().setLinesVisible(true);
      tableViewer.getTable().setHeaderVisible(true);
      tableViewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH));
      tableViewer
          .getTable()
          .setFont(new Font(Display.getDefault(), new FontData("Arial", 10, SWT.NONE)));

      TableViewerColumn column = new TableViewerColumn(tableViewer, SWT.NONE);
      column.getColumn().setText("Predicate");
      column.getColumn().setWidth(225);
      column.setEditingSupport(
          new PredicateEditingSupport(
              tableViewer, dbc, "predicate", getBControl().getVisualization(), getShell()));

      column = new TableViewerColumn(tableViewer, SWT.NONE);
      column.getColumn().setText("Edit");
      column.getColumn().setWidth(225);
      column.setEditingSupport(new AnimationScriptEditingSupport(tableViewer));

      ObservableListContentProvider contentProvider = new ObservableListContentProvider();
      tableViewer.setContentProvider(contentProvider);

      tableViewer.setLabelProvider(
          new ObservableMapLabelProvider(
              BeansObservables.observeMaps(
                  contentProvider.getKnownElements(), new String[] {"predicate"})) {

            @Override
            public String getColumnText(Object element, int columnIndex) {
              if (columnIndex == 1) {
                return "Edit Scheduler";
              }
              return super.getColumnText(element, columnIndex);
            }

            @Override
            public Image getColumnImage(Object element, int columnIndex) {
              return null;
            }
          });

      final WritableList input =
          new WritableList(
              ((ExecuteAnimationScript) getScheduler()).getList(), AnimationScriptObject.class);
      tableViewer.setInput(input);

      Composite comp = new Composite(container, SWT.NONE);
      comp.setLayout(new RowLayout());
      comp.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));

      Button btRemove = new Button(comp, SWT.PUSH);
      btRemove.setText("Remove");
      btRemove.setImage(BMotionStudioImage.getImage(EditorImageRegistry.IMG_ICON_DELETE));
      btRemove.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              if (tableViewer.getSelection().isEmpty()) {
                return;
              }
              AnimationScriptObject obj =
                  (AnimationScriptObject)
                      ((IStructuredSelection) tableViewer.getSelection()).getFirstElement();
              input.remove(obj);
            }
          });

      Button btAdd = new Button(comp, SWT.PUSH);
      btAdd.setText("Add");
      btAdd.setImage(BMotionStudioImage.getImage(EditorImageRegistry.IMG_ICON_ADD));
      btAdd.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              AnimationScriptObject obj = new AnimationScriptObject("");
              input.add(obj);
            }
          });
    }
  /* (non-Javadoc)
   * @see com.hundsun.ares.studio.jres.ui.pages.ColumnViewerBlock#createColumns(org.eclipse.jface.viewers.ColumnViewer)
   */
  @Override
  protected void createColumns(TableViewer columnViewer) {
    final TableViewer treeViewer = (TableViewer) columnViewer;

    EObjectColumnViewerProblemView problemView = new EObjectColumnViewerProblemView(treeViewer);
    /** 证劵模式先为菜单号,银行模式下为交易码 */
    {
      TableViewerColumn column = new TableViewerColumn(treeViewer, SWT.LEFT);
      if (MenuUtils.isStockDepartment()) {
        column.getColumn().setText("菜单号");
      } else {
        column.getColumn().setText("交易码");
      }
      column.getColumn().setWidth(120);
      CellLabelProvider provider =
          new ColumnLabelProvider() {
            @Override
            public String getText(Object element) {
              if (element instanceof FunctionProxy) {
                return ((MenuItem) ((FunctionProxy) element).eContainer()).getName();
              } else {
                return StringUtils.EMPTY;
              }
            }

            @Override
            public Color getBackground(Object element) {
              return Display.getDefault().getSystemColor(SWT.COLOR_GRAY);
            }
          };
      column.setLabelProvider(provider);
      column.getColumn().setMoveable(true);
    }

    /** 证劵模式下为功能号,银行模式下为子交易码 */
    {
      TableViewerColumn column = new TableViewerColumn(treeViewer, SWT.LEFT);
      if (MenuUtils.isStockDepartment()) {
        column.getColumn().setText("功能编号");
      } else {
        column.getColumn().setText("子交易码");
      }
      column.getColumn().setWidth(120);
      EObjectColumnLabelProvider provider =
          new MetadataColumnLabelProvider(
              MetadataPackage.Literals.FUNCTION_PROXY__FUN_CODE, getARESResource());
      provider.setDiagnosticProvider(problemView);
      column.setLabelProvider(provider);

      FuncProxyContentProposalHelper helper = new FuncProxyContentProposalHelper(resource);
      FuncProxyContentProposalProvider proposalProvider =
          new FuncProxyContentProposalProvider(helper, resource);

      // 创建EditingSupport,
      JresTextEditingSupportWithContentAssist es =
          new JresTextEditingSupportWithContentAssist(
              treeViewer, MetadataPackage.Literals.FUNCTION_PROXY__FUN_CODE, proposalProvider);
      column.setEditingSupport(es);
    }
    /** 功能名称 */
    {
      TableViewerColumn column = new TableViewerColumn(treeViewer, SWT.LEFT);
      column.getColumn().setText("功能名称");
      column.getColumn().setWidth(120);
      CellLabelProvider provider =
          new ColumnLabelProvider() {
            @Override
            public String getText(Object element) {
              if (element instanceof FunctionProxy) {
                return MenuUtils.getFunctionByName(resource, ((FunctionProxy) element).getFunCode())
                    .getChineseName();
              } else {
                return StringUtils.EMPTY;
              }
            }

            @Override
            public Color getBackground(Object element) {
              return Display.getDefault().getSystemColor(SWT.COLOR_GRAY);
            }
          };
      column.setLabelProvider(provider);
      column.getColumn().setMoveable(true);
    }
    /** 备注 */
    {
      TableViewerColumn column = new TableViewerColumn(treeViewer, SWT.LEFT);
      column.getColumn().setText("说明");
      column.getColumn().setWidth(200);
      EObjectColumnLabelProvider provider =
          new EObjectColumnLabelProvider(MetadataPackage.Literals.FUNCTION_PROXY__DESCRIPTION) {
            @Override
            public Color getBackground(Object element) {
              return Display.getDefault().getSystemColor(SWT.COLOR_GRAY);
            }

            @Override
            public String getText(Object element) {
              if (element instanceof FunctionProxy) {
                return MenuUtils.getFunctionByName(resource, ((FunctionProxy) element).getFunCode())
                    .getDescription();
              } else {
                return StringUtils.EMPTY;
              }
            }

            @Override
            public String getToolTipText(Object element) {
              String text = super.getToolTipText(element);
              if (StringUtils.isBlank(text)) {
                return getText(element);
              }
              return text;
            }
          };
      provider.setDiagnosticProvider(problemView);
      column.setLabelProvider(provider);
      column.getColumn().setMoveable(true);
    }

    // 增加扩展列支持
    MenuUtils.createFunctionProxyExtensibleModelColumns(
        getColumnViewer(), getARESResource(), MetadataPackage.Literals.FUNCTION);

    //		getEditableControl().addEditableUnit(new
    // JresDefaultEditableUnit(columnViewer.getControl()));
    getProblemPool().addView(problemView);
  }