Revision: 1480
          http://svn.sourceforge.net/spring-rich-c/?rev=1480&view=rev
Author:   jhoskens
Date:     2006-10-03 00:38:57 -0700 (Tue, 03 Oct 2006)

Log Message:
-----------
module refactoring: moved classes needed in several parts to core

Added Paths:
-----------
    
trunk/spring-richclient/core/src/main/java/org/springframework/richclient/core/DescribedElement.java
    
trunk/spring-richclient/core/src/main/java/org/springframework/richclient/core/VisualizedElement.java
    
trunk/spring-richclient/core/src/main/java/org/springframework/richclient/factory/LabelInfo.java

Copied: 
trunk/spring-richclient/core/src/main/java/org/springframework/richclient/core/DescribedElement.java
 (from rev 1457, 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/core/DescribedElement.java)
===================================================================
--- 
trunk/spring-richclient/core/src/main/java/org/springframework/richclient/core/DescribedElement.java
                                (rev 0)
+++ 
trunk/spring-richclient/core/src/main/java/org/springframework/richclient/core/DescribedElement.java
        2006-10-03 07:38:57 UTC (rev 1480)
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2002-2004 the original author or authors.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy 
of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations 
under
+ * the License.
+ */
+package org.springframework.richclient.core;
+
+/**
+ * A interface for managed elements that can be displayed in a GUI.
+ * 
+ * @author Keith Donald
+ */
+public interface DescribedElement {
+    public static final String DISPLAY_NAME_PROPERTY = "displayName";
+
+    public static final String CAPTION_PROPERTY = "caption";
+
+    public static final String DESCRIPTION_PROPERTY = "description";
+
+    public String getDisplayName();
+
+    public String getCaption();
+
+    public String getDescription();
+}
\ No newline at end of file


Property changes on: 
trunk/spring-richclient/core/src/main/java/org/springframework/richclient/core/DescribedElement.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Copied: 
trunk/spring-richclient/core/src/main/java/org/springframework/richclient/core/VisualizedElement.java
 (from rev 1457, 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/core/VisualizedElement.java)
===================================================================
--- 
trunk/spring-richclient/core/src/main/java/org/springframework/richclient/core/VisualizedElement.java
                               (rev 0)
+++ 
trunk/spring-richclient/core/src/main/java/org/springframework/richclient/core/VisualizedElement.java
       2006-10-03 07:38:57 UTC (rev 1480)
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2002-2004 the original author or authors.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy 
of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations 
under
+ * the License.
+ */
+package org.springframework.richclient.core;
+
+import java.awt.Image;
+
+import javax.swing.Icon;
+
+public interface VisualizedElement {
+    public Image getImage();
+
+    public Icon getIcon();
+}
\ No newline at end of file


Property changes on: 
trunk/spring-richclient/core/src/main/java/org/springframework/richclient/core/VisualizedElement.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Copied: 
trunk/spring-richclient/core/src/main/java/org/springframework/richclient/factory/LabelInfo.java
 (from rev 1457, 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/factory/LabelInfo.java)
===================================================================
--- 
trunk/spring-richclient/core/src/main/java/org/springframework/richclient/factory/LabelInfo.java
                            (rev 0)
+++ 
trunk/spring-richclient/core/src/main/java/org/springframework/richclient/factory/LabelInfo.java
    2006-10-03 07:38:57 UTC (rev 1480)
@@ -0,0 +1,134 @@
+/*
+ * Copyright 2002-2004 the original author or authors.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy 
of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations 
under
+ * the License.
+ */
+package org.springframework.richclient.factory;
+
+import javax.swing.AbstractButton;
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.core.style.ToStringCreator;
+import org.springframework.util.Assert;
+import org.springframework.util.StringUtils;
+
+/**
+ * A parameter object for a labelable component; consists of the text, 
mnemonic,
+ * mnemonicIndex, and accelerator that may be associated with a labeled
+ * component. This class also acts a factory for producing control prototypes
+ * which are preconfigured with a LabelInfo's properties.
+ * 
+ * @author Keith Donald
+ */
+public class LabelInfo {
+    private static final Log logger = LogFactory.getLog(LabelInfo.class);
+
+    private String text = "";
+
+    private int mnemonic;
+
+    private int mnemonicIndex;
+
+    public LabelInfo(String text) {
+        this(text, 0, 0);
+    }
+
+    public LabelInfo(String text, int mnemonic) {
+        this(text, mnemonic, 0);
+    }
+
+    public LabelInfo(String text, int mnemonic, int mnemonicIndex) {
+        Assert.notNull(text);
+        this.text = text;
+        if (!StringUtils.hasText(text)) {
+            mnemonicIndex = -1;
+        }
+        if (logger.isDebugEnabled()) {
+            logger.debug("Constructing label info, properties: text='" + text 
+ "', mnemonic=" + mnemonic
+                    + ", mnemonicIndex=" + mnemonicIndex);
+        }
+        Assert.isTrue(mnemonic >= 0 && mnemonicIndex >= -1);
+        Assert.isTrue(mnemonicIndex < text.length(), "The mnemonic index 
cannot be greater than the text length.");
+        this.mnemonic = mnemonic;
+        this.mnemonicIndex = mnemonicIndex;
+    }
+
+    public int hashCode() {
+        return mnemonic + mnemonicIndex + text.hashCode();
+    }
+
+    public boolean equals(Object o) {
+        if (!(o instanceof LabelInfo)) {
+            return false;
+        }
+        LabelInfo info = (LabelInfo)o;
+        return text.equals(info.text) && mnemonic == info.mnemonic && 
mnemonicIndex == info.mnemonicIndex;
+    }
+
+    public JLabel configureLabel(JLabel label) {
+        Assert.notNull(label);
+        label.setText(text);
+        label.setDisplayedMnemonic(getMnemonic());
+        int index = getMnemonicIndex();
+        if (index > 0) {
+            label.setDisplayedMnemonicIndex(index);
+        }
+        return label;
+    }
+
+    public JLabel configureLabelFor(JLabel label, JComponent component) {
+        configureLabel(label);
+        if (!(component instanceof JPanel)) {
+            String labelText = label.getText();
+            if (!labelText.endsWith(":")) {
+                if (logger.isDebugEnabled()) {
+                    logger.debug("Appending colon to text field label text '" 
+ text + "'");
+                }
+                label.setText(labelText += ":");
+            }
+        }
+        label.setLabelFor(component);
+        return label;
+    }
+    
+    public AbstractButton configureButton(AbstractButton button) {
+        Assert.notNull(button);
+        button.setText(text);
+        button.setMnemonic(getMnemonic());
+        int index = getMnemonicIndex();
+        if (index > 0) {
+            button.setDisplayedMnemonicIndex(index);
+        }
+        return button;
+    }
+
+    public String getText() {
+        return text;
+    }
+
+    public int getMnemonic() {
+        return mnemonic;
+    }
+
+    public int getMnemonicIndex() {
+        return mnemonicIndex;
+    }
+
+    public String toString() {
+        return new ToStringCreator(this).toString();
+    }
+}
\ No newline at end of file


Property changes on: 
trunk/spring-richclient/core/src/main/java/org/springframework/richclient/factory/LabelInfo.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
spring-rich-c-cvs mailing list
spring-rich-c-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spring-rich-c-cvs

Reply via email to