Search in sources :

Example 51 with ISelectionProvider

use of org.eclipse.jface.viewers.ISelectionProvider 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 52 with ISelectionProvider

use of org.eclipse.jface.viewers.ISelectionProvider in project cubrid-manager by CUBRID.

the class OptimizeAction method run.

public void run() {
    Object[] obj = this.getSelectedObj();
    if (!isSupported(obj[0])) {
        setEnabled(false);
        return;
    }
    ISchemaNode node = (ISchemaNode) obj[0];
    final CubridDatabase database = node.getDatabase();
    if (database == null) {
        CommonUITool.openErrorBox(getShell(), Messages.msgSelectDB);
        return;
    }
    OptimizeDialog dlg = new OptimizeDialog();
    GetClassListTask task = new GetClassListTask(database.getServer().getServerInfo(), database.getDatabaseInfo().getCharSet());
    task.setDbName(database.getName());
    if (database.getDatabaseInfo().getRunningType() == DbRunningType.STANDALONE) {
        task.setDbStatus(OnOffType.OFF);
    } else {
        task.setDbStatus(OnOffType.ON);
    }
    dlg.executeGetClassListTask(-1, task, true, getShell());
    if (task.getErrorMsg() != null || task.isCancel()) {
        return;
    }
    dlg.setDatabase(database);
    dlg.setUserClassList(task.getDbClassInfo().getUserClassList().getClassList());
    if (dlg.open() == DeleteDatabaseDialog.DELETE_ID) {
        ISelectionProvider provider = getSelectionProvider();
        if (provider instanceof TreeViewer) {
            TreeViewer treeViewer = (TreeViewer) provider;
            CommonUITool.refreshNavigatorTree(treeViewer, database.getParent());
            setEnabled(false);
        }
        ActionManager.getInstance().fireSelectionChanged(getSelection());
    }
}
Also used : ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) GetClassListTask(com.cubrid.cubridmanager.core.cubrid.table.task.GetClassListTask) TreeViewer(org.eclipse.jface.viewers.TreeViewer) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) OptimizeDialog(com.cubrid.cubridmanager.ui.cubrid.database.dialog.OptimizeDialog)

Example 53 with ISelectionProvider

use of org.eclipse.jface.viewers.ISelectionProvider in project cubrid-manager by CUBRID.

the class CopyDatabaseAction method run.

public void run() {
    Object[] obj = this.getSelectedObj();
    if (!isSupported(obj[0])) {
        setEnabled(false);
        return;
    }
    ISchemaNode schemaNode = (ISchemaNode) obj[0];
    final CubridDatabase database = schemaNode.getDatabase();
    if (database == null) {
        CommonUITool.openErrorBox(getShell(), Messages.msgSelectDB);
        return;
    }
    GetDbSizeTask dbSizeTask = new GetDbSizeTask(database.getServer().getServerInfo());
    dbSizeTask.setDbName(database.getName());
    final CommonQueryTask<DbSpaceInfoList> dbSpaceInfotask = new CommonQueryTask<DbSpaceInfoList>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), new DbSpaceInfoList());
    dbSpaceInfotask.setDbName(database.getName());
    ISelectionProvider provider = getSelectionProvider();
    final TreeViewer viewer = (TreeViewer) provider;
    final CopyDatabaseDialog dlg = new CopyDatabaseDialog(getShell(), viewer);
    dlg.execTask(-1, new SocketTask[] { dbSizeTask, dbSpaceInfotask }, true, getShell());
    if (dbSpaceInfotask.getErrorMsg() != null || dbSizeTask.isCancel() || dbSizeTask.getErrorMsg() != null || dbSpaceInfotask.isCancel()) {
        return;
    }
    dlg.setDbSize(dbSizeTask.getDbSize());
    dlg.setDbSpaceInfo(dbSpaceInfotask.getResultModel());
    dlg.setDatabase(database);
    dlg.open();
}
Also used : CopyDatabaseDialog(com.cubrid.cubridmanager.ui.cubrid.database.dialog.CopyDatabaseDialog) GetDbSizeTask(com.cubrid.cubridmanager.core.cubrid.database.task.GetDbSizeTask) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) TreeViewer(org.eclipse.jface.viewers.TreeViewer) DbSpaceInfoList(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 54 with ISelectionProvider

use of org.eclipse.jface.viewers.ISelectionProvider in project cubrid-manager by CUBRID.

the class DisConnectHostAction method doRun.

public void doRun(Object[] objArr) {
    if (CubridNavigatorView.findNavigationView() == null) {
        LOGGER.error("CubridNavigatorView.findNavigationView() is null.");
        return;
    }
    ISelectionProvider provider = CubridNavigatorView.findNavigationView().getViewer();
    if (!(provider instanceof TreeViewer)) {
        return;
    }
    List<CubridServer> connectedServers = new ArrayList<CubridServer>();
    StringBuffer hostNames = new StringBuffer();
    for (int i = 0; objArr != null && i < objArr.length; i++) {
        if (!isSupported(objArr[i])) {
            setEnabled(false);
            continue;
        }
        ICubridNode node = (ICubridNode) objArr[i];
        if (node instanceof CubridServer) {
            connectedServers.add((CubridServer) node);
            hostNames.append(node.getLabel());
            if (i != objArr.length - 1) {
                hostNames.append(",");
            }
        }
    }
    String msg = Messages.bind(Messages.msgConfirmDisconnectHost, hostNames.toString());
    boolean isDisconnectHost = CommonUITool.openConfirmBox(getShell(), msg);
    if (!isDisconnectHost) {
        return;
    }
    for (CubridServer server : connectedServers) {
        boolean isContinue = HostUtils.processHostDisconnected(server);
        if (isContinue) {
            TreeViewer viewer = (TreeViewer) provider;
            viewer.refresh(server, true);
            viewer.setSelection(null, true);
            viewer.setSelection(new StructuredSelection(server), true);
            ActionManager.getInstance().fireSelectionChanged(getSelection());
            LayoutManager.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) ArrayList(java.util.ArrayList) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) CubridServer(com.cubrid.common.ui.spi.model.CubridServer)

Example 55 with ISelectionProvider

use of org.eclipse.jface.viewers.ISelectionProvider in project cubrid-manager by CUBRID.

the class RefreshAction method run.

/**
	 * Reload the selected CUBRID node
	 */
public void run() {
    final Object[] obj = this.getSelectedObj();
    if (obj == null || obj.length == 0 || !isSupported(obj[0])) {
        return;
    }
    ICubridNode cubridNode = (ICubridNode) obj[0];
    String nodeType = cubridNode.getType();
    if (CubridNodeType.USER_TABLE.equals(nodeType) || CubridNodeType.SYSTEM_TABLE.equals(nodeType) || CubridNodeType.USER_PARTITIONED_TABLE_FOLDER.equals(nodeType) || CubridNodeType.USER_PARTITIONED_TABLE.equals(nodeType) || CubridNodeType.SYSTEM_VIEW.equals(nodeType) || CubridNodeType.USER_VIEW.equals(nodeType)) {
        ISchemaNode schemaNode = (ISchemaNode) cubridNode;
        schemaNode.getDatabase().getDatabaseInfo().removeSchema(cubridNode.getLabel());
    }
    LayoutManager.getInstance().getWorkbenchContrItem().reopenEditorOrView(cubridNode);
    if (CubridNodeType.GENERIC_VOLUME_FOLDER.equals(nodeType) || CubridNodeType.DATA_VOLUME_FOLDER.equals(nodeType) || CubridNodeType.INDEX_VOLUME_FOLDER.equals(nodeType) || CubridNodeType.TEMP_VOLUME_FOLDER.equals(nodeType)) {
        cubridNode = cubridNode.getParent();
    } else if (CubridNodeType.ACTIVE_LOG_FOLDER.equals(nodeType) || CubridNodeType.ARCHIVE_LOG_FOLDER.equals(nodeType)) {
        cubridNode = cubridNode.getParent() == null ? null : cubridNode.getParent().getParent();
    }
    ISelectionProvider provider = this.getSelectionProvider();
    if ((provider instanceof TreeViewer) && cubridNode != null && cubridNode.isContainer()) {
        TreeViewer viewer = (TreeViewer) provider;
        CommonUITool.refreshNavigatorTree(viewer, cubridNode);
    }
}
Also used : ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode)

Aggregations

ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)83 TreeViewer (org.eclipse.jface.viewers.TreeViewer)40 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)25 ISelection (org.eclipse.jface.viewers.ISelection)24 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)21 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)18 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)17 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)15 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)13 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)13 ITextSelection (org.eclipse.jface.text.ITextSelection)12 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)12 ArrayList (java.util.ArrayList)10 Shell (org.eclipse.swt.widgets.Shell)10 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)8 IEditorPart (org.eclipse.ui.IEditorPart)8 HashSet (java.util.HashSet)6 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)6 StyledText (org.eclipse.swt.custom.StyledText)6 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)6