use of com.cubrid.common.ui.spi.model.CubridGroupNode in project cubrid-manager by CUBRID.
the class PasteHostAction method isSupported.
/**
*
* Return whether this action support this object,if not support,this action
* will be disabled
*
* @param obj the Object
* @return <code>true</code> if support this obj;<code>false</code>
* otherwise
*/
public boolean isSupported(Object obj) {
CubridNavigatorView navigatorView = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
if (navigatorView == null) {
return false;
}
boolean isShowGroup = navigatorView.isShowGroup();
if (isShowGroup && !(obj instanceof CubridServer) && !(obj instanceof CubridGroupNode)) {
return false;
}
if (!isShowGroup && obj != null && !(obj instanceof CubridServer)) {
return false;
}
Object[] objs = null;
ISelection selection = LocalSelectionTransfer.getTransfer().getSelection();
if (selection instanceof IStructuredSelection) {
IStructuredSelection strSelection = (IStructuredSelection) selection;
objs = strSelection.toArray();
}
if (objs == null || objs.length == 0) {
return false;
}
if (!(objs[0] instanceof CubridServer)) {
return false;
}
return true;
}
use of com.cubrid.common.ui.spi.model.CubridGroupNode in project cubrid-manager by CUBRID.
the class ServiceDashboardEditor method loadCubridGroupData.
/**
* Load cubrid group data
*/
private List<CubridGroupNode> loadCubridGroupData(Object input) {
@SuppressWarnings("unchecked") List<CubridGroupNode> groupList = (List<CubridGroupNode>) input;
List<CubridGroupNode> newGroupList = new ArrayList<CubridGroupNode>();
List<CubridServer> serverList = new ArrayList<CubridServer>();
if (groupList != null) {
for (CubridGroupNode groupNode : groupList) {
serverList = new ArrayList<CubridServer>();
CubridGroupNode newGroupNode = new CubridGroupNode(groupNode.getId(), groupNode.getLabel(), groupNode.getIconPath());
List<ICubridNode> nodeList = ((CubridGroupNode) groupNode).getChildren();
for (ICubridNode node : nodeList) {
serverList.add((CubridServer) node);
}
loadServerDashboardInfo(serverList);
for (CubridServer server : serverList) {
newGroupNode.addChild(ServiceDashboardInfoMap.get(server.getName()));
}
newGroupList.add(newGroupNode);
}
}
return newGroupList;
}
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 CMDatabaseNavigatorMenu 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(CubridManagerUIPlugin.getImage("/icons/navigator/eclipse_dot.png"));
CubridNavigatorView navigatorView = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
boolean isShowGroup = navigatorView == null ? false : navigatorView.isShowGroup();
List<CubridGroupNode> groupList = CMGroupNodePersistManager.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(CubridManagerUIPlugin.getImage("/icons/navigator/group.png"));
groupMenuItem.setText(groupName);
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 CubridServer) {
CubridServer server = (CubridServer) node;
ICubridNode databaseFolderNode = server.getChild(server.getId() + ICubridNodeLoader.NODE_SEPARATOR + CubridServerLoader.DATABASE_FOLDER_ID);
if (databaseFolderNode == null) {
continue;
}
// if (NodeFilterManager.getInstance().isHidden(databaseFolderNode)) {
// continue;
// }
ICubridNode[] dbs = databaseFolderNode.getChildren(new NullProgressMonitor());
if (dbs == null || dbs.length == 0) {
continue;
}
String serverName = server.getLabel();
DatabaseMenuItem serverMenuItem = null;
Menu serverSub = null;
if (isShowGroup) {
serverMenuItem = new DatabaseMenuItem(server.getId(), groupSub, SWT.CASCADE);
serverMenuItem.setImage(CubridManagerUIPlugin.getImage("/icons/navigator/host.png"));
serverMenuItem.setText(serverName);
serverSub = new Menu(groupSub);
serverMenuItem.setMenu(serverSub);
} else {
serverMenuItem = new DatabaseMenuItem(server.getId(), dbSelectionMenu, SWT.CASCADE);
serverMenuItem.setImage(CubridManagerUIPlugin.getImage("/icons/navigator/host.png"));
serverMenuItem.setText(serverName);
serverSub = new Menu(dbSelectionMenu);
serverMenuItem.setMenu(serverSub);
}
count++;
for (ICubridNode database : dbs) {
// if (NodeFilterManager.getInstance().isHidden(database)) {
// continue;
// }
CubridDatabase db = (CubridDatabase) database;
if (!db.isLogined()) {
continue;
}
itemCountInGroup++;
DatabaseMenuItem dbItem = new DatabaseMenuItem(database.getId(), serverSub, SWT.RADIO);
dbItem.setText(database.getLabel());
dbItem.setDatabase((CubridDatabase) database);
dbItem.setEnabled(db.isLogined() && db.getRunningType() == DbRunningType.CS);
dbItem.setGroupName(groupName);
count++;
}
}
}
if (itemCountInGroup <= 0 && groupSub != null && groupMenuItem != null) {
groupSub.dispose();
groupMenuItem.dispose();
continue;
}
}
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 NewQueryConnAction method run.
/**
* Open the QueryConnDialog
*/
public void run() {
QueryConnDialog dialog = new QueryConnDialog(getShell(), null, true);
int returnCode = dialog.open();
if (returnCode == QueryConnDialog.CONNECT_ID || returnCode == QueryConnDialog.SAVE_ID) {
CubridDatabase database = dialog.getDatabase();
CQBDBNodePersistManager.getInstance().addDatabase(database, false);
CubridNavigatorView navigatorView = CubridNavigatorView.getNavigatorView(CubridQueryNavigatorView.ID);
TreeViewer treeViewer = navigatorView == null ? null : navigatorView.getViewer();
if (treeViewer == null) {
return;
}
Tree tree = treeViewer.getTree();
TreeItem item;
CubridGroupNode parent = getParentGroupNode();
if (navigatorView.isShowGroup()) {
item = new TreeItem(navigatorView.getTreeItemByData(parent), SWT.NONE);
} else {
item = new TreeItem(tree, SWT.NONE);
}
parent.addChild(database);
CQBGroupNodePersistManager.getInstance().saveAllGroupNode();
item.setText(database.getLabel());
item.setData(database);
treeViewer.refresh(database, true);
treeViewer.expandToLevel(database, 1);
treeViewer.setSelection(new StructuredSelection(database), true);
if (returnCode == QueryConnDialog.CONNECT_ID) {
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(database, CubridNodeChangedEventType.DATABASE_LOGIN));
}
}
}
Aggregations