/* * The following method creates the color chooser dialog box */ public void createColorDialog() { colorDialog = new JDialog(this, new String("Choose a color"), true); colorDialog.getContentPane().add(createColorPicker(), BorderLayout.CENTER); JButton okButton = new JButton("OK"); // This class is used to create a special ActionListener for // the ok button class ButtonListener implements ActionListener { /* * This method is called whenever the ok button is clicked */ public void actionPerformed(ActionEvent event) { currentChoice.changeColor(color_panel.getColor()); currentChoice.repaint(); fontColor = color_panel.getColor(); colorDialog.hide(); } // end actionPerformed method } ActionListener listener = new ButtonListener(); okButton.addActionListener(listener); // Add the four font control panels to one big panel using // a grid layout JPanel buttonPanel = new JPanel(); buttonPanel.add(okButton); // Add the button panel to the content pane of the ColorDialogue colorDialog.getContentPane().add(buttonPanel, BorderLayout.SOUTH); colorDialog.pack(); }
/** Show the filter dialog */ public void showDialog() { empty_border = new EmptyBorder(5, 5, 0, 5); indent_border = new EmptyBorder(5, 25, 5, 5); include_panel = new ServiceFilterPanel("Include messages based on target service:", filter_include_list); exclude_panel = new ServiceFilterPanel("Exclude messages based on target service:", filter_exclude_list); status_box = new JCheckBox("Filter messages based on status:"); status_box.addActionListener(this); status_active = new JRadioButton("Active messages only"); status_active.setSelected(true); status_active.setEnabled(false); status_complete = new JRadioButton("Complete messages only"); status_complete.setEnabled(false); status_group = new ButtonGroup(); status_group.add(status_active); status_group.add(status_complete); if (filter_active || filter_complete) { status_box.setSelected(true); status_active.setEnabled(true); status_complete.setEnabled(true); if (filter_complete) { status_complete.setSelected(true); } } status_options = new JPanel(); status_options.setLayout(new BoxLayout(status_options, BoxLayout.Y_AXIS)); status_options.add(status_active); status_options.add(status_complete); status_options.setBorder(indent_border); status_panel = new JPanel(); status_panel.setLayout(new BorderLayout()); status_panel.add(status_box, BorderLayout.NORTH); status_panel.add(status_options, BorderLayout.CENTER); status_panel.setBorder(empty_border); ok_button = new JButton("Ok"); ok_button.addActionListener(this); cancel_button = new JButton("Cancel"); cancel_button.addActionListener(this); buttons = new JPanel(); buttons.setLayout(new FlowLayout()); buttons.add(ok_button); buttons.add(cancel_button); panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); panel.add(include_panel); panel.add(exclude_panel); panel.add(status_panel); panel.add(buttons); dialog = new JDialog(); dialog.setTitle("SOAP Monitor Filter"); dialog.setContentPane(panel); dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); dialog.setModal(true); dialog.pack(); Dimension d = dialog.getToolkit().getScreenSize(); dialog.setLocation((d.width - dialog.getWidth()) / 2, (d.height - dialog.getHeight()) / 2); ok_pressed = false; dialog.show(); }
public Viewer() { leveldbStore.setMultiSelectionEnabled(false); leveldbStore.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); putButton.setEnabled(false); key.setEnabled(false); value.setEnabled(false); findField.setEnabled(false); deleteButton.setEnabled(false); saveButton.setEnabled(false); putType.setEnabled(false); putType.setEditable(false); signedBox.setEnabled(false); openButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (openButton.isEnabled()) { openButton.setEnabled(false); new Thread() { public void run() { if (leveldbStore.showOpenDialog(pane) == JFileChooser.APPROVE_OPTION) { File select = leveldbStore.getSelectedFile(); if (select.isDirectory()) { new OpenLevelDBDialog(Viewer.this, select); openDatabase(select); dbPathField.setText(select.getAbsolutePath()); } else { JOptionPane.showMessageDialog( pane, "The selecting item must be a directory", "Unable to load database", JOptionPane.WARNING_MESSAGE); } } else { openButton.setEnabled(true); } } }.start(); } } }); deleteButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (dataList.getSelectedValue() != null) { delete(dataList.getSelectedValue().key); } openDatabase(leveldbStore.getSelectedFile()); } }); putButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { put( ((PutType) putType.getSelectedItem()).getBytes(key.getText()), ((PutType) putType.getSelectedItem()).getBytes(value.getText())); openDatabase(leveldbStore.getSelectedFile()); } }); findField.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openDatabase(leveldbStore.getSelectedFile()); } }); findField .getDocument() .addDocumentListener( new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { openDatabase(leveldbStore.getSelectedFile()); } @Override public void removeUpdate(DocumentEvent e) { openDatabase(leveldbStore.getSelectedFile()); } @Override public void changedUpdate(DocumentEvent e) { openDatabase(leveldbStore.getSelectedFile()); } }); findField .getDocument() .addUndoableEditListener( new UndoableEditListener() { @Override public void undoableEditHappened(UndoableEditEvent e) { openDatabase(leveldbStore.getSelectedFile()); } }); hexKey .getDocument() .addDocumentListener( new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { update(hexKey); } @Override public void removeUpdate(DocumentEvent e) { update(hexKey); } @Override public void changedUpdate(DocumentEvent e) { update(hexKey); } }); hexKey .getDocument() .addUndoableEditListener( new UndoableEditListener() { @Override public void undoableEditHappened(UndoableEditEvent e) { update(hexKey); } }); stringKey .getDocument() .addDocumentListener( new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { update(stringKey); } @Override public void removeUpdate(DocumentEvent e) { update(stringKey); } @Override public void changedUpdate(DocumentEvent e) { update(stringKey); } }); stringKey .getDocument() .addUndoableEditListener( new UndoableEditListener() { @Override public void undoableEditHappened(UndoableEditEvent e) { update(stringKey); } }); hexValue .getDocument() .addDocumentListener( new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { update(hexValue); } @Override public void removeUpdate(DocumentEvent e) { update(hexValue); } @Override public void changedUpdate(DocumentEvent e) { update(hexValue); } }); hexValue .getDocument() .addUndoableEditListener( new UndoableEditListener() { @Override public void undoableEditHappened(UndoableEditEvent e) { update(hexValue); } }); stringValue .getDocument() .addDocumentListener( new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { update(stringValue); } @Override public void removeUpdate(DocumentEvent e) { update(stringValue); } @Override public void changedUpdate(DocumentEvent e) { update(stringValue); } }); stringValue .getDocument() .addUndoableEditListener( new UndoableEditListener() { @Override public void undoableEditHappened(UndoableEditEvent e) { update(stringValue); } }); saveButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { save(); openDatabase(leveldbStore.getSelectedFile()); } }); dataList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); dataList.addListSelectionListener( new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { DBItem item = dataList.getSelectedValue(); if (item != null) { hexValue.setText(cutToLine(LevelDBViewer.toHexString(item.value), 64)); stringValue.setText(cutToLine(new String(item.value), 64)); hexKey.setText(cutToLine(LevelDBViewer.toHexString(item.key), 64)); stringKey.setText(cutToLine(new String(item.key), 64)); lengthLabel.setText(String.valueOf(item.value.length + item.key.length)); keyLength.setText(String.valueOf(item.key.length)); valueLength.setText(String.valueOf(item.value.length)); } } }); signedBox.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { LevelDBViewer.DEFAULT_SINGED = signedBox.isSelected(); int i = dataList.getSelectedIndex(); dataList.clearSelection(); dataList.updateUI(); dataList.setSelectedIndex(i); update(hexKey); update(hexValue); } }); for (PutType t : PutType.values()) { putType.addItem(t); } putType.setSelectedItem(PutType.STRING); putType.addItemListener( new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { openDatabase(leveldbStore.getSelectedFile()); } }); putType.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openDatabase(leveldbStore.getSelectedFile()); } }); dialog.setLocationByPlatform(true); dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); dialog.setContentPane(pane); dialog.setTitle("LevelDB Viewer By Marcus (https://github.com/SuperMarcus)"); dialog.getRootPane().setDefaultButton(openButton); dialog.pack(); dialog.setVisible(true); }
/** * Create a new ProjectionManager. * * @param parent JFrame (application) or JApplet (applet) * @param projections list of initial projections * @param makeDialog true to make this a dialog * @param helpId help id if dialog * @param maps List of MapData */ public ProjectionManager( RootPaneContainer parent, List projections, boolean makeDialog, String helpId, List maps) { this.helpId = helpId; this.maps = maps; this.parent = parent; // manage NewProjectionListeners lm = new ListenerManager( "java.beans.PropertyChangeListener", "java.beans.PropertyChangeEvent", "propertyChange"); // here's where the map will be drawn: but cant be changed/edited npViewControl = new NPController(); if (maps == null) { maps = getDefaultMaps(); // we use the system default } for (int mapIdx = 0; mapIdx < maps.size(); mapIdx++) { MapData mapData = (MapData) maps.get(mapIdx); if (mapData.getVisible()) { npViewControl.addMap(mapData.getSource(), mapData.getColor()); } } mapViewPanel = npViewControl.getNavigatedPanel(); mapViewPanel.setPreferredSize(new Dimension(250, 250)); mapViewPanel.setToolTipText("Shows the default zoom of the current projection"); mapViewPanel.setChangeable(false); if ((projections == null) || (projections.size() == 0)) { projections = makeDefaultProjections(); } // the actual list is a JTable subclass projTable = new JTableProjection(this, projections); JComponent listContents = new JScrollPane(projTable); JComponent buttons = GuiUtils.hbox( GuiUtils.makeButton("Edit", this, "doEdit"), GuiUtils.makeButton("New", this, "doNew"), GuiUtils.makeButton("Export", this, "doExport"), GuiUtils.makeButton("Delete", this, "doDelete")); mapLabel = new JLabel(" "); JComponent leftPanel = GuiUtils.inset(GuiUtils.topCenter(mapLabel, mapViewPanel), 5); JComponent rightPanel = GuiUtils.topCenter(buttons, listContents); rightPanel = GuiUtils.inset(rightPanel, 5); contents = GuiUtils.inset(GuiUtils.hbox(leftPanel, rightPanel), 5); // default current and working projection if (null != (current = projTable.getSelected())) { setWorkingProjection(current); projTable.setCurrentProjection(current); mapLabel.setText(current.getName()); } /* listen for new working Projections from projTable */ projTable.addNewProjectionListener( new NewProjectionListener() { public void actionPerformed(NewProjectionEvent e) { if (e.getProjection() != null) { setWorkingProjection(e.getProjection()); } } }); eventsOK = true; // put it together in the viewDialog if (makeDialog) { Container buttPanel = GuiUtils.makeApplyOkHelpCancelButtons(this); contents = GuiUtils.centerBottom(contents, buttPanel); viewDialog = GuiUtils.createDialog(GuiUtils.getApplicationTitle() + "Projection Manager", false); viewDialog.getContentPane().add(contents); viewDialog.pack(); ucar.unidata.util.Msg.translateTree(viewDialog); viewDialog.setLocation(100, 100); } }
public static boolean showLicensing() { if (Config.getLicenseResource() == null) return true; ClassLoader cl = Main.class.getClassLoader(); URL url = cl.getResource(Config.getLicenseResource()); if (url == null) return true; String license = null; try { URLConnection con = url.openConnection(); int size = con.getContentLength(); byte[] content = new byte[size]; InputStream in = new BufferedInputStream(con.getInputStream()); in.read(content); license = new String(content); } catch (IOException ioe) { Config.trace("Got exception when reading " + Config.getLicenseResource() + ": " + ioe); return false; } // Build dialog JTextArea ta = new JTextArea(license); ta.setEditable(false); final JDialog jd = new JDialog(_installerFrame, true); Container comp = jd.getContentPane(); jd.setTitle(Config.getLicenseDialogTitle()); comp.setLayout(new BorderLayout(10, 10)); comp.add(new JScrollPane(ta), "Center"); Box box = new Box(BoxLayout.X_AXIS); box.add(box.createHorizontalStrut(10)); box.add(new JLabel(Config.getLicenseDialogQuestionString())); box.add(box.createHorizontalGlue()); JButton acceptButton = new JButton(Config.getLicenseDialogAcceptString()); JButton exitButton = new JButton(Config.getLicenseDialogExitString()); box.add(acceptButton); box.add(box.createHorizontalStrut(10)); box.add(exitButton); box.add(box.createHorizontalStrut(10)); jd.getRootPane().setDefaultButton(acceptButton); Box box2 = new Box(BoxLayout.Y_AXIS); box2.add(box); box2.add(box2.createVerticalStrut(5)); comp.add(box2, "South"); jd.pack(); final boolean accept[] = new boolean[1]; acceptButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { accept[0] = true; jd.hide(); jd.dispose(); } }); exitButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { accept[0] = false; jd.hide(); jd.dispose(); } }); // Apply any defaults the user may have, constraining to the size // of the screen, and default (packed) size. Rectangle size = new Rectangle(0, 0, 500, 300); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); size.width = Math.min(screenSize.width, size.width); size.height = Math.min(screenSize.height, size.height); // Center the window jd.setBounds( (screenSize.width - size.width) / 2, (screenSize.height - size.height) / 2, size.width, size.height); // Show dialog jd.show(); return accept[0]; }