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(); }
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; }
public void windowClosed(WindowEvent e) { synchronized (getClass()) { machine.removeMachineStateListener(this); if (instance == this) { instance = null; } } }