StartSimulate.java
Go to the documentation of this file.
1 package com.generalrobotix.ui.actions;
2 
3 import org.eclipse.jface.action.ActionContributionItem;
4 import org.eclipse.jface.action.IAction;
5 import org.eclipse.jface.action.IContributionItem;
6 import org.eclipse.jface.action.ICoolBarManager;
7 import org.eclipse.jface.action.IToolBarManager;
8 import org.eclipse.jface.action.ToolBarContributionItem;
9 import org.eclipse.jface.viewers.ISelection;
10 import org.eclipse.jface.window.ApplicationWindow;
11 import org.eclipse.ui.IWorkbenchWindow;
12 import org.eclipse.ui.IWorkbenchWindowActionDelegate;
13 import org.eclipse.ui.PlatformUI;
14 
24 
25 public class StartSimulate implements IWorkbenchWindowActionDelegate, GrxItemChangeListener, GrxObserver {
26  private IAction action_ = null;
28 
29  public StartSimulate() {
30  setUp();
32  manager_.registerItemChangeListener(this, GrxSimulationItem.class);
33  }
34 
35  public void setUp(){
36  if(simItem_ != null)
39  simItem_ = manager_.<GrxSimulationItem>getSelectedItem(GrxSimulationItem.class, null);
40  if(simItem_!=null){
41  simItem_.addObserver(this);
42  }
43  }
44 
45  public void run(IAction action) {
46  action_ = action;
48  if(simItem_==null){
49  simItem_ = (GrxSimulationItem)manager_.createItem(GrxSimulationItem.class, null);
50  simItem_.addObserver(this);
52  manager_.setSelectedItem(simItem_, true);
53  }
54  if(simItem_.isSimulating()){
55  action_.setEnabled(false);
57  }else {
58  action_.setEnabled(false);
59  if(!simItem_.startSimulation(true))
60  action_.setEnabled(true);
61  }
62  }
63 
64  public void selectionChanged(IAction action, ISelection selection) {}
65  public void dispose() {
66  }
67  public void init(IWorkbenchWindow window) {}
68 
69  public void setActionImage(boolean start){
70  if(action_==null)
72  if(start){
73  action_.setToolTipText(MessageBundle.get("GrxOpenHRPView.text.stop")); //$NON-NLS-1$
74  action_.setText(MessageBundle.get("GrxOpenHRPView.menu.stop")); //$NON-NLS-1$
75  action_.setImageDescriptor(Activator.getDefault().getDescriptor("sim_stop.png")); //$NON-NLS-1$
76  }else{
77  action_.setToolTipText(MessageBundle.get("GrxOpenHRPView.text.start")); //$NON-NLS-1$
78  action_.setText(MessageBundle.get("GrxOpenHRPView.menu.start")); //$NON-NLS-1$
79  action_.setImageDescriptor(Activator.getDefault().getDescriptor("sim_start.png")); //$NON-NLS-1$
80  }
81  }
82 
83  private IAction getStartSimulationAction()
84  {
85  IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
86  for(IWorkbenchWindow w : windows){
87  if(!(w instanceof ApplicationWindow))
88  continue;
89  ApplicationWindow window = (ApplicationWindow)w;
90  ICoolBarManager coolbar = window.getCoolBarManager2();
91  if(coolbar == null)
92  continue;
93  IContributionItem setitem = coolbar.find("com.generalrobotix.ui.actionSet");
94  if(setitem != null && setitem instanceof ToolBarContributionItem)
95  {
96  IToolBarManager toolbar = ((ToolBarContributionItem)setitem).getToolBarManager();
97  if(toolbar == null)
98  continue;
99  IContributionItem actitem = toolbar.find("com.generalrobotix.ui.actions.StartSimulate");
100  if(actitem != null && actitem instanceof ActionContributionItem)
101  return ((ActionContributionItem)actitem).getAction();
102  }
103  }
104  return null;
105  }
106 
107  public void registerItemChange(GrxBaseItem item, int event) {
108  if(item instanceof GrxSimulationItem){
110  switch(event){
112  if(simItem_!=simItem){
113  simItem_ = simItem;
114  simItem_.addObserver(this);
115  }
116  break;
119  if(simItem_==simItem){
120  simItem_.deleteObserver(this);
121  simItem_ = null;
122  }
123  break;
124  default:
125  break;
126  }
127  }
128 
129  }
130 
131  public void update(GrxBasePlugin plugin, Object... arg) {
132  if(simItem_==plugin){
133  if(arg[0].equals("StartSimulation")){
134  setActionImage(true);
135  action_.setEnabled(true);
136  }else if(arg[0].equals("StopSimulation")){
137  setActionImage(false);
138  action_.setEnabled(true);
139  }
140  }
141  }
142 
143 }
com.generalrobotix.ui.grxui.Activator
Definition: GrxUIonEclipse-project-0.9.8/src/com/generalrobotix/ui/grxui/Activator.java:58
com.generalrobotix.ui.grxui
Definition: GrxUIonEclipse-project-0.9.8/src/com/generalrobotix/ui/grxui/Activator.java:1
com.generalrobotix.ui.grxui.Activator.getDescriptor
ImageDescriptor getDescriptor(String iconName)
Definition: GrxUIonEclipse-project-0.9.8/src/com/generalrobotix/ui/grxui/Activator.java:347
com.generalrobotix.ui.util.MessageBundle.get
static final String get(String key)
Definition: MessageBundle.java:50
arg
char * arg
Definition: cdjpeg.h:136
start
png_size_t start
Definition: png.h:1493
com.generalrobotix.ui.GrxPluginManager.createItem
GrxBaseItem createItem(Class<? extends GrxBaseItem > cls, String name)
アイテムの作成. 指定したアイテムプラグインに、指定したアイテム名で新しいアイテムを作る。
Definition: GrxPluginManager.java:433
com.generalrobotix.ui.actions.StartSimulate
Definition: StartSimulate.java:25
com.generalrobotix.ui.grxui.Activator.getDefault
static Activator getDefault()
Definition: GrxUIonEclipse-project-0.9.8/src/com/generalrobotix/ui/grxui/Activator.java:324
com.generalrobotix.ui.actions.StartSimulate.simItem_
GrxSimulationItem simItem_
Definition: StartSimulate.java:27
com.generalrobotix.ui.GrxBasePlugin.addObserver
void addObserver(GrxObserver v)
Definition: GrxBasePlugin.java:491
com.generalrobotix.ui.GrxPluginManager.registerItemChangeListener
void registerItemChangeListener(GrxItemChangeListener view, Class<? extends GrxBaseItem > cls)
Definition: GrxPluginManager.java:1242
com.generalrobotix.ui.GrxPluginManager.SELECTED_ITEM
static final int SELECTED_ITEM
Definition: GrxPluginManager.java:97
com.generalrobotix.ui.GrxPluginManager.itemChange
void itemChange(GrxBaseItem item, int event)
Definition: GrxPluginManager.java:1278
com.generalrobotix.ui.actions.StartSimulate.getStartSimulationAction
IAction getStartSimulationAction()
Definition: StartSimulate.java:83
com.generalrobotix.ui.actions.StartSimulate.dispose
void dispose()
Definition: StartSimulate.java:65
com.generalrobotix.ui.GrxObserver
Definition: GrxObserver.java:3
com.generalrobotix.ui.item.GrxSimulationItem.stopSimulation
void stopSimulation()
Definition: GrxSimulationItem.java:353
com.generalrobotix.ui.actions.StartSimulate.setUp
void setUp()
Definition: StartSimulate.java:35
com.generalrobotix.ui.GrxItemChangeListener
Definition: GrxItemChangeListener.java:3
com.generalrobotix.ui.actions.StartSimulate.update
void update(GrxBasePlugin plugin, Object... arg)
Definition: StartSimulate.java:131
com.generalrobotix.ui.actions.StartSimulate.run
void run(IAction action)
Definition: StartSimulate.java:45
com.generalrobotix.ui.actions.StartSimulate.selectionChanged
void selectionChanged(IAction action, ISelection selection)
Definition: StartSimulate.java:64
com.generalrobotix.ui.item
Definition: GrxCollisionPairItem.java:19
com.generalrobotix.ui.item.GrxSimulationItem.startSimulation
boolean startSimulation(boolean isInteractive)
Definition: GrxSimulationItem.java:142
com.generalrobotix.ui.item.GrxSimulationItem
Definition: GrxSimulationItem.java:74
com.generalrobotix.ui.item.GrxWorldStateItem
Definition: GrxWorldStateItem.java:53
com.generalrobotix.ui.GrxBasePlugin.deleteObserver
void deleteObserver(GrxObserver v)
Definition: GrxBasePlugin.java:495
com.generalrobotix.ui.actions.StartSimulate.setActionImage
void setActionImage(boolean start)
Definition: StartSimulate.java:69
com.generalrobotix.ui.actions.StartSimulate.registerItemChange
void registerItemChange(GrxBaseItem item, int event)
Definition: StartSimulate.java:107
com.generalrobotix.ui.GrxPluginManager.NOTSELECTED_ITEM
static final int NOTSELECTED_ITEM
Definition: GrxPluginManager.java:98
com.generalrobotix.ui.grxui.Activator.manager_
GrxPluginManager manager_
Definition: GrxUIonEclipse-project-0.9.8/src/com/generalrobotix/ui/grxui/Activator.java:67
autoplay.item
item
Definition: autoplay.py:11
com.generalrobotix
com.generalrobotix.ui.GrxPluginManager.setSelectedItem
void setSelectedItem(GrxBaseItem item, boolean select)
select/unselect item
Definition: GrxPluginManager.java:882
com.generalrobotix.ui.GrxPluginManager.ADD_ITEM
static final int ADD_ITEM
Definition: GrxPluginManager.java:95
com.generalrobotix.ui.actions.StartSimulate.StartSimulate
StartSimulate()
Definition: StartSimulate.java:29
com.generalrobotix.ui.GrxPluginManager
プラグイン管理クラス GrxUIの核になるクラス。プラグインのロード等の、初期化を実行する。 プラグインとそのアイテムのマップ(::pluginMap_)、プラグインとその情報のマップ(::pinfoM...
Definition: GrxPluginManager.java:79
com.generalrobotix.ui.GrxPluginManager.REMOVE_ITEM
static final int REMOVE_ITEM
Definition: GrxPluginManager.java:96
com.generalrobotix.ui.util.MessageBundle
Definition: MessageBundle.java:16
com.generalrobotix.ui.GrxBaseItem
Definition: GrxBaseItem.java:35
com
com.generalrobotix.ui.util
Definition: AlertBox.java:17
com.generalrobotix.ui
com.generalrobotix.ui.actions.StartSimulate.init
void init(IWorkbenchWindow window)
Definition: StartSimulate.java:67
com.generalrobotix.ui.item.GrxSimulationItem.isSimulating
boolean isSimulating()
Definition: GrxSimulationItem.java:989
com.generalrobotix.ui.GrxBasePlugin
Definition: GrxBasePlugin.java:50
com.generalrobotix.ui.actions.StartSimulate.action_
IAction action_
Definition: StartSimulate.java:26


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Wed Sep 7 2022 02:51:04