private void controlConnectAction() { if (robot == null) { assert (display.connectButton.getText().equals("connect")); } else { assert (display.connectButton.getText().equals("disconnect")); Debug.info("trying to kill %s", robot); final RobotConnection _robot = robot; Center.addEvent( new Center.EventRunnable() { @Override protected void run() { _robot.kill(); } }); return; } String address = (String) display.robotAddressBox.getSelectedItem(); if (address == null) { ToolMessage.displayError("choose valid address"); return; } address = address.trim(); if (display.localCheckBox.isSelected() && !address.endsWith(".local")) { address += ".local"; } display.connectButton.setEnabled(false); Center.addEvent(new ControlConnectRunnable(address)); }
protected ToolDisplayHandler() { ToolMessage.displayInfo("creating new display and handler: %s", this); display = new ToolDisplay(); listener = new TitleListener(); setupUtilitiesTab(); setupControlTab(); setupLogsTab(); setupLogDisplay(); setupFooter(); Center.listen(Events.LogsFound.class, this, true); Center.listen(Events.LogRefsFound.class, this, true); Center.listen(Events.GroupAdded.class, this, true); final String boundsKey = this.toString(); Center.listen( new NBToolShutdownListener() { @Override public void nbtoolShutdownCallback() { DisplaySettings end = new DisplaySettings( display.getBounds(), viewProfile, display.topLevelSplit.getDividerLocation()); UserSettings.BOUNDS_MAP.put(boundsKey, end); } }); DisplaySettings ds = UserSettings.BOUNDS_MAP.get(boundsKey); if (ds != null) { display.setBounds(ds.bounds); display.topLevelSplit.setDividerLocation(ds.splitLocation); viewProfile = ds.profile == null ? ViewProfile.DEFAULT_PROFILE : ds.profile; } display.setTitle("nbtool v" + ToolSettings.VERSION + "." + ToolSettings.MINOR_VERSION); display.setMinimumSize(MIN_SIZE); if (id == 0) { display.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } else { display.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); } setupKeyBindings(); display.topLevelSplit.setContinuousLayout(false); display.topLevelSplit.setAutoscrolls(false); Dimension min = ToolSettings.DEFAULT_BOUNDS.getSize(); min.width = 0; display.leftSideTabs.setMinimumSize(min); display.displayTabs.setMinimumSize(min); display.topLevelSplit.requestFocus(); }
@SuppressWarnings("unchecked") private void setupControlTab() { updateComboBoxAndSettings(display.pathBox, UserSettings.loadPathes, null); updateComboBoxAndSettings(display.robotAddressBox, UserSettings.addresses, null); final String last = "don't stream"; Vector<String> streamVector = new Vector<String>(); for (Pair<String, Criteria> pair : LogSearching.CRITERIA) { streamVector.add("stream: " + pair.a); } streamVector.add(last); display.streamComboBox.setModel(new DefaultComboBoxModel<String>(streamVector)); display.streamComboBox.setSelectedItem(last); display.selectButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { controlSelectAction(); } }); display.loadButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { controlLoadAction(); } }); display.connectButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { controlConnectAction(); } }); setupKeepSlider(); // Stop streaming if the user selects a log... Center.listen( Events.LogSelected.class, new Events.LogSelected() { @Override public void logSelected(Object source, Log first, List<Log> alsoSelected) { debug.info("Log{%s} selected, %s disabling streaming!", first, outerClassThis); display.streamComboBox.setSelectedItem(last); } }, true); display.leftSideTabs.setSelectedComponent(display.controlTab); ; }
TitleListener() { Debug.event("TitleListener() listening..."); Center.listen(Events.CrossStatus.class, this, true); Center.listen(Events.RobotConnectionStatus.class, this, true); }
private void setupUtilitiesTab() { display.debugLevelBox.setModel( new DefaultComboBoxModel<Debug.LogLevel>(Debug.LogLevel.values())); display.debugLevelBox.setEditable(false); display.debugLevelBox.setSelectedIndex( Arrays.asList(Debug.LogLevel.values()).indexOf(Debug.level)); display.debugLevelBox.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int sel = display.debugLevelBox.getSelectedIndex(); Debug.level = Debug.LogLevel.values()[sel]; UserSettings.logLevel = Debug.level; Debug.print("changed Debug.level to: %s", Debug.level); } }); setupViewProfileBox(); display.viewProfileBox.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ViewProfile prof = (ViewProfile) display.viewProfileBox.getSelectedItem(); if (prof != null) { viewProfile = prof; } } }); Center.listen( Events.ViewProfileSetChanged.class, new ViewProfileSetChanged() { @Override public void viewProfileSetChanged(Object src) { setupViewProfileBox(); } }, true); display.venueField.setText(UserSettings.venue); display.venueField.addKeyListener( new KeyAdapter() { @Override public void keyTyped(KeyEvent e) { UserSettings.venue = display.venueField.getText(); } }); JPanel utilityHolder = new JPanel(); // utilityHolder.setLayout(new BoxLayout(utilityHolder, // BoxLayout.Y_AXIS)); utilityHolder.setLayout(new GridLayout(0, 1)); for (UtilityParent up : UtilityManager.utilities) { utilityHolder.add(new UtilityPanel(up)); } // utilityHolder.add(Box.createVerticalGlue()); display.utilityScrollPane.setViewportView(utilityHolder); }