Search in sources :

Example 1 with CubridNodeChangedEvent

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

the class EditSerialAction method run.

/**
	 * Open the editSerial dialog and edit serial
	 */
public int run(CubridDatabase database, final ISchemaNode node) {
    final Shell shell = getShell();
    TaskExecutor taskExcutor = new TaskExecutor() {

        public boolean exec(final IProgressMonitor monitor) {
            if (monitor.isCanceled()) {
                return false;
            }
            monitor.beginTask(Messages.loadSerialTaskName, IProgressMonitor.UNKNOWN);
            for (ITask task : taskList) {
                SerialInfo serialInfo = null;
                if (task instanceof GetSerialInfoTask) {
                    GetSerialInfoTask getSerialInfoTask = (GetSerialInfoTask) task;
                    serialInfo = getSerialInfoTask.getSerialInfo(node.getLabel());
                }
                final String msg = task.getErrorMsg();
                if (openErrorBox(shell, msg, monitor)) {
                    return false;
                }
                if (monitor.isCanceled()) {
                    return false;
                }
                if (serialInfo == null) {
                    openErrorBox(shell, Messages.errNameNotExist, monitor);
                    return false;
                }
                node.setModelObj(serialInfo);
            }
            return true;
        }
    };
    DatabaseInfo databaseInfo = database.getDatabaseInfo();
    GetSerialInfoTask task = new GetSerialInfoTask(databaseInfo);
    taskExcutor.addTask(task);
    new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
    if (!taskExcutor.isSuccess()) {
        return IDialogConstants.CANCEL_ID;
    }
    boolean isEditorAble = ActionSupportUtil.isSupportSinSelCheckDbUser(node, NodeType.SERIAL);
    CreateOrEditSerialDialog dialog = new CreateOrEditSerialDialog(getShell(), isEditorAble);
    dialog.setEditedNode(node);
    dialog.setDatabase(database);
    if (dialog.open() == IDialogConstants.OK_ID) {
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(node, CubridNodeChangedEventType.NODE_REFRESH));
        ActionManager.getInstance().fireSelectionChanged(getSelection());
        return IDialogConstants.OK_ID;
    }
    return IDialogConstants.CANCEL_ID;
}
Also used : CreateOrEditSerialDialog(com.cubrid.common.ui.cubrid.serial.dialog.CreateOrEditSerialDialog) Shell(org.eclipse.swt.widgets.Shell) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ITask(com.cubrid.common.core.task.ITask) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) SerialInfo(com.cubrid.common.core.common.model.SerialInfo) GetSerialInfoTask(com.cubrid.cubridmanager.core.cubrid.serial.task.GetSerialInfoTask)

Example 2 with CubridNodeChangedEvent

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

the class AlterTriggerAction method run.

/**
	 * edit trigger
	 * @param database
	 * @param node
	 * @return
	 */
public int run(final CubridDatabase database, final ISchemaNode node) {
    // FIXME move this logic to core module
    TaskExecutor taskExcutor = new TaskExecutor() {

        public boolean exec(final IProgressMonitor monitor) {
            if (monitor.isCanceled()) {
                return false;
            }
            for (ITask task : taskList) {
                task.execute();
                final String msg = task.getErrorMsg();
                if (openErrorBox(shell, msg, monitor)) {
                    return false;
                }
                if (monitor.isCanceled()) {
                    return false;
                }
                Trigger trigger = null;
                if (task instanceof GetTriggerListTask) {
                    GetTriggerListTask getTriggerListTask = (GetTriggerListTask) task;
                    List<Trigger> triggerList = getTriggerListTask.getTriggerInfoList();
                    for (int i = 0; triggerList != null && i < triggerList.size(); i++) {
                        Trigger trig = triggerList.get(i);
                        if (node.getName().equals(trig.getName())) {
                            trigger = trig;
                            break;
                        }
                    }
                } else if (task instanceof JDBCGetTriggerInfoTask) {
                    JDBCGetTriggerInfoTask getTriggerInfoTask = (JDBCGetTriggerInfoTask) task;
                    trigger = getTriggerInfoTask.getTriggerInfo(node.getLabel());
                }
                if (trigger == null) {
                    openErrorBox(shell, Messages.errNameNoExist, monitor);
                    return false;
                }
                // getting comment for version after 10.0
                if (CompatibleUtil.isCommentSupports(database.getDatabaseInfo())) {
                    try {
                        SchemaComment schemaComment = SchemaCommentHandler.loadObjectDescription(database.getDatabaseInfo(), JDBCConnectionManager.getConnection(database.getDatabaseInfo(), true), trigger.getName(), CommentType.TRIGGER);
                        trigger.setDescription(schemaComment.getDescription());
                    } catch (SQLException e) {
                        CommonUITool.openErrorBox(e.getMessage());
                    }
                }
                node.setModelObj(trigger);
            }
            return true;
        }
    };
    ITask task = null;
    if (ApplicationType.CUBRID_MANAGER.equals(PerspectiveManager.getInstance().getCurrentMode())) {
        task = new GetTriggerListTask(database.getServer().getServerInfo());
        ((GetTriggerListTask) task).setDbName(database.getName());
    } else {
        task = new JDBCGetTriggerInfoTask(database.getDatabaseInfo());
    }
    taskExcutor.addTask(task);
    new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
    if (!taskExcutor.isSuccess()) {
        return IDialogConstants.CANCEL_ID;
    }
    CreateTriggerDialog dialog = new CreateTriggerDialog(getShell(), node.getDatabase(), (Trigger) node.getAdapter(Trigger.class));
    if (dialog.open() != IDialogConstants.CANCEL_ID) {
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(node, CubridNodeChangedEventType.NODE_REFRESH));
        ActionManager.getInstance().fireSelectionChanged(getSelection());
        return IDialogConstants.OK_ID;
    }
    return IDialogConstants.CANCEL_ID;
}
Also used : ITask(com.cubrid.common.core.task.ITask) JDBCGetTriggerInfoTask(com.cubrid.cubridmanager.core.cubrid.trigger.task.JDBCGetTriggerInfoTask) SQLException(java.sql.SQLException) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Trigger(com.cubrid.common.core.common.model.Trigger) GetTriggerListTask(com.cubrid.cubridmanager.core.cubrid.trigger.task.GetTriggerListTask) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) CreateTriggerDialog(com.cubrid.common.ui.cubrid.trigger.dialog.CreateTriggerDialog) SchemaComment(com.cubrid.common.core.schemacomment.model.SchemaComment)

Example 3 with CubridNodeChangedEvent

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

the class MultiDatabaseLoginFailedDialog method editHost.

public void editHost(MultiDatabaseloginFailedInfo multiDatabaseloginFailedInfo) {
    if (multiDatabaseloginFailedInfo == null) {
        return;
    }
    CubridDatabase database = multiDatabaseloginFailedInfo.getCubridDatabase();
    //if login ,can't edit
    if (database.isLogined()) {
        return;
    }
    //		CubridDatabase oldDatabase = null;
    //		try {
    //			oldDatabase = database.clone();
    //		} catch (CloneNotSupportedException e) {
    //			//Ignore
    //		}
    LoginDatabaseDialog dialog = new LoginDatabaseDialog(getShell(), database);
    int returnVal = dialog.open();
    if (returnVal == IDialogConstants.OK_ID) {
        CubridNavigatorView view = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
        TreeViewer treeViewer = view.getViewer();
        database.removeAllChild();
        if (database.getLoader() != null) {
            database.getLoader().setLoaded(false);
        }
        treeViewer.refresh(database, true);
        treeViewer.expandToLevel(database, 1);
        /*Save the data*/
        DatabaseEditorConfig editorConfig = QueryOptions.getEditorConfig(database, true);
        if (editorConfig == null) {
            editorConfig = new DatabaseEditorConfig();
        }
        editorConfig.setBackGround(dialog.getSelectedColor());
        CMDBNodePersistManager.getInstance().addDatabase(database, editorConfig);
        ActionManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
        LayoutManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(database, CubridNodeChangedEventType.DATABASE_LOGIN));
        multiDatabaseloginFailedInfo.setErrMsg("");
    }
    databaseTable.refresh();
}
Also used : CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) TreeViewer(org.eclipse.jface.viewers.TreeViewer) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) DatabaseEditorConfig(com.cubrid.common.ui.spi.model.DatabaseEditorConfig)

Example 4 with CubridNodeChangedEvent

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

the class RenameHostAction method doRun.

private void doRun(CubridServer server) {
    Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
    RenameHostDialog dlg = new RenameHostDialog(shell, server);
    int ret = dlg.open();
    if (ret == IDialogConstants.OK_ID) {
        server.setLabel(dlg.getNewName());
        server.getServerInfo().setServerName(dlg.getNewName());
        CubridNavigatorView navigatorView = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
        TreeViewer treeViewer = navigatorView == null ? null : navigatorView.getViewer();
        if (treeViewer == null) {
            LOGGER.error("Error: Can't find the navigator view:" + CubridHostNavigatorView.ID);
            return;
        }
        // Fire all the databases which are in the server logout
        List<ICubridNode> children = server.getChildren();
        if (children != null) {
            for (ICubridNode child : children) {
                if (!NodeType.DATABASE_FOLDER.equals(child.getType())) {
                    continue;
                }
                List<ICubridNode> childList = child.getChildren();
                if (childList == null) {
                    continue;
                }
                for (ICubridNode node : childList) {
                    if (!NodeType.DATABASE.equals(node.getType())) {
                        continue;
                    }
                    CubridDatabase database = (CubridDatabase) node;
                    database.setLogined(false);
                    CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(database, CubridNodeChangedEventType.DATABASE_LOGOUT));
                }
            }
        }
        // Refresh the tree view
        server.removeAllChild();
        if (server.getLoader() != null) {
            server.getLoader().setLoaded(false);
        }
        treeViewer.refresh(server, true);
        treeViewer.expandToLevel(server, 1);
        treeViewer.setSelection(null, true);
        treeViewer.setSelection(new StructuredSelection(server), true);
        setEnabled(false);
        // Save the data
        CMHostNodePersistManager.getInstance().addServer(server.getServerInfo().getHostAddress(), server.getServerInfo().getHostMonPort(), server.getServerInfo().getUserName(), server.getServerInfo());
        QueryOptions.removePref(server.getServerInfo());
        BrokerIntervalSettingManager.getInstance().removeAllBrokerIntervalSettingInServer(server.getLabel());
        CMGroupNodePersistManager.getInstance().saveAllGroupNode();
        CMHostNodePersistManager.getInstance().saveServers();
        ActionManager.getInstance().fireSelectionChanged(getSelection());
        LayoutManager.getInstance().fireSelectionChanged(getSelection());
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(server, CubridNodeChangedEventType.SERVER_DISCONNECTED));
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) TreeViewer(org.eclipse.jface.viewers.TreeViewer) RenameHostDialog(com.cubrid.cubridmanager.ui.host.dialog.RenameHostDialog) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) 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 5 with CubridNodeChangedEvent

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

the class ChangeManagerPasswordAction method run.

/**
	 * Open change password dialog and change CUBRID Manager user password
	 */
public void run() {
    final Object[] obj = this.getSelectedObj();
    if (!isSupported(obj[0])) {
        return;
    }
    ICubridNode node = (ICubridNode) obj[0];
    CubridServer server = node.getServer();
    ChangePasswordDialog changePasswordDialog = new ChangePasswordDialog(getShell(), false);
    changePasswordDialog.setServerInfo(server.getServerInfo());
    ISelectionProvider provider = this.getSelectionProvider();
    if (IDialogConstants.OK_ID == changePasswordDialog.open() && provider instanceof TreeViewer) {
        TreeViewer viewer = (TreeViewer) provider;
        boolean isContinue = HostUtils.processHostDisconnected(server);
        if (isContinue) {
            viewer.refresh(server, true);
            ActionManager.getInstance().fireSelectionChanged(getSelection());
            CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(server, CubridNodeChangedEventType.SERVER_DISCONNECTED));
        }
    }
}
Also used : ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ChangePasswordDialog(com.cubrid.cubridmanager.ui.host.dialog.ChangePasswordDialog) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) CubridServer(com.cubrid.common.ui.spi.model.CubridServer)

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