コード例 #1
0
  public GroupManager(Properties propertyBag) {
    super("Groups Manager");
    this.propertyBag = propertyBag;
    setDefaultProperties();

    // Set some UI options:
    UIManager.put(
        "Tree.leafIcon",
        new ImageIcon(GITApp.class.getResource("/resources/images/bullet_black.png")));
    UIManager.put(
        "Tree.closedIcon", new ImageIcon(GITApp.class.getResource("/resources/images/folder.png")));
    UIManager.put(
        "Tree.openIcon", new ImageIcon(GITApp.class.getResource("/resources/images/folder.png")));

    // Create core components
    gameMaster = new GameMaster();
    actorDetailsPanel = new ActorDetailsPanel_v2(false);
    groupTable = new InitTable(gameMaster, false, propertyBag);
    groupTable.getActorTableModel().setActorList(null);
    groupTree = new GroupTree(groupTable);
    searchSupport = new SearchSupport(getRootPane(), groupTree, groupTable);

    // Initialize GameMaster
    gameMaster.initTable = groupTable;
    gameMaster.detailsPanel = actorDetailsPanel;
    groupTable.getActorTableModel().addUndoableEditListener(gameMaster);
    groupTree.addUndoableEditListener(gameMaster);

    // Create and set up the window.
    setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);

    // The file chooser
    groupFileChooser = new JFileChooser();
    groupFileChooser.setCurrentDirectory(
        new File(propertyBag.getProperty("Manager.groupFileChooser.defaultLocation")));
    GroupFilter groupFilter = new GroupFilter();
    groupFileChooser.addChoosableFileFilter(groupFilter);
    groupFileChooser.setFileFilter(groupFilter);

    gcaFileChooser = new JFileChooser();
    gcaFileChooser.setCurrentDirectory(
        new File(propertyBag.getProperty("Manager.gcaFileChooser.defaultLocation")));
    GCAFilter gcaFilter = new GCAFilter();
    gcaFileChooser.addChoosableFileFilter(gcaFilter);
    gcaFileChooser.setFileFilter(gcaFilter);
    gcaFileChooser.setMultiSelectionEnabled(true);

    // The menu bar
    jMenuBar = new JMenuBar();
    jMenu = new JMenu("File");
    jMenu.setMnemonic(KeyEvent.VK_F);
    JMenuItem menuItem = new JMenuItem("New", KeyEvent.VK_N);
    // menuItem.setEnabled(false);
    menuItem.addActionListener(this);
    jMenu.add(menuItem);
    menuItem = new JMenuItem("Open", KeyEvent.VK_O);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK));
    menuItem.addActionListener(this);
    jMenu.add(menuItem);
    menuItem = new JMenuItem("Save As...", KeyEvent.VK_A);
    menuItem
        .getAccessibleContext()
        .setAccessibleDescription("Select the file to save the group list to");
    menuItem.addActionListener(this);
    jMenu.add(menuItem);
    menuItem = new JMenuItem("Save", KeyEvent.VK_S);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK));
    menuItem.getAccessibleContext().setAccessibleDescription("Save the group list");
    menuItem.addActionListener(this);
    jMenu.add(menuItem);
    jMenu.addSeparator();
    menuItem = new JMenuItem("Import GCA4...", KeyEvent.VK_I);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, ActionEvent.CTRL_MASK));
    menuItem.getAccessibleContext().setAccessibleDescription("Import a GCA4 character file");
    menuItem.addActionListener(this);
    jMenu.add(menuItem);
    jMenuBar.add(jMenu);

    jMenu = new JMenu("Edit");
    jMenu.setMnemonic(KeyEvent.VK_E);
    menuItem = new JMenuItem(gameMaster.actionUndo);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Z, ActionEvent.CTRL_MASK));
    jMenu.add(menuItem);
    menuItem = new JMenuItem(gameMaster.actionRedo);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Y, ActionEvent.CTRL_MASK));
    jMenu.add(menuItem);

    menuItem = new JMenuItem(new DefaultEditorKit.CutAction());
    menuItem.setText("Cut");
    menuItem.setMnemonic(KeyEvent.VK_T);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK));
    menuItem.setIcon(new ImageIcon(GITApp.class.getResource("/resources/images/cut.png"), "Cut"));
    jMenu.add(menuItem);
    menuItem = new JMenuItem(new DefaultEditorKit.CopyAction());
    menuItem.setText("Copy");
    menuItem.setMnemonic(KeyEvent.VK_C);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK));
    menuItem.setIcon(
        new ImageIcon(GITApp.class.getResource("/resources/images/page_copy.png"), "Copy"));
    jMenu.add(menuItem);
    menuItem = new JMenuItem(new DefaultEditorKit.PasteAction());
    menuItem.setText("Paste");
    menuItem.setMnemonic(KeyEvent.VK_V);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.CTRL_MASK));
    menuItem.setIcon(
        new ImageIcon(GITApp.class.getResource("/resources/images/paste_plain.png"), "Paste"));
    jMenu.add(menuItem);
    jMenuBar.add(jMenu);

    jMenu = new JMenu("View");
    jMenu.setMnemonic(KeyEvent.VK_V);
    menuItem = new JCheckBoxMenuItem("Auto-fit columns");
    menuItem.setMnemonic(KeyEvent.VK_A);
    menuItem.setSelected(Boolean.valueOf(propertyBag.getProperty("Manager.groupTable.autoResize")));
    menuItem
        .getAccessibleContext()
        .setAccessibleDescription("Table columns auto-fit automatically");
    menuItem.addItemListener(this);
    jMenu.add(menuItem);
    menuItem = new JCheckBoxMenuItem("Actor Details");
    // ((JCheckBoxMenuItem) menuItem).setSelected(true);
    menuItem.setSelected(Boolean.valueOf(propertyBag.getProperty("Manager.actorDetails.visible")));
    menuItem.setMnemonic(KeyEvent.VK_D);
    menuItem.addItemListener(this);
    jMenu.add(menuItem);
    menuItem =
        new JMenuItem(
            new AbstractAction() {
              @Override
              public void actionPerformed(ActionEvent arg0) {
                groupTable.showColumnCustomizer();
              }
            });
    menuItem.setText("Customize Columns");
    menuItem.setMnemonic(KeyEvent.VK_C);
    jMenu.add(menuItem);
    jMenuBar.add(jMenu);

    setJMenuBar(jMenuBar);

    // The top tool bar (search)
    toolbar = searchSupport.getSearchToolBar();
    toolbar.add(Box.createHorizontalGlue());
    getContentPane().add(toolbar, BorderLayout.PAGE_START);

    groupTable.setVisible(false);
    groupTable.getSelectionModel().addListSelectionListener(this);
    groupTable.getActorTableModel().addFileChangeEventListener(new GroupFileChangeEventListener());
    groupTable.getActorTableModel().addTableModelListener(new GroupInitTableModelListener());

    groupTree.addTreeSelectionListener(this);
    groupTree.addFileChangeEventListener(new GroupFileChangeEventListener());
    jScrollPaneTable = new JScrollPane(groupTable);
    jScrollPaneDetails = new JScrollPane(actorDetailsPanel);
    jScrollPaneDetails.setMinimumSize(
        new Dimension(actorDetailsPanel.getPreferredSize().width + 20, 0));

    jScrollPaneTree = new JScrollPane(groupTree);
    jSplitPaneVertical =
        new JSplitPane(JSplitPane.VERTICAL_SPLIT, jScrollPaneTree, jScrollPaneTable);
    jSplitPaneHorizontal =
        new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, jSplitPaneVertical, jScrollPaneDetails);

    jSplitPaneVertical.setDividerLocation(
        Integer.valueOf(propertyBag.getProperty("Manager.splitVertical.dividerLocation")));
    jSplitPaneVertical.setContinuousLayout(true);
    jSplitPaneVertical.setResizeWeight(.95);

    jSplitPaneHorizontal.setDividerLocation(
        Integer.valueOf(propertyBag.getProperty("Manager.splitHorizontal.dividerLocation")));
    jSplitPaneHorizontal.setContinuousLayout(true);
    jSplitPaneHorizontal.setResizeWeight(.95);

    layoutActorPanel();

    setLocation(
        Integer.valueOf(propertyBag.getProperty("Manager.location.x")),
        Integer.valueOf(propertyBag.getProperty("Manager.location.y")));
    setSize(
        Integer.valueOf(propertyBag.getProperty("Manager.size.width")),
        Integer.valueOf(propertyBag.getProperty("Manager.size.height")));
  }
コード例 #2
0
 @Override
 public void valueChanged(ListSelectionEvent e) {
   if (!e.getValueIsAdjusting()) {
     actorDetailsPanel.setActor(groupTable.getSelectedActor());
   }
 }