Package ch.rakudave.jnetmap.view.preferences

Examples of ch.rakudave.jnetmap.view.preferences.PreferencePanel


  @Override
  @SuppressWarnings("serial")
  public PreferencePanel getSettingsPanel() {
    final JTextField command = new JTextField(Settings.get("wireshark.command", "wireshark"));
    PreferencePanel p = new PreferencePanel() {
      @Override
      public void save() {
        Settings.put("wireshark.command", command.getText());
      }
    };
      p.setLayout(new BorderLayout());
      JPanel inner = new JPanel(new GridLayout(0, 1, 5, 5));
        inner.add(new JLabel("Wireshark command:"));
        inner.add(command);
      p.add(inner, BorderLayout.NORTH);
    return p;
  }
View Full Code Here


        rightDevice.setVerticalTextPosition(JLabel.BOTTOM);
      deviceNames.add(leftDevice);
      deviceNames.add(centerLine);
      deviceNames.add(rightDevice);
    JPanel centerWrapper = new JPanel(new GridLayout(1, 3));
      final PreferencePanel leftInterface = InterfaceProperties.getInnerPanel(owner, nif1);
      JPanel connectionPanel = new JPanel(new GridLayout(0, 1, 5, 5));
        connectionPanel.setBorder(BorderFactory.createEmptyBorder(0, 50, 0, 50));
        final JComboBox connectionType = new JComboBox(Connection.Type.values());
          connectionType.setSelectedItem(c.getType());
        final JTextField bandwidth = new JTextField(String.valueOf(c.getBandwidth()));
        connectionPanel.add(new JLabel(Lang.get("connection.type")));
        connectionPanel.add(connectionType);
        connectionPanel.add(new JLabel(Lang.get("connection.bandwidth")));
        connectionPanel.add(bandwidth);
        connectionPanel.add(new JLabel(""));
        connectionPanel.add(new JLabel(""));
        connectionPanel.add(new JLabel(""));
      final PreferencePanel rightInterface = InterfaceProperties.getInnerPanel(owner, nif2);
      centerWrapper.add(leftInterface);
      centerWrapper.add(connectionPanel);
      centerWrapper.add(rightInterface);
    JPanel bottomRow = new JPanel(new FlowLayout(FlowLayout.TRAILING, 5, 5));
      final JDialog _this = this;
      JButton cancel = new JButton(Lang.get("action.cancel"), Icons.get("cancel"));
        cancel.addActionListener(new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            _this.dispose();
          }
        });
       
      JButton ok = new JButton(Lang.get("action.ok"), Icons.get("ok"));
        ok.setPreferredSize(cancel.getPreferredSize());
        ok.addActionListener(new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            leftInterface.save();
            rightInterface.save();
            //TODO skip new command if nothing has changed
            Controller.getCurrentMap().getHistory().execute(new Command() {
              Connection.Type oltType = c.getType(), newType = (Connection.Type) connectionType.getSelectedItem();
              double oldBandwidth = c.getBandwidth(), newBandwidth;
              @Override
View Full Code Here

 
  public InterfaceProperties(final Frame owner, final NetworkIF i) {
    super(owner, Lang.getNoHTML("interface.properties"), ModalityType.DOCUMENT_MODAL);
    setLayout(new BorderLayout(5, 5));
    setPreferredSize(new Dimension(350,320));
    final PreferencePanel main = getInnerPanel(owner, i);
    JPanel bottomRow = new JPanel(new FlowLayout(FlowLayout.TRAILING, 5, 5));
      final JDialog _this = this;
      JButton cancel = new JButton(Lang.get("action.cancel"), Icons.get("cancel"));
        cancel.addActionListener(new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            _this.dispose();
          }
        });
      JButton ok = new JButton(Lang.get("action.ok"), Icons.get("ok"));
        ok.setPreferredSize(cancel.getPreferredSize());
        ok.addActionListener(new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            main.save();
            _this.dispose();
            if (TabPanel.getCurrentTab() != null) TabPanel.getCurrentTab().repaint();
          }
        });
      bottomRow.add(cancel);
View Full Code Here

          gateway.setEnabled(s); mac.setEnabled(s);
          method.setEnabled(s); port.setEnabled(s);
          portScan.setEnabled(s);
        }
      });
    PreferencePanel p = new PreferencePanel() {
      @Override
      public void save() {
      //TODO skip new command if nothing has changed
        Controller.getCurrentMap().getHistory().execute(new Command() {
          String oldName = i.getName(), newName = name.getText(),
            newAddress = address.getText(),
            newSubnet = subnet.getText(), newGateway = gateway.getText(),
            oldMac = (isPhysical)?((PhysicalIF)i).getMacAddress():null, newMac = mac.getText();
          PingMethod newMethod = nameToMethod((String)method.getSelectedItem(), (Integer) port.getValue());
          Connection connection = i.getConnection();
          Device parent = i.getDevice();
          NetworkIF newIF = null;
         
          @Override
          public Object undo() {
            if (isPhysical && !addressCheckbox.isSelected()) {
              PhysicalIF pif = new PhysicalIF(parent, connection, oldAddress);
                pif.setSubnet(oldSubnet);
                pif.setGateway(oldGateway);
                pif.setMacAddress(oldMac);
                pif.setPingMethod(oldMethod);
                pif.setName(oldName);
              parent.addInterface(pif);
              parent.removeInterface(newIF);
            } else if (isTransparent && addressCheckbox.isSelected()) {
              TransparentIF tif = new TransparentIF(parent, connection, Controller.getCurrentMap().
                getOpposite(parent, i.getConnection()).getInterfaceFor(connection));
                tif.setName(oldName);
              parent.addInterface(tif);
              parent.removeInterface(newIF);
            } else {
              i.setAddress(oldAddress);
              i.setSubnet(oldSubnet);
              i.setGateway(oldGateway);
              i.setName(oldName);
              if (isPhysical) {
                ((PhysicalIF)i).setMacAddress(oldMac);
                ((PhysicalIF)i).setPingMethod(oldMethod);
              }
            }
            return null;
          }
         
          @Override
          public Object redo() {
            NetworkIF counterpart = Controller.getCurrentMap().
              getOpposite(parent, i.getConnection()).getInterfaceFor(connection);
            if (isPhysical && !addressCheckbox.isSelected()) {
              newIF = new TransparentIF(parent, connection, counterpart);
                newIF.setName(newName);
              parent.addInterface(newIF);
              parent.removeInterface(i);
            } else if (isTransparent && addressCheckbox.isSelected()) {
              PhysicalIF pif = new PhysicalIF(parent, connection, newAddress);
                pif.setSubnet(newSubnet);
                pif.setGateway(newGateway);
                pif.setMacAddress(newMac);
                pif.setPingMethod(newMethod);
                pif.setName(newName);
              newIF = pif;
              parent.addInterface(pif);
              parent.removeInterface(i);
              if (counterpart instanceof TransparentIF) ((TransparentIF) counterpart).setCounterpart(pif);
            } else {
              i.setAddress(newAddress);
              i.setSubnet(newSubnet);
              i.setGateway(newGateway);
              i.setName(newName);
              if (isPhysical) {
                ((PhysicalIF)i).setMacAddress(newMac);
                ((PhysicalIF)i).setPingMethod(newMethod);
              }
            }
            return null;
          }
        });
      }
    };
    p.setLayout(new GridLayout(0, 2, 5, 5));
    p.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    p.add(new JLabel(Lang.get("interface.name"))); p.add(name);
    p.add(addressCheckbox); p.add(address);
    p.add(new JLabel("      "+Lang.getNoHTML("interface.subnet"))); p.add(subnet);
    p.add(new JLabel("      "+Lang.getNoHTML("interface.gateway"))); p.add(gateway);
    p.add(new JLabel("      "+Lang.getNoHTML("interface.mac"))); p.add(mac);
    p.add(new JLabel("      "+Lang.getNoHTML("interface.pingmethod"))); p.add(method);
    p.add(new JLabel()); p.add(portWrapper);
    if (isPhysical) address.requestFocus();
    else name.requestFocus();
    return p;
  }
View Full Code Here

TOP

Related Classes of ch.rakudave.jnetmap.view.preferences.PreferencePanel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.