Mercurial > projects > dwt-addons
diff dwtx/jface/internal/ConfigureColumnsDialog.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/internal/ConfigureColumnsDialog.d Thu May 22 01:36:46 2008 +0200 +++ b/dwtx/jface/internal/ConfigureColumnsDialog.d Thu May 22 04:03:58 2008 +0200 @@ -35,11 +35,13 @@ import dwtx.jface.resource.JFaceResources; import dwtx.jface.window.IShellProvider; +import dwt.dwthelper.utils; + /** * NON-API - This class is internal and will be moved to another package in 3.5. - * + * */ -public class ConfigureColumnsDialog extends Dialog { +public class ConfigureColumnsDialog : Dialog { private Control targetControl; private ColumnObject[] columnObjects; @@ -59,7 +61,7 @@ bool moveable; bool resizable; - ColumnObject(Item column, int index, String text, Image image, + this(Item column, int index, String text, Image image, int width, bool moveable, bool resizable, bool visible) { this.column = column; this.index = index; @@ -77,11 +79,11 @@ * 3.5. Creates a new dialog for configuring columns of the given column * viewer. The column viewer must have an underlying {@link Tree} or {@link * Table}, other controls are not supported. - * + * * @param shellProvider * @param table */ - public ConfigureColumnsDialog(IShellProvider shellProvider, Table table) { + public this(IShellProvider shellProvider, Table table) { this(shellProvider, (Control) table); } @@ -90,11 +92,11 @@ * 3.5. Creates a new dialog for configuring columns of the given column * viewer. The column viewer must have an underlying {@link Tree} or {@link * Table}, other controls are not supported. - * + * * @param shellProvider * @param tree */ - public ConfigureColumnsDialog(IShellProvider shellProvider, Tree tree) { + public this(IShellProvider shellProvider, Tree tree) { this(shellProvider, (Control) tree); } @@ -102,7 +104,7 @@ * @param shellProvider * @param control */ - private ConfigureColumnsDialog(IShellProvider shellProvider, Control control) { + private this(IShellProvider shellProvider, Control control) { super(shellProvider); this.targetControl = control; this.moveableColumnsFound = createColumnObjects(); @@ -117,7 +119,7 @@ getShell().setText( JFaceResources.getString("ConfigureColumnsDialog_Title")); //$NON-NLS-1$ } - + protected void initializeBounds() { super.initializeBounds(); table.setSelection(0); @@ -152,10 +154,10 @@ * @return */ private Image getColumnImage(Item item) { - if (item instanceof TableColumn) { - return ((TableColumn) item).getImage(); - } else if (item instanceof TreeColumn) { - return ((TreeColumn) item).getImage(); + if (null !is cast(TableColumn)item ) { + return (cast(TableColumn) item).getImage(); + } else if (null !is cast(TreeColumn)item ) { + return (cast(TreeColumn) item).getImage(); } return null; } @@ -164,10 +166,10 @@ * @return */ private int[] getColumnOrder() { - if (targetControl instanceof Table) { - return ((Table) targetControl).getColumnOrder(); - } else if (targetControl instanceof Tree) { - return ((Tree) targetControl).getColumnOrder(); + if (null !is cast(Table)targetControl ) { + return (cast(Table) targetControl).getColumnOrder(); + } else if (null !is cast(Tree)targetControl ) { + return (cast(Tree) targetControl).getColumnOrder(); } return new int[0]; } @@ -177,10 +179,10 @@ * @return */ private bool getMoveable(Item item) { - if (item instanceof TableColumn) { - return ((TableColumn) item).getMoveable(); - } else if (item instanceof TreeColumn) { - return ((TreeColumn) item).getMoveable(); + if (null !is cast(TableColumn)item ) { + return (cast(TableColumn) item).getMoveable(); + } else if (null !is cast(TreeColumn)item ) { + return (cast(TreeColumn) item).getMoveable(); } return false; } @@ -190,16 +192,16 @@ * @return */ private bool getResizable(Item item) { - if (item instanceof TableColumn) { - return ((TableColumn) item).getResizable(); - } else if (item instanceof TreeColumn) { - return ((TreeColumn) item).getResizable(); + if (null !is cast(TableColumn)item ) { + return (cast(TableColumn) item).getResizable(); + } else if (null !is cast(TreeColumn)item ) { + return (cast(TreeColumn) item).getResizable(); } return false; } protected Control createDialogArea(Composite parent) { - Composite composite = (Composite) super.createDialogArea(parent); + Composite composite = cast(Composite) super.createDialogArea(parent); table = new Table(composite, DWT.BORDER | DWT.SINGLE | DWT.V_SCROLL | DWT.H_SCROLL | DWT.FULL_SELECTION /* @@ -219,7 +221,7 @@ upButton = new Button(composite, DWT.PUSH); upButton.setText(JFaceResources .getString("ConfigureColumnsDialog_up")); //$NON-NLS-1$ - upButton.addListener(DWT.Selection, new Listener() { + upButton.addListener(DWT.Selection, new class Listener { public void handleEvent(Event event) { handleMove(table, true); } @@ -228,7 +230,7 @@ downButton = new Button(composite, DWT.PUSH); downButton.setText(JFaceResources .getString("ConfigureColumnsDialog_down")); //$NON-NLS-1$ - downButton.addListener(DWT.Selection, new Listener() { + downButton.addListener(DWT.Selection, new class Listener { public void handleEvent(Event event) { handleMove(table, false); } @@ -257,12 +259,12 @@ GridLayoutFactory.swtDefaults().numColumns(numColumns).applyTo( composite); - table.addListener(DWT.Selection, new Listener() { + table.addListener(DWT.Selection, new class Listener { public void handleEvent(Event event) { handleSelectionChanged(table.indexOf((TableItem) event.item)); } }); - text.addListener(DWT.Modify, new Listener() { + text.addListener(DWT.Modify, new class Listener { public void handleEvent(Event event) { ColumnObject columnObject = columnObjects[table .getSelectionIndex()]; @@ -303,7 +305,7 @@ handleSelectionChanged(newIndex); } - private void createLabel(final Composite composite, String string) { + private void createLabel(Composite composite, String string) { Label label = new Label(composite, DWT.NONE); label.setText(string); } @@ -314,15 +316,15 @@ */ private String getColumnName(Item item) { String result = ""; //$NON-NLS-1$ - if (item instanceof TableColumn) { - result = ((TableColumn) item).getText(); + if (null !is cast(TableColumn)item ) { + result = (cast(TableColumn) item).getText(); if (result.trim().equals("")) { //$NON-NLS-1$ result = ((TableColumn) item).getToolTipText(); } - } else if (item instanceof TreeColumn) { - result = ((TreeColumn) item).getText(); + } else if (null !is cast(TreeColumn)item ) { + result = (cast(TreeColumn) item).getText(); if (result.trim().equals("")) { //$NON-NLS-1$ - result = ((TreeColumn) item).getToolTipText(); + result = (cast(TreeColumn) item).getToolTipText(); } } return result; @@ -333,10 +335,10 @@ * @return */ private int getColumnWidth(Item item) { - if (item instanceof TableColumn) { - return ((TableColumn) item).getWidth(); - } else if (item instanceof TreeColumn) { - return ((TreeColumn) item).getWidth(); + if (null !is cast(TableColumn)item ) { + return (cast(TableColumn) item).getWidth(); + } else if (null !is cast(TreeColumn)item ) { + return (cast(TreeColumn) item).getWidth(); } return 0; } @@ -345,10 +347,10 @@ * @return */ private Item[] getViewerColumns() { - if (targetControl instanceof Table) { - return ((Table) targetControl).getColumns(); - } else if (targetControl instanceof Tree) { - return ((Tree) targetControl).getColumns(); + if (null !is cast(Table)targetControl ) { + return (cast(Table) targetControl).getColumns(); + } else if (null !is cast(Tree)targetControl ) { + return (cast(Tree) targetControl).getColumns(); } return new Item[0]; } @@ -380,10 +382,10 @@ * @param width */ private void setColumnWidth(Item item, int width) { - if (item instanceof TableColumn) { - ((TableColumn) item).setWidth(width); - } else if (item instanceof TreeColumn) { - ((TreeColumn) item).setWidth(width); + if (null !is cast(TableColumn)item ) { + (cast(TableColumn) item).setWidth(width); + } else if (null !is cast(TreeColumn)item ) { + (cast(TreeColumn) item).setWidth(width); } } @@ -391,10 +393,10 @@ * @param columnOrder */ private void setColumnOrder(int[] order) { - if (targetControl instanceof Table) { - ((Table) targetControl).setColumnOrder(order); - } else if (targetControl instanceof Tree) { - ((Tree) targetControl).setColumnOrder(order); + if (null !is cast(Table)targetControl ) { + (cast(Table) targetControl).setColumnOrder(order); + } else if (null !is cast(Tree)targetControl ) { + (cast(Tree) targetControl).setColumnOrder(order); } } }