use of org.geotools.xml.styling.SLDTransformer in project hale by halestudio.
the class SLDStyleWriter method execute.
/**
* @see AbstractIOProvider#execute(ProgressIndicator, IOReporter)
*/
@Override
protected IOReport execute(ProgressIndicator progress, IOReporter reporter) throws IOProviderConfigurationException, IOException {
progress.begin("Save styles to SLD", ProgressIndicator.UNKNOWN);
SLDTransformer trans = new SLDTransformer();
trans.setIndentation(2);
OutputStream out = getTarget().getOutput();
try {
trans.transform(getStyle(), out);
reporter.setSuccess(true);
} catch (Exception e) {
reporter.error(new IOMessageImpl("Saving the style as SLD failed.", e));
reporter.setSuccess(false);
} finally {
out.close();
progress.end();
}
return reporter;
}
use of org.geotools.xml.styling.SLDTransformer in project hale by halestudio.
the class XMLStylePage3 method createControl.
/**
* @see IDialogPage#createControl(Composite)
*/
@Override
public void createControl(Composite parent) {
changed = false;
final Display display = parent.getDisplay();
FillLayout fillLayout = new FillLayout();
fillLayout.type = SWT.VERTICAL;
parent.setLayout(fillLayout);
CompositeRuler ruler = new CompositeRuler(3);
LineNumberRulerColumn lineNumbers = new LineNumberRulerColumn();
// SWT.COLOR_INFO_BACKGROUND));
lineNumbers.setBackground(display.getSystemColor(SWT.COLOR_GRAY));
// SWT.COLOR_INFO_FOREGROUND));
lineNumbers.setForeground(display.getSystemColor(SWT.COLOR_BLACK));
lineNumbers.setFont(JFaceResources.getTextFont());
ruler.addDecorator(0, lineNumbers);
viewer = new SourceViewer(parent, ruler, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
viewer.getTextWidget().setFont(JFaceResources.getTextFont());
SourceViewerConfiguration conf = new SourceViewerConfiguration();
viewer.configure(conf);
SLDTransformer trans = new SLDTransformer();
trans.setIndentation(2);
String xml;
try {
xml = trans.transform(getParent().getStyle());
} catch (TransformerException e) {
// $NON-NLS-1$
xml = "Error: " + e.getMessage();
}
IDocument doc = new Document();
doc.set(xml);
doc.addDocumentListener(new IDocumentListener() {
@Override
public void documentChanged(DocumentEvent event) {
changed = true;
}
@Override
public void documentAboutToBeChanged(DocumentEvent event) {
// ignore
}
});
viewer.setInput(doc);
setControl(viewer.getControl());
}
Aggregations