コード例 #1
0
  /**
   * DOC chuang Comment method "createTagName".
   *
   * @param tableViewerCreator
   * @param column
   * @return
   */
  private TextCellEditorWithProposal createTagNameEditor(
      TableViewerCreator<ConceptTarget> tableViewerCreator, TableViewerCreatorColumn column) {
    final TextCellEditorWithProposal tagNameCellEditor =
        new TextCellEditorWithProposal(tableViewerCreator.getTable(), SWT.NONE, column);
    // (bug 6038) zywang disabled method "newValidValueTyped" to removed duplicate dialog.

    // tagNameCellEditor.addListener(new DialogErrorForCellEditorListener(tagNameCellEditor, column)
    // {
    //
    // @Override
    // public void newValidValueTyped(int itemIndex, Object previousValue, Object newValue,
    // CELL_EDITOR_STATE state)
    // {
    // }
    //
    // @Override
    // public String validateValue(String newValue, int beanPosition) {
    // List<SchemaTarget> list = getModel().getBeansList();
    // String errorMessage = null;
    // int lstSize = list.size();
    // for (int i = 0; i < lstSize; i++) {
    // if (newValue.equals(list.get(i).getTagName()) && i != beanPosition) {
    //                        errorMessage = "The column name '" + newValue + "' already exists.";
    // //$NON-NLS-1$
    // break;
    // }
    //
    // }
    // return errorMessage;
    // }
    //
    // });
    return tagNameCellEditor;
  }
コード例 #2
0
  /** DOC sgandon Comment method "createJarNameColumn". */
  public void createJarNameColumn() {
    TableViewerCreatorColumn<ModuleToInstall, String> column =
        new TableViewerCreatorColumn<ModuleToInstall, String>(tableViewerCreator);
    column.setTitle(
        Messages.getString("ExternalModulesInstallDialog_ColumnJarName")); // $NON-NLS-1$
    column.setToolTipHeader(
        Messages.getString("ExternalModulesInstallDialog_ColumnJarName")); // $NON-NLS-1$
    column.setBeanPropertyAccessors(
        new IBeanPropertyAccessors<ModuleToInstall, String>() {

          @Override
          public String get(ModuleToInstall bean) {
            return bean.getName();
          }

          @Override
          public void set(ModuleToInstall bean, String value) {
            // read only
          }
        });
    column.setSortable(true);
    tableViewerCreator.setDefaultSort(column, SORT.ASC);
    column.setWeight(5);
    column.setModifiable(false);
  }
コード例 #3
0
  /*
   * (non-Javadoc)
   *
   * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
   */
  @Override
  protected Control createDialogArea(Composite parent) {
    checkNetworkStatus();
    GridData layoutData = new GridData(GridData.FILL_BOTH);
    Composite composite = new Composite(parent, SWT.BORDER);
    GridLayout layout = new GridLayout();
    composite.setLayout(layout);
    composite.setLayoutData(layoutData);
    tableViewerCreator = new TableViewerCreator<ModuleToInstall>(composite);
    tableViewerCreator.setCheckboxInFirstColumn(false);
    tableViewerCreator.setColumnsResizableByDefault(true);
    tableViewerCreator.setLinesVisible(true);
    tableViewerCreator.setLayoutMode(LAYOUT_MODE.CONTINUOUS);

    tableViewerCreator.createTable();

    createJarNameColumn();
    createModuleNameColumn();
    createContextColumn();
    createRequiredColumn();
    createLicenseColumn();

    urlcolumn = createMoreInformationColumn();

    installcolumn = createActionColumn();

    tableViewerCreator.init(inputList);
    addInstallButtons();
    layoutData = new GridData(GridData.FILL_BOTH);
    tableViewerCreator.getTable().setLayoutData(layoutData);
    tableViewerCreator.getTable().pack();

    Composite footComposite = new Composite(composite, SWT.NONE);
    layoutData = new GridData(GridData.FILL_HORIZONTAL);
    footComposite.setLayoutData(layoutData);
    layout = new GridLayout();
    layout.numColumns = 2;
    footComposite.setLayout(layout);

    final Link moreInfor = new Link(footComposite, SWT.NONE);
    layoutData = new GridData(GridData.FILL_HORIZONTAL);
    layoutData.widthHint = 200;
    moreInfor.setText(Messages.getString("ExternalModulesInstallDialog_MoreInfor")); // $NON-NLS-1$
    moreInfor.setLayoutData(layoutData);
    moreInfor.addSelectionListener(
        new SelectionAdapter() {

          @Override
          public void widgetSelected(SelectionEvent e) {
            //
            // Program.launch(Messages.getString("download.external.dialog.help.url"));
            // //$NON-NLS-1$
            openURL(Messages.getString("download.external.dialog.help.url")); // $NON-NLS-1$
          }
        });
    setupColumnSortListener();
    createFooter(composite);
    setTitle(title);
    return composite;
  }
コード例 #4
0
  /**
   * DOC ocarbone Comment method "addTreeNavigator".
   *
   * @param parent
   * @param width
   * @param height
   */
  private void addTreeNavigator(Composite parent, int width, int height) {
    // Group
    Group group =
        Form.createGroup(
            parent,
            1,
            Messages.getString("DatabaseTableForm.navigatorTree"),
            height); //$NON-NLS-1$

    // ScrolledComposite
    ScrolledComposite scrolledCompositeFileViewer =
        new ScrolledComposite(group, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NONE);
    scrolledCompositeFileViewer.setExpandHorizontal(true);
    scrolledCompositeFileViewer.setExpandVertical(true);
    GridData gridData1 = new GridData(GridData.FILL_BOTH);
    gridData1.widthHint = width + 12;
    gridData1.heightHint = height;
    gridData1.horizontalSpan = 2;
    scrolledCompositeFileViewer.setLayoutData(gridData1);

    tableViewerCreator = new TableViewerCreator(scrolledCompositeFileViewer);
    tableViewerCreator.setHeaderVisible(false);
    tableViewerCreator.setColumnsResizableByDefault(false);
    tableViewerCreator.setBorderVisible(false);
    tableViewerCreator.setLinesVisible(false);
    tableViewerCreator.setLayoutMode(LAYOUT_MODE.NONE);
    tableViewerCreator.setCheckboxInFirstColumn(false);
    tableViewerCreator.setFirstColumnMasked(false);

    tableNavigator = tableViewerCreator.createTable();
    tableNavigator.setLayoutData(new GridData(GridData.FILL_BOTH));

    TableColumn tableColumn = new TableColumn(tableNavigator, SWT.NONE);
    tableColumn.setText(
        Messages.getString("DatabaseTableForm.tableColumnText.talbe")); // $NON-NLS-1$
    tableColumn.setWidth(width + 120);

    scrolledCompositeFileViewer.setContent(tableNavigator);
    scrolledCompositeFileViewer.setSize(width + 12, height);

    // // Button Add metadata Table
    Composite button =
        Form.startNewGridLayout(group, HEIGHT_BUTTON_PIXEL, false, SWT.CENTER, SWT.CENTER);
    addTableButton =
        new UtilsButton(
            button,
            Messages.getString("DatabaseTableForm.AddTable"),
            width - 30,
            HEIGHT_BUTTON_PIXEL); //$NON-NLS-1$

    Composite rmButton =
        Form.startNewGridLayout(group, HEIGHT_BUTTON_PIXEL, false, SWT.CENTER, SWT.CENTER);
    removeTableButton =
        new UtilsButton(rmButton, "Remove Schema", width - 30, HEIGHT_BUTTON_PIXEL); // $NON-NLS-1$
  }
コード例 #5
0
  private void activateCellEditor() {
    // System.out.println("activateCellEditor");

    // System.out.println("Activating index=" + previousActivatedIndex);

    Object previousModifiedBean =
        this.tableViewerCreator.getTableViewer().getElementAt(previousActivatedIndex);
    int indexColumn = tableViewerCreatorColumn.getIndex();
    tableViewerCreator.getTableViewer().editElement(previousModifiedBean, indexColumn);
  }
コード例 #6
0
 /** DOC sgandon Comment method "updateInstallModulesButtonState". */
 protected void updateInstallModulesButtonState() {
   List<ModuleToInstall> theInputList = tableViewerCreator.getInputList();
   boolean isEnable = false;
   if (!theInputList.isEmpty()) {
     for (ModuleToInstall module : theInputList) {
       if (!MavenConstants.DOWNLOAD_MANUAL.equals(module.getDistribution())) {
         isEnable = true;
         break;
       }
     }
   }
   installAllBtn.setEnabled(isEnable);
 }
コード例 #7
0
 /** DOC sgandon Comment method "updateInstallModulesButtonState". */
 protected void updateInstallModulesButtonState() {
   List<ModuleToInstall> theInputList = tableViewerCreator.getInputList();
   boolean isEnable = false;
   if (!theInputList.isEmpty()) {
     for (ModuleToInstall module : theInputList) {
       if (module.getUrl_download() != null) {
         isEnable = true;
         break;
       }
     }
   }
   installAllBtn.setEnabled(isEnable);
 }
コード例 #8
0
  /**
   * DOC sgandon Comment method "getModulesToBeInstalled".
   *
   * @return
   */
  protected List<ModuleToInstall> getModulesToBeInstalled() {
    List<ModuleToInstall> theInputList = tableViewerCreator.getInputList();

    List<ModuleToInstall> toInstall = new ArrayList<ModuleToInstall>();
    for (ModuleToInstall module : theInputList) {
      if (!MavenConstants.DOWNLOAD_MANUAL.equals(module.getDistribution())
          && !jarsInstalledSuccuss.contains(module.getName())
          && ELibraryInstallStatus.INSTALLED
              != ModuleStatusProvider.getStatusMap().get(module.getMavenUri())) {
        toInstall.add(module);
      }
    }
    return toInstall;
  }
コード例 #9
0
  /**
   * DOC sgandon Comment method "getModulesToBeInstalled".
   *
   * @return
   */
  protected List<ModuleToInstall> getModulesToBeInstalled() {
    List<ModuleToInstall> theInputList = tableViewerCreator.getInputList();

    List<ModuleToInstall> toInstall = new ArrayList<ModuleToInstall>();
    if (!jarsInstalledSuccuss.isEmpty()) {
      for (ModuleToInstall module : theInputList) {
        if (!jarsInstalledSuccuss.contains(module.getName())) {
          toInstall.add(module);
        }
      }
    } else {
      toInstall.addAll(theInputList);
    }
    return toInstall;
  }
コード例 #10
0
  /** DOC sgandon Comment method "setupColumnSortListener". */
  @SuppressWarnings("rawtypes")
  private void setupColumnSortListener() {
    List<TableViewerCreatorColumnNotModifiable> columns = tableViewerCreator.getColumns();
    IColumnSortedListener columnSortedListener =
        new IColumnSortedListener() {

          @Override
          public void handle() {
            BusyIndicator.showWhile(
                Display.getDefault(),
                new Runnable() {

                  @Override
                  public void run() {
                    addInstallButtons();
                  }
                });
          }
        };
    for (TableViewerCreatorColumnNotModifiable column : columns) {
      column.getTableColumnSelectionListener().addColumnSortedListener(columnSortedListener);
    }
  }
コード例 #11
0
  // TODO the implementation of this method is horrible and creating too many widgets
  // table/column renderer/editor should be used instead should be used instead
  protected void addInstallButtons() {
    final AtomicInteger enabledButtonCount = new AtomicInteger(0);
    tableViewerCreator.getTableViewer().getControl().setRedraw(false);
    final Table table = tableViewerCreator.getTable();
    manualInstallButtonMap = new HashMap<ModuleToInstall, Button>();
    ILibrariesService librariesService = LibManagerUiPlugin.getDefault().getLibrariesService();

    disposePreviousEditors();
    for (final TableItem item : table.getItems()) {
      TableEditor editor = new TableEditor(table);
      installButtonsEditors.add(editor);
      Control control = null;
      Object obj = item.getData();
      if (obj instanceof ModuleToInstall) {
        final ModuleToInstall data = (ModuleToInstall) obj;
        boolean isInstalled = false;
        try {
          isInstalled =
              librariesService.getLibraryStatus(data.getName()) == ELibraryInstallStatus.INSTALLED;
        } catch (BusinessException e1) { // log the error and consider as unsinstalled
          log.error(e1);
        }
        boolean hasDownloadUrl = data.getUrl_description() != null;
        if (!MavenConstants.DOWNLOAD_MANUAL.equals(
            data.getDistribution())) { // add the button to download
          final Button button = new Button(table, SWT.FLAT);
          control = button;
          enabledButtonCount.incrementAndGet();
          button.setText(
              Messages.getString("ExternalModulesInstallDialog_Download")); // $NON-NLS-1$
          button.setData(item);
          button.addSelectionListener(
              new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                  table.select(table.indexOf(item));
                  launchIndividualDownload(enabledButtonCount, data, button);
                }
              });
          button.setEnabled(!isInstalled);
          button.setToolTipText(data.toString());
        } else { // add the link for manual download
          Composite composite = new Composite(table, SWT.NONE);
          composite.setBackground(color);
          control = composite;
          GridLayout layout = new GridLayout(hasDownloadUrl ? 2 : 1, false);
          layout.marginHeight = 0;
          layout.verticalSpacing = 1;
          composite.setLayout(layout);
          if (hasDownloadUrl) {
            Link openLink = new Link(composite, SWT.NONE);
            GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).applyTo(openLink);
            openLink.setBackground(color);
            // openLink.setLayoutData(gData);
            openLink.setText(
                "<a href=\"\">"
                    + Messages.getString("ExternalModulesInstallDialog.openInBrowser")
                    + "</a>"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            openLink.addSelectionListener(
                new SelectionAdapter() {

                  @Override
                  public void widgetSelected(final SelectionEvent e) {
                    // Program.launch(data.getUrl_description());
                    openURL(data.getUrl_description());
                  }
                });
          } // else no download URL so just add the install buttonb
          enabledButtonCount.incrementAndGet();
          Button importButton = new Button(composite, SWT.FLAT);
          importButton.setImage(ImageProvider.getImage(ECoreImage.IMPORT_JAR));
          importButton.setToolTipText(
              Messages.getString("ImportExternalJarAction.title")); // $NON-NLS-1$
          importButton.addSelectionListener(
              new ImportButtonSelectionListener(enabledButtonCount, item));
          manualInstallButtonMap.put(data, importButton);
          GridDataFactory.fillDefaults()
              .align(SWT.RIGHT, SWT.CENTER)
              .grab(true, false)
              .applyTo(importButton);
          importButton.setEnabled(!isInstalled);
          importButton.setToolTipText(data.toString());
        }
        editor.grabHorizontal = true;
        editor.setEditor(control, item, tableViewerCreator.getColumns().indexOf(installcolumn));
        editor.layout();
        // url
        editor = new TableEditor(table);
        installButtonsEditors.add(editor);
        Composite composite = new Composite(table, SWT.NONE);
        composite.setBackground(color);
        // GridLayout layout = new GridLayout();
        FormLayout layout = new FormLayout();
        layout.marginHeight = 0;
        layout.marginWidth = 0;
        composite.setLayout(layout);
        FormData gData = new FormData();
        gData.left = new FormAttachment(0);
        gData.right = new FormAttachment(100);
        gData.top = new FormAttachment(composite, 0, SWT.CENTER);
        final Link openLink = new Link(composite, SWT.NONE);
        openLink.setLayoutData(gData);
        openLink.setBackground(color);
        gData.height = new GC(composite).stringExtent(" ").y; // $NON-NLS-1$
        openLink.setText(
            "<a href=\"\">"
                + (hasDownloadUrl ? data.getUrl_description() : "")
                + "</a>"); //$NON-NLS-1$ //$NON-NLS-2$
        openLink.addSelectionListener(
            new SelectionAdapter() {

              @Override
              public void widgetSelected(final SelectionEvent e) {
                // Program.launch(data.getUrl_description());
                openURL(data.getUrl_description());
              }
            });
        editor.grabHorizontal = true;
        // editor.minimumHeight = 20;
        editor.setEditor(composite, item, tableViewerCreator.getColumns().indexOf(urlcolumn));
        editor.layout();
      }
    }
    tableViewerCreator.getTableViewer().getTable().layout();
    tableViewerCreator.getTableViewer().refresh(true);
    tableViewerCreator.getTableViewer().getControl().setRedraw(true);
  }
コード例 #12
0
 @Override
 protected void setTableViewerCreatorOptions(
     TableViewerCreator<IMetadataColumn> newTableViewerCreator) {
   super.setTableViewerCreatorOptions(newTableViewerCreator);
   newTableViewerCreator.setLayoutMode(LAYOUT_MODE.DEFAULT);
 }
コード例 #13
0
 public void activate() {
   previousActivatedIndex = tableViewerCreator.getModifiedObjectInfo().getCurrentModifiedIndex();
   // System.out.println("previousActivatedIndex =" + previousActivatedIndex);
 }
コード例 #14
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);
  }
コード例 #15
0
 /*
  * (non-Javadoc)
  *
  * @see
  * org.talend.commons.ui.swt.extended.macrotable.AbstractExtendedTableViewer#setTableViewerCreatorOptions(org.talend
  * .commons.ui.swt.tableviewer.TableViewerCreator)
  */
 @Override
 protected void setTableViewerCreatorOptions(
     TableViewerCreator<ConceptTarget> newTableViewerCreator) {
   super.setTableViewerCreatorOptions(newTableViewerCreator);
   newTableViewerCreator.setFirstVisibleColumnIsSelection(true);
 }