use of com.cubrid.common.ui.spi.model.CubridGroupNode in project cubrid-manager by CUBRID.
the class PasteQueryConnAction 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) {
if (ApplicationType.CUBRID_QUERY_BROWSER.equals(PerspectiveManager.getInstance().getCurrentMode())) {
CubridNavigatorView navigatorView = CubridNavigatorView.getNavigatorView(CubridQueryNavigatorView.ID);
if (navigatorView == null) {
return false;
}
boolean isShowGroup = navigatorView.isShowGroup();
if (isShowGroup && !(obj instanceof CubridDatabase) && !(obj instanceof CubridGroupNode)) {
return false;
}
if (!isShowGroup && obj != null && !(obj instanceof CubridDatabase)) {
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 CubridDatabase)) {
return false;
}
return true;
}
return false;
}
use of com.cubrid.common.ui.spi.model.CubridGroupNode in project cubrid-manager by CUBRID.
the class CMGroupNodePersistManager method reorderGroup.
/**
* Reorder the groups by input string array.
*
* @param orderedName the ordered group names.
*/
public void reorderGroup(String[] orderedName) {
List<CubridGroupNode> tempNode = new ArrayList<CubridGroupNode>();
for (String name : orderedName) {
CubridGroupNode cgn = getGroupByName(name);
if (cgn == null) {
continue;
}
tempNode.add(cgn);
}
groupNodeList.clear();
groupNodeList.addAll(tempNode);
saveAllGroupNode();
}
use of com.cubrid.common.ui.spi.model.CubridGroupNode in project cubrid-manager by CUBRID.
the class CMGroupNodePersistManager 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<CubridServer> servers = CMHostNodePersistManager.getInstance().getAllServers();
for (CubridServer ser : servers) {
if (!nodesHasParent.contains(ser)) {
dftNode.addChild(ser);
}
}
}
}
use of com.cubrid.common.ui.spi.model.CubridGroupNode in project cubrid-manager by CUBRID.
the class CMGroupNodePersistManager method loadGroupNode.
/**
* Load group nodes from xml memento.
*
* @param memento IXMLMemento
*
*/
private void loadGroupNode(IXMLMemento memento) {
IXMLMemento[] children = memento == null ? null : memento.getChildren("group");
groupNodeList.clear();
for (int i = 0; children != null && 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");
CubridServer cs = CMHostNodePersistManager.getInstance().getServer(itemId);
if (cs == null) {
continue;
}
cgn.addChild(cs);
}
}
//groupNodeList.size >=1
if (groupNodeList.isEmpty()) {
try {
groupNodeList.add((CubridGroupNode) DEFAULT_GROUP_NODE.clone());
List<CubridServer> servers = CMHostNodePersistManager.getInstance().getAllServers();
for (CubridServer server : servers) {
groupNodeList.get(0).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 CMGroupNodePersistManager method removeGroup.
/**
* Remove group by id
*
* @param groupId group id or group name
*/
public void removeGroup(String groupId) {
List<CubridGroupNode> groups = getAllGroupNodes();
CubridGroupNode tobeRemoved = null;
for (CubridGroupNode group : groups) {
if (group.getId().equals(groupId)) {
tobeRemoved = group;
}
}
this.groupNodeList.remove(tobeRemoved);
CubridGroupNode defaultGroup = getDefaultGroup();
List<ICubridNode> children = tobeRemoved.getChildren();
for (ICubridNode chi : children) {
defaultGroup.addChild(chi);
}
saveAllGroupNode();
}
Aggregations