GrxBaseItem.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  * GrxBaseItem.java
12  *
13  * Copyright (C) 2007 GeneralRobotix, Inc.
14  * All Rights Reserved
15  *
16  * @author Yuichiro Kawasumi (General Robotix, Inc.)
17  */
18 package com.generalrobotix.ui;
19 
20 import java.io.File;
21 
22 import org.eclipse.jface.action.Action;
23 import org.eclipse.jface.dialogs.MessageDialog;
24 import org.eclipse.swt.SWT;
25 import org.eclipse.swt.widgets.FileDialog;
26 import org.eclipse.osgi.util.NLS;
27 
29 
30 @SuppressWarnings("serial") //$NON-NLS-1$
31 
32 
35 public class GrxBaseItem extends GrxBasePlugin {
36  private Object value_ = null;
38  protected File file_;
39  private String ext_;
40  protected String clipValue_ = ""; //$NON-NLS-1$
41 
42  protected static final String[] modeComboItem_ = new String[] { "Torque", "HighGain" };
43  protected static final String[] jointTypeComboItem_ = new String[] { "fixed", "rotate", "free", "slide" };
44  protected static final String[] methodComboItem_ = new String[] { "EULER", "RUNGE_KUTTA" };
45 
51  protected GrxBaseItem(String name, GrxPluginManager manager) {
52  super(name, manager);
53  // delete
54  Action item = new Action(){
55  public String getText(){
56  return MessageBundle.get("GrxBaseItem.menu.delete"); //$NON-NLS-1$
57  }
58  public void run(){
59  String mes = MessageBundle.get("GrxBaseItem.dialog.message.delete"); //$NON-NLS-1$
60  mes = NLS.bind(mes, new String[]{GrxBaseItem.this.getName()});
61 
62  if( MessageDialog.openQuestion( null, MessageBundle.get("GrxBaseItem.dialog.title.delete"), //$NON-NLS-1$
63  mes) )
64  delete();
65  }
66  };
67  setMenuItem(item);
68  }
69 
74  public boolean create() {
75  return true;
76  };
77 
83  public boolean load(File file) {
84  file_ = file;
85  return true;
86  };
87 
88 
92  public void delete() {
93  //System.out.println("GrxBaseItem.delete("+getName()+") is called");
94  manager_.removeItem(this);
95  };
96 
101  public String getFileExtention() {
102  if (ext_ == null)
103  ext_ = (String)GrxBasePlugin.getField(this.getClass(), "FILE_EXTENSION", ""); //$NON-NLS-1$ //$NON-NLS-2$
104  return ext_;
105  }
106 
111  public File getDefaultDir() {
112  if (defaultFileDir_ == null)
113  defaultFileDir_ = new File(manager_.getHomePath().getPath() + GrxBasePlugin.getField(this.getClass(), "DEFAULT_DIR", "")); //$NON-NLS-1$ //$NON-NLS-2$
114  return defaultFileDir_;
115  }
116 
121  public Object getValue() {
122  return value_;
123  }
124 
129  protected void setFileExtension(String ext) {
130  ext_ = ext;
131  }
132 
137  protected void setDefaultDirectory(String dir) {
138  defaultFileDir_ = new File(dir);
139  if (!defaultFileDir_.isDirectory())
140  defaultFileDir_ = manager_.getHomePath();
141  }
142 
147  public void setValue(Object o) {
148  value_ = o;
149  }
150 
155  public File chooseSaveFile() {
156  FileDialog openDialog = new FileDialog(null,SWT.SAVE);
157  String openFile = openDialog.open();
158  if( openFile != null )
159  return new File(openFile);
160  else
161  return null;
162  }
163 
167  public void paste(String clipVal) {
168  clipValue_ = clipVal;
169  };
170 
175  public GrxBaseItem clone() {
176  GrxBaseItem ret = (GrxBaseItem) super.clone();
177  ret.setValue(value_);
178 /*
179  * Deep copy suspension list
180  ret.defaultFileDir_ = new File(defaultFileDir_.getPath());
181  ret.file_ = new File(file_.getPath());
182  ret.ext_ = new String(ext_);
183  ret.clipValue_ = new String(clipValue_);
184 */
185  return ret;
186  }
187 }
static final String get(String key)
#define null
our own NULL pointer
Definition: IceTypes.h:57
png_infop png_charpp name
Definition: png.h:2382
GrxBaseItem clone()
Override clone method.
RTC::ReturnCode_t ret(RTC::Local::ReturnCode_t r)
void paste(String clipVal)
paste object
File getDefaultDir()
get default directory
def run(tree, args)
String getFileExtention()
get file extension
プラグイン管理クラス GrxUIの核になるクラス。プラグインのロード等の、初期化を実行する。 プラグインとそ...
def getText(self, nodes=None)
org
GrxBaseItem(String name, GrxPluginManager manager)
constructor


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Sat May 8 2021 02:42:37