Search in sources :

Example 6 with ICubridNodeLoader

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

the class CubridBrokersFolderLoader 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;
        }
        ServerInfo serverInfo = parent.getServer().getServerInfo();
        ServerUserInfo userInfo = serverInfo.getLoginedUserInfo();
        if (userInfo == null || CasAuthType.AUTH_NONE == userInfo.getCasAuth()) {
            parent.removeAllChild();
            CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
            return;
        }
        BrokerInfos brokerInfos = new BrokerInfos();
        final CommonQueryTask<BrokerInfos> task = new CommonQueryTask<BrokerInfos>(serverInfo, CommonSendMsg.getCommonSimpleSendMsg(), brokerInfos);
        monitorCancel(monitor, new ITask[] { task });
        task.execute();
        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;
        }
        brokerInfos = task.getResultModel();
        List<ICubridNode> oldNodeList = parent.getChildren();
        parent.removeAllChild();
        List<BrokerInfo> brokerInfoList = (brokerInfos == null || brokerInfos.getBorkerInfoList() == null) ? null : brokerInfos.getBorkerInfoList().getBrokerInfoList();
        for (int i = 0; brokerInfoList != null && i < brokerInfoList.size(); i++) {
            BrokerInfo brokerInfo = brokerInfoList.get(i);
            String id = parent.getId() + NODE_SEPARATOR + brokerInfo.getName();
            ICubridNode brokerInfoNode = isContained(oldNodeList, id);
            if (brokerInfoNode == null) {
                brokerInfoNode = new CubridBroker(id, brokerInfo.getName(), "icons/navigator/broker.png");
                ((CubridBroker) brokerInfoNode).setStartedIconPath("icons/navigator/broker_started.png");
                brokerInfoNode.setType(CubridNodeType.BROKER);
                brokerInfoNode.setContainer(true);
                brokerInfoNode.setModelObj(brokerInfo);
                brokerInfoNode.setViewId(BrokerStatusView.ID);
                brokerInfoNode.setLoader(new CubridBrokerFolderLoader());
            } else {
                brokerInfoNode.setModelObj(brokerInfo);
                if (brokerInfoNode.getLoader() != null && brokerInfoNode.getLoader().isLoaded()) {
                    brokerInfoNode.getLoader().setLoaded(false);
                    brokerInfoNode.getChildren(monitor);
                }
            }
            parent.addChild(brokerInfoNode);
        }
        serverInfo.setBrokerInfos(brokerInfos);
        // For the Shard Broker Folder
        if (CompatibleUtil.isSupportShard(serverInfo)) {
            Shards shards = new Shards();
            GetShardConfTask<Shards> getShardConfTask = new GetShardConfTask<Shards>(serverInfo, shards);
            getShardConfTask.execute();
            // !"File(?) open error".equals(errorMsg.trim())) {
            if (getShardConfTask.isSuccess()) {
                GetShardStatusTask getShardStatusTask = new GetShardStatusTask(serverInfo, null);
                getShardStatusTask.execute();
                boolean runningShard = getShardStatusTask.isSuccess();
                serverInfo.setShards(shards);
                shards.setRunning(runningShard);
                String shardFolderId = parent.getId() + NODE_SEPARATOR + SHARD_FOLDER_ID;
                ICubridNode shardFolder = parent.getChild(shardFolderId);
                if (shardFolder == null) {
                    shardFolder = new CubridShardFolder(shardFolderId, SHARD_FOLDER_NAME);
                    ICubridNodeLoader loader = new CubridShardsFolderLoader((CubridShardFolder) shardFolder);
                    loader.setLevel(getLevel());
                    shardFolder.setLoader(loader);
                    parent.addChild(shardFolder);
                // shardFolder.getChildren(monitor);
                } else {
                    if (shardFolder.getLoader() != null && shardFolder.getLoader().isLoaded()) {
                        shardFolder.getLoader().setLoaded(false);
                        shardFolder.getChildren(monitor);
                    }
                }
            }
        }
        Collections.sort(parent.getChildren());
        setLoaded(true);
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
    }
}
Also used : ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) BrokerInfos(com.cubrid.cubridmanager.core.broker.model.BrokerInfos) CubridBroker(com.cubrid.cubridmanager.ui.spi.model.CubridBroker) CubridShardFolder(com.cubrid.cubridmanager.ui.spi.model.CubridShardFolder) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) GetShardConfTask(com.cubrid.cubridmanager.core.shard.task.GetShardConfTask) BrokerInfo(com.cubrid.cubridmanager.core.broker.model.BrokerInfo) ICubridNodeLoader(com.cubrid.common.ui.spi.model.ICubridNodeLoader) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) ServerUserInfo(com.cubrid.cubridmanager.core.common.model.ServerUserInfo) Shards(com.cubrid.cubridmanager.core.shard.model.Shards) GetShardStatusTask(com.cubrid.cubridmanager.core.shard.task.GetShardStatusTask) Display(org.eclipse.swt.widgets.Display)

Example 7 with ICubridNodeLoader

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

the class CubridDatabaseLoader method addSerialFolder.

/**
	 * Add serial folder
	 * 
	 * @param monitor the IProgressMonitor
	 * @param database the CubridDatabase
	 */
private void addSerialFolder(final IProgressMonitor monitor, CubridDatabase database) {
    String serialFolderId = database.getId() + NODE_SEPARATOR + CubridSerialFolderLoader.SERIAL_FOLDER_ID;
    ICubridNode serialFolder = database.getChild(serialFolderId);
    if (serialFolder == null) {
        serialFolder = new DefaultSchemaNode(serialFolderId, SERIAL_FOLDER_NAME, "icons/navigator/serial_group.png");
        serialFolder.setType(NodeType.SERIAL_FOLDER);
        serialFolder.setContainer(true);
        ICubridNodeLoader loader = new CubridSerialFolderLoader();
        loader.setLevel(getLevel());
        serialFolder.setLoader(loader);
        database.addChild(serialFolder);
        if (getLevel() == DEFINITE_LEVEL) {
            serialFolder.getChildren(monitor);
        }
    } else {
        if (serialFolder.getLoader() != null && serialFolder.getLoader().isLoaded()) {
            serialFolder.getLoader().setLoaded(false);
            serialFolder.getChildren(monitor);
        }
    }
}
Also used : ICubridNodeLoader(com.cubrid.common.ui.spi.model.ICubridNodeLoader) CubridSerialFolderLoader(com.cubrid.common.ui.spi.model.loader.CubridSerialFolderLoader) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode)

Example 8 with ICubridNodeLoader

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

the class CubridDatabaseLoader method addViewFolder.

/**
	 * Add view folder
	 * 
	 * @param monitor the IProgressMonitor
	 * @param database the CubridDatabase
	 */
private void addViewFolder(final IProgressMonitor monitor, CubridDatabase database) {
    String viewsFolderId = database.getId() + NODE_SEPARATOR + CubridViewsFolderLoader.VIEWS_FOLDER_ID;
    ICubridNode viewsFolder = database.getChild(viewsFolderId);
    if (viewsFolder == null) {
        viewsFolder = new DefaultSchemaNode(viewsFolderId, VIEWS_FOLDER_NAME, "icons/navigator/schema_view.png");
        viewsFolder.setType(NodeType.VIEW_FOLDER);
        viewsFolder.setContainer(true);
        ICubridNodeLoader loader = new CubridViewsFolderLoader();
        loader.setLevel(getLevel());
        viewsFolder.setLoader(loader);
        database.addChild(viewsFolder);
        if (getLevel() == DEFINITE_LEVEL) {
            viewsFolder.getChildren(monitor);
        }
    } else {
        if (viewsFolder.getLoader() != null && viewsFolder.getLoader().isLoaded()) {
            viewsFolder.getLoader().setLoaded(false);
            viewsFolder.getChildren(monitor);
        }
    }
}
Also used : ICubridNodeLoader(com.cubrid.common.ui.spi.model.ICubridNodeLoader) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode) CubridViewsFolderLoader(com.cubrid.common.ui.spi.model.loader.schema.CubridViewsFolderLoader)

Example 9 with ICubridNodeLoader

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

the class CubridDatabaseLoader method addSpaceFolder.

/**
	 * Add database space folder
	 * 
	 * @param monitor the IProgressMonitor
	 * @param database the CubridDatabase
	 */
private void addSpaceFolder(final IProgressMonitor monitor, CubridDatabase database) {
    String databaseSpaceFolderId = database.getId() + NODE_SEPARATOR + DB_SPACE_FOLDER_ID;
    ICubridNode databaseSpaceFolder = database.getChild(databaseSpaceFolderId);
    if (databaseSpaceFolder == null) {
        databaseSpaceFolder = new DefaultSchemaNode(databaseSpaceFolderId, DB_SPACE_FOLDER_NAME, "icons/navigator/volume_group.png");
        databaseSpaceFolder.setType(CubridNodeType.DBSPACE_FOLDER);
        databaseSpaceFolder.setContainer(true);
        databaseSpaceFolder.setEditorId(DatabaseStatusEditor.ID);
        ICubridNodeLoader loader = new CubridDbSpaceFolderLoader();
        loader.setLevel(getLevel());
        databaseSpaceFolder.setLoader(loader);
        database.addChild(databaseSpaceFolder);
        if (getLevel() == DEFINITE_LEVEL) {
            databaseSpaceFolder.getChildren(monitor);
        }
    } else {
        if (databaseSpaceFolder.getLoader() != null && databaseSpaceFolder.getLoader().isLoaded()) {
            databaseSpaceFolder.getLoader().setLoaded(false);
            databaseSpaceFolder.getChildren(monitor);
        }
    }
}
Also used : ICubridNodeLoader(com.cubrid.common.ui.spi.model.ICubridNodeLoader) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode)

Example 10 with ICubridNodeLoader

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

the class CubridDatabaseLoader method addProcedureFolder.

/**
	 * Add procedure folder
	 * 
	 * @param monitor the IProgressMonitor
	 * @param database the CubridDatabase
	 */
private void addProcedureFolder(final IProgressMonitor monitor, CubridDatabase database) {
    String spFolderId = database.getId() + NODE_SEPARATOR + CubridSPFolderLoader.SP_FOLDER_ID;
    ICubridNode spFolder = database.getChild(spFolderId);
    if (spFolder == null) {
        spFolder = new DefaultSchemaNode(spFolderId, SP_FOLDER_NAME, "icons/navigator/procedure_group.png");
        spFolder.setType(NodeType.STORED_PROCEDURE_FOLDER);
        spFolder.setContainer(true);
        ICubridNodeLoader loader = new CubridSPFolderLoader();
        loader.setLevel(getLevel());
        spFolder.setLoader(loader);
        database.addChild(spFolder);
        if (getLevel() == DEFINITE_LEVEL) {
            spFolder.getChildren(monitor);
        }
    } else {
        if (spFolder.getLoader() != null && spFolder.getLoader().isLoaded()) {
            spFolder.getLoader().setLoaded(false);
            spFolder.getChildren(monitor);
        }
    }
}
Also used : ICubridNodeLoader(com.cubrid.common.ui.spi.model.ICubridNodeLoader) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode) CubridSPFolderLoader(com.cubrid.common.ui.spi.model.loader.sp.CubridSPFolderLoader)

Aggregations

ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)27 ICubridNodeLoader (com.cubrid.common.ui.spi.model.ICubridNodeLoader)27 DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)21 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)9 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)5 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)5 DefaultCubridNode (com.cubrid.common.ui.spi.model.DefaultCubridNode)4 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)4 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)4 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)3 ClassInfo (com.cubrid.cubridmanager.core.cubrid.table.model.ClassInfo)3 ArrayList (java.util.ArrayList)3 CubridSerialFolderLoader (com.cubrid.common.ui.spi.model.loader.CubridSerialFolderLoader)2 CubridTriggerFolderLoader (com.cubrid.common.ui.spi.model.loader.CubridTriggerFolderLoader)2 CubridTablesFolderLoader (com.cubrid.common.ui.spi.model.loader.schema.CubridTablesFolderLoader)2 CubridViewsFolderLoader (com.cubrid.common.ui.spi.model.loader.schema.CubridViewsFolderLoader)2 CubridSPFolderLoader (com.cubrid.common.ui.spi.model.loader.sp.CubridSPFolderLoader)2 BrokerInfo (com.cubrid.cubridmanager.core.broker.model.BrokerInfo)2 BrokerInfos (com.cubrid.cubridmanager.core.broker.model.BrokerInfos)2 ServerType (com.cubrid.cubridmanager.core.common.model.ServerType)2