GrxPluginManager.java
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc.
3  * All rights reserved. This program is made available under the terms of the
4  * Eclipse Public License v1.0 which accompanies this distribution, and is
5  * available at http://www.eclipse.org/legal/epl-v10.html
6  * Contributors:
7  * General Robotix Inc.
8  * National Institute of Advanced Industrial Science and Technology (AIST)
9  */
10 /*
11  * GrxPluginManager.java
12  *
13  * Copyright (C) 2007 GeneralRobotix, Inc.
14  * All Rights Reserved
15  *
16  * @author Yuichiro Kawasumi (General Robotix, Inc.)
17  */
18 
19 package com.generalrobotix.ui;
20 
21 import java.awt.Toolkit;
22 import java.awt.datatransfer.Clipboard;
23 import java.awt.datatransfer.DataFlavor;
24 import java.awt.datatransfer.Transferable;
25 import java.io.*;
26 import java.lang.reflect.Method;
27 import java.net.URL;
28 import java.util.*;
29 
30 import org.eclipse.core.resources.ResourcesPlugin;
31 import org.eclipse.jface.action.Action;
32 import org.eclipse.jface.dialogs.MessageDialog;
33 import org.eclipse.jface.preference.IPreferenceStore;
34 import org.eclipse.jface.util.IPropertyChangeListener;
35 import org.eclipse.jface.util.PropertyChangeEvent;
36 import org.omg.PortableServer.POA;
37 
38 import org.w3c.dom.Element;
39 
43 
58 
59 import org.eclipse.osgi.util.NLS;
60 import org.eclipse.swt.SWT;
61 import org.eclipse.swt.widgets.Display;
62 import org.eclipse.swt.widgets.FileDialog;
63 import org.eclipse.ui.IPerspectiveDescriptor;
64 import org.eclipse.ui.IViewPart;
65 import org.eclipse.ui.IViewReference;
66 import org.eclipse.ui.IWorkbench;
67 import org.eclipse.ui.IWorkbenchPage;
68 import org.eclipse.ui.IWorkbenchWindow;
69 import org.eclipse.ui.PlatformUI;
70 
79 public class GrxPluginManager implements IPropertyChangeListener {
80  // project
84 
85  // for managing items
87  public HashMap<Class<? extends GrxBasePlugin>, OrderedHashMap> pluginMap_ = new HashMap<Class<? extends GrxBasePlugin>, OrderedHashMap>(); // プラグインとその生成したアイテムのマップ
88  private List<GrxBaseView> viewList_ = new ArrayList<GrxBaseView>();
89  private List<GrxBaseView> activeViewList_ = new ArrayList<GrxBaseView>();
90  private File homePath_;
91  private Map<Class<? extends GrxBasePlugin>, PluginInfo> pinfoMap_ = new HashMap<Class<? extends GrxBasePlugin>, PluginInfo>();
92 
93  private Map<Class<? extends GrxBaseItem>, List<GrxItemChangeListener>> itemChangeListener_ =
94  new HashMap<Class<? extends GrxBaseItem>, List<GrxItemChangeListener>>();
95  public static final int ADD_ITEM=0;
96  public static final int REMOVE_ITEM=1;
97  public static final int SELECTED_ITEM=2;
98  public static final int NOTSELECTED_ITEM=3;
99  public static final int SETNAME_ITEM=4;
100  public static final int FOCUSED_ITEM=5;
101  public static final int NOTFOCUSED_ITEM=6;
102  public static final int CHANGE_MODE=7;
103 
104  private boolean acceptItemChange_ = true;
105 
106  // for CORBA
107  public POA poa_;
108  public org.omg.CORBA.ORB orb_;
109 
123  public GrxPluginManager() {
124  GrxDebugUtil.println("[PM] GrxPluginManager created"); //$NON-NLS-1$
125  String dir = Activator.getDefault().getPreferenceStore().getString("PROJECT_DIR"); //$NON-NLS-1$
126  if(dir.equals("")) //$NON-NLS-1$
127  dir = System.getenv("PROJECT_DIR"); //$NON-NLS-1$
128  if( dir != null ){
129  homePath_ = new File(dir);
130  }else
131  homePath_ = Activator.getDefault().getHomeDir();
132  System.out.println("[PM] WORKSPACE PATH=" + ResourcesPlugin.getWorkspace().getRoot().getLocation()); //$NON-NLS-1$
133 
134  // TODO: プラグインローダに、プラグインがおいてあるフォルダを指定する方法を検討
135  // 1.そもそもプラグイン管理をEclipseでやらせる
136  // 2.Eclipseの機能を使ってプラグインのディレクトリを持ってきてもらう
137  // 3.とりあえずGrxUIプラグイン自身をロードしたクラスローダを渡しておく <- いまこれ
138  pluginLoader_ = new GrxPluginLoader("", GrxPluginManager.class.getClassLoader()); //$NON-NLS-1$
140 
141  File rtcFile = new File( Activator.getDefault().getTempDir(),"rtc.conf");
142  if (!rtcFile.exists()){
143  try{
144  FileUtil.resourceToFile(getClass(), "/default_rtc.conf", rtcFile);
145  }catch (IOException ex){
146  ex.printStackTrace();
147  }
148  }
149 
150  versionCheck();
151  setInitialMode();
152  currentProject_ = new GrxProjectItem("newproject", this); //$NON-NLS-1$
153  String defaultProject = System.getProperty("PROJECT", null); //$NON-NLS-1$
154  if (defaultProject == null || !currentProject_.load(new File(GrxXmlUtil.expandEnvVal(defaultProject))))
155  currentProject_.create();
156 
157  // サーバの起動  //
158  GrxServerManager serverManager = (GrxServerManager)createItem(GrxServerManager.class, "serverManager");
159  if (serverManager != null){
160  serverManager.initialize();
161  itemChange(serverManager, GrxPluginManager.ADD_ITEM);
162  }
163  GrxProcessManager processManager = (GrxProcessManager)createItem(GrxProcessManager.class, "processManager");
164  if (processManager != null){
165  processManager.setProcessList(serverManager);
166  itemChange(processManager, GrxPluginManager.ADD_ITEM);
167  }
168  }
169 
175  public void focusedItem(GrxBaseItem item) {
176  if (focusedItem_ != item) {
177  if (focusedItem_ != null){
178  focusedItem_.setFocused(false);
179  itemChange(focusedItem_, NOTFOCUSED_ITEM);
180  }
181  if(item != null){
182  focusedItem_ = item;
183  focusedItem_.setFocused(true);
184  itemChange(focusedItem_, FOCUSED_ITEM);
185  }else
186  focusedItem_ = null;
187  }
188  }
189 
195  return focusedItem_;
196  }
197 
202  private boolean isPerspectiveVisible() {
203  IWorkbench workbench = PlatformUI.getWorkbench();
204  IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
205  if (window == null)
206  return false;
207  IWorkbenchPage page = window.getActivePage();
208  if (page == null)
209  return false;
210  IPerspectiveDescriptor pers = page.getPerspective();
211  if (!pers.getId().contains(GrxUIPerspectiveFactory.ID))
212  return false;
213  return true;
214  }
215 
220  private void updateActiveViewList() {
221  activeViewList_.clear();
222 
223  Display display = Display.getDefault();
224  display.syncExec(new Runnable(){
225  public void run(){
226  IWorkbench workbench = PlatformUI.getWorkbench();
227  IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
228  if (window == null)
229  return;
230  IWorkbenchPage page = window.getActivePage();
231  if (page == null) {
232  return;
233  }
234  IPerspectiveDescriptor pers = page.getPerspective();
235  // GrxUIパースペクティブが表示されているか?
236  if (!pers.getId().contains(GrxUIPerspectiveFactory.ID)) {
237  return;
238  }
239 
240  for (IViewReference i : page.getViewReferences()) {
241  // 未初期化のビューは初期化する
242  IViewPart v = i.getView(true);
243  if (v != null && GrxBaseViewPart.class.isAssignableFrom(v.getClass())) {
244  GrxBaseView view = ((GrxBaseViewPart) v).getGrxBaseView();
245  if(view != null)
246  activeViewList_.add(view);
247  }
248  }
249  }
250  });
251 
252  }
253 
254  private void updateViewList() {
255  viewList_.clear();
256 
257  Display display = Display.getDefault();
258  display.syncExec(new Runnable(){
259  public void run(){
260  IWorkbench workbench = PlatformUI.getWorkbench();
261  IWorkbenchWindow[] windows = workbench.getWorkbenchWindows();
262  if (windows.length == 0)
263  return;
264  for(IWorkbenchWindow window : windows){
265  IWorkbenchPage page = window.getActivePage();
266  if (page != null) {
267  IPerspectiveDescriptor pers = page.getPerspective();
268  if (pers.getId().contains(GrxUIPerspectiveFactory.ID)) {
269  for (IViewReference i : page.getViewReferences()) {
270  // 未初期化のビューは初期化する
271  IViewPart v = i.getView(true);
272  if (v != null && GrxBaseViewPart.class.isAssignableFrom(v.getClass())) {
273  GrxBaseView view = ((GrxBaseViewPart) v).getGrxBaseView();
274  if(view != null)
275  viewList_.add(view);
276  }
277  }
278  }
279  }
280  }
281  }
282  });
283  }
284 
292  public void start() {
293  // OnlineViewerなどのサーバの登録用
294  System.out.println("[PM] START GrxPluginManager"); //$NON-NLS-1$
295  new Thread() {
296  public void run() {
297  try {
298  poa_ = GrxCorbaUtil.getRootPOA();
299  poa_.the_POAManager().activate();
300  GrxDebugUtil.println("Corba Server Ready."); //$NON-NLS-1$
302  orb_.run();
303  orb_.destroy();
304  } catch (Exception e) {
305  e.printStackTrace();
306  }
308  }
309  }.start();
310 
311 /*   モードの選択は、現在使用していない。
312  String defaultMode = System.getProperty("MODE", ""); //$NON-NLS-1$ //$NON-NLS-2$
313  GrxModeInfoItem mode = (GrxModeInfoItem) getItem(GrxModeInfoItem.class, defaultMode);
314  GrxDebugUtil.println("[PM] current mode=" + mode); //$NON-NLS-1$
315 
316  Map<?, ?> m = pluginMap_.get(GrxModeInfoItem.class);
317  GrxModeInfoItem[] modes = (GrxModeInfoItem[]) m.values().toArray(new GrxModeInfoItem[0]);
318 
319  System.out.println("[PM] try to setMode"); //$NON-NLS-1$
320 
321  try {
322  if (mode == null) {
323  int ans = 0;
324  if (modes.length > 1) {
325  String[] modeInfoNames = new String[modes.length];
326  for (int i = 0; i < modes.length; i++)
327  modeInfoNames[i] = modes[i].getName();
328  MessageDialog dlg = new MessageDialog(null, MessageBundle.get("GrxPluginManager.dialog.title.mode"), null, MessageBundle.get("GrxPluginManager.dialog.message.mode"), MessageDialog.NONE, modeInfoNames, 0); //$NON-NLS-1$ //$NON-NLS-2$
329  ans = dlg.open();
330  }
331  mode = modes[ans];
332  }
333  setMode(mode);
334  // frame_.updateModeButtons(modes, currentMode_);
335 
336  } catch (Exception e) {
337  GrxDebugUtil.printErr("GrxPluginManager:", e); //$NON-NLS-1$
338  }
339 */
340 
341  }
342 
346  /*
347  void setMode(GrxModeInfoItem mode) {
348  System.out.println("[PM] setMode to " + mode); //$NON-NLS-1$
349 
350  if (currentMode_ == mode)
351  return;
352 
353  // timer_.stop();
354  clearItemSelection();
355 
356  // update active plugin and create view
357  setSelectedItem(mode, true);
358  currentMode_ = mode;
359  currentMode_.restoreProperties();
360  currentProject_.restoreProject();
361  }
362  */
368  return currentMode_;
369  }
370 
371  public void setCurrentMode(GrxModeInfoItem mode){
372  currentMode_ = mode;
373  }
374 
375  @SuppressWarnings("unchecked") //$NON-NLS-1$
376  public Class<? extends GrxBasePlugin> registerPlugin(String className) {
377  Class<?> cls = pluginLoader_.loadClass(className);
378  return registerPlugin((Class<? extends GrxBasePlugin>) cls);
379  }
380 
387  @SuppressWarnings("unchecked") //$NON-NLS-1$
388  public Class<?> registerPlugin(Element el) {
389  Class<?> cls = pluginLoader_.loadClass(el.getAttribute("class")); //$NON-NLS-1$
390  Class<? extends GrxBasePlugin> ret = registerPlugin((Class<? extends GrxBasePlugin>) cls);
391  if (ret != null) {
392  PluginInfo pi = pinfoMap_.get(ret);
393  pi.visible = GrxXmlUtil.getBoolean(el, PluginInfo.VISIBLE, true);
394  pinfoMap_.put(ret, pi);
395  }
396  return ret;
397  }
398 
404  public Class<? extends GrxBasePlugin> registerPlugin(Class<? extends GrxBasePlugin> cls) {
405  if (cls != null && GrxBasePlugin.class.isAssignableFrom(cls)) {
406  if (pluginMap_.get(cls) == null) {
407  GrxDebugUtil.println("[PM] register " + cls.getName()); //$NON-NLS-1$
408 
409  pluginMap_.put(cls, new OrderedHashMap());
410 
411  PluginInfo pi = new PluginInfo();
412  pi.title = (String) GrxBasePlugin.getField(cls, "TITLE", cls.getSimpleName()); //$NON-NLS-1$
413  pi.lastDir = new File(homePath_ + (String) GrxBasePlugin.getField(cls, "DEFAULT_DIR", "")); //$NON-NLS-1$ //$NON-NLS-2$
414  String ext = (String) GrxBasePlugin.getField(cls, "FILE_EXTENSION", null); //$NON-NLS-1$
415  if (ext != null)
416  pi.filter = "*." + ext;// GrxGuiUtil.createFileFilter(ext); //$NON-NLS-1$
417  pinfoMap_.put(cls, pi);
418  }
419 
420  return cls;
421  }
422  return null;
423  }
424 
433  public GrxBaseItem createItem(Class<? extends GrxBaseItem> cls, String name) {
434  //System.out.println("[PM]@createItem " + name + "(" + cls + ")");
435  if (name == null) {
436  String baseName = "new" + getItemTitle(cls); //$NON-NLS-1$
437  baseName = baseName.toLowerCase().replaceAll(" ", ""); //$NON-NLS-1$ //$NON-NLS-2$
438  for (int i = 0;; i++) {
439  name = baseName + i;
440  if (getItem(cls, name) == null)
441  break;
442  }
443  }
444  GrxBaseItem item = (GrxBaseItem) createPlugin(cls, name);
445  //GrxDebugUtil.println("[PM]@createItem createPlugin return " + item);
446  if (item != null) {
447  item.create();
448  }
449  return item;
450  }
451 
459  public GrxBaseItem loadItem(Class<? extends GrxBaseItem> cls, String name, String url) {
460  String _url = GrxXmlUtil.expandEnvVal(url);
461  if (_url == null)
462  return null;
463 
464  File f = null;
465  try {
466  URL u = new URL(_url);
467  f = new File(u.getFile());
468  } catch (Exception e) {
469  //GrxDebugUtil.printErr("loadItem(" + url + ") is not URL format\n", e);
470  f = new File(_url);
471  }
472  try {
473  _url = f.getCanonicalPath();
474  f = new File(_url);
475  } catch (IOException e) {
476  e.printStackTrace();
477  }
478 
479  if (!f.isFile()){
480  FileDialog fdlg = new FileDialog(GrxUIPerspectiveFactory.getCurrentShell(), SWT.OPEN);
481  PluginInfo pi = pinfoMap_.get(cls);
482  String[] fe = { pi.filter };
483  fdlg.setText(_url+" "+MessageBundle.get("GrxPluginManager.fileDialog.notFound"));
484  fdlg.setFilterExtensions(fe);
485  fdlg.setFilterPath(pi.lastDir.getAbsolutePath());
486  String fPath = fdlg.open();
487  if (fPath != null) {
488  f = new File(fPath);
489  _url = fPath;
490  }else
491  return null;
492  }
493 
494  if (name == null){
495  String basename = f.getName().split("[.]")[0]; //$NON-NLS-1$
496  if (getItem(cls, basename) != null){
497  Integer index = 0;
498  do {
499  name = basename + index.toString();
500  index++;
501  }while(getItem(cls, name) != null);
502  }else{
503  name = basename;
504  }
505  }
506 
507  GrxBaseItem item = (GrxBaseItem) createPlugin(cls, name);
508  if (item != null) {
509  if (item.load(f)) {
510  item.setURL(_url);
511  item.setDefaultDirectory(f.getParent());
512  pinfoMap_.get(cls).lastDir = f.getParentFile();
513  } else {
514  removeItem(item);
515  return null;
516  }
517  }
518 
519  return item;
520  }
521 
527  public GrxBaseItem pasteItem(Class<? extends GrxBaseItem> cls, GrxBaseItem item) {
528  /*
529  * try { HashMap<String, GrxBasePlugin> map = pluginMap_.get(cls);
530  * GrxBasePlugin plugin = map.get(item.getName());
531  *
532  * plugin = pluginLoader_.createPlugin(cls, name, this);
533  *
534  * map.put(name, plugin); return plugin;
535  *
536  * } catch (Exception e) { showExceptionTrace("Couldn't load Class:" +
537  * cls.getName(), e); }
538  */
539  return item;
540  }
541 
548  public GrxBaseView createView(Class<? extends GrxBaseView> cls, String name) {
549  if (name == null)
550  name = pinfoMap_.get(cls).title;
551  return (GrxBaseView) createPlugin(cls, name);
552  }
553 
560  @SuppressWarnings("unchecked") //$NON-NLS-1$
561  private GrxBasePlugin createPlugin(Class<? extends GrxBasePlugin> cls, String name) {
562  if (registerPlugin(cls) == null) {
563  GrxDebugUtil.println("[PM]@createPlugin registerPlugin failed"); //$NON-NLS-1$
564  return null;
565  }
566  try {
567  HashMap<String, GrxBasePlugin> map = pluginMap_.get(cls);
568  GrxBasePlugin plugin = map.get(name);
569  if ( plugin != null) {
570  if(plugin instanceof GrxBaseItem)
571  ((GrxBaseItem)plugin).delete();
572  }
573  plugin = pluginLoader_.createPlugin(cls, name, this);
574  if (registerPluginInstance(plugin)) {
575  return plugin;
576  }
577  return plugin;
578  } catch (Exception e) {
579  showExceptionTrace("Couldn't load Class:" + cls.getName(), e); //$NON-NLS-1$
580  }
581  return null;
582  }
583 
590  @SuppressWarnings("unchecked") //$NON-NLS-1$
591  public boolean registerPluginInstance(GrxBasePlugin instance) {
592  HashMap<String, GrxBasePlugin> map = pluginMap_.get(instance.getClass());
593  GrxBasePlugin plugin = map.get(instance.getName());
594  if ( plugin != null) {
595  GrxDebugUtil.println("[PM]@createPlugin Plugin instance named "+instance.getName()+" is already registered."); //$NON-NLS-1$ //$NON-NLS-2$
596  if(plugin instanceof GrxBaseItem){
597  ((GrxBaseItem)plugin).delete();
598  map.put(instance.getName(), instance);
599  }
600  return false;
601  }
602  map.put(instance.getName(), instance);
603  return true;
604  }
605 
611  private void showExceptionTrace(String m, Exception e) {
612  GrxDebugUtil.printErr(m, e);
613 
614  Throwable cause = e.getCause();
615  StackTraceElement[] trace = null;
616  String msg = m + "\n\n"; //$NON-NLS-1$
617  if (cause != null) {
618  msg = cause.toString() + "\n\n"; //$NON-NLS-1$
619  trace = cause.getStackTrace();
620  } else {
621  trace = e.getStackTrace();
622  }
623 
624  for (int i = 0; i < trace.length; i++) {
625  msg += "at " + trace[i].getClassName() + "." + trace[i].getMethodName() + "("; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
626 
627  if (trace[i].isNativeMethod()) {
628  msg += "(Native Method)\n"; //$NON-NLS-1$
629  } else if (trace[i].getFileName() == null) {
630  msg += "(No source code)\n"; //$NON-NLS-1$
631  } else {
632  msg += trace[i].getFileName() + ":" + trace[i].getLineNumber() + ")\n"; //$NON-NLS-1$ //$NON-NLS-2$
633  }
634  }
635  MessageDialog.openWarning(null, "Exception Occered", msg); //$NON-NLS-1$
636  }
637 
642  public void removeItem(GrxBaseItem item) {
643  Map<?, ?> m = pluginMap_.get(item.getClass());
644  if (m != null) {
645  setSelectedItem(item, false);
646  m.remove(item.getName());
647  itemChange(item, REMOVE_ITEM);
648  }
649  }
650 
655  public void removeItems(Class<? extends GrxBaseItem> cls) {
656  Map<?, ?> m = pluginMap_.get(cls);
657  GrxBaseItem[] items = m.values().toArray(new GrxBaseItem[0]);
658  if(cls.isAssignableFrom(GrxModelItem.class)){
659  List<GrxModelItem> modifiedModels = new ArrayList<GrxModelItem>();
660  for (int i = 0; i < items.length; i++){
661  int ret = ((GrxModelItem)items[i]).checkModifiedModel(false);
662  if(ret==GrxModelItem.MODIFIED_NG){
663  for(GrxModelItem modifiedModel : modifiedModels){
664  modifiedModel.reload();
665  }
666  return;
667  }else if(ret==GrxModelItem.MODIFIED_OK){
668  modifiedModels.add((GrxModelItem) items[i]);
669  }
670  }
671  }
672  for (int i = 0; i < items.length; i++)
673  items[i].delete();
674  }
675 
680  public void removeAllItems() {
681  if (currentMode_ == null)
682  return;
683  for (int i = 0; i < currentMode_.activeItemClassList_.size(); i++)
685  }
686 
695  public boolean renamePlugin(GrxBasePlugin item, String newName) {
696  OrderedHashMap m = pluginMap_.get(item.getClass());
697  if (m == null) {
698  System.out.println("map for " + item.getClass() + " doesn't exist in pluginMap_"); //$NON-NLS-1$ //$NON-NLS-2$
699  return false;
700  }
701  if (m.get(newName) == null) {
702  if (!newName.equals(item.getName())) {
703  m.remove(item.getName());
704  m.put(newName, item);
705  item.setName(newName);
706  }
707  return true;
708  } else {
709  System.out.println("GrxPluginManager.renamePlugin() : " + newName + " is already used"); //$NON-NLS-1$ //$NON-NLS-2$
710  }
711  return false;
712  }
713 
718  public ArrayList<GrxBaseItem> getActiveItemList() {
719  ArrayList<Class<? extends GrxBaseItem>> cList = currentMode_.activeItemClassList_;
720  ArrayList<GrxBaseItem> iList = new ArrayList<GrxBaseItem>();
721  for (int i = 0; i < cList.size(); i++) {
722  Iterator it = pluginMap_.get(cList.get(i)).values().iterator();
723  while (it.hasNext()) {
724  GrxBaseItem item = (GrxBaseItem) it.next();
725  iList.add(item);
726  }
727  }
728  return iList;
729  }
730 
737  public GrxBaseItem getItem(Class<? extends GrxBaseItem> cls, String name) {
738  Iterator it = pluginMap_.get(cls).values().iterator();
739  while (it.hasNext()) {
740  GrxBaseItem item = (GrxBaseItem) it.next();
741  if (item.toString().equals(name) || name == null) {
742  //GrxDebugUtil.println("[PM] getItem success " + item);
743  return item;
744  }
745  }
746  GrxDebugUtil.println("[PM] fault getItem " + cls.getName() + ":" + name); //$NON-NLS-1$ //$NON-NLS-2$
747  return null;
748  }
749 
755  public GrxBaseItem getItem(String name) {
756  Iterator<OrderedHashMap> it = pluginMap_.values().iterator();
757  while (it.hasNext()) {
758  HashMap m = (HashMap) it.next();
759  Object o = m.get(name);
760  if (o != null && o instanceof GrxBaseItem)
761  return (GrxBaseItem) o;
762  }
763  return null;
764  }
765 
771  public Map<?, ?> getItemMap(Class<? extends GrxBaseItem> cls) {
772  return pluginMap_.get(cls);
773  }
774 
781  @SuppressWarnings("unchecked") //$NON-NLS-1$
782  public <T> T getSelectedItem(Class<? extends GrxBaseItem> cls, String name) {
783  Map<String, ? extends GrxBaseItem> oMap = pluginMap_.get(cls);
784  if(oMap==null) return null;
785  if(name != null){
786  GrxBaseItem item = oMap.get(name);
787  if(item.isSelected())
788  return (T)item;
789  else
790  return null;
791  }else{
792  for(GrxBaseItem item : oMap.values()){
793  if(item.isSelected())
794  return (T)item;
795  }
796  return null;
797  }
798  }
799 
805  @SuppressWarnings("unchecked") //$NON-NLS-1$
806  public <T> List<T> getSelectedItemList(Class<? extends GrxBaseItem> cls) {
807  ArrayList<T> list = new ArrayList<T>();
808  Map<String, ? extends GrxBaseItem> oMap = pluginMap_.get(cls);
809  if(oMap==null) return list;
810  for(GrxBaseItem item : oMap.values()){
811  if (item.isSelected())
812  list.add((T)item);
813  }
814  return list;
815  }
816 
821  public List<GrxBaseView> getViewList() {
822  updateViewList();
823  return viewList_;
824  }
825 
830  public List<GrxBaseView> getActiveViewList() {
832  return activeViewList_;
833  }
834 
840  public GrxBaseView getView(Class<? extends GrxBaseView> cls, boolean active) {
841  if(active){
843  for (GrxBaseView v : activeViewList_)
844  if (v.getClass() == cls)
845  return v;
846  }else{
847  updateViewList();
848  for (GrxBaseView v : viewList_)
849  if (v.getClass() == cls)
850  return v;
851  }
852  return null;
853  }
854 
855  public synchronized GrxBaseView getView(String name, boolean active) {
856  if(active){
858  for (GrxBaseView v : activeViewList_) {
859  if (v.getName().equals(name)) {
860  return v;
861  }
862  }
863  }else{
864  updateViewList();
865  for (GrxBaseView v : viewList_) {
866  if (v.getName().equals(name)) {
867  return v;
868  }
869  }
870  }
871  return null;
872  }
873 
881  @SuppressWarnings("unchecked") //$NON-NLS-1$
882  public void setSelectedItem(GrxBaseItem item, boolean select) {
883  if (item == null)
884  return;
885 
886  if (select && item.isExclusive()) {
887  for (GrxBaseItem i : (Collection<GrxBaseItem>) getItemMap(item.getClass()).values()) {
888  if (i != item) {
889  i.setSelected(false);
891  }
892  }
893  }
894 
895  // GrxDebugUtil.println("[PM]@setSelectedItem "+item.getName()+" to "+select+". and now changed? "+isItemSelectionChanged_
896  // );
897 
898  item.setSelected(select);
899  if(select) itemChange(item, SELECTED_ITEM);
901  }
902 
903 
907  public void clearItemSelection() {
908  Iterator<OrderedHashMap> i = pluginMap_.values().iterator();
909  while (i.hasNext()) {
910  Iterator j = (i.next()).values().iterator();
911  while (j.hasNext()) {
912  GrxBasePlugin p = (GrxBasePlugin) j.next();
913  if (p instanceof GrxBaseItem)
914  setSelectedItem((GrxBaseItem) p, false);
915  }
916  }
917  }
918 
925  public String getItemTitle(Class<? extends GrxBasePlugin> cls) {
926  return pinfoMap_.get(cls).title;
927  }
928 
935  public boolean isItemVisible(Class<? extends GrxBasePlugin> cls) {
936  return pinfoMap_.get(cls).visible;
937  }
938 
942  private class PluginInfo {
943  static final String VISIBLE = "visible"; //$NON-NLS-1$
944  String title;
945  File lastDir;
946  String filter;
947  Vector<Action> menu;
948  boolean visible;
949  }
950 
956  public Vector<Action> getItemMenu(final Class<? extends GrxBaseItem> cls) {
957  final PluginInfo pi = pinfoMap_.get(cls);
958  Vector<Action> menu = pi.menu;
959  if (menu != null) {
960  dynamicChangeMenu(cls, menu);
961  return menu;
962  }
963  menu = pi.menu = new Vector<Action>();
964 
965  // menu item : create
966  Action create = new Action() {
967  public String getText() {
968  return MessageBundle.get("GrxPluginManager.menu.create"); //$NON-NLS-1$
969  }
970 
971  public void run() {
974  setSelectedItem(item, true);
975  }
976  };
977  menu.add(create);
978 
979  // menu item : load
980  Action load = new Action() {
981  public String getText() {
982  return MessageBundle.get("GrxPluginManager.menu.load"); //$NON-NLS-1$
983  }
984 
985  public void run() {
986  FileDialog fdlg = new FileDialog(GrxUIPerspectiveFactory.getCurrentShell(), SWT.OPEN);
987  String[] fe = { pi.filter };
988  fdlg.setFilterExtensions(fe);
989  fdlg.setFilterPath(pi.lastDir.getAbsolutePath());
990  String fPath = fdlg.open();
991  if (fPath != null) {
992  File f = new File(fPath);
993  GrxBaseItem newItem = loadItem(cls, null, f.getAbsolutePath());
994  if(newItem!=null){
996  setSelectedItem(newItem, true);
997  pi.lastDir = f.getParentFile();
998  }
999  }
1000  }
1001  };
1002  menu.add(load);
1003 
1004  // menu item : clear
1005  Action clear = new Action() {
1006  public String getText() {
1007  return MessageBundle.get("GrxPluginManager.menu.clear"); //$NON-NLS-1$
1008  }
1009 
1010  public void run() {
1011  String mes = MessageBundle.get("GrxPluginManager.dialog.message.removeItem"); //$NON-NLS-1$
1012  mes = NLS.bind(mes, new String[]{GrxPluginManager.this.getItemTitle(cls)});
1013  if (MessageDialog.openConfirm(null, MessageBundle.get("GrxPluginManager.dialog.title.removeItem"), mes)){ //$NON-NLS-1$
1014  refuseItemChange();
1015  removeItems(cls);
1016  acceptItemChange();
1017  }
1018  }
1019  };
1020  menu.add(clear);
1021 
1022  // menu item : delete
1023  Action delete = new Action() {
1024  public String getText() {
1025  return MessageBundle.get("GrxPluginManager.menu.delete"); //$NON-NLS-1$
1026  }
1027 
1028  public void run() {
1029  String mes = MessageBundle.get("GrxPluginManager.dialog.message.deletePlugin"); //$NON-NLS-1$
1030  mes = NLS.bind(mes, new String[]{GrxPluginManager.this.getItemTitle(cls)});
1031  if (MessageDialog.openConfirm(null, MessageBundle.get("GrxPluginManager.dialog.title.deletePlugin"), mes)) //$NON-NLS-1$
1032  deletePlugin(cls);
1033  }
1034  };
1035  menu.add(delete);
1036 
1037  try {
1038  Method m = cls.getMethod("create", (Class[]) null); //$NON-NLS-1$
1039  Class<?> c = m.getDeclaringClass();
1040  create.setEnabled(!(c == GrxBaseItem.class));
1041 
1042  m = cls.getMethod("load", File.class); //$NON-NLS-1$
1043  c = m.getDeclaringClass();
1044  load.setEnabled(!(c == GrxBaseItem.class));
1045  m = cls.getMethod("paste", String.class); //$NON-NLS-1$
1046  c = m.getDeclaringClass();
1047  if (c != GrxBaseItem.class) {
1048  Action paste = new Action() {
1049  public String getText() {
1050  return "paste"; //$NON-NLS-1$
1051  }
1052 
1053  public void run() {
1054  GrxDebugUtil.println("GrxPluginManager.GrxModelItemClass paste Action"); //$NON-NLS-1$
1055  // paste();
1056  }
1057  };
1058  paste.setEnabled(!isEmptyClipBord());
1059  menu.add(paste);
1060  }
1061  } catch (Exception e) {
1062  e.printStackTrace();
1063  }
1064 
1065  // if plugin is user then delete menu is enable
1066  IPreferenceStore store =Activator.getDefault().getPreferenceStore();
1067  String itemClassList=store.getString(PreferenceConstants.ITEM+"."+PreferenceConstants.CLASS);
1068  String[] itemClass=itemClassList.split(PreferenceConstants.SEPARATOR, -1);
1069  boolean found=false;
1070  for(int i=0; i<itemClass.length; i++){
1071  if(cls.getName().equals(itemClass[i])){
1072  found=true;
1073  break;
1074  }
1075  }
1076  if(!found)
1077  delete.setEnabled(true);
1078  else
1079  delete.setEnabled(false);
1080  return menu;
1081  }
1082 
1086  private void dynamicChangeMenu(final Class<? extends GrxBaseItem> cls, Vector<Action> menu) {
1087  try {
1088  Method m = cls.getMethod("paste", String.class); //$NON-NLS-1$
1089  Class<?> c = m.getDeclaringClass();
1090  if (c != GrxBaseItem.class) {
1091  for (Action action : menu) {
1092  if (action.getText().equals("paste")) { //$NON-NLS-1$
1093  action.setEnabled(!isEmptyClipBord());
1094  break;
1095  }
1096  }
1097  }
1098  } catch (Exception e) {
1099  e.printStackTrace();
1100  }
1101  }
1102 
1106  private boolean isEmptyClipBord() {
1108  return GrxPluginManager.getClipBoardVal().length()==0;
1109  }
1110 
1114  public void shutdown() {
1115  GrxDebugUtil.println("[PM] shutdown."); //$NON-NLS-1$
1116 
1117  Iterator<OrderedHashMap> it = pluginMap_.values().iterator();
1118  for (; it.hasNext();) {
1119  Iterator it2 = (it.next()).values().iterator();
1120  for (; it2.hasNext();)
1121  ((GrxBasePlugin) it2.next()).shutdown();
1122  }
1123 
1125  if(orb_!=null)
1126  orb_.shutdown(false);
1127  }
1128 
1136  public void setProjectProperty(String key, String val) {
1137  currentProject_.setProperty(key, val);
1138  }
1139 
1145  public String getProjectProperty(String key) {
1146  return currentProject_.getProperty(key);
1147  }
1148 
1153  public String getCurrentModeName() {
1154  if (currentMode_ == null)
1155  return null;
1156  return currentMode_.getName();
1157  }
1158 
1163  public Vector<Action> getProjectMenu() {
1164  return currentProject_.getMenu();
1165  }
1166 
1171  public File getHomePath() {
1172  return homePath_;
1173  }
1174 
1179  public String getProjectName() {
1180  return currentProject_.getName();
1181  }
1182 
1188  return currentProject_;
1189  }
1190 
1195  /*
1196  * comment out by kanehiro. This class should be independent from any
1197  * specific view class public List<GrxBaseItem>
1198  * getSelectedGrxBaseItemList(){ return selectedItemOnTreeViewList_; }
1199  */
1200 
1205  /*
1206  * comment out by kanehiro. This class should be independent from any
1207  * specific view class private void paste(){
1208  * GrxDebugUtil.println("GrxPluginManager.paste."); for (Object o :
1209  * selectedItemOnTreeViewList_.toArray() ){ if (
1210  * GrxModelItem.class.isAssignableFrom( o.getClass() ) ){
1211  * GrxDebugUtil.println("GrxModelItem 存在確認"); } } }
1212  */
1213 
1218  private static String getClipBoardVal() {
1219  return GrxPluginManager.clipValue_.get();
1220  }
1221 
1225  private static void setClipBordVal() {
1226  Clipboard clp = Toolkit.getDefaultToolkit().getSystemClipboard();
1227  Transferable data = clp.getContents(null);
1228  String ret = ""; //$NON-NLS-1$
1229  if (data != null && data.isDataFlavorSupported(DataFlavor.stringFlavor)) {
1230  try {
1231  ret = (String) data.getTransferData(DataFlavor.stringFlavor);
1232  } catch (Exception e) {
1233  GrxDebugUtil.printErr("GrxPluginManager.setClipBordVal: ", e); //$NON-NLS-1$
1234  }
1235  }
1237  }
1238 
1240 
1241 
1242  public void registerItemChangeListener(GrxItemChangeListener view, Class<? extends GrxBaseItem> cls){
1243  if(itemChangeListener_.get(cls)==null)
1244  itemChangeListener_.put(cls, new ArrayList<GrxItemChangeListener>());
1245  List<GrxItemChangeListener> list = itemChangeListener_.get(cls);
1246  list.add(view);
1247  }
1248 
1249  public void removeItemChangeListener(GrxItemChangeListener view, Class<? extends GrxBaseItem> cls) {
1250  if(itemChangeListener_.get(cls)==null) return;
1251  List<GrxItemChangeListener> list = itemChangeListener_.get(cls);
1252  list.remove(view);
1253  //TODO
1254  }
1255 
1256  public void refuseItemChange(){
1257  acceptItemChange_ = false;
1258  }
1259 
1260  public void acceptItemChange(){
1261  List<GrxItemChangeListener> listenerList = new ArrayList<GrxItemChangeListener>();
1262  Iterator<Class<? extends GrxBaseItem>> it = itemChangeListener_.keySet().iterator();
1263  while(it.hasNext()){
1264  List<GrxItemChangeListener> list = itemChangeListener_.get(it.next());
1265  Iterator<GrxItemChangeListener> itl = list.iterator();
1266  while(itl.hasNext()){
1267  GrxItemChangeListener listener = itl.next();
1268  if(!listenerList.contains(listener)){
1269  listener.setUp();
1270  listenerList.add(listener);
1271  }
1272  }
1273 
1274  }
1275  acceptItemChange_ = true;
1276  }
1277 
1278  public void itemChange(GrxBaseItem item, int event){
1279  if(acceptItemChange_){
1280  Iterator<Class<? extends GrxBaseItem>> it = itemChangeListener_.keySet().iterator();
1281  while(it.hasNext()){
1282  Class<? extends GrxBaseItem> cls = it.next();
1283  if(cls.isAssignableFrom(item.getClass())){
1284  List<GrxItemChangeListener> list = itemChangeListener_.get(cls);
1285  Iterator<GrxItemChangeListener> itView = list.iterator();
1286  while(itView.hasNext())
1287  itView.next().registerItemChange(item, event);
1288  }
1289  }
1290  }
1291  }
1292 
1293  private void setInitialMode(){
1294  IPreferenceStore store =Activator.getDefault().getPreferenceStore();
1295  String modes = store.getString(PreferenceConstants.MODE);
1296  String[] mode = modes.split(PreferenceConstants.SEPARATOR, -1);
1297  String itemIndexs = store.getString(PreferenceConstants.MODE+"."+PreferenceConstants.ITEMINDEX);
1298  String[] itemIndex = itemIndexs.split(PreferenceConstants.SEPARATOR,-1);
1299  String itemClassList=store.getString(PreferenceConstants.ITEM+"."+PreferenceConstants.CLASS);
1300  String[] itemClass=itemClassList.split(PreferenceConstants.SEPARATOR, -1);
1301  String itemVisibleList=store.getString(PreferenceConstants.ITEM+"."+PreferenceConstants.VISIBLE);
1302  String[] itemVisible=itemVisibleList.split(PreferenceConstants.SEPARATOR, -1);
1303  String userItemClassList=store.getString(PreferenceConstants.USERITEM+"."+PreferenceConstants.CLASS);
1304  String[] userItemClass=userItemClassList.split(PreferenceConstants.SEPARATOR, -1);
1305  String userItemPathList=store.getString(PreferenceConstants.USERITEM+"."+PreferenceConstants.CLASSPATH);
1306  String[] userItemPath=userItemPathList.split(PreferenceConstants.SEPARATOR, -1);
1307  String userItemVisibleList=store.getString(PreferenceConstants.USERITEM+"."+PreferenceConstants.VISIBLE);
1308  String[] userItemVisible=userItemVisibleList.split(PreferenceConstants.SEPARATOR, -1);
1309  for(int i=0; i<mode.length; i++){
1311  String[] index=itemIndex[i].split(",",-1);
1312  for(int j=0; j<index.length; j++){
1313  int k=Integer.valueOf(index[j]);
1314  if(k<itemClass.length){
1315  if(pluginLoader_.existClass(itemClass[k])){
1316  Class<? extends GrxBasePlugin> plugin=registerPlugin(itemClass[k]);
1317  if (plugin != null) {
1318  PluginInfo pi = pinfoMap_.get(plugin);
1319  pi.visible = itemVisible[k].equals("true")? true : false;
1320  pinfoMap_.put(plugin, pi);
1321  item.addItemClassList(plugin);
1322  }
1323  }
1324  }
1325  }
1326  for(int j=0; j<userItemClass.length; j++){
1327  if(!userItemClass[j].equals("")){
1328  pluginLoader_.addURL(userItemPath[j]);
1329  if(pluginLoader_.existClass(userItemClass[j])){
1330  Class<? extends GrxBasePlugin> plugin=registerPlugin(userItemClass[j]);
1331  if (plugin != null) {
1332  PluginInfo pi = pinfoMap_.get(plugin);
1333  pi.visible = userItemVisible[j].equals("true")? true : false;
1334  pinfoMap_.put(plugin, pi);
1335  item.addItemClassList(plugin);
1336  }
1337  }
1338  }
1339  }
1340  }
1341  store.addPropertyChangeListener(this);
1342  // 最初のモードを選択 //
1344  setSelectedItem(item, true);
1345  currentMode_ = item;
1346  }
1347 
1348  private void versionCheck(){
1349  IPreferenceStore store =Activator.getDefault().getPreferenceStore();
1350  String version = store.getString(PreferenceConstants.VERSION);
1351  if(version.equals("") || !version.equals(PreferenceConstants.CURRENT_VERSION)){
1352  // ヴァージョンが変わった場合の処理を必要に応じて実装する
1353  if(version.equals("")){
1354  store.setToDefault(PreferenceConstants.PROCESS+"."+PreferenceConstants.ID);
1355  store.setToDefault(PreferenceConstants.PROCESS+"."+PreferenceConstants.COM);
1356  store.setToDefault(PreferenceConstants.PROCESS+"."+PreferenceConstants.ARGS);
1357  store.setToDefault(PreferenceConstants.PROCESS+"."+PreferenceConstants.AUTOSTART);
1358  store.setToDefault(PreferenceConstants.PROCESS+"."+PreferenceConstants.USEORB);
1359  }
1361  }
1362  }
1363 
1364  @SuppressWarnings("unchecked")
1365  public void propertyChange(PropertyChangeEvent event) {
1366  if(event.getProperty().equals("userItemChange")){
1367  String newItemList = (String) event.getNewValue();
1368  String[] newItems = newItemList.split(PreferenceConstants.SEPARATOR, -1);
1369  String oldItemList = (String) event.getOldValue();
1370  String[] oldItems = oldItemList.split(PreferenceConstants.SEPARATOR, -1);
1371  IPreferenceStore store =Activator.getDefault().getPreferenceStore();
1372  String userItemPathList=store.getString(PreferenceConstants.USERITEM+"."+PreferenceConstants.CLASSPATH);
1373  String[] userItemPath=userItemPathList.split(PreferenceConstants.SEPARATOR, -1);
1374  String userItemVisibleList=store.getString(PreferenceConstants.USERITEM+"."+PreferenceConstants.VISIBLE);
1375  String[] userItemVisible=userItemVisibleList.split(PreferenceConstants.SEPARATOR, -1);
1376  Vector<Integer> delList = new Vector<Integer>();
1377  for(int i=0; i<oldItems.length; i++){
1378  boolean flg=false;
1379  for(String newItem : newItems){
1380  if(newItem.equals(oldItems[i])){
1381  flg=true;
1382  break;
1383  }
1384  }
1385  if(!flg && !oldItems[i].equals(""))
1386  delList.add(new Integer(i));
1387 
1388  }
1389 
1391  for(Integer i : delList){
1392  Class<? extends GrxBasePlugin> itemClass=null;
1393  try {
1394  itemClass = (Class<? extends GrxBasePlugin>) Class.forName(oldItems[i.intValue()], false, pluginLoader_);
1395  } catch (ClassNotFoundException e) {
1396  continue;
1397  }
1398  if(currentMode_.activeItemClassList_.contains(itemClass))
1399  removeItems((Class<? extends GrxBaseItem>) itemClass);
1400  Iterator<GrxModeInfoItem> it = modes.values().iterator();
1401  while (it.hasNext()) {
1402  GrxModeInfoItem mode = it.next();
1403  if(mode.activeItemClassList_.contains(itemClass))
1404  mode.activeItemClassList_.remove(itemClass);
1405  }
1406  }
1407  for(int i=0; i<newItems.length; i++){
1408  pluginLoader_.addURL(userItemPath[i]);
1409  Class<? extends GrxBasePlugin> itemClass=null;
1410  try {
1411  itemClass = (Class<? extends GrxBasePlugin>) Class.forName(newItems[i], false, pluginLoader_);
1412  } catch (ClassNotFoundException e) {
1413  continue;
1414  }
1415  Iterator<GrxModeInfoItem> it = modes.values().iterator();
1416  while (it.hasNext()) {
1417  GrxModeInfoItem mode = it.next();
1418  if(mode.activeItemClassList_.contains(itemClass)){
1419  PluginInfo pi = pinfoMap_.get(itemClass);
1420  pi.visible = userItemVisible[i].equals("true")? true : false;
1421  pinfoMap_.put(itemClass, pi);
1422  }else{
1423  if(pluginLoader_.existClass(newItems[i])){
1424  Class<? extends GrxBasePlugin> plugin=registerPlugin(newItems[i]);
1425  if (plugin != null) {
1426  PluginInfo pi = pinfoMap_.get(plugin);
1427  pi.visible = userItemVisible[i].equals("true")? true : false;
1428  pinfoMap_.put(plugin, pi);
1429  mode.addItemClassList(plugin);
1430  }
1431  }
1432  }
1433  }
1434  }
1435  }
1436  else if(event.getProperty().equals(PreferenceConstants.FONT_TABLE)){
1438  List<GrxBaseView> list = getViewList();
1439  for (GrxBaseView v : list){
1440  v.updateTableFont();
1441  }
1442  }
1443  else if(event.getProperty().equals(PreferenceConstants.FONT_EDITER)){
1445  List<GrxBaseView> list = getViewList();
1446  for (GrxBaseView v : list){
1447  v.updateEditerFont();
1448  }
1449  }
1451  }
1452 
1453  @SuppressWarnings("unchecked")
1454  public void addPlugin(String className, String classPath){
1455  pluginLoader_.addURL(classPath);
1456  Class<? extends GrxBasePlugin> itemClass=null;
1457  try {
1458  itemClass = (Class<? extends GrxBasePlugin>) Class.forName(className, false, pluginLoader_);
1459  } catch (ClassNotFoundException e) {
1460  return;
1461  }
1463  Iterator<GrxModeInfoItem> it = modes.values().iterator();
1464  while (it.hasNext()) {
1465  GrxModeInfoItem mode = it.next();
1466  if(!mode.activeItemClassList_.contains(itemClass)){
1467  if(pluginLoader_.existClass(className)){
1468  Class<? extends GrxBasePlugin> plugin=registerPlugin(className);
1469  if (plugin != null) {
1470  PluginInfo pi = pinfoMap_.get(plugin);
1471  pi.visible = true;
1472  pinfoMap_.put(plugin, pi);
1473  mode.addItemClassList(plugin);
1474  }
1475  }
1476  }
1477  }
1479  }
1480 
1481  @SuppressWarnings("unchecked")
1482  public void deletePlugin(Class<? extends GrxBasePlugin> cls){
1484  if(currentMode_.activeItemClassList_.contains(cls)){
1485  removeItems((Class<? extends GrxBaseItem>) cls);
1486  Iterator<GrxModeInfoItem> it = modes.values().iterator();
1487  while (it.hasNext()) {
1488  GrxModeInfoItem mode = it.next();
1489  if(mode.activeItemClassList_.contains(cls))
1490  mode.activeItemClassList_.remove(cls);
1491  }
1492  }
1494  }
1495 
1496  public void dispose(){
1497  IPreferenceStore store =Activator.getDefault().getPreferenceStore();
1498  store.removePropertyChangeListener(this);
1499  }
1500 
1501  public void loadInitialProject(){
1502  IPreferenceStore store =Activator.getDefault().getPreferenceStore();
1503  String initProjectFile = store.getString(PreferenceConstants.INITIALPROJECT);
1504  File f = new File(initProjectFile);
1505  if(f.exists() && f.isFile())
1506  currentProject_.load(f);
1507  }
1508 
1510  return currentProject_.getViewProperties(name);
1511  }
1512 
1513 }
Map< Class<? extends GrxBasePlugin >, PluginInfo > pinfoMap_
static final String get(String key)
void addItemClassList(Class<? extends GrxBasePlugin > item)
int c
Definition: autoplay.py:16
void showExceptionTrace(String m, Exception e)
Vector< Action > getProjectMenu()
get project menu
boolean isPerspectiveVisible()
check if GrxUI perspective is visible or not
Class<? extends GrxBasePlugin > registerPlugin(String className)
ArrayList< GrxBaseItem > getActiveItemList()
void itemChange(GrxBaseItem item, int event)
String getCurrentModeName()
get current model name
void shutdown()
shutdown this manager
void deletePlugin(Class<? extends GrxBasePlugin > cls)
void removeAllItems()
remove all items which are instances of active classes in the current mode
void setName(String name)
set name
void clear(CorbaSequence &seq)
void setProjectProperty(String key, String val)
set property associated to key
#define null
our own NULL pointer
Definition: IceTypes.h:57
void removeItemChangeListener(GrxItemChangeListener view, Class<? extends GrxBaseItem > cls)
void updateActiveViewList()
update list of views python script から呼ばれた場合、UIスレッド外からの呼び出しとなって、NGなのでsync...
GrxBaseItem createItem(Class<? extends GrxBaseItem > cls, String name)
アイテムの作成. 指定したアイテムプラグインに、指定したアイテム名で新しいアイテムを作る。 ...
int version
Definition: jpeglib.h:901
GrxProjectItem getProject()
get current project
png_infop png_charpp name
Definition: png.h:2382
void registerItemChangeListener(GrxItemChangeListener view, Class<? extends GrxBaseItem > cls)
Vector< Action > getItemMenu(final Class<? extends GrxBaseItem > cls)
void clearItemSelection()
unselect all items
RTC::ReturnCode_t ret(RTC::Local::ReturnCode_t r)
item corresponds to a robot model
HashMap< Class<? extends GrxBasePlugin >, OrderedHashMap > pluginMap_
GrxBasePlugin createPlugin(Class<? extends GrxBasePlugin > cls, String name)
void focusedItem(GrxBaseItem item)
set focused item
void setURL(String url)
set URL property
static SynchronizedAccessor< String > clipValue_
boolean isSelected()
check whether this is selected or not
void removeItems(Class<? extends GrxBaseItem > cls)
remove all items which are instances of specified class
png_uint_32 i
Definition: png.h:2735
void dynamicChangeMenu(final Class<? extends GrxBaseItem > cls, Vector< Action > menu)
GrxBaseItem loadItem(Class<? extends GrxBaseItem > cls, String name, String url)
GrxBasePlugin createPlugin(Class cls, String name, GrxPluginManager manager)
std::string basename(const std::string name)
static org.omg.CORBA.ORB getORB(String[] argv)
initialize and get ORB
boolean registerPluginInstance(GrxBasePlugin instance)
register instance of plugin to this manager
void removeItem(GrxBaseItem item)
remove item
void setCurrentMode(GrxModeInfoItem mode)
String getProjectProperty(String key)
get property of current project associated to key
void addPlugin(String className, String classPath)
void setSelectedItem(GrxBaseItem item, boolean select)
select/unselect item
synchronized GrxBaseView getView(String name, boolean active)
boolean isItemVisible(Class<? extends GrxBasePlugin > cls)
check an item class is visible or not
GrxBaseItem pasteItem(Class<? extends GrxBaseItem > cls, GrxBaseItem item)
list index
boolean renamePlugin(GrxBasePlugin item, String newName)
rename plugin. If new name is already used, name is not changed.
GrxBaseView createView(Class<? extends GrxBaseView > cls, String name)
Map<?, ?> getItemMap(Class<? extends GrxBaseItem > cls)
def run(tree, args)
int val
Definition: jpeglib.h:956
Map< Class<? extends GrxBaseItem >, List< GrxItemChangeListener > > itemChangeListener_
GrxBaseItem getItem(Class<? extends GrxBaseItem > cls, String name)
GrxBaseView getView(Class<? extends GrxBaseView > cls, boolean active)
static String expandEnvVal(String str)
Object setProperty(String key, String value)
set property value associated with a keyword
static Object getField(Class<? extends GrxBasePlugin > cls, String field, Object defaultValue)
get field
GrxBaseItem focusedItem()
get current focused item
Class<? extends GrxBasePlugin > registerPlugin(Class<? extends GrxBasePlugin > cls)
Object put(Object key, Object obj)
プラグイン管理クラス GrxUIの核になるクラス。プラグインのロード等の、初期化を実行する。 プラグインとそ...
final String toString()
convert to String. Currently, name is returned.
static void setClipBordVal()
Set clip board value GrxPluginManager.clipValue_.
static void resourceToFile(Class<? extends GrxPluginManager > grxPluginManager, String srcName, File destFile)
Definition: FileUtil.java:56
void setProcessList(GrxServerManager serverManager)
def getText(self, nodes=None)
static String getClipBoardVal()
Get selected GrxBaseItem List on tree view.
void propertyChange(PropertyChangeEvent event)
GrxModeInfoItem getMode()
get current mode
Properties getViewProperties(String viewName)
org
JSAMPIMAGE data
Definition: jpeglib.h:945
String getItemTitle(Class<? extends GrxBasePlugin > cls)
get title of item class
static BodyCustomizerHandle create(BodyHandle bodyHandle, const char *modelName)
GrxPluginManager()
GrxPluginManagerのコンストラクタ. まず、プラグインローダ(GrxPluginLoader)のインスタンス::pluginLoad...
ArrayList< Class<? extends GrxBaseItem > > activeItemClassList_
static Boolean getBoolean(String[] path, String atr, boolean defaultValue)
void setFocused(boolean b)
set/unset focus on this plugin


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Thu Sep 8 2022 02:24:03