Commit 4ebc346b authored by Dumoulin Nicolas's avatar Dumoulin Nicolas
Browse files

* logging configuration loaded from a file

 * some bugfixes in tree
parent 519cbf53
......@@ -11,6 +11,18 @@
<exec.executable>java</exec.executable>
</properties>
</action>
<action>
<actionName>run-devel</actionName>
<goals>
<goal>process-classes</goal>
<goal>org.codehaus.mojo:exec-maven-plugin:1.1:exec</goal>
</goals>
<properties>
<fr.level>ALL</fr.level>
<exec.args>-classpath %classpath fr.cemagref.ohoui.demo.View</exec.args>
<exec.executable>java</exec.executable>
</properties>
</action>
<action>
<actionName>debug</actionName>
<goals>
......
......@@ -2,15 +2,14 @@ package fr.cemagref.ohoui.demo;
import fr.cemagref.ohoui.annotations.Description;
import fr.cemagref.ohoui.ui.nodes.ValueProperty;
import fr.cemagref.ohoui.reflect.DefaultObjectIntrospector;
import fr.cemagref.ohoui.reflect.IntrospectionException;
import fr.cemagref.ohoui.reflect.OhOuiContext;
import fr.cemagref.ohoui.structure.OhObjectComplex;
import fr.cemagref.ohoui.ui.nodesandpanels.NodesAndPanelsPanel;
import fr.cemagref.ohoui.ui.panels.PanelsProvider;
import java.awt.FlowLayout;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.Logger;
import javax.swing.JFrame;
import org.openide.explorer.ExplorerManager;
import org.openide.explorer.view.NodeTableModel;
......@@ -84,6 +83,13 @@ public class View extends javax.swing.JPanel implements ExplorerManager.Provider
}
public static void main(String[] args) throws Exception {
try {
LogManager.getLogManager().readConfiguration(View.class.getResourceAsStream("logging.properties"));
} catch (IOException ex) {
Logger.getLogger(View.class.getName()).log(Level.WARNING,
"Problems to load the logging configuration file", ex);
}
JFrame f = new JFrame("OhOUI");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
......
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package fr.cemagref.ohoui.ui.nodesandpanels;
import fr.cemagref.ohoui.structure.OhObject;
import fr.cemagref.ohoui.ui.nodes.AbstractObjectNode;
import org.openide.nodes.Children;
/**
*
* @author dumoulin
*/
public class ObjectLeaf extends AbstractObjectNode<OhObject> {
public ObjectLeaf(OhObject object) {
super(object, Children.LEAF);
}
}
package fr.cemagref.ohoui.ui.nodesandpanels;
import fr.cemagref.ohoui.structure.OhObject;
import fr.cemagref.ohoui.structure.OhObjectCollection;
import fr.cemagref.ohoui.structure.OhObjectComplex;
import fr.cemagref.ohoui.ui.nodes.AbstractObjectNode;
import fr.cemagref.ohoui.ui.panels.PanelsProvider;
import org.openide.nodes.Children;
import org.openide.nodes.Children.Keys;
import org.openide.nodes.Node;
public class ObjectNode extends AbstractObjectNode<OhObjectComplex> {
public ObjectNode(OhObjectComplex object) {
super(object, new ObjectChildren(object));
}
}
class ObjectChildren extends Children.Keys<OhObject> {
public ObjectChildren(OhObjectComplex object) {
setKeys(object.getChildren());
}
@Override
protected Node[] createNodes(OhObject ohObject) {
// TODO stop if oheditor provided for this object
if (ohObject instanceof OhObjectComplex) {
OhObjectComplex<?> complexOhObject = (OhObjectComplex) ohObject;
if (PanelsProvider.isTypeHandled(ohObject.getDeclaredType())) {
return new Node[]{};
} else if (complexOhObject instanceof OhObjectCollection) {
return new Node[]{new ObjectNode(complexOhObject)};
} else {
boolean hasComplexChild = false;
for (OhObject child : complexOhObject) {
if (child instanceof OhObjectComplex) {
hasComplexChild = true;
break;
}
}
if (hasComplexChild) {
return new Node[]{new ObjectNode(complexOhObject)};
} else {
return new Node[]{new ObjectLeaf(ohObject)};
}
}
} else if (ohObject.getParent() instanceof OhObjectCollection) {
return new Node[]{new ObjectLeaf(ohObject)};
}
return new Node[]{};
}
}
......@@ -54,8 +54,7 @@ public class OhTreeModel implements TreeModel {
@Override
public boolean isLeaf(Object node) {
OhObject ohObject = (OhObject) node;
return (((node instanceof OhObjectComplex) && (PanelsProvider.isTypeHandled(ohObject.getDeclaredType())))
|| (!(node instanceof OhObjectComplex) && !(ohObject.getParent() instanceof OhObjectCollection)));
return (!(node instanceof OhObjectComplex) || (PanelsProvider.isTypeHandled(ohObject)));
}
@Override
......
......@@ -16,9 +16,11 @@ public class DefaultObjectEditor extends AbstractOhEditor<Object, JComponent> {
panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
if (object instanceof OhObjectComplex) {
for (OhObject child : (OhObjectComplex<?>)object) {
if (PanelsProvider.isTypeHandled(child.getDeclaredType())) {
panel.add((JComponent)PanelsProvider.getEditor(child.getDeclaredType()).getEditor(child).getPanel());
for (OhObject child : (OhObjectComplex<?>) object) {
if (child.getValue() == null) {
// TODO add button for object creation
} else if (PanelsProvider.isTypeHandled(child)) {
panel.add((JComponent) PanelsProvider.getEditor(child).getEditor(child).getPanel());
}
}
}
......
......@@ -16,6 +16,7 @@
*/
package fr.cemagref.ohoui.ui.panels;
import fr.cemagref.ohoui.structure.OhObject;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
......@@ -59,13 +60,20 @@ public class PanelsProvider {
return getDefault().editorProducers.keySet();
}
public static boolean isTypeHandled(Class type) {
return getDefault().editorProducers.containsKey(type);
public static boolean isTypeHandled(OhObject ohObject) {
if (ohObject.getValue() != null) {
return getDefault().editorProducers.containsKey(ohObject.getValue().getClass());
}
return true;
}
public static OhEditorProducer getEditor(Class type) {
OhEditorProducer editor = getDefault().editorProducers.get(type);
public static OhEditorProducer getEditor(OhObject ohObject) {
OhEditorProducer editor = null;
if (ohObject.getValue() != null) {
editor = getDefault().editorProducers.get(ohObject.getValue().getClass());
}
if (editor == null) {
// TODO return an new DefaultObjectEditor ? should be avoided upstream
}
return editor;
}
......
# Copyright (C) 2010 Cemagref
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
handlers = java.util.logging.ConsoleHandler
fr.cemagref.ohoui.level = ALL
java.util.logging.ConsoleHandler.level = ALL
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment