[Spedit-commits] CVS: prototype/Sources/net/sourceforge/spedit/app Application.java,1.6,1.7
Status: Planning
Brought to you by:
krunte
|
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.
|