use of com.cubrid.common.ui.query.editor.QueryEditorPart in project cubrid-manager by CUBRID.
the class GotoLineDialog method getActiveSQLEditorComposite.
/**
*
* Get active SQL editor composite
*
* @return SQLEditorComposite
*/
private SQLEditorComposite getActiveSQLEditorComposite() {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IEditorPart editor = window.getActivePage().getActiveEditor();
if (editor instanceof QueryEditorPart) {
QueryEditorPart queryEditor = (QueryEditorPart) editor;
return queryEditor.getCombinedQueryComposite().getSqlEditorComp();
}
return null;
}
use of com.cubrid.common.ui.query.editor.QueryEditorPart in project cubrid-manager by CUBRID.
the class BatchRunDialog method buttonPressed.
/**
* Call this method when the button in button bar is pressed
*
* @param buttonId the button id
*/
protected void buttonPressed(int buttonId) {
if (buttonId == RUN_ID) {
if (!MessageDialog.openConfirm(PlatformUI.getWorkbench().getDisplay().getActiveShell(), Messages.titleBatchRunConfirm, Messages.msgBatchRunConfirm)) {
return;
}
List<String> fileList = container.getFileList();
RunSQLFileEditorInput input = new RunSQLFileEditorInput(cubridDatabase, fileList);
try {
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(input, RunSQLFileViewPart.ID);
} catch (Exception e) {
LOGGER.error(e.getLocalizedMessage());
}
super.buttonPressed(IDialogConstants.OK_ID);
} else if (buttonId == PASTE_ID) {
// if (!MessageDialog.openConfirm(
// PlatformUI.getWorkbench().getDisplay().getActiveShell(),
// Messages.titleBatchRunConfirm, Messages.msgBatchRunPasteConfirm)) {
// return;
// }
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null || window.getActivePage() == null) {
return;
}
IEditorPart editor = window.getActivePage().getActiveEditor();
try {
if (editor == null) {
IEditorInput input = new QueryUnit();
editor = window.getActivePage().openEditor(input, QueryEditorPart.ID);
}
} catch (PartInitException e) {
CommonUITool.openErrorBox(e.getMessage());
}
if (editor == null) {
return;
}
QueryEditorPart oldEditor = (QueryEditorPart) editor;
try {
QueryEditorPart queryEditor = (QueryEditorPart) editor;
String encoding = queryEditor.getCombinedQueryComposite().getSqlEditorComp().getDocument().getEncoding();
StringBuilder sb = new StringBuilder();
List<String> fileList = container.getFileList();
for (int i = 0; i < fileList.size(); i++) {
sb.delete(0, sb.length());
sb.append("/* SQL Filename: ").append(fileList.get(i)).append(" */").append(StringUtil.NEWLINE);
BufferedReader in = null;
try {
in = new BufferedReader(new InputStreamReader(new FileInputStream(new File(fileList.get(i))), encoding));
String line = in.readLine();
while (line != null) {
sb.append(line + StringUtil.NEWLINE);
line = in.readLine();
}
} finally {
try {
if (in != null) {
in.close();
}
} catch (IOException e) {
}
}
try {
QueryUnit input = new QueryUnit();
QueryEditorPart newEditor = (QueryEditorPart) window.getActivePage().openEditor(input, QueryEditorPart.ID);
newEditor.setQuery(sb.toString(), false, false, false);
newEditor.connect(oldEditor.getSelectedDatabase());
} catch (Exception e) {
CommonUITool.openErrorBox(e.getMessage());
}
}
} catch (IOException e) {
CommonUITool.openErrorBox(e.getMessage());
}
super.buttonPressed(IDialogConstants.OK_ID);
} else {
super.buttonPressed(buttonId);
}
}
use of com.cubrid.common.ui.query.editor.QueryEditorPart in project cubrid-manager by CUBRID.
the class ReformatColumnsAliasDialog method getActiveSQLEditorComposite.
private SQLEditorComposite getActiveSQLEditorComposite() {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IEditorPart editor = window.getActivePage().getActiveEditor();
if (editor instanceof QueryEditorPart) {
QueryEditorPart queryEditor = (QueryEditorPart) editor;
return queryEditor.getCombinedQueryComposite().getSqlEditorComp();
}
return null;
}
use of com.cubrid.common.ui.query.editor.QueryEditorPart in project cubrid-manager by CUBRID.
the class LayoutUtil method checkAllQueryEditor.
/**
*
* When server disconnect or delete,check query editor whether some
* transaction are not commit
*
* @param cubridServer the CubridServer object
* @return <code>true</code> if transaction is commited;<code>false</code>
* otherwise
*/
public static boolean checkAllQueryEditor(CubridServer cubridServer) {
IWorkbenchPage page = getActivePage();
if (page == null) {
return true;
}
IEditorReference[] editorRefArr = page.getEditorReferences();
if (editorRefArr == null || editorRefArr.length == 0) {
return true;
}
boolean isContinue = true;
for (IEditorReference editorRef : editorRefArr) {
String editorId = editorRef.getId();
if (editorId != null && editorId.equals(QueryEditorPart.ID)) {
QueryEditorPart queryEditor = (QueryEditorPart) editorRef.getEditor(false);
CubridDatabase db = queryEditor.getSelectedDatabase();
if (db != null && db.getServer() != null && db.getServer().getId().equals(cubridServer.getId())) {
isContinue = queryEditor.resetJDBCConnection();
}
}
}
return isContinue;
}
use of com.cubrid.common.ui.query.editor.QueryEditorPart in project cubrid-manager by CUBRID.
the class LayoutUtil method checkAllQueryEditor.
/**
*
* When database logout or stop,check query editor whether some transaction
* are not commit
*
* @param databaseNode the CubridDatabase object
* @return <code>true</code> if transaction is commited;<code>false</code>
* otherwise
*/
public static boolean checkAllQueryEditor(CubridDatabase databaseNode) {
IWorkbenchPage page = getActivePage();
if (page == null) {
return true;
}
boolean isContinue = true;
IEditorReference[] editorRefArr = page.getEditorReferences();
if (editorRefArr == null || editorRefArr.length == 0) {
return true;
}
for (IEditorReference editorRef : editorRefArr) {
String editorId = editorRef.getId();
if (editorId != null && editorId.equals(QueryEditorPart.ID)) {
QueryEditorPart queryEditor = (QueryEditorPart) editorRef.getEditor(false);
CubridDatabase db = queryEditor.getSelectedDatabase();
if (db != null && db.getId().equals(databaseNode.getId())) {
isContinue = queryEditor.resetJDBCConnection();
}
}
}
return isContinue;
}
Aggregations