Search in sources :

Example 36 with Clipboard

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);
}
Also used : Transferable(java.awt.datatransfer.Transferable) Clipboard(java.awt.datatransfer.Clipboard) Test(org.junit.Test)

Example 37 with Clipboard

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;
        }
    });
}
Also used : JOptionPane(javax.swing.JOptionPane) StringSelection(java.awt.datatransfer.StringSelection) Foundation(org.concord.energy3d.model.Foundation) Clipboard(java.awt.datatransfer.Clipboard) JDialog(javax.swing.JDialog) HousePart(org.concord.energy3d.model.HousePart)

Example 38 with Clipboard

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;
}
Also used : StringSelection(java.awt.datatransfer.StringSelection) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer) Clipboard(java.awt.datatransfer.Clipboard) AudioTableModel(me.ruslanys.vkmusic.ui.model.AudioTableModel)

Example 39 with Clipboard

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;
        }
    });
}
Also used : Calendar(java.util.Calendar) CspProjectDailyEnergyGraph(org.concord.energy3d.gui.CspProjectDailyEnergyGraph) JOptionPane(javax.swing.JOptionPane) StringSelection(java.awt.datatransfer.StringSelection) EnergyPanel(org.concord.energy3d.gui.EnergyPanel) Foundation(org.concord.energy3d.model.Foundation) Clipboard(java.awt.datatransfer.Clipboard) HousePart(org.concord.energy3d.model.HousePart) JDialog(javax.swing.JDialog)

Example 40 with Clipboard

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;
        }
    });
}
Also used : Calendar(java.util.Calendar) JOptionPane(javax.swing.JOptionPane) StringSelection(java.awt.datatransfer.StringSelection) EnergyPanel(org.concord.energy3d.gui.EnergyPanel) PvProjectDailyEnergyGraph(org.concord.energy3d.gui.PvProjectDailyEnergyGraph) Foundation(org.concord.energy3d.model.Foundation) Clipboard(java.awt.datatransfer.Clipboard) HousePart(org.concord.energy3d.model.HousePart) JDialog(javax.swing.JDialog)

Aggregations

Clipboard (java.awt.datatransfer.Clipboard)172 StringSelection (java.awt.datatransfer.StringSelection)110 Transferable (java.awt.datatransfer.Transferable)43 IOException (java.io.IOException)27 UnsupportedFlavorException (java.awt.datatransfer.UnsupportedFlavorException)15 ActionEvent (java.awt.event.ActionEvent)12 JDialog (javax.swing.JDialog)12 JOptionPane (javax.swing.JOptionPane)12 Flame (org.jwildfire.create.tina.base.Flame)10 ActionListener (java.awt.event.ActionListener)9 JButton (javax.swing.JButton)8 JMenuItem (javax.swing.JMenuItem)8 JScrollPane (javax.swing.JScrollPane)8 JPanel (javax.swing.JPanel)7 JTextArea (javax.swing.JTextArea)7 Foundation (org.concord.energy3d.model.Foundation)7 HousePart (org.concord.energy3d.model.HousePart)7 FlameReader (org.jwildfire.create.tina.io.FlameReader)7 RenderedFlame (org.jwildfire.create.tina.render.RenderedFlame)7 Point (java.awt.Point)6