Skip to content

Commit

Permalink
Issue #9 introduce visibility toggle for proposition labels and trans…
Browse files Browse the repository at this point in the history
…lations
  • Loading branch information
CarstenWickner committed Sep 13, 2017
1 parent 55feaf6 commit c3d0ccb
Show file tree
Hide file tree
Showing 16 changed files with 230 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ public enum HmxMessage implements ILocalizableMessage {
MENUBAR_PROJECT_MERGE_INFRONT("Client.MenuBar.Edit.MergeProjects.InFront"),
/** answer: insert content of project to merge with behind current text. */
MENUBAR_PROJECT_MERGE_BEHIND("Client.MenuBar.Edit.MergeProjects.Behind"),
/** menubar entry: View -> Hide/Show Proposition Labels. */
MENUBAR_TOGGLE_PROPOSITION_LABELS("Client.MenuBar.View.TogglePropositionLabels"),
/** menubar entry: View -> Hide/Show Proposition Translations. */
MENUBAR_TOGGLE_PROPOSITION_TRANSLATIONS("Client.MenuBar.View.TogglePropositionTranslations"),

/** in the new-project-setup: the hint label over the main text input. */
TEXTINPUT_TOPIC("TextInput.Topic"),
Expand Down Expand Up @@ -200,6 +204,9 @@ public enum HmxMessage implements ILocalizableMessage {
PREFERENCES_GENERAL_RELATION_COLOR("Preferences.View.Color.Relation"),
PREFERENCES_GENERAL_COMMENTED_BORDER_COLOR("Preferences.View.Color.CommentedBorder"),
PREFERENCES_GENERAL_INDENTATION("Preferences.View.IndentationWidth"),
PREFERENCES_GENERAL_PROPOSITIONS("Preferences.View.Propositions"),
PREFERENCES_GENERAL_PROPOSITIONS_SHOW_LABELS("Preferences.View.Propositions.ShowLabels"),
PREFERENCES_GENERAL_PROPOSITIONS_SHOW_TRANSLATIONS("Preferences.View.Propositions.ShowTranslations"),
PREFERENCES_GENERAL_INPUT("Preferences.View.TextInput"),
PREFERENCES_GENERAL_INPUT_SHOW_SETTINGS("Preferences.View.TextInput.ShowSettings"),
PREFERENCES_GENERAL_AUTHOR("Preferences.Analysis.ProjectInfo.DefaultAuthor"),
Expand Down Expand Up @@ -243,7 +250,7 @@ public enum HmxMessage implements ILocalizableMessage {
PREFERENCES_RELATION_LOW_WEIGHT_ROLE("Preferences.Relation.LowWeightRole"),
PREFERENCES_RELATION_LOW_WEIGHT_REPEAT("Preferences.Relation.LowWeightRepeatable"),
PREFERENCES_RELATION_TOOLTIP("Preferences.Relation.Description"),

PREFERENCES_LANGUAGE("Preferences.OriginLanguage"),
PREFERENCES_LANGUAGE_EDIT("Preferences.OriginLanguage.EditEntry"),
PREFERENCES_LANGUAGE_APPLY("Preferences.OriginLanguage.ApplyChanges"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,13 @@ public enum HmxGeneralOption implements IOptionSetting {
RELATION_COLOR("Relation.Color", ConversionUtil.toString(Color.RED)),
/** user setting: color of semantical relations. */
COMMENTED_BORDER_COLOR("Commented.BorderColor", ConversionUtil.toString(Color.GREEN)),
/** user setting: whether the labels on the analysis views should be visible by default. */
SHOW_PROPOSITION_LABELS("Analysis.Proposition.ShowLabels", String.valueOf(true)),
/** user setting: whether the translations on the analysis views should be visible by default. */
SHOW_PROPOSITION_TRANSLATIONS("Analysis.Proposition.ShowTranslations", String.valueOf(true)),
/** user setting: width of syntactical indentations. */
INDENTATION_WIDTH("SynAnalysis.IndentationWidth", "50"),
/** user setting: if the setting area in the new-project-setup should be visible by default. */
/** user setting: whether the setting area in the new-project-setup should be visible by default. */
SHOW_SETTINGS("TextInput.ShowInputSettings", String.valueOf(true)),
/** user setting: default author name when setting up new projects. */
AUTHOR("ProjectInfo.DefaultAuthor", null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ Continue?</entry>
are being removed from this project.
Continue?</entry>
<entry key="Client.MenuBar.Edit.ProjectInfo">Edit Project Info</entry>
<entry key="Client.MenuBar.View.TogglePropositionLabels">Hide/Show Proposition Labels</entry>
<entry key="Client.MenuBar.View.TogglePropositionTranslations">Hide/Show Proposition Translations</entry>
<entry key="Error.CreateRelation.AtLeastTwoChecked">At least one other element needs to be checked.</entry>
<entry key="Error.CreateRelation.MoreThenTwoChecked">The chosen relation cannot be created
with more then two associates.</entry>
Expand Down Expand Up @@ -194,7 +196,10 @@ It is being displayed as entry in the Syntactical Analysis' context menus.</entr
<entry key="Preferences.View.Color.Relation">Relation Color</entry>
<entry key="Preferences.View.Color.Transparent">Invisible</entry>
<entry key="Preferences.View.IndentationWidth">Indentation Width</entry>
<entry key="Preferences.View.TextInput">On Start of new Analysis</entry>
<entry key="Preferences.View.Propositions">On Propositions in Analysis View</entry>
<entry key="Preferences.View.Propositions.ShowLabels">Show labels</entry>
<entry key="Preferences.View.Propositions.ShowTranslations">Show translations</entry>
<entry key="Preferences.View.TextInput">On Text Input View for new Analysis</entry>
<entry key="Preferences.View.TextInput.ShowSettings">Show settings</entry>
<entry key="ProjectInfo.Author">Author</entry>
<entry key="ProjectInfo.Comment">Comment</entry>
Expand All @@ -221,4 +226,4 @@ Only clause item functions deposited for the chosen language will be available i
<entry key="TextInput.Topic.AddPropositions">Add some more text to your current project</entry>
<entry key="TextInput.Warning">WARNING:
After clicking on "Start Analysis" it will be impossible to change the language of the origin text.</entry>
</properties>
</properties>
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ Wollen Sie wirklich fortfahren?</entry>
<entry key="Client.MenuBar.Edit.OriginText.Remove">Ausgewählte Propositionen Entfernen</entry>
<entry key="Client.MenuBar.Edit.OriginText.Remove.Confirm">Soll(en) die ausgewählte(n) Proposition(en) wirklich gelöscht werden?</entry>
<entry key="Client.MenuBar.Edit.ProjectInfo">Projektinformationen</entry>
<entry key="Client.MenuBar.View.TogglePropositionLabels">Propositionsbezeichner: Aus-/Einblenden</entry>
<entry key="Client.MenuBar.View.TogglePropositionTranslations">Propositionsübersetzungen: Aus-/Einblenden</entry>
<entry key="Error.CreateRelation.AtLeastTwoChecked">Es müssen mindestens zwei Elemente
(über ihre CheckBoxen) ausgewählt sein.</entry>
<entry key="Error.CreateRelation.MoreThenTwoChecked">Die gewählte Beziehung kann
Expand Down Expand Up @@ -194,6 +196,9 @@ Er wird in the Syntaktischen Analyse im entsprechenden Auswahlmenü angezeigt.</
<entry key="Preferences.View.Color.Relation">Farbe der Beziehungen</entry>
<entry key="Preferences.View.Color.Transparent">Ausblenden</entry>
<entry key="Preferences.View.IndentationWidth">Breite der Einrückungen</entry>
<entry key="Preferences.View.Propositions">Auf Propositionen in Analyse-Ansicht</entry>
<entry key="Preferences.View.Propositions.ShowLabels">Kurzbezeichnerfelder einblenden</entry>
<entry key="Preferences.View.Propositions.ShowTranslations">Übersetzungsfelder einblenden</entry>
<entry key="Preferences.View.TextInput">Beim Start der Texteingabe</entry>
<entry key="Preferences.View.TextInput.ShowSettings">Einstellungen einblenden</entry>
<entry key="ProjectInfo.Author">Autor</entry>
Expand Down Expand Up @@ -221,4 +226,4 @@ In der syntaktischen Analyse können nur Satzgliedfunktionen ausgewählt werden,
<entry key="TextInput.Topic.AddPropositions">Fügen Sie zusätzlichen Text zum aktuellen Projekt hinzu</entry>
<entry key="TextInput.Warning">WARNUNG:
Die Sprache des Ausgangstextes kann nach dem Betätigen der "Beginne Analyse"-Schaltfläche nicht mehr nachträglich geändert werden!</entry>
</properties>
</properties>
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,20 @@ public interface IPericopeView extends ISemanticalRelationProvider, IUndoManaged
*/
HmxModelHandler getModelHandler();

/**
* Getter for the view preference whether the label fields of propositions should be displayed or not.
*
* @return whether to displayed proposition label fields
*/
boolean isShowingPropositionLabels();

/**
* Getter for the view preference whether the translation fields of propositions should be displayed or not.
*
* @return whether to displayed proposition translation fields
*/
boolean isShowingPropositionTranslations();

/**
* Collect the list of selected {@link Proposition}s in the syntactical analysis, if it is currently active (i.e. displayed).
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.hmx.scitos.domain.util.ComparisonUtil;
import org.hmx.scitos.hmx.core.HmxModelHandler;
import org.hmx.scitos.hmx.core.i18n.HmxMessage;
import org.hmx.scitos.hmx.core.option.HmxGeneralOption;
import org.hmx.scitos.hmx.domain.ICommentable;
import org.hmx.scitos.hmx.domain.ISemanticalRelationProvider;
import org.hmx.scitos.hmx.domain.model.AbstractConnectable;
Expand Down Expand Up @@ -92,6 +93,14 @@ public final class CombinedAnalysesPanel extends JPanel implements IPericopeView
*/
private final JTextPane commentArea;

/**
* Flag indicating whether the label fields of propositions should be displayed or not.
*/
private boolean showingPropositionLabels = HmxGeneralOption.SHOW_PROPOSITION_LABELS.getValueAsBoolean();
/**
* Flag indicating whether the translation fields of propositions should be displayed or not.
*/
private boolean showingPropositionTranslations = HmxGeneralOption.SHOW_PROPOSITION_TRANSLATIONS.getValueAsBoolean();
/**
* The most recently selected commentable model element currently associated with the {@link #commentArea}.
*/
Expand Down Expand Up @@ -312,6 +321,36 @@ public void refresh() {
}
}

@Override
public boolean isShowingPropositionLabels() {
return this.showingPropositionLabels;
}

@Override
public boolean isShowingPropositionTranslations() {
return this.showingPropositionTranslations;
}

/**
* Toggle the visibility of the label fields for all propositions. This causes a full rebuild of the displayed Pericope.
*
* @see #refresh()
*/
public void togglePropositionLabelVisibility() {
this.showingPropositionLabels = !this.showingPropositionLabels;
this.refresh();
}

/**
* Toggle the visibility of the translation fields for all propositions. This causes a full rebuild of the displayed Pericope.
*
* @see #refresh()
*/
public void togglePropositionTranslationVisibility() {
this.showingPropositionTranslations = !this.showingPropositionTranslations;
this.refresh();
}

/**
* Determine the currently active analysis view (either {@link #synAnalysisView} or {@link #semAnalysisView}).
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package org.hmx.scitos.hmx.view.swing.components;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
Expand All @@ -29,7 +30,6 @@
import java.util.Map.Entry;

import javax.swing.JMenuItem;
import javax.swing.JPanel;

import org.hmx.scitos.core.HmxException;
import org.hmx.scitos.core.i18n.Message;
Expand Down Expand Up @@ -80,6 +80,14 @@ public class SingleProjectView extends AbstractProjectView<HmxSwingProject, Peri
* View specific Edit menu item for adding the contents of another project to this one which is already in progress (i.e. in analysis mode).
*/
private JMenuItem mergeProjectItem;
/**
* View specific View menu item for hiding/showing the labels of propositions in the analysis view.
*/
private JMenuItem toggleLabelsItem;
/**
* View specific View menu item for hiding/showing the translations of propositions in the analysis view.
*/
private JMenuItem toggleTranslationsItem;

/**
* Constructor.
Expand All @@ -103,7 +111,7 @@ public SingleProjectView(final HmxSwingProject project, final ILanguageModelProv
} else {
this.activeView = new TextInputPanel(this, true, languageModelProvider);
}
this.add((JPanel) this.activeView);
this.add((Component) this.activeView);
}

/**
Expand Down Expand Up @@ -168,9 +176,9 @@ public void addNewPropositions(final String originText, final boolean inFront) {
/** Switch from the text-input mode to the analysis mode. If this is already in analysis mode, this method does nothing. */
void goToAnalysisView() {
if (this.activeView instanceof TextInputPanel) {
this.remove((TextInputPanel) this.activeView);
this.remove((Component) this.activeView);
this.activeView = new CombinedAnalysesPanel(this.getProject().getModelHandler(), this.relationProvider);
this.add((CombinedAnalysesPanel) this.activeView);
this.add((Component) this.activeView);
this.revalidate();
this.manageMenuOptions();
}
Expand All @@ -180,9 +188,9 @@ void goToAnalysisView() {
void goToTextInputView() {
if (this.activeView instanceof CombinedAnalysesPanel) {
this.submitChangesToModel();
this.remove((CombinedAnalysesPanel) this.activeView);
this.remove((Component) this.activeView);
this.activeView = new TextInputPanel(this, false, null);
this.add((TextInputPanel) this.activeView);
this.add((Component) this.activeView);
this.revalidate();
this.manageMenuOptions();
}
Expand Down Expand Up @@ -221,12 +229,18 @@ private void manageMenuOptions() {
// handle general menu options
this.getProject().manageMenuOptions();
// handle view specific options
final boolean inAnalysisMode = this.activeView instanceof CombinedAnalysesPanel;
if (this.addTextItem != null) {
final boolean inAnalysisMode = this.activeView instanceof CombinedAnalysesPanel;
// avoid NullPointer if Edit menu items have not been created yet
this.addTextItem.setEnabled(inAnalysisMode);
this.removeTextItem.setEnabled(inAnalysisMode);
this.mergeProjectItem.setEnabled(inAnalysisMode);
}
if (this.toggleLabelsItem != null) {
// avoid NullPointer if View menu items have not been created yet
this.toggleLabelsItem.setEnabled(inAnalysisMode);
this.toggleTranslationsItem.setEnabled(inAnalysisMode);
}
}

@Override
Expand Down Expand Up @@ -307,13 +321,22 @@ public void actionPerformed(final ActionEvent event) {
return Arrays.asList(this.addTextItem, this.removeTextItem, this.mergeProjectItem, null, projectInfoItem);
}

// @Override
// public List<JMenuItem> createViewMenuItems() {
// TODO add menu item to hide/show translation input fields
// }

// @Override
// public List<Component> createToolBarItems() {
// TODO add tool bar item to hide/show translation input fields
// }
@Override
public List<JMenuItem> createViewMenuItems() {
this.toggleLabelsItem = new JMenuItem(HmxMessage.MENUBAR_TOGGLE_PROPOSITION_LABELS.get(), ScitosIcon.ATTRIBUTES_DISPLAY.create());
this.toggleLabelsItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent event) {
((CombinedAnalysesPanel) SingleProjectView.this.activeView).togglePropositionLabelVisibility();
}
});
this.toggleTranslationsItem = new JMenuItem(HmxMessage.MENUBAR_TOGGLE_PROPOSITION_TRANSLATIONS.get(), ScitosIcon.HORIZONTAL_RULE.create());
this.toggleTranslationsItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent event) {
((CombinedAnalysesPanel) SingleProjectView.this.activeView).togglePropositionTranslationVisibility();
}
});
return Arrays.asList(this.toggleLabelsItem, this.toggleTranslationsItem);
}
}
Loading

0 comments on commit c3d0ccb

Please sign in to comment.