コード例 #1
0
 private Map<Flag, JTextField> computeFlagTextMap() {
   Map<Flag, JTextField> result = new EnumMap<Flag, JTextField>(Flag.class);
   for (Flag flag : Flag.values()) {
     JTextField textField = new JTextField(flag.getDefault());
     FieldListener listener = null;
     switch (flag) {
       case FINAL:
       case OPEN:
       case RESULT:
       case START:
       case TRANSIENT:
         String message = flag.getDescription() + " label must be non-empty";
         listener = new EmptyFieldListener(textField, message);
         break;
       case NUMBER:
         message =
             String.format(
                 "%s label must contain placeholde '%s'", flag.getDescription(), PLACEHOLDER);
         listener = new PlaceholderFieldListener(textField, message);
         break;
       case RECIPE:
         // no listener
         break;
       default:
         assert false;
     }
     if (listener != null) {
       textField.getDocument().addDocumentListener(listener);
     }
     textField.setEnabled(false);
     textField.setEditable(false);
     result.put(flag, textField);
   }
   return result;
 }
コード例 #2
0
 /** Returns the LTS labelling specification. */
 public LTSLabels getLTSLabels() {
   EnumMap<Flag, String> flags = new EnumMap<LTSLabels.Flag, String>(Flag.class);
   for (Flag flag : Flag.values()) {
     if (getFlagCheckBox(flag).isSelected()) {
       flags.put(flag, getFlagTextField(flag).getText());
     }
   }
   return new LTSLabels(flags);
 }
コード例 #3
0
 private Map<Flag, JCheckBox> computeFlagCheckMap() {
   Map<Flag, JCheckBox> result = new EnumMap<Flag, JCheckBox>(Flag.class);
   for (Flag flag : Flag.values()) {
     String text = null;
     String tip = null;
     switch (flag) {
       case FINAL:
         text = "Mark final states with:";
         tip = "If ticked, all final states will be labelled";
         break;
       case NUMBER:
         text = "Number all states with:";
         tip =
             String.format(
                 "If ticked, all states will be labelled, with '%s' replaced by the state number",
                 PLACEHOLDER);
         break;
       case TRANSIENT:
         text = "Mark transient states with:";
         tip =
             String.format(
                 "If ticked, transient states will be labelled, "
                     + "with '%s' replaced by the transient depth",
                 PLACEHOLDER);
         break;
       case OPEN:
         text = "Mark open states with:";
         tip = "If ticked, all open states will be labelled";
         break;
       case RESULT:
         text = "Mark result states with:";
         tip = "If ticked, all result states will be labelled";
         break;
       case RECIPE:
         text = "Mark recipe stages with:";
         tip =
             String.format(
                 "If ticked, recipe stages will included and optionally labelled, "
                     + "with '%s' replaced by the recipe name",
                 PLACEHOLDER);
         break;
       case START:
         text = "Mark start state with:";
         tip = "If ticked, the start state will be labelled";
         break;
       default:
         assert false;
     }
     final JCheckBox checkBox = new JCheckBox(text);
     checkBox.setPreferredSize(LARGE_LEFT);
     checkBox.setToolTipText(tip);
     final JTextField textField = getFlagTextField(flag);
     checkBox.addChangeListener(
         new ChangeListener() {
           @Override
           public void stateChanged(ChangeEvent e) {
             textField.setEnabled(checkBox.isSelected());
             textField.setEditable(checkBox.isSelected());
           }
         });
     checkBox.setSelected(LTSLabels.DEFAULT.hasFlag(flag));
     result.put(flag, checkBox);
   }
   return result;
 }