Search in sources :

Example 16 with ISchemaNode

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

the class OIDNavigatorAction method run.

public void run() {
    Object[] obj = this.getSelectedObj();
    if (!isSupported(obj)) {
        this.setEnabled(false);
        return;
    }
    ISchemaNode node = (ISchemaNode) obj[0];
    CubridDatabase database = node.getDatabase();
    Connection conn = null;
    try {
        conn = JDBCConnectionManager.getConnection(database.getDatabaseInfo(), true);
        OIDNavigatorDialog dialog = new OIDNavigatorDialog(getShell(), conn, null);
        dialog.open();
    } catch (SQLException e) {
        LOGGER.error("Can not request oid information by jdbc.", e);
        //TODO: error message localizing
        String message = Messages.bind(Messages.errCommonTip, e.getErrorCode(), e.getMessage());
        CommonUITool.openErrorBox(message);
    } finally {
        QueryUtil.freeQuery(conn);
    }
}
Also used : ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) SQLException(java.sql.SQLException) Connection(java.sql.Connection) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) OIDNavigatorDialog(com.cubrid.common.ui.common.dialog.OIDNavigatorDialog)

Example 17 with ISchemaNode

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

the class FavoriteQueryNavigatorView method getCurrentDatabase.

/**
	 * Return current selected database from the navigation tree.
	 * @return CubridDatabase
	 */
private CubridDatabase getCurrentDatabase() {
    CubridDatabase cubridDatabase = null;
    CubridNavigatorView nav = CubridNavigatorView.findNavigationView();
    if (nav != null) {
        TreeItem[] items = nav.getSelectedItems();
        if (items.length > 0 && items[0] != null && items[0].getData() instanceof ISchemaNode) {
            ISchemaNode node = (ISchemaNode) items[0].getData();
            CubridDatabase tempDatabase = node.getDatabase();
            if (tempDatabase != null && tempDatabase.isLogined()) {
                cubridDatabase = tempDatabase;
            }
        }
    }
    return cubridDatabase;
}
Also used : TreeItem(org.eclipse.swt.widgets.TreeItem) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 18 with ISchemaNode

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

the class BackupDatabaseAction method run.

public void run() {
    Object[] obj = this.getSelectedObj();
    if (!isSupported(obj[0])) {
        setEnabled(false);
        return;
    }
    ISchemaNode node = (ISchemaNode) obj[0];
    final CubridDatabase database = node.getDatabase();
    final BackupDatabaseDialog dialog = new BackupDatabaseDialog(getShell());
    dialog.setDatabase(database);
    final Shell shell = getShell();
    TaskExecutor taskExcutor = new TaskExecutor() {

        public boolean exec(final IProgressMonitor monitor) {
            if (monitor.isCanceled()) {
                return false;
            }
            monitor.beginTask(Messages.loadDbBackupInfoTaskName, IProgressMonitor.UNKNOWN);
            for (ITask task : taskList) {
                task.execute();
                final String msg = task.getErrorMsg();
                if (openErrorBox(shell, msg, monitor)) {
                    return false;
                }
                if (monitor.isCanceled()) {
                    return false;
                }
                if (task instanceof GetDbBackupInfoTask) {
                    GetDbBackupInfoTask getDbBackupInfoTask = (GetDbBackupInfoTask) task;
                    dialog.setDbBackupInfo(getDbBackupInfoTask.getDbBackupInfo());
                } else if (task instanceof GetCubridConfParameterTask) {
                    GetCubridConfParameterTask getCubridConfParameterTask = (GetCubridConfParameterTask) task;
                    Map<String, Map<String, String>> confParas = getCubridConfParameterTask.getConfParameters();
                    Map<String, String> commonParas = confParas.get(ConfConstants.COMMON_SECTION_NAME);
                    Map<String, String> dbParas = confParas.get("[@" + database.getLabel() + "]");
                    String str = dbParas == null ? null : dbParas.get(ConfConstants.REPLICATION);
                    boolean isReplication = "yes".equals(str);
                    if (!isReplication) {
                        str = commonParas == null ? null : commonParas.get(ConfConstants.REPLICATION);
                        isReplication = "yes".equals(str);
                    }
                    dialog.setReplication(isReplication);
                }
            }
            return true;
        }
    };
    ServerInfo serverInfo = database.getServer().getServerInfo();
    GetCubridConfParameterTask getCubridConfParameterTask = new GetCubridConfParameterTask(serverInfo);
    taskExcutor.addTask(getCubridConfParameterTask);
    GetDbBackupInfoTask getDbBackupInfoTask = new GetDbBackupInfoTask(serverInfo);
    getDbBackupInfoTask.setDbName(database.getLabel());
    taskExcutor.addTask(getDbBackupInfoTask);
    new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
    if (taskExcutor.isSuccess()) {
        dialog.open();
    }
}
Also used : ITask(com.cubrid.common.core.task.ITask) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) GetCubridConfParameterTask(com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask) GetDbBackupInfoTask(com.cubrid.cubridmanager.core.cubrid.database.task.GetDbBackupInfoTask) BackupDatabaseDialog(com.cubrid.cubridmanager.ui.cubrid.database.dialog.BackupDatabaseDialog) Shell(org.eclipse.swt.widgets.Shell) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) Map(java.util.Map)

Example 19 with ISchemaNode

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

the class SpaceInfoViewAction method isSupported.

/**
	 * Return whether this action support this object,if not support,this action
	 * will be disabled
	 * 
	 * @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) {
        ISchemaNode node = (ISchemaNode) obj;
        CubridDatabase database = node.getDatabase();
        DbUserInfo dbUserInfo = database.getDatabaseInfo().getAuthLoginedDbUserInfo();
        String type = node.getType();
        if ((CubridNodeType.GENERIC_VOLUME.equals(type) || CubridNodeType.DATA_VOLUME.equals(type) || CubridNodeType.INDEX_VOLUME.equals(type) || CubridNodeType.TEMP_VOLUME.equals(type)) && (dbUserInfo != null && database.isLogined())) {
            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 20 with ISchemaNode

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

the class DeleteBackupPlanAction method isSupported.

/**
	 * Sets this action support this object
	 * 
	 * @see org.eclipse.jface.action.IAction.ISelectionAction
	 * @param obj Object
	 * @return boolean
	 */
public boolean isSupported(Object obj) {
    if (obj instanceof ISchemaNode) {
        ISchemaNode node = (ISchemaNode) obj;
        CubridDatabase database = node.getDatabase();
        if (CubridNodeType.BACKUP_PLAN.equals(node.getType()) && database != null && database.isLogined()) {
            DbUserInfo dbUserInfo = database.getDatabaseInfo().getAuthLoginedDbUserInfo();
            if (dbUserInfo != null && dbUserInfo.isDbaAuthority()) {
                return true;
            }
        }
    } else if (obj instanceof Object[]) {
        Object[] objArr = (Object[]) obj;
        CubridDatabase database = null;
        for (Object object : objArr) {
            DefaultSchemaNode node = (DefaultSchemaNode) object;
            CubridDatabase db = node.getDatabase();
            if (database == null) {
                database = db;
            } else if (!database.getId().equals(db.getId())) {
                return false;
            }
        }
        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) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode)

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