|
Lines 7-17
Link Here
|
| 7 |
* |
7 |
* |
| 8 |
* Contributors: |
8 |
* Contributors: |
| 9 |
* IBM Corporation - initial API and implementation |
9 |
* IBM Corporation - initial API and implementation |
|
|
10 |
* Gunnar Wagenknecht - some contributions (bug fixes and enhancements) |
| 10 |
*******************************************************************************/ |
11 |
*******************************************************************************/ |
| 11 |
package org.eclipse.ui.internal.presentations; |
12 |
package org.eclipse.ui.internal.presentations; |
| 12 |
|
13 |
|
| 13 |
import java.util.ArrayList; |
14 |
import java.util.ArrayList; |
|
|
15 |
import java.util.Iterator; |
| 16 |
import java.util.List; |
| 14 |
|
17 |
|
|
|
18 |
import org.eclipse.core.runtime.Assert; |
| 15 |
import org.eclipse.jface.action.GroupMarker; |
19 |
import org.eclipse.jface.action.GroupMarker; |
| 16 |
import org.eclipse.jface.action.IMenuManager; |
20 |
import org.eclipse.jface.action.IMenuManager; |
| 17 |
import org.eclipse.jface.action.MenuManager; |
21 |
import org.eclipse.jface.action.MenuManager; |
|
Lines 40-46
Link Here
|
| 40 |
import org.eclipse.swt.widgets.Shell; |
44 |
import org.eclipse.swt.widgets.Shell; |
| 41 |
import org.eclipse.swt.widgets.ToolBar; |
45 |
import org.eclipse.swt.widgets.ToolBar; |
| 42 |
import org.eclipse.swt.widgets.ToolItem; |
46 |
import org.eclipse.swt.widgets.ToolItem; |
|
|
47 |
import org.eclipse.ui.IMemento; |
| 43 |
import org.eclipse.ui.IPropertyListener; |
48 |
import org.eclipse.ui.IPropertyListener; |
|
|
49 |
import org.eclipse.ui.internal.IWorkbenchConstants; |
| 44 |
import org.eclipse.ui.internal.IWorkbenchGraphicConstants; |
50 |
import org.eclipse.ui.internal.IWorkbenchGraphicConstants; |
| 45 |
import org.eclipse.ui.internal.WorkbenchImages; |
51 |
import org.eclipse.ui.internal.WorkbenchImages; |
| 46 |
import org.eclipse.ui.internal.dnd.DragUtil; |
52 |
import org.eclipse.ui.internal.dnd.DragUtil; |
|
Lines 51-1057
Link Here
|
| 51 |
import org.eclipse.ui.internal.util.Util; |
57 |
import org.eclipse.ui.internal.util.Util; |
| 52 |
import org.eclipse.ui.presentations.IPartMenu; |
58 |
import org.eclipse.ui.presentations.IPartMenu; |
| 53 |
import org.eclipse.ui.presentations.IPresentablePart; |
59 |
import org.eclipse.ui.presentations.IPresentablePart; |
|
|
60 |
import org.eclipse.ui.presentations.IPresentationSerializer; |
| 54 |
import org.eclipse.ui.presentations.IStackPresentationSite; |
61 |
import org.eclipse.ui.presentations.IStackPresentationSite; |
| 55 |
import org.eclipse.ui.presentations.PresentationUtil; |
62 |
import org.eclipse.ui.presentations.PresentationUtil; |
| 56 |
import org.eclipse.ui.presentations.StackDropResult; |
63 |
import org.eclipse.ui.presentations.StackDropResult; |
| 57 |
import org.eclipse.ui.presentations.StackPresentation; |
64 |
import org.eclipse.ui.presentations.StackPresentation; |
| 58 |
|
65 |
|
| 59 |
/** |
66 |
/** |
| 60 |
* Base class for StackPresentations that display IPresentableParts in a CTabFolder. |
67 |
* Base class for StackPresentations that display IPresentableParts in a |
|
|
68 |
* CTabFolder. |
| 61 |
* |
69 |
* |
| 62 |
* @since 3.0 |
70 |
* @since 3.0 |
| 63 |
*/ |
71 |
*/ |
| 64 |
public class R21BasicStackPresentation extends StackPresentation { |
72 |
public class R21BasicStackPresentation extends StackPresentation { |
| 65 |
|
73 |
|
| 66 |
private R21PaneFolder paneFolder; |
74 |
private R21PaneFolder paneFolder; |
| 67 |
|
75 |
|
| 68 |
private IPresentablePart current; |
76 |
private IPresentablePart current; |
| 69 |
|
77 |
|
| 70 |
private boolean activeState = false; |
78 |
private boolean activeState = false; |
| 71 |
|
79 |
|
| 72 |
private MenuManager systemMenuManager = new MenuManager(); |
80 |
private MenuManager systemMenuManager = new MenuManager(); |
| 73 |
|
81 |
|
| 74 |
private CLabel titleLabel; |
82 |
private CLabel titleLabel; |
| 75 |
|
83 |
|
| 76 |
private boolean shellActive = true; |
84 |
private boolean shellActive = true; |
| 77 |
|
85 |
|
| 78 |
private final static String TAB_DATA = R21BasicStackPresentation.class |
86 |
private final static String TAB_DATA = R21BasicStackPresentation.class |
| 79 |
.getName() |
87 |
.getName() |
| 80 |
+ ".partId"; //$NON-NLS-1$ |
88 |
+ ".partId"; //$NON-NLS-1$ |
| 81 |
|
89 |
|
| 82 |
// private PaneFolderButtonListener buttonListener = new PaneFolderButtonListener() { |
90 |
// private PaneFolderButtonListener buttonListener = new |
| 83 |
// public void stateButtonPressed(int buttonId) { |
91 |
// PaneFolderButtonListener() { |
| 84 |
// getSite().setState(buttonId); |
92 |
// public void stateButtonPressed(int buttonId) { |
| 85 |
// } |
93 |
// getSite().setState(buttonId); |
| 86 |
// |
94 |
// } |
| 87 |
// public void closeButtonPressed(CTabItem item) { |
95 |
// |
| 88 |
// IPresentablePart part = getPartForTab(item); |
96 |
// public void closeButtonPressed(CTabItem item) { |
| 89 |
// |
97 |
// IPresentablePart part = getPartForTab(item); |
| 90 |
// getSite().close(part); |
98 |
// |
| 91 |
// } |
99 |
// getSite().close(part); |
| 92 |
// }; |
100 |
// } |
| 93 |
// |
101 |
// }; |
| 94 |
private MouseListener mouseListener = new MouseAdapter() { |
102 |
// |
| 95 |
public void mouseDown(MouseEvent e) { |
103 |
private MouseListener mouseListener = new MouseAdapter() { |
| 96 |
if (e.widget instanceof Control) { |
104 |
public void mouseDown(MouseEvent e) { |
| 97 |
Control ctrl = (Control) e.widget; |
105 |
if (e.widget instanceof Control) { |
| 98 |
Point globalPos = ctrl.toDisplay(new Point(e.x, e.y)); |
106 |
Control ctrl = (Control) e.widget; |
| 99 |
|
107 |
Point globalPos = ctrl.toDisplay(new Point(e.x, e.y)); |
| 100 |
// PR#1GDEZ25 - If selection will change in mouse up ignore mouse down. |
108 |
|
| 101 |
// Else, set focus. |
109 |
// PR#1GDEZ25 - If selection will change in mouse up ignore |
| 102 |
CTabItem newItem = paneFolder.getItem(paneFolder.getControl() |
110 |
// mouse down. |
| 103 |
.toControl(globalPos)); |
111 |
// Else, set focus. |
| 104 |
if (newItem != null) { |
112 |
CTabItem newItem = paneFolder.getItem(paneFolder.getControl() |
| 105 |
CTabItem oldItem = paneFolder.getSelection(); |
113 |
.toControl(globalPos)); |
| 106 |
if (newItem != oldItem) |
114 |
if (newItem != null) { |
| 107 |
return; |
115 |
CTabItem oldItem = paneFolder.getSelection(); |
| 108 |
} |
116 |
if (newItem != oldItem) |
| 109 |
if (current != null) { |
117 |
return; |
| 110 |
current.setFocus(); |
118 |
} |
| 111 |
} |
119 |
if (current != null) { |
| 112 |
} |
120 |
current.setFocus(); |
| 113 |
} |
121 |
} |
| 114 |
|
122 |
} |
| 115 |
public void mouseDoubleClick(MouseEvent e) { |
123 |
} |
| 116 |
if (getSite().getState() == IStackPresentationSite.STATE_MAXIMIZED) { |
124 |
|
| 117 |
getSite().setState(IStackPresentationSite.STATE_RESTORED); |
125 |
public void mouseDoubleClick(MouseEvent e) { |
| 118 |
} else { |
126 |
if (getSite().getState() == IStackPresentationSite.STATE_MAXIMIZED) { |
| 119 |
getSite().setState(IStackPresentationSite.STATE_MAXIMIZED); |
127 |
getSite().setState(IStackPresentationSite.STATE_RESTORED); |
| 120 |
} |
128 |
} else { |
| 121 |
} |
129 |
getSite().setState(IStackPresentationSite.STATE_MAXIMIZED); |
| 122 |
}; |
130 |
} |
| 123 |
|
131 |
} |
| 124 |
private MouseListener titleMouseListener = new MouseAdapter() { |
132 |
}; |
| 125 |
public void mouseDown(MouseEvent e) { |
133 |
|
| 126 |
if (e.widget instanceof Control) { |
134 |
private MouseListener titleMouseListener = new MouseAdapter() { |
| 127 |
Control ctrl = (Control) e.widget; |
135 |
public void mouseDown(MouseEvent e) { |
| 128 |
Point globalPos = ctrl.toDisplay(new Point(0, titleLabel |
136 |
if (e.widget instanceof Control) { |
| 129 |
.getBounds().height)); |
137 |
Control ctrl = (Control) e.widget; |
| 130 |
|
138 |
Point globalPos = ctrl.toDisplay(new Point(0, titleLabel |
| 131 |
if ((e.button == 1) && overImage(e.x)) |
139 |
.getBounds().height)); |
| 132 |
showSystemMenu(globalPos); |
140 |
|
| 133 |
} |
141 |
if ((e.button == 1) && overImage(e.x)) |
| 134 |
} |
142 |
showSystemMenu(globalPos); |
| 135 |
}; |
143 |
} |
| 136 |
|
144 |
} |
| 137 |
private Listener menuListener = new Listener() { |
145 |
}; |
| 138 |
/* (non-Javadoc) |
146 |
|
| 139 |
* @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event) |
147 |
private Listener menuListener = new Listener() { |
| 140 |
*/ |
148 |
/* |
| 141 |
public void handleEvent(Event event) { |
149 |
* (non-Javadoc) |
| 142 |
Point pos = new Point(event.x, event.y); |
150 |
* |
| 143 |
|
151 |
* @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event) |
| 144 |
showSystemMenu(pos); |
152 |
*/ |
| 145 |
} |
153 |
public void handleEvent(Event event) { |
| 146 |
}; |
154 |
Point pos = new Point(event.x, event.y); |
| 147 |
|
155 |
|
| 148 |
private Listener dragListener = new Listener() { |
156 |
showSystemMenu(pos); |
| 149 |
public void handleEvent(Event event) { |
157 |
} |
| 150 |
|
158 |
}; |
| 151 |
Point localPos = new Point(event.x, event.y); |
159 |
|
| 152 |
CTabItem tabUnderPointer = paneFolder.getItem(localPos); |
160 |
private Listener dragListener = new Listener() { |
| 153 |
|
161 |
public void handleEvent(Event event) { |
| 154 |
// Drags on the title area drag the selected part only |
162 |
|
| 155 |
if (tabUnderPointer == null) { |
163 |
Point localPos = new Point(event.x, event.y); |
| 156 |
if (paneFolder.getTabPosition() == SWT.BOTTOM |
164 |
CTabItem tabUnderPointer = paneFolder.getItem(localPos); |
| 157 |
&& localPos.y < paneFolder.getControl().getBounds().height |
165 |
|
| 158 |
- paneFolder.getTabHeight()) |
166 |
// Drags on the title area drag the selected part only |
| 159 |
tabUnderPointer = paneFolder.getSelection(); |
167 |
if (tabUnderPointer == null) { |
| 160 |
else if (paneFolder.getTabPosition() == SWT.TOP |
168 |
if (paneFolder.getTabPosition() == SWT.BOTTOM |
| 161 |
&& localPos.y > paneFolder.getTabHeight()) |
169 |
&& localPos.y < paneFolder.getControl().getBounds().height |
| 162 |
tabUnderPointer = paneFolder.getSelection(); |
170 |
- paneFolder.getTabHeight()) |
| 163 |
} |
171 |
tabUnderPointer = paneFolder.getSelection(); |
| 164 |
|
172 |
else if (paneFolder.getTabPosition() == SWT.TOP |
| 165 |
// Not in a tab, not in a title area, must be dragging the whole stack |
173 |
&& localPos.y > paneFolder.getTabHeight()) |
| 166 |
if (tabUnderPointer == null) { |
174 |
tabUnderPointer = paneFolder.getSelection(); |
| 167 |
getSite().dragStart( |
175 |
} |
| 168 |
paneFolder.getControl().toDisplay(localPos), false); |
176 |
|
| 169 |
return; |
177 |
// Not in a tab, not in a title area, must be dragging the whole |
| 170 |
} |
178 |
// stack |
| 171 |
|
179 |
if (tabUnderPointer == null) { |
| 172 |
IPresentablePart part = getPartForTab(tabUnderPointer); |
180 |
getSite().dragStart( |
| 173 |
|
181 |
paneFolder.getControl().toDisplay(localPos), false); |
| 174 |
if (getSite().isPartMoveable(part)) { |
182 |
return; |
| 175 |
getSite().dragStart(part, |
183 |
} |
| 176 |
paneFolder.getControl().toDisplay(localPos), false); |
184 |
|
| 177 |
} |
185 |
IPresentablePart part = getPartForTab(tabUnderPointer); |
| 178 |
} |
186 |
|
| 179 |
}; |
187 |
if (getSite().isPartMoveable(part)) { |
| 180 |
|
188 |
getSite().dragStart(part, |
| 181 |
private Listener selectionListener = new Listener() { |
189 |
paneFolder.getControl().toDisplay(localPos), false); |
| 182 |
public void handleEvent(Event e) { |
190 |
} |
| 183 |
IPresentablePart item = getPartForTab((CTabItem) e.item); |
191 |
} |
| 184 |
|
192 |
}; |
| 185 |
if (item != null) { |
193 |
|
| 186 |
getSite().selectPart(item); |
194 |
private Listener selectionListener = new Listener() { |
| 187 |
} |
195 |
public void handleEvent(Event e) { |
| 188 |
} |
196 |
IPresentablePart item = getPartForTab((CTabItem) e.item); |
| 189 |
}; |
197 |
|
| 190 |
|
198 |
if (item != null) { |
| 191 |
private Listener resizeListener = new Listener() { |
199 |
getSite().selectPart(item); |
| 192 |
public void handleEvent(Event e) { |
200 |
} |
| 193 |
setControlSize(); |
201 |
} |
| 194 |
} |
202 |
}; |
| 195 |
}; |
203 |
|
| 196 |
|
204 |
private Listener resizeListener = new Listener() { |
| 197 |
private IPropertyListener childPropertyChangeListener = new IPropertyListener() { |
205 |
public void handleEvent(Event e) { |
| 198 |
public void propertyChanged(Object source, int property) { |
206 |
setControlSize(); |
| 199 |
if (source instanceof IPresentablePart) { |
207 |
} |
| 200 |
IPresentablePart part = (IPresentablePart) source; |
208 |
}; |
| 201 |
childPropertyChanged(part, property); |
209 |
|
| 202 |
} |
210 |
private IPropertyListener childPropertyChangeListener = new IPropertyListener() { |
| 203 |
} |
211 |
public void propertyChanged(Object source, int property) { |
| 204 |
}; |
212 |
if (source instanceof IPresentablePart) { |
| 205 |
|
213 |
IPresentablePart part = (IPresentablePart) source; |
| 206 |
private DisposeListener tabDisposeListener = new DisposeListener() { |
214 |
childPropertyChanged(part, property); |
| 207 |
public void widgetDisposed(DisposeEvent e) { |
215 |
} |
| 208 |
if (e.widget instanceof CTabItem) { |
216 |
} |
| 209 |
CTabItem item = (CTabItem) e.widget; |
217 |
}; |
| 210 |
|
218 |
|
| 211 |
IPresentablePart part = getPartForTab(item); |
219 |
private DisposeListener tabDisposeListener = new DisposeListener() { |
| 212 |
|
220 |
public void widgetDisposed(DisposeEvent e) { |
| 213 |
part.removePropertyListener(childPropertyChangeListener); |
221 |
if (e.widget instanceof CTabItem) { |
| 214 |
} |
222 |
CTabItem item = (CTabItem) e.widget; |
| 215 |
} |
223 |
|
| 216 |
}; |
224 |
IPresentablePart part = getPartForTab(item); |
| 217 |
|
225 |
|
| 218 |
/** the shell listener for upgrading the gradient */ |
226 |
part.removePropertyListener(childPropertyChangeListener); |
| 219 |
private ShellAdapter shellListener = new ShellAdapter() { |
227 |
} |
| 220 |
|
228 |
} |
| 221 |
public void shellActivated(ShellEvent event) { |
229 |
}; |
| 222 |
shellActive = true; |
230 |
|
| 223 |
updateGradient(); |
231 |
/** the shell listener for upgrading the gradient */ |
| 224 |
} |
232 |
private ShellAdapter shellListener = new ShellAdapter() { |
| 225 |
|
233 |
|
| 226 |
public void shellDeactivated(ShellEvent event) { |
234 |
public void shellActivated(ShellEvent event) { |
| 227 |
shellActive = false; |
235 |
shellActive = true; |
| 228 |
updateGradient(); |
236 |
updateGradient(); |
| 229 |
} |
237 |
} |
| 230 |
}; |
238 |
|
| 231 |
|
239 |
public void shellDeactivated(ShellEvent event) { |
| 232 |
private ToolBar viewToolBar; |
240 |
shellActive = false; |
| 233 |
|
241 |
updateGradient(); |
| 234 |
private ToolItem pullDownButton; |
242 |
} |
| 235 |
|
243 |
}; |
| 236 |
private ToolItem closeButton; |
244 |
|
| 237 |
|
245 |
private ToolBar viewToolBar; |
| 238 |
public R21BasicStackPresentation(R21PaneFolder control, |
246 |
|
| 239 |
IStackPresentationSite stackSite) { |
247 |
private ToolItem pullDownButton; |
| 240 |
super(stackSite); |
248 |
|
| 241 |
paneFolder = control; |
249 |
private ToolItem closeButton; |
| 242 |
|
250 |
|
| 243 |
shellActive = paneFolder.getControl().getShell().equals( |
251 |
public R21BasicStackPresentation(R21PaneFolder control, |
| 244 |
control.getControl().getDisplay().getActiveShell()); |
252 |
IStackPresentationSite stackSite) { |
| 245 |
|
253 |
super(stackSite); |
| 246 |
// tabFolder.setMinimizeVisible(stackSite.supportsState(IStackPresentationSite.STATE_MINIMIZED)); |
254 |
paneFolder = control; |
| 247 |
// tabFolder.setMaximizeVisible(stackSite.supportsState(IStackPresentationSite.STATE_MAXIMIZED)); |
255 |
|
| 248 |
// |
256 |
shellActive = paneFolder.getControl().getShell().equals( |
| 249 |
titleLabel = new CLabel(paneFolder.getControl(), SWT.SHADOW_NONE); |
257 |
control.getControl().getDisplay().getActiveShell()); |
| 250 |
titleLabel.setVisible(false); |
258 |
|
| 251 |
titleLabel.moveAbove(null); |
259 |
// tabFolder.setMinimizeVisible(stackSite.supportsState(IStackPresentationSite.STATE_MINIMIZED)); |
| 252 |
titleLabel.addMouseListener(titleMouseListener); |
260 |
// tabFolder.setMaximizeVisible(stackSite.supportsState(IStackPresentationSite.STATE_MAXIMIZED)); |
| 253 |
titleLabel.addMouseListener(mouseListener); |
261 |
// |
| 254 |
titleLabel.addListener(SWT.MenuDetect, menuListener); |
262 |
titleLabel = new CLabel(paneFolder.getControl(), SWT.SHADOW_NONE); |
| 255 |
PresentationUtil.addDragListener(titleLabel, dragListener); |
263 |
titleLabel.setVisible(false); |
| 256 |
|
264 |
titleLabel.moveAbove(null); |
| 257 |
//ColorSchemeService.setViewTitleFont(this, titleLabel); |
265 |
titleLabel.addMouseListener(titleMouseListener); |
| 258 |
|
266 |
titleLabel.addMouseListener(mouseListener); |
| 259 |
viewToolBar = new ToolBar(control.getControl(), SWT.HORIZONTAL |
267 |
titleLabel.addListener(SWT.MenuDetect, menuListener); |
| 260 |
| SWT.FLAT); |
268 |
PresentationUtil.addDragListener(titleLabel, dragListener); |
| 261 |
viewToolBar.moveAbove(null); |
269 |
|
| 262 |
|
270 |
// ColorSchemeService.setViewTitleFont(this, titleLabel); |
| 263 |
pullDownButton = new ToolItem(viewToolBar, SWT.PUSH); |
271 |
|
| 264 |
// Image img = WorkbenchImages.getImage(IWorkbenchGraphicConstants.IMG_LCL_VIEW_MENU); |
272 |
viewToolBar = new ToolBar(control.getControl(), SWT.HORIZONTAL |
| 265 |
Image hoverImage = WorkbenchImages |
273 |
| SWT.FLAT); |
| 266 |
.getImage(IWorkbenchGraphicConstants.IMG_LCL_VIEW_MENU); |
274 |
viewToolBar.moveAbove(null); |
| 267 |
pullDownButton.setDisabledImage(null); // TODO: comment this out? |
275 |
|
| 268 |
// PR#1GE56QT - Avoid creation of unnecessary image. |
276 |
pullDownButton = new ToolItem(viewToolBar, SWT.PUSH); |
| 269 |
pullDownButton.setImage(hoverImage); |
277 |
// Image img = |
| 270 |
pullDownButton.setToolTipText(R21PresentationMessages |
278 |
// WorkbenchImages.getImage(IWorkbenchGraphicConstants.IMG_LCL_VIEW_MENU); |
| 271 |
.getString("BasicStackPresentation.menu.tooltip")); //$NON-NLS-1$ |
279 |
Image hoverImage = WorkbenchImages |
| 272 |
pullDownButton.addSelectionListener(new SelectionAdapter() { |
280 |
.getImage(IWorkbenchGraphicConstants.IMG_LCL_VIEW_MENU); |
| 273 |
public void widgetSelected(SelectionEvent e) { |
281 |
pullDownButton.setDisabledImage(null); // TODO: comment this out? |
| 274 |
showPaneMenu(); |
282 |
// PR#1GE56QT - Avoid creation of unnecessary image. |
| 275 |
} |
283 |
pullDownButton.setImage(hoverImage); |
| 276 |
}); |
284 |
pullDownButton.setToolTipText(R21PresentationMessages |
| 277 |
|
285 |
.getString("BasicStackPresentation.menu.tooltip")); //$NON-NLS-1$ |
| 278 |
// listener to switch between visible tabItems |
286 |
pullDownButton.addSelectionListener(new SelectionAdapter() { |
| 279 |
paneFolder.getControl().addListener(SWT.Selection, selectionListener); |
287 |
public void widgetSelected(SelectionEvent e) { |
| 280 |
|
288 |
showPaneMenu(); |
| 281 |
// listener to resize visible components |
289 |
} |
| 282 |
paneFolder.getControl().addListener(SWT.Resize, resizeListener); |
290 |
}); |
| 283 |
|
291 |
|
| 284 |
// listen for mouse down on tab to set focus. |
292 |
// listener to switch between visible tabItems |
| 285 |
paneFolder.getControl().addMouseListener(mouseListener); |
293 |
paneFolder.getControl().addListener(SWT.Selection, selectionListener); |
| 286 |
|
294 |
|
| 287 |
paneFolder.getControl().addListener(SWT.MenuDetect, menuListener); |
295 |
// listener to resize visible components |
| 288 |
|
296 |
paneFolder.getControl().addListener(SWT.Resize, resizeListener); |
| 289 |
// tabFolder.addButtonListener(buttonListener); |
297 |
|
| 290 |
|
298 |
// listen for mouse down on tab to set focus. |
| 291 |
PresentationUtil.addDragListener(paneFolder.getControl(), dragListener); |
299 |
paneFolder.getControl().addMouseListener(mouseListener); |
| 292 |
|
300 |
|
| 293 |
// add the shell listener to track shell activations |
301 |
paneFolder.getControl().addListener(SWT.MenuDetect, menuListener); |
| 294 |
// TODO: check if workaround can be removed (see bug 55458) |
302 |
|
| 295 |
paneFolder.getControl().getShell().addShellListener(shellListener); |
303 |
// tabFolder.addButtonListener(buttonListener); |
| 296 |
|
304 |
|
| 297 |
// Uncomment to allow dragging from the title label |
305 |
PresentationUtil.addDragListener(paneFolder.getControl(), dragListener); |
| 298 |
// PresentationUtil.addDragListener(titleLabel, new Listener() { |
306 |
|
| 299 |
// public void handleEvent(Event event) { |
307 |
// add the shell listener to track shell activations |
| 300 |
// if (layout.isTrimOnTop()) { |
308 |
// TODO: check if workaround can be removed (see bug 55458) |
| 301 |
// Point localPos = new Point(event.x, event.y); |
309 |
paneFolder.getControl().getShell().addShellListener(shellListener); |
| 302 |
// getSite().dragStart(titleLabel.toDisplay(localPos), false); |
310 |
|
| 303 |
// } |
311 |
// Uncomment to allow dragging from the title label |
| 304 |
// } |
312 |
// PresentationUtil.addDragListener(titleLabel, new Listener() { |
| 305 |
// }); |
313 |
// public void handleEvent(Event event) { |
| 306 |
|
314 |
// if (layout.isTrimOnTop()) { |
| 307 |
// // Compute the tab height |
315 |
// Point localPos = new Point(event.x, event.y); |
| 308 |
// int tabHeight = viewToolBar.computeSize(SWT.DEFAULT, SWT.DEFAULT).y; |
316 |
// getSite().dragStart(titleLabel.toDisplay(localPos), false); |
| 309 |
// |
317 |
// } |
| 310 |
// // Enforce a minimum tab height |
318 |
// } |
| 311 |
// if (tabHeight < 20) { |
319 |
// }); |
| 312 |
// tabHeight = 20; |
320 |
|
| 313 |
// } |
321 |
// // Compute the tab height |
| 314 |
// paneFolder.setTabHeight(tabHeight); |
322 |
// int tabHeight = viewToolBar.computeSize(SWT.DEFAULT, SWT.DEFAULT).y; |
| 315 |
// |
323 |
// |
| 316 |
populateSystemMenu(systemMenuManager); |
324 |
// // Enforce a minimum tab height |
| 317 |
} |
325 |
// if (tabHeight < 20) { |
| 318 |
|
326 |
// tabHeight = 20; |
| 319 |
/* |
327 |
// } |
| 320 |
* Return true if <code>x</code> is over the label image. |
328 |
// paneFolder.setTabHeight(tabHeight); |
| 321 |
*/ |
329 |
// |
| 322 |
private boolean overImage(int x) { |
330 |
populateSystemMenu(systemMenuManager); |
| 323 |
return x < titleLabel.getImage().getBounds().width; |
331 |
} |
| 324 |
} |
332 |
|
| 325 |
|
333 |
/* |
| 326 |
/** |
334 |
* Return true if <code>x</code> is over the label image. |
| 327 |
* @param systemMenuManager |
335 |
*/ |
| 328 |
*/ |
336 |
private boolean overImage(int x) { |
| 329 |
private void populateSystemMenu(IMenuManager systemMenuManager) { |
337 |
return x < titleLabel.getImage().getBounds().width; |
| 330 |
|
338 |
} |
| 331 |
systemMenuManager.add(new GroupMarker("misc")); //$NON-NLS-1$ |
339 |
|
| 332 |
systemMenuManager.add(new GroupMarker("restore")); //$NON-NLS-1$ |
340 |
/** |
| 333 |
systemMenuManager.add(new UpdatingActionContributionItem( |
341 |
* @param systemMenuManager |
| 334 |
new SystemMenuRestore(getSite()))); |
342 |
*/ |
| 335 |
|
343 |
private void populateSystemMenu(IMenuManager systemMenuManager) { |
| 336 |
systemMenuManager.add(new SystemMenuMove(getSite(), getPaneName())); |
344 |
|
| 337 |
systemMenuManager.add(new GroupMarker("size")); //$NON-NLS-1$ |
345 |
systemMenuManager.add(new GroupMarker("misc")); //$NON-NLS-1$ |
| 338 |
systemMenuManager.add(new GroupMarker("state")); //$NON-NLS-1$ |
346 |
systemMenuManager.add(new GroupMarker("restore")); //$NON-NLS-1$ |
| 339 |
systemMenuManager.add(new UpdatingActionContributionItem( |
347 |
systemMenuManager.add(new UpdatingActionContributionItem( |
| 340 |
new SystemMenuMinimize(getSite()))); |
348 |
new SystemMenuRestore(getSite()))); |
| 341 |
|
349 |
|
| 342 |
systemMenuManager.add(new UpdatingActionContributionItem( |
350 |
systemMenuManager.add(new SystemMenuMove(getSite(), getPaneName())); |
| 343 |
new SystemMenuMaximize(getSite()))); |
351 |
systemMenuManager.add(new GroupMarker("size")); //$NON-NLS-1$ |
| 344 |
systemMenuManager.add(new Separator("close")); //$NON-NLS-1$ |
352 |
systemMenuManager.add(new GroupMarker("state")); //$NON-NLS-1$ |
| 345 |
systemMenuManager.add(new UpdatingActionContributionItem( |
353 |
systemMenuManager.add(new UpdatingActionContributionItem( |
| 346 |
new SystemMenuClose(getSite()))); |
354 |
new SystemMenuMinimize(getSite()))); |
| 347 |
|
355 |
|
| 348 |
getSite().addSystemActions(systemMenuManager); |
356 |
systemMenuManager.add(new UpdatingActionContributionItem( |
| 349 |
} |
357 |
new SystemMenuMaximize(getSite()))); |
| 350 |
|
358 |
systemMenuManager.add(new Separator("close")); //$NON-NLS-1$ |
| 351 |
protected String getPaneName() { |
359 |
systemMenuManager.add(new UpdatingActionContributionItem( |
| 352 |
return R21PresentationMessages.getString("BasicStackPresentation.pane"); //$NON-NLS-1$ |
360 |
new SystemMenuClose(getSite()))); |
| 353 |
} |
361 |
|
| 354 |
|
362 |
getSite().addSystemActions(systemMenuManager); |
| 355 |
/** |
363 |
} |
| 356 |
* Displays the view menu as a popup |
364 |
|
| 357 |
*/ |
365 |
protected String getPaneName() { |
| 358 |
public void showPaneMenu() { |
366 |
return R21PresentationMessages.getString("BasicStackPresentation.pane"); //$NON-NLS-1$ |
| 359 |
IPartMenu menu = getPartMenu(); |
367 |
} |
| 360 |
|
368 |
|
| 361 |
if (menu != null) { |
369 |
/** |
| 362 |
Rectangle bounds = DragUtil.getDisplayBounds(viewToolBar); |
370 |
* Displays the view menu as a popup |
| 363 |
menu.showMenu(new Point(bounds.x, bounds.y + bounds.height)); |
371 |
*/ |
| 364 |
} |
372 |
public void showPaneMenu() { |
| 365 |
} |
373 |
IPartMenu menu = getPartMenu(); |
| 366 |
|
374 |
|
| 367 |
/** |
375 |
if (menu != null) { |
| 368 |
* Returns the currently selected part, or <code>null</code>. |
376 |
Rectangle bounds = DragUtil.getDisplayBounds(viewToolBar); |
| 369 |
* |
377 |
menu.showMenu(new Point(bounds.x, bounds.y + bounds.height)); |
| 370 |
* @return the currently selected part, or <code>null</code> |
378 |
} |
| 371 |
*/ |
379 |
} |
| 372 |
protected IPresentablePart getCurrent() { |
380 |
|
| 373 |
return current; |
381 |
/** |
| 374 |
} |
382 |
* Returns the currently selected part, or <code>null</code>. |
| 375 |
|
383 |
* |
| 376 |
/** |
384 |
* @return the currently selected part, or <code>null</code> |
| 377 |
* Returns the index of the tab for the given part, or returns tabFolder.getItemCount() |
385 |
*/ |
| 378 |
* if there is no such tab. |
386 |
protected IPresentablePart getCurrent() { |
| 379 |
* |
387 |
return current; |
| 380 |
* @param part part being searched for |
388 |
} |
| 381 |
* @return the index of the tab for the given part, or the number of tabs |
389 |
|
| 382 |
* if there is no such tab |
390 |
/** |
| 383 |
*/ |
391 |
* Returns the index of the tab for the given part, or returns |
| 384 |
private final int indexOf(IPresentablePart part) { |
392 |
* tabFolder.getItemCount() if there is no such tab. |
| 385 |
if (part == null) { |
393 |
* |
| 386 |
return paneFolder.getItemCount(); |
394 |
* @param part |
| 387 |
} |
395 |
* part being searched for |
| 388 |
|
396 |
* @return the index of the tab for the given part, or the number of tabs if |
| 389 |
CTabItem[] items = paneFolder.getItems(); |
397 |
* there is no such tab |
| 390 |
|
398 |
*/ |
| 391 |
for (int idx = 0; idx < items.length; idx++) { |
399 |
private final int indexOf(IPresentablePart part) { |
| 392 |
IPresentablePart tabPart = getPartForTab(items[idx]); |
400 |
if (part == null) { |
| 393 |
|
401 |
return paneFolder.getItemCount(); |
| 394 |
if (part == tabPart) { |
402 |
} |
| 395 |
return idx; |
403 |
|
| 396 |
} |
404 |
CTabItem[] items = paneFolder.getItems(); |
| 397 |
} |
405 |
|
| 398 |
|
406 |
for (int idx = 0; idx < items.length; idx++) { |
| 399 |
return items.length; |
407 |
IPresentablePart tabPart = getPartForTab(items[idx]); |
| 400 |
} |
408 |
|
| 401 |
|
409 |
if (part == tabPart) { |
| 402 |
/** |
410 |
return idx; |
| 403 |
* Returns the tab for the given part, or null if there is no such tab |
411 |
} |
| 404 |
* |
412 |
} |
| 405 |
* @param part the part being searched for |
413 |
|
| 406 |
* @return the tab for the given part, or null if there is no such tab |
414 |
return items.length; |
| 407 |
*/ |
415 |
} |
| 408 |
protected final CTabItem getTab(IPresentablePart part) { |
416 |
|
| 409 |
CTabItem[] items = paneFolder.getItems(); |
417 |
/** |
| 410 |
|
418 |
* Returns the tab for the given part, or null if there is no such tab |
| 411 |
int idx = indexOf(part); |
419 |
* |
| 412 |
|
420 |
* @param part |
| 413 |
if (idx < items.length) { |
421 |
* the part being searched for |
| 414 |
return items[idx]; |
422 |
* @return the tab for the given part, or null if there is no such tab |
| 415 |
} |
423 |
*/ |
| 416 |
|
424 |
protected final CTabItem getTab(IPresentablePart part) { |
| 417 |
return null; |
425 |
CTabItem[] items = paneFolder.getItems(); |
| 418 |
} |
426 |
|
| 419 |
|
427 |
int idx = indexOf(part); |
| 420 |
/** |
428 |
|
| 421 |
* @param part |
429 |
if (idx < items.length) { |
| 422 |
* @param property |
430 |
return items[idx]; |
| 423 |
*/ |
431 |
} |
| 424 |
protected void childPropertyChanged(IPresentablePart part, int property) { |
432 |
|
| 425 |
|
433 |
return null; |
| 426 |
CTabItem tab = getTab(part); |
434 |
} |
| 427 |
initTab(tab, part); |
435 |
|
| 428 |
|
436 |
/** |
| 429 |
switch (property) { |
437 |
* @param part |
| 430 |
case IPresentablePart.PROP_BUSY: |
438 |
* @param property |
| 431 |
break; |
439 |
*/ |
| 432 |
case IPresentablePart.PROP_HIGHLIGHT_IF_BACK: |
440 |
protected void childPropertyChanged(IPresentablePart part, int property) { |
| 433 |
// FontRegistry registry = |
441 |
|
| 434 |
// PlatformUI.getWorkbench(). |
442 |
CTabItem tab = getTab(part); |
| 435 |
// getThemeManager().getCurrentTheme(). |
443 |
initTab(tab, part); |
| 436 |
// getFontRegistry(); |
444 |
|
| 437 |
// |
445 |
switch (property) { |
| 438 |
// if(!getCurrent().equals(part))//Set bold if it does currently have focus |
446 |
case IPresentablePart.PROP_BUSY: |
| 439 |
// tab.setFont(registry.getBold(IWorkbenchThemeConstants.TAB_TEXT_FONT)); |
447 |
break; |
| 440 |
// break; |
448 |
case IPresentablePart.PROP_HIGHLIGHT_IF_BACK: |
| 441 |
case IPresentablePart.PROP_TOOLBAR: |
449 |
// FontRegistry registry = |
| 442 |
case IPresentablePart.PROP_PANE_MENU: |
450 |
// PlatformUI.getWorkbench(). |
| 443 |
case IPresentablePart.PROP_TITLE: |
451 |
// getThemeManager().getCurrentTheme(). |
| 444 |
setControlSize(); |
452 |
// getFontRegistry(); |
| 445 |
break; |
453 |
// |
| 446 |
} |
454 |
// if(!getCurrent().equals(part))//Set bold if it does currently |
| 447 |
} |
455 |
// have focus |
| 448 |
|
456 |
// tab.setFont(registry.getBold(IWorkbenchThemeConstants.TAB_TEXT_FONT)); |
| 449 |
protected final IPresentablePart getPartForTab(CTabItem item) { |
457 |
// break; |
| 450 |
IPresentablePart part = (IPresentablePart) item.getData(TAB_DATA); |
458 |
case IPresentablePart.PROP_TOOLBAR: |
| 451 |
|
459 |
case IPresentablePart.PROP_PANE_MENU: |
| 452 |
return part; |
460 |
case IPresentablePart.PROP_TITLE: |
| 453 |
} |
461 |
setControlSize(); |
| 454 |
|
462 |
break; |
| 455 |
/** |
463 |
} |
| 456 |
* Returns the underlying tab folder for this presentation. |
464 |
} |
| 457 |
* |
465 |
|
| 458 |
* @return |
466 |
protected final IPresentablePart getPartForTab(CTabItem item) { |
| 459 |
*/ |
467 |
IPresentablePart part = (IPresentablePart) item.getData(TAB_DATA); |
| 460 |
protected R21PaneFolder getPaneFolder() { |
468 |
|
| 461 |
return paneFolder; |
469 |
return part; |
| 462 |
} |
470 |
} |
| 463 |
|
471 |
|
| 464 |
/** |
472 |
/** |
| 465 |
* Returns true iff the underlying tab folder has been disposed. |
473 |
* Returns the underlying tab folder for this presentation. |
| 466 |
* |
474 |
* |
| 467 |
* @return |
475 |
* @return |
| 468 |
*/ |
476 |
*/ |
| 469 |
public boolean isDisposed() { |
477 |
protected R21PaneFolder getPaneFolder() { |
| 470 |
return paneFolder == null || paneFolder.isDisposed(); |
478 |
return paneFolder; |
| 471 |
} |
479 |
} |
| 472 |
|
480 |
|
| 473 |
/** |
481 |
/** |
| 474 |
* Update the tab folder's colours to match the current theme settings |
482 |
* Returns true iff the underlying tab folder has been disposed. |
| 475 |
* and active state |
483 |
* |
| 476 |
*/ |
484 |
* @return |
| 477 |
protected void updateGradient() { |
485 |
*/ |
| 478 |
|
486 |
public boolean isDisposed() { |
| 479 |
if (isDisposed()) |
487 |
return paneFolder == null || paneFolder.isDisposed(); |
| 480 |
return; |
488 |
} |
| 481 |
|
489 |
|
| 482 |
Color fgColor; |
490 |
/** |
| 483 |
Color[] bgColors; |
491 |
* Update the tab folder's colours to match the current theme settings and |
| 484 |
int[] bgPercents; |
492 |
* active state |
| 485 |
boolean vertical = false; |
493 |
*/ |
| 486 |
if (isActive()) { |
494 |
protected void updateGradient() { |
| 487 |
if (getShellActivated()) { |
495 |
|
| 488 |
fgColor = R21Colors.getSystemColor(SWT.COLOR_TITLE_FOREGROUND); |
496 |
if (isDisposed()) |
| 489 |
bgColors = R21Colors.getActiveViewGradient(); |
497 |
return; |
| 490 |
bgPercents = R21Colors.getActiveViewGradientPercents(); |
498 |
|
| 491 |
} else { |
499 |
Color fgColor; |
| 492 |
fgColor = R21Colors |
500 |
Color[] bgColors; |
| 493 |
.getSystemColor(SWT.COLOR_TITLE_INACTIVE_FOREGROUND); |
501 |
int[] bgPercents; |
| 494 |
bgColors = R21Colors.getDeactivatedViewGradient(); |
502 |
boolean vertical = false; |
| 495 |
bgPercents = R21Colors.getDeactivatedViewGradientPercents(); |
503 |
if (isActive()) { |
| 496 |
} |
504 |
if (getShellActivated()) { |
| 497 |
|
505 |
fgColor = R21Colors.getSystemColor(SWT.COLOR_TITLE_FOREGROUND); |
| 498 |
} else { |
506 |
bgColors = R21Colors.getActiveViewGradient(); |
| 499 |
fgColor = R21Colors.getSystemColor(SWT.COLOR_LIST_FOREGROUND); |
507 |
bgPercents = R21Colors.getActiveViewGradientPercents(); |
| 500 |
bgColors = null; |
508 |
} else { |
| 501 |
bgPercents = null; |
509 |
fgColor = R21Colors |
| 502 |
} |
510 |
.getSystemColor(SWT.COLOR_TITLE_INACTIVE_FOREGROUND); |
| 503 |
|
511 |
bgColors = R21Colors.getDeactivatedViewGradient(); |
| 504 |
drawGradient(fgColor, bgColors, bgPercents, vertical); |
512 |
bgPercents = R21Colors.getDeactivatedViewGradientPercents(); |
| 505 |
|
513 |
} |
| 506 |
// Color fgColor; |
514 |
|
| 507 |
// ITheme currentTheme = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme(); |
515 |
} else { |
| 508 |
// FontRegistry fontRegistry = currentTheme.getFontRegistry(); |
516 |
fgColor = R21Colors.getSystemColor(SWT.COLOR_LIST_FOREGROUND); |
| 509 |
// ColorRegistry colorRegistry = currentTheme.getColorRegistry(); |
517 |
bgColors = null; |
| 510 |
// Color [] bgColors = new Color[2]; |
518 |
bgPercents = null; |
| 511 |
// int [] percent = new int[1]; |
519 |
} |
| 512 |
// boolean vertical; |
520 |
|
| 513 |
|
521 |
drawGradient(fgColor, bgColors, bgPercents, vertical); |
| 514 |
// if (isActive()){ |
522 |
|
| 515 |
// |
523 |
// Color fgColor; |
| 516 |
// CTabItem item = getPaneFolder().getSelection(); |
524 |
// ITheme currentTheme = |
| 517 |
// if(item != null && !getPartForTab(item).isBusy()){ |
525 |
// PlatformUI.getWorkbench().getThemeManager().getCurrentTheme(); |
| 518 |
// Font tabFont = fontRegistry.get(IWorkbenchThemeConstants.TAB_TEXT_FONT); |
526 |
// FontRegistry fontRegistry = currentTheme.getFontRegistry(); |
| 519 |
//// item.setFont(tabFont); |
527 |
// ColorRegistry colorRegistry = currentTheme.getColorRegistry(); |
| 520 |
// } |
528 |
// Color [] bgColors = new Color[2]; |
| 521 |
// |
529 |
// int [] percent = new int[1]; |
| 522 |
// fgColor = colorRegistry.get(IWorkbenchThemeConstants.ACTIVE_TAB_TEXT_COLOR); |
530 |
// boolean vertical; |
| 523 |
// bgColors[0] = colorRegistry.get(IWorkbenchThemeConstants.ACTIVE_TAB_BG_START); |
531 |
|
| 524 |
// bgColors[1] = colorRegistry.get(IWorkbenchThemeConstants.ACTIVE_TAB_BG_END); |
532 |
// if (isActive()){ |
| 525 |
// percent[0] = currentTheme.getInt(IWorkbenchThemeConstants.ACTIVE_TAB_PERCENT); |
533 |
// |
| 526 |
// vertical = currentTheme.getBoolean(IWorkbenchThemeConstants.ACTIVE_TAB_VERTICAL); |
534 |
// CTabItem item = getPaneFolder().getSelection(); |
| 527 |
// } else { |
535 |
// if(item != null && !getPartForTab(item).isBusy()){ |
| 528 |
// fgColor = colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_TEXT_COLOR); |
536 |
// Font tabFont = |
| 529 |
// bgColors[0] = colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_START); |
537 |
// fontRegistry.get(IWorkbenchThemeConstants.TAB_TEXT_FONT); |
| 530 |
// bgColors[1] = colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_END); |
538 |
// // item.setFont(tabFont); |
| 531 |
// percent[0] = currentTheme.getInt(IWorkbenchThemeConstants.INACTIVE_TAB_PERCENT); |
539 |
// } |
| 532 |
// vertical = currentTheme.getBoolean(IWorkbenchThemeConstants.INACTIVE_TAB_VERTICAL); |
540 |
// |
| 533 |
// } |
541 |
// fgColor = |
| 534 |
// |
542 |
// colorRegistry.get(IWorkbenchThemeConstants.ACTIVE_TAB_TEXT_COLOR); |
| 535 |
// |
543 |
// bgColors[0] = |
| 536 |
// drawGradient(fgColor, bgColors, bgPercents, false); |
544 |
// colorRegistry.get(IWorkbenchThemeConstants.ACTIVE_TAB_BG_START); |
| 537 |
} |
545 |
// bgColors[1] = |
| 538 |
|
546 |
// colorRegistry.get(IWorkbenchThemeConstants.ACTIVE_TAB_BG_END); |
| 539 |
/** |
547 |
// percent[0] = |
| 540 |
* Draws the applicable gradient on the title area |
548 |
// currentTheme.getInt(IWorkbenchThemeConstants.ACTIVE_TAB_PERCENT); |
| 541 |
* |
549 |
// vertical = |
| 542 |
* @param fgColor |
550 |
// currentTheme.getBoolean(IWorkbenchThemeConstants.ACTIVE_TAB_VERTICAL); |
| 543 |
* @param bgColors |
551 |
// } else { |
| 544 |
* @param percentages |
552 |
// fgColor = |
| 545 |
* @param vertical |
553 |
// colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_TEXT_COLOR); |
| 546 |
*/ |
554 |
// bgColors[0] = |
| 547 |
public void drawGradient(Color fgColor, Color[] bgColors, |
555 |
// colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_START); |
| 548 |
int[] percentages, boolean vertical) { |
556 |
// bgColors[1] = |
| 549 |
// paneFolder.setSelectionForeground(fgColor); |
557 |
// colorRegistry.get(IWorkbenchThemeConstants.INACTIVE_TAB_BG_END); |
| 550 |
// paneFolder.setSelectionBackground(bgColors, percentages, vertical); |
558 |
// percent[0] = |
| 551 |
|
559 |
// currentTheme.getInt(IWorkbenchThemeConstants.INACTIVE_TAB_PERCENT); |
| 552 |
if (titleLabel == null || viewToolBar == null) |
560 |
// vertical = |
| 553 |
return; |
561 |
// currentTheme.getBoolean(IWorkbenchThemeConstants.INACTIVE_TAB_VERTICAL); |
| 554 |
|
562 |
// } |
| 555 |
titleLabel.setBackground(bgColors, percentages, vertical); |
563 |
// |
| 556 |
titleLabel.setForeground(fgColor); |
564 |
// |
| 557 |
|
565 |
// drawGradient(fgColor, bgColors, bgPercents, false); |
| 558 |
titleLabel.update(); |
566 |
} |
| 559 |
} |
567 |
|
| 560 |
|
568 |
/** |
| 561 |
public boolean isActive() { |
569 |
* Draws the applicable gradient on the title area |
| 562 |
return activeState; |
570 |
* |
| 563 |
} |
571 |
* @param fgColor |
| 564 |
|
572 |
* @param bgColors |
| 565 |
/** |
573 |
* @param percentages |
| 566 |
* Set the size of a page in the folder. |
574 |
* @param vertical |
| 567 |
* |
575 |
*/ |
| 568 |
* TODO: Kim here...I had to make this public so that the when the font |
576 |
public void drawGradient(Color fgColor, Color[] bgColors, |
| 569 |
* was updated via the color scheme service it could relayout the |
577 |
int[] percentages, boolean vertical) { |
| 570 |
* presentation... calling control.getLayout() doesn't do the trick. |
578 |
// paneFolder.setSelectionForeground(fgColor); |
| 571 |
*/ |
579 |
// paneFolder.setSelectionBackground(bgColors, percentages, vertical); |
| 572 |
public void setControlSize() { |
580 |
|
| 573 |
// Set up the top-right controls |
581 |
if (titleLabel == null || viewToolBar == null) |
| 574 |
//List topRight = new ArrayList(3); |
582 |
return; |
| 575 |
|
583 |
|
| 576 |
if (current != null) { |
584 |
titleLabel.setBackground(bgColors, percentages, vertical); |
| 577 |
paneFolder.setTopLeft(titleLabel); |
585 |
titleLabel.setForeground(fgColor); |
| 578 |
titleLabel.setText(current.getTitle()); |
586 |
|
| 579 |
titleLabel.setImage(current.getTitleImage()); |
587 |
titleLabel.update(); |
| 580 |
titleLabel.setVisible(true); |
588 |
} |
| 581 |
} |
589 |
|
| 582 |
|
590 |
public boolean isActive() { |
| 583 |
Control currentToolbar = getCurrentToolbar(); |
591 |
return activeState; |
| 584 |
paneFolder.setTopCenter(currentToolbar); |
592 |
} |
| 585 |
|
593 |
|
| 586 |
IPartMenu partMenu = getPartMenu(); |
594 |
/** |
| 587 |
|
595 |
* Set the size of a page in the folder. |
| 588 |
if (partMenu != null) { |
596 |
* |
| 589 |
pullDownButton.setEnabled(true); |
597 |
* TODO: Kim here...I had to make this public so that the when the font was |
| 590 |
} else { |
598 |
* updated via the color scheme service it could relayout the |
| 591 |
pullDownButton.setEnabled(false); |
599 |
* presentation... calling control.getLayout() doesn't do the trick. |
| 592 |
} |
600 |
*/ |
| 593 |
paneFolder.setTopRight(viewToolBar); |
601 |
public void setControlSize() { |
| 594 |
viewToolBar.setVisible(true); |
602 |
// Set up the top-right controls |
| 595 |
|
603 |
// List topRight = new ArrayList(3); |
| 596 |
paneFolder.layout(true); |
604 |
|
| 597 |
|
605 |
if (current != null) { |
| 598 |
if (current != null) { |
606 |
paneFolder.setTopLeft(titleLabel); |
| 599 |
Rectangle clientArea = paneFolder.getClientArea(); |
607 |
titleLabel.setText(current.getTitle()); |
| 600 |
Rectangle bounds = paneFolder.getControl().getBounds(); |
608 |
titleLabel.setImage(current.getTitleImage()); |
| 601 |
clientArea.x += bounds.x; |
609 |
titleLabel.setVisible(true); |
| 602 |
clientArea.y += bounds.y; |
610 |
} |
| 603 |
|
611 |
|
| 604 |
current.setBounds(clientArea); |
612 |
Control currentToolbar = getCurrentToolbar(); |
| 605 |
} |
613 |
paneFolder.setTopCenter(currentToolbar); |
| 606 |
|
614 |
|
| 607 |
} |
615 |
IPartMenu partMenu = getPartMenu(); |
| 608 |
|
616 |
|
| 609 |
/** |
617 |
if (partMenu != null) { |
| 610 |
* Returns the IPartMenu for the currently selected part, or null if the current |
618 |
pullDownButton.setEnabled(true); |
| 611 |
* part does not have a menu. |
619 |
} else { |
| 612 |
* |
620 |
pullDownButton.setEnabled(false); |
| 613 |
* @return the IPartMenu for the currently selected part or null if none |
621 |
} |
| 614 |
*/ |
622 |
paneFolder.setTopRight(viewToolBar); |
| 615 |
protected IPartMenu getPartMenu() { |
623 |
viewToolBar.setVisible(true); |
| 616 |
IPresentablePart part = getCurrentPart(); |
624 |
|
| 617 |
if (part == null) { |
625 |
paneFolder.layout(true); |
| 618 |
return null; |
626 |
|
| 619 |
} |
627 |
if (current != null) { |
| 620 |
|
628 |
Rectangle clientArea = paneFolder.getClientArea(); |
| 621 |
return part.getMenu(); |
629 |
Rectangle bounds = paneFolder.getControl().getBounds(); |
| 622 |
} |
630 |
clientArea.x += bounds.x; |
| 623 |
|
631 |
clientArea.y += bounds.y; |
| 624 |
/* (non-Javadoc) |
632 |
|
| 625 |
* @see org.eclipse.ui.internal.skins.Presentation#dispose() |
633 |
current.setBounds(clientArea); |
| 626 |
*/ |
634 |
} |
| 627 |
public void dispose() { |
635 |
|
| 628 |
if (isDisposed()) { |
636 |
} |
| 629 |
return; |
637 |
|
| 630 |
} |
638 |
/** |
| 631 |
|
639 |
* Returns the IPartMenu for the currently selected part, or null if the |
| 632 |
// remove shell listener |
640 |
* current part does not have a menu. |
| 633 |
paneFolder.getControl().getShell().removeShellListener(shellListener); |
641 |
* |
| 634 |
|
642 |
* @return the IPartMenu for the currently selected part or null if none |
| 635 |
PresentationUtil.removeDragListener(paneFolder.getControl(), |
643 |
*/ |
| 636 |
dragListener); |
644 |
protected IPartMenu getPartMenu() { |
| 637 |
PresentationUtil.removeDragListener(titleLabel, dragListener); |
645 |
IPresentablePart part = getCurrentPart(); |
| 638 |
|
646 |
if (part == null) { |
| 639 |
systemMenuManager.dispose(); |
647 |
return null; |
| 640 |
systemMenuManager.removeAll(); |
648 |
} |
| 641 |
paneFolder.getControl().dispose(); |
649 |
|
| 642 |
paneFolder = null; |
650 |
return part.getMenu(); |
| 643 |
|
651 |
} |
| 644 |
titleLabel.dispose(); |
652 |
|
| 645 |
titleLabel = null; |
653 |
/* |
| 646 |
|
654 |
* (non-Javadoc) |
| 647 |
viewToolBar.dispose(); |
655 |
* |
| 648 |
} |
656 |
* @see org.eclipse.ui.internal.skins.Presentation#dispose() |
| 649 |
|
657 |
*/ |
| 650 |
/* (non-Javadoc) |
658 |
public void dispose() { |
| 651 |
* @see org.eclipse.ui.internal.skins.Presentation#setActive(boolean) |
659 |
if (isDisposed()) { |
| 652 |
*/ |
660 |
return; |
| 653 |
public void setActive(boolean isActive) { |
661 |
} |
| 654 |
activeState = isActive; |
662 |
|
| 655 |
updateGradient(); |
663 |
// remove shell listener |
| 656 |
} |
664 |
paneFolder.getControl().getShell().removeShellListener(shellListener); |
| 657 |
|
665 |
|
| 658 |
/** |
666 |
PresentationUtil.removeDragListener(paneFolder.getControl(), |
| 659 |
* Return whether the window's shell is activated |
667 |
dragListener); |
| 660 |
*/ |
668 |
PresentationUtil.removeDragListener(titleLabel, dragListener); |
| 661 |
/* package */boolean getShellActivated() { |
669 |
|
| 662 |
return shellActive; |
670 |
systemMenuManager.dispose(); |
| 663 |
} |
671 |
systemMenuManager.removeAll(); |
| 664 |
|
672 |
paneFolder.getControl().dispose(); |
| 665 |
/** |
673 |
paneFolder = null; |
| 666 |
* Returns the top level window. |
674 |
|
| 667 |
*/ |
675 |
titleLabel.dispose(); |
| 668 |
public Window getWindow() { |
676 |
titleLabel = null; |
| 669 |
Control ctrl = getControl(); |
677 |
|
| 670 |
if (ctrl != null) { |
678 |
viewToolBar.dispose(); |
| 671 |
Object data = ctrl.getShell().getData(); |
679 |
} |
| 672 |
if (data instanceof Window) |
680 |
|
| 673 |
return (Window) data; |
681 |
/* |
| 674 |
} |
682 |
* (non-Javadoc) |
| 675 |
return null; |
683 |
* |
| 676 |
} |
684 |
* @see org.eclipse.ui.internal.skins.Presentation#setActive(boolean) |
| 677 |
|
685 |
*/ |
| 678 |
private CTabItem createPartTab(IPresentablePart part, int tabIndex) { |
686 |
public void setActive(boolean isActive) { |
| 679 |
CTabItem tabItem; |
687 |
activeState = isActive; |
| 680 |
|
688 |
updateGradient(); |
| 681 |
int style = SWT.NONE; |
689 |
} |
| 682 |
|
690 |
|
| 683 |
if (getSite().isCloseable(part)) |
691 |
/** |
| 684 |
style |= SWT.CLOSE; |
692 |
* Return whether the window's shell is activated |
| 685 |
|
693 |
*/ |
| 686 |
tabItem = paneFolder.createItem(style, tabIndex); |
694 |
/* package */boolean getShellActivated() { |
| 687 |
|
695 |
return shellActive; |
| 688 |
tabItem.setData(TAB_DATA, part); |
696 |
} |
| 689 |
|
697 |
|
| 690 |
part.addPropertyListener(childPropertyChangeListener); |
698 |
/** |
| 691 |
tabItem.addDisposeListener(tabDisposeListener); |
699 |
* Returns the top level window. |
| 692 |
|
700 |
*/ |
| 693 |
initTab(tabItem, part); |
701 |
public Window getWindow() { |
| 694 |
|
702 |
Control ctrl = getControl(); |
| 695 |
return tabItem; |
703 |
if (ctrl != null) { |
| 696 |
} |
704 |
Object data = ctrl.getShell().getData(); |
| 697 |
|
705 |
if (data instanceof Window) |
| 698 |
// Create a close button in the title bar for the argument part (if needed). |
706 |
return (Window) data; |
| 699 |
private void updateCloseButton() { |
707 |
} |
| 700 |
// remove the close button if needed |
708 |
return null; |
| 701 |
if (current == null || !getSite().isCloseable(current)) { |
709 |
} |
| 702 |
if (closeButton != null) { |
710 |
|
| 703 |
closeButton.dispose(); |
711 |
private CTabItem createPartTab(IPresentablePart part, int tabIndex) { |
| 704 |
closeButton = null; |
712 |
CTabItem tabItem; |
| 705 |
|
713 |
|
| 706 |
paneFolder.flush(); |
714 |
int style = SWT.NONE; |
| 707 |
} |
715 |
|
| 708 |
return; |
716 |
if (getSite().isCloseable(part)) |
| 709 |
} |
717 |
style |= SWT.CLOSE; |
| 710 |
|
718 |
|
| 711 |
// a close button is needed, so if its already there, we're done |
719 |
tabItem = paneFolder.createItem(style, tabIndex); |
| 712 |
if (closeButton != null) |
720 |
|
| 713 |
return; |
721 |
tabItem.setData(TAB_DATA, part); |
| 714 |
|
722 |
|
| 715 |
// otherwise create it |
723 |
part.addPropertyListener(childPropertyChangeListener); |
| 716 |
closeButton = new ToolItem(viewToolBar, SWT.PUSH); |
724 |
tabItem.addDisposeListener(tabDisposeListener); |
| 717 |
closeButton.setDisabledImage(null); |
725 |
|
| 718 |
closeButton.setImage(WorkbenchImages |
726 |
initTab(tabItem, part); |
| 719 |
.getImage(IWorkbenchGraphicConstants.IMG_LCL_CLOSE_VIEW)); |
727 |
|
| 720 |
closeButton.setToolTipText(R21PresentationMessages |
728 |
return tabItem; |
| 721 |
.getString("BasicStackPresentation.close.tooltip")); //$NON-NLS-1$ |
729 |
} |
| 722 |
closeButton.addSelectionListener(new SelectionAdapter() { |
730 |
|
| 723 |
public void widgetSelected(SelectionEvent e) { |
731 |
// Create a close button in the title bar for the argument part (if needed). |
| 724 |
close(getCurrent()); |
732 |
private void updateCloseButton() { |
| 725 |
} |
733 |
// remove the close button if needed |
| 726 |
}); |
734 |
if (current == null || !getSite().isCloseable(current)) { |
| 727 |
|
735 |
if (closeButton != null) { |
| 728 |
paneFolder.flush(); |
736 |
closeButton.dispose(); |
| 729 |
} |
737 |
closeButton = null; |
| 730 |
|
738 |
|
| 731 |
/** |
739 |
paneFolder.flush(); |
| 732 |
* Initializes a tab for the given part. Sets the text, icon, tool tip, |
740 |
} |
| 733 |
* etc. This will also be called whenever a relevant property changes |
741 |
return; |
| 734 |
* in the part to reflect those changes in the tab. Subclasses may override |
742 |
} |
| 735 |
* to change the appearance of tabs for a particular part. |
743 |
|
| 736 |
* |
744 |
// a close button is needed, so if its already there, we're done |
| 737 |
* @param tabItem tab for the part |
745 |
if (closeButton != null) |
| 738 |
* @param part the part being displayed |
746 |
return; |
| 739 |
*/ |
747 |
|
| 740 |
protected void initTab(CTabItem tabItem, IPresentablePart part) { |
748 |
// otherwise create it |
| 741 |
tabItem.setText(part.getName()); |
749 |
closeButton = new ToolItem(viewToolBar, SWT.PUSH); |
| 742 |
|
750 |
closeButton.setDisabledImage(null); |
| 743 |
//tabItem.setImage(part.getTitleImage()); |
751 |
closeButton.setImage(WorkbenchImages |
| 744 |
|
752 |
.getImage(IWorkbenchGraphicConstants.IMG_LCL_CLOSE_VIEW)); |
| 745 |
String toolTipText = part.getTitleToolTip(); |
753 |
closeButton.setToolTipText(R21PresentationMessages |
| 746 |
if (!toolTipText.equals(Util.ZERO_LENGTH_STRING)) { |
754 |
.getString("BasicStackPresentation.close.tooltip")); //$NON-NLS-1$ |
| 747 |
tabItem.setToolTipText(toolTipText); |
755 |
closeButton.addSelectionListener(new SelectionAdapter() { |
| 748 |
} |
756 |
public void widgetSelected(SelectionEvent e) { |
| 749 |
|
757 |
close(getCurrent()); |
| 750 |
// FontRegistry registry = |
758 |
} |
| 751 |
// PlatformUI.getWorkbench(). |
759 |
}); |
| 752 |
// getThemeManager().getCurrentTheme(). |
760 |
|
| 753 |
// getFontRegistry(); |
761 |
paneFolder.flush(); |
| 754 |
// |
762 |
} |
| 755 |
// if(part.isBusy()) |
763 |
|
| 756 |
// tabItem.setFont(registry.getItalic(IWorkbenchThemeConstants.TAB_TEXT_FONT)); |
764 |
/** |
| 757 |
// else{ |
765 |
* Initializes a tab for the given part. Sets the text, icon, tool tip, etc. |
| 758 |
// tabItem.setFont(registry.get(IWorkbenchThemeConstants.TAB_TEXT_FONT)); |
766 |
* This will also be called whenever a relevant property changes in the part |
| 759 |
// } |
767 |
* to reflect those changes in the tab. Subclasses may override to change |
| 760 |
|
768 |
* the appearance of tabs for a particular part. |
| 761 |
} |
769 |
* |
| 762 |
|
770 |
* @param tabItem |
| 763 |
/* (non-Javadoc) |
771 |
* tab for the part |
| 764 |
* @see org.eclipse.ui.internal.skins.StackPresentation#addPart(org.eclipse.ui.internal.skins.IPresentablePart, org.eclipse.ui.internal.skins.IPresentablePart) |
772 |
* @param part |
| 765 |
*/ |
773 |
* the part being displayed |
| 766 |
public void addPart(IPresentablePart newPart, Object cookie) { |
774 |
*/ |
| 767 |
|
775 |
protected void initTab(CTabItem tabItem, IPresentablePart part) { |
| 768 |
int idx; |
776 |
tabItem.setText(part.getName()); |
| 769 |
|
777 |
|
| 770 |
if (cookie instanceof Integer) { |
778 |
// tabItem.setImage(part.getTitleImage()); |
| 771 |
idx = ((Integer) cookie).intValue(); |
779 |
|
| 772 |
} else { |
780 |
String toolTipText = part.getTitleToolTip(); |
| 773 |
// Select a location for newly inserted parts |
781 |
if (!toolTipText.equals(Util.ZERO_LENGTH_STRING)) { |
| 774 |
idx = paneFolder.getItemCount(); |
782 |
tabItem.setToolTipText(toolTipText); |
| 775 |
} |
783 |
} |
| 776 |
|
784 |
|
| 777 |
addPart(newPart, idx); |
785 |
// FontRegistry registry = |
| 778 |
} |
786 |
// PlatformUI.getWorkbench(). |
| 779 |
|
787 |
// getThemeManager().getCurrentTheme(). |
| 780 |
/** |
788 |
// getFontRegistry(); |
| 781 |
* Adds the given presentable part to this presentation at the given index. |
789 |
// |
| 782 |
* Does nothing if a tab already exists for the given part. |
790 |
// if(part.isBusy()) |
| 783 |
* |
791 |
// tabItem.setFont(registry.getItalic(IWorkbenchThemeConstants.TAB_TEXT_FONT)); |
| 784 |
* @param newPart |
792 |
// else{ |
| 785 |
* @param index |
793 |
// tabItem.setFont(registry.get(IWorkbenchThemeConstants.TAB_TEXT_FONT)); |
| 786 |
*/ |
794 |
// } |
| 787 |
public void addPart(IPresentablePart newPart, int index) { |
795 |
|
| 788 |
// If we already have a tab for this part, do nothing |
796 |
} |
| 789 |
if (getTab(newPart) != null) { |
797 |
|
| 790 |
return; |
798 |
/* |
| 791 |
} |
799 |
* (non-Javadoc) |
| 792 |
createPartTab(newPart, index); |
800 |
* |
| 793 |
|
801 |
* @see org.eclipse.ui.internal.skins.StackPresentation#addPart(org.eclipse.ui.internal.skins.IPresentablePart, |
| 794 |
setControlSize(); |
802 |
* org.eclipse.ui.internal.skins.IPresentablePart) |
| 795 |
} |
803 |
*/ |
| 796 |
|
804 |
public void addPart(IPresentablePart newPart, Object cookie) { |
| 797 |
/* (non-Javadoc) |
805 |
|
| 798 |
* @see org.eclipse.ui.internal.skins.StackPresentation#removePart(org.eclipse.ui.internal.skins.IPresentablePart) |
806 |
int idx; |
| 799 |
*/ |
807 |
|
| 800 |
public void removePart(IPresentablePart oldPart) { |
808 |
if (cookie instanceof Integer) { |
| 801 |
if (current == oldPart) { |
809 |
idx = ((Integer) cookie).intValue(); |
| 802 |
titleLabel.setImage(null); |
810 |
} else { |
| 803 |
current = null; |
811 |
// Select a location for newly inserted parts |
| 804 |
} |
812 |
idx = paneFolder.getItemCount(); |
| 805 |
|
813 |
} |
| 806 |
CTabItem item = getTab(oldPart); |
814 |
|
| 807 |
if (item == null) { |
815 |
addPart(newPart, idx); |
| 808 |
return; |
816 |
} |
| 809 |
} |
817 |
|
| 810 |
oldPart.setVisible(false); |
818 |
/** |
| 811 |
|
819 |
* Adds the given presentable part to this presentation at the given index. |
| 812 |
item.dispose(); |
820 |
* Does nothing if a tab already exists for the given part. |
| 813 |
|
821 |
* |
| 814 |
// Layout the folder again in case there is only one item |
822 |
* @param newPart |
| 815 |
setControlSize(); |
823 |
* @param index |
| 816 |
} |
824 |
*/ |
| 817 |
|
825 |
public void addPart(IPresentablePart newPart, int index) { |
| 818 |
/* (non-Javadoc) |
826 |
// If we already have a tab for this part, do nothing |
| 819 |
* @see org.eclipse.ui.internal.skins.StackPresentation#selectPart(org.eclipse.ui.internal.skins.IPresentablePart) |
827 |
if (getTab(newPart) != null) { |
| 820 |
*/ |
828 |
return; |
| 821 |
public void selectPart(IPresentablePart toSelect) { |
829 |
} |
| 822 |
if (toSelect == current) { |
830 |
createPartTab(newPart, index); |
| 823 |
return; |
831 |
|
| 824 |
} |
832 |
setControlSize(); |
| 825 |
|
833 |
} |
| 826 |
if (current != null) { |
834 |
|
| 827 |
current.setVisible(false); |
835 |
/* |
| 828 |
} |
836 |
* (non-Javadoc) |
| 829 |
|
837 |
* |
| 830 |
current = toSelect; |
838 |
* @see org.eclipse.ui.internal.skins.StackPresentation#removePart(org.eclipse.ui.internal.skins.IPresentablePart) |
| 831 |
|
839 |
*/ |
| 832 |
if (current != null) { |
840 |
public void removePart(IPresentablePart oldPart) { |
| 833 |
paneFolder.setSelection(indexOf(current)); |
841 |
if (current == oldPart) { |
| 834 |
current.setVisible(true); |
842 |
titleLabel.setImage(null); |
| 835 |
updateCloseButton(); |
843 |
current = null; |
| 836 |
setControlSize(); |
844 |
} |
| 837 |
} |
845 |
|
| 838 |
} |
846 |
CTabItem item = getTab(oldPart); |
| 839 |
|
847 |
if (item == null) { |
| 840 |
public IPresentablePart getCurrentPart() { |
848 |
return; |
| 841 |
return current; |
849 |
} |
| 842 |
} |
850 |
oldPart.setVisible(false); |
| 843 |
|
851 |
|
| 844 |
/* (non-Javadoc) |
852 |
item.dispose(); |
| 845 |
* @see org.eclipse.ui.internal.skins.Presentation#setBounds(org.eclipse.swt.graphics.Rectangle) |
853 |
|
| 846 |
*/ |
854 |
// Layout the folder again in case there is only one item |
| 847 |
public void setBounds(Rectangle bounds) { |
855 |
setControlSize(); |
| 848 |
if (getSite().getState() == IStackPresentationSite.STATE_MINIMIZED) { |
856 |
} |
| 849 |
bounds = Geometry.copy(bounds); |
857 |
|
| 850 |
bounds.height = computePreferredSize(false, Integer.MAX_VALUE, bounds.width, Integer.MAX_VALUE); |
858 |
/* |
| 851 |
} |
859 |
* (non-Javadoc) |
| 852 |
|
860 |
* |
| 853 |
paneFolder.getControl().setBounds(bounds); |
861 |
* @see org.eclipse.ui.internal.skins.StackPresentation#selectPart(org.eclipse.ui.internal.skins.IPresentablePart) |
| 854 |
setControlSize(); |
862 |
*/ |
| 855 |
} |
863 |
public void selectPart(IPresentablePart toSelect) { |
| 856 |
|
864 |
if (toSelect == current) { |
| 857 |
/* (non-Javadoc) |
865 |
return; |
| 858 |
* @see org.eclipse.ui.internal.skins.Presentation#computeMinimumSize() |
866 |
} |
| 859 |
*/ |
867 |
|
| 860 |
public Point computeMinimumSize() { |
868 |
if (current != null) { |
| 861 |
Point result = Geometry.getSize(paneFolder.computeTrim(0, 0, 0, 0)); |
869 |
current.setVisible(false); |
| 862 |
|
870 |
} |
| 863 |
result.x += 100; |
871 |
|
| 864 |
|
872 |
current = toSelect; |
| 865 |
return result; |
873 |
|
| 866 |
} |
874 |
if (current != null) { |
| 867 |
|
875 |
paneFolder.setSelection(indexOf(current)); |
| 868 |
/* (non-Javadoc) |
876 |
current.setVisible(true); |
| 869 |
* @see org.eclipse.ui.internal.skins.Presentation#setVisible(boolean) |
877 |
updateCloseButton(); |
| 870 |
*/ |
878 |
setControlSize(); |
| 871 |
public void setVisible(boolean isVisible) { |
879 |
} |
| 872 |
if (current != null) { |
880 |
} |
| 873 |
current.setVisible(isVisible); |
881 |
|
| 874 |
} |
882 |
public IPresentablePart getCurrentPart() { |
| 875 |
paneFolder.getControl().setVisible(isVisible); |
883 |
return current; |
| 876 |
} |
884 |
} |
| 877 |
|
885 |
|
| 878 |
/* (non-Javadoc) |
886 |
/* |
| 879 |
* @see org.eclipse.ui.internal.skins.Presentation#setState(int) |
887 |
* (non-Javadoc) |
| 880 |
*/ |
888 |
* |
| 881 |
public void setState(int state) { |
889 |
* @see org.eclipse.ui.internal.skins.Presentation#setBounds(org.eclipse.swt.graphics.Rectangle) |
| 882 |
// tabFolder.setState(state); |
890 |
*/ |
| 883 |
} |
891 |
public void setBounds(Rectangle bounds) { |
| 884 |
|
892 |
if (getSite().getState() == IStackPresentationSite.STATE_MINIMIZED) { |
| 885 |
/* (non-Javadoc) |
893 |
bounds = Geometry.copy(bounds); |
| 886 |
* @see org.eclipse.ui.internal.skins.Presentation#getSystemMenuManager() |
894 |
bounds.height = computePreferredSize(false, Integer.MAX_VALUE, |
| 887 |
*/ |
895 |
bounds.width, Integer.MAX_VALUE); |
| 888 |
public IMenuManager getSystemMenuManager() { |
896 |
} |
| 889 |
return systemMenuManager; |
897 |
|
| 890 |
} |
898 |
paneFolder.getControl().setBounds(bounds); |
| 891 |
|
899 |
setControlSize(); |
| 892 |
/** |
900 |
} |
| 893 |
* @param point |
901 |
|
| 894 |
*/ |
902 |
/* |
| 895 |
protected void showSystemMenu(Point point) { |
903 |
* (non-Javadoc) |
| 896 |
Menu aMenu = systemMenuManager.createContextMenu(paneFolder |
904 |
* |
| 897 |
.getControl().getParent()); |
905 |
* @see org.eclipse.ui.internal.skins.Presentation#computeMinimumSize() |
| 898 |
systemMenuManager.update(true); |
906 |
*/ |
| 899 |
aMenu.setLocation(point.x, point.y); |
907 |
public Point computeMinimumSize() { |
| 900 |
aMenu.setVisible(true); |
908 |
Point result = Geometry.getSize(paneFolder.computeTrim(0, 0, 0, 0)); |
| 901 |
} |
909 |
|
| 902 |
|
910 |
result.x += 100; |
| 903 |
/* (non-Javadoc) |
911 |
|
| 904 |
* @see org.eclipse.ui.internal.skins.Presentation#getControl() |
912 |
return result; |
| 905 |
*/ |
913 |
} |
| 906 |
public Control getControl() { |
914 |
|
| 907 |
return paneFolder.getControl(); |
915 |
/* |
| 908 |
} |
916 |
* (non-Javadoc) |
| 909 |
|
917 |
* |
| 910 |
/* |
918 |
* @see org.eclipse.ui.internal.skins.Presentation#setVisible(boolean) |
| 911 |
* (non-Javadoc) |
919 |
*/ |
| 912 |
* |
920 |
public void setVisible(boolean isVisible) { |
| 913 |
* @see org.eclipse.ui.internal.skins.StackPresentation#dragOver(org.eclipse.swt.widgets.Control, |
921 |
if (current != null) { |
| 914 |
* org.eclipse.swt.graphics.Point) |
922 |
current.setVisible(isVisible); |
| 915 |
*/ |
923 |
} |
| 916 |
public StackDropResult dragOver(Control currentControl, Point location) { |
924 |
paneFolder.getControl().setVisible(isVisible); |
| 917 |
|
925 |
} |
| 918 |
// Determine which tab we're currently dragging over |
926 |
|
| 919 |
Point localPos = paneFolder.getControl().toControl(location); |
927 |
/* |
| 920 |
final CTabItem tabUnderPointer = paneFolder.getItem(localPos); |
928 |
* (non-Javadoc) |
| 921 |
|
929 |
* |
| 922 |
// This drop target only deals with tabs... if we're not dragging over |
930 |
* @see org.eclipse.ui.internal.skins.Presentation#setState(int) |
| 923 |
// a tab, exit. |
931 |
*/ |
| 924 |
if (tabUnderPointer == null) |
932 |
public void setState(int state) { |
| 925 |
return null; |
933 |
// tabFolder.setState(state); |
| 926 |
|
934 |
} |
| 927 |
// workaround when left tab is dragged over next |
935 |
|
| 928 |
int dragOverIndex = paneFolder.indexOf(tabUnderPointer); |
936 |
/* |
| 929 |
|
937 |
* (non-Javadoc) |
| 930 |
return new StackDropResult(Geometry.toDisplay(paneFolder.getControl(), |
938 |
* |
| 931 |
tabUnderPointer.getBounds()), new Integer(dragOverIndex)); |
939 |
* @see org.eclipse.ui.internal.skins.Presentation#getSystemMenuManager() |
| 932 |
} |
940 |
*/ |
| 933 |
|
941 |
public IMenuManager getSystemMenuManager() { |
| 934 |
/** |
942 |
return systemMenuManager; |
| 935 |
* Returns the toolbar control for the currently selected part, or null if none (not |
943 |
} |
| 936 |
* all parts have a toolbar). |
944 |
|
| 937 |
* |
945 |
/** |
| 938 |
* @return the current toolbar or null if none |
946 |
* @param point |
| 939 |
*/ |
947 |
*/ |
| 940 |
protected Control getCurrentToolbar() { |
948 |
protected void showSystemMenu(Point point) { |
| 941 |
IPresentablePart part = getCurrentPart(); |
949 |
Menu aMenu = systemMenuManager.createContextMenu(paneFolder |
| 942 |
if (part == null) { |
950 |
.getControl().getParent()); |
| 943 |
return null; |
951 |
systemMenuManager.update(true); |
| 944 |
} |
952 |
aMenu.setLocation(point.x, point.y); |
| 945 |
|
953 |
aMenu.setVisible(true); |
| 946 |
return part.getToolBar(); |
954 |
} |
| 947 |
} |
955 |
|
| 948 |
|
956 |
/* |
| 949 |
/* (non-Javadoc) |
957 |
* (non-Javadoc) |
| 950 |
* @see org.eclipse.ui.presentations.StackPresentation#showSystemMenu() |
958 |
* |
| 951 |
*/ |
959 |
* @see org.eclipse.ui.internal.skins.Presentation#getControl() |
| 952 |
public void showSystemMenu() { |
960 |
*/ |
| 953 |
IPresentablePart part = getCurrentPart(); |
961 |
public Control getControl() { |
| 954 |
if (part != null) { |
962 |
return paneFolder.getControl(); |
| 955 |
Rectangle bounds = DragUtil.getDisplayBounds(paneFolder |
963 |
} |
| 956 |
.getControl()); |
964 |
|
| 957 |
|
965 |
/* |
| 958 |
int idx = paneFolder.getSelectionIndex(); |
966 |
* (non-Javadoc) |
| 959 |
if (idx > -1) { |
967 |
* |
| 960 |
CTabItem item = paneFolder.getItem(idx); |
968 |
* @see org.eclipse.ui.internal.skins.StackPresentation#dragOver(org.eclipse.swt.widgets.Control, |
| 961 |
Rectangle itemBounds = item.getBounds(); |
969 |
* org.eclipse.swt.graphics.Point) |
| 962 |
|
970 |
*/ |
| 963 |
bounds.x += itemBounds.x; |
971 |
public StackDropResult dragOver(Control currentControl, Point location) { |
| 964 |
bounds.y += itemBounds.y; |
972 |
|
| 965 |
} |
973 |
// Determine which tab we're currently dragging over |
| 966 |
|
974 |
Point localPos = paneFolder.getControl().toControl(location); |
| 967 |
Point location = new Point(bounds.x, bounds.y |
975 |
final CTabItem tabUnderPointer = paneFolder.getItem(localPos); |
| 968 |
+ paneFolder.getTabHeight()); |
976 |
|
| 969 |
showSystemMenu(location); |
977 |
// This drop target only deals with tabs... if we're not dragging over |
| 970 |
} |
978 |
// a tab, exit. |
| 971 |
} |
979 |
if (tabUnderPointer == null) |
| 972 |
|
980 |
return null; |
| 973 |
/* (non-Javadoc) |
981 |
|
| 974 |
* @see org.eclipse.ui.presentations.StackPresentation#getTabList(IPresentablePart) |
982 |
// workaround when left tab is dragged over next |
| 975 |
*/ |
983 |
int dragOverIndex = paneFolder.indexOf(tabUnderPointer); |
| 976 |
public Control[] getTabList(IPresentablePart part) { |
984 |
|
| 977 |
ArrayList list = new ArrayList(); |
985 |
return new StackDropResult(Geometry.toDisplay(paneFolder.getControl(), |
| 978 |
if (paneFolder.getTabPosition() == SWT.BOTTOM) { |
986 |
tabUnderPointer.getBounds()), new Integer(dragOverIndex)); |
| 979 |
if (part.getToolBar() != null) |
987 |
} |
| 980 |
list.add(part.getToolBar()); |
988 |
|
| 981 |
if (part.getControl() != null) |
989 |
/** |
| 982 |
list.add(part.getControl()); |
990 |
* Returns the toolbar control for the currently selected part, or null if |
| 983 |
if (getPaneFolder() != null) |
991 |
* none (not all parts have a toolbar). |
| 984 |
list.add(getPaneFolder().getControl()); |
992 |
* |
| 985 |
} else { |
993 |
* @return the current toolbar or null if none |
| 986 |
if (getPaneFolder() != null) |
994 |
*/ |
| 987 |
list.add(getPaneFolder().getControl()); |
995 |
protected Control getCurrentToolbar() { |
| 988 |
if (part.getToolBar() != null) |
996 |
IPresentablePart part = getCurrentPart(); |
| 989 |
list.add(part.getToolBar()); |
997 |
if (part == null) { |
| 990 |
if (part.getControl() != null) |
998 |
return null; |
| 991 |
list.add(part.getControl()); |
999 |
} |
| 992 |
} |
1000 |
|
| 993 |
return (Control[]) list.toArray(new Control[list.size()]); |
1001 |
return part.getToolBar(); |
| 994 |
} |
1002 |
} |
| 995 |
|
1003 |
|
| 996 |
protected void showList(Shell parentShell, int x, int y) { |
1004 |
/* |
| 997 |
// final R21PaneFolder tabFolder = getTabFolder(); |
1005 |
* (non-Javadoc) |
| 998 |
// |
1006 |
* |
| 999 |
// int shellStyle = SWT.RESIZE | SWT.ON_TOP | SWT.NO_TRIM; |
1007 |
* @see org.eclipse.ui.presentations.StackPresentation#showSystemMenu() |
| 1000 |
// int tableStyle = SWT.V_SCROLL | SWT.H_SCROLL; |
1008 |
*/ |
| 1001 |
// final BasicStackList editorList = new BasicStackList(tabFolder.getControl().getShell(), |
1009 |
public void showSystemMenu() { |
| 1002 |
// shellStyle, tableStyle); |
1010 |
IPresentablePart part = getCurrentPart(); |
| 1003 |
// editorList.setInput(this); |
1011 |
if (part != null) { |
| 1004 |
// Point size = editorList.computeSizeHint(); |
1012 |
Rectangle bounds = DragUtil.getDisplayBounds(paneFolder |
| 1005 |
// |
1013 |
.getControl()); |
| 1006 |
// Rectangle bounds = Display.getCurrent().getBounds(); |
1014 |
|
| 1007 |
// if (x + size.x > bounds.width) x = bounds.width - size.x; |
1015 |
int idx = paneFolder.getSelectionIndex(); |
| 1008 |
// if (y + size.y > bounds.height) y = bounds.height - size.y; |
1016 |
if (idx > -1) { |
| 1009 |
// editorList.setLocation(new Point(x, y)); |
1017 |
CTabItem item = paneFolder.getItem(idx); |
| 1010 |
// editorList.setVisible(true); |
1018 |
Rectangle itemBounds = item.getBounds(); |
| 1011 |
// editorList.setFocus(); |
1019 |
|
| 1012 |
// editorList.getTableViewer().getTable().getShell().addListener( |
1020 |
bounds.x += itemBounds.x; |
| 1013 |
// SWT.Deactivate, new Listener() { |
1021 |
bounds.y += itemBounds.y; |
| 1014 |
// |
1022 |
} |
| 1015 |
// public void handleEvent(Event event) { |
1023 |
|
| 1016 |
// editorList.setVisible(false); |
1024 |
Point location = new Point(bounds.x, bounds.y |
| 1017 |
// } |
1025 |
+ paneFolder.getTabHeight()); |
| 1018 |
// }); |
1026 |
showSystemMenu(location); |
| 1019 |
} |
1027 |
} |
| 1020 |
|
1028 |
} |
| 1021 |
/* |
1029 |
|
| 1022 |
* Shows the list of tabs at the top left corner of the editor |
1030 |
/* |
| 1023 |
*/ |
1031 |
* (non-Javadoc) |
| 1024 |
protected void showListDefaultLocation() { |
1032 |
* |
| 1025 |
R21PaneFolder tabFolder = getPaneFolder(); |
1033 |
* @see org.eclipse.ui.presentations.StackPresentation#getTabList(IPresentablePart) |
| 1026 |
Shell shell = tabFolder.getControl().getShell(); |
1034 |
*/ |
| 1027 |
Rectangle clientArea = tabFolder.getClientArea(); |
1035 |
public Control[] getTabList(IPresentablePart part) { |
| 1028 |
Point location = tabFolder.getControl().getDisplay().map( |
1036 |
ArrayList list = new ArrayList(); |
| 1029 |
tabFolder.getControl(), null, clientArea.x, clientArea.y); |
1037 |
if (paneFolder.getTabPosition() == SWT.BOTTOM) { |
| 1030 |
showList(shell, location.x, location.y); |
1038 |
if (part.getToolBar() != null) |
| 1031 |
} |
1039 |
list.add(part.getToolBar()); |
| 1032 |
|
1040 |
if (part.getControl() != null) |
| 1033 |
void setSelection(CTabItem tabItem) { |
1041 |
list.add(part.getControl()); |
| 1034 |
getSite().selectPart(getPartForTab(tabItem)); |
1042 |
if (getPaneFolder() != null) |
| 1035 |
} |
1043 |
list.add(getPaneFolder().getControl()); |
| 1036 |
|
1044 |
} else { |
| 1037 |
void close(IPresentablePart presentablePart) { |
1045 |
if (getPaneFolder() != null) |
| 1038 |
getSite().close(new IPresentablePart[] { presentablePart }); |
1046 |
list.add(getPaneFolder().getControl()); |
| 1039 |
} |
1047 |
if (part.getToolBar() != null) |
| 1040 |
|
1048 |
list.add(part.getToolBar()); |
| 1041 |
Image getLabelImage(IPresentablePart presentablePart) { |
1049 |
if (part.getControl() != null) |
| 1042 |
return presentablePart.getTitleImage(); |
1050 |
list.add(part.getControl()); |
| 1043 |
} |
1051 |
} |
| 1044 |
|
1052 |
return (Control[]) list.toArray(new Control[list.size()]); |
| 1045 |
String getLabelText(IPresentablePart presentablePart, boolean includePath) { |
1053 |
} |
| 1046 |
String title = presentablePart.getTitle().trim(); |
1054 |
|
| 1047 |
return title; |
1055 |
protected void showList(Shell parentShell, int x, int y) { |
| 1048 |
} |
1056 |
// final R21PaneFolder tabFolder = getTabFolder(); |
| 1049 |
|
1057 |
// |
| 1050 |
/* (non-Javadoc) |
1058 |
// int shellStyle = SWT.RESIZE | SWT.ON_TOP | SWT.NO_TRIM; |
| 1051 |
* @see org.eclipse.ui.presentations.StackPresentation#setActive(int) |
1059 |
// int tableStyle = SWT.V_SCROLL | SWT.H_SCROLL; |
| 1052 |
*/ |
1060 |
// final BasicStackList editorList = new |
| 1053 |
public void setActive(int newState) { |
1061 |
// BasicStackList(tabFolder.getControl().getShell(), |
| 1054 |
setActive(newState == AS_ACTIVE_FOCUS); |
1062 |
// shellStyle, tableStyle); |
| 1055 |
} |
1063 |
// editorList.setInput(this); |
|
|
1064 |
// Point size = editorList.computeSizeHint(); |
| 1065 |
// |
| 1066 |
// Rectangle bounds = Display.getCurrent().getBounds(); |
| 1067 |
// if (x + size.x > bounds.width) x = bounds.width - size.x; |
| 1068 |
// if (y + size.y > bounds.height) y = bounds.height - size.y; |
| 1069 |
// editorList.setLocation(new Point(x, y)); |
| 1070 |
// editorList.setVisible(true); |
| 1071 |
// editorList.setFocus(); |
| 1072 |
// editorList.getTableViewer().getTable().getShell().addListener( |
| 1073 |
// SWT.Deactivate, new Listener() { |
| 1074 |
// |
| 1075 |
// public void handleEvent(Event event) { |
| 1076 |
// editorList.setVisible(false); |
| 1077 |
// } |
| 1078 |
// }); |
| 1079 |
} |
| 1080 |
|
| 1081 |
/* |
| 1082 |
* Shows the list of tabs at the top left corner of the editor |
| 1083 |
*/ |
| 1084 |
protected void showListDefaultLocation() { |
| 1085 |
R21PaneFolder tabFolder = getPaneFolder(); |
| 1086 |
Shell shell = tabFolder.getControl().getShell(); |
| 1087 |
Rectangle clientArea = tabFolder.getClientArea(); |
| 1088 |
Point location = tabFolder.getControl().getDisplay().map( |
| 1089 |
tabFolder.getControl(), null, clientArea.x, clientArea.y); |
| 1090 |
showList(shell, location.x, location.y); |
| 1091 |
} |
| 1092 |
|
| 1093 |
void setSelection(CTabItem tabItem) { |
| 1094 |
getSite().selectPart(getPartForTab(tabItem)); |
| 1095 |
} |
| 1096 |
|
| 1097 |
void close(IPresentablePart presentablePart) { |
| 1098 |
getSite().close(new IPresentablePart[] { presentablePart }); |
| 1099 |
} |
| 1100 |
|
| 1101 |
Image getLabelImage(IPresentablePart presentablePart) { |
| 1102 |
return presentablePart.getTitleImage(); |
| 1103 |
} |
| 1104 |
|
| 1105 |
String getLabelText(IPresentablePart presentablePart, boolean includePath) { |
| 1106 |
String title = presentablePart.getTitle().trim(); |
| 1107 |
return title; |
| 1108 |
} |
| 1109 |
|
| 1110 |
/* |
| 1111 |
* (non-Javadoc) |
| 1112 |
* |
| 1113 |
* @see org.eclipse.ui.presentations.StackPresentation#setActive(int) |
| 1114 |
*/ |
| 1115 |
public void setActive(int newState) { |
| 1116 |
setActive(newState == AS_ACTIVE_FOCUS); |
| 1117 |
} |
| 1118 |
|
| 1119 |
/* |
| 1120 |
* (non-Javadoc) |
| 1121 |
* |
| 1122 |
* @see org.eclipse.ui.presentations.StackPresentation#restoreState(org.eclipse.ui.presentations.IPresentationSerializer, |
| 1123 |
* org.eclipse.ui.IMemento) |
| 1124 |
*/ |
| 1125 |
public void restoreState(IPresentationSerializer serializer, |
| 1126 |
IMemento savedState) { |
| 1127 |
IMemento[] parts = savedState.getChildren(IWorkbenchConstants.TAG_PART); |
| 1128 |
|
| 1129 |
for (int idx = 0; idx < parts.length; idx++) { |
| 1130 |
String id = parts[idx].getString(IWorkbenchConstants.TAG_ID); |
| 1131 |
|
| 1132 |
if (id != null) { |
| 1133 |
IPresentablePart part = serializer.getPart(id); |
| 1134 |
|
| 1135 |
if (part != null) { |
| 1136 |
addPart(part, getPaneFolder().getItemCount()); |
| 1137 |
} |
| 1138 |
} |
| 1139 |
} |
| 1140 |
} |
| 1141 |
|
| 1142 |
/* |
| 1143 |
* (non-Javadoc) |
| 1144 |
* |
| 1145 |
* @see org.eclipse.ui.presentations.StackPresentation#saveState(org.eclipse.ui.presentations.IPresentationSerializer, |
| 1146 |
* org.eclipse.ui.IMemento) |
| 1147 |
*/ |
| 1148 |
public void saveState(IPresentationSerializer context, IMemento memento) { |
| 1149 |
super.saveState(context, memento); |
| 1150 |
|
| 1151 |
List parts = getPresentableParts(); |
| 1152 |
|
| 1153 |
Iterator iter = parts.iterator(); |
| 1154 |
while (iter.hasNext()) { |
| 1155 |
IPresentablePart next = (IPresentablePart) iter.next(); |
| 1156 |
|
| 1157 |
IMemento childMem = memento |
| 1158 |
.createChild(IWorkbenchConstants.TAG_PART); |
| 1159 |
childMem.putString(IWorkbenchConstants.TAG_ID, context.getId(next)); |
| 1160 |
} |
| 1161 |
} |
| 1162 |
|
| 1163 |
/** |
| 1164 |
* Returns the List of IPresentablePart currently in this presentation |
| 1165 |
*/ |
| 1166 |
private List getPresentableParts() { |
| 1167 |
Assert.isTrue(!isDisposed()); |
| 1168 |
|
| 1169 |
CTabItem[] items = getPaneFolder().getItems(); |
| 1170 |
List result = new ArrayList(items.length); |
| 1171 |
|
| 1172 |
for (int idx = 0; idx < getPaneFolder().getItemCount(); idx++) { |
| 1173 |
result.add(getPartForTab(items[idx])); |
| 1174 |
} |
| 1056 |
|
1175 |
|
|
|
1176 |
return result; |
| 1177 |
} |
| 1057 |
} |
1178 |
} |