Search in sources :

Example 1 with ApplicationPersistUtil

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);
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) StatusLineContrItem(com.cubrid.common.ui.spi.contribution.StatusLineContrItem) CombinedQueryEditorComposite(com.cubrid.common.ui.query.control.CombinedQueryEditorComposite) ArrayList(java.util.ArrayList) ApplicationPersistUtil(com.cubrid.common.ui.spi.persist.ApplicationPersistUtil) QueryEditorPart(com.cubrid.common.ui.query.editor.QueryEditorPart) QueryUnit(com.cubrid.common.ui.query.editor.QueryUnit) PartInitException(org.eclipse.ui.PartInitException) RestorableQueryEditorInfo(com.cubrid.common.ui.spi.model.RestorableQueryEditorInfo)

Aggregations

CombinedQueryEditorComposite (com.cubrid.common.ui.query.control.CombinedQueryEditorComposite)1 QueryEditorPart (com.cubrid.common.ui.query.editor.QueryEditorPart)1 QueryUnit (com.cubrid.common.ui.query.editor.QueryUnit)1 StatusLineContrItem (com.cubrid.common.ui.spi.contribution.StatusLineContrItem)1 RestorableQueryEditorInfo (com.cubrid.common.ui.spi.model.RestorableQueryEditorInfo)1 ApplicationPersistUtil (com.cubrid.common.ui.spi.persist.ApplicationPersistUtil)1 ArrayList (java.util.ArrayList)1 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)1 PartInitException (org.eclipse.ui.PartInitException)1