Mercurial > projects > dwt-samples
changeset 58:3b18f03b2f41
images into the res folder, first working jface example
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Thu, 10 Apr 2008 09:12:59 +0200 |
parents | d7e6c648cb57 |
children | 6fb20f548c46 |
files | .hgignore dsss.conf dwtexamples/controlexample/ControlExample.d dwtsnippets/images/cancel.gif dwtsnippets/images/eclipse.png dwtsnippets/images/region_shell.gif dwtsnippets/spinner/Snippet190.d dwtsnippets/table/Snippet38.d dwtsnippets/text/Snippet258.d jface/ActionAndStatusbar.d res/cancel.gif res/eclipse.png res/region_shell.gif |
diffstat | 13 files changed, 147 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgignore Thu Apr 10 10:36:33 2008 +0900 +++ b/.hgignore Thu Apr 10 09:12:59 2008 +0200 @@ -22,3 +22,5 @@ ^user/drawingboard/DrawingBoard$ ^user/dragdrop/texttolabel$ +^jface/ActionAndStatusbar$ +
--- a/dsss.conf Thu Apr 10 10:36:33 2008 +0900 +++ b/dsss.conf Thu Apr 10 09:12:59 2008 +0200 @@ -4,7 +4,7 @@ #used for dwtsnippets/text/Snippet258 #dwtsnippets/expandbar/Snippet223 -buildflags+=-Jdwtsnippets/images +buildflags+=-Jres version(Windows){ #buildflags+= -L/SUBSYSTEM:windows:5 @@ -20,7 +20,6 @@ #buildflags+= -L-lDD-tango-util #} -#[jfacesimple.d] [dwtexamples/simple.d] [dwtexamples/clipboard/ClipboardExample.d] [dwtexamples/helloworld/HelloWorld1.d] @@ -119,3 +118,8 @@ buildflags+= -L/rc:dwt } buildflags+=-Jdwtexamples/texteditor + + +[jface/ActionAndStatusbar.d] + +
--- a/dwtexamples/controlexample/ControlExample.d Thu Apr 10 10:36:33 2008 +0900 +++ b/dwtexamples/controlexample/ControlExample.d Thu Apr 10 09:12:59 2008 +0200 @@ -57,6 +57,7 @@ import tango.text.convert.Format; import tango.io.Stdout; import Math = tango.math.Math; +import dwt.dwthelper.utils; version(JIVE){ import jive.stacktrace; @@ -215,6 +216,8 @@ char[] res; try { res = resourceBundle.getString(key); + } catch (MissingResourceException e) { + return key; } catch (NoSuchElementException e) { return key; }
--- a/dwtsnippets/spinner/Snippet190.d Thu Apr 10 10:36:33 2008 +0900 +++ b/dwtsnippets/spinner/Snippet190.d Thu Apr 10 09:12:59 2008 +0200 @@ -25,10 +25,10 @@ /* * Floating point values in Spinner - * + * * For a list of all DWT example snippets see * http://www.eclipse.org/swt/snippets/ - * + * * @since 3.1 */
--- a/dwtsnippets/table/Snippet38.d Thu Apr 10 10:36:33 2008 +0900 +++ b/dwtsnippets/table/Snippet38.d Thu Apr 10 09:12:59 2008 +0200 @@ -1,4 +1,4 @@ -/******************************************************************************* +/******************************************************************************* * Copyright (c) 2000, 2004 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 @@ -34,10 +34,11 @@ table.setLinesVisible (true); table.setHeaderVisible (true); char[][] titles = [" ", "C", "!", "Description", "Resource", "In Folder", "Location"]; - foreach (title; titles) { - auto column = new TableColumn (table, DWT.NONE); + int[] styles = [DWT.NONE, DWT.LEFT, DWT.RIGHT, DWT.CENTER, DWT.NONE, DWT.NONE, DWT.NONE]; + foreach (i,title; titles) { + auto column = new TableColumn (table, styles[i]); column.setText (title); - } + } int count = 128; for (int i=0; i<count; i++) { auto item = new TableItem (table, DWT.NONE); @@ -51,7 +52,7 @@ } for (int i=0; i<titles.length; i++) { table.getColumn (i).pack (); - } + } table.setSize (table.computeSize (DWT.DEFAULT, 200)); shell.pack (); shell.open ();
--- a/dwtsnippets/text/Snippet258.d Thu Apr 10 10:36:33 2008 +0900 +++ b/dwtsnippets/text/Snippet258.d Thu Apr 10 09:12:59 2008 +0200 @@ -73,6 +73,6 @@ while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } - if (image != null) image.dispose(); + if (image !is null) image.dispose(); display.dispose(); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jface/ActionAndStatusbar.d Thu Apr 10 09:12:59 2008 +0200 @@ -0,0 +1,127 @@ +/* +DWT/JFace in Action +GUI Design with Eclipse 3.0 +Matthew Scarpino, Stephen Holder, Stanford Ng, and Laurent Mihalkovic + +ISBN: 1932394273 + +Publisher: Manning + +Port to the D programming language: + Frank Benoit <benoit@tionex.de> +*/ +module jfacestatusbar; + +import dwtx.jface.action.Action; +import dwtx.jface.action.ActionContributionItem; +import dwtx.jface.action.MenuManager; +import dwtx.jface.action.StatusLineManager; +import dwtx.jface.action.ToolBarManager; +import dwtx.jface.resource.ImageDescriptor; +import dwtx.jface.window.ApplicationWindow; +import dwtx.core.runtime.IProgressMonitor; +import dwt.DWT; +import dwt.widgets.Composite; +import dwt.widgets.Control; +import dwt.widgets.Display; + +import tango.text.convert.Format; +import jive.stacktrace; +import dwt.dwthelper.utils; +import dwt.dwthelper.Runnable; + +void main() { + Ch4_Contributions swin = new Ch4_Contributions(); + swin.setBlockOnOpen(true); + swin.open(); + Display.getCurrent().dispose(); +} + +public class Ch4_Contributions : ApplicationWindow { + StatusLineManager slm; + + Ch4_StatusAction status_action; + + ActionContributionItem aci; + + public this() { + super(null); + slm = new StatusLineManager(); + status_action = new Ch4_StatusAction(slm); + aci = new ActionContributionItem(status_action); + addStatusLine(); + addMenuBar(); + addToolBar(DWT.FLAT | DWT.WRAP); + } + + protected Control createContents(Composite parent) { + getShell().setText("Action/Contribution Example"); + parent.setSize(290, 150); + aci.fill(parent); + return parent; + } + + protected MenuManager createMenuManager() { + MenuManager main_menu = new MenuManager(null); + MenuManager action_menu = new MenuManager("Menu"); + main_menu.add(action_menu); + action_menu.add(status_action); + return main_menu; + } + + protected ToolBarManager createToolBarManager(int style) { + ToolBarManager tool_bar_manager = new ToolBarManager(style); + tool_bar_manager.add(status_action); + return tool_bar_manager; + } + + protected StatusLineManager createStatusLineManager() { + return slm; + } +} + +class Ch4_StatusAction : Action { + StatusLineManager statman; + + short triggercount = 0; + + public this(StatusLineManager sm) { + super("&Trigger@Ctrl+T", AS_PUSH_BUTTON); + statman = sm; + setToolTipText("Trigger the Action"); + setImageDescriptor(ImageDescriptor.createFromFile( + getImportData!("eclipse-icon-red-16.png"))); + //getImportData!("cancel.gif"))); + } + + public void run() { + triggercount++; + statman.setMessage( Format("The status action has fired. Count: {}", triggercount)); + + if( triggercount % 5 == 0 ){ + statman.setCancelEnabled(true); + auto pm = statman.getProgressMonitor(); + pm.setCanceled(false); + pm.beginTask( "Task", 100 ); + auto runner = new class(pm) Runnable { + IProgressMonitor pm; + int w; + this(IProgressMonitor a){ + this.pm = a; + } + void run(){ + const incr = 2; + this.pm.worked( incr ); + w += incr; + if( w < 100 && !this.pm.isCanceled() ){ + Display.getCurrent().timerExec( 100, this); + } + else{ + this.pm.done(); + } + } + }; + Display.getCurrent().syncExec(runner); + } + } +} \ No newline at end of file