Esempio n. 1
0
  /**
   * Create the editor panel.
   *
   * @return The editor panel.
   */
  protected JPanel createEditorPanel() {
    try {
      SwingEngine swingEngine = new SwingEngine(this);

      swingEngine.setClassLoader(InterfacingPlugin.class.getClassLoader());

      JPanel panel =
          (JPanel) swingEngine.render(getClass().getResource("/swixml/NullDriverDialog.xml"));

      return panel;
    } catch (Exception x) {
      Log.logError("client", "NullDriverDialog", x.toString());

      return new JPanel();
    }
  }
  /** Initialize the gui. Subclasses should override this method to create a custom gui. */
  public void initGUI() {
    try {
      SwingEngine swingEngine = new SwingEngine(this);

      swingEngine.setClassLoader(AppPlugin.class.getClassLoader());

      JPanel panel =
          (JPanel) swingEngine.render(getClass().getResource("/swixml/GagingSystemListEditor.xml"));

      content.add(panel, createConstraints(0, 0, 1, 1, GridBagConstraints.BOTH, 100, 100, null));

      gagingSystemTableModel =
          new IObjectTableModel() {
            private String[] columnNames =
                new String[] {
                  Engine.instance().getResourceService().getStringWithoutException("metix.name"),
                  Engine.instance().getResourceService().getStringWithoutException("metix.active")
                };
            private Class[] columnClasses = new Class[] {String.class, Boolean.class};

            public int getColumnCount() {
              return columnNames.length;
            }

            public String getColumnName(int col) {
              return columnNames[col];
            }

            public Class getColumnClass(int col) {
              return columnClasses[col];
            }

            public int getRowCount() {
              InterfaceRegistry registry = (InterfaceRegistry) iobject;

              if (registry == null) {
                return 0;
              }

              return registry.getGagingSystemCount();
            }

            public Object getValueAt(int row, int col) {
              InterfaceRegistry registry = (InterfaceRegistry) iobject;
              GagingSystem station = (GagingSystem) registry.getGagingSystem(row);

              switch (col) {
                case 0:
                  return station.getName();

                case 1:
                  return new Boolean(station.getActive());

                default:
                  return null;
              }
            }
          };

      gagingSystemTableModel.addTableModelListener(this);
      gagingSystemTable.setModel(gagingSystemTableModel);

      gagingSystemTable.addMouseListener(
          new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
              if (e.getClickCount() == 2) {
                editGagingStationAction.actionPerformed(null);
              }
            }
          });
    } catch (Exception x) {
      Log.logError("client", "GagingSystemListEditor.initGUI", x.toString());
    }
  }