GrxControllerView.java
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010, 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  */
17 package com.generalrobotix.ui.view;
18 
19 import java.util.ArrayList;
20 import java.util.Iterator;
21 import java.util.List;
22 
23 import org.eclipse.swt.SWT;
24 import org.eclipse.swt.widgets.Composite;
25 
34 
35 @SuppressWarnings("serial")
36 public class GrxControllerView extends GrxBaseView {
38  private List<GrxModelItem> currentModels_ = new ArrayList<GrxModelItem>();
39  private List<GrxCollisionPairItem> currentCollisionPairs_ = new ArrayList<GrxCollisionPairItem>();
40 
41  public GrxControllerView(String name, GrxPluginManager manager, GrxBaseViewPart vp, Composite parent) {
42  super(name, manager, vp, parent);
43 
44  controllerPane_ = new ControllerPanel(composite_, SWT.NONE, manager_);
45  currentModels_ = manager_.<GrxModelItem>getSelectedItemList(GrxModelItem.class);
46  controllerPane_.updateRobots(currentModels_);
47  controllerPane_.setEnabled(true);
48 
49  currentCollisionPairs_ = manager_.<GrxCollisionPairItem>getSelectedItemList(GrxCollisionPairItem.class);
50 
51  Iterator<GrxModelItem> it = currentModels_.iterator();
52  while(it.hasNext()) {
53  it.next().addObserver(this);
54  }
55  manager_.registerItemChangeListener(this, GrxModelItem.class);
56  manager_.registerItemChangeListener(this, GrxCollisionPairItem.class);
57  }
58 
59  public void setUp(){
60  Iterator<GrxModelItem> it = currentModels_.iterator();
61  while(it.hasNext())
62  it.next().deleteObserver(this);
63  currentModels_ = manager_.<GrxModelItem>getSelectedItemList(GrxModelItem.class);
64  currentCollisionPairs_ = manager_.<GrxCollisionPairItem>getSelectedItemList(GrxCollisionPairItem.class);
65  controllerPane_.updateRobots(currentModels_);
66  it = currentModels_.iterator();
67  while(it.hasNext())
68  it.next().addObserver(this);
69 
70  }
71 
72  public void registerItemChange(GrxBaseItem item, int event){
73  if(item instanceof GrxModelItem){
74  GrxModelItem mitem = (GrxModelItem)item;
75  switch(event){
77  if(!currentModels_.contains(mitem)){
78  currentModels_.add(mitem);
79  controllerPane_.updateRobots(currentModels_);
80  mitem.addObserver(this);
81  }
82  break;
85  if(currentModels_.contains(mitem)){
86  currentModels_.remove(mitem);
87  controllerPane_.updateRobots(currentModels_);
88  mitem.deleteObserver(this);
89  }
90  break;
91  default:
92  break;
93  }
94  }else if(item instanceof GrxCollisionPairItem){
95  GrxCollisionPairItem citem = (GrxCollisionPairItem)item;
96  switch(event){
99  if(!currentCollisionPairs_.contains(citem)){
100  currentCollisionPairs_.add(citem);
101  controllerPane_.updateRobots(currentModels_);
102  }
103  break;
106  if(currentCollisionPairs_.contains(citem)){
107  currentCollisionPairs_.remove(citem);
108  controllerPane_.updateRobots(currentModels_);
109  }
110  break;
111  default:
112  break;
113  }
114  }
115  }
116 
117  public void update(GrxBasePlugin plugin, Object... arg) {
118 
119  if(currentModels_.contains(plugin)){
120  if((String)arg[0]=="PropertyChange"){ //$NON-NLS-1$
121  if((String)arg[1]=="isRobot")
122  controllerPane_.updateRobots(currentModels_);
123  }
124  }
125  }
126 
127  public void shutdown() {
128  Iterator<GrxModelItem> it = currentModels_.iterator();
129  while(it.hasNext()) {
130  it.next().deleteObserver(this);
131  }
132 
133  manager_.removeItemChangeListener(this, GrxModelItem.class);
134  manager_.removeItemChangeListener(this, GrxCollisionPairItem.class);
135  }
136 
137  public void updateTableFont(){
138  controllerPane_.updateTableFont();
139  }
140 }
GrxControllerView(String name, GrxPluginManager manager, GrxBaseViewPart vp, Composite parent)
png_infop png_charpp name
Definition: png.h:2382
item corresponds to a robot model
void registerItemChange(GrxBaseItem item, int event)
プラグイン管理クラス GrxUIの核になるクラス。プラグインのロード等の、初期化を実行する。 プラグインとそ...
void update(GrxBasePlugin plugin, Object... arg)
org
char * arg
Definition: cdjpeg.h:136


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