use of com.cubrid.common.ui.cubrid.table.dialog.PstmtSQLDialog in project cubrid-manager by CUBRID.
the class SqlPstmtAction method run.
/**
* @see org.eclipse.jface.action.Action#run()
*/
public void run() {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IEditorPart editor = window.getActivePage().getActiveEditor();
if (editor instanceof QueryEditorPart) {
QueryEditorPart queryEditor = (QueryEditorPart) editor;
PstmtSQLDialog dialog = new PstmtSQLDialog(queryEditor.getSite().getShell(), queryEditor.getSelectedDatabase());
dialog.create();
dialog.setEditorInput((QueryUnit) queryEditor.getEditorInput());
String queries = queryEditor.getCombinedQueryComposite().getSqlEditorComp().getText().getSelectionText();
dialog.setSql(queries);
dialog.open();
}
}
use of com.cubrid.common.ui.cubrid.table.dialog.PstmtSQLDialog in project cubrid-manager by CUBRID.
the class InsertOneByPstmtAction method doRun.
/**
* Perform insert
* @param node
*/
private void doRun(ISchemaNode node) {
PstmtSQLDialog dialog = new PstmtSQLDialog(getShell(), node.getDatabase(), node.getName(), true);
dialog.open();
}
use of com.cubrid.common.ui.cubrid.table.dialog.PstmtSQLDialog in project cubrid-manager by CUBRID.
the class PstmtOneDataAction method run.
/**
* @see org.eclipse.jface.action.Action#run()
*/
public void run() {
Object[] obj = this.getSelectedObj();
if (!isSupported(obj)) {
setEnabled(false);
return;
}
ISchemaNode node = (ISchemaNode) obj[0];
//modify to deal with muti data dialog
PstmtSQLDialog dialog = new PstmtSQLDialog(getShell(), node.getDatabase());
dialog.create();
dialog.open();
}
use of com.cubrid.common.ui.cubrid.table.dialog.PstmtSQLDialog in project cubrid-manager by CUBRID.
the class QueryEditorPart method fillInToolbar.
public void fillInToolbar() {
qeToolBar.addDatabaseChangedListener(new Listener() {
public void handleEvent(Event event) {
Object data = event.data;
if (data instanceof CubridDatabase) {
CubridDatabase database = (CubridDatabase) data;
if (database == DatabaseNavigatorMenu.NULL_DATABASE) {
resetJDBCConnection();
} else {
initConnection(database);
}
ServerInfo serverInfo = database.getServer() == null ? null : database.getServer().getServerInfo();
boolean autoCommit = QueryOptions.getAutoCommit(serverInfo);
setAutocommit(autoCommit);
}
}
});
final ToolBar toolBar = qeToolBar;
// [TOOLS-2425]Support shard broker
changeShardIdValItem = new ToolItem(toolBar, SWT.PUSH);
changeShardIdValItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/change_shard_id.png"));
changeShardIdValItem.setDisabledImage(CommonUIPlugin.getImage("icons/queryeditor/change_shard_id_disabled.png"));
changeShardIdValItem.setToolTipText(Messages.changeShardId);
changeShardIdValItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
CubridDatabase cubridDatabase = getSelectedDatabase();
if (cubridDatabase != null) {
DatabaseInfo dbInfo = cubridDatabase.getDatabaseInfo();
if (dbInfo != null && dbInfo.isShard()) {
ShardIdSelectionDialog dialog = new ShardIdSelectionDialog(Display.getDefault().getActiveShell());
dialog.setDatabaseInfo(dbInfo);
dialog.setShardId(shardId);
dialog.setShardVal(shardVal);
dialog.setShardQueryType(shardQueryType);
if (dialog.open() == IDialogConstants.OK_ID) {
shardId = dialog.getShardId();
shardVal = dialog.getShardVal();
shardQueryType = dialog.getShardQueryType();
changeQueryEditorPartNameWithShard();
}
}
}
}
});
CubridDatabase cubridDatabase = getSelectedDatabase();
if (cubridDatabase == null || CubridDatabase.hasValidDatabaseInfo(cubridDatabase) && cubridDatabase.getDatabaseInfo().isShard()) {
changeShardIdValItem.setEnabled(false);
}
new ToolItem(toolBar, SWT.SEPARATOR);
runItem = new ToolItem(toolBar, SWT.PUSH);
runItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_run.png"));
runItem.setDisabledImage(CommonUIPlugin.getImage("icons/queryeditor/query_run_disabled.png"));
runItem.setToolTipText(Messages.run + "(F5)");
runItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
hideToolTip();
runQuery(false);
}
});
multiRunItem = new ToolItem(toolBar, SWT.PUSH);
multiRunItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_multi_run.png"));
multiRunItem.setToolTipText(Messages.runMultiQuery + "(F8)");
multiRunItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
changeMultiQueryMode();
}
});
queryPlanItem = new ToolItem(toolBar, SWT.PUSH);
queryPlanItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_execution_plan.png"));
queryPlanItem.setToolTipText(Messages.queryPlanTip + "(F6)");
queryPlanItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
hideToolTip();
runQuery(true);
}
});
ToolItem historyItem = new ToolItem(toolBar, SWT.PUSH);
historyItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_history.png"));
historyItem.setToolTipText(Messages.queryHistory + "(F7)");
historyItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
hideToolTip();
getCombinedQueryComposite().select(2, -1);
}
});
setPstmtParaItem = new ToolItem(toolBar, SWT.PUSH);
setPstmtParaItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_set_param.png"));
setPstmtParaItem.setToolTipText(Messages.tipSetPstmt);
setPstmtParaItem.setEnabled(false);
setPstmtParaItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
hideToolTip();
if (combinedQueryComposite.getSqlEditorComp().isDisposed()) {
return;
}
PstmtSQLDialog dialog = new PstmtSQLDialog(getSite().getShell(), getSelectedDatabase());
dialog.create();
dialog.setEditorInput((QueryUnit) getEditorInput());
String queries = getSelectedText();
dialog.setSql(queries);
dialog.open();
}
});
tuneModeItem = new ToolItem(toolBar, SWT.CHECK);
tuneModeItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/tune_mode.png"));
tuneModeItem.setToolTipText(Messages.tipExecStat + "(F9)");
tuneModeItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
hideToolTip();
boolean isTuneMode = tuneModeItem.getSelection();
changeCollectExecStats(isTuneMode);
if (isTuneMode) {
showToolTip(qeToolBar, tuneModeItem, Messages.ttQeToolbarTuneModeTitle, Messages.ttQeToolbarTuneModeMSg);
} else {
hideToolTip();
}
}
});
new ToolItem(toolBar, SWT.SEPARATOR);
final ToolItem addEditorItem = new ToolItem(toolBar, SWT.PUSH);
addEditorItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/tab_item_add.png"));
addEditorItem.setToolTipText(Messages.queryEditorAddTabItemTooltip + "(Ctrl+Shift+T)");
addEditorItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
hideToolTip();
addEditorTab();
}
});
new ToolItem(toolBar, SWT.SEPARATOR);
runBatchItem = new ToolItem(toolBar, SWT.PUSH);
runBatchItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/run_batch_sql.png"));
runBatchItem.setToolTipText(Messages.batchRun);
runBatchItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
hideToolTip();
try {
// FIXME extract utility
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IViewPart view = page.findView(FavoriteQueryNavigatorView.ID);
if (view != null) {
page.hideView(view);
} else {
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(FavoriteQueryNavigatorView.ID, null, IWorkbenchPage.VIEW_ACTIVATE);
}
} catch (PartInitException e) {
LOGGER.error(e.getMessage(), e);
}
}
});
new ToolItem(toolBar, SWT.SEPARATOR);
ToolItem itemFormatterr = new ToolItem(toolBar, SWT.PUSH);
itemFormatterr.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_format.png"));
itemFormatterr.setToolTipText(Messages.formatTip + "(Ctrl+Shift+F)");
itemFormatterr.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
hideToolTip();
combinedQueryComposite.getSqlEditorComp().format();
}
});
ToolItem itemIndent = new ToolItem(toolBar, SWT.PUSH);
itemIndent.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_indent_add.png"));
itemIndent.setToolTipText(Messages.indentTip + "(Tab)");
itemIndent.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
hideToolTip();
if (combinedQueryComposite.getSqlEditorComp().isDisposed()) {
return;
}
combinedQueryComposite.getSqlEditorComp().indent();
}
});
ToolItem itemUnindent = new ToolItem(toolBar, SWT.PUSH);
itemUnindent.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_indent_delete.png"));
itemUnindent.setToolTipText(Messages.unIndentTip + "(Shift+Tab)");
itemUnindent.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
hideToolTip();
if (combinedQueryComposite.getSqlEditorComp().isDisposed()) {
return;
}
combinedQueryComposite.getSqlEditorComp().unindent();
}
});
ToolItem clearItem = new ToolItem(toolBar, SWT.PUSH);
clearItem.setImage(CommonUIPlugin.getImage("/icons/queryeditor/clear_sql.png"));
clearItem.setToolTipText(Messages.clear);
clearItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
hideToolTip();
if (combinedQueryComposite.getSqlEditorComp().isDisposed()) {
return;
}
if (!CommonUITool.openConfirmBox(Messages.msgClear)) {
return;
}
combinedQueryComposite.getSqlEditorComp().setQueries("");
}
});
new ToolItem(toolBar, SWT.SEPARATOR);
ToolItem itemComment = new ToolItem(toolBar, SWT.PUSH);
itemComment.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_comment_add.png"));
itemComment.setToolTipText(Messages.commentTip + "(Ctrl+/)");
itemComment.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
hideToolTip();
if (combinedQueryComposite.getSqlEditorComp().isDisposed()) {
return;
}
combinedQueryComposite.getSqlEditorComp().comment();
}
});
ToolItem itemUncomment = new ToolItem(toolBar, SWT.PUSH);
itemUncomment.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_comment_delete.png"));
itemUncomment.setToolTipText(Messages.unCommentTip + "(Ctrl+/)");
itemUncomment.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
hideToolTip();
if (combinedQueryComposite.getSqlEditorComp().isDisposed()) {
return;
}
combinedQueryComposite.getSqlEditorComp().uncomment();
}
});
new ToolItem(toolBar, SWT.SEPARATOR);
commitItem = new ToolItem(toolBar, SWT.PUSH);
commitItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_commit.png"));
commitItem.setDisabledImage(CommonUIPlugin.getImage("icons/queryeditor/query_commit_disabled.png"));
commitItem.setToolTipText(Messages.commit);
commitItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
hideToolTip();
commit();
}
});
commitItem.setEnabled(false);
rollbackItem = new ToolItem(toolBar, SWT.PUSH);
rollbackItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_rollback.png"));
rollbackItem.setDisabledImage(CommonUIPlugin.getImage("icons/queryeditor/query_rollback_disabled.png"));
rollbackItem.setToolTipText(Messages.rollback);
rollbackItem.setEnabled(false);
rollbackItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
hideToolTip();
rollback();
}
});
autoCommitItem = new ToolItem(toolBar, SWT.CHECK);
autoCommitItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_auto_false.png"));
autoCommitItem.setToolTipText(Messages.autoCommit);
autoCommitItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
hideToolTip();
if (checkActive()) {
return;
}
setAutocommit(autoCommitItem.getSelection());
if (connection != null) {
try {
connection.setAutoCommit(isAutocommit());
} catch (SQLException e) {
}
}
}
});
setAutocommit(true);
new ToolItem(toolBar, SWT.SEPARATOR);
ToolItem openItem = new ToolItem(toolBar, SWT.PUSH);
openItem.setImage(CommonUIPlugin.getImage("/icons/queryeditor/file_open.png"));
openItem.setToolTipText(Messages.open);
openItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
hideToolTip();
doOpen();
}
});
ToolItem saveItem = new ToolItem(toolBar, SWT.PUSH);
saveItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/file_save.png"));
saveItem.setToolTipText(Messages.save);
saveItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
hideToolTip();
doSave(new NullProgressMonitor());
}
});
ToolItem saveAsItem = new ToolItem(toolBar, SWT.PUSH);
saveAsItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/file_saveas.png"));
saveAsItem.setToolTipText(Messages.saveAs);
saveAsItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
hideToolTip();
doSaveAs();
}
});
//Fill in the show or hide result pane tool item
new ToolItem(toolBar, SWT.SEPARATOR);
showResultItem = new ToolItem(toolBar, SWT.PUSH);
showResultItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_panel_down.png"));
showResultItem.setToolTipText(Messages.tooltip_qedit_result_show_hide);
showResultItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
hideToolTip();
CTabFolder resultTabFolder = combinedQueryComposite.getResultTabFolder();
SashForm topSash = combinedQueryComposite.getTopSash();
if (resultTabFolder.getMinimized()) {
resultTabFolder.setMinimized(false);
resultTabFolder.setMaximized(false);
topSash.setMaximizedControl(null);
showResultItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_panel_down.png"));
topSash.layout(true);
} else if (!resultTabFolder.getMaximized() && !resultTabFolder.getMinimized()) {
resultTabFolder.setMinimized(true);
topSash.setMaximizedControl(combinedQueryComposite.getSqlEditorComp().getParent());
showResultItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_panel_up.png"));
topSash.layout(true);
}
}
});
topComposite.pack();
packToolBar();
}
Aggregations