use of java.awt.datatransfer.Clipboard in project jmeter-plugins by undera.
the class FlexibleFileWriterGuiTest method testLostOwnership.
/**
* Test of lostOwnership method, of class FlexibleFileWriterGui.
*/
@Test
public void testLostOwnership() {
System.out.println("lostOwnership");
Clipboard clipboard = null;
Transferable contents = null;
FlexibleFileWriterGui instance = new FlexibleFileWriterGui();
instance.lostOwnership(clipboard, contents);
}
use of java.awt.datatransfer.Clipboard in project energy3d by concord-consortium.
the class EnergyDailyAnalysis method runAnalysis.
@Override
void runAnalysis(final JDialog parent) {
graph.info = "Calculating...";
graph.repaint();
onStart();
SceneManager.getTaskManager().update(new Callable<Object>() {
@Override
public Object call() {
final Throwable t = compute();
if (t != null) {
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
BugReporter.report(t);
}
});
}
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
onCompletion();
if (graph instanceof BuildingEnergyDailyGraph) {
final int net = (int) Math.round(getResult("Net"));
final Map<String, Double> recordedResults = getRecordedResults("Net");
final int n = recordedResults.size();
if (n > 0) {
String previousRuns = "";
final Object[] keys = recordedResults.keySet().toArray();
for (int i = n - 1; i >= 0; i--) {
previousRuns += keys[i] + " : " + Graph.TWO_DECIMALS.format(recordedResults.get(keys[i])) + " kWh<br>";
}
final Object[] options = new Object[] { "OK", "Copy Data" };
final String msg = "<html>The calculated daily net energy is <b>" + net + " kWh</b>.<br><hr>Results from previously recorded tests:<br>" + previousRuns + "</html>";
final JOptionPane optionPane = new JOptionPane(msg, JOptionPane.INFORMATION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, options, options[0]);
final JDialog dialog = optionPane.createDialog(MainFrame.getInstance(), "Daily Net Energy");
dialog.setVisible(true);
final Object choice = optionPane.getValue();
if (choice == options[1]) {
String output = "";
for (int i = 0; i < n; i++) {
output += Graph.TWO_DECIMALS.format(recordedResults.get(keys[i])) + "\n";
}
output += Graph.TWO_DECIMALS.format(getResult("Net"));
final Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard();
clpbrd.setContents(new StringSelection(output), null);
JOptionPane.showMessageDialog(MainFrame.getInstance(), "<html>" + (n + 1) + " data points copied to system clipboard.<br><hr>" + output, "Confirmation", JOptionPane.INFORMATION_MESSAGE);
}
} else {
JOptionPane.showMessageDialog(parent, "<html>The calculated daily net energy is <b>" + net + " kWh</b>.</html>", "Daily Net Energy", JOptionPane.INFORMATION_MESSAGE);
}
final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
if (selectedPart instanceof Foundation) {
EnergyPanel.getInstance().getBuildingDailyEnergyGraph().addGraph((Foundation) selectedPart);
}
}
}
});
return null;
}
});
}
use of java.awt.datatransfer.Clipboard in project selenium_java by sergueik.
the class MainFrame method initMainPanel.
@Override
protected JPanel initMainPanel() {
JPanel panel = new JPanel(new BorderLayout(0, 0));
final JScrollPane scrollPane = new JScrollPane();
panel.add(scrollPane, BorderLayout.CENTER);
table = new JTable() {
@Override
public Class<?> getColumnClass(int column) {
return getValueAt(0, column).getClass();
}
};
model = new AudioTableModel();
table.setModel(model);
table.setTransferHandler(new TransferHandler() {
@Override
public void exportToClipboard(JComponent comp, Clipboard clip, int action) {
int selectedRow = table.getSelectedRow();
String artist = model.getValueAt(selectedRow, 1).toString();
String title = model.getValueAt(selectedRow, 2).toString();
StringSelection selection = new StringSelection(artist + " - " + title);
clip.setContents(selection, null);
}
});
DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer();
centerRenderer.setHorizontalAlignment(JLabel.CENTER);
table.getColumnModel().getColumn(0).setPreferredWidth(50);
table.getColumnModel().getColumn(0).setMaxWidth(100);
table.getColumnModel().getColumn(1).setPreferredWidth(200);
table.getColumnModel().getColumn(2).setPreferredWidth(200);
table.getColumnModel().getColumn(3).setCellRenderer(centerRenderer);
table.getColumnModel().getColumn(3).setPreferredWidth(55);
table.getColumnModel().getColumn(3).setMaxWidth(70);
table.getColumnModel().getColumn(4).setPreferredWidth(55);
table.getColumnModel().getColumn(4).setMaxWidth(70);
scrollPane.setViewportView(table);
final JToolBar toolBar = new JToolBar();
toolBar.setFloatable(false);
toolBar.setMargin(new Insets(0, 5, 0, 0));
panel.add(toolBar, BorderLayout.SOUTH);
toolbarLabel = new JLabel("...");
toolBar.add(toolbarLabel);
return panel;
}
use of java.awt.datatransfer.Clipboard in project energy3d by concord-consortium.
the class ParabolicTroughAnnualAnalysis method runAnalysis.
@Override
void runAnalysis(final JDialog parent) {
graph.info = "Calculating...";
graph.repaint();
onStart();
final EnergyPanel e = EnergyPanel.getInstance();
for (final int m : MONTHS) {
SceneManager.getTaskManager().update(new Callable<Object>() {
@Override
public Object call() {
if (!analysisStopped) {
final Calendar c = Heliodon.getInstance().getCalendar();
c.set(Calendar.MONTH, m);
final Calendar today = (Calendar) c.clone();
Scene.getInstance().updateTrackables();
final Throwable t = compute();
if (t != null) {
stopAnalysis();
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
BugReporter.report(t);
}
});
}
final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
if (selectedPart instanceof Foundation) {
// synchronize with daily graph
final CspProjectDailyEnergyGraph g = e.getCspProjectDailyEnergyGraph();
if (g.hasGraph()) {
g.setCalendar(today);
g.updateGraph();
}
}
final Calendar today2 = today;
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
e.getDateSpinner().setValue(c.getTime());
if (selectedPart instanceof Foundation) {
final CspProjectDailyEnergyGraph g = e.getCspProjectDailyEnergyGraph();
e.getCspProjectTabbedPane().setSelectedComponent(g);
if (!g.hasGraph()) {
g.setCalendar(today2);
g.addGraph((Foundation) selectedPart);
}
}
}
});
}
return null;
}
});
}
SceneManager.getTaskManager().update(new Callable<Object>() {
@Override
public Object call() {
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
onCompletion();
if (Heliodon.getInstance().getCalendar().get(Calendar.MONTH) != Calendar.DECEMBER) {
// annual calculation aborted
return;
}
final String current = Graph.TWO_DECIMALS.format(getResult("Solar"));
final Map<String, Double> recordedResults = getRecordedResults("Solar");
final int n = recordedResults.size();
if (n > 0) {
String previousRuns = "";
final Object[] keys = recordedResults.keySet().toArray();
for (int i = n - 1; i >= 0; i--) {
previousRuns += keys[i] + " : " + Graph.TWO_DECIMALS.format(recordedResults.get(keys[i]) * 365.0 / 12.0) + " kWh<br>";
}
final Object[] options = new Object[] { "OK", "Copy Data" };
final String msg = "<html>The calculated annual output is <b>" + current + " kWh</b>.<br><hr>Results from previously recorded tests:<br>" + previousRuns + "</html>";
final JOptionPane optionPane = new JOptionPane(msg, JOptionPane.INFORMATION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, options, options[0]);
final JDialog dialog = optionPane.createDialog(MainFrame.getInstance(), "Annual Output");
dialog.setVisible(true);
final Object choice = optionPane.getValue();
if (choice == options[1]) {
String output = "";
for (int i = 0; i < n; i++) {
output += Graph.TWO_DECIMALS.format(recordedResults.get(keys[i]) * 365.0 / 12.0) + "\n";
}
output += current;
final Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard();
clpbrd.setContents(new StringSelection(output), null);
JOptionPane.showMessageDialog(MainFrame.getInstance(), "<html>" + (n + 1) + " data points copied to system clipboard.<br><hr>" + output, "Confirmation", JOptionPane.INFORMATION_MESSAGE);
}
} else {
JOptionPane.showMessageDialog(parent, "<html>The calculated annual output is <b>" + current + " kWh</b>.</html>", "Annual Output", JOptionPane.INFORMATION_MESSAGE);
}
}
});
return null;
}
});
}
use of java.awt.datatransfer.Clipboard in project energy3d by concord-consortium.
the class PvAnnualAnalysis method runAnalysis.
@Override
void runAnalysis(final JDialog parent) {
graph.info = "Calculating...";
graph.repaint();
onStart();
final EnergyPanel e = EnergyPanel.getInstance();
for (final int m : MONTHS) {
SceneManager.getTaskManager().update(new Callable<Object>() {
@Override
public Object call() {
if (!analysisStopped) {
final Calendar c = Heliodon.getInstance().getCalendar();
c.set(Calendar.MONTH, m);
final Calendar today = (Calendar) c.clone();
Scene.getInstance().updateTrackables();
final Throwable t = compute();
if (t != null) {
stopAnalysis();
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
BugReporter.report(t);
}
});
}
final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
if (selectedPart instanceof Foundation) {
// synchronize with daily graph
final PvProjectDailyEnergyGraph g = e.getPvProjectDailyEnergyGraph();
if (g.hasGraph()) {
g.setCalendar(today);
g.updateGraph();
}
}
final Calendar today2 = today;
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
e.getDateSpinner().setValue(c.getTime());
if (selectedPart instanceof Foundation) {
final PvProjectDailyEnergyGraph g = e.getPvProjectDailyEnergyGraph();
e.getPvProjectTabbedPane().setSelectedComponent(g);
if (!g.hasGraph()) {
g.setCalendar(today2);
g.addGraph((Foundation) selectedPart);
}
}
}
});
}
return null;
}
});
}
SceneManager.getTaskManager().update(new Callable<Object>() {
@Override
public Object call() {
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
onCompletion();
if (Heliodon.getInstance().getCalendar().get(Calendar.MONTH) != Calendar.DECEMBER) {
// annual calculation aborted
return;
}
final String current = Graph.TWO_DECIMALS.format(getResult("Solar"));
final Map<String, Double> recordedResults = getRecordedResults("Solar");
final int n = recordedResults.size();
if (n > 0) {
String previousRuns = "";
final Object[] keys = recordedResults.keySet().toArray();
for (int i = n - 1; i >= 0; i--) {
previousRuns += keys[i] + " : " + Graph.TWO_DECIMALS.format(recordedResults.get(keys[i]) * 365.0 / 12.0) + " kWh<br>";
}
final Object[] options = new Object[] { "OK", "Copy Data" };
final String msg = "<html>The calculated annual output is <b>" + current + " kWh</b>.<br><hr>Results from previously recorded tests:<br>" + previousRuns + "</html>";
final JOptionPane optionPane = new JOptionPane(msg, JOptionPane.INFORMATION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, options, options[0]);
final JDialog dialog = optionPane.createDialog(MainFrame.getInstance(), "Annual Photovoltaic Output");
dialog.setVisible(true);
final Object choice = optionPane.getValue();
if (choice == options[1]) {
String output = "";
for (int i = 0; i < n; i++) {
output += Graph.TWO_DECIMALS.format(recordedResults.get(keys[i]) * 365.0 / 12.0) + "\n";
}
output += current;
final Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard();
clpbrd.setContents(new StringSelection(output), null);
JOptionPane.showMessageDialog(MainFrame.getInstance(), "<html>" + (n + 1) + " data points copied to system clipboard.<br><hr>" + output, "Confirmation", JOptionPane.INFORMATION_MESSAGE);
}
} else {
JOptionPane.showMessageDialog(parent, "<html>The calculated annual output is <b>" + current + " kWh</b>.</html>", "Annual Photovoltaic Output", JOptionPane.INFORMATION_MESSAGE);
}
}
});
return null;
}
});
}
Aggregations