Author: tchemit Date: 2010-03-11 00:49:05 +0100 (Thu, 11 Mar 2010) New Revision: 1768 Log: - fix javadoc - reformat code - use none deprecated api Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXUtil.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/LocaleEditor.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationMultiContentUI.java Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXUtil.java =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXUtil.java 2010-03-10 22:28:59 UTC (rev 1767) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXUtil.java 2010-03-10 23:49:05 UTC (rev 1768) @@ -21,6 +21,7 @@ package jaxx.runtime; import jaxx.runtime.context.JAXXContextEntryDef; +import jaxx.runtime.context.JAXXInitialContext; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -36,17 +37,22 @@ public class JAXXUtil { - // public static final String DEFAULT_ICON_PATH = "/icons/"; - // public static final String DEFAULT_ICON_PATH_PROPERTY = "default.icon.path"; /** * Logger */ static private final Log log = LogFactory.getLog(JAXXUtil.class); + public static final String PARENT = "parent"; + // Maps root objects to lists of event listeners - private static Map<Object, WeakReference<List<EventListenerDescriptor>>> eventListeners = new WeakHashMap<Object, WeakReference<List<EventListenerDescriptor>>>(); - private static Map<JAXXObject, WeakReference<List<DataBindingUpdateListener>>> dataBindingUpdateListeners = new WeakHashMap<JAXXObject, WeakReference<List<DataBindingUpdateListener>>>(); + private static Map<Object, WeakReference<List<EventListenerDescriptor>>> + eventListeners = new WeakHashMap<Object, WeakReference<List<EventListenerDescriptor>>>(); + private static Map<JAXXObject, WeakReference<List<DataBindingUpdateListener>>> + dataBindingUpdateListeners = new WeakHashMap<JAXXObject, WeakReference<List<DataBindingUpdateListener>>>(); + + private static final PropertyChangeListener[] EMPTY_ARRAY_PROPERTY_CHANGE_LISTENERS = new PropertyChangeListener[0]; + private static class EventListenerDescriptor { Class<?> listenerClass; @@ -63,9 +69,11 @@ * @param descriptor descriptor to decode * @return the dedoced descriptor */ - public static JAXXObjectDescriptor decodeJAXXObjectDescriptor(String descriptor) { + public static JAXXObjectDescriptor decodeJAXXObjectDescriptor( + String descriptor) { try { - return (JAXXObjectDescriptor) Base64Coder.deserialize(descriptor, false); + return (JAXXObjectDescriptor) Base64Coder.deserialize(descriptor, + false); /*byte[] data = new byte[descriptor.length()]; // copy low-order bytes into the array. The high-order bytes should all be zero. System.arraycopy(descriptor.getBytes(), 0, data, 0, data.length); @@ -79,9 +87,11 @@ } } - public static JAXXObjectDescriptor decodeCompressedJAXXObjectDescriptor(String descriptor) { + public static JAXXObjectDescriptor decodeCompressedJAXXObjectDescriptor( + String descriptor) { try { - return (JAXXObjectDescriptor) Base64Coder.deserialize(descriptor, true); + return (JAXXObjectDescriptor) Base64Coder.deserialize(descriptor, + true); /*byte[] data = new byte[descriptor.length()]; // copy low-order bytes into the array. The high-order bytes should all be zero. @@ -96,11 +106,13 @@ } } - public static <O> JAXXContextEntryDef<O> newContextEntryDef(Class<O> klass) { + public static <O> JAXXContextEntryDef<O> newContextEntryDef( + Class<O> klass) { return newContextEntryDef(null, klass); } - public static <O> JAXXContextEntryDef<O> newContextEntryDef(String name, Class<O> klass) { + public static <O> JAXXContextEntryDef<O> newContextEntryDef( + String name, Class<O> klass) { return new JAXXContextEntryDef<O>(name, klass); } @@ -108,42 +120,14 @@ return newListContextEntryDef(null); } - public static <O> JAXXContextEntryDef<List<O>> newListContextEntryDef(String name) { - Class<List<O>> castList = JAXXUtil.castList(); - JAXXContextEntryDef<List<O>> contextEntryDef = new JAXXContextEntryDef<List<O>>(name, castList); + public static <O> JAXXContextEntryDef<List<O>> newListContextEntryDef( + String name) { + Class<List<O>> castList = castList(); + JAXXContextEntryDef<List<O>> contextEntryDef = + new JAXXContextEntryDef<List<O>>(name, castList); return contextEntryDef; } -// public static DefaultJAXXBinding registerBinding(Map<String, DefaultJAXXBinding> bindings, DefaultJAXXBinding binding) { -// bindings.put(binding.getId(), binding); -//// binding.applyDataBinding(); -//// binding.processDataBinding(); -// return binding; -// } - -// /** -// * Return parent's container corresponding to the Class clazz -// * -// * @param <O> type of container to obtain from context -// * @param top the top container -// * @param clazz desired -// * @return parent's container -// */ -// @SuppressWarnings({"unchecked"}) -// public static <O extends Container> O getParentContainer(Object top, Class<O> clazz) { -// if (top == null) { -// throw new IllegalArgumentException("top parameter can not be null"); -// } -// if (!Container.class.isAssignableFrom(top.getClass())) { -// throw new IllegalArgumentException("top parameter " + top + " is not a " + Container.class); -// } -// Container parent = ((Container) top).getParent(); -// if (parent != null && !clazz.isAssignableFrom(parent.getClass())) { -// parent = getParentContainer(parent, clazz); -// } -// return (O) parent; -// } - @SuppressWarnings({"unchecked"}) protected static <O> Class<List<O>> castList() { return (Class<List<O>>) Collections.emptyList().getClass(); @@ -157,8 +141,8 @@ */ public static void initContext(JAXXObject ui, JAXXContext parentContext) { - if (parentContext instanceof jaxx.runtime.context.JAXXInitialContext) { - ((jaxx.runtime.context.JAXXInitialContext) parentContext).to(ui); + if (parentContext instanceof JAXXInitialContext) { + ((JAXXInitialContext) parentContext).to(ui); } else { ui.setContextValue(parentContext); } @@ -169,16 +153,29 @@ } } - public static <E extends EventListener> E getEventListener(Class<E> listenerClass, final String listenerMethodName, final Object methodContainer, final String methodName) { - WeakReference<List<EventListenerDescriptor>> ref = eventListeners.get(methodContainer); - List<EventListenerDescriptor> descriptors = ref != null ? ref.get() : null; + public static <E extends EventListener> E getEventListener( + Class<E> listenerClass, + final String listenerMethodName, + final Object methodContainer, + String methodName) { + + WeakReference<List<EventListenerDescriptor>> ref = + eventListeners.get(methodContainer); + List<EventListenerDescriptor> descriptors = ref != null ? + ref.get() : null; if (descriptors == null) { descriptors = new ArrayList<EventListenerDescriptor>(); - eventListeners.put(methodContainer, new WeakReference<List<EventListenerDescriptor>>(descriptors)); + eventListeners.put( + methodContainer, + new WeakReference<List<EventListenerDescriptor>>( + descriptors)); } else { for (EventListenerDescriptor descriptor : descriptors) { - if (listenerClass == descriptor.listenerClass && - (listenerMethodName == null ? descriptor.listenerMethodName == null : listenerMethodName.equals(descriptor.listenerMethodName)) && + if (descriptor.listenerClass.equals(listenerClass) && + (listenerMethodName == null ? + descriptor.listenerMethodName == null : + listenerMethodName.equals( + descriptor.listenerMethodName)) && methodName.equals(descriptor.methodName)) { return (E) descriptor.eventListener; } @@ -191,35 +188,48 @@ descriptor.listenerMethodName = listenerMethodName; descriptor.methodName = methodName; try { - final List<Method> listenerMethods = Arrays.asList(listenerClass.getMethods()); + final List<Method> listenerMethods = + Arrays.asList(listenerClass.getMethods()); Method listenerMethod = null; if (listenerMethodName != null) { for (Method listenerMethod1 : listenerMethods) { - if ((listenerMethod1).getName().equals(listenerMethodName)) { + if (listenerMethod1.getName().equals(listenerMethodName)) { listenerMethod = listenerMethod1; break; } } } if (listenerMethodName != null && listenerMethod == null) { - throw new IllegalArgumentException("no method named " + listenerMethodName + " found in class " + listenerClass.getName()); + throw new IllegalArgumentException( + "no method named " + listenerMethodName + + " found in class " + listenerClass.getName()); } - Class<?>[] parameterTypes = listenerMethods.get(0).getParameterTypes(); + Class<?>[] parameterTypes = + listenerMethods.get(0).getParameterTypes(); Class<?> methodContainerClass = methodContainer.getClass(); - final Method targetMethod = methodContainerClass.getMethod(methodName, parameterTypes); - descriptor.eventListener = Proxy.newProxyInstance(listenerClass.getClassLoader(), + final Method targetMethod = + methodContainerClass.getMethod(methodName, parameterTypes); + descriptor.eventListener = + Proxy.newProxyInstance(listenerClass.getClassLoader(), new Class<?>[]{listenerClass}, new InvocationHandler() { @Override - public Object invoke(Object proxy, Method method, Object[] args) { + public Object invoke(Object proxy, + Method method, + Object[] args) { String methodName = method.getName(); - if ((listenerMethodName == null && listenerMethods.contains(method)) || methodName.equals(listenerMethodName)) { + if ((listenerMethodName == null && + listenerMethods.contains(method)) || + methodName.equals(listenerMethodName)) { try { targetMethod.setAccessible(true); - return targetMethod.invoke(methodContainer, args); + return targetMethod.invoke( + methodContainer, args); } catch (IllegalAccessException e) { - throw new RuntimeException("could not invoke on container " + methodContainer, e); + throw new RuntimeException( + "could not invoke on container " + + methodContainer, e); } catch (InvocationTargetException e) { throw new RuntimeException(e); } @@ -243,16 +253,26 @@ } } - public static <E extends EventListener> E getEventListener(Class<E> listenerClass, final Object methodContainer, final String methodName) { - return getEventListener(listenerClass, null, methodContainer, methodName); + public static <E extends EventListener> E getEventListener( + Class<E> listenerClass, + Object methodContainer, + String methodName) { + return getEventListener(listenerClass, null, methodContainer, + methodName); } - public static DataBindingUpdateListener getDataBindingUpdateListener(JAXXObject object, String bindingName) { - WeakReference<List<DataBindingUpdateListener>> ref = dataBindingUpdateListeners.get(object); - List<DataBindingUpdateListener> listeners = ref == null ? null : ref.get(); + public static DataBindingUpdateListener getDataBindingUpdateListener( + JAXXObject object, String bindingName) { + WeakReference<List<DataBindingUpdateListener>> ref = + dataBindingUpdateListeners.get(object); + List<DataBindingUpdateListener> listeners = ref == null ? null : + ref.get(); if (listeners == null) { listeners = new ArrayList<DataBindingUpdateListener>(); - dataBindingUpdateListeners.put(object, new WeakReference<List<DataBindingUpdateListener>>(listeners)); + dataBindingUpdateListeners.put( + object, + new WeakReference<List<DataBindingUpdateListener>>( + listeners)); } else { for (DataBindingUpdateListener listener : listeners) { if (bindingName.equals(listener.getBindingName())) { @@ -260,7 +280,8 @@ } } } - DataBindingUpdateListener listener = new DataBindingUpdateListener(object, bindingName); + DataBindingUpdateListener listener = + new DataBindingUpdateListener(object, bindingName); listeners.add(listener); return listener; } @@ -329,7 +350,7 @@ return value; } - public static java.lang.Object assignment(java.lang.Object value, String name, JAXXObject src) { + public static Object assignment(Object value, String name, JAXXObject src) { src.firePropertyChange(name.trim(), null, "dummy value"); return value; } @@ -340,7 +361,8 @@ * Return empty string if given object is null * * @param value the value to write - * @return the string representation of the given object or an empty string if object is null. + * @return the string representation of the given object or an empty + * string if object is null. */ public static String getStringValue(Object value) { String result; @@ -349,7 +371,8 @@ } /** - * Test if a type of entry exists in a given context and throw an IllegalArgumentException if not found. + * Test if a type of entry exists in a given context and throw an + * IllegalArgumentException if not found. * <p/> * If entry is found, return his value in context. * @@ -359,12 +382,16 @@ * @return the value from the context * @throws IllegalArgumentException if the entry is not found in context. */ - public static <T> T checkJAXXContextEntry(JAXXContext context, JAXXContextEntryDef<T> def) throws IllegalArgumentException { + public static <T> T checkJAXXContextEntry(JAXXContext context, + JAXXContextEntryDef<T> def) + throws IllegalArgumentException { T value = def.getContextValue(context); if (value == null) { - throw new IllegalArgumentException("the context entry [" + def + "] ] was not found in context " + context); + throw new IllegalArgumentException( + "the context entry [" + def + "] ] was not found in " + + "context " + context); } return value; @@ -387,7 +414,8 @@ * @param src the ui to treate * @param bindings the list of binding to process. */ - public static void applyDataBinding(JAXXObject src, Collection<String> bindings) { + public static void applyDataBinding(JAXXObject src, + Collection<String> bindings) { for (String binding : bindings) { src.applyDataBinding(binding); } @@ -417,52 +445,6 @@ } } -// public static ImageIcon createIcon(String path) { -// java.net.URL imgURL = JAXXUtil.class.getResource(path); -// if (imgURL != null) { -// return new ImageIcon(imgURL); -// } else { -// throw new IllegalArgumentException("could not find icon " + path); -// } -// } - -// /** -// * @param path the location of icons in root directory icons -// * @return the icon at {@link #getIconPath()}+path -// */ -// public static ImageIcon createImageIcon(String path) { -// String iconPath = getIconPath(); -// return createIcon(iconPath + path); -// } -// -// /** -// * @param key the key of the icon to retreave from {@link UIManager} -// * @return the icon, or <code>null if no icon found in {@link UIManager} -// */ -// public static Icon getUIManagerIcon(String key) { -// return UIManager.getIcon(key); -// } -// -// /** -// * retreave for the {@link UIManager} the icon prefixed by <code>action.</code> -// * -// * @param key the key of the action icon to retreave from {@link UIManager} -// * @return the icon, or <code>null if no icon found in {@link UIManager} -// */ -// public static Icon getUIManagerActionIcon(String key) { -// return getUIManagerIcon("action." + key); -// } -// -// public static ImageIcon createActionIcon(String name) { -// String iconPath = getIconPath(); -// return createIcon(iconPath + "action-" + name + ".png"); -// } -// -// public static ImageIcon createI18nIcon(String name) { -// String iconPath = getIconPath(); -// return createIcon(iconPath + "i18n/" + name + ".png"); -// } - /** * detects all PropertychangedListener added by Jaxx uis * (should be a {@link DataBindingListener} @@ -471,13 +453,15 @@ * @param listeners the array of listeners to filter * @return the filtered listeners */ - public static PropertyChangeListener[] findJaxxPropertyChangeListener(String[] propertyNames, PropertyChangeListener... listeners) { + public static PropertyChangeListener[] findJaxxPropertyChangeListener( + String[] propertyNames, PropertyChangeListener... listeners) { if (listeners == null || listeners.length == 0) { - return new PropertyChangeListener[0]; + return EMPTY_ARRAY_PROPERTY_CHANGE_LISTENERS; } List<String> pNames = Arrays.asList(propertyNames); - List<PropertyChangeListener> toRemove = new ArrayList<PropertyChangeListener>(); + List<PropertyChangeListener> toRemove = + new ArrayList<PropertyChangeListener>(); for (PropertyChangeListener listener : listeners) { String pName = null; @@ -491,9 +475,12 @@ listener = (PropertyChangeListener) plistener.getListener(); pName = plistener.getPropertyName(); } - if (plistener != null && pName != null && listener instanceof DataBindingListener) { + if (plistener != null && + pName != null && + listener instanceof DataBindingListener) { if (log.isDebugEnabled()) { - log.debug("find config listener to remove [" + pName + "] : " + listener); + log.debug("find config listener to remove [" + pName + + "] : " + listener); } toRemove.add(plistener); //toRemove.add(listener); @@ -502,15 +489,4 @@ return toRemove.toArray(new PropertyChangeListener[toRemove.size()]); } -// private static String getIconPath() { -// String iconPath = UIManager.getString(DEFAULT_ICON_PATH_PROPERTY); -// if (iconPath == null) { -// iconPath = DEFAULT_ICON_PATH; -// } else { -// if (!iconPath.endsWith("/")) { -// iconPath += "/"; -// } -// } -// return iconPath; -// } } Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java 2010-03-10 22:28:59 UTC (rev 1767) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java 2010-03-10 23:49:05 UTC (rev 1768) @@ -59,7 +59,6 @@ import javax.swing.tree.TreeNode; import javax.swing.tree.TreePath; -import jaxx.runtime.swing.navigation.NavigationTreeNode; import jaxx.runtime.swing.renderer.BooleanCellRenderer; import jaxx.runtime.swing.renderer.EmptyNumberTableCellRenderer; import jaxx.runtime.swing.renderer.EnumTableCellRenderer; @@ -85,11 +84,17 @@ * to use log facility, just put in your code: log.info(\"...\"); */ static private final Log log = LogFactory.getLog(SwingUtil.class); + public static final String DEFAULT_ICON_PATH = "/icons/"; + public static final String DEFAULT_ICON_PATH_PROPERTY = "default.icon.path"; + private static Field numReaders; + private static Field notifyingListeners; + public static final String ICON_PREFIX = "icon."; + public static final String COLOR_PREFIX = "color."; public static Dimension newMinDimension() { @@ -161,9 +166,12 @@ * @param data data ot inject in combo * @param select the object to select in combo after reflling his model */ - public static void fillComboBox(JComboBox combo, Collection<?> data, Object select) { + public static void fillComboBox(JComboBox combo, Collection<?> data, + Object select) { if (!(combo.getModel() instanceof DefaultComboBoxModel)) { - throw new IllegalArgumentException("this method need a DefaultComboBoxModel for this model but was " + combo.getModel().getClass()); + throw new IllegalArgumentException( + "this method need a DefaultComboBoxModel for " + + "this model but was " + combo.getModel().getClass()); } DefaultComboBoxModel model = (DefaultComboBoxModel) combo.getModel(); // evince the model @@ -188,7 +196,9 @@ */ public static void fillList(JList list, Collection<?> data, Object select) { if (!(list.getModel() instanceof DefaultListModel)) { - throw new IllegalArgumentException("this method need a DefaultListModel for this model but was " + list.getModel().getClass()); + throw new IllegalArgumentException( + "this method need a DefaultListModel for this model " + + "but was " + list.getModel().getClass()); } DefaultListModel model = (DefaultListModel) list.getModel(); // evince the model @@ -216,14 +226,18 @@ * @deprecated since 1.7.XXX this code is moved to JAXXComboBox */ @Deprecated - public static void fillComboBox(JAXXComboBox combo, Collection<?> data, Object select, boolean firstNull) { + public static void fillComboBox(JAXXComboBox combo, + Collection<?> data, + Object select, boolean firstNull) { List<Item> items = new ArrayList<Item>(); if (firstNull) { items.add(new Item("null", " ", null, false)); } if (data != null) { for (Object d : data) { - items.add(new Item(d.toString(), d.toString(), d, d.equals(select))); + Item item = new Item(d.toString(), d.toString(), d, + d.equals(select)); + items.add(item); } } combo.setItems(items); @@ -238,12 +252,14 @@ * @return parent's container */ @SuppressWarnings({"unchecked"}) - public static <O extends Container> O getParentContainer(Object top, Class<O> clazz) { + public static <O extends Container> O getParentContainer(Object top, + Class<O> clazz) { if (top == null) { throw new IllegalArgumentException("top parameter can not be null"); } if (!Container.class.isAssignableFrom(top.getClass())) { - throw new IllegalArgumentException("top parameter " + top + " is not a " + Container.class); + throw new IllegalArgumentException("top parameter " + top + + " is not a " + Container.class); } Container parent = ((Container) top).getParent(); if (parent != null && !clazz.isAssignableFrom(parent.getClass())) { @@ -252,7 +268,9 @@ return (O) parent; } - public static int computeTableColumnWidth(JTable table, Font font, int columnIndex, String suffix) { + public static int computeTableColumnWidth(JTable table, + Font font, + int columnIndex, String suffix) { int width = 0; if (font == null) { font = table.getFont(); @@ -272,7 +290,9 @@ return width; } - public static void fixTableColumnWidth(JTable table, int columnIndex, int width) { + public static void fixTableColumnWidth(JTable table, + int columnIndex, + int width) { TableColumn column = table.getColumnModel().getColumn(columnIndex); column.setMaxWidth(width); column.setMinWidth(width); @@ -280,37 +300,69 @@ column.setPreferredWidth(width); } - public static void setTableColumnEditor(JTable table, int columnIndex, TableCellEditor editor) { + public static void setTableColumnEditor(JTable table, + int columnIndex, + TableCellEditor editor) { TableColumn column = table.getColumnModel().getColumn(columnIndex); column.setCellEditor(editor); } - public static void setTableColumnRenderer(JTable table, int columnIndex, TableCellRenderer editor) { + public static void setTableColumnRenderer(JTable table, + int columnIndex, + TableCellRenderer editor) { TableColumn column = table.getColumnModel().getColumn(columnIndex); column.setCellRenderer(editor); } - public static void setI18nTableHeaderRenderer(JTable table, String... libelles) { - table.getTableHeader().setDefaultRenderer(new I18nTableCellRenderer(table.getTableHeader().getDefaultRenderer(), libelles)); + public static void setI18nTableHeaderRenderer(JTable table, + String... libelles) { + I18nTableCellRenderer defaultRenderer = + new I18nTableCellRenderer( + table.getTableHeader().getDefaultRenderer(), libelles); + table.getTableHeader().setDefaultRenderer(defaultRenderer); } - public static TableCellRenderer newStringTableCellRenderer(final DefaultTableCellRenderer renderer, final int length, final boolean tooltip) { + public static TableCellRenderer newStringTableCellRenderer( + final DefaultTableCellRenderer renderer, + final int length, + final boolean tooltip) { return new DefaultTableCellRenderer() { private static final long serialVersionUID = 1l; @Override - public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + public Component getTableCellRendererComponent( + JTable table, + Object value, + boolean isSelected, + boolean hasFocus, + int row, + int column) { - renderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + renderer.getTableCellRendererComponent( + table, + value, + isSelected, + hasFocus, + row, + column + ); String val = renderer.getText(); String val2 = val; if (val.length() > length) { val2 = val.substring(0, length - 3) + "..."; } - JComponent comp = (JComponent) super.getTableCellRendererComponent(table, val2, isSelected, hasFocus, row, column); + JComponent comp = (JComponent) + super.getTableCellRendererComponent( + table, + val2, + isSelected, + hasFocus, + row, + column + ); if (tooltip) { comp.setToolTipText(val); } @@ -320,17 +372,17 @@ } /** - * Box a component in a {@link org.jdesktop.jxlayer.JXLayer}. + * Box a component in a {@link JXLayer}. * * @param component the component to box - * @return the {@link org.jdesktop.jxlayer.JXLayer} boxing the component + * @return the {@link JXLayer} boxing the component */ public static JXLayer<?> boxComponentWithJxLayer(JComponent component) { JXLayer<?> layer = getLayer(component); if (layer != null) { return layer; } - layer = new org.jdesktop.jxlayer.JXLayer<JComponent>(); + layer = new JXLayer<JComponent>(); layer.add(component); return layer; } @@ -378,15 +430,19 @@ * @param container le container ou rechercher les composants d'edition * @return le dictionnaire des composants recherches. */ - public static Map<String, JComponent> lookingForEditor(Class<?> clazz, Container container) { + public static Map<String, JComponent> lookingForEditor( + Class<?> clazz, + Container container) { Map<String, JComponent> result = new HashMap<String, JComponent>(); try { // looking for all component with name set - Map<String, JComponent> allNamedComponent = new HashMap<String, JComponent>(); + Map<String, JComponent> allNamedComponent = + new HashMap<String, JComponent>(); List<Container> todo = new LinkedList<Container>(); todo.add(container); while (todo.size() > 0) { - for (ListIterator<Container> i = todo.listIterator(); i.hasNext();) { + for (ListIterator<Container> i = todo.listIterator(); + i.hasNext();) { Container parent = i.next(); i.remove(); for (Component c : parent.getComponents()) { @@ -463,13 +519,17 @@ } /** - * Load the ui.properties file and set in {@link UIManager} colors and icons found. + * Load the ui.properties file and set in {@link UIManager} colors and + * icons found. * - * @param defaultUIConfig le path vers le fichier de la config d'ui par défaut (doit etre dansle class-path) - * @param extraUIConfig le path vers une surcharge de la config d'ui (doit etre dans le class-path) + * @param defaultUIConfig le path vers le fichier de la config d'ui par + * défaut (doit etre dansle class-path) + * @param extraUIConfig le path vers une surcharge de la config d'ui + * (doit etre dans le class-path) * @throws IOException if could not load the ui.properties file */ - public static void loadUIConfig(String defaultUIConfig, String extraUIConfig) throws IOException { + public static void loadUIConfig(String defaultUIConfig, + String extraUIConfig) throws IOException { Properties p = new Properties(); log.info("loading default UI config " + defaultUIConfig); @@ -478,7 +538,8 @@ log.debug(p.toString()); } if (extraUIConfig != null) { - InputStream extraStream = SwingUtil.class.getResourceAsStream(extraUIConfig); + InputStream extraStream = + SwingUtil.class.getResourceAsStream(extraUIConfig); if (extraStream == null) { log.warn("could not find extraUIConfig : " + extraUIConfig); } else { @@ -506,7 +567,14 @@ if (key.startsWith(COLOR_PREFIX)) { String value = (String) entry.getValue(); String[] rgb = value.split(","); - UIManager.put(key.substring(COLOR_PREFIX.length()), new Color(Integer.valueOf(rgb[0]), Integer.valueOf(rgb[1]), Integer.valueOf(rgb[2]))); + UIManager.put( + key.substring(COLOR_PREFIX.length()), + new Color( + Integer.valueOf(rgb[0]), + Integer.valueOf(rgb[1]), + Integer.valueOf(rgb[2]) + ) + ); } } } @@ -520,7 +588,8 @@ * @return the iterator * @since 1.4 */ - public static TabbedPaneIterator<Component> newTabbedPaneIterator(JTabbedPane tabs) { + public static TabbedPaneIterator<Component> newTabbedPaneIterator( + JTabbedPane tabs) { return new TabbedPaneIterator<Component>(false, tabs) { @Override @@ -533,7 +602,7 @@ /** * A simple iterator on a {@link JTabbedPane}. * <p/> - * Implements the method {@link #get(int, java.awt.Component)} to obtain + * Implements the method {@link #get(int, Component)} to obtain * the data required given the component (or index). * <p/> * You can also inverse the order by usin the method {@link #reverse()}. @@ -598,7 +667,8 @@ @Override public String toString() { - return super.toString() + "< reverse:" + reverse + ", index:" + index + ", size:" + tabs.getTabCount() + " >"; + return super.toString() + "< reverse:" + reverse + ", index:" + + index + ", size:" + tabs.getTabCount() + " >"; } protected void setReverse(boolean reverse) { @@ -643,7 +713,9 @@ if (parent instanceof Container) { Container cont = (Container) parent; // use a copy of 1.3 Container.findComponentAt - Component child = findComponentAt(cont, cont.getWidth(), cont.getHeight(), x, y); + Component child = findComponentAt(cont, + cont.getWidth(), + cont.getHeight(), x, y); if (child != null && child != cont) { //log.info("child find : " + child.getName()); if (child instanceof JRootPane) { @@ -662,11 +734,16 @@ return parent; } - public static Component findComponentAt(Container cont, int width, int height, int x, int y) { + public static Component findComponentAt(Container cont, + int width, + int height, + int x, + int y) { //log.info("container : " + cont.getName()); synchronized (cont.getTreeLock()) { - if (!((x >= 0) && (x < width) && (y >= 0) && (y < height) && cont.isVisible() && cont.isEnabled())) { + if (!(x >= 0 && x < width && y >= 0 && y < height && + cont.isVisible() && cont.isEnabled())) { return null; } @@ -687,7 +764,13 @@ comp = layer.getView(); } if (comp instanceof Container) { - comp = findComponentAt((Container) comp, rect.width, rect.height, x - rect.x, y - rect.y); + comp = findComponentAt( + (Container) comp, + rect.width, + rect.height, + x - rect.x, + y - rect.y + ); } else { comp = comp.getComponentAt(x - rect.x, y - rect.y); } @@ -710,7 +793,13 @@ comp = layer.getView(); } if (comp instanceof Container) { - comp = findComponentAt((Container) comp, rect.width, rect.height, x - rect.x, y - rect.y); + comp = findComponentAt( + (Container) comp, + rect.width, + rect.height, + x - rect.x, + y - rect.y + ); } else { comp = comp.getComponentAt(x - rect.x, y - rect.y); } @@ -723,7 +812,8 @@ } } - public static TableCellRenderer newDeleteCellRenderer(DefaultTableCellRenderer renderer) { + public static TableCellRenderer newDeleteCellRenderer( + DefaultTableCellRenderer renderer) { Icon icon = UIManager.getIcon("Table.removeIcon"); if (icon == null) { // try with default icon @@ -732,15 +822,18 @@ return new BooleanCellRenderer(renderer, icon); } - public static TableCellRenderer newBooleanTableCellRenderer(DefaultTableCellRenderer renderer) { + public static TableCellRenderer newBooleanTableCellRenderer( + DefaultTableCellRenderer renderer) { return new BooleanCellRenderer(renderer); } - public static EmptyNumberTableCellRenderer newEmptyNumberTableCellRenderer(TableCellRenderer renderer) { + public static EmptyNumberTableCellRenderer newEmptyNumberTableCellRenderer( + TableCellRenderer renderer) { return new EmptyNumberTableCellRenderer(renderer); } - public static <E extends Enum<E>> EnumTableCellRenderer<E> newEnumTableCellRenderer(TableCellRenderer renderer, Class<E> enumClass) { + public static <E extends Enum<E>> EnumTableCellRenderer<E> + newEnumTableCellRenderer(TableCellRenderer renderer, Class<E> enumClass) { return new EnumTableCellRenderer<E>(renderer, enumClass); } @@ -758,7 +851,9 @@ if (Desktop.isDesktopSupported()) { try { URL u = he.getURL(); - if (u.getProtocol().equalsIgnoreCase("mailto") || u.getProtocol().equalsIgnoreCase("http") || u.getProtocol().equalsIgnoreCase("ftp")) { + if (u.getProtocol().equalsIgnoreCase("mailto") || + u.getProtocol().equalsIgnoreCase("http") || + u.getProtocol().equalsIgnoreCase("ftp")) { Desktop.getDesktop().browse(u.toURI()); } } catch (IOException e) { @@ -820,34 +915,38 @@ */ public static void addExpandOnClickListener(final JTree tree) { - tree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() { + tree.getSelectionModel().addTreeSelectionListener( + new TreeSelectionListener() { - @Override - public void valueChanged(final TreeSelectionEvent e) { - TreeNode node = (TreeNode) e.getPath().getLastPathComponent(); - if (node != null && !node.isLeaf()) { + @Override + public void valueChanged(final TreeSelectionEvent e) { + TreeNode node = (TreeNode) + e.getPath().getLastPathComponent(); + if (node != null && !node.isLeaf()) { - SwingUtilities.invokeLater(new Runnable() { + SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - for (TreePath path : e.getPaths()) { - if (e.isAddedPath(path) && !tree.isExpanded(path)) { - log.info("expand node [" + path + "]"); - // will expand the node - tree.expandPath(path); + @Override + public void run() { + for (TreePath path : e.getPaths()) { + if (e.isAddedPath(path) && + !tree.isExpanded(path)) { + log.info("expand node [" + path + + "]"); + // will expand the node + tree.expandPath(path); + } + } } - } + }); } - }); - } - } + } }); } /** - * Add a listener of tree table selection model to expand a new selected node - * when it is selected. + * Add a listener of tree table selection model to expand a new selected + * node when it is selected. * * FIXME : Voir pour enlever le copier coller * @@ -867,7 +966,8 @@ @Override public void run() { for (TreePath path : e.getPaths()) { - if (e.isAddedPath(path) && !treeTable.isExpanded(path)) { + if (e.isAddedPath(path) && + !treeTable.isExpanded(path)) { log.info("expand node [" + path + "]"); // will expand the node treeTable.expandPath(path); @@ -890,8 +990,14 @@ component.setSize(width, component.getHeight()); if (component instanceof JComponent) { JComponent jcomponent = (JComponent) component; - jcomponent.setPreferredSize(new Dimension(width, jcomponent.getPreferredSize().height)); - jcomponent.setMinimumSize(new Dimension(width, jcomponent.getPreferredSize().height)); + jcomponent.setPreferredSize( + new Dimension(width, + jcomponent.getPreferredSize().height) + ); + jcomponent.setMinimumSize( + new Dimension(width, + jcomponent.getPreferredSize().height) + ); if (jcomponent.isDisplayable()) { jcomponent.revalidate(); } @@ -907,8 +1013,10 @@ component.setSize(component.getWidth(), height); if (component instanceof JComponent) { JComponent jcomponent = (JComponent) component; - jcomponent.setPreferredSize(new Dimension(jcomponent.getPreferredSize().width, height)); - jcomponent.setMinimumSize(new Dimension(jcomponent.getPreferredSize().width, height)); + jcomponent.setPreferredSize( + new Dimension(jcomponent.getPreferredSize().width, height)); + jcomponent.setMinimumSize( + new Dimension(jcomponent.getPreferredSize().width, height)); if (jcomponent.isDisplayable()) { jcomponent.revalidate(); } @@ -916,7 +1024,7 @@ } public static ImageIcon createIcon(String path) { - java.net.URL imgURL = JAXXUtil.class.getResource(path); + URL imgURL = JAXXUtil.class.getResource(path); if (imgURL != null) { return new ImageIcon(imgURL); } else { @@ -942,7 +1050,7 @@ } /** - * retreave for the {@link UIManager} the icon prefixed by <code>action.</code> + * retreave for the {@link UIManager} the icon prefixed by {@code action}. * * @param key the key of the action icon to retreave from {@link UIManager} * @return the icon, or <code>null if no icon found in {@link UIManager} Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/LocaleEditor.java =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/LocaleEditor.java 2010-03-10 22:28:59 UTC (rev 1767) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/LocaleEditor.java 2010-03-10 23:49:05 UTC (rev 1768) @@ -22,14 +22,16 @@ import javax.swing.JComboBox; import java.util.Locale; import org.nuiton.i18n.I18n; +import org.nuiton.i18n.I18nStore; /** * A {@link Locale} editor. * <p/> - * use the static method to have an instance of editor {@link #newEditor(java.util.Locale[])} + * use the static method to have an instance of editor + * {@link #newEditor(Locale...)} * <p/> * If no locale is given to this method, it will go and seek via - * {@link org.nuiton.i18n.I18nLoader#getLocales()} all loaded locales in i18n system + * {@link I18nStore#getLocales()} all loaded locales in i18n system * * @author chemit * @since 1.6.0 @@ -59,7 +61,7 @@ return type; } // get availables locales registred in I18n system - type = I18n.getLoader().getLocales(); + type = I18n.getStore().getLocales(); return type; } Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationMultiContentUI.java =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationMultiContentUI.java 2010-03-10 22:28:59 UTC (rev 1767) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationMultiContentUI.java 2010-03-10 23:49:05 UTC (rev 1768) @@ -21,6 +21,7 @@ package jaxx.runtime.swing.navigation; +import java.awt.Component; import java.util.List; /** @@ -33,8 +34,7 @@ /** * Init the ui just before been opened by the method - * {@link NavigationMultiTreeHandler#openUI(java.awt.Component, - * java.util.List<jaxx.runtime.swing.navigation.NavigationTreeNode>)}. + * {@link NavigationMultiTreeHandler#openUI(Component, List)}. * * @param nodes the selected node associated to the ui * @throws Exception if any pb while opening the content's ui @@ -43,11 +43,11 @@ /** * Clean the ui after been closed by the method - * {@link NavigationTreeHandler#closeUI(java.awt.Component)}. + * {@link NavigationTreeHandler#closeUI(Component)}. * * @param nodes the selected node associated to the ui * @throws Exception if any pb when closing the content'sui - * @see NavigationTreeHandler#closeUI(java.awt.Component) + * @see NavigationTreeHandler#closeUI(Component) */ void closeUI(List<NavigationTreeNode> nodes) throws Exception; }
participants (1)
-
tchemit@users.nuiton.org