示例#1
0
  private StatusPanelWindow(MachineController m) {
    super("Status Panel");

    // save our machine!
    machine = m;
    driver = machine.getDriver();
    driver.invalidatePosition(); // Always force a query when we open the panel

    // Listen to it-- stop and close if we're in build mode.
    machine.addMachineStateListener(this);

    // default behavior
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    // create all our GUI interfaces
    add(createToolsPanel());

    // add our listener hooks.
    addWindowListener(this);

    setResizable(false);

    // start our thread.
    updateThread = new UpdateThread(this);
    updateThread.start();
  }
示例#2
0
  protected JComponent createToolsPanel() {
    toolsPane = new JTabbedPane();

    for (Enumeration<ToolModel> e = machine.getModel().getTools().elements();
        e.hasMoreElements(); ) {
      ToolModel t = e.nextElement();
      if (t == null) continue;
      if (t.getType().equals("extruder")) {
        Base.logger.fine("Creating panel for " + t.getName());
        StatusPanel statusPanel = new StatusPanel(machine, t, this);
        toolsPane.addTab(t.getName(), statusPanel);
        statusPanels.add(statusPanel);
        if (machine.getModel().currentTool() == t) {
          toolsPane.setSelectedComponent(statusPanel);
        }
      } else {
        Base.logger.warning("Unsupported tool for control panel.");
      }
    }

    toolsPane.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent ce) {
            final JTabbedPane tp = (JTabbedPane) ce.getSource();
            final StatusPanel ep = (StatusPanel) tp.getSelectedComponent();
            machine.getModel().selectTool(ep.getTool().getIndex());
          }
        });
    return toolsPane;
  }
示例#3
0
 public void windowClosed(WindowEvent e) {
   synchronized (getClass()) {
     machine.removeMachineStateListener(this);
     if (instance == this) {
       instance = null;
     }
   }
 }