Search in sources :

Example 16 with PrefData

use of com.sldeditor.common.preferences.PrefData in project sldeditor by robward-scisys.

the class PrefManagerTest method testFinish.

/**
 * Test method for {@link com.sldeditor.common.preferences.PrefManager#finish()}.
 */
@Test
public void testFinish() {
    PrefManager.initialise(null);
    PrefManager.getInstance().finish();
    DummyPropertyManager propertyManager = new DummyPropertyManager();
    PrefManager.initialise(propertyManager);
    // Set up data as if it had been read in
    PrefData prefData = new PrefData();
    prefData.setUseAntiAlias(true);
    Color backgroundColour = Color.GRAY;
    prefData.setBackgroundColour(backgroundColour);
    List<VersionData> vendorOptionList = new ArrayList<VersionData>();
    vendorOptionList.add(VendorOptionManager.getInstance().getDefaultVendorOptionVersionData());
    vendorOptionList.add(VersionData.getEarliestVersion(GeoServerVendorOption.class));
    prefData.setVendorOptionVersionList(vendorOptionList);
    String uiLayoutClass = "perfect curve";
    prefData.setUiLayoutClass(uiLayoutClass);
    String lastFolderViewed = "secret";
    prefData.setLastFolderViewed(lastFolderViewed);
    prefData.setLastViewedKey(PrefDataLastViewedEnum.FOLDER);
    prefData.setSaveLastFolderView(true);
    PrefManager.getInstance().setPrefData(prefData);
    PrefManager.getInstance().finish();
    // Try GeoServer as last item viewed
    prefData.setLastViewedKey(PrefDataLastViewedEnum.GEOSERVER);
    PrefManager.getInstance().setPrefData(prefData);
    PrefManager.getInstance().finish();
}
Also used : GeoServerVendorOption(com.sldeditor.common.vendoroption.GeoServerVendorOption) PrefData(com.sldeditor.common.preferences.PrefData) VersionData(com.sldeditor.common.vendoroption.VersionData) Color(java.awt.Color) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 17 with PrefData

use of com.sldeditor.common.preferences.PrefData in project sldeditor by robward-scisys.

the class PrefManagerTest method testUndoAction.

/**
 * Test method for {@link com.sldeditor.common.preferences.PrefManager#undoAction(com.sldeditor.common.undo.UndoInterface)}. Test method for
 * {@link com.sldeditor.common.preferences.PrefManager#redoAction(com.sldeditor.common.undo.UndoInterface)}.
 */
@Test
public void testUndoAction() {
    PrefManager.initialise(null);
    PrefManager.getInstance().finish();
    DummyPropertyManager propertyManager = new DummyPropertyManager();
    PrefManager.initialise(propertyManager);
    // Set up data as if it had been read in
    PrefData prefData = new PrefData();
    prefData.setUseAntiAlias(true);
    Color backgroundColour = Color.GRAY;
    prefData.setBackgroundColour(backgroundColour);
    List<VersionData> vendorOptionList = new ArrayList<VersionData>();
    vendorOptionList.add(VendorOptionManager.getInstance().getDefaultVendorOptionVersionData());
    vendorOptionList.add(VersionData.getEarliestVersion(GeoServerVendorOption.class));
    prefData.setVendorOptionVersionList(vendorOptionList);
    String uiLayoutClass = "perfect curve";
    prefData.setUiLayoutClass(uiLayoutClass);
    String lastFolderViewed = "secret";
    prefData.setLastFolderViewed(lastFolderViewed);
    prefData.setLastViewedKey(PrefDataLastViewedEnum.FOLDER);
    prefData.setSaveLastFolderView(true);
    PrefManager.getInstance().setPrefData(prefData);
    PrefData copy = prefData.clone();
    copy.setLastViewedKey(PrefDataLastViewedEnum.GEOSERVER);
    PrefManager.getInstance().setPrefData(copy);
    PrefData actual = PrefManager.getInstance().getPrefData();
    assertEquals(PrefDataLastViewedEnum.GEOSERVER, actual.getLastViewedKey());
    UndoManager.getInstance().undo();
    actual = PrefManager.getInstance().getPrefData();
    assertEquals(PrefDataLastViewedEnum.FOLDER, actual.getLastViewedKey());
    UndoManager.getInstance().redo();
    actual = PrefManager.getInstance().getPrefData();
    assertEquals(PrefDataLastViewedEnum.GEOSERVER, actual.getLastViewedKey());
    // Increase the code coverage
    PrefManager.getInstance().undoAction(null);
    PrefManager.getInstance().undoAction(new UndoEvent(null, FieldIdEnum.NAME, "", "new"));
    PrefManager.getInstance().redoAction(null);
    PrefManager.getInstance().redoAction(new UndoEvent(null, FieldIdEnum.NAME, "", "new"));
}
Also used : UndoEvent(com.sldeditor.common.undo.UndoEvent) GeoServerVendorOption(com.sldeditor.common.vendoroption.GeoServerVendorOption) PrefData(com.sldeditor.common.preferences.PrefData) VersionData(com.sldeditor.common.vendoroption.VersionData) Color(java.awt.Color) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 18 with PrefData

use of com.sldeditor.common.preferences.PrefData in project sldeditor by robward-scisys.

the class PrefManagerTest method testPrefData.

/**
 * Test method for {@link com.sldeditor.common.preferences.PrefManager#useAntiAlias()}.
 */
@Test
public void testPrefData() {
    PrefData prefData = new PrefData();
    prefData.setUseAntiAlias(true);
    Color backgroundColour = Color.GRAY;
    prefData.setBackgroundColour(backgroundColour);
    List<VersionData> vendorOptionList = new ArrayList<VersionData>();
    vendorOptionList.add(VendorOptionManager.getInstance().getDefaultVendorOptionVersionData());
    prefData.setVendorOptionVersionList(vendorOptionList);
    String uiLayoutClass = "perfect curve";
    prefData.setUiLayoutClass(uiLayoutClass);
    PrefManager.getInstance().setPrefData(prefData);
    assertEquals(backgroundColour, PrefManager.getInstance().getPrefData().getBackgroundColour());
    assertEquals(uiLayoutClass, PrefManager.getInstance().getPrefData().getUiLayoutClass());
    assertEquals(true, PrefManager.getInstance().getPrefData().isUseAntiAlias());
}
Also used : PrefData(com.sldeditor.common.preferences.PrefData) VersionData(com.sldeditor.common.vendoroption.VersionData) Color(java.awt.Color) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 19 with PrefData

use of com.sldeditor.common.preferences.PrefData in project sldeditor by robward-scisys.

the class PrefManagerUI method showPrefPanel.

/**
 * Show preferences panel.
 */
public static void showPrefPanel() {
    PrefPanel panel = new PrefPanel();
    PrefData originalPrefData = PrefManager.getInstance().getPrefData();
    if (panel.showDialog(originalPrefData)) {
        PrefData prefData = panel.getPrefData();
        if (!originalPrefData.isSaveLastFolderView() && prefData.isSaveLastFolderView()) {
            prefData.setLastFolderViewed(originalPrefData.getLastFolderViewed());
        }
        PrefManager.getInstance().setPrefData(prefData);
    }
}
Also used : PrefData(com.sldeditor.common.preferences.PrefData)

Example 20 with PrefData

use of com.sldeditor.common.preferences.PrefData in project sldeditor by robward-scisys.

the class FileSystemExtensionTest method testUpdateForPreferences.

/**
 * Test method for
 * {@link com.sldeditor.extension.filesystem.FileSystemExtension#updateForPreferences(PrefData, List String)}.
 */
@Test
public void testUpdateForPreferences() {
    FileSystemExtension fsExt = new FileSystemExtension();
    FileSystemExtensionFactory.override(null);
    fsExt.initialise(null, null);
    fsExt.updateForPreferences(null, null);
    // Set up with 'save last folder view' set to false
    PrefData prefData = new PrefData();
    String lastFolderViewed = null;
    prefData.setLastFolderViewed(lastFolderViewed);
    PrefDataLastViewedEnum lastViewedKey = PrefDataLastViewedEnum.FOLDER;
    prefData.setLastViewedKey(lastViewedKey);
    prefData.setSaveLastFolderView(false);
    List<String> actualArgList = new ArrayList<String>();
    fsExt.updateForPreferences(prefData, actualArgList);
    assertTrue(actualArgList.isEmpty());
    // Set up with 'save last folder view' set to true but no folder
    prefData.setSaveLastFolderView(true);
    fsExt.updateForPreferences(prefData, actualArgList);
    assertTrue(actualArgList.isEmpty());
    // Set up with 'save last folder view' set to true but with folder
    lastFolderViewed = "last viewed";
    prefData.setLastFolderViewed(lastFolderViewed);
    fsExt.updateForPreferences(prefData, actualArgList);
    assertEquals(1, actualArgList.size());
    String expected = String.format("%s.%s.%s=%s", ExtensionFactory.EXTENSION_PREFIX, fsExt.getExtensionArgPrefix(), "folder", lastFolderViewed);
    assertEquals(expected, actualArgList.get(0));
    // Set up with 'save last folder view' set to true but with GeoServer
    actualArgList.clear();
    lastViewedKey = PrefDataLastViewedEnum.GEOSERVER;
    prefData.setLastViewedKey(lastViewedKey);
    fsExt.updateForPreferences(prefData, actualArgList);
    assertEquals(1, actualArgList.size());
    expected = String.format("%s.%s.%s=%s", ExtensionFactory.EXTENSION_PREFIX, fsExt.getExtensionArgPrefix(), "geoserver", lastFolderViewed);
    assertEquals(expected, actualArgList.get(0));
    // Try and replace existing argument
    // CHECKSTYLE:OFF
    String previous = lastFolderViewed;
    // CHECKSTYLE:ON
    lastFolderViewed = "new folder";
    prefData.setLastFolderViewed(lastFolderViewed);
    fsExt.updateForPreferences(prefData, actualArgList);
    assertEquals(1, actualArgList.size());
    expected = String.format("%s.%s.%s=%s", ExtensionFactory.EXTENSION_PREFIX, fsExt.getExtensionArgPrefix(), "geoserver", previous);
    assertEquals(expected, actualArgList.get(0));
}
Also used : FileSystemExtension(com.sldeditor.extension.filesystem.FileSystemExtension) PrefData(com.sldeditor.common.preferences.PrefData) PrefDataLastViewedEnum(com.sldeditor.common.preferences.PrefDataLastViewedEnum) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

PrefData (com.sldeditor.common.preferences.PrefData)20 Test (org.junit.Test)17 ArrayList (java.util.ArrayList)9 VersionData (com.sldeditor.common.vendoroption.VersionData)7 Color (java.awt.Color)5 GeoServerVendorOption (com.sldeditor.common.vendoroption.GeoServerVendorOption)3 PrefDataLastViewedEnum (com.sldeditor.common.preferences.PrefDataLastViewedEnum)2 GeoServerConnection (com.sldeditor.common.data.GeoServerConnection)1 SLDData (com.sldeditor.common.data.SLDData)1 SelectedFiles (com.sldeditor.common.filesystem.SelectedFiles)1 UndoEvent (com.sldeditor.common.undo.UndoEvent)1 VendorOptionVersion (com.sldeditor.common.vendoroption.VendorOptionVersion)1 VendorOptionInfo (com.sldeditor.common.vendoroption.info.VendorOptionInfo)1 MinimumVersion (com.sldeditor.common.vendoroption.minversion.MinimumVersion)1 VendorOptionPresent (com.sldeditor.common.vendoroption.minversion.VendorOptionPresent)1 FileSystemExtension (com.sldeditor.extension.filesystem.FileSystemExtension)1 GetMinimumVersionInterface (com.sldeditor.ui.panels.GetMinimumVersionInterface)1 File (java.io.File)1 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)1 NamedLayer (org.geotools.styling.NamedLayer)1