1 26 package org.objectweb.util.explorer.interpreter.lib.swt; 27 28 import org.eclipse.swt.SWT; 29 import org.eclipse.swt.widgets.Event; 30 import org.eclipse.swt.widgets.Listener; 31 import org.eclipse.swt.widgets.MessageBox; 32 import org.objectweb.util.explorer.api.MenuItem; 33 import org.objectweb.util.explorer.api.MenuItemTreeView; 34 import org.objectweb.util.explorer.core.menu.api.MenuItemTreeViewConfiguration; 35 import org.objectweb.util.explorer.swt.lib.DynamicTree; 36 import org.objectweb.util.trace.TraceSystem; 37 38 46 public class GenericAction 47 implements Listener 48 { 49 50 56 protected MenuItem delegate_; 57 protected MenuItemTreeView treeView_; 58 59 65 public GenericAction(MenuItem action, MenuItemTreeView treeView){ 66 delegate_ = action; 67 treeView_ = treeView; 68 } 69 70 76 82 85 public void handleEvent(Event event) { 86 try{ 87 ((MenuItemTreeViewConfiguration)treeView_).setEvent(event); 88 delegate_.actionPerformed(treeView_); 89 } catch (Exception e) { 90 TraceSystem.get("explorer").warn(getClass().getName() + ", " + e.getClass().getName() + ": "+ e.getMessage()); 91 MessageBox mb = new MessageBox(DynamicTree.shell_, SWT.ICON_ERROR | SWT.OK); 92 mb.setMessage(e.getClass().getName() + ":\n" + e.getMessage()); 93 mb.setText("Exception (" + event.widget + ")"); 94 mb.open(); 95 } 96 treeView_.getTree().refreshAll(); 97 } 98 99 } 100 | Popular Tags |