|
Lines 11-28
Link Here
|
| 11 |
|
11 |
|
| 12 |
package org.eclipse.ui.navigator.resources; |
12 |
package org.eclipse.ui.navigator.resources; |
| 13 |
|
13 |
|
|
|
14 |
import org.eclipse.core.resources.IFile; |
| 14 |
import org.eclipse.core.resources.IResource; |
15 |
import org.eclipse.core.resources.IResource; |
| 15 |
import org.eclipse.core.runtime.IAdaptable; |
16 |
import org.eclipse.core.runtime.IAdaptable; |
| 16 |
import org.eclipse.core.runtime.IPath; |
17 |
import org.eclipse.core.runtime.IPath; |
|
|
18 |
import org.eclipse.jface.action.IAction; |
| 19 |
import org.eclipse.jface.viewers.ISelectionChangedListener; |
| 20 |
import org.eclipse.jface.viewers.IStructuredSelection; |
| 21 |
import org.eclipse.jface.viewers.SelectionChangedEvent; |
| 17 |
import org.eclipse.osgi.util.NLS; |
22 |
import org.eclipse.osgi.util.NLS; |
| 18 |
import org.eclipse.swt.widgets.Composite; |
23 |
import org.eclipse.swt.widgets.Composite; |
| 19 |
import org.eclipse.ui.IAggregateWorkingSet; |
24 |
import org.eclipse.ui.IAggregateWorkingSet; |
|
|
25 |
import org.eclipse.ui.IMemento; |
| 20 |
import org.eclipse.ui.IPageLayout; |
26 |
import org.eclipse.ui.IPageLayout; |
|
|
27 |
import org.eclipse.ui.IViewSite; |
| 21 |
import org.eclipse.ui.IWorkbench; |
28 |
import org.eclipse.ui.IWorkbench; |
| 22 |
import org.eclipse.ui.IWorkbenchPage; |
29 |
import org.eclipse.ui.IWorkbenchPage; |
| 23 |
import org.eclipse.ui.IWorkbenchWindow; |
30 |
import org.eclipse.ui.IWorkbenchWindow; |
| 24 |
import org.eclipse.ui.IWorkingSet; |
31 |
import org.eclipse.ui.IWorkingSet; |
|
|
32 |
import org.eclipse.ui.PartInitException; |
| 25 |
import org.eclipse.ui.PlatformUI; |
33 |
import org.eclipse.ui.PlatformUI; |
|
|
34 |
import org.eclipse.ui.actions.ActionFactory; |
| 35 |
import org.eclipse.ui.commands.ActionHandler; |
| 36 |
import org.eclipse.ui.handlers.IHandlerService; |
| 26 |
import org.eclipse.ui.internal.navigator.framelist.Frame; |
37 |
import org.eclipse.ui.internal.navigator.framelist.Frame; |
| 27 |
import org.eclipse.ui.internal.navigator.framelist.FrameList; |
38 |
import org.eclipse.ui.internal.navigator.framelist.FrameList; |
| 28 |
import org.eclipse.ui.internal.navigator.framelist.TreeFrame; |
39 |
import org.eclipse.ui.internal.navigator.framelist.TreeFrame; |
|
Lines 71-83
Link Here
|
| 71 |
*/ |
82 |
*/ |
| 72 |
private String workingSetLabel; |
83 |
private String workingSetLabel; |
| 73 |
|
84 |
|
|
|
85 |
private ActionHandler printActionHandler; |
| 86 |
|
| 87 |
private ISelectionChangedListener selectionListener; |
| 88 |
|
| 74 |
public void createPartControl(Composite aParent) { |
89 |
public void createPartControl(Composite aParent) { |
| 75 |
super.createPartControl(aParent); |
90 |
super.createPartControl(aParent); |
| 76 |
|
91 |
|
| 77 |
if (!false) |
92 |
getCommonViewer().setMapper(new ResourceToItemsMapper(getCommonViewer())); |
| 78 |
getCommonViewer().setMapper(new ResourceToItemsMapper(getCommonViewer())); |
93 |
getCommonViewer().addSelectionChangedListener(selectionListener); |
| 79 |
} |
94 |
} |
|
|
95 |
|
| 96 |
public void init(IViewSite aSite, IMemento aMemento) |
| 97 |
throws PartInitException { |
| 98 |
super.init(aSite, aMemento); |
| 99 |
|
| 100 |
final IAction printAction = ActionFactory.PRINT.create(PlatformUI.getWorkbench().getActiveWorkbenchWindow()); |
| 101 |
printActionHandler = new ActionHandler(printAction); |
| 102 |
|
| 103 |
selectionListener = new ISelectionChangedListener() { |
| 104 |
public void selectionChanged(SelectionChangedEvent event) { |
| 105 |
IHandlerService service = (IHandlerService)PlatformUI.getWorkbench().getService(IHandlerService.class); |
| 106 |
IStructuredSelection sel = (IStructuredSelection) event.getSelection(); |
| 107 |
Object obj = sel.getFirstElement(); |
| 108 |
// TODO - remember the activation using an IHandlerActivation |
| 109 |
// TODO - better check for what exactly to print? check instanceof and |
| 110 |
// check adapts to |
| 111 |
if (obj instanceof IFile) { |
| 112 |
service.activateHandler(printAction.getActionDefinitionId(), printActionHandler); |
| 113 |
} else { |
| 114 |
// TODO deactivate the remembered activation if any, reset it |
| 115 |
} |
| 116 |
} |
| 117 |
}; |
| 118 |
|
| 119 |
} |
| 120 |
|
| 121 |
|
| 80 |
|
122 |
|
|
|
123 |
public void dispose() { |
| 124 |
super.dispose(); |
| 125 |
|
| 126 |
getCommonViewer().removeSelectionChangedListener(selectionListener); |
| 127 |
} |
| 128 |
|
| 129 |
|
| 81 |
/** |
130 |
/** |
| 82 |
* The superclass does not deal with the content description, handle it |
131 |
* The superclass does not deal with the content description, handle it |
| 83 |
* here. |
132 |
* here. |
|
Lines 214-217
Link Here
|
| 214 |
return workingSetLabel; |
263 |
return workingSetLabel; |
| 215 |
} |
264 |
} |
| 216 |
|
265 |
|
|
|
266 |
|
| 267 |
|
| 217 |
} |
268 |
} |