Modified:
felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/UPnPDeviceTreeNode.java
URL:
http://svn.apache.org/viewvc/felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/UPnPDeviceTreeNode.java?rev=674879&r1=674878&r2=674879&view=diff
==============================================================================
---
felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/UPnPDeviceTreeNode.java
(original)
+++
felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/UPnPDeviceTreeNode.java
Tue Jul 8 09:59:54 2008
@@ -1,236 +1,236 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.felix.upnp.tester.gui;
-
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.image.ImageObserver;
-import java.net.URL;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-
-import javax.swing.Icon;
-import javax.swing.ImageIcon;
-import javax.swing.JToolTip;
-import javax.swing.JTree;
-import javax.swing.tree.DefaultMutableTreeNode;
-import javax.swing.tree.DefaultTreeCellRenderer;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.service.upnp.UPnPAction;
-import org.osgi.service.upnp.UPnPDevice;
-import org.osgi.service.upnp.UPnPService;
-import org.osgi.service.upnp.UPnPStateVariable;
-
-import org.apache.felix.upnp.tester.discovery.DeviceNode;
-
-/*
-* @author <a href="mailto:[EMAIL PROTECTED]">Felix Project Team</a>
-*/
-public class UPnPDeviceTreeNode extends DefaultMutableTreeNode {
- public final static String ROOT_DEVICE = "RootDeviceNode";
- public final static String DEVICE = "DeviceNode";
- public final static String SERVICE = "UPnPService";
- public final static String ACTION = "UPnPAction";
- public final static String STATE = "UPnPStateVariable";
- public final static String EVENTED_STATE = "EventedStateVariable";
- public final static String SUBSCRIBED_STATE = "SubscribedStateVariable";
-
- protected String category;
- public UPnPDeviceTreeNode(String obj) {
- super(obj);
- category = obj.getClass().getName();
- }
-
- public UPnPDeviceTreeNode(DeviceNode obj, BundleContext ctx) {
- super(obj);
-
- if (obj.isRoot()) category = ROOT_DEVICE;
- else category = DEVICE;
-
- UPnPDevice device =
(UPnPDevice)ctx.getService(obj.getReference());
- UPnPService[] services = device.getServices();
-
- Collection nodeChildren = obj.getChildren();
- if (nodeChildren != null){
- Iterator list = nodeChildren.iterator();
- while (list.hasNext()){
- DeviceNode node = (DeviceNode)list.next();
- this.add(new UPnPDeviceTreeNode(node,ctx));
- }
- }
- if (services != null){
- for (int i=0;i<services.length;i++)
- this.add(new UPnPDeviceTreeNode(services[i]));
- }
-
- }
-
- public UPnPDeviceTreeNode(UPnPService obj) {
- super(obj);
- category = SERVICE;
- UPnPStateVariable[] variables = obj.getStateVariables();
- if (variables != null){
- for (int i=0;i<variables.length;i++)
- this.add(new UPnPDeviceTreeNode(variables[i]));
- }
- UPnPAction[] actions = obj.getActions();
- if (actions != null){
- for (int i=0;i<actions.length;i++)
- this.add(new UPnPDeviceTreeNode(actions[i]));
- }
- }
- public UPnPDeviceTreeNode(UPnPAction obj) {
- super(obj);
- category = ACTION;
- }
-
- public UPnPDeviceTreeNode(UPnPStateVariable obj) {
- super(obj);
- if (obj.sendsEvents()) category = EVENTED_STATE;
- else category = STATE;
- }
-
- public String toString() {
- if (category.equals(DEVICE)||category.equals(ROOT_DEVICE)){
- DeviceNode node = (DeviceNode) getUserObject();
- return node.toString();
- }
- else if (category.equals(SERVICE)){
- UPnPService node = (UPnPService) getUserObject();
- return node.getType();
- }
- else if (category.equals(ACTION)){
- UPnPAction node = (UPnPAction) getUserObject();
- return node.getName();
- }
- else if (category.equals(STATE)
||category.equals(EVENTED_STATE)||category.equals(SUBSCRIBED_STATE)){
- UPnPStateVariable node = (UPnPStateVariable)
getUserObject();
- return node.getName();
- }
- else
- return getUserObject().toString();
- }
-}
-
-// local class for JTree icon renderer
-class TreeNodeCellRenderer extends DefaultTreeCellRenderer implements
ImageObserver{
-
- private HashMap icons ;
- ImageIcon image;
- public TreeNodeCellRenderer() {
- super();
- icons = new HashMap();
- try {
- icons.put(UPnPDeviceTreeNode.EVENTED_STATE,
loadIcon(UPnPDeviceTreeNode.EVENTED_STATE));
- image = loadIcon(UPnPDeviceTreeNode.SUBSCRIBED_STATE);
- // to use animate gif
- //image.setImageObserver(this);
- icons.put(UPnPDeviceTreeNode.SUBSCRIBED_STATE, image);
-
- icons.put(UPnPDeviceTreeNode.ROOT_DEVICE,
loadIcon(UPnPDeviceTreeNode.ROOT_DEVICE));
- icons.put(UPnPDeviceTreeNode.DEVICE,
loadIcon(UPnPDeviceTreeNode.DEVICE));
- icons.put(UPnPDeviceTreeNode.SERVICE,
loadIcon(UPnPDeviceTreeNode.SERVICE));
- icons.put(UPnPDeviceTreeNode.ACTION,
loadIcon(UPnPDeviceTreeNode.ACTION));
- icons.put(UPnPDeviceTreeNode.STATE,
loadIcon(UPnPDeviceTreeNode.STATE));
- } catch (Exception ex) {
- System.out.println(ex);
- }
-
- }
-
- public JToolTip createToolTip() {
- JToolTip tip = super.createToolTip();
- tip.setBackground(Color.yellow);
- return tip;
- }
-
- //test to display animated gif
- /*
- public boolean imageUpdate(Image img, int infoflags,
- int x, int y, int width, int height){
- //System.out.println("image update");
- Mediator.getUPnPDeviceTree().validate();
- Mediator.getUPnPDeviceTree().repaint();
- return true;
- }
- */
-
- public Component getTreeCellRendererComponent(JTree tree, Object value,
- boolean sel, boolean expanded, boolean leaf, int row,
- boolean hasFocus) {
- Icon icon = selectIcon((UPnPDeviceTreeNode) value);
- setToolTip((UPnPDeviceTreeNode) value);
- if (icon != null) {
- setOpenIcon(icon);
- setClosedIcon(icon);
- setLeafIcon(icon);
- } else {
- setOpenIcon(getDefaultOpenIcon());
- setClosedIcon(getDefaultClosedIcon());
- setLeafIcon(getDefaultLeafIcon());
- }
- return super.getTreeCellRendererComponent(tree, value, sel,
expanded,
- leaf, row, hasFocus);
- }
-
- public Icon selectIcon(UPnPDeviceTreeNode node) {
- Icon icon = null;
- try {
- String tag = node.category;
- icon = (Icon) icons.get(tag);
- } catch (Exception ex) {
- System.out.println("getTreeCellRendererComponent Exception:" + ex);
- }
- return icon;
- }
-
- public void setToolTip(UPnPDeviceTreeNode node) {
- String tag = node.category;
- if (tag.equals(UPnPDeviceTreeNode.ROOT_DEVICE)
- ||tag.equals(UPnPDeviceTreeNode.DEVICE))
- {
- DeviceNode device = (DeviceNode) node.getUserObject();
- setToolTipText("<html><TABLE BORDER='0' CELLPADDING='0'
CELLSPACING='0' ><TR BGCOLOR='#F9FF79' ><TD>"
- +
device.getReference().getProperty(UPnPDevice.FRIENDLY_NAME).toString()
- +"</TD></TR></TABLE ></html>");
- }
- else
- setToolTipText(null);
- }
-
- public static ImageIcon loadIcon(String name)
- {
- try {
- /*
- System.out.println("loading image ..."+name);
- System.out.println("from "+"IMAGES/" + name + ".gif");
- */
- URL eventIconUrl = UPnPDeviceTreeNode.class.getResource("IMAGES/"
+ name + ".gif");
- return new ImageIcon(eventIconUrl,name);
- }
- catch (Exception ex){
- System.out.println("Resource:" + name + " not found : "
+ ex.toString());
- return null;
- }
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.felix.upnp.tester.gui;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.image.ImageObserver;
+import java.net.URL;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+
+import javax.swing.Icon;
+import javax.swing.ImageIcon;
+import javax.swing.JToolTip;
+import javax.swing.JTree;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.DefaultTreeCellRenderer;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.service.upnp.UPnPAction;
+import org.osgi.service.upnp.UPnPDevice;
+import org.osgi.service.upnp.UPnPService;
+import org.osgi.service.upnp.UPnPStateVariable;
+
+import org.apache.felix.upnp.tester.discovery.DeviceNode;
+
+/*
+* @author <a href="mailto:[EMAIL PROTECTED]">Felix Project Team</a>
+*/
+public class UPnPDeviceTreeNode extends DefaultMutableTreeNode {
+ public final static String ROOT_DEVICE = "RootDeviceNode";
+ public final static String DEVICE = "DeviceNode";
+ public final static String SERVICE = "UPnPService";
+ public final static String ACTION = "UPnPAction";
+ public final static String STATE = "UPnPStateVariable";
+ public final static String EVENTED_STATE = "EventedStateVariable";
+ public final static String SUBSCRIBED_STATE = "SubscribedStateVariable";
+
+ protected String category;
+ public UPnPDeviceTreeNode(String obj) {
+ super(obj);
+ category = obj.getClass().getName();
+ }
+
+ public UPnPDeviceTreeNode(DeviceNode obj, BundleContext ctx) {
+ super(obj);
+
+ if (obj.isRoot()) category = ROOT_DEVICE;
+ else category = DEVICE;
+
+ UPnPDevice device =
(UPnPDevice)ctx.getService(obj.getReference());
+ UPnPService[] services = device.getServices();
+
+ Collection nodeChildren = obj.getChildren();
+ if (nodeChildren != null){
+ Iterator list = nodeChildren.iterator();
+ while (list.hasNext()){
+ DeviceNode node = (DeviceNode)list.next();
+ this.add(new UPnPDeviceTreeNode(node,ctx));
+ }
+ }
+ if (services != null){
+ for (int i=0;i<services.length;i++)
+ this.add(new UPnPDeviceTreeNode(services[i]));
+ }
+
+ }
+
+ public UPnPDeviceTreeNode(UPnPService obj) {
+ super(obj);
+ category = SERVICE;
+ UPnPStateVariable[] variables = obj.getStateVariables();
+ if (variables != null){
+ for (int i=0;i<variables.length;i++)
+ this.add(new UPnPDeviceTreeNode(variables[i]));
+ }
+ UPnPAction[] actions = obj.getActions();
+ if (actions != null){
+ for (int i=0;i<actions.length;i++)
+ this.add(new UPnPDeviceTreeNode(actions[i]));
+ }
+ }
+ public UPnPDeviceTreeNode(UPnPAction obj) {
+ super(obj);
+ category = ACTION;
+ }
+
+ public UPnPDeviceTreeNode(UPnPStateVariable obj) {
+ super(obj);
+ if (obj.sendsEvents()) category = EVENTED_STATE;
+ else category = STATE;
+ }
+
+ public String toString() {
+ if (category.equals(DEVICE)||category.equals(ROOT_DEVICE)){
+ DeviceNode node = (DeviceNode) getUserObject();
+ return node.toString();
+ }
+ else if (category.equals(SERVICE)){
+ UPnPService node = (UPnPService) getUserObject();
+ return node.getType();
+ }
+ else if (category.equals(ACTION)){
+ UPnPAction node = (UPnPAction) getUserObject();
+ return node.getName();
+ }
+ else if (category.equals(STATE)
||category.equals(EVENTED_STATE)||category.equals(SUBSCRIBED_STATE)){
+ UPnPStateVariable node = (UPnPStateVariable)
getUserObject();
+ return node.getName();
+ }
+ else
+ return getUserObject().toString();
+ }
+}
+
+// local class for JTree icon renderer
+class TreeNodeCellRenderer extends DefaultTreeCellRenderer implements
ImageObserver{
+
+ private HashMap icons ;
+ ImageIcon image;
+ public TreeNodeCellRenderer() {
+ super();
+ icons = new HashMap();
+ try {
+ icons.put(UPnPDeviceTreeNode.EVENTED_STATE,
loadIcon(UPnPDeviceTreeNode.EVENTED_STATE));
+ image = loadIcon(UPnPDeviceTreeNode.SUBSCRIBED_STATE);
+ // to use animate gif
+ //image.setImageObserver(this);
+ icons.put(UPnPDeviceTreeNode.SUBSCRIBED_STATE, image);
+
+ icons.put(UPnPDeviceTreeNode.ROOT_DEVICE,
loadIcon(UPnPDeviceTreeNode.ROOT_DEVICE));
+ icons.put(UPnPDeviceTreeNode.DEVICE,
loadIcon(UPnPDeviceTreeNode.DEVICE));
+ icons.put(UPnPDeviceTreeNode.SERVICE,
loadIcon(UPnPDeviceTreeNode.SERVICE));
+ icons.put(UPnPDeviceTreeNode.ACTION,
loadIcon(UPnPDeviceTreeNode.ACTION));
+ icons.put(UPnPDeviceTreeNode.STATE,
loadIcon(UPnPDeviceTreeNode.STATE));
+ } catch (Exception ex) {
+ System.out.println(ex);
+ }
+
+ }
+
+ public JToolTip createToolTip() {
+ JToolTip tip = super.createToolTip();
+ tip.setBackground(Color.yellow);
+ return tip;
+ }
+
+ //test to display animated gif
+ /*
+ public boolean imageUpdate(Image img, int infoflags,
+ int x, int y, int width, int height){
+ //System.out.println("image update");
+ Mediator.getUPnPDeviceTree().validate();
+ Mediator.getUPnPDeviceTree().repaint();
+ return true;
+ }
+ */
+
+ public Component getTreeCellRendererComponent(JTree tree, Object value,
+ boolean sel, boolean expanded, boolean leaf, int row,
+ boolean hasFocus) {
+ Icon icon = selectIcon((UPnPDeviceTreeNode) value);
+ setToolTip((UPnPDeviceTreeNode) value);
+ if (icon != null) {
+ setOpenIcon(icon);
+ setClosedIcon(icon);
+ setLeafIcon(icon);
+ } else {
+ setOpenIcon(getDefaultOpenIcon());
+ setClosedIcon(getDefaultClosedIcon());
+ setLeafIcon(getDefaultLeafIcon());
+ }
+ return super.getTreeCellRendererComponent(tree, value, sel,
expanded,
+ leaf, row, hasFocus);
+ }
+
+ public Icon selectIcon(UPnPDeviceTreeNode node) {
+ Icon icon = null;
+ try {
+ String tag = node.category;
+ icon = (Icon) icons.get(tag);
+ } catch (Exception ex) {
+ System.out.println("getTreeCellRendererComponent Exception:" + ex);
+ }
+ return icon;
+ }
+
+ public void setToolTip(UPnPDeviceTreeNode node) {
+ String tag = node.category;
+ if (tag.equals(UPnPDeviceTreeNode.ROOT_DEVICE)
+ ||tag.equals(UPnPDeviceTreeNode.DEVICE))
+ {
+ DeviceNode device = (DeviceNode) node.getUserObject();
+ setToolTipText("<html><TABLE BORDER='0' CELLPADDING='0'
CELLSPACING='0' ><TR BGCOLOR='#F9FF79' ><TD>"
+ +
device.getReference().getProperty(UPnPDevice.FRIENDLY_NAME).toString()
+ +"</TD></TR></TABLE ></html>");
+ }
+ else
+ setToolTipText(null);
+ }
+
+ public static ImageIcon loadIcon(String name)
+ {
+ try {
+ /*
+ System.out.println("loading image ..."+name);
+ System.out.println("from "+"IMAGES/" + name + ".gif");
+ */
+ URL eventIconUrl = UPnPDeviceTreeNode.class.getResource("IMAGES/"
+ name + ".gif");
+ return new ImageIcon(eventIconUrl,name);
+ }
+ catch (Exception ex){
+ System.out.println("Resource:" + name + " not found : "
+ ex.toString());
+ return null;
+ }
+ }
+
+}
Propchange:
felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/UPnPDeviceTreeNode.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/UPnPDeviceTreeNode.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange:
felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/UPnPDeviceTreeNode.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified:
felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/Util.java
URL:
http://svn.apache.org/viewvc/felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/Util.java?rev=674879&r1=674878&r2=674879&view=diff
==============================================================================
---
felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/Util.java
(original)
+++
felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/Util.java
Tue Jul 8 09:59:54 2008
@@ -1,104 +1,104 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.felix.upnp.tester.gui;
-
-import java.awt.GridBagConstraints;
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-
-/*
-* @author <a href="mailto:[EMAIL PROTECTED]">Felix Project Team</a>
-*/
-
-public class Util {
- final static GridBagConstraints constrains = new GridBagConstraints();
-
- public static GridBagConstraints setConstrains(int x,int y,int w,int
h,int wx, int wy)
- {
- constrains.insets.left=5;
- constrains.insets.right=5;
- constrains.insets.bottom=3;
- constrains.fill=GridBagConstraints.BOTH;
- constrains.anchor=GridBagConstraints.WEST;
- constrains.gridx=x;
- constrains.gridy=y;
- constrains.gridwidth=w;
- constrains.gridheight=h;
- constrains.weightx=wx;
- constrains.weighty=wy;
- return constrains;
- }
-
- public static String justString(Object obj){
- if (obj == null) return "";
- else if (obj instanceof String[]){
- String[] items = (String[])obj;
- String tmp = "";
- for (int i = 0; i < items.length; i++) {
- tmp+=items[i]+"; ";
- }
- return tmp;
- }
- return obj.toString();
- }
-
- public static void openUrl(String url) {
- try {
- if (url == null) return;
- String os=System.getProperty("os.name","").toLowerCase();
- Process p = null;
- if(os.indexOf("windows")!=-1){
- String cmd = null;
- cmd = "cmd.exe /C start "+url;
- LogPanel.log("[Executing cmd] " +cmd);
- p = Runtime.getRuntime().exec(cmd);
-
- }else if(os.indexOf("linux")!=-1){
- String[] cmd = new String[]{
- "/bin/sh",
- "-c",
- "( $BROWSER " + url + " || mozilla-firefox '" +
url + "' || firefox '" + url
- + "' || mozilla '" + url + "' || konqueror '" +
url + "' || opera '" + url + "' )"
- };
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < cmd.length; i++) {
- sb.append(" ").append(cmd[i]);
-
- }
- LogPanel.log("[Executing cmd] " +sb.toString());
- p = Runtime.getRuntime().exec(cmd);
- }
- BufferedReader err = new BufferedReader(new
InputStreamReader(p.getErrorStream()));
- BufferedReader out = new BufferedReader(new
InputStreamReader(p.getInputStream()));
- while (true) {
- while(err.ready()) System.err.println(err.readLine());
- while(out.ready()) System.out.println(out.readLine());
- try{
- p.exitValue();
- break;
- }catch (IllegalThreadStateException e) {
- }
- }
- } catch (Exception ex){
- System.out.println(ex);
- }
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.felix.upnp.tester.gui;
+
+import java.awt.GridBagConstraints;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+
+/*
+* @author <a href="mailto:[EMAIL PROTECTED]">Felix Project Team</a>
+*/
+
+public class Util {
+ final static GridBagConstraints constrains = new GridBagConstraints();
+
+ public static GridBagConstraints setConstrains(int x,int y,int w,int
h,int wx, int wy)
+ {
+ constrains.insets.left=5;
+ constrains.insets.right=5;
+ constrains.insets.bottom=3;
+ constrains.fill=GridBagConstraints.BOTH;
+ constrains.anchor=GridBagConstraints.WEST;
+ constrains.gridx=x;
+ constrains.gridy=y;
+ constrains.gridwidth=w;
+ constrains.gridheight=h;
+ constrains.weightx=wx;
+ constrains.weighty=wy;
+ return constrains;
+ }
+
+ public static String justString(Object obj){
+ if (obj == null) return "";
+ else if (obj instanceof String[]){
+ String[] items = (String[])obj;
+ String tmp = "";
+ for (int i = 0; i < items.length; i++) {
+ tmp+=items[i]+"; ";
+ }
+ return tmp;
+ }
+ return obj.toString();
+ }
+
+ public static void openUrl(String url) {
+ try {
+ if (url == null) return;
+ String os=System.getProperty("os.name","").toLowerCase();
+ Process p = null;
+ if(os.indexOf("windows")!=-1){
+ String cmd = null;
+ cmd = "cmd.exe /C start "+url;
+ LogPanel.log("[Executing cmd] " +cmd);
+ p = Runtime.getRuntime().exec(cmd);
+
+ }else if(os.indexOf("linux")!=-1){
+ String[] cmd = new String[]{
+ "/bin/sh",
+ "-c",
+ "( $BROWSER " + url + " || mozilla-firefox '" +
url + "' || firefox '" + url
+ + "' || mozilla '" + url + "' || konqueror '" +
url + "' || opera '" + url + "' )"
+ };
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < cmd.length; i++) {
+ sb.append(" ").append(cmd[i]);
+
+ }
+ LogPanel.log("[Executing cmd] " +sb.toString());
+ p = Runtime.getRuntime().exec(cmd);
+ }
+ BufferedReader err = new BufferedReader(new
InputStreamReader(p.getErrorStream()));
+ BufferedReader out = new BufferedReader(new
InputStreamReader(p.getInputStream()));
+ while (true) {
+ while(err.ready()) System.err.println(err.readLine());
+ while(out.ready()) System.out.println(out.readLine());
+ try{
+ p.exitValue();
+ break;
+ }catch (IllegalThreadStateException e) {
+ }
+ }
+ } catch (Exception ex){
+ System.out.println(ex);
+ }
+ }
+
+}
Propchange:
felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/Util.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/Util.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange:
felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/Util.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified:
felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/test.java
URL:
http://svn.apache.org/viewvc/felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/test.java?rev=674879&r1=674878&r2=674879&view=diff
==============================================================================
---
felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/test.java
(original)
+++
felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/test.java
Tue Jul 8 09:59:54 2008
@@ -1,79 +1,79 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.felix.upnp.tester;
-
-import java.awt.Image;
-import java.net.URL;
-
-import javax.swing.ImageIcon;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-
-public class test extends JFrame {
-
- Image image;
-
- public test(String filename) {
- super(filename);
- setDefaultCloseOperation(EXIT_ON_CLOSE);
- //image = getToolkit().getImage(filename);
- ImageIcon image =loadIcon("EventedStateVariable");
- //image.setImageObserver(this);
- JPanel panel = new JPanel();
-
- panel.add(new JLabel(image));
- JLabel lab = new JLabel();
- lab.setIcon(image);
- panel.add(lab);
- this.getContentPane().add(panel);
- }
-
- /*public void paint(Graphics g) {
- super.paint(g);
- g.drawImage(image, 25, 25, this);
- }*/
-
- public static void main(String args[]) {
- if (args.length > 0) {
- JFrame f = new test(args[0]);
- f.setSize(300, 300);
- f.show();
- } else {
- System.err.println(
- "You must specify an image filename to display");
- }
- }
-
-
- public static ImageIcon loadIcon(String name)
- {
- try {
- //System.out.println("loading image ..."+path);
- URL eventIconUrl = test.class.getResource("images/" + name +
".gif");
- return new ImageIcon(eventIconUrl,name);
- }
- catch (Exception ex){
- System.out.println("Resource:" + name + " not found : "
+ ex.toString());
- return null;
- }
- }
-
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.felix.upnp.tester;
+
+import java.awt.Image;
+import java.net.URL;
+
+import javax.swing.ImageIcon;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+
+public class test extends JFrame {
+
+ Image image;
+
+ public test(String filename) {
+ super(filename);
+ setDefaultCloseOperation(EXIT_ON_CLOSE);
+ //image = getToolkit().getImage(filename);
+ ImageIcon image =loadIcon("EventedStateVariable");
+ //image.setImageObserver(this);
+ JPanel panel = new JPanel();
+
+ panel.add(new JLabel(image));
+ JLabel lab = new JLabel();
+ lab.setIcon(image);
+ panel.add(lab);
+ this.getContentPane().add(panel);
+ }
+
+ /*public void paint(Graphics g) {
+ super.paint(g);
+ g.drawImage(image, 25, 25, this);
+ }*/
+
+ public static void main(String args[]) {
+ if (args.length > 0) {
+ JFrame f = new test(args[0]);
+ f.setSize(300, 300);
+ f.show();
+ } else {
+ System.err.println(
+ "You must specify an image filename to display");
+ }
+ }
+
+
+ public static ImageIcon loadIcon(String name)
+ {
+ try {
+ //System.out.println("loading image ..."+path);
+ URL eventIconUrl = test.class.getResource("images/" + name +
".gif");
+ return new ImageIcon(eventIconUrl,name);
+ }
+ catch (Exception ex){
+ System.out.println("Resource:" + name + " not found : "
+ ex.toString());
+ return null;
+ }
+ }
+
}
Propchange:
felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/test.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/test.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange:
felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/test.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Propchange:
felix/trunk/upnp/tester/src/main/resources/org/apache/felix/upnp/tester/gui/IMAGES/AnimatedStateVariable.gif
------------------------------------------------------------------------------
--- svn:mime-type (original)
+++ svn:mime-type Tue Jul 8 09:59:54 2008
@@ -1 +1 @@
-application/octet-stream
+image/gif
Propchange:
felix/trunk/upnp/tester/src/main/resources/org/apache/felix/upnp/tester/gui/IMAGES/DeviceNode.gif
------------------------------------------------------------------------------
--- svn:mime-type (original)
+++ svn:mime-type Tue Jul 8 09:59:54 2008
@@ -1 +1 @@
-application/octet-stream
+image/gif
Propchange:
felix/trunk/upnp/tester/src/main/resources/org/apache/felix/upnp/tester/gui/IMAGES/EventedStateVariable.gif
------------------------------------------------------------------------------
--- svn:mime-type (original)
+++ svn:mime-type Tue Jul 8 09:59:54 2008
@@ -1 +1 @@
-application/octet-stream
+image/gif
Propchange:
felix/trunk/upnp/tester/src/main/resources/org/apache/felix/upnp/tester/gui/IMAGES/RootDeviceNode.gif
------------------------------------------------------------------------------
--- svn:mime-type (original)
+++ svn:mime-type Tue Jul 8 09:59:54 2008
@@ -1 +1 @@
-application/octet-stream
+image/gif
Propchange:
felix/trunk/upnp/tester/src/main/resources/org/apache/felix/upnp/tester/gui/IMAGES/SubscribedStateVariable.gif
------------------------------------------------------------------------------
--- svn:mime-type (original)
+++ svn:mime-type Tue Jul 8 09:59:54 2008
@@ -1 +1 @@
-application/octet-stream
+image/gif
Propchange:
felix/trunk/upnp/tester/src/main/resources/org/apache/felix/upnp/tester/gui/IMAGES/UPnPAction.gif
------------------------------------------------------------------------------
--- svn:mime-type (original)
+++ svn:mime-type Tue Jul 8 09:59:54 2008
@@ -1 +1 @@
-application/octet-stream
+image/gif
Propchange:
felix/trunk/upnp/tester/src/main/resources/org/apache/felix/upnp/tester/gui/IMAGES/UPnPService.gif
------------------------------------------------------------------------------
--- svn:mime-type (original)
+++ svn:mime-type Tue Jul 8 09:59:54 2008
@@ -1 +1 @@
-application/octet-stream
+image/gif
Propchange:
felix/trunk/upnp/tester/src/main/resources/org/apache/felix/upnp/tester/gui/IMAGES/UPnPStateVariable.gif
------------------------------------------------------------------------------
--- svn:mime-type (original)
+++ svn:mime-type Tue Jul 8 09:59:54 2008
@@ -1 +1 @@
-application/octet-stream
+image/gif
Propchange:
felix/trunk/upnp/tester/src/main/resources/org/apache/felix/upnp/tester/gui/IMAGES/logo.gif
------------------------------------------------------------------------------
--- svn:mime-type (original)
+++ svn:mime-type Tue Jul 8 09:59:54 2008
@@ -1 +1 @@
-application/octet-stream
+image/gif