void refresh() { Command cmd = model.getCommand(); stateLabel.setForeground(ui.getColor(cmd)); stateLabel.setText(ui.getState(cmd)); activeButton.setAction(getActionMap().get(cmd.isRunning() ? "stop" : "close")); }
public ExePane(Executor mdl, UiCommon texts) { super(new BorderLayout()); ui = texts; model = mdl; mdl.getParent() .addPropertyChangeListener( new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getSource() == model) { if (EventQueue.isDispatchThread()) { refresh(); } else { EventQueue.invokeLater( new Runnable() { public void run() { refresh(); } }); } } } }); mdl.setInputStream(new TextAreaStream(std)); mdl.setErrorStream(new TextAreaStream(err)); SwingHelper h = new SwingHelper(this); h.with("header", new BorderLayout(), BorderLayout.PAGE_START) .add("line", new JLabel(model.getCommand().getLine()), BorderLayout.CENTER) .add("state", stateLabel, BorderLayout.LINE_END) .back(); // h.add("streams", new JSplitPane(JSplitPane.VERTICAL_SPLIT, // new JScrollPane(std), new JScrollPane(err)), BorderLayout.CENTER); h.with("streams", new JTabbedPane(), BorderLayout.CENTER) .add("std", new JScrollPane(std)) .add("err", new JScrollPane(err)) .back(); // streams = std.setEditable(false); err.setEditable(false); h.with("buttons", new FlowLayout(), BorderLayout.PAGE_END).add("button", activeButton); }
public Command getCommand() { return model.getCommand(); }