/** Initializes this dialog. */ private void initDialog() { setMinimumSize(new Dimension(640, 480)); final JComponent settingsPane = createSettingsPane(); final JComponent previewPane = createPreviewPane(); final JPanel contentPane = new JPanel(new GridBagLayout()); contentPane.add( settingsPane, new GridBagConstraints( 0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.NONE, new Insets(2, 0, 2, 0), 0, 0)); contentPane.add( previewPane, new GridBagConstraints( 1, 0, 1, 1, 1.0, 1.0, GridBagConstraints.NORTH, GridBagConstraints.BOTH, new Insets(2, 0, 2, 0), 0, 0)); final JButton runAnalysisButton = ToolUtils.createRunAnalysisButton(this); this.runAnalysisAction = (RestorableAction) runAnalysisButton.getAction(); final JButton exportButton = ToolUtils.createExportButton(this); this.exportAction = exportButton.getAction(); this.exportAction.setEnabled(false); final JButton closeButton = ToolUtils.createCloseButton(); this.closeAction = closeButton.getAction(); final JComponent buttons = SwingComponentUtils.createButtonPane(runAnalysisButton, exportButton, closeButton); SwingComponentUtils.setupWindowContentPane(this, contentPane, buttons, runAnalysisButton); }
/** @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */ @Override public void actionPerformed(final ActionEvent aEvent) { final Window parent = SwingComponentUtils.getOwningWindow(aEvent); final ClientController controller = getController(); // Issue #62: in case the user does NOT confirm to lose its changes, we // should bail out immediately, otherwise continue normally... if (controller.isProjectChanged() && // !SwingComponentUtils.askConfirmation( parent, "Current project has been changed.\nDo you really want to lose your changes?")) { return; } controller.createNewProject(); }
/** * Creates a new RepeatCaptureAction instance. * * @param aController the controller to use for this action. */ public RepeatCaptureAction(final ClientController aController) { super( ID, aController, ICON_RECAPTURE_DATA, "Repeat capture", "Repeat capture with current device settings"); putValue(ACCELERATOR_KEY, SwingComponentUtils.createMenuKeyMask(KeyEvent.VK_R)); putValue(MNEMONIC_KEY, Integer.valueOf(KeyEvent.VK_R)); }
/** @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */ @Override public void actionPerformed(final ActionEvent aEvent) { final Window owner = SwingComponentUtils.getOwningWindow(aEvent); if (!getController().isDeviceSelected()) { JOptionPane.showMessageDialog( owner, "No capturing device found!", "Capture error", JOptionPane.ERROR_MESSAGE); return; } if (!getController().isDeviceSetup()) { JOptionPane.showMessageDialog( owner, "Capturing device is not setup!", "Capture error", JOptionPane.ERROR_MESSAGE); return; } getController().repeatCaptureData(); }
/** * @param aEvent * @param aStartPoint */ protected void handleZoomRegion(final MouseEvent aEvent, final Point aStartPoint) { // For now, disabled by default as it isn't 100% working yet... if (Boolean.FALSE.equals(Boolean.valueOf(System.getProperty("zoomregionenabled", "false")))) { return; } final JComponent source = (JComponent) aEvent.getComponent(); final boolean dragging = (aEvent.getID() == MouseEvent.MOUSE_DRAGGED); final GhostGlassPane glassPane = (GhostGlassPane) SwingUtilities.getRootPane(source).getGlassPane(); Rectangle viewRect; final JScrollPane scrollPane = SwingComponentUtils.getAncestorOfClass(JScrollPane.class, source); if (scrollPane != null) { final JViewport viewport = scrollPane.getViewport(); viewRect = SwingUtilities.convertRectangle(viewport, viewport.getVisibleRect(), glassPane); } else { viewRect = SwingUtilities.convertRectangle(source, source.getVisibleRect(), glassPane); } final Point start = SwingUtilities.convertPoint(source, aStartPoint, glassPane); final Point current = SwingUtilities.convertPoint(source, aEvent.getPoint(), glassPane); if (dragging) { if (!glassPane.isVisible()) { glassPane.setVisible(true); glassPane.setRenderer(new RubberBandRenderer(), start, current, viewRect); } else { glassPane.updateRenderer(start, current, viewRect); } glassPane.repaintPartially(); } else /* if ( !dragging ) */ { // Fire off a signal to the zoom controller to do its job... this.controller.getZoomController().zoomRegion(aStartPoint, aEvent.getPoint()); glassPane.setVisible(false); } }
/** * @param aEvent * @return */ protected final MouseEvent convertEvent(final MouseEvent aEvent) { JComponent view = SwingComponentUtils.getDeepestComponentAt(aEvent); return SwingUtilities.convertMouseEvent(aEvent.getComponent(), aEvent, view); }
/** @return */ private JPanel createSettingsPane() { final int channelCount = getData().getChannels(); final Integer[] baudrates = new Integer[AsyncSerialDataDecoder.COMMON_BAUDRATES.length]; for (int i = 0; i < baudrates.length; i++) { baudrates[i] = Integer.valueOf(AsyncSerialDataDecoder.COMMON_BAUDRATES[i]); } final String[] bitarray = new String[10]; // allow symbol lengths between 5 and 14 bits... for (int i = 0; i < bitarray.length; i++) { bitarray[i] = String.format("%d", Integer.valueOf(i + 5)); } final JPanel settings = new JPanel(new SpringLayout()); SpringLayoutUtils.addSeparator(settings, "Settings"); settings.add(createRightAlignedLabel("RxD")); this.rxd = SwingComponentUtils.createOptionalChannelSelector(channelCount); settings.add(this.rxd); settings.add(createRightAlignedLabel("TxD")); this.txd = SwingComponentUtils.createOptionalChannelSelector(channelCount); settings.add(this.txd); settings.add(createRightAlignedLabel("CTS")); this.cts = SwingComponentUtils.createOptionalChannelSelector(channelCount); settings.add(this.cts); settings.add(createRightAlignedLabel("RTS")); this.rts = SwingComponentUtils.createOptionalChannelSelector(channelCount); settings.add(this.rts); settings.add(createRightAlignedLabel("DTR")); this.dtr = SwingComponentUtils.createOptionalChannelSelector(channelCount); settings.add(this.dtr); settings.add(createRightAlignedLabel("DSR")); this.dsr = SwingComponentUtils.createOptionalChannelSelector(channelCount); settings.add(this.dsr); settings.add(createRightAlignedLabel("DCD")); this.dcd = SwingComponentUtils.createOptionalChannelSelector(channelCount); settings.add(this.dcd); settings.add(createRightAlignedLabel("RI")); this.ri = SwingComponentUtils.createOptionalChannelSelector(channelCount); settings.add(this.ri); settings.add(createRightAlignedLabel("Baudrate")); this.autoDetectBaudRate = new JCheckBox("Auto detect"); settings.add(this.autoDetectBaudRate); settings.add(new JLabel("")); this.baudrate = new JComboBox(baudrates); // Issue #90: allow custom baudrates to be specified... this.baudrate.setEditable(true); this.baudrate.setSelectedIndex(0); settings.add(this.baudrate); this.autoDetectBaudRate.addItemListener( new ItemListener() { @Override public void itemStateChanged(final ItemEvent aEvent) { final JCheckBox cb = (JCheckBox) aEvent.getSource(); UARTProtocolAnalysisDialog.this.baudrate.setEnabled(!cb.isSelected()); } }); settings.add(createRightAlignedLabel("Parity")); this.parity = new JComboBox(Parity.values()); this.parity.setSelectedIndex(0); this.parity.setRenderer(new UARTParityItemRenderer()); settings.add(this.parity); settings.add(createRightAlignedLabel("Bits")); this.bits = new JComboBox(bitarray); this.bits.setSelectedIndex(3); settings.add(this.bits); settings.add(createRightAlignedLabel("Stopbits")); this.stop = new JComboBox(StopBits.values()); this.stop.setSelectedIndex(0); this.stop.setRenderer(new UARTStopBitsItemRenderer()); settings.add(this.stop); settings.add(createRightAlignedLabel("Idle level")); this.idleLevel = new JComboBox(BitLevel.values()); this.idleLevel.setSelectedIndex(0); this.idleLevel.setRenderer(new UARTIdleLevelItemRenderer()); settings.add(this.idleLevel); settings.add(createRightAlignedLabel("Bit encoding")); this.bitEncoding = new JComboBox(BitEncoding.values()); this.bitEncoding.setSelectedIndex(0); this.bitEncoding.setRenderer(new UARTBitEncodingItemRenderer()); settings.add(this.bitEncoding); settings.add(createRightAlignedLabel("Bit order")); this.bitOrder = new JComboBox(BitOrder.values()); this.bitOrder.setSelectedIndex(0); this.bitOrder.setRenderer(new UARTBitOrderItemRenderer()); settings.add(this.bitOrder); SpringLayoutUtils.makeEditorGrid(settings, 10, 4); return settings; }
/** * Creates a new NewProjectAction instance. * * @param aController the client controller to use. */ public NewProjectAction(final ClientController aController) { super(ID, aController, "New project ...", "Create a new project"); putValue(ACCELERATOR_KEY, SwingComponentUtils.createMenuKeyMask(KeyEvent.VK_N)); putValue(MNEMONIC_KEY, Integer.valueOf(KeyEvent.VK_N)); }
/** @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */ @Override public void actionPerformed(final ActionEvent aEvent) { final Window owner = SwingComponentUtils.getOwningWindow(aEvent); getController().showBundlesDialog(owner); }