Search in sources :

Example 31 with DefaultSchemaNode

use of com.cubrid.common.ui.spi.model.DefaultSchemaNode in project cubrid-manager by CUBRID.

the class QueryPlanCompositeWithHistory method createPlanToolbar.

private void createPlanToolbar() {
    Composite toolBarComposite = new Composite(this, SWT.NONE);
    GridLayout gridLayout = new GridLayout(2, false);
    gridLayout.verticalSpacing = 0;
    gridLayout.horizontalSpacing = 10;
    gridLayout.marginWidth = 0;
    gridLayout.marginHeight = 0;
    toolBarComposite.setLayout(gridLayout);
    toolBarComposite.setLayoutData(new GridData(SWT.FILL, SWT.NONE, false, false));
    ToolBar toolBar = new ToolBar(toolBarComposite, SWT.FLAT | SWT.RIGHT);
    dispModeTextItem = new ToolItem(toolBar, SWT.CHECK);
    dispModeTextItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_explain_mode_raw.png"));
    dispModeTextItem.setToolTipText(Messages.tooltip_qedit_explain_display_mode + "(F11)");
    dispModeTextItem.setText(Messages.lblPlanRawBtn);
    dispModeTextItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            showSelectedPlan(PLAN_DISPLAY_MODE.TEXT.getInt());
        }
    });
    new ToolItem(toolBar, SWT.SEPARATOR);
    dispModeTreeItem = new ToolItem(toolBar, SWT.CHECK);
    dispModeTreeItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_explain_mode_tree.png"));
    dispModeTreeItem.setToolTipText(Messages.tooltip_qedit_explain_display_mode + "(F11)");
    dispModeTreeItem.setText(Messages.lblPlanTreeBtn);
    dispModeTreeItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            showSelectedPlan(PLAN_DISPLAY_MODE.TREE.getInt());
        }
    });
    new ToolItem(toolBar, SWT.SEPARATOR);
    dispModeGraphItem = new ToolItem(toolBar, SWT.CHECK);
    dispModeGraphItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_explain_mode_graph.png"));
    dispModeGraphItem.setToolTipText(Messages.tooltip_qedit_explain_display_mode + "(F11)");
    dispModeGraphItem.setText(Messages.lblPlanGraph);
    dispModeGraphItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            showSelectedPlan(PLAN_DISPLAY_MODE.GRAPH.getInt());
        }
    });
    new ToolItem(toolBar, SWT.SEPARATOR);
    editTableItem = new ToolItem(toolBar, SWT.None);
    editTableItem.setImage(CommonUIPlugin.getImage("icons/navigator/schema_table_item.png"));
    editTableItem.setText(Messages.lblPlanEditTable);
    editTableItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            QueryPlanComposite comp = getSelectedQueryPlanComposite();
            String tableName = comp.getSelectedTable();
            if (StringUtil.isEmpty(tableName)) {
                CommonUITool.openErrorBox(Messages.msgPlanEditTable);
                return;
            }
            ISchemaNode node = new DefaultSchemaNode(tableName, tableName, null);
            node.setDatabase(editor.getSelectedDatabase());
            EditTableAction action = (EditTableAction) ActionManager.getInstance().getAction(EditTableAction.ID);
            if (action == null) {
                CommonUITool.openErrorBox(Messages.errPlanEditNoAction);
                return;
            }
            action.run((ISchemaNode) node);
        }
    });
    editIndexItem = new ToolItem(toolBar, SWT.None);
    editIndexItem.setImage(CommonUIPlugin.getImage("icons/navigator/table_index_item.png"));
    editIndexItem.setText(Messages.lblPlanEditIndex);
    editIndexItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            QueryPlanComposite comp = getSelectedQueryPlanComposite();
            String tableName = comp.getSelectedTable();
            //				String indexName = comp.getSelectedIndex();
            if (StringUtil.isEmpty(tableName)) {
                CommonUITool.openErrorBox(Messages.msgPlanEditIndex);
                return;
            }
            ISchemaNode node = new DefaultSchemaNode(tableName, tableName, null);
            node.setDatabase(editor.getSelectedDatabase());
            EditTableAction action = (EditTableAction) ActionManager.getInstance().getAction(EditTableAction.ID);
            if (action == null) {
                CommonUITool.openErrorBox(Messages.errPlanEditNoAction);
                return;
            }
            action.editIndexMode((ISchemaNode) node);
        }
    });
    ToolItem comparePlanItem = new ToolItem(toolBar, SWT.None);
    comparePlanItem.setImage(CommonUIPlugin.getImage("icons/queryplan/use_compare_queryplan.png"));
    comparePlanItem.setText(Messages.lblComparePlan);
    comparePlanItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            QueryPlanComposite comp = getSelectedQueryPlanComposite();
            StructQueryPlan sq = comp.getQueryPlan();
            TuneModeModel tuneModeModel = new TuneModeModel(sq, null);
            editor.displayTuneModeResult(tuneModeModel);
        }
    });
    ToolBar delHistoryToolBar = new ToolBar(toolBarComposite, SWT.FLAT);
    delHistoryToolBar.setLayoutData(new GridData(SWT.END, SWT.CENTER, true, true));
    // Show/hide of the history pane
    historyShowHideItem = new ToolItem(delHistoryToolBar, SWT.PUSH);
    historyShowHideItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_explain_history_hide.png"));
    historyShowHideItem.setToolTipText(Messages.tooltip_qedit_explain_history_show_hide);
    historyShowHideItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            boolean isShow = !planHistoryTable.getVisible();
            if (isShow) {
                showHistoryPane();
            } else {
                hideHistoryPane();
            }
        }
    });
    new ToolItem(delHistoryToolBar, SWT.SEPARATOR);
    // Collecting histories switch
    historySwitchItem = new ToolItem(delHistoryToolBar, SWT.CHECK);
    historySwitchItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_explain_history_switch.png"));
    historySwitchItem.setToolTipText(Messages.tooltip_qedit_explain_history_switch);
    historySwitchItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            collectToHistoryFlag = !historySwitchItem.getSelection();
        }
    });
    historySwitchItem.setSelection(true);
    new ToolItem(delHistoryToolBar, SWT.SEPARATOR);
    delHistory = new ToolItem(delHistoryToolBar, SWT.PUSH);
    delHistory.setImage(CommonUIPlugin.getImage("icons/action/table_record_delete.png"));
    delHistory.setDisabledImage(CommonUIPlugin.getImage("icons/action/table_record_delete_disabled.png"));
    delHistory.setToolTipText(Messages.tooltip_qedit_explain_history_delete);
    delHistory.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            if (planHistoryTable.getSelectionIndices().length == 0) {
                MessageDialog.openError(PlatformUI.getWorkbench().getDisplay().getActiveShell(), Messages.error, Messages.explain_history_delete_error);
                return;
            }
            deleteHistory();
        }
    });
}
Also used : Composite(org.eclipse.swt.widgets.Composite) QueryPlanComposite(com.cubrid.common.ui.query.control.queryplan.QueryPlanComposite) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) EditTableAction(com.cubrid.common.ui.cubrid.table.action.EditTableAction) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) QueryPlanComposite(com.cubrid.common.ui.query.control.queryplan.QueryPlanComposite) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode) TuneModeModel(com.cubrid.common.ui.query.control.tunemode.TuneModeModel) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) ToolBar(org.eclipse.swt.widgets.ToolBar) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ToolItem(org.eclipse.swt.widgets.ToolItem) StructQueryPlan(com.cubrid.common.core.queryplan.StructQueryPlan)

Example 32 with DefaultSchemaNode

use of com.cubrid.common.ui.spi.model.DefaultSchemaNode in project cubrid-manager by CUBRID.

the class CubridSPFolderLoader method load.

/**
	 * 
	 * Load children object for parent
	 * 
	 * @param parent the parent node
	 * @param monitor the IProgressMonitor object
	 */
public void load(ICubridNode parent, final IProgressMonitor monitor) {
    synchronized (this) {
        if (isLoaded()) {
            return;
        }
        CubridDatabase database = ((ISchemaNode) parent).getDatabase();
        if (!database.isLogined() || database.getRunningType() == DbRunningType.STANDALONE) {
            parent.removeAllChild();
            CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
            return;
        }
        // add function folder
        String functionFolderId = parent.getId() + NODE_SEPARATOR + FUNCTION_FOLDER_ID;
        ICubridNode functionFolder = parent.getChild(functionFolderId);
        if (functionFolder == null) {
            functionFolder = new DefaultSchemaNode(functionFolderId, FUNCTION_FOLDER_NAME, "icons/navigator/folder.png");
            functionFolder.setType(NodeType.STORED_PROCEDURE_FUNCTION_FOLDER);
            functionFolder.setContainer(true);
            ICubridNodeLoader loader = new CubridFunctionFolderLoader();
            loader.setLevel(getLevel());
            functionFolder.setLoader(loader);
            parent.addChild(functionFolder);
            if (getLevel() == DEFINITE_LEVEL) {
                functionFolder.getChildren(monitor);
            }
        } else {
            if (functionFolder.getLoader() != null && functionFolder.getLoader().isLoaded()) {
                functionFolder.getLoader().setLoaded(false);
                functionFolder.getChildren(monitor);
            }
        }
        // add procedure folder
        String procedureFolderId = parent.getId() + NODE_SEPARATOR + PROCEDURE_FOLDER_ID;
        ICubridNode procedureFolder = parent.getChild(procedureFolderId);
        if (procedureFolder == null) {
            procedureFolder = new DefaultSchemaNode(procedureFolderId, PROCEDURE_FOLDER_NAME, "icons/navigator/folder.png");
            procedureFolder.setType(NodeType.STORED_PROCEDURE_PROCEDURE_FOLDER);
            procedureFolder.setContainer(true);
            ICubridNodeLoader loader = new CubridProcedureFolderLoader();
            loader.setLevel(getLevel());
            procedureFolder.setLoader(loader);
            parent.addChild(procedureFolder);
            if (getLevel() == DEFINITE_LEVEL) {
                procedureFolder.getChildren(monitor);
            }
        } else {
            if (procedureFolder.getLoader() != null && procedureFolder.getLoader().isLoaded()) {
                procedureFolder.getLoader().setLoaded(false);
                procedureFolder.getChildren(monitor);
            }
        }
        setLoaded(true);
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
    }
}
Also used : ICubridNodeLoader(com.cubrid.common.ui.spi.model.ICubridNodeLoader) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode)

Example 33 with DefaultSchemaNode

use of com.cubrid.common.ui.spi.model.DefaultSchemaNode in project cubrid-manager by CUBRID.

the class CubridUserTableColumnLoader method load.

/**
	 * 
	 * Load children object for parent
	 * 
	 * @param parent the parent node
	 * @param monitor the IProgressMonitor object
	 */
public void load(ICubridNode parent, final IProgressMonitor monitor) {
    synchronized (this) {
        if (isLoaded()) {
            return;
        }
        CubridDatabase database = ((ISchemaNode) parent).getDatabase();
        if (!database.isLogined() || database.getRunningType() == DbRunningType.STANDALONE) {
            parent.removeAllChild();
            CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
            return;
        }
        if (columns == null && !getColumns(parent, monitor, database)) {
            return;
        }
        if (monitor.isCanceled()) {
            columns = null;
            setLoaded(true);
            return;
        }
        parent.removeAllChild();
        String parentId = parent.getId();
        if (columns != null && !columns.isEmpty()) {
            for (TableColumn column : columns) {
                String label = column.getColumnName() + ",";
                label += FieldHandlerUtils.getComleteType(column.getTypeName(), column.getSubElementTypeName(), column.getPrecision(), column.getScale());
                String nodeId = parentId + NODE_SEPARATOR + column.getColumnName();
                ICubridNode node = new DefaultSchemaNode(nodeId, label, "icons/navigator/table_column_item.png");
                if (column.isPrimaryKey()) {
                    node.setIconPath("icons/primary_key.png");
                }
                node.setType(NodeType.TABLE_COLUMN);
                node.setModelObj(column);
                node.setContainer(false);
                parent.addChild(node);
            }
        }
        columns = null;
        setLoaded(true);
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
    }
}
Also used : ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode) TableColumn(com.cubrid.cubridmanager.core.cubrid.table.model.TableColumn)

Example 34 with DefaultSchemaNode

use of com.cubrid.common.ui.spi.model.DefaultSchemaNode in project cubrid-manager by CUBRID.

the class CubridUserTableIndexLoader method load.

/**
	 * 
	 * Load children object for parent
	 * 
	 * @param parent the parent node
	 * @param monitor the IProgressMonitor object
	 */
public void load(ICubridNode parent, final IProgressMonitor monitor) {
    synchronized (this) {
        if (isLoaded()) {
            return;
        }
        CubridDatabase database = ((ISchemaNode) parent).getDatabase();
        if (!database.isLogined() || database.getRunningType() == DbRunningType.STANDALONE) {
            parent.removeAllChild();
            CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
            return;
        }
        DatabaseInfo databaseInfo = database.getDatabaseInfo();
        final GetUserClassIndexesTask task = new GetUserClassIndexesTask(databaseInfo);
        monitorCancel(monitor, new ITask[] { task });
        String tableName = parent.getParent().getLabel();
        List<TableIndex> indexes = task.getIndexesNames(tableName);
        final String errorMsg = task.getErrorMsg();
        if (!monitor.isCanceled() && errorMsg != null && errorMsg.trim().length() > 0) {
            parent.removeAllChild();
            Display display = Display.getDefault();
            display.syncExec(new Runnable() {

                public void run() {
                    CommonUITool.openErrorBox(errorMsg);
                }
            });
            setLoaded(true);
            return;
        }
        if (monitor.isCanceled()) {
            setLoaded(true);
            return;
        }
        parent.removeAllChild();
        String parentId = parent.getId();
        if (indexes != null && !indexes.isEmpty()) {
            for (TableIndex index : indexes) {
                String indexName = index.getIndexName();
                String nodeId = parentId + NODE_SEPARATOR + indexName;
                String label = indexName;
                List<String> dependColumns = index.getColumns();
                if (dependColumns != null && !dependColumns.isEmpty()) {
                    String keyAttrName = index.getColumns().toString();
                    label += keyAttrName.replace('[', '(').replace(']', ')');
                }
                ICubridNode node = new DefaultSchemaNode(nodeId, label, "icons/navigator/table_index_item.png");
                if (index.isPrimaryKey()) {
                    node.setIconPath("icons/primary_key.png");
                }
                node.setType(NodeType.TABLE_INDEX);
                node.setModelObj(index);
                node.setContainer(false);
                parent.addChild(node);
            }
        }
        Collections.sort(parent.getChildren());
        setLoaded(true);
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
    }
}
Also used : ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) TableIndex(com.cubrid.cubridmanager.core.cubrid.table.model.TableIndex) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode) GetUserClassIndexesTask(com.cubrid.cubridmanager.core.cubrid.table.task.GetUserClassIndexesTask) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) Display(org.eclipse.swt.widgets.Display)

Example 35 with DefaultSchemaNode

use of com.cubrid.common.ui.spi.model.DefaultSchemaNode in project cubrid-manager by CUBRID.

the class CubridUserTableLoader method loadIndexes.

/**
	 * Load the indexes and its children node
	 * 
	 * @param parent the parent node
	 * @param level the node level
	 * @param monitor the IProgressMonitor object
	 */
protected void loadIndexes(ICubridNode parent, int level, final IProgressMonitor monitor) {
    synchronized (this) {
        String indexFolderId = parent.getId() + NODE_SEPARATOR + INDEX_FOLDER_ID;
        ICubridNode indexFolder = parent.getChild(indexFolderId);
        if (indexFolder == null) {
            indexFolder = new DefaultSchemaNode(indexFolderId, INDEX_FOLDER_NAME, "icons/navigator/folder.png");
            indexFolder.setType(NodeType.TABLE_INDEX_FOLDER);
            indexFolder.setContainer(true);
            parent.addChild(indexFolder);
            ICubridNodeLoader indexLoader = new CubridUserTableIndexLoader();
            indexLoader.setLevel(level);
            indexFolder.setLoader(indexLoader);
        } else {
            if (indexFolder.getLoader() != null && indexFolder.getLoader().isLoaded()) {
                indexFolder.getLoader().setLoaded(false);
                indexFolder.getChildren(monitor);
            }
        }
    }
}
Also used : ICubridNodeLoader(com.cubrid.common.ui.spi.model.ICubridNodeLoader) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode)

Aggregations

DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)88 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)62 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)33 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)22 ICubridNodeLoader (com.cubrid.common.ui.spi.model.ICubridNodeLoader)21 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)18 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)17 ArrayList (java.util.ArrayList)15 TreeViewer (org.eclipse.jface.viewers.TreeViewer)10 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)9 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)9 Display (org.eclipse.swt.widgets.Display)9 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)8 ClassInfo (com.cubrid.cubridmanager.core.cubrid.table.model.ClassInfo)7 File (java.io.File)5 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)4 CommonQueryTask (com.cubrid.cubridmanager.core.common.task.CommonQueryTask)4 DbSpaceInfoList (com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList)4 GetAllClassListTask (com.cubrid.cubridmanager.core.cubrid.table.task.GetAllClassListTask)4 DbUserInfo (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo)4