Search in sources :

Example 31 with CubridNavigatorView

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

the class PasteHostAction method isSupported.

/**
	 * 
	 * Return whether this action support this object,if not support,this action
	 * will be disabled
	 * 
	 * @param obj the Object
	 * @return <code>true</code> if support this obj;<code>false</code>
	 *         otherwise
	 */
public boolean isSupported(Object obj) {
    CubridNavigatorView navigatorView = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
    if (navigatorView == null) {
        return false;
    }
    boolean isShowGroup = navigatorView.isShowGroup();
    if (isShowGroup && !(obj instanceof CubridServer) && !(obj instanceof CubridGroupNode)) {
        return false;
    }
    if (!isShowGroup && obj != null && !(obj instanceof CubridServer)) {
        return false;
    }
    Object[] 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 false;
    }
    if (!(objs[0] instanceof CubridServer)) {
        return false;
    }
    return true;
}
Also used : CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) CubridGroupNode(com.cubrid.common.ui.spi.model.CubridGroupNode) ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) CubridServer(com.cubrid.common.ui.spi.model.CubridServer)

Example 32 with CubridNavigatorView

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

the class ServiceDashboardEditor method loadAllData.

/**
	 * Load all data
	 */
public void loadAllData() {
    ServiceDashboardInfoMap.clear();
    CubridNavigatorView navigatorView = CubridNavigatorView.findNavigationView();
    if (navigatorView != null && navigatorView.savedIsShowGroup()) {
        inputList = CMGroupNodePersistManager.getInstance().getAllGroupNodes();
        List<CubridGroupNode> groupList = loadCubridGroupData(inputList);
        serviceTreeViewer.setInput(groupList);
    } else {
        inputList = CMHostNodePersistManager.getInstance().getAllServers();
        loadServerDashboardInfo(inputList);
        serviceTreeViewer.setInput(ServiceDashboardInfoMap);
    }
    serviceTreeViewer.expandAll();
}
Also used : CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) CubridGroupNode(com.cubrid.common.ui.spi.model.CubridGroupNode)

Example 33 with CubridNavigatorView

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

the class StartServiceAction method doRun.

/**
	 * Perform do run
	 * 
	 * @param servers
	 */
public void doRun(CubridServer[] servers) {
    CubridNavigatorView view = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
    final TreeViewer viewer = view.getViewer();
    if (servers.length > 0) {
        CubridServer server = servers[0];
        if (isSupported(server)) {
            final JobFamily jobFamily = new JobFamily();
            final String serverName = server.getName();
            String dbName = JobFamily.ALL_DB;
            jobFamily.setServerName(serverName);
            jobFamily.setDbName(dbName);
            Job[] jobs = Job.getJobManager().find(jobFamily);
            if (jobs.length > 0) {
                CommonUITool.openWarningBox(Messages.bind(Messages.msgStartServiceWithJob, serverName));
                return;
            }
            TaskExecutor taskExcutor = new StartServiceExecutor(server, getShell(), viewer);
            ServerInfo serverInfo = server.getServerInfo();
            GetCubridConfParameterTask task = new GetCubridConfParameterTask(serverInfo);
            taskExcutor.addTask(task);
            new ExecTaskWithProgress(taskExcutor).exec();
        }
    }
//		for(CubridServer server : servers) {
//			final JobFamily jobFamily = new JobFamily();
//			final String serverName = server.getName();
//			String dbName = JobFamily.ALL_DB;
//			jobFamily.setServerName(serverName);
//			jobFamily.setDbName(dbName);
//			Job[] jobs = Job.getJobManager().find(jobFamily);
//			if (jobs.length > 0) {
//				CommonUITool.openWarningBox(Messages.bind(
//						Messages.msgStartServiceWithJob, serverName));
//				return;
//			}
//
//			TaskExecutor taskExcutor = new StartServiceExecutor(server, getShell(),
//					viewer);
//			ServerInfo serverInfo = server.getServerInfo();
//			GetCubridConfParameterTask task = new GetCubridConfParameterTask(
//					serverInfo);
//			taskExcutor.addTask(task);
//			new ExecTaskWithProgress(taskExcutor).exec();
//		}
}
Also used : CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) JobFamily(com.cubrid.common.ui.spi.progress.JobFamily) GetCubridConfParameterTask(com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask) CubridServer(com.cubrid.common.ui.spi.model.CubridServer) Job(org.eclipse.core.runtime.jobs.Job)

Example 34 with CubridNavigatorView

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

the class CMDatabaseNavigatorMenu method loadNavigatorMenu.

/**
	 * load all database on all server. if not login or database not started,
	 * the item disabled.
	  * 
	  * @param dbSelectionMenu
	 */
public void loadNavigatorMenu(Menu dbSelectionMenu) {
    setSelectedImage(CubridManagerUIPlugin.getImage("/icons/navigator/eclipse_dot.png"));
    CubridNavigatorView navigatorView = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
    boolean isShowGroup = navigatorView == null ? false : navigatorView.isShowGroup();
    List<CubridGroupNode> groupList = CMGroupNodePersistManager.getInstance().getAllGroupNodes();
    if (groupList == null || groupList.isEmpty()) {
        return;
    }
    Collections.sort(groupList, new Comparator<CubridGroupNode>() {

        public int compare(CubridGroupNode o1, CubridGroupNode o2) {
            if (o1 == null || o2 == null || o1.getLabel() == null || o2.getLabel() == null) {
                return 0;
            }
            return o1.getLabel().compareToIgnoreCase(o2.getLabel());
        }
    });
    int count = 0;
    for (CubridGroupNode groupNode : groupList) {
        //			if (NodeFilterManager.getInstance().isHidden(groupNode)) {
        //				continue;
        //			}
        List<ICubridNode> nodeList = groupNode.getChildren();
        if (nodeList == null || nodeList.isEmpty()) {
            continue;
        }
        DatabaseMenuItem groupMenuItem = null;
        Menu groupSub = null;
        String groupName = null;
        if (isShowGroup) {
            groupName = groupNode.getLabel();
            groupMenuItem = new DatabaseMenuItem(groupNode.getId(), dbSelectionMenu, SWT.CASCADE);
            groupMenuItem.setImage(CubridManagerUIPlugin.getImage("/icons/navigator/group.png"));
            groupMenuItem.setText(groupName);
            groupSub = new Menu(dbSelectionMenu);
            groupMenuItem.setMenu(groupSub);
        }
        Collections.sort(nodeList, new Comparator<ICubridNode>() {

            public int compare(ICubridNode o1, ICubridNode o2) {
                if (o1 == null || o2 == null || o1.getLabel() == null || o2.getLabel() == null) {
                    return 0;
                }
                return o1.getLabel().compareToIgnoreCase(o2.getLabel());
            }
        });
        int itemCountInGroup = 0;
        for (ICubridNode node : nodeList) {
            //				}
            if (node instanceof CubridServer) {
                CubridServer server = (CubridServer) node;
                ICubridNode databaseFolderNode = server.getChild(server.getId() + ICubridNodeLoader.NODE_SEPARATOR + CubridServerLoader.DATABASE_FOLDER_ID);
                if (databaseFolderNode == null) {
                    continue;
                }
                //					if (NodeFilterManager.getInstance().isHidden(databaseFolderNode)) {
                //						continue;
                //					}
                ICubridNode[] dbs = databaseFolderNode.getChildren(new NullProgressMonitor());
                if (dbs == null || dbs.length == 0) {
                    continue;
                }
                String serverName = server.getLabel();
                DatabaseMenuItem serverMenuItem = null;
                Menu serverSub = null;
                if (isShowGroup) {
                    serverMenuItem = new DatabaseMenuItem(server.getId(), groupSub, SWT.CASCADE);
                    serverMenuItem.setImage(CubridManagerUIPlugin.getImage("/icons/navigator/host.png"));
                    serverMenuItem.setText(serverName);
                    serverSub = new Menu(groupSub);
                    serverMenuItem.setMenu(serverSub);
                } else {
                    serverMenuItem = new DatabaseMenuItem(server.getId(), dbSelectionMenu, SWT.CASCADE);
                    serverMenuItem.setImage(CubridManagerUIPlugin.getImage("/icons/navigator/host.png"));
                    serverMenuItem.setText(serverName);
                    serverSub = new Menu(dbSelectionMenu);
                    serverMenuItem.setMenu(serverSub);
                }
                count++;
                for (ICubridNode database : dbs) {
                    //						if (NodeFilterManager.getInstance().isHidden(database)) {
                    //							continue;
                    //						}
                    CubridDatabase db = (CubridDatabase) database;
                    if (!db.isLogined()) {
                        continue;
                    }
                    itemCountInGroup++;
                    DatabaseMenuItem dbItem = new DatabaseMenuItem(database.getId(), serverSub, SWT.RADIO);
                    dbItem.setText(database.getLabel());
                    dbItem.setDatabase((CubridDatabase) database);
                    dbItem.setEnabled(db.isLogined() && db.getRunningType() == DbRunningType.CS);
                    dbItem.setGroupName(groupName);
                    count++;
                }
            }
        }
        if (itemCountInGroup <= 0 && groupSub != null && groupMenuItem != null) {
            groupSub.dispose();
            groupMenuItem.dispose();
            continue;
        }
    }
    if (count > 0) {
        new MenuItem(dbSelectionMenu, SWT.SEPARATOR);
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) MenuItem(org.eclipse.swt.widgets.MenuItem) DatabaseMenuItem(com.cubrid.common.ui.query.control.DatabaseMenuItem) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) DatabaseMenuItem(com.cubrid.common.ui.query.control.DatabaseMenuItem) CubridServer(com.cubrid.common.ui.spi.model.CubridServer) CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) CubridGroupNode(com.cubrid.common.ui.spi.model.CubridGroupNode) DatabaseNavigatorMenu(com.cubrid.common.ui.query.control.DatabaseNavigatorMenu) Menu(org.eclipse.swt.widgets.Menu) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 35 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 cubridNavigatorView = CubridNavigatorView.findNavigationView();
    if (cubridNavigatorView != null) {
        cubridNavigatorView.setFocus();
    }
}
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