Skip to content

Commit

Permalink
HmX module: allow pericope in input mode to be saved; validate config…
Browse files Browse the repository at this point in the history
…ured syntactic function codes; fix some minor ui bugs
  • Loading branch information
CarstenWickner committed Jul 28, 2016
1 parent 3506b08 commit ca469fb
Show file tree
Hide file tree
Showing 13 changed files with 269 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -476,14 +476,14 @@ public Entry<Pericope, List<?>> parseModelFromXml(final Document xml, final File
newPericope.addNewPropositions(text, false);

final Element connectablesTree = DomUtil.getChildElement(pericopeNode, ModelParseServiceImpl.TAG_RELATION_SUB_TREE);
if (connectablesTree != null) {
if (connectablesTree != null && !text.isEmpty()) {
// gets a list of all Propositions contained in the pericope in order of appearence
final Deque<Proposition> propositionsInOrder = new LinkedList<Proposition>();
Proposition nextProposition = newPericope.getPropositionAt(0);
do {
while (nextProposition != null) {
propositionsInOrder.addLast(nextProposition);
nextProposition = nextProposition.getFollowingConnectableProposition();
} while (nextProposition != null);
}
for (final Element topLevelConnectable : DomUtil.getChildElements(connectablesTree, ModelParseServiceImpl.TAG_CONNECTABLE)) {
this.parseConnectableFromXml(topLevelConnectable, propositionsInOrder, compatibleRoleTranslator);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,6 @@ public enum HmxMessage implements ILocalizableMessage {
TEXTINPUT_BEFORE_BUTTON("TextInput.AddText.Before"),
/** text input view: button to add new propositions behind current text. */
TEXTINPUT_BEHIND_BUTTON("TextInput.AddText.Behind"),
/** confirmation question: proceed closing of new project in setup mode. */
TEXTINPUT_QUIT_QUESTION("TextInput.Quit.DiscardInputQuestion"),
/**
* title of the {@link #TEXTINPUT_QUIT_QUESTION} dialog.
*/
TEXTINPUT_QUIT_TITLE("TextInput.Quit.DiscardInputTitle"),

/**
* title of the popup behind the {@link #MENUBAR_PROJECTINFO} entry.
Expand Down Expand Up @@ -210,6 +204,7 @@ public enum HmxMessage implements ILocalizableMessage {
PREFERENCES_GENERAL_INPUT_SHOW_SETTINGS("Preferences.View.TextInput.ShowSettings"),
PREFERENCES_GENERAL_AUTHOR("Preferences.Analysis.ProjectInfo.DefaultAuthor"),
PREFERENCES_GENERAL_LANGUAGE("Preferences.Analysis.TextInput.DefaultOriginLanguage"),
PREFERENCES_EDITINPROGRESS("Preferences.EditInProgress"),

PREFERENCES_EXPORT("Preferences.Export"),
PREFERENCES_EXPORT_ELEMENTCOLOR("Preferences.Export.Color"),
Expand Down Expand Up @@ -275,6 +270,7 @@ public enum HmxMessage implements ILocalizableMessage {
PREFERENCES_LANGUAGEFUNCTIONS_NAME("Preferences.OriginLanguageFunctions.Name"),
PREFERENCES_LANGUAGEFUNCTIONS_NAME_MANDATORY("Preferences.OriginLanguageFunctions.Name.Mandatory"),
PREFERENCES_LANGUAGEFUNCTIONS_CODE("Preferences.OriginLanguageFunctions.Code"),
PREFERENCES_LANGUAGEFUNCTIONS_CODE_UNIQUE("Preferences.OriginLanguageFunctions.Code.Unique"),
PREFERENCES_LANGUAGEFUNCTIONS_CODE_MANDATORY("Preferences.OriginLanguageFunctions.Code.Mandatory"),
PREFERENCES_LANGUAGEFUNCTIONS_UNDERLINE("Preferences.OriginLanguageFunctions.Underline"),
PREFERENCES_LANGUAGEFUNCTIONS_DESCRIPTION("Preferences.OriginLanguageFunctions.Description");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ is allowed to be checked.</entry>
<entry key="Hmx.Project.Unsaved">HmX Project - unsaved</entry>
<entry key="Preferences.Analysis.ProjectInfo.DefaultAuthor">Default Author</entry>
<entry key="Preferences.Analysis.TextInput.DefaultOriginLanguage">Default Origin Language</entry>
<entry key="Preferences.General">HmX – General</entry>
<entry key="Preferences.EditInProgress">Cannot submit changes as there is a pending edit operation.</entry>
<entry key="Preferences.Export">HmX – Export</entry>
<entry key="Preferences.Export.Color">Element Colors</entry>
<entry key="Preferences.Export.Font">Non-Origin Text Font</entry>
Expand All @@ -132,6 +132,7 @@ is allowed to be checked.</entry>
<entry key="Preferences.Export.SynFunction.Italic.FontColor">Syntactical Function (italic)</entry>
<entry key="Preferences.Export.SynFunction.Plain.FontColor">Syntactical Function (plain)</entry>
<entry key="Preferences.Export.Translation.FontColor">Translation Text</entry>
<entry key="Preferences.General">HmX – General</entry>
<entry key="Preferences.OriginLanguage">HmX – Languages</entry>
<entry key="Preferences.OriginLanguage.ApplyChanges">Apply Changes</entry>
<entry key="Preferences.OriginLanguage.CloneLanguage">Clone Language Model</entry>
Expand All @@ -154,6 +155,8 @@ is allowed to be checked.</entry>
<entry key="Preferences.OriginLanguageFunctions.Code">Code</entry>
<entry key="Preferences.OriginLanguageFunctions.Code.Mandatory">The Code cannot be empty.
It is being displayed as representation of a selected function in the Syntactical Analysis.</entry>
<entry key="Preferences.OriginLanguageFunctions.Code.Unique">The Code values for syntactical functions in a single language must be unique.
''{0}'' contains at least one pair of duplicate Code values.</entry>
<entry key="Preferences.OriginLanguageFunctions.Description">Description</entry>
<entry key="Preferences.OriginLanguageFunctions.MoveDown">Move Entry Down</entry>
<entry key="Preferences.OriginLanguageFunctions.MoveUp">Move Entry Up</entry>
Expand Down Expand Up @@ -210,8 +213,6 @@ All text parts divided by tabs will be treated as single clause items.

Set the origin language:
Only clause item functions deposited for the chosen language will be available in the syntactical analysis.</entry>
<entry key="TextInput.Quit.DiscardInputQuestion">Do you really want to discard your input?</entry>
<entry key="TextInput.Quit.DiscardInputTitle">Discard Input?</entry>
<entry key="TextInput.Settings.Hide">Hide</entry>
<entry key="TextInput.Settings.OriginLanguage">Origin Language</entry>
<entry key="TextInput.Settings.Show">Show</entry>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ keine weiteren Satzgliedern befinden.</entry>
<entry key="Hmx.Project.Unsaved">HmX Projekt - ungespeichert</entry>
<entry key="Preferences.Analysis.ProjectInfo.DefaultAuthor">Standard-Autor</entry>
<entry key="Preferences.Analysis.TextInput.DefaultOriginLanguage">Standard-Ausgangssprache</entry>
<entry key="Preferences.General">HmX – Allgemein</entry>
<entry key="Preferences.EditInProgress">Änderungen können nicht übernommen werden,
da der aktuelle Bearbeitungsvorgang noch nicht abgeschlossen ist.</entry>
<entry key="Preferences.Export">HmX – Export</entry>
<entry key="Preferences.Export.Color">Elementfarben</entry>
<entry key="Preferences.Export.Font">Schrift für nicht-ausgangssprachliche Texte</entry>
Expand All @@ -131,6 +132,7 @@ keine weiteren Satzgliedern befinden.</entry>
<entry key="Preferences.Export.SynFunction.Italic.FontColor">Syntakt. Funktion (kursiv)</entry>
<entry key="Preferences.Export.SynFunction.Plain.FontColor">Syntakt. Funktion (normal)</entry>
<entry key="Preferences.Export.Translation.FontColor">Übersetzungstext</entry>
<entry key="Preferences.General">HmX – Allgemein</entry>
<entry key="Preferences.OriginLanguage">HmX – Syntaktisch</entry>
<entry key="Preferences.OriginLanguage.ApplyChanges">Anwenden</entry>
<entry key="Preferences.OriginLanguage.CloneLanguage">Klone Ausgangssprache</entry>
Expand All @@ -157,6 +159,8 @@ keine weiteren Satzgliedern befinden.</entry>
<entry key="Preferences.OriginLanguageFunctions.Code">Kurzform</entry>
<entry key="Preferences.OriginLanguageFunctions.Code.Mandatory">Die Kurzform darf nicht leer sein.
Sie wird in der Syntaktischen Analyse auf zugeordneten Elementen angezeigt.</entry>
<entry key="Preferences.OriginLanguageFunctions.Code.Unique">Die Kurzform syntaktischer Funktionen innerhalb einer Sprache muss eindeutig sein.
''{0}'' enthält mindestens ein Paar doppelter Kurzformen.</entry>
<entry key="Preferences.OriginLanguageFunctions.Description">Beschreibung</entry>
<entry key="Preferences.OriginLanguageFunctions.Name">Funktion</entry>
<entry key="Preferences.OriginLanguageFunctions.Name.Mandatory">Der Funktionsbezeichner darf nicht leer sein.
Expand Down Expand Up @@ -209,8 +213,6 @@ Jeder innerhalb einer Zeile durch Tabs getrennte Textabschnitt, wird im Weiteren

Stellen Sie die Ausgangssprache ein:
In der syntaktischen Analyse können nur Satzgliedfunktionen ausgewählt werden, die für die jeweilige Sprache hinterlegt sind.</entry>
<entry key="TextInput.Quit.DiscardInputQuestion">Sollen die bisherigen Eingaben wirklich verworfen werden?</entry>
<entry key="TextInput.Quit.DiscardInputTitle">Eingaben verwerfen?</entry>
<entry key="TextInput.Settings.Hide">Ausblenden</entry>
<entry key="TextInput.Settings.OriginLanguage">Ausgangssprache</entry>
<entry key="TextInput.Settings.Show">Einblenden</entry>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public List<Relation> getFlatRelations() {
final List<Relation> result = new LinkedList<Relation>();
// get the first Proposition
AbstractConnectable currentFocus = this.getPropositionAt(0);
do {
while (currentFocus != null) {
// get the highest relation over the current focused Proposition
while (currentFocus.getSuperOrdinatedRelation() != null) {
currentFocus = currentFocus.getSuperOrdinatedRelation();
Expand All @@ -211,7 +211,7 @@ public List<Relation> getFlatRelations() {
}
// iterate whole pericope
currentFocus = currentFocus.getFollowingConnectableProposition();
} while (currentFocus != null);
}
return result;
}

Expand Down Expand Up @@ -240,7 +240,7 @@ private void collectFlatRelations(final Relation subtreeRoot, final List<Relatio
* @return the language of the origin text
*/
public String getLanguage() {
return this.languageModel.getName();
return this.languageModel == null ? null : this.languageModel.getName();
}

/**
Expand All @@ -249,12 +249,13 @@ public String getLanguage() {
* @return if the text orientation is {@code left-to-right} (otherwise {@code right-to-left})
*/
public boolean isLeftToRightOriented() {
return this.languageModel.isLeftToRightOriented();
return this.languageModel == null || this.languageModel.isLeftToRightOriented();
}

@Override
public List<List<AbstractSyntacticalFunctionElement>> provideFunctions() {
return this.languageModel.provideFunctions();
return this.languageModel == null ? Collections.<List<AbstractSyntacticalFunctionElement>>emptyList() : this.languageModel
.provideFunctions();
}

/**
Expand Down Expand Up @@ -379,10 +380,13 @@ public List<Proposition> getContainingList(final Proposition childProposition) {
* @see #indexOfProposition(Proposition)
*/
public Proposition getPropositionAt(final int index) {
if (this.text.isEmpty()) {
return null;
}
// get the first Proposition
Proposition proposition = this.text.get(0);
List<Proposition> priorChildren = proposition.getPriorChildren();
while (priorChildren != null && !priorChildren.isEmpty()) {
while (!priorChildren.isEmpty()) {
proposition = priorChildren.get(0);
priorChildren = proposition.getPriorChildren();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,6 @@ public boolean close() {

@Override
public boolean prepareForClosing() {
if (this.getModelObject().getText().isEmpty()) {
return MessageHandler.Choice.YES == MessageHandler.showConfirmDialog(HmxMessage.TEXTINPUT_QUIT_QUESTION.get(),
HmxMessage.TEXTINPUT_QUIT_TITLE.get());
}
// if the project is in analysis mode it is possible to save
if (!this.isSaved()) {
final String dialogTitle = Message.PROJECT_CLOSE.get() + " - " + this.getTitle();
final MessageHandler.Choice choice = MessageHandler.showYesNoCancelDialog(Message.PROJECT_CLOSE_QUESTION.get(), dialogTitle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,16 @@

import org.hmx.scitos.domain.IModel;
import org.hmx.scitos.hmx.core.ModelHandlerImpl;
import org.hmx.scitos.hmx.core.i18n.HmxMessage;
import org.hmx.scitos.hmx.core.option.HmxLanguageOption;
import org.hmx.scitos.hmx.core.option.HmxRelationOption;
import org.hmx.scitos.hmx.domain.model.LanguageModel;
import org.hmx.scitos.hmx.domain.model.Pericope;
import org.hmx.scitos.hmx.domain.model.RelationModel;
import org.hmx.scitos.hmx.view.swing.components.SingleProjectView;
import org.hmx.scitos.view.ContextMenuBuilder;
import org.hmx.scitos.view.FileType;
import org.hmx.scitos.view.IViewProject;
import org.hmx.scitos.view.service.IProjectViewService;
import org.hmx.scitos.view.swing.ScitosClient;
import org.hmx.scitos.view.swing.util.ViewUtil;

/**
* Implementation of the {@link IProjectViewService} for the AIS module.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@
import org.hmx.scitos.hmx.core.ILanguageModelProvider;
import org.hmx.scitos.hmx.core.i18n.HmxMessage;
import org.hmx.scitos.hmx.domain.ISemanticalRelationProvider;
import org.hmx.scitos.hmx.domain.model.ClauseItem;
import org.hmx.scitos.hmx.domain.model.LanguageModel;
import org.hmx.scitos.hmx.domain.model.Pericope;
import org.hmx.scitos.hmx.domain.model.Proposition;
import org.hmx.scitos.hmx.domain.model.RelationTemplate;
import org.hmx.scitos.hmx.view.IPericopeView;
import org.hmx.scitos.hmx.view.swing.HmxSwingProject;
import org.hmx.scitos.hmx.view.swing.elements.ProjectInfoDialog;
import org.hmx.scitos.view.ScitosIcon;
Expand Down Expand Up @@ -98,15 +100,43 @@ public SingleProjectView(final HmxSwingProject project, final ILanguageModelProv
super(project, project.getModelObject(), new BorderLayout());
this.relationProvider = relationProvider;
this.modelParseProvider = modelParseProvider;
if (this.getModel().getText().isEmpty()) {
this.activeView = new TextInputPanel(this, languageModelProvider);
} else {
if (this.containsAnalysisData()) {
this.undoManager = new UndoManager<Pericope>(this.getModel());
this.activeView = new CombinedAnalysesPanel(this.getProject().getModelHandler(), this.relationProvider);
} else {
this.activeView = new TextInputPanel(this, true, languageModelProvider);
}
this.add(this.activeView);
}

/**
* Check whether the current model contains any analysis related data - i.e. if information would be lost if the current model was displayed in a
* {@link TextInputPanel} rather than a {@link CombinedAnalysesPanel}.
*
* @return if any information besides the origin text is present
*/
boolean containsAnalysisData() {
if (!this.getModel().getFlatRelations().isEmpty()) {
// the semantical analysis has already been started
return true;
}
// we only have to check the top level propositions, if there is any non-top-level one we return true anyway
for (final Proposition singleProposition : this.getModel().getText()) {
if (!singleProposition.getPriorChildren().isEmpty() || !singleProposition.getLaterChildren().isEmpty()
|| singleProposition.getPartAfterArrow() != null || singleProposition.getLabel() != null
|| singleProposition.getSemTranslation() != null || singleProposition.getSynTranslation() != null
|| singleProposition.getComment() != null) {
return true;
}
for (final ClauseItem singleItem : singleProposition) {
if (singleItem.getFunction() != null || singleItem.getFontStyle() != ClauseItem.Style.PLAIN || singleItem.getComment() != null) {
return true;
}
}
}
return false;
}

/**
* Initialize the analysis by referring to the chosen origin language and {@link Font}, opening the analysis view with the syntactical analysis.
*
Expand Down Expand Up @@ -155,7 +185,7 @@ void goToTextInputView() {
if (this.activeView instanceof CombinedAnalysesPanel) {
this.submitChangesToModel();
this.remove(this.activeView);
this.activeView = new TextInputPanel(this, null);
this.activeView = new TextInputPanel(this, false, null);
this.add(this.activeView);
this.revalidate();
this.manageMenuOptions();
Expand Down Expand Up @@ -212,8 +242,10 @@ public void refresh() {

@Override
public void submitChangesToModel() {
if (this.activeView instanceof CombinedAnalysesPanel) {
((CombinedAnalysesPanel) this.activeView).submitChangesToModel();
if (this.activeView instanceof IPericopeView) {
((IPericopeView) this.activeView).submitChangesToModel();
} else if (this.activeView instanceof TextInputPanel) {
((TextInputPanel) this.activeView).submitChangesToModel();
}
}

Expand Down
Loading

0 comments on commit ca469fb

Please sign in to comment.