Search in sources :

Example 1 with GCPreferences

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();
}
Also used : GCViewerGui(com.tagtraum.perf.gcviewer.view.GCViewerGui) GCPreferences(com.tagtraum.perf.gcviewer.view.model.GCPreferences)

Example 2 with GCPreferences

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;
}
Also used : GCResourceGroup(com.tagtraum.perf.gcviewer.view.model.GCResourceGroup) GCPreferences(com.tagtraum.perf.gcviewer.view.model.GCPreferences) OpenFile(com.tagtraum.perf.gcviewer.ctrl.action.OpenFile) LinkedList(java.util.LinkedList)

Example 3 with GCPreferences

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()));
}
Also used : GCPreferences(com.tagtraum.perf.gcviewer.view.model.GCPreferences) ModelChartImpl(com.tagtraum.perf.gcviewer.view.ModelChartImpl) GCModel(com.tagtraum.perf.gcviewer.model.GCModel) DoubleData(com.tagtraum.perf.gcviewer.math.DoubleData) Theory(org.junit.experimental.theories.Theory)

Example 4 with GCPreferences

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);
    }
}
Also used : GCModelLoaderController(com.tagtraum.perf.gcviewer.ctrl.GCModelLoaderController) GCViewerGui(com.tagtraum.perf.gcviewer.view.GCViewerGui) GCPreferences(com.tagtraum.perf.gcviewer.view.model.GCPreferences)

Example 5 with GCPreferences

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()));
    }
}
Also used : GCPreferences(com.tagtraum.perf.gcviewer.view.model.GCPreferences) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem)

Aggregations

GCPreferences (com.tagtraum.perf.gcviewer.view.model.GCPreferences)7 GCViewerGui (com.tagtraum.perf.gcviewer.view.GCViewerGui)3 GCModelLoaderController (com.tagtraum.perf.gcviewer.ctrl.GCModelLoaderController)1 OpenFile (com.tagtraum.perf.gcviewer.ctrl.action.OpenFile)1 DoubleData (com.tagtraum.perf.gcviewer.math.DoubleData)1 GCModel (com.tagtraum.perf.gcviewer.model.GCModel)1 ModelChartImpl (com.tagtraum.perf.gcviewer.view.ModelChartImpl)1 GCResourceGroup (com.tagtraum.perf.gcviewer.view.model.GCResourceGroup)1 Dimension (java.awt.Dimension)1 Graphics2D (java.awt.Graphics2D)1 BufferedImage (java.awt.image.BufferedImage)1 LinkedList (java.util.LinkedList)1 JCheckBoxMenuItem (javax.swing.JCheckBoxMenuItem)1 Before (org.junit.Before)1 Theory (org.junit.experimental.theories.Theory)1