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();
}
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"));
}
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());
}
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);
}
}
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));
}
Aggregations