|
Lines 117-142
Link Here
|
| 117 |
break; |
117 |
break; |
| 118 |
} |
118 |
} |
| 119 |
|
119 |
|
| 120 |
Composite parent = control; |
120 |
Composite parent = control; |
| 121 |
Menu menu = null; |
121 |
if( flags == SWT.DROP_DOWN ) { |
| 122 |
// pulldown |
|
|
| 123 |
if( flags == SWT.DROP_DOWN && item instanceof CommandContributionItem ) { |
| 124 |
CommandContributionItem commandItem = ( CommandContributionItem ) item; |
| 125 |
CommandParameter param |
| 126 |
= CommandUtil.extractCommandInformation( commandItem, control ); |
| 127 |
if( param.getMenu() != null ) { |
| 128 |
menu = param.getMenu(); |
| 129 |
} |
| 130 |
} else if( action instanceof WWinPluginPulldown ) { |
| 131 |
WWinPluginPulldown pulldown = ( WWinPluginPulldown ) action; |
| 132 |
menu = pulldown.getMenuCreator().getMenu( control ); |
| 133 |
} else if( action instanceof IMenuCreator ) { |
| 134 |
IMenuCreator creator = ( IMenuCreator ) action; |
| 135 |
menu = creator.getMenu( control ); |
| 136 |
} else if( action instanceof IWorkbenchWindowPulldownDelegate ) { |
| 137 |
System.out.println("pull"); |
| 138 |
} |
| 139 |
if( menu != null ) { |
| 140 |
final Composite pulldownParent = getPulldownParent(); |
122 |
final Composite pulldownParent = getPulldownParent(); |
| 141 |
parent = pulldownParent; |
123 |
parent = pulldownParent; |
| 142 |
flags = SWT.PUSH; |
124 |
flags = SWT.PUSH; |
|
Lines 165-171
Link Here
|
| 165 |
} |
147 |
} |
| 166 |
} ); |
148 |
} ); |
| 167 |
// pulldown |
149 |
// pulldown |
| 168 |
if( menu != null ) { |
150 |
if( action.getStyle() == SWT.DROP_DOWN ) { |
| 169 |
FormData fdButton = new FormData(); |
151 |
FormData fdButton = new FormData(); |
| 170 |
button.setLayoutData( fdButton ); |
152 |
button.setLayoutData( fdButton ); |
| 171 |
fdButton.left = new FormAttachment( 0 ); |
153 |
fdButton.left = new FormAttachment( 0 ); |
|
Lines 180-192
Link Here
|
| 180 |
Image image = builder.getImage( StackInitializer.VIEW_PULLDOWN ); |
162 |
Image image = builder.getImage( StackInitializer.VIEW_PULLDOWN ); |
| 181 |
arrow.setImage( image ); |
163 |
arrow.setImage( image ); |
| 182 |
arrow.setData( WidgetUtil.CUSTOM_VARIANT, "clearButton" ); |
164 |
arrow.setData( WidgetUtil.CUSTOM_VARIANT, "clearButton" ); |
| 183 |
arrow.setMenu( menu ); |
|
|
| 184 |
arrow.addSelectionListener( new SelectionAdapter() { |
165 |
arrow.addSelectionListener( new SelectionAdapter() { |
| 185 |
public void widgetSelected( final SelectionEvent e ) { |
166 |
public void widgetSelected( final SelectionEvent e ) { |
| 186 |
Display display = arrow.getDisplay(); |
167 |
Display display = arrow.getDisplay(); |
| 187 |
Point newLoc = display.map( arrow, null, 0, 10 ); |
168 |
Point newLoc = display.map( arrow, null, 0, 10 ); |
| 188 |
arrow.getMenu().setVisible( true ); |
169 |
Menu menu = getActionMenu( action, item ); |
| 189 |
arrow.getMenu().setLocation( newLoc ); |
170 |
if( menu != null ) { |
|
|
171 |
menu.setVisible( true ); |
| 172 |
menu.setLocation( newLoc ); |
| 173 |
} |
| 190 |
}; |
174 |
}; |
| 191 |
} ); |
175 |
} ); |
| 192 |
} |
176 |
} |
|
Lines 194-199
Link Here
|
| 194 |
} |
178 |
} |
| 195 |
} |
179 |
} |
| 196 |
|
180 |
|
|
|
181 |
private Menu getActionMenu( |
| 182 |
final Action action, |
| 183 |
final IContributionItem item ) |
| 184 |
{ |
| 185 |
Menu menu = null; |
| 186 |
// pulldown |
| 187 |
if( item instanceof CommandContributionItem ) { |
| 188 |
CommandContributionItem commandItem = ( CommandContributionItem ) item; |
| 189 |
CommandParameter param |
| 190 |
= CommandUtil.extractCommandInformation( commandItem, control ); |
| 191 |
if( param.getMenu() != null ) { |
| 192 |
menu = param.getMenu(); |
| 193 |
} |
| 194 |
} else if( action instanceof WWinPluginPulldown ) { |
| 195 |
WWinPluginPulldown pulldown = ( WWinPluginPulldown ) action; |
| 196 |
menu = pulldown.getMenuCreator().getMenu( control ); |
| 197 |
} else if( action instanceof IMenuCreator ) { |
| 198 |
IMenuCreator creator = ( IMenuCreator ) action; |
| 199 |
menu = creator.getMenu( control ); |
| 200 |
} else if( action instanceof IWorkbenchWindowPulldownDelegate ) { |
| 201 |
IWorkbenchWindowPulldownDelegate delegate |
| 202 |
= ( IWorkbenchWindowPulldownDelegate ) action; |
| 203 |
menu = delegate.getMenu( control ); |
| 204 |
} |
| 205 |
return menu; |
| 206 |
} |
| 207 |
|
| 197 |
private Composite getPulldownParent() { |
208 |
private Composite getPulldownParent() { |
| 198 |
final Composite pulldownParent = new Composite( control, SWT.NONE ); |
209 |
final Composite pulldownParent = new Composite( control, SWT.NONE ); |
| 199 |
pulldownParent.setLayout( new FormLayout() ); |
210 |
pulldownParent.setLayout( new FormLayout() ); |