smm.addObserver(new Observer() {
@Override
public void update(Observable o, Object arg) {
if (arg instanceof ObserverNotification) {
final ObserverNotification notification = (ObserverNotification) arg;
final NotificationType type = notification.getType();
if (type.equals(NotificationType.displayInfoBox)) {
showInfoBox((String) notification.getObj1(), (String) notification.getObj2());
}
}
}
});
//setAllowedAreas(Qt.DockWidgetArea.RightDockWidgetArea, Qt.DockWidgetArea.LeftDockWidgetArea);
// setTitle(title);
tabWidget = new JPanel();
tabWidget.setMinimumSize(new Dimension(150, 200));
tabWidget.setMaximumSize(new Dimension(235,9999));
// statDataWidget
// ------------------------------------------------------------
statDataWidget = new JPanel();
GridBagLayout dataLayout = new GridBagLayout();
listModel = new DefaultListModel<ListValue>();
datasetsList = new JList<Object>();
datasetsListPopup = new JPopupMenu();
datasetsListPopup.addPopupMenuListener(new PopupMenuListener() {
@Override
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
displayDatasetItem((ListValue) e.getSource());
}
@Override
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {}
@Override
public void popupMenuCanceled(PopupMenuEvent e) {}
});
// context actions
JMenuItem showPropertiesAction = new JMenuItem("Properties");
showPropertiesAction.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
super.mouseClicked(e);
showProperties();
}
});
datasetsListPopup.add(showPropertiesAction);
JMenuItem showChartsAction = new JMenuItem("Show charts");
showChartsAction.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
super.mouseClicked(e);
showCharts();
}
});
datasetsListPopup.add(showChartsAction);
showOnMapAction = new JMenuItem("Show on map");
showOnMapAction.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
super.mouseClicked(e);
initShowOnMap();
}
});
datasetsListPopup.add(showOnMapAction);
JMenuItem showRawAction = new JMenuItem("Open data file");
showRawAction.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
super.mouseClicked(e);
showRawData();
}
});
datasetsListPopup.add(showRawAction);
JMenuItem renameSetAction = new JMenuItem("Rename");
renameSetAction.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
super.mouseClicked(e);
onRenameDataset();
}
});
datasetsListPopup.add(renameSetAction);
JMenuItem deleteSetAction = new JMenuItem("Remove");
deleteSetAction.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
super.mouseClicked(e);
onDeleteDataset();
}
});
datasetsListPopup.add(deleteSetAction);
JMenuItem deleteAllAction = new JMenuItem("Remove all");
deleteAllAction.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
super.mouseClicked(e);
onDeleteAllDatasets();
}
});
datasetsListPopup.add(deleteAllAction);
//datasetsList.setContextMenuPolicy(Qt.ContextMenuPolicy.NoContextMenu);
datasetsList.addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
checkBelongingToMap();
}
});
statAutoImport = new JCheckBox("Automatically import data");
statAutoImport.setToolTipText("Import of the SUMO dump data will be triggered automatically when the simulation finishes");
statAutoImport.setSelected(true);
final GridBagConstraints datasetsListConstraints = new GridBagConstraints();
datasetsListConstraints.gridx = 0;
datasetsListConstraints.gridy = 0;
datasetsListConstraints.fill = GridBagConstraints.HORIZONTAL;
dataLayout.setConstraints(datasetsList, datasetsListConstraints);
mainPanel.add(datasetsList);
final GridBagConstraints statAutoImportConstraints = new GridBagConstraints();
statAutoImportConstraints.gridx = 1;
statAutoImportConstraints.gridy = 0;
statAutoImportConstraints.gridwidth = 1;
statAutoImportConstraints.fill = GridBagConstraints.HORIZONTAL;
dataLayout.setConstraints(statAutoImport, statAutoImportConstraints);
mainPanel.add(statAutoImport);
statDataWidget.setLayout(dataLayout);
//simulationDock.set(tabWidget.indexOf(statDataWidget));
smm.addObserver(new Observer() {
@Override
public void update(Observable o, Object arg) {
if (arg instanceof ObserverNotification) {
final ObserverNotification notification = (ObserverNotification) arg;
final NotificationType type = notification.getType();
if (type.equals(NotificationType.datasetsChanged)) {
onDatasetsChanged();
}
}
}
});
smm.addObserver(new Observer() {
@Override
public void update(Observable o, Object arg) {
if (arg instanceof ObserverNotification) {
final ObserverNotification notification = (ObserverNotification) arg;
final NotificationType type = notification.getType();
if (type.equals(NotificationType.datasetsCleared)) {
onDatasetsCleared();
}
}
}
});