Search in sources :

Example 36 with TreeViewer

use of org.eclipse.jface.viewers.TreeViewer in project cubrid-manager by CUBRID.

the class HiddenElementAction method run.

/**
	 * Hidden the elements
	 */
public void run() {
    Object[] objArr = this.getSelectedObj();
    if (!isSupported(objArr)) {
        setEnabled(false);
        return;
    }
    ISelectionProvider provider = this.getSelectionProvider();
    if (!(provider instanceof TreeViewer)) {
        return;
    }
    List<String> idGrayList = new ArrayList<String>();
    List<String> idList = new ArrayList<String>();
    for (Object obj : objArr) {
        if (obj instanceof ICubridNode) {
            ICubridNode node = (ICubridNode) obj;
            idList.add(node.getId());
            addParentToGrayFilter(idGrayList, node.getParent());
        }
    }
    NodeFilterManager.getInstance().addIdFilterList(idList);
    NodeFilterManager.getInstance().addIdGrayFilterList(idGrayList);
    TreeViewer viewer = (TreeViewer) provider;
    viewer.setFilters(NodeFilterManager.getInstance().getViewerFilter());
}
Also used : ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ArrayList(java.util.ArrayList) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode)

Example 37 with TreeViewer

use of org.eclipse.jface.viewers.TreeViewer 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 38 with TreeViewer

use of org.eclipse.jface.viewers.TreeViewer in project cubrid-manager by CUBRID.

the class CubridNavigatorView method addListener.

/**
	 *
	 * Add listener
	 *
	 */
protected void addListener() {
    tv.getTree().addMouseListener(new MouseAdapter() {

        public void mouseDown(MouseEvent event) {
            if (toolTip.isVisible()) {
                toolTip.setVisible(false);
            }
        }

        public void mouseUp(MouseEvent event) {
            if (event.button == 1 && LayoutManager.getInstance().isUseClickOnce()) {
                ISelection selection = tv.getSelection();
                if (selection == null || selection.isEmpty()) {
                    return;
                }
                Object obj = ((IStructuredSelection) selection).getFirstElement();
                if (!(obj instanceof ICubridNode)) {
                    return;
                }
                ICubridNode cubridNode = (ICubridNode) obj;
                LayoutManager.getInstance().getWorkbenchContrItem().openEditorOrView(cubridNode);
            }
        }
    });
    tv.getTree().addMouseTrackListener(new MouseTrackAdapter() {

        public void mouseHover(MouseEvent event) {
            if (toolTip.isVisible()) {
                toolTip.setVisible(false);
            }
            int x = event.x;
            int y = event.y;
            TreeItem item = tv.getTree().getItem(new Point(x, y));
            if (item == null) {
                return;
            }
            showToolTip(item);
        }
    });
    tv.getTree().addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent event) {
            widgetSelected(event);
        }

        public void widgetSelected(SelectionEvent event) {
            if (toolTip.isVisible()) {
                toolTip.setVisible(false);
            }
            TreeItem[] items = tv.getTree().getSelection();
            if (items == null || items.length == 0) {
                return;
            }
            showToolTip(items[0]);
            if (items.length == 1) {
                showSchemaInfo(items[0]);
            } else {
                showSchemaInfo(null);
            }
        }
    });
    addDragDropSupport(tv.getTree());
    tv.getTree().addKeyListener(new KeyListener() {

        public void keyReleased(KeyEvent e) {
        }

        public void keyPressed(KeyEvent e) {
            // prevent to make events by key press for a long time
            if (e.character == ' ') {
                TreeItem[] items = tv.getTree().getSelection();
                if (items == null || items.length == 0) {
                    return;
                }
                if (items.length == 1) {
                    showSchemaInfo(items[0]);
                } else {
                    showSchemaInfo(null);
                }
            }
            lastKeyInputTimestamp = System.currentTimeMillis();
            // by showing object information tab on the query editor.
            if (e.keyCode == SWT.F2) {
                TreeItem[] items = tv.getTree().getSelection();
                if (items == null || items.length == 0) {
                    return;
                }
                for (TreeItem item : items) {
                    Object obj = item.getData();
                    if (obj instanceof ICubridNode) {
                        ICubridNode node = (ICubridNode) obj;
                        if (NodeType.USER_TABLE.equals(node.getType()) || NodeType.SYSTEM_TABLE.equals(node.getType()) || NodeType.USER_VIEW.equals(node.getType()) || NodeType.SYSTEM_VIEW.equals(node.getType())) {
                            DefaultSchemaNode table = (DefaultSchemaNode) obj;
                            OpenTargetAction action = new OpenTargetAction();
                            action.showObjectInfo(table);
                        } else if (NodeType.TABLE_FOLDER.equals(node.getType())) {
                            CubridNavigatorView view = CubridNavigatorView.getNavigatorView(ID_CQB);
                            if (view == null) {
                                view = CubridNavigatorView.getNavigatorView(ID_CM);
                            }
                            if (view == null) {
                                return;
                            }
                            TreeViewer treeViewer = view.getViewer();
                            //if not expand ,expand the node and wait until all children be added
                            if (!treeViewer.getExpandedState(node)) {
                                treeViewer.expandToLevel(node, 1);
                                while (node.getChildren().size() == 0) {
                                    try {
                                        Thread.sleep(500);
                                    } catch (Exception ignored) {
                                    }
                                }
                            }
                            CubridDatabase database = (CubridDatabase) node.getParent();
                            OpenTargetAction action = new OpenTargetAction();
                            action.showTableDashboard(database);
                        }
                    }
                }
            }
        }
    });
}
Also used : MouseEvent(org.eclipse.swt.events.MouseEvent) TreeItem(org.eclipse.swt.widgets.TreeItem) TreeViewer(org.eclipse.jface.viewers.TreeViewer) MouseAdapter(org.eclipse.swt.events.MouseAdapter) MouseTrackAdapter(org.eclipse.swt.events.MouseTrackAdapter) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) Point(org.eclipse.swt.graphics.Point) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode) OpenTargetAction(com.cubrid.common.ui.common.action.OpenTargetAction) KeyEvent(org.eclipse.swt.events.KeyEvent) ISelection(org.eclipse.jface.viewers.ISelection) SelectionEvent(org.eclipse.swt.events.SelectionEvent) KeyListener(org.eclipse.swt.events.KeyListener) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 39 with TreeViewer

use of org.eclipse.jface.viewers.TreeViewer in project azure-tools-for-java by Microsoft.

the class ServiceExplorerView method createPartControl.

/**
     * This is a callback that will allow us
     * to create the viewer and initialize it.
     */
public void createPartControl(Composite parent) {
    viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    viewer.setContentProvider(new ViewContentProvider());
    viewer.setLabelProvider(new ViewLabelProvider());
    viewer.setSorter(new NameSorter());
    viewer.setInput(getViewSite());
    // Create the help context id for the viewer's control
    PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(), "com.microsoft.azuretools.azureexplorer.viewer");
    makeActions();
    hookContextMenu();
    hookMouseActions();
    contributeToActionBars();
}
Also used : TreeViewer(org.eclipse.jface.viewers.TreeViewer)

Example 40 with TreeViewer

use of org.eclipse.jface.viewers.TreeViewer in project cubrid-manager by CUBRID.

the class AddVolumeAction method run.

/**
	 * 
	 * Creates a Dialog which is the instance of AddVolumeDialog to add a query
	 * plan
	 * 
	 */
public void run() {
    Object[] obj = this.getSelectedObj();
    CubridDatabase database = null;
    if (obj.length > 0 && obj[0] instanceof DefaultSchemaNode) {
        selection = (DefaultSchemaNode) obj[0];
        database = selection.getDatabase();
    }
    if (database == null) {
        CommonUITool.openErrorBox(Messages.msgSelectDB);
        return;
    }
    // Gets the status of adding volume
    GetAddVolumeStatusInfo getAddVolumeStatusInfo = new GetAddVolumeStatusInfo();
    final CommonQueryTask<GetAddVolumeStatusInfo> statusTask = new CommonQueryTask<GetAddVolumeStatusInfo>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), getAddVolumeStatusInfo);
    statusTask.setDbName(database.getLabel());
    TaskExecutor taskExecutor = new CommonTaskExec(com.cubrid.cubridmanager.ui.cubrid.dbspace.Messages.getVolumeInfoTaskName);
    taskExecutor.addTask(statusTask);
    CommonQueryTask<DbSpaceInfoList> spaceInfoTask = null;
    DatabaseInfo databaseInfo = database.getDatabaseInfo();
    DbSpaceInfoList dbSpaceInfoList = databaseInfo.getDbSpaceInfoList();
    int pageSize = 0;
    if (null == dbSpaceInfoList) {
        dbSpaceInfoList = new DbSpaceInfoList();
        spaceInfoTask = new CommonQueryTask<DbSpaceInfoList>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), dbSpaceInfoList);
        spaceInfoTask.setDbName(database.getLabel());
        taskExecutor.addTask(spaceInfoTask);
    }
    new ExecTaskWithProgress(taskExecutor).busyCursorWhile();
    if (spaceInfoTask == null) {
        pageSize = dbSpaceInfoList.getPagesize();
    } else {
        final DbSpaceInfoList model = ((CommonQueryTask<DbSpaceInfoList>) spaceInfoTask).getResultModel();
        pageSize = model.getPagesize();
    }
    getAddVolumeStatusInfo = statusTask.getResultModel();
    TreeViewer treeViewer = (TreeViewer) this.getSelectionProvider();
    AddVolumeDialog addVolumeDialog = new AddVolumeDialog(getShell());
    addVolumeDialog.setGetAddVolumeStatusInfo(getAddVolumeStatusInfo);
    addVolumeDialog.initPara(selection);
    addVolumeDialog.setTreeViewer(treeViewer);
    addVolumeDialog.setPageSize(pageSize);
    addVolumeDialog.open();
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) TreeViewer(org.eclipse.jface.viewers.TreeViewer) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode) GetAddVolumeStatusInfo(com.cubrid.cubridmanager.core.cubrid.dbspace.model.GetAddVolumeStatusInfo) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) AddVolumeDialog(com.cubrid.cubridmanager.ui.cubrid.dbspace.dialog.AddVolumeDialog) DbSpaceInfoList(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Aggregations

TreeViewer (org.eclipse.jface.viewers.TreeViewer)248 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)62 GridData (org.eclipse.swt.layout.GridData)50 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)45 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)43 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)42 Composite (org.eclipse.swt.widgets.Composite)42 Tree (org.eclipse.swt.widgets.Tree)42 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)40 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)39 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)38 CubridNavigatorView (com.cubrid.common.ui.common.navigator.CubridNavigatorView)36 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)36 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)36 GridLayout (org.eclipse.swt.layout.GridLayout)34 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)31 ArrayList (java.util.ArrayList)29 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)27 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)27 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)25