コード例 #1
0
  private void createSysnonymListColumne() {

    TableViewColumnDefine[] tableColumnDef =
        new TableViewColumnDefine[] { //
          new TableViewColumnDefine(
              "SYNONYM_NAME",
              Messages.get().TadpoleSynonymComposite_5,
              100,
              SWT.LEFT) // //$NON-NLS-1$
          ,
          new TableViewColumnDefine(
              "TABLE_OWNER",
              Messages.get().TadpoleSynonymComposite_7,
              60,
              SWT.LEFT) // //$NON-NLS-1$
          ,
          new TableViewColumnDefine(
              "OBJECT_TYPE",
              Messages.get().TadpoleSynonymComposite_9,
              70,
              SWT.CENTER) // //$NON-NLS-1$
          ,
          new TableViewColumnDefine(
              "TABLE_NAME",
              Messages.get().TadpoleSynonymComposite_11,
              100,
              SWT.LEFT) // //$NON-NLS-1$
          ,
          new TableViewColumnDefine(
              "COMMENTS", Messages.get().TadpoleSynonymComposite_13, 100, SWT.LEFT) // //$NON-NLS-1$
        };

    ColumnHeaderCreator.createColumnHeader(synonymListViewer, tableColumnDef);

    synonymListViewer.setContentProvider(new ArrayContentProvider());
    synonymListViewer.setLabelProvider(new DefaultLabelProvider(synonymListViewer));
  }
コード例 #2
0
  private void createSynonymDetailColumne() {
    TableViewColumnDefine[] tableColumnDef =
        new TableViewColumnDefine[] { //
          new TableViewColumnDefine(
              "COLUMN_ID",
              Messages.get().TadpoleSynonymComposite_15,
              50,
              SWT.RIGHT) // //$NON-NLS-1$
          ,
          new TableViewColumnDefine(
              "COLUMN_NAME",
              Messages.get().TadpoleSynonymComposite_17,
              100,
              SWT.LEFT) // //$NON-NLS-1$
          ,
          new TableViewColumnDefine(
              "DATA_TYPE",
              Messages.get().TadpoleSynonymComposite_19,
              80,
              SWT.CENTER) // //$NON-NLS-1$
          ,
          new TableViewColumnDefine(
              "NULLABLE",
              Messages.get().TadpoleSynonymComposite_21,
              60,
              SWT.CENTER) // //$NON-NLS-1$
          ,
          new TableViewColumnDefine(
              "KEY", Messages.get().TadpoleSynonymComposite_23, 50, SWT.CENTER) // //$NON-NLS-1$
          ,
          new TableViewColumnDefine(
              "COMMENTS", Messages.get().TadpoleSynonymComposite_25, 100, SWT.LEFT) // //$NON-NLS-1$
        };

    ColumnHeaderCreator.createColumnHeader(synonymColumnViewer, tableColumnDef);

    synonymColumnViewer.setContentProvider(new ArrayContentProvider());
    synonymColumnViewer.setLabelProvider(new DefaultLabelProvider(synonymColumnViewer));
  }
コード例 #3
0
  /**
   * 정보를 최신으로 리프레쉬합니다.
   *
   * @param strObjectName
   */
  public void refreshSynonym(
      final UserDBDAO selectUserDb, final boolean boolRefresh, final String strObjectName) {
    if (!boolRefresh) if (selectUserDb == null) return;
    this.userDB = selectUserDb;

    Job job =
        new Job(Messages.get().MainEditor_45) {
          @Override
          public IStatus run(IProgressMonitor monitor) {
            monitor.beginTask("Connect database", IProgressMonitor.UNKNOWN); // $NON-NLS-1$

            try {
              showSynonyms = getSynonymList(userDB);
            } catch (Exception e) {
              logger.error("Synonym Referesh", e); // $NON-NLS-1$

              return new Status(Status.WARNING, Activator.PLUGIN_ID, e.getMessage());
            } finally {
              monitor.done();
            }

            return Status.OK_STATUS;
          }
        };

    job.addJobChangeListener(
        new JobChangeAdapter() {

          public void done(IJobChangeEvent event) {
            final IJobChangeEvent jobEvent = event;

            getSite()
                .getShell()
                .getDisplay()
                .asyncExec(
                    new Runnable() {
                      public void run() {
                        if (jobEvent.getResult().isOK()) {
                          synonymListViewer.setInput(showSynonyms);
                          synonymListViewer.refresh();
                          TableUtil.packTable(synonymListViewer.getTable());

                          // select tabitem
                          getTabFolderObject().setSelection(tbtmSynonym);

                          selectDataOfTable(strObjectName);
                        } else {
                          if (showSynonyms != null) showSynonyms.clear();
                          synonymListViewer.setInput(showSynonyms);
                          synonymListViewer.refresh();
                          TableUtil.packTable(synonymListViewer.getTable());

                          Status errStatus =
                              new Status(
                                  IStatus.ERROR,
                                  Activator.PLUGIN_ID,
                                  jobEvent.getResult().getMessage(),
                                  jobEvent.getResult().getException()); // $NON-NLS-1$
                          ExceptionDetailsErrorDialog.openError(
                              null,
                              "Error",
                              Messages.get().ExplorerViewer_86,
                              errStatus); //$NON-NLS-1$
                        }
                      }
                    }); // end display.asyncExec
          } // end done
        }); // end job

    job.setName(userDB.getDisplay_name());
    job.setUser(true);
    job.schedule();
  }
コード例 #4
0
  private void createWidget(final CTabFolder tabFolderObject) {
    tbtmSynonym = new CTabItem(tabFolderObject, SWT.NONE);
    tbtmSynonym.setText(Messages.get().TadpoleSynonymComposite_0);
    tbtmSynonym.setData(TAB_DATA_KEY, PublicTadpoleDefine.OBJECT_TYPE.SYNONYM.name());

    Composite compositeTables = new Composite(tabFolderObject, SWT.NONE);
    tbtmSynonym.setControl(compositeTables);
    GridLayout gl_compositeTables = new GridLayout(1, false);
    gl_compositeTables.verticalSpacing = 2;
    gl_compositeTables.horizontalSpacing = 2;
    gl_compositeTables.marginHeight = 2;
    gl_compositeTables.marginWidth = 2;
    compositeTables.setLayout(gl_compositeTables);
    compositeTables.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    SashForm sashForm = new SashForm(compositeTables, SWT.NONE);
    sashForm.setOrientation(SWT.VERTICAL);
    sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    // SWT.VIRTUAL 일 경우 FILTER를 적용하면 데이터가 보이지 않는 오류수정.
    synonymListViewer = new TableViewer(sashForm, SWT.BORDER | SWT.FULL_SELECTION);
    synonymListViewer.addDoubleClickListener(
        new IDoubleClickListener() {
          public void doubleClick(DoubleClickEvent event) {
            try {
              IStructuredSelection is = (IStructuredSelection) event.getSelection();
              if (null != is) {
                OracleSynonymDAO tableDAO = (OracleSynonymDAO) is.getFirstElement();

                if (PublicTadpoleDefine.OBJECT_TYPE
                    .FUNCTIONS
                    .toString()
                    .startsWith(tableDAO.getObject_type())) {
                  AbstractRDBDDLScript rdbScript =
                      new OracleDDLScript(userDB, PublicTadpoleDefine.OBJECT_TYPE.FUNCTIONS);
                  ProcedureFunctionDAO dao = new ProcedureFunctionDAO();
                  dao.setName(tableDAO.getTable_name());

                  FindEditorAndWriteQueryUtil.run(
                      userDB,
                      rdbScript.getFunctionScript(dao),
                      PublicTadpoleDefine.OBJECT_TYPE.FUNCTIONS);
                }
              }
            } catch (Exception e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            }
          }
        });
    synonymListViewer.addPostSelectionChangedListener(
        new ISelectionChangedListener() {
          public void selectionChanged(SelectionChangedEvent event) {
            try {
              IStructuredSelection is = (IStructuredSelection) event.getSelection();
              Object synonymDAO = is.getFirstElement();

              if (synonymDAO != null) {
                OracleSynonymDAO synonym = (OracleSynonymDAO) synonymDAO;

                if (selectSynonymName.equals(synonym.getSynonym_name())) return;
                selectSynonymName = synonym.getSynonym_name();

                SqlMapClient sqlClient = TadpoleSQLManager.getInstance(userDB);
                Map<String, String> mapParam = new HashMap<String, String>();
                mapParam.put("db", userDB.getDb()); // $NON-NLS-1$
                mapParam.put("owner", synonym.getTable_owner()); // $NON-NLS-1$
                mapParam.put("table", synonym.getTable_name()); // $NON-NLS-1$

                showSynonymColumns =
                    sqlClient.queryForList("synonymColumnList", mapParam); // $NON-NLS-1$

              } else showSynonymColumns = null;

              synonymColumnViewer.setInput(showSynonymColumns);
              synonymColumnViewer.refresh();

            } catch (Exception e) {
              logger.error("get table column", e); // $NON-NLS-1$

              Status errStatus =
                  new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); // $NON-NLS-1$
              ExceptionDetailsErrorDialog.openError(
                  tabFolderObject.getShell(), "Error", e.getMessage(), errStatus); // $NON-NLS-1$
            }
          }
        });

    Table tableTableList = synonymListViewer.getTable();
    tableTableList.setLinesVisible(true);
    tableTableList.setHeaderVisible(true);

    createSynonymMenu();

    // columns
    synonymColumnViewer = new TableViewer(sashForm, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
    synonymColumnViewer.addDoubleClickListener(
        new IDoubleClickListener() {
          public void doubleClick(DoubleClickEvent event) {
            IStructuredSelection is = (IStructuredSelection) event.getSelection();

            if (null != is) {
              OracleSynonymColumnDAO synonymDAO = (OracleSynonymColumnDAO) is.getFirstElement();
              FindEditorAndWriteQueryUtil.runAtPosition(synonymDAO.getColumn_name());
            }
          }
        });
    Table tableTableColumn = synonymColumnViewer.getTable();
    tableTableColumn.setHeaderVisible(true);
    tableTableColumn.setLinesVisible(true);

    createSysnonymListColumne();
    createSynonymDetailColumne();

    synonymListViewer.setInput(showSynonyms);
    synonymListViewer.refresh();

    synonymFilter = new DefaultTableColumnFilter();
    synonymListViewer.addFilter(synonymFilter);

    sashForm.setWeights(new int[] {1, 1});
  }
コード例 #5
0
  @Override
  public void run(IStructuredSelection selection, UserDBDAO userDB, OBJECT_TYPE actionType) {
    try {
      PublicTadpoleDefine.QUERY_DML_TYPE queryType = QUERY_DML_TYPE.INSERT;
      if (queryType == QUERY_DML_TYPE.INSERT) {
        if (PublicTadpoleDefine.YES_NO
            .YES
            .name()
            .equals(userDB.getDbAccessCtl().getInsert_lock())) {
          throw new Exception(Messages.get().MainEditor_21);
        }
      }
      queryType = QUERY_DML_TYPE.UPDATE;
      if (queryType == QUERY_DML_TYPE.UPDATE) {
        if (PublicTadpoleDefine.YES_NO
            .YES
            .name()
            .equals(userDB.getDbAccessCtl().getUpdate_lock())) {
          throw new Exception(Messages.get().MainEditor_21);
        }
      }
      queryType = QUERY_DML_TYPE.DELETE;
      if (queryType == QUERY_DML_TYPE.DELETE) {
        if (PublicTadpoleDefine.YES_NO
            .YES
            .name()
            .equals(userDB.getDbAccessCtl().getDelete_locl())) {
          throw new Exception(Messages.get().MainEditor_21);
        }
      }
    } catch (Exception e) {
      MessageDialog.openError(
          getWindow().getShell(), Messages.get().ObjectDeleteAction_2, e.getMessage());
      return;
    }

    try {
      if (!GrantCheckerUtils.ifExecuteQuery(userDB)) return;
    } catch (Exception e) {
      MessageDialog.openError(
          getWindow().getShell(), Messages.get().ObjectDeleteAction_2, e.getMessage());
      return;
    }

    TableDAO tableDAO = (TableDAO) selection.getFirstElement();
    try {
      // get the table columns
      SqlMapClient sqlClient = TadpoleSQLManager.getInstance(userDB);
      Map<String, String> mapParam = new HashMap<String, String>();
      mapParam.put("db", userDB.getDb()); // $NON-NLS-1$
      mapParam.put("table", tableDAO.getName()); // $NON-NLS-1$
      List showTableColumns = sqlClient.queryForList("tableColumnList", mapParam); // $NON-NLS-1$

      // Open the table director editor
      IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();

      DBTableEditorInput dbEditorInput = new DBTableEditorInput(tableDAO, userDB, showTableColumns);
      page.openEditor(dbEditorInput, TableInformationEditor.ID, false);
    } catch (Exception e) {
      logger.error("Load the table data", e); // $NON-NLS-1$

      Status errStatus =
          new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); // $NON-NLS-1$
      ExceptionDetailsErrorDialog.openError(
          null, "Error", Messages.get().ExplorerViewer_39, errStatus); // $NON-NLS-1$
    }
  }
コード例 #6
0
  public TableDataEditorAction(IWorkbenchWindow window, OBJECT_TYPE actionType) {
    super(window, actionType);

    setId(ID + actionType);
    setText(Messages.get().TableDataEditorAction_1);
  }