Search in sources :

Example 56 with CubridNodeChangedEvent

use of com.cubrid.common.ui.spi.event.CubridNodeChangedEvent in project cubrid-manager by CUBRID.

the class LoginDatabaseAction method doRun.

public void doRun(CubridDatabase[] databaseArray) {
    if (databaseArray == null || databaseArray.length == 0) {
        return;
    }
    CubridNavigatorView navigationView = CubridNavigatorView.findNavigationView();
    if (navigationView != null && databaseArray.length > 0) {
        final TreeViewer treeViewer = navigationView.getViewer();
        if (databaseArray.length > 1) {
            List<MultiDatabaseloginFailedInfo> failedDatabaseList = new ArrayList<MultiDatabaseloginFailedInfo>();
            for (CubridDatabase object : databaseArray) {
                CubridDatabase database = (CubridDatabase) object;
                String errMsg = null;
                if (database.isAutoSavePassword()) {
                    errMsg = CubridWorkbenchContrItem.connectDatabaseWithErrMsg(database.getDatabaseInfo(), false);
                } else {
                    errMsg = "Incorrect or missing password.";
                }
                if (errMsg == null) {
                    database.getLoader().setLoaded(false);
                    database.setLogined(true);
                    treeViewer.refresh(database, true);
                    treeViewer.expandToLevel(database, 1);
                    ActionManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
                    LayoutManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
                    CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(database, CubridNodeChangedEventType.DATABASE_LOGIN));
                    // open database dashboard
                    if (GeneralPreference.isUseDatabaseDashboard()) {
                        LayoutManager.getInstance().getWorkbenchContrItem().openEditorOrView(database);
                    }
                } else {
                    failedDatabaseList.add(new MultiDatabaseloginFailedInfo(database, errMsg));
                }
            }
            if (failedDatabaseList.size() > 0) {
                MultiDatabaseLoginFailedDialog dialog = new MultiDatabaseLoginFailedDialog(getShell(), failedDatabaseList);
                dialog.open();
            }
            return;
        } else {
            CubridDatabase database = databaseArray[0];
            if (DbRunningType.STANDALONE.equals(database.getRunningType()) && ActionSupportUtil.hasAdminPermissionOnStopState(database)) {
                if (CommonUITool.openConfirmBox(Messages.bind(Messages.msgWhetherStartDB, database.getName()))) {
                    StartDatabaseAction startDatabaseAction = (StartDatabaseAction) ActionManager.getInstance().getAction(StartDatabaseAction.ID);
                    startDatabaseAction.doRun(new CubridDatabase[] { database });
                }
            }
            if (!database.isLogined() && database.isAutoSavePassword()) {
                DatabaseEditorConfig editorConfig = QueryOptions.getEditorConfig(database, true);
                if (EditorConstance.isNeedSetBackground(editorConfig)) {
                    new ShortSetEditorConfigAction(database).run();
                }
            }
            if (!database.isLogined() && database.isAutoSavePassword() && CubridWorkbenchContrItem.connectDatabase(database.getDatabaseInfo(), true)) {
                database.getLoader().setLoaded(false);
                database.setLogined(true);
                treeViewer.refresh(database, true);
                treeViewer.expandToLevel(database, 1);
                ActionManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
                LayoutManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
                CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(database, CubridNodeChangedEventType.DATABASE_LOGIN));
                // open database dashboard
                if (GeneralPreference.isUseDatabaseDashboard()) {
                    LayoutManager.getInstance().getWorkbenchContrItem().openEditorOrView(database);
                }
            } else if (!database.isLogined()) {
                EditDatabaseLoginAction editDatabaseLoginAction = (EditDatabaseLoginAction) ActionManager.getInstance().getAction(EditDatabaseLoginAction.ID);
                editDatabaseLoginAction.doRun(databaseArray);
            }
        }
    }
}
Also used : TreeViewer(org.eclipse.jface.viewers.TreeViewer) ArrayList(java.util.ArrayList) MultiDatabaseloginFailedInfo(com.cubrid.cubridmanager.ui.cubrid.database.dialog.MultiDatabaseloginFailedInfo) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) ShortSetEditorConfigAction(com.cubrid.cubridmanager.ui.common.action.ShortSetEditorConfigAction) MultiDatabaseLoginFailedDialog(com.cubrid.cubridmanager.ui.cubrid.database.dialog.MultiDatabaseLoginFailedDialog) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) DatabaseEditorConfig(com.cubrid.common.ui.spi.model.DatabaseEditorConfig)

Example 57 with CubridNodeChangedEvent

use of com.cubrid.common.ui.spi.event.CubridNodeChangedEvent in project cubrid-manager by CUBRID.

the class LogoutDatabaseAction method run.

public void run() {
    Object[] objArr = this.getSelectedObj();
    if (objArr == null || objArr.length <= 0) {
        setEnabled(false);
        return;
    }
    ISelectionProvider provider = this.getSelectionProvider();
    if (!(provider instanceof TreeViewer)) {
        return;
    }
    StringBuffer dbNames = new StringBuffer();
    for (int i = 0; objArr != null && i < objArr.length; i++) {
        if (!isSupported(objArr[i])) {
            setEnabled(false);
            return;
        }
        ICubridNode node = (ICubridNode) objArr[i];
        dbNames.append(node.getLabel());
        if (i != objArr.length - 1) {
            dbNames.append(",");
        }
    }
    boolean isLogout = CommonUITool.openConfirmBox(getShell(), Messages.bind(Messages.msgConfirmLogoutDatabase, dbNames.toString()));
    if (!isLogout) {
        return;
    }
    TreeViewer viewer = (TreeViewer) provider;
    for (int i = 0; i < objArr.length; i++) {
        CubridDatabase database = (CubridDatabase) objArr[i];
        boolean isContinue = DatabaseUtils.processDatabaseLogout(database);
        if (isContinue) {
            viewer.refresh(database, true);
            CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(database, CubridNodeChangedEventType.DATABASE_LOGOUT));
        }
    }
    ActionManager.getInstance().fireSelectionChanged(getSelection());
}
Also used : ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 58 with CubridNodeChangedEvent

use of com.cubrid.common.ui.spi.event.CubridNodeChangedEvent in project cubrid-manager by CUBRID.

the class EditDatabaseLoginAction method doRun.

public void doRun(CubridDatabase[] databaseArray) {
    if (databaseArray == null || databaseArray.length == 0) {
        return;
    }
    CubridNavigatorView navigationView = CubridNavigatorView.findNavigationView();
    if (navigationView != null) {
        final TreeViewer treeViewer = navigationView.getViewer();
        CubridDatabase database = (CubridDatabase) databaseArray[0];
        LoginDatabaseDialog dialog = new LoginDatabaseDialog(getShell(), database);
        int returnVal = dialog.open();
        if (returnVal == IDialogConstants.OK_ID && provider instanceof TreeViewer) {
            database.removeAllChild();
            if (database.getLoader() != null) {
                database.getLoader().setLoaded(false);
            }
            treeViewer.refresh(database, true);
            treeViewer.expandToLevel(database, 1);
            ActionManager.getInstance().fireSelectionChanged(getSelection());
            LayoutManager.getInstance().fireSelectionChanged(getSelection());
            if (dialog.isFireLogoutEvent()) {
                CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(database, CubridNodeChangedEventType.DATABASE_LOGOUT));
            }
            CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(database, CubridNodeChangedEventType.DATABASE_LOGIN));
        } else if (returnVal == LoginDatabaseDialog.SAVE_ID && provider instanceof TreeViewer) {
            treeViewer.refresh(database, true);
            treeViewer.expandToLevel(database, 1);
        }
    }
}
Also used : CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) TreeViewer(org.eclipse.jface.viewers.TreeViewer) LoginDatabaseDialog(com.cubrid.cubridmanager.ui.cubrid.database.dialog.LoginDatabaseDialog) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 59 with CubridNodeChangedEvent

use of com.cubrid.common.ui.spi.event.CubridNodeChangedEvent in project cubrid-manager by CUBRID.

the class AddMonitorStatisticPageAction method run.

/**
	 * Override the run method in order to open an instance of status monitor
	 * dialog
	 * 
	 */
public void run() {
    Object[] obj = this.getSelectedObj();
    ICubridNode node = null;
    if (obj.length > 0) {
        node = (ICubridNode) obj[0];
    }
    String hostId = null;
    boolean isSingleHost = node != null && CubridNodeType.MONITOR_FOLDER.equals(node.getType());
    if (isSingleHost) {
        ServerInfo serverInfo = node.getServer().getServerInfo();
        hostId = serverInfo.getServerName();
        if (!serverInfo.isSupportMonitorStatistic()) {
            CommonUITool.openWarningBox(Messages.needEnableMonitorStatisticMsg);
            return;
        }
    }
    AddStatisticPageDialog dialog = new AddStatisticPageDialog(getShell());
    dialog.setCubridServerId(hostId);
    if (dialog.open() == Dialog.OK) {
        final String iconPath = "icons/navigator/status_item.png";
        String labelName = dialog.getName();
        String pageName = labelName;
        if (hostId != null) {
            pageName += "@" + hostId;
        }
        MonitorStatistic monitorStatisticNode = new MonitorStatistic(pageName, labelName, iconPath);
        monitorStatisticNode.setType(CubridNodeType.MONITOR_STATISTIC_PAGE);
        monitorStatisticNode.setEditorId(MonitorStatisticEditor.ID);
        if (isSingleHost) {
            monitorStatisticNode.setMultiHost(false);
            ServerInfo serverInfo = node.getServer().getServerInfo();
            monitorStatisticNode.setIp(serverInfo.getHostAddress());
            monitorStatisticNode.setPort(serverInfo.getHostMonPort());
        } else {
            monitorStatisticNode.setMultiHost(true);
        }
        MonitorStatisticPersistManager persistManager = MonitorStatisticPersistManager.getInstance();
        persistManager.addMonitorStatistic(monitorStatisticNode, hostId);
        persistManager.saveStatistic();
        //refresh TreeViewer
        TreeViewer treeViewer = (TreeViewer) this.getSelectionProvider();
        if (isSingleHost) {
            node.addChild(monitorStatisticNode);
            treeViewer.add(node, monitorStatisticNode);
        } else {
            /*TOOLS-3665 Refresh the input of TreeViewer*/
            treeViewer.setInput(CubridMonitorNavigatorView.getTreeViewerInput());
        }
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(monitorStatisticNode, CubridNodeChangedEventType.NODE_ADD));
        try {
            IWorkbench workbench = PlatformUI.getWorkbench();
            IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
            workbenchWindow.getActivePage().openEditor(monitorStatisticNode, MonitorStatisticEditor.ID);
        } catch (Exception ignore) {
        }
    } else {
    //TODO
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) MonitorStatisticPersistManager(com.cubrid.cubridmanager.ui.spi.persist.MonitorStatisticPersistManager) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) IWorkbench(org.eclipse.ui.IWorkbench) AddStatisticPageDialog(com.cubrid.cubridmanager.ui.monstatistic.dialog.AddStatisticPageDialog) MonitorStatistic(com.cubrid.common.ui.spi.model.MonitorStatistic)

Example 60 with CubridNodeChangedEvent

use of com.cubrid.common.ui.spi.event.CubridNodeChangedEvent in project cubrid-manager by CUBRID.

the class DeleteMonitorStatisticPageAction method run.

/**
	 * Override the run method in order to open an instance of status monitor
	 * dialog
	 * 
	 */
public void run() {
    Object[] obj = this.getSelectedObj();
    ICubridNode node = (ICubridNode) obj[0];
    String message = Messages.bind(Messages.confirmStatisticPageDeleteWarn, node.getId());
    if (!CommonUITool.openConfirmBox(message)) {
        return;
    }
    ICubridNode parent = node.getParent();
    boolean isSingHost = parent != null && CubridNodeType.MONITOR_FOLDER.equals(parent.getType());
    String hostId = null;
    if (isSingHost) {
        hostId = node.getServer().getServerName();
        hostId = parent.getServer().getServerName();
    }
    MonitorStatisticPersistManager persistManager = MonitorStatisticPersistManager.getInstance();
    persistManager.removeMonitorStatistic((MonitorStatistic) node, hostId);
    persistManager.saveStatistic();
    TreeViewer treeViewer = (TreeViewer) this.getSelectionProvider();
    LayoutUtil.closeEditorAndView(node);
    if (isSingHost) {
        parent.removeChild(node);
        treeViewer.remove(node);
    } else {
        /*TOOLS-3666 Refresh the input of TreeViewer*/
        treeViewer.setInput(CubridMonitorNavigatorView.getTreeViewerInput());
    }
    CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(node, CubridNodeChangedEventType.NODE_REMOVE));
}
Also used : MonitorStatisticPersistManager(com.cubrid.cubridmanager.ui.spi.persist.MonitorStatisticPersistManager) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)

Aggregations

CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)98 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)55 TreeViewer (org.eclipse.jface.viewers.TreeViewer)45 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)42 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)23 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)23 CubridNavigatorView (com.cubrid.common.ui.common.navigator.CubridNavigatorView)21 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)21 DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)17 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)17 ArrayList (java.util.ArrayList)13 DefaultCubridNode (com.cubrid.common.ui.spi.model.DefaultCubridNode)11 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)10 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)10 ClassInfo (com.cubrid.cubridmanager.core.cubrid.table.model.ClassInfo)10 Display (org.eclipse.swt.widgets.Display)10 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)9 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)9 DbUserInfo (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo)9 ICubridNodeLoader (com.cubrid.common.ui.spi.model.ICubridNodeLoader)8