Skip to content

Commit

Permalink
Merge pull request #46 from PASTA-ELN/feature/ontology_editor_gui_cha…
Browse files Browse the repository at this point in the history
…nges

feat(ontology): editor GUI changes and other modifications
  • Loading branch information
jmurugan-fzj authored Sep 18, 2023
2 parents dff4b37 + 26bc028 commit 55d4d8b
Show file tree
Hide file tree
Showing 20 changed files with 508 additions and 307 deletions.
9 changes: 6 additions & 3 deletions pasta_eln/GUI/ontology_configuration/create_type_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,19 @@ def setupUi(self, CreateTypeDialog):
self.tileHorizontalLayout = QtWidgets.QHBoxLayout()
self.tileHorizontalLayout.setObjectName("tileHorizontalLayout")
self.titleLabel = QtWidgets.QLabel(parent=self.verticalLayoutWidget)
self.titleLabel.setMinimumSize(QtCore.QSize(120, 0))
self.titleLabel.setObjectName("titleLabel")
self.tileHorizontalLayout.addWidget(self.titleLabel)
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Minimum)
self.tileHorizontalLayout.addItem(spacerItem)
self.titleLineEdit = QtWidgets.QLineEdit(parent=self.verticalLayoutWidget)
self.titleLineEdit.setToolTip("")
self.titleLineEdit.setObjectName("titleLineEdit")
self.tileHorizontalLayout.addWidget(self.titleLineEdit)
self.mainVerticalLayout.addLayout(self.tileHorizontalLayout)
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
self.typeLabel = QtWidgets.QLabel(parent=self.verticalLayoutWidget)
self.typeLabel.setMinimumSize(QtCore.QSize(120, 0))
self.typeLabel.setObjectName("typeLabel")
self.horizontalLayout.addWidget(self.typeLabel)
spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Minimum)
Expand All @@ -63,9 +64,11 @@ def retranslateUi(self, CreateTypeDialog):
_translate = QtCore.QCoreApplication.translate
CreateTypeDialog.setWindowTitle(_translate("CreateTypeDialog", "Create New Type"))
self.titleLabel.setText(_translate("CreateTypeDialog", "Enter Type title"))
self.titleLineEdit.setPlaceholderText(_translate("CreateTypeDialog", "Enter the title for the new type"))
self.titleLineEdit.setToolTip(_translate("CreateTypeDialog", "Exclude titles which start with \'x\' (reserved for structure level titles) or whitespace"))
self.titleLineEdit.setPlaceholderText(_translate("CreateTypeDialog", "Enter title for the new type"))
self.typeLabel.setText(_translate("CreateTypeDialog", "Enter Type Label"))
self.labelLineEdit.setPlaceholderText(_translate("CreateTypeDialog", "Enter the label for the new type"))
self.labelLineEdit.setToolTip(_translate("CreateTypeDialog", "Enter label for the new type, which can also be modified later in the main editor window"))
self.labelLineEdit.setPlaceholderText(_translate("CreateTypeDialog", "Enter label for the new type"))
self.structuralLevelCheckBox.setToolTip(_translate("CreateTypeDialog", "If this is a structural type, then title will be automatically populated as (x0, x1...xn). Next number will be chosen for xn from the existing list of structural items."))
self.structuralLevelCheckBox.setText(_translate("CreateTypeDialog", "Is this a structural Type?"))

Expand Down
21 changes: 18 additions & 3 deletions pasta_eln/GUI/ontology_configuration/create_type_dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@
<layout class="QHBoxLayout" name="tileHorizontalLayout">
<item>
<widget class="QLabel" name="titleLabel">
<property name="minimumSize">
<size>
<width>120</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Enter Type title</string>
</property>
Expand All @@ -73,10 +79,10 @@
<item>
<widget class="QLineEdit" name="titleLineEdit">
<property name="toolTip">
<string/>
<string>Exclude titles which start with 'x' (reserved for structure level titles) or whitespace</string>
</property>
<property name="placeholderText">
<string>Enter the title for the new type</string>
<string>Enter title for the new type</string>
</property>
</widget>
</item>
Expand All @@ -86,6 +92,12 @@
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="typeLabel">
<property name="minimumSize">
<size>
<width>120</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Enter Type Label</string>
</property>
Expand All @@ -109,8 +121,11 @@
</item>
<item>
<widget class="QLineEdit" name="labelLineEdit">
<property name="toolTip">
<string>Enter label for the new type, which can also be modified later in the main editor window</string>
</property>
<property name="placeholderText">
<string>Enter the label for the new type</string>
<string>Enter label for the new type</string>
</property>
</widget>
</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
from typing import Any

from PySide6 import QtCore
from PySide6.QtCore import QRegularExpression
from PySide6.QtGui import QRegularExpressionValidator
from PySide6.QtWidgets import QDialog

from pasta_eln.GUI.ontology_configuration.create_type_dialog import Ui_CreateTypeDialog
Expand All @@ -45,10 +47,13 @@ def __init__(self,
accepted_callback (Callable): Accepted button parent callback.
rejected_callback (Callable): Rejected button parent callback.
"""
self.logger = logging.getLogger(__name__ + "." + self.__class__.__name__)
self.logger = logging.getLogger(f"{__name__}.{self.__class__.__name__}")
self.next_struct_level: str | None = ""
self.instance = QDialog()
super().setupUi(self.instance)
# Restricts the title input to allow anything except x or space
# as the first character which is reserved for structural level
self.titleLineEdit.setValidator(QRegularExpressionValidator(QRegularExpression("^[^ Ax].*")))
self.setup_slots(accepted_callback, rejected_callback)

def setup_slots(self,
Expand All @@ -74,7 +79,8 @@ def structural_level_checkbox_callback(self) -> None:
Returns: Nothing
"""
if self.structuralLevelCheckBox.isChecked():
self.titleLineEdit.setText(self.next_struct_level if self.next_struct_level else "")
self.titleLineEdit.setText(self.next_struct_level.replace("x", "Structure level ")
if self.next_struct_level else "")
self.titleLineEdit.setDisabled(True)
else:
self.titleLineEdit.clear()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,19 @@ def __init__(self,
parent (QWidget): Parent view or the widget
"""
super().__init__(parent)
self.logger = logging.getLogger(__name__ + "." + self.__class__.__name__)
self.logger = logging.getLogger(f"{__name__}.{self.__class__.__name__}")
self.data_set = []
self.data_name_map = {
0: "location",
1: "link",
0: "description",
1: "type",
2: "delete",
3: "re-order"
}
self.column_widths: dict[int, int] = {
0: 300, # Location column width
1: 600, # Link column width
2: 120, # Delete column width
3: 120, # Re-order column width
}
self.header_values: list[str] = list(self.data_name_map.values())
self.columns_count: int = len(self.header_values)
37 changes: 16 additions & 21 deletions pasta_eln/GUI/ontology_configuration/ontology_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ def setupUi(self, OntologyConfigurationBaseForm):
self.mainGridLayout.setContentsMargins(30, 0, 30, 0)
self.mainGridLayout.setObjectName("mainGridLayout")
self.typePropsTableView = QtWidgets.QTableView(parent=self.verticalLayoutWidget_2)
self.typePropsTableView.setSortingEnabled(True)
self.typePropsTableView.setSortingEnabled(False)
self.typePropsTableView.setObjectName("typePropsTableView")
self.typePropsTableView.horizontalHeader().setCascadingSectionResizes(True)
self.typePropsTableView.horizontalHeader().setSortIndicatorShown(True)
self.typePropsTableView.horizontalHeader().setSortIndicatorShown(False)
self.typePropsTableView.horizontalHeader().setStretchLastSection(True)
self.typePropsTableView.verticalHeader().setCascadingSectionResizes(True)
self.typePropsTableView.verticalHeader().setSortIndicatorShown(True)
self.typePropsTableView.verticalHeader().setSortIndicatorShown(False)
self.typePropsTableView.verticalHeader().setStretchLastSection(False)
self.mainGridLayout.addWidget(self.typePropsTableView, 6, 0, 1, 1)
self.attachmentsHeaderHorizontalLayout = QtWidgets.QHBoxLayout()
Expand Down Expand Up @@ -113,14 +113,14 @@ def setupUi(self, OntologyConfigurationBaseForm):
self.typeLabelLineEdit.setText("")
self.typeLabelLineEdit.setObjectName("typeLabelLineEdit")
self.datatypeHorizontalLayout.addWidget(self.typeLabelLineEdit)
self.typeLinkLineEdit = QtWidgets.QLineEdit(parent=self.verticalLayoutWidget_2)
self.typeIriLineEdit = QtWidgets.QLineEdit(parent=self.verticalLayoutWidget_2)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Minimum)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.typeLinkLineEdit.sizePolicy().hasHeightForWidth())
self.typeLinkLineEdit.setSizePolicy(sizePolicy)
self.typeLinkLineEdit.setObjectName("typeLinkLineEdit")
self.datatypeHorizontalLayout.addWidget(self.typeLinkLineEdit)
sizePolicy.setHeightForWidth(self.typeIriLineEdit.sizePolicy().hasHeightForWidth())
self.typeIriLineEdit.setSizePolicy(sizePolicy)
self.typeIriLineEdit.setObjectName("typeIriLineEdit")
self.datatypeHorizontalLayout.addWidget(self.typeIriLineEdit)
self.addTypePushButton = QtWidgets.QPushButton(parent=self.verticalLayoutWidget_2)
self.addTypePushButton.setObjectName("addTypePushButton")
self.datatypeHorizontalLayout.addWidget(self.addTypePushButton)
Expand All @@ -143,16 +143,16 @@ def setupUi(self, OntologyConfigurationBaseForm):
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum)
self.propsTableButtonHorizontalLayout.addItem(spacerItem)
self.mainGridLayout.addLayout(self.propsTableButtonHorizontalLayout, 8, 0, 1, 1)
self.structureTableHorizontalLayout = QtWidgets.QHBoxLayout()
self.structureTableHorizontalLayout.setContentsMargins(0, 5, 0, 5)
self.structureTableHorizontalLayout.setObjectName("structureTableHorizontalLayout")
self.attachmentTableButtonsHorizontalLayout = QtWidgets.QHBoxLayout()
self.attachmentTableButtonsHorizontalLayout.setContentsMargins(0, 5, 0, 5)
self.attachmentTableButtonsHorizontalLayout.setObjectName("attachmentTableButtonsHorizontalLayout")
self.addAttachmentPushButton = QtWidgets.QPushButton(parent=self.verticalLayoutWidget_2)
self.addAttachmentPushButton.setMinimumSize(QtCore.QSize(200, 0))
self.addAttachmentPushButton.setObjectName("addAttachmentPushButton")
self.structureTableHorizontalLayout.addWidget(self.addAttachmentPushButton)
self.attachmentTableButtonsHorizontalLayout.addWidget(self.addAttachmentPushButton)
spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum)
self.structureTableHorizontalLayout.addItem(spacerItem1)
self.mainGridLayout.addLayout(self.structureTableHorizontalLayout, 13, 0, 1, 1)
self.attachmentTableButtonsHorizontalLayout.addItem(spacerItem1)
self.mainGridLayout.addLayout(self.attachmentTableButtonsHorizontalLayout, 13, 0, 1, 1)
self.propertiesTableHeaderHorizontalLayout = QtWidgets.QHBoxLayout()
self.propertiesTableHeaderHorizontalLayout.setContentsMargins(-1, 5, -1, 5)
self.propertiesTableHeaderHorizontalLayout.setObjectName("propertiesTableHeaderHorizontalLayout")
Expand All @@ -172,9 +172,6 @@ def setupUi(self, OntologyConfigurationBaseForm):
self.headerHorizontalLayout.addWidget(self.headerLabel)
spacerItem2 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum)
self.headerHorizontalLayout.addItem(spacerItem2)
self.loadOntologyPushButton = QtWidgets.QPushButton(parent=self.verticalLayoutWidget_2)
self.loadOntologyPushButton.setObjectName("loadOntologyPushButton")
self.headerHorizontalLayout.addWidget(self.loadOntologyPushButton)
self.saveOntologyPushButton = QtWidgets.QPushButton(parent=self.verticalLayoutWidget_2)
self.saveOntologyPushButton.setObjectName("saveOntologyPushButton")
self.headerHorizontalLayout.addWidget(self.saveOntologyPushButton)
Expand Down Expand Up @@ -207,8 +204,8 @@ def retranslateUi(self, OntologyConfigurationBaseForm):
self.typeComboBox.setToolTip(_translate("OntologyConfigurationBaseForm", "Select the type from the loaded ontology"))
self.typeLabelLineEdit.setToolTip(_translate("OntologyConfigurationBaseForm", "Modify the label property of the type"))
self.typeLabelLineEdit.setPlaceholderText(_translate("OntologyConfigurationBaseForm", "Modify the type label here"))
self.typeLinkLineEdit.setToolTip(_translate("OntologyConfigurationBaseForm", "Enter the link/url to be associated with this data-type"))
self.typeLinkLineEdit.setPlaceholderText(_translate("OntologyConfigurationBaseForm", "Enter the type for the link"))
self.typeIriLineEdit.setToolTip(_translate("OntologyConfigurationBaseForm", "Enter the link/iri to be associated with this data-type"))
self.typeIriLineEdit.setPlaceholderText(_translate("OntologyConfigurationBaseForm", "Enter the iri for the type"))
self.addTypePushButton.setToolTip(_translate("OntologyConfigurationBaseForm", "Add a new type (structural or normal type) to the ontology data set."))
self.addTypePushButton.setText(_translate("OntologyConfigurationBaseForm", "+ Add"))
self.deleteTypePushButton.setToolTip(_translate("OntologyConfigurationBaseForm", "Delete the type with the full properties completely"))
Expand All @@ -219,8 +216,6 @@ def retranslateUi(self, OntologyConfigurationBaseForm):
self.propertiesTableHeaderLabel.setText(_translate("OntologyConfigurationBaseForm", "Properties"))
self.typeAttachmentsTableView.setToolTip(_translate("OntologyConfigurationBaseForm", "Table which displays the attachments for the above selected data type"))
self.headerLabel.setText(_translate("OntologyConfigurationBaseForm", "Edit Questionnaires"))
self.loadOntologyPushButton.setToolTip(_translate("OntologyConfigurationBaseForm", "Load ontology from local database"))
self.loadOntologyPushButton.setText(_translate("OntologyConfigurationBaseForm", "Load"))
self.saveOntologyPushButton.setToolTip(_translate("OntologyConfigurationBaseForm", "Save loaded ontology in local database"))
self.saveOntologyPushButton.setText(_translate("OntologyConfigurationBaseForm", "Save"))
self.helpPushButton.setToolTip(_translate("OntologyConfigurationBaseForm", "Navigate to the help page"))
Expand Down
24 changes: 7 additions & 17 deletions pasta_eln/GUI/ontology_configuration/ontology_configuration.ui
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@
<string>Table which lists and allows editing of all the properties associated with the above selected type</string>
</property>
<property name="sortingEnabled">
<bool>true</bool>
<bool>false</bool>
</property>
<attribute name="horizontalHeaderCascadingSectionResizes">
<bool>true</bool>
</attribute>
<attribute name="horizontalHeaderShowSortIndicator" stdset="0">
<bool>true</bool>
<bool>false</bool>
</attribute>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
Expand All @@ -74,7 +74,7 @@
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderShowSortIndicator" stdset="0">
<bool>true</bool>
<bool>false</bool>
</attribute>
<attribute name="verticalHeaderStretchLastSection">
<bool>false</bool>
Expand Down Expand Up @@ -284,18 +284,18 @@
</widget>
</item>
<item>
<widget class="QLineEdit" name="typeLinkLineEdit">
<widget class="QLineEdit" name="typeIriLineEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Enter the link/url to be associated with this data-type</string>
<string>Enter the link/iri to be associated with this data-type</string>
</property>
<property name="placeholderText">
<string>Enter the type for the link</string>
<string>Enter the iri for the type</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -376,7 +376,7 @@
</layout>
</item>
<item row="13" column="0">
<layout class="QHBoxLayout" name="structureTableHorizontalLayout">
<layout class="QHBoxLayout" name="attachmentTableButtonsHorizontalLayout">
<property name="leftMargin">
<number>0</number>
</property>
Expand Down Expand Up @@ -484,16 +484,6 @@
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="loadOntologyPushButton">
<property name="toolTip">
<string>Load ontology from local database</string>
</property>
<property name="text">
<string>Load</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="saveOntologyPushButton">
<property name="toolTip">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
# You should have received a copy of the license with this file. Please refer the license file for more information.

# Ontology Table view constants
PROPS_TABLE_REQUIRED_COLUMN_INDEX = 4
PROPS_TABLE_LIST_COLUMN_INDEX = 2
PROPS_TABLE_REQUIRED_COLUMN_INDEX = 5
PROPS_TABLE_DELETE_COLUMN_INDEX = 6
PROPS_TABLE_REORDER_COLUMN_INDEX = 7

Expand Down
Loading

0 comments on commit 55d4d8b

Please sign in to comment.