Search in sources :

Example 36 with CubridNodeChangedEvent

use of com.cubrid.common.ui.spi.event.CubridNodeChangedEvent in project cubrid-manager by CUBRID.

the class CubridWorkbenchContrItem method checkConnectionStatus.

/**
	 * When selection changed,check whether selected server is connected
	 *
	 * @param selection the ISelection object
	 */
private void checkConnectionStatus(ISelection selection) {
    if (selection == null || selection.isEmpty()) {
        return;
    }
    Object obj = ((IStructuredSelection) selection).getFirstElement();
    if (!(obj instanceof ICubridNode)) {
        return;
    }
    ICubridNode cubridNode = (ICubridNode) obj;
    CubridServer cubridServer = cubridNode.getServer();
    if (cubridServer == null) {
        return;
    }
    ServerInfo serverInfo = cubridServer.getServerInfo();
    boolean needToCheck = !serverInfo.isConnected() && (!(obj instanceof CubridServer) || (cubridServer.getChildren() != null && cubridServer.getChildren().size() > 0));
    if (needToCheck) {
        boolean connectAgagin = false;
        if (CommonUITool.openConfirmBox(Messages.errCannotConnectServerReconnect)) {
            connectAgagin = true;
        }
        closeAllEditorAndViewInServer(cubridServer, false);
        cubridServer.removeAllChild();
        TreeViewer viewer = (TreeViewer) LayoutManager.getInstance().getSelectionProvider();
        viewer.refresh(cubridServer);
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(cubridServer, CubridNodeChangedEventType.SERVER_DISCONNECTED));
        if (connectAgagin && connectHost(serverInfo, true)) {
            refreshAfterConnected(cubridServer);
        }
    }
}
Also used : ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) TreeViewer(org.eclipse.jface.viewers.TreeViewer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) CubridServer(com.cubrid.common.ui.spi.model.CubridServer)

Example 37 with CubridNodeChangedEvent

use of com.cubrid.common.ui.spi.event.CubridNodeChangedEvent in project cubrid-manager by CUBRID.

the class CQBConnectionChangingObserver method afterModify.

/**
	 * When modify an existed connection.
	 *
	 * @param initiator IJDBCInfoChangedSubject who triggered the event.
	 * @param oldCon IJDBCConnecInfo
	 * @param newCon IJDBCConnecInfo
	 */
public void afterModify(IJDBCInfoChangedSubject initiator, IJDBCConnecInfo oldCon, IJDBCConnecInfo newCon) {
    if (CQBDBNodePersistManager.getInstance().equals(initiator)) {
        return;
    }
    //If not a CUBRID connection
    if (oldCon.getDbType() != 1 || newCon.getDbType() != 1) {
        return;
    }
    /*Must fire database changed event first*/
    CubridDatabase database = CQBDatabaseFactory.getDatabaseJDBCConnectInfo(oldCon);
    if (database != null) {
        if (isNeedLogout(oldCon, newCon)) {
            CQBConnectionUtils.processConnectionLogout(database);
            CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(database, CubridNodeChangedEventType.DATABASE_LOGOUT));
        }
        CubridDatabase newDatabase = CQBDatabaseFactory.modifyDatabaseByJDBCConnectInfo(oldCon, newCon);
        CQBDBNodePersistManager.getInstance().saveDatabases();
        refreshNavigationTree(newDatabase);
    } else {
        database = CQBDatabaseFactory.createDatabase(newCon);
        CQBDBNodePersistManager.getInstance().addDatabase(database, true);
        refreshNavigationTree(null);
    }
}
Also used : CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 38 with CubridNodeChangedEvent

use of com.cubrid.common.ui.spi.event.CubridNodeChangedEvent in project cubrid-manager by CUBRID.

the class CQBDBNodePersistManager method addDatabase.

/**
	 *
	 * Add database
	 *
	 * @param database the CubridDatabase object
	 * @param silence if true the event will not be triggered.
	 */
public void addDatabase(CubridDatabase database, boolean silence) {
    synchronized (this) {
        if (database != null) {
            databaseList.add(database);
            saveDatabases();
            CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(database, CubridNodeChangedEventType.NODE_ADD));
            if (!silence) {
                fireAddDatabase(database);
            }
        }
    }
}
Also used : CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)

Example 39 with CubridNodeChangedEvent

use of com.cubrid.common.ui.spi.event.CubridNodeChangedEvent in project cubrid-manager by CUBRID.

the class CMHostNodePersistManager method removeServer.

/**
	 *
	 * Remove server
	 *
	 * @param server the CubridServer object
	 */
public void removeServer(CubridServer server) {
    synchronized (this) {
        if (server != null) {
            ServerManager.getInstance().removeServer(server.getServerInfo().getHostAddress(), server.getServerInfo().getHostMonPort(), server.getServerInfo().getUserName());
            serverList.remove(server);
            CMDBNodePersistManager.getInstance().deleteParameter(server);
            saveServers();
            CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(server, CubridNodeChangedEventType.NODE_REMOVE));
        }
    }
}
Also used : CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)

Example 40 with CubridNodeChangedEvent

use of com.cubrid.common.ui.spi.event.CubridNodeChangedEvent in project cubrid-manager by CUBRID.

the class CMHostNodePersistManager method removeAllServer.

/**
	 *
	 * Remove all servers
	 *
	 */
public void removeAllServer() {
    synchronized (this) {
        for (int i = 0; i < serverList.size(); i++) {
            CubridServer server = serverList.get(i);
            ServerManager.getInstance().removeServer(server.getHostAddress(), server.getServerInfo().getHostMonPort(), server.getServerInfo().getUserName());
            serverList.remove(server);
            CMDBNodePersistManager.getInstance().deleteParameter(server);
            CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(server, CubridNodeChangedEventType.NODE_REMOVE));
        }
        saveServers();
    }
}
Also used : CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) CubridServer(com.cubrid.common.ui.spi.model.CubridServer)

Aggregations

CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)98 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)55 TreeViewer (org.eclipse.jface.viewers.TreeViewer)45 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)42 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)23 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)23 CubridNavigatorView (com.cubrid.common.ui.common.navigator.CubridNavigatorView)21 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)21 DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)17 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)17 ArrayList (java.util.ArrayList)13 DefaultCubridNode (com.cubrid.common.ui.spi.model.DefaultCubridNode)11 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)10 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)10 ClassInfo (com.cubrid.cubridmanager.core.cubrid.table.model.ClassInfo)10 Display (org.eclipse.swt.widgets.Display)10 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)9 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)9 DbUserInfo (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo)9 ICubridNodeLoader (com.cubrid.common.ui.spi.model.ICubridNodeLoader)8