summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxwu2013-05-03 03:40:17 (EDT)
committerlzhu2013-05-03 03:40:17 (EDT)
commit3ad1da6db0d21a4ccaef50eaf53cea2f0c0b68a3 (patch)
treed77db8b27ea3e83cee4daf768c151a9ef03cc9e0
parentab3b7d6c508a1fbd7a535b5ad2c8d20cd02b45d8 (diff)
downloadorg.eclipse.datatools.connectivity-3ad1da6db0d21a4ccaef50eaf53cea2f0c0b68a3.zip
org.eclipse.datatools.connectivity-3ad1da6db0d21a4ccaef50eaf53cea2f0c0b68a3.tar.gz
org.eclipse.datatools.connectivity-3ad1da6db0d21a4ccaef50eaf53cea2f0c0b68a3.tar.bz2
Fix an issue - [Accessibility]Shortcut 'R' doesn't work for 'Browse'v201305031540
profile store when create connection profile datasource.[59635]
-rw-r--r--plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/browse/MenuButton.java901
-rw-r--r--plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/browse/ProfileStoreBrowseButton.java345
2 files changed, 634 insertions, 612 deletions
diff --git a/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/browse/MenuButton.java b/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/browse/MenuButton.java
index 5ddbf30..8ebb26f 100644
--- a/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/browse/MenuButton.java
+++ b/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/browse/MenuButton.java
@@ -1,440 +1,461 @@
-/*
- *************************************************************************
- * Copyright (c) 2011, 2012 Actuate Corporation.
- * 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 available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Actuate Corporation - initial API and implementation
- *
- *************************************************************************
- */
-
-package org.eclipse.datatools.connectivity.oda.design.internal.ui.profile.browse;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Menu;
-
-/**
- * Internal class for a button that contains menu items.
- * @since 3.2.6 (DTP 1.9.2)
- */
-public class MenuButton extends Composite
-{
- private Button button;
-
- private String text;
- private Image image;
-
- public String getText( )
- {
- return text;
- }
-
- public Image getImage( )
- {
- return image;
- }
-
- private static final int IMAGE_HEIGHT = 16, IMAGE_WIDTH = 16;
-
- private static int DRAW_FLAGS = SWT.DRAW_MNEMONIC
- | SWT.DRAW_TAB
- | SWT.DRAW_TRANSPARENT
- | SWT.DRAW_DELIMITER;
-
- private static final int MARGIN_GAP = 4;
-
- private static final int TRIANGLE_WIDTH = 5;
-
- private static final int WIDTH_MORE = 2 * MARGIN_GAP + TRIANGLE_WIDTH + 1;
-
- public void setText( String text )
- {
- this.text = text;
- layoutControl( );
- }
-
- private void layoutControl( )
- {
- getParent( ).layout( );
- button.redraw( );
- }
-
- private Point defaultSize = new Point( 0, 0 );
-
- public Point computeSize( int wHint, int hHint, boolean changed )
- {
- int width;
- int height;
-
- Button tmp = new Button( this, button.getStyle( ) );
- if ( text != null )
- {
- tmp.setText( text );
- height = tmp.computeSize( SWT.DEFAULT, SWT.DEFAULT ).y;
- }
- else
- {
- tmp.setText( "" ); //$NON-NLS-1$
- height = tmp.computeSize( SWT.DEFAULT, SWT.DEFAULT ).y;
- }
- if ( image != null )
- tmp.setImage( image );
- Point size = tmp.computeSize( SWT.DEFAULT, SWT.DEFAULT );
- tmp.dispose( );
-
- if ( menu != null )
- {
- width = size.x + WIDTH_MORE;
- }
- else
- width = size.x;
-
- if ( isFixed && image != null )
- {
- int imageWidth = image.getImageData( ).width;
- if ( imageWidth > IMAGE_WIDTH )
- width -= ( imageWidth - IMAGE_WIDTH );
-
- }
- if ( !isFixed )
- height = size.y;
- defaultSize = new Point( width, height );
- if ( wHint != SWT.DEFAULT )
- width = wHint;
- if ( hHint != SWT.DEFAULT )
- height = hHint;
-
- return new Point( width, height );
- }
-
- public void setImage( Image image )
- {
- this.image = image;
- layoutControl( );
- }
-
- public void setToolTipText( String toolTipText )
- {
- super.setToolTipText( toolTipText );
- button.setToolTipText( toolTipText );
- }
-
- public void setBackground( Color color )
- {
- super.setBackground( color );
- button.setBackground( color );
- button.redraw( );
- }
-
- public void setForeground( Color color )
- {
- super.setBackground( color );
- button.setForeground( color );
- button.redraw( );
- }
-
- public void setFont( Font font )
- {
- super.setFont( font );
- button.setFont( font );
- button.redraw( );
- }
-
- public void setEnabled( boolean enable )
- {
- super.setEnabled( enable );
- button.setEnabled( enable );
- button.redraw( );
- }
-
- public MenuButton( Composite parent, int style, String text )
- {
- this( parent, style, false, text );
- }
-
- private boolean isFixed = true;
-
- private boolean mouseSelection = false;
-
- public MenuButton( Composite parent, int style, boolean fixed, String text )
- {
- super( parent, SWT.NONE );
- isFixed = fixed;
- GridLayout layout = new GridLayout( );
- layout.marginHeight = layout.marginWidth = 0;
- this.setLayout( layout );
-
- button = new Button( this, style );
- GridData gd = new GridData( GridData.FILL_BOTH );
- this.setText(text);
- button.setLayoutData( gd );
- button.addPaintListener( new PaintListener( ) {
-
- public void paintControl( PaintEvent e )
- {
- MenuButton.this.paintControl( e );
- }
- } );
- button.addListener( SWT.MouseUp, new Listener( ) {
-
- public void handleEvent( Event e )
- {
- if ( !button.isEnabled( ) || e.button != 1 )
- return;
- mouseSelection = true;
- Rectangle size = button.getBounds( );
- if ( !size.contains( e.x, e.y ) )
- return;
- int left = WIDTH_MORE + MARGIN_GAP - 1;
- if ( menu == null )
- left = 0;
-
- if ( e.x < size.width - left )
- {
- if ( listeners == null )
- return;
-
- e.widget = MenuButton.this;
-
- for ( int i = 0; i < listeners.size( ); i++ )
- {
- ( (SelectionListener) listeners.get( i ) ).widgetSelected( new SelectionEvent( e ) );
- }
- }
- else
- {
- if ( menu != null )
- {
- menu.setLocation( button.toDisplay( new Point( 0,
- size.height - 1 ) ) );
- menu.setVisible( true );
- }
- }
- }
-
- } );
- button.addListener( SWT.KeyUp, new Listener( ) {
-
- public void handleEvent( Event e )
- {
- if ( e.keyCode == SWT.ARROW_DOWN || e.keyCode == SWT.ARROW_UP )
- {
- if ( menu != null )
- {
- Rectangle size = button.getBounds( );
- menu.setLocation( button.toDisplay( new Point( 0,
- size.height - 1 ) ) );
- menu.setVisible( true );
- }
- }
- }
-
- } );
- button.addListener( SWT.Selection, new Listener( ) {
-
- public void handleEvent( Event e )
- {
- if ( mouseSelection == true )
- {
- mouseSelection = false;
- return;
- }
-
- if ( listeners == null )
- return;
-
- // separate the mouse click from the key press event on the button
- boolean keyPress = false;
- if( e.widget instanceof Button )
- {
- if( ((Button)e.widget).getParent() instanceof MenuButton )
- {
- if ( menu != null )
- {
- keyPress = true;
- Rectangle size = button.getBounds( );
- menu.setLocation( button.toDisplay( new Point( 0,
- size.height - 1 ) ) );
- menu.setVisible( true );
- }
- }
- }
-
- if( !keyPress )
- {
- e.widget = MenuButton.this;
-
- for ( int i = 0; i < listeners.size( ); i++ )
- {
- ( (SelectionListener) listeners.get( i ) ).widgetSelected( new SelectionEvent( e ) );
- }
- }
- }
-
- } );
- }
-
- private Menu menu;
-
- public void setDropDownMenu( Menu menu )
- {
- this.menu = menu;
- }
-
- private List<SelectionListener> listeners;
-
- public void addSelectionListener( SelectionListener listener )
- {
- if ( listeners == null )
- listeners = new ArrayList<SelectionListener>( );
- listeners.add( listener );
- }
-
- public void removeSelectionListener( SelectionListener listener )
- {
- if ( listeners != null )
- {
- listeners.remove( listener );
- if ( listeners.size( ) == 0 )
- listeners = null;
- }
- }
-
- protected void paintControl( PaintEvent e )
- {
- e.gc.setFont( getFont( ) );
- Color fg = isEnabled( ) ? getForeground( )
- : new Color( e.gc.getDevice( ),
- UIUtil.blend( getBackground( ).getRGB( ),
- getForeground( ).getRGB( ),
- 70 ) );
- try
- {
- e.gc.setForeground( fg );
- Color bgColor = e.gc.getBackground( );
- e.gc.setBackground( e.gc.getForeground( ) );
- Rectangle size = button.getBounds( );
-
- if ( menu != null )
- {
- Rectangle rect = new Rectangle( size.width - 12,
- 0,
- TRIANGLE_WIDTH,
- size.height );
- UIUtil.drawArrow( e.gc, rect, SWT.DOWN );
- }
-
- e.gc.setBackground( bgColor );
-
- int height = e.gc.textExtent( "", DRAW_FLAGS ).y; //$NON-NLS-1$
-
- if ( !isFixed && image != null )
- {
- int imageHeight = image.getImageData( ).height;
- if ( height < imageHeight )
- height = imageHeight;
- }
-
- if ( defaultSize.y > size.height )
- {
- height = height - ( defaultSize.y - size.height );
- height = e.gc.textExtent( "", DRAW_FLAGS ).y > height ? e.gc.textExtent( "", //$NON-NLS-1$ //$NON-NLS-2$
- DRAW_FLAGS ).y
- : height;
- }
-
- int left = WIDTH_MORE + MARGIN_GAP - 1;
-
- if ( menu == null )
- left = MARGIN_GAP - 1;
-
- if ( menu != null )
- {
- Color fgColor = e.gc.getForeground( );
- e.gc.setForeground( getDisplay( ).getSystemColor( SWT.COLOR_WIDGET_NORMAL_SHADOW ) );
- e.gc.drawLine( size.width - left,
- ( size.height - height ) / 2,
- size.width - left,
- ( size.height - height ) / 2 + height );
- e.gc.setForeground( fgColor );
- }
-
- if ( text != null && text.trim( ).length( ) > 0 )
- {
- int width = e.gc.textExtent( text, DRAW_FLAGS ).x;
- int fontHeight = e.gc.textExtent( text, DRAW_FLAGS ).y;
- left += ( MARGIN_GAP + width );
- e.gc.drawText( text,
- ( size.width - left ) / 2 + MARGIN_GAP,
- ( size.height - fontHeight ) / 2,
- DRAW_FLAGS | SWT.DRAW_TRANSPARENT );
- }
-
- if ( image != null )
- {
- int imageWidth = image.getImageData( ).width;
- int imageHeight = image.getImageData( ).height;
-
- Image imageTemp;
-
- if ( isEnabled( ) )
- imageTemp = new Image( e.gc.getDevice( ),
- image,
- SWT.IMAGE_COPY );
- else
- imageTemp = new Image( e.gc.getDevice( ),
- image,
- SWT.IMAGE_DISABLE );
-
- if ( isFixed )
- {
- imageWidth = imageWidth > IMAGE_WIDTH ? IMAGE_WIDTH
- : imageWidth;
- imageHeight = imageHeight > IMAGE_HEIGHT ? IMAGE_HEIGHT
- : imageHeight;
- }
-
- left += ( MARGIN_GAP + imageWidth );
- e.gc.drawImage( imageTemp,
- 0,
- 0,
- imageTemp.getImageData( ).width,
- imageTemp.getImageData( ).height,
- ( size.width - left ) / 2 + MARGIN_GAP,
- Math.round( ( (float) ( size.height - imageHeight ) / 2 ) ),
- imageWidth,
- imageHeight );
-
- imageTemp.dispose( );
- }
- }
- finally
- {
- if ( !isEnabled( ) && fg != null )
- fg.dispose( );
- }
- }
-
-}
+/*
+ *************************************************************************
+ * Copyright (c) 2011, 2012 Actuate Corporation.
+ * 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 available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Actuate Corporation - initial API and implementation
+ *
+ *************************************************************************
+ */
+
+package org.eclipse.datatools.connectivity.oda.design.internal.ui.profile.browse;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Menu;
+
+/**
+ * Internal class for a button that contains menu items.
+ * @since 3.2.6 (DTP 1.9.2)
+ */
+public class MenuButton extends Composite
+{
+ private Button button;
+
+ private String text;
+ private Image image;
+
+ public String getText( )
+ {
+ return text;
+ }
+
+ public Image getImage( )
+ {
+ return image;
+ }
+
+ private static final int IMAGE_HEIGHT = 16, IMAGE_WIDTH = 16;
+
+ private static int DRAW_FLAGS = SWT.DRAW_MNEMONIC
+ | SWT.DRAW_TAB
+ | SWT.DRAW_TRANSPARENT
+ | SWT.DRAW_DELIMITER;
+
+ private static final int MARGIN_GAP = 4;
+
+ private static final int TRIANGLE_WIDTH = 5;
+
+ private static final int WIDTH_MORE = 2 * MARGIN_GAP + TRIANGLE_WIDTH + 1;
+
+ public void setText( String text )
+ {
+ this.text = text;
+ button.setText( "" ); //$NON-NLS-1$
+ layoutControl( );
+ }
+
+ public void setToolTipText( String string )
+ {
+ button.setToolTipText( string );
+ }
+
+ private void layoutControl( )
+ {
+ getParent( ).layout( );
+ button.redraw( );
+ }
+
+ private Point defaultSize = new Point( 0, 0 );
+
+ public Point computeSize( int wHint, int hHint, boolean changed )
+ {
+
+ int width;
+ int height;
+
+ Button tmp = new Button( this, button.getStyle( ) );
+ if ( text != null )
+ {
+ tmp.setText( text );
+ height = tmp.computeSize( SWT.DEFAULT, SWT.DEFAULT ).y;
+ }
+ else
+ {
+ tmp.setText( "" ); //$NON-NLS-1$
+ height = tmp.computeSize( SWT.DEFAULT, SWT.DEFAULT ).y;
+ }
+ if ( image != null )
+ tmp.setImage( image );
+ Point size = tmp.computeSize( SWT.DEFAULT, SWT.DEFAULT );
+ tmp.dispose( );
+
+ if ( menu != null )
+ {
+ width = size.x + WIDTH_MORE;
+ }
+ else
+ width = size.x;
+
+ if ( isFixed && image != null )
+ {
+ int imageWidth = image.getImageData( ).width;
+ if ( imageWidth > IMAGE_WIDTH )
+ width -= ( imageWidth - IMAGE_WIDTH );
+
+ }
+ if ( !isFixed )
+ height = size.y;
+ defaultSize = new Point( width, height );
+ if ( wHint != SWT.DEFAULT )
+ width = wHint;
+ if ( hHint != SWT.DEFAULT )
+ height = hHint;
+
+ return new Point( width, height );
+ }
+
+ public void setImage( Image image )
+ {
+ this.image = image;
+ layoutControl( );
+ }
+
+ public void setBackground( Color color )
+ {
+ super.setBackground( color );
+ button.setBackground( color );
+ button.redraw( );
+ }
+
+ public void setForeground( Color color )
+ {
+ super.setBackground( color );
+ button.setForeground( color );
+ button.redraw( );
+ }
+
+ public void setFont( Font font )
+ {
+ super.setFont( font );
+ button.setFont( font );
+ button.redraw( );
+ }
+
+ public void setEnabled( boolean enable )
+ {
+ super.setEnabled( enable );
+ button.setEnabled( enable );
+ button.redraw( );
+ }
+
+ public MenuButton( Composite parent, int style )
+ {
+ this( parent, style, false );
+ }
+
+ private boolean isFixed = true;
+
+ private boolean mouseSelection = false;
+
+ private boolean mouseDown = false;
+
+ public MenuButton( Composite parent, int style, boolean fixed )
+ {
+ super( parent, SWT.DOUBLE_BUFFERED );
+ isFixed = fixed;
+ GridLayout layout = new GridLayout( );
+ layout.marginHeight = layout.marginWidth = 0;
+ this.setLayout( layout );
+
+ button = new Button( this, style | SWT.DOUBLE_BUFFERED ){
+ protected void checkSubclass( )
+ {
+
+ }
+
+ public String getText( )
+ {
+ return MenuButton.this.getText( );
+ }
+ };
+ GridData gd = new GridData( GridData.FILL_BOTH );
+ button.setLayoutData( gd );
+ button.addPaintListener( new PaintListener( ) {
+
+ public void paintControl( final PaintEvent e )
+ {
+ MenuButton.this.paintControl( e );
+ }
+ } );
+
+ button.addListener( SWT.MouseUp, new Listener( ) {
+
+ public void handleEvent( Event e )
+ {
+ if ( !button.isEnabled( ) || e.button != 1 || !mouseDown )
+ return;
+ mouseDown = false;
+ mouseSelection = true;
+ Rectangle size = button.getBounds( );
+ if ( !size.contains( e.x, e.y ) )
+ return;
+ int left = WIDTH_MORE + MARGIN_GAP - 1;
+ if ( menu == null )
+ left = 0;
+
+ if ( e.x < size.width - left )
+ {
+ if ( listeners == null )
+ return;
+
+ e.widget = MenuButton.this;
+
+ for ( int i = 0; i < listeners.size( ); i++ )
+ {
+ ( (SelectionListener) listeners.get( i ) ).widgetSelected( new SelectionEvent( e ) );
+ }
+ }
+ else
+ {
+ if ( menu != null )
+ {
+ menu.setLocation( button.toDisplay( new Point( 0,
+ size.height - 1 ) ) );
+ menu.setVisible( true );
+ }
+ }
+ }
+
+ } );
+
+ button.addListener( SWT.MouseDown, new Listener( ) {
+
+ public void handleEvent( Event e )
+ {
+ if ( !button.isEnabled( ) || e.button != 1 )
+ return;
+ mouseSelection = true;
+ Rectangle size = button.getBounds( );
+ if ( !size.contains( e.x, e.y ) )
+ return;
+ mouseDown = true;
+ }
+
+ } );
+ button.addListener( SWT.KeyUp, new Listener( ) {
+
+ public void handleEvent( Event e )
+ {
+ if ( e.keyCode == SWT.ARROW_DOWN || e.keyCode == SWT.ARROW_UP )
+ {
+ if ( menu != null )
+ {
+ Rectangle size = button.getBounds( );
+ menu.setLocation( button.toDisplay( new Point( 0,
+ size.height - 1 ) ) );
+ menu.setVisible( true );
+ }
+ }
+ }
+
+ } );
+ button.addListener( SWT.Selection, new Listener( ) {
+
+ public void handleEvent( Event e )
+ {
+ if ( mouseSelection == true )
+ {
+ mouseSelection = false;
+ return;
+ }
+
+ if ( listeners == null )
+ return;
+
+ e.widget = MenuButton.this;
+
+ for ( int i = 0; i < listeners.size( ); i++ )
+ {
+ ( (SelectionListener) listeners.get( i ) ).widgetSelected( new SelectionEvent( e ) );
+ }
+ }
+
+ } );
+ }
+
+ private Menu menu;
+
+ public void setDropDownMenu( Menu menu )
+ {
+ this.menu = menu;
+ }
+
+ private List listeners;
+
+ public void addSelectionListener( SelectionListener listener )
+ {
+ if ( listeners == null )
+ listeners = new ArrayList( );
+ listeners.add( listener );
+ }
+
+ public void removeSelectionListener( SelectionListener listener )
+ {
+ if ( listeners != null )
+ {
+ listeners.remove( listener );
+ if ( listeners.size( ) == 0 )
+ listeners = null;
+ }
+ }
+
+ protected void paintControl( PaintEvent e )
+ {
+ e.gc.setFont( getFont( ) );
+ Color fg = isEnabled( ) ? getForeground( )
+ : new Color( e.gc.getDevice( ),
+ UIUtil.blend( getBackground( ).getRGB( ),
+ getForeground( ).getRGB( ),
+ 70 ) );
+ try
+ {
+ e.gc.setForeground( fg );
+ Color bgColor = e.gc.getBackground( );
+ e.gc.setBackground( e.gc.getForeground( ) );
+ Rectangle size = button.getBounds( );
+
+ if ( menu != null )
+ {
+ Rectangle rect = new Rectangle( size.width - 12,
+ 0,
+ TRIANGLE_WIDTH,
+ size.height );
+ UIUtil.drawArrow( e.gc, rect, SWT.DOWN );
+ }
+
+ e.gc.setBackground( bgColor );
+
+ int height = e.gc.textExtent( "", DRAW_FLAGS ).y; //$NON-NLS-1$
+
+ if ( !isFixed && image != null )
+ {
+ int imageHeight = image.getImageData( ).height;
+ if ( height < imageHeight )
+ height = imageHeight;
+ }
+
+ if ( defaultSize.y > size.height )
+ {
+ height = height - ( defaultSize.y - size.height );
+ height = e.gc.textExtent( "", DRAW_FLAGS ).y > height ? e.gc.textExtent( "", //$NON-NLS-1$ //$NON-NLS-2$
+ DRAW_FLAGS ).y
+ : height;
+ }
+
+ int left = WIDTH_MORE + MARGIN_GAP - 1;
+
+ if ( menu == null )
+ left = MARGIN_GAP - 1;
+
+ if ( menu != null )
+ {
+ Color fgColor = e.gc.getForeground( );
+ e.gc.setForeground( getDisplay( ).getSystemColor( SWT.COLOR_WIDGET_NORMAL_SHADOW ) );
+ e.gc.drawLine( size.width - left,
+ ( size.height - height ) / 2,
+ size.width - left,
+ ( size.height - height ) / 2 + height );
+ e.gc.setForeground( fgColor );
+ }
+
+ if ( text != null && text.trim( ).length( ) > 0 )
+ {
+ int width = e.gc.textExtent( text, DRAW_FLAGS ).x;
+ int fontHeight = e.gc.textExtent( text, DRAW_FLAGS ).y;
+ left += ( MARGIN_GAP + width );
+ e.gc.drawText( text,
+ ( size.width - left ) / 2 + MARGIN_GAP,
+ ( size.height - fontHeight ) / 2,
+ DRAW_FLAGS | SWT.DRAW_TRANSPARENT );
+ }
+
+ if ( image != null )
+ {
+ int imageWidth = image.getImageData( ).width;
+ int imageHeight = image.getImageData( ).height;
+
+ Image imageTemp = null;
+
+ if ( !isEnabled( ) )
+ imageTemp = new Image( e.gc.getDevice( ),
+ image,
+ SWT.IMAGE_DISABLE );
+
+ if ( isFixed )
+ {
+ imageWidth = imageWidth > IMAGE_WIDTH ? IMAGE_WIDTH
+ : imageWidth;
+ imageHeight = imageHeight > IMAGE_HEIGHT ? IMAGE_HEIGHT
+ : imageHeight;
+ }
+
+ left += ( MARGIN_GAP + imageWidth );
+ if ( !isEnabled( ) )
+ {
+ e.gc.drawImage( imageTemp,
+ 0,
+ 0,
+ imageTemp.getImageData( ).width,
+ imageTemp.getImageData( ).height,
+ ( size.width - left ) / 2 + MARGIN_GAP,
+ Math.round( ( (float) ( size.height - imageHeight ) / 2 ) ),
+ imageWidth,
+ imageHeight );
+
+ imageTemp.dispose( );
+ }
+ else
+ {
+ e.gc.drawImage( image,
+ 0,
+ 0,
+ image.getImageData( ).width,
+ image.getImageData( ).height,
+ ( size.width - left ) / 2 + MARGIN_GAP,
+ Math.round( ( (float) ( size.height - imageHeight ) / 2 ) ),
+ imageWidth,
+ imageHeight );
+ }
+ }
+
+ }
+ finally
+ {
+ if ( !isEnabled( ) && fg != null )
+ fg.dispose( );
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/browse/ProfileStoreBrowseButton.java b/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/browse/ProfileStoreBrowseButton.java
index 946d0f1..f6c4007 100644
--- a/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/browse/ProfileStoreBrowseButton.java
+++ b/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/profile/browse/ProfileStoreBrowseButton.java
@@ -1,172 +1,173 @@
-/*
- *************************************************************************
- * Copyright (c) 2011 Actuate Corporation.
- * 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 available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Actuate Corporation - initial API and implementation
- *
- *************************************************************************
- */
-
-package org.eclipse.datatools.connectivity.oda.design.internal.ui.profile.browse;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.MenuItem;
-import org.eclipse.swt.widgets.Widget;
-
-/**
- * Internal class for implementing a Browse button with two
- * menu items - one for browsing using a path relative to
- * the host resource folder, and the second one for
- * browsing using an absolute path.
- *
- * @since 3.2.6 (DTP 1.9.2)
- */
-public class ProfileStoreBrowseButton
-{
- private static final int BUTTON_MIN_WIDTH = 80;
-
- private MenuButton button;
- private Menu menu;
-
- private IMenuButtonProvider provider;
- private IBrowseButtonHost host;
-
- private SelectionAdapter listener = new SelectionAdapter( ) {
-
- public void widgetSelected( SelectionEvent e )
- {
- Widget widget = e.widget;
- host.browseSelected();
- if ( widget instanceof MenuItem )
- {
- provider.handleSelectionEvent( (String) widget.getData( ) );
- }
- else if ( widget instanceof MenuButton )
- {
- provider.handleSelectionEvent( ( (MenuButtonProvider) provider ).getDefaultOptionType( ) );
- }
- }
-
- };
-
- public ProfileStoreBrowseButton( Composite parent, int style,
- IMenuButtonProvider provider, IBrowseButtonHost host)
- {
- this.host = host;
- button = new MenuButton( parent, style, provider.getButtonText() );
- button.addSelectionListener( listener );
- button.addSelectionListener( new SelectionAdapter( ) {
-
- public void widgetSelected( SelectionEvent e )
- {
- refreshMenuItems( );
- }
-
- } );
-
- menu = new Menu( parent.getShell( ), SWT.POP_UP );
- button.setDropDownMenu( menu );
- button.setToolTipText( provider.getToolTipText() );
- setMenuButtonProvider( provider );
- refresh( );
- }
-
- public void setLayoutData(Object layoutData)
- {
- button.setLayoutData( layoutData );
- }
-
- public void refreshMenuItems( )
- {
- ( (MenuButtonProvider) this.provider ).resetProperties( );
- populateMenuItems( );
- }
-
- public void setEnabled( boolean enable )
- {
- button.setEnabled( enable );
- }
-
- public boolean isEnabled( )
- {
- return button.isEnabled( );
- }
-
- public MenuButton getControl( )
- {
- return button;
- }
-
- public IMenuButtonProvider getMenuButtonProvider()
- {
- return provider;
- }
-
- public void refresh( )
- {
- }
-
- public void setMenuButtonProvider( IMenuButtonProvider provider )
- {
- if ( provider != null && provider != this.provider )
- {
- this.provider = provider;
-
- provider.setInput( this );
-
- populateMenuItems( );
- }
- }
-
- private void populateMenuItems( )
- {
- for ( int i = 0; i < menu.getItemCount( ); i++ )
- {
- menu.getItem( i ).dispose( );
- i--;
- }
-
- String[] types = this.provider.getMenuItems( );
- for ( int i = 0; i < types.length; i++ )
- {
- MenuItem item = new MenuItem( menu, SWT.PUSH );
- item.setText( provider.getMenuItemText( types[i] ) );
- item.setData( types[i] );
- item.setImage( this.provider.getMenuItemImage( types[i] ) );
- item.addSelectionListener( listener );
- }
-
- if ( menu.getItemCount( ) <= 0 )
- {
- button.setDropDownMenu( null );
- }
- refresh( );
- }
-
- public void handleSelection( String path, boolean isRelative )
- {
- host.setProfileStorePath( path, isRelative);
- }
-
- public int computeButtonWidth( )
- {
- return computeButtonWidth(button);
- }
-
- static int computeButtonWidth( MenuButton button )
- {
- int defaultWidth = button.computeSize( SWT.DEFAULT, SWT.DEFAULT ).x;
- return ( defaultWidth < BUTTON_MIN_WIDTH ) ?
- BUTTON_MIN_WIDTH : defaultWidth;
- }
-
-}
+/*
+ *************************************************************************
+ * Copyright (c) 2011 Actuate Corporation.
+ * 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 available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Actuate Corporation - initial API and implementation
+ *
+ *************************************************************************
+ */
+
+package org.eclipse.datatools.connectivity.oda.design.internal.ui.profile.browse;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.swt.widgets.Widget;
+
+/**
+ * Internal class for implementing a Browse button with two
+ * menu items - one for browsing using a path relative to
+ * the host resource folder, and the second one for
+ * browsing using an absolute path.
+ *
+ * @since 3.2.6 (DTP 1.9.2)
+ */
+public class ProfileStoreBrowseButton
+{
+ private static final int BUTTON_MIN_WIDTH = 80;
+
+ private MenuButton button;
+ private Menu menu;
+
+ private IMenuButtonProvider provider;
+ private IBrowseButtonHost host;
+
+ private SelectionAdapter listener = new SelectionAdapter( ) {
+
+ public void widgetSelected( SelectionEvent e )
+ {
+ Widget widget = e.widget;
+ host.browseSelected();
+ if ( widget instanceof MenuItem )
+ {
+ provider.handleSelectionEvent( (String) widget.getData( ) );
+ }
+ else if ( widget instanceof MenuButton )
+ {
+ provider.handleSelectionEvent( ( (MenuButtonProvider) provider ).getDefaultOptionType( ) );
+ }
+ }
+
+ };
+
+ public ProfileStoreBrowseButton( Composite parent, int style,
+ IMenuButtonProvider provider, IBrowseButtonHost host)
+ {
+ this.host = host;
+ button = new MenuButton( parent, style );
+ button.addSelectionListener( listener );
+ button.addSelectionListener( new SelectionAdapter( ) {
+
+ public void widgetSelected( SelectionEvent e )
+ {
+ refreshMenuItems( );
+ }
+
+ } );
+
+ menu = new Menu( parent.getShell( ), SWT.POP_UP );
+ button.setDropDownMenu( menu );
+ button.setText( provider.getButtonText( ) );
+ button.setToolTipText( provider.getToolTipText() );
+ setMenuButtonProvider( provider );
+ refresh( );
+ }
+
+ public void setLayoutData(Object layoutData)
+ {
+ button.setLayoutData( layoutData );
+ }
+
+ public void refreshMenuItems( )
+ {
+ ( (MenuButtonProvider) this.provider ).resetProperties( );
+ populateMenuItems( );
+ }
+
+ public void setEnabled( boolean enable )
+ {
+ button.setEnabled( enable );
+ }
+
+ public boolean isEnabled( )
+ {
+ return button.isEnabled( );
+ }
+
+ public MenuButton getControl( )
+ {
+ return button;
+ }
+
+ public IMenuButtonProvider getMenuButtonProvider()
+ {
+ return provider;
+ }
+
+ public void refresh( )
+ {
+ }
+
+ public void setMenuButtonProvider( IMenuButtonProvider provider )
+ {
+ if ( provider != null && provider != this.provider )
+ {
+ this.provider = provider;
+
+ provider.setInput( this );
+
+ populateMenuItems( );
+ }
+ }
+
+ private void populateMenuItems( )
+ {
+ for ( int i = 0; i < menu.getItemCount( ); i++ )
+ {
+ menu.getItem( i ).dispose( );
+ i--;
+ }
+
+ String[] types = this.provider.getMenuItems( );
+ for ( int i = 0; i < types.length; i++ )
+ {
+ MenuItem item = new MenuItem( menu, SWT.PUSH );
+ item.setText( provider.getMenuItemText( types[i] ) );
+ item.setData( types[i] );
+ item.setImage( this.provider.getMenuItemImage( types[i] ) );
+ item.addSelectionListener( listener );
+ }
+
+ if ( menu.getItemCount( ) <= 0 )
+ {
+ button.setDropDownMenu( null );
+ }
+ refresh( );
+ }
+
+ public void handleSelection( String path, boolean isRelative )
+ {
+ host.setProfileStorePath( path, isRelative);
+ }
+
+ public int computeButtonWidth( )
+ {
+ return computeButtonWidth(button);
+ }
+
+ static int computeButtonWidth( MenuButton button )
+ {
+ int defaultWidth = button.computeSize( SWT.DEFAULT, SWT.DEFAULT ).x;
+ return ( defaultWidth < BUTTON_MIN_WIDTH ) ?
+ BUTTON_MIN_WIDTH : defaultWidth;
+ }
+
+}