public PushToApplicationAction(JabRefFrame frame, PushToApplication operation) { this.frame = frame; putValue(Action.SMALL_ICON, operation.getIcon()); putValue(Action.NAME, operation.getName()); putValue(Action.SHORT_DESCRIPTION, operation.getTooltip()); this.operation = operation; }
@Override public void run() { // Do the operation: operation.pushEntries(panel.database(), entries, getKeyString(entries), panel.metaData()); // Call the operationCompleted() method on the event dispatch thread: SwingUtilities.invokeLater( new Runnable() { @Override public void run() { operation.operationCompleted(panel); } }); }
@Override public void actionPerformed(ActionEvent e) { panel = frame.getCurrentBasePanel(); // Check if a BasePanel exists: if (panel == null) { return; } // Check if any entries are selected: entries = panel.getSelectedEntries(); if (entries.length == 0) { JOptionPane.showMessageDialog( frame, Localization.lang("This operation requires one or more entries to be selected."), (String) getValue(Action.NAME), JOptionPane.ERROR_MESSAGE); return; } // If required, check that all entries have BibTeX keys defined: if (operation.requiresBibtexKeys()) { for (BibEntry entry : entries) { if ((entry.getCiteKey() == null) || entry.getCiteKey().trim().isEmpty()) { JOptionPane.showMessageDialog( frame, Localization.lang( "This operation requires all selected entries to have BibTex keys defined."), (String) getValue(Action.NAME), JOptionPane.ERROR_MESSAGE); return; } } } // All set, call the operation in a new thread: JabRefExecutorService.INSTANCE.execute(this); }