Search in sources :

Example 11 with CubridNodeChangedEventType

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

the class TableEditorPart method nodeChanged.

public void nodeChanged(CubridNodeChangedEvent event) {
    ICubridNode cubridNode = event.getCubridNode();
    CubridNodeChangedEventType eventType = event.getType();
    if (cubridNode == null || eventType == null) {
        return;
    }
    if (CubridNodeChangedEventType.SERVER_DISCONNECTED.equals(event.getType())) {
        close(event, database.getServer());
    }
    if (CubridNodeChangedEventType.DATABASE_LOGOUT.equals(event.getType()) || CubridNodeChangedEventType.DATABASE_STOP.equals(event.getType())) {
        close(event, database);
    }
}
Also used : CubridNodeChangedEventType(com.cubrid.common.ui.spi.event.CubridNodeChangedEventType) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode)

Example 12 with CubridNodeChangedEventType

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

the class ERSchemaEditor method close.

/**
	 * Close the editors which are the same server
	 * 
	 * @param event CubridNodeChangedEvent
	 * @param database CubridServer
	 */
public void close(CubridNodeChangedEvent event, CubridServer server) {
    ICubridNode cubridNode = event.getCubridNode();
    CubridNodeChangedEventType eventType = event.getType();
    if (cubridNode == null || eventType == null) {
        return;
    }
    if (event.getSource() instanceof CubridServer) {
        CubridServer eventCubridServer = (CubridServer) event.getSource();
        if (eventCubridServer.equals(server)) {
            IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
            if (window == null) {
                return;
            }
            window.getActivePage().closeEditor(this, true);
        }
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) CubridNodeChangedEventType(com.cubrid.common.ui.spi.event.CubridNodeChangedEventType) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridServer(com.cubrid.common.ui.spi.model.CubridServer)

Example 13 with CubridNodeChangedEventType

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

the class ERSchemaEditor method nodeChanged.

public void nodeChanged(CubridNodeChangedEvent event) {
    ICubridNode cubridNode = event.getCubridNode();
    CubridNodeChangedEventType eventType = event.getType();
    if (cubridNode == null || eventType == null) {
        return;
    }
    String type = cubridNode.getType();
    if (!NodeType.DATABASE.equals(type) && !NodeType.SERVER.equals(type)) {
        return;
    }
    if (!CubridNodeChangedEventType.DATABASE_LOGIN.equals(eventType) && !CubridNodeChangedEventType.DATABASE_LOGOUT.equals(eventType) && !CubridNodeChangedEventType.NODE_REMOVE.equals(eventType) && !CubridNodeChangedEventType.NODE_REFRESH.equals(eventType) && !CubridNodeChangedEventType.SERVER_DISCONNECTED.equals(eventType)) {
        return;
    }
    if (NodeType.SERVER.equals(type) && cubridNode instanceof CubridServer) {
        if (CubridNodeChangedEventType.NODE_REMOVE.equals(eventType) || CubridNodeChangedEventType.SERVER_DISCONNECTED.equals(eventType)) {
            Object obj = database.getAdapter(ServerInfo.class);
            CubridServer server = (CubridServer) cubridNode;
            ServerInfo severInfo = server.getServerInfo();
            if (severInfo != null && severInfo.equals(obj)) {
                setDatabase(ERVirtualDatabase.getInstance());
                CubridNodeManager.getInstance().removeCubridNodeChangeListener(this);
            }
        }
    }
    if (CubridNodeChangedEventType.DATABASE_LOGOUT.equals(eventType) || CubridNodeChangedEventType.NODE_REMOVE.equals(eventType)) {
        if (cubridNode.equals(database)) {
            setDatabase(ERVirtualDatabase.getInstance());
            CubridNodeManager.getInstance().removeCubridNodeChangeListener(this);
        }
    }
    synchronized (this) {
        erToolBar.refresh();
    }
}
Also used : CubridNodeChangedEventType(com.cubrid.common.ui.spi.event.CubridNodeChangedEventType) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) EventObject(java.util.EventObject) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridServer(com.cubrid.common.ui.spi.model.CubridServer)

Aggregations

CubridNodeChangedEventType (com.cubrid.common.ui.spi.event.CubridNodeChangedEventType)13 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)13 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)5 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)4 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)3 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)2 DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)1 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)1 EventObject (java.util.EventObject)1