Search in sources :

Example 21 with CubridNavigatorView

use of com.cubrid.common.ui.common.navigator.CubridNavigatorView in project cubrid-manager by CUBRID.

the class CubridStatusLineContrItem method changeStuatusLineForNavigator.

/**
	 *
	 * Change status line for navigator selection
	 *
	 * @param selection the ISelection object
	 */
public void changeStuatusLineForNavigator(ISelection selection) {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window == null) {
        return;
    }
    //window.setStatus("");
    clearStatusLine();
    updateStatusLineForRestoreQueryEditor();
    if (selection == null || selection.isEmpty()) {
        return;
    }
    Object obj = ((IStructuredSelection) selection).getFirstElement();
    if (!(obj instanceof ICubridNode)) {
        return;
    }
    CubridNavigatorView navigatorView = CubridNavigatorView.getNavigatorView(CubridQueryNavigatorView.ID);
    boolean isShowGroup = false;
    if (navigatorView != null) {
        isShowGroup = navigatorView.isShowGroup();
    }
    ICubridNode cubridNode = (ICubridNode) obj;
    String nodePath = cubridNode.getLabel();
    ICubridNode parent = cubridNode.getParent();
    while (parent != null) {
        if (!isShowGroup && NodeType.GROUP.equals(parent.getType())) {
            break;
        }
        nodePath = parent.getLabel() + "/" + nodePath;
        parent = parent.getParent();
    }
    //window.setStatus(nodePath);
    if (window instanceof WorkbenchWindow) {
        StatusLineManager statusLineManager = ((WorkbenchWindow) window).getStatusLineManager();
        if (statusLineManager != null) {
            updateStatusLine(statusLineManager, cubridNode);
        }
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) WorkbenchWindow(org.eclipse.ui.internal.WorkbenchWindow) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) StatusLineManager(org.eclipse.jface.action.StatusLineManager) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode)

Example 22 with CubridNavigatorView

use of com.cubrid.common.ui.common.navigator.CubridNavigatorView 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));
        }
    }
}
Also used : TreeItem(org.eclipse.swt.widgets.TreeItem) TreeViewer(org.eclipse.jface.viewers.TreeViewer) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) CubridGroupNode(com.cubrid.common.ui.spi.model.CubridGroupNode) ISelection(org.eclipse.jface.viewers.ISelection) Tree(org.eclipse.swt.widgets.Tree) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) QueryConnDialog(com.cubrid.cubridquery.ui.connection.dialog.QueryConnDialog)

Example 23 with CubridNavigatorView

use of com.cubrid.common.ui.common.navigator.CubridNavigatorView in project cubrid-manager by CUBRID.

the class RenameConnectionAction method doRun.

/**
	 * Perform rename Table
	 *
	 * @param cubridDatabase
	 * @param table
	 */
private void doRun(CubridDatabase database) {
    RenameConnectionDialog dlg = new RenameConnectionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), database);
    int ret = dlg.open();
    if (ret == IDialogConstants.OK_ID) {
        /*Fire the database logout*/
        try {
            CubridDatabase orignDatabase = database.clone();
            CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(orignDatabase, CubridNodeChangedEventType.DATABASE_LOGOUT));
        } catch (CloneNotSupportedException e) {
            LOGGER.error(e.getMessage());
        }
        database.setLabel(dlg.getNewName());
        database.setLogined(false);
        CubridNavigatorView navigatorView = CubridNavigatorView.getNavigatorView(CubridQueryNavigatorView.ID);
        TreeViewer treeViewer = navigatorView == null ? null : navigatorView.getViewer();
        if (treeViewer == null) {
            LOGGER.error("Error: Can't find the navigator view:" + CubridQueryNavigatorView.ID);
            return;
        }
        // Refresh the tree view
        database.removeAllChild();
        treeViewer.refresh(database, true);
        treeViewer.expandToLevel(database, 1);
        setEnabled(false);
        // Save the data
        ServerInfo preServerInfo = (database == null || database.getServer() == null) ? null : database.getServer().getServerInfo();
        QueryOptions.removePref(preServerInfo);
        CQBGroupNodePersistManager.getInstance().saveAllGroupNode();
        CQBDBNodePersistManager.getInstance().saveDatabases();
        ActionManager.getInstance().fireSelectionChanged(getSelection());
        LayoutManager.getInstance().fireSelectionChanged(getSelection());
    }
}
Also used : CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) RenameConnectionDialog(com.cubrid.cubridquery.ui.connection.dialog.RenameConnectionDialog) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 24 with CubridNavigatorView

use of com.cubrid.common.ui.common.navigator.CubridNavigatorView 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;
}
Also used : CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) CubridGroupNode(com.cubrid.common.ui.spi.model.CubridGroupNode) TreeItem(org.eclipse.swt.widgets.TreeItem) TreeViewer(org.eclipse.jface.viewers.TreeViewer) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) Tree(org.eclipse.swt.widgets.Tree) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 25 with CubridNavigatorView

use of com.cubrid.common.ui.common.navigator.CubridNavigatorView in project cubrid-manager by CUBRID.

the class PerspectiveChangedListener method showPerspective.

public void showPerspective(PerspectiveChangeEvent event) {
    WorkbenchWindow window = (WorkbenchWindow) PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window != null) {
        ICoolBarManager coolBarManager = window.getCoolBarManager2();
        IMenuManager menuManager = window.getMenuBarManager();
        ActionAdvisor.getInstance().showToolbar(coolBarManager);
        ActionAdvisor.getInstance().showMenu(menuManager);
    }
    ActionManager.getInstance().setMenuProvider(menuProvider);
    LayoutManager.getInstance().setStatusLineContrItem(cubridStatusLineContrItem);
    LayoutManager.getInstance().setTitleLineContrItem(cubridTitleLineContrItem);
    cubridTitleLineContrItem.changeTitleForNavigator(null);
    LayoutManager.getInstance().setWorkbenchContrItem(cubridWorkbenchContrItem);
    CubridNavigatorView navigatorView = CubridNavigatorView.findNavigationView();
    if (navigatorView != null) {
        navigatorView.setFocus();
        if (navigatorView.getViewer() != null) {
            navigatorView.getViewer().refresh(true);
        }
    }
}
Also used : WorkbenchWindow(org.eclipse.ui.internal.WorkbenchWindow) CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) IMenuManager(org.eclipse.jface.action.IMenuManager) ICoolBarManager(org.eclipse.jface.action.ICoolBarManager)

Aggregations

CubridNavigatorView (com.cubrid.common.ui.common.navigator.CubridNavigatorView)50 TreeViewer (org.eclipse.jface.viewers.TreeViewer)36 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)25 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)22 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)21 CubridGroupNode (com.cubrid.common.ui.spi.model.CubridGroupNode)15 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)13 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)12 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)8 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)7 TreeItem (org.eclipse.swt.widgets.TreeItem)7 ArrayList (java.util.ArrayList)6 Tree (org.eclipse.swt.widgets.Tree)6 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)6 DatabaseEditorConfig (com.cubrid.common.ui.spi.model.DatabaseEditorConfig)5 ISelection (org.eclipse.jface.viewers.ISelection)5 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)4 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)4 WorkbenchWindow (org.eclipse.ui.internal.WorkbenchWindow)4 DatabaseMenuItem (com.cubrid.common.ui.query.control.DatabaseMenuItem)3