예제 #1
0
  private void configureIndexColumn(TableViewerCreator<IMetadataColumn> tableViewerCreator) {
    TableViewerCreatorColumn<IMetadataColumn, String> column =
        new TableViewerCreatorColumn<IMetadataColumn, String>(tableViewerCreator);
    column.setBeanPropertyAccessors(
        new IBeanPropertyAccessors<IMetadataColumn, String>() {

          @Override
          public void set(IMetadataColumn bean, String value) {}

          @Override
          public String get(IMetadataColumn bean) {
            if (bean instanceof MetadataColumnExt) {
              MetadataColumnExt columnExt = (MetadataColumnExt) bean;
              boolean indexed =
                  (columnExt.getData().getIndexes() != null
                          && columnExt.getData().getIndexes().size() > 0)
                      || columnExt.getData().isAutoIndexed();
              return indexed ? "*" : "";
            }
            return "";
          }
        });
    column.setTitle("Indexed"); // TODO: Internationalize this
    column.setModifiable(false);
    column.setWidth(70);
  }
예제 #2
0
  private void configureAutoIndexColumn(
      TableViewerCreator<IMetadataColumn> tableViewerCreator, Table table) {
    TableViewerCreatorColumn<IMetadataColumn, Boolean> column =
        new TableViewerCreatorColumn<IMetadataColumn, Boolean>(tableViewerCreator);
    column.setBeanPropertyAccessors(
        new IBeanPropertyAccessors<IMetadataColumn, Boolean>() {

          @Override
          public Boolean get(IMetadataColumn bean) {
            if (bean instanceof MetadataColumnExt) {
              MetadataColumnExt columnExt = (MetadataColumnExt) bean;
              return columnExt.getData().isAutoIndexed();
            }
            return false;
          }

          @Override
          public void set(IMetadataColumn bean, Boolean value) {
            if (bean instanceof MetadataColumnExt) {
              MetadataColumnExt columnExt = (MetadataColumnExt) bean;
              columnExt.getData().setAutoIndexed(value);
            }
          }
        });
    String title = "Auto indexed"; // TODO: Internationalize this
    column.setTitle(title);
    column.setToolTipHeader(title);
    column.setModifiable(true);
    column.setWidth(76);
    column.setDisplayedValue("");
    column.setTableColumnSelectionListener(
        new CheckColumnSelectionListener(column, tableViewerCreator));
    column.setImageHeader(ImageProvider.getImage(EImage.CHECKED_ICON));
    CheckboxTableEditorContent checkbox = new CheckboxTableEditorContent();
    checkbox.setToolTipText(title);
    column.setTableEditorContent(checkbox);
  }
예제 #3
0
  /*
   * (non-Javadoc)
   *
   * @see
   * org.talend.commons.ui.swt.advanced.macrotable.AbstractExtendedTableViewer#createColumns(org.talend.commons.ui
   * .swt.tableviewer.TableViewerCreator, org.eclipse.swt.widgets.Table)
   */
  @Override
  protected void createColumns(
      TableViewerCreator<ConceptTarget> tableViewerCreator, final Table table) {
    CellEditorValueAdapter intValueAdapter =
        new CellEditorValueAdapter() {

          @Override
          public Object getOriginalTypedValue(final CellEditor cellEditor, Object value) {
            try {
              return new Integer(value.toString());
            } catch (Exception ex) {
              return null;
            }
          }

          @Override
          public Object getCellEditorTypedValue(final CellEditor cellEditor, Object value) {
            if (value != null) {
              return String.valueOf(value);
            }
            return ""; //$NON-NLS-1$
          }
        };

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

    // column for mouse selection
    TableViewerCreatorColumn column = new TableViewerCreatorColumn(tableViewerCreator);
    column.setTitle(""); // $NON-NLS-1$
    column.setDefaultInternalValue(""); // $NON-NLS-1$
    column.setWidth(15);

    // //////////////////////////////////////////////////////////////////////////////////////
    // X Path Query

    column = new TableViewerCreatorColumn(tableViewerCreator);
    xPathColumn = column;
    column.setTitle(
        Messages.getString("ExtractionFieldsWithXPathEditorView.columnTitle.xPath")); // $NON-NLS-1$
    column.setBeanPropertyAccessors(
        new IBeanPropertyAccessors<ConceptTarget, String>() {

          public String get(ConceptTarget bean) {
            return bean.getRelativeLoopExpression();
          }

          public void set(ConceptTarget bean, String value) {
            bean.setRelativeLoopExpression(value);
          }
        });
    xPathCellEditor =
        new TextCellEditorWithProposal(tableViewerCreator.getTable(), SWT.NONE, column);
    column.setCellEditor(xPathCellEditor);
    xPathCellEditor.addListener(
        new DialogErrorForCellEditorListener(xPathCellEditor, column) {

          @Override
          public void newValidValueTyped(
              int itemIndex, Object previousValue, Object newValue, CELL_EDITOR_STATE state) {
            if (state == CELL_EDITOR_STATE.EDITING) {
              linker.onXPathValueChanged(table, newValue.toString(), itemIndex);
            }
          }

          @Override
          public String validateValue(String newValue, int beanPosition) {
            String currentLoopXPath = linker.getCurrentLoopXPath();
            String value = null;
            if (newValue.trim().length() == 0) {
              return null;
            } else if (newValue.trim().startsWith("/")) { // $NON-NLS-1$
              value = newValue;
            } else {
              value = currentLoopXPath + "/" + newValue; // $NON-NLS-1$
            }
            return linker.validateXPathExpression(value);
          }
        });
    column.setModifiable(true);
    column.setWeight(30);
    column.setMinimumWidth(50);
    column.setDefaultInternalValue(""); // $NON-NLS-1$
    // //////////////////////////////////////////////////////////////////////////////////////

    // //////////////////////////////////////////////////////////////////////////////////////
    // Tag Name
    column = new TableViewerCreatorColumn(tableViewerCreator);
    column.setTitle(
        Messages.getString(
            "ExtractionFieldsWithXPathEditorView.columnTitle.columnName")); //$NON-NLS-1$
    column.setBeanPropertyAccessors(
        new IBeanPropertyAccessors<ConceptTarget, String>() {

          public String get(ConceptTarget bean) {
            return bean.getTargetName();
          }

          public void set(ConceptTarget bean, String value) {
            bean.setTargetName(value);
          }
        });
    column.setModifiable(true);
    column.setWeight(10);
    column.setMinimumWidth(50);
    // column.setCellEditor(new TextCellEditor(table));
    column.setDefaultInternalValue(""); // $NON-NLS-1$

    final TextCellEditorWithProposal tagNameCellEditor =
        createTagNameEditor(tableViewerCreator, column);
    column.setCellEditor(tagNameCellEditor);
  }