Search in sources :

Example 16 with ICubridNode

use of com.cubrid.common.ui.spi.model.ICubridNode in project cubrid-manager by CUBRID.

the class DBAuthComparator method dropUser.

/**
	 * drop User
	 */
public void dropUser() {
    TableItem[] items = userTableViewer.getTable().getSelection();
    if (items.length == 1) {
        TableItem item = items[0];
        UserDetailInfo userInfo = (UserDetailInfo) item.getData();
        String msg = Messages.bind(Messages.msgDoYouWantToDeleteUser, userInfo.getUserName());
        if (!CommonUITool.openConfirmBox(msg)) {
            return;
        }
        Set<String> typeSet = new HashSet<String>();
        typeSet.add(NodeType.USER);
        ICubridNode userNode = CommonUITool.findNode(database, typeSet, userInfo.getUserName());
        if (userNode != null) {
            DeleteUserAction action = (DeleteUserAction) ActionManager.getInstance().getAction(DeleteUserAction.ID);
            action.doRun((ISchemaNode) userNode);
            refresh();
        }
    } else {
        CommonUITool.openWarningBox(Messages.errNoUserSelected);
    }
}
Also used : DeleteUserAction(com.cubrid.common.ui.cubrid.user.action.DeleteUserAction) TableItem(org.eclipse.swt.widgets.TableItem) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) UserDetailInfo(com.cubrid.cubridmanager.core.cubrid.user.model.UserDetailInfo) HashSet(java.util.HashSet)

Example 17 with ICubridNode

use of com.cubrid.common.ui.spi.model.ICubridNode in project cubrid-manager by CUBRID.

the class TriggerDashboardEditorPart method editTrigger.

/**
	 * editTrigger
	 */
public void editTrigger() {
    TableItem[] items = triggersDetailInfoTable.getTable().getSelection();
    if (items.length != 0) {
        TableItem item = items[0];
        Trigger trigger = (Trigger) item.getData();
        Set<String> typeSet = new HashSet<String>();
        typeSet.add(NodeType.TRIGGER);
        ICubridNode triggerNode = CommonUITool.findNode(database, typeSet, trigger.getName());
        if (triggerNode != null) {
            AlterTriggerAction action = (AlterTriggerAction) ActionManager.getInstance().getAction(AlterTriggerAction.ID);
            if (action.run(database, (ISchemaNode) triggerNode) == IDialogConstants.OK_ID) {
                refresh();
            }
        }
    } else {
        CommonUITool.openWarningBox(Messages.errTriggerNoSelection);
    }
}
Also used : Trigger(com.cubrid.common.core.common.model.Trigger) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) TableItem(org.eclipse.swt.widgets.TableItem) AlterTriggerAction(com.cubrid.common.ui.cubrid.trigger.action.AlterTriggerAction) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) HashSet(java.util.HashSet)

Example 18 with ICubridNode

use of com.cubrid.common.ui.spi.model.ICubridNode in project cubrid-manager by CUBRID.

the class EditVirtualTableDialog method nodeChanged.

public void nodeChanged(CubridNodeChangedEvent event) {
    ICubridNode cubridNode = event.getCubridNode();
    CubridNodeChangedEventType eventType = event.getType();
    if (cubridNode == null || eventType == null) {
        return;
    }
    if (CubridNodeChangedEventType.SERVER_DISCONNECTED.equals(event.getType())) {
        super.close();
    }
    if (CubridNodeChangedEventType.DATABASE_LOGOUT.equals(event.getType()) || CubridNodeChangedEventType.DATABASE_STOP.equals(event.getType())) {
        super.close();
    }
}
Also used : CubridNodeChangedEventType(com.cubrid.common.ui.spi.event.CubridNodeChangedEventType) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode)

Example 19 with ICubridNode

use of com.cubrid.common.ui.spi.model.ICubridNode in project cubrid-manager by CUBRID.

the class ViewDashboardEditorPart method dropView.

public void dropView() {
    TableItem[] items = viewsDetailInfoTable.getTable().getSelection();
    if (items.length > 0) {
        List<ISchemaNode> selectNodeList = new ArrayList<ISchemaNode>();
        for (TableItem item : items) {
            ViewDetailInfo viewInfo = (ViewDetailInfo) item.getData();
            Set<String> typeSet = new HashSet<String>();
            typeSet.add(NodeType.USER_VIEW);
            ICubridNode viewNode = CommonUITool.findNode(database, typeSet, viewInfo.getViewName());
            selectNodeList.add((ISchemaNode) viewNode);
        }
        if (selectNodeList.size() > 0) {
            DropViewAction action = (DropViewAction) ActionManager.getInstance().getAction(DropViewAction.ID);
            ISchemaNode[] nodeArr = new ISchemaNode[selectNodeList.size()];
            action.run(selectNodeList.toArray(nodeArr));
            if (!action.isCanceledTask()) {
                refresh();
            }
        }
    } else {
        CommonUITool.openWarningBox(Messages.viewDetailInfoPartTableNoSelectionMsg);
    }
}
Also used : ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) TableItem(org.eclipse.swt.widgets.TableItem) ArrayList(java.util.ArrayList) ViewDetailInfo(com.cubrid.common.core.common.model.ViewDetailInfo) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) HashSet(java.util.HashSet) DropViewAction(com.cubrid.common.ui.cubrid.table.action.DropViewAction)

Example 20 with ICubridNode

use of com.cubrid.common.ui.spi.model.ICubridNode in project cubrid-manager by CUBRID.

the class MultiDBQueryComposite method initialize.

/**
	 * Create the SQL history composite
	 */
public void initialize() {
    Composite toolBarComposite = new Composite(this, SWT.NONE);
    GridLayout gridLayout = new GridLayout(2, false);
    gridLayout.verticalSpacing = 0;
    gridLayout.horizontalSpacing = 10;
    gridLayout.marginWidth = 0;
    gridLayout.marginHeight = 0;
    toolBarComposite.setLayout(gridLayout);
    toolBarComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    ToolBar toolBar = new ToolBar(toolBarComposite, SWT.FLAT | SWT.RIGHT);
    toolBar.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false));
    ToolItem refreshToolItem = new ToolItem(toolBar, SWT.PUSH);
    refreshToolItem.setText(Messages.lblItemRefreshMulti);
    refreshToolItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_refresh.png"));
    refreshToolItem.setDisabledImage(CommonUIPlugin.getImage("icons/queryeditor/query_refresh.png"));
    refreshToolItem.setToolTipText(Messages.refresh);
    refreshToolItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            //refresh may set tree to group type or not
            //so mark the select db then set it to checked after set input
            //				Object[] checkedObject = ctv.getCheckedElements();
            setInput();
        //				for (Object o : checkedObject) {
        //					if (o instanceof CubridDatabase) {
        //						ctv.setChecked(o, true);
        //					}
        //				}
        //				refresh(editor.getSelectedDatabase());
        }
    });
    runItem = new ToolItem(toolBar, SWT.PUSH);
    runItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_run.png"));
    runItem.setDisabledImage(CommonUIPlugin.getImage("icons/queryeditor/query_run_disabled.png"));
    runItem.setText(Messages.lblItemRunMulti);
    runItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            editor.runMultiQuery();
        }
    });
    Label lblNotice = new Label(toolBarComposite, SWT.None);
    lblNotice.setText(Messages.qedit_multiDBQueryComp_noticeToolbarMsg);
    lblNotice.setLayoutData(new GridData(SWT.TRAIL, SWT.CENTER, true, false));
    // create the query result tab folder
    multiDBQueryCompTabFolder = new CTabFolder(this, SWT.BOTTOM);
    multiDBQueryCompTabFolder.setSimple(false);
    multiDBQueryCompTabFolder.setUnselectedImageVisible(true);
    multiDBQueryCompTabFolder.setUnselectedCloseVisible(true);
    multiDBQueryCompTabFolder.setSelectionBackground(CombinedQueryEditorComposite.BACK_COLOR);
    multiDBQueryCompTabFolder.setSelectionForeground(ResourceManager.getColor(SWT.COLOR_BLACK));
    multiDBQueryCompTabFolder.setLayout(new GridLayout(1, true));
    multiDBQueryCompTabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
    //TabContextMenuManager tabContextMenuManager = new TabContextMenuManager(multiDBQueryCompTabFolder);
    //tabContextMenuManager.createContextMenu();
    multiDBQueryCompTabItem = new CTabItem(resultTabFolder, SWT.NONE);
    multiDBQueryCompTabItem.setText(Messages.qedit_multiDBQueryComp_folder);
    multiDBQueryCompTabItem.setControl(this);
    multiDBQueryCompTabItem.setShowClose(false);
    SashForm bottomSash = new SashForm(multiDBQueryCompTabFolder, SWT.VERTICAL);
    bottomSash.SASH_WIDTH = SASH_WIDTH;
    bottomSash.setBackground(CombinedQueryEditorComposite.BACK_COLOR);
    SashForm tailSash = new SashForm(bottomSash, SWT.HORIZONTAL);
    tailSash.SASH_WIDTH = SASH_WIDTH;
    tailSash.setBackground(CombinedQueryEditorComposite.BACK_COLOR);
    Composite treeComp = new Composite(tailSash, SWT.NONE);
    {
        treeComp.setLayoutData(new GridData(GridData.FILL_BOTH));
        treeComp.setLayout(new GridLayout());
    }
    ctv = new ContainerCheckedTreeViewer(treeComp, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
    ctv.getControl().setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 3, 1, -1, 200));
    ctv.setContentProvider(new MultiDBQueryTreeContentProvider());
    ctv.addCheckStateListener(new ICheckStateListener() {

        public void checkStateChanged(CheckStateChangedEvent event) {
            if (lastSelectedTime != 0 && lastSelectedTime > System.currentTimeMillis()) {
                ctv.setChecked(event.getElement(), true);
                return;
            }
            ctv.setChecked(event.getElement(), false);
            lastSelectedTime = System.currentTimeMillis() + 100;
            if (getQueryDatabaseList().size() > 0 && editor.getAllQueries().trim().length() != 0) {
                editor.setMultiQueryRunItemStatus(true);
            } else if (getQueryDatabaseList().size() == 0) {
                editor.setMultiQueryRunItemStatus(false);
            }
            //if (!event.getChecked()) {
            selectedNodes.remove(event.getElement());
            if (event.getElement() instanceof CubridDatabase) {
                CubridDatabase database = (CubridDatabase) event.getElement();
                if (database.getRunningType() == DbRunningType.STANDALONE || !database.isLogined()) {
                    //ctv.setChecked(event.getElement(), false);
                    selectedNodes.remove(database);
                } else {
                    if (database.getData(INDEXKEY) == null) {
                        database.setData(INDEXKEY, String.valueOf(databaseIndex++));
                    }
                }
            } else if (event.getElement() instanceof CubridServer) {
                CubridServer serverNode = (CubridServer) event.getElement();
                for (ICubridNode dbFolderNode : serverNode.getChildren()) {
                    for (ICubridNode dbNode : dbFolderNode.getChildren()) {
                        if (dbNode instanceof CubridDatabase) {
                            CubridDatabase database = (CubridDatabase) dbNode;
                            if (database.getRunningType() == DbRunningType.STANDALONE || !database.isLogined()) {
                                //ctv.setChecked(dbNode, false);
                                selectedNodes.remove(database);
                            } else if (ctv.getChecked(dbNode)) {
                                ctv.setChecked(dbNode, true);
                                if (dbNode.getData(INDEXKEY) == null) {
                                    dbNode.setData(INDEXKEY, String.valueOf(databaseIndex++));
                                }
                            } else {
                                ctv.setChecked(dbNode, true);
                            }
                        }
                    }
                    //only has one db folder  so first time break it
                    break;
                }
            } else if (event.getElement() instanceof ICubridNode) {
                ICubridNode node = (ICubridNode) event.getElement();
                if (node.getType().equals(NodeType.DATABASE_FOLDER)) {
                    for (ICubridNode dbNode : node.getChildren()) {
                        if (dbNode instanceof CubridDatabase) {
                            CubridDatabase database = (CubridDatabase) dbNode;
                            if (database.getRunningType() == DbRunningType.STANDALONE || !database.isLogined()) {
                                ctv.setChecked(dbNode, false);
                            } else if (ctv.getChecked(dbNode)) {
                                ctv.setChecked(dbNode, true);
                                if (dbNode.getData(INDEXKEY) == null) {
                                    dbNode.setData(INDEXKEY, String.valueOf(databaseIndex++));
                                }
                            } else {
                                ctv.setChecked(dbNode, false);
                            }
                        }
                    }
                }
            //					else if (node.getType().equals(NodeType.GROUP)) {
            //						for (ICubridNode childNode : node.getChildren()) {
            //							//CQB tree
            //							if(childNode instanceof CubridDatabase) {
            //								CubridDatabase database = (CubridDatabase) childNode;
            //								if (database.getRunningType() == DbRunningType.STANDALONE
            //										|| !database.isLogined()) {
            //									if (childNode.getData(INDEXKEY) == null) {
            //										childNode.setData(INDEXKEY, String.valueOf(databaseIndex++));
            //									}
            //								}
            //								continue;
            //							}
            //							//CM tree
            //							for (ICubridNode dbFolderNode : childNode.getChildren()) {
            //								for (ICubridNode dbNode : dbFolderNode.getChildren()) {
            //									if(dbNode instanceof CubridDatabase) {
            //										CubridDatabase database = (CubridDatabase) dbNode;
            //										if (database.getRunningType() == DbRunningType.STANDALONE
            //												|| !database.isLogined()) {
            //											ctv.setChecked(dbNode, false);
            //										} else if (ctv.getChecked(dbNode)) {
            //											ctv.setChecked(dbNode, true);
            //											if (dbNode.getData(INDEXKEY) == null) {
            //												dbNode.setData(INDEXKEY, String.valueOf(databaseIndex++));
            //											}
            //										} else {
            //											ctv.setChecked(dbNode, false);
            //										}
            //									}
            //								}
            //							}
            //							//only has one db folder  so first time break it
            //							break;
            //						}
            //					}
            }
            ctv.refresh();
        }
    });
    ctv.getTree().addKeyListener(new KeyAdapter() {

        public void keyReleased(KeyEvent event) {
            //mac can't drag and drop,so support copy and paste db node
            if (((event.stateMask & SWT.CTRL) != 0) || ((event.stateMask & SWT.COMMAND) != 0) && event.keyCode == 'v') {
                final Clipboard cb = new Clipboard(getShell().getDisplay());
                String plainText = (String) cb.getContents(TextTransfer.getInstance());
                String[] databaseNameArray = plainText.split(",");
                selectedNodes.addAll(getDatabaseNode(databaseNameArray));
                setInput();
            }
        }
    });
    //		ctv.addDoubleClickListener(LayoutManager.getInstance());
    //		ctv.addTreeListener(new ITreeViewerListener() {
    //			public void treeCollapsed(TreeExpansionEvent event) {
    //				CommonTool.clearExpandedElements(ctv);
    //			}
    //
    //			public void treeExpanded(TreeExpansionEvent event) {
    //				CommonTool.clearExpandedElements(ctv);
    //			}
    //		});
    final Tree tableTree = ctv.getTree();
    tableTree.setHeaderVisible(true);
    tableTree.setLinesVisible(true);
    final TreeViewerColumn dbCol = new TreeViewerColumn(ctv, SWT.NONE);
    dbCol.setLabelProvider(new MultiDBQueryTreeColumnLabelProvider());
    dbCol.getColumn().setWidth(250);
    dbCol.getColumn().setText(Messages.qedit_multiDBQueryComp_tree_dbCol);
    final TreeViewerColumn indexCol = new TreeViewerColumn(ctv, SWT.NONE);
    indexCol.setLabelProvider(new MultiDBQueryTreeColumnLabelProvider());
    indexCol.getColumn().setWidth(50);
    indexCol.getColumn().setText(Messages.qedit_multiDBQueryComp_tree_indexCol);
    indexCol.setEditingSupport(new EditingSupport(ctv) {

        TextCellEditor textCellEditor;

        protected boolean canEdit(Object element) {
            if (element instanceof ICubridNode) {
                ICubridNode node = (ICubridNode) element;
                if (node.getType() == NodeType.DATABASE) {
                    CubridDatabase database = (CubridDatabase) element;
                    if ((database.getRunningType() == DbRunningType.CS && database.isLogined())) {
                        return true;
                    }
                }
            }
            return false;
        }

        protected CellEditor getCellEditor(Object element) {
            if (textCellEditor == null) {
                textCellEditor = new TextCellEditor(ctv.getTree());
                textCellEditor.setValidator(new IndexCellEditorValidator());
                textCellEditor.addListener(new ICellEditorListener() {

                    public void applyEditorValue() {
                    }

                    public void cancelEditor() {
                    }

                    public void editorValueChanged(boolean oldValidState, boolean newValidState) {
                    }
                });
            }
            return textCellEditor;
        }

        protected Object getValue(Object element) {
            final ICubridNode node = (ICubridNode) element;
            String index = (String) node.getData(INDEXKEY);
            if (index == null) {
                return "";
            } else {
                return index;
            }
        }

        protected void setValue(Object element, Object value) {
            if (value == null) {
                return;
            }
            try {
                Integer.valueOf((String) value);
            } catch (Exception e) {
                return;
            }
            final ICubridNode node = (ICubridNode) element;
            node.setData(INDEXKEY, value);
            //				setAllParentExpandOrCollapse(node.getParent(), true);
            ctv.refresh();
        }

        /**
			 * MyCellEditorValidator
			 *
			 * @author fulei
			 *
			 */
        class IndexCellEditorValidator implements ICellEditorValidator {

            /**
				 * isValid
				 *
				 * @param value Object
				 * @return String
				 */
            public String isValid(Object value) {
                try {
                    Integer.valueOf((String) value);
                } catch (Exception e) {
                    CommonUITool.openErrorBox(Messages.qedit_multiDBQueryComp_tree_indexErr);
                    return Messages.qedit_multiDBQueryComp_tree_indexErr;
                }
                return null;
            }
        }
    });
    final TreeViewerColumn commentCol = new TreeViewerColumn(ctv, SWT.NONE);
    commentCol.setLabelProvider(new MultiDBQueryTreeColumnLabelProvider());
    commentCol.getColumn().setWidth(200);
    commentCol.getColumn().setText(Messages.qedit_multiDBQueryComp_tree_commentCol);
    CTabItem tabItem = new CTabItem(multiDBQueryCompTabFolder, SWT.NONE);
    tabItem.setText(Messages.qedit_multiDBQueryComp_tabItem);
    tabItem.setControl(bottomSash);
    tabItem.setShowClose(false);
    setInput();
    //		HostNodePersistManager.getInstance().getAllServer();
    multiDBQueryCompTabFolder.setSelection(tabItem);
    dragController = new MultiDBQueryDNDController(this, ctv);
    dragController.registerDropTarget();
}
Also used : CTabFolder(org.eclipse.swt.custom.CTabFolder) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) CellEditor(org.eclipse.jface.viewers.CellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Label(org.eclipse.swt.widgets.Label) EditingSupport(org.eclipse.jface.viewers.EditingSupport) CTabItem(org.eclipse.swt.custom.CTabItem) KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) ICellEditorListener(org.eclipse.jface.viewers.ICellEditorListener) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Tree(org.eclipse.swt.widgets.Tree) ToolItem(org.eclipse.swt.widgets.ToolItem) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridServer(com.cubrid.common.ui.spi.model.CubridServer) TreeViewerColumn(org.eclipse.jface.viewers.TreeViewerColumn) SashForm(org.eclipse.swt.custom.SashForm) ICellEditorValidator(org.eclipse.jface.viewers.ICellEditorValidator) GridData(org.eclipse.swt.layout.GridData) ToolBar(org.eclipse.swt.widgets.ToolBar) ContainerCheckedTreeViewer(org.eclipse.ui.dialogs.ContainerCheckedTreeViewer) Clipboard(org.eclipse.swt.dnd.Clipboard) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Aggregations

ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)362 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)67 ArrayList (java.util.ArrayList)67 DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)62 TreeViewer (org.eclipse.jface.viewers.TreeViewer)62 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)55 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)55 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)41 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)40 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)33 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)32 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)31 ICubridNodeLoader (com.cubrid.common.ui.spi.model.ICubridNodeLoader)27 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)26 CubridGroupNode (com.cubrid.common.ui.spi.model.CubridGroupNode)25 DefaultCubridNode (com.cubrid.common.ui.spi.model.DefaultCubridNode)25 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)25 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)25 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)23 CubridNavigatorView (com.cubrid.common.ui.common.navigator.CubridNavigatorView)22