use of com.sldeditor.common.data.SLDData in project sldeditor by robward-scisys.
the class ReloadManagerTest method testReloadFile.
/**
* Test method for
* {@link com.sldeditor.common.watcher.ReloadManager#fileAdded(java.nio.file.Path)}. Test method
* for {@link com.sldeditor.common.watcher.ReloadManager#fileModified(java.nio.file.Path)}. Test
* method for
* {@link com.sldeditor.common.watcher.ReloadManager#fileDeleted(java.nio.file.Path)}. Test
* method for
* {@link com.sldeditor.common.watcher.ReloadManager#sldDataUpdated(com.sldeditor.common.SLDDataInterface, boolean)}.
* Test method for
* {@link com.sldeditor.common.watcher.ReloadManager#addListener(com.sldeditor.common.LoadSLDInterface)}.
*/
@Test
public void testReloadFile() {
ReloadManager.getInstance().fileAdded(null);
ReloadManager.getInstance().fileModified(null);
ReloadManager.getInstance().fileDeleted(null);
SLDData sldData = new SLDData(new StyleWrapper(), "");
ReloadManager.getInstance().sldDataUpdated(sldData, true);
File expectedFile = new File("/tmp/testFile.sld");
Path path = expectedFile.toPath();
// Try with no callback
ReloadManager.getInstance().fileModified(path);
DummyCallback callback = new DummyCallback();
ReloadManager.getInstance().addListener(callback);
assertEquals(0, callback.reloadCallbackCalled);
// Set loaded file - should match
sldData.setSLDFile(expectedFile);
ReloadManager.getInstance().sldDataUpdated(sldData, true);
ReloadManager.getInstance().fileModified(path);
try {
Thread.sleep(1500);
} catch (InterruptedException e) {
e.printStackTrace();
}
assertEquals(1, callback.reloadCallbackCalled);
// Set loaded file - won't match
callback.reloadCallbackCalled = 0;
File expectedFile2 = new File("/tmp/differenttestFile.sld");
path = expectedFile2.toPath();
ReloadManager.getInstance().fileModified(path);
try {
Thread.sleep(1500);
} catch (InterruptedException e) {
e.printStackTrace();
}
assertEquals(0, callback.reloadCallbackCalled);
// Now try valid multiple calls
path = expectedFile.toPath();
ReloadManager.getInstance().fileModified(path);
ReloadManager.getInstance().fileModified(path);
ReloadManager.getInstance().fileModified(path);
try {
Thread.sleep(1500);
} catch (InterruptedException e) {
e.printStackTrace();
}
assertEquals(1, callback.reloadCallbackCalled);
}
use of com.sldeditor.common.data.SLDData in project sldeditor by robward-scisys.
the class SLDTree method repopulateTree.
/**
* Repopulate tree for a undo/redo operation.
*
* @param sldContents the sld contents
*/
private void repopulateTree(String sldContents) {
int[] selectedRows = symbolTree.getSelectionRows();
SLDDataInterface sldData = new SLDData(null, sldContents);
StyledLayerDescriptor sld = SLDUtils.createSLDFromString(sldData);
SelectedSymbol.getInstance().setSld(sld);
populateSLD();
if ((selectedRows != null) && (selectedRows.length > 0)) {
symbolTree.setSelectionRow(selectedRows[0]);
}
}
use of com.sldeditor.common.data.SLDData in project sldeditor by robward-scisys.
the class NewSLDPanel method showDialog.
/**
* Show dialog.
*
* @param parent the parent
* @return the created SLD if selected
*/
public List<SLDDataInterface> showDialog(JFrame parent) {
List<SLDDataInterface> newSLDList = null;
selected = null;
if (parent != null) {
this.setLocationRelativeTo(parent);
int x = ((parent.getWidth() - getWidth()) / 2);
int y = ((parent.getHeight() - getHeight()) / 2);
this.setLocation(x, y);
}
setVisible(true);
if (selected != null) {
newSLDList = new ArrayList<SLDDataInterface>();
StyledLayerDescriptor sld = selected.create();
if (sldWriter == null) {
sldWriter = SLDWriterFactory.createWriter(null);
}
newSLDList.add(new SLDData(new StyleWrapper(selected.getName()), sldWriter.encodeSLD(null, sld)));
return newSLDList;
}
return null;
}
use of com.sldeditor.common.data.SLDData in project sldeditor by robward-scisys.
the class InlineFeatureUtilsTest method testGetInlineFeaturesText.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.inlinefeature.InlineFeatureUtils#getInlineFeaturesText(org.geotools.styling.UserLayer)}.
*/
@Test
public void testGetInlineFeaturesText() {
String actualResult = InlineFeatureUtils.getInlineFeaturesText(null);
assertTrue(actualResult.compareTo("") == 0);
// Test 1
SLDData sldData = new SLDData(null, testInline1a);
StyledLayerDescriptor sld = SLDUtils.createSLDFromString(sldData);
UserLayer userLayer1 = (UserLayer) sld.layers().get(0);
actualResult = InlineFeatureUtils.getInlineFeaturesText(userLayer1);
assertTrue(actualResult.startsWith("<FeatureCollection>"));
assertTrue(actualResult.endsWith("</FeatureCollection>"));
// Test 2
sldData = new SLDData(null, testInline1b);
sld = SLDUtils.createSLDFromString(sldData);
UserLayer userLayer2 = (UserLayer) sld.layers().get(0);
actualResult = InlineFeatureUtils.getInlineFeaturesText(userLayer2);
assertTrue(actualResult.startsWith("<FeatureCollection>"));
assertTrue(actualResult.endsWith("</FeatureCollection>"));
}
use of com.sldeditor.common.data.SLDData in project sldeditor by robward-scisys.
the class InlineFeatureUtilsTest method testContainsInLineFeatures.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.inlinefeature.InlineFeatureUtils#containsInLineFeatures(org.geotools.styling.StyledLayerDescriptor)}.
*/
@Test
public void testContainsInLineFeatures() {
assertFalse(InlineFeatureUtils.containsInLineFeatures(null));
// Contains inline data
SLDData sldData = new SLDData(null, testInline1a);
StyledLayerDescriptor sld = SLDUtils.createSLDFromString(sldData);
assertTrue(InlineFeatureUtils.containsInLineFeatures(sld));
// Contains no inline data
sldData = new SLDData(null, testNoInline);
sld = SLDUtils.createSLDFromString(sldData);
assertFalse(InlineFeatureUtils.containsInLineFeatures(sld));
}
Aggregations