Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 package com.generalrobotix.ui;
00019
00020 import java.awt.Dimension;
00021 import java.util.Enumeration;
00022 import java.util.List;
00023 import java.util.Properties;
00024
00025 import org.eclipse.swt.SWT;
00026 import org.eclipse.swt.custom.ScrolledComposite;
00027 import org.eclipse.swt.widgets.Composite;
00028 import org.w3c.dom.Element;
00029 import org.w3c.dom.Node;
00030
00031 import com.generalrobotix.ui.item.GrxProjectItem;
00032
00037 @SuppressWarnings("serial")
00038 public class GrxBaseView extends GrxBasePlugin implements GrxItemChangeListener, GrxObserver , GrxPositionObserver{
00039
00040 private static Dimension defaultButtonSize_ = new Dimension(27, 27);
00041 public boolean isScrollable_ = true;
00042
00043 public double min, max, now;
00044
00045 private GrxBaseViewPart vp_;
00046 private Composite parent_;
00047 private ScrolledComposite scrollComposite_;
00048 protected Composite composite_;
00049
00057 public GrxBaseView( String name, GrxPluginManager manager_, GrxBaseViewPart vp, Composite parent ){
00058 super( name, manager_ );
00059 vp_ = vp;
00060 parent_ = parent;
00061
00062 scrollComposite_ = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL);
00063 composite_ = new Composite(scrollComposite_, SWT.NONE);
00064 composite_.setLayout(parent.getLayout());
00065 scrollComposite_.setExpandHorizontal(true);
00066 scrollComposite_.setExpandVertical(true);
00067 scrollComposite_.setContent(composite_);
00068 }
00069
00074 public void setName(String name) {
00075 super.setName(name);
00076 }
00077
00082 public GrxBaseViewPart getViewPart(){
00083 return vp_;
00084 }
00085
00090 public Composite getParent(){
00091 return parent_;
00092 }
00093
00098 public Composite getComposite(){
00099 return composite_;
00100 }
00101
00105 public void setScrollMinSize(int width, int height){
00106 scrollComposite_.setMinSize(composite_.computeSize(width, height));
00107 }
00108
00113 public static Dimension getDefaultButtonSize() {
00114 return defaultButtonSize_;
00115 }
00116 public boolean cleanup(List<GrxBaseItem> itemList){return true;}
00122
00126 public void itemListChanged() {
00127 }
00128
00129 public void focusedItemChanged(GrxBaseItem item) {
00130 }
00131
00135 public void propertyChanged() {
00136 }
00137
00138 public void registerItemChange(GrxBaseItem item, int event){
00139 }
00140
00141 public void update(GrxBasePlugin plugin, Object... arg) {
00142 }
00143
00144 public void updatePosition(GrxBasePlugin plugin, Integer pos){
00145 }
00146
00147 public void updateTableFont(){
00148 }
00149
00150 public void updateEditerFont(){
00151 }
00152
00153 public void restoreProperties() {
00154 clear();
00155 Properties properties = manager_.getViewProperties(getName());
00156 if(properties!=null){
00157 for (Enumeration<?> e = properties.propertyNames(); e.hasMoreElements(); ){
00158 String key = (String) e.nextElement();
00159 String val = properties.getProperty(key);
00160 if (!propertyChanged(key, val)){
00161 setProperty(key, val);
00162 }
00163 }
00164 }
00165 }
00166
00167 public Element storeProperties() {
00168 if (doc_ == null)
00169 return null;
00170
00171 String tag = VIEW_TAG;
00172 element_ = doc_.createElement(tag);
00173
00174 element_.setAttribute("class",getClass().getName());
00175 element_.setAttribute("name", getName());
00176 element_.appendChild(doc_.createTextNode("\n"));
00177
00178 Enumeration<?> keys = propertyNames();
00179 boolean hasProperty=false;
00180 while (keys.hasMoreElements()) {
00181 String key = (String)keys.nextElement();
00182 String val = getProperty(key);
00183 if (key == null || val == null || key.equals("name"))
00184 continue;
00185
00186 hasProperty = true;
00187 Element propEl = doc_.createElement(GrxProjectItem.PROPERTY_TAG);
00188 propEl.setAttribute("name", key);
00189 propEl.setAttribute("value", val);
00190
00191 element_.appendChild(doc_.createTextNode(INDENT4+INDENT4+INDENT4));
00192 element_.appendChild(propEl);
00193 element_.appendChild(doc_.createTextNode("\n"));
00194 }
00195 element_.appendChild(doc_.createTextNode(INDENT4+INDENT4));
00196
00197 if(hasProperty)
00198 return element_;
00199 else
00200 return null;
00201 }
00202
00203 public void setUp() {
00204
00205 }
00206
00207 }