use of com.cubrid.common.ui.spi.persist.ApplicationPersistUtil 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