Beispiel #1
0
  @Override
  protected void layoutComponents() {
    batchPanel = new JPanel();
    batchPanel.setLayout(new GridBagLayout());

    GridBagConstraintsExt c = new GridBagConstraintsExt();
    c.ipadx = 2;
    c.ipady = 2;
    c.insets = new Insets(5, 5, 5, 5);

    c.place(0, 1, 1, 1);
    batchPanel.add(entryDateLabel, c);

    c.place(1, 1, 2, 1);
    batchPanel.add(entryDateSpinner, c);

    c.place(3, 1, 1, 1);
    batchPanel.add(countLabel, c);

    c.place(4, 1, 1, 1);
    batchPanel.add(countField, c);

    c.place(0, 0, 1, 1);
    batchPanel.add(barcodeLabel, c);

    c.place(1, 0, 2, 1);
    batchPanel.add(barcodeField, c);

    c.place(3, 0, 2, 1);
    batchPanel.add(scannerBox, c);

    c.place(1, 2, 1, 1);
    batchPanel.add(itemActionButton, c);

    c.place(2, 2, 1, 1);
    batchPanel.add(undoButton, c);

    c.place(3, 2, 1, 1);
    batchPanel.add(redoButton, c);

    c.place(4, 2, 1, 1);
    batchPanel.add(doneButton, c);

    setMaximumSize(batchPanel);

    productPanel = new JPanel();
    productPanel.setLayout(new BoxLayout(productPanel, BoxLayout.Y_AXIS));

    productPanel.add(Box.createRigidArea(new Dimension(10, 10)));
    productPanel.add(batchPanel);
    productPanel.add(Box.createRigidArea(new Dimension(10, 10)));
    productPanel.add(productTableScrollPane);

    splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, productPanel, itemTableScrollPane);

    this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    this.add(splitPane);
  }
Beispiel #2
0
  public void buildPopulationBox() {
    rebuilding = true;
    populationBox.removeAll();
    peopleList = new ArrayList<Object>();
    famList = new ArrayList<Family>();
    peopleList.addAll(ctxt.individualCensus);
    String plur = (peopleList.size() == 1 ? "" : "s");
    populationBox.setLayout(new BoxLayout(populationBox, BoxLayout.PAGE_AXIS));
    populationBox.setBorder(
        BorderFactory.createTitledBorder(
            BorderFactory.createLineBorder(Color.blue), "Current Population"));
    populationBox.setAlignmentX(0.5f);
    populationBox.add(Box.createRigidArea(new Dimension(8, 0)));
    indivLabel = new JLabel("Contains " + peopleList.size() + " Individual" + plur);
    indivLabel.setAlignmentX(0.5f);
    populationBox.add(indivLabel);
    if (peopleList.size() > 0) {
      JPanel indivBtnBox = new JPanel();
      indivBtnBox.setLayout(new BoxLayout(indivBtnBox, BoxLayout.LINE_AXIS));
      Dimension sizer2 = new Dimension(350, 50);
      String[] indMenu = genIndMenu(peopleList);
      indPick = new JComboBox(indMenu);
      indPick.addActionListener(listener);
      indPick.setActionCommand("view/edit person");
      indPick.setMinimumSize(sizer2);
      indPick.setMaximumSize(sizer2);
      indPick.setBorder(
          BorderFactory.createTitledBorder(
              BorderFactory.createLineBorder(Color.blue), "View/Edit Person"));
      indivBtnBox.add(indPick);
      populationBox.add(indivBtnBox);
    } //  end of if-any-people-exist

    famList.addAll(ctxt.familyCensus); //  end of filtering deleted records
    plur = (famList.size() == 1 ? "y" : "ies");
    famLabel = new JLabel("Contains " + famList.size() + " Famil" + plur);
    famLabel.setAlignmentX(0.5f);
    populationBox.add(Box.createRigidArea(new Dimension(0, 4)));
    populationBox.add(famLabel);
    if (famList.size() > 0) {
      JPanel famBtnBox = new JPanel();
      famBtnBox.setLayout(new BoxLayout(famBtnBox, BoxLayout.LINE_AXIS));
      Dimension sizer2 = new Dimension(350, 50);
      String[] famMenu = genFamMenu(famList);
      famPick = new JComboBox(famMenu);
      famPick.addActionListener(listener);
      famPick.setActionCommand("view/edit family");
      famPick.setMinimumSize(sizer2);
      famPick.setMaximumSize(sizer2);
      famPick.setBorder(
          BorderFactory.createTitledBorder(
              BorderFactory.createLineBorder(Color.blue), "View/Edit Family"));
      famBtnBox.add(famPick);
      populationBox.add(famBtnBox);
    } //  end of if-any-families-exist
    rebuilding = false;
  } //  end of method buildPopulationBox
  /** Constructor. */
  public TilePatternsView() {
    super();

    tilePatternIcons = new ArrayList<TilePatternIcon>();

    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    // tileset properties
    // the tile pattern list
    // view of the current tile pattern

    // tileset properties
    tilesetPropertiesView = new TilesetPropertiesView();
    tilesetPropertiesView.setMaximumSize(new Dimension(Integer.MAX_VALUE, 120));
    tilesetPropertiesView.setAlignmentX(Component.LEFT_ALIGNMENT);

    // list
    tilePatternsListModel = new TilePatternsListModel();
    tilePatternsList = new JList(tilePatternsListModel);
    tilePatternsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    tilePatternsList.setLayoutOrientation(JList.HORIZONTAL_WRAP);
    tilePatternsList.setVisibleRowCount(-1); // make the rows as wide as possible
    tilePatternsList
        .getSelectionModel()
        .addListSelectionListener(new TilePatternListSelectionListener());
    tilePatternsList.setCellRenderer(new TilePatternListRenderer());

    tilePatternsList.addKeyListener(
        new KeyAdapter() {
          public void keyPressed(KeyEvent keyEvent) {
            if (keyEvent.getKeyCode() == KeyEvent.VK_DELETE) {
              if (tileset != null && tileset.getSelectedTilePattern() != null) {
                tileset.removeTilePattern();
              }
            }
          }
        });

    JScrollPane listScroller = new JScrollPane(tilePatternsList);
    listScroller.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
    listScroller.setAlignmentX(Component.LEFT_ALIGNMENT);

    // tile view
    tilePatternView = new TilePatternView();
    tilePatternView.setMaximumSize(new Dimension(Integer.MAX_VALUE, 300));
    tilePatternView.setAlignmentX(Component.LEFT_ALIGNMENT);

    add(tilesetPropertiesView);
    add(Box.createRigidArea(new Dimension(0, 5)));
    add(listScroller);
    add(Box.createRigidArea(new Dimension(0, 5)));
    add(tilePatternView);
  }
Beispiel #4
0
  /** Constructor */
  public WPart11Dialog() {
    super(null);
    setVisible(false);

    m_pnlDisplay = new JPanel();
    m_pcsTypesMgr = new PropertyChangeSupport(this);
    JScrollPane spDisplay = new JScrollPane(m_pnlDisplay);
    m_pnlDisplay.setLayout(new WGridLayout(0, 2));
    addComp(spDisplay);
    initBlink();

    buttonPane.removeAll();
    // Add the buttons to the panel with space between buttons.
    m_btnChecksum = new JButton("Make new checksum");
    buttonPane.add(m_btnChecksum);
    buttonPane.add(Box.createRigidArea(new Dimension(5, 0)));
    buttonPane.add(validateButton);
    buttonPane.add(Box.createRigidArea(new Dimension(5, 0)));
    buttonPane.add(closeButton);
    buttonPane.add(Box.createRigidArea(new Dimension(5, 0)));
    buttonPane.add(abandonButton);
    buttonPane.add(Box.createRigidArea(new Dimension(5, 0)));
    buttonPane.add(helpButton);
    setHelpEnabled(false);

    closeButton.setActionCommand("close");
    closeButton.addActionListener(this);
    validateButton.setActionCommand("validate");
    validateButton.addActionListener(this);
    abandonButton.setActionCommand("cancel");
    abandonButton.addActionListener(this);
    helpButton.setActionCommand("help");
    helpButton.addActionListener(this);
    m_btnChecksum.setActionCommand("checksum");
    m_btnChecksum.addActionListener(this);

    setCloseEnabled(true);
    setAbandonEnabled(true);

    setTitle("Configuration");
    setLocation(300, 500);
    setResizable(true);
    setSize(450, 300);
  }
Beispiel #5
0
  public ComboBoxDemo2() {
    setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
    String[] patternExamples = {
      "dd MMMMM yyyy",
      "dd.MM.yy",
      "MM/dd/yy",
      "yyyy.MM.dd G 'at' hh:mm:ss z",
      "EEE, MMM d, ''yy",
      "h:mm a",
      "H:mm:ss:SSS",
      "K:mm a,z",
      "yyyy.MMMMM.dd GGG hh:mm aaa"
    };

    currentPattern = patternExamples[0];

    // Set up the UI for selecting a pattern.
    JLabel patternLabel1 = new JLabel("Enter the pattern string or");
    JLabel patternLabel2 = new JLabel("select one from the list:");

    JComboBox patternList = new JComboBox(patternExamples);
    patternList.setEditable(true);
    patternList.addActionListener(this);

    // Create the UI for displaying result.
    JLabel resultLabel = new JLabel("Current Date/Time", JLabel.LEADING); // == LEFT
    result = new JLabel(" ");
    result.setForeground(Color.black);
    result.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createLineBorder(Color.black),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));

    // Lay out everything.
    JPanel patternPanel = new JPanel();
    patternPanel.setLayout(new BoxLayout(patternPanel, BoxLayout.PAGE_AXIS));
    patternPanel.add(patternLabel1);
    patternPanel.add(patternLabel2);
    patternList.setAlignmentX(Component.LEFT_ALIGNMENT);
    patternPanel.add(patternList);

    JPanel resultPanel = new JPanel(new GridLayout(0, 1));
    resultPanel.add(resultLabel);
    resultPanel.add(result);

    patternPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    resultPanel.setAlignmentX(Component.LEFT_ALIGNMENT);

    add(patternPanel);
    add(Box.createRigidArea(new Dimension(0, 10)));
    add(resultPanel);

    setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    reformat();
  } // constructor
  /**
   * Update the dialog contents.
   *
   * @param jheader The job portion of the dialog header.
   * @param job The queue job.
   * @param info The current job status information.
   */
  public void updateContents(
      String jheader, QueueJob job, QueueJobInfo info, SubProcessExecDetails details) {
    ActionAgenda agenda = job.getActionAgenda();
    QueueJobResults results = info.getResults();

    String dir = "-";
    if ((agenda != null) && (info.getOsType() != null))
      dir = agenda.getTargetPath(info.getOsType()).toString();

    String hostname = "";
    if (info.getHostname() != null) hostname = (" [" + info.getHostname() + "]");

    String command = "-";
    if (details != null) command = details.getCommand();

    TreeMap<String, String> env = new TreeMap<String, String>();
    if (details != null) env = details.getEnvironment();

    setHeader("Execution Details -" + jheader + hostname);

    pWorkingDirField.setText(dir);

    BaseAction action = job.getAction();
    pCommandLineLabel.setText(
        "Action Command:  " + action.getName() + " (v" + action.getVersionID() + ")");
    pCommandLineArea.setText(command);

    {
      Component comps[] = UIFactory.createTitledPanels();
      {
        JPanel tpanel = (JPanel) comps[0];
        JPanel vpanel = (JPanel) comps[1];

        if (!env.isEmpty()) {
          String last = env.lastKey();
          for (String key : env.keySet()) {
            String value = env.get(key);

            JTextField field =
                UIFactory.createTitledTextField(tpanel, key + ":", sTSize, vpanel, value, sVSize);
            field.setHorizontalAlignment(JLabel.LEFT);

            if (!key.equals(last)) UIFactory.addVerticalSpacer(tpanel, vpanel, 3);
          }
        } else {
          tpanel.add(Box.createRigidArea(new Dimension(sTSize, 0)));
          vpanel.add(Box.createHorizontalGlue());
        }
      }

      pEnvLabel.setText("Toolset Environment:  " + agenda.getToolset());
      pEnvScroll.setViewportView(comps[2]);
    }
  }
Beispiel #7
0
  /** OptionPaneDemo Constructor */
  public OptionPaneDemo(SwingSet2 swingset) {
    // Set the title for this demo, and an icon used to represent this
    // demo inside the SwingSet2 app.
    super(swingset, "OptionPaneDemo", "toolbar/JOptionPane.gif");

    JPanel demo = getDemoPanel();

    demo.setLayout(new BoxLayout(demo, BoxLayout.X_AXIS));

    JPanel bp =
        new JPanel() {
          public Dimension getMaximumSize() {
            return new Dimension(getPreferredSize().width, super.getMaximumSize().height);
          }
        };
    bp.setLayout(new BoxLayout(bp, BoxLayout.Y_AXIS));

    bp.add(Box.createRigidArea(VGAP30));
    bp.add(Box.createRigidArea(VGAP30));

    bp.add(createInputDialogButton());
    bp.add(Box.createRigidArea(VGAP15));
    bp.add(createWarningDialogButton());
    bp.add(Box.createRigidArea(VGAP15));
    bp.add(createMessageDialogButton());
    bp.add(Box.createRigidArea(VGAP15));
    bp.add(createComponentDialogButton());
    bp.add(Box.createRigidArea(VGAP15));
    bp.add(createConfirmDialogButton());
    bp.add(Box.createVerticalGlue());

    demo.add(Box.createHorizontalGlue());
    demo.add(bp);
    demo.add(Box.createHorizontalGlue());
  }
  public void createFileChooserDemo() {
    theImage = new JLabel("");
    jpgIcon = createImageIcon("filechooser/jpgIcon.jpg", "jpg image");
    gifIcon = createImageIcon("filechooser/gifIcon.gif", "gif image");

    JPanel demoPanel = getDemoPanel();
    demoPanel.setLayout(new BoxLayout(demoPanel, BoxLayout.Y_AXIS));

    JPanel innerPanel = new JPanel();
    innerPanel.setLayout(new BoxLayout(innerPanel, BoxLayout.X_AXIS));

    demoPanel.add(Box.createRigidArea(VGAP20));
    demoPanel.add(innerPanel);
    demoPanel.add(Box.createRigidArea(VGAP20));

    innerPanel.add(Box.createRigidArea(HGAP20));

    // Create a panel to hold buttons
    JPanel buttonPanel =
        new JPanel() {
          public Dimension getMaximumSize() {
            return new Dimension(getPreferredSize().width, super.getMaximumSize().height);
          }
        };
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.Y_AXIS));

    buttonPanel.add(Box.createRigidArea(VGAP15));
    buttonPanel.add(createPlainFileChooserButton());
    buttonPanel.add(Box.createRigidArea(VGAP15));
    buttonPanel.add(createPreviewFileChooserButton());
    buttonPanel.add(Box.createRigidArea(VGAP15));
    buttonPanel.add(createCustomFileChooserButton());
    buttonPanel.add(Box.createVerticalGlue());

    // Create a panel to hold the image
    JPanel imagePanel = new JPanel();
    imagePanel.setLayout(new BorderLayout());
    imagePanel.setBorder(new BevelBorder(BevelBorder.LOWERED));
    JScrollPane scroller = new JScrollPane(theImage);
    scroller.getVerticalScrollBar().setUnitIncrement(10);
    scroller.getHorizontalScrollBar().setUnitIncrement(10);
    imagePanel.add(scroller, BorderLayout.CENTER);

    // add buttons and image panels to inner panel
    innerPanel.add(buttonPanel);
    innerPanel.add(Box.createRigidArea(HGAP30));
    innerPanel.add(imagePanel);
    innerPanel.add(Box.createRigidArea(HGAP20));
  }
  /**
   * The constructor.
   *
   * @param parent The parent window.
   * @param idata The installation data.
   */
  public SudoPanel(InstallerFrame parent, InstallData idata) {
    super(parent, idata);

    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    add(
        new JLabel(
            /*parent.langpack.getString("SudoPanel.info")*/ "For installing administrator privileges are necessary",
            JLabel.TRAILING));

    add(Box.createRigidArea(new Dimension(0, 5)));

    add(
        new JLabel(
            /*parent.langpack.getString("SudoPanel.tip")*/ "Please note that passwords are case-sensitive",
            parent.icons.getImageIcon("tip"),
            JLabel.TRAILING));

    add(Box.createRigidArea(new Dimension(0, 5)));

    JPanel spacePanel = new JPanel();
    spacePanel.setAlignmentX(LEFT_ALIGNMENT);
    spacePanel.setAlignmentY(CENTER_ALIGNMENT);
    spacePanel.setBorder(BorderFactory.createEmptyBorder(80, 30, 0, 50));
    spacePanel.setLayout(new BorderLayout(5, 5));
    spacePanel.add(
        new JLabel(
            /*parent.langpack.getString("SudoPanel.specifyAdminPassword")*/ "Please specify your password:"),
        BorderLayout.NORTH);
    passwordField = new JPasswordField();
    passwordField.addActionListener(this);
    JPanel space2Panel = new JPanel();
    space2Panel.setLayout(new BorderLayout());
    space2Panel.add(passwordField, BorderLayout.NORTH);
    space2Panel.add(Box.createRigidArea(new Dimension(0, 5)), BorderLayout.CENTER);
    spacePanel.add(space2Panel, BorderLayout.CENTER);
    add(spacePanel);
  }
  /**
   * Initialize the common user interface components.
   *
   * <p>
   */
  protected JButton[] initUI(
      String title, JComponent extraComps, String confirm, String[][] extra, String cancel) {
    JButton[] extraBtns = null;

    /* create dialog body components */
    {
      JPanel body = new JPanel();
      body.setName("MainDialogPanel");

      body.setLayout(new BoxLayout(body, BoxLayout.Y_AXIS));

      body.add(UIFactory.createPanelLabel("Existing Layouts:"));

      body.add(Box.createRigidArea(new Dimension(0, 4)));

      {
        DefaultMutableTreeNode root = new DefaultMutableTreeNode(new TreeData(), true);
        DefaultTreeModel model = new DefaultTreeModel(root, true);

        JTree tree = new JFancyTree(model);
        pTree = tree;
        tree.setName("DarkTree");

        tree.setCellRenderer(new JLayoutTreeCellRenderer());
        tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

        {
          JScrollPane scroll =
              UIFactory.createScrollPane(
                  pTree,
                  ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED,
                  ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
                  new Dimension(230, 120),
                  new Dimension(230, 150),
                  null);

          body.add(scroll);
        }
      }

      if (extraComps != null) body.add(extraComps);

      extraBtns = super.initUI(title, body, confirm, null, extra, cancel);
    }

    return extraBtns;
  }
Beispiel #11
0
    public PlayerView(String player) {
      playerName = new String(player);

      // Set-Up Top of Score Area
      namePanel = new JPanel();
      nameText = new JLabel(player);
      nameText.setFont(ScoreFont);
      namePanel.setLayout(new BorderLayout());
      namePanel.add(nameText, BorderLayout.CENTER);

      scorePanel = new JPanel();
      scoreText = new JLabel("  0");
      scoreText.setFont(ScoreFont);
      scorePanel.setLayout(new BorderLayout());
      scorePanel.add(scoreText, BorderLayout.CENTER);

      topPanel = new JPanel();
      BoxLayout layout = new BoxLayout(topPanel, BoxLayout.LINE_AXIS);

      topPanel.setLayout(layout);
      topPanel.add(namePanel);
      topPanel.add(Box.createRigidArea(new Dimension(10, 0)));
      topPanel.add(scorePanel);
      topPanel.add(Box.createRigidArea(new Dimension(10, 0)));

      //
      // topPanel.setLayout( new BorderLayout());
      // topPanel.add(namePanel, BorderLayout.WEST);
      // topPanel.add(scorePanel, BorderLayout.EAST);
      //
      // Create bordering for top panel
      Border raisedBevel, loweredBevel, compound;

      raisedBevel = BorderFactory.createRaisedBevelBorder();
      loweredBevel = BorderFactory.createLoweredBevelBorder();
      compound = BorderFactory.createCompoundBorder(raisedBevel, loweredBevel);
      topPanel.setBorder(compound);

      // Set-Up area to display word list
      wordPanel = new JPanel();
      Border etched = BorderFactory.createEtchedBorder();
      TitledBorder etchedTitle = BorderFactory.createTitledBorder(etched, "Word List");
      etchedTitle.setTitleJustification(TitledBorder.RIGHT);
      wordPanel.setBorder(etchedTitle);
      myWordList = new ExpandableList();
      myWordList.addActionListener(
          new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
              String word = e.getActionCommand();
              java.util.List<BoardCell> list = myFinder.cellsForWord(myBoard, word);
              myBoardPanel.highlightDice(list);
            }
          });
      wordPanel.add(
          new JScrollPane(
              myWordList,
              JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
              JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED));

      setLayout(new BorderLayout(30, 30));
      add(topPanel, BorderLayout.NORTH);
      add(wordPanel, BorderLayout.CENTER);
    }
  /**
   * Present a GUI allowing the user to select shots in which each previously selected asset should
   * be updated.
   *
   * @return
   * @throws PipelineException
   */
  private String confirmShotsToUpdate() throws PipelineException {

    /* DO GUI DRAWING STUFF*/
    JScrollPane scroll = null;
    {
      Box ibox = new Box(BoxLayout.Y_AXIS);
      if (pAssetManager.isEmpty()) {
        Component comps[] = UIFactory.createTitledPanels();
        JPanel tpanel = (JPanel) comps[0];
        JPanel vpanel = (JPanel) comps[1];

        tpanel.add(Box.createRigidArea(new Dimension(sTSize - 7, 0)));
        vpanel.add(Box.createHorizontalGlue());

        ibox.add(comps[2]);
      } else {

        for (String assetName : pAssetManager.keySet()) {
          String name = getShortName(assetName);
          AssetInfo info = pAssetManager.get(assetName);

          Component comps[] = UIFactory.createTitledPanels();
          JPanel tpanel = (JPanel) comps[0];
          JPanel vpanel = (JPanel) comps[1];
          String title = "Replace " + name + " with ";
          title += getShortName(info.getNewAsset());

          JDrawer shotList = new JDrawer(title, (JComponent) comps[2], true);
          ibox.add(shotList);

          for (String shot : info.getLoHiResShots().keySet()) {

            String shortShot = getShortName(shot);
            JBooleanField field =
                UIFactory.createTitledBooleanField(
                    tpanel,
                    shortShot,
                    sVSize,
                    vpanel,
                    sTSize,
                    "Whether to replace this asset source for the node.");
            field.setName(shot);
            field.setValue(true);

            if (!pSubstituteFields.containsKey(assetName))
              pSubstituteFields.put(assetName, new LinkedList<JBooleanField>());

            pSubstituteFields.get(assetName).add(field);
            UIFactory.addVerticalSpacer(tpanel, vpanel, 3);
          }
        }
      }

      {
        JPanel spanel = new JPanel();
        spanel.setName("Spacer");

        spanel.setMinimumSize(new Dimension(sTSize + sVSize, 7));
        spanel.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
        spanel.setPreferredSize(new Dimension(sTSize + sVSize, 7));

        ibox.add(spanel);
      }

      {
        scroll = new JScrollPane(ibox);
        scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

        Dimension size = new Dimension(sTSize + sVSize + 52, 300);
        scroll.setMinimumSize(size);
        scroll.setPreferredSize(size);

        scroll.getViewport().setScrollMode(JViewport.BACKINGSTORE_SCROLL_MODE);
      }
    }

    /* query the user */
    JToolDialog diag = new JToolDialog("Update Assets Per Shot", scroll, "Confirm");
    diag.setVisible(true);

    /* Process User Input */
    if (diag.wasConfirmed()) {

      for (String asset : pSubstituteFields.keySet()) {
        for (JBooleanField field : pSubstituteFields.get(asset)) {
          Boolean bUpdate = field.getValue();
          if ((bUpdate == null) || !bUpdate) {
            pAssetManager.get(asset).getLoHiResShots().remove(field.getName());

            // logLine("\tRemoving: "+ getShortName(field.getName())
            // TODO		+" from list for "+ getShortName(asset));
          }
        }
      }
      return ": Modifying Nodes...";
    }
    return null;
  } // end confirmShotsToUpdate
Beispiel #13
0
  class MyRenderer implements TreeCellRenderer {
    private JLabel renderer;
    private Component fill = Box.createRigidArea(new Dimension(0, 0));

    public MyRenderer() {
      renderer = new JLabel();
      renderer.setOpaque(Preferences.getBoolean("jeti", "bmw", true));
      renderer.setBackground(UIManager.getColor("Tree.selectionBackground"));
      renderer.setForeground(UIManager.getColor("Tree.textForeground"));
      renderer.setFont(UIManager.getFont("Tree.font"));
    }

    public Component getTreeCellRendererComponent(
        JTree tree,
        Object value,
        boolean sel,
        boolean expanded,
        boolean leaf,
        int row,
        boolean hasFocus) {
      renderer.setForeground(Color.BLACK);
      renderer.setText(value.toString());
      if (sel) {
        renderer.setOpaque(true);
      } else {
        renderer.setOpaque(false);
      }
      if (leaf) {
        return (makeComponent((JIDStatus) value));
      }
      if (value instanceof PrimaryJIDStatus) {
        PrimaryJIDStatus ps = (PrimaryJIDStatus) value;
        JIDStatus jidsStatus = ps.getJIDPrimaryStatus();
        if (ps.hasMultiple()) {
          if (onlineTree) {
            if (ps.multipleJIDstatusOnline()) renderer.setForeground(new Color(0, 0, 190));
            return makeComponent(jidsStatus);
          }
          if (ps.isAJIDstatusOffline()) { // if offline tree and a jidStatus in primary is offline
            // show
            renderer.setIcon(StatusIcons.getImageIcon("multiple"));
            return renderer;
          }
          return fill;
        }
        return makeComponent(jidsStatus);
      } else if (value instanceof JIDStatusGroup) {
        JIDStatusGroup group = (JIDStatusGroup) value;
        if (onlineTree) {
          if (group.getOnlines() == 0) return fill;
          else renderer.setText(group.toString() + " (" + group.getOnlines() + ")");
        }
        if (expanded) renderer.setIcon(StatusIcons.getImageIcon("arrowDown"));
        else renderer.setIcon(StatusIcons.getImageIcon("arrowUp"));
      }
      return renderer;
    }

    private Component makeComponent(JIDStatus jidStatus) {
      if (jidStatus.isOnline()) {
        if (!onlineTree) return fill; // leeg want offline tree
        int show = jidStatus.getShow();
        renderer.setIcon(StatusIcons.getStatusIcon(show, jidStatus.getType()));
      } else {
        if (onlineTree) return fill; // leeg want online tree
        renderer.setIcon(StatusIcons.getStatusIcon(Presence.UNAVAILABLE, jidStatus.getType()));
      }
      return renderer;
    }
  }
  /** Construct a new panel. */
  public JUnixPanel(ConfigApp app) {
    super(app, "Linux Paths:");

    /* initialize UI components */
    {
      pHomeDirComp = new JAbsoluteDirComp("Home Directory", sSize);
      add(pHomeDirComp);

      add(Box.createRigidArea(new Dimension(0, 20)));

      pTempDirComp = new JAbsoluteDirComp("Temporary Directory", sSize);
      add(pTempDirComp);

      add(Box.createRigidArea(new Dimension(0, 20)));

      pJavaHomeDirComp = new JAbsoluteDirComp("Java Home Directory", sSize);
      add(pJavaHomeDirComp);

      add(Box.createRigidArea(new Dimension(0, 40)));

      pJavadocDirComp = new JAbsoluteDirComp("Local Vendor Javadoc Directory", sSize);
      add(pJavadocDirComp);

      add(Box.createRigidArea(new Dimension(0, 20)));

      pExtraJavaLibsComp = new JAbsoluteJarsComp("Local Java Libraries", sSize);
      add(pExtraJavaLibsComp);

      add(Box.createRigidArea(new Dimension(0, 20)));
      add(Box.createVerticalGlue());

      pNotesDialog.setMessage(
          "Linux Parameters:",
          "The Home Directory is the absolute path to the parent directory of all user "
              + "home directories.  Usually this directory resides on a network file system and "
              + "may not be (/home) at your site.\n"
              + "\n"
              + "The Temporary Directory is absolute path to the directory used to write various "
              + "temporary files generated by Pipeline programs.  For optimal performance, this "
              + "directory should reside on a local file system.\n"
              + "\n"
              + "The Java Home Directory is the path to the root directory of the local Java "
              + "Runtime Environment (JRE) installed on Linux artist workstations used to run "
              + "Pipeline client programs.  By default, this is set to the JRE used to run this "
              + "configuration tool and the Pipeline server daemons in the Java Runtime section "
              + "above.  If you wish to use a different JRE for workstation clients than is used "
              + "for the server daemons, you can specify the location of the alternative JRE "
              + "here.\n"
              + "\n"
              + "The Local Vendor Javadoc Directory is the path to the root directory where the "
              + "documentation generated by javadoc for locally created Pipeline plugins and "
              + "standalone utils is located.  Providing this will allow users to easily access "
              + "the documentation for locally created plugins from Pipeline's user interface.\n"
              + "\n"
              + "The Local Java Libraries is a optional set of JAR files containing common Java "
              + "class shared by a large number of locally created plugins and/or standalone "
              + "utils.  Any JARs provided will be added to the Java classpath for all Pipeline "
              + "programs.  This is typically used for relatively large 3rd party libraries for "
              + "things such as XML parsing or SQL database connections which would otherwise "
              + "need to be embedded in many different plugin JARs.  Since these libraries "
              + "be dynamically updated (like plugins can), they are not suitable for anything "
              + "which might need to modified without a Pipeline shutdown.  This feature is "
              + "only an optimization to reduce plugin size and memory footprint but is not "
              + "required in order to use 3rd party Java libraries with Pipeline.");
    }
  }
  public void installComponents(JFileChooser fc) {
    fc.setLayout(new BorderLayout(10, 10));
    fc.setAlignmentX(JComponent.CENTER_ALIGNMENT);

    JPanel interior =
        new JPanel() {
          public Insets getInsets() {
            return insets;
          }
        };
    align(interior);
    interior.setLayout(new BoxLayout(interior, BoxLayout.PAGE_AXIS));

    fc.add(interior, BorderLayout.CENTER);

    // PENDING(jeff) - I18N
    JLabel l = new JLabel(pathLabelText);
    l.setDisplayedMnemonic(pathLabelMnemonic);
    align(l);
    interior.add(l);

    File currentDirectory = fc.getCurrentDirectory();
    String curDirName = null;
    if (currentDirectory != null) {
      curDirName = currentDirectory.getPath();
    }
    pathField =
        new JTextField(curDirName) {
          public Dimension getMaximumSize() {
            Dimension d = super.getMaximumSize();
            d.height = getPreferredSize().height;
            return d;
          }
        };
    l.setLabelFor(pathField);
    align(pathField);

    // Change to folder on return
    pathField.addActionListener(getUpdateAction());
    interior.add(pathField);

    interior.add(Box.createRigidArea(vstrut10));

    // CENTER: left, right accessory
    JPanel centerPanel = new JPanel();
    centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.LINE_AXIS));
    align(centerPanel);

    // left panel - Filter & folderList
    JPanel leftPanel = new JPanel();
    leftPanel.setLayout(new BoxLayout(leftPanel, BoxLayout.PAGE_AXIS));
    align(leftPanel);

    // add the filter PENDING(jeff) - I18N
    l = new JLabel(filterLabelText);
    l.setDisplayedMnemonic(filterLabelMnemonic);
    align(l);
    leftPanel.add(l);

    filterComboBox =
        new JComboBox() {
          public Dimension getMaximumSize() {
            Dimension d = super.getMaximumSize();
            d.height = getPreferredSize().height;
            return d;
          }
        };
    l.setLabelFor(filterComboBox);
    filterComboBoxModel = createFilterComboBoxModel();
    filterComboBox.setModel(filterComboBoxModel);
    filterComboBox.setRenderer(createFilterComboBoxRenderer());
    fc.addPropertyChangeListener(filterComboBoxModel);
    align(filterComboBox);
    leftPanel.add(filterComboBox);

    // leftPanel.add(Box.createRigidArea(vstrut10));

    // Add the Folder List PENDING(jeff) - I18N
    l = new JLabel(foldersLabelText);
    l.setDisplayedMnemonic(foldersLabelMnemonic);
    align(l);
    leftPanel.add(l);
    JScrollPane sp = createDirectoryList();
    sp.getVerticalScrollBar().setFocusable(false);
    sp.getHorizontalScrollBar().setFocusable(false);
    l.setLabelFor(sp.getViewport().getView());
    leftPanel.add(sp);

    // create files list
    JPanel rightPanel = new JPanel();
    align(rightPanel);
    rightPanel.setLayout(new BoxLayout(rightPanel, BoxLayout.PAGE_AXIS));

    l = new JLabel(filesLabelText);
    l.setDisplayedMnemonic(filesLabelMnemonic);
    align(l);
    rightPanel.add(l);
    sp = createFilesList();
    l.setLabelFor(sp);
    rightPanel.add(sp);

    centerPanel.add(leftPanel);
    centerPanel.add(Box.createRigidArea(hstrut10));
    centerPanel.add(rightPanel);

    JComponent accessoryPanel = getAccessoryPanel();
    JComponent accessory = fc.getAccessory();
    if (accessoryPanel != null) {
      if (accessory == null) {
        accessoryPanel.setPreferredSize(ZERO_ACC_SIZE);
        accessoryPanel.setMaximumSize(ZERO_ACC_SIZE);
      } else {
        getAccessoryPanel().add(accessory, BorderLayout.CENTER);
        accessoryPanel.setPreferredSize(PREF_ACC_SIZE);
        accessoryPanel.setMaximumSize(MAX_SIZE);
      }
      align(accessoryPanel);
      centerPanel.add(accessoryPanel);
    }
    interior.add(centerPanel);
    interior.add(Box.createRigidArea(vstrut10));

    // add the filename field PENDING(jeff) - I18N
    l = new JLabel(enterFileNameLabelText);
    l.setDisplayedMnemonic(enterFileNameLabelMnemonic);
    align(l);
    interior.add(l);

    filenameTextField =
        new JTextField() {
          public Dimension getMaximumSize() {
            Dimension d = super.getMaximumSize();
            d.height = getPreferredSize().height;
            return d;
          }
        };
    l.setLabelFor(filenameTextField);
    filenameTextField.addActionListener(getApproveSelectionAction());
    align(filenameTextField);
    filenameTextField.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    interior.add(filenameTextField);

    bottomPanel = getBottomPanel();
    bottomPanel.add(new JSeparator(), BorderLayout.NORTH);

    // Add buttons
    JPanel buttonPanel = new JPanel();
    align(buttonPanel);
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS));
    buttonPanel.add(Box.createGlue());

    approveButton =
        new JButton(getApproveButtonText(fc)) {
          public Dimension getMaximumSize() {
            return new Dimension(MAX_SIZE.width, this.getPreferredSize().height);
          }
        };
    approveButton.setMnemonic(getApproveButtonMnemonic(fc));
    approveButton.setToolTipText(getApproveButtonToolTipText(fc));
    align(approveButton);
    approveButton.setMargin(buttonMargin);
    approveButton.addActionListener(getApproveSelectionAction());
    buttonPanel.add(approveButton);
    buttonPanel.add(Box.createGlue());

    JButton updateButton =
        new JButton(updateButtonText) {
          public Dimension getMaximumSize() {
            return new Dimension(MAX_SIZE.width, this.getPreferredSize().height);
          }
        };
    updateButton.setMnemonic(updateButtonMnemonic);
    updateButton.setToolTipText(updateButtonToolTipText);
    align(updateButton);
    updateButton.setMargin(buttonMargin);
    updateButton.addActionListener(getUpdateAction());
    buttonPanel.add(updateButton);
    buttonPanel.add(Box.createGlue());

    JButton cancelButton =
        new JButton(cancelButtonText) {
          public Dimension getMaximumSize() {
            return new Dimension(MAX_SIZE.width, this.getPreferredSize().height);
          }
        };
    cancelButton.setMnemonic(cancelButtonMnemonic);
    cancelButton.setToolTipText(cancelButtonToolTipText);
    align(cancelButton);
    cancelButton.setMargin(buttonMargin);
    cancelButton.addActionListener(getCancelSelectionAction());
    buttonPanel.add(cancelButton);
    buttonPanel.add(Box.createGlue());

    JButton helpButton =
        new JButton(helpButtonText) {
          public Dimension getMaximumSize() {
            return new Dimension(MAX_SIZE.width, this.getPreferredSize().height);
          }
        };
    helpButton.setMnemonic(helpButtonMnemonic);
    helpButton.setToolTipText(helpButtonToolTipText);
    align(helpButton);
    helpButton.setMargin(buttonMargin);
    helpButton.setEnabled(false);
    buttonPanel.add(helpButton);
    buttonPanel.add(Box.createGlue());

    bottomPanel.add(buttonPanel, BorderLayout.SOUTH);
    if (fc.getControlButtonsAreShown()) {
      fc.add(bottomPanel, BorderLayout.SOUTH);
    }
  }
Beispiel #16
0
    public final void initUI() throws FileNotFoundException, IOException {

      String FileName = "config.txt";
      String DirSeparator = System.getProperty("file.separator");
      File currentDir = new File(".");
      String FilePath = currentDir.getCanonicalPath() + DirSeparator + FileName;

      myProperties = new Properties();
      myProperties.load(new FileInputStream(FilePath));

      setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));

      add(Box.createRigidArea(new Dimension(0, 10)));

      JLabel label = new JLabel();
      label.setAlignmentX(0.5f);
      add(label);

      add(Box.createRigidArea(new Dimension(0, 10)));

      String result = myProperties.getProperty("1");
      if (result == null) result = "0";

      JLabel name = new JLabel("Level 1:  " + result);
      name.setFont(new Font("Serif", Font.BOLD, 13));
      name.setAlignmentX(0.5f);
      add(name);

      result = myProperties.getProperty("2");
      if (result == null) result = "0";
      name = new JLabel("Level 2:  " + result);
      name.setFont(new Font("Serif", Font.BOLD, 13));
      name.setAlignmentX(0.5f);
      add(name);

      result = myProperties.getProperty("3");
      if (result == null) result = "0";
      name = new JLabel("Level 3:  " + result);
      name.setFont(new Font("Serif", Font.BOLD, 13));
      name.setAlignmentX(0.5f);
      add(name);

      result = myProperties.getProperty("4");
      if (result == null) result = "0";
      name = new JLabel("Level 4:  " + result);
      name.setFont(new Font("Serif", Font.BOLD, 13));
      name.setAlignmentX(0.5f);
      add(name);

      result = myProperties.getProperty("5");
      if (result == null) result = "0";
      name = new JLabel("Level 5:  " + result);
      name.setFont(new Font("Serif", Font.BOLD, 13));
      name.setAlignmentX(0.5f);
      add(name);

      myProperties = null;

      add(Box.createRigidArea(new Dimension(0, 50)));

      JButton close = new JButton("Close");
      close.addActionListener(
          new ActionListener() {

            public void actionPerformed(ActionEvent event) {
              dispose();
            }
          });

      close.setAlignmentX(0.5f);
      add(close);

      setModalityType(ModalityType.APPLICATION_MODAL);

      setTitle("Table of records");
      setDefaultCloseOperation(DISPOSE_ON_CLOSE);
      setLocationRelativeTo(null);
      setSize(300, 200);
    }
Beispiel #17
0
  public PlayerWaitingView() {

    this.setOpaque(true);
    this.setLayout(new BorderLayout());
    this.setBorder(BorderFactory.createLineBorder(Color.black, BORDER_WIDTH));

    // set the heading at the top of the pane
    label = new JLabel("Player Waiting View");
    FontUtils.setFont(label, LABEL_TEXT_SIZE);
    this.add(label, BorderLayout.NORTH);

    // create the center panel that displays player info
    center = new JPanel();
    center.setLayout(new BoxLayout(center, BoxLayout.Y_AXIS));
    this.add(center, BorderLayout.CENTER);

    // create the AI panel for the bottom of the pane
    aiPanel = new JPanel();
    aiPanel.setLayout(new BoxLayout(aiPanel, BoxLayout.Y_AXIS));

    // create the AI type panel
    JPanel aiTypePanel = new JPanel();
    aiTypePanel.setLayout(new BoxLayout(aiTypePanel, BoxLayout.X_AXIS));

    aiTypePanel.add(Box.createHorizontalGlue());

    JLabel aiTypeLabel = new JLabel("Select AI Type:");
    FontUtils.setFont(aiTypeLabel, AI_TEXT_SIZE);
    aiTypePanel.add(aiTypeLabel);

    aiTypePanel.add(Box.createRigidArea(new Dimension(5, 0)));

    aiModel = new SpinnerListModel();
    aiChoices = new JSpinner(aiModel);
    ((JSpinner.DefaultEditor) aiChoices.getEditor()).getTextField().setEditable(false);
    FontUtils.setFont(aiChoices, AI_TEXT_SIZE);
    aiTypePanel.add(aiChoices);

    aiTypePanel.add(Box.createHorizontalGlue());

    aiPanel.add(aiTypePanel);

    aiPanel.add(Box.createRigidArea(new Dimension(0, 10)));

    // create the AI button panel
    JPanel aiButtonPanel = new JPanel();
    aiButtonPanel.setLayout(new BoxLayout(aiButtonPanel, BoxLayout.X_AXIS));

    aiButtonPanel.add(Box.createHorizontalGlue());

    addAiButton = new JButton("Add a computer player");
    addAiButton.addActionListener(actionListener);
    FontUtils.setFont(addAiButton, BUTTON_TEXT_SIZE);
    aiButtonPanel.add(addAiButton);

    aiButtonPanel.add(Box.createHorizontalGlue());

    aiPanel.add(aiButtonPanel);

    aiPanel.add(Box.createRigidArea(new Dimension(0, 10)));

    // add the AI panel
    this.add(aiPanel, BorderLayout.SOUTH);
  }
  public SearchPatient(final String type, final int docID) {

    try {
      // "Load" the JDBC driver
      Class.forName("java.sql.Driver");

      // Establish the connection to the database
      String url = "jdbc:mysql://localhost:3306/cse";
      conn = DriverManager.getConnection(url, "root", "admin");
    } catch (Exception e) {
      System.err.println("Got an exception!");
      System.err.println(e.getMessage());
    }

    // Menu
    // MENU ACTIONS

    // Action to view new patient registered
    class NewPatientAction extends AbstractAction {
      private static final long serialVersionUID = 1L;

      public NewPatientAction() {
        putValue(SHORT_DESCRIPTION, "View list of new patients");
      }

      public void actionPerformed(ActionEvent e) {
        ViewRegisteredPatients vp = new ViewRegisteredPatients("new");
        vp.setVisible(true);
        ViewRegisteredPatients.hasNew = false;
      }
    }
    Action newPatientAction = new NewPatientAction();

    // Action to view all patient registered
    class AllPatientAction extends AbstractAction {
      private static final long serialVersionUID = 1L;

      public AllPatientAction() {
        putValue(SHORT_DESCRIPTION, "View list of all patients");
      }

      public void actionPerformed(ActionEvent e) {
        ViewRegisteredPatients vp = new ViewRegisteredPatients("all");
        vp.setVisible(true);
      }
    }
    Action allPatientAction = new AllPatientAction();

    // Action to open Statistical Report
    class StatsReportAction implements MenuListener {
      public void menuSelected(MenuEvent e) {
        StatsReport report = new StatsReport();
        setAlwaysOnTop(false);
        report.setVisible(true);
        report.setAlwaysOnTop(true);
      }

      public void menuDeselected(MenuEvent e) {}

      public void menuCanceled(MenuEvent e) {}
    }

    // Action to open Statistical Report
    class ProfileAction implements MenuListener {
      public void menuSelected(MenuEvent e) {
        Profile profilePage = new Profile("staff", docID, type);
        profilePage.setVisible(true);
        dispose();
      }

      public void menuDeselected(MenuEvent e) {}

      public void menuCanceled(MenuEvent e) {}
    }

    // MENU COMPONENTS
    menu = new JMenuBar();

    menuOp1 = new JMenu();
    menuOp2 = new JMenu();
    menuOp3 = new JMenu();
    menuOp4 = new JMenu();
    menuOp5 = new JMenu();

    menuOp1.setText("Profile");
    menuOp1.addMenuListener(new ProfileAction());

    optionsFrame = new JFrame("Options");

    optionsContainer = new JPanel();
    optionsContainer.setLayout(new BoxLayout(optionsContainer, BoxLayout.Y_AXIS));
    optionsContainer.add(Box.createRigidArea(new Dimension(20, 5)));

    if (type.equals("Doctor")) // if a doctor is logging in
    {
      menuOp2.setText("Patients");
      menuOp3.setText("Appointments Request");
      menuOp4.setText("View Medical Alerts");

      menuItem1 = new JMenuItem("Search Patient");

      menuOp2.add(menuItem1);

      menu.add(menuOp1);
      menu.add(menuOp2);
      menu.add(menuOp3);
      menu.add(menuOp4);

      // optionsFrame
      optionUpdateHCC = new JLabel("Update Healthcare Condition");
      optionUpdateHCC.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
      optionUpdateHCC.addMouseListener(new MouseUpdateHCCListener());

      optionPrescription = new JLabel("e-Prescription");
      optionPrescription.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
      // optionPrescription.addMouseListener(new MousePrescriptionListener());

      optionLabRecord = new JLabel("View Lab Records");
      optionLabRecord.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
      optionLabRecord.addMouseListener(new MouseLabRecordListener());

      optionUpdateHCR = new JLabel("Update Healthcare Records");
      optionUpdateHCR.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
      optionUpdateHCR.addMouseListener(new MouseUpdateHCRListener());

      // add option to container
      optionsContainer.add(optionUpdateHCC);
      optionsContainer.add(Box.createRigidArea(new Dimension(20, 5)));
      optionsContainer.add(optionPrescription);
      optionsContainer.add(Box.createRigidArea(new Dimension(20, 5)));
      optionsContainer.add(optionLabRecord);
      optionsContainer.add(Box.createRigidArea(new Dimension(20, 5)));
      optionsContainer.add(optionLabRecord);
      optionsContainer.add(Box.createRigidArea(new Dimension(20, 5)));
      optionsContainer.add(optionUpdateHCR);
    } else if (type.equals("HSP")) // if the HSP is logging in
    {
      menuOp2.setText("Patients");
      menuOp3.setText("Appointment Request");
      menuOp4.setText("View Medical Alerts");
      menuOp5.setText("Generate Statistical Report");
      menuOp5.addMenuListener(new StatsReportAction());

      menuItem1 = new JMenuItem("Search Patient");
      menuOp6 = new JMenu("List of Registered Patient");
      menuOp6.setMnemonic(KeyEvent.VK_S);

      menuItem2 = new JMenuItem(newPatientAction);
      menuItem2.setText("List of New Registered Patient");
      menuItem3 = new JMenuItem(allPatientAction);
      menuItem3.setText("List of All Registered Patient");

      menuOp2.add(menuItem1);
      menuOp2.add(menuOp6);
      menuOp6.add(menuItem2);
      menuOp6.add(menuItem3);

      menu.add(menuOp1);
      menu.add(menuOp2);
      menu.add(menuOp3);
      menu.add(menuOp4);
      menu.add(menuOp5);

      // optionsFrame
      optionUpdateHCC = new JLabel("Update Healthcare Condition");
      optionUpdateHCC.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
      optionUpdateHCC.addMouseListener(new MouseUpdateHCCListener());

      optionLabRecord = new JLabel("View Lab Records");
      optionLabRecord.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
      optionLabRecord.addMouseListener(new MouseLabRecordListener());

      optionHCR = new JLabel("Upload Healthcare Records");
      optionHCR.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
      optionHCR.addMouseListener(new MouseUploadHCRListener());

      optionUpdateHCR = new JLabel("Update Healthcare Records");
      optionUpdateHCR.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
      optionUpdateHCR.addMouseListener(new MouseUpdateHCRListener());

      // add option to container
      optionsContainer.add(optionUpdateHCC);
      optionsContainer.add(Box.createRigidArea(new Dimension(20, 5)));
      optionsContainer.add(optionLabRecord);
      optionsContainer.add(Box.createRigidArea(new Dimension(20, 5)));
      optionsContainer.add(optionLabRecord);
      optionsContainer.add(Box.createRigidArea(new Dimension(20, 5)));
      optionsContainer.add(optionHCR);
      optionsContainer.add(Box.createRigidArea(new Dimension(20, 5)));
      optionsContainer.add(optionUpdateHCR);
    } else if (type.equals("Pharmacist")) // if the Pharmacist is logging in
    {
      menuOp2.setText("Patients");

      menuItem1 = new JMenuItem("Search Patients");

      menuOp2.add(menuItem1);

      menu.add(menuOp1);
      menu.add(menuOp2);

      // optionsFrame
      optionViewPrescription = new JLabel("View e-Prescription");
      optionViewPrescription.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
      optionViewPrescription.addMouseListener(new MouseViewPrescriptionListener());

      // add option to container
      optionsContainer.add(optionViewPrescription);

    } else if (type.equals("Nurse")) // if the nurse is logging in
    {
      menuOp2.setText("Patients");

      menuItem1 = new JMenuItem("Search Patients");

      menuOp2.add(menuItem1);

      menu.add(menuOp1);
      menu.add(menuOp2);

      // optionsFrame
      optionUpdateHCR = new JLabel("Update Healthcare Records");
      optionUpdateHCR.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
      optionUpdateHCR.addMouseListener(new MouseUpdateHCRListener());

      // add option to container
      optionsContainer.add(optionUpdateHCR);
    }

    // Labels
    firstNameLabel = new JLabel(" First name:"); // first name label
    lastNameLabel = new JLabel("Last name:"); // last name label
    patientListLabel = new JLabel("Patient List:"); // patient list label

    // Text Fields
    firstNameField = new JTextField(10); // first name text field
    lastNameField = new JTextField(10); // last name text field

    // Buttons
    searchButton = new JButton("Search"); // search button
    searchButton.addActionListener(new SearchButtonListener()); // add listener

    selectButton = new JButton("Select");
    selectButton.addActionListener(new SelectButtonListener()); // add listener

    cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(new CancelButtonListener()); // add listener

    // JPanels
    firstNamePanel = new JPanel(); // First name panel
    firstNamePanel.add(firstNameLabel);
    firstNamePanel.add(firstNameField);

    lastNamePanel = new JPanel(); // Last name panel
    lastNamePanel.add(lastNameLabel);
    lastNamePanel.add(lastNameField);

    patientInfoPanel = new JPanel();
    patientInfoPanel.setLayout(new BoxLayout(patientInfoPanel, BoxLayout.X_AXIS));
    patientInfoPanel.add(firstNamePanel);
    patientInfoPanel.add(lastNamePanel);
    patientInfoPanel.add(searchButton);

    buttonPanel = new JPanel(); // button panel
    buttonPanel.add(selectButton);
    buttonPanel.add(cancelButton);

    // Patient List
    patientVector = new Vector(); // Vector of Patient objects
    patientList =
        new JList(patientVector); // creates a JList that show the content of the recordVector

    scrollPatientList = new JScrollPane(patientList); // add scroll option to the list
    patientList.setSelectionMode(
        ListSelectionModel.SINGLE_SELECTION); // Allow the selection of only one item at a time

    String[] patients = new String[1000000];

    // Populates the patient list with the patients from the database
    if (type.equals("Doctor")) {
      int i = 0;
      try {
        // checks if the patient is a patient of the doctor logged
        statement = conn.createStatement();
        rs =
            statement.executeQuery(
                "SELECT * FROM appointments WHERE `docID`='" + docID + "' ORDER BY `patientID`");

        while (rs.next()) {
          int patientID = rs.getInt("patientID");
          patients[i] = String.valueOf(patientID);

          i++;
        }

        String[] patientSet =
            (String[]) new HashSet(Arrays.asList(patients)).toArray(new String[0]);

        // gets information from the specific set of patients
        for (int j = 0; j < patientSet.length; j++) {
          statement = conn.createStatement();
          rs =
              statement.executeQuery(
                  "SELECT * FROM patient WHERE `idpatient`='" + patientSet[j] + "';");

          while (rs.next()) {
            Patient obj = new Patient();
            obj.setFirstName(rs.getString("fname"));
            obj.setLastName(rs.getString("lname"));
            obj.setDOB(rs.getString("dob"));
            obj.setPatientId(Integer.parseInt(patientSet[j]));

            patientVector.add(obj);
          }
        }

      } catch (Exception e) {
        System.err.println("Got an exception! ");
        System.err.println(e.getMessage());
        System.err.println(e);
      }
    } else {
      try {
        statement = conn.createStatement();
        rs = statement.executeQuery("SELECT * FROM patient ORDER BY fname");

        while (rs.next()) {
          Patient obj = new Patient();
          obj.setFirstName(rs.getString("fname"));
          obj.setLastName(rs.getString("lname"));
          obj.setDOB(rs.getString("dob"));
          obj.setPatientId(rs.getInt("idpatient"));

          patientVector.add(obj);
        }
      } catch (Exception e) {
        System.err.println("Got an exception! ");
        System.err.println(e.getMessage());
      }
    }

    searchVector = new Vector();

    // set options frame
    optionsFrame.add(optionsContainer);
    optionsFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); // close the window on close
    optionsFrame.setSize(300, 150); // set size of window
    optionsFrame.setLocation(600, 280);
    optionsFrame.setVisible(false);

    searchPanel = new JPanel();
    searchPanel.setLayout(new BoxLayout(searchPanel, BoxLayout.Y_AXIS));
    searchPanel.add(patientInfoPanel);
    searchPanel.add(patientListLabel);
    searchPanel.add(scrollPatientList);
    searchPanel.add(buttonPanel);

    Border padding = BorderFactory.createEmptyBorder(20, 20, 10, 10);
    searchPanel.setBorder(padding);

    setJMenuBar(menu);
    add(searchPanel);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setSize(1200, 580);
  }
  /** Initialize the common user interface components. */
  private void initUI() {
    /* initialize fields */
    {
      pFileSeqPanels = new TreeMap<FileSeq, JFileSeqPanel>();
    }

    /* initialize the popup menus */
    {
      initBasicMenus(true, false);
      updateMenuToolTips();
    }

    /* initialize the panel components */
    {
      setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

      /* header */
      {
        pApplyToolTipText = "Replace the working area files with the selected checked-in files.";
        pUnApplyToolTipText = "There are no unsaved changes to Apply at this time.";

        JPanel panel = initHeader(true);
        add(panel);
      }

      add(Box.createRigidArea(new Dimension(0, 4)));

      /* full node name */
      {
        LinkedList<Component> extra = new LinkedList<Component>();
        extra.add(Box.createRigidArea(new Dimension(4, 0)));
        {
          JButton btn = new JButton();
          pSeqLayoutButton = btn;
          btn.setName(pIsListLayout ? "ListLayoutButton" : "TabbedLayoutButton");

          Dimension size = new Dimension(19, 19);
          btn.setMinimumSize(size);
          btn.setMaximumSize(size);
          btn.setPreferredSize(size);

          btn.setActionCommand("seq-layout-changed");
          btn.addActionListener(this);

          extra.add(btn);
        }

        initNameField(this, extra);

        pNodeNameField.setFocusable(true);
        pNodeNameField.addKeyListener(this);
        pNodeNameField.addMouseListener(this);
      }

      add(Box.createRigidArea(new Dimension(0, 4)));

      {
        JTabbedPane tab = new JTabbedPane();
        pFileSeqsTab = tab;
        tab.setVisible(!pIsListLayout);
        add(tab);
      }

      {
        Box vbox = new Box(BoxLayout.Y_AXIS);
        pFileSeqsBox = vbox;

        {
          JScrollPane scroll = UIFactory.createVertScrollPane(vbox);
          pFileSeqsScroll = scroll;
          scroll.setVisible(!pIsListLayout);

          add(scroll);
        }
      }

      Dimension size = new Dimension(sSize + 22, 120);
      setMinimumSize(size);
      setPreferredSize(size);

      setFocusable(true);
      addKeyListener(this);
      addMouseListener(this);
    }

    updateNodeStatus(null, null, null);
  }
  /**
   * Draws the GUI that allows a user to select assets to be updated.
   *
   * @return true if the user made a valid choice of assets to replace.
   * @throws PipelineException
   */
  private boolean buildUpdateGUI() throws PipelineException {
    Box finalBox = new Box(BoxLayout.Y_AXIS);
    top = new Box(BoxLayout.Y_AXIS);

    JScrollPane scroll;

    {
      scroll = new JScrollPane(finalBox);

      scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
      scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

      Dimension size = new Dimension(sVSize + sVSize + sTSize + 52, 500);
      scroll.setMinimumSize(size);
      scroll.setPreferredSize(size);
      scroll.getViewport().setScrollMode(JViewport.BACKINGSTORE_SCROLL_MODE);
    }

    /* query the user */
    diag = new JToolDialog("Propagate Asset", scroll, "Continue");

    areas = mclient.getWorkingAreas();
    {
      Box hbox = new Box(BoxLayout.X_AXIS);
      Component comps[] = UIFactory.createTitledPanels();
      JPanel tpanel = (JPanel) comps[0];
      JPanel vpanel = (JPanel) comps[1];
      {
        userField =
            UIFactory.createTitledCollectionField(
                tpanel,
                "User:"******"The user whose area the node is being created in.");
        userField.setActionCommand("user");
        userField.setSelected(PackageInfo.sUser);
        userField.addActionListener(this);
      }
      UIFactory.addVerticalSpacer(tpanel, vpanel, 3);
      {
        viewField =
            UIFactory.createTitledCollectionField(
                tpanel,
                "View:",
                sTSize,
                vpanel,
                areas.get(PackageInfo.sUser),
                diag,
                sVSize,
                "The working area to create the nodes in.");
        viewField.setActionCommand("wrap");
        viewField.addActionListener(this);
      }
      UIFactory.addVerticalSpacer(tpanel, vpanel, 3);
      {
        toolsetField =
            UIFactory.createTitledCollectionField(
                tpanel,
                "Toolset:",
                sTSize,
                vpanel,
                mclient.getActiveToolsetNames(),
                diag,
                sVSize,
                "The toolset to set on all the nodes.");
        toolsetField.setSelected(mclient.getDefaultToolsetName());
        toolsetField.setActionCommand("wrap");
        toolsetField.addActionListener(this);
      }
      UIFactory.addVerticalSpacer(tpanel, vpanel, 3);

      w =
          new Wrapper(
              userField.getSelected(),
              viewField.getSelected(),
              toolsetField.getSelected(),
              mclient);

      charList = SonyConstants.getAssetList(w, project, AssetType.CHARACTER);
      setsList = SonyConstants.getAssetList(w, project, AssetType.SET);
      propsList = SonyConstants.getAssetList(w, project, AssetType.PROP);

      {
        projectField =
            UIFactory.createTitledCollectionField(
                tpanel,
                "Project:",
                sTSize,
                vpanel,
                Globals.getChildrenDirs(w, "/projects"),
                diag,
                sVSize,
                "All the projects in pipeline.");
        projectField.setActionCommand("proj");
        projectField.addActionListener(this);
      }
      hbox.add(comps[2]);
      top.add(hbox);
    }

    {
      Box vbox = new Box(BoxLayout.Y_AXIS);
      Box hbox = new Box(BoxLayout.X_AXIS);
      JButton button = new JButton("Propagate Additional Asset");
      button.setName("ValuePanelButton");
      button.setRolloverEnabled(false);
      button.setFocusable(false);
      Dimension d = new Dimension(sVSize, 25);
      button.setPreferredSize(d);
      button.setMinimumSize(d);
      button.setMaximumSize(new Dimension(Integer.MAX_VALUE, 25));

      vbox.add(Box.createRigidArea(new Dimension(0, 5)));
      hbox.add(button);
      hbox.add(Box.createRigidArea(new Dimension(4, 0)));
      vbox.add(hbox);
      vbox.add(Box.createRigidArea(new Dimension(0, 5)));

      button.setActionCommand("add");
      button.addActionListener(this);

      top.add(vbox);
    }

    list = new Box(BoxLayout.Y_AXIS);
    test = new JDrawer("Propagate Additional Asset", list, false);

    top.add(test);
    list.add(assetChoiceBox());

    finalBox.add(top);

    {
      JPanel spanel = new JPanel();
      spanel.setName("Spacer");
      spanel.setMinimumSize(new Dimension(sTSize + sVSize, 7));
      spanel.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
      spanel.setPreferredSize(new Dimension(sTSize + sVSize, 7));
      finalBox.add(spanel);
    }

    diag.setVisible(true);
    if (diag.wasConfirmed()) {
      // get list of things to change.
      for (Component comp : list.getComponents()) {
        if (comp instanceof Box) {
          Box can = (Box) comp;
          JCollectionField oldOne = (JCollectionField) can.getComponent(2);
          JCollectionField newOne = (JCollectionField) can.getComponent(4);

          TreeMap<String, String> assetList = new TreeMap<String, String>();
          assetList.putAll(charList);
          assetList.putAll(propsList);
          assetList.putAll(setsList);

          String key = assetList.get(oldOne.getSelected()) + lr;
          String value = assetList.get(newOne.getSelected()) + lr;
          if (!key.equals(value)) {
            potentialUpdates.add(key);
            pAssetManager.put(key, new AssetInfo(key, value));
          }
          // System.err.println("bUG: "+pAssetManager.get(key).getHiLoResShots());
        }
      }

      if (!pAssetManager.isEmpty()) return true;
    }
    return false;
  } // end buildReplacementGUI
  /** Construct a new dialog. */
  public JExecDetailsDialog() {
    super("Execution Details");

    /* create dialog body components */
    {
      JPanel body = new JPanel();
      body.setLayout(new BoxLayout(body, BoxLayout.Y_AXIS));

      {
        JPanel panel = new JPanel();
        panel.setName("MainDialogPanel");
        panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));

        /* working directory */
        {
          panel.add(UIFactory.createPanelLabel("Working Directory:"));

          panel.add(Box.createRigidArea(new Dimension(0, 4)));

          JTextField field = UIFactory.createTextField(null, 100, JLabel.LEFT);
          pWorkingDirField = field;

          panel.add(field);
        }

        body.add(panel);
      }

      {
        JPanel panel = new JPanel();
        panel.setName("HorizontalBar");

        Dimension size = new Dimension(100, 7);
        panel.setPreferredSize(size);
        panel.setMinimumSize(size);
        panel.setMaximumSize(new Dimension(Integer.MAX_VALUE, 7));

        body.add(panel);
      }

      /* command line */
      JPanel above = new JPanel();
      {
        above.setName("MainDialogPanel");
        above.setLayout(new BoxLayout(above, BoxLayout.Y_AXIS));

        {
          Box hbox = new Box(BoxLayout.X_AXIS);

          hbox.add(Box.createRigidArea(new Dimension(4, 0)));

          {
            JLabel label = new JLabel("X");
            pCommandLineLabel = label;

            label.setName("PanelLabel");

            hbox.add(label);
          }

          hbox.add(Box.createHorizontalGlue());

          above.add(hbox);
        }

        above.add(Box.createRigidArea(new Dimension(0, 4)));

        {
          JTextArea area = new JTextArea(null, 5, 70);
          pCommandLineArea = area;

          area.setName("CodeTextArea");
          area.setLineWrap(true);
          area.setWrapStyleWord(true);
          area.setEditable(false);
        }

        {
          JScrollPane scroll =
              UIFactory.createScrollPane(
                  pCommandLineArea,
                  ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER,
                  ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
                  new Dimension(100, 27),
                  null,
                  null);

          above.add(scroll);
        }
      }

      /* environment */
      JPanel below = new JPanel();
      {
        below.setName("MainDialogPanel");
        below.setLayout(new BoxLayout(below, BoxLayout.Y_AXIS));

        {
          Box hbox = new Box(BoxLayout.X_AXIS);

          hbox.add(Box.createRigidArea(new Dimension(4, 0)));

          {
            JLabel label = new JLabel("X");
            pEnvLabel = label;

            label.setName("PanelLabel");

            hbox.add(label);
          }

          hbox.add(Box.createHorizontalGlue());

          below.add(hbox);
        }

        below.add(Box.createRigidArea(new Dimension(0, 4)));

        Component comps[] = UIFactory.createTitledPanels();
        {
          JPanel tpanel = (JPanel) comps[0];
          JPanel vpanel = (JPanel) comps[1];

          tpanel.add(Box.createRigidArea(new Dimension(sTSize, 0)));
          vpanel.add(Box.createHorizontalGlue());
        }

        {
          pEnvScroll =
              UIFactory.createScrollPane(
                  comps[2],
                  ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER,
                  ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
                  new Dimension(100, 50),
                  new Dimension(100, 300),
                  null);

          below.add(pEnvScroll);
        }
      }

      {
        JVertSplitPanel split = new JVertSplitPanel(above, below);
        split.setResizeWeight(0.0);
        split.setAlignmentX(0.5f);

        body.add(split);
      }

      super.initUI("X", body, null, null, null, "Close", null);
    }
  }
  /** Construct a new dialog. */
  public JArchiveDialog() {
    super("Archive Tool");

    pPrivilegeDetails = new PrivilegeDetails();

    /* create dialog body components */
    {
      JPanel cpanel = new JPanel();
      {
        cpanel.setName("ButtonDialogPanel");
        cpanel.setLayout(new BoxLayout(cpanel, BoxLayout.Y_AXIS));

        cpanel.add(UIFactory.createPanelLabel("Candidate Versions:"));

        cpanel.add(Box.createRigidArea(new Dimension(0, 4)));

        {
          ArchiveCandidateTableModel model = new ArchiveCandidateTableModel();
          pCandidateTableModel = model;

          JTablePanel tpanel = new JTablePanel(model);
          pCandidateTablePanel = tpanel;

          cpanel.add(tpanel);
        }

        cpanel.add(Box.createRigidArea(new Dimension(0, 5)));

        {
          Box hbox = new Box(BoxLayout.X_AXIS);

          hbox.add(Box.createHorizontalGlue());
          hbox.add(Box.createRigidArea(new Dimension(10, 0)));

          {
            JButton btn =
                UIFactory.createDialogButton(
                    "Search...",
                    "candidate-search",
                    this,
                    "Search for new candidate checked-in versions to archive.");

            hbox.add(btn);
          }

          hbox.add(Box.createRigidArea(new Dimension(20, 0)));

          {
            JButton btn =
                UIFactory.createDialogButton(
                    "Clear",
                    "clear-candidate",
                    this,
                    "Clear the displayed candidate checked-in versions.");

            hbox.add(btn);
          }

          hbox.add(Box.createRigidArea(new Dimension(10, 0)));
          hbox.add(Box.createHorizontalGlue());

          cpanel.add(hbox);
        }
      }

      JPanel apanel = new JPanel();
      {
        apanel.setName("ButtonDialogPanel");
        apanel.setLayout(new BoxLayout(apanel, BoxLayout.Y_AXIS));

        {
          Box box = new Box(BoxLayout.X_AXIS);

          box.add(Box.createRigidArea(new Dimension(4, 0)));

          {
            JLabel label = new JLabel("Versions to Archive:");
            label.setName("PanelLabel");
            box.add(label);
          }

          box.add(Box.createHorizontalGlue());

          {
            JLabel label = new JLabel("Total Size: ???");
            pArchiveSizeLabel = label;
            label.setName("PanelLabel");
            box.add(label);
          }

          box.add(Box.createRigidArea(new Dimension(23, 0)));

          apanel.add(box);
        }

        apanel.add(Box.createRigidArea(new Dimension(0, 4)));

        {
          NodeVersionSizeTableModel model = new NodeVersionSizeTableModel(880);
          pArchiveTableModel = model;

          JTablePanel tpanel = new JTablePanel(model);
          pArchiveTablePanel = tpanel;

          apanel.add(tpanel);
        }

        apanel.add(Box.createRigidArea(new Dimension(0, 5)));

        {
          Box hbox = new Box(BoxLayout.X_AXIS);

          hbox.add(Box.createHorizontalGlue());
          hbox.add(Box.createRigidArea(new Dimension(10, 0)));

          {
            JButton btn =
                UIFactory.createDialogButton(
                    "Add",
                    "add-archive",
                    this,
                    "Add the selected candidate versions to the list of versions to be "
                        + "archived.");

            hbox.add(btn);
          }

          hbox.add(Box.createRigidArea(new Dimension(10, 0)));

          {
            JButton btn =
                UIFactory.createDialogButton(
                    "Add All",
                    "add-all-archive",
                    this,
                    "Add all candidate versions to the list of versions to be archived.");

            hbox.add(btn);
          }

          hbox.add(Box.createRigidArea(new Dimension(20, 0)));

          {
            JButton btn =
                UIFactory.createDialogButton(
                    "Remove",
                    "remove-archive",
                    this,
                    "Remove the selected versions from the list of versions to be archived.");

            hbox.add(btn);
          }

          hbox.add(Box.createRigidArea(new Dimension(10, 0)));

          {
            JButton btn =
                UIFactory.createDialogButton(
                    "Clear",
                    "remove-all-archive",
                    this,
                    "Clear the list of versions to be archived.");

            hbox.add(btn);
          }

          hbox.add(Box.createRigidArea(new Dimension(20, 0)));

          {
            JButton btn =
                UIFactory.createDialogButton(
                    "Calc Sizes",
                    "calc-archive",
                    this,
                    "Calculate the amount of disk space needed to archive the files "
                        + "associated with the checked-in versions.");

            hbox.add(btn);
          }

          hbox.add(Box.createRigidArea(new Dimension(10, 0)));
          hbox.add(Box.createHorizontalGlue());

          apanel.add(hbox);
        }
      }

      JSplitPane body = new JVertSplitPanel(cpanel, apanel);
      body.setAlignmentX(0.5f);

      String extra[][] = {{"Archive...", "archive"}};

      JButton btns[] = super.initUI("Archive Tool:", body, null, null, extra, "Close", null);

      pArchiveButton = btns[0];
      pArchiveButton.setEnabled(false);

      updatePanel();
      pack();
    }

    pQueryDialog = new JArchiveQueryDialog(this);
    pArchiveParamsDialog = new JArchiveParamsDialog(this);
  }
Beispiel #23
0
  public ContextEditor(Context cntxt) {
    super("Edit User Context: " + localFileName(cntxt));
    ctxt = cntxt;
    windowNum = ctxt.languageName + " Context Editor";
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    listener = new CEListener(this);

    JPanel nameBox = new JPanel();
    nameBox.setLayout(new BoxLayout(nameBox, BoxLayout.LINE_AXIS));
    name = new JTextField(ctxt.languageName, 28);
    name.setMaximumSize(new Dimension(225, 22));
    name.addFocusListener(
        new java.awt.event.FocusAdapter() {

          public void focusLost(java.awt.event.FocusEvent evt) {
            nameFocusLost(evt);
          }
        });

    JLabel nameLabel = new JLabel("Language Name: ");
    nameBox.add(nameLabel);
    nameBox.add(name);

    JPanel folderBox = new JPanel();
    folderBox.setLayout(new BoxLayout(folderBox, BoxLayout.LINE_AXIS));
    folder = new JTextField(ctxt.editDirectory);
    folder.setMaximumSize(new Dimension(225, 22));
    //        folder.addActionListener(listener);
    //        folder.setActionCommand("folder edit");
    folder.addFocusListener(
        new java.awt.event.FocusAdapter() {

          public void focusLost(java.awt.event.FocusEvent evt) {
            folderFocusLost(evt);
          }
        });

    JLabel folderLabel = new JLabel("SILK file folder: ");
    folderBox.add(folderLabel);
    folderBox.add(folder);

    JPanel nameFolderBox = new JPanel();
    nameFolderBox.setLayout(new BoxLayout(nameFolderBox, BoxLayout.PAGE_AXIS));
    nameBox.setAlignmentX(0.5f);
    nameFolderBox.add(nameBox);
    nameFolderBox.add(Box.createRigidArea(new Dimension(0, 4)));
    nameFolderBox.add(folderBox);
    nameFolderBox.setAlignmentX(0.5f);

    buildPopulationBox();

    JPanel btnBoxUDPs = new JPanel(), subBoxUDP = new JPanel();
    btnBoxUDPs.setLayout(new BoxLayout(btnBoxUDPs, BoxLayout.PAGE_AXIS));
    subBoxUDP.setLayout(new BoxLayout(subBoxUDP, BoxLayout.LINE_AXIS));
    int numUDPs = 0;
    if (ctxt.userDefinedProperties != null) {
      numUDPs = ctxt.userDefinedProperties.size();
    }
    String plur = "ies";
    if (numUDPs == 1) {
      plur = "y";
    }
    JLabel udpLabel = new JLabel("Has " + numUDPs + " User-Defined Propert" + plur);
    subBoxUDP.add(udpLabel);
    JButton addUDP = new JButton("Add UDP");
    addUDP.setActionCommand("add UDP");
    addUDP.addActionListener(listener);
    subBoxUDP.add(addUDP);
    btnBoxUDPs.add(subBoxUDP);
    if (numUDPs > 0) {
      Dimension sizer = new Dimension(250, 50);
      String[] udpMenu = genUDPMenu();
      UDPick = new JComboBox(udpMenu);
      UDPick.addActionListener(listener);
      UDPick.setActionCommand("view/edit UDP");
      UDPick.setMinimumSize(sizer);
      UDPick.setMaximumSize(sizer);
      UDPick.setBorder(
          BorderFactory.createTitledBorder(
              BorderFactory.createLineBorder(Color.blue), "View/Edit UDPs"));
      btnBoxUDPs.add(UDPick);
    } //  end of if-any-UDPs-exist

    JPanel domThs = new JPanel();
    domThs.setLayout(new BoxLayout(domThs, BoxLayout.PAGE_AXIS));
    domThs.setBorder(
        BorderFactory.createTitledBorder(
            BorderFactory.createLineBorder(Color.blue), "Kinship System Domain Theories"));
    domThs.setAlignmentX(0.5f);
    JPanel dtRefBtnBox = new JPanel();
    dtRefBtnBox.setLayout(new BoxLayout(dtRefBtnBox, BoxLayout.LINE_AXIS));
    dtRefBtnBox.setAlignmentX(0.0f);
    JLabel dtRefLabel = new JLabel("Terms of Reference ");
    dtRefBtnBox.add(dtRefLabel);
    if (ctxt.domTheoryRefExists()) {
      JButton dtRefEdit = new JButton("Edit Theory");
      dtRefEdit.setActionCommand("edit dtRef");
      dtRefEdit.addActionListener(listener);
      dtRefBtnBox.add(dtRefEdit);
      //            JButton dtRefDelete = new JButton("Delete Theory");
      //            dtRefDelete.setActionCommand("dtRef delete");
      //            dtRefDelete.addActionListener(listener);
      //            dtRefBtnBox.add(dtRefDelete);
    } //  end of if-dt-exists
    else { //  if does not exist
      JLabel dtRefNone = new JLabel("< None >");
      dtRefBtnBox.add(dtRefNone);
      //            JButton dtRefAdd = new JButton("Add Theory");
      //            dtRefAdd.setActionCommand("dtRef add");
      //            dtRefAdd.addActionListener(listener);
      //            dtRefBtnBox.add(dtRefAdd);
    } //  end of does-not-exist
    domThs.add(dtRefBtnBox);

    JPanel dtAddrBtnBox = new JPanel();
    dtAddrBtnBox.setLayout(new BoxLayout(dtAddrBtnBox, BoxLayout.LINE_AXIS));
    dtAddrBtnBox.setAlignmentX(0.0f);
    JLabel dtAddrLabel = new JLabel("Terms of Address ");
    dtAddrBtnBox.add(dtAddrLabel);
    if (ctxt.domTheoryAdrExists()) {
      JButton dtAddrEdit = new JButton("Edit Theory");
      dtAddrEdit.setActionCommand("edit dtAddr");
      dtAddrEdit.addActionListener(listener);
      dtAddrBtnBox.add(dtAddrEdit);
      //            JButton dtAddrViewList = new JButton("Delete Theory");
      //            dtAddrViewList.setActionCommand("dtAddr delete");
      //            dtAddrViewList.addActionListener(listener);
      //            dtAddrBtnBox.add(dtAddrViewList);
    } //  end of if-dt-exists
    else { //  if does not exist
      JLabel dtAddrNone = new JLabel("< None >");
      dtAddrBtnBox.add(dtAddrNone);
      //            JButton dtAddrAdd = new JButton("Add Theory");
      //            dtAddrAdd.setActionCommand("dtAddr add");
      //            dtAddrAdd.addActionListener(listener);
      //            dtAddrBtnBox.add(dtAddrAdd);
    } //  end of does-not-exist
    domThs.add(dtAddrBtnBox);
    // End of the left hand portion
    // Right hand portion follows. it is narrower.

    JPanel polyBox = new JPanel();
    polyBox.setLayout(new BoxLayout(polyBox, BoxLayout.PAGE_AXIS));
    polyBox.setAlignmentX(0.5f);
    JLabel polyLabelA = new JLabel("Polygamy");
    JLabel polyLabelB = new JLabel("Permitted?");
    JRadioButton yesPoly = new JRadioButton("Yes");
    yesPoly.setActionCommand("polygamy yes");
    yesPoly.addActionListener(listener);
    JRadioButton noPoly = new JRadioButton("No");
    noPoly.setActionCommand("polygamy no");
    noPoly.addActionListener(listener);
    if (cntxt.polygamyPermit) {
      yesPoly.setSelected(true);
    } else {
      noPoly.setSelected(true);
    }
    ButtonGroup polyBtns = new ButtonGroup();
    polyBtns.add(yesPoly);
    polyBtns.add(noPoly);
    polyBox.add(polyLabelA);
    polyBox.add(polyLabelB);
    polyBox.add(yesPoly);
    polyBox.add(noPoly);

    JPanel matrixBox = new JPanel();
    matrixBox.setLayout(new BoxLayout(matrixBox, BoxLayout.PAGE_AXIS));
    matrixBox.setAlignmentX(0.5f);
    JLabel matrixLabelA = new JLabel("Kin Term Matrix");
    JLabel matrixLabelC = new JLabel(ctxt.indSerNumGen + " rows");
    JLabel matrixLabelD = new JLabel(ctxt.ktm.numberOfKinTerms() + " terms");
    matrixLabelA.setAlignmentX(0.5f);
    matrixLabelC.setAlignmentX(0.5f);
    matrixLabelD.setAlignmentX(0.5f);
    JButton matrixEditBtn = new JButton("Edit Matrix");
    matrixEditBtn.setEnabled(false);
    matrixEditBtn.setActionCommand("edit matrix");
    matrixEditBtn.addActionListener(listener);
    matrixEditBtn.setAlignmentX(0.5f);
    matrixBox.add(matrixLabelA);
    matrixBox.add(matrixLabelC);
    matrixBox.add(matrixLabelD);
    matrixBox.add(matrixEditBtn);

    JPanel distinctBox = new JPanel();
    distinctBox.setLayout(new BoxLayout(distinctBox, BoxLayout.PAGE_AXIS));
    distinctBox.setAlignmentX(0.5f);
    JLabel distinctLabelA = new JLabel("Distinct Terms");
    JLabel distinctLabelB = new JLabel("of Address");
    distinctLabelA.setAlignmentX(0.5f);
    distinctLabelB.setAlignmentX(0.5f);
    JRadioButton yesDistinct = new JRadioButton("Yes");
    yesDistinct.setActionCommand("distinct yes");
    yesDistinct.addActionListener(listener);
    JRadioButton noDistinct = new JRadioButton("No");
    noDistinct.setActionCommand("distinct no");
    noDistinct.addActionListener(listener);
    yesDistinct.setAlignmentX(0.5f);
    noDistinct.setAlignmentX(0.5f);
    if (ctxt.distinctAdrTerms) {
      yesDistinct.setSelected(true);
    } else {
      noDistinct.setSelected(true);
    }
    ButtonGroup distinctBtns = new ButtonGroup();
    distinctBtns.add(yesDistinct);
    distinctBtns.add(noDistinct);
    distinctBox.add(distinctLabelA);
    distinctBox.add(distinctLabelB);
    distinctBox.add(yesDistinct);
    distinctBox.add(noDistinct);

    /*
     * NOTE: It should be possible to put all these elements directly into
     * the ContentPane. But that doesn't work; the layout is truly ugly and
     * stuff gets stacked on top of other stuff. What works is to put
     * everything into a JPanel with BoxLayout. Then put the JPanel into
     * ContentPane.
     */
    JPanel leftCol = new JPanel();
    leftCol.setLayout(new BoxLayout(leftCol, BoxLayout.PAGE_AXIS));
    leftCol.add(nameFolderBox);
    leftCol.add(Box.createRigidArea(new Dimension(0, 4)));
    leftCol.add(populationBox);
    leftCol.add(Box.createRigidArea(new Dimension(0, 8)));
    leftCol.add(btnBoxUDPs);
    leftCol.add(Box.createRigidArea(new Dimension(0, 8)));
    leftCol.add(domThs);
    leftCol.add(new JLabel(" "));

    JPanel rightCol = new JPanel();
    rightCol.setLayout(new BoxLayout(rightCol, BoxLayout.PAGE_AXIS));
    rightCol.setBorder(
        BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.blue), "Options"));
    rightCol.add(Box.createRigidArea(new Dimension(0, 20)));
    rightCol.add(polyBox);
    rightCol.add(Box.createRigidArea(new Dimension(0, 20)));
    rightCol.add(matrixBox);
    int high = (numUDPs > 0 ? 120 : 20);
    rightCol.add(Box.createRigidArea(new Dimension(0, high)));
    rightCol.add(distinctBox);

    JPanel commentBox = new JPanel();
    commentBox.setLayout(new BoxLayout(commentBox, BoxLayout.PAGE_AXIS));
    commentBox.setBorder(
        BorderFactory.createTitledBorder(
            BorderFactory.createLineBorder(Color.blue), "Notes on this culture:"));
    JScrollPane commentsPane = new JScrollPane();
    comments = new JTextArea();
    comments.setColumns(20);
    comments.setEditable(true);
    comments.setRows(3);
    comments.setText(PersonPanel.restoreLineBreaks(ctxt.comments));
    comments.getDocument().addDocumentListener(new CommentListener());
    commentsPane.setViewportView(comments);
    commentBox.add(commentsPane);

    JPanel guts = new JPanel(); // Holds the guts of this window
    guts.setLayout(new BoxLayout(guts, BoxLayout.LINE_AXIS));
    guts.add(leftCol);
    guts.add(Box.createRigidArea(new Dimension(10, 4)));
    guts.add(rightCol);

    JPanel wholeThing = new JPanel();
    wholeThing.setLayout(new BoxLayout(wholeThing, BoxLayout.PAGE_AXIS));
    wholeThing.add(Box.createRigidArea(new Dimension(0, 4)));
    wholeThing.add(guts);
    wholeThing.add(Box.createRigidArea(new Dimension(0, 8)));
    wholeThing.add(commentBox);
    wholeThing.add(Box.createRigidArea(new Dimension(0, 4)));

    getContentPane().add(wholeThing);

    addInternalFrameListener(this);
    setSize(600, 620);
    setVisible(true);
  } //  end of ContextEditor constructor