use of com.tagtraum.perf.gcviewer.view.model.GCPreferences in project GCViewer by chewiebug.
the class GCViewerGuiController method windowClosing.
/**
* @see java.awt.event.WindowAdapter#windowClosing(java.awt.event.WindowEvent)
*/
@Override
public void windowClosing(WindowEvent e) {
// TODO SWINGWORKER fix closing of main window with correct storing of preferences
closeAllButSelectedDocument(((GCViewerGui) e.getWindow()));
GCPreferences preferences = copyPreferencesFromGui(((GCViewerGui) e.getWindow()));
preferences.store();
e.getWindow().dispose();
}
use of com.tagtraum.perf.gcviewer.view.model.GCPreferences in project GCViewer by chewiebug.
the class GCViewerGuiController method copyPreferencesFromGui.
/**
* Copies values that are stored in menu items into <code>GCPreferences</code> instance.
*
* @param gui source to copy values from
* @return <code>GCPreferences</code> with current values
*/
private GCPreferences copyPreferencesFromGui(GCViewerGui gui) {
GCPreferences preferences = gui.getPreferences();
for (Entry<String, JCheckBoxMenuItem> menuEntry : ((GCViewerGuiMenuBar) gui.getJMenuBar()).getViewMenuItems().entrySet()) {
JCheckBoxMenuItem item = menuEntry.getValue();
preferences.setGcLineProperty(item.getActionCommand(), item.getState());
}
preferences.setWindowWidth(gui.getWidth());
preferences.setWindowHeight(gui.getHeight());
preferences.setWindowX(gui.getX());
preferences.setWindowY(gui.getY());
OpenFile openFileAction = (OpenFile) gui.getActionMap().get(ActionCommands.OPEN_FILE.toString());
if (openFileAction.getLastSelectedFiles().length != 0) {
preferences.setLastFile(openFileAction.getLastSelectedFiles()[0].getAbsolutePath());
}
// recent files
List<String> recentFileList = new LinkedList<String>();
for (GCResourceGroup urlSet : ((GCViewerGuiMenuBar) gui.getJMenuBar()).getRecentGCResourcesModel().getResourceNameGroups()) {
recentFileList.add(urlSet.getUrlGroupString());
}
preferences.setRecentFiles(recentFileList);
return preferences;
}
use of com.tagtraum.perf.gcviewer.view.model.GCPreferences in project GCViewer by chewiebug.
the class ModelChartImplTest method shouldShowOrNotDateStampAccordingToModelAndSettings.
@Theory
public void shouldShowOrNotDateStampAccordingToModelAndSettings(TestCase testCase) throws Exception {
//given
ModelChartImpl modelChart = new ModelChartImpl();
GCPreferences preferences = new GCPreferences();
GCModel gcModel = Mockito.mock(GCModel.class);
Mockito.when(gcModel.hasDateStamp()).thenReturn(testCase.hasDateStamp());
Mockito.when(gcModel.getFirstDateStamp()).thenReturn(ZonedDateTime.now());
Mockito.when(gcModel.getPause()).thenReturn(new DoubleData());
preferences.setShowDateStamp(testCase.isShowDateStamp());
//when
modelChart.setModel(gcModel, preferences);
//then
assertThat(modelChart.isShowDateStamp(), equalTo(testCase.isExpectedShowDateStamp()));
}
use of com.tagtraum.perf.gcviewer.view.model.GCPreferences in project GCViewer by chewiebug.
the class GCViewerGuiController method startGui.
/**
* Start graphical user interface and load a log file (resourceName - if not <code>null</code>).
*
* @param gcResource {@link GCResource} to be loaded at startup or <code>null</code>
* @throws InvocationTargetException Some problem trying to start the gui
* @throws InterruptedException Some problem trying to start the gui
*/
public void startGui(final GCResource gcResource) throws InvocationTargetException, InterruptedException {
final GCViewerGui gcViewerGui = new GCViewerGui();
final GCModelLoaderController modelLoaderController = new GCModelLoaderControllerImpl(gcViewerGui);
Runnable guiStarter = new Runnable() {
@Override
public void run() {
new GCViewerGuiBuilder().initGCViewerGui(gcViewerGui, modelLoaderController);
applyPreferences(gcViewerGui, new GCPreferences());
gcViewerGui.addWindowListener(GCViewerGuiController.this);
Thread.setDefaultUncaughtExceptionHandler(new GCViewerUncaughtExceptionHandler(gcViewerGui));
gcViewerGui.setVisible(true);
}
};
SwingUtilities.invokeAndWait(guiStarter);
if (gcResource != null) {
Runnable resourceLoader = new Runnable() {
@Override
public void run() {
modelLoaderController.open(gcResource);
}
};
SwingUtilities.invokeLater(resourceLoader);
}
}
use of com.tagtraum.perf.gcviewer.view.model.GCPreferences in project GCViewer by chewiebug.
the class GCViewerGuiInternalFrameController method updateMenuItemState.
private void updateMenuItemState(InternalFrameEvent e) {
getToolBar(e).getZoomComboBox().setSelectedItem((int) (getSelectedGCDocument(e).getModelChart().getScaleFactor() * 1000.0) + "%");
GCPreferences preferences = getSelectedGCDocument(e).getPreferences();
for (Entry<String, JCheckBoxMenuItem> menuEntry : getMenuBar(e).getViewMenuItems().entrySet()) {
JCheckBoxMenuItem item = menuEntry.getValue();
item.setState(preferences.getGcLineProperty(menuEntry.getKey()));
}
}
Aggregations