Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 24274 Details for
Bug 93806
[PresentationAPI] Improve the presentation examples
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch to improve the example with the native tabs
org.eclipse.ui.workbench-patch.diff (text/plain), 10.58 KB, created by
Stephan Michels
on 2005-07-01 13:43:39 EDT
(
hide
)
Description:
Patch to improve the example with the native tabs
Filename:
MIME Type:
Creator:
Stephan Michels
Created:
2005-07-01 13:43:39 EDT
Size:
10.58 KB
patch
obsolete
>Index: Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/NativePresentationFactory.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/NativePresentationFactory.java,v >retrieving revision 1.4 >diff -u -r1.4 NativePresentationFactory.java >--- Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/NativePresentationFactory.java 15 Jun 2005 18:41:21 -0000 1.4 >+++ Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/NativePresentationFactory.java 1 Jul 2005 17:37:06 -0000 >@@ -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)); > } > > } >Index: Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/NativeTabFolder.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/NativeTabFolder.java,v >retrieving revision 1.7 >diff -u -r1.7 NativeTabFolder.java >--- Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/NativeTabFolder.java 15 Jun 2005 18:41:21 -0000 1.7 >+++ Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/NativeTabFolder.java 1 Jul 2005 17:37:07 -0000 >@@ -10,43 +10,43 @@ > *******************************************************************************/ > 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 IStackPresentationSite site; > private TabFolder control; > 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 static final String FULL_TITLE = "part_title"; //$NON-NLS-1$ > > private Listener selectionListener = new Listener() { >@@ -71,16 +71,58 @@ > > }; > >- public NativeTabFolder(Composite parent) { >- control = new TabFolder(parent, SWT.BOTTOM); >+ public NativeTabFolder(Composite parent, final IStackPresentationSite site) { >+ >+ this.site = site; >+ >+ int tabPos = preferenceStore.getInt(IPreferenceConstants.VIEW_TAB_POSITION); >+ >+ control = new TabFolder(parent, tabPos); > control.addListener(SWT.Selection, selectionListener); > attachListeners(control, false); > > 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()); >+ >+ viewToolBar = new ToolBar(viewForm, SWT.HORIZONTAL|SWT.FLAT); >+ viewForm.setTopRight(viewToolBar); >+ >+ 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(); >@@ -127,16 +169,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) >@@ -192,11 +226,8 @@ > * @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) >@@ -264,6 +295,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() > */ >@@ -292,7 +332,7 @@ > * @since 3.1 > */ > /* protected */ void setSelectedTitle(String newTitle) { >- title.setText(newTitle); >+ getSelectedTabItem().setText(newTitle); > } > > /** >@@ -300,7 +340,7 @@ > * @since 3.1 > */ > /* protected */ void setSelectedImage(Image image) { >- title.setImage(image); >+ getSelectedTabItem().setImage(image); > } > > /* (non-Javadoc) >@@ -315,6 +355,6 @@ > * @since 3.1 > */ > public void enablePaneMenu(boolean enabled) { >- systemToolbar.enablePaneMenu(enabled); >+ menuButton.setEnabled(enabled); > } > } >Index: Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/NativeTabItem.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/NativeTabItem.java,v >retrieving revision 1.5 >diff -u -r1.5 NativeTabItem.java >--- Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/NativeTabItem.java 15 Jun 2005 18:41:21 -0000 1.5 >+++ Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/NativeTabItem.java 1 Jul 2005 17:37:07 -0000 >@@ -39,6 +39,11 @@ > if (!Util.equals(widget.getText(), info.name)) { > widget.setText(info.name); > } >+ >+ if (!Util.equals(widget.getImage(), info.image)) { >+ widget.setImage(info.image); >+ } >+ > String oldToolTip = Util.safeString(widget.getToolTipText()); > > if (!Util.equals(info.toolTip, oldToolTip)) {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 93806
:
24274
|
24275
|
24347