Search in sources :

Example 16 with CubridDatabase

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

the class DeleteSerialAction method run.

/**
	 * Delete the selected serials
	 */
public void run(ISchemaNode[] nodeArray) {
    if (nodeArray == null) {
        LOGGER.error("The nodeArray parameter is a null.");
        return;
    }
    final List<String> serialNameList = new ArrayList<String>();
    final StringBuffer serialNames = new StringBuffer();
    for (int i = 0; nodeArray != null && i < nodeArray.length; i++) {
        if (!isSupported(nodeArray[i])) {
            setEnabled(false);
            return;
        }
        ISchemaNode schemaNode = (ISchemaNode) nodeArray[i];
        if (i == 0) {
            serialNames.append(schemaNode.getLabel());
        }
        serialNameList.add(schemaNode.getLabel());
    }
    if (nodeArray.length > 1) {
        serialNames.append(", ...");
    }
    String cfmMsg = Messages.bind(Messages.msgConfirmDelSerial, serialNames.toString(), nodeArray.length);
    boolean isDelete = CommonUITool.openConfirmBox(getShell(), cfmMsg);
    if (!isDelete) {
        return;
    }
    final Shell shell = getShell();
    TaskExecutor taskExcutor = new TaskExecutor() {

        public boolean exec(final IProgressMonitor monitor) {
            if (monitor.isCanceled()) {
                return false;
            }
            String taskName = Messages.bind(Messages.delSerialTaskName, serialNames.toString());
            monitor.beginTask(taskName, IProgressMonitor.UNKNOWN);
            for (ITask task : taskList) {
                if (task instanceof DeleteSerialTask) {
                    DeleteSerialTask deleteSerialTask = (DeleteSerialTask) task;
                    String[] serialNames = new String[serialNameList.size()];
                    deleteSerialTask.deleteSerial(serialNameList.toArray(serialNames));
                }
                final String msg = task.getErrorMsg();
                if (openErrorBox(shell, msg, monitor)) {
                    return false;
                }
                if (monitor.isCanceled()) {
                    return false;
                }
            }
            return true;
        }
    };
    ISchemaNode schemaNode = (ISchemaNode) nodeArray[0];
    CubridDatabase database = schemaNode.getDatabase();
    DatabaseInfo databaseInfo = database.getDatabaseInfo();
    DeleteSerialTask deleteSerialTask = new DeleteSerialTask(databaseInfo);
    taskExcutor.addTask(deleteSerialTask);
    new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
    if (!taskExcutor.isSuccess()) {
        return;
    }
    ISelectionProvider provider = this.getSelectionProvider();
    ICubridNode parent = schemaNode.getParent();
    if (provider instanceof TreeViewer) {
        TreeViewer viewer = (TreeViewer) provider;
        for (int i = 0; nodeArray != null && i < nodeArray.length; i++) {
            parent.removeChild((ICubridNode) nodeArray[i]);
        }
        viewer.remove(parent, nodeArray);
        viewer.setSelection(new StructuredSelection(parent), true);
        CommonUITool.updateFolderNodeLabelIncludingChildrenCount(viewer, parent);
    }
}
Also used : ITask(com.cubrid.common.core.task.ITask) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ArrayList(java.util.ArrayList) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) DeleteSerialTask(com.cubrid.cubridmanager.core.cubrid.serial.task.DeleteSerialTask) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) Shell(org.eclipse.swt.widgets.Shell) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 17 with CubridDatabase

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

the class RunSQLFileDialog method addDatabase.

public void addDatabase(Object[] selectedNodes) {
    List<CubridDatabase> dbList = new ArrayList<CubridDatabase>();
    for (CubridDatabase db : cubridDatabases) {
        dbList.add(db);
    }
    for (Object o : selectedNodes) {
        if (!(o instanceof ISchemaNode)) {
            continue;
        }
        ICubridNode node = (ICubridNode) o;
        if (node.getType() != NodeType.DATABASE) {
            continue;
        }
        CubridDatabase database = ((ISchemaNode) o).getDatabase();
        if (!dbList.contains(database)) {
            dbList.add(database);
        }
    }
    cubridDatabases = dbList.toArray(new CubridDatabase[dbList.size()]);
    databaseTableViewer.setInput(cubridDatabases);
}
Also used : ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) ArrayList(java.util.ArrayList) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 18 with CubridDatabase

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

the class AddUserAction method isSupported.

/**
	 *
	 * @see com.cubrid.common.ui.spi.action.ISelectionAction#isSupported(java
	 *      .lang.Object)
	 * @param obj the Object
	 * @return <code>true</code> if support this obj;<code>false</code>
	 *         otherwise
	 */
public boolean isSupported(Object obj) {
    if (!(obj instanceof ISchemaNode)) {
        return false;
    }
    ISchemaNode node = (ISchemaNode) obj;
    CubridDatabase database = node.getDatabase();
    if (database != null && database.getRunningType() == DbRunningType.CS && database.isLogined()) {
        DbUserInfo dbUserInfo = database.getDatabaseInfo().getAuthLoginedDbUserInfo();
        if (dbUserInfo != null && dbUserInfo.isDbaAuthority()) {
            return true;
        }
    }
    return false;
}
Also used : DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 19 with CubridDatabase

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

the class CreateTriggerDialog method addColumns.

/**
	 *
	 * Add columns of this table to combo
	 *
	 * @param tableName the tablename
	 */
private void addColumns(String tableName) {
    triggerTargetColumnCombo.removeAll();
    if (tableName == null || tableName.trim().length() == 0) {
        return;
    }
    CubridDatabase db = database;
    DatabaseInfo dbInfo = db.getDatabaseInfo();
    GetAllAttrTask task = new GetAllAttrTask(dbInfo);
    List<String> attrNameList = task.getAttrNameList(tableName);
    if (task.getErrorMsg() != null) {
        CommonUITool.openErrorBox(task.getErrorMsg());
        return;
    }
    triggerTargetColumnCombo.add("");
    for (String name : attrNameList) {
        triggerTargetColumnCombo.add(name);
    }
}
Also used : DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) GetAllAttrTask(com.cubrid.cubridmanager.core.cubrid.table.task.GetAllAttrTask)

Example 20 with CubridDatabase

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

the class CreateTriggerDialog method getTableList.

/**
	 *
	 * Get table list
	 *
	 * @return the table string list
	 */
private List<String> getTableList() {
    // FIXME move this logic to core module
    if (null == tableList) {
        CubridDatabase db = database;
        DatabaseInfo dbInfo = db.getDatabaseInfo();
        GetTablesTask task = new GetTablesTask(dbInfo);
        //9.1.0 can't create trigger on sub-partion table
        if (CompatibleUtil.isNotSupportGetSubPartitionTable(database.getServer().getServerInfo())) {
            tableList = task.getUserTablesNotContainSubPartitionTable();
        } else {
            tableList = task.getUserTables();
        }
        if (task.getErrorMsg() != null) {
            CommonUITool.openErrorBox(task.getErrorMsg());
            return tableList;
        }
    }
    return tableList;
}
Also used : DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) GetTablesTask(com.cubrid.cubridmanager.core.cubrid.table.task.GetTablesTask)

Aggregations

CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)278 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)104 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)79 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)67 ArrayList (java.util.ArrayList)45 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)43 TreeViewer (org.eclipse.jface.viewers.TreeViewer)42 DbUserInfo (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo)36 DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)33 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)30 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)29 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)28 CubridNavigatorView (com.cubrid.common.ui.common.navigator.CubridNavigatorView)25 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)22 Shell (org.eclipse.swt.widgets.Shell)22 DatabaseEditorConfig (com.cubrid.common.ui.spi.model.DatabaseEditorConfig)19 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)18 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)18 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)18 ITask (com.cubrid.common.core.task.ITask)17