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 179934 Details for
Bug 326159
[design] click on part toolbar needs two clicks on an inactive part
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]
Updated patch
ViewToolbar.patch (text/plain), 13.63 KB, created by
Ivan Furnadjiev
on 2010-09-30 04:57:26 EDT
(
hide
)
Description:
Updated patch
Filename:
MIME Type:
Creator:
Ivan Furnadjiev
Created:
2010-09-30 04:57:26 EDT
Size:
13.63 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.rap.design.example >Index: src/org/eclipse/rap/internal/design/example/managers/ViewToolBarManager.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.design.example/src/org/eclipse/rap/internal/design/example/managers/ViewToolBarManager.java,v >retrieving revision 1.8 >diff -u -r1.8 ViewToolBarManager.java >--- src/org/eclipse/rap/internal/design/example/managers/ViewToolBarManager.java 9 Sep 2010 15:36:05 -0000 1.8 >+++ src/org/eclipse/rap/internal/design/example/managers/ViewToolBarManager.java 30 Sep 2010 08:56:57 -0000 >@@ -1,4 +1,4 @@ >-/******************************************************************************* >+/******************************************************************************* > * Copyright (c) 2008, 2010 EclipseSource and others. All rights reserved. This > * program and the accompanying materials are made available under the terms of > * the Eclipse Public License v1.0 which accompanies this distribution, and is >@@ -6,91 +6,83 @@ > * > * Contributors: > * EclipseSource - initial API and implementation >-*******************************************************************************/ >+*******************************************************************************/ > package org.eclipse.rap.internal.design.example.managers; > > import java.util.ArrayList; > import java.util.Iterator; >-import java.util.List; >- > import org.eclipse.jface.action.IContributionItem; > import org.eclipse.jface.internal.provisional.action.ToolBarManager2; > import org.eclipse.rwt.lifecycle.WidgetUtil; > import org.eclipse.swt.SWT; > import org.eclipse.swt.widgets.Composite; > import org.eclipse.swt.widgets.Control; >-import org.eclipse.swt.widgets.Menu; > import org.eclipse.swt.widgets.ToolBar; > import org.eclipse.swt.widgets.ToolItem; > > > public class ViewToolBarManager extends ToolBarManager2 { >- >- private static final String STYLING_VARIANT = "viewToolbar"; //$NON-NLS-1$ >- private ToolBar toolBar; >- private ToolBar fakeToolbar; > >+ private static final String STYLING_VARIANT = "viewToolbar"; //$NON-NLS-1$ >+ private ToolBar fakeToolBar; > >- public ToolBar createControl(Composite parent) { >+ public ToolBar createControl( final Composite parent ) { >+ ToolBar toolBar = getControl(); > if( !toolBarExist() && parent != null ) { >- toolBar = new ToolBar( parent, SWT.NONE ); >+ fakeToolBar = new ToolBar( parent, SWT.NONE ); >+ fakeToolBar.setVisible( false ); >+ toolBar = super.createControl( parent ); > toolBar.setData( WidgetUtil.CUSTOM_VARIANT, STYLING_VARIANT ); >- toolBar.setMenu( getContextMenuControl() ); >- // create the fake Toolbar >- fakeToolbar = new ToolBar( parent, SWT.NONE ); >- fakeToolbar.setVisible( false ); >- update( true ); > } > return toolBar; > } >- >- public ToolBar getControl() { >- return toolBar; >- } >- >- private Menu getContextMenuControl() { >- Menu result = null; >- if( ( getContextMenuManager() != null ) && ( toolBar != null ) ) { >- Menu menuWidget = getContextMenuManager().getMenu(); >- if( ( menuWidget == null ) || ( menuWidget.isDisposed() ) ) { >- menuWidget = getContextMenuManager().createContextMenu( toolBar); >- } >- result = menuWidget; >+ >+ public void dispose() { >+ super.dispose(); >+ if( fakeToolBar != null ) { >+ fakeToolBar.dispose(); >+ fakeToolBar = null; > } >- return result; >- } >- >- private boolean toolBarExist() { >- return toolBar != null && !toolBar.isDisposed(); > } >- >- /* >- * (non-Javadoc) Method declared on IContributionManager. >- */ >- public void update( boolean force ) { >+ >+ public void update( final boolean force ) { > if( isDirty() || force ) { > if( toolBarExist() ) { >- >- // clean contains all active items without separators >+ ToolBar toolBar = getControl(); >+ // clean contains all active items without double separators > IContributionItem[] items = getItems(); >- ArrayList clean = new ArrayList( items.length ); >+ ArrayList clean = new ArrayList(items.length); >+ IContributionItem separator = null; > for( int i = 0; i < items.length; ++i ) { > IContributionItem ci = items[ i ]; >- if( !ci.isSeparator() ) { >+ if( ci.isSeparator() ) { >+ separator = ci; >+ } else { >+ if( separator != null ) { >+ if( clean.size() > 0 ) { >+ clean.add( separator ); >+ } >+ separator = null; >+ } > clean.add( ci ); > } > } > // determine obsolete items (removed or non active) > ToolItem[] mi = toolBar.getItems(); >- ArrayList toRemove = new ArrayList(); >+ ArrayList toRemove = new ArrayList( mi.length ); > for( int i = 0; i < mi.length; i++ ) { >- toRemove.add( mi[ i ] ); >- } >- // add fake toolbar items to the items to remove >- for( int i = 0; i < fakeToolbar.getItemCount(); i++ ) { >- toRemove.add( fakeToolbar.getItem( i ) ); >+ // there may be null items in a toolbar >+ if( mi[ i ] == null ) { >+ continue; >+ } >+ Object data = mi[ i ].getData(); >+ if( data == null >+ || !clean.contains( data ) >+ || ( data instanceof IContributionItem && ( ( IContributionItem ) data) >+ .isDynamic() ) ) { >+ toRemove.add( mi[ i ] ); >+ } > } >- > // Turn redraw off if the number of items to be added > // is above a certain threshold, to minimize flicker, > // otherwise the toolbar can be seen to redraw after each item. >@@ -102,10 +94,9 @@ > if( useRedraw ) { > toolBar.setRedraw( false ); > } >- > // remove obsolete items >- for( int i = toRemove.size(); --i >= 0; ) { >- ToolItem item = ( ToolItem ) toRemove.get(i); >+ for (int i = toRemove.size(); --i >= 0;) { >+ ToolItem item = ( ToolItem )toRemove.get( i ); > if( !item.isDisposed() ) { > Control ctrl = item.getControl(); > if( ctrl != null ) { >@@ -115,55 +106,38 @@ > item.dispose(); > } > } >- > // add new items > IContributionItem src, dest; > mi = toolBar.getItems(); > int srcIx = 0; >- int destIx = 0; >- >+ int destIx = 0; > for( Iterator e = clean.iterator(); e.hasNext(); ) { > src = ( IContributionItem )e.next(); >- > // get corresponding item in SWT widget > if( srcIx < mi.length ) { >- dest = ( IContributionItem ) mi[ srcIx ].getData(); >+ dest = ( IContributionItem )mi[ srcIx ].getData(); > } else { > dest = null; > } >- > if( dest != null && src.equals( dest ) ) { > srcIx++; > destIx++; > continue; > } >- >- if( dest != null && dest.isSeparator() >- && src.isSeparator() ) >- { >+ if( dest != null && dest.isSeparator() && src.isSeparator() ) { > mi[ srcIx ].setData( src ); > srcIx++; > destIx++; > continue; > } >- >- // fill item if visible, if not fill it into the fake toolbar >- ToolBar tempToolBar = null; >- if( src.isVisible() ) { >- src.fill( toolBar, destIx ); >- tempToolBar = toolBar; >- } else { >- src.fill( fakeToolbar, destIx ); >- tempToolBar = fakeToolbar; >- } >- // check necessary for bug 306741 >- if( destIx >= 0 && destIx < tempToolBar.getItemCount() - 1 ) { >- ToolItem toolItem = tempToolBar.getItem( destIx ); >- toolItem.setData( src ); >- toolItem.setData( WidgetUtil.CUSTOM_VARIANT, STYLING_VARIANT ); >+ int start = toolBar.getItemCount(); >+ src.fill( toolBar, destIx ); >+ int newItems = toolBar.getItemCount() - start; >+ for( int i = 0; i < newItems; i++ ) { >+ ToolItem item = toolBar.getItem( destIx++ ); >+ item.setData( src ); > } > } >- > // remove any old tool items not accounted for > for( int i = mi.length; --i >= srcIx; ) { > ToolItem item = mi[ i ]; >@@ -176,8 +150,9 @@ > item.dispose(); > } > } >- >- setDirty( false ); >+ setDirty(false); >+ updateFakeToolBar(); >+ disposeInvisibleItems(); > } finally { > // turn redraw back on if we turned it off above > if( useRedraw ) { >@@ -187,16 +162,51 @@ > } > } > } >- >- public List getToolItems() { >- List result = new ArrayList(); >- for( int i = 0; i < toolBar.getItemCount(); i++ ) { >- result.add( toolBar.getItem( i ) ); >+ >+ public ToolItem[] getToolItems() { >+ return fakeToolBar.getItems(); >+ } >+ >+ private boolean toolBarExist() { >+ ToolBar toolBar = getControl(); >+ return toolBar != null && !toolBar.isDisposed(); >+ } >+ >+ private void updateFakeToolBar() { >+ ToolBar toolBar = getControl(); >+ ToolItem[] items = fakeToolBar.getItems(); >+ for( int i = 0; i < items.length; i++ ) { >+ items[ i ].dispose(); > } >- for( int i = 0; i < fakeToolbar.getItemCount(); i++ ) { >- result.add( fakeToolbar.getItem( i ) ); >+ items = toolBar.getItems(); >+ for( int i = 0; i < items.length; i++ ) { >+ ToolItem item = new ToolItem( fakeToolBar, items[ i ].getStyle() ); >+ item.setText( items[ i ].getText() ); >+ item.setToolTipText( items[ i ].getToolTipText() ); >+ item.setImage( items[ i ].getImage() ); >+ item.setData( items[ i ].getData() ); > } >- return result; > } > >+ private void disposeInvisibleItems() { >+ ToolBar toolBar = getControl(); >+ ToolItem[] items = toolBar.getItems(); >+ for( int i = 0; i < items.length; i++ ) { >+ ToolItem item = items[ i ]; >+ if( !item.isDisposed() ) { >+ Object data = item.getData(); >+ if( data instanceof IContributionItem ) { >+ IContributionItem itemData = ( IContributionItem )data; >+ if( !itemData.isVisible() ) { >+ Control ctrl = item.getControl(); >+ if( ctrl != null ) { >+ item.setControl( null ); >+ ctrl.dispose(); >+ } >+ item.dispose(); >+ } >+ } >+ } >+ } >+ } > } >Index: src/org/eclipse/rap/internal/design/example/stacks/ConfigurationDialog.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.design.example/src/org/eclipse/rap/internal/design/example/stacks/ConfigurationDialog.java,v >retrieving revision 1.10 >diff -u -r1.10 ConfigurationDialog.java >--- src/org/eclipse/rap/internal/design/example/stacks/ConfigurationDialog.java 9 Sep 2010 15:36:05 -0000 1.10 >+++ src/org/eclipse/rap/internal/design/example/stacks/ConfigurationDialog.java 30 Sep 2010 08:56:57 -0000 >@@ -112,7 +112,7 @@ > = ( ConfigurableStack ) action.getStackPresentation(); > IToolBarManager manager = stackPresentation.getPartToolBarManager(); > if( manager != null ) { >- manager.update( true ); >+ manager.update( true ); > } > action.fireToolBarChange(); > return super.close(); >@@ -161,7 +161,7 @@ > fdOK.width = 90; > ok.addSelectionListener( new SelectionAdapter() { > public void widgetSelected( final SelectionEvent e ) { >- close( true ); >+ close( true ); > }; > } ); > ok.moveAbove( cancel ); >@@ -209,12 +209,12 @@ > String paneId = stackPresentation.getPaneId( site ); > if( manager instanceof ViewToolBarManager ) { > //manager.update( true ); >- List toolItems = ( ( ViewToolBarManager) manager ).getToolItems(); >- for( int i = 0; i < toolItems.size(); i++ ) { >- ToolItem item = ( ToolItem ) toolItems.get( i ); >+ ToolItem[] toolItems = ( ( ViewToolBarManager) manager ).getToolItems(); >+ for( int i = 0; i < toolItems.length; i++ ) { >+ ToolItem item = toolItems[ i ]; > if( item != null && !item.isDisposed() ) { > // handle parameter >- IContributionItem contribItem >+ IContributionItem contribItem > = ( IContributionItem ) item.getData(); > String itemId = contribItem.getId(); > Image icon = item.getImage(); >@@ -224,7 +224,7 @@ > } else { > text = item.getToolTipText(); > } >- >+ > // render the dialog > Label imageLabel = new Label( container, SWT.NONE ); > imageLabel.setImage( icon ); >@@ -238,7 +238,7 @@ > lastImageLabel = imageLabel; > } > fdImageLabel.left = new FormAttachment( 0, OFFSET * 4 ); >- >+ > Button check = new Button( container, SWT.CHECK ); > check.setText( text ); > check.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); >@@ -259,12 +259,12 @@ > } > } > >- public int open() { >+ public int open() { > int result = super.open(); > Shell shell = getShell(); > shell.setData( WidgetUtil.CUSTOM_VARIANT, "confDialog" ); //$NON-NLS-1$ > shell.setBackgroundMode( SWT.INHERIT_NONE ); >- shell.setText( Messages.get().ConfigurationDialog_ConfigurationFor >+ shell.setText( Messages.get().ConfigurationDialog_ConfigurationFor > + site.getSelectedPart().getName() ); > String configDialogIcon = ILayoutSetConstants.CONFIG_DIALOG_ICON; > shell.setImage( builder.getImage( configDialogIcon ) );
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 326159
:
179930
| 179934