Mercurial > projects > dwt-addons
diff dwtx/jface/action/ActionContributionItem.d @ 71:4878bef4a38e
Some fixing
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Thu, 22 May 2008 04:03:58 +0200 |
parents | 46a6e0e6ccd4 |
children | 5df4896124c7 |
line wrap: on
line diff
--- a/dwtx/jface/action/ActionContributionItem.d Thu May 22 01:36:46 2008 +0200 +++ b/dwtx/jface/action/ActionContributionItem.d Thu May 22 04:03:58 2008 +0200 @@ -62,7 +62,7 @@ */ public class ActionContributionItem : ContributionItem { alias ContributionItem.fill fill; - + /** * Mode bit: Show text on tool items or buttons, even if an image is * present. If this mode bit is not set, text is only shown on tool items if @@ -298,7 +298,7 @@ } if (flags is DWT.CASCADE) { - // just create a proxy for now, if the user shows it then + // just create a proxy for now, if the user shows it then // fill it in Menu subMenu = new Menu(parent); subMenu.addListener(DWT.Show, getMenuCreatorListener()); @@ -566,8 +566,8 @@ if (actionDefinitionId !is null) { Object obj = ExternalActionManager.getInstance() .getCallback(); - if (obj instanceof ExternalActionManager.IExecuteCallback) { - callback = (ExternalActionManager.IExecuteCallback) obj; + if (null !is cast(ExternalActionManager.IExecuteCallback)obj ) { + callback = cast(ExternalActionManager.IExecuteCallback) obj; } } @@ -581,16 +581,16 @@ if (trace) { ms = System.currentTimeMillis(); Stdout.formatln("Running action: {}", action.getText()); //$NON-NLS-1$ - } - + } + IPropertyChangeListener resultListener = null; if (callback !is null) { - resultListener = new IPropertyChangeListener() { + resultListener = new class IPropertyChangeListener { public void propertyChange(PropertyChangeEvent event) { // Check on result if (event.getProperty().equals(IAction.RESULT)) { - if (event.getNewValue() instanceof Boolean) { - result = (Boolean) event.getNewValue(); + if (null !is cast(Boolean)event.getNewValue() ) { + result = cast(Boolean) event.getNewValue(); } } } @@ -611,7 +611,7 @@ } } - if (resultListener!isnull) { + if (resultListener !is null) { result = null; action.removePropertyChangeListener(resultListener); } @@ -1200,7 +1200,7 @@ /* * (non-Javadoc) - * + * * @see dwtx.jface.action.ContributionItem#dispose() */ public void dispose() { @@ -1210,24 +1210,24 @@ } holdMenu = null; } - + /** * Handle show and hide on the proxy menu for IAction.AS_DROP_DOWN_MENU * actions. - * + * * @return the appropriate listener * @since 3.4 */ private Listener getMenuCreatorListener() { if (menuCreatorListener is null) { - menuCreatorListener = new Listener() { + menuCreatorListener = new class Listener { public void handleEvent(Event event) { switch (event.type) { case DWT.Show: - handleShowProxy((Menu) event.widget); + handleShowProxy(cast(Menu) event.widget); break; case DWT.Hide: - handleHideProxy((Menu) event.widget); + handleHideProxy(cast(Menu) event.widget); break; } } @@ -1235,7 +1235,7 @@ } return menuCreatorListener; } - + /** * This is the easiest way to hold the menu until we can swap it in to the * proxy. @@ -1243,10 +1243,10 @@ private Menu holdMenu = null; private bool menuCreatorCalled = false; - + /** * The proxy menu is being shown, we better get the real menu. - * + * * @param proxy * the proxy menu * @since 3.4 @@ -1268,7 +1268,7 @@ /** * Create MenuItems in the proxy menu that can execute the real menu items * if selected. Create proxy menus for any real item submenus. - * + * * @param realMenu * the real menu to copy from * @param proxy @@ -1279,22 +1279,22 @@ if (realMenu.isDisposed() || proxy.isDisposed()) { return; } - + // we notify the real menu so it can populate itself if it was // listening for DWT.Show realMenu.notifyListeners(DWT.Show, null); - final Listener passThrough = new Listener() { + final Listener passThrough = new class Listener { public void handleEvent(Event event) { if (!event.widget.isDisposed()) { - Widget realItem = (Widget) event.widget.getData(); + Widget realItem = cast(Widget) event.widget.getData(); if (!realItem.isDisposed()) { int style = event.widget.getStyle(); if (event.type is DWT.Selection && ((style & (DWT.TOGGLE | DWT.CHECK)) !is 0) - && realItem instanceof MenuItem) { - ((MenuItem) realItem) - .setSelection(((MenuItem) event.widget) + && (null !is cast(MenuItem)realItem )) { + (cast(MenuItem) realItem) + .setSelection((cast(MenuItem) event.widget) .getSelection()); } event.widget = realItem; @@ -1326,44 +1326,40 @@ final Menu subMenu = new Menu(proxy); subMenu.setData(itemMenu); proxyItem.setMenu(subMenu); - subMenu.addListener(DWT.Show, new Listener() { - public void handleEvent(Event event) { - event.widget.removeListener(DWT.Show, this); - if (event.type is DWT.Show) { - copyMenu(itemMenu, subMenu); - } + subMenu.addListener(DWT.Show, dgListener( (Event event,Menu subMenu_,Menu itemMenu_) { + event.widget.removeListener(DWT.Show, this); + if (event.type is DWT.Show) { + copyMenu(itemMenu_, subMenu_); } - }); + }, subMenu, itemMenu)); subMenu.addListener(DWT.Help, passThrough); subMenu.addListener(DWT.Hide, passThrough); } } } - + /** * The proxy menu is being hidden, so we need to make it go away. - * + * * @param proxy * the proxy menu * @since 3.4 */ - private void handleHideProxy(final Menu proxy) { + private void handleHideProxy(Menu proxy) { proxy.removeListener(DWT.Hide, getMenuCreatorListener()); - proxy.getDisplay().asyncExec(new Runnable() { - public void run() { - if (!proxy.isDisposed()) { - MenuItem parentItem = proxy.getParentItem(); - proxy.dispose(); + proxy.getDisplay().asyncExec(dgRunnable( (Menu proxy_) { + if (!proxy_.isDisposed()) { + MenuItem parentItem = proxy_.getParentItem(); + proxy_.dispose(); parentItem.setMenu(holdMenu); } if (holdMenu !is null && !holdMenu.isDisposed()) { holdMenu.notifyListeners(DWT.Hide, null); } holdMenu = null; - } - }); + }, proxy )); } - + /** * Return the widget associated with this contribution item. It should not * be cached, as it can be disposed and re-created by its containing @@ -1373,7 +1369,7 @@ * actual type of the widget can be any valid control for this * ContributionItem's current ContributionManager. * </p> - * + * * @return the widget, or <code>null</code> depending on the lifecycle. * @since 3.4 */