1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482
|
#! /bin/sh -e
##
## DP: Enable the internal native presentation and add some
## DP: improvments(https://bugs.eclipse.org/bugs/show_bug.cgi?id=93806)
[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
if [ $# -ne 1 ]; then
echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
exit 1
fi
case "$1" in
-patch)
patch $patch_opts -p0 < $0;;
-unpatch)
patch $patch_opts -p0 -R < $0;;
*)
echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
exit 1;;
esac
exit 0
@DPATCH@
diff -r -u source-tree/plugins.orig/org.eclipse.ui/plugin.properties source-tree/plugins/org.eclipse.ui/plugin.properties
--- source-tree/plugins.orig/org.eclipse.ui/plugin.properties 2006-10-22 10:31:55.000000000 +0200
+++ source-tree/plugins/org.eclipse.ui/plugin.properties 2006-10-22 10:39:38.000000000 +0200
@@ -73,6 +73,7 @@
Presentation.default=View and Editor Folders
Presentation.default.desc=Colors and fonts used by the default Eclipse presentation.
Presentation.default.name=Default
+Presentation.native.name=Native presentation (experimental)
SystemSummary.sectionTitle.platform=Platform Details
diff -r -u source-tree/plugins.orig/org.eclipse.ui/plugin.xml source-tree/plugins/org.eclipse.ui/plugin.xml
--- source-tree/plugins.orig/org.eclipse.ui/plugin.xml 2006-10-22 10:31:55.000000000 +0200
+++ source-tree/plugins/org.eclipse.ui/plugin.xml 2006-10-22 10:39:33.000000000 +0200
@@ -1221,6 +1221,10 @@
class="org.eclipse.ui.presentations.WorkbenchPresentationFactory"
id="org.eclipse.ui.presentations.default">
</factory>
+ <factory
+ class="org.eclipse.ui.internal.presentations.defaultpresentation.NativePresentationFactory"
+ name="%Presentation.native.name"
+ id="org.eclipse.ui.internal.presentations.defaultpresentation.NativePresentationFactory"/>
</extension>
<extension
point="org.eclipse.ui.encodings">
diff -r -u source-tree/plugins.orig/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/NativePresentationFactory.java source-tree/plugins/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/NativePresentationFactory.java
--- source-tree/plugins.orig/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/NativePresentationFactory.java 2006-10-22 10:33:59.000000000 +0200
+++ source-tree/plugins/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/NativePresentationFactory.java 2006-10-22 10:41:23.000000000 +0200
@@ -30,7 +30,7 @@
*/
public StackPresentation createEditorPresentation(Composite parent,
IStackPresentationSite site) {
- return new TabbedStackPresentation(site, new NativeTabFolder(parent), new StandardEditorSystemMenu(site));
+ return new TabbedStackPresentation(site, new NativeTabFolder(parent, site), new StandardEditorSystemMenu(site));
}
/*
@@ -40,7 +40,7 @@
*/
public StackPresentation createViewPresentation(Composite parent,
IStackPresentationSite site) {
- return new TabbedStackPresentation(site, new NativeTabFolder(parent), new StandardViewSystemMenu(site));
+ return new TabbedStackPresentation(site, new NativeTabFolder(parent, site), new StandardViewSystemMenu(site));
}
/*
@@ -51,8 +51,7 @@
public StackPresentation createStandaloneViewPresentation(Composite parent,
IStackPresentationSite site, boolean showTitle) {
// TODO honour showTitle
- return new TabbedStackPresentation(site, new NativeTabFolder(parent),
- new StandardViewSystemMenu(site));
+ return new TabbedStackPresentation(site, new NativeTabFolder(parent, site), new StandardViewSystemMenu(site));
}
}
diff -r -u source-tree/plugins.orig/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/NativeTabFolder.java source-tree/plugins/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/NativeTabFolder.java
--- source-tree/plugins.orig/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/NativeTabFolder.java 2006-10-22 10:33:59.000000000 +0200
+++ source-tree/plugins/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/NativeTabFolder.java 2006-10-22 10:41:40.000000000 +0200
@@ -1,4 +1,4 @@
-/*******************************************************************************
+ /*******************************************************************************
* Copyright (c) 2004, 2005 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -10,75 +10,113 @@
*******************************************************************************/
package org.eclipse.ui.internal.presentations.defaultpresentation;
+import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.util.Geometry;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.custom.ViewForm;
+import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.TabFolder;
-import org.eclipse.swt.widgets.TabItem;
-import org.eclipse.swt.widgets.Widget;
+import org.eclipse.swt.widgets.*;
import org.eclipse.ui.IPropertyListener;
+import org.eclipse.ui.internal.*;
import org.eclipse.ui.internal.dnd.DragUtil;
import org.eclipse.ui.internal.layout.SizeCache;
-import org.eclipse.ui.internal.presentations.util.AbstractTabFolder;
-import org.eclipse.ui.internal.presentations.util.AbstractTabItem;
-import org.eclipse.ui.internal.presentations.util.PartInfo;
-import org.eclipse.ui.internal.presentations.util.ProxyControl;
-import org.eclipse.ui.internal.presentations.util.StandardSystemToolbar;
-import org.eclipse.ui.internal.presentations.util.TabFolderEvent;
+import org.eclipse.ui.internal.presentations.util.*;
import org.eclipse.ui.internal.util.Util;
+import org.eclipse.ui.presentations.*;
/**
* @since 3.1
*/
public class NativeTabFolder extends AbstractTabFolder {
- private TabFolder control;
+ private IStackPresentationSite site;
+ private TabFolder tabFolder;
private ViewForm viewForm;
- private StandardSystemToolbar systemToolbar;
private CLabel title;
+
+ private ToolBar viewToolBar;
+ private ToolItem menuButton;
+ private ToolItem closeButton;
+
private ProxyControl topCenter;
private SizeCache topCenterCache;
+ private IPreferenceStore preferenceStore = WorkbenchPlugin.getDefault().getPreferenceStore();
+
private Listener selectionListener = new Listener() {
public void handleEvent(Event e) {
fireEvent(TabFolderEvent.EVENT_TAB_SELECTED, getTab(e.item));
}
};
- private IPropertyListener systemToolbarListener = new IPropertyListener() {
-
- public void propertyChanged(Object source, int propId) {
- Point location;
+ /**
+ * @param parent
+ * @param site
+ */
+ public NativeTabFolder(Composite parent, final IStackPresentationSite site) {
+
+ this.site = site;
+
+ int tabPos = preferenceStore.getInt(IPreferenceConstants.VIEW_TAB_POSITION);
+
+ tabFolder = new TabFolder(parent, tabPos);
+ tabFolder.addListener(SWT.Selection, selectionListener);
+ attachListeners(tabFolder, false);
+
+ viewForm = new ViewForm(tabFolder, SWT.FLAT);
+ viewForm.setVisible(false);
+ attachListeners(viewForm, false);
+
+ addListener(new TabFolderListener() {
+ public void handleEvent(TabFolderEvent e) {
- if (propId == TabFolderEvent.EVENT_PANE_MENU) {
- location = getPaneMenuLocation();
- } else {
- location = new Point(0,0);
+ viewForm.setVisible(site.getPartList().length>0);
}
-
- fireEvent(propId, getSelection(), location);
- }
+ });
- };
-
- public NativeTabFolder(Composite parent) {
- control = new TabFolder(parent, SWT.BOTTOM);
- control.addListener(SWT.Selection, selectionListener);
- attachListeners(control, false);
+ viewToolBar = new ToolBar(viewForm, SWT.HORIZONTAL|SWT.FLAT);
+ viewForm.setTopRight(viewToolBar);
- viewForm = new ViewForm(control, SWT.FLAT);
- attachListeners(viewForm, false);
- systemToolbar = new StandardSystemToolbar(viewForm, true, false, true, true, true);
- systemToolbar.addListener(systemToolbarListener);
- viewForm.setTopRight(systemToolbar.getControl());
+ menuButton = new ToolItem(viewToolBar, SWT.PUSH);
+ menuButton.setDisabledImage(null); // TODO: comment this out?
+ // PR#1GE56QT - Avoid creation of unnecessary image.
+ menuButton.setImage(WorkbenchImages.getImage(IWorkbenchGraphicConstants.IMG_LCL_VIEW_MENU));
+ menuButton.setToolTipText("Menu"); //$NON-NLS-1$
+ menuButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ IPresentablePart part = site.getSelectedPart();
+ if (part == null)
+ return;
+
+ IPartMenu menu = part.getMenu();
+
+ if (menu != null) {
+ menu.showMenu(getPaneMenuLocation());
+ }
+ }
+ });
+
+ closeButton = new ToolItem(viewToolBar, SWT.PUSH);
+ closeButton.setDisabledImage(null); // TODO: comment this out?
+ // PR#1GE56QT - Avoid creation of unnecessary image.
+ closeButton.setImage(WorkbenchImages.getImage(IWorkbenchGraphicConstants.IMG_LCL_CLOSE_VIEW));
+ closeButton.setToolTipText("Close"); //$NON-NLS-1$
+ closeButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ IPresentablePart part = site.getSelectedPart();
+ if (part == null)
+ return;
+
+ fireEvent(TabFolderEvent.EVENT_CLOSE);
+ if (part != null) {
+ site.close(new IPresentablePart[] { part });
+ }
+ }
+ });
topCenter = new ProxyControl(viewForm);
topCenterCache = new SizeCache();
@@ -112,7 +150,7 @@
super.layout(flushCache);
Rectangle oldBounds = viewForm.getBounds();
- Rectangle newBounds = control.getClientArea();
+ Rectangle newBounds = tabFolder.getClientArea();
viewForm.setBounds(newBounds);
@@ -125,16 +163,8 @@
* @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#getPaneMenuLocation()
*/
public Point getPaneMenuLocation() {
- return systemToolbar.getPaneMenuLocation();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#setState(int)
- */
- public void setState(int state) {
- super.setState(state);
-
- systemToolbar.setState(state);
+ Rectangle bounds = DragUtil.getDisplayBounds(viewToolBar);
+ return new Point(bounds.x, bounds.y + bounds.height);
}
/* (non-Javadoc)
@@ -147,14 +177,14 @@
return new Rectangle(0,0,0,0);
}
- return Geometry.toControl(control, DragUtil.getDisplayBounds(content));
+ return Geometry.toControl(tabFolder, DragUtil.getDisplayBounds(content));
}
/* (non-Javadoc)
* @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#getItems()
*/
public AbstractTabItem[] getItems() {
- TabItem[] items = control.getItems();
+ TabItem[] items = tabFolder.getItems();
AbstractTabItem[] result = new AbstractTabItem[items.length];
@@ -183,18 +213,15 @@
}
NativeTabItem tab = (NativeTabItem) toSelect;
- control.setSelection(new TabItem[] {(TabItem)tab.getWidget()});
+ tabFolder.setSelection(new TabItem[] {(TabItem)tab.getWidget()});
}
/* (non-Javadoc)
* @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#setSelectedInfo(org.eclipse.ui.internal.presentations.util.PartInfo)
*/
public void setSelectedInfo(PartInfo info) {
- if (!Util.equals(title.getText(), info.title)) {
- title.setText(info.title);
- }
- if (title.getImage() != info.image) {
- title.setImage(info.image);
+ if (!Util.equals(title.getText(), info.contentDescription)) {
+ title.setText(info.contentDescription);
}
}
/* (non-Javadoc)
@@ -209,15 +236,15 @@
*/
public Rectangle getTabArea() {
- Rectangle bounds = control.getBounds();
+ Rectangle bounds = tabFolder.getBounds();
- Rectangle clientArea = control.getClientArea();
+ Rectangle clientArea = tabFolder.getClientArea();
bounds.x = 0;
bounds.y = 0;
Geometry.expand(bounds, 0, 0, - (clientArea.height + clientArea.y), 0);
- return Geometry.toDisplay(control.getParent(), bounds);
+ return Geometry.toDisplay(tabFolder.getParent(), bounds);
}
/* (non-Javadoc)
@@ -239,7 +266,7 @@
}
public Control getControl() {
- return control;
+ return tabFolder;
}
/* (non-Javadoc)
@@ -253,7 +280,7 @@
}
public AbstractTabItem getSelection() {
- TabItem[] sel = control.getSelection();
+ TabItem[] sel = tabFolder.getSelection();
if (sel.length == 0) {
return null;
@@ -262,6 +289,15 @@
return getTab(sel[0]);
}
+ private TabItem getSelectedTabItem() {
+ WidgetTabItem selection = (WidgetTabItem)getSelection();
+
+ if (selection==null)
+ return null;
+
+ return (TabItem)selection.getWidget();
+ }
+
/* (non-Javadoc)
* @see org.eclipse.ui.internal.presentations.util.AbstractTabFolder#getContentParent()
*/
@@ -281,16 +317,15 @@
* @since 3.1
*/
public TabFolder getTabFolder() {
- return control;
+ return tabFolder;
}
/**
- * @param item
* @param newTitle
* @since 3.1
*/
/* protected */ void setSelectedTitle(String newTitle) {
- title.setText(newTitle);
+ getSelectedTabItem().setText(newTitle);
}
/**
@@ -298,7 +333,7 @@
* @since 3.1
*/
/* protected */ void setSelectedImage(Image image) {
- title.setImage(image);
+ getSelectedTabItem().setImage(image);
}
/* (non-Javadoc)
@@ -313,6 +348,6 @@
* @since 3.1
*/
public void enablePaneMenu(boolean enabled) {
- systemToolbar.enablePaneMenu(enabled);
+ menuButton.setEnabled(enabled);
}
}
Nur in source-tree/plugins/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation: NativeTabFolder.java.rej.
diff -r -u source-tree/plugins.orig/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/NativeTabItem.java source-tree/plugins/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/NativeTabItem.java
--- source-tree/plugins.orig/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/NativeTabItem.java 2006-10-22 10:33:59.000000000 +0200
+++ source-tree/plugins/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/NativeTabItem.java 2006-10-22 10:41:40.000000000 +0200
@@ -22,6 +22,10 @@
*/
public class NativeTabItem extends WidgetTabItem {
+ /**
+ * @param parent
+ * @param index
+ */
public NativeTabItem(NativeTabFolder parent, int index) {
super(new TabItem(parent.getTabFolder(), SWT.NONE, index));
}
@@ -32,13 +36,19 @@
public Rectangle getBounds() {
return new Rectangle(0,0,0,0);
}
-
+
public void setInfo(PartInfo info) {
TabItem widget = (TabItem) getWidget();
- if (!Util.equals(widget.getText(), info.name)) {
- widget.setText(info.name);
+ String name = getLabelText(info, false, false);
+ if (!Util.equals(widget.getText(), name)) {
+ widget.setText(name);
+ }
+
+ if (!Util.equals(widget.getImage(), info.image)) {
+ widget.setImage(info.image);
}
+
String oldToolTip = Util.safeString(widget.getToolTipText());
if (!Util.equals(info.toolTip, oldToolTip)) {
@@ -48,5 +58,47 @@
}
widget.setToolTipText(toolTip);
}
+ }
+
+ /**
+ * Returns the label text that should be used for the tab item for the
+ * specified part
+ *
+ * @param info
+ * @param dirtyLeft
+ * @param includePath
+ * @return a formated label text
+ */
+ private static String getLabelText(PartInfo info, boolean dirtyLeft, boolean includePath) {
+ String title = info.name.trim();
+ String text = title;
+
+ if (includePath) {
+ String titleTooltip = info.toolTip.trim();
+
+ if (titleTooltip.endsWith(title))
+ titleTooltip = titleTooltip.substring(0,
+ titleTooltip.lastIndexOf(title)).trim();
+
+ if (titleTooltip.endsWith("\\")) //$NON-NLS-1$
+ titleTooltip = titleTooltip.substring(0,
+ titleTooltip.lastIndexOf("\\")).trim(); //$NON-NLS-1$
+
+ if (titleTooltip.endsWith("/")) //$NON-NLS-1$
+ titleTooltip = titleTooltip.substring(0,
+ titleTooltip.lastIndexOf("/")).trim(); //$NON-NLS-1$
+
+ if (titleTooltip.length() >= 1)
+ text += " - " + titleTooltip; //$NON-NLS-1$
+ }
+
+ if (info.dirty) {
+ if (dirtyLeft)
+ text = "* " + text; //$NON-NLS-1$
+ else
+ text = text + " *"; //$NON-NLS-1$
+ }
+
+ return text;
}
}
|