Search in sources :

Example 31 with ICubridNode

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

the class OpenTargetAction method run.

public void run() {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window == null) {
        return;
    }
    final Object[] obj = this.getSelectedObj();
    if (!isSupported(obj)) {
        setEnabled(false);
        return;
    }
    for (int i = 0; i < obj.length; i++) {
        if (!NodeUtil.isCubridNode(obj[i])) {
            continue;
        }
        ICubridNode node = (ICubridNode) obj[i];
        if (NodeUtil.isTableViewNode(node)) {
            DefaultSchemaNode table = (DefaultSchemaNode) obj[i];
            showObjectInfo(table);
        } else if (NodeUtil.isTableFolderNode(node)) {
            CubridNavigatorView view = CubridNavigatorView.findNavigationView();
            if (view == null) {
                return;
            }
            //if not expand ,expand the node and wait until all children be added
            TreeViewer treeViewer = view.getViewer();
            if (!treeViewer.getExpandedState(node)) {
                treeViewer.expandToLevel(node, 1);
                while (node.getChildren().size() == 0) {
                    ThreadUtil.sleep(500);
                }
            }
            showTableDashboard(NodeUtil.getCubridDatabase(node));
        } else if (NodeUtil.isViewFolderNode(node)) {
            CubridNavigatorView view = CubridNavigatorView.getNavigatorView("com.cubrid.cubridquery.connection.navigator");
            if (view == null) {
                view = CubridNavigatorView.getNavigatorView("com.cubrid.cubridmanager.host.navigator");
            }
            if (view == null) {
                return;
            }
            //if not expand ,expand the node and wait until all children be added
            TreeViewer treeViewer = view.getViewer();
            if (!treeViewer.getExpandedState(node)) {
                treeViewer.expandToLevel(node, 1);
                while (node.getChildren().size() == 0) {
                    ThreadUtil.sleep(500);
                }
            }
            openViewsDetailInfoEditor(NodeUtil.getCubridDatabase(node));
        } else if (NodeUtil.isSerialFolderNode(node)) {
            CubridNavigatorView view = CubridNavigatorView.findNavigationView();
            if (view == null) {
                return;
            }
            //if not expand ,expand the node and wait until all children be added
            TreeViewer treeViewer = view.getViewer();
            if (!treeViewer.getExpandedState(node)) {
                treeViewer.expandToLevel(node, 1);
                while (node.getChildren().size() == 0) {
                    ThreadUtil.sleep(500);
                }
            }
            openSerialsDetailInfoEditor(NodeUtil.getCubridDatabase(node), null);
        } else if (NodeUtil.isTriggerFolderNode(node)) {
            CubridNavigatorView view = CubridNavigatorView.findNavigationView();
            if (view == null) {
                return;
            }
            //if not expand ,expand the node and wait until all children be added
            TreeViewer treeViewer = view.getViewer();
            if (!treeViewer.getExpandedState(node)) {
                treeViewer.expandToLevel(node, 1);
                while (node.getChildren().size() == 0) {
                    ThreadUtil.sleep(500);
                }
            }
            openTriggersDetailInfoEditor(NodeUtil.getCubridDatabase(node));
        } else if (NodeUtil.isUserFolderNode(node)) {
            CubridNavigatorView view = CubridNavigatorView.findNavigationView();
            if (view == null) {
                return;
            }
            //if not expand ,expand the node and wait until all children be added
            TreeViewer treeViewer = view.getViewer();
            if (!treeViewer.getExpandedState(node)) {
                treeViewer.expandToLevel(node, 1);
                while (node.getChildren().size() == 0) {
                    ThreadUtil.sleep(500);
                }
            }
            openUsersDetailInfoEditor(NodeUtil.getCubridDatabase(node));
        }
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode)

Example 32 with ICubridNode

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

the class JdbcManageComposite method isJdbcDriverUsing.

/**
	 * 
	 * Return whether the JDBC driver is using
	 * 
	 * @param jdbcVersion String
	 * @return boolean
	 */
private boolean isJdbcDriverUsing(String jdbcVersion) {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window == null) {
        return false;
    }
    IWorkbenchPage page = window.getActivePage();
    if (page == null) {
        return false;
    }
    IViewReference[] viewReference = page.getViewReferences();
    for (int i = 0; viewReference != null && i < viewReference.length; i++) {
        IViewPart viewPart = viewReference[i].getView(false);
        if (!(viewPart instanceof CubridNavigatorView)) {
            continue;
        }
        CubridNavigatorView navigatorView = (CubridNavigatorView) viewPart;
        List<ICubridNode> list = getUsingJdbcNodeList(navigatorView);
        if (list == null) {
            continue;
        }
        for (ICubridNode node : list) {
            if (NodeType.SERVER.equals(node.getType())) {
                CubridServer server = (CubridServer) node;
                ServerInfo serverInfo = server.getServerInfo();
                if (serverInfo == null) {
                    continue;
                }
                if (serverInfo.isConnected() && serverInfo.getJdbcDriverVersion().equals(jdbcVersion)) {
                    CommonUITool.openErrorBox(Messages.bind(Messages.errDeleteJdbcServer, new Object[] { serverInfo.getServerName(), jdbcVersion }));
                    return true;
                }
            } else if (NodeType.DATABASE.equals(node.getType())) {
                CubridDatabase database = (CubridDatabase) node;
                if (database == null || database.getServer() == null || database.getServer().getServerInfo() == null) {
                    continue;
                }
                ServerInfo serverInfo = database.getServer().getServerInfo();
                if (serverInfo == null) {
                    LOGGER.error("The serverInfo is a null.");
                    return false;
                }
                boolean isSameVersion = StringUtil.isEqual(serverInfo.getJdbcDriverVersion(), jdbcVersion);
                if (isSameVersion && database.isLogined()) {
                    CommonUITool.openErrorBox(Messages.bind(Messages.errDeleteJdbcConn, new Object[] { database.getName(), jdbcVersion }));
                    return true;
                }
            }
        }
    }
    IEditorReference[] editorReference = page.getEditorReferences();
    for (int i = 0; editorReference != null && i < editorReference.length; i++) {
        IEditorPart editorPart = editorReference[i].getEditor(false);
        if (!(editorPart instanceof QueryEditorPart)) {
            continue;
        }
        QueryEditorPart queryEditorPart = (QueryEditorPart) editorPart;
        CubridServer server = queryEditorPart.getSelectedServer();
        ServerInfo serverInfo = server == null ? null : server.getServerInfo();
        String partName = queryEditorPart.getPartName();
        if (serverInfo != null && serverInfo.getJdbcDriverVersion().equals(jdbcVersion)) {
            CommonUITool.openErrorBox(Messages.bind(Messages.errDeleteJdbcQuery, new Object[] { partName, jdbcVersion }));
            return true;
        }
    }
    return false;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IViewPart(org.eclipse.ui.IViewPart) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) IEditorPart(org.eclipse.ui.IEditorPart) CubridServer(com.cubrid.common.ui.spi.model.CubridServer) CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) QueryEditorPart(com.cubrid.common.ui.query.editor.QueryEditorPart) IEditorReference(org.eclipse.ui.IEditorReference) IViewReference(org.eclipse.ui.IViewReference) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 33 with ICubridNode

use of com.cubrid.common.ui.spi.model.ICubridNode 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)

Example 34 with ICubridNode

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

the class CubridNavigatorView method addDragDropSupport.

/**
	 * Add the drag drop support of tree.
	 *
	 * @param tree the tree need to drag and drop.
	 */
protected void addDragDropSupport(final Tree tree) {
    // Define 'Transfer Type', 'Operation'
    Transfer[] types = new Transfer[] { TextTransfer.getInstance() };
    int operations = DND.DROP_MOVE | DND.DROP_COPY;
    // DragSource
    final DragSource source = new DragSource(tree, operations);
    source.setTransfer(types);
    source.addDragListener(new DragSourceListener() {

        public void dragStart(DragSourceEvent event) {
            event.doit = false;
            if (!dataSupportDND(tree.getSelection())) {
                return;
            }
            event.doit = true;
        }

        public void dragSetData(DragSourceEvent event) {
            event.data = ((ICubridNode) tree.getSelection()[0].getData()).getLabel();
        }

        public void dragFinished(DragSourceEvent event) {
        }
    });
    addTreeDropTarget(tree);
    String perspectiveId = PerspectiveManager.getInstance().getCurrentPerspectiveId();
    // DropTarget for query editor.
    QueryEditorDNDController.registerDragSource(perspectiveId, tv);
    // DropTarget for multiple query
    MultiDBQueryDNDController.registerDragSource(perspectiveId, tv);
    // DropTarget for Run SQL file
    RunSQLFileDialogDNDController.registerDragSource(perspectiveId, tv);
    //DropTarget for ERD
    ERDNDController.registerDragSource(perspectiveId, tv);
}
Also used : DragSourceEvent(org.eclipse.swt.dnd.DragSourceEvent) Transfer(org.eclipse.swt.dnd.Transfer) TextTransfer(org.eclipse.swt.dnd.TextTransfer) DragSource(org.eclipse.swt.dnd.DragSource) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) DragSourceListener(org.eclipse.swt.dnd.DragSourceListener) Point(org.eclipse.swt.graphics.Point)

Example 35 with ICubridNode

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

the class CubridNavigatorView method showSchemaInfo.

private void showSchemaInfo(TreeItem item) {
    if (System.currentTimeMillis() - lastKeyInputTimestamp <= 50) {
        return;
    }
    boolean isAutoShowSchemaInfo = GeneralPreference.isAutoShowSchemaInfo();
    if (!isAutoShowSchemaInfo) {
        return;
    }
    Object obj = null;
    if (item != null) {
        obj = item.getData();
    }
    DefaultSchemaNode table = null;
    if (obj != null) {
        if ((obj instanceof ICubridNode)) {
            ICubridNode node = (ICubridNode) obj;
            if (NodeType.USER_TABLE.equals(node.getType()) || NodeType.USER_VIEW.equals(node.getType()) || NodeType.USER_PARTITIONED_TABLE_FOLDER.equals(node.getType()) || NodeType.SYSTEM_TABLE.equals(node.getType()) || NodeType.SYSTEM_VIEW.equals(node.getType())) {
                table = (DefaultSchemaNode) node;
            }
        }
    }
    final CubridDatabase database = table == null ? null : table.getDatabase();
    currentDatabaseInfo = database == null ? null : database.getDatabaseInfo();
    final String schemaName = table == null ? null : table.getName();
    boolean isTable = (ActionSupportUtil.isSupportSingleSelection(table, new String[] { NodeType.USER_TABLE, NodeType.SYSTEM_TABLE, NodeType.USER_PARTITIONED_TABLE_FOLDER }));
    showQuickView(currentDatabaseInfo, schemaName, isTable);
    lastKeyInputTimestamp = System.currentTimeMillis();
}
Also used : ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode) 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