use of com.cubrid.common.ui.spi.model.CubridGroupNode in project cubrid-manager by CUBRID.
the class CQBGroupNodePersistManager 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 PasteQueryConnAction method run.
/**
* Paste the query connection
*/
public void run() {
Object[] objs = this.getSelectedObj();
if (!isSupported(objs[0])) {
setEnabled(false);
return;
}
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;
}
if (!(objs[0] instanceof CubridDatabase)) {
return;
}
CubridDatabase pastedDb = (CubridDatabase) objs[0];
QueryConnDialog dialog = new QueryConnDialog(getShell(), pastedDb, 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));
}
}
}
use of com.cubrid.common.ui.spi.model.CubridGroupNode in project cubrid-manager by CUBRID.
the class CreateConnectionByUrlWizard method performFinish.
/**
* Perform finish
*/
public boolean performFinish() {
List<CubridDatabase> parsedDatabaseList = connectionPriviewPage.getParsedConnection();
/*Add the database list to the tree*/
CubridNavigatorView navigatorView = CubridNavigatorView.getNavigatorView(CubridQueryNavigatorView.ID);
TreeViewer treeViewer = navigatorView == null ? null : navigatorView.getViewer();
if (treeViewer == null) {
return false;
}
for (CubridDatabase database : parsedDatabaseList) {
CQBDBNodePersistManager.getInstance().addDatabase(database, false);
Tree tree = treeViewer.getTree();
TreeItem item;
CubridGroupNode parent = CQBGroupNodePersistManager.getInstance().getDefaultGroup();
if (navigatorView.isShowGroup()) {
item = new TreeItem(navigatorView.getTreeItemByData(parent), SWT.NONE);
} else {
item = new TreeItem(tree, SWT.NONE);
}
parent.addChild(database);
item.setText(database.getLabel());
item.setData(database);
treeViewer.refresh(database, true);
treeViewer.expandToLevel(database, 1);
treeViewer.setSelection(new StructuredSelection(database), true);
}
CQBGroupNodePersistManager.getInstance().saveAllGroupNode();
return true;
}
use of com.cubrid.common.ui.spi.model.CubridGroupNode in project cubrid-manager by CUBRID.
the class ItemNodeDnDHandler method handle.
/**
* Handle the node to be DND.
*
* @param dragNode the drag node
* @param dropNode the drop node
* @param insertBefore insert into the drop node before or after
* @param dropOperation the drop operation type <code>DND.DROP_COPY</code>
* <code>DND.DROP_MOVE</code>
* @return boolean whether to handle with the drop
*/
public boolean handle(ICubridNode dragNode, ICubridNode dropNode, boolean insertBefore, int dropOperation) {
ICubridNode newDragNode = dragNode;
if (DND.DROP_COPY == dropOperation && dragNode instanceof CubridDatabase) {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
QueryConnDialog dialog = new QueryConnDialog(shell, (CubridDatabase) dragNode, true);
int returnCode = dialog.open();
if (returnCode == QueryConnDialog.CONNECT_ID || returnCode == QueryConnDialog.SAVE_ID) {
newDragNode = dialog.getDatabase();
CQBDBNodePersistManager.getInstance().addDatabase((CubridDatabase) newDragNode, false);
CubridGroupNode groupNode = CQBGroupNodePersistManager.getInstance().getDefaultGroup();
groupNode.addChild(newDragNode);
} else {
return false;
}
}
return super.handle(newDragNode, dropNode, insertBefore, dropOperation);
}
use of com.cubrid.common.ui.spi.model.CubridGroupNode in project cubrid-manager by CUBRID.
the class DeleteQueryConnAction method run.
/**
* Drop the query connection
*/
public void run() {
Object[] objArr = this.getSelectedObj();
if (objArr == null || objArr.length <= 0) {
setEnabled(false);
return;
}
ISelectionProvider provider = this.getSelectionProvider();
if (!(provider instanceof TreeViewer)) {
return;
}
StringBuffer connNames = new StringBuffer();
for (int i = 0; objArr != null && i < objArr.length; i++) {
if (!isSupported(objArr[i])) {
setEnabled(false);
return;
}
ICubridNode node = (ICubridNode) objArr[i];
connNames.append(node.getLabel());
if (i != objArr.length - 1) {
connNames.append(",");
}
}
boolean isDrop = CommonUITool.openConfirmBox(getShell(), Messages.bind(Messages.msgConfirmDropConn, connNames.toString()));
if (!isDrop) {
return;
}
for (int i = 0; i < objArr.length; i++) {
CubridDatabase database = (CubridDatabase) objArr[i];
boolean isContinue = CQBConnectionUtils.processConnectionDeleted(database);
List<CubridGroupNode> groups = CQBGroupNodePersistManager.getInstance().getAllGroupNodes();
for (CubridGroupNode grp : groups) {
grp.removeChild(database);
}
if (isContinue) {
TreeViewer viewer = (TreeViewer) provider;
viewer.remove(database);
}
}
}
Aggregations