]> source.dussan.org Git - vaadin-framework.git/commitdiff
Changed border style to enum (#9072)
authorArtur Signell <artur@vaadin.com>
Wed, 22 Aug 2012 05:53:23 +0000 (08:53 +0300)
committerArtur Signell <artur@vaadin.com>
Wed, 22 Aug 2012 11:01:49 +0000 (14:01 +0300)
client/src/com/vaadin/terminal/gwt/client/ui/link/LinkConnector.java
client/src/com/vaadin/terminal/gwt/client/ui/link/VLink.java
server/src/com/vaadin/terminal/Page.java
server/src/com/vaadin/ui/Link.java
server/src/com/vaadin/ui/Root.java
shared/src/com/vaadin/shared/ui/BorderStyle.java [new file with mode: 0755]

index c4bbcd34f72f55b906b7a16e7b54ffcaf9ba3fe4..f2b8361f2b8ceaa44653420b53117611e308a1ac 100644 (file)
@@ -17,6 +17,7 @@
 package com.vaadin.terminal.gwt.client.ui.link;
 
 import com.google.gwt.user.client.DOM;
+import com.vaadin.shared.ui.BorderStyle;
 import com.vaadin.shared.ui.Connect;
 import com.vaadin.terminal.gwt.client.ApplicationConnection;
 import com.vaadin.terminal.gwt.client.Paintable;
@@ -57,12 +58,12 @@ public class LinkConnector extends AbstractComponentConnector implements
 
         if (uidl.hasAttribute("border")) {
             if ("none".equals(uidl.getStringAttribute("border"))) {
-                getWidget().borderStyle = VLink.BORDER_STYLE_NONE;
+                getWidget().borderStyle = BorderStyle.NONE;
             } else {
-                getWidget().borderStyle = VLink.BORDER_STYLE_MINIMAL;
+                getWidget().borderStyle = BorderStyle.MINIMAL;
             }
         } else {
-            getWidget().borderStyle = VLink.BORDER_STYLE_DEFAULT;
+            getWidget().borderStyle = BorderStyle.DEFAULT;
         }
 
         getWidget().targetHeight = uidl.hasAttribute("targetHeight") ? uidl
index e312d4d4891b5b3381d5676bf143a0e47aca5a34..b0e44c9d132c4d45d09a9cf6d102b26aaec5961f 100644 (file)
@@ -23,6 +23,7 @@ import com.google.gwt.user.client.Element;
 import com.google.gwt.user.client.Event;
 import com.google.gwt.user.client.Window;
 import com.google.gwt.user.client.ui.HTML;
+import com.vaadin.shared.ui.BorderStyle;
 import com.vaadin.terminal.gwt.client.ApplicationConnection;
 import com.vaadin.terminal.gwt.client.Util;
 import com.vaadin.terminal.gwt.client.ui.Icon;
@@ -31,15 +32,20 @@ public class VLink extends HTML implements ClickHandler {
 
     public static final String CLASSNAME = "v-link";
 
-    protected static final int BORDER_STYLE_DEFAULT = 0;
-    protected static final int BORDER_STYLE_MINIMAL = 1;
-    protected static final int BORDER_STYLE_NONE = 2;
+    @Deprecated
+    protected static final BorderStyle BORDER_STYLE_DEFAULT = BorderStyle.DEFAULT;
+
+    @Deprecated
+    protected static final BorderStyle BORDER_STYLE_MINIMAL = BorderStyle.MINIMAL;
+
+    @Deprecated
+    protected static final BorderStyle BORDER_STYLE_NONE = BorderStyle.NONE;
 
     protected String src;
 
     protected String target;
 
-    protected int borderStyle = BORDER_STYLE_DEFAULT;
+    protected BorderStyle borderStyle = BorderStyle.DEFAULT;
 
     protected boolean enabled;
 
@@ -73,10 +79,10 @@ public class VLink extends HTML implements ClickHandler {
             }
             String features;
             switch (borderStyle) {
-            case BORDER_STYLE_NONE:
+            case NONE:
                 features = "menubar=no,location=no,status=no";
                 break;
-            case BORDER_STYLE_MINIMAL:
+            case MINIMAL:
                 features = "menubar=yes,location=no,status=no";
                 break;
             default:
index 933f9b39e652f80292eb05dbb1370417fd2770f6..8eb77b7d0dd60b5e5fc24db1131b944dfa39262f 100644 (file)
@@ -24,6 +24,7 @@ import java.util.LinkedList;
 import java.util.List;
 
 import com.vaadin.event.EventRouter;
+import com.vaadin.shared.ui.BorderStyle;
 import com.vaadin.shared.ui.root.PageClientRpc;
 import com.vaadin.shared.ui.root.RootConstants;
 import com.vaadin.terminal.WrappedRequest.BrowserDetails;
@@ -128,7 +129,7 @@ public class Page implements Serializable {
         /**
          * The border style of the target window
          */
-        private final int border;
+        private final BorderStyle border;
 
         /**
          * Creates a new open resource.
@@ -145,7 +146,7 @@ public class Page implements Serializable {
          *            The border style of the target window
          */
         private OpenResource(Resource resource, String name, int width,
-                int height, int border) {
+                int height, BorderStyle border) {
             this.resource = resource;
             this.name = name;
             this.width = width;
@@ -174,10 +175,10 @@ public class Page implements Serializable {
                 target.addAttribute("height", height);
             }
             switch (border) {
-            case BORDER_MINIMAL:
+            case MINIMAL:
                 target.addAttribute("border", "minimal");
                 break;
-            case BORDER_NONE:
+            case NONE:
                 target.addAttribute("border", "none");
                 break;
             }
@@ -193,19 +194,20 @@ public class Page implements Serializable {
     /**
      * A border style used for opening resources in a window without a border.
      */
-    public static final int BORDER_NONE = 0;
+    @Deprecated
+    public static final BorderStyle BORDER_NONE = BorderStyle.NONE;
 
     /**
      * A border style used for opening resources in a window with a minimal
      * border.
      */
-    public static final int BORDER_MINIMAL = 1;
+    public static final BorderStyle BORDER_MINIMAL = BorderStyle.MINIMAL;
 
     /**
      * A border style that indicates that the default border style should be
      * used when opening resources.
      */
-    public static final int BORDER_DEFAULT = 2;
+    public static final BorderStyle BORDER_DEFAULT = BorderStyle.DEFAULT;
 
     /**
      * Listener that listens changes in URI fragment.
@@ -581,11 +583,10 @@ public class Page implements Serializable {
      * @param height
      *            the height of the window in pixels
      * @param border
-     *            the border style of the window. See {@link #BORDER_NONE
-     *            Window.BORDER_* constants}
+     *            the border style of the window.
      */
     public void open(Resource resource, String windowName, int width,
-            int height, int border) {
+            int height, BorderStyle border) {
         openList.add(new OpenResource(resource, windowName, width, height,
                 border));
         root.requestRepaint();
index 57f20880541082422afddcdc28477c35fbdd51f2..ae2934f8788cf80407f6e5c4927811ea4397b257 100644 (file)
@@ -18,7 +18,7 @@ package com.vaadin.ui;
 
 import java.util.Map;
 
-import com.vaadin.terminal.Page;
+import com.vaadin.shared.ui.BorderStyle;
 import com.vaadin.terminal.PaintException;
 import com.vaadin.terminal.PaintTarget;
 import com.vaadin.terminal.Resource;
@@ -34,19 +34,22 @@ import com.vaadin.terminal.Vaadin6Component;
 public class Link extends AbstractComponent implements Vaadin6Component {
 
     /* Target window border type constant: No window border */
-    public static final int TARGET_BORDER_NONE = Page.BORDER_NONE;
+    @Deprecated
+    public static final BorderStyle TARGET_BORDER_NONE = BorderStyle.NONE;
 
     /* Target window border type constant: Minimal window border */
-    public static final int TARGET_BORDER_MINIMAL = Page.BORDER_MINIMAL;
+    @Deprecated
+    public static final BorderStyle TARGET_BORDER_MINIMAL = BorderStyle.MINIMAL;
 
     /* Target window border type constant: Default window border */
-    public static final int TARGET_BORDER_DEFAULT = Page.BORDER_DEFAULT;
+    @Deprecated
+    public static final BorderStyle TARGET_BORDER_DEFAULT = BorderStyle.DEFAULT;
 
     private Resource resource = null;
 
     private String targetName;
 
-    private int targetBorder = TARGET_BORDER_DEFAULT;
+    private BorderStyle targetBorder = BorderStyle.DEFAULT;
 
     private int targetWidth = -1;
 
@@ -89,7 +92,7 @@ public class Link extends AbstractComponent implements Vaadin6Component {
      * 
      */
     public Link(String caption, Resource resource, String targetName,
-            int width, int height, int border) {
+            int width, int height, BorderStyle border) {
         setCaption(caption);
         this.resource = resource;
         setTargetName(targetName);
@@ -131,10 +134,10 @@ public class Link extends AbstractComponent implements Vaadin6Component {
 
         // Target window border
         switch (getTargetBorder()) {
-        case TARGET_BORDER_MINIMAL:
+        case MINIMAL:
             target.addAttribute("border", "minimal");
             break;
-        case TARGET_BORDER_NONE:
+        case NONE:
             target.addAttribute("border", "none");
             break;
         }
@@ -145,7 +148,7 @@ public class Link extends AbstractComponent implements Vaadin6Component {
      * 
      * @return the target window border.
      */
-    public int getTargetBorder() {
+    public BorderStyle getTargetBorder() {
         return targetBorder;
     }
 
@@ -183,13 +186,9 @@ public class Link extends AbstractComponent implements Vaadin6Component {
      * @param targetBorder
      *            the targetBorder to set.
      */
-    public void setTargetBorder(int targetBorder) {
-        if (targetBorder == TARGET_BORDER_DEFAULT
-                || targetBorder == TARGET_BORDER_MINIMAL
-                || targetBorder == TARGET_BORDER_NONE) {
-            this.targetBorder = targetBorder;
-            requestRepaint();
-        }
+    public void setTargetBorder(BorderStyle targetBorder) {
+        this.targetBorder = targetBorder;
+        requestRepaint();
     }
 
     /**
index b37005a16e3747bbb798da2db748650c728b1cae..020ff869faef2697ccd0599abdfabdb64cbeac6a 100644 (file)
@@ -34,6 +34,7 @@ import com.vaadin.event.MouseEvents.ClickEvent;
 import com.vaadin.event.MouseEvents.ClickListener;
 import com.vaadin.shared.EventId;
 import com.vaadin.shared.MouseEventDetails;
+import com.vaadin.shared.ui.BorderStyle;
 import com.vaadin.shared.ui.root.RootConstants;
 import com.vaadin.shared.ui.root.RootServerRpc;
 import com.vaadin.shared.ui.root.RootState;
@@ -283,13 +284,12 @@ public abstract class Root extends AbstractComponentContainer implements
          * @param height
          *            the height of the window in pixels
          * @param border
-         *            the border style of the window. See {@link #BORDER_NONE
-         *            Window.BORDER_* constants}
+         *            the border style of the window.
          * @deprecated As of 7.0, use getPage().open instead
          */
         @Deprecated
         public void open(Resource resource, String windowName, int width,
-                int height, int border) {
+                int height, BorderStyle border) {
             getPage().open(resource, windowName, width, height, border);
         }
 
diff --git a/shared/src/com/vaadin/shared/ui/BorderStyle.java b/shared/src/com/vaadin/shared/ui/BorderStyle.java
new file mode 100755 (executable)
index 0000000..786d340
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2011 Vaadin Ltd.
+ *
+ * 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 com.vaadin.shared.ui;
+
+public enum BorderStyle {
+    NONE, MINIMAL, DEFAULT;
+}