Skip to content

Commit

Permalink
reordering the explanation preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
stefborg committed May 27, 2024
1 parent 76c63ad commit 9f66185
Showing 1 changed file with 9 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,7 @@
import java.util.HashMap;
import java.util.Map;

import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.*;

import org.protege.editor.core.ui.preferences.PreferencesLayoutPanel;
import org.protege.editor.owl.ui.preferences.OWLPreferencesPanel;
Expand All @@ -21,16 +15,16 @@ public class ExplanationPreferencesGeneralPanel extends OWLPreferencesPanel {

private static final long serialVersionUID = -3354987384223578780L;

private JRadioButton buttonLast, buttonFirst;
private JCheckBox checkRecentlyUsed;
private SortedPluginsTableModel tableModel;

@Override
public void initialise() throws Exception {
setLayout(new BorderLayout());
PreferencesLayoutPanel panel = new PreferencesLayoutPanel();
add(panel, BorderLayout.NORTH);
addDefaultExplanationServiceComponent(panel);
addInstalledExplanationServicesComponent(panel);
addDefaultExplanationServiceComponent(panel);
loadFrom(ExplanationPreferences.create().load());
}

Expand All @@ -47,34 +41,21 @@ public void applyChanges() {
}

private void loadFrom(ExplanationPreferences prefs) {
if (prefs.useLastExplanationService) {
buttonLast.setSelected(true);
} else {
buttonFirst.setSelected(true);
}
checkRecentlyUsed.setSelected(prefs.useLastExplanationService);
tableModel.setPluginIds(prefs.explanationServicesList);
tableModel.setDisabledIds(prefs.disabledExplanationServices);
}

private void saveTo(ExplanationPreferences prefs) {
prefs.useLastExplanationService = buttonLast.isSelected();
prefs.useLastExplanationService = checkRecentlyUsed.isSelected();
prefs.explanationServicesList = tableModel.getPluginIds();
prefs.disabledExplanationServices = tableModel.getDisabledIds();
}

private void addDefaultExplanationServiceComponent(PreferencesLayoutPanel panel) {
panel.addGroup("Default explanation service");
buttonLast = new JRadioButton("Most recently used explanation service");
buttonLast.setToolTipText(
"Always use the most recently used explanation service, if it can provide an explanation for the chosen axiom");
buttonFirst = new JRadioButton("First available explanation service from the list below");
buttonFirst.setToolTipText(
"Always use the first explanation service from the list below that can provide an explanation for the chosen axiom");
ButtonGroup group = new ButtonGroup();
group.add(buttonLast);
group.add(buttonFirst);
panel.addGroupComponent(buttonLast);
panel.addGroupComponent(buttonFirst);
checkRecentlyUsed = new JCheckBox("Try using the most recently used explanation service first");
checkRecentlyUsed.setToolTipText("Use the most recently used explanation service, if it can provide an explanation for the chosen axiom; otherwise, use the first available service from the list above");
panel.addGroupComponent(checkRecentlyUsed);
}

private void addInstalledExplanationServicesComponent(PreferencesLayoutPanel panel) {
Expand All @@ -88,7 +69,7 @@ private void addInstalledExplanationServicesComponent(PreferencesLayoutPanel pan
tableModel = new SortedPluginsTableModel(nameMap);
JTable pluginTable = new JTable(tableModel);
pluginTable.setToolTipText(
"Plugins that provide explanation facilities. You can disable and enable plugins and change their order using the buttons below.");
"Plugins that provide explanation facilities. Protégé will use the first enabled service on the list that can provide an explanation for the chosen axiom.");
pluginTable.setRowSelectionAllowed(true);
pluginTable.setColumnSelectionAllowed(false);
pluginTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
Expand Down

0 comments on commit 9f66185

Please sign in to comment.