Exemplo n.º 1
0
 /** Called to alter data in all cells */
 public boolean operateOnData(CharacterData data) {
   if (!(data instanceof ContinuousData)) return false;
   ContinuousData cData = (ContinuousData) data;
   int numItems = cData.getNumItems();
   String[] items = new String[numItems];
   for (int i = 0; i < items.length; i++) {
     if (StringUtil.blank(cData.getItemName(i))) items[i] = "(unnamed)";
     else items[i] = cData.getItemName(i);
   }
   int d =
       ListDialog.queryList(
           containerOfModule(),
           "Rename item",
           "Rename item:",
           MesquiteString.helpString,
           items,
           0);
   if (!MesquiteInteger.isCombinable(d) || d < 0 || d >= numItems) return false;
   else {
     String s =
         MesquiteString.queryString(
             containerOfModule(), "Rename Item", "New name for " + items[d], items[d]);
     if (StringUtil.blank(s)) return false;
     cData.setItemReference(d, NameReference.getNameReference(s));
     return true;
   }
 }
 /*..........................................MContinuousStates................*/
 public int userQueryItem(String message, MesquiteModule module) {
   int numItems = getNumItems();
   String[] items = new String[numItems];
   for (int i = 0; i < items.length; i++) {
     if (StringUtil.blank(getItemName(i))) items[i] = "(unnamed)";
     else items[i] = getItemName(i);
   }
   return ListDialog.queryList(
       module.containerOfModule(), "Select item", message, MesquiteString.helpString, items, 0);
 }
Exemplo n.º 3
0
 /** queryies the user to choose a tree and returns an integer of the tree chosen */
 public int queryUserChoose(Taxa taxa, String forMessage) {
   int ic = MesquiteInteger.unassigned;
   int numBlocks = getNumberOfTreeBlocks(taxa);
   if (MesquiteInteger.isCombinable(numBlocks)) {
     String[] s = new String[numBlocks];
     for (int i = 0; i < numBlocks; i++) {
       s[i] = getTreeBlockNameString(taxa, i);
     }
     if (forMessage == null) {
       forMessage = "Choose tree block";
     }
     return ListDialog.queryList(
         containerOfModule(), "Choose tree block", forMessage, MesquiteString.helpString, s, 0);
   } else {
     if (forMessage == null) {
       forMessage = "Number of tree block to be used";
     }
     int r = MesquiteInteger.queryInteger(containerOfModule(), "Choose tree block", forMessage, 1);
     if (MesquiteInteger.isCombinable(r)) return MesquiteTree.toInternal(r);
     else return r;
   }
 }