use of com.cubrid.common.ui.query.editor.QueryEditorPart in project cubrid-manager by CUBRID.
the class ApplicationWorkbenchWindowAdvisor method preWindowShellClose.
/**
* Performs arbitrary actions as the window's shell is being closed
* directly, and possibly veto the close.
*
* @return <code>true</code> to allow the window to close, and
* <code>false</code> to prevent the window from closing
* @see org.eclipse.ui.IWorkbenchWindow#close
* @see WorkbenchAdvisor#preShutdown()
*/
public boolean preWindowShellClose() {
Shell shell = getWindowConfigurer().getWindow().getShell();
GeneralPreference.setMaximizeWindowOnStartUp(shell.getMaximized());
if (timer != null) {
timer.cancel();
HeartBeatTaskManager.getInstance().cancel();
}
/*Close the information window*/
InfoWindowManager.dispose();
/*All opened queryEditor*/
List<QueryEditorPart> editorPartList = QueryEditorUtil.getAllQueryEditorPart();
boolean isNeedSaveQueryEditor = isNeedSaveQueryEditor(editorPartList);
boolean hasJobRunning = false;
final JobFamily jobFamily = new JobFamily();
jobFamily.setServerName(JobFamily.ALL_SERVER);
Job[] jobs = Job.getJobManager().find(jobFamily);
if (jobs.length > 0) {
hasJobRunning = true;
}
boolean isExit = false;
if (hasJobRunning) {
isExit = CommonUITool.openConfirmBox(getWindowConfigurer().getWindow().getShell(), Messages.msgExistConfirmWithJob);
if (isExit) {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
try {
Job.getJobManager().cancel(jobFamily);
} catch (Exception e) {
LOGGER.error("Stopping background jobs was failed.", e);
}
}
});
if (isNeedSaveQueryEditor) {
processSaveQueryEditor();
}
}
} else {
if (isNeedSaveQueryEditor) {
processSaveQueryEditor();
return true;
} else {
if (GeneralPreference.isAlwaysExit()) {
return true;
}
MessageDialogWithToggle dialog = MessageDialogWithToggle.openOkCancelConfirm(getWindowConfigurer().getWindow().getShell(), com.cubrid.common.ui.common.Messages.titleExitConfirm, Messages.msgExistConfirm, com.cubrid.common.ui.common.Messages.msgToggleExitConfirm, false, CommonUIPlugin.getDefault().getPreferenceStore(), GeneralPreference.IS_ALWAYS_EXIT);
isExit = dialog.getReturnCode() == 0 ? true : false;
}
}
return isExit;
}
use of com.cubrid.common.ui.query.editor.QueryEditorPart in project cubrid-manager by CUBRID.
the class OpenQueryAction method run.
public void run() {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return;
}
String fileName = null;
try {
SetFileEncodingDialog dialog = new SetFileEncodingDialog(getShell(), StringUtil.getDefaultCharset(), true);
if (IDialogConstants.OK_ID != dialog.open()) {
return;
}
fileName = dialog.getFilePath();
IEditorPart editor = window.getActivePage().openEditor(new QueryUnit(), QueryEditorPart.ID);
if (editor == null) {
return;
}
QueryEditorPart queryEditor = (QueryEditorPart) editor;
queryEditor.getCombinedQueryComposite().getSqlEditorComp().open(dialog.getFilePath(), dialog.getEncoding());
Object[] obj = this.getSelectedObj();
CubridDatabase[] cubridDatabases = handleSelectionObj(obj);
if (cubridDatabases.length > 0 && cubridDatabases[0] != null) {
((QueryEditorPart) editor).connect(cubridDatabases[0]);
}
} catch (PartInitException e) {
LOGGER.error("Can not initialize the query editor UI.", e);
} catch (IOException e) {
LOGGER.error("Can not open the {} file.", fileName, e);
//TODO: message localizing
CommonUITool.openErrorBox(e.getMessage());
}
}
use of com.cubrid.common.ui.query.editor.QueryEditorPart in project cubrid-manager by CUBRID.
the class BrokerLogParserAction method run.
public void run() {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return;
}
BrokerLogParserDialog dialog = new BrokerLogParserDialog(window.getShell());
dialog.open();
if (dialog.getReturnCode() != IDialogConstants.OK_ID) {
return;
}
String sql = dialog.getResultSql();
try {
QueryUnit input = new QueryUnit();
QueryEditorPart editor = (QueryEditorPart) window.getActivePage().openEditor(input, QueryEditorPart.ID);
editor.setQuery(sql, false, false, false);
} catch (PartInitException e) {
LOGGER.debug("Failed sql is {}.", sql);
LOGGER.error("Can not parse broker sql log.", e);
}
}
use of com.cubrid.common.ui.query.editor.QueryEditorPart in project cubrid-manager by CUBRID.
the class OpenTargetAction method showObjectInfo.
public void showObjectInfo(DefaultSchemaNode table) {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return;
}
try {
QueryEditorPart queryEditPart = null;
IEditorPart editorPart = window.getActivePage().getActiveEditor();
if (editorPart != null && editorPart instanceof QueryEditorPart) {
QueryEditorPart activeQueryEditorPart = (QueryEditorPart) editorPart;
if (table.getDatabase().equals(activeQueryEditorPart.getSelectedDatabase())) {
queryEditPart = activeQueryEditorPart;
}
}
if (queryEditPart != null) {
queryEditPart.getCombinedQueryComposite().createObjInfoFolder(table);
window.getActivePage().activate(queryEditPart);
} else {
QueryUnit input = new QueryUnit();
input.setDatabase(table.getDatabase());
queryEditPart = (QueryEditorPart) window.getActivePage().openEditor(input, QueryEditorPart.ID);
queryEditPart.connect(table.getDatabase());
queryEditPart.getCombinedQueryComposite().createObjInfoFolder(table);
}
} catch (PartInitException e) {
LOGGER.error("Can not initialize the query editor UI.", e);
}
}
use of com.cubrid.common.ui.query.editor.QueryEditorPart in project cubrid-manager by CUBRID.
the class RestoreQueryEditorAction method run.
public void run() {
ApplicationPersistUtil util = ApplicationPersistUtil.getInstance();
List<ArrayList<RestorableQueryEditorInfo>> restoreList = util.getEditorStatusListAtLastSession();
if (restoreList == null || restoreList.size() == 0) {
CommonUITool.openInformationBox(Messages.errNoRestoreQueryEditor);
return;
}
if (!CommonUITool.openConfirmBox(Messages.restoreQueryEditorConfirm)) {
return;
}
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
CommonUITool.openErrorBox(Messages.restoreQueryEditorRestoreFailed);
return;
}
for (List<RestorableQueryEditorInfo> editorStatusList : ApplicationPersistUtil.getInstance().getEditorStatusListAtLastSession()) {
QueryUnit input = new QueryUnit();
try {
QueryEditorPart editor = (QueryEditorPart) window.getActivePage().openEditor(input, QueryEditorPart.ID);
if (editor == null) {
continue;
}
for (int i = 0; i < editorStatusList.size(); i++) {
RestorableQueryEditorInfo editorStatus = editorStatusList.get(i);
if (editorStatus == null) {
continue;
}
String sql = CheckQueryEditorTask.getQuery(editorStatus);
CombinedQueryEditorComposite combinedQueryComposite = null;
if (i == 0) {
combinedQueryComposite = editor.getCombinedQueryComposite();
} else {
combinedQueryComposite = editor.addEditorTab();
}
if (combinedQueryComposite != null) {
combinedQueryComposite.getSqlEditorComp().setQueries(sql);
}
}
editor.setCombinedQueryEditortabFolderSelecton(0);
} catch (PartInitException e) {
e.printStackTrace();
}
}
ApplicationPersistUtil.getInstance().clearRestorableQueryEditors();
StatusLineContrItem statusCont = LayoutManager.getInstance().getStatusLineContrItem();
statusCont.changeStuatusLineForNavigator(null);
CommonUITool.openInformationBox(Messages.restoreQueryEditorTitle, Messages.restoreQueryEditorRestoreSuccess);
}
Aggregations