[Spedit-commits] CVS: prototype/Sources/net/sourceforge/spedit/core Styleable.java,1.3,1.4 XMLInform
Status: Planning
Brought to you by:
krunte
|
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]);
+ }
}
}
|