Search in sources :

Example 1 with DbSpaceInfoListOld

use of com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoListOld in project cubrid-manager by CUBRID.

the class VolumeFolderInfoEditor method loadData.

/**
	 * load the editor data
	 *
	 * @return boolean
	 */
public boolean loadData() {
    TaskJobExecutor taskJobExecutor = new TaskJobExecutor() {

        @SuppressWarnings("unchecked")
        @Override
        public IStatus exec(IProgressMonitor monitor) {
            if (monitor.isCanceled()) {
                return Status.CANCEL_STATUS;
            }
            for (ITask t : taskList) {
                t.execute();
                final String msg = t.getErrorMsg();
                if (monitor.isCanceled()) {
                    return Status.CANCEL_STATUS;
                }
                if (msg != null && msg.length() > 0 && !monitor.isCanceled()) {
                    return new Status(IStatus.ERROR, CubridManagerUIPlugin.PLUGIN_ID, msg);
                } else {
                    final DbSpaceInfoList model = ((CommonQueryTask<? extends DbSpaceInfoList>) t).getResultModel();
                    Display.getDefault().syncExec(new Runnable() {

                        public void run() {
                            database.getDatabaseInfo().setDbSpaceInfoList(model);
                            if (scrolledComp == null || scrolledComp.isDisposed()) {
                                return;
                            }
                            initialize();
                            paintComp();
                            scrolledComp.setContent(parentComp);
                            scrolledComp.setExpandHorizontal(true);
                            scrolledComp.setExpandVertical(true);
                        }
                    });
                }
                if (monitor.isCanceled()) {
                    return Status.CANCEL_STATUS;
                }
            }
            return Status.OK_STATUS;
        }
    };
    CommonQueryTask<? extends DbSpaceInfoList> task = DbSpaceInfoList.useOld(database.getServer().getServerInfo().getEnvInfo()) ? new CommonQueryTask<DbSpaceInfoListOld>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), new DbSpaceInfoListOld()) : new CommonQueryTask<DbSpaceInfoListNew>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), new DbSpaceInfoListNew());
    task.setDbName(database.getName());
    taskJobExecutor.addTask(task);
    String serverName = database.getServer().getName();
    String dbName = database.getName();
    String jobName = Messages.viewVolumeInfoJobName + " - " + volumeFolderName + "@" + dbName + "@" + serverName;
    taskJobExecutor.schedule(jobName, null, false, Job.LONG);
    return true;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) TaskJobExecutor(com.cubrid.common.ui.spi.progress.TaskJobExecutor) ITask(com.cubrid.common.core.task.ITask) DbSpaceInfoListOld(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoListOld) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) DbSpaceInfoListNew(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoListNew) DbSpaceInfoList(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask)

Example 2 with DbSpaceInfoListOld

use of com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoListOld in project cubrid-manager by CUBRID.

the class VolumeInformationEditor method loadData.

/**
	 * load the data
	 *
	 * @return boolean
	 */
public boolean loadData() {
    TaskJobExecutor taskJobExecutor = new TaskJobExecutor() {

        @SuppressWarnings("unchecked")
        @Override
        public IStatus exec(IProgressMonitor monitor) {
            if (monitor.isCanceled()) {
                return Status.CANCEL_STATUS;
            }
            for (ITask t : taskList) {
                t.execute();
                final String msg = t.getErrorMsg();
                if (monitor.isCanceled()) {
                    return Status.CANCEL_STATUS;
                }
                if (msg != null && msg.length() > 0 && !monitor.isCanceled()) {
                    return new Status(IStatus.ERROR, CubridManagerUIPlugin.PLUGIN_ID, msg);
                } else {
                    final DbSpaceInfoList model = ((CommonQueryTask<? extends DbSpaceInfoList>) t).getResultModel();
                    Display.getDefault().syncExec(new Runnable() {

                        public void run() {
                            database.getDatabaseInfo().setDbSpaceInfoList(model);
                            if (scrolledComp == null || scrolledComp.isDisposed()) {
                                return;
                            }
                            initial();
                            paintComp();
                            scrolledComp.setContent(parentComp);
                            scrolledComp.setExpandHorizontal(true);
                            scrolledComp.setExpandVertical(true);
                            scrolledComp.setMinHeight(800);
                            scrolledComp.setMinWidth(800);
                        }
                    });
                }
                if (monitor.isCanceled()) {
                    return Status.CANCEL_STATUS;
                }
            }
            return Status.OK_STATUS;
        }
    };
    CommonQueryTask<? extends DbSpaceInfoList> task = DbSpaceInfoList.useOld(database.getServer().getServerInfo().getEnvInfo()) ? new CommonQueryTask<DbSpaceInfoListOld>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), new DbSpaceInfoListOld()) : new CommonQueryTask<DbSpaceInfoListNew>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), new DbSpaceInfoListNew());
    task.setDbName(database.getName());
    taskJobExecutor.addTask(task);
    String jobName = Messages.viewVolumeInfoJobName + " - " + dbSpaceInfo.getSpacename() + "@" + database.getName() + "@" + database.getServer().getName();
    taskJobExecutor.schedule(jobName, null, false, Job.LONG);
    return true;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) TaskJobExecutor(com.cubrid.common.ui.spi.progress.TaskJobExecutor) ITask(com.cubrid.common.core.task.ITask) DbSpaceInfoListOld(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoListOld) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) DbSpaceInfoListNew(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoListNew) DbSpaceInfoList(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask)

Example 3 with DbSpaceInfoListOld

use of com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoListOld in project cubrid-manager by CUBRID.

the class CubridDbSpaceFolderLoader 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();
        HashMap<String, FolderInformationContainer> foldersInformation;
        HashMap<String, ICubridNode> foldersHashMap = new HashMap<String, ICubridNode>();
        DatabaseInfo databaseInfo = database.getDatabaseInfo();
        CommonQueryTask<? extends DbSpaceInfoList> task;
        DbSpaceInfoList dbSpaceInfoList;
        if (DbSpaceInfoList.useOld(database.getDatabaseInfo().getServerInfo().getEnvInfo())) {
            foldersInformation = foldersInformationOldFormat;
            task = new CommonQueryTask<DbSpaceInfoListOld>(parent.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), new DbSpaceInfoListOld());
        } else {
            foldersInformation = foldersInformationNewFormat;
            task = new CommonQueryTask<DbSpaceInfoListNew>(parent.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), new DbSpaceInfoListNew());
        }
        for (Map.Entry<String, FolderInformationContainer> entry : foldersInformation.entrySet()) {
            String key = entry.getKey();
            FolderInformationContainer value = entry.getValue();
            ICubridNode folder = addFolder(parent, key, value.volumeFolderName, value.volumeFolder, value.type);
            foldersHashMap.put(value.volumeType, folder);
        }
        ICubridNode logFolder = addFolder(parent, LOG_VOLUME_FOLDER_ID, LOG_VOLUME_FOLDER_NAME, CubridNodeType.LOG_VOLUEM_FOLDER, null);
        foldersHashMap.put(VolumeType.ACTIVE_LOG.getText(), addFolder(logFolder, ACTIVE_LOG_FOLDER_ID, ACTIVE_LOG_FOLDER_NAME, CubridNodeType.ACTIVE_LOG_FOLDER, CubridNodeType.ACTIVE_LOG));
        foldersHashMap.put(VolumeType.ARCHIVE_LOG.getText(), addFolder(logFolder, ARCHIVE_LOG_FOLDER_ID, ARCHIVE_LOG_FOLDER_NAME, CubridNodeType.ARCHIVE_LOG_FOLDER, CubridNodeType.ARCHIVE_LOG));
        task.setDbName(database.getLabel());
        monitorCancel(monitor, new ITask[] { task });
        task.execute();
        final String errorMsg = task.getErrorMsg();
        if (!monitor.isCanceled() && errorMsg != null && errorMsg.trim().length() > 0) {
            for (ICubridNode folder : foldersHashMap.values()) {
                folder.removeAllChild();
            }
            Display display = Display.getDefault();
            display.syncExec(new Runnable() {

                public void run() {
                    CommonUITool.openErrorBox(null, errorMsg);
                }
            });
            setLoaded(true);
            return;
        }
        if (monitor.isCanceled()) {
            setLoaded(true);
            return;
        }
        for (ICubridNode folder : foldersHashMap.values()) {
            folder.removeAllChild();
        }
        dbSpaceInfoList = task.getResultModel();
        List<DbSpaceInfo> spaceInfoList = dbSpaceInfoList == null ? null : dbSpaceInfoList.getSpaceinfo();
        for (int i = 0; spaceInfoList != null && i < spaceInfoList.size(); i++) {
            DbSpaceInfo spaceInfo = spaceInfoList.get(i);
            ICubridNode volumeNode = new DefaultSchemaNode("", spaceInfo.getShortVolumeName(), "");
            volumeNode.setContainer(false);
            volumeNode.setModelObj(spaceInfo);
            volumeNode.setEditorId(VolumeInformationEditor.ID);
            String key = null;
            String type = spaceInfo.getType();
            if (spaceInfo.getPurpose() != null) {
                key = type + "_" + spaceInfo.getPurpose();
            } else {
                key = type;
            }
            if (type == null) {
                continue;
            }
            ICubridNode folder = foldersHashMap.get(key);
            if (folder != null) {
                String id = folder.getId() + NODE_SEPARATOR + spaceInfo.getShortVolumeName();
                volumeNode.setId(id);
                volumeNode.setType(folder.getType());
                volumeNode.setIconPath("icons/navigator/volume_item.png");
                folder.addChild(volumeNode);
            }
        }
        if (spaceInfoList != null && !spaceInfoList.isEmpty()) {
            for (ICubridNode folder : foldersHashMap.values()) {
                Collections.sort(folder.getChildren());
            }
        }
        databaseInfo.setDbSpaceInfoList(dbSpaceInfoList);
        setLoaded(true);
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
    }
}
Also used : ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) HashMap(java.util.HashMap) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) DbSpaceInfoListOld(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoListOld) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode) DbSpaceInfoListNew(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoListNew) DbSpaceInfoList(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList) DbSpaceInfo(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfo) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) HashMap(java.util.HashMap) Map(java.util.Map) Display(org.eclipse.swt.widgets.Display)

Example 4 with DbSpaceInfoListOld

use of com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoListOld in project cubrid-manager by CUBRID.

the class DatabaseStatusEditor method loadData.

/**
	 *
	 * Load data
	 *
	 * @return <code>true</code> whether it is successful;<code>false</code>
	 *         otherwise
	 */
public boolean loadData() {
    TaskJobExecutor taskJobExecutor = new TaskJobExecutor() {

        @SuppressWarnings("unchecked")
        @Override
        public IStatus exec(IProgressMonitor monitor) {
            if (monitor.isCanceled()) {
                return Status.CANCEL_STATUS;
            }
            for (ITask t : taskList) {
                t.execute();
                final String msg = t.getErrorMsg();
                if (monitor.isCanceled()) {
                    return Status.CANCEL_STATUS;
                }
                if (msg != null && msg.length() > 0 && !monitor.isCanceled()) {
                    return new Status(IStatus.ERROR, CubridManagerUIPlugin.PLUGIN_ID, msg);
                } else {
                    final DbSpaceInfoList dbSpaceInfoList = ((CommonQueryTask<? extends DbSpaceInfoList>) t).getResultModel();
                    Display.getDefault().syncExec(new Runnable() {

                        public void run() {
                            database.getDatabaseInfo().setDbSpaceInfoList(dbSpaceInfoList);
                            if (scrolledComp == null || scrolledComp.isDisposed()) {
                                return;
                            }
                            initial();
                            paintComp();
                            scrolledComp.setContent(parentComp);
                            scrolledComp.setExpandHorizontal(true);
                            scrolledComp.setExpandVertical(true);
                        }
                    });
                }
                if (monitor.isCanceled()) {
                    return Status.CANCEL_STATUS;
                }
            }
            return Status.OK_STATUS;
        }
    };
    CommonQueryTask<? extends DbSpaceInfoList> task = DbSpaceInfoList.useOld(database.getServer().getServerInfo().getEnvInfo()) ? new CommonQueryTask<DbSpaceInfoListOld>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), new DbSpaceInfoListOld()) : new CommonQueryTask<DbSpaceInfoListNew>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), new DbSpaceInfoListNew());
    task.setDbName(database.getName());
    taskJobExecutor.addTask(task);
    String serverName = database.getServer().getName();
    String dbName = database.getName();
    String jobName = Messages.viewDbStatusJobName + " - " + dbName + "@" + serverName;
    taskJobExecutor.schedule(jobName, null, false, Job.SHORT);
    return true;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) TaskJobExecutor(com.cubrid.common.ui.spi.progress.TaskJobExecutor) ITask(com.cubrid.common.core.task.ITask) DbSpaceInfoListOld(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoListOld) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) DbSpaceInfoListNew(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoListNew) DbSpaceInfoList(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask)

Aggregations

DbSpaceInfoList (com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList)4 DbSpaceInfoListNew (com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoListNew)4 DbSpaceInfoListOld (com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoListOld)4 ITask (com.cubrid.common.core.task.ITask)3 TaskJobExecutor (com.cubrid.common.ui.spi.progress.TaskJobExecutor)3 CommonQueryTask (com.cubrid.cubridmanager.core.common.task.CommonQueryTask)3 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3 IStatus (org.eclipse.core.runtime.IStatus)3 Status (org.eclipse.core.runtime.Status)3 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)1 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)1 DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)1 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)1 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)1 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)1 DbSpaceInfo (com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfo)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Display (org.eclipse.swt.widgets.Display)1