Search in sources :

Example 46 with ISchemaNode

use of com.cubrid.common.ui.spi.model.ISchemaNode 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 47 with ISchemaNode

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

the class QueryEditorDNDController method getScript.

/**
	 * Get the script
	 *
	 * @param tableName String
	 * @param columnNodeList List<ISchemaNode>
	 * @return String
	 */
private String getScript(String tableName, List<ISchemaNode> columnNodeList) {
    // FIXME move this logic to core module
    StringBuilder sql = new StringBuilder();
    sql.append("SELECT ");
    for (ISchemaNode node : columnNodeList) {
        String escapedColumnName = QuerySyntax.escapeKeyword(node.getName().split(",")[0]);
        sql.append(" ").append(escapedColumnName).append(", ");
    }
    sql.append(" FROM ").append(QuerySyntax.escapeKeyword(tableName)).append(";").append(StringUtil.NEWLINE);
    return sql.toString();
}
Also used : ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode)

Example 48 with ISchemaNode

use of com.cubrid.common.ui.spi.model.ISchemaNode 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 49 with ISchemaNode

use of com.cubrid.common.ui.spi.model.ISchemaNode 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 50 with ISchemaNode

use of com.cubrid.common.ui.spi.model.ISchemaNode 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)

Aggregations

ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)158 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)104 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)55 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)30 ArrayList (java.util.ArrayList)28 TreeViewer (org.eclipse.jface.viewers.TreeViewer)27 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)23 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)23 DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)22 DbUserInfo (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo)22 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)21 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)21 Shell (org.eclipse.swt.widgets.Shell)16 ITask (com.cubrid.common.core.task.ITask)13 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)13 IEditorPart (org.eclipse.ui.IEditorPart)12 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)12 HashSet (java.util.HashSet)11 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)11 PartInitException (org.eclipse.ui.PartInitException)10