forked from linkedgeodesy/myfirstqgisplugin
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed errormessage dialog and added triple store result detection dialog
- Loading branch information
Showing
6 changed files
with
268 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
from qgis.PyQt.QtWidgets import QDialog | ||
from qgis.PyQt.QtWidgets import QStyle | ||
from qgis.PyQt.QtGui import QIcon | ||
from ...util.ui.uiutils import UIUtils | ||
import os | ||
import json | ||
from qgis.PyQt.QtGui import QRegExpValidator | ||
from qgis.PyQt import uic | ||
|
||
FORM_CLASS, _ = uic.loadUiType(os.path.join( | ||
os.path.dirname(__file__), '../ui/detecttriplestoreresultdialog.ui')) | ||
|
||
class DetectTripleStoreResultDialog(QDialog, FORM_CLASS): | ||
|
||
def __init__(self,parentdialog,triplestoreconf,triplestorename,triplestorechooser,prefixes,configuration,permanentAdd,capabilities,missingproperties,typeproperty="http://www.w3.org/1999/02/22-rdf-syntax-ns#type",subclassofproperty="http://www.w3.org/2000/01/rdf-schema#subClassOf"): | ||
QDialog.__init__(self,parentdialog) | ||
self.setupUi(self) | ||
self.setWindowTitle("Triple Store Detection Result") | ||
self.setWindowIcon(QIcon(self.style().standardIcon(getattr(QStyle, 'SP_MessageBoxInformation')))) | ||
self.parentdialog=parentdialog | ||
self.permanentAdd=permanentAdd | ||
self.missingproperties=missingproperties | ||
self.triplestoreconf=triplestoreconf | ||
self.triplestorename=triplestorename | ||
self.tripleStoreChooser=triplestorechooser | ||
self.prefixes=prefixes | ||
self.configuration=configuration | ||
self.capabilitiesLabel.setText(capabilities) | ||
if len(self.missingproperties)>0: | ||
self.propertiesMissingLabel.setText("<html><font color=red><b>The plugin could not detect type or subclass properties for this triple store.<br/> Please provide them for the ClassTree View to work properly</font></b></html>") | ||
if "typeproperty" not in self.missingproperties: | ||
self.typePropertyEdit.setText(self.configuration["typeproperty"]) | ||
self.typePropertyEdit.setValidator(QRegExpValidator(UIUtils.urlregex, self)) | ||
self.typePropertyEdit.textChanged.connect(lambda: UIUtils.check_state(self.typePropertyEdit)) | ||
self.typePropertyEdit.textChanged.emit(self.typePropertyEdit.text()) | ||
if "subclassproperty" not in self.missingproperties: | ||
self.typePropertyEdit.setText(self.configuration["subclassproperty"]) | ||
self.subClassOfEdit.setText(self.configuration["subclassproperty"]) | ||
self.subClassOfEdit.setValidator(QRegExpValidator(UIUtils.urlregex, self)) | ||
self.subClassOfEdit.textChanged.connect(lambda: UIUtils.check_state(self.subClassOfEdit)) | ||
self.subClassOfEdit.textChanged.emit(self.subClassOfEdit.text()) | ||
self.geoPropertyEdit.setValidator(QRegExpValidator(UIUtils.urlregex, self)) | ||
self.geoPropertyEdit.textChanged.connect(lambda: UIUtils.check_state(self.geoPropertyEdit)) | ||
self.geoPropertyEdit.textChanged.emit(self.geoPropertyEdit.text()) | ||
self.stackedWidget.show() | ||
else: | ||
self.stackedWidget.hide() | ||
self.addTripleStoreButton.clicked.connect(self.addConfiguration) | ||
self.cancelButton.clicked.connect(self.close) | ||
self.show() | ||
|
||
|
||
def addConfiguration(self): | ||
if self.missingproperties: | ||
if self.typePropertyEdit.text()=="": | ||
self.configuration["typeproperty"]="http://www.w3.org/1999/02/22-rdf-syntax-ns#type" | ||
else: | ||
self.configuration["typeproperty"]=self.typePropertyEdit.text() | ||
if self.subClassOfEdit.text()=="": | ||
self.configuration["subclassproperty"]="http://www.w3.org/2000/01/rdf-schema#subClassOf" | ||
else: | ||
self.configuration["subclassproperty"]=self.subClassOfEdit.text() | ||
if "type" in self.configuration and self.configuration["type"] == "geosparqlendpoint": | ||
self.tripleStoreChooser.addItem(UIUtils.geoendpointicon, self.triplestorename + " [GeoSPARQL Endpoint]") | ||
else: | ||
self.tripleStoreChooser.addItem(UIUtils.linkeddataicon, self.triplestorename + " [SPARQL Endpoint]") | ||
index = len(self.triplestoreconf) | ||
self.triplestoreconf.append({}) | ||
self.triplestoreconf[index] = self.configuration | ||
self.addTripleStore = False | ||
self.prefixes.append("") | ||
for prefix in self.configuration["prefixes"]: | ||
self.prefixes[len(self.prefixes) - 1] += "PREFIX " + prefix + ":<" + self.configuration["prefixes"][ | ||
prefix] + ">\n" | ||
if self.permanentAdd is not None and self.permanentAdd: | ||
__location__ = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__))) | ||
f = open(os.path.join(__location__, 'triplestoreconf_personal.json'), "w") | ||
f.write(json.dumps(self.triplestoreconf, indent=2)) | ||
f.close() | ||
if self.tripleStoreChooser is not None: | ||
# self.tripleStoreChooser.addItem(self.triplestorename) | ||
self.tripleStoreChooser.setCurrentIndex(self.tripleStoreChooser.count() - 1) | ||
if self.parentdialog is not None: | ||
self.parentdialog.close() | ||
self.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>Dialog</class> | ||
<widget class="QDialog" name="Dialog"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>291</width> | ||
<height>260</height> | ||
</rect> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>Dialog</string> | ||
</property> | ||
<property name="windowIcon"> | ||
<iconset> | ||
<normaloff>:/icons/resources/icons/featurecollectionToRDF.png</normaloff>:/icons/resources/icons/featurecollectionToRDF.png</iconset> | ||
</property> | ||
<layout class="QGridLayout" name="gridLayout"> | ||
<item row="4" column="0" colspan="2"> | ||
<widget class="QStackedWidget" name="stackedWidget"> | ||
<property name="enabled"> | ||
<bool>true</bool> | ||
</property> | ||
<property name="currentIndex"> | ||
<number>0</number> | ||
</property> | ||
<widget class="QWidget" name="page_3"> | ||
<layout class="QGridLayout" name="gridLayout_2"> | ||
<item row="1" column="1"> | ||
<widget class="QLineEdit" name="typePropertyEdit"> | ||
<property name="placeholderText"> | ||
<string>http://www.w3.org/1999/02/22-rdf-syntax-ns#type</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="4" column="0" colspan="2"> | ||
<widget class="QLabel" name="propertiesMissingLabel"> | ||
<property name="text"> | ||
<string/> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="1" column="0"> | ||
<widget class="QLabel" name="typePropertyLabel"> | ||
<property name="font"> | ||
<font> | ||
<weight>75</weight> | ||
<bold>true</bold> | ||
</font> | ||
</property> | ||
<property name="toolTip"> | ||
<string>Select the target conversion vocabulary</string> | ||
</property> | ||
<property name="text"> | ||
<string>Type Property:</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="2" column="0"> | ||
<widget class="QLabel" name="subClassOfLabel"> | ||
<property name="font"> | ||
<font> | ||
<weight>75</weight> | ||
<bold>true</bold> | ||
</font> | ||
</property> | ||
<property name="text"> | ||
<string>SubClass Property:</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="2" column="1"> | ||
<widget class="QLineEdit" name="subClassOfEdit"> | ||
<property name="placeholderText"> | ||
<string>http://www.w3.org/2000/01/rdf-schema#subClassOf</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="0" column="0" colspan="2"> | ||
<widget class="QLabel" name="typeHeadingLabel"> | ||
<property name="text"> | ||
<string><html><head/><body><p align="center"><span style=" font-weight:600;">Automatic Detection for Properties</span></p></body></html></string> | ||
</property> | ||
<property name="alignment"> | ||
<set>Qt::AlignJustify|Qt::AlignVCenter</set> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="3" column="0"> | ||
<widget class="QLabel" name="geoPropertyLabel"> | ||
<property name="text"> | ||
<string><b>GeoProperty:</b></string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="3" column="1"> | ||
<widget class="QLineEdit" name="geoPropertyEdit"> | ||
<property name="placeholderText"> | ||
<string>http://www.opengis.net/ont/geosparql#asWKT</string> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</widget> | ||
</widget> | ||
</item> | ||
<item row="12" column="1"> | ||
<widget class="QPushButton" name="addTripleStoreButton"> | ||
<property name="text"> | ||
<string>Add Triple Store</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="0" column="0" colspan="3" alignment="Qt::AlignHCenter"> | ||
<widget class="QLabel" name="convertLayerLabel"> | ||
<property name="font"> | ||
<font> | ||
<weight>75</weight> | ||
<bold>true</bold> | ||
</font> | ||
</property> | ||
<property name="text"> | ||
<string><html><head/><body><p>Detection Results</p></body></html></string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="3" column="0" colspan="2"> | ||
<widget class="QLabel" name="capabilitiesLabel"> | ||
<property name="text"> | ||
<string/> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="12" column="0"> | ||
<widget class="QPushButton" name="cancelButton"> | ||
<property name="text"> | ||
<string>Cancel</string> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</widget> | ||
<resources/> | ||
<connections> | ||
<connection> | ||
<sender>cancelButton</sender> | ||
<signal>clicked()</signal> | ||
<receiver>Dialog</receiver> | ||
<slot>close()</slot> | ||
<hints> | ||
<hint type="sourcelabel"> | ||
<x>329</x> | ||
<y>149</y> | ||
</hint> | ||
<hint type="destinationlabel"> | ||
<x>199</x> | ||
<y>84</y> | ||
</hint> | ||
</hints> | ||
</connection> | ||
</connections> | ||
</ui> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters