Exemple #1
0
  /**
   * _more_
   *
   * @param symbols _more_
   * @param listener _more_
   * @param smm _more_
   * @return _more_
   */
  public static List makeStationModelMenuItems(
      List symbols, final ObjectListener listener, StationModelManager smm) {
    List items = new ArrayList();
    List subMenus = new ArrayList();
    Hashtable categories = new Hashtable();
    for (int i = 0; i < symbols.size(); i++) {
      StationModel sm = (StationModel) symbols.get(i);
      boolean isUsers = smm.isUsers(sm);
      String name = sm.getName();
      if (name.equals("")) continue;
      List toks = StringUtil.split(name, ">", true, true);
      if (toks.size() > 0) {
        name = (String) toks.get(toks.size() - 1);
      }
      JMenuItem item = new JMenuItem(GuiUtils.getLocalName(name, isUsers));
      item.addActionListener(
          new ObjectListener(sm) {
            public void actionPerformed(ActionEvent ae) {
              listener.setObject(this.theObject);
              listener.actionPerformed(ae);
            }
          });

      toks.remove(toks.size() - 1);
      if (toks.size() == 0) {
        items.add(item);
        continue;
      }
      JMenu categoryMenu = null;
      String catSoFar = "";
      String menuCategory = "";
      for (int catIdx = 0; catIdx < toks.size(); catIdx++) {
        String subCat = (String) toks.get(catIdx);
        catSoFar = catSoFar + "/" + subCat;
        JMenu m = (JMenu) categories.get(catSoFar);
        if (m == null) {
          m = new JMenu(subCat);
          menuCategory = catSoFar;
          categories.put(catSoFar, m);
          if (categoryMenu != null) {
            categoryMenu.add(m, 0);
          } else {
            subMenus.add(m);
          }
        }
        categoryMenu = m;
      }
      if (categoryMenu == null) {
        categoryMenu = new JMenu("");
        categories.put(toks.toString(), categoryMenu);
        subMenus.add(categoryMenu);
        menuCategory = toks.toString();
      }
      categoryMenu.add(item);
    }
    items.addAll(subMenus);
    return items;
  }
Exemple #2
0
 /** Save the current station model under a new name */
 private void doSaveAs() {
   StationModel nl = getStationModel();
   String newName = smm.doSaveAs(nl, this);
   if (newName == null) {
     return;
   }
   nl = new StationModel(newName, new ArrayList(nl.getList()));
   setStationModel(nl, false);
   smm.addUsers(nl);
 }
Exemple #3
0
 /** Rename the current station model */
 protected void doRename() {
   if (!okToChange()) {
     return;
   }
   String newName = smm.doNew(this, "Rename", stationModel.getName(), "Use '>' to add categories");
   if (newName == null) {
     return;
   }
   doSave(false);
   StationModel sm = getStationModel();
   sm.setName(newName);
   setStationModel(sm, false);
   doSave(true);
 }
Exemple #4
0
 /**
  * Set the current station model
  *
  * @param newModel The station model
  * @param closeDialogs If true then close any dialog windows
  */
 public void setStationModel(StationModel newModel, boolean closeDialogs) {
   if (closeDialogs) {
     closeDialogs();
   }
   if (!smm.isUsers(newModel)) {
     List newGlyphs = cloneGlyphs(newModel.getList());
     newModel = new StationModel(newModel.getName(), newGlyphs);
     // new ArrayList(newModel.getList()));
   }
   stationModel = newModel;
   setGlyphs(cloneGlyphs(newModel.getList()));
   setName(stationModel.getDisplayName());
   setHaveChanged(false);
   frame.setTitle(
       GuiUtils.getApplicationTitle() + "Layout Model Editor -- " + stationModel.getName());
 }
Exemple #5
0
 /** Remove the current station model */
 protected void doRemove() {
   if (!GuiUtils.showYesNoDialog(
       null,
       "Are you sure you want to remove the station model: " + stationModel.getName() + "?",
       "Confirm")) {
     return;
   }
   smm.removeUsers(stationModel);
   initFromDefault();
 }
Exemple #6
0
 /**
  * If there has been a change to the station model then ask the user if they want to save them
  *
  * @return Should the cancel proceed
  */
 boolean okToChange() {
   if (getHaveChanged()) {
     int result =
         GuiUtils.showYesNoCancelDialog(
             null,
             "Save changes to station model: " + stationModel.getName(),
             "Save station model changes");
     if (result == JOptionPane.CANCEL_OPTION) {
       return false;
     }
     if (result == JOptionPane.YES_OPTION) {
       doSave();
     }
   }
   return true;
 }
Exemple #7
0
 /**
  * Return the station model name
  *
  * @return The station model name
  */
 public String toString() {
   return stationModel.toString();
 }
Exemple #8
0
 /**
  * Get the current station model
  *
  * @return The current station model
  */
 public StationModel getStationModel() {
   stationModel.setList(getGlyphs());
   return stationModel;
 }