00001
00002
00003
00004
00005
00006
00007
00008
00009
00018 package com.generalrobotix.ui.view.simulation;
00019
00020 import java.util.ArrayList;
00021 import java.util.Iterator;
00022 import java.util.List;
00023 import java.util.Vector;
00024
00025 import org.eclipse.jface.dialogs.MessageDialog;
00026 import org.eclipse.jface.viewers.ArrayContentProvider;
00027 import org.eclipse.jface.viewers.ColumnWeightData;
00028 import org.eclipse.jface.viewers.ILabelProviderListener;
00029 import org.eclipse.jface.viewers.ITableLabelProvider;
00030 import org.eclipse.jface.viewers.TableLayout;
00031 import org.eclipse.jface.viewers.TableViewer;
00032 import org.eclipse.swt.SWT;
00033 import org.eclipse.swt.events.SelectionEvent;
00034 import org.eclipse.swt.events.SelectionListener;
00035 import org.eclipse.swt.graphics.Image;
00036 import org.eclipse.swt.layout.FillLayout;
00037 import org.eclipse.swt.layout.GridData;
00038 import org.eclipse.swt.layout.GridLayout;
00039 import org.eclipse.swt.widgets.Button;
00040 import org.eclipse.swt.widgets.Combo;
00041 import org.eclipse.swt.widgets.Composite;
00042 import org.eclipse.swt.widgets.Control;
00043 import org.eclipse.swt.widgets.Label;
00044 import org.eclipse.swt.widgets.TableColumn;
00045 import org.eclipse.swt.widgets.Text;
00046
00047 import com.generalrobotix.ui.GrxBaseItem;
00048 import com.generalrobotix.ui.GrxPluginManager;
00049 import com.generalrobotix.ui.grxui.Activator;
00050 import com.generalrobotix.ui.item.GrxCollisionPairItem;
00051 import com.generalrobotix.ui.item.GrxModelItem;
00052 import com.generalrobotix.ui.item.GrxWorldStateItem;
00053 import com.generalrobotix.ui.util.MessageBundle;
00054 import com.generalrobotix.ui.view.graph.SEBoolean;
00055
00056 @SuppressWarnings("serial")
00057 public class CollisionPairPanel extends Composite {
00058 private GrxPluginManager manager_;
00059 private TableViewer viewer_;
00060 private Vector<GrxCollisionPairItem> vecCollision_;
00061
00062 private Button btnAdd_;
00063 private Button btnRemove_;
00064 private Button btnEdit_;
00065 private Button btnAddAll_;
00066 private CollisionPairEditorPanel editorPanel_;
00067
00068 private String defaultStaticFriction_;
00069 private String defaultSlidingFriction_;
00070 private String defaultCullingThresh_;
00071 private String defaultRestitution_;
00072
00073 private static final String ATTR_NAME_STATIC_FRICTION = "staticFriction";
00074 private static final String ATTR_NAME_SLIDING_FRICTION = "slidingFriction";
00075 private static final String ATTR_NAME_CULLING_THRESH = "cullingThresh";
00076 private static final String ATTR_NAME_RESTITUTION = "Restitution";
00077
00078 private final String[] clmName_ ={
00079 MessageBundle.get("panel.collision.table.obj1"),
00080 MessageBundle.get("panel.collision.table.link1"),
00081 MessageBundle.get("panel.collision.table.obj2"),
00082 MessageBundle.get("panel.collision.table.link2"),
00083 MessageBundle.get("panel.collision.staticFriction"),
00084 MessageBundle.get("panel.collision.slidingFriction"),
00085 MessageBundle.get("panel.collision.cullingThresh"),
00086 MessageBundle.get("panel.collision.restitution")
00087 };
00088
00089 private final String[] attrName_ ={
00090 "objectName1","jointName1",
00091 "objectName2","jointName2",
00092 ATTR_NAME_STATIC_FRICTION, ATTR_NAME_SLIDING_FRICTION, ATTR_NAME_CULLING_THRESH, ATTR_NAME_RESTITUTION
00093 };
00094
00095 private static final int BUTTONS_HEIGHT = 26;
00096
00097 public void setEnabled(boolean flag) {
00098 super.setEnabled(flag);
00099 if (editorPanel_ != null)
00100 editorPanel_.doCancel();
00101 _setButtonEnabled(flag);
00102 }
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120 public CollisionPairPanel(Composite parent,int style,GrxPluginManager manager) {
00121 super(parent, style);
00122 manager_ = manager;
00123
00124 defaultStaticFriction_ = "0.5";
00125 defaultSlidingFriction_ = "0.5";
00126 defaultCullingThresh_ = "0.01";
00127 defaultRestitution_ = "0.0";
00128
00129 vecCollision_ = new Vector<GrxCollisionPairItem>();
00130
00131 setLayout(new GridLayout(1,false));
00132
00133 viewer_ = new TableViewer(this,SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION);
00134 viewer_.getTable().setLayoutData(new GridData(GridData.FILL_BOTH));
00135 viewer_.setContentProvider(new ArrayContentProvider());
00136 viewer_.setLabelProvider(new InnerTableLabelProvider());
00137 viewer_.getTable().addSelectionListener(new SelectionListener(){
00138
00139 public void widgetDefaultSelected(SelectionEvent e) {
00140 }
00141
00142 public void widgetSelected(SelectionEvent e) {
00143 int row = viewer_.getTable().getSelectionIndex();
00144 if (row >= 0 && row < vecCollision_.size()) {
00145 editorPanel_.setNode(vecCollision_.get(row));
00146 }
00147 }
00148 });
00149 TableLayout tableLayout = new TableLayout();
00150 for(int i=0;i<clmName_.length;i++){
00151 new TableColumn(viewer_.getTable(),i).setText(clmName_[i]);;
00152 tableLayout.addColumnData(new ColumnWeightData(1,true));
00153 }
00154 viewer_.getTable().setLayout(tableLayout);
00155 viewer_.getTable().setHeaderVisible(true);
00156 viewer_.getTable().setLinesVisible(true);
00157 viewer_.setInput(vecCollision_);
00158
00159
00160 Composite pnlBttn = new Composite(this,SWT.NONE);
00161 GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
00162 gridData.heightHint = BUTTONS_HEIGHT;
00163 pnlBttn.setLayoutData(gridData);
00164 pnlBttn.setLayout(new FillLayout(SWT.HORIZONTAL));
00165
00166 btnAdd_ = new Button(pnlBttn,SWT.PUSH);
00167 btnAdd_.setText(MessageBundle.get("panel.add"));
00168 btnAdd_.addSelectionListener(new SelectionListener(){
00169
00170 public void widgetDefaultSelected(SelectionEvent e) {
00171 }
00172
00173 public void widgetSelected(SelectionEvent e) {
00174 _setButtonEnabled(false);
00175 editorPanel_.startAddMode();
00176 }
00177
00178 });
00179
00180 btnRemove_ = new Button(pnlBttn,SWT.PUSH);
00181 btnRemove_.setText(MessageBundle.get("panel.remove"));
00182 btnRemove_.addSelectionListener(new SelectionListener(){
00183
00184 public void widgetDefaultSelected(SelectionEvent e) {
00185 }
00186
00187 public void widgetSelected(SelectionEvent e) {
00188 int row = viewer_.getTable().getSelectionIndex();
00189 if (row >= 0 && row < vecCollision_.size()) {
00190 if (_checkDialog(MessageBundle.get("collision.remove"))) {
00191 vecCollision_.get(row).delete();
00192 }
00193 }
00194 }
00195
00196 });
00197
00198 btnEdit_ = new Button(pnlBttn,SWT.PUSH);
00199 btnEdit_.setText(MessageBundle.get("panel.edit"));
00200 btnEdit_.addSelectionListener(new SelectionListener(){
00201
00202 public void widgetDefaultSelected(SelectionEvent e) {
00203 }
00204
00205 public void widgetSelected(SelectionEvent e) {
00206 int row = viewer_.getTable().getSelectionIndex() ;
00207 if(row>=0 && row<vecCollision_.size()){
00208 _setButtonEnabled(false);
00209 editorPanel_.startEditMode(vecCollision_.get(row));
00210 }
00211 }
00212
00213 });
00214
00215 btnAddAll_ = new Button(pnlBttn,SWT.PUSH);
00216 btnAddAll_.setText(MessageBundle.get("panel.addAll"));
00217 btnAddAll_.addSelectionListener(new SelectionListener(){
00218
00219 public void widgetDefaultSelected(SelectionEvent e) {
00220 }
00221
00222 public void widgetSelected(SelectionEvent e) {
00223 manager_.refuseItemChange();
00224 List<GrxModelItem> list = manager_.<GrxModelItem>getSelectedItemList(GrxModelItem.class);
00225 for (int i=0; i<list.size(); i++) {
00226 GrxModelItem m1 = list.get(i);
00227 for (int j=i; j<list.size(); j++) {
00228 GrxModelItem m2 = list.get(j);
00229 for (int k=0; k<m1.links_.size(); k++) {
00230 int l=0;
00231 if(i==j) l=k;
00232 for (; l<m2.links_.size(); l++) {
00233 if (i != j || k != l){
00234 editorPanel_.txtStaticFric_.setText(defaultStaticFriction_);
00235 editorPanel_.txtSlidingFric_.setText(defaultSlidingFriction_);
00236 editorPanel_.txtCullingThresh_.setText(defaultCullingThresh_);
00237 editorPanel_.txtRestitution_.setText(defaultRestitution_);
00238 _createItem(m1.getName(), m1.links_.get(k).getName(), m2.getName(), m2.links_.get(l).getName());
00239 }
00240 }
00241 }
00242 }
00243 }
00244 manager_.acceptItemChange();
00245 }
00246
00247 });
00248
00249 Composite editorPanelComposite = new Composite(this,SWT.NONE);
00250 GridData editorPanelGridData = new GridData(GridData.FILL_HORIZONTAL);
00251 editorPanelComposite.setLayoutData(editorPanelGridData);
00252 editorPanelComposite.setLayout(new FillLayout(SWT.HORIZONTAL));
00253 editorPanel_ = new CollisionPairEditorPanel(editorPanelComposite,SWT.NONE);
00254
00255 updateTableFont();
00256 }
00257
00258 private boolean _checkDialog(String msg) {
00259 boolean overwrite = MessageDialog.openQuestion(getShell(), MessageBundle.get("dialog.overwrite"), msg);
00260 return overwrite;
00261 }
00262
00263 private void _setButtonEnabled(boolean flag) {
00264 btnAdd_.setEnabled(flag);
00265 btnRemove_.setEnabled(flag);
00266 btnEdit_.setEnabled(flag);
00267 btnAddAll_.setEnabled(flag);
00268 viewer_.getTable().setEnabled(flag);
00269 _repaint();
00270 }
00271
00272 private void _repaint() {
00273
00274 }
00275
00276 private class CollisionPairEditorPanel extends Composite {
00277
00278 private static final int MODE_ADD = 0 ;
00279 private static final int MODE_EDIT = 1 ;
00280
00281 private static final int BUTTON_WIDTH = 50;
00282
00283 private int mode_;
00284 private GrxCollisionPairItem node_;
00285 private JointSelectPanel pnlJoint1_;
00286 private JointSelectPanel pnlJoint2_;
00287 private Button btnOk_, btnCancel_;
00288
00289 private Text txtStaticFric_,txtSlidingFric_,txtCullingThresh_,txtRestitution_;
00290 private Label lblFriction_,lblStaticFric_,lblSlidingFric_,lblCullingThresh_,lblRestitution_;
00291
00292 public CollisionPairEditorPanel(Composite parent,int style) {
00293 super(parent,style);
00294 setLayout(new GridLayout(2,false));
00295
00296 pnlJoint1_ = new JointSelectPanel(this,SWT.NONE,"1");
00297 pnlJoint1_.setLayoutData(new GridData(GridData.FILL_BOTH));
00298
00299
00300 pnlJoint2_ = new JointSelectPanel(this,SWT.NONE,"2");
00301 pnlJoint2_.setLayoutData(new GridData(GridData.FILL_BOTH));
00302
00303
00304 lblFriction_ = new Label(this,SWT.SHADOW_NONE);
00305 lblFriction_.setText(MessageBundle.get("panel.collision.friction"));
00306
00307
00308 new Label(this,SWT.SHADOW_NONE);
00309
00310 lblStaticFric_ = new Label(this,SWT.SHADOW_NONE);
00311 lblStaticFric_.setText(MessageBundle.get("panel.collision.staticFriction"));
00312 lblStaticFric_.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
00313
00314
00315 txtStaticFric_ = new Text(this,SWT.SINGLE | SWT.BORDER);
00316 txtStaticFric_.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
00317
00318
00319 lblSlidingFric_ = new Label(this,SWT.SHADOW_NONE);
00320 lblSlidingFric_.setText(MessageBundle.get("panel.collision.slidingFriction"));
00321 lblSlidingFric_.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
00322
00323
00324 txtSlidingFric_ = new Text(this,SWT.SINGLE | SWT.BORDER);
00325 txtSlidingFric_.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
00326
00327
00328 lblCullingThresh_ = new Label(this,SWT.SHADOW_NONE);
00329 lblCullingThresh_.setText(MessageBundle.get("panel.collision.cullingThresh"));
00330 lblCullingThresh_.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
00331
00332 txtCullingThresh_ = new Text(this,SWT.SINGLE | SWT.BORDER);
00333 txtCullingThresh_.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
00334
00335 lblRestitution_ = new Label(this,SWT.SHADOW_NONE);
00336 lblRestitution_.setText(MessageBundle.get("panel.collision.restitution"));
00337 lblRestitution_.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
00338
00339 txtRestitution_ = new Text(this,SWT.SINGLE | SWT.BORDER);
00340 txtRestitution_.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
00341
00342 btnOk_ = new Button(this,SWT.PUSH);
00343 btnOk_.setText(MessageBundle.get("dialog.okButton"));
00344 btnOk_.addSelectionListener(new SelectionListener(){
00345
00346 public void widgetDefaultSelected(SelectionEvent e) {
00347 }
00348
00349 public void widgetSelected(SelectionEvent e) {
00350 switch (mode_) {
00351 case MODE_ADD:
00352 if (pnlJoint1_.getObjectName().equals(pnlJoint2_.getObjectName())
00353 && pnlJoint1_.getJointName().equals(pnlJoint2_.getJointName())) {
00354 MessageDialog.openWarning(getShell(), "", MessageBundle.get("collision.invalid"));
00355 return;
00356 }
00357
00358 GrxCollisionPairItem item = _createItem(pnlJoint1_.getObjectName(), pnlJoint1_.getJointName(),
00359 pnlJoint2_.getObjectName(), pnlJoint2_.getJointName());
00360
00361 if (item == null ){
00362 System.out.println("error: item = "+item);
00363 return;
00364 }
00365
00366 break;
00367 case MODE_EDIT:
00368 _setAttribute(node_);
00369 break;
00370 }
00371 setEnabled(false);
00372 }
00373
00374
00375
00376 });
00377
00378 GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_CENTER);
00379 gridData.widthHint = BUTTON_WIDTH;
00380 btnOk_.setLayoutData(gridData);
00381
00382
00383 btnCancel_ = new Button(this,SWT.PUSH);
00384 btnCancel_.setText(MessageBundle.get("dialog.cancelButton"));
00385 btnCancel_.addSelectionListener(new SelectionListener(){
00386
00387 public void widgetDefaultSelected(SelectionEvent e) {
00388 }
00389
00390 public void widgetSelected(SelectionEvent e) {
00391 doCancel();
00392 }
00393
00394 });
00395 gridData = new GridData();
00396
00397 btnCancel_.setLayoutData(gridData);
00398
00399 }
00400
00401 private boolean _setAttribute(GrxCollisionPairItem node) {
00402 try{
00403 String sTxtStaticFric_ = txtStaticFric_.getText();
00404 String sTxtSlidingFric_ = txtSlidingFric_.getText();
00405 String sTxtCullingThresh_ = txtCullingThresh_.getText();
00406 String sTxtRestitution_ = txtRestitution_.getText();
00407
00408 node.setProperty( ATTR_NAME_STATIC_FRICTION, sTxtStaticFric_ );
00409 node.setProperty( ATTR_NAME_SLIDING_FRICTION, sTxtSlidingFric_ );
00410 node.setProperty( ATTR_NAME_CULLING_THRESH, sTxtCullingThresh_ );
00411 node.setProperty( ATTR_NAME_RESTITUTION, sTxtRestitution_ );
00412 } catch (Exception ex) {
00413 MessageDialog.openWarning(getShell(), "", MessageBundle.get("message.attributeerror"));
00414 return false;
00415 }
00416 return true;
00417 }
00418
00419 public void startAddMode() {
00420 mode_ = MODE_ADD;
00421 setEnabled(true);
00422 if (pnlJoint1_.entry()){
00423 pnlJoint2_.entry();
00424 txtStaticFric_.setText(defaultStaticFriction_);
00425 txtSlidingFric_.setText(defaultSlidingFriction_);
00426 txtCullingThresh_.setText(defaultCullingThresh_);
00427 txtRestitution_.setText(defaultRestitution_);
00428 node_ = null;
00429 }else{
00430 doCancel();
00431 }
00432 }
00433
00434 public void startEditMode(GrxCollisionPairItem node) {
00435 mode_ = MODE_EDIT;
00436 setNode(node);
00437 setEnabled(true);
00438 }
00439
00440 public void doCancel() {
00441 setEnabled(false);
00442 txtStaticFric_.setText("");
00443 txtSlidingFric_.setText("");
00444 txtCullingThresh_.setText("");
00445 txtRestitution_.setText("");
00446 }
00447
00448 public void setNode(GrxCollisionPairItem node) {
00449 try{
00450 pnlJoint1_.setJoint(
00451 node.getStr("objectName1", ""),
00452 node.getStr("jointName1", "")
00453 );
00454 pnlJoint2_.setJoint(
00455 node.getStr("objectName2", ""),
00456 node.getStr("jointName2", "")
00457 );
00458 txtStaticFric_.setText(node.getStr(ATTR_NAME_STATIC_FRICTION, ""));
00459 txtSlidingFric_.setText(node.getStr(ATTR_NAME_SLIDING_FRICTION, ""));
00460 txtCullingThresh_.setText(node.getStr(ATTR_NAME_CULLING_THRESH, ""));
00461 txtRestitution_.setText(node.getStr(ATTR_NAME_RESTITUTION, ""));
00462 } catch (Exception ex) {
00463 ex.printStackTrace();
00464 }
00465 node_ = node;
00466 }
00467
00468 public void setEnabled(boolean flag) {
00469 super.setEnabled(flag);
00470 Control[] cmps = getChildren();
00471 for (int i = 0; i < cmps.length; i ++) {
00472 cmps[i].setEnabled(flag);
00473 }
00474
00475 if (mode_ == MODE_EDIT) {
00476 pnlJoint1_.setEnabled(false);
00477 pnlJoint2_.setEnabled(false);
00478 }
00479 _setButtonEnabled(!flag);
00480
00481 lblStaticFric_.setEnabled(flag);
00482 lblSlidingFric_.setEnabled(flag);
00483 lblCullingThresh_.setEnabled(flag);
00484 lblRestitution_.setEnabled(flag);
00485 txtStaticFric_.setEnabled(true);
00486 txtStaticFric_.setEditable(flag);
00487 txtSlidingFric_.setEnabled(true);
00488 txtSlidingFric_.setEditable(flag);
00489 txtCullingThresh_.setEnabled(true);
00490 txtCullingThresh_.setEditable(flag);
00491 txtRestitution_.setEnabled(true);
00492 txtRestitution_.setEditable(flag);
00493 }
00494
00495 private class JointSelectPanel extends Composite {
00496
00497 private Combo boxObject_;
00498 private Combo boxLink_;
00499 boolean flag_ = false;
00500
00501
00502 private List<GrxModelItem> modelItemList_;
00503
00504 public JointSelectPanel(Composite parent,int style,String title) {
00505 super(parent,style);
00506 modelItemList_ = new ArrayList<GrxModelItem>();
00507
00508 setLayout(new GridLayout(2,false));
00509
00510 Label label = new Label(this,SWT.SHADOW_NONE);
00511 label.setText(MessageBundle.get("panel.joint.object") + title);
00512 label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
00513
00514
00515 boxObject_ = new Combo(this,SWT.READ_ONLY);
00516 boxObject_.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
00517
00518
00519 label = new Label(this,SWT.SHADOW_NONE);
00520 label.setText(MessageBundle.get("panel.joint.link") + title);
00521 label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
00522
00523
00524 boxLink_ = new Combo(this,SWT.READ_ONLY);
00525 boxLink_.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
00526
00527
00528
00529 boxObject_.addSelectionListener(new SelectionListener(){
00530
00531 public void widgetDefaultSelected(SelectionEvent e) {
00532 }
00533
00534 public void widgetSelected(SelectionEvent e) {
00535 if (!flag_) {
00536 _entryLink(
00537 modelItemList_.get(boxObject_.getSelectionIndex())
00538 );
00539 }
00540 }
00541
00542 });
00543 }
00544
00545 private void _entryLink(GrxModelItem model) {
00546 boxLink_.removeAll();
00547
00548 for (int i=0; i<model.links_.size(); i++)
00549 boxLink_.add(model.links_.get(i).getName());
00550 boxLink_.deselectAll();
00551 }
00552
00553 public boolean entry() {
00554 boolean addFlag = false;
00555
00556 flag_ = true;
00557 boxObject_.removeAll();
00558 flag_ = false;
00559
00560 Iterator it = manager_.getItemMap(GrxModelItem.class).values().iterator();
00561 while (it.hasNext()) {
00562 GrxModelItem model = (GrxModelItem)it.next();
00563 modelItemList_.add(model);
00564 boxObject_.add(model.toString());
00565 addFlag = true;
00566 }
00567 return addFlag;
00568 }
00569
00570 public void remove() {
00571 flag_ = true;
00572 modelItemList_.clear();
00573 boxObject_.removeAll();
00574 flag_ = false;
00575 boxLink_.removeAll();
00576 }
00577
00578
00579 public void setJoint(String obj,String joint) {
00580 remove();
00581 flag_ = true;
00582 boxObject_.add(obj);
00583 boxLink_.add(joint);
00584 flag_ = false;
00585 }
00586
00587 public String getJointName() {
00588 return boxLink_.getText();
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598 }
00599
00600 public String getObjectName() {
00601 return boxObject_.getText();
00602 }
00603
00604 public void setEnabled(boolean flag) {
00605 super.setEnabled(flag);
00606 Control[] cmps = getChildren();
00607 for(int i = 0; i < cmps.length; i ++) {
00608 cmps[i].setEnabled(flag);
00609 }
00610 }
00611 }
00612
00613 }
00614
00615 private class InnerTableLabelProvider implements ITableLabelProvider{
00616
00617 public Image getColumnImage(Object element, int columnIndex) {
00618 return null;
00619 }
00620
00621 public String getColumnText(Object element, int columnIndex) {
00622 GrxBaseItem item = (GrxBaseItem)element;
00623 String str = null;
00624 try {
00625 str = item.getProperty(attrName_[columnIndex], "");
00626 } catch (Exception ex) {
00627 ex.printStackTrace();
00628 }
00629 return str;
00630 }
00631
00632 public void addListener(ILabelProviderListener listener) {
00633 }
00634
00635 public void dispose() {
00636 }
00637
00638 public boolean isLabelProperty(Object element, String property) {
00639 return false;
00640 }
00641
00642 public void removeListener(ILabelProviderListener listener) {
00643 }
00644
00645 }
00646
00647 public void updateCollisionPairs(List<GrxCollisionPairItem> clist, List<GrxModelItem> mlist) {
00648 editorPanel_.doCancel();
00649 vecCollision_ = new Vector<GrxCollisionPairItem>();
00650 for (int i=0; i<clist.size(); i++)
00651 vecCollision_.add(clist.get(i));
00652 viewer_.getTable().deselectAll();
00653 viewer_.setInput(vecCollision_);
00654 setEnabled(vecCollision_.size() > 0 || !mlist.isEmpty());
00655 _repaint();
00656 }
00657
00658
00659 public void replaceWorld(GrxWorldStateItem world) {
00660 editorPanel_.doCancel();
00661
00662 vecCollision_ = new Vector<GrxCollisionPairItem>();
00663 viewer_.setInput(vecCollision_);
00664 }
00665
00666 public void childAdded(GrxCollisionPairItem item) {
00667 int i;
00668 for (i = 0; i < vecCollision_.size(); i ++) {
00669 vecCollision_.get(i);
00670 if (vecCollision_.get(i).getName().compareTo(item.getName()) > 0)
00671 break;
00672 }
00673 vecCollision_.add(i, item);
00674 _repaint();
00675 return;
00676 }
00677
00678
00679
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703 public Vector vecCollision(){ return vecCollision_; }
00704
00705 private GrxCollisionPairItem _createItem(String oName1, String jName1, String oName2, String jName2) {
00706 GrxCollisionPairItem item = (GrxCollisionPairItem)manager_.createItem(
00707 GrxCollisionPairItem.class,
00708 "CP#"+oName1+"_"+jName1+"#"+oName2+"_"+jName2);
00709 if (item != null) {
00710 item.setProperty("objectName1", oName1);
00711 item.setProperty("jointName1", jName1);
00712 item.setProperty("objectName2", oName2);
00713 item.setProperty("jointName2", jName2);
00714 editorPanel_._setAttribute(item);
00715 }
00716 manager_.itemChange(item, GrxPluginManager.ADD_ITEM);
00717 manager_.setSelectedItem(item, true);
00718 return item;
00719 }
00720
00721 public void updateTableFont(){
00722 viewer_.getTable().setFont(Activator.getDefault().getFont("preference_table"));
00723 }
00724 }