コード例 #1
0
ファイル: MetadataDialog.java プロジェクト: DetriusXii/jdip
  /** Handle OK/Cancel selections */
  @Override
  public void close(String actionCommand) {
    super.close(actionCommand);

    if (isOKorAccept(actionCommand)) {
      World world = clientFrame.getWorld();

      // this isn't really the way to do it
      GamePanel gp = (GamePanel) tabPane.getComponentAt(0);
      GameMetadata gmd = new GameMetadata();
      gp.write(gmd);
      world.setGameMetadata(gmd);

      // assume panels 1-n are all player panels
      for (int i = 1; i < tabPane.getTabCount(); i++) {
        PlayerPanel pp = (PlayerPanel) tabPane.getComponentAt(i);
        PlayerMetadata pmd = new PlayerMetadata();
        pp.write(pmd);
        world.setPlayerMetadata(pp.getPower(), pmd);
      }

      // set data-changed flag
      clientFrame.fireStateModified();
    }

    if (propertyListener != null) {
      clientFrame.removePropertyChangeListener(propertyListener);
    }
  } // close()
コード例 #2
0
ファイル: MetadataDialog.java プロジェクト: DetriusXii/jdip
  /** Creates the dialog */
  private MetadataDialog(ClientFrame parent) {
    super(parent, Utils.getLocalString(TITLE), true);
    this.clientFrame = parent;

    mmd = clientFrame.getMapMetadata();
    if (mmd == null) {
      propertyListener = new IconColorListener();
      clientFrame.addPropertyChangeListener(propertyListener);
    }

    makeTabPanel();
    setTabIcons();

    setHeaderText(Utils.getText(Utils.getLocalString(HEADER_LOCATION)));
    createDefaultContentBorder(tabPane);
    setContentPane(tabPane);
    addTwoButtons(makeCancelButton(), makeOKButton(), false, true);
    setHelpID(dip.misc.Help.HelpID.Dialog_Metadata);
  } // MetadataDialog()
コード例 #3
0
ファイル: MetadataDialog.java プロジェクト: DetriusXii/jdip
 /** Sets the tab icons for each power. */
 private void setTabIcons() {
   if (mmd != null) {
     final World world = clientFrame.getWorld();
     final int tabCount = tabPane.getTabCount();
     for (int i = 1; i < tabCount; i++) // no icon for 'game' info
     {
       Power power = world.getMap().getPower(tabPane.getTitleAt(i));
       assert (power != null);
       String colorName = mmd.getPowerColor(power);
       Color color = SVGColorParser.parseColor(colorName);
       tabPane.setIconAt(i, new ColorRectIcon(12, 12, color));
     }
   }
 } // setTabIcons()
コード例 #4
0
ファイル: MetadataDialog.java プロジェクト: DetriusXii/jdip
  /** Make the tab panel */
  private void makeTabPanel() {
    // create tabbed pane
    tabPane = new JTabbedPane();

    // first tab is Game info
    World world = clientFrame.getWorld();
    tabPane.add(Utils.getLocalString(TAB_GAME_PANEL), makeGamePanel(world.getGameMetadata()));

    // all other tabs are by Power name
    Power[] powers = world.getMap().getPowers();
    for (int i = 0; i < powers.length; i++) {
      tabPane.add(
          powers[i].getName(), makePlayerPanel(powers[i], world.getPlayerMetadata(powers[i])));
    }
  } // makeTabPanel()