GrxServerManagerView.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 package com.generalrobotix.ui.view;
00012 
00013 import java.lang.reflect.InvocationTargetException;
00014 import java.util.Vector;
00015 
00016 import org.eclipse.jface.dialogs.MessageDialog;
00017 import org.eclipse.swt.SWT;
00018 import org.eclipse.swt.widgets.Button;
00019 import org.eclipse.swt.widgets.Composite;
00020 import org.eclipse.swt.widgets.Label;
00021 import org.eclipse.swt.widgets.TabItem;
00022 import org.eclipse.swt.widgets.Text;
00023 import org.eclipse.core.runtime.IProgressMonitor;
00024 import org.eclipse.jface.dialogs.ProgressMonitorDialog;
00025 import org.eclipse.jface.operation.IRunnableWithProgress;
00026 
00027 import com.generalrobotix.ui.GrxBaseItem;
00028 import com.generalrobotix.ui.GrxBasePlugin;
00029 import com.generalrobotix.ui.GrxBaseView;
00030 import com.generalrobotix.ui.GrxBaseViewPart;
00031 import com.generalrobotix.ui.GrxPluginManager;
00032 import com.generalrobotix.ui.grxui.GrxUIPerspectiveFactory;
00033 import com.generalrobotix.ui.item.GrxSimulationItem;
00034 import com.generalrobotix.ui.item.GrxWorldStateItem;
00035 import com.generalrobotix.ui.util.GrxServerManager;
00036 import com.generalrobotix.ui.util.GrxServerManagerPanel;
00037 import com.generalrobotix.ui.util.MessageBundle;
00038 import com.generalrobotix.ui.util.GrxProcessManager.ProcessInfo;
00039 import com.generalrobotix.ui.view.Grx3DView;
00040 
00041 import org.eclipse.swt.events.SelectionEvent;
00042 import org.eclipse.swt.events.SelectionListener;
00043 import org.eclipse.swt.events.ModifyEvent;
00044 import org.eclipse.swt.events.ModifyListener; 
00045 import org.eclipse.swt.graphics.Point;
00046 import org.eclipse.swt.layout.GridData;
00047 import org.eclipse.swt.layout.GridLayout;
00048 import org.eclipse.swt.widgets.*;
00049 
00050 import org.eclipse.swt.events.DisposeEvent;
00051 import org.eclipse.swt.events.DisposeListener;
00052 import org.eclipse.osgi.util.NLS;
00053 
00054 @SuppressWarnings("serial") //$NON-NLS-1$
00055 public class GrxServerManagerView extends GrxBaseView 
00056     implements DisposeListener {
00057     public static final String TITLE = "Server Manager"; //$NON-NLS-1$
00058     static private final int    HORIZONTAL_INDENT = 8;
00059     static private final int    COLLUMN_NUM = 4;
00060     static private final int    NAME_SERVER_GROUP_COLLUMN_NUM = 3;
00061     
00062     private GrxServerManager serverManager_ = null;
00063     private GrxSimulationItem simItem_ = null;
00064     private Vector<TabItem> vecTabItem_      = new Vector<TabItem>();
00065     private TabFolder folder_;
00066     private Text       textNsPort_ = null;
00067     private Text       textNsHost_ = null;
00068     private Button     updateNameServerBtn_ = null;    
00069 
00070     public GrxServerManagerView(String name, GrxPluginManager manager_,
00071             GrxBaseViewPart vp, Composite parent) {
00072         super(name, manager_, vp, parent);
00073         
00074         serverManager_ = (GrxServerManager)manager_.getItem(GrxServerManager.class, null);
00075                 if(serverManager_ != null){
00076                         InitItems();
00077                         serverManager_.addObserver(this);
00078                 }
00079         setUp();
00080                 manager_.registerItemChangeListener(this, GrxServerManager.class);
00081                 manager_.registerItemChangeListener(this, GrxSimulationItem.class);
00082         //setScrollMinSize(SWT.DEFAULT,SWT.DEFAULT);
00083         }
00084     
00085     public void setUp(){
00086         if(simItem_ != null)
00087                 simItem_.deleteObserver(this);
00088                 simItem_ = manager_.<GrxSimulationItem>getSelectedItem(GrxSimulationItem.class, null);
00089                 if(simItem_!=null){
00090                         simItem_.addObserver(this);
00091                 }
00092     }
00093     
00094     // GUIの配置、イベントの設定
00095     private void InitItems(){
00096         Composite top = new Composite(composite_,SWT.NONE);
00097         top.setLayoutData(new GridData(GridData.FILL_BOTH));
00098         GridLayout localGridLayout = new GridLayout( COLLUMN_NUM, false);
00099         localGridLayout.marginWidth = 0;
00100         localGridLayout.horizontalSpacing = 0;
00101         top.setLayout( localGridLayout );
00102         
00103         Button insertBtn = new Button(top , SWT.PUSH);
00104         insertBtn.setText(MessageBundle.get("GrxServerManagerView.button.insert")); //$NON-NLS-1$
00105         GridData insertBtnGridData = new GridData();
00106         insertBtnGridData.horizontalIndent = HORIZONTAL_INDENT;
00107         insertBtn.setLayoutData(insertBtnGridData);
00108         
00109         Button addBtn = new Button(top , SWT.PUSH);
00110         addBtn.setText(MessageBundle.get("GrxServerManagerView.button.add")); //$NON-NLS-1$
00111         GridData addBtnGridData = new GridData();
00112         addBtnGridData.horizontalIndent = HORIZONTAL_INDENT;
00113         addBtn.setLayoutData(addBtnGridData);
00114         
00115         Button delBtn = new Button(top , SWT.PUSH);
00116         delBtn.setText(MessageBundle.get("GrxServerManagerView.button.remove")); //$NON-NLS-1$
00117         GridData delBtnGridData = new GridData();
00118         delBtnGridData.horizontalIndent = HORIZONTAL_INDENT;
00119         delBtn.setLayoutData(delBtnGridData);
00120         
00121         Button defBtn = new Button(top , SWT.PUSH);
00122         defBtn.setText(MessageBundle.get("GrxServerManagerView.button.default")); //$NON-NLS-1$
00123         GridData defBtnGridData = new GridData();
00124         defBtnGridData.horizontalIndent = HORIZONTAL_INDENT;
00125         defBtn.setLayoutData(defBtnGridData);
00126 
00127         folder_ = new TabFolder(top,SWT.FILL);
00128         
00129         GridData folderGridData = new GridData();
00130         folderGridData.horizontalSpan = COLLUMN_NUM;
00131         folderGridData.horizontalAlignment = SWT.FILL;
00132         folderGridData.grabExcessHorizontalSpace = true;
00133         folder_.setLayoutData(folderGridData);
00134         
00135         insertBtn.addSelectionListener(new SelectionListener(){
00136             public void widgetDefaultSelected(SelectionEvent e) {}
00137             public void widgetSelected(SelectionEvent e) {
00138                 insertServerBtn( folder_ );
00139             }
00140         }
00141         );
00142         addBtn.addSelectionListener(new SelectionListener(){
00143             public void widgetDefaultSelected(SelectionEvent e) {}
00144             public void widgetSelected(SelectionEvent e) {
00145                 addServerBtn( folder_ );
00146             }
00147         }
00148         );
00149         delBtn.addSelectionListener(new SelectionListener(){
00150             public void widgetDefaultSelected(SelectionEvent e) {}
00151 
00152             public void widgetSelected(SelectionEvent e) {
00153                 removeServerBtn( folder_ );
00154             }
00155         }
00156         );
00157         
00158         defBtn.addSelectionListener(new SelectionListener(){
00159             public void widgetDefaultSelected(SelectionEvent e) {}
00160 
00161             public void widgetSelected(SelectionEvent e) {
00162                 restoreDefault();
00163             }
00164         }
00165         );
00166 
00167         GrxServerManagerPanel panel = null;
00168         Vector<ProcessInfo> vecServerInfo = serverManager_.getServerInfo();
00169         
00170         for (int i = 0; i < vecServerInfo.size() ; ++i ){
00171             vecTabItem_.add(new TabItem(folder_,SWT.NONE)) ;
00172             vecTabItem_.elementAt(i).setText(vecServerInfo.elementAt(i).id);
00173             
00174             folder_.setSelection(i);
00175             panel = new GrxServerManagerPanel(serverManager_, folder_ , SWT.NONE , i, manager_ );
00176             vecTabItem_.elementAt(i).setControl(panel);
00177         }
00178         folder_.addDisposeListener(this);
00179         folder_.setSelection(0);
00180         
00181         // Name Server Goup setting
00182         Group localGroup = new Group(top, SWT.FILL);
00183         localGroup.setText("Name Service");
00184         GridData groupGridData = new GridData();
00185         groupGridData.heightHint = 60;
00186         groupGridData.horizontalAlignment = SWT.FILL;
00187         groupGridData.horizontalSpan = NAME_SERVER_GROUP_COLLUMN_NUM; 
00188         
00189         localGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL |
00190                 GridData.GRAB_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER));
00191 
00192         GridLayout groupGridLayout = new GridLayout(NAME_SERVER_GROUP_COLLUMN_NUM, false);
00193         groupGridLayout.marginWidth = 2;
00194         groupGridLayout.marginHeight = 2;
00195         
00196         localGroup.setLayout(groupGridLayout);
00197         localGroup.setLayoutData(groupGridData);
00198         
00199         Label localHostLabel = new Label(localGroup, SWT.RIGHT);
00200         GridData hostLabelGridData = new GridData();
00201         hostLabelGridData.widthHint = 100;
00202         localHostLabel.setText(MessageBundle.get("GrxORBMonitor.label.host"));
00203         localHostLabel.setLayoutData(hostLabelGridData);
00204         
00205         textNsHost_ = new Text(localGroup, SWT.SINGLE | SWT.BORDER);
00206         GridData textNsHostGridData = new GridData();
00207         textNsHostGridData.widthHint = 100;
00208         textNsHost_.setText( String.valueOf( serverManager_.getNewHost()) );
00209         textNsHost_.setLayoutData(textNsHostGridData);
00210         textNsHost_.addModifyListener( new ModifyListener(){
00211             public void modifyText(ModifyEvent e){
00212                 updateNameServerBtn_.setEnabled(!equalsHostPort());
00213             }
00214         }
00215         );
00216         updateNameServerBtn_ = new Button(localGroup , SWT.PUSH);
00217         GridData btnGridData = new GridData();
00218         btnGridData.widthHint = 64;
00219         btnGridData.verticalSpan = 2;
00220         
00221         updateNameServerBtn_.setText(MessageBundle.get("GrxServerManagerView.NameServer.button"));
00222         
00223         updateNameServerBtn_.addSelectionListener(new SelectionListener() {
00224             public void widgetDefaultSelected(SelectionEvent e) {}
00225 
00226             public void widgetSelected(SelectionEvent e) {
00227                 updateNameServerBtn();
00228             }
00229         }); 
00230         
00231         updateNameServerBtn_.setEnabled(false);        
00232         updateNameServerBtn_.setLayoutData(btnGridData);
00233         
00234         Label localPortLabel = new Label(localGroup, SWT.RIGHT);
00235         GridData portLabelGridData = new GridData();
00236         portLabelGridData.widthHint = 100;
00237         localPortLabel.setText(MessageBundle.get("GrxORBMonitor.label.port"));
00238         localPortLabel.setLayoutData(portLabelGridData);
00239         
00240         textNsPort_ = new Text(localGroup, SWT.SINGLE | SWT.BORDER);
00241         GridData textNsPortGridData = new GridData();
00242         textNsPortGridData.widthHint = 100;
00243         textNsPort_.setText( String.valueOf( serverManager_.getNewPort()) );
00244         textNsPort_.setLayoutData(textNsPortGridData);
00245         
00246         textNsPort_.addModifyListener( new ModifyListener(){
00247             public void modifyText(ModifyEvent e){
00248                 updateNameServerBtn_.setEnabled(!equalsHostPort());
00249             }
00250         }
00251         );
00252     }
00253     
00254     private void updateItems(){
00255         textNsHost_.setText( String.valueOf( serverManager_.getNewHost()) );
00256         textNsPort_.setText( String.valueOf( serverManager_.getNewPort()) );
00257         for (int i = 0; i < vecTabItem_.size() ; ++i ){
00258                 vecTabItem_.elementAt(i).getControl().dispose();
00259                 vecTabItem_.elementAt(i).dispose();
00260         }
00261         vecTabItem_.clear();
00262         Vector<ProcessInfo> vecServerInfo = serverManager_.getServerInfo();       
00263         for (int i = 0; i < vecServerInfo.size() ; ++i ){
00264             vecTabItem_.add(new TabItem(folder_,SWT.NONE)) ;
00265             vecTabItem_.elementAt(i).setText(vecServerInfo.elementAt(i).id);
00266             GrxServerManagerPanel panel = new GrxServerManagerPanel(serverManager_, folder_ , SWT.NONE , i, manager_ );
00267             vecTabItem_.elementAt(i).setControl(panel);
00268         }
00269         folder_.setSelection(0);
00270     }
00271     
00272     private void insertServerBtn(final TabFolder folder){
00273         Display display = Display.getCurrent();
00274         final Shell shell = new Shell(display , SWT.TITLE | SWT.OK);
00275         shell.setLayout(new GridLayout(2,false));
00276         shell.setText(MessageBundle.get("GrxServerManagerView.text.newServer")); //$NON-NLS-1$
00277         Label idLabel = new Label( shell , SWT.RIGHT);
00278         idLabel.setText("id:"); //$NON-NLS-1$
00279         final Text id = new Text( shell , SWT.BORDER);
00280         GridData idGridData = new GridData();
00281         idGridData.horizontalAlignment = SWT.FILL;
00282         idGridData.grabExcessHorizontalSpace = true;
00283         id.setLayoutData(idGridData);
00284         Button okBtn = new Button( shell , SWT.PUSH);
00285         okBtn.setText(MessageBundle.get("GrxServerManagerView.button.ok")); //$NON-NLS-1$
00286         Point point = display.getCursorLocation();
00287         shell.setLocation(point.x , point.y );
00288         shell.setSize(200, 100);
00289         shell.open();
00290         
00291         okBtn.addSelectionListener(new SelectionListener(){
00292             public void widgetDefaultSelected(SelectionEvent e) {}
00293 
00294             public void widgetSelected(SelectionEvent e) {
00295                 if( checkID(id.getText()) ){
00296                     int index = folder.getSelectionIndex();
00297                     if(index<0) index=0;
00298                     ProcessInfo localInfo = new ProcessInfo();
00299                     localInfo.id = id.getText();
00300                     localInfo.com.clear();
00301                     localInfo.com.add(""); //$NON-NLS-1$
00302                     localInfo.args = ""; //$NON-NLS-1$
00303                     localInfo.autoStart = false;
00304                     localInfo.useORB = false;
00305                     localInfo.dir=serverManager_.serverInfoDefaultDir_;
00306                     localInfo.waitCount=serverManager_.serverInfoDefaultWaitCount_;           
00307                     Vector<ProcessInfo> vecServerInfo = serverManager_.getServerInfo();    
00308                     vecServerInfo.add(index,localInfo);
00309                     vecTabItem_.add(index , new TabItem(folder,SWT.NONE , index)) ;
00310                     vecTabItem_.elementAt(index).setText(vecServerInfo.elementAt(index).id);
00311                     folder.setSelection(index);
00312                     GrxServerManagerPanel panel = new GrxServerManagerPanel(serverManager_,folder , SWT.NONE , index, manager_ );
00313                     vecTabItem_.elementAt(index).setControl(panel);
00314                 }
00315                 shell.close();
00316             }
00317         }
00318         );
00319 
00320     }
00321 
00322     private void addServerBtn(final TabFolder folder){
00323         Display display = Display.getCurrent();
00324         final Shell shell = new Shell(display , SWT.TITLE | SWT.OK);
00325         shell.setLayout(new GridLayout(2,false));
00326         shell.setText(MessageBundle.get("GrxServerManagerView.text.addServer")); //$NON-NLS-1$
00327         Label idLabel = new Label( shell , SWT.RIGHT);
00328         idLabel.setText("id:"); //$NON-NLS-1$
00329         final Text id = new Text( shell , SWT.BORDER);
00330         GridData idGridData = new GridData();
00331         idGridData.horizontalAlignment = SWT.FILL;
00332         idGridData.grabExcessHorizontalSpace = true;
00333         id.setLayoutData(idGridData);
00334         Button okBtn = new Button( shell , SWT.PUSH);
00335         okBtn.setText(MessageBundle.get("GrxServerManagerView.button.ok")); //$NON-NLS-1$
00336         Point point = display.getCursorLocation();
00337         shell.setLocation(point.x , point.y );
00338         shell.setSize(200, 100);
00339         shell.open();
00340         okBtn.addSelectionListener(new SelectionListener(){
00341             public void widgetDefaultSelected(SelectionEvent e) {}
00342 
00343             public void widgetSelected(SelectionEvent e) {
00344                 if( checkID(id.getText()) ){
00345                     int index = folder.getSelectionIndex() + 1;
00346                     ProcessInfo localInfo = new ProcessInfo();
00347                     localInfo.id = id.getText();
00348                     localInfo.com.clear();
00349                     localInfo.com.add(""); //$NON-NLS-1$
00350                     localInfo.args = ""; //$NON-NLS-1$
00351                     localInfo.autoStart = false;
00352                     localInfo.useORB = false;
00353                     localInfo.dir=serverManager_.serverInfoDefaultDir_;
00354                     localInfo.waitCount=serverManager_.serverInfoDefaultWaitCount_;
00355                     Vector<ProcessInfo> vecServerInfo = serverManager_.getServerInfo();    
00356                     vecServerInfo.add(index,localInfo);
00357                     vecTabItem_.add(index , new TabItem(folder,SWT.NONE , index)) ;
00358                     vecTabItem_.elementAt(index).setText(vecServerInfo.elementAt(index).id);
00359                     folder.setSelection(index);
00360                     GrxServerManagerPanel panel = new GrxServerManagerPanel(serverManager_, folder , SWT.NONE , index, manager_ );
00361                     vecTabItem_.elementAt(index).setControl(panel);
00362                 }
00363                 shell.close();
00364             }
00365         }
00366         );
00367 
00368     }
00369     
00370     private void removeServerBtn(TabFolder folder){
00371         int index = folder.getSelectionIndex();
00372         Vector<ProcessInfo> vecServerInfo = serverManager_.getServerInfo();
00373 
00374         String mes = MessageBundle.get("GrxServerManagerView.dialog.message.remove"); //$NON-NLS-1$
00375         mes = NLS.bind(mes, new String[]{vecTabItem_.elementAt(index).getText()});
00376         
00377         // 確認ダイアログ表示後 当該 タブを削除
00378         if ( MessageDialog.openConfirm(
00379                 composite_.getShell(),
00380                 MessageBundle.get("GrxServerManagerView.dialog.title.remove"), //$NON-NLS-1$
00381                 mes))
00382         {
00383             vecTabItem_.elementAt(index).getControl().dispose();
00384             folder.getItem(index).dispose();
00385             vecTabItem_.remove(index);
00386             vecServerInfo.remove(index);
00387         }
00388     }
00389     
00390     private boolean checkID(String id){
00391         if(id.isEmpty()){
00392             MessageDialog.openWarning(
00393                     composite_.getShell(),
00394                     MessageBundle.get("GrxServerManagerView.dialog.title.warning") , //$NON-NLS-1$
00395                     MessageBundle.get("GrxServerManagerView.dialog.message.emptyID")  ); //$NON-NLS-1$
00396             return false;
00397         }
00398         boolean ret = true;
00399         String localID = id.toUpperCase();
00400         for (TabItem i:vecTabItem_){
00401             String srcStr = i.getText().toUpperCase();
00402             if( srcStr.equals(localID) ){
00403                 ret = false;
00404                 MessageDialog.openWarning(
00405                         composite_.getShell(),
00406                         MessageBundle.get("GrxServerManagerView.dialog.title.warning") , //$NON-NLS-1$
00407                         MessageBundle.get("GrxServerManagerView.dialog.message.sameID")  ); //$NON-NLS-1$
00408                 break;
00409             }
00410         }
00411         return ret;
00412     }
00413     
00414     private boolean equalsHostPort(){
00415         boolean ret = true;
00416         String port = textNsPort_.getText();
00417         String host = textNsHost_.getText();
00418         
00419         if( !host.equals(serverManager_.getNewHost()) ){
00420             ret= false;
00421         }
00422         
00423         try{
00424             if( serverManager_.getNewPort() != Integer.valueOf(port) ){
00425                 ret = false;
00426             }
00427         }catch (NumberFormatException ex){
00428             ret = false;
00429         }catch (Exception ex){
00430             ex.printStackTrace();
00431             ret = false;
00432         }
00433         
00434         return ret;
00435     }
00436     
00437     //タブウィンドウが閉じるときGUIによって生じた変更を反映する。
00438     private void storevecServerInfo(){       
00439         for (int i = 0; i < vecTabItem_.size(); ++i){
00440             GrxServerManagerPanel localPanel = (GrxServerManagerPanel) vecTabItem_.elementAt(i).getControl();
00441             localPanel.updateProcessInfo();
00442         }
00443     }
00444     
00445     private void updateNameServerBtn(){
00446         StringBuffer refHost = new StringBuffer("");
00447         StringBuffer refPort = new StringBuffer("");
00448         
00449         boolean ret = MessageDialog.openQuestion(composite_.getShell(),
00450                 MessageBundle.get("GrxServerManagerView.dialog.infomation.tittle.updateNameServer"),
00451                 MessageBundle.get("GrxServerManagerView.dialog.infomation.message.updateNameServer"));
00452         
00453         if(ret){
00454             String message = serverManager_.setNewHostPort(textNsHost_.getText(), textNsPort_.getText(), refHost, refPort );
00455             // TODO 
00456             if(message.isEmpty()){
00457                 updateNameServerBtn_.setEnabled(false);
00458                 restartServers();
00459             }else{
00460                 MessageDialog.openError(composite_.getShell(),
00461                         MessageBundle.get("GrxServerManagerView.dialog.error.tittle.updateNameServer"),
00462                         message);
00463                 if( refHost.length() != 0){
00464                     textNsHost_.setText(refHost.toString());
00465                 }
00466                 if( refPort.length() != 0 ){
00467                     textNsPort_.setText(refPort.toString());
00468                 }
00469             }
00470         }
00471     }
00472 
00473     private void restartServers(){
00474         try {
00475             IRunnableWithProgress iProgress = new IRunnableWithProgress() {
00476                 public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
00477                     monitor.beginTask(MessageBundle.get("GrxServerManagerView.dialog.title.progress"),
00478                             2 + ( serverManager_.getServerInfo().size() + 1) * 2); //$NON-NLS-1$
00479                     restartServers(monitor);
00480                     monitor.done();
00481                 }
00482             };
00483             new ProgressMonitorDialog(GrxUIPerspectiveFactory.getCurrentShell()).run(false, false, iProgress);
00484         } catch (InvocationTargetException e) {
00485             e.printStackTrace();
00486         } catch (InterruptedException e) {
00487         }
00488         
00489         
00490     }
00491 
00492     private void restartServers(IProgressMonitor monitor) throws InterruptedException{
00493         Grx3DView dview =  (Grx3DView)manager_.getView( Grx3DView.class, false );
00494         if(dview != null){
00495             dview.unregisterCORBA();
00496         }
00497         if(simItem_ != null){
00498             simItem_.unregisterCORBA();
00499         }
00500         monitor.worked(1);
00501         serverManager_.restart(monitor);
00502         monitor.worked(1);
00503         if(simItem_ != null){
00504             simItem_.registerCORBA();
00505         }
00506         if(dview != null){
00507             dview.registerCORBA();
00508         }
00509     }
00510     
00511     private void restoreDefault(){
00512         serverManager_.restoreDefault();
00513         updateItems();
00514     }
00515     
00516     public void registerItemChange(GrxBaseItem item, int event){
00517                 if(item instanceof GrxServerManager){
00518                         GrxServerManager serverManager = (GrxServerManager) item;
00519                 switch(event){
00520                 case GrxPluginManager.ADD_ITEM:
00521                         if(serverManager_ == null){
00522                                 serverManager_ = serverManager;
00523                                 updateItems();
00524                                 serverManager_.addObserver(this);
00525                         }
00526                         break;
00527                 default:
00528                         break;
00529                 }
00530                 }else if(item instanceof GrxSimulationItem){
00531                 GrxSimulationItem simItem = (GrxSimulationItem) item;
00532                 switch(event){
00533                 case GrxPluginManager.SELECTED_ITEM:
00534                         if(simItem_!=simItem){
00535                                 simItem_ = simItem;
00536                                 simItem_.addObserver(this);
00537                         }
00538                         break;
00539                 case GrxPluginManager.REMOVE_ITEM:
00540                 case GrxPluginManager.NOTSELECTED_ITEM:
00541                         if(simItem_==simItem){
00542                                 simItem_.deleteObserver(this);
00543                                 simItem_ = null;
00544                         }
00545                         break;
00546                 default:
00547                         break;
00548                 }
00549         }
00550         }
00551     
00552     public void widgetDisposed(DisposeEvent e)
00553     {
00554         storevecServerInfo();
00555     }
00556     
00557     public void update(GrxBasePlugin plugin, Object... arg) {
00558         if(serverManager_==plugin){
00559                 if((String)arg[0]=="ProcessEnd"){
00560                         for (TabItem i: vecTabItem_){
00561                     if(i.getText().equals((String)arg[1])){
00562                         ((GrxServerManagerPanel)i.getControl()).setStartText();
00563                     }
00564                         }
00565                 }
00566         }else if(simItem_==plugin){
00567                 if((String)arg[0]=="StartSimulation"){
00568                         setEditableHostPortText(false);
00569                 }else if((String)arg[0]=="StopSimulation"){
00570                         setEditableHostPortText(true);
00571                 }
00572         }
00573     }
00574     
00575     public void shutdown() {
00576         manager_.removeItemChangeListener(this, GrxServerManager.class);
00577         if(serverManager_!=null)
00578                 serverManager_.deleteObserver(this);
00579         serverManager_.SaveServerInfo();
00580         if(simItem_!=null)
00581                         simItem_.deleteObserver(this);
00582                 manager_.removeItemChangeListener(this, GrxSimulationItem.class);
00583         }
00584 
00585     public void setEditableHostPortText(boolean bEnable){
00586         textNsHost_.setEditable(bEnable);
00587         textNsPort_.setEditable(bEnable);
00588     }
00589 }


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Sun Apr 2 2017 03:43:54