use of com.cubrid.common.ui.spi.model.CubridGroupNode in project cubrid-manager by CUBRID.
the class GroupSettingDialog method okPressed.
/**
* If OK pressed.
*/
protected void okPressed() {
//copy edit result to persist.
java.util.List<String> newIds = new ArrayList<String>();
for (CubridGroupNode grp : groups) {
newIds.add(grp.getId());
CubridGroupNode oldgrp = nodeManager.getGroupById(grp.getId());
if (oldgrp == null) {
CubridGroupNode newgrp = new CubridGroupNode(grp.getId(), grp.getName(), grp.getIconPath());
copyGroupChild2Persist(grp, newgrp);
nodeManager.addGroupNode(newgrp);
} else {
oldgrp.removeAllChild();
copyGroupChild2Persist(grp, oldgrp);
}
}
java.util.List<String> deleteIds = new ArrayList<String>();
for (CubridGroupNode oldgrp : nodeManager.getAllGroupNodes()) {
if (newIds.indexOf(oldgrp.getId()) < 0) {
deleteIds.add(oldgrp.getId());
}
}
for (String id : deleteIds) {
nodeManager.removeGroup(id);
}
nodeManager.reorderGroup(groupList.getItems());
super.okPressed();
}
use of com.cubrid.common.ui.spi.model.CubridGroupNode in project cubrid-manager by CUBRID.
the class GroupSettingDialog method refreshDefaultNode.
/**
* Refresh the default node's children.
*
*/
private void refreshDefaultNode() {
java.util.List<ICubridNode> nodeWithParent = new ArrayList<ICubridNode>();
CubridGroupNode defaultGrp = null;
for (CubridGroupNode grp : groups) {
if (nodeManager.isDefaultGroup(grp)) {
defaultGrp = grp;
} else {
nodeWithParent.addAll(grp.getChildren());
}
}
if (defaultGrp == null) {
LOGGER.warn("The defaultGrp is a null.");
return;
}
defaultGrp.removeAllChild();
java.util.List<ICubridNode> allItems = nodeManager.getAllGroupItems();
for (ICubridNode item : allItems) {
if (nodeWithParent.indexOf(item) < 0) {
defaultGrp.addChild(item);
}
}
}
use of com.cubrid.common.ui.spi.model.CubridGroupNode in project cubrid-manager by CUBRID.
the class GroupSettingDialog method createManagerButtons.
/**
* Create the buttons about add ,edit and delete.
*
* @param parentComp parent composite.
*/
private void createManagerButtons(Composite parentComp) {
Composite group2 = new Composite(parentComp, SWT.NONE);
{
group2.setLayout(new GridLayout(3, true));
group2.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Button btnNew = new Button(group2, SWT.NONE);
btnNew.setText(Messages.btnAdd);
btnNew.addSelectionListener(new SelectionAdapter() {
/**
* push button event
*
* @param event SelectionEvent
*/
public void widgetSelected(SelectionEvent event) {
GroupEditDialog dialog = new GroupEditDialog(GroupSettingDialog.this.getShell(), nodeManager, groups, null);
if (dialog.open() == Dialog.OK) {
CubridGroupNode groupNode = dialog.getGroup();
if (groupNode == null) {
LOGGER.warn("The groupNode is a null.");
} else {
groupList.add(groupNode.getName());
groups.add(groupNode);
}
refreshDefaultNode();
}
}
});
btnEdit = new Button(group2, SWT.NONE);
btnEdit.setText(Messages.btnEdit);
btnEdit.addSelectionListener(new SelectionAdapter() {
/**
* push button event
*
* @param event SelectionEvent
*/
public void widgetSelected(SelectionEvent event) {
GroupEditDialog dialog = new GroupEditDialog(GroupSettingDialog.this.getShell(), nodeManager, groups, getGroupByName(groupList.getSelection()[0]));
if (dialog.open() == Dialog.OK) {
CubridGroupNode groupNode = dialog.getGroup();
if (groupNode == null) {
LOGGER.warn("The groupNode is a null.");
} else {
groupList.setItem(groupList.getSelectionIndex(), groupNode.getName());
}
refreshDefaultNode();
}
}
});
btnRemove = new Button(group2, SWT.NONE);
btnRemove.setText(Messages.btnDelete);
btnRemove.addSelectionListener(new SelectionAdapter() {
/**
* push button event
*
* @param event SelectionEvent
*/
public void widgetSelected(SelectionEvent event) {
for (String grpName : groupList.getSelection()) {
CubridGroupNode cgn = getGroupByName(grpName);
groups.remove(cgn);
int idx = groupList.getSelectionIndex();
if (idx == groupList.getItemCount() - 1) {
idx--;
}
groupList.remove(grpName);
groupList.setSelection(idx);
setButtonStatus();
}
refreshDefaultNode();
}
});
}
}
use of com.cubrid.common.ui.spi.model.CubridGroupNode in project cubrid-manager by CUBRID.
the class GroupPropertyAction method isSupported.
/**
* Support CubridGroupNode except Default Group Node
*
* @param obj Object that selected.
* @return support or not.
*/
public boolean isSupported(Object obj) {
boolean ins = obj instanceof CubridGroupNode;
if (!ins) {
return false;
}
CubridGroupNode group = (CubridGroupNode) obj;
return !group.getId().equals(ICubridGroupNodeManager.DEFAULT_GROUP_NODE.getId());
}
use of com.cubrid.common.ui.spi.model.CubridGroupNode in project cubrid-manager by CUBRID.
the class NavigatorViewSorter method compare.
/**
* @see <code>ViewerSorter</code>
*
* @param viewer
* Viewer
* @param e1
* Object
* @param e2
* Object
*
* @return int
*/
public int compare(Viewer viewer, Object e1, Object e2) {
if (e1 == null && e2 == null) {
return 0;
}
if (e1 == null) {
return -1;
}
if (e2 == null) {
return -1;
}
if (!(e1 instanceof ICubridNode) || !(e2 instanceof ICubridNode)) {
return 0;
}
ICubridNode node1 = (ICubridNode) e1;
ICubridNode node2 = (ICubridNode) e2;
// If group node, not sorting
if (node1 instanceof CubridGroupNode) {
return 0;
} else // If cubrid group node ,use the list's order
if ((node1 instanceof CubridServer) || (node1 instanceof CubridDatabase)) {
return order * node1.getLabel().compareTo(node2.getLabel());
}
int cat1 = category(node1);
int cat2 = category(node2);
if (cat1 > 0 && cat2 > 0) {
return cat1 - cat2;
}
if (cat1 != cat2) {
return cat1 - cat2;
}
return node1.compareTo(node2);
}
Aggregations