Search in sources :

Example 96 with IWorkbenchWindow

use of org.eclipse.ui.IWorkbenchWindow in project cubrid-manager by CUBRID.

the class BrokerEnvStatusView method createTable.

/**
	 * This method initializes table
	 *
	 */
private void createTable() {
    tableViewer = new TableViewer(composite, SWT.FULL_SELECTION);
    tableViewer.getTable().setHeaderVisible(true);
    tableViewer.getTable().setLinesVisible(true);
    BrokerTblColumnSetHelp bcsh = BrokerTblColumnSetHelp.getInstance();
    bcsh.loadSetting(BrokerTblColumnSetHelp.StatusColumn.BrokerEnvStatusColumn, BrokerEnvStatusColumn.values());
    TableLayout tlayout = new TableLayout();
    for (BrokerEnvStatusColumn column : BrokerEnvStatusColumn.values()) {
        if (column.getValue() == -1) {
            tlayout.addColumnData(new ColumnWeightData(0, 0, false));
        } else {
            tlayout.addColumnData(new ColumnWeightData(10, 40, true));
        }
    }
    tableViewer.getTable().setLayout(tlayout);
    tableViewer.getTable().addMouseListener(new MouseAdapter() {

        public void mouseDoubleClick(MouseEvent event) {
            int index = -1;
            if ((index = tableViewer.getTable().getSelectionIndex()) >= 0) {
                TableItem tableItem = tableViewer.getTable().getItem(index);
                String brokename = tableItem.getText(0).trim();
                ICubridNode input = null;
                for (ICubridNode node : cubridNode.getChildren()) {
                    if (node.getLabel().equalsIgnoreCase(brokename)) {
                        input = node;
                        break;
                    }
                }
                LayoutManager.getInstance().setCurrentSelectedNode(input);
                IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
                if (null == window) {
                    return;
                }
                IWorkbenchPage activePage = window.getActivePage();
                IViewPart viewPart = window.getActivePage().findView(BrokerStatusView.ID);
                if (null != viewPart) {
                    activePage.hideView(viewPart);
                }
                try {
                    activePage.showView(BrokerStatusView.ID);
                } catch (PartInitException e1) {
                    LOGGER.error(e1.getMessage(), e1);
                }
            }
        }
    });
    makeTableColumn();
    tableViewer.setContentProvider(new BrokersStatusContentProvider());
    ServerInfo serverInfo = cubridNode.getServer().getServerInfo();
    BrokersStatusLabelProvider brokersStatusLabelProvider = new BrokersStatusLabelProvider();
    brokersStatusLabelProvider.setServerInfo(serverInfo);
    tableViewer.setLabelProvider(brokersStatusLabelProvider);
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IViewPart(org.eclipse.ui.IViewPart) MouseEvent(org.eclipse.swt.events.MouseEvent) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) TableItem(org.eclipse.swt.widgets.TableItem) MouseAdapter(org.eclipse.swt.events.MouseAdapter) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) BrokerEnvStatusColumn(com.cubrid.cubridmanager.ui.broker.editor.internal.BrokerEnvStatusColumn) BrokerTblColumnSetHelp(com.cubrid.cubridmanager.ui.broker.editor.internal.BrokerTblColumnSetHelp) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException) TableViewer(org.eclipse.jface.viewers.TableViewer) TableLayout(org.eclipse.jface.viewers.TableLayout)

Example 97 with IWorkbenchWindow

use of org.eclipse.ui.IWorkbenchWindow in project cubrid-manager by CUBRID.

the class QueryNewCustomAction method run.

/**
	 * @see org.eclipse.jface.action.Action#run()
	 */
public void run() {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window == null) {
        return;
    }
    Object[] selected = getSelectedObj();
    LoginQueryEditDialog dialog = new LoginQueryEditDialog(getShell());
    if (selected != null && selected.length == 1 && selected[0] instanceof ISchemaNode) {
        dialog.setSelServerName(((ISchemaNode) selected[0]).getServer().getServerName());
        dialog.setSelDatabaseName(((ISchemaNode) selected[0]).getDatabase().getName());
    } else if (selected != null && selected.length == 1 && selected[0] instanceof CubridServer) {
        dialog.setSelServerName(((CubridServer) selected[0]).getName());
    } else {
        dialog.setSelServerName(DatabaseNavigatorMenu.SELF_DATABASE_SELECTED_LABEL);
    }
    if (dialog.open() == IDialogConstants.OK_ID) {
        try {
            IEditorInput input = new QueryUnit();
            IEditorPart editor = window.getActivePage().openEditor(input, QueryEditorPart.ID);
            ((QueryEditorPart) editor).connect(DatabaseNavigatorMenu.SELF_DATABASE);
        } catch (PartInitException e) {
            LOGGER.error(e.getMessage());
        }
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) QueryEditorPart(com.cubrid.common.ui.query.editor.QueryEditorPart) QueryUnit(com.cubrid.common.ui.query.editor.QueryUnit) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) LoginQueryEditDialog(com.cubrid.cubridmanager.ui.common.dialog.LoginQueryEditDialog) IEditorPart(org.eclipse.ui.IEditorPart) PartInitException(org.eclipse.ui.PartInitException) CubridServer(com.cubrid.common.ui.spi.model.CubridServer) IEditorInput(org.eclipse.ui.IEditorInput)

Example 98 with IWorkbenchWindow

use of org.eclipse.ui.IWorkbenchWindow in project cubrid-manager by CUBRID.

the class EditBrokerConfigAction method run.

public void run() {
    final Object[] obj = this.getSelectedObj();
    if (obj == null || obj.length <= 0) {
        setEnabled(false);
        return;
    }
    CubridServer server = null;
    if (obj[0] instanceof CubridServer) {
        server = (CubridServer) obj[0];
    } else if (obj[0] instanceof CubridBrokerFolder) {
        server = ((CubridBrokerFolder) obj[0]).getServer();
    }
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window == null || server == null) {
        return;
    }
    ConfEditInput editorInput = new ConfEditInput();
    String id = ConfigType.CUBRID_BROKER.getValue() + "&" + server.getId();
    editorInput.setId(id);
    editorInput.setServerInfo(server.getServerInfo());
    editorInput.setName(server.getName());
    editorInput.setServerName(server.getServerName());
    editorInput.setServerPort(server.getMonPort());
    String[] tipMsg = new String[] { ConfigType.CUBRID_BROKER.getValue(), server.getName(), server.getServerName(), server.getMonPort() };
    String toolTipText = Messages.bind(Messages.msgEditorTooltip, tipMsg);
    editorInput.setToolTipText(toolTipText);
    try {
        window.getActivePage().openEditor(editorInput, EditCMCubridBrokerConfPart.ID);
    } catch (Exception ex) {
        LOGGER.error("", ex);
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) CubridServer(com.cubrid.common.ui.spi.model.CubridServer) CubridBrokerFolder(com.cubrid.cubridmanager.ui.spi.model.CubridBrokerFolder)

Example 99 with IWorkbenchWindow

use of org.eclipse.ui.IWorkbenchWindow in project cubrid-manager by CUBRID.

the class HostDashboardAction method getOpenedEditorPart.

/**
	 * Get all opened query editor
	 * 
	 * @return
	 */
private HostDashboardEditor getOpenedEditorPart(String serverName) {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window == null) {
        return null;
    }
    IEditorReference[] editorReferences = window.getActivePage().getEditorReferences();
    for (IEditorReference reference : editorReferences) {
        if (reference.getId().equals(HostDashboardEditor.ID)) {
            HostDashboardEditor editor = (HostDashboardEditor) reference.getEditor(false);
            if (editor != null && editor.getServerInfo() != null && editor.getServerInfo().getServerName().equals(serverName)) {
                return editor;
            }
        }
    }
    return null;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IEditorReference(org.eclipse.ui.IEditorReference) HostDashboardEditor(com.cubrid.cubridmanager.ui.host.editor.HostDashboardEditor)

Example 100 with IWorkbenchWindow

use of org.eclipse.ui.IWorkbenchWindow in project cubrid-manager by CUBRID.

the class HostDashboardAction method doRun.

public void doRun(ServerInfo serverInfo) {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (null == window) {
        return;
    }
    // Check it open same editor
    HostDashboardEditor editorPart = getOpenedEditorPart(serverInfo.getServerName());
    if (editorPart == null) {
        HostDashboardEditorInput editorInput = new HostDashboardEditorInput(serverInfo);
        editorInput.setName(serverInfo.getServerName());
        editorInput.setToolTipText(serverInfo.getServerName());
        try {
            editorPart = (HostDashboardEditor) window.getActivePage().openEditor(editorInput, HostDashboardEditor.ID);
        } catch (PartInitException ex) {
            LOGGER.error(ex.getMessage());
        }
    } else {
        window.getActivePage().activate(editorPart);
        editorPart.loadAllData();
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) PartInitException(org.eclipse.ui.PartInitException) HostDashboardEditor(com.cubrid.cubridmanager.ui.host.editor.HostDashboardEditor)

Aggregations

IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)284 IEditorPart (org.eclipse.ui.IEditorPart)114 PartInitException (org.eclipse.ui.PartInitException)70 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)68 QueryEditorPart (com.cubrid.common.ui.query.editor.QueryEditorPart)39 IViewPart (org.eclipse.ui.IViewPart)38 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)35 ArrayList (java.util.ArrayList)34 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)32 IEditorReference (org.eclipse.ui.IEditorReference)30 XLIFFEditorImplWithNatTable (net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable)27 ISelection (org.eclipse.jface.viewers.ISelection)25 XLFHandler (net.heartsome.cat.ts.core.file.XLFHandler)24 IFile (org.eclipse.core.resources.IFile)23 IWorkbench (org.eclipse.ui.IWorkbench)21 CoreException (org.eclipse.core.runtime.CoreException)20 QueryUnit (com.cubrid.common.ui.query.editor.QueryUnit)19 IProject (org.eclipse.core.resources.IProject)19 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)17 TreeViewer (org.eclipse.jface.viewers.TreeViewer)17