use of com.cubrid.common.ui.spi.model.CubridGroupNode in project cubrid-manager by CUBRID.
the class ServiceDashboardEditor method loadAllData.
/**
* Load all data
*/
public void loadAllData() {
ServiceDashboardInfoMap.clear();
CubridNavigatorView navigatorView = CubridNavigatorView.findNavigationView();
if (navigatorView != null && navigatorView.savedIsShowGroup()) {
inputList = CMGroupNodePersistManager.getInstance().getAllGroupNodes();
List<CubridGroupNode> groupList = loadCubridGroupData(inputList);
serviceTreeViewer.setInput(groupList);
} else {
inputList = CMHostNodePersistManager.getInstance().getAllServers();
loadServerDashboardInfo(inputList);
serviceTreeViewer.setInput(ServiceDashboardInfoMap);
}
serviceTreeViewer.expandAll();
}
use of com.cubrid.common.ui.spi.model.CubridGroupNode in project cubrid-manager by CUBRID.
the class CQDatabaseNavigatorMenu method loadNavigatorMenu.
/**
* load all database on all server. if not login or database not started,
* the item disabled.
*
* @param dbSelectionMenu
*/
public void loadNavigatorMenu(Menu dbSelectionMenu) {
setSelectedImage(CubridQueryUIPlugin.getImage("/icons/navigator/eclipse_dot.png"));
CubridNavigatorView navigatorView = CubridNavigatorView.getNavigatorView(CubridQueryNavigatorView.ID);
boolean isShowGroup = navigatorView == null ? false : navigatorView.isShowGroup();
List<CubridGroupNode> groupList = CQBGroupNodePersistManager.getInstance().getAllGroupNodes();
if (groupList == null || groupList.isEmpty()) {
return;
}
Collections.sort(groupList, new Comparator<CubridGroupNode>() {
public int compare(CubridGroupNode o1, CubridGroupNode o2) {
if (o1 == null || o2 == null || o1.getLabel() == null || o2.getLabel() == null) {
return 0;
}
return o1.getLabel().compareToIgnoreCase(o2.getLabel());
}
});
int count = 0;
for (CubridGroupNode groupNode : groupList) {
// if (NodeFilterManager.getInstance().isHidden(groupNode)) {
// continue;
// }
List<ICubridNode> nodeList = groupNode.getChildren();
if (nodeList == null || nodeList.isEmpty()) {
continue;
}
DatabaseMenuItem groupMenuItem = null;
Menu groupSub = null;
String groupName = null;
if (isShowGroup) {
groupName = groupNode.getLabel();
groupMenuItem = new DatabaseMenuItem(groupNode.getId(), dbSelectionMenu, SWT.CASCADE);
groupMenuItem.setImage(CubridQueryUIPlugin.getImage("/icons/navigator/group.png"));
groupMenuItem.setText(groupNode.getLabel());
groupSub = new Menu(dbSelectionMenu);
groupMenuItem.setMenu(groupSub);
}
Collections.sort(nodeList, new Comparator<ICubridNode>() {
public int compare(ICubridNode o1, ICubridNode o2) {
if (o1 == null || o2 == null || o1.getLabel() == null || o2.getLabel() == null) {
return 0;
}
return o1.getLabel().compareToIgnoreCase(o2.getLabel());
}
});
int itemCountInGroup = 0;
for (ICubridNode node : nodeList) {
// }
if (node instanceof CubridDatabase) {
CubridDatabase database = (CubridDatabase) node;
if (!database.isLogined()) {
continue;
}
itemCountInGroup++;
DatabaseMenuItem dbItem = null;
if (isShowGroup) {
dbItem = new DatabaseMenuItem(database.getId(), groupSub, SWT.RADIO);
} else {
dbItem = new DatabaseMenuItem(database.getId(), dbSelectionMenu, SWT.RADIO);
}
dbItem.setText(database.getLabelWithUser());
dbItem.setDatabase((CubridDatabase) database);
dbItem.setEnabled(database.isLogined() && database.getRunningType() == DbRunningType.CS);
dbItem.setGroupName(groupName);
count++;
}
}
// If it has no active item on the group, it's group should be disposed
if (isShowGroup && itemCountInGroup <= 0 && groupSub != null && groupMenuItem != null) {
groupSub.dispose();
groupMenuItem.dispose();
}
}
if (count > 0) {
new MenuItem(dbSelectionMenu, SWT.SEPARATOR);
}
}
use of com.cubrid.common.ui.spi.model.CubridGroupNode in project cubrid-manager by CUBRID.
the class CQBGroupNodePersistManager method addGroupNode.
/**
* Add a new group node to list. The default group node only contain the
* items which has no parent group.
*
* @param group new group node.
*/
public void addGroupNode(CubridGroupNode group) {
synchronized (this) {
if (!groupNodeList.contains(group)) {
groupNodeList.add(group);
}
//refresh the default node.
List<ICubridNode> nodesHasParent = new ArrayList<ICubridNode>();
CubridGroupNode dftNode = null;
for (CubridGroupNode grp : groupNodeList) {
//if is default node, don't add children here.
if (isDefaultGroup(grp)) {
dftNode = grp;
} else {
nodesHasParent.addAll(grp.getChildren());
}
}
dftNode.removeAllChild();
List<CubridDatabase> databases = CQBDBNodePersistManager.getInstance().getAllDatabase();
for (CubridDatabase db : databases) {
if (!nodesHasParent.contains(db)) {
dftNode.addChild(db);
}
}
}
}
use of com.cubrid.common.ui.spi.model.CubridGroupNode in project cubrid-manager by CUBRID.
the class CQBGroupNodePersistManager method loadGroupNode.
/**
* Load group nodes from xml memento.
*
* @param memento IXMLMemento
*/
private void loadGroupNode(IXMLMemento memento) {
if (memento != null) {
IXMLMemento[] children = memento.getChildren("group");
for (int i = 0; i < children.length; i++) {
String id = children[i].getString("id");
String name = children[i].getString("name");
CubridGroupNode cgn = getGroupById(id);
if (cgn == null) {
cgn = new CubridGroupNode(id, name, DEFAULT_GROUP_NODE.getIconPath());
groupNodeList.add(cgn);
}
cgn.setLoader(DEFAULT_GROUP_NODE.getLoader());
IXMLMemento[] items = children[i].getChildren("item");
for (IXMLMemento item : items) {
String itemId = item.getString("id");
CubridDatabase cs = CQBDBNodePersistManager.getInstance().getDatabase(itemId);
if (cs == null || cs.getParent() != null) {
continue;
}
cgn.addChild(cs);
}
}
}
//groupNodeList.size >=1
if (groupNodeList.isEmpty()) {
try {
CubridGroupNode defaultGroup = (CubridGroupNode) DEFAULT_GROUP_NODE.clone();
groupNodeList.add(defaultGroup);
List<CubridDatabase> servers = CQBDBNodePersistManager.getInstance().getAllDatabase();
for (CubridDatabase server : servers) {
defaultGroup.addChild(server);
}
} catch (CloneNotSupportedException e) {
LOGGER.error(e.getMessage());
}
}
}
use of com.cubrid.common.ui.spi.model.CubridGroupNode in project cubrid-manager by CUBRID.
the class CQBGroupNodePersistManager method saveAllGroupNode.
/**
* Save all group node.
*
*/
public void saveAllGroupNode() {
synchronized (this) {
XMLMemento memento = XMLMemento.createWriteRoot("groups");
for (CubridGroupNode group : groupNodeList) {
IXMLMemento child = memento.createChild("group");
child.putString("id", group.getId());
child.putString("name", group.getName());
for (ICubridNode cn : group.getChildren()) {
IXMLMemento childHost = child.createChild("item");
childHost.putString("id", cn.getId());
}
}
PersistUtils.saveXMLMemento(ApplicationUtil.CQB_UI_PLUGIN_ID, COM_CUBRID_QB_DBGROUP, memento);
}
}
Aggregations