예제 #1
0
    public AddElementDialog(MapFilterModel model) {
      super(
          tufts.vue.VUE.getDialogParentAsFrame(),
          VueResources.getString("dialog.addkey.title"),
          true);
      this.model = model;
      allTypes = (Vector) TypeFactory.getAllTypes();
      keyLabel = new JLabel(VueResources.getString("nodefilter.field.label"));
      typeLabel = new JLabel(VueResources.getString("nodefilter.type.label"));
      keyEditor = new JTextField();
      typeEditor = new JComboBox(allTypes);
      keyEditor.setPreferredSize(new Dimension(80, 20));
      JPanel keyPanel = new JPanel();
      keyPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
      keyPanel.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
      keyPanel.add(keyLabel);
      keyPanel.add(keyEditor);

      JPanel typePanel = new JPanel();
      typePanel.setLayout(new FlowLayout(FlowLayout.CENTER));
      typePanel.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
      typePanel.add(typeLabel);
      typePanel.add(typeEditor);

      // SOUTH: southPanel(cancelButton, okButton)

      JButton okButton = new JButton(VueResources.getString("button.ok.label"));
      okButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              updateModelAndNotify();
              setVisible(false);
            }
          });

      JButton cancelButton = new JButton(VueResources.getString("button.cancel.lable"));
      cancelButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              setVisible(false);
            }
          });

      JPanel southPanel = new JPanel();
      southPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
      southPanel.add(okButton);
      southPanel.add(cancelButton);
      BoxLayout layout = new BoxLayout(getContentPane(), BoxLayout.Y_AXIS);

      getContentPane().setLayout(layout);
      getContentPane().add(keyPanel);
      getContentPane().add(typePanel);
      getContentPane().add(southPanel);
      pack();
      setLocation(NodeFilterEditor.this.getLocationOnScreen());
      setVisible(true);
    }
예제 #2
0
    public AddDialog(NodeFilter model) {
      super(
          tufts.vue.VUE.getDialogParentAsFrame(),
          VueResources.getString("dialog.addkey.title"),
          true);
      this.model = model;
      allTypes = (Vector) TypeFactory.getAllTypes();
      keyLabel = new JLabel(VueResources.getString("button.key.label"));
      typeLabel = new JLabel(VueResources.getString("nodefilter.type.label"));
      operatorLabel = new JLabel(VueResources.getString("nodefilter.operator.label"));
      valueLabel = new JLabel(VueResources.getString("nodefilter.value.label"));
      keyEditor = new JComboBox(tufts.vue.VUE.getActiveMap().getMapFilterModel().getKeyVector());

      operatorEditor = new JComboBox();
      valueEditor = new JTextField();
      typeEditor = new JTextField();
      typeEditor.setEditable(false);

      keyEditor.setPreferredSize(new Dimension(80, 20));

      GridBagLayout gridbag = new GridBagLayout();
      GridBagConstraints c = new GridBagConstraints();
      c.insets = new Insets(2, 2, 2, 2);
      JPanel panel = new JPanel();
      panel.setLayout(gridbag);

      c.anchor = GridBagConstraints.EAST;
      c.gridwidth = GridBagConstraints.RELATIVE;
      gridbag.setConstraints(keyLabel, c);
      panel.add(keyLabel);

      c.anchor = GridBagConstraints.WEST;
      c.gridwidth = GridBagConstraints.REMAINDER;
      gridbag.setConstraints(keyEditor, c);
      panel.add(keyEditor);

      c.anchor = GridBagConstraints.EAST;
      c.gridwidth = GridBagConstraints.RELATIVE;
      gridbag.setConstraints(operatorLabel, c);
      panel.add(operatorLabel);

      c.anchor = GridBagConstraints.WEST;
      c.gridwidth = GridBagConstraints.REMAINDER;
      gridbag.setConstraints(operatorEditor, c);
      panel.add(operatorEditor);

      c.anchor = GridBagConstraints.EAST;
      c.gridwidth = GridBagConstraints.RELATIVE;
      gridbag.setConstraints(valueLabel, c);
      panel.add(valueLabel);

      c.anchor = GridBagConstraints.WEST;
      c.gridwidth = GridBagConstraints.REMAINDER;
      c.fill = GridBagConstraints.HORIZONTAL;
      gridbag.setConstraints(valueEditor, c);
      panel.add(valueEditor);

      c.anchor = GridBagConstraints.EAST;
      c.fill = GridBagConstraints.NONE;
      c.gridwidth = GridBagConstraints.RELATIVE;
      gridbag.setConstraints(typeLabel, c);
      panel.add(typeLabel);

      c.anchor = GridBagConstraints.WEST;
      c.gridwidth = GridBagConstraints.REMAINDER;
      c.fill = GridBagConstraints.HORIZONTAL;
      gridbag.setConstraints(typeEditor, c);
      panel.add(typeEditor);

      // SOUTH: southPanel(cancelButton, okButton)

      JButton okButton = new JButton(VueResources.getString("button.ok.label"));
      okButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              updateModelAndNotify();
              setVisible(false);
            }
          });

      JButton cancelButton = new JButton(VueResources.getString("button.cancel.lable"));
      cancelButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              setVisible(false);
            }
          });

      JPanel southPanel = new JPanel();
      southPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
      southPanel.add(okButton);
      southPanel.add(cancelButton);

      c.gridwidth = GridBagConstraints.REMAINDER;
      gridbag.setConstraints(southPanel, c);
      panel.add(southPanel);

      getContentPane().setLayout(new BorderLayout());
      getContentPane().add(panel, BorderLayout.CENTER);

      pack();
      setLocation(500, 300);
      setVisible(true);
    }