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);
}
}
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;
}
}
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);
}
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);
}
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);
}
Aggregations