Search in sources :

Example 86 with IViewPart

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

the class DatabaseMonitorPart method performRequest.

/**
	 * @see org.eclipse.gef.editparts.AbstractEditPart#performRequest(org.eclipse.gef.Request)
	 * @param req Request
	 */
public void performRequest(Request req) {
    if (req.getType() == RequestConstants.REQ_OPEN) {
        DatabaseNode databaseNode = (DatabaseNode) getModel();
        if (!databaseNode.isConnected()) {
            return;
        }
        IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        if (window == null) {
            return;
        }
        IWorkbenchPage page = window.getActivePage();
        if (page == null) {
            return;
        }
        HostNode hn = databaseNode.getParent();
        String secondaryId = new StringBuffer(databaseNode.getDbName()).append("&").append(hn.getUserName()).append("&").append(hn.getIp()).append("&").append(hn.getPort()).toString();
        IViewReference viewReference = page.findViewReference(DatabaseDashboardViewPart.ID, secondaryId);
        if (viewReference == null) {
            try {
                IViewPart viewPart = page.showView(DatabaseDashboardViewPart.ID, secondaryId, IWorkbenchPage.VIEW_ACTIVATE);
                ((DatabaseDashboardViewPart) viewPart).init(databaseNode);
            } catch (PartInitException ex) {
                viewReference = null;
            }
        } else {
            IViewPart viewPart = viewReference.getView(false);
            window.getActivePage().bringToTop(viewPart);
            ((DatabaseDashboardViewPart) viewPart).init(databaseNode);
        }
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IViewPart(org.eclipse.ui.IViewPart) DatabaseNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode) HostNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode) IViewReference(org.eclipse.ui.IViewReference) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException) DatabaseDashboardViewPart(com.cubrid.cubridmanager.ui.mondashboard.editor.DatabaseDashboardViewPart)

Example 87 with IViewPart

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

the class HostMonitorPart method performRequest.

/**
	 * @see org.eclipse.gef.editparts.AbstractEditPart#performRequest(org.eclipse.gef.Request)
	 * @param req Request
	 */
public void performRequest(Request req) {
    if (req.getType() == RequestConstants.REQ_OPEN) {
        HostNode hn = (HostNode) getModel();
        if (!hn.isConnected()) {
            return;
        }
        IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        if (window == null) {
            return;
        }
        IWorkbenchPage page = window.getActivePage();
        if (page == null) {
            return;
        }
        String secondaryId = new StringBuffer(hn.getUserName()).append("&").append(hn.getIp()).append("&").append(hn.getPort()).toString();
        IViewReference viewReference = page.findViewReference(HostDashboardViewPart.ID, secondaryId);
        if (viewReference == null) {
            try {
                IViewPart viewPart = page.showView(HostDashboardViewPart.ID, secondaryId, IWorkbenchPage.VIEW_ACTIVATE);
                ((HostDashboardViewPart) viewPart).init((HostNode) getModel());
            } catch (PartInitException ex) {
                viewReference = null;
            }
        } else {
            IViewPart viewPart = viewReference.getView(false);
            window.getActivePage().bringToTop(viewPart);
            ((HostDashboardViewPart) viewPart).init((HostNode) getModel());
        }
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IViewPart(org.eclipse.ui.IViewPart) HostNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode) IViewReference(org.eclipse.ui.IViewReference) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException) HostDashboardViewPart(com.cubrid.cubridmanager.ui.mondashboard.editor.HostDashboardViewPart)

Example 88 with IViewPart

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

the class DeleteStatusMonitorTemplateAction method delStatusTemp.

/**
	 * delete status template task.
	 * 
	 * @param activePage IWorkbenchPage
	 * @param selection ICubridNode
	 * @return DelStatusTemplateTask
	 */
private DelStatusTemplateTask delStatusTemp(IWorkbenchPage activePage, ICubridNode selection) {
    DelStatusTemplateTask delTsk = new DelStatusTemplateTask(selection.getServer().getServerInfo());
    IViewReference viewRef = activePage.findViewReference(StatusMonitorViewPart.ID, selection.getLabel());
    if (viewRef != null) {
        IViewPart viewPart = viewRef.getView(false);
        //closes the view part
        if (null != viewPart && viewPart.getTitle().endsWith(selection.getLabel())) {
            activePage.hideView(viewPart);
        }
    }
    delTsk.setTemplateName(selection.getName());
    return delTsk;
}
Also used : IViewPart(org.eclipse.ui.IViewPart) DelStatusTemplateTask(com.cubrid.cubridmanager.core.monitoring.task.DelStatusTemplateTask) IViewReference(org.eclipse.ui.IViewReference)

Example 89 with IViewPart

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

the class HostDashboardHistoryAction method run.

/**
	 * Open monitor host detail windows.
	 */
public void run() {
    if (getSelectedObj() == null || getSelectedObj().length == 0) {
        return;
    }
    Object obj = getSelectedObj()[0];
    if (!(obj instanceof HostMonitorPart)) {
        return;
    }
    HostMonitorPart part = (HostMonitorPart) obj;
    HostNode hn = (HostNode) part.getModel();
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window == null) {
        return;
    }
    IWorkbenchPage page = window.getActivePage();
    if (page == null) {
        return;
    }
    String secondaryId = new StringBuffer(hn.getUserName()).append("&").append(hn.getIp()).append("&").append(hn.getPort()).toString();
    IViewReference viewReference = page.findViewReference(HostDashboardHistoryViewPart.ID, secondaryId);
    if (viewReference == null) {
        try {
            IViewPart viewPart = page.showView(HostDashboardHistoryViewPart.ID, secondaryId, IWorkbenchPage.VIEW_ACTIVATE);
            ((HostDashboardHistoryViewPart) viewPart).init((HostNode) part.getModel());
        } catch (PartInitException ex) {
            viewReference = null;
        }
    } else {
        IViewPart viewPart = viewReference.getView(false);
        window.getActivePage().bringToTop(viewPart);
        ((HostDashboardHistoryViewPart) viewPart).init((HostNode) part.getModel());
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IViewPart(org.eclipse.ui.IViewPart) HostNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode) IViewReference(org.eclipse.ui.IViewReference) HostDashboardHistoryViewPart(com.cubrid.cubridmanager.ui.mondashboard.editor.HostDashboardHistoryViewPart) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException) HostMonitorPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.HostMonitorPart)

Example 90 with IViewPart

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

the class OpenMonitorDashboardViewAction method run.

/**
	 * Open HA monitor view part
	 */
public void run() {
    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    boolean isExist = false;
    IViewReference[] viewRefArr = page.getViewReferences();
    if (viewRefArr != null && viewRefArr.length > 0) {
        for (IViewReference viewRef : viewRefArr) {
            String id = viewRef.getId();
            if (CubridMonitorNavigatorView.ID.equals(id)) {
                IViewPart viewPart = viewRef.getView(true);
                if (viewPart == null) {
                    isExist = false;
                } else {
                    page.bringToTop(viewRef.getView(true));
                    isExist = true;
                }
                break;
            }
        }
    }
    if (!isExist) {
        try {
            page.showView(CubridMonitorNavigatorView.ID);
        } catch (PartInitException e) {
            LOGGER.error(e.getMessage());
        }
    }
}
Also used : IViewPart(org.eclipse.ui.IViewPart) IViewReference(org.eclipse.ui.IViewReference) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException)

Aggregations

IViewPart (org.eclipse.ui.IViewPart)104 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)58 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)39 IEditorPart (org.eclipse.ui.IEditorPart)34 PartInitException (org.eclipse.ui.PartInitException)28 IViewReference (org.eclipse.ui.IViewReference)26 ArrayList (java.util.ArrayList)16 IFile (org.eclipse.core.resources.IFile)15 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)15 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)15 IEditorInput (org.eclipse.ui.IEditorInput)13 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)13 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)10 IXliffEditor (net.heartsome.cat.ts.ui.editors.IXliffEditor)10 ITermViewPart (net.heartsome.cat.ts.ui.view.ITermViewPart)10 Shell (org.eclipse.swt.widgets.Shell)9 IEditorReference (org.eclipse.ui.IEditorReference)9 XLFHandler (net.heartsome.cat.ts.core.file.XLFHandler)8 XLIFFEditorImplWithNatTable (net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable)8 IProject (org.eclipse.core.resources.IProject)8