Search in sources :

Example 1 with IViewSite

use of org.eclipse.ui.IViewSite in project tdi-studio-se by Talend.

the class StatLogsAndImplicitcontextTreeViewPage method createStatTree.

private void createStatTree(Composite composite) {
    //$NON-NLS-1$
    Group g = widgetFactory.createGroup(composite, Messages.getString("StatsAndLogsComposite.StatsLogsSettings"));
    GridData gd = new GridData(GridData.FILL_BOTH);
    g.setLayoutData(gd);
    g.setLayout(new FillLayout());
    statViewer = new CheckboxRepositoryTreeViewer(g, SWT.MULTI | SWT.V_SCROLL);
    statContentProvider = new AllJobContentProvider(repositoryView);
    statViewer.setContentProvider(statContentProvider);
    statViewer.setLabelProvider(new RepositoryLabelProvider(repositoryView));
    statViewer.setSorter(repositoryView.getViewer().getSorter());
    IViewSite viewSite = repositoryView.getViewSite();
    statViewer.setInput(viewSite);
    // This only tree listener aim is to change open/close icons on folders :
    statViewer.addTreeListener(new ITreeViewerListener() {

        @Override
        public void treeCollapsed(TreeExpansionEvent event) {
            RepositoryNode node = (RepositoryNode) event.getElement();
            if (node.getType().equals(ENodeType.SIMPLE_FOLDER)) {
                TreeItem item = getObject(statViewer.getTree(), event.getElement());
                if (item != null) {
                    item.setImage(ImageProvider.getImage(ECoreImage.FOLDER_CLOSE_ICON));
                }
            }
        }

        @Override
        public void treeExpanded(TreeExpansionEvent event) {
            RepositoryNode node = (RepositoryNode) event.getElement();
            if (node.getType().equals(ENodeType.SIMPLE_FOLDER)) {
                TreeItem item = getObject(statViewer.getTree(), event.getElement());
                if (item != null) {
                    item.setImage(ImageProvider.getImage(ECoreImage.FOLDER_OPEN_ICON));
                }
            }
        }
    });
    statViewer.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            RepositoryNode node = (RepositoryNode) event.getElement();
            List<RepositoryNode> objects = new ArrayList<RepositoryNode>();
            processItems(objects, node);
            if (event.getChecked()) {
                statAddedObjects.addAll(objects);
                statRemovedObjects.removeAll(objects);
                statCheckedObjects.addAll(objects);
            } else {
                statAddedObjects.removeAll(objects);
                statRemovedObjects.addAll(objects);
                statCheckedObjects.removeAll(objects);
            }
            // set checked
            statViewer.setCheckedElements(statCheckedObjects.toArray());
        // viewer.refresh();
        }
    });
    RepositoryNode[] nodes = statContentProvider.getContents();
    List<RepositoryNode> objects = new ArrayList<RepositoryNode>();
    if (nodes != null) {
        for (RepositoryNode n : nodes) {
            processItems(objects, n);
            for (RepositoryNode node : objects) {
                if (isStatUseProjectSetting(node)) {
                    if (!statCheckedObjects.contains(node)) {
                        statCheckedObjects.add(node);
                    }
                }
            }
        }
    }
    statViewer.setCheckedElements(statCheckedObjects.toArray());
    if (nodes != null) {
        statViewer.setExpandedElements(nodes);
    }
}
Also used : Group(org.eclipse.swt.widgets.Group) TreeItem(org.eclipse.swt.widgets.TreeItem) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) ITreeViewerListener(org.eclipse.jface.viewers.ITreeViewerListener) ArrayList(java.util.ArrayList) FillLayout(org.eclipse.swt.layout.FillLayout) RepositoryLabelProvider(org.talend.core.repository.ui.view.RepositoryLabelProvider) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) IViewSite(org.eclipse.ui.IViewSite) CheckboxRepositoryTreeViewer(org.talend.repository.viewer.ui.viewer.CheckboxRepositoryTreeViewer) GridData(org.eclipse.swt.layout.GridData) List(java.util.List) ArrayList(java.util.ArrayList) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) TreeExpansionEvent(org.eclipse.jface.viewers.TreeExpansionEvent)

Example 2 with IViewSite

use of org.eclipse.ui.IViewSite in project sling by apache.

the class StatusLineUtils method getStatusLineManager.

private static IStatusLineManager getStatusLineManager() {
    IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (activeWorkbenchWindow == null) {
        return null;
    }
    IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
    if (activePage == null) {
        return null;
    }
    IEditorPart activeEditor = activePage.getActiveEditor();
    if (activeEditor != null) {
        return activeEditor.getEditorSite().getActionBars().getStatusLineManager();
    }
    IViewReference[] viewRefs = activePage.getViewReferences();
    if (viewRefs != null) {
        for (IViewReference aViewRef : viewRefs) {
            IViewPart view = aViewRef.getView(false);
            if (view != null) {
                return view.getViewSite().getActionBars().getStatusLineManager();
            }
        }
    }
    IEditorReference[] editorRefs = activePage.getEditorReferences();
    if (editorRefs != null) {
        for (IEditorReference anEditorRef : editorRefs) {
            IEditorPart editor = anEditorRef.getEditor(false);
            if (editor != null) {
                return editor.getEditorSite().getActionBars().getStatusLineManager();
            }
        }
    }
    IWorkbenchPart activePart = activePage.getActivePart();
    if (activePart == null) {
        return null;
    }
    IWorkbenchPartSite site = activePart.getSite();
    if (site instanceof IEditorSite) {
        IEditorSite editorSite = (IEditorSite) site;
        return editorSite.getActionBars().getStatusLineManager();
    } else if (site instanceof IViewSite) {
        IViewSite viewSite = (IViewSite) site;
        return viewSite.getActionBars().getStatusLineManager();
    } else {
        return null;
    }
}
Also used : IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IViewSite(org.eclipse.ui.IViewSite) IViewPart(org.eclipse.ui.IViewPart) IEditorReference(org.eclipse.ui.IEditorReference) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) IViewReference(org.eclipse.ui.IViewReference) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart) IEditorSite(org.eclipse.ui.IEditorSite)

Example 3 with IViewSite

use of org.eclipse.ui.IViewSite in project yamcs-studio by yamcs.

the class RCPUtils method setStatusMessage.

/**
 * Sets a message in the lower left status line. These messages are by
 * rcp-design associated with a view.
 *
 * @param viewId
 *            the view from which the message originates
 */
public static void setStatusMessage(String viewId, String message) {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    IViewSite site = window.getActivePage().findView(viewId).getViewSite();
    IStatusLineManager mgr = site.getActionBars().getStatusLineManager();
    mgr.setMessage(message);
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IViewSite(org.eclipse.ui.IViewSite) IStatusLineManager(org.eclipse.jface.action.IStatusLineManager)

Example 4 with IViewSite

use of org.eclipse.ui.IViewSite in project yamcs-studio by yamcs.

the class RCPUtils method setStatusErrorMessage.

/**
 * Sets an error message in the lower left status line. These messages are
 * by rcp-design associated with a view.
 *
 * @param viewId
 *            the view from which the message originates
 */
public static void setStatusErrorMessage(String viewId, String message) {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    IViewSite site = window.getActivePage().findView(viewId).getViewSite();
    IStatusLineManager mgr = site.getActionBars().getStatusLineManager();
    mgr.setErrorMessage(message);
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IViewSite(org.eclipse.ui.IViewSite) IStatusLineManager(org.eclipse.jface.action.IStatusLineManager)

Example 5 with IViewSite

use of org.eclipse.ui.IViewSite in project yamcs-studio by yamcs.

the class OPIView method setTitleToolTip.

// In debug mode, include view ID in tool tip
@Override
protected void setTitleToolTip(String tool_tip) {
    if (debug) {
        final IViewSite view = getViewSite();
        tool_tip = view.getId() + ":" + view.getSecondaryId() + " - " + tool_tip;
    }
    super.setTitleToolTip(tool_tip);
}
Also used : IViewSite(org.eclipse.ui.IViewSite)

Aggregations

IViewSite (org.eclipse.ui.IViewSite)15 FillLayout (org.eclipse.swt.layout.FillLayout)3 IActionBars (org.eclipse.ui.IActionBars)3 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 IStatusLineManager (org.eclipse.jface.action.IStatusLineManager)2 IToolBarManager (org.eclipse.jface.action.IToolBarManager)2 CheckStateChangedEvent (org.eclipse.jface.viewers.CheckStateChangedEvent)2 ICheckStateListener (org.eclipse.jface.viewers.ICheckStateListener)2 ITreeViewerListener (org.eclipse.jface.viewers.ITreeViewerListener)2 TreeExpansionEvent (org.eclipse.jface.viewers.TreeExpansionEvent)2 TreeViewer (org.eclipse.jface.viewers.TreeViewer)2 GridData (org.eclipse.swt.layout.GridData)2 Group (org.eclipse.swt.widgets.Group)2 TreeItem (org.eclipse.swt.widgets.TreeItem)2 WorkbenchLabelProvider (org.eclipse.ui.model.WorkbenchLabelProvider)2 ProjectRepositoryNode (org.talend.core.repository.model.ProjectRepositoryNode)2 RepositoryLabelProvider (org.talend.core.repository.ui.view.RepositoryLabelProvider)2 IRepositoryNode (org.talend.repository.model.IRepositoryNode)2