|
Archives
D Programming
digitalmars.Ddigitalmars.D.bugs digitalmars.D.dtl digitalmars.D.ide digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger D.gnu D C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript electronics |
digitalmars.D.dwt - What's the problem with IMenuListener
switched to dwt2, jface IMenuListener causes problem, the gui is not responsed when acition.sebEnalbed(false), how to fix this? thanks! -- yidabu <yidabu.spam gmail.com> http://www.dsource.org/projects/dwin/ D 语言-中文(D Chinese): http://www.d-programming-language-china.org/ http://bbs.d-programming-language-china.org/ http://dwin.d-programming-language-china.org/ http://scite4d.d-programming-language-china.org/ Apr 05 2009
yidabu schrieb:switched to dwt2, jface IMenuListener causes problem, the gui is not responsed when acition.sebEnalbed(false), how to fix this? thanks! Apr 05 2009
yidabu schrieb:dynamic change Action's text in menuAboutToShow, will get exception: rg.eclipse.swt.SWTException.SWTException: Failed to execute runnable object.Exception: Access Violation - Read at address 0x9090911b Apr 08 2009
On Sun, 05 Apr 2009 13:59:58 +0200 Frank Benoit <keinfarbton googlemail.com> wrote:yidabu schrieb:switched to dwt2, jface IMenuListener causes problem, the gui is not responsed when acition.sebEnalbed(false), how to fix this? thanks! Apr 05 2009
On Mon, 6 Apr 2009 09:28:24 +0800 yidabu <dyuyan.spam gmail.com> wrote:On Sun, 05 Apr 2009 13:59:58 +0200 Frank Benoit <keinfarbton googlemail.com> wrote:yidabu schrieb:switched to dwt2, jface IMenuListener causes problem, the gui is not responsed when acition.sebEnalbed(false), how to fix this? thanks! Apr 05 2009
On Mon, 6 Apr 2009 12:18:15 +0800 yidabu <dyuyan.spam gmail.com> wrote:On Mon, 6 Apr 2009 09:28:24 +0800 yidabu <dyuyan.spam gmail.com> wrote:On Sun, 05 Apr 2009 13:59:58 +0200 Frank Benoit <keinfarbton googlemail.com> wrote:yidabu schrieb:switched to dwt2, jface IMenuListener causes problem, the gui is not responsed when acition.sebEnalbed(false), how to fix this? thanks! Apr 06 2009
On Sun, 05 Apr 2009 13:59:58 +0200 Frank Benoit <keinfarbton googlemail.com> wrote:yidabu schrieb:switched to dwt2, jface IMenuListener causes problem, the gui is not responsed when acition.sebEnalbed(false), how to fix this? thanks! Apr 07 2009
dynamic change Action's text in menuAboutToShow, will get exception: rg.eclipse.swt.SWTException.SWTException: Failed to execute runnable object.Exception: Access Violation - Read at address 0x9090911b /******************************************************************************* * Copyright (c) 2006 Tom Schindl 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 * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Tom Schindl - initial API and implementation * Port to the D programming language: * wbaxter at gmail dot com *******************************************************************************/ module org.eclipse.jface.snippets.viewers.Snippet002TreeViewer; import org.eclipse.swt.SWT; import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.viewers.Viewer; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import java.lang.all; import tango.util.Convert; import tango.math.random.Kiss; import tango.io.Stdout; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.Action; import org.eclipse.jface.resource.ImageDescriptor; /** * A simple TreeViewer to demonstrate usage * * author Tom Schindl <tom.schindl bestsolution.at> * */ class Snippet002TreeViewer { private class MyContentProvider : ITreeContentProvider { /* (non-Javadoc) * see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) */ public Object[] getElements(Object inputElement) { return (cast(MyModel)inputElement).child/*.dup*/; } /* (non-Javadoc) * see org.eclipse.jface.viewers.IContentProvider#dispose() */ public void dispose() { } /* (non-Javadoc) * see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.j ace.viewers.Viewer, java.lang.Object, java.lang.Object) */ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } /* (non-Javadoc) * see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object) */ public Object[] getChildren(Object parentElement) { return getElements(parentElement); } /* (non-Javadoc) * see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object) */ public Object getParent(Object element) { if( element is null) { return null; } return (cast(MyModel)element).parent; } /* (non-Javadoc) * see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object) */ public bool hasChildren(Object element) { return (cast(MyModel)element).child.length > 0; } } public class MyModel { public MyModel parent; public MyModel[] child; public int counter; public this(int counter, MyModel parent) { this.parent = parent; this.counter = counter; } public String toString() { String rv = "Item "; if( parent !is null ) { rv = parent.toString() ~ "."; } rv ~= to!(char[])(counter); return rv; } } public class TestAction : Action { public this() { super("&Test Action Ctrl+X", ImageDescriptor.createFromFile(getImportData!("eclipse-red-16.png"))); //super("&Test Action Ctrl+X", null); } public void run() { } } public class Test2Action : Action { public this() { super("&Test2 Action Ctrl+X", ImageDescriptor.createFromFile(getImportData!("eclipse-red-16.png"))); //super("&Test Action Ctrl+X", null); } public void run() { } } class MyListener : IMenuListener { void menuAboutToShow(IMenuManager manager) { auto t = Kiss.instance.natural(0,2); if( t == 0) { testAction.setText("&new Test Action Ctrl+Alt+C"); manager.add(testAction); test2Action.setText("new Test2 Action"); manager.add(test2Action); } else { testAction.setText("Test Action Ctrl+Alt+T"); manager.add(testAction); } } } // TestAction testAction; Test2Action test2Action; public this(Shell shell) { testAction = new TestAction(); test2Action = new Test2Action(); TreeViewer v = new TreeViewer(shell); v.setLabelProvider(new LabelProvider()); v.setContentProvider(new MyContentProvider()); v.setInput(createModel()); auto menuManager = new MenuManager(); menuManager.setRemoveAllWhenShown(true); menuManager.addMenuListener( new MyListener()); auto menu = menuManager.createContextMenu( v.getControl() ); v.getControl.setMenu( menu ); } private MyModel createModel() { MyModel root = new MyModel(0,null); root.counter = 0; MyModel tmp; for( int i = 1; i < 10; i++ ) { tmp = new MyModel(i, root); root.child ~= tmp; for( int j = 1; j < i; j++ ) { tmp.child ~= new MyModel(j,tmp); } } return root; } } void main() { Display display = new Display (); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); new Snippet002TreeViewer(shell); shell.open (); while (!shell.isDisposed ()) { if (!display.readAndDispatch ()) display.sleep (); } display.dispose (); } -- yidabu <yidabu.spam gmail.com> http://www.dsource.org/projects/dwin/ D 语言-中文(D Chinese): http://www.d-programming-language-china.org/ http://bbs.d-programming-language-china.org/ http://dwin.d-programming-language-china.org/ http://scite4d.d-programming-language-china.org/ Apr 08 2009
|