List of usage examples for javax.swing JDialog JDialog
public JDialog(Window owner, String title, Dialog.ModalityType modalityType)
From source file:org.uncommons.watchmaker.swing.evolutionmonitor.EvolutionMonitor.java
/** * Displays the evolution monitor component in a new {@link JDialog}. There is no * need to make sure this method is invoked from the Event Dispatch Thread, the * method itself ensures that the window is created and displayed from the EDT. * @param owner The owning frame for the new dialog. * @param title The title for the new dialog. * @param modal Whether the //from w ww . ja v a 2 s. c om */ public void showInDialog(final JFrame owner, final String title, final boolean modal) { SwingUtilities.invokeLater(new Runnable() { public void run() { JDialog dialog = new JDialog(owner, title, modal); dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); showWindow(dialog); } }); }
From source file:net.sf.jabref.openoffice.StyleSelectDialog.java
private void init(String inSelection) { this.initSelection = inSelection; ButtonGroup bg = new ButtonGroup(); bg.add(useDefaultAuthoryear);/*from w w w . jav a2 s . c o m*/ bg.add(useDefaultNumerical); bg.add(chooseDirectly); bg.add(setDirectory); if (Globals.prefs.getBoolean(JabRefPreferences.OO_USE_DEFAULT_AUTHORYEAR_STYLE)) { useDefaultAuthoryear.setSelected(true); } else if (Globals.prefs.getBoolean(JabRefPreferences.OO_USE_DEFAULT_NUMERICAL_STYLE)) { useDefaultNumerical.setSelected(true); } else { if (Globals.prefs.getBoolean(JabRefPreferences.OO_CHOOSE_STYLE_DIRECTLY)) { chooseDirectly.setSelected(true); } else { setDirectory.setSelected(true); } } directFile.setText(Globals.prefs.get(JabRefPreferences.OO_DIRECT_FILE)); styleDir.setText(Globals.prefs.get(JabRefPreferences.OO_STYLE_DIRECTORY)); directFile.setEditable(false); styleDir.setEditable(false); popup.add(edit); BrowseAction dfBrowse = BrowseAction.buildForFile(directFile, directFile); browseDirectFile.addActionListener(dfBrowse); BrowseAction sdBrowse = BrowseAction.buildForDir(styleDir, setDirectory); browseStyleDir.addActionListener(sdBrowse); showDefaultAuthoryearStyle.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { displayDefaultStyle(true); } }); showDefaultNumericalStyle.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { displayDefaultStyle(false); } }); // Add action listener to "Edit" menu item, which is supposed to open the style file in an external editor: edit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { int i = table.getSelectedRow(); if (i == -1) { return; } ExternalFileType type = ExternalFileTypes.getInstance().getExternalFileTypeByExt("jstyle"); String link = tableModel.getElementAt(i).getFile().getPath(); try { if (type == null) { JabRefDesktop.openExternalFileUnknown(frame, new BibEntry(), new MetaData(), link, new UnknownExternalFileType("jstyle")); } else { JabRefDesktop.openExternalFileAnyFormat(new MetaData(), link, type); } } catch (IOException e) { LOGGER.warn("Problem open style file editor", e); } } }); diag = new JDialog(frame, Localization.lang("Styles"), true); styles = new BasicEventList<>(); EventList<OOBibStyle> sortedStyles = new SortedList<>(styles); // Create a preview panel for previewing styles: preview = new PreviewPanel(null, new MetaData(), ""); // Use the test entry from the Preview settings tab in Preferences: preview.setEntry(prevEntry); tableModel = (DefaultEventTableModel<OOBibStyle>) GlazedListsSwing .eventTableModelWithThreadProxyList(sortedStyles, new StyleTableFormat()); table = new JTable(tableModel); TableColumnModel cm = table.getColumnModel(); cm.getColumn(0).setPreferredWidth(100); cm.getColumn(1).setPreferredWidth(200); cm.getColumn(2).setPreferredWidth(80); selectionModel = (DefaultEventSelectionModel<OOBibStyle>) GlazedListsSwing .eventSelectionModelWithThreadProxyList(sortedStyles); table.setSelectionModel(selectionModel); table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent mouseEvent) { if (mouseEvent.isPopupTrigger()) { tablePopup(mouseEvent); } } @Override public void mouseReleased(MouseEvent mouseEvent) { if (mouseEvent.isPopupTrigger()) { tablePopup(mouseEvent); } } }); selectionModel.getSelected().addListEventListener(new EntrySelectionListener()); styleDir.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent documentEvent) { readStyles(); setDirectory.setSelected(true); } @Override public void removeUpdate(DocumentEvent documentEvent) { readStyles(); setDirectory.setSelected(true); } @Override public void changedUpdate(DocumentEvent documentEvent) { readStyles(); setDirectory.setSelected(true); } }); directFile.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent documentEvent) { chooseDirectly.setSelected(true); } @Override public void removeUpdate(DocumentEvent documentEvent) { chooseDirectly.setSelected(true); } @Override public void changedUpdate(DocumentEvent documentEvent) { chooseDirectly.setSelected(true); } }); contentPane.setTopComponent(new JScrollPane(table)); contentPane.setBottomComponent(preview); readStyles(); DefaultFormBuilder b = new DefaultFormBuilder( new FormLayout("fill:pref,4dlu,fill:150dlu,4dlu,fill:pref", "")); b.append(useDefaultAuthoryear, 3); b.append(showDefaultAuthoryearStyle); b.nextLine(); b.append(useDefaultNumerical, 3); b.append(showDefaultNumericalStyle); b.nextLine(); b.append(chooseDirectly); b.append(directFile); b.append(browseDirectFile); b.nextLine(); b.append(setDirectory); b.append(styleDir); b.append(browseStyleDir); b.nextLine(); DefaultFormBuilder b2 = new DefaultFormBuilder( new FormLayout("fill:1dlu:grow", "fill:pref, fill:pref, fill:270dlu:grow")); b2.nextLine(); b2.append(new JLabel("<html>" + Localization.lang("This is the list of available styles. Select the one you want to use.") + "</html>")); b2.nextLine(); b2.append(contentPane); b.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); b2.getPanel().setBorder(BorderFactory.createEmptyBorder(15, 5, 5, 5)); diag.add(b.getPanel(), BorderLayout.NORTH); diag.add(b2.getPanel(), BorderLayout.CENTER); AbstractAction okListener = new AbstractAction() { @Override public void actionPerformed(ActionEvent event) { if (!useDefaultAuthoryear.isSelected() && !useDefaultNumerical.isSelected()) { if (chooseDirectly.isSelected()) { File f = new File(directFile.getText()); if (!f.exists()) { JOptionPane.showMessageDialog(diag, Localization.lang( "You must select either a valid style file, or use a default style."), Localization.lang("Style selection"), JOptionPane.ERROR_MESSAGE); return; } } else { if ((table.getRowCount() == 0) || (table.getSelectedRowCount() == 0)) { JOptionPane.showMessageDialog(diag, Localization.lang( "You must select either a valid style file, or use a default style."), Localization.lang("Style selection"), JOptionPane.ERROR_MESSAGE); return; } } } okPressed = true; storeSettings(); diag.dispose(); } }; ok.addActionListener(okListener); Action cancelListener = new AbstractAction() { @Override public void actionPerformed(ActionEvent event) { diag.dispose(); } }; cancel.addActionListener(cancelListener); ButtonBarBuilder bb = new ButtonBarBuilder(); bb.addGlue(); bb.addButton(ok); bb.addButton(cancel); bb.addGlue(); bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); diag.add(bb.getPanel(), BorderLayout.SOUTH); ActionMap am = bb.getPanel().getActionMap(); InputMap im = bb.getPanel().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close"); am.put("close", cancelListener); im.put(KeyStroke.getKeyStroke("ENTER"), "enterOk"); am.put("enterOk", okListener); diag.pack(); diag.setLocationRelativeTo(frame); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { contentPane.setDividerLocation(contentPane.getSize().height - 150); } }); }
From source file:de.mpg.mpi_inf.bioinf.netanalyzer.ui.ChartDisplayPanel.java
/** * Creates a dialog window which contains the chart in its preferred size. */// www .jav a 2 s .c om private void displayEnlarged() { JDialog dialog = new JDialog(ownerDialog, visualizer.getTitle(), false); dialog.getContentPane().add(JFreeChartConn.createPanel(chart)); dialog.pack(); dialog.setLocationRelativeTo(ownerDialog); dialog.setVisible(true); }
From source file:net.automatalib.visualization.jung.JungGraphVisualizationProvider.java
@Override public <N, E> void visualize(Graph<N, E> graph, GraphDOTHelper<N, ? super E> helper, boolean modal, Map<String, String> options) { DirectedGraph<NodeVisualization, EdgeVisualization> visGraph = createVisualizationGraph(graph, helper); Layout<NodeVisualization, EdgeVisualization> layout = new KKLayout<>(visGraph); VisualizationViewer<NodeVisualization, EdgeVisualization> vv = new VisualizationViewer<>(layout); setupRenderContext(vv.getRenderContext()); vv.setGraphMouse(mouse);//from w ww.j a v a2 s . c om final JDialog frame = new JDialog((Dialog) null, "Visualization", modal); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.getContentPane().add(vv); frame.pack(); frame.setVisible(true); }
From source file:net.sf.jabref.openoffice.AutoDetectPaths.java
public JDialog showProgressDialog(JDialog progressParent, String title, String message, boolean includeCancelButton) { fileSearchCancelled = false;/* w w w. j a va2s .c o m*/ JProgressBar bar = new JProgressBar(SwingConstants.HORIZONTAL); JButton cancel = new JButton(Localization.lang("Cancel")); cancel.addActionListener(event -> { fileSearchCancelled = true; ((JButton) event.getSource()).setEnabled(false); }); final JDialog progressDialog = new JDialog(progressParent, title, false); bar.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); bar.setIndeterminate(true); if (includeCancelButton) { progressDialog.add(cancel, BorderLayout.SOUTH); } progressDialog.add(new JLabel(message), BorderLayout.NORTH); progressDialog.add(bar, BorderLayout.CENTER); progressDialog.pack(); progressDialog.setLocationRelativeTo(null); progressDialog.setVisible(true); return progressDialog; }
From source file:net.sf.jabref.gui.openoffice.OpenOfficePanel.java
private void initPanel() { connect.addActionListener(e -> connect(true)); manualConnect.addActionListener(e -> connect(false)); selectDocument.setToolTipText(Localization.lang("Select which open Writer document to work on")); selectDocument.addActionListener(e -> { try {//from w w w. jav a 2s . co m ooBase.selectDocument(); frame.output(Localization.lang("Connected to document") + ": " + ooBase.getCurrentDocumentTitle().orElse("")); } catch (UnknownPropertyException | WrappedTargetException | IndexOutOfBoundsException | NoSuchElementException | NoDocumentException ex) { JOptionPane.showMessageDialog(frame, ex.getMessage(), Localization.lang("Error"), JOptionPane.ERROR_MESSAGE); LOGGER.warn("Problem connecting", ex); } }); setStyleFile.addActionListener(event -> { if (styleDialog == null) { styleDialog = new StyleSelectDialog(frame, preferences, loader); } styleDialog.setVisible(true); styleDialog.getStyle().ifPresent(selectedStyle -> { style = selectedStyle; try { style.ensureUpToDate(); } catch (IOException e) { LOGGER.warn("Unable to reload style file '" + style.getPath() + "'", e); } frame.setStatus(Localization.lang("Current style is '%0'", style.getName())); }); }); pushEntries.setToolTipText(Localization.lang("Cite selected entries between parenthesis")); pushEntries.addActionListener(e -> pushEntries(true, true, false)); pushEntriesInt.setToolTipText(Localization.lang("Cite selected entries with in-text citation")); pushEntriesInt.addActionListener(e -> pushEntries(false, true, false)); pushEntriesEmpty.setToolTipText( Localization.lang("Insert a citation without text (the entry will appear in the reference list)")); pushEntriesEmpty.addActionListener(e -> pushEntries(false, false, false)); pushEntriesAdvanced.setToolTipText(Localization.lang("Cite selected entries with extra information")); pushEntriesAdvanced.addActionListener(e -> pushEntries(false, true, true)); update.setToolTipText(Localization.lang("Ensure that the bibliography is up-to-date")); Action updateAction = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { try { if (style == null) { style = loader.getUsedStyle(); } else { style.ensureUpToDate(); } ooBase.updateSortedReferenceMarks(); List<BibDatabase> databases = getBaseList(); List<String> unresolvedKeys = ooBase.refreshCiteMarkers(databases, style); ooBase.rebuildBibTextSection(databases, style); if (!unresolvedKeys.isEmpty()) { JOptionPane.showMessageDialog(frame, Localization.lang( "Your OpenOffice/LibreOffice document references the BibTeX key '%0', which could not be found in your current database.", unresolvedKeys.get(0)), Localization.lang("Unable to synchronize bibliography"), JOptionPane.ERROR_MESSAGE); } } catch (UndefinedCharacterFormatException ex) { reportUndefinedCharacterFormat(ex); } catch (UndefinedParagraphFormatException ex) { reportUndefinedParagraphFormat(ex); } catch (ConnectionLostException ex) { showConnectionLostErrorMessage(); } catch (IOException ex) { JOptionPane.showMessageDialog(frame, Localization.lang( "You must select either a valid style file, or use one of the default styles."), Localization.lang("No valid style file defined"), JOptionPane.ERROR_MESSAGE); LOGGER.warn("Problem with style file", ex); } catch (BibEntryNotFoundException ex) { JOptionPane.showMessageDialog(frame, Localization.lang( "Your OpenOffice/LibreOffice document references the BibTeX key '%0', which could not be found in your current database.", ex.getBibtexKey()), Localization.lang("Unable to synchronize bibliography"), JOptionPane.ERROR_MESSAGE); LOGGER.debug("BibEntry not found", ex); } catch (Exception ex) { LOGGER.warn("Could not update bibliography", ex); } } }; update.addActionListener(updateAction); merge.setToolTipText(Localization.lang("Combine pairs of citations that are separated by spaces only")); merge.addActionListener(e -> { try { ooBase.combineCiteMarkers(getBaseList(), style); } catch (UndefinedCharacterFormatException ex) { reportUndefinedCharacterFormat(ex); } catch (Exception ex) { LOGGER.warn("Problem combining cite markers", ex); } }); settingsB.addActionListener(e -> showSettingsPopup()); manageCitations.addActionListener(e -> { try { CitationManager cm = new CitationManager(frame, ooBase); cm.showDialog(); } catch (NoSuchElementException | WrappedTargetException | UnknownPropertyException ex) { LOGGER.warn("Problem showing citation manager", ex); } }); selectDocument.setEnabled(false); pushEntries.setEnabled(false); pushEntriesInt.setEnabled(false); pushEntriesEmpty.setEnabled(false); pushEntriesAdvanced.setEnabled(false); update.setEnabled(false); merge.setEnabled(false); manageCitations.setEnabled(false); diag = new JDialog((JFrame) null, "OpenOffice/LibreOffice panel", false); FormBuilder mainBuilder = FormBuilder.create() .layout(new FormLayout("fill:pref:grow", "p,p,p,p,p,p,p,p,p,p")); FormBuilder topRowBuilder = FormBuilder.create() .layout(new FormLayout("fill:pref:grow, 1dlu, fill:pref:grow, 1dlu, fill:pref:grow, " + "1dlu, fill:pref:grow, 1dlu, fill:pref:grow", "pref")); topRowBuilder.add(connect).xy(1, 1); topRowBuilder.add(manualConnect).xy(3, 1); topRowBuilder.add(selectDocument).xy(5, 1); topRowBuilder.add(update).xy(7, 1); topRowBuilder.add(help).xy(9, 1); mainBuilder.add(topRowBuilder.getPanel()).xy(1, 1); mainBuilder.add(setStyleFile).xy(1, 2); mainBuilder.add(pushEntries).xy(1, 3); mainBuilder.add(pushEntriesInt).xy(1, 4); mainBuilder.add(pushEntriesAdvanced).xy(1, 5); mainBuilder.add(pushEntriesEmpty).xy(1, 6); mainBuilder.add(merge).xy(1, 7); mainBuilder.add(manageCitations).xy(1, 8); mainBuilder.add(settingsB).xy(1, 9); JPanel content = new JPanel(); comp.setContentContainer(content); content.setLayout(new BorderLayout()); content.add(mainBuilder.getPanel(), BorderLayout.CENTER); frame.getTabbedPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) .put(Globals.getKeyPrefs().getKey(KeyBinding.REFRESH_OO), "Refresh OO"); frame.getTabbedPane().getActionMap().put("Refresh OO", updateAction); }
From source file:com.marginallyclever.makelangelo.MainGUI.java
protected boolean ChooseImageConversionOptions(boolean isDXF) { final JDialog driver = new JDialog(mainframe, translator.get("ConversionOptions"), true); driver.setLayout(new GridBagLayout()); final String[] choices = machineConfiguration.getKnownMachineNames(); final JComboBox<String> machine_choice = new JComboBox<String>(choices); machine_choice.setSelectedIndex(machineConfiguration.getCurrentMachineIndex()); final JSlider input_paper_margin = new JSlider(JSlider.HORIZONTAL, 0, 50, 100 - (int) (machineConfiguration.paper_margin * 100)); input_paper_margin.setMajorTickSpacing(10); input_paper_margin.setMinorTickSpacing(5); input_paper_margin.setPaintTicks(false); input_paper_margin.setPaintLabels(true); //final JCheckBox allow_metrics = new JCheckBox(String.valueOf("I want to add the distance drawn to the // total")); //allow_metrics.setSelected(allowMetrics); final JCheckBox reverse_h = new JCheckBox(translator.get("FlipForGlass")); reverse_h.setSelected(machineConfiguration.reverseForGlass); final JButton cancel = new JButton(translator.get("Cancel")); final JButton save = new JButton(translator.get("Start")); String[] filter_names = new String[image_converters.size()]; Iterator<Filter> fit = image_converters.iterator(); int i = 0;/*from www . j a v a2 s . com*/ while (fit.hasNext()) { Filter f = fit.next(); filter_names[i++] = f.GetName(); } final JComboBox<String> input_draw_style = new JComboBox<String>(filter_names); input_draw_style.setSelectedIndex(GetDrawStyle()); GridBagConstraints c = new GridBagConstraints(); //c.gridwidth=4; c.gridx=0; c.gridy=0; driver.add(allow_metrics,c); int y = 0; c.anchor = GridBagConstraints.EAST; c.gridwidth = 1; c.gridx = 0; c.gridy = y; driver.add(new JLabel(translator.get("MenuLoadMachineConfig")), c); c.anchor = GridBagConstraints.WEST; c.gridwidth = 2; c.gridx = 1; c.gridy = y++; driver.add(machine_choice, c); if (!isDXF) { c.anchor = GridBagConstraints.EAST; c.gridwidth = 1; c.gridx = 0; c.gridy = y; driver.add(new JLabel(translator.get("ConversionStyle")), c); c.anchor = GridBagConstraints.WEST; c.gridwidth = 3; c.gridx = 1; c.gridy = y++; driver.add(input_draw_style, c); } c.anchor = GridBagConstraints.EAST; c.gridwidth = 1; c.gridx = 0; c.gridy = y; driver.add(new JLabel(translator.get("PaperMargin")), c); c.anchor = GridBagConstraints.WEST; c.gridwidth = 3; c.gridx = 1; c.gridy = y++; driver.add(input_paper_margin, c); c.anchor = GridBagConstraints.WEST; c.gridwidth = 1; c.gridx = 1; c.gridy = y++; driver.add(reverse_h, c); c.anchor = GridBagConstraints.EAST; c.gridwidth = 1; c.gridx = 2; c.gridy = y; driver.add(save, c); c.anchor = GridBagConstraints.WEST; c.gridwidth = 1; c.gridx = 3; c.gridy = y++; driver.add(cancel, c); startConvertingNow = false; ActionListener driveButtons = new ActionListener() { public void actionPerformed(ActionEvent e) { Object subject = e.getSource(); if (subject == save) { long new_uid = Long.parseLong(choices[machine_choice.getSelectedIndex()]); machineConfiguration.LoadConfig(new_uid); SetDrawStyle(input_draw_style.getSelectedIndex()); machineConfiguration.paper_margin = (100 - input_paper_margin.getValue()) * 0.01; machineConfiguration.reverseForGlass = reverse_h.isSelected(); machineConfiguration.SaveConfig(); // if we aren't connected, don't show the new if (connectionToRobot != null && !connectionToRobot.isRobotConfirmed()) { // Force update of graphics layout. previewPane.updateMachineConfig(); // update window title mainframe.setTitle( translator.get("TitlePrefix") + Long.toString(machineConfiguration.robot_uid) + translator.get("TitleNotConnected")); } startConvertingNow = true; driver.dispose(); } if (subject == cancel) { driver.dispose(); } } }; save.addActionListener(driveButtons); cancel.addActionListener(driveButtons); driver.getRootPane().setDefaultButton(save); driver.pack(); driver.setVisible(true); return startConvertingNow; }
From source file:ffx.ui.MainPanel.java
/** * <p>/* w w w . j a v a 2 s . co m*/ * about</p> */ public void about() { if (aboutDialog == null) { aboutDialog = new JDialog(frame, "About... ", true); URL ffxURL = getClass().getClassLoader().getResource("ffx/ui/icons/splash.png"); ImageIcon logoIcon = new ImageIcon(ffxURL); JLabel logoLabel = new JLabel(logoIcon); logoLabel.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED)); Container contentpane = aboutDialog.getContentPane(); contentpane.setLayout(new BorderLayout()); initAbout(); contentpane.add(aboutTextArea, BorderLayout.SOUTH); contentpane.add(logoLabel, BorderLayout.CENTER); aboutDialog.pack(); Dimension dim = getToolkit().getScreenSize(); Dimension ddim = aboutDialog.getSize(); aboutDialog.setLocation((dim.width - ddim.width) / 2, (dim.height - ddim.height) / 2); aboutDialog.setResizable(false); } aboutDialog.setVisible(true); }
From source file:net.sf.jabref.openoffice.OpenOfficePanel.java
private void initPanel() { useDefaultAuthoryearStyle = Globals.prefs.getBoolean(JabRefPreferences.OO_USE_DEFAULT_AUTHORYEAR_STYLE); useDefaultNumericalStyle = Globals.prefs.getBoolean(JabRefPreferences.OO_USE_DEFAULT_NUMERICAL_STYLE); connect.addActionListener(e -> connect(true)); manualConnect.addActionListener(e -> connect(false)); selectDocument.setToolTipText(Localization.lang("Select which open Writer document to work on")); selectDocument.addActionListener(e -> { try {//from w ww. ja v a2 s. co m ooBase.selectDocument(); frame.output(Localization.lang("Connected to document") + ": " + ooBase.getCurrentDocumentTitle().orElse("")); } catch (UnknownPropertyException | WrappedTargetException | IndexOutOfBoundsException | NoSuchElementException | NoDocumentException ex) { JOptionPane.showMessageDialog(frame, ex.getMessage(), Localization.lang("Error"), JOptionPane.ERROR_MESSAGE); LOGGER.warn("Problem connecting", ex); } }); setStyleFile.addActionListener(e -> { if (styleDialog == null) { styleDialog = new StyleSelectDialog(frame, styleFile); } styleDialog.setVisible(true); if (styleDialog.isOkPressed()) { useDefaultAuthoryearStyle = Globals.prefs .getBoolean(JabRefPreferences.OO_USE_DEFAULT_AUTHORYEAR_STYLE); useDefaultNumericalStyle = Globals.prefs .getBoolean(JabRefPreferences.OO_USE_DEFAULT_NUMERICAL_STYLE); styleFile = Globals.prefs.get(JabRefPreferences.OO_BIBLIOGRAPHY_STYLE_FILE); try { readStyleFile(); } catch (IOException ex) { LOGGER.warn("Could not read style file", ex); } } }); pushEntries.setToolTipText(Localization.lang("Cite selected entries between parenthesis")); pushEntries.addActionListener(e -> pushEntries(true, true, false)); pushEntriesInt.setToolTipText(Localization.lang("Cite selected entries with in-text citation")); pushEntriesInt.addActionListener(e -> pushEntries(false, true, false)); pushEntriesEmpty.setToolTipText( Localization.lang("Insert a citation without text (the entry will appear in the reference list)")); pushEntriesEmpty.addActionListener(e -> pushEntries(false, false, false)); pushEntriesAdvanced.setToolTipText(Localization.lang("Cite selected entries with extra information")); pushEntriesAdvanced.addActionListener(e -> pushEntries(false, true, true)); update.setToolTipText(Localization.lang("Ensure that the bibliography is up-to-date")); Action updateAction = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { try { if (style == null) { readStyleFile(); } else { style.ensureUpToDate(); } ooBase.updateSortedReferenceMarks(); List<BibDatabase> databases = getBaseList(); List<String> unresolvedKeys = ooBase.refreshCiteMarkers(databases, style); ooBase.rebuildBibTextSection(databases, style); if (!unresolvedKeys.isEmpty()) { JOptionPane.showMessageDialog(frame, Localization.lang( "Your OpenOffice document references the BibTeX key '%0', which could not be found in your current database.", unresolvedKeys.get(0)), Localization.lang("Unable to synchronize bibliography"), JOptionPane.ERROR_MESSAGE); } } catch (UndefinedCharacterFormatException ex) { reportUndefinedCharacterFormat(ex); } catch (UndefinedParagraphFormatException ex) { reportUndefinedParagraphFormat(ex); } catch (ConnectionLostException ex) { showConnectionLostErrorMessage(); } catch (IOException ex) { JOptionPane.showMessageDialog(frame, Localization.lang( "You must select either a valid style file, or use one of the default styles."), Localization.lang("No valid style file defined"), JOptionPane.ERROR_MESSAGE); LOGGER.warn("Problem with style file", ex); return; } catch (BibEntryNotFoundException ex) { JOptionPane.showMessageDialog(frame, Localization.lang( "Your OpenOffice document references the BibTeX key '%0', which could not be found in your current database.", ex.getBibtexKey()), Localization.lang("Unable to synchronize bibliography"), JOptionPane.ERROR_MESSAGE); LOGGER.debug("BibEntry not found", ex); } catch (Exception ex) { LOGGER.warn("Could not update bibliography", ex); } } }; update.addActionListener(updateAction); merge.setToolTipText(Localization.lang("Combine pairs of citations that are separated by spaces only")); merge.addActionListener(e -> { try { ooBase.combineCiteMarkers(getBaseList(), style); } catch (UndefinedCharacterFormatException ex) { reportUndefinedCharacterFormat(ex); } catch (Exception ex) { LOGGER.warn("Problem combining cite markers", ex); } }); settingsB.addActionListener(e -> showSettingsPopup()); manageCitations.addActionListener(e -> { try { CitationManager cm = new CitationManager(frame, ooBase); cm.showDialog(); } catch (NoSuchElementException | WrappedTargetException | UnknownPropertyException ex) { LOGGER.warn("Problem showing citation manager", ex); } }); selectDocument.setEnabled(false); pushEntries.setEnabled(false); pushEntriesInt.setEnabled(false); pushEntriesEmpty.setEnabled(false); pushEntriesAdvanced.setEnabled(false); update.setEnabled(false); merge.setEnabled(false); manageCitations.setEnabled(false); diag = new JDialog((JFrame) null, "OpenOffice panel", false); DefaultFormBuilder b = new DefaultFormBuilder(new FormLayout("fill:pref:grow", //"p,0dlu,p,0dlu,p,0dlu,p,0dlu,p,0dlu,p,0dlu,p,0dlu,p,0dlu,p,0dlu,p,0dlu")); "p,p,p,p,p,p,p,p,p,p")); //ButtonBarBuilder bb = new ButtonBarBuilder(); DefaultFormBuilder bb = new DefaultFormBuilder( new FormLayout("fill:pref:grow, 1dlu, fill:pref:grow, 1dlu, fill:pref:grow, " + "1dlu, fill:pref:grow, 1dlu, fill:pref:grow", "")); bb.append(connect); bb.append(manualConnect); bb.append(selectDocument); bb.append(update); bb.append(help); b.append(bb.getPanel()); b.append(setStyleFile); b.append(pushEntries); b.append(pushEntriesInt); b.append(pushEntriesAdvanced); b.append(pushEntriesEmpty); b.append(merge); b.append(manageCitations); b.append(settingsB); JPanel content = new JPanel(); comp.setContentContainer(content); content.setLayout(new BorderLayout()); content.add(b.getPanel(), BorderLayout.CENTER); frame.getTabbedPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) .put(Globals.getKeyPrefs().getKey(KeyBinding.REFRESH_OO), "Refresh OO"); frame.getTabbedPane().getActionMap().put("Refresh OO", updateAction); }
From source file:com.xilinx.kintex7.MainScreen.java
private void showDialog(String message) { modalDialog = new JDialog(frame, "Busy", Dialog.ModalityType.DOCUMENT_MODAL); JLabel lmessage = new JLabel(message, JLabel.CENTER); //modalDialog.add(limg, BorderLayout.LINE_START); modalDialog.add(lmessage, BorderLayout.CENTER); modalDialog.setSize(400, 150);//from ww w. j av a 2 s .co m modalDialog.setLocationRelativeTo(frame); modalDialog.setVisible(true); }