Search in sources :

Example 36 with ISchemaNode

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

the class SelectByOnePstmtDataAction method run.

/**
	 * @see org.eclipse.jface.action.Action#run()
	 */
public void run() {
    Object[] obj = this.getSelectedObj();
    if (!isSupported(obj)) {
        setEnabled(false);
        return;
    }
    ISchemaNode node = (ISchemaNode) obj[0];
    doRun(node);
}
Also used : ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode)

Example 37 with ISchemaNode

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

the class EditTableAction method run.

public void run() {
    Object[] obj = this.getSelectedObj();
    if (!isSupported(obj)) {
        setEnabled(false);
        return;
    }
    ISelectionProvider provider = getSelectionProvider();
    if (!(provider instanceof TreeViewer)) {
        return;
    }
    ISchemaNode tableNode = (ISchemaNode) obj[0];
    doRun(tableNode, MODE_TABLE_EDIT);
}
Also used : ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) TreeViewer(org.eclipse.jface.viewers.TreeViewer)

Example 38 with ISchemaNode

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

the class EditTableAction method doRun.

private void doRun(ISchemaNode table, int type) {
    final DatabaseInfo databaseInfo = NodeUtil.findDatabaseInfo(table);
    if (databaseInfo == null) {
        return;
    }
    final String tableName = table.getName();
    TaskExecutor taskExcutor = new TaskExecutor() {

        public boolean exec(final IProgressMonitor monitor) {
            if (monitor.isCanceled()) {
                return false;
            }
            for (ITask task : taskList) {
                task.execute();
                final String msg = task.getErrorMsg();
                if (openErrorBox(shell, msg, monitor)) {
                    return false;
                }
                if (monitor.isCanceled()) {
                    return false;
                }
            }
            databaseInfo.removeSchema(tableName);
            SchemaInfo schemaInfo = databaseInfo.getSchemaInfo(tableName);
            if (schemaInfo == null) {
                openErrorBox(shell, databaseInfo.getErrorMessage(), monitor);
                return false;
            }
            return true;
        }
    };
    boolean supportCharset = CompatibleUtil.isSupportCreateDBByCharset(databaseInfo);
    JDBCGetAllDbUserTask allUserTask = new JDBCGetAllDbUserTask(databaseInfo);
    taskExcutor.addTask(allUserTask);
    GetCollations collationTask = null;
    if (supportCharset) {
        collationTask = new GetCollations(databaseInfo);
        taskExcutor.addTask(collationTask);
    }
    new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
    if (!taskExcutor.isSuccess()) {
        return;
    }
    List<String> dbUserList = allUserTask.getDbUserList();
    SchemaInfo schemaInfo = databaseInfo.getSchemaInfo(tableName);
    TableEditorInput input = new TableEditorInput(table.getDatabase(), false, schemaInfo, table, type);
    input.setDbUserList(dbUserList);
    if (supportCharset) {
        List<Collation> collations = collationTask.getCollations();
        input.setCollationList(collations);
    }
    try {
        IWorkbench workbench = PlatformUI.getWorkbench();
        IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
        //If true, active opened editor of it and return, else open new editor.
        for (IEditorReference editorRef : workbenchWindow.getActivePage().getEditorReferences()) {
            IEditorPart oldEditor = editorRef.getEditor(true);
            if (oldEditor.getEditorInput() instanceof TableEditorInput) {
                TableEditorInput oldInput = (TableEditorInput) oldEditor.getEditorInput();
                ISchemaNode oldTable = oldInput.getEditedTableNode();
                if (oldTable != null && oldTable.equals(table)) {
                    workbenchWindow.getActivePage().activate(oldEditor);
                    return;
                }
            }
        }
        workbenchWindow.getActivePage().openEditor(input, TableEditorPart.ID);
    } catch (Exception ignore) {
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) ITask(com.cubrid.common.core.task.ITask) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) TableEditorInput(com.cubrid.common.ui.cubrid.table.editor.TableEditorInput) JDBCGetAllDbUserTask(com.cubrid.cubridmanager.core.cubrid.user.task.JDBCGetAllDbUserTask) IEditorPart(org.eclipse.ui.IEditorPart) GetCollations(com.cubrid.cubridmanager.core.cubrid.table.task.GetCollations) Collation(com.cubrid.cubridmanager.core.cubrid.database.model.Collation) IWorkbench(org.eclipse.ui.IWorkbench) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IEditorReference(org.eclipse.ui.IEditorReference) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) SchemaInfo(com.cubrid.common.core.common.model.SchemaInfo)

Example 39 with ISchemaNode

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

the class SerialDashboardEditorPart method openEditSerialDialog.

private void openEditSerialDialog(SerialInfo serialInfo) {
    Set<String> typeSet = new HashSet<String>();
    typeSet.add(NodeType.SERIAL);
    ICubridNode serialNode = CommonUITool.findNode(database, typeSet, serialInfo.getName());
    if (serialNode != null) {
        EditSerialAction action = (EditSerialAction) ActionManager.getInstance().getAction(EditSerialAction.ID);
        if (action.run(database, (ISchemaNode) serialNode) == IDialogConstants.OK_ID) {
            refresh();
        }
    }
}
Also used : ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) EditSerialAction(com.cubrid.common.ui.cubrid.serial.action.EditSerialAction) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) HashSet(java.util.HashSet)

Example 40 with ISchemaNode

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

the class ColumnSelectSqlAction method isSupported.

public boolean isSupported(Object obj) {
    boolean isPlainSupport = ActionSupportUtil.isSupportMultiSelection(obj, new String[] { NodeType.TABLE_COLUMN }, true);
    boolean isSameTable = true;
    if (isPlainSupport && obj instanceof Object[]) {
        Object[] objArr = (Object[]) obj;
        String parentNodeId = "";
        for (int i = 0; i < objArr.length; i++) {
            ISchemaNode schemaNode = (ISchemaNode) objArr[i];
            ICubridNode parent = schemaNode.getParent();
            if (i == 0) {
                parentNodeId = parent.getId();
            } else {
                isSameTable = parentNodeId.equals(parent.getId());
            }
        }
    }
    return isPlainSupport && isSameTable;
}
Also used : ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode)

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