[Spedit-commits] CVS: prototype/Sources/net/sourceforge/spedit/core Styleable.java,1.4,1.5 XMLDocume
Status: Planning
Brought to you by:
krunte
|
From: S?bastien P. <kaz...@us...> - 2001-11-28 13:14:40
|
Update of /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/core
In directory usw-pr-cvs1:/tmp/cvs-serv1688/net/sourceforge/spedit/core
Modified Files:
Styleable.java XMLDocument.java XMLViewFactory.java
Log Message:
New feature in XMLViewFactory is ancestor checking for XMLInformation.
Views have been slightly modified, mainly JavaDoc. Styleable is more robust
and provides support for the new view layout mechanism.
Index: Styleable.java
===================================================================
RCS file: /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/core/Styleable.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Styleable.java 2001/11/27 10:31:41 1.4
--- Styleable.java 2001/11/28 13:14:37 1.5
***************
*** 559,563 ****
//Font size
! int fontsize=12;
if (getStyle("font.size")!=null)
{ fontsize = ((Number)getStyle("font.size")).intValue(); }
--- 559,563 ----
//Font size
! int fontsize=14;
if (getStyle("font.size")!=null)
{ fontsize = ((Number)getStyle("font.size")).intValue(); }
***************
*** 578,582 ****
//Font name
! String fontname="Times";
if (getStyle("font.name")!=null)
{ fontname = (String)getStyle("font.name"); }
--- 578,582 ----
//Font name
! String fontname="TimesNewRoman";
if (getStyle("font.name")!=null)
{ fontname = (String)getStyle("font.name"); }
Index: XMLDocument.java
===================================================================
RCS file: /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/core/XMLDocument.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** XMLDocument.java 2001/11/21 11:02:04 1.4
--- XMLDocument.java 2001/11/28 13:14:37 1.5
***************
*** 16,20 ****
// History :
// 07-Nov-2001 Improved document filtering with
! // strippin.(sp)
// 25-Oct-2001 Added some javadoc.(sp)
// 17-Oct-2001 Event management revamp.(SP)
--- 16,20 ----
// History :
// 07-Nov-2001 Improved document filtering with
! // stripping.(sp)
// 25-Oct-2001 Added some javadoc.(sp)
// 17-Oct-2001 Event management revamp.(SP)
Index: XMLViewFactory.java
===================================================================
RCS file: /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/core/XMLViewFactory.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** XMLViewFactory.java 2001/11/27 10:31:41 1.5
--- XMLViewFactory.java 2001/11/28 13:14:37 1.6
***************
*** 1,5 ****
// Project : SPEdit-Prototypes
// ClassName : XMLViewFactory
! // Version : 0.81
// Type : Swing application component
//
--- 1,5 ----
// Project : SPEdit-Prototypes
// ClassName : XMLViewFactory
! // Version : 0.85
// Type : Swing application component
//
***************
*** 11,16 ****
// ----------------------------------------------------------------------------
// Creation date : 03-Sep-2001
! // Last mod. : 22-Nov-2001
// History :
// 22-Nov-2001 View can now be defined into Elements.(sp)
// 07-Nov-2001 Addes strip attribute support.(sp)
--- 11,18 ----
// ----------------------------------------------------------------------------
// Creation date : 03-Sep-2001
! // Last mod. : 27-Nov-2001
// History :
+ // 27-Nov-2001 Implemented ancestor checking for
+ // context-related view assignation.(sp)
// 22-Nov-2001 View can now be defined into Elements.(sp)
// 07-Nov-2001 Addes strip attribute support.(sp)
***************
*** 103,111 ****
//We get the information and associate it to the element
! XMLInformation info = (XMLInformation)configs.get(elt.getName());
! ((XMLNode)elt).setInformation(info);
//We instanciate the view
! if ( configs.get(elt.getName())!=null )
{ view = info.getNewDefaultView(elt); }
else if ( elt instanceof XMLTextWrapper )
--- 105,141 ----
//We get the information and associate it to the element
! XMLInformation info=null;
! Object ob = configs.get(elt.getName());
! //In case we have more than one element info we look for the
! //first that will match the ancestors of the current element
! if ( ob instanceof List )
! {
! ListIterator it = ((List)ob).listIterator();
! while (it.hasNext())
! {
! info = ((XMLInformation)it.next());
! if ( info!=null && hasAncestors((XMLElementWrapper)elt, info) )
! { break; }
! else
! { info=null; }
! }
! }
! //Otherwise there is only one info, and we still check that
! //the current element has the right ancestors.
! else
! {
! info = ((XMLInformation)ob);
! if ( info!=null && hasAncestors((XMLElementWrapper)elt, info) )
! {
! ((XMLNode)elt).setInformation(info);
! }
! else
! {
! info=null;
! }
! }
//We instanciate the view
! if ( info!=null )
{ view = info.getNewDefaultView(elt); }
else if ( elt instanceof XMLTextWrapper )
***************
*** 193,197 ****
public XMLInformation getElementInformation(javax.swing.text.Element e)
{
! return (XMLInformation)configs.get(e.getName());
}
--- 223,228 ----
public XMLInformation getElementInformation(javax.swing.text.Element e)
{
! //return (XMLInformation)configs.get(e.getName());
! return ((XMLNode)e).getInformation();
}
***************
*** 285,289 ****
Element gd_child = (Element)child.getChildren().get(j);
XMLInformation info = createXMLInformation(gd_child);
! configs.put(info.getName(), info);
}
}
--- 316,340 ----
Element gd_child = (Element)child.getChildren().get(j);
XMLInformation info = createXMLInformation(gd_child);
! List ancestors = getAncestors(info.getName());
! Object ob = configs.get(ancestors.get(ancestors.size()-1));
! if ( ob==null )
! {
! configs.put(ancestors.get(ancestors.size()-1), info);
! }
! else
! {
! if ( ob instanceof List )
! {
! ((List)ob).add(info);
! }
! else
! {
! LinkedList list = new LinkedList();
! list.add(ob);
! list.add(info);
! configs.put(ancestors.get(ancestors.size()-1), list);
! }
! }
!
}
}
***************
*** 469,472 ****
--- 520,557 ----
}
+ /**
+ * Splits the given ancestor hierarchy into a list.
+ * The given ancestor list is a list of element names separated
+ * by slashes. For example <code>Document/Section/Title</code>
+ * indicates that the Title element has a Section parent and
+ * a Document grand parent.
+ * @param ancestors is the string representing the parent
+ * hierarchy.
+ * @return the corresponding list of ancestors.
+ */
+ public List getAncestors(String ancestors)
+ {
+ List list = new LinkedList();
+ StringTokenizer tk = new StringTokenizer(ancestors,"/");
+
+ while( tk.hasMoreTokens() )
+ { list.add(tk.nextToken()); }
+
+ return list;
+ }
+
+ public boolean hasAncestors(XMLElementWrapper node, XMLInformation info)
+ {
+ List list = getAncestors(info.getName());
+ for ( int i=list.size()-1 ; i>=0 ; i-- )
+ {
+ String name = (String)list.get(i);
+ if ( node==null || !node.getName().equals(name) )
+ { return false; }
+ node = (XMLElementWrapper)node.getParentElement();
+ }
+ return true;
+ }
+
//------------------------------------------------------------------------
//
|