# HG changeset patch # User Frank Benoit # Date 1211471777 -7200 # Node ID 5df4896124c70b824868c7954ea5564f8767b0fd # Parent 4878bef4a38e701bd65eae55c1dbc92a8480c500 JFace and its examples do compile diff -r 4878bef4a38e -r 5df4896124c7 dwtx/core/runtime/AssertionFailedException.d --- a/dwtx/core/runtime/AssertionFailedException.d Thu May 22 04:03:58 2008 +0200 +++ b/dwtx/core/runtime/AssertionFailedException.d Thu May 22 17:56:17 2008 +0200 @@ -13,6 +13,7 @@ module dwtx.core.runtime.AssertionFailedException; import dwt.dwthelper.utils; +version(JIVE) import jive.stacktrace; /** * AssertionFailedException is a runtime exception thrown diff -r 4878bef4a38e -r 5df4896124c7 dwtx/core/runtime/CoreException.d --- a/dwtx/core/runtime/CoreException.d Thu May 22 04:03:58 2008 +0200 +++ b/dwtx/core/runtime/CoreException.d Thu May 22 17:56:17 2008 +0200 @@ -52,7 +52,25 @@ } /** + * Returns the cause of this exception, or null if none. + * + * @return the cause for this exception + * @since 3.4 + */ + public Exception getCause() { + return status.getException(); + } + + /** * Returns the status object for this exception. + *

+ * IMPORTANT:
+ * The result must NOT be used to log a CoreException + * (e.g., using yourPlugin.getLog().log(status);), + * since that code pattern hides the original stacktrace. + * Instead, create a new {@link Status} with your plug-in ID and + * this CoreException, and log that new status. + *

* * @return a status object */ diff -r 4878bef4a38e -r 5df4896124c7 dwtx/core/runtime/Path.d --- a/dwtx/core/runtime/Path.d Thu May 22 04:03:58 2008 +0200 +++ b/dwtx/core/runtime/Path.d Thu May 22 17:56:17 2008 +0200 @@ -590,7 +590,7 @@ * Initialize the current path with the given string. */ private IPath initialize(String deviceString, String path) { - Assert.isTrue(path.length > 0); + //Assert.isNotNull(path); // allow for DWT this.device = deviceString; path = collapseSlashes(path); diff -r 4878bef4a38e -r 5df4896124c7 dwtx/jface/action/ActionContributionItem.d --- a/dwtx/jface/action/ActionContributionItem.d Thu May 22 04:03:58 2008 +0200 +++ b/dwtx/jface/action/ActionContributionItem.d Thu May 22 17:56:17 2008 +0200 @@ -564,7 +564,7 @@ ExternalActionManager.IExecuteCallback callback = null; String actionDefinitionId = action.getActionDefinitionId(); if (actionDefinitionId !is null) { - Object obj = ExternalActionManager.getInstance() + Object obj = cast(Object) ExternalActionManager.getInstance() .getCallback(); if (null !is cast(ExternalActionManager.IExecuteCallback)obj ) { callback = cast(ExternalActionManager.IExecuteCallback) obj; @@ -602,12 +602,12 @@ action.runWithEvent(e); if (callback !is null) { - if (result is null || result.equals(Boolean.TRUE)) { + if (result is null || result.opEquals(Boolean.TRUE)) { callback.postExecuteSuccess(action, Boolean.TRUE); } else { callback.postExecuteFailure(action, new ExecutionException(action.getText() - + " returned failure.")); //$NON-NLS-1$ + ~ " returned failure.")); //$NON-NLS-1$ } } @@ -622,7 +622,7 @@ if (callback !is null) { callback.notEnabled(action, new NotEnabledException(action .getText() - + " is not enabled.")); //$NON-NLS-1$ + ~ " is not enabled.")); //$NON-NLS-1$ } } } @@ -1326,12 +1326,20 @@ final Menu subMenu = new Menu(proxy); subMenu.setData(itemMenu); proxyItem.setMenu(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.addListener(DWT.Show, new class(subMenu, itemMenu) Listener { + Menu subMenu_; + Menu itemMenu_; + this(Menu a,Menu b){ + subMenu_=a; + itemMenu_=b; } - }, subMenu, itemMenu)); + void handleEvent(Event event){ + event.widget.removeListener(DWT.Show, this); + if (event.type is DWT.Show) { + copyMenu(itemMenu_, subMenu_); + } + } + }); subMenu.addListener(DWT.Help, passThrough); subMenu.addListener(DWT.Hide, passThrough); } diff -r 4878bef4a38e -r 5df4896124c7 dwtx/jface/action/ContributionManager.d --- a/dwtx/jface/action/ContributionManager.d Thu May 22 04:03:58 2008 +0200 +++ b/dwtx/jface/action/ContributionManager.d Thu May 22 17:56:17 2008 +0200 @@ -86,7 +86,7 @@ * (non-Javadoc) Method declared on IContributionManager. */ public void add(IAction action) { - Assert.isNotNull(action, "Action must not be null"); //$NON-NLS-1$ + Assert.isNotNull( cast(Object)action, "Action must not be null"); //$NON-NLS-1$ add(new ActionContributionItem(action)); } @@ -94,7 +94,7 @@ * (non-Javadoc) Method declared on IContributionManager. */ public void add(IContributionItem item) { - Assert.isNotNull(item, "Item must not be null"); //$NON-NLS-1$ + Assert.isNotNull( cast(Object)item, "Item must not be null"); //$NON-NLS-1$ if (allowItem(item)) { contributions.append(item); itemAdded(item); diff -r 4878bef4a38e -r 5df4896124c7 dwtx/jface/action/ExternalActionManager.d --- a/dwtx/jface/action/ExternalActionManager.d Thu May 22 04:03:58 2008 +0200 +++ b/dwtx/jface/action/ExternalActionManager.d Thu May 22 17:56:17 2008 +0200 @@ -73,6 +73,11 @@ */ public final class ExternalActionManager { + private static HashMap!(String,String) EMPTY_MAP; + static this(){ + EMPTY_MAP = new HashMap!(String,String); + } + /** * A simple implementation of the ICallback mechanism that * simply takes a BindingManager and a @@ -99,7 +104,7 @@ /** * Check the applicability of firing an execution event for an action. */ - private final IExecuteApplicable applicabilityChecker; + private /+final+/ IExecuteApplicable applicabilityChecker; /** * The binding manager for your application. Must not be @@ -439,14 +444,14 @@ } Command command = commandManager.getCommand(actionDefinitionId); ExecutionEvent executionEvent = new ExecutionEvent(command, - Collections.EMPTY_MAP, event, null); + EMPTY_MAP, event, null); commandManager.firePreExecute(actionDefinitionId, executionEvent); } public void postExecuteSuccess(IAction action, Object returnValue) { String actionDefinitionId = action.getActionDefinitionId(); - if (actionDefinitionIdisnull + if (actionDefinitionId is null || !applicabilityChecker.isApplicable(action)) { return; } @@ -456,7 +461,7 @@ public void postExecuteFailure(IAction action, ExecutionException exception) { String actionDefinitionId = action.getActionDefinitionId(); - if (actionDefinitionIdisnull + if (actionDefinitionId is null || !applicabilityChecker.isApplicable(action)) { return; } @@ -465,7 +470,7 @@ public void notDefined(IAction action, NotDefinedException exception) { String actionDefinitionId = action.getActionDefinitionId(); - if (actionDefinitionIdisnull + if (actionDefinitionId is null || !applicabilityChecker.isApplicable(action)) { return; } @@ -474,7 +479,7 @@ public void notEnabled(IAction action, NotEnabledException exception) { String actionDefinitionId = action.getActionDefinitionId(); - if (actionDefinitionIdisnull + if (actionDefinitionId is null || !applicabilityChecker.isApplicable(action)) { return; } @@ -540,7 +545,7 @@ * * @since 3.4 */ - public static interface IExecuteApplicable { + public interface IExecuteApplicable { /** * Allow the callback to filter out actions that should not fire * execution events. @@ -564,7 +569,7 @@ * @since 3.4 * */ - public static interface IExecuteCallback { + public interface IExecuteCallback { /** * Fires a NotEnabledException because the action was not diff -r 4878bef4a38e -r 5df4896124c7 dwtx/jface/action/StatusLineContributionItem.d --- a/dwtx/jface/action/StatusLineContributionItem.d Thu May 22 04:03:58 2008 +0200 +++ b/dwtx/jface/action/StatusLineContributionItem.d Thu May 22 17:56:17 2008 +0200 @@ -24,6 +24,10 @@ import dwtx.core.runtime.Assert; import dwtx.jface.util.Util; +import dwtx.jface.action.ContributionItem; +import dwtx.jface.action.StatusLineLayoutData; +import dwtx.jface.action.IContributionManager; + import dwt.dwthelper.utils; /** @@ -49,7 +53,7 @@ */ private Composite statusLine = null; - private String text = Util.ZERO_LENGTH_STRING; + private String text; private int widthHint = -1; @@ -77,6 +81,7 @@ * the number of characters to display */ public this(String id, int charWidth) { + text = Util.ZERO_LENGTH_STRING; super(id); this.charWidth = charWidth; setVisible(false); // no text to start with diff -r 4878bef4a38e -r 5df4896124c7 dwtx/jface/action/ToolBarManager.d --- a/dwtx/jface/action/ToolBarManager.d Thu May 22 04:03:58 2008 +0200 +++ b/dwtx/jface/action/ToolBarManager.d Thu May 22 17:56:17 2008 +0200 @@ -203,7 +203,7 @@ Point afterPack = layoutBar.getSize(); // If the TB didn't change size then we're done - if (beforePack.equals(afterPack)) + if (beforePack.opEquals(afterPack)) return; // OK, we need to re-layout the TB diff -r 4878bef4a38e -r 5df4896124c7 dwtx/jface/dialogs/PopupDialog.d --- a/dwtx/jface/dialogs/PopupDialog.d Thu May 22 04:03:58 2008 +0200 +++ b/dwtx/jface/dialogs/PopupDialog.d Thu May 22 17:56:17 2008 +0200 @@ -55,6 +55,7 @@ import dwtx.jface.window.Window; import dwt.dwthelper.utils; +import dwt.dwthelper.Runnable; /** * A lightweight, transient dialog that is popped up to show contextual or @@ -81,7 +82,17 @@ /** * */ - private static const GridDataFactory LAYOUTDATA_GRAB_BOTH; + private static GridDataFactory LAYOUTDATA_GRAB_BOTH_; + private static GridDataFactory LAYOUTDATA_GRAB_BOTH(){ + if( LAYOUTDATA_GRAB_BOTH_ is null ){ + synchronized( PopupDialog.classinfo ){ + if( LAYOUTDATA_GRAB_BOTH_ is null ){ + LAYOUTDATA_GRAB_BOTH_ = GridDataFactory.fillDefaults().grab(true,true); + } + } + } + return LAYOUTDATA_GRAB_BOTH_; + } /** * The dialog settings key name for stored dialog x location. @@ -285,25 +296,30 @@ * * @since 3.3 */ - public static final String POPUP_IMG_MENU = "popup_menu_image"; //$NON-NLS-1$ + public static const String POPUP_IMG_MENU = "popup_menu_image"; //$NON-NLS-1$ /** * Image registry key for disabled menu image. * * @since 3.3 */ - public static final String POPUP_IMG_MENU_DISABLED = "popup_menu_image_diabled"; //$NON-NLS-1$ + public static const String POPUP_IMG_MENU_DISABLED = "popup_menu_image_diabled"; //$NON-NLS-1$ /** * */ - private static final GridLayoutFactory POPUP_LAYOUT_FACTORY; - - static this(){ - LAYOUTDATA_GRAB_BOTH = GridDataFactory.fillDefaults().grab(true,true); - POPUP_LAYOUT_FACTORY = GridLayoutFactory - .fillDefaults().margins(POPUP_MARGINWIDTH, POPUP_MARGINHEIGHT) - .spacing(POPUP_HORIZONTALSPACING, POPUP_VERTICALSPACING); + private static GridLayoutFactory POPUP_LAYOUT_FACTORY_; + private static GridLayoutFactory POPUP_LAYOUT_FACTORY() { + if( POPUP_LAYOUT_FACTORY_ is null ){ + synchronized( PopupDialog.classinfo ){ + if( POPUP_LAYOUT_FACTORY_ is null ){ + POPUP_LAYOUT_FACTORY_ = GridLayoutFactory + .fillDefaults().margins(POPUP_MARGINWIDTH, POPUP_MARGINHEIGHT) + .spacing(POPUP_HORIZONTALSPACING, POPUP_VERTICALSPACING); + } + } + } + return POPUP_LAYOUT_FACTORY_; } /** @@ -835,7 +851,7 @@ titleLabel = new Label(parent, DWT.NONE); GridDataFactory.fillDefaults().align_(DWT.FILL, DWT.CENTER).grab(true, - false).span(showDialogMenu ? 1 : 2, 1).applyTo(titleLabel); + false).span(showDialogMenu_ ? 1 : 2, 1).applyTo(titleLabel); if (titleText !is null) { titleLabel.setText(titleText); @@ -1208,11 +1224,11 @@ settings.put(prefix ~ DIALOG_ORIGIN_X, shellLocation.x); settings.put(prefix ~ DIALOG_ORIGIN_Y, shellLocation.y); } - if (showPersistActions && showDialogMenu) { - settings.put(getClass().getName() + DIALOG_USE_PERSISTED_SIZE, + if (showPersistActions && showDialogMenu_) { + settings.put(this.classinfo.name ~ DIALOG_USE_PERSISTED_SIZE, persistSize); - settings.put(getClass().getName() - + DIALOG_USE_PERSISTED_LOCATION, persistLocation); + settings.put(this.classinfo.name + ~ DIALOG_USE_PERSISTED_LOCATION, persistLocation); } } @@ -1582,16 +1598,16 @@ if (settings is null) return; - final String className = getClass().getName(); + final String className = this.classinfo.name; - String key = className + DIALOG_USE_PERSISTED_BOUNDS; + String key = className ~ DIALOG_USE_PERSISTED_BOUNDS; String value = settings.get(key); if (value is null || DIALOG_VALUE_MIGRATED_TO_34.equals(value)) return; bool storeBounds = settings.getBoolean(key); - settings.put(className + DIALOG_USE_PERSISTED_LOCATION, storeBounds); - settings.put(className + DIALOG_USE_PERSISTED_SIZE, storeBounds); + settings.put(className ~ DIALOG_USE_PERSISTED_LOCATION, storeBounds); + settings.put(className ~ DIALOG_USE_PERSISTED_SIZE, storeBounds); settings.put(key, DIALOG_VALUE_MIGRATED_TO_34); } diff -r 4878bef4a38e -r 5df4896124c7 dwtx/jface/fieldassist/ComboContentAdapter.d --- a/dwtx/jface/fieldassist/ComboContentAdapter.d Thu May 22 04:03:58 2008 +0200 +++ b/dwtx/jface/fieldassist/ComboContentAdapter.d Thu May 22 17:56:17 2008 +0200 @@ -14,6 +14,7 @@ import dwt.DWT; import dwtx.jface.fieldassist.IControlContentAdapter; +import dwtx.jface.fieldassist.IControlContentAdapter2; import dwt.graphics.GC; import dwt.graphics.Point; @@ -33,7 +34,7 @@ */ public class ComboContentAdapter : IControlContentAdapter, IControlContentAdapter2 { - + /* * Set to true if we should compute the text * vertical bounds rather than just use the field size. @@ -104,7 +105,7 @@ * @see dwtx.jface.fieldassist.IControlContentAdapter#getInsertionBounds(dwt.widgets.Control) */ public Rectangle getInsertionBounds(Control control) { - // This doesn't take horizontal scrolling into affect. + // This doesn't take horizontal scrolling into affect. // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=204599 Combo combo = cast(Combo) control; int position = combo.getSelection().y; @@ -133,25 +134,25 @@ /* * (non-Javadoc) - * + * * @see dwtx.jface.fieldassist.IControlContentAdapter2#getSelection(dwt.widgets.Control) - * + * * @since 3.4 */ public Point getSelection(Control control) { - return ((Combo) control).getSelection(); + return (cast(Combo) control).getSelection(); } /* * (non-Javadoc) - * + * * @see dwtx.jface.fieldassist.IControlContentAdapter2#setSelection(dwt.widgets.Control, * dwt.graphics.Point) - * + * * @since 3.4 */ public void setSelection(Control control, Point range) { - ((Combo) control).setSelection(range); + (cast(Combo) control).setSelection(range); } } diff -r 4878bef4a38e -r 5df4896124c7 dwtx/jface/fieldassist/ContentProposalAdapter.d --- a/dwtx/jface/fieldassist/ContentProposalAdapter.d Thu May 22 04:03:58 2008 +0200 +++ b/dwtx/jface/fieldassist/ContentProposalAdapter.d Thu May 22 17:56:17 2008 +0200 @@ -15,6 +15,7 @@ import dwtx.jface.fieldassist.IContentProposal; import dwtx.jface.fieldassist.IContentProposalProvider; import dwtx.jface.fieldassist.IControlContentAdapter; +import dwtx.jface.fieldassist.IControlContentAdapter2; import dwtx.jface.fieldassist.IContentProposalListener; import dwtx.jface.fieldassist.IContentProposalListener2; @@ -1257,7 +1258,7 @@ * selection position if the proposal popup gets focus, so we need to * remember it. */ - private Point selectionRange = new Point(-1, -1); + private Point selectionRange; /* * A flag that indicates that we are watching modify events @@ -1299,8 +1300,10 @@ IControlContentAdapter controlContentAdapter, IContentProposalProvider proposalProvider, KeyStroke keyStroke, char[] autoActivationCharacters) { + //DWT_Init proposalListeners = new ListenerList(); proposalListeners2 = new ListenerList(); + selectionRange = new Point(-1, -1); //super(); // We always assume the control and content adapter are valid. Assert.isNotNull(cast(Object)control); @@ -1949,7 +1952,7 @@ // the popup opened. // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=127108 // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=139063 - if (null !is cast(IControlContentAdapter2)controlContentAdapter + if ((null !is cast(IControlContentAdapter2)controlContentAdapter) && selectionRange.x !is -1) { (cast(IControlContentAdapter2) controlContentAdapter).setSelection( control, selectionRange); @@ -2109,6 +2112,6 @@ */ private bool isControlContentEmpty() { return getControlContentAdapter().getControlContents(getControl()) - .length() is 0; + .length is 0; } } diff -r 4878bef4a38e -r 5df4896124c7 dwtx/jface/fieldassist/TextContentAdapter.d --- a/dwtx/jface/fieldassist/TextContentAdapter.d Thu May 22 04:03:58 2008 +0200 +++ b/dwtx/jface/fieldassist/TextContentAdapter.d Thu May 22 17:56:17 2008 +0200 @@ -13,6 +13,7 @@ module dwtx.jface.fieldassist.TextContentAdapter; import dwtx.jface.fieldassist.IControlContentAdapter; +import dwtx.jface.fieldassist.IControlContentAdapter2; import dwt.graphics.Point; import dwt.graphics.Rectangle; @@ -105,24 +106,24 @@ /* * (non-Javadoc) - * + * * @see dwtx.jface.fieldassist.IControlContentAdapter2#getSelection(dwt.widgets.Control) - * + * * @since 3.4 */ public Point getSelection(Control control) { - return ((Text) control).getSelection(); + return (cast(Text) control).getSelection(); } /* * (non-Javadoc) - * + * * @see dwtx.jface.fieldassist.IControlContentAdapter2#setSelection(dwt.widgets.Control, * dwt.graphics.Point) - * + * * @since 3.4 */ public void setSelection(Control control, Point range) { - ((Text) control).setSelection(range); + (cast(Text) control).setSelection(range); } } diff -r 4878bef4a38e -r 5df4896124c7 dwtx/jface/internal/ConfigureColumnsDialog.d --- a/dwtx/jface/internal/ConfigureColumnsDialog.d Thu May 22 04:03:58 2008 +0200 +++ b/dwtx/jface/internal/ConfigureColumnsDialog.d Thu May 22 17:56:17 2008 +0200 @@ -84,7 +84,7 @@ * @param table */ public this(IShellProvider shellProvider, Table table) { - this(shellProvider, (Control) table); + this(shellProvider, cast(Control) table); } /** @@ -97,7 +97,7 @@ * @param tree */ public this(IShellProvider shellProvider, Tree tree) { - this(shellProvider, (Control) tree); + this(shellProvider, cast(Control) tree); } /** @@ -261,7 +261,7 @@ table.addListener(DWT.Selection, new class Listener { public void handleEvent(Event event) { - handleSelectionChanged(table.indexOf((TableItem) event.item)); + handleSelectionChanged(table.indexOf(cast(TableItem) event.item)); } }); text.addListener(DWT.Modify, new class Listener { @@ -319,7 +319,7 @@ if (null !is cast(TableColumn)item ) { result = (cast(TableColumn) item).getText(); if (result.trim().equals("")) { //$NON-NLS-1$ - result = ((TableColumn) item).getToolTipText(); + result = (cast(TableColumn) item).getToolTipText(); } } else if (null !is cast(TreeColumn)item ) { result = (cast(TreeColumn) item).getText(); diff -r 4878bef4a38e -r 5df4896124c7 dwtx/jface/layout/AbstractColumnLayout.d --- a/dwtx/jface/layout/AbstractColumnLayout.d Thu May 22 04:03:58 2008 +0200 +++ b/dwtx/jface/layout/AbstractColumnLayout.d Thu May 22 17:56:17 2008 +0200 @@ -48,6 +48,11 @@ */ public abstract class AbstractColumnLayout : Layout { private static int COLUMN_TRIM; + + static const bool IS_GTK; + + static const String LAYOUT_DATA; + static this() { if ("win32".equals(DWT.getPlatform())) { //$NON-NLS-1$ COLUMN_TRIM = 4; @@ -56,14 +61,6 @@ } else { COLUMN_TRIM = 3; } - } - - static const bool IS_GTK; - - static const String LAYOUT_DATA; - - static this(){ - COLUMN_TRIM = "carbon".equals(DWT.getPlatform()) ? 24 : 3; //$NON-NLS-1$ IS_GTK = "gtk".equals(DWT.getPlatform());//$NON-NLS-1$ LAYOUT_DATA = Policy.JFACE ~ ".LAYOUT_DATA"; //$NON-NLS-1$ } @@ -187,7 +184,7 @@ recalculate = false; for (int i = 0; i < numberOfWeightColumns; i++) { int colIndex = weightColumnIndices[i]; - ColumnWeightData cw = (ColumnWeightData) getLayoutData( + ColumnWeightData cw = cast(ColumnWeightData) getLayoutData( scrollable, colIndex); final int minWidth = cw.minimumWidth; final int allowedWidth = (width - fixedWidth) * cw.weight diff -r 4878bef4a38e -r 5df4896124c7 dwtx/jface/operation/ModalContext.d --- a/dwtx/jface/operation/ModalContext.d Thu May 22 04:03:58 2008 +0200 +++ b/dwtx/jface/operation/ModalContext.d Thu May 22 17:56:17 2008 +0200 @@ -429,12 +429,12 @@ Thread switchingThread) { try { listener.threadChange(switchingThread); - } catch (ThreadDeath e) { +// } catch (ThreadDeath e) { // Make sure to propagate ThreadDeath, or threads will never // fully terminate - throw e; - } catch (Error e) { - return e; +// throw e; +// } catch (Error e) { +// return e; }catch (RuntimeException e) { return e; } diff -r 4878bef4a38e -r 5df4896124c7 dwtx/jface/preference/IntegerFieldEditor.d --- a/dwtx/jface/preference/IntegerFieldEditor.d Thu May 22 04:03:58 2008 +0200 +++ b/dwtx/jface/preference/IntegerFieldEditor.d Thu May 22 17:56:17 2008 +0200 @@ -21,6 +21,7 @@ import dwtx.jface.resource.JFaceResources; import dwt.dwthelper.utils; +import tango.util.Convert; /** * A field editor for an integer type preference. @@ -119,7 +120,7 @@ if (text !is null) { int value = getPreferenceStore().getInt(getPreferenceName()); text.setText( tango.text.convert.Integer.toString(value));//$NON-NLS-1$ - oldValue = "" + value; //$NON-NLS-1$ + oldValue = to!(String)( value ); //$NON-NLS-1$ } } diff -r 4878bef4a38e -r 5df4896124c7 dwtx/jface/preference/PreferenceDialog.d --- a/dwtx/jface/preference/PreferenceDialog.d Thu May 22 04:03:58 2008 +0200 +++ b/dwtx/jface/preference/PreferenceDialog.d Thu May 22 17:56:17 2008 +0200 @@ -877,7 +877,7 @@ (cast(IPersistentPreferenceStore) store).save(); } catch (IOException e) { String message =JFaceResources.format( - "PreferenceDialog.saveErrorMessage", [ page.getTitle(), e.getMessage() ]); //$NON-NLS-1$ + "PreferenceDialog.saveErrorMessage", [ page.getTitle(), e.msg ]); //$NON-NLS-1$ Policy.getStatusHandler().show( new Status(IStatus.ERROR, Policy.JFACE, message, e), JFaceResources.getString("PreferenceDialog.saveErrorTitle")); //$NON-NLS-1$ @@ -1037,7 +1037,7 @@ IPreferenceNode[] nodes = preferenceManager.getRootSubNodes(); ViewerComparator comparator = getTreeViewer().getComparator(); if (comparator !is null) { - comparator.sort(null, nodes); + comparator.sort(null, arraycast!(Object)(nodes)); } ViewerFilter[] filters = getTreeViewer().getFilters(); for (int i = 0; i < nodes.length; i++) { diff -r 4878bef4a38e -r 5df4896124c7 dwtx/jface/resource/ColorRegistry.d --- a/dwtx/jface/resource/ColorRegistry.d Thu May 22 04:03:58 2008 +0200 +++ b/dwtx/jface/resource/ColorRegistry.d Thu May 22 17:56:17 2008 +0200 @@ -12,8 +12,9 @@ *******************************************************************************/ module dwtx.jface.resource.ColorRegistry; +import dwtx.jface.resource.ColorDescriptor; import dwtx.jface.resource.ResourceRegistry; -import dwtx.jface.resource.ColorDescriptor; +import dwtx.jface.resource.RGBColorDescriptor; import tango.util.collection.ArraySeq; import tango.util.collection.HashMap; diff -r 4878bef4a38e -r 5df4896124c7 dwtx/jface/resource/FileImageDescriptor.d --- a/dwtx/jface/resource/FileImageDescriptor.d Thu May 22 04:03:58 2008 +0200 +++ b/dwtx/jface/resource/FileImageDescriptor.d Thu May 22 17:56:17 2008 +0200 @@ -167,7 +167,7 @@ * object which is suitable only for debugging. */ public override String toString() { - return Format("FileImageDescriptor(location={}, name={})", location, name );//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$ + return Format("FileImageDescriptor(name={})", name );//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$ } /* @@ -212,13 +212,13 @@ */ private String getFilePath() { - if (location is null) - return (new Path(name)).toOSString(); - - URL resource = location.getResource(name); - - if (resource is null) - return null; +// if (location is null) +// return (new Path(name)).toOSString(); +// +// URL resource = location.getResource(name); +// +// if (resource is null) +// return null; // try { // if (JFaceActivator.getBundleContext() is null) {// Stand-alone case // diff -r 4878bef4a38e -r 5df4896124c7 dwtx/jface/resource/ImageDescriptor.d --- a/dwtx/jface/resource/ImageDescriptor.d Thu May 22 04:03:58 2008 +0200 +++ b/dwtx/jface/resource/ImageDescriptor.d Thu May 22 17:56:17 2008 +0200 @@ -67,10 +67,16 @@ * A small red square used to warn that an image cannot be created. *

*/ - protected static const ImageData DEFAULT_IMAGE_DATA; - - static this(){ - DEFAULT_IMAGE_DATA = new ImageData(6, 6, 1, new PaletteData( [ new RGB(255, 0, 0) ] )); + protected static ImageData DEFAULT_IMAGE_DATA_; + protected static ImageData DEFAULT_IMAGE_DATA(){ + if( DEFAULT_IMAGE_DATA_ is null ){ + synchronized( ImageDescriptor.classinfo ){ + if( DEFAULT_IMAGE_DATA_ is null ){ + DEFAULT_IMAGE_DATA_ = new ImageData(6, 6, 1, new PaletteData( [ new RGB(255, 0, 0) ] )); + } + } + } + return DEFAULT_IMAGE_DATA_; } /** diff -r 4878bef4a38e -r 5df4896124c7 dwtx/jface/resource/JFaceResources.d --- a/dwtx/jface/resource/JFaceResources.d Thu May 22 04:03:58 2008 +0200 +++ b/dwtx/jface/resource/JFaceResources.d Thu May 22 17:56:17 2008 +0200 @@ -460,11 +460,11 @@ declareImage(bundle, PreferenceDialog.PREF_DLG_TITLE_IMG, ICONS_PATH ~ "pref_dialog_title.gif", getImportData!( "dwtx.jface.preference.images.pref_dialog_title.gif"));//$NON-NLS-1$ //$NON-NLS-2$ declareImage(bundle, PopupDialog.POPUP_IMG_MENU, ICONS_PATH - ~ "popup_menu.gif", getImportData!( "images/popup_menu.gif"));//$NON-NLS-1$ //$NON-NLS-2$ + ~ "popup_menu.gif", getImportData!( "dwtx.jface.dialogs.images.popup_menu.gif"));//$NON-NLS-1$ //$NON-NLS-2$ declareImage( bundle, PopupDialog.POPUP_IMG_MENU_DISABLED, - ICONS_PATH ~ "popup_menu_disabled.gif", getImportData!( "images/popup_menu_disabled.gif"));//$NON-NLS-1$ //$NON-NLS-2$ + ICONS_PATH ~ "popup_menu_disabled.gif", getImportData!( "dwtx.jface.dialogs.images.popup_menu_disabled.gif"));//$NON-NLS-1$ //$NON-NLS-2$ } /** diff -r 4878bef4a38e -r 5df4896124c7 dwtx/jface/util/Policy.d --- a/dwtx/jface/util/Policy.d Thu May 22 04:03:58 2008 +0200 +++ b/dwtx/jface/util/Policy.d Thu May 22 17:56:17 2008 +0200 @@ -24,6 +24,7 @@ import dwtx.jface.dialogs.ErrorSupportProvider; import dwtx.jface.util.StatusHandler; +import dwtx.jface.util.SafeRunnableDialog; import dwtx.jface.util.ILogger; import dwt.dwthelper.utils; @@ -151,27 +152,23 @@ private SafeRunnableDialog dialog; public void show(IStatus status, String title) { - Runnable runnable = dgRunnable( (IStatus status_, SafeRunnableDialog* dialog_) { - if (*dialog_ is null || dialog_.getShell().isDisposed()) { - *dialog_ = new SafeRunnableDialog(status_); - *dialog_.create(); - *dialog_.getShell().addDisposeListener( - new class(dialog_) DisposeListener { - private SafeRunnableDialog* dialog__; - this( SafeRunnableDialog* a ){ - dialog__ = a; - } + Runnable runnable = dgRunnable( (IStatus status_) { + if (dialog is null || dialog.getShell().isDisposed()) { + dialog = new SafeRunnableDialog(status_); + dialog.create(); + dialog.getShell().addDisposeListener( + new class DisposeListener { public void widgetDisposed( DisposeEvent e) { - *dialog__ = null; + dialog = null; } }); - *dialog_.open(); + dialog.open(); } else { - *dialog_.addStatus(status_); - *dialog_.refresh(); + dialog.addStatus(status_); + dialog.refresh(); } - }, status, &dialog); + }, status ); if (Display.getCurrent() !is null) { runnable.run(); } else { @@ -290,8 +287,8 @@ */ public static void logException(Exception exception) { getLog().log( - new Status(IStatus.ERROR, JFACE, exception - .getLocalizedMessage(), exception)); + new Status(IStatus.ERROR, JFACE, ExceptionGetLocalizedMessage( exception ) + , exception)); } diff -r 4878bef4a38e -r 5df4896124c7 dwtx/jface/util/Util.d --- a/dwtx/jface/util/Util.d Thu May 22 04:03:58 2008 +0200 +++ b/dwtx/jface/util/Util.d Thu May 22 17:56:17 2008 +0200 @@ -498,10 +498,10 @@ return defaultString; } - + /** * Foundation replacement for String.replaceAll(*). - * + * * @param src the starting string. * @param find the string to find. * @param replacement the string to replace. @@ -509,8 +509,8 @@ * @since 3.4 */ public static final String replaceAll(String src, String find, String replacement) { - final int len = src.length(); - final int findLen = find.length(); + final int len = src.length; + final int findLen = find.length; int idx = src.indexOf(find); if (idx < 0) { @@ -522,7 +522,7 @@ while (idx !is -1 && idx < len) { buf.append(src.substring(beginIndex, idx)); buf.append(replacement); - + beginIndex = idx + findLen; if (beginIndex < len) { idx = src.indexOf(find, beginIndex); @@ -531,7 +531,7 @@ } } if (beginIndex 0) { StyledString newString = new StyledString(decorated .substring(0, originalStart), style); newString.append(styledString); styledString = newString; } - if (decorated.length() > originalStart + label.length()) { // decorator + if (decorated.length > originalStart + label.length) { // decorator // appended // something return styledString.append(decorated.substring(originalStart - + label.length()), style); + + label.length), style); } return styledString; } @@ -248,7 +261,7 @@ * * @return return the decoration style */ - protected Styler getDecorationStyle(Object element) { + protected StyledString.Styler getDecorationStyle(Object element) { return StyledString.DECORATIONS_STYLER; } diff -r 4878bef4a38e -r 5df4896124c7 dwtx/jface/viewers/DelegatingStyledCellLabelProvider.d --- a/dwtx/jface/viewers/DelegatingStyledCellLabelProvider.d Thu May 22 04:03:58 2008 +0200 +++ b/dwtx/jface/viewers/DelegatingStyledCellLabelProvider.d Thu May 22 17:56:17 2008 +0200 @@ -12,6 +12,14 @@ *******************************************************************************/ module dwtx.jface.viewers.DelegatingStyledCellLabelProvider; +import dwtx.jface.viewers.StyledCellLabelProvider; +import dwtx.jface.viewers.IBaseLabelProvider; +import dwtx.jface.viewers.StyledString; +import dwtx.jface.viewers.ViewerCell; +import dwtx.jface.viewers.ILabelProviderListener; +import dwtx.jface.viewers.IColorProvider; +import dwtx.jface.viewers.IFontProvider; + import dwt.graphics.Color; import dwt.graphics.Font; import dwt.graphics.Image; diff -r 4878bef4a38e -r 5df4896124c7 dwtx/jface/viewers/FocusCellHighlighter.d --- a/dwtx/jface/viewers/FocusCellHighlighter.d Thu May 22 04:03:58 2008 +0200 +++ b/dwtx/jface/viewers/FocusCellHighlighter.d Thu May 22 17:56:17 2008 +0200 @@ -74,6 +74,9 @@ protected void focusCellChanged(ViewerCell newCell, ViewerCell oldCell) { focusCellChanged(newCell); } + package void focusCellChanged_package(ViewerCell newCell, ViewerCell oldCell){ + focusCellChanged(newCell,oldCell); + } /** * This method is called by the framework to initialize this cell diff -r 4878bef4a38e -r 5df4896124c7 dwtx/jface/viewers/OwnerDrawLabelProvider.d --- a/dwtx/jface/viewers/OwnerDrawLabelProvider.d Thu May 22 04:03:58 2008 +0200 +++ b/dwtx/jface/viewers/OwnerDrawLabelProvider.d Thu May 22 17:56:17 2008 +0200 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2007 IBM Corporation and others. + * Copyright (c) 2006, 2008 IBM Corporation 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 available at @@ -16,14 +16,17 @@ import dwtx.jface.viewers.CellLabelProvider; import dwtx.jface.viewers.ColumnViewer; import dwtx.jface.viewers.ViewerCell; +import dwtx.jface.viewers.ViewerColumn; import dwt.DWT; import dwt.graphics.Color; import dwt.graphics.Rectangle; +import dwt.widgets.Control; import dwt.widgets.Event; import dwt.widgets.Listener; import dwt.dwthelper.utils; +import tango.util.collection.HashSet; /** * OwnerDrawLabelProvider is an abstract implementation of a label provider that @@ -38,101 +41,147 @@ */ public abstract class OwnerDrawLabelProvider : CellLabelProvider { + alias CellLabelProvider.dispose dispose; + + static class OwnerDrawListener : Listener { + HashSet!(ViewerColumn) enabledColumns; + int enabledGlobally = 0; + private ColumnViewer viewer; + + this(ColumnViewer viewer) { + enabledColumns = new HashSet!(ViewerColumn); + this.viewer = viewer; + } + + public void handleEvent(Event event) { + CellLabelProvider provider = viewer.getViewerColumn(event.index) + .getLabelProvider(); + ViewerColumn column = viewer.getViewerColumn(event.index); + if (enabledGlobally > 0 || enabledColumns.contains(column)) { + if (null !is cast(OwnerDrawLabelProvider)provider ) { + Object element = event.item.getData(); + OwnerDrawLabelProvider ownerDrawProvider = cast(OwnerDrawLabelProvider) provider; + switch (event.type) { + case DWT.MeasureItem: + ownerDrawProvider.measure(event, element); + break; + case DWT.PaintItem: + ownerDrawProvider.paint(event, element); + break; + case DWT.EraseItem: + ownerDrawProvider.erase(event, element); + break; + } + } + } + } + } + + private static const String OWNER_DRAW_LABEL_PROVIDER_LISTENER = "owner_draw_label_provider_listener"; //$NON-NLS-1$ + /** * Set up the owner draw callbacks for the viewer. * * @param viewer * the viewer the owner draw is set up + * + * @deprecated Since 3.4, the default implementation of + * {@link CellLabelProvider#initialize(ColumnViewer, ViewerColumn)} + * in this class will set up the necessary owner draw callbacks + * automatically. Calls to this method can be removed. */ public static void setUpOwnerDraw(ColumnViewer viewer) { - viewer.getControl().addListener(DWT.MeasureItem, new class(viewer) Listener { - ColumnViewer viewer_; - this(ColumnViewer a){ - viewer_=a; - } - /* - * (non-Javadoc) - * - * @see dwt.widgets.Listener#handleEvent(dwt.widgets.Event) - */ - public void handleEvent(Event event) { - CellLabelProvider provider = viewer_ - .getViewerColumn(event.index).getLabelProvider(); - Object element = event.item.getData(); - - if ( auto p = cast(OwnerDrawLabelProvider) provider ) - p.measure(event, element); - } - }); + getOrCreateOwnerDrawListener(viewer).enabledGlobally++; + } - viewer.getControl().addListener(DWT.PaintItem, new class(viewer) Listener { - ColumnViewer viewer_; - this(ColumnViewer a){ - viewer_=a; - } - /* - * (non-Javadoc) - * - * @see dwt.widgets.Listener#handleEvent(dwt.widgets.Event) - */ - public void handleEvent(Event event) { - CellLabelProvider provider = viewer_ - .getViewerColumn(event.index).getLabelProvider(); - Object element = event.item.getData(); + /** + * @param viewer + * @param control + * @return + */ + private static OwnerDrawListener getOrCreateOwnerDrawListener( + ColumnViewer viewer) { + Control control = viewer.getControl(); + OwnerDrawListener listener = cast(OwnerDrawListener) control + .getData(OWNER_DRAW_LABEL_PROVIDER_LISTENER); + if (listener is null) { + listener = new OwnerDrawListener(viewer); + control.setData(OWNER_DRAW_LABEL_PROVIDER_LISTENER, listener); + control.addListener(DWT.MeasureItem, listener); + control.addListener(DWT.EraseItem, listener); + control.addListener(DWT.PaintItem, listener); + } + return listener; + } - if ( auto p = cast(OwnerDrawLabelProvider) provider ) - p.paint(event, element); - } - }); + /** + * Create a new instance of the receiver based on a column viewer. + * + */ + public this() { + + } + + public void dispose(ColumnViewer viewer, ViewerColumn column) { + if (!viewer.getControl().isDisposed()) { + setOwnerDrawEnabled(viewer, column, false); + } + super.dispose(viewer, column); + } - viewer.getControl().addListener(DWT.EraseItem, new class(viewer) Listener { - ColumnViewer viewer_; - this(ColumnViewer a){ - viewer_=a; - } - /* - * (non-Javadoc) - * - * @see dwt.widgets.Listener#handleEvent(dwt.widgets.Event) - */ - public void handleEvent(Event event) { - - CellLabelProvider provider = getLabelProvider(viewer_, event); - Object element = getElement(event); - - if ( auto p = cast(OwnerDrawLabelProvider) provider ) - p.erase(event, element); - - } + /** + * This implementation of + * {@link CellLabelProvider#initialize(ColumnViewer, ViewerColumn)} + * delegates to {@link #initialize(ColumnViewer, ViewerColumn, bool)} + * with a value of true for enableOwnerDraw. + * Subclasses may override this method but should either call the super + * implementation or, alternatively, + * {@link #initialize(ColumnViewer, ViewerColumn, bool)}. + */ + protected void initialize(ColumnViewer viewer, ViewerColumn column) { + this.initialize(viewer, column, true); + } - /** - * Return the item for the event - * - * @param event - * @return Object - */ - private Object getElement(Event event) { - return event.item.getData(); - } + /** + * May be called from subclasses that override + * {@link #initialize(ColumnViewer, ViewerColumn)} but want to customize + * whether owner draw will be enabled. This method calls + * super.initialize(ColumnViewer, ViewerColumn), and then + * enables or disables owner draw by calling + * {@link #setOwnerDrawEnabled(ColumnViewer, ViewerColumn, bool)}. + * + * @param viewer + * the viewer + * @param column + * the column, or null if a column is not + * available. + * @param enableOwnerDraw + * true if owner draw should be enabled for the + * given viewer and column, false otherwise. + * + * @since 3.4 + */ + final protected void initialize(ColumnViewer viewer, ViewerColumn column, + bool enableOwnerDraw) { + super.initialize(viewer, column); + setOwnerDrawEnabled(viewer, column, enableOwnerDraw); + } - /** - * Return the label provider for the column. - * - * @param viewer - * @param event - * @return CellLabelProvider - */ - private CellLabelProvider getLabelProvider( - ColumnViewer cv, Event event) { - return cv.getViewerColumn(event.index).getLabelProvider(); - } - }); + public void update(ViewerCell cell) { + // Force a redraw + Rectangle cellBounds = cell.getBounds(); + cell.getControl().redraw(cellBounds.x, cellBounds.y, cellBounds.width, + cellBounds.height, true); + } /** * Handle the erase event. The default implementation colors the background * of selected areas with {@link DWT#COLOR_LIST_SELECTION} and foregrounds - * with {@link DWT#COLOR_LIST_SELECTION_TEXT} + * with {@link DWT#COLOR_LIST_SELECTION_TEXT}. Note that this + * implementation causes non-native behavior on some platforms. Subclasses + * should override this method and not call the super + * implementation. * * @param event * the erase event @@ -166,17 +215,6 @@ } /** - * Handle the paint event. - * - * @param event - * the paint event - * @param element - * the model element - * @see DWT#PaintItem - */ - protected abstract void paint(Event event, Object element); - - /** * Handle the measure event. * * @param event @@ -188,24 +226,64 @@ protected abstract void measure(Event event, Object element); /** - * Create a new instance of the receiver based on a column viewer. + * Handle the paint event. * + * @param event + * the paint event + * @param element + * the model element + * @see DWT#PaintItem */ - public this() { - - } + protected abstract void paint(Event event, Object element); - /* - * (non-Javadoc) + /** + * Enables or disables owner draw for the given viewer and column. This + * method will attach or remove a listener to the underlying control as + * necessary. This method is called from + * {@link #initialize(ColumnViewer, ViewerColumn)} and + * {@link #dispose(ColumnViewer, ViewerColumn)} but may be called from + * subclasses to enable or disable owner draw dynamically. * - * @see dwtx.jface.viewers.ViewerLabelProvider#update(dwtx.jface.viewers.ViewerCell) + * @param viewer + * the viewer + * @param column + * the column, or null if a column is not + * available + * @param enabled + * true if owner draw should be enabled, + * false otherwise + * + * @since 3.4 */ - public override void update(ViewerCell cell) { - // Force a redraw - Rectangle cellBounds = cell.getBounds(); - cell.getControl().redraw(cellBounds.x, cellBounds.y, cellBounds.width, - cellBounds.height, true); - + protected void setOwnerDrawEnabled(ColumnViewer viewer, + ViewerColumn column, bool enabled) { + if (enabled) { + OwnerDrawListener listener = getOrCreateOwnerDrawListener(viewer); + if (column is null) { + listener.enabledGlobally++; + } else { + listener.enabledColumns.add(column); + } + } else { + OwnerDrawListener listener = cast(OwnerDrawListener) viewer + .getControl().getData(OWNER_DRAW_LABEL_PROVIDER_LISTENER); + if (listener !is null) { + if (column is null) { + listener.enabledGlobally--; + } else { + listener.enabledColumns.remove(column); + } + if (listener.enabledColumns.drained() + && listener.enabledGlobally <= 0) { + viewer.getControl().removeListener(DWT.MeasureItem, + listener); + viewer.getControl().removeListener(DWT.EraseItem, listener); + viewer.getControl().removeListener(DWT.PaintItem, listener); + viewer.getControl().setData( + OWNER_DRAW_LABEL_PROVIDER_LISTENER, null); + } + } + } } } diff -r 4878bef4a38e -r 5df4896124c7 dwtx/jface/viewers/SWTFocusCellManager.d --- a/dwtx/jface/viewers/SWTFocusCellManager.d Thu May 22 04:03:58 2008 +0200 +++ b/dwtx/jface/viewers/SWTFocusCellManager.d Thu May 22 17:56:17 2008 +0200 @@ -193,7 +193,7 @@ this.focusCell.getItem().addDisposeListener(itemDeletionListener); } - this.cellHighlighter.focusCellChanged/*_package*/(focusCell,oldCell); + this.cellHighlighter.focusCellChanged_package(focusCell,oldCell); } ColumnViewer getViewer() { diff -r 4878bef4a38e -r 5df4896124c7 dwtx/jface/viewers/StructuredSelection.d --- a/dwtx/jface/viewers/StructuredSelection.d Thu May 22 04:03:58 2008 +0200 +++ b/dwtx/jface/viewers/StructuredSelection.d Thu May 22 17:56:17 2008 +0200 @@ -102,7 +102,7 @@ * the comparer, or null * @since 3.4 */ - public this(Seq!(Object) elements, IElementComparer comparer) { + public this(SeqView!(Object) elements, IElementComparer comparer) { this.elements = elements.toArray(); this.comparer = comparer; } @@ -143,11 +143,11 @@ //element comparison for (int i = 0; i < myLen; i++) { if (useComparer) { - if (!comparer.equals(elements[i], s2.elements[i])) { + if (!comparer.opEquals(elements[i], s2.elements[i])) { return false; } } else { - if (!elements[i].equals(s2.elements[i])) { + if (!elements[i].opEquals(s2.elements[i])) { return false; } } diff -r 4878bef4a38e -r 5df4896124c7 dwtx/jface/viewers/StyledCellLabelProvider.d --- a/dwtx/jface/viewers/StyledCellLabelProvider.d Thu May 22 04:03:58 2008 +0200 +++ b/dwtx/jface/viewers/StyledCellLabelProvider.d Thu May 22 17:56:17 2008 +0200 @@ -13,6 +13,11 @@ *******************************************************************************/ module dwtx.jface.viewers.StyledCellLabelProvider; +import dwtx.jface.viewers.OwnerDrawLabelProvider; +import dwtx.jface.viewers.ColumnViewer; +import dwtx.jface.viewers.ViewerColumn; +import dwtx.jface.viewers.ViewerCell; +import dwtx.jface.viewers.ViewerRow; import dwt.DWT; import dwt.custom.StyleRange; @@ -55,6 +60,8 @@ */ public abstract class StyledCellLabelProvider : OwnerDrawLabelProvider { + alias OwnerDrawLabelProvider.setOwnerDrawEnabled setOwnerDrawEnabled; + /** * Style constant for indicating that the styled colors are to be applied * even it the viewer's item is selected. Default is not to apply colors. @@ -270,7 +277,7 @@ // colors and font if (styleRange.font !is null || !applyColors && (styleRange.foreground !is null || styleRange.background !is null)) { - styleRange = (StyleRange) styleRange.clone(); + styleRange = cast(StyleRange) styleRange.clone(); styleRange.font = null; // ignore font settings until bug 168807 is resolved if (!applyColors) { styleRange.foreground = null; @@ -281,7 +288,7 @@ } private ViewerCell getViewerCell(Event event, Object element) { - ViewerRow row= viewer.getViewerRowFromItem(event.item); + ViewerRow row= viewer.getViewerRowFromItem_package(event.item); return new ViewerCell(row, event.index, element); } diff -r 4878bef4a38e -r 5df4896124c7 dwtx/jface/viewers/StyledString.d --- a/dwtx/jface/viewers/StyledString.d Thu May 22 04:03:58 2008 +0200 +++ b/dwtx/jface/viewers/StyledString.d Thu May 22 17:56:17 2008 +0200 @@ -20,6 +20,9 @@ import dwt.dwthelper.utils; import tango.text.convert.Format; +import tango.util.collection.ArraySeq; +import tango.core.Exception; + /** * A mutable string with styled ranges. All ranges mark substrings of the string @@ -61,24 +64,21 @@ * managed in the JFace color registry (See * {@link JFaceResources#getColorRegistry()}). */ - public static final Styler QUALIFIER_STYLER = createColorRegistryStyler( - JFacePreferences.QUALIFIER_COLOR, null); + public static const Styler QUALIFIER_STYLER; /** * A built-in styler using the {@link JFacePreferences#COUNTER_COLOR} * managed in the JFace color registry (See * {@link JFaceResources#getColorRegistry()}). */ - public static final Styler COUNTER_STYLER = createColorRegistryStyler( - JFacePreferences.COUNTER_COLOR, null); + public static const Styler COUNTER_STYLER; /** * A built-in styler using the {@link JFacePreferences#DECORATIONS_COLOR} * managed in the JFace color registry (See * {@link JFaceResources#getColorRegistry()}). */ - public static final Styler DECORATIONS_STYLER = createColorRegistryStyler( - JFacePreferences.DECORATIONS_COLOR, null); + public static const Styler DECORATIONS_STYLER; /** * Creates a styler that takes the given foreground and background colors @@ -96,10 +96,20 @@ return new DefaultStyler(foregroundColorName, backgroundColorName); } - private static final StyleRange[] EMPTY = new StyleRange[0]; + private static const StyleRange[] EMPTY; private StringBuffer fBuffer; private StyleRunList fStyleRuns; + static this(){ + QUALIFIER_STYLER = createColorRegistryStyler( + JFacePreferences.QUALIFIER_COLOR, null); + COUNTER_STYLER = createColorRegistryStyler( + JFacePreferences.COUNTER_COLOR, null); + DECORATIONS_STYLER = createColorRegistryStyler( + JFacePreferences.DECORATIONS_COLOR, null); + EMPTY = new StyleRange[0]; + } + /** * Creates an empty {@link StyledString}. */ @@ -173,18 +183,18 @@ return append(string, null); } - /** - * Appends the string representation of the given character array - * to the {@link StyledString}. The appended - * character array will have no associated styler. - * - * @param chars - * the character array to append - * @return returns a reference to this object - */ - public StyledString append(char[] chars) { - return append(chars, null); - } +// /** +// * Appends the string representation of the given character array +// * to the {@link StyledString}. The appended +// * character array will have no associated styler. +// * +// * @param chars +// * the character array to append +// * @return returns a reference to this object +// */ +// public StyledString append(char[] chars) { +// return append(chars, null); +// } /** * Appends the string representation of the given character @@ -195,8 +205,8 @@ * the character to append * @return returns a reference to this object */ - public StyledString append(char ch) { - return append(String.valueOf(ch), null); + public StyledString append(dchar ch) { + return append(dcharToString(ch), null); } /** @@ -214,10 +224,10 @@ int offset = fBuffer.length(); fBuffer.append(string.toString()); - List otherRuns = string.fStyleRuns; - if (otherRuns !is null && !otherRuns.isEmpty()) { + auto otherRuns = string.fStyleRuns; + if (otherRuns !is null && !otherRuns.drained()) { for (int i = 0; i < otherRuns.size(); i++) { - StyleRun curr = (StyleRun) otherRuns.get(i); + StyleRun curr = cast(StyleRun) otherRuns.get(i); if (i is 0 && curr.offset !is 0) { appendStyleRun(null, offset); // appended string will // start with the default @@ -245,8 +255,8 @@ * appended character * @return returns a reference to this object */ - public StyledString append(char ch, Styler styler) { - return append(String.valueOf(ch), styler); + public StyledString append(dchar ch, Styler styler) { + return append(dcharToString(ch), styler); } /** @@ -262,37 +272,37 @@ * @return returns a reference to this object */ public StyledString append(String string, Styler styler) { - if (string.length() is 0) + if (string.length is 0) return this; - int offset = fBuffer.length(); // the length before appending + int offset = fBuffer.length; // the length before appending fBuffer.append(string); appendStyleRun(styler, offset); return this; } - /** - * Appends the string representation of the given character array - * with a style to the {@link StyledString}. The - * appended character array will be styled using the given styler. - * - * @param chars - * the character array to append - * @param styler - * the styler to use for styling the character array to append or - * null if no styler should be associated with the - * appended character array - * @return returns a reference to this object - */ - public StyledString append(char[] chars, Styler styler) { - if (chars.length is 0) - return this; - - int offset = fBuffer.length(); // the length before appending - fBuffer.append(chars); - appendStyleRun(styler, offset); - return this; - } +// /** +// * Appends the string representation of the given character array +// * with a style to the {@link StyledString}. The +// * appended character array will be styled using the given styler. +// * +// * @param chars +// * the character array to append +// * @param styler +// * the styler to use for styling the character array to append or +// * null if no styler should be associated with the +// * appended character array +// * @return returns a reference to this object +// */ +// public StyledString append(char[] chars, Styler styler) { +// if (chars.length is 0) +// return this; +// +// int offset = fBuffer.length(); // the length before appending +// fBuffer.append(chars); +// appendStyleRun(styler, offset); +// return this; +// } /** * Sets a styler to use for the given source range. The range must be @@ -311,9 +321,9 @@ * length is greater than the length of this object. */ public void setStyle(int offset, int length, Styler styler) { - if (offset < 0 || offset + length > fBuffer.length()) { - throw new StringIndexOutOfBoundsException( - "Invalid offset (" + offset + ") or length (" + length + ")"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ + if (offset < 0 || offset + length > fBuffer.length) { + throw new IllegalArgumentException ( + Format( "Invalid offset ({}) or length ({})", offset, length )); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ } if (length is 0) { return; @@ -335,7 +345,7 @@ Styler prevStyle = endRun > 0 ? fStyleRuns.getRun(endRun - 1).style : null; fStyleRuns - .add(endRun, new StyleRun(offset + length, prevStyle)); + .addAt(endRun, new StyleRun(offset + length, prevStyle)); } } @@ -351,7 +361,7 @@ : null; if (isDifferentStyle(prevStyle, styler) || (startRun is 0 && styler !is null)) { - fStyleRuns.add(startRun, new StyleRun(offset, styler)); + fStyleRuns.addAt(startRun, new StyleRun(offset, styler)); endRun++; // endrun is moved one back } else { startRun--; // we use the previous @@ -371,25 +381,25 @@ */ public StyleRange[] getStyleRanges() { if (hasRuns()) { - ArrayList res = new ArrayList(); + StyleRange[] res; - List styleRuns = getStyleRuns(); + auto styleRuns = getStyleRuns(); int offset = 0; Styler style = null; for (int i = 0; i < styleRuns.size(); i++) { - StyleRun curr = (StyleRun) styleRuns.get(i); + StyleRun curr = cast(StyleRun) styleRuns.get(i); if (isDifferentStyle(curr.style, style)) { if (curr.offset > offset && style !is null) { - res.add(createStyleRange(offset, curr.offset, style)); + res ~= createStyleRange(offset, curr.offset, style); } offset = curr.offset; style = curr.style; } } if (fBuffer.length() > offset && style !is null) { - res.add(createStyleRange(offset, fBuffer.length(), style)); + res ~= createStyleRange(offset, fBuffer.length(), style); } - return (StyleRange[]) res.toArray(new StyleRange[res.size()]); + return res; } return EMPTY; } @@ -421,7 +431,7 @@ } private bool hasRuns() { - return fStyleRuns !is null && !fStyleRuns.isEmpty(); + return fStyleRuns !is null && !fStyleRuns.drained(); } private void appendStyleRun(Styler style, int offset) { @@ -433,7 +443,7 @@ if (lastRun is null && style !is null || lastRun !is null && isDifferentStyle(style, lastRun.style)) { - getStyleRuns().add(new StyleRun(offset, style)); + getStyleRuns().append(new StyleRun(offset, style)); } } @@ -441,17 +451,17 @@ if (style1 is null) { return style2 !is null; } - return !style1.equals(style2); + return !style1.opEquals(style2); } private StyleRun getLastRun() { - if (fStyleRuns is null || fStyleRuns.isEmpty()) { + if (fStyleRuns is null || fStyleRuns.drained()) { return null; } return fStyleRuns.getRun(fStyleRuns.size() - 1); } - private List getStyleRuns() { + private StyleRunList getStyleRuns() { if (fStyleRuns is null) fStyleRuns = new StyleRunList(); return fStyleRuns; @@ -471,20 +481,21 @@ } } - private static class StyleRunList : ArrayList { + private static class StyleRunList : ArraySeq!(Object) { private static final long serialVersionUID = 123L; public this() { - super(3); + super(); + capacity(3); } public StyleRun getRun(int index) { - return (StyleRun) get(index); + return cast(StyleRun) get(index); } - public void removeRange(int fromIndex, int toIndex) { - super.removeRange(fromIndex, toIndex); - } + //public void removeRange(int fromIndex, int toIndex) { + // super.removeRange(fromIndex, toIndex); + //} } private static class DefaultStyler : Styler { diff -r 4878bef4a38e -r 5df4896124c7 dwtx/jface/viewers/TableViewerFocusCellManager.d --- a/dwtx/jface/viewers/TableViewerFocusCellManager.d Thu May 22 04:03:58 2008 +0200 +++ b/dwtx/jface/viewers/TableViewerFocusCellManager.d Thu May 22 17:56:17 2008 +0200 @@ -89,13 +89,13 @@ public ViewerCell getFocusCell() { ViewerCell cell = super.getFocusCell(); - Table t = (Table) getViewer().getControl(); + Table t = cast(Table) getViewer().getControl(); // It is possible that the selection has changed under the hood if (cell !is null) { if (t.getSelection().length is 1 && t.getSelection()[0] !is cell.getItem()) { - setFocusCell(getViewer().getViewerRowFromItem( + setFocusCell(getViewer().getViewerRowFromItem_package( t.getSelection()[0]).getCell(cell.getColumnIndex())); } } diff -r 4878bef4a38e -r 5df4896124c7 dwtx/jface/viewers/TreeViewerFocusCellManager.d --- a/dwtx/jface/viewers/TreeViewerFocusCellManager.d Thu May 22 04:03:58 2008 +0200 +++ b/dwtx/jface/viewers/TreeViewerFocusCellManager.d Thu May 22 17:56:17 2008 +0200 @@ -86,8 +86,8 @@ } private bool isFirstColumnCell(ViewerCell cell) { - return cell.getViewerRow().getVisualIndex(cell.getColumnIndex()) is 0; - } + return cell.getViewerRow().getVisualIndex_package(cell.getColumnIndex()) is 0; + } }; } @@ -140,13 +140,13 @@ public ViewerCell getFocusCell() { ViewerCell cell = super.getFocusCell(); - Tree t = (Tree) getViewer().getControl(); + Tree t = cast(Tree) getViewer().getControl(); // It is possible that the selection has changed under the hood if (cell !is null) { if (t.getSelection().length is 1 && t.getSelection()[0] !is cell.getItem()) { - setFocusCell(getViewer().getViewerRowFromItem( + setFocusCell(getViewer().getViewerRowFromItem_package( t.getSelection()[0]).getCell(cell.getColumnIndex())); } } diff -r 4878bef4a38e -r 5df4896124c7 dwtx/jface/viewers/ViewerCell.d --- a/dwtx/jface/viewers/ViewerCell.d Thu May 22 04:03:58 2008 +0200 +++ b/dwtx/jface/viewers/ViewerCell.d Thu May 22 17:56:17 2008 +0200 @@ -44,24 +44,24 @@ /** * Constant denoting the cell above current one (value is 1). */ - public static int ABOVE = 1; + public static const int ABOVE = 1; /** * Constant denoting the cell below current one (value is 2). */ - public static int BELOW = 1 << 1; + public static const int BELOW = 1 << 1; /** * Constant denoting the cell to the left of the current one (value is 4). */ - public static int LEFT = 1 << 2; + public static const int LEFT = 1 << 2; /** * Constant denoting the cell to the right of the current one (value is 8). */ - public static int RIGHT = 1 << 3; + public static const int RIGHT = 1 << 3; - + /** * Create a new instance of the receiver on the row. * @@ -176,26 +176,26 @@ row.setImage(columnIndex, image); } - + /** * Set the style ranges to be applied on the text label * Note: Requires {@link StyledCellLabelProvider} with owner draw enabled. - * + * * @param styleRanges the styled ranges - * + * * @since 3.4 */ public void setStyleRanges(StyleRange[] styleRanges) { row.setStyleRanges(columnIndex, styleRanges); } - - + + /** * Returns the style ranges to be applied on the text label or null if no * style ranges have been set. - * + * * @return styleRanges the styled ranges - * + * * @since 3.4 */ public StyleRange[] getStyleRanges() { @@ -250,7 +250,7 @@ * @since 3.4 */ public int getVisualIndex() { - return row.getVisualIndex(getColumnIndex()); + return row.getVisualIndex_package(getColumnIndex()); } /** @@ -335,10 +335,10 @@ public Rectangle getTextBounds() { return row.getTextBounds(columnIndex); } - + /** - * Returns the location and bounds of the area where the image is drawn - * + * Returns the location and bounds of the area where the image is drawn + * * @return The bounds of the of the image area. May return null * if the underlying widget implementation doesn't provide this * information @@ -350,37 +350,37 @@ /** * Gets the foreground color of the cell. - * + * * @return the foreground of the cell or null for the default foreground - * + * * @since 3.4 */ public Color getForeground() { return row.getForeground(columnIndex); } - + /** * Gets the background color of the cell. - * + * * @return the background of the cell or null for the default background - * + * * @since 3.4 */ public Color getBackground() { return row.getBackground(columnIndex); } - + /** * Gets the font of the cell. - * + * * @return the font of the cell or null for the default font - * + * * @since 3.4 */ public Font getFont() { return row.getFont(columnIndex); } - + /* * (non-Javadoc) * diff -r 4878bef4a38e -r 5df4896124c7 dwtx/jface/viewers/ViewerColumn.d --- a/dwtx/jface/viewers/ViewerColumn.d Thu May 22 04:03:58 2008 +0200 +++ b/dwtx/jface/viewers/ViewerColumn.d Thu May 22 17:56:17 2008 +0200 @@ -34,9 +34,9 @@ * providers and editing support can be configured for each column separately. * Concrete subclasses of {@link ColumnViewer} should implement a matching * concrete subclass of {@link ViewerColumn}. - * + * * @since 3.3 - * + * */ public abstract class ViewerColumn { @@ -54,7 +54,7 @@ /** * Create a new instance of the receiver at columnIndex. - * + * * @param viewer * the viewer the column is part of * @param columnOwner @@ -87,7 +87,7 @@ /** * Return the label provider for the receiver. - * + * * @return ViewerLabelProvider */ /* package */CellLabelProvider getLabelProvider() { @@ -97,7 +97,7 @@ /** * Set the label provider for the column. Subclasses may extend but must * call the super implementation. - * + * * @param labelProvider * the new {@link CellLabelProvider} */ @@ -122,7 +122,7 @@ this.labelProvider = labelProvider; if (registerListener) { - this.labelProvider.initialize(viewer, this); + this.labelProvider.initialize_package(viewer, this); this.labelProvider.addListener(listener); listenerRegistered = true; } @@ -130,7 +130,7 @@ /** * Return the editing support for the receiver. - * + * * @return {@link EditingSupport} */ /* package */EditingSupport getEditingSupport() { @@ -155,7 +155,7 @@ * Refresh the cell for the given columnIndex. NOTE:the * {@link ViewerCell} provided to this method is no longer valid after this * method returns. Do not cache the cell for future use. - * + * * @param cell * {@link ViewerCell} */ @@ -188,9 +188,9 @@ /** * Returns the viewer of this viewer column. - * + * * @return Returns the viewer. - * + * * @since 3.4 */ public ColumnViewer getViewer() { diff -r 4878bef4a38e -r 5df4896124c7 dwtx/jface/viewers/ViewerRow.d --- a/dwtx/jface/viewers/ViewerRow.d Thu May 22 04:03:58 2008 +0200 +++ b/dwtx/jface/viewers/ViewerRow.d Thu May 22 17:56:17 2008 +0200 @@ -30,6 +30,7 @@ import dwtx.jface.util.Policy; import dwt.dwthelper.utils; +import tango.util.Convert; /** * ViewerRow is the abstract superclass of the part that represents items in a @@ -55,7 +56,7 @@ */ public static const int BELOW = 2; - private static final String KEY_TEXT_LAYOUT = Policy.JFACE + "styled_label_key_"; //$NON-NLS-1$ + private static const String KEY_TEXT_LAYOUT = Policy.JFACE ~ "styled_label_key_"; //$NON-NLS-1$ /** * Get the bounds of the entry at the columnIndex, @@ -301,6 +302,9 @@ protected int getVisualIndex(int creationIndex) { return creationIndex; } + package int getVisualIndex_package(int creationIndex) { + return getVisualIndex(creationIndex); + } /** * Translate the current column index (as shown in the UI) to the original @@ -319,6 +323,9 @@ protected int getCreationIndex(int visualIndex) { return visualIndex; } + package int getCreationIndex_package(int visualIndex) { + return getCreationIndex(visualIndex); + } /** * The location and bounds of the area where the text is drawn depends on @@ -360,7 +367,7 @@ * @since 3.4 */ public void setStyleRanges(int columnIndex, StyleRange[] styleRanges) { - getItem().setData(KEY_TEXT_LAYOUT + columnIndex, styleRanges); + getItem().setData(KEY_TEXT_LAYOUT ~ to!(String)(columnIndex), new ArrayWrapperT!(StyleRange)(styleRanges)); } @@ -374,6 +381,6 @@ * @since 3.4 */ public StyleRange[] getStyleRanges(int columnIndex) { - return (cast(ArrayWrapperT!(StyleRange)) getItem().getData(KEY_TEXT_LAYOUT + columnIndex)).array; + return (cast(ArrayWrapperT!(StyleRange)) getItem().getData(KEY_TEXT_LAYOUT ~ to!(String)(columnIndex))).array; } } diff -r 4878bef4a38e -r 5df4896124c7 dwtx/jface/window/ToolTip.d --- a/dwtx/jface/window/ToolTip.d Thu May 22 04:03:58 2008 +0200 +++ b/dwtx/jface/window/ToolTip.d Thu May 22 17:56:17 2008 +0200 @@ -34,7 +34,7 @@ import dwt.dwthelper.utils; import dwt.dwthelper.Runnable; - +import tango.core.Thread; /** * This class gives implementors to provide customized tooltips for any control. * @@ -107,8 +107,8 @@ * @see #RECREATE * @see #NO_RECREATE */ - public this(Control control, int style, bool manualActivation) { - this.control = control; + public this(Control control_, int style, bool manualActivation) { + this.control = control_; this.style = style; this.hideListener = new TooltipHideListener(); this.control.addDisposeListener(new class DisposeListener { @@ -122,18 +122,14 @@ this.listener = new ToolTipOwnerControlListener(); this.shellListener = new class Listener { - public void handleEvent(final Event event) { - if( this.outer.control !is null && ! this.outer.control.isDisposed() ) { - this.outer.control.getDisplay().asyncExec(new class Runnable { - - public void run() { - // Check if the new active shell is the tooltip itself - if( this.outer.control.getDisplay().getActiveShell() !is CURRENT_TOOLTIP) { - toolTipHide(CURRENT_TOOLTIP, event); - } + public void handleEvent(Event event) { + if( control_ !is null && ! control_.isDisposed() ) { + control_.getDisplay().asyncExec( dgRunnable( (Event event_){ + // Check if the new active shell is the tooltip itself + if( control_.getDisplay().getActiveShell() !is CURRENT_TOOLTIP) { + toolTipHide(CURRENT_TOOLTIP, event_); } - - }); + }, event)); } } }; diff -r 4878bef4a38e -r 5df4896124c7 dwtx/jface/wizard/ProgressMonitorPart.d --- a/dwtx/jface/wizard/ProgressMonitorPart.d Thu May 22 04:03:58 2008 +0200 +++ b/dwtx/jface/wizard/ProgressMonitorPart.d Thu May 22 17:56:17 2008 +0200 @@ -281,7 +281,7 @@ * @return String */ private String taskLabel() { - bool hasTask= fTaskName !is null && fTaskName.length() > 0; + bool hasTask= fTaskName !is null && fTaskName.length > 0; bool hasSubtask= fSubTaskName !is null && fSubTaskName.length > 0; if (hasTask) {