コード例 #1
0
  /**
   * addButtonControls.
   *
   * @param cancelButton
   */
  @Override
  protected void addUtilsButtonListeners() {

    // Event guessButton
    guessButton.addSelectionListener(
        new SelectionAdapter() {

          @Override
          public void widgetSelected(final SelectionEvent e) {
            // changed by hqzhang for TDI-13613, old code is strange, maybe caused by duplicated
            // addUtilsButtonListeners() in addFields() method
            if (connectionItem.getConnection().isContextMode()) {
              connectionItem.getConnection().setContextName(null);
            }
            initGuessSchema();
            LdifFileConnection originalValueConnection = getOriginalValueConnection();
            // if no file, the process don't be executed
            if (originalValueConnection.getFilePath() == null
                || originalValueConnection.getFilePath().equals("")) { // $NON-NLS-1$
              informationLabel.setText(
                  "   "
                      + Messages.getString("FileStep3.filepathAlert") // $NON-NLS-1$ //$NON-NLS-2$
                      + "                                                                              "); //$NON-NLS-1$
              return;
            }
            if (!new File(originalValueConnection.getFilePath()).exists()) {
              String msg = Messages.getString("FileStep3.fileNotExist"); // $NON-NLS-1$
              informationLabel.setText(
                  MessageFormat.format(msg, originalValueConnection.getFilePath()));
              return;
            }
            if (tableEditorView.getMetadataEditor().getBeanCount() > 0) {
              if (MessageDialog.openConfirm(
                  getShell(),
                  Messages.getString("FileStep3.guessConfirmation"),
                  Messages //$NON-NLS-1$
                      .getString("FileStep3.guessConfirmationMessage"))) { // $NON-NLS-1$
                runShadowProcess();
              }
              return;
            }
            runShadowProcess();
          }
        });
    if (cancelButton != null) {
      // Event CancelButton
      cancelButton.addSelectionListener(
          new SelectionAdapter() {

            @Override
            public void widgetSelected(final SelectionEvent e) {
              getShell().close();
            }
          });
    }
  }
コード例 #2
0
  @Override
  protected void addUtilsButtonListeners() {
    checkConnectionBtn.addSelectionListener(
        new SelectionAdapter() {

          @Override
          public void widgetSelected(SelectionEvent e) {
            checkConnection();
          }
        });
  }
コード例 #3
0
  /**
   * addButtonControls.
   *
   * @param cancelButton
   */
  @Override
  protected void addUtilsButtonListeners() {

    // Event guessButton
    guessButton.addSelectionListener(
        new SelectionAdapter() {

          @Override
          public void widgetSelected(final SelectionEvent e) {
            if (tableEditorView.getMetadataEditor().getBeanCount() > 0) {

              if (!guessButton.getEnabled()) {
                guessButton.setEnabled(true);
                if (MessageDialog.openConfirm(
                    getShell(),
                    Messages.getString("FileStep3.guessConfirmation"),
                    Messages //$NON-NLS-1$
                        .getString("FileStep3.guessConfirmationMessage"))) { // $NON-NLS-1$
                  runShadowProcess();
                }
              } else {
                guessButton.setEnabled(false);
              }

            } else {

              if (!guessButton.getEnabled()) {
                guessButton.setEnabled(true);
                runShadowProcess();
              } else {
                guessButton.setEnabled(false);
              }
            }
          }
        });
    // Event addTable Button
    addTableButton.addSelectionListener(
        new SelectionAdapter() {

          @Override
          public void widgetSelected(final SelectionEvent e) {
            if (!addTableButton.getEnabled()) {
              addTableButton.setEnabled(true);
              addMetadataTable();
            } else {
              addTableButton.setEnabled(false);
            }
          }
        });

    removeTableButton.addSelectionListener(
        new SelectionAdapter() {

          @Override
          public void widgetSelected(SelectionEvent e) {
            if (!removeTableButton.getEnabled()) {
              removeTableButton.setEnabled(true);
              TableItem[] selection = tableNavigator.getSelection();
              if (selection != null && selection.length > 0) {
                boolean openConfirm =
                    MessageDialog.openConfirm(
                        getShell(), "Confirm", "Are you sure to delete this schema ?");
                if (openConfirm) {
                  for (TableItem item : selection) {

                    if (tableNavigator.indexOf(item) != -1) {
                      EList<SalesforceModuleUnit> modules = temConnection.getModules();
                      for (int i = 0; i < modules.size(); i++) {
                        if (modules.get(i).getModuleName().equals(moduleName)) {
                          for (int j = 0; j < modules.get(i).getTables().size(); j++) {
                            if (item.getText()
                                .equals(modules.get(i).getTables().get(j).getLabel())) {
                              modules.get(i).getTables().remove(j);
                            }
                          }
                        }
                      }
                      tableNavigator.remove(tableNavigator.indexOf(item));
                      if (tableNavigator.getItemCount() > 1) {
                        tableNavigator.setSelection(
                            tableNavigator.getItem(tableNavigator.getItemCount() - 1));
                      }
                    }
                  }
                  initTreeNavigatorNodes();
                }
              }
            } else {
              removeTableButton.setEnabled(false);
            }
          }
        });
    if (cancelButton != null) {
      // Event CancelButton
      cancelButton.addSelectionListener(
          new SelectionAdapter() {

            @Override
            public void widgetSelected(final SelectionEvent e) {
              getShell().close();
            }
          });
    }
  }