use of org.eclipse.ui.part.IPageSite in project erlide_eclipse by erlang.
the class ErlangOutlinePage method createControl.
@Override
public void createControl(final Composite parent) {
final Tree tree = new Tree(parent, SWT.MULTI);
fOutlineViewer = new TreeViewer(tree);
fOutlineViewer.setAutoExpandLevel(0);
fOutlineViewer.setUseHashlookup(true);
fOutlineViewer.setContentProvider(fEditor.createOutlineContentProvider());
fOutlineViewer.setLabelProvider(fEditor.createOutlineLabelProvider());
fOutlineViewer.addPostSelectionChangedListener(this);
fOutlineViewer.setInput(fModule);
final IPageSite site = getSite();
fOpenAndLinkWithEditorHelper = new OpenAndLinkWithEditorHelper(fOutlineViewer, fEditor, site.getPage());
final IContextService service = site.getService(IContextService.class);
if (service != null) {
service.activateContext("org.erlide.ui.erlangOutlineAndNavigatorScope");
}
final MenuManager manager = new MenuManager();
manager.setRemoveAllWhenShown(true);
manager.addMenuListener(new IMenuListener() {
@Override
public void menuAboutToShow(final IMenuManager m) {
// recursive loop?
// menuAboutToShow(m);
contextMenuAboutToShow(m);
}
});
final Menu menu = manager.createContextMenu(tree);
tree.setMenu(menu);
site.registerContextMenu(ErlangCore.PLUGIN_ID + ".outline", manager, fOutlineViewer);
fActionGroups = new CompositeActionGroup(new ActionGroup[] { new ErlangSearchActionGroup(this) });
// register global actions
final IActionBars actionBars = site.getActionBars();
actionBars.setGlobalActionHandler(ITextEditorActionConstants.UNDO, fEditor.getAction(ITextEditorActionConstants.UNDO));
actionBars.setGlobalActionHandler(ITextEditorActionConstants.REDO, fEditor.getAction(ITextEditorActionConstants.REDO));
fActionGroups.fillActionBars(actionBars);
registerToolbarActions(actionBars);
final IHandlerService handlerService = site.getService(IHandlerService.class);
if (handlerService != null) {
handlerService.activateHandler(IWorkbenchCommandConstants.NAVIGATE_TOGGLE_LINK_WITH_EDITOR, new ActionHandler(fToggleLinkingAction));
}
fPartListener = new IPartListener() {
@Override
public void partOpened(final IWorkbenchPart part) {
// JC borde filter-metoden ovan r�cka?
addFilters();
}
@Override
public void partDeactivated(final IWorkbenchPart part) {
}
@Override
public void partClosed(final IWorkbenchPart part) {
}
@Override
public void partBroughtToTop(final IWorkbenchPart part) {
}
@Override
public void partActivated(final IWorkbenchPart part) {
addFilters();
}
};
getSite().getPage().addPartListener(fPartListener);
}
use of org.eclipse.ui.part.IPageSite in project erlide_eclipse by erlang.
the class ConsolePageParticipant method activated.
@Override
public void activated() {
// add EOF submissions
final IPageSite site = fPage.getSite();
final IHandlerService handlerService = site.getService(IHandlerService.class);
final IContextService contextService = site.getService(IContextService.class);
if (handlerService == null || contextService == null) {
return;
}
fActivatedContext = contextService.activateContext(ConsolePageParticipant.fContextId);
fActivatedHandler = handlerService.activateHandler("org.eclipse.debug.ui.commands.eof", // $NON-NLS-1$
fEOFHandler);
}
use of org.eclipse.ui.part.IPageSite in project erlide_eclipse by erlang.
the class ConsolePageParticipant method deactivated.
@Override
public void deactivated() {
// remove EOF submissions
final IPageSite site = fPage.getSite();
final IHandlerService handlerService = site.getService(IHandlerService.class);
final IContextService contextService = site.getService(IContextService.class);
if (handlerService == null || contextService == null) {
return;
}
handlerService.deactivateHandler(fActivatedHandler);
contextService.deactivateContext(fActivatedContext);
}
use of org.eclipse.ui.part.IPageSite in project mylyn.docs by eclipse.
the class MarkupEditorOutline method createControl.
@Override
public void createControl(Composite parent) {
super.createControl(parent);
TreeViewer viewer = getTreeViewer();
viewer.setUseHashlookup(true);
viewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
viewer.setContentProvider(new BaseWorkbenchContentProvider());
viewer.setLabelProvider(WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider());
viewer.setInput(editor.getOutlineModel());
viewer.addOpenListener(new IOpenListener() {
public void open(OpenEvent event) {
revealInEditor(event.getSelection(), true);
}
});
viewer.addPostSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
revealInEditor(event.getSelection(), false);
}
});
viewer.expandAll();
new ToolTip(viewer.getControl(), ToolTip.RECREATE, false) {
@Override
protected Composite createToolTipContentArea(Event event, Composite parent) {
Composite comp = new Composite(parent, SWT.NONE);
comp.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
GridLayout gl = new GridLayout(1, false);
gl.marginBottom = 2;
gl.marginTop = 2;
gl.marginHeight = 0;
gl.marginWidth = 0;
gl.marginLeft = 2;
gl.marginRight = 2;
gl.verticalSpacing = 1;
comp.setLayout(gl);
Object tipItem = getToolTipItem(new Point(event.x, event.y));
if (tipItem instanceof OutlineItem) {
OutlineItem outlineItem = (OutlineItem) tipItem;
Label label = new Label(comp, SWT.WRAP);
label.setBackground(comp.getBackground());
label.setText(outlineItem.getTooltip());
}
return comp;
}
@Override
protected boolean shouldCreateToolTip(Event event) {
final Object eventItem = getToolTipItem(new Point(event.x, event.y));
boolean shouldCreate = eventItem != null && eventItem instanceof OutlineItem && super.shouldCreateToolTip(event);
if (!shouldCreate) {
hide();
}
return shouldCreate;
}
protected Object getToolTipItem(Point point) {
TreeItem item = ((Tree) getTreeViewer().getControl()).getItem(point);
if (item != null) {
return item.getData();
}
return null;
}
};
IPageSite site = getSite();
site.setSelectionProvider(viewer);
configureActionBars(site);
// $NON-NLS-1$
MenuManager manager = new MenuManager("#PopUp");
manager.setRemoveAllWhenShown(true);
manager.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager menuManager) {
contextMenuAboutToShow(menuManager);
}
});
viewer.getTree().setMenu(manager.createContextMenu(viewer.getTree()));
// $NON-NLS-1$
site.registerContextMenu(MarkupEditor.ID + ".outlineContextMenu", manager, viewer);
configureDnd();
configureActions();
}
Aggregations