Search in sources :

Example 46 with CubridGroupNode

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

the class CQBGroupNodePersistManager method fix.

/**
	 * To fix when it has crashed group information
	 */
public void fix() {
    List<CubridDatabase> dbs = CQBDBNodePersistManager.getInstance().getAllDatabase();
    if (dbs == null)
        return;
    List<ICubridNode> cnodes = new ArrayList<ICubridNode>();
    try {
        List<CubridGroupNode> gnodes = getAllGroupNodes();
        for (int i = 0; i < gnodes.size(); i++) {
            CubridGroupNode node = gnodes.get(i);
            List<ICubridNode> snode = node.getChildren();
            for (int j = 0; j < snode.size(); j++) {
                cnodes.add(snode.get(j));
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    try {
        for (int i = 0; i < dbs.size(); i++) {
            CubridDatabase db = dbs.get(i);
            String gid = db.getName() + "/" + db.getName();
            boolean exists = false;
            for (int j = 0; j < cnodes.size(); j++) {
                ICubridNode cnode = cnodes.get(j);
                if (cnode.getId() != null && cnode.getId().equals(gid)) {
                    exists = true;
                    break;
                }
            }
            if (!exists) {
                getDefaultGroup().addChild(db);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    saveAllGroupNode();
}
Also used : CubridGroupNode(com.cubrid.common.ui.spi.model.CubridGroupNode) ArrayList(java.util.ArrayList) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) IOException(java.io.IOException)

Aggregations

CubridGroupNode (com.cubrid.common.ui.spi.model.CubridGroupNode)46 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)25 CubridNavigatorView (com.cubrid.common.ui.common.navigator.CubridNavigatorView)15 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)15 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)15 ArrayList (java.util.ArrayList)11 TreeViewer (org.eclipse.jface.viewers.TreeViewer)11 TreeItem (org.eclipse.swt.widgets.TreeItem)9 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)6 Tree (org.eclipse.swt.widgets.Tree)6 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)5 IXMLMemento (com.cubrid.cubridmanager.core.common.xml.IXMLMemento)4 HostDialog (com.cubrid.cubridmanager.ui.host.dialog.HostDialog)4 ISelection (org.eclipse.jface.viewers.ISelection)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 MenuItem (org.eclipse.swt.widgets.MenuItem)4 DatabaseMenuItem (com.cubrid.common.ui.query.control.DatabaseMenuItem)3 QueryConnDialog (com.cubrid.cubridquery.ui.connection.dialog.QueryConnDialog)3 List (java.util.List)3 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)3