use of org.concord.energy3d.agents.OperationEvent in project energy3d by concord-consortium.
the class DailyEnvironmentalTemperature method showDialog.
public void showDialog() {
final JDialog dialog = new JDialog(MainFrame.getInstance(), "Daily Environmental Temperature", true);
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
final JPanel contentPane = new JPanel(new BorderLayout());
dialog.setContentPane(contentPane);
final JMenuBar menuBar = new JMenuBar();
dialog.setJMenuBar(menuBar);
final JCheckBoxMenuItem[] cbmiGroundTemperature = new JCheckBoxMenuItem[depth.length];
for (int i = 0; i < depth.length; i++) {
cbmiGroundTemperature[i] = new JCheckBoxMenuItem(i == 0 ? "Air Temperature" : "Ground Temperature (" + depth[i] + "m)");
Util.selectSilently(cbmiGroundTemperature[i], !hideData.get(groundTemperature[i]));
}
final JMenu menuView = new JMenu("View");
menuBar.add(menuView);
menuView.addMenuListener(new MenuListener() {
@Override
public void menuSelected(final MenuEvent e) {
for (int i = 0; i < depth.length; i++) {
Util.selectSilently(cbmiGroundTemperature[i], !hideData.get(groundTemperature[i]));
}
}
@Override
public void menuDeselected(final MenuEvent e) {
}
@Override
public void menuCanceled(final MenuEvent e) {
}
});
for (int i = 0; i < depth.length; i++) {
final int i2 = i;
cbmiGroundTemperature[i].addItemListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
final JCheckBoxMenuItem source = (JCheckBoxMenuItem) e.getSource();
hideData.put(groundTemperature[i2], !source.isSelected());
DailyEnvironmentalTemperature.this.repaint();
}
});
menuView.add(cbmiGroundTemperature[i]);
}
final JMenu menuExport = new JMenu("Export");
menuBar.add(menuExport);
final JMenuItem mi = new JMenuItem("Copy Image");
mi.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
new ClipImage().copyImageToClipboard(DailyEnvironmentalTemperature.this);
}
});
menuExport.add(mi);
final JPanel panel = new JPanel(new BorderLayout());
panel.setBorder(BorderFactory.createEtchedBorder());
contentPane.add(panel, BorderLayout.CENTER);
panel.add(this, BorderLayout.CENTER);
final JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
contentPane.add(buttonPanel, BorderLayout.SOUTH);
final JButton button = new JButton("Close");
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
dialog.dispose();
}
});
buttonPanel.add(button);
dialog.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(final WindowEvent e) {
dialog.dispose();
}
});
dialog.pack();
dialog.setLocationRelativeTo(MainFrame.getInstance());
dialog.setVisible(true);
TimeSeriesLogger.getInstance().logAnalysis(this);
final HashMap<String, Object> attributes = new HashMap<String, Object>();
attributes.put("Location", Scene.getInstance().getCity());
attributes.put("Date", Scene.getInstance().getDate().toString());
MainApplication.addEvent(new OperationEvent(Scene.getURL(), System.currentTimeMillis(), getClass().getSimpleName(), attributes));
}
use of org.concord.energy3d.agents.OperationEvent in project energy3d by concord-consortium.
the class MyUndoManager method redo.
@Override
public void redo() throws CannotRedoException {
super.redo();
SaveCommand.setGloabalSignificant(true);
Scene.getInstance().setEdited(!(editToBeUndone() instanceof SaveCommand));
SaveCommand.setGloabalSignificant(false);
refreshUndoRedoGui();
TimeSeriesLogger.getInstance().logRedo();
final HashMap<String, Object> attributes = new HashMap<String, Object>();
attributes.put("Action", getPresentationName());
MainApplication.addEvent(new OperationEvent(Scene.getURL(), System.currentTimeMillis(), "Redo", attributes));
}
use of org.concord.energy3d.agents.OperationEvent in project energy3d by concord-consortium.
the class MainFrame method getNewMenuItem.
private JMenuItem getNewMenuItem() {
if (newMenuItem == null) {
newMenuItem = new JMenuItem("New");
newMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, Config.isMac() ? KeyEvent.META_MASK : KeyEvent.CTRL_MASK));
newMenuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
boolean ok = false;
if (Scene.getInstance().isEdited()) {
final int save = JOptionPane.showConfirmDialog(MainFrame.this, "Do you want to save changes?", "Save", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
if (save == JOptionPane.YES_OPTION) {
save();
if (!Scene.getInstance().isEdited()) {
ok = true;
}
} else if (save != JOptionPane.CANCEL_OPTION) {
ok = true;
}
} else {
ok = true;
}
if (ok) {
SceneManager.getTaskManager().update(new Callable<Object>() {
@Override
public Object call() throws Exception {
try {
Scene.newFile();
SceneManager.getInstance().resetCamera(ViewMode.NORMAL);
SceneManager.getInstance().getCameraControl().reset();
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
updateTitleBar();
EnergyPanel.getInstance().update();
EnergyPanel.getInstance().clearAllGraphs();
EnergyPanel.getInstance().selectInstructionSheet(0);
MainApplication.addEvent(new OperationEvent(Scene.getURL(), System.currentTimeMillis(), "New File", null));
}
});
} catch (final Throwable err) {
BugReporter.report(err);
}
return null;
}
});
}
}
});
}
return newMenuItem;
}
Aggregations