private void initTable(Grammar converted, UndoKeeper keeper) {
    final AutoProductionDataHelper helper = new AutoProductionDataHelper(converted, keeper);
    ProductionTableModel model =
        new ProductionTableModel(converted, keeper, helper) {
          public boolean isCellEditable(int row, int column) {
            return false;
          };
        };
    myTable = new ProductionTable(converted, keeper, true, model);

    myTable
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              public void valueChanged(ListSelectionEvent e) {
                changeSelection();
              }
            });

    converted
        .getProductionSet()
        .addListener(
            new ChangeListener() {

              @Override
              public void stateChanged(ChangeEvent e) {
                if (e instanceof AddEvent) {
                  for (Object o : ((AddEvent) e).getToAdd()) {
                    Production p = (Production) o;
                    helper.add(getMaxRow(), new Object[] {p.getLHS(), null, p.getRHS()});
                  }
                }
              }
            });
  }
コード例 #2
0
 public boolean addRightmostStep(Production p) {
   SymbolString current = createResult();
   for (int i = current.size() - 1; i >= 0; i--) {
     if (Grammar.isVariable(current.get(i))) {
       return this.addStep(p, i);
     }
   }
   return false;
 }