org.simantics.diagram.ontology,
org.simantics.modeling.ontology,
org.simantics.district.network,
- org.simantics.district.network.ontology
+ org.simantics.district.network.ontology,
+ org.simantics.district.maps
Bundle-ActivationPolicy: lazy
-<?xml version="1.0" encoding="UTF-8"?>\r
-<?eclipse version="3.4"?>\r
-<plugin>\r
- <extension\r
- point="org.eclipse.ui.importWizards">\r
- <wizard\r
- class="org.simantics.district.imports.ui.CSVImportWizard"\r
- id="org.simantics.district.imports.ui.csvimportwizard"\r
- name="Import CSV data to Simantics District">\r
- <description>\r
- Imports CSV data to Simantics District network\r
- </description>\r
- </wizard>\r
- </extension>\r
-</plugin>\r
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.ui.importWizards">
+ <wizard
+ class="org.simantics.district.imports.ui.CSVImportWizard"
+ id="org.simantics.district.imports.ui.csvimportwizard"
+ name="Import CSV data to Simantics District"
+ icon="icons/database_table.png">
+ <description>
+ Imports CSV data to Simantics District network
+ </description>
+ </wizard>
+ </extension>
+</plugin>
// Second page fills these
private char delimiter;
- private boolean read;
+ private boolean readFirstAsHeader = true;
private Map<String, Character> delimiters;
- private Path wktFile;
+// private Path wktFile;
// Vertex import
private int xCoordIndex = -1;
private int componentMappingIndex = -1;
private Map<String, Resource> componentMappings = new HashMap<>();
private boolean isVertexImport;
+ private String sourceCRS;
+ private int tempIndex;
+ private int pressureIndex;
+ private int diameterIndex;
+ private int outerDiamterIndex;
+ private int nominalMassFlowIndex;
// Third page
}
public void setReadFirstAsHeader(boolean read) {
- this.read = read;
+ this.readFirstAsHeader = read;
}
public Path getSource() {
public Map<CSVHeader, List<String>> getHeaderAndRows(int amount) throws IOException {
if (source != null)
- return DistrictImportUtils.readCSVHeaderAndRows(source, delimiter, read, amount);
+ return DistrictImportUtils.readCSVHeaderAndRows(source, delimiter, readFirstAsHeader, amount);
else
return Collections.emptyMap();
}
public Map<String, Integer> getHeader() throws IOException {
Map<String, Integer> header = null;
if (source != null)
- header = DistrictImportUtils.readCSVHeader(source, delimiter, read);
+ header = DistrictImportUtils.readCSVHeader(source, delimiter, readFirstAsHeader);
if (header == null)
header = Collections.emptyMap();
return header;
}
public boolean getReadFirstAsHeader() {
- return read;
+ return readFirstAsHeader;
}
public String[] getDelimiterFormats() {
public List<Map<String, String>> readRows(int amount) throws IOException {
if (source != null)
- return DistrictImportUtils.readRows(source, delimiter, read, amount);
+ return DistrictImportUtils.readRows(source, delimiter, readFirstAsHeader, amount);
else
return Collections.emptyList();
}
return delimiter;
}
- public Path getWKTFile() {
- return wktFile;
- }
+// public Path getWKTFile() {
+// return wktFile;
+// }
public int getXCoordIndex() {
return xCoordIndex;
return targetDiagram;
}
- public void setWKTFile(Path wktFile) {
- this.wktFile = wktFile;
- }
+// public void setWKTFile(Path wktFile) {
+// this.wktFile = wktFile;
+// }
public void setComponentMappings(String value, Resource resource) {
componentMappings.put(value, resource);
return endZCoordIndex;
}
+ public void setSourceCRS(String crs) {
+ this.sourceCRS = crs;
+ }
+
+ public String getSourceCRS() {
+ return sourceCRS;
+ }
+
+ public void setTempIndex(int tempIndex) {
+ this.tempIndex = tempIndex;
+ }
+
+ public int getTempIndex() {
+ return tempIndex;
+ }
+
+ public void setPressureIndex(int pressureIndex) {
+ this.pressureIndex = pressureIndex;
+ }
+
+ public int getPressureIndex() {
+ return pressureIndex;
+ }
+
+ public void setDiameterIndex(int parseInt) {
+ this.diameterIndex = parseInt;
+ }
+
+ public int getDiameterIndex() {
+ return diameterIndex;
+ }
+
+ public void setOuterDiameterIndex(int parseInt) {
+ this.outerDiamterIndex = parseInt;
+ }
+
+ public int getOuterDiamterIndex() {
+ return outerDiamterIndex;
+ }
+
+ public void setNominalMassFlowIndex(int parseInt) {
+ this.nominalMassFlowIndex = parseInt;
+ }
+
+ public int getNominalMassFlowIndex() {
+ return nominalMassFlowIndex;
+ }
+
}
package org.simantics.district.imports.ui;
-import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
import java.nio.file.Path;
import java.util.List;
import org.apache.commons.csv.CSVRecord;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.ui.IImportWizard;
import org.eclipse.ui.IWorkbench;
import org.geotools.geometry.DirectPosition2D;
import org.geotools.referencing.CRS;
import org.opengis.geometry.DirectPosition;
import org.opengis.geometry.MismatchedDimensionException;
-import org.opengis.referencing.FactoryException;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.operation.MathTransform;
import org.opengis.referencing.operation.TransformException;
import org.simantics.district.network.DistrictNetworkUtil;
import org.simantics.district.network.ontology.DistrictNetworkResource;
import org.simantics.district.network.ui.DNEdgeBuilder;
+import org.simantics.maps.MapScalingTransform;
+import org.simantics.utils.ui.ExceptionUtils;
public class CSVImportWizard extends Wizard implements IImportWizard {
@Override
public boolean performFinish() {
try {
-
-
- Path csvFile = model.getSource();
- char delim = model.getDelimiter();
-
- List<CSVRecord> rows = DistrictImportUtils.readRows(csvFile, delim, -1);
-
- Path wktFile = model.getWKTFile();
-
- int xCoordColumnIndex = model.getXCoordIndex();
- int yCoordColumnIndex = model.getYCoordIndex();
- int zCoordColumnIndex = model.getZCoordIndex();
-
- int startXCoordColumnIndex = model.getStartXCoordIndex();
- int startYCoordColumnIndex = model.getStartYCoordIndex();
- int startZValueColumnIndex = model.getStartZCoordIndex();
- int endXCoordColumnIndex = model.getEndXCoordIndex();
- int endYCoordColumnIndex = model.getEndYCoordIndex();
- int endZValueColumnIndex = model.getEndZCoordIndex();
-
- int mappingColumn = model.getComponentMappingIndex();
-
- try {
- CoordinateReferenceSystem sourceCRS = CRS.decode("EPSG:3879");
- CoordinateReferenceSystem targetCRS = CRS.decode("EPSG:4326");
- MathTransform transform = CRS.findMathTransform(sourceCRS, targetCRS, true);
-
- Simantics.getSession().syncRequest(new Write() {
-
- @Override
- public void perform(WriteGraph graph) throws DatabaseException {
- for (int k = 1; k < rows.size(); k++) {
- CSVRecord row = rows.get(k);
-
- String mappingValue = row.get(mappingColumn);
+ getContainer().run(true, true, new IRunnableWithProgress() {
- try {
- if (model.isVertexImport()) {
- String xCoords = row.get(xCoordColumnIndex);
- String yCoords = row.get(yCoordColumnIndex);
- double xCoord = Double.parseDouble(xCoords);
- double yCoord = Double.parseDouble(yCoords);
-
- String zs = row.get(zCoordColumnIndex);
- double z = Double.parseDouble(zs);
-
- DirectPosition2D targetPos = new DirectPosition2D();
- DirectPosition2D sourcePos = new DirectPosition2D(xCoord, yCoord);
- DirectPosition res = transform.transform(sourcePos, targetPos);
- double[] coords = res.getCoordinate();
- Resource vertex = DistrictNetworkUtil.createVertex(graph, model.getParentDiagram(), new double[] { coords[1], -coords[0]}, model.getComponentMappings().get(mappingValue));
- graph.claimLiteral(vertex, DistrictNetworkResource.getInstance(graph).Vertex_HasElevation, z, Bindings.DOUBLE);
- } else {
- String startXCoords = row.get(startXCoordColumnIndex);
- String startYCoords = row.get(startYCoordColumnIndex);
- String endXCoords = row.get(endXCoordColumnIndex);
- String endYCoords = row.get(endYCoordColumnIndex);
-
- double startXCoord = Double.parseDouble(startXCoords);
- double startYCoord = Double.parseDouble(startYCoords);
-
- double endXCoord = Double.parseDouble(endXCoords);
- double endYCoord = Double.parseDouble(endYCoords);
-
- DirectPosition2D startTargetPos = new DirectPosition2D();
- DirectPosition2D startSourcePos = new DirectPosition2D(startXCoord, startYCoord);
- DirectPosition startRes = transform.transform(startSourcePos, startTargetPos);
- double[] startCoords = startRes.getCoordinate();
-
- DirectPosition2D endTargetPos = new DirectPosition2D();
- DirectPosition2D endSourcePos = new DirectPosition2D(endXCoord, endYCoord);
- DirectPosition endRes = transform.transform(endSourcePos, endTargetPos);
- double[] endCoords = endRes.getCoordinate();
+ @Override
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ try {
+ Path csvFile = model.getSource();
+ char delim = model.getDelimiter();
+
+ List<CSVRecord> rows = DistrictImportUtils.readRows(csvFile, delim, -1);
+
+ // Path wktFile = model.getWKTFile();
+
+ int xCoordColumnIndex = model.getXCoordIndex();
+ int yCoordColumnIndex = model.getYCoordIndex();
+ int zCoordColumnIndex = model.getZCoordIndex();
+ int tempColumnIndex = model.getTempIndex();
+ int pressureColumnIndex = model.getPressureIndex();
+
+ int startXCoordColumnIndex = model.getStartXCoordIndex();
+ int startYCoordColumnIndex = model.getStartYCoordIndex();
+ int startZValueColumnIndex = model.getStartZCoordIndex();
+ int endXCoordColumnIndex = model.getEndXCoordIndex();
+ int endYCoordColumnIndex = model.getEndYCoordIndex();
+ int endZValueColumnIndex = model.getEndZCoordIndex();
+ int diameterColumnIndex= model.getDiameterIndex();
+ int outerDiameterColumnIndex = model.getOuterDiamterIndex();
+ int nominalMassFlowIndex = model.getNominalMassFlowIndex();
+
+ int mappingColumn = model.getComponentMappingIndex();
+
+ String sourceEPSGCRS = model.getSourceCRS();
+
+ MathTransform transform = null;
+ boolean doTransform = false;
+ // if sourceEPSGCRS is empty || null then ignore transformation
+ if (sourceEPSGCRS != null && !sourceEPSGCRS.isEmpty()) {
+ CoordinateReferenceSystem sourceCRS = CRS.decode(sourceEPSGCRS);
+ CoordinateReferenceSystem targetCRS = CRS.decode("EPSG:4326");
+ transform = CRS.findMathTransform(sourceCRS, targetCRS, true);
+ doTransform = true;
+ }
+ final boolean actualDoTransform = doTransform;
+ final MathTransform actualTransform = transform;
+ Simantics.getSession().syncRequest(new Write() {
+
+ @Override
+ public void perform(WriteGraph graph) throws DatabaseException {
+
+ DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
+
+ for (int k = 1; k < rows.size(); k++) {
+ CSVRecord row = rows.get(k);
- Resource edge = DNEdgeBuilder.create(graph, model.getParentDiagram(), new double[] { startCoords[1], -startCoords[0]}, new double[] { endCoords[1], -endCoords[0]}, 0.0000001);
- graph.claim(edge, DistrictNetworkResource.getInstance(graph).HasMapping, model.getComponentMappings().get(mappingValue));
-// graph.claimLiteral(edge, DistrictNetworkResource.getInstance(graph).Edge_HasDiameter, value);
+ String mappingValue = row.get(mappingColumn);
+
+ try {
+ if (model.isVertexImport()) {
+ String xCoords = row.get(xCoordColumnIndex);
+ String yCoords = row.get(yCoordColumnIndex);
+ double xCoord = Double.parseDouble(xCoords);
+ double yCoord = Double.parseDouble(yCoords);
+
+ String zs = row.get(zCoordColumnIndex);
+ double z = 0;
+ if (!zs.isEmpty()) {
+ try {
+ z = Double.parseDouble(zs);
+ } catch (NumberFormatException e) {
+ throw new DatabaseException(e);
+ }
+ }
+
+ double[] coords;
+ if (actualDoTransform) {
+ DirectPosition2D targetPos = new DirectPosition2D();
+ DirectPosition2D sourcePos = new DirectPosition2D(xCoord, yCoord);
+ DirectPosition res = actualTransform.transform(sourcePos, targetPos);
+ coords = res.getCoordinate();
+ } else {
+ coords = new double[] { xCoord / MapScalingTransform.getScaleX(), yCoord / MapScalingTransform.getScaleY() };
+ }
+ Resource vertex = DistrictNetworkUtil.createVertex(graph, model.getParentDiagram(), new double[] { coords[1], -coords[0]}, model.getComponentMappings().get(mappingValue));
+
+ graph.claimLiteral(vertex, DN.Vertex_HasElevation, z, Bindings.DOUBLE);
+
+ String tempS = row.get(tempColumnIndex);
+ if (!tempS.isEmpty()) {
+ try {
+ double temp = Double.parseDouble(tempS);
+ graph.claimLiteral(vertex, DN.Vertex_HasTemperature, temp, Bindings.DOUBLE);
+ } catch (NumberFormatException e) {
+ throw new DatabaseException(e);
+ }
+ }
+ String pressureS = row.get(pressureColumnIndex);
+ if (!pressureS.isEmpty()) {
+ try {
+ double pressure = Double.parseDouble(pressureS);
+ graph.claimLiteral(vertex, DN.Vertex_HasPressure, pressure, Bindings.DOUBLE);
+ } catch (NumberFormatException e) {
+ throw new DatabaseException(e);
+ }
+ }
+
+ } else {
+ String startXCoords = row.get(startXCoordColumnIndex);
+ String startYCoords = row.get(startYCoordColumnIndex);
+ String endXCoords = row.get(endXCoordColumnIndex);
+ String endYCoords = row.get(endYCoordColumnIndex);
+
+ double startXCoord = Double.parseDouble(startXCoords);
+ double startYCoord = Double.parseDouble(startYCoords);
+
+ double endXCoord = Double.parseDouble(endXCoords);
+ double endYCoord = Double.parseDouble(endYCoords);
+
+ double[] startCoords;
+ double[] endCoords;
+ if (actualDoTransform) {
+ DirectPosition2D startTargetPos = new DirectPosition2D();
+ DirectPosition2D startSourcePos = new DirectPosition2D(startXCoord, startYCoord);
+ DirectPosition startRes = actualTransform.transform(startSourcePos, startTargetPos);
+ startCoords = startRes.getCoordinate();
+
+ DirectPosition2D endTargetPos = new DirectPosition2D();
+ DirectPosition2D endSourcePos = new DirectPosition2D(endXCoord, endYCoord);
+ DirectPosition endRes = actualTransform.transform(endSourcePos, endTargetPos);
+ endCoords = endRes.getCoordinate();
+ } else {
+ startCoords = new double[] { startXCoord / MapScalingTransform.getScaleX(), startYCoord / MapScalingTransform.getScaleY() };
+ endCoords = new double[] { endXCoord / MapScalingTransform.getScaleX(), endYCoord / MapScalingTransform.getScaleY() };
+ }
+
+ Resource edge = DNEdgeBuilder.create(graph, model.getParentDiagram(), new double[] { startCoords[1], -startCoords[0]}, new double[] { endCoords[1], -endCoords[0]}, 0.0000001);
+ graph.claim(edge, DistrictNetworkResource.getInstance(graph).HasMapping, model.getComponentMappings().get(mappingValue));
+
+ String diameterS = row.get(diameterColumnIndex);
+ if (!diameterS.isEmpty()) {
+ try {
+ double diameter = Double.parseDouble(diameterS);
+ graph.claimLiteral(edge, DN.Edge_HasDiameter, diameter);
+ } catch (NumberFormatException e) {
+ throw new DatabaseException(e);
+ }
+ }
+ String outerDiameterS = row.get(outerDiameterColumnIndex);
+ if (!outerDiameterS.isEmpty()) {
+ try {
+ double outerDiameter = Double.parseDouble(outerDiameterS);
+ graph.claimLiteral(edge, DN.Edge_HasOuterDiameter, outerDiameter);
+ } catch (NumberFormatException e) {
+ throw new DatabaseException(e);
+ }
+ }
+ String nominalMassFlowS = row.get(nominalMassFlowIndex);
+ if (!nominalMassFlowS.isEmpty()) {
+ try {
+ double nominalMassFlow = Double.parseDouble(nominalMassFlowS);
+ graph.claimLiteral(edge, DN.Edge_HasNominalMassFlow, nominalMassFlow);
+ } catch (NumberFormatException e) {
+ throw new DatabaseException(e);
+ }
+ }
+ }
+ } catch (MismatchedDimensionException | TransformException | DatabaseException e) {
+ throw new DatabaseException(e);
+ }
}
- } catch (MismatchedDimensionException | TransformException | DatabaseException e) {
- e.printStackTrace();
}
-
- }
+ });
+ } catch (Exception e) {
+ throw new InvocationTargetException(e);
}
- });
- return true;
- } catch (FactoryException | DatabaseException e) {
- e.printStackTrace();
- }
-
- } catch (IOException e) {
- e.printStackTrace();
+ }
+ });
+ return true;
+ } catch (InvocationTargetException e) {
+ Throwable t = e.getTargetException();
+ WizardPage cp = (WizardPage) getContainer().getCurrentPage();
+ cp.setErrorMessage(t.getMessage());
+ ExceptionUtils.logAndShowError(t);
+ return false;
+ } catch (InterruptedException e) {
+ ExceptionUtils.logAndShowError(e);
+ return false;
}
- return false;
}
-
}
package org.simantics.district.imports.ui;
import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Set;
import org.apache.commons.csv.CSVRecord;
import org.eclipse.jface.dialogs.IPageChangeProvider;
import org.eclipse.jface.wizard.IWizardContainer;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
+import org.geotools.referencing.CRS;
import org.simantics.district.imports.ui.controls.DynamicComboFieldEditor;
-import org.simantics.utils.ui.widgets.FileOrDirectorySelectionWidget;
-import org.simantics.utils.ui.widgets.FileSelectionListener;
-import org.simantics.utils.ui.widgets.FileSelectionWidget;
public class CSVImportWizardPage extends WizardPage {
private Map<Integer, String> headerIndexAndValues = new HashMap<>();
private Table headerTable;
- private Button firstAsHeader;
+// private Button firstAsHeader;
private Combo delimiterCombo;
private TableColumnLayout tableColumnLayout;
private Composite tableComposite;
- private FileSelectionWidget wktFileSelection;
+// private FileSelectionWidget wktFileSelection;
// Common for vertex and edge
private DynamicComboFieldEditor componentMappingSelector;
private DynamicComboFieldEditor endXCoordSelector;
private DynamicComboFieldEditor endYCoordSelector;
private DynamicComboFieldEditor endZValueSelector;
+ private DynamicComboFieldEditor tempValueSelector;
+ private DynamicComboFieldEditor pressureValueSelector;
+
+ private DynamicComboFieldEditor outerDiameterSelector;
+ private DynamicComboFieldEditor diameterSelector;
+ private DynamicComboFieldEditor nominalMassFlowSelector;
private Group indexMappingGroup;
private Composite composite;
private Button isVertexImport;
+
+ private Combo sourceCRSCombo;
protected CSVImportWizardPage(CSVImportModel model) {
super("Import CSV Data");
this.model = model;
- setMessage("Select columng index mappings");
+ setMessage("Select column index mappings");
}
@Override
composite.setLayout(new GridLayout(1, false));
GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).applyTo(composite);
+ Label label = new Label(composite, SWT.NONE);
+ label.setText("Select delimiter");
+
delimiterCombo = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY);
+ delimiterCombo.setToolTipText("Select the delimiter that is used to separate elements in the CSV file");
delimiterCombo.setItems(model.getDelimiterFormats());
delimiterCombo.addSelectionListener(new SelectionListener() {
}
});
- firstAsHeader = new Button(composite, SWT.CHECK);
- firstAsHeader.setText("Read first row as header");
- firstAsHeader.setSelection(model.getReadFirstAsHeader());
- firstAsHeader.addSelectionListener(new SelectionListener() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- model.setReadFirstAsHeader(firstAsHeader.getSelection());
- updateHeaders();
- updateCombos();
- }
-
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
-
- }
- });
+// firstAsHeader = new Button(composite, SWT.CHECK);
+// firstAsHeader.setText("Read first row as header");
+// firstAsHeader.setSelection(model.getReadFirstAsHeader());
+// firstAsHeader.addSelectionListener(new SelectionListener() {
+//
+// @Override
+// public void widgetSelected(SelectionEvent e) {
+// model.setReadFirstAsHeader(firstAsHeader.getSelection());
+// updateHeaders();
+// updateCombos();
+// }
+//
+// @Override
+// public void widgetDefaultSelected(SelectionEvent e) {
+// widgetSelected(e);
+// }
+// });
tableComposite = new Composite(composite, SWT.BORDER);
tableColumnLayout = new TableColumnLayout();
tableComposite.setLayout(tableColumnLayout);
- wktFileSelection = new FileSelectionWidget(composite, "WKT file", SWT.OPEN);
- wktFileSelection.addListener(new FileSelectionListener() {
-
+ label = new Label(composite, SWT.NONE);
+ label.setText("Select source Coordinate Reference System");
+
+ sourceCRSCombo = new Combo(composite, SWT.NONE);
+ sourceCRSCombo.setToolTipText("Select the coordinate reference system that is used in the source material for possible transformation to target coordinate reference system (EPSG:4326)");
+ Set<String> codes = CRS.getSupportedCodes("EPSG");
+ sourceCRSCombo.setItems(codes.toArray(new String[codes.size()]));
+ sourceCRSCombo.addSelectionListener(new SelectionAdapter() {
+
@Override
- public void fileSelected(FileOrDirectorySelectionWidget source, String[] filename) {
- String[] selection = wktFileSelection.getFilename();
- if (selection != null && selection.length > 0) {
- Path wktFile = Paths.get(selection[0]);
- if (!Files.exists(wktFile)) {
- setErrorMessage("File " + wktFile.toAbsolutePath() + " does not exist");
- } else {
- model.setWKTFile(wktFile);
- validatePageComplete();
- }
- }
+ public void widgetSelected(SelectionEvent e) {
+ String current = sourceCRSCombo.getItem(sourceCRSCombo.getSelectionIndex());
+ model.setSourceCRS("EPSG:" + current);
}
});
+
+// wktFileSelection = new FileSelectionWidget(composite, "WKT file", SWT.OPEN);
+// wktFileSelection.addListener(new FileSelectionListener() {
+//
+// @Override
+// public void fileSelected(FileOrDirectorySelectionWidget source, String[] filename) {
+// String[] selection = wktFileSelection.getFilename();
+// if (selection != null && selection.length > 0) {
+// Path wktFile = Paths.get(selection[0]);
+// if (!Files.exists(wktFile)) {
+// setErrorMessage("File " + wktFile.toAbsolutePath() + " does not exist");
+// } else {
+// model.setWKTFile(wktFile);
+// validatePageComplete();
+// }
+// }
+// }
+// });
isVertexImport = new Button(composite, SWT.CHECK);
isVertexImport.setText("File contains vertices");
+ isVertexImport.setToolTipText("Enable this if the file contains vertices, i.e. points");
isVertexImport.setSelection(model.isVertexImport());
isVertexImport.addSelectionListener(new SelectionListener() {
validatePageComplete();
}
});
+ tempValueSelector = new DynamicComboFieldEditor("tempValue", "Temperature value", parent);
+ tempValueSelector.addComboListener(new SelectionListener() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ widgetDefaultSelected(e);
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ model.setTempIndex(Integer.parseInt(tempValueSelector.getValue()));
+ validatePageComplete();
+ }
+ });
+ pressureValueSelector = new DynamicComboFieldEditor("pressureValue", "Pressure value", parent);
+ pressureValueSelector.addComboListener(new SelectionListener() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ widgetDefaultSelected(e);
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ model.setPressureIndex(Integer.parseInt(pressureValueSelector.getValue()));
+ validatePageComplete();
+ }
+ });
}
private void createEdgeIndexMappingField(Group parent) {
validatePageComplete();
}
});
+ diameterSelector = new DynamicComboFieldEditor("diameterValue", "Diameter value", parent);
+ diameterSelector.addComboListener(new SelectionListener() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ widgetDefaultSelected(e);
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ model.setDiameterIndex(Integer.parseInt(diameterSelector.getValue()));
+ validatePageComplete();
+ }
+ });
+ outerDiameterSelector = new DynamicComboFieldEditor("outerDiameterValue", "Outer Diameter value", parent);
+ outerDiameterSelector.addComboListener(new SelectionListener() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ widgetDefaultSelected(e);
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ model.setOuterDiameterIndex(Integer.parseInt(outerDiameterSelector.getValue()));
+ validatePageComplete();
+ }
+ });
+ nominalMassFlowSelector = new DynamicComboFieldEditor("nominalMassFlowValue", "Nominal Mass Flow", parent);
+ nominalMassFlowSelector.addComboListener(new SelectionListener() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ widgetDefaultSelected(e);
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ model.setNominalMassFlowIndex(Integer.parseInt(nominalMassFlowSelector.getValue()));
+ validatePageComplete();
+ }
+ });
}
private void updateCombos() {
}
if (model.isVertexImport())
- updateVertexcombos(namesAndValues);
+ updateVertexCombos(namesAndValues);
else
updateEdgeCombos(namesAndValues);
endYCoordSelector.updateCombo(namesAndValues);
startZValueSelector.updateCombo(namesAndValues);
endZValueSelector.updateCombo(namesAndValues);
+ diameterSelector.updateCombo(namesAndValues);
+ outerDiameterSelector.updateCombo(namesAndValues);
+ nominalMassFlowSelector.updateCombo(namesAndValues);
}
- private void updateVertexcombos(String[][] namesAndValues) {
+ private void updateVertexCombos(String[][] namesAndValues) {
xCoordSelector.updateCombo(namesAndValues);
yCoordSelector.updateCombo(namesAndValues);
zValueSelector.updateCombo(namesAndValues);
+ pressureValueSelector.updateCombo(namesAndValues);
+ tempValueSelector.updateCombo(namesAndValues);
}
private void updateHeaders() {
public static Map<String, Character> getSupportedCSVDelimiterFormats() {
Map<String, Character> delimiters = new HashMap<>();
- delimiters.put("COMMA", ',');
- delimiters.put("SEMICOMMA", ';');
+ delimiters.put("Comma", ',');
+ delimiters.put("Semicolon", ';');
return delimiters;
}
L0.HasRange L0.Double
L0.readOnly false
+DN.Vertex.HasTemperature <R L0.HasProperty : SEL.GenericParameterType
+ L0.HasLabel "Temperature"
+ L0.HasRange L0.Double
+ L0.readOnly false
+
+DN.Vertex.HasPressure <R L0.HasProperty : SEL.GenericParameterType
+ L0.HasLabel "Pressure"
+ L0.HasRange L0.Double
+ L0.readOnly false
+
DN.Edge.HasOuterDiameter <R L0.HasProperty : SEL.GenericParameterType
L0.HasLabel "Outer Diameter"
L0.HasRange L0.Double
L0.readOnly false
+DN.Edge.HasNominalMassFlow <R L0.HasProperty : SEL.GenericParameterType
+ L0.HasLabel "Nominal Mass Flow"
+ L0.HasRange L0.Double
+ L0.readOnly false
+
+
DN.InLayer
@L0.defTag
@L0.tag L0.Abstract
DN.Mapping.VertexMapping <T DN.Mapping.Base
>-- DN.Mapping.ComponentType --> STR.ComponentType <R L0.DependsOn
>-- DN.Mapping.VertexMapping.ElevationAttribute --> L0.String <R L0.HasProperty
+ >-- DN.Mapping.VertexMapping.TemperatureAttribute --> L0.String <R L0.HasProperty
+ >-- DN.Mapping.VertexMapping.PressureAttribute --> L0.String <R L0.HasProperty
>-- DN.Mapping.Terminals --> DN.Mapping.TerminalPair <R L0.HasProperty
DN.Mapping.EdgeMapping <T DN.Mapping.Base
>-- DN.Mapping.ComponentType
>-- DN.Mapping.EdgeMapping.LengthAttribute --> L0.String <R L0.HasProperty
>-- DN.Mapping.EdgeMapping.DiameterAttribute --> L0.String <R L0.HasProperty
+ >-- DN.Mapping.EdgeMapping.OuterDiameterAttribute --> L0.String <R L0.HasProperty
+ >-- DN.Mapping.EdgeMapping.NominalMassFlowAttribute --> L0.String <R L0.HasProperty
>-- DN.Mapping.Terminals
public final Resource Edge_HasDiameter_Inverse;
public final Resource Edge_HasLength;
public final Resource Edge_HasLength_Inverse;
+ public final Resource Edge_HasNominalMassFlow;
+ public final Resource Edge_HasNominalMassFlow_Inverse;
public final Resource Edge_HasOuterDiameter;
public final Resource Edge_HasOuterDiameter_Inverse;
public final Resource Functions;
public final Resource Mapping_EdgeMapping_DiameterAttribute_Inverse;
public final Resource Mapping_EdgeMapping_LengthAttribute;
public final Resource Mapping_EdgeMapping_LengthAttribute_Inverse;
+ public final Resource Mapping_EdgeMapping_NominalMassFlowAttribute;
+ public final Resource Mapping_EdgeMapping_NominalMassFlowAttribute_Inverse;
+ public final Resource Mapping_EdgeMapping_OuterDiameterAttribute;
+ public final Resource Mapping_EdgeMapping_OuterDiameterAttribute_Inverse;
public final Resource Mapping_InputTerminal;
public final Resource Mapping_InputTerminal_Inverse;
public final Resource Mapping_OutputTerminal;
public final Resource Mapping_VertexMapping;
public final Resource Mapping_VertexMapping_ElevationAttribute;
public final Resource Mapping_VertexMapping_ElevationAttribute_Inverse;
+ public final Resource Mapping_VertexMapping_PressureAttribute;
+ public final Resource Mapping_VertexMapping_PressureAttribute_Inverse;
+ public final Resource Mapping_VertexMapping_TemperatureAttribute;
+ public final Resource Mapping_VertexMapping_TemperatureAttribute_Inverse;
public final Resource SpatialRefSystem;
public final Resource Vertex;
public final Resource VertexDefaultMapping;
public final Resource VertexMappingParameterType;
public final Resource Vertex_HasElevation;
public final Resource Vertex_HasElevation_Inverse;
+ public final Resource Vertex_HasPressure;
+ public final Resource Vertex_HasPressure_Inverse;
+ public final Resource Vertex_HasTemperature;
+ public final Resource Vertex_HasTemperature_Inverse;
public static class URIs {
public static final String ActionContext = "http://www.simantics.org/DistrictNetwork-1.0/ActionContext";
public static final String Edge_HasDiameter_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Edge/HasDiameter/Inverse";
public static final String Edge_HasLength = "http://www.simantics.org/DistrictNetwork-1.0/Edge/HasLength";
public static final String Edge_HasLength_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Edge/HasLength/Inverse";
+ public static final String Edge_HasNominalMassFlow = "http://www.simantics.org/DistrictNetwork-1.0/Edge/HasNominalMassFlow";
+ public static final String Edge_HasNominalMassFlow_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Edge/HasNominalMassFlow/Inverse";
public static final String Edge_HasOuterDiameter = "http://www.simantics.org/DistrictNetwork-1.0/Edge/HasOuterDiameter";
public static final String Edge_HasOuterDiameter_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Edge/HasOuterDiameter/Inverse";
public static final String Functions = "http://www.simantics.org/DistrictNetwork-1.0/Functions";
public static final String Mapping_EdgeMapping_DiameterAttribute_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/EdgeMapping/DiameterAttribute/Inverse";
public static final String Mapping_EdgeMapping_LengthAttribute = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/EdgeMapping/LengthAttribute";
public static final String Mapping_EdgeMapping_LengthAttribute_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/EdgeMapping/LengthAttribute/Inverse";
+ public static final String Mapping_EdgeMapping_NominalMassFlowAttribute = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/EdgeMapping/NominalMassFlowAttribute";
+ public static final String Mapping_EdgeMapping_NominalMassFlowAttribute_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/EdgeMapping/NominalMassFlowAttribute/Inverse";
+ public static final String Mapping_EdgeMapping_OuterDiameterAttribute = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/EdgeMapping/OuterDiameterAttribute";
+ public static final String Mapping_EdgeMapping_OuterDiameterAttribute_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/EdgeMapping/OuterDiameterAttribute/Inverse";
public static final String Mapping_InputTerminal = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/InputTerminal";
public static final String Mapping_InputTerminal_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/InputTerminal/Inverse";
public static final String Mapping_OutputTerminal = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/OutputTerminal";
public static final String Mapping_VertexMapping = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping";
public static final String Mapping_VertexMapping_ElevationAttribute = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/ElevationAttribute";
public static final String Mapping_VertexMapping_ElevationAttribute_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/ElevationAttribute/Inverse";
+ public static final String Mapping_VertexMapping_PressureAttribute = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/PressureAttribute";
+ public static final String Mapping_VertexMapping_PressureAttribute_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/PressureAttribute/Inverse";
+ public static final String Mapping_VertexMapping_TemperatureAttribute = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/TemperatureAttribute";
+ public static final String Mapping_VertexMapping_TemperatureAttribute_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/TemperatureAttribute/Inverse";
public static final String SpatialRefSystem = "http://www.simantics.org/DistrictNetwork-1.0/SpatialRefSystem";
public static final String Vertex = "http://www.simantics.org/DistrictNetwork-1.0/Vertex";
public static final String VertexDefaultMapping = "http://www.simantics.org/DistrictNetwork-1.0/VertexDefaultMapping";
public static final String VertexMappingParameterType = "http://www.simantics.org/DistrictNetwork-1.0/VertexMappingParameterType";
public static final String Vertex_HasElevation = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasElevation";
public static final String Vertex_HasElevation_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasElevation/Inverse";
+ public static final String Vertex_HasPressure = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasPressure";
+ public static final String Vertex_HasPressure_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasPressure/Inverse";
+ public static final String Vertex_HasTemperature = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasTemperature";
+ public static final String Vertex_HasTemperature_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasTemperature/Inverse";
}
public static Resource getResourceOrNull(ReadGraph graph, String uri) {
Edge_HasDiameter_Inverse = getResourceOrNull(graph, URIs.Edge_HasDiameter_Inverse);
Edge_HasLength = getResourceOrNull(graph, URIs.Edge_HasLength);
Edge_HasLength_Inverse = getResourceOrNull(graph, URIs.Edge_HasLength_Inverse);
+ Edge_HasNominalMassFlow = getResourceOrNull(graph, URIs.Edge_HasNominalMassFlow);
+ Edge_HasNominalMassFlow_Inverse = getResourceOrNull(graph, URIs.Edge_HasNominalMassFlow_Inverse);
Edge_HasOuterDiameter = getResourceOrNull(graph, URIs.Edge_HasOuterDiameter);
Edge_HasOuterDiameter_Inverse = getResourceOrNull(graph, URIs.Edge_HasOuterDiameter_Inverse);
Functions = getResourceOrNull(graph, URIs.Functions);
Mapping_EdgeMapping_DiameterAttribute_Inverse = getResourceOrNull(graph, URIs.Mapping_EdgeMapping_DiameterAttribute_Inverse);
Mapping_EdgeMapping_LengthAttribute = getResourceOrNull(graph, URIs.Mapping_EdgeMapping_LengthAttribute);
Mapping_EdgeMapping_LengthAttribute_Inverse = getResourceOrNull(graph, URIs.Mapping_EdgeMapping_LengthAttribute_Inverse);
+ Mapping_EdgeMapping_NominalMassFlowAttribute = getResourceOrNull(graph, URIs.Mapping_EdgeMapping_NominalMassFlowAttribute);
+ Mapping_EdgeMapping_NominalMassFlowAttribute_Inverse = getResourceOrNull(graph, URIs.Mapping_EdgeMapping_NominalMassFlowAttribute_Inverse);
+ Mapping_EdgeMapping_OuterDiameterAttribute = getResourceOrNull(graph, URIs.Mapping_EdgeMapping_OuterDiameterAttribute);
+ Mapping_EdgeMapping_OuterDiameterAttribute_Inverse = getResourceOrNull(graph, URIs.Mapping_EdgeMapping_OuterDiameterAttribute_Inverse);
Mapping_InputTerminal = getResourceOrNull(graph, URIs.Mapping_InputTerminal);
Mapping_InputTerminal_Inverse = getResourceOrNull(graph, URIs.Mapping_InputTerminal_Inverse);
Mapping_OutputTerminal = getResourceOrNull(graph, URIs.Mapping_OutputTerminal);
Mapping_VertexMapping = getResourceOrNull(graph, URIs.Mapping_VertexMapping);
Mapping_VertexMapping_ElevationAttribute = getResourceOrNull(graph, URIs.Mapping_VertexMapping_ElevationAttribute);
Mapping_VertexMapping_ElevationAttribute_Inverse = getResourceOrNull(graph, URIs.Mapping_VertexMapping_ElevationAttribute_Inverse);
+ Mapping_VertexMapping_PressureAttribute = getResourceOrNull(graph, URIs.Mapping_VertexMapping_PressureAttribute);
+ Mapping_VertexMapping_PressureAttribute_Inverse = getResourceOrNull(graph, URIs.Mapping_VertexMapping_PressureAttribute_Inverse);
+ Mapping_VertexMapping_TemperatureAttribute = getResourceOrNull(graph, URIs.Mapping_VertexMapping_TemperatureAttribute);
+ Mapping_VertexMapping_TemperatureAttribute_Inverse = getResourceOrNull(graph, URIs.Mapping_VertexMapping_TemperatureAttribute_Inverse);
SpatialRefSystem = getResourceOrNull(graph, URIs.SpatialRefSystem);
Vertex = getResourceOrNull(graph, URIs.Vertex);
VertexDefaultMapping = getResourceOrNull(graph, URIs.VertexDefaultMapping);
VertexMappingParameterType = getResourceOrNull(graph, URIs.VertexMappingParameterType);
Vertex_HasElevation = getResourceOrNull(graph, URIs.Vertex_HasElevation);
Vertex_HasElevation_Inverse = getResourceOrNull(graph, URIs.Vertex_HasElevation_Inverse);
+ Vertex_HasPressure = getResourceOrNull(graph, URIs.Vertex_HasPressure);
+ Vertex_HasPressure_Inverse = getResourceOrNull(graph, URIs.Vertex_HasPressure_Inverse);
+ Vertex_HasTemperature = getResourceOrNull(graph, URIs.Vertex_HasTemperature);
+ Vertex_HasTemperature_Inverse = getResourceOrNull(graph, URIs.Vertex_HasTemperature_Inverse);
}
public static DistrictNetworkResource getInstance(ReadGraph graph) {
super.initializeCanvasContext(ctx);
IHintContext h = ctx.getDefaultHintContext();
h.setHint(PanZoomRotateHandler.KEY_ZOOM_IN_LIMIT, 1000000.0);
- h.setHint(PanZoomRotateHandler.KEY_ZOOM_OUT_LIMIT, 0.01);
+ h.setHint(PanZoomRotateHandler.KEY_ZOOM_OUT_LIMIT, 0.003);
}
@Override