Search in sources :

Example 1 with CubridGroupNode

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();
}
Also used : CubridGroupNode(com.cubrid.common.ui.spi.model.CubridGroupNode) ArrayList(java.util.ArrayList)

Example 2 with CubridGroupNode

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);
        }
    }
}
Also used : CubridGroupNode(com.cubrid.common.ui.spi.model.CubridGroupNode) ArrayList(java.util.ArrayList) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode)

Example 3 with CubridGroupNode

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();
            }
        });
    }
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) CubridGroupNode(com.cubrid.common.ui.spi.model.CubridGroupNode) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 4 with CubridGroupNode

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());
}
Also used : CubridGroupNode(com.cubrid.common.ui.spi.model.CubridGroupNode)

Example 5 with CubridGroupNode

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);
}
Also used : CubridGroupNode(com.cubrid.common.ui.spi.model.CubridGroupNode) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridServer(com.cubrid.common.ui.spi.model.CubridServer) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Aggregations

CubridGroupNode (com.cubrid.common.ui.spi.model.CubridGroupNode)46 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)25 CubridNavigatorView (com.cubrid.common.ui.common.navigator.CubridNavigatorView)15 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)15 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)15 ArrayList (java.util.ArrayList)11 TreeViewer (org.eclipse.jface.viewers.TreeViewer)11 TreeItem (org.eclipse.swt.widgets.TreeItem)9 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)6 Tree (org.eclipse.swt.widgets.Tree)6 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)5 IXMLMemento (com.cubrid.cubridmanager.core.common.xml.IXMLMemento)4 HostDialog (com.cubrid.cubridmanager.ui.host.dialog.HostDialog)4 ISelection (org.eclipse.jface.viewers.ISelection)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 MenuItem (org.eclipse.swt.widgets.MenuItem)4 DatabaseMenuItem (com.cubrid.common.ui.query.control.DatabaseMenuItem)3 QueryConnDialog (com.cubrid.cubridquery.ui.connection.dialog.QueryConnDialog)3 List (java.util.List)3 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)3