Search in sources :

Example 71 with ICubridNode

use of com.cubrid.common.ui.spi.model.ICubridNode in project cubrid-manager by CUBRID.

the class ExecuteSqlLogAction method isSupported.

/**
	 * @see com.cubrid.common.ui.spi.action.ISelectionAction#isSupported(java
	 *      .lang.Object)
	 * @param obj Object
	 * @return boolean
	 */
public boolean isSupported(Object obj) {
    if (obj instanceof ICubridNode) {
        ICubridNode node = (ICubridNode) obj;
        if (node.getServer() == null) {
            return false;
        }
        ServerUserInfo serverUserInfo = node.getServer().getServerInfo().getLoginedUserInfo();
        if (serverUserInfo == null || serverUserInfo.getCasAuth() != CasAuthType.AUTH_ADMIN) {
            return false;
        }
        if (CubridNodeType.BROKER_SQL_LOG.equals(node.getType())) {
            return true;
        }
    }
    return false;
}
Also used : ServerUserInfo(com.cubrid.cubridmanager.core.common.model.ServerUserInfo) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode)

Example 72 with ICubridNode

use of com.cubrid.common.ui.spi.model.ICubridNode in project cubrid-manager by CUBRID.

the class DeleteMonitorDashboardAction method run.

/**
	 * Delete the selected monitoring dash board
	 */
public void run() {
    Object[] objArr = this.getSelectedObj();
    if (objArr == null || objArr.length <= 0) {
        setEnabled(false);
        return;
    }
    StringBuffer dashboardNames = new StringBuffer();
    for (int i = 0; objArr != null && i < objArr.length; i++) {
        if (!isSupported(objArr[i])) {
            setEnabled(false);
            return;
        }
        ICubridNode node = (ICubridNode) objArr[i];
        dashboardNames.append(node.getLabel());
        if (i != objArr.length - 1) {
            dashboardNames.append(",");
        }
    }
    boolean isDelete = CommonUITool.openConfirmBox(getShell(), Messages.bind(Messages.msgConfirmDeleteDashboard, dashboardNames.toString()));
    if (!isDelete) {
        return;
    }
    ISelectionProvider provider = this.getSelectionProvider();
    if (provider instanceof TreeViewer) {
        TreeViewer viewer = (TreeViewer) provider;
        for (int i = 0; i < objArr.length; i++) {
            ICubridNode node = (ICubridNode) objArr[i];
            LayoutUtil.closeEditorAndView(node);
            MonitorDashboardPersistManager.getInstance().removeMonitorDashboard(node);
            CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(node, CubridNodeChangedEventType.NODE_REMOVE));
        }
        /*TOOLS-3666 Refresh the input of TreeViewer*/
        viewer.setInput(CubridMonitorNavigatorView.getTreeViewerInput());
    }
}
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)

Example 73 with ICubridNode

use of com.cubrid.common.ui.spi.model.ICubridNode in project cubrid-manager by CUBRID.

the class RemoveAllScriptLogAction method isSupported.

/**
	 * @see com.cubrid.common.ui.spi.action.ISelectionAction#isSupported(java
	 *      .lang.Object)
	 * @param obj Object
	 * @return boolean(whether to support)
	 */
public boolean isSupported(Object obj) {
    if (obj instanceof ICubridNode) {
        ICubridNode node = (ICubridNode) obj;
        if (node.getServer() == null) {
            return false;
        }
        ServerUserInfo serverUserInfo = node.getServer().getServerInfo().getLoginedUserInfo();
        if (serverUserInfo == null || serverUserInfo.getCasAuth() != CasAuthType.AUTH_ADMIN) {
            return false;
        }
        if (CubridNodeType.BROKER_SQL_LOG_FOLDER.equals(node.getType())) {
            return true;
        }
    }
    return false;
}
Also used : ServerUserInfo(com.cubrid.cubridmanager.core.common.model.ServerUserInfo) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode)

Example 74 with ICubridNode

use of com.cubrid.common.ui.spi.model.ICubridNode in project cubrid-manager by CUBRID.

the class RemoveLogAction method isSupported.

/**
	 * @see com.cubrid.common.ui.spi.action.ISelectionAction#isSupported(java
	 *      .lang.Object)
	 * @param obj Object
	 * @return boolean(whether to support)
	 */
public boolean isSupported(Object obj) {
    if (obj instanceof Object[]) {
        return true;
    }
    if (!(obj instanceof ICubridNode)) {
        return false;
    }
    ICubridNode node = (ICubridNode) obj;
    if (node.getServer() == null) {
        return false;
    }
    ServerUserInfo serverUserInfo = node.getServer().getServerInfo().getLoginedUserInfo();
    String type = node.getType();
    if (CubridNodeType.BROKER_SQL_LOG.equals(type)) {
        if (serverUserInfo == null || serverUserInfo.getCasAuth() != CasAuthType.AUTH_ADMIN) {
            return false;
        }
        return true;
    } else if (CubridNodeType.LOGS_BROKER_ACCESS_LOG.equals(type) || CubridNodeType.LOGS_BROKER_ERROR_LOG.equals(type) || CubridNodeType.LOGS_SERVER_DATABASE_LOG.equals(type)) {
        if (serverUserInfo == null || !serverUserInfo.isAdmin()) {
            return false;
        }
        if (CubridNodeType.LOGS_SERVER_DATABASE_LOG.equals(type) && isLastDbServerLog(node)) {
            return false;
        }
        return true;
    }
    return false;
}
Also used : ServerUserInfo(com.cubrid.cubridmanager.core.common.model.ServerUserInfo) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode)

Example 75 with ICubridNode

use of com.cubrid.common.ui.spi.model.ICubridNode in project cubrid-manager by CUBRID.

the class TimeSetAction method run.

/**
	 * Open dialog
	 */
public void run() {
    TimeSetDialog timeSetDialog = new TimeSetDialog(getShell());
    timeSetDialog.create();
    timeSetDialog.getShell().setSize(580, 275);
    if (timeSetDialog.open() == Dialog.OK) {
        IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        if (window == null) {
            return;
        }
        Object[] obj = this.getSelectedObj();
        if (!isSupported(obj[0])) {
            setEnabled(false);
            return;
        }
        ICubridNode node = (ICubridNode) obj[0];
        LogInfo logInfo = (LogInfo) node.getAdapter(LogInfo.class);
        GetLogListTask task = new GetLogListTask(node.getServer().getServerInfo());
        task.setPath(logInfo.getPath());
        task.setStart("1");
        task.setEnd("100");
        TaskExecutor taskExcutor = new CommonTaskExec(Messages.loadLogTaskName);
        taskExcutor.addTask(task);
        new ExecTaskWithProgress(taskExcutor).exec();
        if (!taskExcutor.isSuccess()) {
            return;
        }
        LogContentInfo logContentInfo = (LogContentInfo) task.getLogContent();
        IEditorPart editor;
        try {
            editor = window.getActivePage().openEditor(node, LogEditorPart.ID);
            ((LogEditorPart) editor).setTableInfo(logContentInfo, true);
        } catch (PartInitException e) {
            LOGGER.error(e.getMessage(), e);
        }
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) LogInfo(com.cubrid.cubridmanager.core.logs.model.LogInfo) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) IEditorPart(org.eclipse.ui.IEditorPart) TimeSetDialog(com.cubrid.cubridmanager.ui.logs.dialog.TimeSetDialog) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) LogContentInfo(com.cubrid.cubridmanager.core.logs.model.LogContentInfo) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) GetLogListTask(com.cubrid.cubridmanager.core.logs.task.GetLogListTask) PartInitException(org.eclipse.ui.PartInitException) LogEditorPart(com.cubrid.cubridmanager.ui.logs.editor.LogEditorPart)

Aggregations

ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)362 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)67 ArrayList (java.util.ArrayList)67 DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)62 TreeViewer (org.eclipse.jface.viewers.TreeViewer)62 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)55 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)55 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)41 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)40 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)33 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)32 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)31 ICubridNodeLoader (com.cubrid.common.ui.spi.model.ICubridNodeLoader)27 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)26 CubridGroupNode (com.cubrid.common.ui.spi.model.CubridGroupNode)25 DefaultCubridNode (com.cubrid.common.ui.spi.model.DefaultCubridNode)25 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)25 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)25 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)23 CubridNavigatorView (com.cubrid.common.ui.common.navigator.CubridNavigatorView)22