spedit-commits Mailing List for SPedit - Swiss-Prot curation environment
Status: Planning
Brought to you by:
krunte
You can subscribe to this list here.
| 2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(15) |
Dec
(11) |
|---|
|
From: S?bastien P. <kaz...@us...> - 2001-12-06 10:11:46
|
Update of /cvsroot/spedit/prototype/Support
In directory usw-pr-cvs1:/tmp/cvs-serv12456
Modified Files:
Application.py SP-Configuration.xml
Log Message:
Small improvement in configuration.
Index: Application.py
===================================================================
RCS file: /cvsroot/spedit/prototype/Support/Application.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Application.py 2001/11/28 13:12:58 1.4
--- Application.py 2001/12/06 10:11:43 1.5
***************
*** 12,15 ****
--- 12,17 ----
# Last mod. : 27-Nov-2001
# History :
+ # 29-Nov-2001 Added documentation, improved presentation
+ # and added the EventPanel class for the JDocumentFrame
# 27-Nov-2001 Added the getInstance and the checkAncestors
# methods.(sp)
***************
*** 29,32 ****
--- 31,74 ----
from javax.swing import *
+
+ #------------------------------------------------------------------------------
+ #
+ # Generic application utilities
+ #
+ #------------------------------------------------------------------------------
+
+ def getInstance( name, parameters ):
+ """Generates a new instance of the fully qualified Python class
+ given by the 'name' paremeter. The 'parameters' is the tuple that
+ will be given to the constructor.
+
+ In case the constructor fails or that the class has not been found
+ None is returned, otherwise the new instance is returned."""
+
+ module = None
+ for i in range(0,len(name)):
+ if name[i]=='.':
+ module = name[:i]
+ break
+
+ if module!=None:
+ constructor = None
+ try:
+ constructor = eval(name)
+ except:
+ exec "import %s" % (module)
+ constructor = eval(name)
+ instance = apply(eval(name), parameters)
+ return instance
+ else:
+ return None
+
+
+ #------------------------------------------------------------------------------
+ #
+ # Menus management functions
+ #
+ #------------------------------------------------------------------------------
+
menus = [
['File',
***************
*** 80,126 ****
return menubar
- def getInstance( name, parameters ):
- """Generates a new instance of the fully qualified Python class
- given by the 'name' paremeter. The 'parameters' is the tuple that
- will be given to the constructor.
-
- In case the constructor fails or that the class has not been found
- None is returned, otherwise the new instance is returned."""
-
- module = None
- for i in range(0,len(name)):
- if name[i]=='.':
- module = name[:i]
- break
-
- if module!=None:
- constructor = None
- try:
- constructor = eval(name)
- except:
- exec "import %s" % (module)
- constructor = eval(name)
- instance = apply(eval(name), parameters)
- return instance
- else:
- return None
-
- def checkAncestors( ancestors, element ):
- """Checks if the given element has the ancestor list given by the
- expression. The expression is a descendant list like 'document/section/title',
- which means that the current element must be a title, that its parent must be a section
- and its grandparent a document."""
- if type(ancestors)==type(""):
- ancestors = string.split(ancestors,"/")
- if element==None: return 0
- if len(ancestors)==1:
- if element.getName()==ancestors[0]: return 1
- else: return 0
- else:
- if checkAncestors(ancestors[:-1], element.getParent()) and\
- element.getName()==ancestors[-1]: return 1
- else: return 0
-
class MenuListener( java.awt.event.ActionListener ):
def __init__( self, documentWindow ):
--- 122,127 ----
return menubar
class MenuListener( java.awt.event.ActionListener ):
+ """This class sets up the listener that react to menus action events."""
def __init__( self, documentWindow ):
***************
*** 183,247 ****
f.getContentPane().add(JScrollPane(tree))
f.setVisible(1)
!
! class ElementItem ( JButton, java.awt.event.MouseListener):
! """The ElementItem represents an element in the hierarchy of elements
! displayed in the status bar. It allows selection of elements that are not
! selectable otherwise, as addition of new elements."""
! def __init__( self, element, viewFactory, docframe):
! JButton.__init__(self, element.getName())
! self.viewFactory = viewFactory
! self.element = element
! self.docframe = docframe
! self.plain = java.awt.Font("Helvetica",java.awt.Font.PLAIN,9)
! self.bold = java.awt.Font("Helvetica",java.awt.Font.BOLD,9)
! self.setFont(self.plain)
! self.setHorizontalAlignment(SwingConstants.LEFT)
! self.setMargin(java.awt.Insets(0,0,0,0))
! self.setBorderPainted(0)
self.addMouseListener(self)
!
def mouseClicked(self, e):
! if SwingUtilities.isRightMouseButton(e) or e.isControlDown():
! self.popUpMenu(e)
! else:
! view = self.viewFactory.getElementView(self.element)
! try:
! #view.setSelected(not view.isSelected())
! if view.isCollapsed():
! view.expand()
! else:
! view.collapse()
! except:
! pass
def mouseEntered(self, e):
! view = self.viewFactory.getElementView(self.element)
! try:
! self.setFont(self.bold)
! view.setFocused(1)
! except:
! pass
def mouseExited(self, e):
! view = self.viewFactory.getElementView(self.element)
! try:
! self.setFont(self.plain)
! view.setFocused(0)
! except:
! pass
!
! def mousesPressed(self, e):
pass
! def mouseReleased(self, e):
pass
! def popUpMenu(self, e):
! menu = self.docframe.getElementMenu(self.element, self.element.getEndOffset()-1)
! menu.show(self, e.getX(), e.getY())
class StatusBar ( JPanel, javax.swing.event.CaretListener,\
javax.swing.event.ChangeListener ):
def __init__(self, parent):
--- 184,236 ----
f.getContentPane().add(JScrollPane(tree))
f.setVisible(1)
! #------------------------------------------------------------------------------
! #
! # EventPane
! #
! #------------------------------------------------------------------------------
! class EventPane ( JPanel, java.awt.event.MouseListener,\
! java.awt.event.MouseMotionListener ):
! """The EventPane is used to intercept events from the DocumentFrame
! and dispatch them to the views that will then delegate them to the
! registered AttributesDisplay."""
!
! def __init__ ( self ):
! JPanel.__init__(self)
self.addMouseListener(self)
! self.add(JButton("qajdhak"))
! self.setVisible(1)
! self.setOpaque(1)
! print "Created EventPane"
!
def mouseClicked(self, e):
! print "askdasjld"
! pass
def mouseEntered(self, e):
! print "askdasjld"
! pass
def mouseExited(self, e):
! print "askdasjld"
pass
! def mousePressed(self, e):
! print "askdasjld"
pass
! def mouseReleased(self, e):
! print "askdasjld"
! pass
! #------------------------------------------------------------------------------
! #
! # StatusBar
! #
! #------------------------------------------------------------------------------
class StatusBar ( JPanel, javax.swing.event.CaretListener,\
javax.swing.event.ChangeListener ):
+ """This class defines the behaviour and appearance of the status bar at
+ the bottom of the document frame"""
def __init__(self, parent):
***************
*** 269,272 ****
--- 258,263 ----
else:
self.caret = "[ %s-%s ]" % ( mark, dot)
+ #FIXME: The return is for DEBUG
+ return
element = self._parent.getDocument().getElementAt(dot)
self.caret += " <%s,%s>" % (element.getStartOffset(), element.getEndOffset())
***************
*** 295,298 ****
--- 286,348 ----
self.doLayout()
self.repaint()
+
+
+ class ElementItem ( JButton, java.awt.event.MouseListener):
+ """The ElementItem represents an element in the hierarchy of elements
+ displayed in the status bar. It allows selection of elements that are not
+ selectable otherwise, as addition of new elements."""
+
+ def __init__( self, element, viewFactory, docframe):
+ JButton.__init__(self, element.getName())
+ self.viewFactory = viewFactory
+ self.element = element
+ self.docframe = docframe
+ self.plain = java.awt.Font("Helvetica",java.awt.Font.PLAIN,9)
+ self.bold = java.awt.Font("Helvetica",java.awt.Font.BOLD,9)
+ self.setFont(self.plain)
+ self.setHorizontalAlignment(SwingConstants.LEFT)
+ self.setMargin(java.awt.Insets(0,0,0,0))
+ self.setBorderPainted(0)
+ self.addMouseListener(self)
+
+ def mouseClicked(self, e):
+ if SwingUtilities.isRightMouseButton(e) or e.isControlDown():
+ self.popUpMenu(e)
+ else:
+ view = self.viewFactory.getElementView(self.element)
+ try:
+ #view.setSelected(not view.isSelected())
+ if view.isCollapsed():
+ view.expand()
+ else:
+ view.collapse()
+ except:
+ pass
+
+ def mouseEntered(self, e):
+ view = self.viewFactory.getElementView(self.element)
+ try:
+ self.setFont(self.bold)
+ view.setFocused(1)
+ except:
+ pass
+
+ def mouseExited(self, e):
+ view = self.viewFactory.getElementView(self.element)
+ try:
+ self.setFont(self.plain)
+ view.setFocused(0)
+ except:
+ pass
+
+ def mousePressed(self, e):
+ pass
+
+ def mouseReleased(self, e):
+ pass
+
+ def popUpMenu(self, e):
+ menu = self.docframe.getElementMenu(self.element, self.element.getEndOffset()-1)
+ menu.show(self, e.getX(), e.getY())
# EOF-Unix/ASCII------------------------------------@RisingSun//Jython//1.0//EN
Index: SP-Configuration.xml
===================================================================
RCS file: /cvsroot/spedit/prototype/Support/SP-Configuration.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** SP-Configuration.xml 2001/11/28 13:12:58 1.2
--- SP-Configuration.xml 2001/12/06 10:11:43 1.3
***************
*** 157,162 ****
--- 157,187 ----
<use name="block"/>
</Views>
+ <Children>
+ <element name='secondaryEntryNames'/>
+ <element name='secondaryAccNos'/>
+ <element name='proteinName'/>
+ <element name='genes'/>
+ <element name='organisms'/>
+ <element name='organelle'/>
+ <element name='plasmids'/>
+ <element name='references'/>
+ <element name='comments'/>
+ <element name='dbreferences'/>
+ <element name='keywords'/>
+ <element name='features'/>
+ <element name='sequence'/>
+ <element name='evidences'/>
+ <element name='internal'/>
+ <element name='source'/>
+ </Children>
+
</element>
+ <element name='secondaryEntryNames'>
+ <Children>
+ <element name='name'/>
+ </Children>
+ </element>
+
<element name='secondaryAccNos'>
<Style>
***************
*** 165,168 ****
--- 190,196 ----
</Style>
<Views><use name="xblock"/></Views>
+ <Children>
+ <element name='ac'/>
+ </Children>
</element>
***************
*** 221,224 ****
--- 249,257 ----
</Style>
<Views><use name="block"/></Views>
+ <Children>
+ <element name='name'/>
+ <element name='taxId'/>
+ <element name='classification'/>
+ </Children>
</element>
***************
*** 260,263 ****
--- 293,301 ----
</Style>
<Views><use name="block"/></Views>
+ <Children>
+ <element name='name'/>
+ <element name='taxId'/>
+ <element name='classification'/>
+ </Children>
</element>
***************
*** 308,311 ****
--- 346,354 ----
</Style>
<Views><use name="paragraph"/></Views>
+ <Children>
+ <element name='name'/>
+ <element name='taxId'/>
+ <element name='classification'/>
+ </Children>
</element>
***************
*** 321,325 ****
<Style>
<inherit from="listItem"/>
- <Attributes><display string="net.sourceforge.spedit.spml.DataBaseDisplay"/></Attributes>
</Style>
<Views><use name="label"/></Views>
--- 364,367 ----
|
|
From: S?bastien P. <kaz...@us...> - 2001-12-06 10:11:20
|
Update of /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/app
In directory usw-pr-cvs1:/tmp/cvs-serv12239/net/sourceforge/spedit/app
Modified Files:
Application.java
Log Message:
Partly fixed remove bug. Functional thought.
Index: Application.java
===================================================================
RCS file: /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/app/Application.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** Application.java 2001/12/04 16:37:29 1.7
--- Application.java 2001/12/06 10:11:17 1.8
***************
*** 147,152 ****
editorPane = new JEditorPane();
navigator = new NavigationTree(this);
! //editorKit = new XMLEditorKit("../Support/SP-Configuration.xml");
! editorKit = new XMLEditorKit("../Support/ON-Configuration.xml");
editorPane.setEditorKit(editorKit);
factory = (XMLViewFactory)editorKit.getViewFactory();
--- 147,152 ----
editorPane = new JEditorPane();
navigator = new NavigationTree(this);
! editorKit = new XMLEditorKit("../Support/SP-Configuration.xml");
! //editorKit = new XMLEditorKit("../Support/ON-Configuration.xml");
editorPane.setEditorKit(editorKit);
factory = (XMLViewFactory)editorKit.getViewFactory();
***************
*** 178,183 ****
//We load the custom file
! //File ff = new File("../Support/SP-P11388.xml");
! File ff = new File("../Support/ON-Document.xml");
document = XMLDocument.loadFromFile(ff, factory);
document.filter(factory);
--- 178,183 ----
//We load the custom file
! File ff = new File("../Support/SP-P11388.xml");
! //File ff = new File("../Support/ON-Document.xml");
document = XMLDocument.loadFromFile(ff, factory);
document.filter(factory);
***************
*** 374,381 ****
CompositeView view =
(CompositeView)((WrapperView)factory.getElementView(wrp)).getNestedView();
- //wrp.getXMLElement().removeContent(wrapper.getXMLElement());
- wrapper.remove(wrapper.getStartOffset(), wrapper.getEndOffset());
- //We do this to force a loadChildren() method call in the CompositeView.
view.replace(0,view.getViewCount(),new View[0]);
view.setParent(view.getParent());
//view.getContainer().repaint();
--- 374,381 ----
CompositeView view =
(CompositeView)((WrapperView)factory.getElementView(wrp)).getNestedView();
view.replace(0,view.getViewCount(),new View[0]);
+ wrp.getXMLElement().removeContent(wrapper.getXMLElement());
+ //wrapper.remove(wrapper.getStartOffset(), wrapper.getEndOffset());
+ //We do this to force a loadChildren() method call in the CompositeView.
view.setParent(view.getParent());
//view.getContainer().repaint();
|
|
From: S?bastien P. <kaz...@us...> - 2001-12-06 10:11:20
|
Update of /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/ui In directory usw-pr-cvs1:/tmp/cvs-serv12239/net/sourceforge/spedit/ui Modified Files: BlockView.java Log Message: Partly fixed remove bug. Functional thought. Index: BlockView.java =================================================================== RCS file: /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/ui/BlockView.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** BlockView.java 2001/11/28 13:14:37 1.3 --- BlockView.java 2001/12/06 10:11:17 1.4 *************** *** 37,40 **** --- 37,41 ---- import javax.swing.event.*; import net.sourceforge.spedit.core.*; + import net.sourceforge.spedit.core.Styleable; //----------------------------------------------------------------------------- |
|
From: S?bastien P. <kaz...@us...> - 2001-12-06 10:11:20
|
Update of /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/core
In directory usw-pr-cvs1:/tmp/cvs-serv12239/net/sourceforge/spedit/core
Modified Files:
XMLDocument.java XMLElementWrapper.java
Log Message:
Partly fixed remove bug. Functional thought.
Index: XMLDocument.java
===================================================================
RCS file: /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/core/XMLDocument.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** XMLDocument.java 2001/12/05 16:28:44 1.7
--- XMLDocument.java 2001/12/06 10:11:17 1.8
***************
*** 13,18 ****
// ----------------------------------------------------------------------------
// Creation date : 03-Sep-2001
! // Last mod. : 07-Nov-2001
// History :
// 07-Nov-2001 Improved document filtering with
// stripping.(sp)
--- 13,19 ----
// ----------------------------------------------------------------------------
// Creation date : 03-Sep-2001
! // Last mod. : 05-Dec-2001
// History :
+ // 05-Dec-2001 GetText exception dump(sp)
// 07-Nov-2001 Improved document filtering with
// stripping.(sp)
***************
*** 553,557 ****
--- 554,566 ----
throws BadLocationException
{
+ try{
return content.getString(offset, length);
+ }
+ catch (BadLocationException e)
+ {
+ System.err.println("Bad location exception has occured in XMLDocument.getText.\n"+
+ "> Given offset is "+offset+" and given length is "+length+", while text length is "+content.length());
+ throw e;
+ }
}
***************
*** 569,573 ****
throws BadLocationException
{
! content.getChars(offset, length, s);
}
--- 578,591 ----
throws BadLocationException
{
! try
! {
! content.getChars(offset, length, s);
! }
! catch (BadLocationException e)
! {
! System.err.println("Bad location exception has occured in XMLDocument.getText.\n"+
! "> Given offset is "+offset+" and given length is "+length+", while text length is "+content.length());
! throw e;
! }
}
***************
*** 1128,1132 ****
if ( doc!=null )
{
! doc.fireDocumentEvent(this);
if ( doc !=null && type==DocumentEvent.EventType.INSERT )
{
--- 1146,1150 ----
if ( doc!=null )
{
!
if ( doc !=null && type==DocumentEvent.EventType.INSERT )
{
***************
*** 1164,1167 ****
--- 1182,1187 ----
System.out.println("Element CHANGE not supported yet.");
}
+
+ doc.fireDocumentEvent(this);
}
}
Index: XMLElementWrapper.java
===================================================================
RCS file: /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/core/XMLElementWrapper.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** XMLElementWrapper.java 2001/12/05 16:28:44 1.4
--- XMLElementWrapper.java 2001/12/06 10:11:17 1.5
***************
*** 547,601 ****
return element.startOffset;
}
-
- /*
- if ( element.getParent()==null )
- {
- return 0;
- }
- else if ( getDocument()==null )
- {
- return 0;
- }
- else if ( startPosition!=null )
- {
- return startPosition.getOffset();
- }
- else
- {
- XMLDocument doc = (XMLDocument)getDocument();
- XMLElement parent = (XMLElement)element.getParent();
- int startOffset = parent.getWrapper().getStartOffset();
-
- //We iterate through the parent children
- for ( int i=0 ; i<parent.getContent().size() ; i++ )
- {
- Object o = parent.getContent().get(i);
- //If child is an XMLElement
- if ( o instanceof XMLElement )
- {
- XMLElement elt = (XMLElement)o;
- if ( elt==element )
- { break; }
- else
- { startOffset+=elt.getWrapper().getLength(); }
- }
- //If child is an XMLElement
- else if ( o instanceof XMLText )
- {
- startOffset+=((XMLText)o).getValue().length();
- }
- //Otherwise there is an unsupported child type, so we warn the
- //user.
- else
- {
- System.err.println("Warning: XMLElementWrapper.getStartOffset");
- System.err.println(" Element child not supported:"+
- o.toString());
- }
- }
- startPosition = doc.createBackwardPosition(startOffset);
- return startOffset;
- }
- */
}
--- 547,550 ----
***************
*** 609,664 ****
{
return getStartOffset()+getLength();
- /*
- //If the end position has already been created, we use it
- if ( endPosition!=null )
- {
- return endPosition.getOffset();
- }
- else if ( getDocument()==null )
- {
- return 0;
- }
- //Otherwise we create it
- else
- {
- XMLDocument doc = (XMLDocument)getDocument();
- int contentLength=0;
-
- //We iterate through the element children to calculate the total
- //length of the children.
- for ( int i=0 ; i<element.getContent().size() ; i++ )
- {
- Object elt = element.getContent().get(i);
- System.out.println("Content element : "+elt);
- //The child is an XMLElement
- if ( elt instanceof XMLElement )
- {
- System.out.println(" Found child : "+elt);
- int old = contentLength;
- contentLength+=((XMLElement)elt).getWrapper().getLength();
- old = contentLength-old;
- System.out.println(" of length : "+old);
- }
- //The child is an XMLText
- else if ( elt instanceof XMLText)
- {
- System.out.println(" Found text : "+elt);
- int old = contentLength;
- contentLength+=((XMLText)elt).getValue().length();
- old = contentLength-old;
- System.out.println(" of length : "+old);
- }
- //The child is of an unknown type.
- else
- {
- System.err.println("Warning: XMLElementWrapper.getEndOffset");
- System.err.println(" Element child not supported:"+
- elt.toString());
- }
- }
- endPosition = doc.createForwardPosition(getStartOffset());
- return endPosition.getOffset();
- }
- */
}
--- 558,561 ----
***************
*** 670,699 ****
public int getLength()
{
! //We check if the cached attributes values are
! //still valid
! //if ( element.getDocument()==null || ((XMLDocument)element.getDocument()).timeStamp>element.timeStamp )
{
! element.contentLength=0;
! ListIterator iterator = element.getContent().listIterator();
! while( iterator.hasNext() )
{
! Object elt = iterator.next();
! if ( elt instanceof XMLElement )
! {
! element.contentLength+=((XMLElement)elt).getWrapper().getLength();
! }
! else if ( elt instanceof XMLText)
! {
! element.contentLength+=((XMLText)elt).getValue().length();
! }
! else
! {
! System.err.println("Unknown content: "+elt);
! }
}
}
return element.contentLength;
-
- //return getEndOffset()-getStartOffset();
}
--- 567,590 ----
public int getLength()
{
!
! element.contentLength=0;
! ListIterator iterator = element.getContent().listIterator();
! while( iterator.hasNext() )
{
! Object elt = iterator.next();
! if ( elt instanceof XMLElement )
{
! element.contentLength+=((XMLElement)elt).getWrapper().getLength();
}
+ else if ( elt instanceof XMLText)
+ {
+ element.contentLength+=((XMLText)elt).getValue().length();
+ }
+ else
+ {
+ System.err.println("Unknown content: "+elt);
+ }
}
return element.contentLength;
}
***************
*** 728,764 ****
startOffset+=increment;
}
return -1;
-
- /*
- int startOffset = getStartOffset();
- List content = ((XMLElement)element).getContent();
-
- //We iterate through the children
- for (int i=0 ; i<content.size() ; i++ )
- {
- int increment=0;
- Object o=content.get(i);
-
- //Here we test recognized elements, but we do not warn of
- //unrecognized ones, because they should already be signaled by
- //start and end offset accesses.
- if ( o instanceof XMLElement )
- {
- XMLElement elt = (XMLElement)o;
- increment =elt.getWrapper().getLength();
- }
- else if ( o instanceof XMLText )
- { increment=((XMLText)o).getValue().length(); }
-
- //Here we break if we have found the element
- if ( object.equals(o) )
- { return startOffset; }
- //Otherwise we increment thes start offset
- else
- { startOffset+=increment; }
- }
- //If nothing was found we return -1
- return -1;
- */
}
--- 619,624 ----
startOffset+=increment;
}
+ System.err.println("GETTING START OFFSET OF "+object.toString()+" which is -1");
return -1;
}
***************
*** 1124,1129 ****
//We fire the event
if ( fireEvent ) { event.fire(); }
!
return result;
--- 984,990 ----
//We fire the event
+ System.out.println("Event firing "+getName());
if ( fireEvent ) { event.fire(); }
! System.out.println("Removal end "+getName());
return result;
|
|
From: S?bastien P. <kaz...@us...> - 2001-12-05 16:28:47
|
Update of /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/ui
In directory usw-pr-cvs1:/tmp/cvs-serv13979/net/sourceforge/spedit/ui
Modified Files:
AttributesDisplay.java ParagraphView.java WrapperView.java
Log Message:
Fixed a bug in the removal, but there are still some others. The
current implementation seems to be weak and crashes sometimes. Event
firing has been improved in XMLElementWrapper, in order for the events
to be fired only after the element has gained a stable state, ie. that
the actual modifications have been taken into effect.
Index: AttributesDisplay.java
===================================================================
RCS file: /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/ui/AttributesDisplay.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** AttributesDisplay.java 2001/12/04 16:37:29 1.6
--- AttributesDisplay.java 2001/12/05 16:28:44 1.7
***************
*** 76,82 ****
this.view = view;
this.element = element;
- //This seems strange but this actually fetches the DocumentFrame ;)
- // JEditorPane->JViewPort->JScrollPane->JSplitBar->JPanel->JLayeredPane->JRootPane->DocumentFrame
- //addMouseListener((MouseListener)view.getContainer().getParent().getParent().getParent().getParent().getParent().getParent().getParent());
setFont(view.getStyleSheet().font);
}
--- 76,79 ----
***************
*** 128,132 ****
else
{
! return element.getXMLElement().getAttributes().size();;
}
--- 125,129 ----
else
{
! return element.getXMLElement().getAttributes().size();
}
Index: ParagraphView.java
===================================================================
RCS file: /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/ui/ParagraphView.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** ParagraphView.java 2001/11/28 13:14:37 1.4
--- ParagraphView.java 2001/12/05 16:28:44 1.5
***************
*** 73,81 ****
--- 73,92 ----
public void paint(Graphics g, Shape bounds)
{
+ //System.out.println(">>Painting paragraph name:"+getElement().getName()+" from offset"+
+ //getStartOffset()+" to "+getEndOffset());
int off = getStartOffset();
+ try
+ {
Shape shape = getParent().getChildAllocation(getViewIndex(off,
Position.Bias.Forward),bounds);
super.paint(g,bounds);
+ }
+ catch (Exception e)
+ {
+ System.out.println(">>Painting paragraph name:"+getElement().getName()+" from offset"+
+ getStartOffset()+" to "+getEndOffset());
+ System.out.println(" element has parent : "+getElement().getParentElement());
+ }
}
Index: WrapperView.java
===================================================================
RCS file: /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/ui/WrapperView.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** WrapperView.java 2001/12/04 16:37:30 1.6
--- WrapperView.java 2001/12/05 16:28:44 1.7
***************
*** 518,521 ****
--- 518,522 ----
public int viewToModel(float x, float y, Shape a, Position.Bias[] biasReturn)
{
+ System.out.println("Element :"+getElement().getName()+" start:"+getStartOffset()+" end:"+getEndOffset());
return nested.viewToModel(x-getLeftInset(styleSheet),
y-getTopInset(styleSheet),a,biasReturn);
***************
*** 955,958 ****
--- 956,965 ----
{ return nested.getElement().getName(); }
+ protected void updateLayout(DocumentEvent.ElementChange ec, DocumentEvent e, Shape a)
+ {
+ refreshBounds=true;
+ super.updateLayout(ec, e, a);
+ }
+
//-------------------------------------------------------------------------
//
|
|
From: S?bastien P. <kaz...@us...> - 2001-12-05 16:28:47
|
Update of /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/core
In directory usw-pr-cvs1:/tmp/cvs-serv13979/net/sourceforge/spedit/core
Modified Files:
XMLDocument.java XMLElementWrapper.java
Log Message:
Fixed a bug in the removal, but there are still some others. The
current implementation seems to be weak and crashes sometimes. Event
firing has been improved in XMLElementWrapper, in order for the events
to be fired only after the element has gained a stable state, ie. that
the actual modifications have been taken into effect.
Index: XMLDocument.java
===================================================================
RCS file: /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/core/XMLDocument.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** XMLDocument.java 2001/12/04 16:37:29 1.6
--- XMLDocument.java 2001/12/05 16:28:44 1.7
***************
*** 1149,1156 ****
{
System.out.println("Removal from:"+offset+" to:"+(offset+length));
- try
- { except(); }
- catch (Exception e)
- { e.printStackTrace(); }
doc.updatePositions(offset, -length);
--- 1149,1152 ----
***************
*** 1170,1177 ****
}
}
-
- public void except() throws Exception
- { throw new Exception(); }
}
//------------------------------------------------------------------------
//
--- 1166,1171 ----
}
}
}
+
//------------------------------------------------------------------------
//
Index: XMLElementWrapper.java
===================================================================
RCS file: /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/core/XMLElementWrapper.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** XMLElementWrapper.java 2001/12/04 16:37:29 1.3
--- XMLElementWrapper.java 2001/12/05 16:28:44 1.4
***************
*** 337,340 ****
--- 337,342 ----
* is out of the XMLElement bounds.
*/
+ public void except() throws Exception
+ { throw new Exception("wqe"); }
public Element getElementAt(int offset)
{
***************
*** 343,346 ****
--- 345,349 ----
System.err.println("XMLElementWrapper: Offset out of bounds "
+offset+" for element "+this);
+ try { except(); } catch (Exception e) { e.printStackTrace(); }
return null;
}
***************
*** 802,806 ****
//Variables
int cur_offset=getStartOffset();
! XMLDocument.DocumentEvent event;
XMLDocument doc = (XMLDocument)element.getDocument();
ArrayList new_content = new ArrayList(element.getContent().size()-1);
--- 805,809 ----
//Variables
int cur_offset=getStartOffset();
! XMLDocument.DocumentEvent event=null;
XMLDocument doc = (XMLDocument)element.getDocument();
ArrayList new_content = new ArrayList(element.getContent().size()-1);
***************
*** 839,843 ****
event = new XMLDocument.DocumentEvent(doc, offset, s);
event.addEdit(new XMLDocument.ElementEdit(((XMLText)obj).getWrapper()));
- event.fire();
}
//We add the content anyway
--- 842,845 ----
***************
*** 858,862 ****
edit.addAddedElement(new_text.getWrapper());
event.addEdit(edit);
- event.fire();
}
--- 860,863 ----
***************
*** 867,870 ****
--- 868,874 ----
//We set the new content
element.setNewContent(new_content);
+
+ //We fire the event
+ if ( event!=null ) { event.fire(); }
}
***************
*** 885,889 ****
XMLDocument.ElementEdit edit;
! XMLDocument.DocumentEvent event;
int cur_offset = getStartOffset();
XMLDocument doc = (XMLDocument)element.getDocument();
--- 889,893 ----
XMLDocument.ElementEdit edit;
! XMLDocument.DocumentEvent event=null;
int cur_offset = getStartOffset();
XMLDocument doc = (XMLDocument)element.getDocument();
***************
*** 935,939 ****
edit.addAddedElement(new_text.getWrapper());
event.addEdit(edit);
- event.fire();
}
//Or do we append it?
--- 939,942 ----
***************
*** 961,966 ****
edit.addAddedElement(elt.getWrapper());
event.addEdit(edit);
- event.fire();
- event = null;
}
}
--- 964,967 ----
***************
*** 979,983 ****
edit.addAddedElement(elt.getWrapper());
event.addEdit(edit);
- event.fire();
}
--- 980,983 ----
***************
*** 988,991 ****
--- 988,994 ----
//We set the new content
element.setNewContent(new_content);
+
+ //We fire the event
+ if ( event!=null ) { event.fire(); }
}
***************
*** 1113,1118 ****
}
! //We fire the event
! if ( fireEvent ) { event.fire(); }
System.out.println("Removal in "+getName());
//Now we detach the nodes
--- 1116,1120 ----
}
!
System.out.println("Removal in "+getName());
//Now we detach the nodes
***************
*** 1120,1123 ****
--- 1122,1129 ----
{ ((XMLElement)e.nextElement()).detach(); }
element.setNewContent(new_content);
+
+ //We fire the event
+ if ( fireEvent ) { event.fire(); }
+
return result;
|
|
From: S?bastien P. <kaz...@us...> - 2001-12-04 16:37:32
|
Update of /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/ui
In directory usw-pr-cvs1:/tmp/cvs-serv21181/net/sourceforge/spedit/ui
Modified Files:
AttributesDisplay.java WrapperView.java
Log Message:
New element menu, add element bug fix.
Index: AttributesDisplay.java
===================================================================
RCS file: /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/ui/AttributesDisplay.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** AttributesDisplay.java 2001/11/28 14:52:50 1.5
--- AttributesDisplay.java 2001/12/04 16:37:29 1.6
***************
*** 34,37 ****
--- 34,38 ----
import java.awt.*;
+ import java.awt.event.*;
import java.awt.geom.*;
import javax.swing.*;
***************
*** 75,78 ****
--- 76,82 ----
this.view = view;
this.element = element;
+ //This seems strange but this actually fetches the DocumentFrame ;)
+ // JEditorPane->JViewPort->JScrollPane->JSplitBar->JPanel->JLayeredPane->JRootPane->DocumentFrame
+ //addMouseListener((MouseListener)view.getContainer().getParent().getParent().getParent().getParent().getParent().getParent().getParent());
setFont(view.getStyleSheet().font);
}
***************
*** 124,128 ****
else
{
! return element.getXMLElement().getAttributes().size();
}
--- 128,132 ----
else
{
! return element.getXMLElement().getAttributes().size();;
}
Index: WrapperView.java
===================================================================
RCS file: /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/ui/WrapperView.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** WrapperView.java 2001/11/27 10:31:41 1.5
--- WrapperView.java 2001/12/04 16:37:30 1.6
***************
*** 93,99 ****
protected Rectangle2D viewBounds=null;
protected boolean refreshBounds=true;
! private final Image icn_exp = new ImageIcon("../Support/icon-expanded.gif").getImage();
! private final Image icn_clp = new ImageIcon("../Support/icon-collapsed.gif").getImage();
//-------------------------------------------------------------------------
--- 93,101 ----
protected Rectangle2D viewBounds=null;
protected boolean refreshBounds=true;
+ protected boolean blinkState=true;
! protected final Image icn_exp = new ImageIcon("../Support/icon-expanded.gif").getImage();
! protected final Image icn_clp = new ImageIcon("../Support/icon-collapsed.gif").getImage();
!
//-------------------------------------------------------------------------
***************
*** 159,163 ****
*/
! public void paint(Graphics g, Shape s)
{
Graphics2D gg=(Graphics2D)g;
--- 161,165 ----
*/
! public synchronized void paint(Graphics g, Shape s)
{
Graphics2D gg=(Graphics2D)g;
***************
*** 186,196 ****
gg.draw(r);
}
-
- //We paint a specific color if the element has been newly created
- if (((XMLNode)element).hasInformation() && ((XMLNode)element).getInformation().isNewlyCreated() )
- {
- g.setColor(new Color(240,200,150));
- gg.fill(r);
- }
//We draw the border
--- 188,191 ----
***************
*** 204,207 ****
--- 199,208 ----
}
+ if ( element instanceof XMLElementWrapper && ((XMLElementWrapper)element).isNewlyCreated )
+ {
+ g.setColor(new Color(199,250,199));
+ gg.fill(r);
+ }
+
//If the view is collapsed
if ( isCollapsed() )
***************
*** 627,631 ****
public void setSize(float width, float height)
! { nested.setSize(width,height); }
//-------------------------------------------------------------------------
--- 628,634 ----
public void setSize(float width, float height)
! {
! nested.setSize(width,height);
! }
//-------------------------------------------------------------------------
|
|
From: S?bastien P. <kaz...@us...> - 2001-12-04 16:37:32
|
Update of /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/core
In directory usw-pr-cvs1:/tmp/cvs-serv21181/net/sourceforge/spedit/core
Modified Files:
XMLDocument.java XMLElement.java XMLElementWrapper.java
XMLInformation.java XMLViewFactory.java
Log Message:
New element menu, add element bug fix.
Index: XMLDocument.java
===================================================================
RCS file: /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/core/XMLDocument.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** XMLDocument.java 2001/11/28 13:14:37 1.5
--- XMLDocument.java 2001/12/04 16:37:29 1.6
***************
*** 349,353 ****
if ( factory!=null )
{
! info = factory.getElementInformation(((XMLElement)element).getWrapper());
}
--- 349,355 ----
if ( factory!=null )
{
! //info = factory.getElementInformation(((XMLElement)element).getWrapper());
! info = ((XMLElement)element).getWrapper().getInformation();
! //info.setNewlyCreated(false);
}
***************
*** 467,473 ****
Element e = root.getWrapper().getElementAt(offset);
if ( e.isLeaf() )
! return e.getParentElement();
else
! return e;
}
--- 469,475 ----
Element e = root.getWrapper().getElementAt(offset);
if ( e.isLeaf() )
! { return e.getParentElement(); }
else
! { return e; }
}
***************
*** 911,914 ****
--- 913,919 ----
else if ( pos.offset>offset-length )
{ pos.offset += length; }
+ /*else
+ {System.out.println("Oh my god!!:pos.offset="+pos.offset+
+ " offset:"+offset+" -length:"+(-length));}*/
}
}
***************
*** 1021,1031 ****
! // PRIVATE___________________________________________________________
! private int offset;
! private int length;
! private ElementEdit edit;
! private DocumentEvent.EventType type;
! private XMLDocument doc;
! private String value;
// CONSTRUCTORS______________________________________________________
--- 1026,1038 ----
! // PROTECTED__________________________________________________________
! protected int offset;
! protected int length;
! protected ElementEdit edit;
! protected DocumentEvent.EventType type;
! protected XMLDocument doc;
! protected String value;
!
! protected javax.swing.text.Position.Bias bias = javax.swing.text.Position.Bias.Forward;
// CONSTRUCTORS______________________________________________________
***************
*** 1062,1065 ****
--- 1069,1086 ----
/**
+ * Sets the bias of the current event.
+ * @param The new bias for this event
+ */
+ public void setBias(javax.swing.text.Position.Bias bias)
+ { this.bias = bias; }
+
+ /**
+ * Gets the bias of the current event.
+ * @return The bias of the current event
+ */
+ public javax.swing.text.Position.Bias getBias()
+ { return this.bias; }
+
+ /**
* This actually not adds an edit but <em>sets</em> the
* <code>ElementEdit</code>. Because a document event occurs at a
***************
*** 1110,1124 ****
if ( doc !=null && type==DocumentEvent.EventType.INSERT )
{
doc.updatePositions(offset, length);
try
{ doc.content.insertString(offset, value); }
catch (BadLocationException e)
{ e.printStackTrace(); }
- //System.out.println("Insertion of string:"+value+"\n at:"+offset);
}
//TODO: When it is a CHANGE
else if( doc !=null && type==DocumentEvent.EventType.REMOVE )
{
!
doc.updatePositions(offset, -length);
--- 1131,1156 ----
if ( doc !=null && type==DocumentEvent.EventType.INSERT )
{
+ if ( bias==javax.swing.text.Position.Bias.Forward)
+ {
+ System.out.println("Insert forward, old offset:"+offset);
+ offset = Math.min(offset+1,doc.content.length()-1);
+ //offset = Math.max(offset,0);
+ }
+
doc.updatePositions(offset, length);
+ System.out.println("Insertion of string:"+value+"\n at:"+offset+"/"+doc.content.length());
try
{ doc.content.insertString(offset, value); }
catch (BadLocationException e)
{ e.printStackTrace(); }
}
//TODO: When it is a CHANGE
else if( doc !=null && type==DocumentEvent.EventType.REMOVE )
{
! System.out.println("Removal from:"+offset+" to:"+(offset+length));
! try
! { except(); }
! catch (Exception e)
! { e.printStackTrace(); }
doc.updatePositions(offset, -length);
***************
*** 1127,1132 ****
String old = doc.content.getString(offset, length);
doc.content.remove(offset, length);
- System.out.println("Removal of from:"+offset+" to:"+(offset+length));
- System.out.println(" was:"+old);
}
catch (BadLocationException e)
--- 1159,1162 ----
***************
*** 1141,1146 ****
}
}
-
//------------------------------------------------------------------------
//
--- 1171,1177 ----
}
+ public void except() throws Exception
+ { throw new Exception(); }
}
//------------------------------------------------------------------------
//
Index: XMLElement.java
===================================================================
RCS file: /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/core/XMLElement.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** XMLElement.java 2001/11/01 15:41:43 1.1
--- XMLElement.java 2001/12/04 16:37:29 1.2
***************
*** 76,81 ****
// PROTECTED______________________________________________________________
! protected int contentLength;
! protected int startOffset;
protected XMLElementWrapper wrapper;
protected XMLAttributes xmlAttributes;
--- 76,81 ----
// PROTECTED______________________________________________________________
! protected int contentLength;
! protected int startOffset;
protected XMLElementWrapper wrapper;
protected XMLAttributes xmlAttributes;
***************
*** 132,138 ****
}
protected void init()
{
! this.content = new ArrayList(5);
this.wrapper = new XMLElementWrapper(this);
xmlAttributes = new XMLAttributes(getAttributes());
--- 132,142 ----
}
+ /**
+ * Initializes the <code>XMLElement</code> with a new content, with a
+ * new wrapper and a new set of attributes.
+ */
protected void init()
{
! this.content = new ArrayList(1);
this.wrapper = new XMLElementWrapper(this);
xmlAttributes = new XMLAttributes(getAttributes());
***************
*** 179,183 ****
}
-
public org.jdom.Element setAttribute(java.lang.String name,
java.lang.String value, org.jdom.Namespace ns)
--- 183,186 ----
***************
*** 188,192 ****
}
-
public org.jdom.Element setAttributes(java.util.List attributes)
{
--- 191,194 ----
***************
*** 346,349 ****
--- 348,352 ----
{
Object o=it.next();
+ //If it is an element we simply use the parent AddContent method
if ( o instanceof org.jdom.Element )
{ super.addContent((org.jdom.Element)o); }
***************
*** 352,357 ****
else
{
! System.err.println("Class "+o.getClass()+
! " not supported by XMLElement.setNewContent");
}
}
--- 355,359 ----
else
{
! notSupported(o.getClass().getName());
}
}
Index: XMLElementWrapper.java
===================================================================
RCS file: /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/core/XMLElementWrapper.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** XMLElementWrapper.java 2001/11/15 10:49:43 1.2
--- XMLElementWrapper.java 2001/12/04 16:37:29 1.3
***************
*** 2,9 ****
// Project : SPEdit-Prototypes
// ClassName : XMLElementWrapper
! // Version : 0.93c
// Type :
//
! // ThreadSafe : Nope
// Description : Subclass of JDOM Element, plus a Wrapper to make the
// JDOM element visible as a Swing Element.
--- 2,9 ----
// Project : SPEdit-Prototypes
// ClassName : XMLElementWrapper
! // Version : 0.95
// Type :
//
! // ThreadSafe : More or less ;)
// Description : Subclass of JDOM Element, plus a Wrapper to make the
// JDOM element visible as a Swing Element.
***************
*** 13,18 ****
// ----------------------------------------------------------------------------
// Creation date : 17-Sep-2001
! // Last mod. : 01-Nov-2001
// History :
// 01-Nov-2001 Fixed nasty bug in the insert method.(sp)
// 26-Oct-2001 Added some Javadoc. (sp)
--- 13,20 ----
// ----------------------------------------------------------------------------
// Creation date : 17-Sep-2001
! // Last mod. : 28-Nov-2001
// History :
+ // 28-Nov-2001 Improved TreeNode interface JavaDoc,
+ // added siblings access methods.(sp)
// 01-Nov-2001 Fixed nasty bug in the insert method.(sp)
// 26-Oct-2001 Added some Javadoc. (sp)
***************
*** 40,43 ****
--- 42,47 ----
// parent.getContent().size()... should test the
// difference between variable and method calls.
+ // - Wait for next JDom release to use MutableList and then
+ // optimize this class to the max.
package net.sourceforge.spedit.core;
***************
*** 122,125 ****
--- 126,130 ----
protected Position startPosition = null;
protected Position endPosition = null;
+ public boolean isNewlyCreated = false;
// CONSTRUCTORS___________________________________________________________
***************
*** 132,136 ****
{
this.element = element;
! information = null;
}
--- 137,141 ----
{
this.element = element;
! information = new net.sourceforge.spedit.core.XMLInformation(this.getName());
}
***************
*** 184,187 ****
--- 189,198 ----
//------------------------------------------------------------------------
+ /**
+ * Returns a list containing the children of the wrappeet. The
+ * only children that will be added to the list are XMLElemenWrapper and
+ * XMLTextWrapper instances.
+ * @return An enumeration on the children.
+ */
public synchronized Enumeration children()
{
***************
*** 194,207 ****
{ result.add(((XMLElement)o).getWrapper()); }
else if ( o instanceof XMLText )
! { result.add(((XMLElement)o).getWrapper()); }
}
return result.elements();
}
public boolean getAllowsChildren()
{
! return true;
}
public synchronized TreeNode getChildAt(int childIndex)
{
--- 205,235 ----
{ result.add(((XMLElement)o).getWrapper()); }
else if ( o instanceof XMLText )
! { result.add(((XMLText)o).getWrapper()); }
}
return result.elements();
}
+ /**
+ * Tells if the current element allows children. This is actually completely
+ * disjoined from the XMLInformation that the wrapper has.
+ * @return Returns <code>true</code> when the element has more than one child,
+ * otherwise returns <code>false</code>.
+ */
public boolean getAllowsChildren()
{
! if ( getChildCount()==0 )
! { return false; }
! else
! { return true; }
}
+ /**
+ * Return the child which has the given index. Basically a wrapper around
+ * the <code>getElement</code> method.
+ * @param childIndex the index of the child
+ * @return the designated children (which is a wrapper around a JDOM object),
+ * or <code>null</code>.
+ * @see #getElement
+ */
public synchronized TreeNode getChildAt(int childIndex)
{
***************
*** 209,212 ****
--- 237,245 ----
}
+ /**
+ * Returns the number of child elements of this wrapper.
+ * @return Same value as <code>getElementCount</code>
+ * @see #getElementCount
+ */
public int getChildCount()
{
***************
*** 214,217 ****
--- 247,257 ----
}
+ /**
+ * Returns the index of the given node if it is a child of the current
+ * element.
+ * @param node The node that we want to know the index.
+ * @return the index of the node if it is a child, otherwise returns
+ * <code>-1</code>.
+ */
public int getIndex(TreeNode node)
{
***************
*** 229,232 ****
--- 269,276 ----
}
+ /**
+ * Returns the parrent of the wrapper. Of course the parent is also an
+ * <code>XMLElementWrapper</code> so you can cast safely.
+ */
public TreeNode getParent()
{
***************
*** 403,406 ****
--- 447,505 ----
//------------------------------------------------------------------------
//
+ // Siblings
+ //
+ //------------------------------------------------------------------------
+
+ /**
+ * Returns the next <code>XMLElementWrapper</code> sibling
+ */
+ public XMLElementWrapper getNextSibling()
+ {
+ XMLElementWrapper parent = (XMLElementWrapper)getParentElement();
+ if ( parent==null ) { return null; }
+ int index = parent.getIndex(this);
+ if ( index<parent.getElementCount()-1 )
+ {
+ Object sibling = null;
+
+ for ( sibling = parent.getElement(++index) ;
+ !(sibling instanceof XMLElementWrapper) && index<parent.getElementCount() ;
+ sibling=parent.getElement(++index) );
+
+ if ( sibling instanceof XMLElementWrapper )
+ { return (XMLElementWrapper)sibling; }
+ else
+ { return null; }
+ }
+ else
+ { return null; }
+ }
+
+ /**
+ * Returns the previous <code>XMLElementWrapper</code> sibling
+ */
+ public XMLElementWrapper getPreviousSibling()
+ {
+ XMLElementWrapper parent = (XMLElementWrapper)getParentElement();
+ if ( parent==null ) { return null; }
+ int index = parent.getIndex(this);
+ if ( index>1 )
+ {
+ Object sibling = null;
+
+ for ( sibling = parent.getElement(--index) ;
+ !(sibling instanceof XMLElementWrapper) && index>0 ;
+ sibling=parent.getElement(--index) );
+
+ if ( sibling instanceof XMLElementWrapper )
+ { return (XMLElementWrapper)sibling; }
+ else
+ { return null; }
+ }
+ else
+ { return null; }
+ }
+ //------------------------------------------------------------------------
+ //
// Offsets
//
***************
*** 831,835 ****
XMLText new_text=new XMLText(st.substring(str_split,st.length()));
new_content.add(new_text);
- //We fire a new Document event
event = new XMLDocument.DocumentEvent(doc, offset,
inserted);
--- 930,933 ----
***************
*** 838,842 ****
event.addEdit(edit);
event.fire();
- System.out.println("Event fire-1");
}
//Or do we append it?
--- 936,939 ----
***************
*** 860,871 ****
new_content.add(new_text);
}
! //We fire a new Document event
! event = new XMLDocument.DocumentEvent(doc, offset,
! inserted);
edit = new XMLDocument.ElementEdit(this);
edit.addAddedElement(elt.getWrapper());
event.addEdit(edit);
event.fire();
! System.out.println("Event fire-2");
}
}
--- 957,966 ----
new_content.add(new_text);
}
! event = new XMLDocument.DocumentEvent(doc, offset, inserted);
edit = new XMLDocument.ElementEdit(this);
edit.addAddedElement(elt.getWrapper());
event.addEdit(edit);
event.fire();
! event = null;
}
}
***************
*** 880,885 ****
{
new_content.add(elt);
- //We create the DocumentEvent associated with the change and fire
- //it to the containing document.
event = new XMLDocument.DocumentEvent(doc, offset, inserted);
edit = new XMLDocument.ElementEdit(this);
--- 975,978 ----
***************
*** 887,891 ****
event.addEdit(edit);
event.fire();
- System.out.println("Event fire-3");
}
--- 980,983 ----
***************
*** 949,952 ****
--- 1041,1047 ----
*/
public Vector remove(int start, int end)
+ { return remove(start,end,true); }
+
+ protected Vector remove(int start, int end, boolean fireEvent)
{
//We make sure that the offsets are within the element bounds.
***************
*** 955,960 ****
//We adjust the end
! if ( end>=getEndOffset() )
! { end = getEndOffset(); }
ArrayList new_content = new ArrayList(element.getContent().size()-1);
--- 1050,1055 ----
//We adjust the end
! start = Math.max(start, getStartOffset());
! end = Math.min(end , getEndOffset());
ArrayList new_content = new ArrayList(element.getContent().size()-1);
***************
*** 964,967 ****
--- 1059,1063 ----
//We prepare the event
XMLDocument doc = (XMLDocument)element.getDocument();
+
XMLDocument.DocumentEvent event=new XMLDocument.DocumentEvent(doc, start,
end-start);
***************
*** 983,987 ****
case CUT_INSIDE:
//In these case we do not have to notify anything
! wrp.remove(start, end);
case LEAVE:
new_content.add(wrp.element);
--- 1079,1083 ----
case CUT_INSIDE:
//In these case we do not have to notify anything
! wrp.remove(start, end, false);
case LEAVE:
new_content.add(wrp.element);
***************
*** 992,997 ****
//node.
edit = new XMLDocument.ElementEdit(this);
! edit.addAddedElement(wrp);
! event.fire();
to_be_detached.add(wrp.element);
result.add(wrp.element);
--- 1088,1092 ----
//node.
edit = new XMLDocument.ElementEdit(this);
! edit.addRemovedElement(wrp);
to_be_detached.add(wrp.element);
result.add(wrp.element);
***************
*** 1019,1023 ****
//We fire the event
! //event.fire();
//Now we detach the nodes
for (Enumeration e=to_be_detached.elements();e.hasMoreElements();)
--- 1114,1119 ----
//We fire the event
! if ( fireEvent ) { event.fire(); }
! System.out.println("Removal in "+getName());
//Now we detach the nodes
for (Enumeration e=to_be_detached.elements();e.hasMoreElements();)
Index: XMLInformation.java
===================================================================
RCS file: /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/core/XMLInformation.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** XMLInformation.java 2001/11/27 10:31:41 1.3
--- XMLInformation.java 2001/12/04 16:37:29 1.4
***************
*** 63,67 ****
* @version 0.30
*/
! public class XMLInformation
{
// PROTECTED_______________________________________________________________
--- 63,67 ----
* @version 0.30
*/
! public class XMLInformation implements Cloneable
{
// PROTECTED_______________________________________________________________
***************
*** 84,88 ****
protected boolean strip=true;
- protected boolean newlyCreated=false;
// CONSTRUCTORS____________________________________________________________
--- 84,87 ----
***************
*** 110,114 ****
attachedViewParameters = new Hashtable();
}
!
//------------------------------------------------------------------------
//
--- 109,113 ----
attachedViewParameters = new Hashtable();
}
!
//------------------------------------------------------------------------
//
***************
*** 276,303 ****
//------------------------------------------------------------------------
//
- // Element state meta information
- //
- //------------------------------------------------------------------------
-
- /**
- * Tells if the element is a newly created element. For example elements
- * that have just been inserted may need some editing by the user, in
- * this case the WrapperView will activate a special display mode that
- * will graphically tell the user that he should edit the element.
- * @return Tells if the elment is a newly created one.
- */
- public boolean isNewlyCreated()
- { return newlyCreated; }
-
- /**
- * Sets or unsets the <code>newlyCreated</code> flag for this element.
- * @param nc The flag is set if <code>nc</code> is <code>true</code>.
- * @see #isNewlyCreated
- */
- public void setNewlyCreated(boolean nc)
- { newlyCreated = nc; }
-
- //------------------------------------------------------------------------
- //
// Textual content processing attributes
//
--- 275,278 ----
***************
*** 331,336 ****
return result.toString();
}
-
-
}
--- 306,309 ----
Index: XMLViewFactory.java
===================================================================
RCS file: /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/core/XMLViewFactory.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** XMLViewFactory.java 2001/11/28 13:14:37 1.6
--- XMLViewFactory.java 2001/12/04 16:37:29 1.7
***************
*** 95,99 ****
* @param elt The element that the view will display.
* @return A new wrapped and registered view.
! * @see #getElementView
*/
public View create(javax.swing.text.Element elt)
--- 95,99 ----
* @param elt The element that the view will display.
* @return A new wrapped and registered view.
! * @see #getElementView
*/
public View create(javax.swing.text.Element elt)
***************
*** 121,138 ****
}
}
! //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
--- 121,137 ----
}
}
! //Otherwise there is only one info, and we also check that
//the current element has the right ancestors.
else
{
! info = (XMLInformation)((XMLInformation)ob);
if ( info!=null && hasAncestors((XMLElementWrapper)elt, info) )
! { info = (XMLInformation)((XMLInformation)ob); }
else
! { info=null; }
}
+
+ if ( info!=null )
+ { ((XMLNode)elt).setInformation(info); }
//We instanciate the view
|
Update of /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/core/test In directory usw-pr-cvs1:/tmp/cvs-serv21181/net/sourceforge/spedit/core/test Added Files: StyleableTestCase.java XMLBridgeTestCase.java XMLDocumentTestCase.java XMLElementTestCase.java XMLTextTestCase.java Log Message: New element menu, add element bug fix. --- NEW FILE: StyleableTestCase.java --- // ---------------------------------------------------@RisingSun//Java//1.0//EN // Project : SPEdit-Prototypes-TestCases // ClassName : StyleableTestCase // Version : 0.08 // Type : Test case // // ThreadSafe : - // Description : A test case for Styleable.Utils class. // // URL : <http://SPEdit.sourceforge.net> // ---------------------------------------------------------------------------- // Authors : Sebastien Pierre <sp...@is...> // ---------------------------------------------------------------------------- // Creation date : 26-Sep-2001 // Last mod. : 26-Sep-2001 // History : // 26-Sep-2001 First implementation.(SP) // // Bugs : // - // // To do : // - // - // package net.sourceforge.spedit.core.test; import junit.framework.*; import javax.swing.text.*; import java.util.*; import java.awt.Color; import net.sourceforge.spedit.core.*; public class StyleableTestCase extends TestCase { public StyleableTestCase(String name) { super(name); } protected void setUp() { } //------------------------------------------------------------------------- // // Test suite // //------------------------------------------------------------------------- /** * Test the recognition of colors */ public void testIdentifyColor() { assertEquals(Styleable.Utils.COLOR, Styleable.Utils.identify("#FFFFFF")); assertEquals(new Color(255,255,255), Styleable.Utils.parseColor("#FFFFFF")); assertEquals(Styleable.Utils.COLOR, Styleable.Utils.identify("#FF201009")); assertEquals(new Color(255,32,16,9), Styleable.Utils.parseColor("#FF201009")); assertEquals(Styleable.Utils.UNKNOWN, Styleable.Utils.identify("#FFFFF")); assertEquals(Styleable.Utils.UNKNOWN, Styleable.Utils.identify("#FFFF")); } /** * Test the recognition of pixels */ public void testIdentifyPixel() { assertEquals(Styleable.Utils.PIXEL, Styleable.Utils.identify("10")); assertEquals(10, Styleable.Utils.parsePixel("10")); assertEquals(Styleable.Utils.UNKNOWN, Styleable.Utils.identify("10a")); } /** * Test the recognition of points */ public void testIdentifyPoint() { assertEquals(Styleable.Utils.POINT, Styleable.Utils.identify("10pt")); assertEquals(Styleable.Utils.POINT, Styleable.Utils.identify("10.1pt")); assert(10.0==Styleable.Utils.parsePoint("10.0pt")); assert(10.1==Styleable.Utils.parsePoint("10.1pt")); assertEquals(Styleable.Utils.UNKNOWN, Styleable.Utils.identify("10.0p")); } /** * Test the splitStyle method. This tests a simple property, a property * nested in two groups, and a property nested in three groups. */ public void testSplitStyle() { String[] st = Styleable.Utils.splitStyle("block"); assertEquals(1, st.length); assertEquals("block", st[0]); st = Styleable.Utils.splitStyle("block.border"); assertEquals(2, st.length); assertEquals("block", st[0]); assertEquals("border", st[1]); st = Styleable.Utils.splitStyle("block.border.color"); assertEquals(3, st.length); assertEquals("block", st[0]); assertEquals("border", st[1]); assertEquals("color", st[2]); } //------------------------------------------------------------------------- // // Testing the style object // //------------------------------------------------------------------------- /** * Tests the <code>Style</code> object. */ public void testStyle() { Styleable.StyleSheet stylea = new Styleable.StyleSheet(); Styleable.StyleSheet styleb = new Styleable.StyleSheet(); stylea.setStyleClass("font.name", String.class); assertEquals(String.class, stylea.getStyleClass("font.name")); stylea.setStyle("font.name", "Times"); assertEquals("Times", stylea.getStyle("font.name")); //We test the inheritance of the fonts styleb.inheritStyle("font", stylea); assertEquals("Times", styleb.getStyle("font.name")); assertEquals(String.class, stylea.getStyleClass("font.name")); //We check the dynamicity stylea.setStyle("font.name", "Arial"); assertEquals("Arial", stylea.getStyle("font.name")); assertEquals("Arial", styleb.getStyle("font.name")); //We mask the font.name property in styleb styleb.setStyle("font.name", "AvantGarde"); assertEquals("Arial", stylea.getStyle("font.name")); assertEquals("AvantGarde", styleb.getStyle("font.name")); styleb.inheritStyle(stylea); stylea.setStyle("border.size",new Integer(1)); assertEquals(new Integer(1), stylea.getStyle("border.size")); assertEquals(new Integer(1), styleb.getStyle("border.size")); } //------------------------------------------------------------------------- // // Integration // //------------------------------------------------------------------------- public static Test suite() { TestSuite suite = new TestSuite(StyleableTestCase.class); return suite; } public static void main(String args[]) { String[] testCaseName = {StyleableTestCase.class.getName()}; junit.swingui.TestRunner.main(testCaseName); } } // EOF-Unix/ASCII--------------------------------------@RisingSun//Java/1.0//EN --- NEW FILE: XMLBridgeTestCase.java --- // ---------------------------------------------------@RisingSun//Java//1.0//EN // Project : SPEdit-Prototypes-TestCases // ClassName : XMLBridgeTestCase // Version : 0.08 // Type : Package test case // // ThreadSafe : - // Description : A test case for testing every component of the // XMLBridge package. // // URL : <http://SPEdit.sourceforge.net> // ---------------------------------------------------------------------------- // Authors : Sebastien Pierre <sp...@is...> // ---------------------------------------------------------------------------- // Creation date : 10-Sep-2001 // Last mod. : 10-Sep-2001 // History : // 10-Sep-2001 First implementation.(SP) // // Bugs : // - // // To do : // - // package net.sourceforge.spedit.core.test; import java.util.*; import junit.framework.*; import net.sourceforge.spedit.core.*; public class XMLBridgeTestCase extends TestCase { public XMLBridgeTestCase(String name) { super(name); } //------------------------------------------------------------------------- // // Integration // //------------------------------------------------------------------------- public static Test suite() { TestSuite suite = new TestSuite(); suite.addTest(XMLDocumentTestCase.suite()); suite.addTest(XMLElementTestCase.suite()); suite.addTest(XMLTextTestCase.suite()); suite.addTest(StyleableTestCase.suite()); return suite; } public static void main(String args[]) { String[] testCaseName = {XMLBridgeTestCase.class.getName()}; junit.swingui.TestRunner.main(testCaseName); } } // EOF-Unix/ASCII-------------------------------------@RisingSun//Java//1.0//EN --- NEW FILE: XMLDocumentTestCase.java --- // ---------------------------------------------------@RisingSun//Java//1.0//EN // Project : SPEdit-Prototypes-TestCases // ClassName : XMLDocumentTestCase // Version : 0.40 // Type : Test case // // ThreadSafe : - // Description : A test case for the XMLDocument class. // // URL : <http://SPEdit.sourceforge.net> // ---------------------------------------------------------------------------- // Authors : Sebastien Pierre <sp...@is...> // ---------------------------------------------------------------------------- // Creation date : 10-Sep-2001 // Last mod. : 27-Sep-2001 // History : // 27-Sep-2001 Position test case.(SP) // 10-Sep-2001 First implementation.(SP) // // Bugs : // - // // To do : // -Test events (seems like difficult). // -Extensive test of the getText method // // package net.sourceforge.spedit.core.test; import junit.framework.*; import javax.swing.event.*; import javax.swing.text.*; import java.util.*; import net.sourceforge.spedit.core.*; public class XMLDocumentTestCase extends TestCase { XMLDocument doc; DocumentEvent docEvent; public XMLDocumentTestCase(String name) { super(name); } protected void setUp() { doc = new XMLDocument(); } //------------------------------------------------------------------------- // // Test suite // //------------------------------------------------------------------------- /** * The purpose of this test is to check that the properties can be set and * retrieved properly. */ public void testProperties() { Vector value = new Vector(); value.add("Pouet"); doc.putProperty("Spam", value); assert(value==doc.getProperty("Spam")); value.add("Poupou"); assert(value==doc.getProperty("Spam")); doc.removeProperty("Spam"); assert(doc.getProperty("Spam")==null); } /** * The purpose of this test is to check that when positions are registered * into the document they follow any change made to it. */ public void testPositions() { XMLElement root = new XMLElement("root"); XMLElement child= new XMLElement("child"); XMLDocument doc = new XMLDocument(root); root.addContent("01234"); root.addContent(child); child.addContent("56789"); root.addContent("VWXY"); Position start = doc.createPosition(0); Position end = doc.createPosition(14); Position cpos = doc.createPosition(5); //We check position update after insertion assertEquals("0123456789VWXY", root.getWrapper().getWholeText()); assertEquals(root.getWrapper().getWholeText(), root.getWrapper().getWholeText(0,14)); root.getWrapper().insert("ABCD", 3, Position.Bias.Forward) ; assertEquals(0, start.getOffset()); assertEquals(18, end.getOffset()); assertEquals(9, cpos.getOffset()); assertEquals("0123ABCD456789VWXY", root.getWrapper().getWholeText()); assertEquals(root.getWrapper().getWholeText(), root.getWrapper().getWholeText(0,18)); try{ assertEquals(root.getWrapper().getWholeText(), doc.getTextContent().getString(0, doc.getTextContent().length())); } catch (Exception e) { assertEquals(0,1); } //We check position update after removal System.out.println("Before removal"+root.getWrapper().getWholeText()); root.getWrapper().remove(4,8); System.out.println("After removal"+root.getWrapper().getWholeText()); assertEquals(0, start.getOffset()); assertEquals(14, end.getOffset()); assertEquals(5, cpos.getOffset()); assertEquals(root.getWrapper().getWholeText(), root.getWrapper().getWholeText(0,14)); try{ assertEquals(root.getWrapper().getWholeText(), doc.getTextContent().getString(0, doc.getTextContent().length())); } catch (Exception e) { assertEquals(0,1); } } //------------------------------------------------------------------------- // // Integration // //------------------------------------------------------------------------- public static Test suite() { TestSuite suite = new TestSuite(XMLDocumentTestCase.class); return suite; } public static void main(String args[]) { String[] testCaseName = {XMLDocumentTestCase.class.getName()}; junit.swingui.TestRunner.main(testCaseName); } } // EOF-Unix/ASCII--------------------------------------@RisingSun//Java/1.0//EN --- NEW FILE: XMLElementTestCase.java --- // ---------------------------------------------------@RisingSun//Java//1.0//EN // Project : SPEdit-Prototypes-TestCases // ClassName : XMLAttributeSetTestCase // Version : 0.30 // Type : Test case // // ThreadSafe : - // Description : A test case for the XMLElement and XMLTest classes. // // URL : <http://SPEdit.sourceforge.net> // ---------------------------------------------------------------------------- // Authors : Sebastien Pierre <sp...@is...> // ---------------------------------------------------------------------------- // Creation date : 10-Sep-2001 // Last mod. : 14-Sep-2001 // History : // 14-Sep-2001 Lots of other test case. // 11-Sep-2001 Fixed small bugs.(SP) // 10-Sep-2001 First implementation.(SP) // // Bugs : // - // // To do : // -Test case for testElementInsertion is weak.(SP) // package net.sourceforge.spedit.core.test; import java.util.*; import junit.framework.*; import javax.swing.text.*; import net.sourceforge.spedit.core.*; public class XMLElementTestCase extends TestCase { private XMLDocument doc; private XMLElement docroot; public XMLElementTestCase(String name) { super(name); } protected void setUp() { doc = new XMLDocument(new XMLElement("root")); docroot = (XMLElement)doc.getRootElement(); } protected void tearDown() { } //------------------------------------------------------------------------- // // Tools testing // //------------------------------------------------------------------------- public void testGetOperation() { XMLElementWrapper wrp = new XMLElement().getWrapper(); //We test the left cut assertEquals(wrp.CUT_LEFT,wrp.getOperation(10,10,5,15)); assertEquals(wrp.CUT_LEFT,wrp.getOperation(10,10,10,15)); assertEquals(wrp.CUT_LEFT,wrp.getOperation(10,10,10,19)); //We test the right cut assertEquals(wrp.CUT_RIGHT,wrp.getOperation(10,10,15,25)); assertEquals(wrp.CUT_RIGHT,wrp.getOperation(10,10,15,20)); assertEquals(wrp.CUT_RIGHT, wrp.getOperation(10,10,11,20)); //We test the inside cut assertEquals(wrp.CUT_INSIDE, wrp.getOperation(10,10,11,19)); //We test the deletion assertEquals(wrp.DELETE, wrp.getOperation(10,10,10,20)); assertEquals(wrp.DELETE, wrp.getOperation(10,10,9,20)); assertEquals(wrp.DELETE, wrp.getOperation(10,10,9,21)); //We test the leave assertEquals(wrp.LEAVE, wrp.getOperation(10,10,0,10)); assertEquals(wrp.LEAVE, wrp.getOperation(10,10,0,9)); assertEquals(wrp.LEAVE, wrp.getOperation(10,10,20,22)); } public void testCutString() { XMLElementWrapper wrp = new XMLElement().getWrapper(); String s = new String("ABCDEF"); //We test the left cut assertEquals("BCDEF", wrp.cutString(s,3,0,4)); assertEquals("BCDEF", wrp.cutString(s,3,2,4)); assertEquals("EF", wrp.cutString(s,3,3,7)); assertEquals("F", wrp.cutString(s,3,3,8)); //We test the right cut assertEquals("ABCDE",wrp.cutString(s,3,8,10)); assertEquals("A",wrp.cutString(s,3,4,10)); assertEquals("ABCDE",wrp.cutString(s,3,8,9)); //We test the inside cut assertEquals("ABF",wrp.cutString(s,3,5,8)); assertEquals("ABF",wrp.cutString(s,3,5,8)); assertEquals("ACDEF",wrp.cutString(s,3,4,5)); //We test the deletion assert(wrp.cutString(s,3,3,9)==null); } public void testStaticInsert() { String source="ABCDE"; XMLElementWrapper wrp = new XMLElement().getWrapper(); assertEquals("XABCDE", wrp.insertString(source,"X",0,Position.Bias.Backward)); assertEquals("AXBCDE", wrp.insertString(source,"X",0,Position.Bias.Forward)); assertEquals("ABCDXE", wrp.insertString(source,"X",4,Position.Bias.Backward)); assertEquals("ABCDEX", wrp.insertString(source,"X",4,Position.Bias.Forward)); assertEquals("ABXCDE", wrp.insertString(source,"X",2,Position.Bias.Backward)); assertEquals("ABXCDE", wrp.insertString(source,"X",1,Position.Bias.Forward)); } //------------------------------------------------------------------------- // // XMLElement test // //------------------------------------------------------------------------- public void testElementCreation() { //We check the values of the element at construction XMLElement elem = new XMLElement("Pouet"); assert(elem.getDocument()==null); assert(elem.getParent()==null); assertEquals(elem.getName(), "Pouet"); //Then we add a child XMLElement elem2 = new XMLElement("Pouet-2"); elem.addContent(elem2); //And make sure the axioms are verified assert(elem.getWrapper().getElementCount()==1); assert(elem.getWrapper().getElement(0)==elem2.getWrapper()); assert(elem2.getParent()==elem); assert(elem2.getDocument()==null); //We check that the wrapping count is different from the core element //count elem.addContent("qweqwqe"); assert(elem.getWrapper().getElementCount()==2); assert(elem.getWrapper().getElement(0)==elem2.getWrapper()); //Do the same for elem2 elem2.addContent("qweqwqe"); assert(elem2.getWrapper().getElementCount()==1); XMLElement pouet = new XMLElement(); elem2.addContent(pouet); assert(elem2.getWrapper().getElementCount()==2); assertEquals(pouet.getWrapper(), elem2.getWrapper().getElement(1)); //Then we change the parent document, and check that the //child has also changed of document elem.setDocument(doc); assert(elem.getDocument()!=null); assert(elem2.getDocument()==elem.getDocument()); //Then we remove the child and verify the axioms elem.removeContent(elem2); assert(elem2.getParent()!=elem); assert(elem.getWrapper().getElementCount()==1); } public void testElementInsertion() { XMLElement elem = new XMLElement("Pouet1"); XMLElement elem2 = new XMLElement("Spam1"); //We add the elements to the document docroot.addContent(elem); //We add a structured content elem.addContent("123890"); elem2.addContent("4567"); elem.getWrapper().insert(elem2,3,Position.Bias.Backward); assertEquals("1234567890", elem.getWrapper().getWholeText()); assertEquals(elem2.getWrapper(), elem.getWrapper().getElement(1)); //We add the elements to the document docroot.removeContent(elem); docroot.removeContent(elem2); } public void testElementWrapper() { XMLElement elem = new XMLElement("Pouet2"); XMLElement elem2 = new XMLElement("Spam2"); XMLElement elem3 = new XMLElement("Foobar2"); //We add a structured content elem.addContent("12345"); elem.addContent(elem2); elem.addContent(elem3); elem2.addContent("6789"); elem3.addContent("0123"); elem.addContent("45"); //Verify the attribute axioms assert(elem.getWrapper().getElementCount()==4); assert(elem.getWrapper().getElement(1)==elem2.getWrapper()); assert(elem.getWrapper().getStartOffset()==0); assert(elem.getWrapper().getLength()==15); assert(elem.getWrapper().getEndOffset()==15); assertEquals(5, elem2.getWrapper().getStartOffset()); assertEquals(4, elem2.getWrapper().getLength()); assertEquals(9, elem2.getWrapper().getEndOffset()); //And verify that the wrapper works well assertEquals("123456789012345", elem.getWrapper().getWholeText()); assertEquals( 0, elem.getWrapper().getElementIndex(-1)); assertEquals( 0, elem.getWrapper().getElementIndex(4)); assertEquals( 1, elem.getWrapper().getElementIndex(5)); assertEquals( 1, elem.getWrapper().getElementIndex(8)); assertEquals( 2, elem.getWrapper().getElementIndex(9)); assertEquals( 2, elem.getWrapper().getElementIndex(10)); assertEquals( 2, elem.getWrapper().getElementIndex(12)); assertEquals( 3, elem.getWrapper().getElementIndex(13)); assertEquals( 3, elem.getWrapper().getElementIndex(14)); assertEquals( 3, elem.getWrapper().getElementIndex(15)); } public void testElementOffsets() { XMLElement elem = new XMLElement("Pouet"); XMLElement elem2 = new XMLElement("Spam"); XMLElement elem3 = new XMLElement("Spam"); elem.setDocument(doc); elem.addContent("012345"); elem2.addContent("6789"); elem3.addContent("01"); elem.addContent(elem2); //We check that a child related to its parent assert(elem.getWrapper().getStartOffset()==0); assert(elem.getWrapper().getEndOffset()==10); assert(elem2.getWrapper().getStartOffset()==6); assert(elem2.getWrapper().getEndOffset()==10); //Even when the parent is moved to another parent elem2.addContent(elem3); assert(elem.getWrapper().getStartOffset()==0); assert(elem.getWrapper().getEndOffset()==12); assert(elem2.getWrapper().getStartOffset()==6); assert(elem2.getWrapper().getEndOffset()==12); assert(elem3.getWrapper().getStartOffset()==10); assert(elem3.getWrapper().getEndOffset()==12); } public void testElementRange() { XMLElement elem = new XMLElement("Pouet"); XMLElement elem2 = new XMLElement("Spam"); //We add a structured content elem.addContent("12345"); elem.addContent(elem2); elem2.addContent("6789"); elem.addContent("012345"); //We check that the range work well assert(elem.getWrapper().contains(0,15)); assert(elem.getWrapper().contains(0,16)); assert(elem.getWrapper().contains(14,16)); assert(!elem.getWrapper().contains(15,16)); assert(elem2.getWrapper().contains(0,15)); assert(!elem2.getWrapper().contains(0,4)); assert(elem2.getWrapper().contains(0,5)); assert(elem2.getWrapper().contains(5,15)); assert(elem2.getWrapper().contains(5,8)); assert(elem2.getWrapper().contains(5,9)); assert(!elem2.getWrapper().contains(9,10)); } /** * Tests the following aspects: * <ul> * <li>Removal of a part of a text node.</li> * <li>Removal of an element inside an element</li> * <li>Coherence of the node content during and after the removals.</li> * </ul> */ public void testElementTextRemoval() { XMLElement elem = new XMLElement("Pouet"); XMLElement elem2 = new XMLElement("Spam"); //We add a structured content elem.addContent("12345"); elem.addContent(elem2); elem2.addContent("6789"); elem.addContent("ABCDE"); //We check that the range work well elem.getWrapper().remove(10,15); assertEquals("123456789A",elem.getWrapper().getWholeText()); assert(elem.getWrapper().getElementCount()==3); assert(elem.getWrapper().getElement(1)==elem2.getWrapper()); //And we remove an element elem.getWrapper().remove(elem2.getWrapper().getStartOffset(),elem2.getWrapper().getEndOffset()); assert(elem2.getParent()==null); assertEquals("12345A",elem.getWrapper().getWholeText()); } /** * Test the coeherence of an element after adding text in it. */ public void testElementTextInsertion() { XMLElement elem = new XMLElement("Pouet"); XMLElement elem2 = new XMLElement("Spam"); //We add a structured content elem.addContent("12345"); elem.addContent(elem2); elem2.addContent("6789"); elem.addContent("ABCDE"); //We have text content "123456789ABCDE" //with offsets 01234567890123" // 00000000001111 elem.getWrapper().insert("XX",3,Position.Bias.Forward); assertEquals("1234XX56789ABCDE", elem.getWrapper().getWholeText()); elem.getWrapper().insert("YY",7,Position.Bias.Backward); assertEquals("1234XX5YY6789ABCDE", elem.getWrapper().getWholeText()); assertEquals("YY6789", elem2.getWrapper().getWholeText()); } //------------------------------------------------------------------------- // // XMLAttributes test // //------------------------------------------------------------------------- public void testSetAttribute() { XMLElement elem = new XMLElement("Pouet"); String sampleKey = "Spam"; String sampleValue = "Foobar"; elem.setAttribute(sampleKey, sampleValue); AttributeSet attrs = elem.getWrapper().getAttributes(); //We check what happens when we add the attribute. assert(attrs.isDefined(sampleKey)); assert(attrs.containsAttribute(sampleKey, sampleValue)); assert(attrs.getAttributeCount()==1); assertEquals( sampleValue, attrs.getAttribute(sampleKey) ); assert(attrs.containsAttributes(attrs)); } public void testRemoveAttribute() { XMLElement elem = new XMLElement("Pouet"); String sampleKey = "Spam"; String sampleValue = "Foobar"; elem.setAttribute(sampleKey, sampleValue); AttributeSet attrs = elem.getWrapper().getAttributes(); assert(attrs.containsAttribute(sampleKey, sampleValue)); assert(attrs.getAttributeCount()==1); //And what happens when we remove it. elem.removeAttribute(sampleKey); assert(attrs.getAttributeCount()==0); assert(!attrs.containsAttribute(sampleKey, sampleValue)); assert(!attrs.isDefined(sampleKey)); assert(attrs.containsAttributes(attrs)); } public void testClone() { XMLElement elem = new XMLElement("Pouet"); String sampleKey = "Spam"; String spam = "pouet"; elem.setAttribute(sampleKey, spam); AttributeSet attrs = elem.getWrapper().getAttributes(); AttributeSet attrs2 = attrs.copyAttributes(); AttributeSet attrs3 = attrs.copyAttributes(); assert(attrs2.containsAttributes(attrs)); assert(attrs3.containsAttributes(attrs)); //We change the attr value, and check that attrs2 has not changed. elem.setAttribute(sampleKey, spam+"c"); assert(!attrs.containsAttributes(attrs2)); assert(attrs3.containsAttributes(attrs2)); } //------------------------------------------------------------------------- // // Integration // //------------------------------------------------------------------------- public static Test suite() { TestSuite suite = new TestSuite(XMLElementTestCase.class); return suite; } public static void main(String args[]) { String[] testCaseName = {XMLElementTestCase.class.getName()}; junit.swingui.TestRunner.main(testCaseName); } } // EOF-Unix/ASCII-------------------------------------@RisingSun//Java//1.0//EN --- NEW FILE: XMLTextTestCase.java --- // ---------------------------------------------------@RisingSun//Java//1.0//EN // Project : SPEdit-Prototypes-TestCases // ClassName : XMLTextTestCase // Version : 0.08 // Type : Test case // // ThreadSafe : - // Description : A test case for the XMLText and XMLTextWrapper classes. // // URL : <http://SPEdit.sourceforge.net> // ---------------------------------------------------------------------------- // Authors : Sebastien Pierre <sp...@is...> // ---------------------------------------------------------------------------- // Creation date : 20-Sep-2001 // Last mod. : 20-Sep-2001 // History : // -Sep-2001 First implementation.(SP) // // Bugs : // - // // To do : // - // - // package net.sourceforge.spedit.core.test; import junit.framework.*; import javax.swing.text.*; import java.util.*; import net.sourceforge.spedit.core.*; public class XMLTextTestCase extends TestCase { public XMLTextTestCase(String name) { super(name); } protected void setUp() { } //------------------------------------------------------------------------- // // Test suite // //------------------------------------------------------------------------- /** * The purpose of this test is to check that: * <ul> * <li>When the text content of an XMLElement is changed, the given * XMLText is changed too.</li> * <li>When test is added after an XMLText node then the XMLText node is * extended with the given text</li> * <li>Same test when appending in the middle, and appending at the * beginning.</li> * </ul> */ public void testDynamicity() { XMLElement elem1 = new XMLElement("Spam"); XMLElement elem2 = new XMLElement("Foo"); XMLText text1 = new XMLText("1234"); XMLText text2 = new XMLText("9012"); //We create the test case data elem1.addContent(text1); elem1.addContent(elem2); elem2.addContent("popo"); elem1.addContent(text2); assertEquals("1234", text1.getValue()); assertEquals("9012", text2.getValue()); //We check that the offsets are OK assertEquals(0, text1.getWrapper().getStartOffset()); assertEquals(4, text1.getWrapper().getEndOffset()); assertEquals(4, text1.getWrapper().getLength()); assertEquals(8, text2.getWrapper().getStartOffset()); assertEquals(12,text2.getWrapper().getEndOffset()); assertEquals(4, text2.getWrapper().getLength()); //We check that the text has been dynamically changed when prepending elem1.getWrapper().insert("AB", 0, Position.Bias.Backward); assertEquals("AB1234", text1.getValue()); assertEquals(0, text1.getWrapper().getStartOffset()); assertEquals(6, text1.getWrapper().getEndOffset()); assertEquals(6, text1.getWrapper().getLength()); assertEquals(10, text2.getWrapper().getStartOffset()); assertEquals(14, text2.getWrapper().getEndOffset()); assertEquals(4, text2.getWrapper().getLength()); //That it has been changed when appending elem1.getWrapper().insert("XY", 13, Position.Bias.Forward); assertEquals("9012XY", text2.getValue()); assertEquals(10, text2.getWrapper().getStartOffset()); assertEquals(16, text2.getWrapper().getEndOffset()); assertEquals(6, text2.getWrapper().getLength()); //That is has been changed when inserting elem1.getWrapper().insert("OP", 11, Position.Bias.Forward); assertEquals("90OP12XY", text2.getValue()); assertEquals(10, text2.getWrapper().getStartOffset()); assertEquals(18, text2.getWrapper().getEndOffset()); assertEquals(8, text2.getWrapper().getLength()); } public void testStripping() { XMLText text1 = new XMLText("1234"); XMLText text2 = new XMLText(" 1234"); XMLText text3 = new XMLText(" 1234"); XMLText text4 = new XMLText(" 1234 "); XMLText text5 = new XMLText(" "); XMLText text6 = new XMLText(" "); XMLText text7 = new XMLText(""); text1.strip(); text2.strip(); text3.strip(); text4.strip(); text5.strip(); text6.strip(); text7.strip(); assertEquals("1234",text1.getValue()); assertEquals("1234",text2.getValue()); assertEquals("1234",text3.getValue()); assertEquals("1234",text4.getValue()); assertEquals("",text5.getValue()); assertEquals("",text6.getValue()); assertEquals("",text7.getValue()); } //------------------------------------------------------------------------- // // Integration // //------------------------------------------------------------------------- public static Test suite() { TestSuite suite = new TestSuite(XMLTextTestCase.class); return suite; } public static void main(String args[]) { String[] testCaseName = {XMLTextTestCase.class.getName()}; junit.swingui.TestRunner.main(testCaseName); } } // EOF-Unix/ASCII--------------------------------------@RisingSun//Java/1.0//EN |
|
From: S?bastien P. <kaz...@us...> - 2001-12-04 16:37:32
|
Update of /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/app
In directory usw-pr-cvs1:/tmp/cvs-serv21181/net/sourceforge/spedit/app
Modified Files:
Application.java
Log Message:
New element menu, add element bug fix.
Index: Application.java
===================================================================
RCS file: /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/app/Application.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** Application.java 2001/11/28 13:14:37 1.6
--- Application.java 2001/12/04 16:37:29 1.7
***************
*** 30,33 ****
--- 30,34 ----
import java.util.*;
import java.awt.Component;
+ import java.awt.AWTEvent;
import java.awt.event.*;
import java.lang.reflect.*;
***************
*** 146,166 ****
editorPane = new JEditorPane();
navigator = new NavigationTree(this);
! editorKit = new XMLEditorKit("../Support/SP-Configuration.xml");
! //editorKit = new XMLEditorKit("../Support/ON-Configuration.xml");
editorPane.setEditorKit(editorKit);
factory = (XMLViewFactory)editorKit.getViewFactory();
- editorPane.addMouseListener(this);
init();
}
public void init()
! {
! //We load the custom file
! File ff = new File("../Support/SP-P11388.xml");
! //File ff = new File("../Support/ON-Document.xml");
! document = XMLDocument.loadFromFile(ff, factory);
! document.filter(factory);
! setDocument(document);
!
//We set layout for container
getContentPane().setLayout(new XmFormLayout(constraints));
--- 147,161 ----
editorPane = new JEditorPane();
navigator = new NavigationTree(this);
! //editorKit = new XMLEditorKit("../Support/SP-Configuration.xml");
! editorKit = new XMLEditorKit("../Support/ON-Configuration.xml");
editorPane.setEditorKit(editorKit);
factory = (XMLViewFactory)editorKit.getViewFactory();
init();
}
public void init()
! {
! editorPane.addMouseListener(this);
!
//We set layout for container
getContentPane().setLayout(new XmFormLayout(constraints));
***************
*** 173,185 ****
//We generate the document content
scrollPane = new JScrollPane(editorPane);
! JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
new JScrollPane(navigator), scrollPane);
splitPane.setName("document");
getContentPane().add("document", splitPane);
python.eval("frame.getContentPane().add('status', status)");
//We open the window
setBounds(10,10,500,400);
- splitPane.setDividerLocation(0.40);
setVisible(true);
}
--- 168,190 ----
//We generate the document content
scrollPane = new JScrollPane(editorPane);
! JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true,
new JScrollPane(navigator), scrollPane);
+ splitPane.setDividerLocation(150);
+ splitPane.setDividerSize(6);
+ splitPane.setOneTouchExpandable(true);
splitPane.setName("document");
getContentPane().add("document", splitPane);
python.eval("frame.getContentPane().add('status', status)");
+ //We load the custom file
+ //File ff = new File("../Support/SP-P11388.xml");
+ File ff = new File("../Support/ON-Document.xml");
+ document = XMLDocument.loadFromFile(ff, factory);
+ document.filter(factory);
+ setDocument(document);
+
//We open the window
+
setBounds(10,10,500,400);
setVisible(true);
}
***************
*** 197,200 ****
--- 202,207 ----
public void mouseClicked(MouseEvent evt)
{
+ System.out.println("Mouse clicked on application!");
+
XMLElementWrapper e = (XMLElementWrapper)getDocument().getDefaultRootElement();
WrapperView wrap = (WrapperView)factory.getElementView(e);
***************
*** 202,209 ****
if ( oldWrapper!=null )
{ oldWrapper.setFocused(false); }
- wrap.setFocused(true);
- oldWrapper = wrap;
- wrap.propagateMouseClicked(evt);
if (evt.isControlDown() || SwingUtilities.isRightMouseButton(evt))
{
--- 209,220 ----
if ( oldWrapper!=null )
{ oldWrapper.setFocused(false); }
+ if ( wrap!=null )
+ {
+ wrap.setFocused(true);
+ oldWrapper = wrap;
+ wrap.propagateMouseClicked(evt);
+ }
+
if (evt.isControlDown() || SwingUtilities.isRightMouseButton(evt))
{
***************
*** 294,307 ****
if ( info!=null )
{
JMenuItem item;
! Enumeration e = info.getChildren();
menu.add(new ActionElementRemove(element));
menu.add(new JSeparator());
//We add insertable children in the menu
while ( e.hasMoreElements() )
{
! //(item = new JMenuItem("Insert "+e.nextElement());
! //item.setActionCommand("add");
! XMLElement nelt = new XMLElement(e.nextElement().toString());
menu.add(new ActionElementInsert(element,nelt, dot));
}
--- 305,345 ----
if ( info!=null )
{
+ JMenu before, after;
JMenuItem item;
! Enumeration e;
! XMLElementWrapper parent;
! boolean menuAdded = false;
! parent = (XMLElementWrapper)element.getParentElement();
menu.add(new ActionElementRemove(element));
menu.add(new JSeparator());
+
+ before = new JMenu("Insert before...");
+ after = new JMenu("Insert after...");
+
+
//We add insertable children in the menu
+ e = parent.getInformation().getChildren();
while ( e.hasMoreElements() )
{
! String childName = (String)e.nextElement();
! item = new JMenuItem("Insert "+childName);
! item.setActionCommand("add");
! XMLElement nelt = new XMLElement(childName);
! after.add(new ActionElementInsert(parent,nelt, dot));
! before.add(new ActionElementInsert(parent,nelt, dot));
! }
!
! menu.add(before);
! menu.add(after);
! menu.add(new JSeparator());
!
! //We add insertable children in the menu
! e = info.getChildren();
! while ( e.hasMoreElements() )
! {
! String childName = (String)e.nextElement();
! item = new JMenuItem("Insert "+childName);
! item.setActionCommand("add");
! XMLElement nelt = new XMLElement(childName);
menu.add(new ActionElementInsert(element,nelt, dot));
}
***************
*** 336,344 ****
CompositeView view =
(CompositeView)((WrapperView)factory.getElementView(wrp)).getNestedView();
! wrp.remove(wrapper.getStartOffset(), wrapper.getEndOffset());
//We do this to force a loadChildren() method call in the CompositeView.
view.replace(0,view.getViewCount(),new View[0]);
view.setParent(view.getParent());
! view.getContainer().repaint();
}
}
--- 374,383 ----
CompositeView view =
(CompositeView)((WrapperView)factory.getElementView(wrp)).getNestedView();
! //wrp.getXMLElement().removeContent(wrapper.getXMLElement());
! wrapper.remove(wrapper.getStartOffset(), wrapper.getEndOffset());
//We do this to force a loadChildren() method call in the CompositeView.
view.replace(0,view.getViewCount(),new View[0]);
view.setParent(view.getParent());
! //view.getContainer().repaint();
}
}
***************
*** 369,372 ****
--- 408,413 ----
{
XMLElementWrapper wrp = (XMLElementWrapper)wrapper.getParentElement();
+ System.out.println("Getting element view for:"+wrp);
+ System.out.println("is:"+((WrapperView)factory.getElementView(wrp)));
//We get the parent view
CompositeView view =
***************
*** 375,379 ****
view.replace(0,view.getViewCount(),new View[0]);
//FIXME: Insertion should be made through the DOM...
! newElement.getWrapper().getInformation().setNewlyCreated(true);
wrapper.insert(newElement,pos,javax.swing.text.Position.Bias.Forward);
//This makes the actual forced reaload after element insertion.
--- 416,421 ----
view.replace(0,view.getViewCount(),new View[0]);
//FIXME: Insertion should be made through the DOM...
! newElement.getWrapper().isNewlyCreated = true;
! newElement.addContent(new String("EDIT ME"));
wrapper.insert(newElement,pos,javax.swing.text.Position.Bias.Forward);
//This makes the actual forced reaload after element insertion.
|
|
From: S?bastien P. <kaz...@us...> - 2001-12-04 10:58:38
|
Update of /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/core/test In directory usw-pr-cvs1:/tmp/cvs-serv29357/net/sourceforge/spedit/core/test Log Message: Directory /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/core/test added to the repository |
|
From: Kai R. <kr...@us...> - 2001-11-28 14:52:56
|
Update of /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/ui
In directory usw-pr-cvs1:/tmp/cvs-serv25959
Modified Files:
AttributesDisplay.java
Log Message:
Remove a semicolon in line 126. It cause the jikes parser to fail.
Index: AttributesDisplay.java
===================================================================
RCS file: /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/ui/AttributesDisplay.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** AttributesDisplay.java 2001/11/28 13:14:37 1.4
--- AttributesDisplay.java 2001/11/28 14:52:50 1.5
***************
*** 124,128 ****
else
{
! return element.getXMLElement().getAttributes().size();;
}
--- 124,128 ----
else
{
! return element.getXMLElement().getAttributes().size();
}
|
|
From: S?bastien P. <kaz...@us...> - 2001-11-28 13:15:57
|
Update of /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/spml In directory usw-pr-cvs1:/tmp/cvs-serv2387 Removed Files: AuthorDisplay.java DataBaseDisplay.java Log Message: AttributesDisplay have migrated in the SPML jython module. --- AuthorDisplay.java DELETED --- --- DataBaseDisplay.java DELETED --- |
|
From: S?bastien P. <kaz...@us...> - 2001-11-28 13:14:41
|
Update of /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/spml In directory usw-pr-cvs1:/tmp/cvs-serv1688/net/sourceforge/spedit/spml Added Files: AuthorDisplay.java DataBaseDisplay.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. --- NEW FILE: AuthorDisplay.java --- // ---------------------------------------------------@RisingSun//Java//1.0//EN // Project : SPEdit-SPML // ClassName : AuthorDisplay // Version : 0.20 // Type : SPEdit view extension // ThreadSafe : Yep // Description : Displays the authors in an SPML document // URL : <http://spedit.sf.net> // ---------------------------------------------------------------------------- // Authors : Sbastien Pierre <sp...@is...> // ---------------------------------------------------------------------------- // Creation date : 26-Nov-2001 // Last mod. : 26-Nov-2001 // History : // 26-Nov-2001 First implementation.(sp) // // Bugs : // - // // To do : // package net.sourceforge.spedit.spml; import java.awt.*; import java.awt.event.*; import java.util.Vector; import javax.swing.*; import javax.swing.tree.*; import javax.swing.event.*; import net.sourceforge.spedit.core.*; import net.sourceforge.spedit.ui.*; public class AuthorDisplay extends AttributesDisplay { public AuthorDisplay(XMLElementWrapper element, WrapperView view) { super(element,view); } protected void init() { setLayout(new FlowLayout()); add(new JLabel("name")); add(new JLabel("surname")); } } // EOF-Linux/ISO-8859-1-------------------------------@RisingSun//Java//1.0//EN --- NEW FILE: DataBaseDisplay.java --- // ---------------------------------------------------@RisingSun//Java//1.0//EN // Project : SPEdit-SPML // ClassName : DataBaseDisplay // Version : 0.20 // Type : SPEdit view extension // ThreadSafe : Yep // Description : Displays the database entry in an SPML document // URL : <http://spedit.sf.net> // ---------------------------------------------------------------------------- // Authors : Sbastien Pierre <sp...@is...> // ---------------------------------------------------------------------------- // Creation date : 26-Nov-2001 // Last mod. : 26-Nov-2001 // History : // 26-Nov-2001 First implementation.(sp) // // Bugs : // - // // To do : // package net.sourceforge.spedit.spml; import java.awt.*; import java.awt.event.*; import java.util.Vector; import javax.swing.*; import javax.swing.tree.*; import javax.swing.event.*; import net.sourceforge.spedit.core.*; import net.sourceforge.spedit.ui.*; public class DataBaseDisplay extends AttributesDisplay { public DataBaseDisplay(XMLElementWrapper element, WrapperView view) { super(element,view); } protected void init() { setLayout(new FlowLayout()); add(new JLabel("DATABASE")); add(new JLabel("PRIMARY")); add(new JLabel("SECONDARY")); add(new JLabel("STATUS")); } } // EOF-Linux/ISO-8859-1-------------------------------@RisingSun//Java//1.0//EN |
|
From: S?bastien P. <kaz...@us...> - 2001-11-28 13:14:41
|
Update of /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/ui
In directory usw-pr-cvs1:/tmp/cvs-serv1688/net/sourceforge/spedit/ui
Modified Files:
AttributesDisplay.java BlockView.java LabelView.java
ParagraphView.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: AttributesDisplay.java
===================================================================
RCS file: /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/ui/AttributesDisplay.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** AttributesDisplay.java 2001/11/27 10:31:41 1.3
--- AttributesDisplay.java 2001/11/28 13:14:37 1.4
***************
*** 3,7 ****
// Module : GUI-Views
// ClassName : AttributesDisplay
! // Version : 0.90
// Type :
//
--- 3,7 ----
// Module : GUI-Views
// ClassName : AttributesDisplay
! // Version : 0.95
// Type :
//
***************
*** 14,19 ****
// ----------------------------------------------------------------------------
// Creation date : 13-Nov-2001
! // Last mod. : 21-Nov-2001
// History :
// 21-Nov-2001 Much cleaner for sublacssing, only displays
// children so display intergrated well with the
--- 14,21 ----
// ----------------------------------------------------------------------------
// Creation date : 13-Nov-2001
! // Last mod. : 27-Nov-2001
// History :
+ // 27-Nov-2001 Moved init code to DefaultAttributeDisplay.
+ // (sp)
// 21-Nov-2001 Much cleaner for sublacssing, only displays
// children so display intergrated well with the
***************
*** 74,88 ****
this.element = element;
setFont(view.getStyleSheet().font);
- init();
}
- protected void init()
- {
- add(new JTable(new AttributesModel(element)));
- }
-
public void paint(Graphics g)
{
- //System.out.println("Repaiting "+model.element.getName());
paintChildren(g);
}
--- 76,83 ----
***************
*** 200,203 ****
--- 195,210 ----
}
+ /**
+ * This is the default attributes display implementation that displays the attributes
+ * either as a vertical or an horizontal table.
+ */
+ public class DefaultAttributesDisplay extends AttributesDisplay
+ {
+ public DefaultAttributesDisplay(XMLElementWrapper element, WrapperView view)
+ {
+ super(element, view);
+ add(new JTable(new AttributesModel(element)));
+ }
+ }
}
Index: BlockView.java
===================================================================
RCS file: /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/ui/BlockView.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** BlockView.java 2001/11/27 10:31:41 1.2
--- BlockView.java 2001/11/28 13:14:37 1.3
***************
*** 16,20 ****
// Last mod. : 27-Nov-2001
// History :
! // 27-Nov-2001 Updated inset accession.(sp)
// 27-Sep-2001 First implementation. (SP)
//
--- 16,21 ----
// Last mod. : 27-Nov-2001
// History :
! // 27-Nov-2001 Updated inset accession. Code
! // cleanup and delegtaion to WrapperView.(sp)
// 27-Sep-2001 First implementation. (SP)
//
Index: LabelView.java
===================================================================
RCS file: /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/ui/LabelView.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** LabelView.java 2001/11/27 10:31:41 1.3
--- LabelView.java 2001/11/28 13:14:37 1.4
***************
*** 16,20 ****
// Last mod. : 27-Nov-2001
// History :
! // 27-Nov-2001 Updated inset accession.(sp)
// 07-Nov-2001 Fixed selcetion problem. The solution was
// to copy the sourcecode from the JDK 1.3.1 and modify
--- 16,21 ----
// Last mod. : 27-Nov-2001
// History :
! // 27-Nov-2001 Updated inset accession. Code
! // cleanup and delegtaion to WrapperView.(sp)
// 07-Nov-2001 Fixed selcetion problem. The solution was
// to copy the sourcecode from the JDK 1.3.1 and modify
Index: ParagraphView.java
===================================================================
RCS file: /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/ui/ParagraphView.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** ParagraphView.java 2001/11/27 10:31:41 1.3
--- ParagraphView.java 2001/11/28 13:14:37 1.4
***************
*** 16,20 ****
// Last mod. : 27-Nov-2001
// History :
! // 27-Nov-2001 Updated inset accession.(sp)
// 27-Sep-2001 First implementation. (sp)
//
--- 16,21 ----
// Last mod. : 27-Nov-2001
// History :
! // 27-Nov-2001 Updated inset accession. Code
! // cleanup and delegtaion to WrapperView.(sp)
// 27-Sep-2001 First implementation. (sp)
//
|
|
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;
+ }
+
//------------------------------------------------------------------------
//
|
|
From: S?bastien P. <kaz...@us...> - 2001-11-28 13:14:40
|
Update of /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/app
In directory usw-pr-cvs1:/tmp/cvs-serv1688/net/sourceforge/spedit/app
Modified Files:
Application.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: Application.java
===================================================================
RCS file: /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/app/Application.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Application.java 2001/11/27 10:31:41 1.5
--- Application.java 2001/11/28 13:14:37 1.6
***************
*** 146,152 ****
editorPane = new JEditorPane();
navigator = new NavigationTree(this);
! //editorKit = new XMLEditorKit("../Support/Configuration.xml");
! //editorKit = new XMLEditorKit("../Support/SP-Configuration.xml");
! editorKit = new XMLEditorKit("../Support/ON-Configuration.xml");
editorPane.setEditorKit(editorKit);
factory = (XMLViewFactory)editorKit.getViewFactory();
--- 146,151 ----
editorPane = new JEditorPane();
navigator = new NavigationTree(this);
! editorKit = new XMLEditorKit("../Support/SP-Configuration.xml");
! //editorKit = new XMLEditorKit("../Support/ON-Configuration.xml");
editorPane.setEditorKit(editorKit);
factory = (XMLViewFactory)editorKit.getViewFactory();
***************
*** 158,163 ****
{
//We load the custom file
! //File ff = new File("../Support/SP-P11388.xml");
! File ff = new File("../Support/ON-Document.xml");
document = XMLDocument.loadFromFile(ff, factory);
document.filter(factory);
--- 157,162 ----
{
//We load the custom file
! File ff = new File("../Support/SP-P11388.xml");
! //File ff = new File("../Support/ON-Document.xml");
document = XMLDocument.loadFromFile(ff, factory);
document.filter(factory);
|
|
From: S?bastien P. <kaz...@us...> - 2001-11-28 13:13:00
|
Update of /cvsroot/spedit/prototype/Support In directory usw-pr-cvs1:/tmp/cvs-serv1455 Modified Files: Application.py SP-Configuration.xml Log Message: New configuration file that has been updated to support the new XML Schema. There are many improvements in the overall construction. Best thing is to have a look at the diffs. Index: Application.py =================================================================== RCS file: /cvsroot/spedit/prototype/Support/Application.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Application.py 2001/11/21 11:02:31 1.3 --- Application.py 2001/11/28 13:12:58 1.4 *************** *** 1,15 **** # --------------------------------------------------@RisingSun//Jython//1.0//EN ! # Module : SPEdit-GUI Prototype ! # Version : 0.01 ! # Type : GUI utility # ThreadSafe : - # Description : # URL : <http://SPEdit.sourceforge.net> # ----------------------------------------------------------------------------- ! # Author : Sebastien Pierre <sp...@is...> # ----------------------------------------------------------------------------- # Creation date : 19-Sep-2001 ! # Last mod. : 19-Sep-2001 # History : # 19-Sep-2001 First implementation. # --- 1,17 ---- # --------------------------------------------------@RisingSun//Jython//1.0//EN ! # Module : SPEdit ! # Version : 0.1 ! # Type : Application support library # ThreadSafe : - # Description : # URL : <http://SPEdit.sourceforge.net> # ----------------------------------------------------------------------------- ! # Author : Sbastien Pierre <sp...@is...> # ----------------------------------------------------------------------------- # Creation date : 19-Sep-2001 ! # Last mod. : 27-Nov-2001 # History : + # 27-Nov-2001 Added the getInstance and the checkAncestors + # methods.(sp) # 19-Sep-2001 First implementation. # *************** *** 20,24 **** # -Test suite ! import java, javax, sys from javax.swing import * --- 22,30 ---- # -Test suite ! # Jython imports ! import sys, string ! ! # Java imports ! import java, javax from javax.swing import * *************** *** 73,78 **** menubar.add(menu) return menubar ! class MenuListener( java.awt.event.ActionListener ): --- 79,124 ---- menubar.add(menu) return menubar ! ! def getInstance( name, parameters ): ! """Generates a new instance of the fully qualified Python class ! given by the 'name' paremeter. The 'parameters' is the tuple that ! will be given to the constructor. ! ! In case the constructor fails or that the class has not been found ! None is returned, otherwise the new instance is returned.""" ! ! module = None ! for i in range(0,len(name)): ! if name[i]=='.': ! module = name[:i] ! break ! ! if module!=None: ! constructor = None ! try: ! constructor = eval(name) ! except: ! exec "import %s" % (module) ! constructor = eval(name) ! instance = apply(eval(name), parameters) ! return instance ! else: ! return None + def checkAncestors( ancestors, element ): + """Checks if the given element has the ancestor list given by the + expression. The expression is a descendant list like 'document/section/title', + which means that the current element must be a title, that its parent must be a section + and its grandparent a document.""" + if type(ancestors)==type(""): + ancestors = string.split(ancestors,"/") + if element==None: return 0 + if len(ancestors)==1: + if element.getName()==ancestors[0]: return 1 + else: return 0 + else: + if checkAncestors(ancestors[:-1], element.getParent()) and\ + element.getName()==ancestors[-1]: return 1 + else: return 0 class MenuListener( java.awt.event.ActionListener ): Index: SP-Configuration.xml =================================================================== RCS file: /cvsroot/spedit/prototype/Support/SP-Configuration.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SP-Configuration.xml 2001/11/21 11:02:31 1.1 --- SP-Configuration.xml 2001/11/28 13:12:58 1.2 *************** *** 19,23 **** Creation date : 20-Nov-2001 ! Last revision : 21-Sep-2001 Revision : 0.5 History : --- 19,23 ---- Creation date : 20-Nov-2001 ! Last revision : 20-Nov-2001 Revision : 0.5 History : *************** *** 116,119 **** --- 116,124 ---- <element name='swissprot'> <Style> + <Font> + <name string="Palatino"/> + <type string="plain"/> + <size int="12"/> + </Font> <Title> <content string="SwissProt - Protein editing interface"/> *************** *** 123,126 **** --- 128,134 ---- <size int="26"/> </Font> + <Padding> + <left int="150"/> + </Padding> </Title> <Padding> *************** *** 139,142 **** --- 147,157 ---- <element name='entry'> + <Style> + <Padding> + <stick string="attributes.lower-left"/> + <padding int="10"/> + </Padding> + <Attributes><display string="spml.EntryDisplay"/></Attributes> + </Style> <Views> <use name="block"/> *************** *** 155,159 **** --- 170,183 ---- <Style> <inherit from="contentItem"/> + <Padding> + <stick string="attributes.upper-right"/> + </Padding> <Title><content string="Protein name"/></Title> + <Attributes> + <display string="spml.ProteinNameDisplay"/> + <Padding> + <left int="70"/> + </Padding> + </Attributes> </Style> <Views><use name="label"/></Views> *************** *** 261,264 **** --- 285,293 ---- <element name='author'> + <Style> + <Attributes> + <display string="spml.AuthorDisplay"/> + </Attributes> + </Style> <Views><use name="label"/></Views> </element> *************** *** 273,283 **** --- 302,329 ---- </element> + <element name='published/comments/comment'> + <Style> + <inherit from="listItem"/> + <Title><content string="COMMENTS/COMMENT"/></Title> + </Style> + <Views><use name="paragraph"/></Views> + </element> + <element name='comment'> <Style> <inherit from="listItem"/> + <Title><content string="COMMENT"/></Title> </Style> <Views><use name="paragraph"/></Views> </element> + <element name='dbreference'> + <Style> + <inherit from="listItem"/> + <Attributes><display string="net.sourceforge.spedit.spml.DataBaseDisplay"/></Attributes> + </Style> + <Views><use name="label"/></Views> + </element> + </Document> |
|
From: S?bastien P. <kaz...@us...> - 2001-11-28 13:11:38
|
Update of /cvsroot/spedit/prototype/Execution/Scripts In directory usw-pr-cvs1:/tmp/cvs-serv1329/Scripts Added Files: SPML.py Log Message: SPML Jython extensions to SPEedit. --- NEW FILE: SPML.py --- # --------------------------------------------------@RisingSun//Jython//1.0//EN # Module : SPML # Version : 0.00 # Type : SPEdit Extensions # ThreadSafe : - # Description : A set of extensions classes for the SP-ML format. # URL : <http://spedit.sf.net> # ----------------------------------------------------------------------------- # Author : spierre <sp...@is...> # ----------------------------------------------------------------------------- # Creation date : 22-Nov-2001 # Last mod. : 22-Nov-2001 # History : # 22-Nov-2001 First implementation. # # Bugs : # - # # To do : # - import java, javax import net.sourceforge.spedit from net.sourceforge.spedit.ui import XmFormLayout #------------------------------------------------------------------------------ # # Entry display # #------------------------------------------------------------------------------ class EntryDisplay(net.sourceforge.spedit.ui.AttributesDisplay): """Display an <entry> element attributes""" def __init__( self, element, view ): """Default AttributesDisplay constructor""" net.sourceforge.spedit.ui.AttributesDisplay.__init__(self,element,view) self.setLayout(java.awt.GridLayout(6,2)) self.add(javax.swing.JLabel("Name")) self.add(javax.swing.JTextField("Hello world")) self.add(javax.swing.JLabel("A.N.")) self.add(javax.swing.JTextField("Hello world")) self.add(javax.swing.JLabel("Status")) self.add(javax.swing.JTextField("Hello world")) self.add(javax.swing.JLabel("Database")) self.add(javax.swing.JTextField("Hello world")) self.add(javax.swing.JLabel("First public")) self.add(javax.swing.JTextField("Hello world")) self.add(javax.swing.JLabel("Last update")) self.add(javax.swing.JTextField("Hello world")) #------------------------------------------------------------------------------ # # Protein name display # #------------------------------------------------------------------------------ class ProteinNameDisplay(net.sourceforge.spedit.ui.AttributesDisplay): """Display an <proteinName> element attributes""" def __init__( self, element, view ): """Default AttributesDisplay constructor""" net.sourceforge.spedit.ui.AttributesDisplay.__init__(self,element,view) self.setLayout(java.awt.FlowLayout()) self.add(javax.swing.JLabel("e.c.")) self.add(javax.swing.JTextField("###")) #------------------------------------------------------------------------------ # # Author display # #------------------------------------------------------------------------------ class AuthorDisplay(net.sourceforge.spedit.ui.AttributesDisplay): """Display an <author> element attributes""" def __init__( self, element, view ): """Default AttributesDisplay constructor""" net.sourceforge.spedit.ui.AttributesDisplay.__init__(self,element,view) #We create the AttributesDisplay content self.setLayout(java.awt.FlowLayout()) self.add(javax.swing.JLabel("name")) self.add(javax.swing.JLabel("surname")) # EOF-Linux/ASCII-----------------------------------@RisingSun//Jython//1.0//EN |
|
From: S?bastien P. <kaz...@us...> - 2001-11-28 13:10:31
|
Update of /cvsroot/spedit/prototype/Execution/Scripts In directory usw-pr-cvs1:/tmp/cvs-serv1214/Scripts Log Message: Directory /cvsroot/spedit/prototype/Execution/Scripts added to the repository |
|
From: S?bastien P. <kaz...@us...> - 2001-11-28 13:10:18
|
Update of /cvsroot/spedit/prototype/Execution In directory usw-pr-cvs1:/tmp/cvs-serv1167/Execution Log Message: Directory /cvsroot/spedit/prototype/Execution added to the repository |
|
From: S?bastien P. <kaz...@us...> - 2001-11-27 10:31:45
|
Update of /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/ui
In directory usw-pr-cvs1:/tmp/cvs-serv25172/sourceforge/spedit/ui
Modified Files:
AttributesDisplay.java BlockView.java LabelView.java
ParagraphView.java WrapperView.java
Removed Files:
TableView.java
Log Message:
Apart from the new SPML package many improvements have been done both
to the StyleSheet and to the Views. There is now a basic layout management
in the Views using the "stick" element of Padding style properties groups
in XSS.
One of the interesting aspect is the Pool class that gathers resources
allowing the editor to dynamically manage resources. This is particulary
useful for images/icons.
Index: AttributesDisplay.java
===================================================================
RCS file: /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/ui/AttributesDisplay.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** AttributesDisplay.java 2001/11/21 11:02:04 1.2
--- AttributesDisplay.java 2001/11/27 10:31:41 1.3
***************
*** 3,7 ****
// Module : GUI-Views
// ClassName : AttributesDisplay
! // Version : 0.50
// Type :
//
--- 3,7 ----
// Module : GUI-Views
// ClassName : AttributesDisplay
! // Version : 0.90
// Type :
//
***************
*** 14,19 ****
// ----------------------------------------------------------------------------
// Creation date : 13-Nov-2001
! // Last mod. : 13-Nov-2001
// History :
// 13-Nov-2001 First implementation.(sp)
//
--- 14,22 ----
// ----------------------------------------------------------------------------
// Creation date : 13-Nov-2001
! // Last mod. : 21-Nov-2001
// History :
+ // 21-Nov-2001 Much cleaner for sublacssing, only displays
+ // children so display intergrated well with the
+ // WrapperView, imprtoved documentation.(sp)
// 13-Nov-2001 First implementation.(sp)
//
***************
*** 41,44 ****
--- 44,53 ----
* subclass <code>AttributesDisplay</code> and adapt it to your needs. By default
* it will display a table with the different attributes.</p>
+ *
+ * <p>Each <code>AttributesDisplay</code> has a reference to both the containing
+ * view and thre reprensented element (in Swing sense). This allows the attributes
+ * display to reach the style information located in the represented element.
+ * Note that at instanciation time of the attributes display the element has
+ * already an initialized stylesheet.</p>
*/
public class AttributesDisplay extends JPanel
***************
*** 46,57 ****
// PROTECTED_______________________________________________________________
! protected JTable table;
! protected AttributesModel model;
! protected WrapperView view;
!
! protected int xOffset=0;
! protected int yOffset=0;
! protected int xSize=0;
! protected int ySize=0;
//-------------------------------------------------------------------------
--- 55,60 ----
// PROTECTED_______________________________________________________________
! protected WrapperView view;
! protected XMLElementWrapper element;
//-------------------------------------------------------------------------
***************
*** 68,108 ****
{
super();
- this.model = new AttributesModel(element);
- this.table = new JTable(model);
this.view = view;
! add(table);
}
! public void paint(Graphics g)
{
! //System.out.println("Repaiting "+model.element.getName());
! paintChildren(g);
}
! /**
! * The offset is used to translate the graphics to paint the component
! * at the right location. This is allow to move the component without having
! * to relayout everythin, thus gaining precious time in the repaint mechanism.
! * @param The offset on the X axis in pixels
! * @param The offset on the Y axis in pixels
! */
! public void setOffset(int x, int y)
{
! this.xOffset = x;
! this.yOffset = y;
}
- /**
- * This <code>setSize</code> redefinition does nothing if the size has not
- * been changed.
- * NOTE: THIS MAY NOT BE REQUIRED, SHOULD HAVE A LOOK INSIDE COMPONENT
-
- public void setBounds(int x, int y, int w, int h)
- {
- if ( x!=xOffset || y!=yOffset || w!=xSize || h!=ySize )
- { super.setBounds(x,y,w,h); xOffset=x ; yOffset=y ; xSize=w ; ySize=h ; }
- }*/
-
-
//-------------------------------------------------------------------------
//
--- 71,91 ----
{
super();
this.view = view;
! this.element = element;
! setFont(view.getStyleSheet().font);
! init();
}
! protected void init()
{
! add(new JTable(new AttributesModel(element)));
}
! public void paint(Graphics g)
{
! //System.out.println("Repaiting "+model.element.getName());
! paintChildren(g);
}
//-------------------------------------------------------------------------
//
***************
*** 118,122 ****
{
public final boolean HORIZONTAL=true;
! public final boolean VERTICAL=true;
protected XMLElementWrapper element;
protected boolean orientation=HORIZONTAL;
--- 101,105 ----
{
public final boolean HORIZONTAL=true;
! public final boolean VERTICAL=false;
protected XMLElementWrapper element;
protected boolean orientation=HORIZONTAL;
Index: BlockView.java
===================================================================
RCS file: /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/ui/BlockView.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** BlockView.java 2001/11/01 15:41:43 1.1
--- BlockView.java 2001/11/27 10:31:41 1.2
***************
*** 3,7 ****
// Module : GUI-Views
// ClassName : BlockView
! // Version : 0.08
// Type :
//
--- 3,7 ----
// Module : GUI-Views
// ClassName : BlockView
! // Version : 0.80
// Type :
//
***************
*** 14,19 ****
// ----------------------------------------------------------------------------
// Creation date : 27-Sep-2001
! // Last mod. : 27-Sep-2001
// History :
// 27-Sep-2001 First implementation. (SP)
//
--- 14,20 ----
// ----------------------------------------------------------------------------
// Creation date : 27-Sep-2001
! // Last mod. : 27-Nov-2001
// History :
+ // 27-Nov-2001 Updated inset accession.(sp)
// 27-Sep-2001 First implementation. (SP)
//
***************
*** 86,144 ****
//-------------------------------------------------------------------------
- /**
- * Transforms the given shape that corresponds to the container view to
- * the destination view.
- */
- protected Shape adjustC2V(Shape shape)
- {
- Rectangle2D bounds = (Rectangle2D)shape.getBounds();
- double x = bounds.getX()+styleSheet.paddingLeft;
- double y = bounds.getY()+styleSheet.paddingTop;
- double w = bounds.getWidth();
- double h = bounds.getHeight();
- bounds.setRect(x,y,w,h);
- return bounds;
- }
-
- /**
- * Transforms the given shape that corresponds to the container view to
- * the destination view.
- */
- protected Shape adjustV2C(Shape shape)
- {
- Rectangle2D bounds = (Rectangle2D)shape.getBounds();
- double x = bounds.getX()-styleSheet.paddingLeft;
- double y = bounds.getY()-styleSheet.paddingTop;
- double w = bounds.getWidth();
- double h = bounds.getHeight();
- bounds.setRect(x,y,w,h);
- return bounds;
- }
- public int viewToModel(float x, float y, Shape a)
- { return super.viewToModel(x-styleSheet.paddingLeft,y-styleSheet.paddingTop,a); }
-
- public int viewToModel(float x, float y, Shape a, Position.Bias[] biasReturn)
- { return super.viewToModel(x-styleSheet.paddingLeft,y-styleSheet.paddingTop,a,biasReturn); }
-
- public Shape modelToView(int p0, Position.Bias b0, int p1, Position.Bias b1, Shape a)
- throws BadLocationException
- {
- Rectangle2D shape = (Rectangle2D) super.modelToView(p0,b0,p1,b1,a);
- return adjustC2V(shape);
- }
-
- public Shape modelToView(int pos, Shape a)
- throws BadLocationException
- {
- Rectangle2D shape = (Rectangle2D) super.modelToView(pos,a);
- return adjustC2V(shape);
- }
-
- public Shape modelToView(int pos, Shape a, Position.Bias b)
- throws BadLocationException
- {
- Rectangle2D shape = (Rectangle2D) super.modelToView(pos,a,b);
- return adjustC2V(shape);
- }
//-------------------------------------------------------------------------
//
--- 87,90 ----
***************
*** 148,161 ****
public short getLeftInset()
! { return styleSheet.paddingLeft; }
public short getTopInset()
! { return styleSheet.paddingTop; }
public short getBottomInset()
! { return styleSheet.paddingBottom; }
public short getRightInset()
! { return styleSheet.paddingRight; }
public float getAlignment(int axis)
--- 94,107 ----
public short getLeftInset()
! { return WrapperView.getLeftInset(styleSheet);}
public short getTopInset()
! { return WrapperView.getTopInset(styleSheet); }
public short getBottomInset()
! { return WrapperView.getBottomInset(styleSheet); }
public short getRightInset()
! { return WrapperView.getRightInset(styleSheet); }
public float getAlignment(int axis)
Index: LabelView.java
===================================================================
RCS file: /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/ui/LabelView.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** LabelView.java 2001/11/15 10:49:43 1.2
--- LabelView.java 2001/11/27 10:31:41 1.3
***************
*** 3,7 ****
// Module : GUI-Views
// ClassName : BlockView
! // Version : 0.08
// Type :
//
--- 3,7 ----
// Module : GUI-Views
// ClassName : BlockView
! // Version : 0.80
// Type :
//
***************
*** 14,19 ****
// ----------------------------------------------------------------------------
// Creation date : 27-Sep-2001
! // Last mod. : 07-Nov-2001
// History :
// 07-Nov-2001 Fixed selcetion problem. The solution was
// to copy the sourcecode from the JDK 1.3.1 and modify
--- 14,20 ----
// ----------------------------------------------------------------------------
// Creation date : 27-Sep-2001
! // Last mod. : 27-Nov-2001
// History :
+ // 27-Nov-2001 Updated inset accession.(sp)
// 07-Nov-2001 Fixed selcetion problem. The solution was
// to copy the sourcecode from the JDK 1.3.1 and modify
***************
*** 88,92 ****
int p1 = getEndOffset();
Rectangle alloc = (bounds instanceof Rectangle) ? (Rectangle)bounds : bounds.getBounds();
! Shape adjusted = adjustC2V(bounds);
Color bg = getBackground();
Color fg = getForeground();
--- 89,93 ----
int p1 = getEndOffset();
Rectangle alloc = (bounds instanceof Rectangle) ? (Rectangle)bounds : bounds.getBounds();
! Shape adjusted = WrapperView.translateNestedToView(bounds, styleSheet);
Color bg = getBackground();
Color fg = getForeground();
***************
*** 103,107 ****
{
((LayeredHighlighter)h).paintLayeredHighlights
! (g, p0, p1, adjustV2C(bounds), tc, this);
}
}
--- 104,108 ----
{
((LayeredHighlighter)h).paintLayeredHighlights
! (g, p0, p1, WrapperView.translateViewToNested(bounds, styleSheet), tc, this);
}
}
***************
*** 171,235 ****
//-------------------------------------------------------------------------
//
! // Model-View
//
//-------------------------------------------------------------------------
/**
- * Transforms the given shape that corresponds to the container view to
- * the destination view.
- */
- protected Shape adjustC2V(Shape shape)
- {
- Rectangle2D bounds = (Rectangle2D)shape.getBounds();
- double x = bounds.getX()+styleSheet.paddingLeft;
- double y = bounds.getY()+styleSheet.paddingTop;
- double w = bounds.getWidth();
- double h = bounds.getHeight();
- bounds.setRect(x,y,w,h);
- return bounds;
- }
-
- /**
- * Transforms the given shape that corresponds to the container view to
- * the destination view.
- */
- protected Shape adjustV2C(Shape shape)
- {
- Rectangle2D bounds = (Rectangle2D)shape.getBounds();
- double x = bounds.getX()-styleSheet.paddingLeft;
- double y = bounds.getY()-styleSheet.paddingTop;
- double w = bounds.getWidth();
- double h = bounds.getHeight();
- bounds.setRect(x,y,w,h);
- return bounds;
- }
- public int viewToModel(float x, float y, Shape a)
- { return super.viewToModel(x-styleSheet.paddingLeft,y-styleSheet.paddingTop,a); }
-
- public int viewToModel(float x, float y, Shape a, Position.Bias[] biasReturn)
- { return super.viewToModel(x-styleSheet.paddingLeft,y-styleSheet.paddingTop,a,biasReturn); }
-
- public Shape modelToView(int p0, Position.Bias b0, int p1, Position.Bias b1, Shape a)
- throws BadLocationException
- {
- Rectangle2D shape = (Rectangle2D) super.modelToView(p0,b0,p1,b1,a);
- return adjustC2V(shape);
- }
-
- public Shape modelToView(int pos, Shape a)
- throws BadLocationException
- {
- Rectangle2D shape = (Rectangle2D) super.modelToView(pos,a);
- return adjustC2V(shape);
- }
-
- public Shape modelToView(int pos, Shape a, Position.Bias b)
- throws BadLocationException
- {
- Rectangle2D shape = (Rectangle2D) super.modelToView(pos,a,b);
- return adjustC2V(shape);
- }
-
- /**
* Fetch the background color to use to render the
* glyphs. If there is no background color, null should
--- 172,180 ----
//-------------------------------------------------------------------------
//
! // Style properties
//
//-------------------------------------------------------------------------
/**
* Fetch the background color to use to render the
* glyphs. If there is no background color, null should
***************
*** 311,324 ****
public short getLeftInset()
! { return styleSheet.paddingLeft; }
public short getTopInset()
! { return styleSheet.paddingTop; }
public short getBottomInset()
! { return styleSheet.paddingBottom; }
public short getRightInset()
! { return styleSheet.paddingRight; }
--- 256,269 ----
public short getLeftInset()
! { return WrapperView.getLeftInset(styleSheet);}
public short getTopInset()
! { return WrapperView.getTopInset(styleSheet); }
public short getBottomInset()
! { return WrapperView.getBottomInset(styleSheet); }
public short getRightInset()
! { return WrapperView.getRightInset(styleSheet); }
Index: ParagraphView.java
===================================================================
RCS file: /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/ui/ParagraphView.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** ParagraphView.java 2001/11/15 10:49:43 1.2
--- ParagraphView.java 2001/11/27 10:31:41 1.3
***************
*** 3,7 ****
// Module : GUI-Views
// ClassName : ParagraphView
! // Version : 0.08
// Type :
//
--- 3,7 ----
// Module : GUI-Views
// ClassName : ParagraphView
! // Version : 0.80
// Type :
//
***************
*** 11,20 ****
// URL : <http://SPEdit.sourceforge.net>
// ----------------------------------------------------------------------------
! // Authors : Sebastien Pierre <sp...@is...>
// ----------------------------------------------------------------------------
// Creation date : 27-Sep-2001
! // Last mod. : 27-Sep-2001
// History :
! // 27-Sep-2001 First implementation. (SP)
//
// Notes :
--- 11,21 ----
// URL : <http://SPEdit.sourceforge.net>
// ----------------------------------------------------------------------------
! // Authors : Sbastien Pierre <sp...@is...>
// ----------------------------------------------------------------------------
// Creation date : 27-Sep-2001
! // Last mod. : 27-Nov-2001
// History :
! // 27-Nov-2001 Updated inset accession.(sp)
! // 27-Sep-2001 First implementation. (sp)
//
// Notes :
***************
*** 84,142 ****
//-------------------------------------------------------------------------
- /**
- * Transforms the given shape that corresponds to the container view to
- * the destination view.
- */
- protected Shape adjustC2V(Shape shape)
- {
- Rectangle2D bounds = (Rectangle2D)shape.getBounds();
- double x = bounds.getX()+styleSheet.paddingLeft;
- double y = bounds.getY()+styleSheet.paddingTop;
- double w = bounds.getWidth();
- double h = bounds.getHeight();
- bounds.setRect(x,y,w,h);
- return bounds;
- }
-
- /**
- * Transforms the given shape that corresponds to the container view to
- * the destination view.
- */
- protected Shape adjustV2C(Shape shape)
- {
- Rectangle2D bounds = (Rectangle2D)shape.getBounds();
- double x = bounds.getX()-styleSheet.paddingLeft;
- double y = bounds.getY()-styleSheet.paddingTop;
- double w = bounds.getWidth();
- double h = bounds.getHeight();
- bounds.setRect(x,y,w,h);
- return bounds;
- }
- public int viewToModel(float x, float y, Shape a)
- { return super.viewToModel(x-styleSheet.paddingLeft,y-styleSheet.paddingTop,a); }
-
- public int viewToModel(float x, float y, Shape a, Position.Bias[] biasReturn)
- { return super.viewToModel(x-styleSheet.paddingLeft,y-styleSheet.paddingTop,a,biasReturn); }
-
- public Shape modelToView(int p0, Position.Bias b0, int p1, Position.Bias b1, Shape a)
- throws BadLocationException
- {
- Rectangle2D shape = (Rectangle2D) super.modelToView(p0,b0,p1,b1,a);
- return adjustC2V(shape);
- }
-
- public Shape modelToView(int pos, Shape a)
- throws BadLocationException
- {
- Rectangle2D shape = (Rectangle2D) super.modelToView(pos,a);
- return adjustC2V(shape);
- }
-
- public Shape modelToView(int pos, Shape a, Position.Bias b)
- throws BadLocationException
- {
- Rectangle2D shape = (Rectangle2D) super.modelToView(pos,a,b);
- return adjustC2V(shape);
- }
//-------------------------------------------------------------------------
//
--- 85,88 ----
***************
*** 144,159 ****
//
//-------------------------------------------------------------------------
!
public short getLeftInset()
! { return styleSheet.paddingLeft; }
public short getTopInset()
! { return styleSheet.paddingTop; }
public short getBottomInset()
! { return styleSheet.paddingBottom; }
public short getRightInset()
! { return styleSheet.paddingRight; }
public float getAlignment(int axis)
--- 90,105 ----
//
//-------------------------------------------------------------------------
!
public short getLeftInset()
! { return WrapperView.getLeftInset(styleSheet);}
public short getTopInset()
! { return WrapperView.getTopInset(styleSheet); }
public short getBottomInset()
! { return WrapperView.getBottomInset(styleSheet); }
public short getRightInset()
! { return WrapperView.getRightInset(styleSheet); }
public float getAlignment(int axis)
Index: WrapperView.java
===================================================================
RCS file: /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/ui/WrapperView.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** WrapperView.java 2001/11/21 11:02:04 1.4
--- WrapperView.java 2001/11/27 10:31:41 1.5
***************
*** 1,8 ****
// ---------------------------------------------------@RisingSun//Java//1.0//EN
! // Project : SPEdit-Prototypes
// Module : GUI-Views
// ClassName : BlockView
! // Version : 0.50
! // Type :
//
// ThreadSafe : Nope
--- 1,8 ----
// ---------------------------------------------------@RisingSun//Java//1.0//EN
! // Project : SPEdit
// Module : GUI-Views
// ClassName : BlockView
! // Version : 0.80
! // Type : View extension wrapper
//
// ThreadSafe : Nope
***************
*** 14,19 ****
// ----------------------------------------------------------------------------
// Creation date : 19-Oct-2001
! // Last mod. : 19-Nov-2001
// History :
// 19-Nov-2001 Prelimiary sluggish AttributesDisplay
// implementation.(sp)
--- 14,23 ----
// ----------------------------------------------------------------------------
// Creation date : 19-Oct-2001
! // Last mod. : 27-Nov-2001
// History :
+ // 27-Nov-2001 Added inset utility methods.(sp)
+ // 22-Nov-2001 Enable Python environment introspection
+ // when assigning attributesDisplay in setParent.(sp)
+ // 21-Nov-2001 Support for the newlyCreated flag.(sp)
// 19-Nov-2001 Prelimiary sluggish AttributesDisplay
// implementation.(sp)
***************
*** 42,49 ****
--- 46,55 ----
import java.util.*;
import java.text.*;
+ import org.python.util.*;
import javax.swing.text.*;
import javax.swing.event.*;
import javax.swing.ImageIcon;
import net.sourceforge.spedit.core.*;
+ import net.sourceforge.spedit.app.*;
//-----------------------------------------------------------------------------
***************
*** 68,75 ****
// PUBLIC__________________________________________________________________
// PROTECTED_______________________________________________________________
protected View nested;
- protected AttributesDisplay attributesDisplay;
protected String nestedName;
--- 74,82 ----
// PUBLIC__________________________________________________________________
+ public static int MIN_HEIGHT = 10;
+
// PROTECTED_______________________________________________________________
protected View nested;
protected String nestedName;
***************
*** 128,142 ****
protected void init()
{
- //XMLElementWrapper is the only one that has attributes
- if ( element instanceof XMLElementWrapper )
- {
- if ( ((XMLElementWrapper)element).getXMLElement().getAttributes().size()>0 )
- { attributesDisplay = new AttributesDisplay((XMLElementWrapper)element, this); }
- else
- { attributesDisplay = null; }
- }
- else
- { attributesDisplay = null; }
styleSheet = new StyleSheet("empty", this);
}
--- 135,140 ----
protected void init()
{
styleSheet = new StyleSheet("empty", this);
+ styleSheet.attributesDisplay = null;
}
***************
*** 146,151 ****
protected void finalize() throws Throwable
{
! if (attributesDisplay!=null && getContainer()!=null)
! { getContainer().remove(attributesDisplay); }
}
--- 144,149 ----
protected void finalize() throws Throwable
{
! if (styleSheet.attributesDisplay!=null && getContainer()!=null)
! { getContainer().remove(styleSheet.attributesDisplay); }
}
***************
*** 166,172 ****
Rectangle2D r = (Rectangle2D)s.getBounds();
! if ( getStartOffset()>=getEndOffset()-1 )
! { g.setColor(new Color(200,200,150));
! gg.fill(r); }
//We udpate the view bounds
--- 164,171 ----
Rectangle2D r = (Rectangle2D)s.getBounds();
! //This will store the title bounds in case of "stick" padding property
! int title_ul=0, title_ur=0, title_ll=0, title_lr=0;
! //Attributes display bounds, same rore as title bounds.
! int attributes_ul=0, attributes_ur=0, attributes_ll=0, attributes_lr=0;
//We udpate the view bounds
***************
*** 174,181 ****
{ viewBounds=r; refreshBounds=false; }
- //We paint the nested view
- if (!collapsed)
- { nested.paint(g,s); }
-
//And we draw the wrapper attributes
if (selected)
--- 173,176 ----
***************
*** 185,193 ****
}
if (focused)
{
! g.setColor(Color.pink);
gg.draw(r);
! }
//We draw the border
--- 180,196 ----
}
+ //We draw the focus highlight
if (focused)
{
! g.setColor(Color.blue);
gg.draw(r);
! }
!
! //We paint a specific color if the element has been newly created
! if (((XMLNode)element).hasInformation() && ((XMLNode)element).getInformation().isNewlyCreated() )
! {
! g.setColor(new Color(240,200,150));
! gg.fill(r);
! }
//We draw the border
***************
*** 204,207 ****
--- 207,211 ----
if ( isCollapsed() )
{
+ //We draw the collapsed expander in case it has been defined in the stylesheet
if ( styleSheet.hasExpander )
{
***************
*** 214,219 ****
(int)(r.getY()+12+(r.getHeight()-12)/2));
//We hide the attributes display
! if (attributesDisplay!=null)
! { attributesDisplay.setVisible(false); }
}
//If the view is expanded
--- 218,223 ----
(int)(r.getY()+12+(r.getHeight()-12)/2));
//We hide the attributes display
! if (styleSheet.attributesDisplay!=null)
! { styleSheet.attributesDisplay.setVisible(false); }
}
//If the view is expanded
***************
*** 221,227 ****
{
//We make sure that the attributesDisplay is visible
! if (attributesDisplay!=null && attributesDisplay.getParent()!=null)
! { attributesDisplay.setVisible(true); }
if ( styleSheet.hasExpander )
{
--- 225,232 ----
{
//We make sure that the attributesDisplay is visible
! if (styleSheet.attributesDisplay!=null && styleSheet.attributesDisplay.getParent()!=null)
! { styleSheet.attributesDisplay.setVisible(true); }
+ //We draw the expander
if ( styleSheet.hasExpander )
{
***************
*** 229,232 ****
--- 234,238 ----
}
+ //We draw the title
if ( styleSheet.title!=null )
{
***************
*** 237,255 ****
(int)r.getY()+styleSheet.titlePaddingTop+styleSheet.titleFont.getSize());
}
}
//We take care of the attributes display
! if ( attributesDisplay!=null )
{
! if (attributesDisplay.getParent()==null && getContainer()!=null)
! { getContainer().add(attributesDisplay); }
Rectangle2D bounds = getBounds();
! Dimension psize = attributesDisplay.getPreferredSize();
! attributesDisplay.setOffset((int)bounds.getX(), (int)bounds.getY());
! attributesDisplay.setSize((int)psize.getWidth(), (int)psize.getHeight());
! attributesDisplay.setBounds((int)bounds.getX(), (int)bounds.getY(),
(int)psize.getWidth(), (int)psize.getHeight());
- //attributesDisplay.repaint();
}
}
--- 243,267 ----
(int)r.getY()+styleSheet.titlePaddingTop+styleSheet.titleFont.getSize());
}
+ //We draw the nested view
+ nested.paint(g,s);
}
//We take care of the attributes display
! if ( styleSheet.attributesDisplay!=null )
{
! if (styleSheet.attributesDisplay.getParent()==null && getContainer()!=null)
! { getContainer().add(styleSheet.attributesDisplay); }
Rectangle2D bounds = getBounds();
! Dimension psize = styleSheet.attributesDisplay.getPreferredSize();
! styleSheet.attributesDisplay.setBounds((int)bounds.getX(), (int)bounds.getY(),
(int)psize.getWidth(), (int)psize.getHeight());
}
+
+ if ( getContainer()!=null && styleSheet.title!=null && styleSheet.titleWidth==-1 )
+ {
+ FontMetrics metrics = g.getFontMetrics(styleSheet.titleFont);
+ styleSheet.titleWidth = metrics.stringWidth(styleSheet.title);
+ styleSheet.titleHeight = metrics.getHeight();
+ }
}
***************
*** 467,487 ****
//-------------------------------------------------------------------------
public int viewToModel(float x, float y, Shape a)
! { return nested.viewToModel(x,y, a); }
public int viewToModel(float x, float y, Shape a, Position.Bias[] biasReturn)
! { return nested.viewToModel(x,y,a,biasReturn); }
public Shape modelToView(int p0, Position.Bias b0, int p1, Position.Bias b1, Shape a)
throws BadLocationException
! { return nested.modelToView(p0,b0,p1,b1,a); }
public Shape modelToView(int pos, Shape a)
throws BadLocationException
! { return nested.modelToView(pos,a); }
public Shape modelToView(int pos, Shape a, Position.Bias b)
throws BadLocationException
! { return nested.modelToView(pos,a,b); }
//-------------------------------------------------------------------------
--- 479,544 ----
//-------------------------------------------------------------------------
+ /**
+ * Transforms the given shape that corresponds to the container view to
+ * the destination view.
+ */
+ public static Shape translateNestedToView(Shape shape, Styleable.StyleSheet styleSheet)
+ {
+ Rectangle2D bounds = (Rectangle2D)shape.getBounds();
+ double x = bounds.getX()+getLeftInset(styleSheet);
+ double y = bounds.getY()+getTopInset(styleSheet);
+ double w = bounds.getWidth();
+ double h = bounds.getHeight();
+ bounds.setRect(x,y,w,h);
+ return bounds;
+ }
+
+ /**
+ * Transforms the given shape that corresponds to the container view to
+ * the destination view.
+ */
+ public static Shape translateViewToNested(Shape shape, Styleable.StyleSheet styleSheet)
+ {
+ Rectangle2D bounds = (Rectangle2D)shape.getBounds();
+ double x = bounds.getX()-getLeftInset(styleSheet);
+ double y = bounds.getY()-getTopInset(styleSheet);
+ double w = bounds.getWidth();
+ double h = bounds.getHeight();
+ bounds.setRect(x,y,w,h);
+ return bounds;
+ }
+
public int viewToModel(float x, float y, Shape a)
! {
! return nested.viewToModel(x-getLeftInset(styleSheet),
! y-getTopInset(styleSheet),a);
! }
public int viewToModel(float x, float y, Shape a, Position.Bias[] biasReturn)
! {
! return nested.viewToModel(x-getLeftInset(styleSheet),
! y-getTopInset(styleSheet),a,biasReturn);
! }
public Shape modelToView(int p0, Position.Bias b0, int p1, Position.Bias b1, Shape a)
throws BadLocationException
! {
! Rectangle2D shape = (Rectangle2D) nested.modelToView(p0,b0,p1,b1,a);
! return translateNestedToView(shape, styleSheet);
! }
public Shape modelToView(int pos, Shape a)
throws BadLocationException
! {
! Rectangle2D shape = (Rectangle2D) nested.modelToView(pos,a);
! return translateNestedToView(shape, styleSheet);
! }
public Shape modelToView(int pos, Shape a, Position.Bias b)
throws BadLocationException
! {
! Rectangle2D shape = (Rectangle2D) nested.modelToView(pos,a,b);
! return translateNestedToView(shape, styleSheet);
! }
//-------------------------------------------------------------------------
***************
*** 493,524 ****
public float getPreferredSpan(int axis)
{
//We check wether the wrapper view is collapsed or not
if (!collapsed)
{
! if (axis==View.X_AXIS)
! {
! if ( attributesDisplay!=null )
! {
! float span = (float)nested.getPreferredSpan(axis);
! return Math.max(span,
! (float)attributesDisplay.getPreferredSize().getWidth());
! }
! else
! {
! return nested.getPreferredSpan(axis);
! }
! }
! else
! {
! if ( attributesDisplay!=null )
! {
! float span = (float)nested.getPreferredSpan(axis);
! return Math.max(span,
! (float)attributesDisplay.getPreferredSize().getHeight());
! }
! else
! {
! return nested.getPreferredSpan(axis);
! }
}
}
--- 550,563 ----
public float getPreferredSpan(int axis)
{
+ float result;
//We check wether the wrapper view is collapsed or not
if (!collapsed)
{
! result = (float)nested.getPreferredSpan(axis);
! if (styleSheet.attributesDisplay!=null)
! {
! Dimension size = styleSheet.attributesDisplay.getPreferredSize();
! if (axis==View.X_AXIS) { result=Math.max(result,(float)size.getWidth()); }
! else { result=Math.max(result,(float)size.getHeight()); }
}
}
***************
*** 527,566 ****
{
if (axis==View.X_AXIS)
! { return nested.getPreferredSpan(axis); }
else
! { return Math.max(10,styleSheet.paddingTop+styleSheet.paddingBottom); }
}
}
public float getMinimumSpan(int axis)
{
//We check wether the wrapper view is collapsed or not
if (!collapsed)
{
! if (axis==View.X_AXIS)
! {
! if ( attributesDisplay!=null )
! {
! float span = (float)nested.getMinimumSpan(axis);
! return Math.max(span,
! (float)attributesDisplay.getMinimumSize().getWidth());
! }
! else
! {
! return nested.getMinimumSpan(axis);
! }
! }
! else
! {
! if ( attributesDisplay!=null )
! {
! float span = (float)nested.getMinimumSpan(axis);
! return Math.max(span,
! (float)attributesDisplay.getMinimumSize().getHeight());
! }
! else
! {
! return nested.getMinimumSpan(axis);
! }
}
}
--- 566,589 ----
{
if (axis==View.X_AXIS)
! { result = nested.getPreferredSpan(axis); }
else
! { result = styleSheet.paddingTop+styleSheet.paddingBottom; }
}
+ //We make sure the view is not less than 10x10 pixels.
+ return Math.max(MIN_HEIGHT,result);
}
public float getMinimumSpan(int axis)
{
+ float result;
//We check wether the wrapper view is collapsed or not
if (!collapsed)
{
! result = (float)nested.getMinimumSpan(axis);
! if (styleSheet.attributesDisplay!=null)
! {
! Dimension size = styleSheet.attributesDisplay.getPreferredSize();
! if (axis==View.X_AXIS) { result=Math.max(result,(float)size.getWidth()); }
! else { result=Math.max(result,(float)size.getHeight()); }
}
}
***************
*** 569,611 ****
{
if (axis==View.X_AXIS)
! { return nested.getMinimumSpan(axis); }
else
! { return Math.max(10,styleSheet.paddingTop+styleSheet.paddingBottom); }
}
}
public float getMaximumSpan(int axis)
{
! if ( getStartOffset()>=getEndOffset()-1 )
! { return 10; }
!
//We check wether the wrapper view is collapsed or not
if (!collapsed)
{
! if (axis==View.X_AXIS)
! {
! if ( attributesDisplay!=null )
! {
! float span = (float)nested.getMaximumSpan(axis);
! return Math.max(span,
! (float)attributesDisplay.getMaximumSize().getWidth());
! }
! else
! {
! return nested.getMaximumSpan(axis);
! }
! }
! else
! {
! if ( attributesDisplay!=null )
! {
! float span = (float)nested.getMaximumSpan(axis);
! return Math.max(span,
! (float)attributesDisplay.getMaximumSize().getHeight());
! }
! else
! {
! return nested.getMaximumSpan(axis);
! }
}
}
--- 592,615 ----
{
if (axis==View.X_AXIS)
! { result = nested.getMinimumSpan(axis); }
else
! { result = styleSheet.paddingTop+styleSheet.paddingBottom; }
}
+ //We make sure the view is not less than 10x10 pixels.
+ return Math.max(MIN_HEIGHT,result);
}
public float getMaximumSpan(int axis)
{
! float result;
//We check wether the wrapper view is collapsed or not
if (!collapsed)
{
! result = (float)nested.getMaximumSpan(axis);
! if (styleSheet.attributesDisplay!=null)
! {
! Dimension size = styleSheet.attributesDisplay.getPreferredSize();
! if (axis==View.X_AXIS) { result=Math.max(result,(float)size.getWidth()); }
! else { result=Math.max(result,(float)size.getHeight()); }
}
}
***************
*** 614,621 ****
{
if (axis==View.X_AXIS)
! { return nested.getMaximumSpan(axis); }
else
! { return Math.max(15,styleSheet.paddingTop+styleSheet.paddingBottom); }
}
}
--- 618,627 ----
{
if (axis==View.X_AXIS)
! { result = nested.getMaximumSpan(axis); }
else
! { result = styleSheet.paddingTop+styleSheet.paddingBottom; }
}
+ //We make sure the view is not less than 10x10 pixels.
+ return Math.max(MIN_HEIGHT,result);
}
***************
*** 625,628 ****
--- 631,750 ----
//-------------------------------------------------------------------------
//
+ // Insets management
+ //
+ //-------------------------------------------------------------------------
+
+ /**
+ * This is a utility method that computes the insets of a given nested
+ * view according to the information found in the given StyleSheet.
+ * Any view that wants to be displayed correctly should use the values
+ * returned by this method.
+ * @param the stylesheet that contains the inset information.
+ * @return the left inset of this view as a short.
+ * @see #getRightInset
+ * @see #getTopInset
+ * @see #getBottomInset
+ */
+ public static short getLeftInset(Styleable.StyleSheet styleSheet)
+ {
+ //In case the view sticks to the title
+ if ( styleSheet.contentStick==Styleable.StyleSheet.TITLE_UL
+ || styleSheet.contentStick==Styleable.StyleSheet.TITLE_LL)
+ {
+ return (short)(styleSheet.titlePaddingLeft + styleSheet.paddingLeft);
+ }
+ else if ( styleSheet.contentStick==Styleable.StyleSheet.TITLE_UR
+ || styleSheet.contentStick==Styleable.StyleSheet.TITLE_LR )
+ {
+ return (short)(styleSheet.titlePaddingLeft + styleSheet.titleWidth+
+ styleSheet.titlePaddingBottom+styleSheet.paddingLeft);
+ }
+ //In case the view sticks to the attributes
+ else if ( styleSheet.attributesDisplay!=null &&
+ styleSheet.contentStick==Styleable.StyleSheet.ATTR_UL
+ || styleSheet.contentStick==Styleable.StyleSheet.ATTR_LL)
+ {
+ return (short)(styleSheet.attributesPaddingLeft + styleSheet.paddingLeft);
+ }
+ else if ( styleSheet.attributesDisplay!=null &&
+ styleSheet.contentStick==Styleable.StyleSheet.ATTR_UR
+ || styleSheet.contentStick==Styleable.StyleSheet.ATTR_LR )
+ {
+ return (short)(styleSheet.attributesPaddingLeft +
+ styleSheet.attributesDisplay.getPreferredSize().getHeight()+
+ styleSheet.attributesPaddingBottom+styleSheet.paddingLeft);
+ }
+ //Otherwise is does stick to the upper left corner of the view
+ else
+ { return styleSheet.paddingLeft; }
+ }
+
+ /**
+ * This is a utility method that computes the insets of a given nested
+ * view according to the information found in the given StyleSheet.
+ * Any view that wants to be displayed correctly should use the values
+ * returned by this method.
+ * @param the stylesheet that contains the inset information.
+ * @return the top inset of this view as a short.
+ * @see #getRightInset
+ * @see #getLeftInset
+ * @see #getBottomInset
+ */
+ public static short getTopInset(Styleable.StyleSheet styleSheet)
+ {
+ //In case the view sticks to a title
+ if ( styleSheet.contentStick==Styleable.StyleSheet.TITLE_LL
+ || styleSheet.contentStick==Styleable.StyleSheet.TITLE_LR )
+ {
+ return (short)(styleSheet.titlePaddingTop+styleSheet.titleHeight+
+ styleSheet.titlePaddingBottom+styleSheet.paddingTop);
+ }
+ //In case the view sticks to the attirutes
+ else if ( styleSheet.attributesDisplay!=null &&
+ styleSheet.contentStick==Styleable.StyleSheet.ATTR_LL
+ || styleSheet.contentStick==Styleable.StyleSheet.ATTR_LR )
+ {
+ return (short)(styleSheet.attributesPaddingTop+
+ styleSheet.attributesDisplay.getSize().getHeight()+
+ styleSheet.attributesPaddingBottom+styleSheet.paddingTop);
+ }
+ //Otherwise it sticks to the origin
+ else
+ {
+ return styleSheet.paddingTop;
+ }
+ }
+
+ /**
+ * This is a utility method that computes the insets of a given nested
+ * view according to the information found in the given StyleSheet.
+ * Any view that wants to be displayed correctly should use the values
+ * returned by this method.
+ * @param the stylesheet that contains the inset information.
+ * @return the bottom inset of this view as a short.
+ * @see #getRightInset
+ * @see #getLeftInset
+ * @see #getTopInset
+ */
+ public static short getBottomInset(Styleable.StyleSheet styleSheet)
+ { return styleSheet.paddingBottom; }
+
+ /**
+ * This is a utility method that computes the insets of a given nested
+ * view according to the information found in the given StyleSheet.
+ * Any view that wants to be displayed correctly should use the values
+ * returned by this method.
+ * @param the stylesheet that contains the inset information.
+ * @return the right inset of this view as a short.
+ * @see #getBottomInset
+ * @see #getLeftInset
+ * @see #getTopInset
+ */
+ public static short getRightInset(Styleable.StyleSheet styleSheet)
+ { return styleSheet.paddingRight; }
+
+
+ //-------------------------------------------------------------------------
+ //
// View management
//
***************
*** 645,648 ****
--- 767,779 ----
{ nested.replace(offset,length,views); }
+ /**
+ * <p>The <code>setParent</code> method plays quite a big role in the
+ * WrapperView. Is is strangely called very often by the Swing text
+ * display enginge (JTextComponent), in this respect this method has
+ * to be very fast.</p>
+ * <p>This basically creates the nested view and the attributes display
+ * if it has to. Most of the processing here is only done once, during
+ * the first binding of the <code>WrapperView</code>.
+ */
public void setParent(View parent)
{
***************
*** 666,676 ****
//This automatically updates the nested view stylesheet
if ( hasToUpdate )
! { setStyleSheet(styleSheet); hasToUpdate=false;}
if ( parent!=nested.getParent() )
! { nested.setParent(parent);}
! //if ( attributes!=null )
! //{ attributes.setParent(parent); attributes.getComponent().setSize(40,10); }
}
--- 797,858 ----
//This automatically updates the nested view stylesheet
if ( hasToUpdate )
! {
! setStyleSheet(styleSheet);
! hasToUpdate=false;
! }
if ( parent!=nested.getParent() )
! {
! nested.setParent(parent);
! }
! //XMLElementWrapper is the only one that has attributes
! if ( styleSheet.attributesDisplay==null && element instanceof XMLElementWrapper )
! {
!
! if ( ((XMLElementWrapper)element).getXMLElement().getAttributes().size()>0 )
! {
! Object style = styleSheet.getStyle("attributes.display");
! XMLElementWrapper wrapper = (XMLElementWrapper)element;
! if ( style!=null )
! {
! //We use reflection to create a new instance of the AttributesDisplay
! //subclass given by the <attributes.display> property.
! try
! {
! Class display = Class.forName(style.toString());
! Constructor constructor =
! display.getConstructor(new Class[] { XMLElementWrapper.class, WrapperView.class });
! styleSheet.attributesDisplay = (AttributesDisplay)constructor.newInstance(
! new Object[] { wrapper, this });
! }
! catch (Exception e)
! {
! //If the class has not been found in the Java environemnt, then we try to
! //load it from the python environment.
! Application.python.set("wrapper", wrapper);
! Application.python.set("view", this);
! Application.python.exec("new_instance = getInstance('"+style.toString()
! +"', (wrapper, view))");
! try
! {
! styleSheet.attributesDisplay =
! (AttributesDisplay)Application.python.get("new_instance", AttributesDisplay.class);
! }
! catch (NullPointerException ex)
! { System.err.println(ex); }
!
! if ( styleSheet.attributesDisplay == null )
! {
! System.err.println("Class <"+style.toString()+"> has not been found.");
! System.err.println(" -->"+e.toString());
! styleSheet.attributesDisplay = new AttributesDisplay(wrapper,this);
! }
! }
! }
! else
! { styleSheet.attributesDisplay = new AttributesDisplay(wrapper,this); }
! }
! }
}
***************
*** 772,776 ****
//-------------------------------------------------------------------------
//
! // StyleSheet
//
//-------------------------------------------------------------------------
--- 954,958 ----
//-------------------------------------------------------------------------
//
! // StyleSheet management
//
//-------------------------------------------------------------------------
***************
*** 789,792 ****
--- 971,976 ----
s.update();
}
+ if ( styleSheet.attributesDisplay!=null )
+ { styleSheet.attributesDisplay.setFont(s.font); }
}
***************
*** 826,853 ****
}
}
-
- public class Constrainer extends javax.swing.text.ComponentView
- {
-
- public Constrainer(Element e)
- {
- super(e);
- }
-
- public float getMaximumSpan()
- {
- return 50.0f;
- }
- public float getMinimumSpan()
- {
- return 50.0f;
- }
- public float getPreferredSpan()
- {
- return 50.0f;
- }
- }
-
-
}
// EOF-Unix/ASCII-------------------------------------@RisingSun//Java//1.0//EN
--- 1010,1013 ----
--- TableView.java DELETED ---
|
|
From: S?bastien P. <kaz...@us...> - 2001-11-27 10:31:45
|
Update of /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/core
In directory usw-pr-cvs1:/tmp/cvs-serv25172/sourceforge/spedit/core
Modified Files:
Styleable.java XMLInformation.java XMLViewFactory.java
Log Message:
Apart from the new SPML package many improvements have been done both
to the StyleSheet and to the Views. There is now a basic layout management
in the Views using the "stick" element of Padding style properties groups
in XSS.
One of the interesting aspect is the Pool class that gathers resources
allowing the editor to dynamically manage resources. This is particulary
useful for images/icons.
Index: Styleable.java
===================================================================
RCS file: /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/core/Styleable.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Styleable.java 2001/11/15 10:49:43 1.3
--- Styleable.java 2001/11/27 10:31:41 1.4
***************
*** 2,6 ****
// Project : SPEdit-Prototypes
// ClassName : Styleable
! // Version : 0.98
// Type : Core interface
//
--- 2,6 ----
// Project : SPEdit-Prototypes
// ClassName : Styleable
! // Version : 0.99
// Type : Core interface
//
***************
*** 13,18 ****
// ----------------------------------------------------------------------------
// Creation date : 25-Sep-2001
! // Last mod. : 09-Nov-2001
// History :
// 09-Nov-2001 Added border style attributes.(sp)
// 29-Oct-2001 Added title and title padding
--- 13,21 ----
// ----------------------------------------------------------------------------
// Creation date : 25-Sep-2001
! // Last mod. : 26-Nov-2001
// History :
+ // 26-Nov-2001 Updated cached attributes to allow
+ // minimal layout through the "stick" positionning
+ // style properties.(sp)
// 09-Nov-2001 Added border style attributes.(sp)
// 29-Oct-2001 Added title and title padding
***************
*** 49,52 ****
--- 52,56 ----
import java.beans.*;
import gnu.regexp.*;
+ import net.sourceforge.spedit.ui.AttributesDisplay;
/**
***************
*** 86,89 ****
--- 90,96 ----
* inheritance of whole, or part of the style tree structure, plus
* resolution into a parent <code>Styleable</code> element.</p>
+ * <p>The <code>StyleSheet</code> has been tailored for the specific
+ * needs of SPEdit and provides faster, direct access to common style
+ * attributes used by the Views of SPEdit.</p>
*/
public static class StyleSheet implements PropertyChangeListener
***************
*** 94,98 ****
--- 101,117 ----
public static final float CENTER=0.5f;
public static final float RIGHT=1f;
+
+ public static final int NONE=0;
+
+ public static final int TITLE_UL=1;
+ public static final int TITLE_UR=2;
+ public static final int TITLE_LL=3;
+ public static final int TITLE_LR=4;
+ public static final int ATTR_UL=11;
+ public static final int ATTR_UR=12;
+ public static final int ATTR_LL=13;
+ public static final int ATTR_LR=14;
+
// PROTECTED_________________________________________________________
***************
*** 112,115 ****
--- 131,137 ----
//Style properties
+ public Color foreground;
+ public Color background;
+
public short paddingLeft;
public short paddingRight;
***************
*** 121,127 ****
public Font font;
- public Color foreground;
- public Color background;
-
public String title;
public Font titleFont;
--- 143,146 ----
***************
*** 130,133 ****
--- 149,154 ----
public short titlePaddingTop;
public short titlePaddingBottom;
+ public int titleWidth = -1;
+ public int titleHeight = -1;
public int borderSize;
***************
*** 139,142 ****
--- 160,172 ----
public boolean hasExpander;
+
+ public AttributesDisplay attributesDisplay=null;
+ public short attributesPaddingLeft;
+ public short attributesPaddingRight;
+ public short attributesPaddingTop;
+ public short attributesPaddingBottom;
+
+ public int contentStick=NONE;
+ public int attributesStick=NONE;
//---------------------------------------------------------------------
***************
*** 482,488 ****
//---------------------------------------------------------------------
! int counter=0;
public void update()
{
//Foreground color
if (getStyle("color.foreground")==null)
--- 512,525 ----
//---------------------------------------------------------------------
! /**
! * Updates the cached style property values contained in this
! * stylesheet. As this method is quite slow it should not be called
! * too often.
! */
public void update()
{
+ //WELCOME to the wonderful world of code compacity, brought to
+ //you by the java language ;)
+
//Foreground color
if (getStyle("color.foreground")==null)
***************
*** 663,673 ****
{ borderPaddingBottom = ((Number)getStyle("border.padding.bottom")).shortValue(); }
//Expander
if (getStyle("expander.presence")==null)
{ hasExpander=false; }
else
! { hasExpander=true;; }
! counter++;
}
--- 700,768 ----
{ borderPaddingBottom = ((Number)getStyle("border.padding.bottom")).shortValue(); }
+ //Attributes left padding
+ if (getStyle("attributes.padding.left")==null)
+ { attributesPaddingLeft = (short)0; }
+ else
+ { attributesPaddingLeft = ((Number)getStyle("attributes.padding.left")).shortValue(); }
+
+ //Attributes bottom padding
+ if (getStyle("attributes.padding.right")==null)
+ { attributesPaddingRight = (short)0; }
+ else
+ { attributesPaddingRight = ((Number)getStyle("attributes.padding.right")).shortValue(); }
+
+ //Attributes top padding
+ if (getStyle("attributes.padding.top")==null)
+ { attributesPaddingTop = (short)0; }
+ else
+ { attributesPaddingTop = ((Number)getStyle("attributes.padding.top")).shortValue(); }
+
+ //Attributes bottom padding
+ if (getStyle("border.padding.bottom")==null)
+ { attributesPaddingBottom = (short)0; }
+ else
+ { attributesPaddingBottom = ((Number)getStyle("attributes.padding.bottom")).shortValue(); }
+
//Expander
if (getStyle("expander.presence")==null)
{ hasExpander=false; }
else
! { hasExpander=true; }
!
! //Stick attribute for attributesDisplay
! if (getStyle("attributes.padding.stick")!=null)
! {
! String s = ((String)getStyle("attributes.stick")).toLowerCase();
! if ( s.equals("title.ul") || s.equals("title.upper-left") )
! { attributesStick = TITLE_UL; }
! else if ( s.equals("title.ur") || s.equals("title.upper-right") )
! { attributesStick = TITLE_UR; }
! else if ( s.equals("title.ll") || s.equals("title.lower-left") )
! { attributesStick = TITLE_LL; }
! else if ( s.equals("title.lr") || s.equals("title.lower-right") )
! { attributesStick = TITLE_LR; }
! }
! //Stick attribute for content
! if (getStyle("padding.stick")!=null)
! {
! String s = ((String)getStyle("padding.stick")).toLowerCase();
! if ( s.equals("title.ul") || s.equals("title.upper-left") )
! { contentStick = TITLE_UL; }
! else if ( s.equals("title.ur") || s.equals("title.upper-right") )
! { contentStick = TITLE_UR; }
! else if ( s.equals("title.ll") || s.equals("title.lower-left") )
! { contentStick = TITLE_LL; }
! else if ( s.equals("title.lr") || s.equals("title.lower-right") )
! { contentStick = TITLE_LR; }
! else if ( s.equals("attributes.ul") || s.equals("attributes.upper-left") )
! { contentStick = ATTR_UR; }
! else if ( s.equals("attributes.ur") || s.equals("attributes.upper-right") )
! { contentStick = ATTR_UR; }
! else if ( s.equals("attributes.ll") || s.equals("attributes.lower-left") )
! { contentStick = ATTR_LL; }
! else if ( s.equals("attributes.lr") || s.equals("attributes.lower-right") )
! { contentStick = ATTR_LR; }
! }
}
Index: XMLInformation.java
===================================================================
RCS file: /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/core/XMLInformation.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** XMLInformation.java 2001/11/07 13:00:42 1.2
--- XMLInformation.java 2001/11/27 10:31:41 1.3
***************
*** 2,6 ****
// Project : SPEdit-Prototypes
// ClassName : XMLInformation
! // Version : 0.30
// Type : Core data class.
//
--- 2,6 ----
// Project : SPEdit-Prototypes
// ClassName : XMLInformation
! // Version : 0.32
// Type : Core data class.
//
***************
*** 12,17 ****
// ----------------------------------------------------------------------------
// Creation date : 19-Sep-2001
! // Last mod. : 06-Nov-2001
// History :
// 06-Nov-2001 Added attributes that indicate how the
// element textual content should be processed.(sp)
--- 12,19 ----
// ----------------------------------------------------------------------------
// Creation date : 19-Sep-2001
! // Last mod. : 21-Nov-2001
// History :
+ // 21-Nov-2001 Added newlyCreated flag to be used by
+ // the WrapperView class.(sp)
// 06-Nov-2001 Added attributes that indicate how the
// element textual content should be processed.(sp)
***************
*** 81,85 ****
protected Styleable.StyleSheet styleSheet;
! protected boolean strip=true;
// CONSTRUCTORS____________________________________________________________
--- 83,88 ----
protected Styleable.StyleSheet styleSheet;
! protected boolean strip=true;
! protected boolean newlyCreated=false;
// CONSTRUCTORS____________________________________________________________
***************
*** 273,280 ****
--- 276,313 ----
//------------------------------------------------------------------------
//
+ // Element state meta information
+ //
+ //------------------------------------------------------------------------
+
+ /**
+ * Tells if the element is a newly created element. For example elements
+ * that have just been inserted may need some editing by the user, in
+ * this case the WrapperView will activate a special display mode that
+ * will graphically tell the user that he should edit the element.
+ * @return Tells if the elment is a newly created one.
+ */
+ public boolean isNewlyCreated()
+ { return newlyCreated; }
+
+ /**
+ * Sets or unsets the <code>newlyCreated</code> flag for this element.
+ * @param nc The flag is set if <code>nc</code> is <code>true</code>.
+ * @see #isNewlyCreated
+ */
+ public void setNewlyCreated(boolean nc)
+ { newlyCreated = nc; }
+
+ //------------------------------------------------------------------------
+ //
// Textual content processing attributes
//
//------------------------------------------------------------------------
+ /**
+ * This method tells wether the content of the element has to be stripped
+ * or not. Stripping means getting rid of the trailing and leading blank
+ * characters.
+ * @return Wether the content should be stripped or not.
+ */
public boolean hasStrip()
{ return strip; }
Index: XMLViewFactory.java
===================================================================
RCS file: /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/core/XMLViewFactory.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** XMLViewFactory.java 2001/11/21 11:02:04 1.4
--- XMLViewFactory.java 2001/11/27 10:31:41 1.5
***************
*** 1,5 ****
// Project : SPEdit-Prototypes
// ClassName : XMLViewFactory
! // Version : 0.80
// Type : Swing application component
//
--- 1,5 ----
// Project : SPEdit-Prototypes
// ClassName : XMLViewFactory
! // Version : 0.81
// Type : Swing application component
//
***************
*** 11,16 ****
// ----------------------------------------------------------------------------
// Creation date : 03-Sep-2001
! // Last mod. : 07-Nov-2001
// History :
// 07-Nov-2001 Addes strip attribute support.(sp)
// 18-Oct-2001 Added support for default stylesheet.
--- 11,17 ----
// ----------------------------------------------------------------------------
// 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)
// 18-Oct-2001 Added support for default stylesheet.
***************
*** 429,438 ****
for (int j=0 ; j<child.getChildren().size() ; j++)
{
Element gd_child = (Element)child.getChildren().get(j);
! name = gd_child.getAttribute("name").getValue();
! Object[] vp = (Object[])views.get(name);
! if ( vp!=null )
{
info.addView((Class)vp[0], (Vector)vp[1]);
}
}
--- 430,452 ----
for (int j=0 ; j<child.getChildren().size() ; j++)
{
+ Object vp[];
Element gd_child = (Element)child.getChildren().get(j);
! //This is the case where the view is directly specified into
! //the configuration
! if ( gd_child.getName().equals("view") && gd_child.getAttribute("name")==null )
{
+ vp = createViewInformation(gd_child);
+ if ( vp!=null )
+ { info.addView((Class)vp[0], (Vector)vp[1]); }
+ }
+ //This is the case where the view refers to a view formerly defined.
+ else if ( gd_child.getName().equals("use") )
+ {
+ name = gd_child.getAttribute("name").getValue();
+ vp = (Object[])views.get(name);
+ if ( vp!=null )
+ {
info.addView((Class)vp[0], (Vector)vp[1]);
+ }
}
}
|
|
From: S?bastien P. <kaz...@us...> - 2001-11-27 10:31:44
|
Update of /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/app In directory usw-pr-cvs1:/tmp/cvs-serv25172/sourceforge/spedit/app Modified Files: Application.java NavigationTree.java Added Files: Pool.java Log Message: Apart from the new SPML package many improvements have been done both to the StyleSheet and to the Views. There is now a basic layout management in the Views using the "stick" element of Padding style properties groups in XSS. One of the interesting aspect is the Pool class that gathers resources allowing the editor to dynamically manage resources. This is particulary useful for images/icons. --- NEW FILE: Pool.java --- // ---------------------------------------------------@RisingSun//Java//1.0//EN // Project : SPEdit-Prototypes // ClassName : Pool // Version : 0.50 // Type : Resource collector // ThreadSafe : Yep // Description : Gathers resources, providing a way to cache them. // URL : <http://spedit.sf.net> // ---------------------------------------------------------------------------- // Authors : Sbastien Pierre <sp...@is...> // ---------------------------------------------------------------------------- // Creation date : 23-Nov-2001 // Last mod. : 23-Nov-2001 // History : // 23-Nov-2001 First implementation.(sp) // // Bugs : // - // // To do : // package net.sourceforge.spedit.app; import java.util.*; //----------------------------------------------------------------------------- // // Pool // //----------------------------------------------------------------------------- /** * <p>The <code>Pool</code> class is a <em>resource collector</em>. This * basically means that the pool plays the role of a cache, which is especially * useful for images or icons. Basically when an extension needs an image or * another file it should use the pool, which will take care of loading it * properly and * cache it.</p> * <p>The nested abstract <code>Resource</code> class allows to put any kind * of resource into the pool. The resource charcteristics are that they are * identifiend by an URI which should be asbolute, that they can contain * any kind of object, that they are observable, can be refreshed and mutated. * Typical use case is run-time reloding of icons, or simply changing the * application localization on the fly.</p> */ public class Pool { //PROTECTED________________________________________________________________ protected Hashtable resourcePool; //------------------------------------------------------------------------- // // Constructors // //------------------------------------------------------------------------- /** * Creates a new resource pool. */ public Pool() { resourcePool = new Hashtable(); } //------------------------------------------------------------------------- // // Resource access & monitoring // //------------------------------------------------------------------------- /** * Puts a new resource into the pool. Take care of putting absolute uri, * otherwise there may be some conflicts with the resources. * @param resource the resource to be added. */ public void putResource(Resource resource) { resourcePool.put(resource.getURI(), resource); } /** * Access the given resource in the pool. * @param the URI identifying the resource. * @return the requested resource, or <code>null</code> if it has not * been found. */ public Resource getResource(String uri) { return (Resource)resourcePool.get(uri); } /** * Releases the given resource from the pool, this actually means * deleting it from the pool resource registry. * @param uri the uri identifying the resource * @return the released resource, or <code>null</code> if it has not * been found. */ public Resource releaseResource(String uri) { return (Resource)resourcePool.remove(uri); } /** * Releases the given resource from the pool, this actually means * deleting it from the pool resource registry. * @param resource the resource to be released from the pool. * @return the released resource, or <code>null</code> if it has not * been found. */ public Resource releaseResource(Resource resource) { return (Resource)resourcePool.remove(resource.getURI()); } //------------------------------------------------------------------------- // // Resource object // //------------------------------------------------------------------------- /** * <p>A resource is a mutable wrapper around an object, storing information * on the object source, allowing the resource to be observed in case it * changes, and allowing the resource to be refreshed.</p> */ public abstract class Resource extends Observable { protected String uri; protected Object resource; protected Exception e; /** * Creates a new resource with the given URI. The resource will * be loaded automatically. If an exception occurs, the resource * will be kept null and the exception can be reached using the * <code>getException</code> method. * @param uri URI of the resource to be loaded. */ public Resource(String uri) { this.uri = uri; this.resource = null; this.refresh(); } /** * Mutates the resource, changing its former value to the new value. * There is no checking on the resource consistency, this means that * you can mutate a List into an Image if you like, so use this method * with care. * @param resource is the new object that will be assigned to the * current resource. * @return the previous content of the resource. */ public synchronized Object mutate(Object resource) { Object oldres = this.resource; this.resource = resource; setChanged(); notifyObservers(resource); return oldres; } /** * Refreshes the resource content, trying to reload it. If an exception * happens during the refresh, the old resource value is kept and the * exception is made available using the <code>getException</code> method. * Note that this method should be implemented as <code>synchronized</code>. * @see #getException */ public abstract void refresh(); /** * Returns the resource content. This can be null in case an exception * has occured during the resource loading or refresh. In this case the * exception can be reached using the <code>getException</code> method. * @return The actual resource content, which may be <code>null</code> * in case an error has occured. * @see #getException */ public Object getContent() { return resource; } /** * This method can be called in case the resource <code>getContent</code> * method returns <code>null</code>. * @return Generally returns <code>null</code>, returns an exception when * an exception occured during resource loading or refresh. * @see #getContent */ public Exception getException() { return e; } /** * Returns the URI which describes the location of the resource. */ public String getURI() { return uri; } } //------------------------------------------------------------------------- // // Image resource // //------------------------------------------------------------------------- } // EOF-Unix/ISO-8859-1--------------------------------@RisingSun//Java//1.0//EN Index: Application.java =================================================================== RCS file: /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/app/Application.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Application.java 2001/11/21 11:02:02 1.4 --- Application.java 2001/11/27 10:31:41 1.5 *************** *** 2,6 **** // Project : SPEdit-Prototypes // ClassName : Application ! // Version : 0.10 // Type : Swing application // ThreadSafe : Yep --- 2,6 ---- // Project : SPEdit-Prototypes // ClassName : Application ! // Version : 0.20 // Type : Swing application // ThreadSafe : Yep *************** *** 12,17 **** // ---------------------------------------------------------------------------- // Creation date : 15-Sep-2001 ! // Last mod. : 24-Oct-2001 // History : // 24-Sep-2001 Moved inside the app package, better doc // and structure.(sp) --- 12,18 ---- // ---------------------------------------------------------------------------- // Creation date : 15-Sep-2001 ! // Last mod. : 22-Nov-2001 // History : + // 22-Nov-2001 Added code for Python modules path.(sp) // 24-Sep-2001 Moved inside the app package, better doc // and structure.(sp) *************** *** 69,72 **** --- 70,83 ---- public Application() { + //We initialize the PYTHONPATH equivalent that tells where modules can + //be found. + Properties props = new Properties(); + python.execfile("../Support/Application.py"); + File ext = new File("../Execution/Scripts"); + try { + python.exec("import sys ; sys.path.append('"+ext.getCanonicalPath()+"')"); + } + catch (IOException e) + { System.err.println("Scripts dir does not exist..."); } documentFrames = new Vector(); currentDocumentFrame = new DocumentFrame(); *************** *** 74,82 **** } - public void init() - { - currentDocumentFrame.init(); - } - //------------------------------------------------------------------------- // --- 85,88 ---- *************** *** 141,145 **** navigator = new NavigationTree(this); //editorKit = new XMLEditorKit("../Support/Configuration.xml"); ! editorKit = new XMLEditorKit("../Support/SP-Configuration.xml"); editorPane.setEditorKit(editorKit); factory = (XMLViewFactory)editorKit.getViewFactory(); --- 147,152 ---- navigator = new NavigationTree(this); //editorKit = new XMLEditorKit("../Support/Configuration.xml"); ! //editorKit = new XMLEditorKit("../Support/SP-Configuration.xml"); ! editorKit = new XMLEditorKit("../Support/ON-Configuration.xml"); editorPane.setEditorKit(editorKit); factory = (XMLViewFactory)editorKit.getViewFactory(); *************** *** 151,156 **** { //We load the custom file ! File ff = new File("../Support/SP-P11388.xml"); ! //File ff = new File("../Support/SP-Document.xml"); document = XMLDocument.loadFromFile(ff, factory); document.filter(factory); --- 158,163 ---- { //We load the custom file ! //File ff = new File("../Support/SP-P11388.xml"); ! File ff = new File("../Support/ON-Document.xml"); document = XMLDocument.loadFromFile(ff, factory); document.filter(factory); *************** *** 159,164 **** //We set layout for container getContentPane().setLayout(new XmFormLayout(constraints)); ! ! python.execfile("../Support/Application.py"); python.set("frame", this); python.exec("listener = MenuListener(frame)"); --- 166,170 ---- //We set layout for container getContentPane().setLayout(new XmFormLayout(constraints)); ! python.set("frame", this); python.exec("listener = MenuListener(frame)"); *************** *** 218,237 **** --- 224,248 ---- } } + evt.consume(); } public void mouseEntered(MouseEvent evt) { + evt.consume(); } public void mouseExited(MouseEvent evt) { + evt.consume(); } public void mousePressed(MouseEvent evt) { + evt.consume(); } public void mouseReleased(MouseEvent evt) { + evt.consume(); } *************** *** 365,368 **** --- 376,380 ---- view.replace(0,view.getViewCount(),new View[0]); //FIXME: Insertion should be made through the DOM... + newElement.getWrapper().getInformation().setNewlyCreated(true); wrapper.insert(newElement,pos,javax.swing.text.Position.Bias.Forward); //This makes the actual forced reaload after element insertion. Index: NavigationTree.java =================================================================== RCS file: /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/app/NavigationTree.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NavigationTree.java 2001/11/01 15:41:43 1.1 --- NavigationTree.java 2001/11/27 10:31:41 1.2 *************** *** 10,14 **** // URL : <http://spedit.sf.net> // ---------------------------------------------------------------------------- ! // Authors : Sébastien Pierre <sp...@is...> // ---------------------------------------------------------------------------- // Creation date : 19-Oct-2001 --- 10,14 ---- // URL : <http://spedit.sf.net> // ---------------------------------------------------------------------------- ! // Authors : Sbastien Pierre <sp...@is...> // ---------------------------------------------------------------------------- // Creation date : 19-Oct-2001 |
|
From: S?bastien P. <kaz...@us...> - 2001-11-27 10:08:18
|
Update of /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/spml In directory usw-pr-cvs1:/tmp/cvs-serv19558/spml Log Message: Directory /cvsroot/spedit/prototype/Sources/net/sourceforge/spedit/spml added to the repository |