GrxModeInfoItem.java
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc.
00003  * All rights reserved. This program is made available under the terms of the
00004  * Eclipse Public License v1.0 which accompanies this distribution, and is
00005  * available at http://www.eclipse.org/legal/epl-v10.html
00006  * Contributors:
00007  * General Robotix Inc.
00008  * National Institute of Advanced Industrial Science and Technology (AIST)
00009  */
00010 /*
00011  *  GrxModeInfoItem.java
00012  *
00013  *  Copyright (C) 2007 GeneralRobotix, Inc.
00014  *  All Rights Reserved
00015  *
00016  *  @author Yuichiro Kawasumi (General Robotix, Inc.)
00017  */
00018 
00019 package com.generalrobotix.ui.item;
00020 
00021 import java.util.ArrayList;
00022 
00023 import org.w3c.dom.Element;
00024 import org.w3c.dom.NodeList;
00025 
00026 import com.generalrobotix.ui.GrxBaseItem;
00027 import com.generalrobotix.ui.GrxBasePlugin;
00028 import com.generalrobotix.ui.GrxBaseView;
00029 import com.generalrobotix.ui.GrxPluginManager;
00030 import com.generalrobotix.ui.util.GrxDebugUtil;
00031 import com.generalrobotix.ui.util.GrxXmlUtil;
00032 
00033 @SuppressWarnings("serial")
00037 public class GrxModeInfoItem extends GrxBaseItem {
00038         public static final String TITLE = "Mode Info";
00039 
00040         public ArrayList<Class<? extends GrxBaseItem>> activeItemClassList_ = new ArrayList<Class<? extends GrxBaseItem>>();
00041         public ArrayList<Class<? extends GrxBaseView>> activeViewClassList_ = new ArrayList<Class<? extends GrxBaseView>>();
00042 
00043         public GrxModeInfoItem(String name, GrxPluginManager manager) {
00044                 super(name, manager);
00045                 setExclusive(true);
00046         }
00047 
00048         public void addItemClassList(Class<? extends GrxBasePlugin> item){
00049                 if ( GrxBaseItem.class.isAssignableFrom(item) && !activeItemClassList_.contains(item)) {
00050                         activeItemClassList_.add((Class<? extends GrxBaseItem>)item);
00051                 }
00052         }
00053 
00054         @SuppressWarnings("unchecked")
00055         public void restoreProperties() {
00056                 super.restoreProperties();
00057                 // アイテムプラグインの追加
00058                 NodeList list = element_.getElementsByTagName("item");
00059                 for (int i = 0; i < list.getLength(); i++) {
00060                         Element el = (Element) list.item(i);
00061                         manager_.pluginLoader_.addURL(GrxXmlUtil.expandEnvVal(el.getAttribute("lib")));
00062                         Class<?> cls = manager_.registerPlugin(el);
00063                         if ( cls != null && GrxBaseItem.class.isAssignableFrom(cls) &&
00064                                         !activeItemClassList_.contains(cls)) {
00065                                 activeItemClassList_.add((Class<? extends GrxBaseItem>)cls);
00066                                 GrxDebugUtil.println( "[MODEITEM] load "+cls.getName() );
00067                         }
00068                 }
00069                 // ビュープラグインの追加
00070                 list = element_.getElementsByTagName("view");
00071                 for (int i = 0; i < list.getLength(); i++) {
00072                         Element el = (Element) list.item(i);
00073                         manager_.pluginLoader_.addURL(GrxXmlUtil.expandEnvVal(el.getAttribute("lib")));
00074                         Class cls = manager_.registerPlugin(el.getAttribute("class"));
00075                         if (cls != null &&
00076                                         GrxBaseView.class.isAssignableFrom(cls) &&
00077                                         !activeViewClassList_.contains(cls)) {
00078                                 activeViewClassList_.add((Class<? extends GrxBaseView>)cls);
00079                                 String name = el.getAttribute("name");
00080                                 name = name.length()>0 ? name:null;
00081                                 // TODO:ビューはEclipseで管理しているので、このあたりの処理はざっくり削ってもよさそう。
00082                                 // ビューを1つしか出さない、などの設定もEclipseで可能。
00083                                 manager_.createView((Class<? extends GrxBaseView>)cls, name);
00084                         }
00085                 }
00086         }
00087 
00088         public boolean create() {
00089                 return true;
00090         }
00091 }


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Thu Apr 11 2019 03:30:16