From: <Jen...@us...> - 2008-09-09 14:27:43
|
Revision: 1188 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1188&view=rev Author: JensLehmann Date: 2008-09-09 14:27:41 +0000 (Tue, 09 Sep 2008) Log Message: ----------- more cleanup, added some status messages Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/Config.java trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java trunk/src/dl-learner/org/dllearner/gui/StartGUI.java trunk/src/dl-learner/org/dllearner/gui/StatusPanel.java Modified: trunk/src/dl-learner/org/dllearner/gui/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-09-09 13:48:15 UTC (rev 1187) +++ trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-09-09 14:27:41 UTC (rev 1188) @@ -31,6 +31,8 @@ import org.dllearner.core.ReasoningService; import org.dllearner.core.config.ConfigEntry; import org.dllearner.core.config.ConfigOption; +import org.dllearner.kb.KBFile; +import org.dllearner.kb.OWLFile; // import org.dllearner.core.Component; @@ -357,18 +359,18 @@ return false; } - public void reInit() { - cm = ComponentManager.getInstance(); - source = null; - reasoner = null; - rs = null; - lp = null; - la = null; - needsInit = new boolean[4]; - threadIsRunning = false; - algorithmRunStartTime = null; - algorithmRunStopTime = null; - } +// public void reInit() { +// cm = ComponentManager.getInstance(); +// source = null; +// reasoner = null; +// rs = null; +// lp = null; +// la = null; +// needsInit = new boolean[4]; +// threadIsRunning = false; +// algorithmRunStartTime = null; +// algorithmRunStopTime = null; +// } // init the specified component and record which ones where initialised public void init(int tabIndex) { @@ -394,29 +396,63 @@ // applies a configuration option - used as delegate method, which invalidates components public <T> void applyConfigEntry(Component component, ConfigEntry<T> entry) { cm.applyConfigEntry(component, entry); + // enable tabs if setting the value completed mandatory settings + enableTabsIfPossible(); // invalidate components if(component instanceof KnowledgeSource) { needsInit[0] = true; needsInit[1] = true; needsInit[2] = true; needsInit[3] = true; - if(mandatoryOptionsSpecified(component)) { - isEnabled[1] = true; + if(isEnabled[0]) { + gui.setStatusMessage("All mandatory options filled in. You can continue to the reasoner tab."); } } else if(component instanceof ReasonerComponent) { needsInit[1] = true; needsInit[2] = true; needsInit[3] = true; + if(isEnabled[1]) { + gui.setStatusMessage("All mandatory options filled in. You can continue to the learning problem tab."); + } } else if(component instanceof LearningProblem) { needsInit[2] = true; needsInit[3] = true; + if(isEnabled[2]) { + gui.setStatusMessage("All mandatory options filled in. You can continue to the learning algorithm tab."); + } } else if(component instanceof LearningAlgorithm) { needsInit[3] = true; + if(isEnabled[3]) { + gui.setStatusMessage("All mandatory options filled in. You can now run the algorithm."); + } } - gui.updateTabColors(); + + gui.updateTabs(); } + private void enableTabsIfPossible() { + if(mandatoryOptionsSpecified(source)) { + isEnabled[0] = true; + } else if(mandatoryOptionsSpecified(reasoner)) { + isEnabled[1] = true; + } else if(mandatoryOptionsSpecified(lp)) { + isEnabled[2] = true; + } else if(mandatoryOptionsSpecified(la)) { + isEnabled[3] = true; + } + } + + // TODO use specification of mandatory variables private boolean mandatoryOptionsSpecified(Component component) { + if(component instanceof OWLFile) { + if(cm.getConfigOptionValue(source, "url") != null) { + return true; + } + } else if(component instanceof KBFile) { + if(cm.getConfigOptionValue(source, "url") != null | cm.getConfigOptionValue(source, "filename") != null) { + return true; + } + } return false; } Modified: trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java 2008-09-09 13:48:15 UTC (rev 1187) +++ trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java 2008-09-09 14:27:41 UTC (rev 1188) @@ -74,7 +74,7 @@ * parse file */ public void startParser() { - config.reInit(); // new ComponentManager +// config.reInit(); // new ComponentManager if (this.file.exists()) { ConfParser parser = ConfParser.parseFile(file); // create a mapping between components and prefixes in the conf file @@ -94,7 +94,7 @@ config.setKnowledgeSource(config.getKnowledgeSource()); Start.configureComponent(config.getComponentManager(), config.getKnowledgeSource(), componentPrefixMapping, parser); - startGUI.updateTabColors(); + startGUI.updateTabs(); // init if (config.getKnowledgeSource() != null && config.isSetURL()) { try { @@ -122,7 +122,7 @@ config.getReasoner())); System.out.println("init ReasoningService"); // config.setInitReasoner(true); - startGUI.updateTabColors(); + startGUI.updateTabs(); } catch (ComponentInitException e) { e.printStackTrace(); } @@ -146,7 +146,7 @@ config.getLearningProblem().init(); // config.setInitLearningProblem(true); System.out.println("init LearningProblem"); - startGUI.updateTabColors(); + startGUI.updateTabs(); } catch (ComponentInitException e) { e.printStackTrace(); } @@ -170,14 +170,14 @@ config.getLearningAlgorithm().init(); // config.setInitLearningAlgorithm(true); System.out.println("init LearningAlgorithm"); - startGUI.updateTabColors(); + startGUI.updateTabs(); } catch (ComponentInitException e) { e.printStackTrace(); } } // update graphic - startGUI.updateTabColors(); + startGUI.updateTabs(); } } Modified: trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-09-09 13:48:15 UTC (rev 1187) +++ trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-09-09 14:27:41 UTC (rev 1188) @@ -46,13 +46,10 @@ private Config config; // private StartGUI startGUI; -// private JButton initButton; - private JButton setButton; private JButton clearButton; private String[] kbBoxItems = {}; private JComboBox cb = new JComboBox(kbBoxItems); private JPanel choosePanel = new JPanel(); -// private JPanel initPanel = new JPanel(); private int choosenClassIndex; private List<Class<? extends KnowledgeSource>> selectableSources; private OptionPanel optionPanel; @@ -69,13 +66,8 @@ // OWL API ontology is only useful programmatically (not in the GUI itself) selectableSources.remove(OWLAPIOntology.class); - setButton = new JButton("Set"); - setButton.addActionListener(this); - setButton = new JButton("Clear All"); - setButton.addActionListener(this); -// initButton = new JButton("Init KnowledgeSource"); -// initButton.addActionListener(this); -// initButton.setEnabled(true); + clearButton = new JButton("Reset to Default Values"); + clearButton.addActionListener(this); // add to comboBox for (int i = 0; i < selectableSources.size(); i++) { @@ -84,19 +76,15 @@ cb.addActionListener(this); choosePanel.add(cb); - choosePanel.add(setButton); + choosePanel.add(clearButton); choosenClassIndex = cb.getSelectedIndex(); // whenever a component is selected, we immediately create an instance (non-initialised) KnowledgeSource ks = config.newKnowledgeSource(selectableSources.get(cb.getSelectedIndex())); optionPanel = new OptionPanel(config, ks); - -// optionPanel = new OptionPanel(config, config.getKnowledgeSource(), sources.get(choosenClassIndex)); - // initPanel.add(initButton); - add(choosePanel, BorderLayout.PAGE_START); + add(choosePanel, BorderLayout.NORTH); add(optionPanel, BorderLayout.CENTER); -// add(initPanel, BorderLayout.PAGE_END); choosenClassIndex = cb.getSelectedIndex(); @@ -117,88 +105,33 @@ // init(); } - if (e.getSource() == setButton) { - setSource(); + if (e.getSource() == clearButton) { + config.setKnowledgeSource(config.getComponentManager().knowledgeSource( + selectableSources.get(choosenClassIndex))); + updateOptionPanel(); } // if (e.getSource() == initButton) { // init(); // } - if (e.getSource() == clearButton) { - config.reInit(); - } +// if (e.getSource() == clearButton) { +// config.reInit(); +// } } /** * after this, you can change widgets */ - public void setSource() { - config.setKnowledgeSource(config.getComponentManager().knowledgeSource( - selectableSources.get(choosenClassIndex))); -// config.setInitKnowledgeSource(false); - updateAll(); - } +// public void setSource() { +// +// } /** - * after this, next tab can be used - */ - /* - public void init() { - setSource(); - if (config.getKnowledgeSource() != null && config.isSetURL()) { - try { - config.getKnowledgeSource().init(); -// config.setInitKnowledgeSource(true); - System.out.println("init KnowledgeSource"); - startGUI.updateTabColors(); - } catch (ComponentInitException e) { - e.printStackTrace(); - } - } - } - */ - - /** - * updateAll - */ - public void updateAll() { -// updateComboBox(); - updateOptionPanel(); -// updateInitButtonColor(); - } - - /** - * set ComboBox to selected class - */ - /* - public void updateComboBox() { - if (config.getKnowledgeSource() != null) - for (int i = 0; i < selectableSources.size(); i++) - if (config.getKnowledgeSource().getClass().equals( - config.getComponentManager().getKnowledgeSources().get(i))) { - cb.setSelectedIndex(i); - } - this.choosenClassIndex = cb.getSelectedIndex(); - }*/ - - /** * update OptionPanel with new selection */ public void updateOptionPanel() { optionPanel.update(config.getKnowledgeSource()); } - /** - * make init-button red if you have to click - */ - /* - public void updateInitButtonColor() { - if (!config.needsInitKnowledgeSource()) { - initButton.setForeground(Color.RED); - } else - initButton.setForeground(Color.BLACK); - } - */ - } Modified: trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-09-09 13:48:15 UTC (rev 1187) +++ trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-09-09 14:27:41 UTC (rev 1188) @@ -107,7 +107,7 @@ if (config.needsInitReasoner()) { config.setLearningProblem(config.getComponentManager().learningProblem( lpClasses.get(choosenClassIndex), config.getReasoningService())); - startGUI.updateTabColors(); + startGUI.updateTabs(); updateOptionPanel(); } } Modified: trunk/src/dl-learner/org/dllearner/gui/StartGUI.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-09-09 13:48:15 UTC (rev 1187) +++ trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-09-09 14:27:41 UTC (rev 1188) @@ -123,7 +123,7 @@ add(tabPane, BorderLayout.CENTER); add(statusPanel, BorderLayout.SOUTH); setVisible(true); - updateTabColors(); + updateTabs(); // Register a change listener tabPane.addChangeListener(new ChangeListener() { @@ -141,18 +141,12 @@ } } - updateTabColors(); + updateTabs(); - // TODO: handle init code here => whenever a tab - // is selected, we have to determine whether it - // and the tabs before need to be initialised - - Component c = tabPane.getSelectedComponent(); - if (c == tab0) { - // System.out.println(tab0); - } + // new tab => ask user to fill in values + statusPanel.setTabInitMessage(); + } - // init(); } }); @@ -260,7 +254,7 @@ /** * Update colors of tabulators; red should be clicked, black for OK. */ - public void updateTabColors() { + public void updateTabs() { for(int i=0; i<4; i++) { // red = needs init, black = initialised if(config.needsInit(i)) { Modified: trunk/src/dl-learner/org/dllearner/gui/StatusPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/StatusPanel.java 2008-09-09 13:48:15 UTC (rev 1187) +++ trunk/src/dl-learner/org/dllearner/gui/StatusPanel.java 2008-09-09 14:27:41 UTC (rev 1188) @@ -32,9 +32,9 @@ private static final long serialVersionUID = 2426470148153461670L; - private String initText = "Please fill in the mandatory config options and proceed to the next tab."; + private String tabInitText = "Please fill in the mandatory config options and proceed to the next tab."; - private JLabel statusLabel = new JLabel(initText); + private JLabel statusLabel = new JLabel(tabInitText); public StatusPanel() { super(); @@ -44,5 +44,9 @@ public void setStatus(String message) { statusLabel.setText(message); } + + public void setTabInitMessage() { + statusLabel.setText(tabInitText); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |