List of usage examples for org.eclipse.jface.viewers IStructuredSelection isEmpty
public boolean isEmpty();
From source file:com.hangum.tadpole.rdb.core.dialog.dml.TableInformationDialog.java
License:Open Source License
/** * Create contents of the dialog.//w ww . ja v a 2 s . c o m * * @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(2, false)); lblTableName = new Label(compositeTable, SWT.NONE); lblTableName.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1)); lblTableName.setText(SQLUtil.getTableName(userDB, tableDAO)); textTBNameCmt = new Text(compositeTable, SWT.BORDER | SWT.READ_ONLY | SWT.WRAP | SWT.V_SCROLL | 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()); SashForm sashFormData = new SashForm(compositeBody, SWT.VERTICAL); sashFormData.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); tableViewer = new TableViewer(sashFormData, SWT.BORDER | SWT.FULL_SELECTION); tableViewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { IStructuredSelection is = (IStructuredSelection) event.getSelection(); if (!is.isEmpty()) { ExtendTableColumnDAO tableDAO = (ExtendTableColumnDAO) is.getFirstElement(); FindEditorAndWriteQueryUtil.runAtPosition(String.format("%s, ", tableDAO.getName())); } } }); Table table = tableViewer.getTable(); table.setLinesVisible(true); table.setHeaderVisible(true); TableViewerColumn tvColumnName = new TableViewerColumn(tableViewer, SWT.NONE); TableColumn tcColumnName = tvColumnName.getColumn(); tcColumnName.setWidth(150); tcColumnName.setText(Messages.get().ColumnName); // tvColumnName.setEditingSupport(new // DMLColumnEditingSupport(tableViewer, 0, this)); TableViewerColumn tvColumnDataType = new TableViewerColumn(tableViewer, SWT.LEFT); TableColumn tcDataType = tvColumnDataType.getColumn(); tcDataType.setWidth(100); tcDataType.setText(Messages.get().DataType); TableViewerColumn tvColumnKey = new TableViewerColumn(tableViewer, SWT.CENTER); TableColumn tcKey = tvColumnKey.getColumn(); tcKey.setWidth(50); tcKey.setText(Messages.get().Key); TableViewerColumn tvColumnCmt = new TableViewerColumn(tableViewer, SWT.LEFT); TableColumn tcCmt = tvColumnCmt.getColumn(); tcCmt.setWidth(300); tcCmt.setText(CommonMessages.get().Description); tableViewer_ext = new TableViewer(sashFormData, SWT.BORDER | SWT.FULL_SELECTION); Table table_ext = tableViewer_ext.getTable(); table_ext.setLinesVisible(true); table_ext.setHeaderVisible(true); TableViewerColumn tvPropertyName = new TableViewerColumn(tableViewer_ext, SWT.NONE); TableColumn tcPropertyName = tvPropertyName.getColumn(); tcPropertyName.setWidth(180); tcPropertyName.setText("Property"); TableViewerColumn tvPropertyValue = new TableViewerColumn(tableViewer_ext, SWT.NONE); TableColumn tcPropertyValue = tvPropertyValue.getColumn(); tcPropertyValue.setWidth(300); tcPropertyValue.setText("Value"); //DefaultViewerSorter sorterMessage = new DefaultViewerSorter(); tableViewer_ext.setContentProvider(new ArrayContentProvider()); tableViewer_ext.setLabelProvider(new TableStatisticsLabelProvider()); tableViewer.setContentProvider(new ArrayContentProvider()); tableViewer.setLabelProvider(new TableInformationLabelProvider()); sashFormData.setWeights(new int[] { 6, 4 }); initData(); //tableViewer_ext.setComparator(new BasicViewerSorter()); initExtendedData(); // google analytic AnalyticCaller.track(this.getClass().getName()); return container; }
From source file:com.hangum.tadpole.rdb.core.editors.main.composite.QueryHistoryComposite.java
License:Open Source License
/** * Create the composite.//from w ww . j a v a 2s . c o m * @param parent * @param style */ public QueryHistoryComposite(Composite parent, int style) { super(parent, style); setLayout(new GridLayout(1, false)); // SWT.VIRTUAL ? FILTER ? ?? ? . tvSQLHistory = new TableViewer(this, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION); tvSQLHistory.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { IStructuredSelection is = (IStructuredSelection) event.getSelection(); if (!is.isEmpty()) { SQLHistoryDAO historyDAO = (SQLHistoryDAO) is.getFirstElement(); appendText(historyDAO.getStrSQLText()); // google analytic AnalyticCaller.track(MainEditor.ID, "QueryHistoryComposite"); } } }); Table tableSQLHistory = tvSQLHistory.getTable(); tableSQLHistory.setLinesVisible(true); tableSQLHistory.setHeaderVisible(true); tableSQLHistory.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); tableSQLHistory.setSortDirection(SWT.DOWN); // auto column layout AutoResizeTableLayout layoutColumnLayout = new AutoResizeTableLayout(tvSQLHistory.getTable()); tvSQLHistory.getTable().setLayout(layoutColumnLayout); SQLHistorySorter sorterHistory = new SQLHistorySorter(); SQLHistoryCreateColumn.createTableHistoryColumn(tvSQLHistory, sorterHistory, layoutColumnLayout, false); tvSQLHistory.setLabelProvider(new SQLHistoryLabelProvider()); tvSQLHistory.setContentProvider(new ArrayContentProvider()); tvSQLHistory.setInput(listSQLHistory); tvSQLHistory.setSorter(sorterHistory); Composite compositeRecallBtn = new Composite(this, SWT.NONE); compositeRecallBtn.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); GridLayout gl_compositeRecallBtn = new GridLayout(8, false); gl_compositeRecallBtn.marginWidth = 1; gl_compositeRecallBtn.marginHeight = 0; compositeRecallBtn.setLayout(gl_compositeRecallBtn); final Button btnExportHistory = new Button(compositeRecallBtn, SWT.NONE); btnExportHistory.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); btnExportHistory.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { IStructuredSelection is = (IStructuredSelection) tvSQLHistory.getSelection(); if (!is.isEmpty()) { SQLHistoryDAO historyDAO = (SQLHistoryDAO) is.getFirstElement(); appendText(historyDAO.getStrSQLText()); } else { MessageDialog.openInformation(null, Messages.MainEditor_2, Messages.MainEditor_29); } } }); btnExportHistory.setText(Messages.MainEditor_12); Button btnDetailView = new Button(compositeRecallBtn, SWT.NONE); btnDetailView.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { IStructuredSelection is = (IStructuredSelection) tvSQLHistory.getSelection(); Object selElement = is.getFirstElement(); if (selElement instanceof SQLHistoryDAO) { SQLHistoryDAO tmd = (SQLHistoryDAO) selElement; TadpoleMessageDialog dlg = new TadpoleMessageDialog(null, Messages.MainEditor_11, SQLHistoryLabelProvider.dateToStr(tmd.getStartDateExecute()), tmd.getStrSQLText()); dlg.open(); } else { MessageDialog.openInformation(null, Messages.MainEditor_2, Messages.MainEditor_29); } } }); btnDetailView.setText(Messages.MainEditor_btnDetailView_text); // Button btnSetEditor = new Button(compositeRecallBtn, SWT.NONE); // btnSetEditor.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); // btnSetEditor.addSelectionListener(new SelectionAdapter() { // @Override // public void widgetSelected(SelectionEvent e) { // StringBuffer sbExportData = new StringBuffer(); // // for(SQLHistoryDAO dao : listSQLHistory) { // sbExportData.append( dao.getStrSQLText() ).append(PublicTadpoleDefine.LINE_SEPARATOR); //$NON-NLS-1$ // } // //// downloadExtFile(getRdbResultComposite().getUserDB().getDisplay_name() + "_RecallSQLExport.txt", sbExportData.toString()); //$NON-NLS-1$ // } // }); // btnSetEditor.setText(Messages.MainEditor_17); // table clear Button btnHistoyClear = new Button(compositeRecallBtn, SWT.NONE); btnHistoyClear.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); btnHistoyClear.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { listSQLHistory.clear(); tvSQLHistory.refresh(); } }); btnHistoyClear.setText(Messages.MainEditor_btnClear_text); Label labelDumyRecal = new Label(compositeRecallBtn, SWT.NONE); labelDumyRecal.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); textHistoryFilter = new Text(compositeRecallBtn, SWT.SEARCH | SWT.ICON_SEARCH | SWT.ICON_CANCEL); textHistoryFilter.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.keyCode == SWT.Selection) refreshSqlHistory(); } }); textHistoryFilter.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); // refresh Button btnRefresh = new Button(compositeRecallBtn, SWT.NONE); btnRefresh.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); btnRefresh.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { refreshSqlHistory(); } }); btnRefresh.setText(Messages.MainEditor_24); }
From source file:com.hangum.tadpole.rdb.core.editors.objects.table.TableDirectEditorComposite.java
License:Open Source License
/** * default composite// w ww .j av a 2 s . c o m * * @param parent * @param style * @param userDB * @param initTableNameStr * @param columnList * @param primaryKEYListString */ public TableDirectEditorComposite(Composite parent, int style, final UserDBDAO userDB, final TableDAO tableDao, List<TableColumnDAO> columnList, Map<String, Boolean> primaryKEYListString) { super(parent, style); GridLayout gridLayout = new GridLayout(1, false); gridLayout.verticalSpacing = 2; gridLayout.horizontalSpacing = 2; gridLayout.marginHeight = 2; gridLayout.marginWidth = 2; setLayout(gridLayout); // start initialize value this.userDB = userDB; this.tableDao = tableDao; this.columnList = columnList; this.primaryKEYListString = primaryKEYListString; // end initialize value Composite compositeBase = new Composite(this, SWT.NONE); compositeBase.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); GridLayout gl_compositeBase = new GridLayout(1, false); gl_compositeBase.verticalSpacing = 3; gl_compositeBase.horizontalSpacing = 3; gl_compositeBase.marginHeight = 3; gl_compositeBase.marginWidth = 3; compositeBase.setLayout(gl_compositeBase); toolBar = new ToolBar(compositeBase, SWT.NONE | SWT.FLAT | SWT.RIGHT); toolBar.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); tltmRefresh = new ToolItem(toolBar, SWT.NONE); tltmRefresh.setImage(ImageUtils.getRefresh()); tltmRefresh.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (tltmSave.getEnabled()) { if (!MessageDialog.openConfirm(null, "Confirm", Messages.TableDirectEditorComposite_1)) //$NON-NLS-1$ return; } refreshEditor(); } }); tltmRefresh.setToolTipText(Messages.TableDirectEditorComposite_tltmRefersh_text); tltmSave = new ToolItem(toolBar, SWT.NONE); tltmSave.setImage(ImageUtils.getSave()); tltmSave.setEnabled(false); tltmSave.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { saveTableData(); } }); tltmSave.setToolTipText(Messages.TableEditPart_0); tltmInsert = new ToolItem(toolBar, SWT.NONE); tltmInsert.setImage(ImageUtils.getAdd()); tltmInsert.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { insertRow(); } }); tltmInsert.setToolTipText(Messages.TableEditPart_tltmInsert_text); tltmDelete = new ToolItem(toolBar, SWT.NONE); tltmDelete.setImage(ImageUtils.getDelete()); tltmDelete.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { IStructuredSelection is = (IStructuredSelection) sqlResultTableViewer.getSelection(); if (!is.isEmpty()) { deleteRow(is.getFirstElement()); } } }); tltmDelete.setEnabled(false); tltmDelete.setToolTipText(Messages.TableEditPart_1); Composite compositeBody = new Composite(compositeBase, SWT.NONE); GridLayout gl_compositeBody = new GridLayout(2, false); gl_compositeBody.horizontalSpacing = 3; gl_compositeBody.verticalSpacing = 3; gl_compositeBody.marginHeight = 3; gl_compositeBody.marginWidth = 3; compositeBody.setLayout(gl_compositeBody); compositeBody.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); Label lblWhere = new Label(compositeBody, SWT.NONE); lblWhere.setText(Messages.TableEditPart_lblWhere_text); textWhere = new Text(compositeBody, SWT.BORDER); textWhere.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { if (e.keyCode == SWT.Selection) initBusiness(); } }); textWhere.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); lblOrderBy = new Label(compositeBody, SWT.NONE); lblOrderBy.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblOrderBy.setText(Messages.TableDirectEditorComposite_lblOrderBy_text); textOrderBy = new Text(compositeBody, SWT.BORDER); textOrderBy.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { if (e.keyCode == SWT.Selection) initBusiness(); } }); textOrderBy.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); Label lblNewLabel = new Label(compositeBody, SWT.NONE); lblNewLabel.setText(Messages.TableEditPart_3); textFilter = new Text(compositeBody, SWT.SEARCH | SWT.ICON_SEARCH | SWT.ICON_CANCEL); textFilter.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.keyCode == SWT.Selection) setFilter(); } }); textFilter.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); sqlResultTableViewer = new TableViewer(compositeBody, SWT.BORDER | SWT.FULL_SELECTION); sqlResultTableViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { tltmDelete.setEnabled(true); } }); tableResult = sqlResultTableViewer.getTable(); tableResult.setHeaderVisible(true); tableResult.setLinesVisible(true); tableResult.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1)); // table markup-enable tableResult.setData(RWT.MARKUP_ENABLED, Boolean.TRUE); sqlFilter.setTable(tableResult); compositeTail = new Composite(compositeBase, SWT.NONE); GridLayout gl_compositeTail = new GridLayout(1, false); gl_compositeTail.verticalSpacing = 2; gl_compositeTail.horizontalSpacing = 2; gl_compositeTail.marginHeight = 2; gl_compositeTail.marginWidth = 2; compositeTail.setLayout(gl_compositeTail); compositeTail.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); btnDdlSourceView = new Button(compositeTail, SWT.NONE); btnDdlSourceView.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { try { DDLScriptManager scriptManager = new DDLScriptManager(userDB, PublicTadpoleDefine.DB_ACTION.TABLES); FindEditorAndWriteQueryUtil.run(userDB, scriptManager.getScript(tableDao), PublicTadpoleDefine.DB_ACTION.TABLES); } catch (Exception ee) { MessageDialog.openError(null, "Confirm", ee.getMessage()); //$NON-NLS-1$ } } }); btnDdlSourceView.setText(Messages.TableDirectEditorComposite_btnDdlSourceView_text); initBusiness(); // google analytic AnalyticCaller.track(this.getClass().getName()); }
From source file:com.hangum.tadpole.rdb.core.editors.table.TableViewerEditPart.java
License:Open Source License
/** * Create contents of the editor part./* w w w.j ava 2 s .c om*/ * @param parent */ @Override public void createPartControl(Composite parent) { GridLayout gl_parent = new GridLayout(1, false); gl_parent.marginHeight = 0; parent.setLayout(gl_parent); composite = new Composite(parent, SWT.NONE); composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); composite.setLayout(new GridLayout(1, false)); toolBar = new ToolBar(composite, SWT.FLAT | SWT.RIGHT); toolBar.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); tltmSave = new ToolItem(toolBar, SWT.NONE); tltmSave.setEnabled(false); tltmSave.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // save ? . java.sql.Connection javaConn = null; Statement stmt = null; String lastExeQuery = ""; //$NON-NLS-1$ try { SqlMapClient client = TadpoleSQLManager.getInstance(userDB); javaConn = client.getDataSource().getConnection(); // sqlite? forward cursor ? stmt = javaConn.createStatement();//ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); javaConn.setAutoCommit(false); String[] querys = SQLTextUtil.delLineChar(getChangeQuery()).split(";"); //$NON-NLS-1$ for (int i = 0; i < querys.length; i++) { // logger.info("exe query [" + querys[i] + "]"); //$NON-NLS-1$ //$NON-NLS-2$ lastExeQuery = querys[i]; stmt.execute(querys[i]); } javaConn.commit(); // ?? . tltmSave.setEnabled(false); initBusiness(textWhere.getText()); isDirty = false; } catch (Exception ee) { try { if (javaConn != null) javaConn.rollback(); } catch (SQLException roE) { } ; logger.error(Messages.TableViewerEditPart_7, ee); // ? . MessageDialog.openError(null, Messages.TableViewerEditPart_3, "Query [ " + lastExeQuery + Messages.TableViewerEditPart_10 + ee.getMessage() + Messages.TableViewerEditPart_11); //$NON-NLS-2$ } finally { // connection? ? ? . try { javaConn.setAutoCommit(true); } catch (Exception ee) { } try { if (stmt != null) stmt.close(); } catch (Exception ee) { } try { if (javaConn != null) javaConn.close(); } catch (Exception ee) { } } } }); tltmSave.setText(Messages.TableEditPart_0); tltmInsert = new ToolItem(toolBar, SWT.NONE); tltmInsert.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (modifyType == TABLE_MOD_TYPE.EDITOR) insertRow(); } }); tltmInsert.setText(Messages.TableEditPart_tltmInsert_text); tltmInsert.setEnabled(false); tltmDelete = new ToolItem(toolBar, SWT.NONE); tltmDelete.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { IStructuredSelection is = (IStructuredSelection) sqlResultTableViewer.getSelection(); if (!is.isEmpty()) { deleteRow(is.getFirstElement()); } } }); tltmDelete.setEnabled(false); tltmDelete.setText(Messages.TableEditPart_1); tltmTablecomment = new ToolItem(toolBar, SWT.NONE); tltmTablecomment.setText(TbUtils.NONE_MSG); Composite compositeBody = new Composite(parent, SWT.NONE); compositeBody.setLayout(new GridLayout(2, false)); compositeBody.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); Label lblWhere = new Label(compositeBody, SWT.NONE); lblWhere.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblWhere.setText(Messages.TableEditPart_lblWhere_text); textWhere = new Text(compositeBody, SWT.BORDER); textWhere.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { if (e.keyCode == SWT.Selection) changeWhere(textWhere.getText()); } }); textWhere.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); Label lblNewLabel = new Label(compositeBody, SWT.NONE); lblNewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblNewLabel.setText(Messages.TableEditPart_3); textFilter = new Text(compositeBody, SWT.BORDER); textFilter.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.keyCode == SWT.Selection) setFilter(); } }); textFilter.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); sqlResultTableViewer = new TableViewer(compositeBody, SWT.VIRTUAL | SWT.BORDER | SWT.FULL_SELECTION); sqlResultTableViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { if (primaryKeyListIndex.size() >= 1) tltmDelete.setEnabled(true); } }); tableResult = sqlResultTableViewer.getTable(); tableResult.setHeaderVisible(true); tableResult.setLinesVisible(true); tableResult.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1)); // table markup-enable tableResult.setData(RWT.MARKUP_ENABLED, Boolean.TRUE); sqlFilter.setTable(tableResult); initBusiness(StringUtils.trimToEmpty(textWhere.getText())); }
From source file:com.hangum.tadpole.rdb.core.viewers.object.sub.rdb.function.TadpoleFunctionComposite.java
License:Open Source License
private void createWidget(final CTabFolder tabFolderObject) { CTabItem tbtmFunctions = new CTabItem(tabFolderObject, SWT.NONE); tbtmFunctions.setText("Functions"); //$NON-NLS-1$ ;//from w ww.jav a 2s.com Composite compositeIndexes = new Composite(tabFolderObject, SWT.NONE); tbtmFunctions.setControl(compositeIndexes); GridLayout gl_compositeIndexes = new GridLayout(1, false); gl_compositeIndexes.verticalSpacing = 2; gl_compositeIndexes.horizontalSpacing = 2; gl_compositeIndexes.marginHeight = 2; gl_compositeIndexes.marginWidth = 2; compositeIndexes.setLayout(gl_compositeIndexes); SashForm sashForm = new SashForm(compositeIndexes, SWT.NONE); sashForm.setOrientation(SWT.VERTICAL); sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); // SWT.VIRTUAL ? FILTER ? ?? ? . functionTableViewer = new TableViewer(sashForm, SWT.BORDER | SWT.FULL_SELECTION); Table tableTableList = functionTableViewer.getTable(); tableTableList.setLinesVisible(true); tableTableList.setHeaderVisible(true); functionComparator = new ProcedureFunctionComparator(); functionTableViewer.setSorter(functionComparator); functionComparator.setColumn(0); createProcedureFunctionColumn(functionTableViewer, functionComparator); functionTableViewer.setLabelProvider(new ProcedureFunctionLabelProvicer()); functionTableViewer.setContentProvider(new ArrayContentProvider()); functionTableViewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { IStructuredSelection iss = (IStructuredSelection) event.getSelection(); if (!iss.isEmpty()) { ProcedureFunctionDAO procedureDAO = (ProcedureFunctionDAO) iss.getFirstElement(); ProcedureExecuterManager pm = new ProcedureExecuterManager(getUserDB(), procedureDAO); if (pm.isExecuted(procedureDAO, getUserDB())) { ExecuteProcedureDialog epd = new ExecuteProcedureDialog(null, getUserDB(), procedureDAO); epd.open(); } } // end iss.isempty } }); functionFilter = new ProcedureFunctionViewFilter(); functionTableViewer.addFilter(functionFilter); sashForm.setWeights(new int[] { 1 }); // creat action createMenu(); }
From source file:com.hangum.tadpole.rdb.core.viewers.object.sub.rdb.orapackage.TadpolePackageComposite.java
License:Open Source License
/** * package procedure function list//from w w w. j a va2 s .co m */ protected void createProcedureFunctionListColumne(final TableViewer tv) { String[] name = { "Type", "Name" }; int[] size = { 120, 300 }; for (int i = 0; i < name.length; i++) { TableViewerColumn packageProcFuncColumn = new TableViewerColumn(tv, SWT.LEFT); packageProcFuncColumn.getColumn().setText(name[i]); packageProcFuncColumn.getColumn().setWidth(size[i]); packageProcFuncColumn.getColumn().addSelectionListener(getSelectionAdapter(packageProcFuncColumn, i)); } packageProcFuncViewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { IStructuredSelection iss = (IStructuredSelection) event.getSelection(); if (!iss.isEmpty()) { ProcedureFunctionDAO procedureDAO = (ProcedureFunctionDAO) iss.getFirstElement(); ProcedureExecuterManager pm = new ProcedureExecuterManager(getUserDB(), procedureDAO); if (pm.isExecuted(procedureDAO, getUserDB())) { ExecuteProcedureDialog epd = new ExecuteProcedureDialog(null, getUserDB(), procedureDAO); epd.open(); } } // end iss.isempty } }); }
From source file:com.hangum.tadpole.rdb.core.viewers.object.sub.rdb.procedure.TadpoleProcedureComposite.java
License:Open Source License
private void createWidget(final CTabFolder tabFolderObject) { CTabItem tbtmProcedures = new CTabItem(tabFolderObject, SWT.NONE); tbtmProcedures.setText("Procedures"); //$NON-NLS-1$ Composite compositeIndexes = new Composite(tabFolderObject, SWT.NONE); tbtmProcedures.setControl(compositeIndexes); GridLayout gl_compositeIndexes = new GridLayout(1, false); gl_compositeIndexes.verticalSpacing = 2; gl_compositeIndexes.horizontalSpacing = 2; gl_compositeIndexes.marginHeight = 2; gl_compositeIndexes.marginWidth = 2; compositeIndexes.setLayout(gl_compositeIndexes); SashForm sashForm = new SashForm(compositeIndexes, SWT.NONE); sashForm.setOrientation(SWT.VERTICAL); sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); // SWT.VIRTUAL ? FILTER ? ?? ? . procedureTableViewer = new TableViewer(sashForm, SWT.BORDER | SWT.FULL_SELECTION); Table tableTableList = procedureTableViewer.getTable(); tableTableList.setLinesVisible(true); tableTableList.setHeaderVisible(true); procedureTableViewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { IStructuredSelection iss = (IStructuredSelection) event.getSelection(); if (!iss.isEmpty()) { ProcedureFunctionDAO procedureDAO = (ProcedureFunctionDAO) iss.getFirstElement(); ProcedureExecuterManager pm = new ProcedureExecuterManager(getUserDB(), procedureDAO); if (pm.isExecuted(procedureDAO, getUserDB())) { ExecuteProcedureDialog epd = new ExecuteProcedureDialog(null, getUserDB(), procedureDAO); epd.open();//from w ww. j av a 2 s. com } } // end iss.isempty } }); procedureComparator = new ProcedureFunctionComparator(); procedureTableViewer.setSorter(procedureComparator); procedureComparator.setColumn(0); createProcedureFunctionColumn(procedureTableViewer, procedureComparator); procedureTableViewer.setLabelProvider(new ProcedureFunctionLabelProvicer()); procedureTableViewer.setContentProvider(new ArrayContentProvider()); procedureFilter = new ProcedureFunctionViewFilter(); procedureTableViewer.addFilter(procedureFilter); sashForm.setWeights(new int[] { 1 }); // creat action createMenu(); }
From source file:com.hangum.tadpole.rdb.core.viewers.object.sub.rdb.sysnonym.TadpoleSynonymComposite.java
License:Open Source License
/** * create Table menu/* w w w.jav a 2 s. c om*/ */ private void createSynonymMenu() { deleteAction_Synonym = new ObjectDeleteAction(getSite().getWorkbenchWindow(), PublicTadpoleDefine.DB_ACTION.SYNONYM, "Synonym"); //$NON-NLS-1$ refreshAction_Synonym = new ObjectRefreshAction(getSite().getWorkbenchWindow(), PublicTadpoleDefine.DB_ACTION.SYNONYM, "Synonym"); //$NON-NLS-1$ executeAction = new ObjectExecuteProcedureAction(getSite().getWorkbenchWindow(), PublicTadpoleDefine.DB_ACTION.SYNONYM, "Synonym"); viewDDLAction = new GenerateViewDDLAction(getSite().getWorkbenchWindow(), PublicTadpoleDefine.DB_ACTION.SYNONYM, "View"); //$NON-NLS-1$ // menu final MenuManager menuMgr = new MenuManager("#PopupMenu", "Synonym"); //$NON-NLS-1$ menuMgr.setRemoveAllWhenShown(true); menuMgr.addMenuListener(new IMenuListener() { @Override public void menuAboutToShow(IMenuManager manager) { if (userDB != null) { IStructuredSelection is = (IStructuredSelection) synonymListViewer.getSelection(); manager.add(deleteAction_Synonym); manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); manager.add(refreshAction_Synonym); if (!is.isEmpty()) { manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); OracleSynonymDAO synonymDAO = (OracleSynonymDAO) is.getFirstElement(); if (synonymDAO.getObject_type().startsWith("PROCEDURE") || synonymDAO.getObject_type().startsWith("FUNCTION")) { viewDDLAction.setEnabled(true); executeAction.setEnabled(true); manager.add(viewDDLAction); manager.add(executeAction); } else if (synonymDAO.getObject_type().startsWith("PACKAGE") || synonymDAO.getObject_type().startsWith("VIEW") || synonymDAO.getObject_type().startsWith("TABLE")) { viewDDLAction.setEnabled(true); manager.add(viewDDLAction); } } } } }); synonymListViewer.getTable().setMenu(menuMgr.createContextMenu(synonymListViewer.getTable())); getSite().registerContextMenu(menuMgr, synonymListViewer); }
From source file:com.hangum.tadpole.rdb.core.viewers.object.sub.rdb.table.DragListener.java
License:Open Source License
@Override public void dragSetData(DragSourceEvent event) { IStructuredSelection iss = (IStructuredSelection) viewer.getSelection(); if (!iss.isEmpty()) { // Table table = viewer.getTable(); // if( table.getSelectionCount() == 0) return; // event.data = table.getSelection()[0].getText(); TableDAO td = (TableDAO) iss.getFirstElement(); event.data = userDB.getSeq() + PublicTadpoleDefine.DELIMITER + td.getName(); }/*from www. j a va 2 s . co m*/ }
From source file:com.hangum.tadpole.rdb.core.viewers.object.sub.rdb.table.TableDragListener.java
License:Open Source License
@Override public void dragSetData(DragSourceEvent event) { IStructuredSelection iss = (IStructuredSelection) viewer.getSelection(); if (!iss.isEmpty()) { TableDAO td = (TableDAO) iss.getFirstElement(); if (userDB.getDbms_types().equals(DBDefine.SQLite_DEFAULT)) { event.data = userDB.getSeq() + PublicTadpoleDefine.DELIMITER + td.getName() + PublicTadpoleDefine.DELIMITER + ""; } else {/*from w ww .j a v a 2 s . c om*/ event.data = userDB.getSeq() + PublicTadpoleDefine.DELIMITER + td.getName() + PublicTadpoleDefine.DELIMITER + td.getComment(); } } }