Beispiel #1
0
 /* (non-Javadoc)
  * @see forge.gui.framework.IVDoc#populate()
  */
 @Override
 public void populate() {
   parentCell.getBody().setLayout(new MigLayout("insets 0, gap 0"));
   parentCell.getBody().add(scroller, "w 100%, h 100%!");
 }
Beispiel #2
0
  @Override
  public void populate() {
    // Dev mode disabled? Remove from parent cell if exists.
    if (!ForgePreferences.DEV_MODE) {
      if (VDev.SINGLETON_INSTANCE.getParentCell() != null) {
        final DragCell parent = VDev.SINGLETON_INSTANCE.getParentCell();
        parent.removeDoc(VDev.SINGLETON_INSTANCE);
        VDev.SINGLETON_INSTANCE.setParentCell(null);

        // If dev mode was first tab, the new first tab needs re-selecting.
        if (parent.getDocs().size() > 0) {
          parent.setSelected(parent.getDocs().get(0));
        }
      }
    }
    // Dev mode enabled? May already by added, or put in message cell by default.
    else {
      if (VDev.SINGLETON_INSTANCE.getParentCell() == null) {
        VPrompt.SINGLETON_INSTANCE.getParentCell().addDoc(VDev.SINGLETON_INSTANCE);
      }
    }

    // Clear previous match views if screen was previously closed
    if (wasClosed) {
      wasClosed = false;
    } else { // focus first enabled Prompt button if returning to match screen
      if (getBtnOK().isEnabled()) {
        getBtnOK().requestFocusInWindow();
      } else if (getBtnCancel().isEnabled()) {
        getBtnCancel().requestFocusInWindow();
      }
    }

    // Add extra players alternatively to existing user/AI field panels.
    for (int i = 2; i < lstFields.size(); i++) {
      // If already in layout, no need to add again.
      VField vField = lstFields.get(i);
      if (vField.getParentCell() == null) {
        lstFields.get(i % 2).getParentCell().addDoc(vField);
      }
    }

    // Add extra players alternatively to existing user/AI field panels.
    for (int i = 2; i < lstCommands.size(); i++) {
      // If already in layout, no need to add again.
      VCommand cmdView = lstCommands.get(i);
      if (cmdView.getParentCell() == null) {
        lstCommands.get(i % 2).getParentCell().addDoc(cmdView);
      }
    }

    // Add extra hands to existing hand panel.
    for (int i = 1; i < lstHands.size(); i++) {
      // If already in layout, no need to add again.
      if (lstHands.get(i).getParentCell() == null) { // if i == 0, we get NPE in two lines
        DragCell cellWithHand = lstHands.get(0).getParentCell();
        cellWithHand.addDoc(lstHands.get(i));
      }
    }

    // Remove any hand panels that aren't needed anymore
    for (int i = EDocID.Hands.length - 1; i >= lstHands.size(); i--) {
      DragCell cellWithHand = EDocID.Hands[i].getDoc().getParentCell();
      if (cellWithHand != null) {
        cellWithHand.removeDoc(EDocID.Hands[i].getDoc());
        EDocID.Hands[i].setDoc(new VEmptyDoc(EDocID.Hands[i]));
      }
    }

    // Fill in gaps
    SwingUtilities.invokeLater(
        new Runnable() {
          @Override
          public void run() {
            for (final DragCell c : FView.SINGLETON_INSTANCE.getDragCells()) {
              if (c.getDocs().isEmpty()) {
                SRearrangingUtil.fillGap(c);
                FView.SINGLETON_INSTANCE.removeDragCell(c);
              }
            }
          }
        });
  }