www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.dwt - What's the problem with IMenuListener

reply yidabu <dyuyan.spam gmail.com> writes:
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
next sibling parent reply Frank Benoit <keinfarbton googlemail.com> writes:
yidabu schrieb:
 switched to dwt2, jface IMenuListener causes problem, the gui is not responsed
when acition.sebEnalbed(false), how to fix this?
 
 thanks!
 
 

Like you reported in the IRC, this is solved. Frank
Apr 05 2009
parent Frank Benoit <keinfarbton googlemail.com> writes:
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
 
 

Thanks for this test case. It is fixed now. http://hg.dsource.org/projects/dwt2/rev/bf0426bfc6e0
Apr 08 2009
prev sibling next sibling parent yidabu <dyuyan.spam gmail.com> writes:
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!
 
 

Like you reported in the IRC, this is solved. Frank

seems still not works. I tried another app, Singleton removed from MenuListener, problem again. I Tried to build dwt2 lib by dsss, get error: dwt2\org.eclipse.core.jobs\src\org\eclipse\core\internal\jobs\Worker.d(24): modu le org.eclipse.osgi.util.NLS is in multiple packages org.eclipse.osgi.util.NLS dwt2\org.eclipse.core.runtime\src\org\eclipse\core\runtime\ILog.d(19): module or g.eclipse.osgi.framework.Bundle is in multiple packages org.eclipse.osgi.framewo rk.Bundle dwt2\org.eclipse.text\src\org\eclipse\jface\text\templates\TemplateTranslator.d( 29): module java.util.LinkedHashmap is in multiple packages java.util.LinkedHash map fiexed the name issues, to build dwt2.lib by dsss 0.75 now, It will take several hours to build.... -- 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
prev sibling next sibling parent yidabu <dyuyan.spam gmail.com> writes:
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!
 
 

Like you reported in the IRC, this is solved. Frank

seems still not works. I tried another app, Singleton removed from MenuListener, problem again. I Tried to build dwt2 lib by dsss, get error: dwt2\org.eclipse.core.jobs\src\org\eclipse\core\internal\jobs\Worker.d(24): modu le org.eclipse.osgi.util.NLS is in multiple packages org.eclipse.osgi.util.NLS dwt2\org.eclipse.core.runtime\src\org\eclipse\core\runtime\ILog.d(19): module or g.eclipse.osgi.framework.Bundle is in multiple packages org.eclipse.osgi.framewo rk.Bundle dwt2\org.eclipse.text\src\org\eclipse\jface\text\templates\TemplateTranslator.d( 29): module java.util.LinkedHashmap is in multiple packages java.util.LinkedHash map fiexed the name issues, to build dwt2.lib by dsss 0.75 now, It will take several hours to build....

Building org.eclipse.core.jobs org\eclipse\core\internal\jobs\WorkerPool.d(84): redundant protection attribute org\eclipse\core\internal\jobs\WorkerPool.d(167): redundant protection attribute org\eclipse\core\internal\jobs\ThreadJob.d(80): redundant protection attribute org\eclipse\core\internal\jobs\InternalJob.d(178): redundant protection attribut e org\eclipse\core\internal\jobs\InternalJob.d(185): redundant protection attribut e org\eclipse\core\internal\jobs\InternalJob.d(227): redundant protection attribut e org\eclipse\core\internal\jobs\InternalJob.d(259): redundant protection attribut e rake aborted! compile error module org.eclipse.core.runtime.Platform Line:27 import org.eclipse.osgi.framework.Bundle; should be: import osgi.framework.Bundle; -- 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
prev sibling next sibling parent yidabu <dyuyan.spam gmail.com> writes:
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!
 
 

Like you reported in the IRC, this is solved. Frank

seems still not works. I tried another app, Singleton removed from MenuListener, problem again. I Tried to build dwt2 lib by dsss, get error: dwt2\org.eclipse.core.jobs\src\org\eclipse\core\internal\jobs\Worker.d(24): modu le org.eclipse.osgi.util.NLS is in multiple packages org.eclipse.osgi.util.NLS dwt2\org.eclipse.core.runtime\src\org\eclipse\core\runtime\ILog.d(19): module or g.eclipse.osgi.framework.Bundle is in multiple packages org.eclipse.osgi.framewo rk.Bundle dwt2\org.eclipse.text\src\org\eclipse\jface\text\templates\TemplateTranslator.d( 29): module java.util.LinkedHashmap is in multiple packages java.util.LinkedHash map fiexed the name issues, to build dwt2.lib by dsss 0.75 now, It will take several hours to build....

Building org.eclipse.core.jobs org\eclipse\core\internal\jobs\WorkerPool.d(84): redundant protection attribute org\eclipse\core\internal\jobs\WorkerPool.d(167): redundant protection attribute org\eclipse\core\internal\jobs\ThreadJob.d(80): redundant protection attribute org\eclipse\core\internal\jobs\InternalJob.d(178): redundant protection attribut e org\eclipse\core\internal\jobs\InternalJob.d(185): redundant protection attribut e org\eclipse\core\internal\jobs\InternalJob.d(227): redundant protection attribut e org\eclipse\core\internal\jobs\InternalJob.d(259): redundant protection attribut e rake aborted! compile error module org.eclipse.core.runtime.Platform Line:27 import org.eclipse.osgi.framework.Bundle; should be: import osgi.framework.Bundle;

build dwt2.lib by dsss 0.75, the problem is not solved, but the exe size is went down from 10.9 MB to 4.9 MB (the old one with dwt-win, dmd 1.037 is 4.3MB) -- 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 06 2009
prev sibling next sibling parent yidabu <dyuyan.spam gmail.com> writes:
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!
 
 

Like you reported in the IRC, this is solved. Frank

captured exception by ddbg when mouse right click on treeviewer: Unhandled Exception: EXCEPTION_ACCESS_VIOLATION(0xc0000005) at org.eclipse.jface.action.ActionContributionItem.ActionContributionItem.actionPropertyChange.org.eclipse.jface.util.PropertyChangeEvent.PropertyChangeEvent.__dgliteral1.org.eclipse.jface.util.PropertyChangeEvent PropertyChangeEvent org.eclipse.jface\src\org\eclipse\jface\action\ActionCo tributionItem.d:193 (0x004830fd) thread(3436) ->us #0 org.eclipse.jface.action.ActionContributionItem.ActionContributionItem. ctionPropertyChange () at org.eclipse.jface\src\org\eclipse\jface\action\ActionContributionItem.d:193 #1 0x0048565a in java.lang.Runnable._DgRunnableT! () at imp\java\lang\Runnable.di:57 #2 0x00572f19 in void org.eclipse.swt.widgets.RunnableLock.RunnableLock.run(void*) () from RunnableLock what's the exceptin means? I tested a sample code, it's works fine, I can not give you a sample to reproduce the exception. It seems a thread issue with my code, how to fix this? the app works fine with dwt-win, dmd 1.037 and dsss(lib), now I built dwt2.lib by dsss, get the sampe exception. I ported my code to dwt2, I spend twot days to tried to figured the thread issue out, but failed. thanks! My code like this: auto menuManager = new MenuManager("#PopUp"); menuManager.setRemoveAllWhenShown(true); menuManager.addMenuListener(new MyMenuListener); auto menu = menuManager.createContextMenu( treeViewer.getTree() ); treeViewer.getTree.setMenu( menu ); class MyMenuListener : IMenuListener { void menuAboutToShow(IMenuManager manager) { fillContextMenu(manager); } } public class TestAction : Action { public this() { super( "test", null); } void run() {} } void fillContextMenu(IMenuManager manager) { manager.add( new TestAction ); } -- 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 07 2009
prev sibling parent yidabu <dyuyan.spam gmail.com> writes:
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