    001package org.vishia.gral.widget;
    002
    003import java.util.LinkedList;
    004import java.util.List;
    005
    006import org.vishia.byteData.VariableAccess_ifc;
    007import org.vishia.gral.base.GralWidget;
    008import org.vishia.gral.ifc.GralMng_ifc;
    009import org.vishia.gral.ifc.GralUserAction;
    010import org.vishia.gral.ifc.GralWidget_ifc;
    011
    012public class GralSwitchExclusiveButtonMng implements VariableAccess_ifc
    013{
    014
    015  //final GuiPanelMngWorkingIfc mng;
    016
    017  private final List<GralWidget> listSwitchButtons = new LinkedList<GralWidget>();
    018
    019  String currentButtonText;
    020
    021  public void add(GralWidget widgd){
    022    listSwitchButtons.add(widgd);
    023    if(widgd.getActionChange(GralWidget_ifc.ActionChangeWhen.onEnter) == null){
    024      widgd.specifyActionChange(null, switchAction, null, GralWidget_ifc.ActionChangeWhen.onEnter);
    025    }
    026  }
    027
    028  public void remove(GralWidget widgd)
    029  {
    030    listSwitchButtons.remove(widgd);
    031  }
    032
    033
    034  public GralSwitchExclusiveButtonMng() //GuiPanelMngWorkingIfc mng)
    035  { //this.mng = mng;
    036  }
    037
    038  public GralUserAction switchAction = new GralUserAction()
    039  {
    040
    041    @Override
    042    public boolean userActionGui(int key, GralWidget infos, Object... params)
    043    {
    044      // TODO Auto-generated method stub
    045      currentButtonText = infos.sCmd;
    046      for(GralWidget item: listSwitchButtons){
    047        if(item != infos){
    048          item.setValue(GralMng_ifc.cmdSet, 0, 0);
    049        }
    050      }
    051      return true;
    052    }
    053  };
    054
    055  @Override public int getInt(){ return 0; }
    056  @Override public int setInt(int value){ return 0; }
    057
    058  @Override public long getLong(){ return 0; }
    059  @Override public long setLong(long value){ return 0; }
    060
    061  @Override
    062  public float getFloat()
    063  {
    064    // TODO Auto-generated method stub
    065    return 0;
    066  }
    067
    068  @Override
    069  public float setFloat(float value)
    070  {
    071    // TODO Auto-generated method stub
    072    return 0;
    073  }
    074
    075  @Override
    076  public double getDouble()
    077  {
    078    // TODO Auto-generated method stub
    079    return 0;
    080  }
    081
    082  @Override
    083  public double setDouble(double value)
    084  {
    085    // TODO Auto-generated method stub
    086    return 0;
    087  }
    088
    089  @Override
    090  public String getString()
    091  { return currentButtonText;
    092  }
    093
    094  @Override
    095  public String setString(String value)
    096  {
    097    // TODO Auto-generated method stub
    098    return null;
    099  }
    100
    101  @Override public char getType(){ return 'I'; }
    102
    103
    104  @Override public void setRefreshed(long time){ }
    105
    106  @Override
    107  public long getLastRefreshTime()
    108  {
    109    // TODO Auto-generated method stub
    110    return 0;
    111  }
    112
    113
    114  @Override public boolean isRefreshed(){ return true; }
    115
    116  @Override
    117  public void requestValue(long timeRequested) { }
    118
    119  @Override public void requestValue(){ requestValue(System.currentTimeMillis()); }
    120
    121
    122  @Override
    123  public void requestValue(long timeRequested, Runnable run) { }
    124
    125  @Override public boolean isRequestedValue(long timeEarlyRequested, boolean retryFaultyVariables){ return false; }
    126
    127
    128
    129}