You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by le...@apache.org on 2008/07/08 18:59:57 UTC

svn commit: r674879 [11/12] - in /felix/trunk/upnp: ./ basedriver/ basedriver/src/main/java/org/apache/felix/upnp/basedriver/ basedriver/src/main/java/org/apache/felix/upnp/basedriver/controller/ basedriver/src/main/java/org/apache/felix/upnp/basedrive...

Modified: felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/ActionPanel.java
URL: http://svn.apache.org/viewvc/felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/ActionPanel.java?rev=674879&r1=674878&r2=674879&view=diff
==============================================================================
--- felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/ActionPanel.java (original)
+++ felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/ActionPanel.java Tue Jul  8 09:59:54 2008
@@ -1,366 +1,366 @@
-/* 
- * 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.BorderLayout;
-import java.awt.Component;
-import java.awt.GridBagLayout;
-import java.awt.event.ActionEvent;
-import java.util.Dictionary;
-import java.util.Hashtable;
-
-import javax.swing.AbstractAction;
-import javax.swing.AbstractCellEditor;
-import javax.swing.DefaultCellEditor;
-import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JOptionPane;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JSlider;
-import javax.swing.JTable;
-import javax.swing.JTextField;
-import javax.swing.SwingConstants;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
-import javax.swing.event.TableModelEvent;
-import javax.swing.table.AbstractTableModel;
-import javax.swing.table.TableCellEditor;
-import javax.swing.table.TableModel;
-
-import org.osgi.service.upnp.UPnPAction;
-import org.osgi.service.upnp.UPnPException;
-import org.osgi.service.upnp.UPnPStateVariable;
-
-import org.apache.felix.upnp.basedriver.util.Converter;
-import org.apache.felix.upnp.tester.Mediator;
-
-/* 
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-public class ActionPanel extends JPanel {
-	
-	UPnPAction action;
-	ArgumentsModel argsModel;
-	MyTable table; 
-	JPanel buttonPanel;
-	
-	OutputArgumentsModel outArgsModel; 
-	JTable outTable; 
-	
-	/**
-	 * 
-	 */
-	public ActionPanel() {
-		super(new GridBagLayout());
-		buildButtonPanel();
-		buildTable();
-		add(new JScrollPane(table),Util.setConstrains(0,0,1,1,100,100));
-		add(new JScrollPane(outTable),Util.setConstrains(0,1,1,1,100,100)); 
-		add(buttonPanel,Util.setConstrains(1,0,1,1,1,1));
-	}
-
-	private void buildButtonPanel(){
-		buttonPanel = new JPanel();
-		JButton doAction = new JButton("Do Action");
-		doAction.addActionListener(new AbstractAction(){
-			public void actionPerformed(ActionEvent e) {
-				outArgsModel.clearData(); 
-
-				Dictionary params = null;
-				Dictionary result = null;
-				if (argsModel.getRowCount()!= 0){
-					if (table.isEditing()) table.getCellEditor().stopCellEditing();
-					params = new Hashtable();
-					for (int i =0;i<argsModel.getRowCount();i++){
-						String name = (String) argsModel.getValueAt(i,0);
-						String value = (String)argsModel.getValueAt(i,3);
-						try {
-                            params.put(
-                            	name,
-                                Converter.parseString(
-                                    value,
-                                    action.getStateVariable(name).getUPnPDataType()));
-                        } catch (Exception ex) {
-                        	LogPanel.log("Error invoking action (bad parameter)");
-                         	return ;
-                        }
-					}
-				}
-				try {result = action.invoke(params);}
-                catch (UPnPException ex){
-                    String error =  
-                        "===== Action Failed =====" +
-                        "\nUPnP Error Code::\n    " +ex.getUPnPError_Code() +
-                        "\nUPnP Error Description::\n    " +ex.getMessage();
-                    printReport(params,error);
-                    JOptionPane.showMessageDialog(
-                        Mediator.getPropertiesViewer(),error);                   
-                }
-                catch (Exception ex){
-                    printReport(params,ex.getMessage());
-					JOptionPane.showMessageDialog(
-						Mediator.getPropertiesViewer(),
-						ex.getMessage()
-					);
-				}
-				if (result != null) {
-                    printReport(params,result);
-					outArgsModel.setData(action,result);
-					JOptionPane.showMessageDialog(
-						Mediator.getPropertiesViewer(),
-						"Action invoked!"
-					);
-				
-				}
-			}
-            private void printReport(Dictionary params,Object result) {
-                String input = "";
-                String output = "";
-                if (params != null) input = params.toString();
-                if (output != null) output = result.toString();
-                String method = action.getName();
-                String report = "\n==== Action:: " + method + " ====\n"
-                                + input 
-                                + "\n----------- result ----------\n"
-                                + output
-                                + "\n-----------------------------";
-               LogPanel.log(report);
-            }
-		});		
-	    buttonPanel.add(doAction);
-	}
-	
-	private void buildTable(){
-		argsModel = new ArgumentsModel();
-	    table = new MyTable(argsModel); 
-		argsModel.setTable(table); 		
-
-		outArgsModel = new OutputArgumentsModel();
-	    outTable = new JTable(outArgsModel); 
-	}
-
-	public void setArguments(UPnPAction action){
-		this.action = action;
-		argsModel.setData(action);		
-		outArgsModel.clearData(); 
-	}
-	
-}
-
-//thanks to Thomas Wagner 18/10/2005
-class OutputArgumentsModel extends ArgumentsModel { 
-
-	public OutputArgumentsModel() {
-		super();
-        header = new String[]{"output arg name","related Var","Java \\ UpnP type","value"};
-	}
-
-	public void clearData() {
-		names = new String[]{""};
-        related = new String[]{""};
-    	types = new String[]{""};
-    	values = new String[]{""};
-		size=0;
-		this.fireTableChanged(new TableModelEvent(this));
-	}
-
-    public void setData(UPnPAction  action, Object result){
-
-		Hashtable res = (Hashtable) result;
-
-        String[] names = action.getOutputArgumentNames();
-   	    size = 0;
-    	this.names = names;
-    	if (names!=null){
-	    	values = new String[names.length];
-            types = new String[names.length];
-            related = new String[names.length];
-	    	for (int i=0;i<names.length;i++) {
-                UPnPStateVariable currentStateVar = action.getStateVariable(names[i]);
-
-				Object value = res.get(names[i]);
-                values[i]=value.toString();
-                related[i] = currentStateVar.getName();
-                
-                String javaType =currentStateVar.getJavaDataType().toString();
-                javaType = javaType.substring(javaType.lastIndexOf('.')+1);
-                String upnpType = currentStateVar.getUPnPDataType();
-                types[i] = javaType + " \\ " + upnpType;
-            }   	
-	    	size = names.length;
-    	}
-		this.fireTableChanged(new TableModelEvent(this));
-    }
-}
-
-//thanks to Thomas Wagner 12/10/2005
-class ArgumentsModel extends  AbstractTableModel {
-	int size = 0;
-	private MyTable table;	
-	String[] names = new String[]{""};
-    String[] related = new String[]{""};
-    String[] types = new String[]{""};
-    String[] values = new String[]{""};
-	String[] header = new String[]{"arg name","related Var","Java \\ UpnP type","value"};
-   
-	public void setTable(MyTable table) { 
-		this.table = table;
-	}
- 
-	public int getColumnCount() { return 4; }
-    public int getRowCount() { return size;}
-    public String getColumnName(int col) { return header[col]; }
-    public boolean isCellEditable(int rowIndex, int columnIndex) {
-    	return (columnIndex ==3);
-    }
-    public Object getValueAt(int row, int col) { 
-    	if (col == 0) return names[row];
-        else if (col == 1) return related[row];
-        else if (col == 2) return types[row];
-        else if (col == 3) return values[row];
-    	return null;
-	}   
-    public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
-    	values[rowIndex]= (String) aValue; 
-    }
-
-    public void setData(UPnPAction  action){
-
-		table.deleteMyCellEditors();
-        
-
-        String[] names = action.getInputArgumentNames();
-   	    size = 0;
-    	this.names = names;
-    	if (names!=null){
-	    	values = new String[names.length];
-            related = new String[names.length];
-            types = new String[names.length];
-	    	for (int i=0;i<names.length;i++) {
-                values[i]="";
-                UPnPStateVariable currentStateVar = action.getStateVariable(names[i]);
-                related[i] = currentStateVar.getName();
-                String javaType = currentStateVar.getJavaDataType().toString();
-                javaType = javaType.substring(javaType.lastIndexOf('.')+1);
-                String upnpType = currentStateVar.getUPnPDataType();
-                types[i] = javaType + " \\ " + upnpType;
-
-				//handle allowed value list
-				if ( currentStateVar.getAllowedValues() != null) {
-					String av[] = currentStateVar.getAllowedValues();
-					JComboBox comboBox = new JComboBox();
-					for (int j = 0; j < av.length; j++) {
-						comboBox.addItem(av[j]);
-					}
-					values[i] = av[0]; //preset the first value from list
-					table.setMyCellEditor(new DefaultCellEditor(comboBox),i);
-				}
-
-				//handle default value
-				if (currentStateVar.getDefaultValue() != null) {
-					String val = currentStateVar.getDefaultValue().toString();
-					if(val.length() > 0)
-						values[i] = val;
-				}
-				
-               //handle range values
-               if ((currentStateVar.getMaximum()!= null)
-                   &&(currentStateVar.getMinimum()!= null)){
-                   int max = currentStateVar.getMaximum().intValue();
-                   int min = currentStateVar.getMinimum().intValue();
-                   int value = min;
-                   try { value = Integer.parseInt(values[i]);}
-                   catch (NumberFormatException ignored){}
-                   table.setMyCellEditor(new SliderEditor(min,max,value),i);
-               }
-
-            }   	
-	    	size = names.length;
-    	}
-		this.fireTableChanged(new TableModelEvent(this));
-        this.fireTableStructureChanged();
-    }
-}
-
-// thanks to Thomas Wagner 12/10/2005
-class MyTable extends JTable { 
-
-	private Hashtable cellEditors;
-	
-	public MyTable(TableModel dm) {
-		super(dm);
-		cellEditors = new Hashtable();
-	}
-
-	public void setMyCellEditor(TableCellEditor editor,int col){
-		cellEditors.put(new Integer(col),editor);
-	}
-
-	public void deleteMyCellEditors(){
-		cellEditors.clear();
-	}
-
-	//overwritten JTable method	
-	public TableCellEditor getCellEditor(int row,int col) {
-		TableCellEditor tce = (TableCellEditor) cellEditors.get(new Integer(row));
-		if( tce != null) {
-			return tce;
-		} else {
-			return super.getCellEditor(row,col);
-		}
-	}
-}
-
-class SliderEditor extends AbstractCellEditor implements TableCellEditor
-{
-    JPanel editor;
-    JTextField text;
-    JSlider slider;
-    public SliderEditor(int min, int max, int value){
-         editor = new JPanel(new BorderLayout());
-         //editor.setBorder(new EmptyBorder(1,0,1,0));
-         text = new JTextField(Integer.toString(max).length());
-         slider = new JSlider(SwingConstants.HORIZONTAL,min,max,value);
-         editor.add(text,BorderLayout.WEST);
-         editor.add(slider);
-         slider.addChangeListener(new ChangeListener(){
-            public void stateChanged(ChangeEvent e) {
-                //if (! replSlider.getValueIsAdjusting()){
-                text.setText(new Integer(slider.getValue()).toString());
-                //}
-            }
-         });
-
-    }
-    
-    public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
-        text.setText((String) value);
-        try {
-            slider.setValue(Integer.parseInt((String)value));
-        } catch (NumberFormatException ignored) {}
-        return editor;
-    }
-
-    public Object getCellEditorValue() {
-        return text.getText();
-    }
-}
-
+/* 
+ * 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.BorderLayout;
+import java.awt.Component;
+import java.awt.GridBagLayout;
+import java.awt.event.ActionEvent;
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import javax.swing.AbstractAction;
+import javax.swing.AbstractCellEditor;
+import javax.swing.DefaultCellEditor;
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JSlider;
+import javax.swing.JTable;
+import javax.swing.JTextField;
+import javax.swing.SwingConstants;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+import javax.swing.event.TableModelEvent;
+import javax.swing.table.AbstractTableModel;
+import javax.swing.table.TableCellEditor;
+import javax.swing.table.TableModel;
+
+import org.osgi.service.upnp.UPnPAction;
+import org.osgi.service.upnp.UPnPException;
+import org.osgi.service.upnp.UPnPStateVariable;
+
+import org.apache.felix.upnp.basedriver.util.Converter;
+import org.apache.felix.upnp.tester.Mediator;
+
+/* 
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+public class ActionPanel extends JPanel {
+	
+	UPnPAction action;
+	ArgumentsModel argsModel;
+	MyTable table; 
+	JPanel buttonPanel;
+	
+	OutputArgumentsModel outArgsModel; 
+	JTable outTable; 
+	
+	/**
+	 * 
+	 */
+	public ActionPanel() {
+		super(new GridBagLayout());
+		buildButtonPanel();
+		buildTable();
+		add(new JScrollPane(table),Util.setConstrains(0,0,1,1,100,100));
+		add(new JScrollPane(outTable),Util.setConstrains(0,1,1,1,100,100)); 
+		add(buttonPanel,Util.setConstrains(1,0,1,1,1,1));
+	}
+
+	private void buildButtonPanel(){
+		buttonPanel = new JPanel();
+		JButton doAction = new JButton("Do Action");
+		doAction.addActionListener(new AbstractAction(){
+			public void actionPerformed(ActionEvent e) {
+				outArgsModel.clearData(); 
+
+				Dictionary params = null;
+				Dictionary result = null;
+				if (argsModel.getRowCount()!= 0){
+					if (table.isEditing()) table.getCellEditor().stopCellEditing();
+					params = new Hashtable();
+					for (int i =0;i<argsModel.getRowCount();i++){
+						String name = (String) argsModel.getValueAt(i,0);
+						String value = (String)argsModel.getValueAt(i,3);
+						try {
+                            params.put(
+                            	name,
+                                Converter.parseString(
+                                    value,
+                                    action.getStateVariable(name).getUPnPDataType()));
+                        } catch (Exception ex) {
+                        	LogPanel.log("Error invoking action (bad parameter)");
+                         	return ;
+                        }
+					}
+				}
+				try {result = action.invoke(params);}
+                catch (UPnPException ex){
+                    String error =  
+                        "===== Action Failed =====" +
+                        "\nUPnP Error Code::\n    " +ex.getUPnPError_Code() +
+                        "\nUPnP Error Description::\n    " +ex.getMessage();
+                    printReport(params,error);
+                    JOptionPane.showMessageDialog(
+                        Mediator.getPropertiesViewer(),error);                   
+                }
+                catch (Exception ex){
+                    printReport(params,ex.getMessage());
+					JOptionPane.showMessageDialog(
+						Mediator.getPropertiesViewer(),
+						ex.getMessage()
+					);
+				}
+				if (result != null) {
+                    printReport(params,result);
+					outArgsModel.setData(action,result);
+					JOptionPane.showMessageDialog(
+						Mediator.getPropertiesViewer(),
+						"Action invoked!"
+					);
+				
+				}
+			}
+            private void printReport(Dictionary params,Object result) {
+                String input = "";
+                String output = "";
+                if (params != null) input = params.toString();
+                if (output != null) output = result.toString();
+                String method = action.getName();
+                String report = "\n==== Action:: " + method + " ====\n"
+                                + input 
+                                + "\n----------- result ----------\n"
+                                + output
+                                + "\n-----------------------------";
+               LogPanel.log(report);
+            }
+		});		
+	    buttonPanel.add(doAction);
+	}
+	
+	private void buildTable(){
+		argsModel = new ArgumentsModel();
+	    table = new MyTable(argsModel); 
+		argsModel.setTable(table); 		
+
+		outArgsModel = new OutputArgumentsModel();
+	    outTable = new JTable(outArgsModel); 
+	}
+
+	public void setArguments(UPnPAction action){
+		this.action = action;
+		argsModel.setData(action);		
+		outArgsModel.clearData(); 
+	}
+	
+}
+
+//thanks to Thomas Wagner 18/10/2005
+class OutputArgumentsModel extends ArgumentsModel { 
+
+	public OutputArgumentsModel() {
+		super();
+        header = new String[]{"output arg name","related Var","Java \\ UpnP type","value"};
+	}
+
+	public void clearData() {
+		names = new String[]{""};
+        related = new String[]{""};
+    	types = new String[]{""};
+    	values = new String[]{""};
+		size=0;
+		this.fireTableChanged(new TableModelEvent(this));
+	}
+
+    public void setData(UPnPAction  action, Object result){
+
+		Hashtable res = (Hashtable) result;
+
+        String[] names = action.getOutputArgumentNames();
+   	    size = 0;
+    	this.names = names;
+    	if (names!=null){
+	    	values = new String[names.length];
+            types = new String[names.length];
+            related = new String[names.length];
+	    	for (int i=0;i<names.length;i++) {
+                UPnPStateVariable currentStateVar = action.getStateVariable(names[i]);
+
+				Object value = res.get(names[i]);
+                values[i]=value.toString();
+                related[i] = currentStateVar.getName();
+                
+                String javaType =currentStateVar.getJavaDataType().toString();
+                javaType = javaType.substring(javaType.lastIndexOf('.')+1);
+                String upnpType = currentStateVar.getUPnPDataType();
+                types[i] = javaType + " \\ " + upnpType;
+            }   	
+	    	size = names.length;
+    	}
+		this.fireTableChanged(new TableModelEvent(this));
+    }
+}
+
+//thanks to Thomas Wagner 12/10/2005
+class ArgumentsModel extends  AbstractTableModel {
+	int size = 0;
+	private MyTable table;	
+	String[] names = new String[]{""};
+    String[] related = new String[]{""};
+    String[] types = new String[]{""};
+    String[] values = new String[]{""};
+	String[] header = new String[]{"arg name","related Var","Java \\ UpnP type","value"};
+   
+	public void setTable(MyTable table) { 
+		this.table = table;
+	}
+ 
+	public int getColumnCount() { return 4; }
+    public int getRowCount() { return size;}
+    public String getColumnName(int col) { return header[col]; }
+    public boolean isCellEditable(int rowIndex, int columnIndex) {
+    	return (columnIndex ==3);
+    }
+    public Object getValueAt(int row, int col) { 
+    	if (col == 0) return names[row];
+        else if (col == 1) return related[row];
+        else if (col == 2) return types[row];
+        else if (col == 3) return values[row];
+    	return null;
+	}   
+    public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
+    	values[rowIndex]= (String) aValue; 
+    }
+
+    public void setData(UPnPAction  action){
+
+		table.deleteMyCellEditors();
+        
+
+        String[] names = action.getInputArgumentNames();
+   	    size = 0;
+    	this.names = names;
+    	if (names!=null){
+	    	values = new String[names.length];
+            related = new String[names.length];
+            types = new String[names.length];
+	    	for (int i=0;i<names.length;i++) {
+                values[i]="";
+                UPnPStateVariable currentStateVar = action.getStateVariable(names[i]);
+                related[i] = currentStateVar.getName();
+                String javaType = currentStateVar.getJavaDataType().toString();
+                javaType = javaType.substring(javaType.lastIndexOf('.')+1);
+                String upnpType = currentStateVar.getUPnPDataType();
+                types[i] = javaType + " \\ " + upnpType;
+
+				//handle allowed value list
+				if ( currentStateVar.getAllowedValues() != null) {
+					String av[] = currentStateVar.getAllowedValues();
+					JComboBox comboBox = new JComboBox();
+					for (int j = 0; j < av.length; j++) {
+						comboBox.addItem(av[j]);
+					}
+					values[i] = av[0]; //preset the first value from list
+					table.setMyCellEditor(new DefaultCellEditor(comboBox),i);
+				}
+
+				//handle default value
+				if (currentStateVar.getDefaultValue() != null) {
+					String val = currentStateVar.getDefaultValue().toString();
+					if(val.length() > 0)
+						values[i] = val;
+				}
+				
+               //handle range values
+               if ((currentStateVar.getMaximum()!= null)
+                   &&(currentStateVar.getMinimum()!= null)){
+                   int max = currentStateVar.getMaximum().intValue();
+                   int min = currentStateVar.getMinimum().intValue();
+                   int value = min;
+                   try { value = Integer.parseInt(values[i]);}
+                   catch (NumberFormatException ignored){}
+                   table.setMyCellEditor(new SliderEditor(min,max,value),i);
+               }
+
+            }   	
+	    	size = names.length;
+    	}
+		this.fireTableChanged(new TableModelEvent(this));
+        this.fireTableStructureChanged();
+    }
+}
+
+// thanks to Thomas Wagner 12/10/2005
+class MyTable extends JTable { 
+
+	private Hashtable cellEditors;
+	
+	public MyTable(TableModel dm) {
+		super(dm);
+		cellEditors = new Hashtable();
+	}
+
+	public void setMyCellEditor(TableCellEditor editor,int col){
+		cellEditors.put(new Integer(col),editor);
+	}
+
+	public void deleteMyCellEditors(){
+		cellEditors.clear();
+	}
+
+	//overwritten JTable method	
+	public TableCellEditor getCellEditor(int row,int col) {
+		TableCellEditor tce = (TableCellEditor) cellEditors.get(new Integer(row));
+		if( tce != null) {
+			return tce;
+		} else {
+			return super.getCellEditor(row,col);
+		}
+	}
+}
+
+class SliderEditor extends AbstractCellEditor implements TableCellEditor
+{
+    JPanel editor;
+    JTextField text;
+    JSlider slider;
+    public SliderEditor(int min, int max, int value){
+         editor = new JPanel(new BorderLayout());
+         //editor.setBorder(new EmptyBorder(1,0,1,0));
+         text = new JTextField(Integer.toString(max).length());
+         slider = new JSlider(SwingConstants.HORIZONTAL,min,max,value);
+         editor.add(text,BorderLayout.WEST);
+         editor.add(slider);
+         slider.addChangeListener(new ChangeListener(){
+            public void stateChanged(ChangeEvent e) {
+                //if (! replSlider.getValueIsAdjusting()){
+                text.setText(new Integer(slider.getValue()).toString());
+                //}
+            }
+         });
+
+    }
+    
+    public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
+        text.setText((String) value);
+        try {
+            slider.setValue(Integer.parseInt((String)value));
+        } catch (NumberFormatException ignored) {}
+        return editor;
+    }
+
+    public Object getCellEditorValue() {
+        return text.getText();
+    }
+}
+

Propchange: felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/ActionPanel.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/ActionPanel.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/ActionPanel.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/LogPanel.java
URL: http://svn.apache.org/viewvc/felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/LogPanel.java?rev=674879&r1=674878&r2=674879&view=diff
==============================================================================
--- felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/LogPanel.java (original)
+++ felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/LogPanel.java Tue Jul  8 09:59:54 2008
@@ -1,74 +1,74 @@
-/* 
- * 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.BorderLayout;
-
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JScrollBar;
-import javax.swing.JScrollPane;
-import javax.swing.JTextArea;
-
-/* 
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-public class LogPanel extends JPanel {
-    private static JTextArea logArea = new JTextArea(4,50);
-    private static JPanel statusBar = new JPanel(new BorderLayout());
-    private static JLabel statusText = new JLabel();
-    
-    private static JScrollPane scroll = new JScrollPane(logArea);
-    
-    public LogPanel() {
-        super(new BorderLayout());
-        logArea.setText("");
-        //add(new JScrollPane(new JTextArea(4,80)));
-        add(scroll);
-        statusBar.add(statusText,BorderLayout.EAST);
-        add(statusBar,BorderLayout.SOUTH);
-        }
-
-    /* public static void log(String msg) {
-        logArea.append(msg + "\n\r");
-		JScrollBar scrBar = scroll.getVerticalScrollBar();
-		int maxPos = scrBar.getMaximum();
-		scrBar.setValue(maxPos);
-   }*/
-    
-    public static void log(final String msg){ 
-        synchronized (logArea) {
-            logArea.append(msg );
-            logArea.append("\n\r");
-        }
-        JScrollBar scrBar = scroll.getVerticalScrollBar();
-        int maxPos = scrBar.getMaximum();
-        scrBar.setValue(maxPos);
-    }
-    
-    public static void status(final String msg){ 
-        statusText.setText(msg);
-     }
-
-   public static void clear(String msg) {
-        logArea.setText("");
-   }
-
-}
+/* 
+ * 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.BorderLayout;
+
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollBar;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+
+/* 
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+public class LogPanel extends JPanel {
+    private static JTextArea logArea = new JTextArea(4,50);
+    private static JPanel statusBar = new JPanel(new BorderLayout());
+    private static JLabel statusText = new JLabel();
+    
+    private static JScrollPane scroll = new JScrollPane(logArea);
+    
+    public LogPanel() {
+        super(new BorderLayout());
+        logArea.setText("");
+        //add(new JScrollPane(new JTextArea(4,80)));
+        add(scroll);
+        statusBar.add(statusText,BorderLayout.EAST);
+        add(statusBar,BorderLayout.SOUTH);
+        }
+
+    /* public static void log(String msg) {
+        logArea.append(msg + "\n\r");
+		JScrollBar scrBar = scroll.getVerticalScrollBar();
+		int maxPos = scrBar.getMaximum();
+		scrBar.setValue(maxPos);
+   }*/
+    
+    public static void log(final String msg){ 
+        synchronized (logArea) {
+            logArea.append(msg );
+            logArea.append("\n\r");
+        }
+        JScrollBar scrBar = scroll.getVerticalScrollBar();
+        int maxPos = scrBar.getMaximum();
+        scrBar.setValue(maxPos);
+    }
+    
+    public static void status(final String msg){ 
+        statusText.setText(msg);
+     }
+
+   public static void clear(String msg) {
+        logArea.setText("");
+   }
+
+}

Propchange: felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/LogPanel.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/LogPanel.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/LogPanel.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/PropertiesViewer.java
URL: http://svn.apache.org/viewvc/felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/PropertiesViewer.java?rev=674879&r1=674878&r2=674879&view=diff
==============================================================================
--- felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/PropertiesViewer.java (original)
+++ felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/PropertiesViewer.java Tue Jul  8 09:59:54 2008
@@ -1,223 +1,223 @@
-/* 
- * 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.Component;
-import java.awt.Cursor;
-import java.awt.Dimension;
-import java.awt.GridBagLayout;
-import java.awt.Point;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.awt.event.MouseMotionListener;
-
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JTable;
-import javax.swing.JTree;
-import javax.swing.event.TableModelEvent;
-import javax.swing.table.AbstractTableModel;
-import javax.swing.table.DefaultTableCellRenderer;
-
-import org.osgi.service.upnp.UPnPAction;
-import org.osgi.service.upnp.UPnPDevice;
-
-import org.apache.felix.upnp.tester.Mediator;
-import org.apache.felix.upnp.tester.discovery.DeviceNode;
-
-/* 
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-public class PropertiesViewer extends JPanel {
-
-    ActionPanel actionsPanel;
-	SubscriptionPanel subscriptionPanel;
-	DataModel dataModel;
-	JTable table;
-	
-	public PropertiesViewer(){
-		super(new GridBagLayout());
-		buildTable();
-		actionsPanel = new ActionPanel();
-		subscriptionPanel = new SubscriptionPanel();
-		
-		JScrollPane scroll = new JScrollPane(table);
-		scroll.setPreferredSize(new Dimension(500,200));
-		//actionsPanel.setPreferredSize(new Dimension(500,100)); twa
-		actionsPanel.setPreferredSize(new Dimension(500,200));
-		add(scroll,Util.setConstrains(0,0,6,2,100,50));
-		add(actionsPanel,Util.setConstrains(0,2,6,1,100,20));
-		add(subscriptionPanel,Util.setConstrains(0,3,6,1,100,5));
-		showActionPanel(false);
-		showSubscriptionPanel(false);
-         
-        table.addMouseMotionListener(new MouseMotionListener(){
-           private final Cursor handCursor = new Cursor(Cursor.HAND_CURSOR);
-           
-           public void mouseDragged(MouseEvent e) {}
-           public void mouseMoved(MouseEvent e) {
-                String link = getDataLink(e.getPoint());
-                if (link != null)
-                    table.setCursor(handCursor);                       
-                else
-                    table.setCursor(Cursor.getDefaultCursor());
-           }
-
-        });
-        
-        table.addMouseListener(new MouseAdapter(){
-            public void mouseClicked(MouseEvent e){
-                String link = getDataLink(e.getPoint());
-                if (link != null)
-                    Util.openUrl(link);              
-            }
-        });
-
-    }   
-        
-    public String getDataLink(Point p) {
-        int col = table.columnAtPoint(p);
-        if (col != 1) 
-            return null;
-        else {
-            int row = table.rowAtPoint(p);
-            String data = (String) dataModel.getValueAt(row,col);
-            if (data == null) return null;
-            if (data.length()<4) return null;
-            String begin = data.substring(0,4);
-            if (begin.equalsIgnoreCase("http"))
-                return data;
-            else {
-                String propertyName= (String) dataModel.getValueAt(row,0);
-                if (propertyName.equalsIgnoreCase(UPnPDevice.PRESENTATION_URL)
-                    ||propertyName.equalsIgnoreCase(UPnPDevice.MANUFACTURER_URL)
-                    ||propertyName.equalsIgnoreCase(UPnPDevice.MODEL_URL) )
-                    {
-                    JTree tree = Mediator.getUPnPDeviceTree();
-                    UPnPDeviceTreeNode selectedNode = (UPnPDeviceTreeNode)tree.getLastSelectedPathComponent();   
-                    String url = "";
-                    if (selectedNode.category.equals(UPnPDeviceTreeNode.DEVICE)){
-                        UPnPDeviceTreeNode parent =  (UPnPDeviceTreeNode)selectedNode.getParent();
-                        while (parent.category!=UPnPDeviceTreeNode.ROOT_DEVICE)
-                             parent =  (UPnPDeviceTreeNode)parent.getParent();
-                        DeviceNode device =  (DeviceNode) parent.getUserObject();
-                        String udn = (String)device.getReference().getProperty(UPnPDevice.UDN);
-                        url = Mediator.getDriverProxy().resolveRelativeUrl(udn,data);
-                        return url;
-                    }                           
-                    else if (selectedNode.category.equals(UPnPDeviceTreeNode.ROOT_DEVICE))
-                    {
-                        DeviceNode node =  (DeviceNode) selectedNode.getUserObject();
-                        String udn = (String)node.getReference().getProperty(UPnPDevice.UDN);
-                        url = Mediator.getDriverProxy().resolveRelativeUrl(udn,data);
-                        return url;
-                    }
-                }
-                return null;     
-            }
-        }
-	}
-	
-	public void setProperties(String[]name,String[]values){
-		dataModel.setData(name,values);
-	}
-	
-	public void setAction(UPnPAction action){
-		actionsPanel.setArguments(action);
-		
-	}
-	
-	public void showActionPanel(boolean show){
-		actionsPanel.setVisible(show);
-	}
-	
-	public void showSubscriptionPanel(boolean show){
-	    subscriptionPanel.setVisible(show);
-	}
-	
-	private void buildTable(){
-		dataModel = new DataModel();
-	    table = new JTable(dataModel);
-        table.setDefaultRenderer(table.getColumnClass(1), new LinkCellRenderer());
-	}
-
-
-}
-
-class DataModel extends  AbstractTableModel {
-	int size = 0;
-	String[] names = new String[]{""};
-	String[] values = new String[]{""};
-    String[] header = new String[]{"property key","value"};
-    
-    public String getColumnName(int col) { return header[col]; }
-	public int getColumnCount() { return 2; }
-    public int getRowCount() { return size;}
-    public Object getValueAt(int row, int col) { 
-    	if (col==0) return names[row];
-    	else return values[row];
-    }
-    
-    /*
-    public boolean isCellEditable(int rowIndex, int columnIndex) {
-        return false;
-    }
-    */
-    
-    public void setData(String[]names,String[]values){
-    	this.names=names;
-    	this.values=values;
-    	size = names.length;
-		this.fireTableChanged(new TableModelEvent(this));
-    }
-    
-}
-
-class LinkCellRenderer extends DefaultTableCellRenderer
-{
-    public LinkCellRenderer(){
-        super();
-    }
-    
-    public Component getTableCellRendererComponent(JTable table, Object value,
-            boolean isSelected, boolean hasFocus, int row, int column) {
-        super.getTableCellRendererComponent(table,value,isSelected,hasFocus,row,column);
-        if (column==1){
-            String propertyName = (String)table.getModel().getValueAt(row,0);
-            if (propertyName.equalsIgnoreCase(UPnPDevice.PRESENTATION_URL)
-                ||propertyName.equalsIgnoreCase(UPnPDevice.MODEL_URL)
-                ||propertyName.equalsIgnoreCase(UPnPDevice.MANUFACTURER_URL))
-            {
-                if (!value.equals(""))
-                    setValue("<html><a href=''>"+value+"</a></html>");
-                return this;
-            }
-            if (((String) value).length()<4) return this;
-            String begin = ((String) value).substring(0,4);
-            if (begin.equalsIgnoreCase("http"))
-                setValue("<html><a href=''>"+value+"</a></html>");
-        }
-        return this;
-    }
- 
-}
-
+/* 
+ * 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.Component;
+import java.awt.Cursor;
+import java.awt.Dimension;
+import java.awt.GridBagLayout;
+import java.awt.Point;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseMotionListener;
+
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTable;
+import javax.swing.JTree;
+import javax.swing.event.TableModelEvent;
+import javax.swing.table.AbstractTableModel;
+import javax.swing.table.DefaultTableCellRenderer;
+
+import org.osgi.service.upnp.UPnPAction;
+import org.osgi.service.upnp.UPnPDevice;
+
+import org.apache.felix.upnp.tester.Mediator;
+import org.apache.felix.upnp.tester.discovery.DeviceNode;
+
+/* 
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+public class PropertiesViewer extends JPanel {
+
+    ActionPanel actionsPanel;
+	SubscriptionPanel subscriptionPanel;
+	DataModel dataModel;
+	JTable table;
+	
+	public PropertiesViewer(){
+		super(new GridBagLayout());
+		buildTable();
+		actionsPanel = new ActionPanel();
+		subscriptionPanel = new SubscriptionPanel();
+		
+		JScrollPane scroll = new JScrollPane(table);
+		scroll.setPreferredSize(new Dimension(500,200));
+		//actionsPanel.setPreferredSize(new Dimension(500,100)); twa
+		actionsPanel.setPreferredSize(new Dimension(500,200));
+		add(scroll,Util.setConstrains(0,0,6,2,100,50));
+		add(actionsPanel,Util.setConstrains(0,2,6,1,100,20));
+		add(subscriptionPanel,Util.setConstrains(0,3,6,1,100,5));
+		showActionPanel(false);
+		showSubscriptionPanel(false);
+         
+        table.addMouseMotionListener(new MouseMotionListener(){
+           private final Cursor handCursor = new Cursor(Cursor.HAND_CURSOR);
+           
+           public void mouseDragged(MouseEvent e) {}
+           public void mouseMoved(MouseEvent e) {
+                String link = getDataLink(e.getPoint());
+                if (link != null)
+                    table.setCursor(handCursor);                       
+                else
+                    table.setCursor(Cursor.getDefaultCursor());
+           }
+
+        });
+        
+        table.addMouseListener(new MouseAdapter(){
+            public void mouseClicked(MouseEvent e){
+                String link = getDataLink(e.getPoint());
+                if (link != null)
+                    Util.openUrl(link);              
+            }
+        });
+
+    }   
+        
+    public String getDataLink(Point p) {
+        int col = table.columnAtPoint(p);
+        if (col != 1) 
+            return null;
+        else {
+            int row = table.rowAtPoint(p);
+            String data = (String) dataModel.getValueAt(row,col);
+            if (data == null) return null;
+            if (data.length()<4) return null;
+            String begin = data.substring(0,4);
+            if (begin.equalsIgnoreCase("http"))
+                return data;
+            else {
+                String propertyName= (String) dataModel.getValueAt(row,0);
+                if (propertyName.equalsIgnoreCase(UPnPDevice.PRESENTATION_URL)
+                    ||propertyName.equalsIgnoreCase(UPnPDevice.MANUFACTURER_URL)
+                    ||propertyName.equalsIgnoreCase(UPnPDevice.MODEL_URL) )
+                    {
+                    JTree tree = Mediator.getUPnPDeviceTree();
+                    UPnPDeviceTreeNode selectedNode = (UPnPDeviceTreeNode)tree.getLastSelectedPathComponent();   
+                    String url = "";
+                    if (selectedNode.category.equals(UPnPDeviceTreeNode.DEVICE)){
+                        UPnPDeviceTreeNode parent =  (UPnPDeviceTreeNode)selectedNode.getParent();
+                        while (parent.category!=UPnPDeviceTreeNode.ROOT_DEVICE)
+                             parent =  (UPnPDeviceTreeNode)parent.getParent();
+                        DeviceNode device =  (DeviceNode) parent.getUserObject();
+                        String udn = (String)device.getReference().getProperty(UPnPDevice.UDN);
+                        url = Mediator.getDriverProxy().resolveRelativeUrl(udn,data);
+                        return url;
+                    }                           
+                    else if (selectedNode.category.equals(UPnPDeviceTreeNode.ROOT_DEVICE))
+                    {
+                        DeviceNode node =  (DeviceNode) selectedNode.getUserObject();
+                        String udn = (String)node.getReference().getProperty(UPnPDevice.UDN);
+                        url = Mediator.getDriverProxy().resolveRelativeUrl(udn,data);
+                        return url;
+                    }
+                }
+                return null;     
+            }
+        }
+	}
+	
+	public void setProperties(String[]name,String[]values){
+		dataModel.setData(name,values);
+	}
+	
+	public void setAction(UPnPAction action){
+		actionsPanel.setArguments(action);
+		
+	}
+	
+	public void showActionPanel(boolean show){
+		actionsPanel.setVisible(show);
+	}
+	
+	public void showSubscriptionPanel(boolean show){
+	    subscriptionPanel.setVisible(show);
+	}
+	
+	private void buildTable(){
+		dataModel = new DataModel();
+	    table = new JTable(dataModel);
+        table.setDefaultRenderer(table.getColumnClass(1), new LinkCellRenderer());
+	}
+
+
+}
+
+class DataModel extends  AbstractTableModel {
+	int size = 0;
+	String[] names = new String[]{""};
+	String[] values = new String[]{""};
+    String[] header = new String[]{"property key","value"};
+    
+    public String getColumnName(int col) { return header[col]; }
+	public int getColumnCount() { return 2; }
+    public int getRowCount() { return size;}
+    public Object getValueAt(int row, int col) { 
+    	if (col==0) return names[row];
+    	else return values[row];
+    }
+    
+    /*
+    public boolean isCellEditable(int rowIndex, int columnIndex) {
+        return false;
+    }
+    */
+    
+    public void setData(String[]names,String[]values){
+    	this.names=names;
+    	this.values=values;
+    	size = names.length;
+		this.fireTableChanged(new TableModelEvent(this));
+    }
+    
+}
+
+class LinkCellRenderer extends DefaultTableCellRenderer
+{
+    public LinkCellRenderer(){
+        super();
+    }
+    
+    public Component getTableCellRendererComponent(JTable table, Object value,
+            boolean isSelected, boolean hasFocus, int row, int column) {
+        super.getTableCellRendererComponent(table,value,isSelected,hasFocus,row,column);
+        if (column==1){
+            String propertyName = (String)table.getModel().getValueAt(row,0);
+            if (propertyName.equalsIgnoreCase(UPnPDevice.PRESENTATION_URL)
+                ||propertyName.equalsIgnoreCase(UPnPDevice.MODEL_URL)
+                ||propertyName.equalsIgnoreCase(UPnPDevice.MANUFACTURER_URL))
+            {
+                if (!value.equals(""))
+                    setValue("<html><a href=''>"+value+"</a></html>");
+                return this;
+            }
+            if (((String) value).length()<4) return this;
+            String begin = ((String) value).substring(0,4);
+            if (begin.equalsIgnoreCase("http"))
+                setValue("<html><a href=''>"+value+"</a></html>");
+        }
+        return this;
+    }
+ 
+}
+

Propchange: felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/PropertiesViewer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/PropertiesViewer.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/PropertiesViewer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/SubscriptionPanel.java
URL: http://svn.apache.org/viewvc/felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/SubscriptionPanel.java?rev=674879&r1=674878&r2=674879&view=diff
==============================================================================
--- felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/SubscriptionPanel.java (original)
+++ felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/SubscriptionPanel.java Tue Jul  8 09:59:54 2008
@@ -1,155 +1,155 @@
-/* 
- * 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.event.ActionEvent;
-import java.util.Dictionary;
-import java.util.Enumeration;
-
-import javax.swing.AbstractAction;
-import javax.swing.JButton;
-import javax.swing.JPanel;
-import javax.swing.JTree;
-import javax.swing.SwingUtilities;
-
-import org.osgi.service.upnp.UPnPDevice;
-import org.osgi.service.upnp.UPnPEventListener;
-import org.osgi.service.upnp.UPnPService;
-
-import org.apache.felix.upnp.tester.Activator;
-import org.apache.felix.upnp.tester.Mediator;
-import org.apache.felix.upnp.tester.UPnPSubscriber;
-import org.apache.felix.upnp.tester.discovery.DeviceNode;
-/* 
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-public class SubscriptionPanel extends JPanel implements UPnPEventListener{
-	public SubscriptionPanel() {
-		super();
-		buildButtonPanel();
-	}
-
-	private void buildButtonPanel(){
-		JButton subscribeBtn = new JButton("Subscribe");
-		subscribeBtn.addActionListener(new AbstractAction(){
-			public void actionPerformed(ActionEvent e) {
-			    //System.out.println("subscribing ...");
-			    doSubscribe();
-			}
-		});		
-		JButton unsubscribeBtn = new JButton("Unsubscribe");
-		unsubscribeBtn.addActionListener(new AbstractAction(){
-			public void actionPerformed(ActionEvent e) {
-			    //System.out.println("unsubscribing ...");
-			    doUnsubscribe();
-				}
-		});		
-	    add(subscribeBtn);
-	    add(unsubscribeBtn);
-	}
-	
-	UPnPSubscriber subscriber;
-	public void doSubscribe()
-	{
-		if (subscriber == null)
-		    subscriber = new UPnPSubscriber(Activator.context,this);
-		
-		UPnPDeviceTreeNode selectedNode = getSelectedNode();
-		String serviceId = getServiceId(selectedNode);
-		String parentId = getDeviceId(selectedNode);
-		LogPanel.log("subscribing ... "+ "ServiceId ["+serviceId+"] of DeviceId ["+parentId +"]");
-		subscriber.subscribe(parentId,serviceId);
-		setSubscribedVariableOf(selectedNode);
-	}
-	
-	public void doUnsubscribe(){
-		UPnPDeviceTreeNode selectedNode = getSelectedNode();
-		String serviceId = getServiceId(selectedNode);
-		String parentId = getDeviceId(selectedNode);
-		LogPanel.log("unsubscribing ... "+ "ServiceId ["+serviceId+"] of DeviceId ["+parentId +"]");
-		subscriber.unsubscribe(parentId,serviceId);
-		setUnubscribedVariableOf(selectedNode);
-		}
-	
-	public void notifyUPnPEvent(final String deviceId, final String serviceId, final Dictionary events) {
-        // UPnP base driver notify are synchronous !!
-		Runnable doShowMsg = new Runnable() {
-       	 public void run() {
-			LogPanel.log("notifyUPnPEvent::[DeviceID "+deviceId+"][ServiceId "+serviceId+"]");
-			Enumeration elements = events.keys();
-			while (elements.hasMoreElements()){
-			    Object key = elements.nextElement();
-			    Object value = events.get(key);
-			    LogPanel.log("["+key+"][value "+value+"]");
-			}
-       	 }
-        };
-        SwingUtilities.invokeLater(doShowMsg);
-		
-	}
-	
-	private void setSubscribedVariableOf(UPnPDeviceTreeNode selectedNode){
-	    Enumeration list = selectedNode.children();
-	    while (list.hasMoreElements()){
-	        UPnPDeviceTreeNode node =  (UPnPDeviceTreeNode) list.nextElement();
-	        if (node.category == UPnPDeviceTreeNode.EVENTED_STATE)
-	            node.category = UPnPDeviceTreeNode.SUBSCRIBED_STATE;
-	    }
-	    JTree tree = Mediator.getUPnPDeviceTree();
-	    tree.validate();
-	    tree.repaint();
-	}
-	
-	private void setUnubscribedVariableOf(UPnPDeviceTreeNode selectedNode){
-	    Enumeration list = selectedNode.children();
-	    while (list.hasMoreElements()){
-	        UPnPDeviceTreeNode node =  (UPnPDeviceTreeNode) list.nextElement();
-	        if (node.category == UPnPDeviceTreeNode.SUBSCRIBED_STATE)
-	            node.category = UPnPDeviceTreeNode.EVENTED_STATE;
-	    }
-	    JTree tree = Mediator.getUPnPDeviceTree();
-	    tree.validate();
-	    tree.repaint();
-	}
-	
-	private  UPnPDeviceTreeNode getSelectedNode(){
-		JTree tree = Mediator.getUPnPDeviceTree();
-		UPnPDeviceTreeNode selectedNode = (UPnPDeviceTreeNode)tree.getLastSelectedPathComponent();
-	    return selectedNode;
-	}
-	private  String getServiceId (UPnPDeviceTreeNode selectedNode){
-		Object userObj = selectedNode.getUserObject();
-	    String serviceId = ((UPnPService) userObj).getId();
-	    return serviceId;
-	}
-	private String getDeviceId (UPnPDeviceTreeNode selectedNode){
-	     UPnPDeviceTreeNode parent = (UPnPDeviceTreeNode)selectedNode.getParent();
-	     DeviceNode node =(DeviceNode)parent.getUserObject();
-	     String parentId = (String) node.getReference().getProperty(UPnPDevice.ID);
-	    return parentId;
-	}
-	
-	
-	
-}
-
-
+/* 
+ * 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.event.ActionEvent;
+import java.util.Dictionary;
+import java.util.Enumeration;
+
+import javax.swing.AbstractAction;
+import javax.swing.JButton;
+import javax.swing.JPanel;
+import javax.swing.JTree;
+import javax.swing.SwingUtilities;
+
+import org.osgi.service.upnp.UPnPDevice;
+import org.osgi.service.upnp.UPnPEventListener;
+import org.osgi.service.upnp.UPnPService;
+
+import org.apache.felix.upnp.tester.Activator;
+import org.apache.felix.upnp.tester.Mediator;
+import org.apache.felix.upnp.tester.UPnPSubscriber;
+import org.apache.felix.upnp.tester.discovery.DeviceNode;
+/* 
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+public class SubscriptionPanel extends JPanel implements UPnPEventListener{
+	public SubscriptionPanel() {
+		super();
+		buildButtonPanel();
+	}
+
+	private void buildButtonPanel(){
+		JButton subscribeBtn = new JButton("Subscribe");
+		subscribeBtn.addActionListener(new AbstractAction(){
+			public void actionPerformed(ActionEvent e) {
+			    //System.out.println("subscribing ...");
+			    doSubscribe();
+			}
+		});		
+		JButton unsubscribeBtn = new JButton("Unsubscribe");
+		unsubscribeBtn.addActionListener(new AbstractAction(){
+			public void actionPerformed(ActionEvent e) {
+			    //System.out.println("unsubscribing ...");
+			    doUnsubscribe();
+				}
+		});		
+	    add(subscribeBtn);
+	    add(unsubscribeBtn);
+	}
+	
+	UPnPSubscriber subscriber;
+	public void doSubscribe()
+	{
+		if (subscriber == null)
+		    subscriber = new UPnPSubscriber(Activator.context,this);
+		
+		UPnPDeviceTreeNode selectedNode = getSelectedNode();
+		String serviceId = getServiceId(selectedNode);
+		String parentId = getDeviceId(selectedNode);
+		LogPanel.log("subscribing ... "+ "ServiceId ["+serviceId+"] of DeviceId ["+parentId +"]");
+		subscriber.subscribe(parentId,serviceId);
+		setSubscribedVariableOf(selectedNode);
+	}
+	
+	public void doUnsubscribe(){
+		UPnPDeviceTreeNode selectedNode = getSelectedNode();
+		String serviceId = getServiceId(selectedNode);
+		String parentId = getDeviceId(selectedNode);
+		LogPanel.log("unsubscribing ... "+ "ServiceId ["+serviceId+"] of DeviceId ["+parentId +"]");
+		subscriber.unsubscribe(parentId,serviceId);
+		setUnubscribedVariableOf(selectedNode);
+		}
+	
+	public void notifyUPnPEvent(final String deviceId, final String serviceId, final Dictionary events) {
+        // UPnP base driver notify are synchronous !!
+		Runnable doShowMsg = new Runnable() {
+       	 public void run() {
+			LogPanel.log("notifyUPnPEvent::[DeviceID "+deviceId+"][ServiceId "+serviceId+"]");
+			Enumeration elements = events.keys();
+			while (elements.hasMoreElements()){
+			    Object key = elements.nextElement();
+			    Object value = events.get(key);
+			    LogPanel.log("["+key+"][value "+value+"]");
+			}
+       	 }
+        };
+        SwingUtilities.invokeLater(doShowMsg);
+		
+	}
+	
+	private void setSubscribedVariableOf(UPnPDeviceTreeNode selectedNode){
+	    Enumeration list = selectedNode.children();
+	    while (list.hasMoreElements()){
+	        UPnPDeviceTreeNode node =  (UPnPDeviceTreeNode) list.nextElement();
+	        if (node.category == UPnPDeviceTreeNode.EVENTED_STATE)
+	            node.category = UPnPDeviceTreeNode.SUBSCRIBED_STATE;
+	    }
+	    JTree tree = Mediator.getUPnPDeviceTree();
+	    tree.validate();
+	    tree.repaint();
+	}
+	
+	private void setUnubscribedVariableOf(UPnPDeviceTreeNode selectedNode){
+	    Enumeration list = selectedNode.children();
+	    while (list.hasMoreElements()){
+	        UPnPDeviceTreeNode node =  (UPnPDeviceTreeNode) list.nextElement();
+	        if (node.category == UPnPDeviceTreeNode.SUBSCRIBED_STATE)
+	            node.category = UPnPDeviceTreeNode.EVENTED_STATE;
+	    }
+	    JTree tree = Mediator.getUPnPDeviceTree();
+	    tree.validate();
+	    tree.repaint();
+	}
+	
+	private  UPnPDeviceTreeNode getSelectedNode(){
+		JTree tree = Mediator.getUPnPDeviceTree();
+		UPnPDeviceTreeNode selectedNode = (UPnPDeviceTreeNode)tree.getLastSelectedPathComponent();
+	    return selectedNode;
+	}
+	private  String getServiceId (UPnPDeviceTreeNode selectedNode){
+		Object userObj = selectedNode.getUserObject();
+	    String serviceId = ((UPnPService) userObj).getId();
+	    return serviceId;
+	}
+	private String getDeviceId (UPnPDeviceTreeNode selectedNode){
+	     UPnPDeviceTreeNode parent = (UPnPDeviceTreeNode)selectedNode.getParent();
+	     DeviceNode node =(DeviceNode)parent.getUserObject();
+	     String parentId = (String) node.getReference().getProperty(UPnPDevice.ID);
+	    return parentId;
+	}
+	
+	
+	
+}
+
+

Propchange: felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/SubscriptionPanel.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/SubscriptionPanel.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/SubscriptionPanel.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/TreeViewer.java
URL: http://svn.apache.org/viewvc/felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/TreeViewer.java?rev=674879&r1=674878&r2=674879&view=diff
==============================================================================
--- felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/TreeViewer.java (original)
+++ felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/TreeViewer.java Tue Jul  8 09:59:54 2008
@@ -1,322 +1,322 @@
-/* 
- * 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.BorderLayout;
-import java.awt.event.ActionEvent;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.util.ArrayList;
-import java.util.Dictionary;
-import java.util.Enumeration;
-
-import javax.swing.AbstractAction;
-import javax.swing.JMenuItem;
-import javax.swing.JPanel;
-import javax.swing.JPopupMenu;
-import javax.swing.JScrollPane;
-import javax.swing.JTree;
-import javax.swing.SwingUtilities;
-import javax.swing.ToolTipManager;
-import javax.swing.event.PopupMenuEvent;
-import javax.swing.event.PopupMenuListener;
-import javax.swing.event.TreeSelectionEvent;
-import javax.swing.event.TreeSelectionListener;
-import javax.swing.tree.DefaultTreeModel;
-import javax.swing.tree.TreePath;
-
-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.Activator;
-import org.apache.felix.upnp.tester.Mediator;
-import org.apache.felix.upnp.tester.discovery.DeviceNode;
-import org.apache.felix.upnp.tester.discovery.DeviceNodeListener;
-
-/* 
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-
-public class TreeViewer extends JPanel 	implements DeviceNodeListener 
-{
-	
-	private UPnPDeviceTreeNode root;
-	private DefaultTreeModel treeModel;
-	private JTree tree;
-    final TreePopup popup ;
-	public TreeViewer(){
-		super(new BorderLayout());
-		Mediator.setTreeViewer(this);
-		root = new UPnPDeviceTreeNode("UPnP Devices");
-		treeModel= new DefaultTreeModel(root);
-		tree = new JTree(treeModel);
-		Mediator.setUPnPDeviceTree(tree);
-		tree.setCellRenderer(new TreeNodeCellRenderer() );
-		tree.putClientProperty("JTree.lineStyle", "Angled");
-        add(new JScrollPane(tree));
-		addTreeSelectionListener();
-        
-        
-        popup = new TreePopup(tree);
-        popup.setEnabled(false);
-        tree.addMouseListener(new MouseAdapter(){
-            public void mouseClicked(MouseEvent e){
-                if (SwingUtilities.isRightMouseButton(e)){
-                    TreePath path = tree.getClosestPathForLocation(e.getX(), e.getY());
-                    tree.setSelectionPath(path);
-                    tree.scrollPathToVisible(path);
-                    popup.show(tree, e.getX(), e.getY());
-                }
-            }
-        });
-        ToolTipManager.sharedInstance().registerComponent(tree);
-         
-
-	}
-	
-    public void setPopupMenuEnabled(boolean driverControllerAvailable){
-        popup.getComponent(0).setEnabled(driverControllerAvailable);
-    }
-	public void deviceDetected(DeviceNode node) {
-		root.add(new UPnPDeviceTreeNode(node,Activator.context));
-		treeModel.nodeStructureChanged(root);
-	}
-	
-	public void rootDeviceUnplugged(String udn){
-		Enumeration list = root.children();
-		while (list.hasMoreElements()){
-			UPnPDeviceTreeNode node= (UPnPDeviceTreeNode)list.nextElement();
-			DeviceNode device = (DeviceNode)node.getUserObject();
-			if (udn.equals(device.toString())) {
-				node.removeFromParent();
-				treeModel.nodeStructureChanged(root);
-			}
-		}
-	}
-
-	private void addTreeSelectionListener(){
-		tree.addTreeSelectionListener(new TreeSelectionListener(){
-			public void valueChanged(TreeSelectionEvent e){
-				UPnPDeviceTreeNode selectedNode = (UPnPDeviceTreeNode)tree.getLastSelectedPathComponent();				
-				doNodeAction(selectedNode);			
-			}		
-		});
-	}
-	
-	private void doNodeAction(UPnPDeviceTreeNode node){
-		if (node == null) {
-			clearPropertiesViewer();
-			return;
-		}
-		if (node.category.equals(UPnPDeviceTreeNode.ACTION))
-			Mediator.getPropertiesViewer().showActionPanel(true);
-		else
-			Mediator.getPropertiesViewer().showActionPanel(false);
-
-		if (node.category.equals(UPnPDeviceTreeNode.SERVICE))
-			Mediator.getPropertiesViewer().showSubscriptionPanel(true);
-		else
-			Mediator.getPropertiesViewer().showSubscriptionPanel(false);
-
-		if ( node.category.equals(UPnPDeviceTreeNode.DEVICE)
-			||node.category.equals(UPnPDeviceTreeNode.ROOT_DEVICE)){
-			DeviceNode device = (DeviceNode) node.getUserObject();
-			UPnPDevice upnpDevice = device.getDevice(Activator.context);
-			makeProperties(upnpDevice);
-		} 
-		else if (node.category.equals(UPnPDeviceTreeNode.SERVICE)){
-			UPnPService service = (UPnPService) node.getUserObject();			
-			makeProperties(service);
-		}
-		else if (node.category.equals(UPnPDeviceTreeNode.ACTION)){
-			UPnPAction action = (UPnPAction) node.getUserObject();
-			makeProperties(action);
-			Mediator.getPropertiesViewer().setAction(action);
-		}
-		else if (node.category.equals(UPnPDeviceTreeNode.STATE)
-		        ||node.category.equals(UPnPDeviceTreeNode.EVENTED_STATE)
-		        ||node.category.equals(UPnPDeviceTreeNode.SUBSCRIBED_STATE)){
-			UPnPStateVariable state = (UPnPStateVariable) node.getUserObject();
-			makeProperties(state);
-		}
-		
-	}
-	
-	private void clearPropertiesViewer(){
-		String[] names = new String[]{};
-		String[] values = new String[]{};
-		PropertiesViewer viewer = Mediator.getPropertiesViewer();
-		viewer.setProperties(names,values);
-		viewer.showActionPanel(false);
-		viewer.showSubscriptionPanel(false);
-	}
-	
-	private void makeProperties(UPnPDevice upnpDevice){
-		Dictionary dict = upnpDevice.getDescriptions(null);
-		int size = dict.size();
-		String[] names = new String[size];
-		String[] values = new String[size];
-		Enumeration keys = dict.keys();
-		for (int i=0;i<size;i++){
-			names[i]= (String) keys.nextElement();
-			values[i]= Util.justString(dict.get(names[i]));
-		}
-		Mediator.getPropertiesViewer().setProperties(names,values);
-	}
-	
-	private void makeProperties(UPnPService service){
-		String[] names = new String[]{"Id","Type","Version"};
-		String[] values = new String[]{service.getId(),service.getType(),service.getType()};
-		Mediator.getPropertiesViewer().setProperties(names,values);
-	}
-	
-	private void makeProperties(UPnPAction action){
-		ArrayList names = new ArrayList();
-		ArrayList values = new ArrayList();
-		names.add("Name");
-		values.add(action.getName());
-		
-		String returnName = action.getReturnArgumentName();
-		if (returnName != null){
-			names.add("Return value name");
-			values.add(returnName);
-		}
-		String[] inArg = action.getInputArgumentNames();
-		if (inArg != null){
-			for (int i = 0; i<inArg.length;i++){
-				names.add("Input arg["+ (i+1)+"]");
-				values.add(inArg[i]);			
-			}
-		}
-		String[] outArg = action.getOutputArgumentNames();
-		if (outArg != null){
-			for (int i = 0; i<outArg.length;i++){
-				names.add("Output arg["+ (i+1)+"]");
-				values.add(outArg[i]);			
-			}
-		}
-		
-		Mediator.getPropertiesViewer().setProperties(
-				(String[])names.toArray(new String[]{}),
-				(String[])values.toArray(new String[]{})
-		);
-		
-	}
-	
-	private void makeProperties(UPnPStateVariable state){
-		ArrayList names = new ArrayList();
-		ArrayList values = new ArrayList();
-		names.add("Name");
-		values.add(state.getName());
-		names.add("Evented");
-		values.add(state.sendsEvents()? "yes":"no");
-		names.add("Default Value");
-		values.add(Util.justString(state.getDefaultValue()));
-		names.add("Java Data Type");
-		values.add(state.getJavaDataType().getName());
-		names.add("Java UPnP Type");
-		values.add(state.getUPnPDataType());
-		names.add("Minimum");
-		values.add(Util.justString(state.getMinimum()));
-		names.add("Maximum");
-		values.add(Util.justString(state.getMaximum()));
-		names.add("Step");
-		values.add(Util.justString(state.getStep()));		
-		String[] allowed = state.getAllowedValues();
-		if (allowed!=null){
-			for (int i=0;i<allowed.length;i++){
-				names.add("Allowed value["+i+1+"]");
-				values.add(allowed[i]);		
-			}			
-		}
-		Mediator.getPropertiesViewer().setProperties(
-				(String[])names.toArray(new String[]{}),
-				(String[])values.toArray(new String[]{})
-		);
-	}
-	
-	
-}
-
-class TreePopup extends JPopupMenu implements PopupMenuListener {
-    JTree tree;
-    JMenuItem item;
-
-    public TreePopup(final JTree tree){
-        super();
-        this.tree = tree;
-        (item = add(new AbstractAction(){
-            public void actionPerformed(ActionEvent e){
-                UPnPDeviceTreeNode selectedNode = (UPnPDeviceTreeNode)tree.getLastSelectedPathComponent();   
-                String url = "";
-                if (selectedNode.category.equals(UPnPDeviceTreeNode.DEVICE)){
-                    UPnPDeviceTreeNode parent =  (UPnPDeviceTreeNode)selectedNode.getParent();
-                    while (parent.category!=UPnPDeviceTreeNode.ROOT_DEVICE)
-                         parent =  (UPnPDeviceTreeNode)parent.getParent();
-                    DeviceNode device =  (DeviceNode) parent.getUserObject();
-                    String udn = (String)device.getReference().getProperty(UPnPDevice.UDN);
-                    url = Mediator.getDriverProxy().getDeviceDescriptionURI(udn);
-                }
-                        
-                else if (selectedNode.category.equals(UPnPDeviceTreeNode.ROOT_DEVICE))
-                {
-                    DeviceNode node =  (DeviceNode) selectedNode.getUserObject();
-                    String udn = (String)node.getReference().getProperty(UPnPDevice.UDN);
-                    url = Mediator.getDriverProxy().getDeviceDescriptionURI(udn);
-                }
-                else if (selectedNode.category.equals(UPnPDeviceTreeNode.SERVICE))
-                {
-                    UPnPDeviceTreeNode parent =  (UPnPDeviceTreeNode)selectedNode.getParent();
-                    while (parent.category!=UPnPDeviceTreeNode.ROOT_DEVICE)
-                         parent =  (UPnPDeviceTreeNode)parent.getParent();
-                    DeviceNode device =  (DeviceNode) parent.getUserObject();
-                    String udn = (String)device.getReference().getProperty(UPnPDevice.UDN);
-                    UPnPService service =  (UPnPService) selectedNode.getUserObject();
-                    url = Mediator.getDriverProxy().getServiceDescriptionURI(udn,service.getId());
-                }                    
-                Util.openUrl(url);   
-            }
-        })).setText("Show Description");
-        addPopupMenuListener(this);
-
-    }
-    
-    public void popupMenuCanceled(PopupMenuEvent e){}
-    public void popupMenuWillBecomeInvisible(PopupMenuEvent e){}
-    public void popupMenuWillBecomeVisible(PopupMenuEvent e){
-        if (Mediator.getDriverProxy().isDriverAvailable()){
-        UPnPDeviceTreeNode selectedNode = (UPnPDeviceTreeNode)tree.getLastSelectedPathComponent();              
-            if (selectedNode.category.equals(UPnPDeviceTreeNode.DEVICE)
-                ||selectedNode.category.equals(UPnPDeviceTreeNode.ROOT_DEVICE)
-                ||selectedNode.category.equals(UPnPDeviceTreeNode.SERVICE))
-            {
-                item.setEnabled(true);
-            } 
-            else
-                item.setEnabled(false);
-        }
-        else
-            item.setEnabled(false);
-           
-    }
-}
+/* 
+ * 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.BorderLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.util.ArrayList;
+import java.util.Dictionary;
+import java.util.Enumeration;
+
+import javax.swing.AbstractAction;
+import javax.swing.JMenuItem;
+import javax.swing.JPanel;
+import javax.swing.JPopupMenu;
+import javax.swing.JScrollPane;
+import javax.swing.JTree;
+import javax.swing.SwingUtilities;
+import javax.swing.ToolTipManager;
+import javax.swing.event.PopupMenuEvent;
+import javax.swing.event.PopupMenuListener;
+import javax.swing.event.TreeSelectionEvent;
+import javax.swing.event.TreeSelectionListener;
+import javax.swing.tree.DefaultTreeModel;
+import javax.swing.tree.TreePath;
+
+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.Activator;
+import org.apache.felix.upnp.tester.Mediator;
+import org.apache.felix.upnp.tester.discovery.DeviceNode;
+import org.apache.felix.upnp.tester.discovery.DeviceNodeListener;
+
+/* 
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+
+public class TreeViewer extends JPanel 	implements DeviceNodeListener 
+{
+	
+	private UPnPDeviceTreeNode root;
+	private DefaultTreeModel treeModel;
+	private JTree tree;
+    final TreePopup popup ;
+	public TreeViewer(){
+		super(new BorderLayout());
+		Mediator.setTreeViewer(this);
+		root = new UPnPDeviceTreeNode("UPnP Devices");
+		treeModel= new DefaultTreeModel(root);
+		tree = new JTree(treeModel);
+		Mediator.setUPnPDeviceTree(tree);
+		tree.setCellRenderer(new TreeNodeCellRenderer() );
+		tree.putClientProperty("JTree.lineStyle", "Angled");
+        add(new JScrollPane(tree));
+		addTreeSelectionListener();
+        
+        
+        popup = new TreePopup(tree);
+        popup.setEnabled(false);
+        tree.addMouseListener(new MouseAdapter(){
+            public void mouseClicked(MouseEvent e){
+                if (SwingUtilities.isRightMouseButton(e)){
+                    TreePath path = tree.getClosestPathForLocation(e.getX(), e.getY());
+                    tree.setSelectionPath(path);
+                    tree.scrollPathToVisible(path);
+                    popup.show(tree, e.getX(), e.getY());
+                }
+            }
+        });
+        ToolTipManager.sharedInstance().registerComponent(tree);
+         
+
+	}
+	
+    public void setPopupMenuEnabled(boolean driverControllerAvailable){
+        popup.getComponent(0).setEnabled(driverControllerAvailable);
+    }
+	public void deviceDetected(DeviceNode node) {
+		root.add(new UPnPDeviceTreeNode(node,Activator.context));
+		treeModel.nodeStructureChanged(root);
+	}
+	
+	public void rootDeviceUnplugged(String udn){
+		Enumeration list = root.children();
+		while (list.hasMoreElements()){
+			UPnPDeviceTreeNode node= (UPnPDeviceTreeNode)list.nextElement();
+			DeviceNode device = (DeviceNode)node.getUserObject();
+			if (udn.equals(device.toString())) {
+				node.removeFromParent();
+				treeModel.nodeStructureChanged(root);
+			}
+		}
+	}
+
+	private void addTreeSelectionListener(){
+		tree.addTreeSelectionListener(new TreeSelectionListener(){
+			public void valueChanged(TreeSelectionEvent e){
+				UPnPDeviceTreeNode selectedNode = (UPnPDeviceTreeNode)tree.getLastSelectedPathComponent();				
+				doNodeAction(selectedNode);			
+			}		
+		});
+	}
+	
+	private void doNodeAction(UPnPDeviceTreeNode node){
+		if (node == null) {
+			clearPropertiesViewer();
+			return;
+		}
+		if (node.category.equals(UPnPDeviceTreeNode.ACTION))
+			Mediator.getPropertiesViewer().showActionPanel(true);
+		else
+			Mediator.getPropertiesViewer().showActionPanel(false);
+
+		if (node.category.equals(UPnPDeviceTreeNode.SERVICE))
+			Mediator.getPropertiesViewer().showSubscriptionPanel(true);
+		else
+			Mediator.getPropertiesViewer().showSubscriptionPanel(false);
+
+		if ( node.category.equals(UPnPDeviceTreeNode.DEVICE)
+			||node.category.equals(UPnPDeviceTreeNode.ROOT_DEVICE)){
+			DeviceNode device = (DeviceNode) node.getUserObject();
+			UPnPDevice upnpDevice = device.getDevice(Activator.context);
+			makeProperties(upnpDevice);
+		} 
+		else if (node.category.equals(UPnPDeviceTreeNode.SERVICE)){
+			UPnPService service = (UPnPService) node.getUserObject();			
+			makeProperties(service);
+		}
+		else if (node.category.equals(UPnPDeviceTreeNode.ACTION)){
+			UPnPAction action = (UPnPAction) node.getUserObject();
+			makeProperties(action);
+			Mediator.getPropertiesViewer().setAction(action);
+		}
+		else if (node.category.equals(UPnPDeviceTreeNode.STATE)
+		        ||node.category.equals(UPnPDeviceTreeNode.EVENTED_STATE)
+		        ||node.category.equals(UPnPDeviceTreeNode.SUBSCRIBED_STATE)){
+			UPnPStateVariable state = (UPnPStateVariable) node.getUserObject();
+			makeProperties(state);
+		}
+		
+	}
+	
+	private void clearPropertiesViewer(){
+		String[] names = new String[]{};
+		String[] values = new String[]{};
+		PropertiesViewer viewer = Mediator.getPropertiesViewer();
+		viewer.setProperties(names,values);
+		viewer.showActionPanel(false);
+		viewer.showSubscriptionPanel(false);
+	}
+	
+	private void makeProperties(UPnPDevice upnpDevice){
+		Dictionary dict = upnpDevice.getDescriptions(null);
+		int size = dict.size();
+		String[] names = new String[size];
+		String[] values = new String[size];
+		Enumeration keys = dict.keys();
+		for (int i=0;i<size;i++){
+			names[i]= (String) keys.nextElement();
+			values[i]= Util.justString(dict.get(names[i]));
+		}
+		Mediator.getPropertiesViewer().setProperties(names,values);
+	}
+	
+	private void makeProperties(UPnPService service){
+		String[] names = new String[]{"Id","Type","Version"};
+		String[] values = new String[]{service.getId(),service.getType(),service.getType()};
+		Mediator.getPropertiesViewer().setProperties(names,values);
+	}
+	
+	private void makeProperties(UPnPAction action){
+		ArrayList names = new ArrayList();
+		ArrayList values = new ArrayList();
+		names.add("Name");
+		values.add(action.getName());
+		
+		String returnName = action.getReturnArgumentName();
+		if (returnName != null){
+			names.add("Return value name");
+			values.add(returnName);
+		}
+		String[] inArg = action.getInputArgumentNames();
+		if (inArg != null){
+			for (int i = 0; i<inArg.length;i++){
+				names.add("Input arg["+ (i+1)+"]");
+				values.add(inArg[i]);			
+			}
+		}
+		String[] outArg = action.getOutputArgumentNames();
+		if (outArg != null){
+			for (int i = 0; i<outArg.length;i++){
+				names.add("Output arg["+ (i+1)+"]");
+				values.add(outArg[i]);			
+			}
+		}
+		
+		Mediator.getPropertiesViewer().setProperties(
+				(String[])names.toArray(new String[]{}),
+				(String[])values.toArray(new String[]{})
+		);
+		
+	}
+	
+	private void makeProperties(UPnPStateVariable state){
+		ArrayList names = new ArrayList();
+		ArrayList values = new ArrayList();
+		names.add("Name");
+		values.add(state.getName());
+		names.add("Evented");
+		values.add(state.sendsEvents()? "yes":"no");
+		names.add("Default Value");
+		values.add(Util.justString(state.getDefaultValue()));
+		names.add("Java Data Type");
+		values.add(state.getJavaDataType().getName());
+		names.add("Java UPnP Type");
+		values.add(state.getUPnPDataType());
+		names.add("Minimum");
+		values.add(Util.justString(state.getMinimum()));
+		names.add("Maximum");
+		values.add(Util.justString(state.getMaximum()));
+		names.add("Step");
+		values.add(Util.justString(state.getStep()));		
+		String[] allowed = state.getAllowedValues();
+		if (allowed!=null){
+			for (int i=0;i<allowed.length;i++){
+				names.add("Allowed value["+i+1+"]");
+				values.add(allowed[i]);		
+			}			
+		}
+		Mediator.getPropertiesViewer().setProperties(
+				(String[])names.toArray(new String[]{}),
+				(String[])values.toArray(new String[]{})
+		);
+	}
+	
+	
+}
+
+class TreePopup extends JPopupMenu implements PopupMenuListener {
+    JTree tree;
+    JMenuItem item;
+
+    public TreePopup(final JTree tree){
+        super();
+        this.tree = tree;
+        (item = add(new AbstractAction(){
+            public void actionPerformed(ActionEvent e){
+                UPnPDeviceTreeNode selectedNode = (UPnPDeviceTreeNode)tree.getLastSelectedPathComponent();   
+                String url = "";
+                if (selectedNode.category.equals(UPnPDeviceTreeNode.DEVICE)){
+                    UPnPDeviceTreeNode parent =  (UPnPDeviceTreeNode)selectedNode.getParent();
+                    while (parent.category!=UPnPDeviceTreeNode.ROOT_DEVICE)
+                         parent =  (UPnPDeviceTreeNode)parent.getParent();
+                    DeviceNode device =  (DeviceNode) parent.getUserObject();
+                    String udn = (String)device.getReference().getProperty(UPnPDevice.UDN);
+                    url = Mediator.getDriverProxy().getDeviceDescriptionURI(udn);
+                }
+                        
+                else if (selectedNode.category.equals(UPnPDeviceTreeNode.ROOT_DEVICE))
+                {
+                    DeviceNode node =  (DeviceNode) selectedNode.getUserObject();
+                    String udn = (String)node.getReference().getProperty(UPnPDevice.UDN);
+                    url = Mediator.getDriverProxy().getDeviceDescriptionURI(udn);
+                }
+                else if (selectedNode.category.equals(UPnPDeviceTreeNode.SERVICE))
+                {
+                    UPnPDeviceTreeNode parent =  (UPnPDeviceTreeNode)selectedNode.getParent();
+                    while (parent.category!=UPnPDeviceTreeNode.ROOT_DEVICE)
+                         parent =  (UPnPDeviceTreeNode)parent.getParent();
+                    DeviceNode device =  (DeviceNode) parent.getUserObject();
+                    String udn = (String)device.getReference().getProperty(UPnPDevice.UDN);
+                    UPnPService service =  (UPnPService) selectedNode.getUserObject();
+                    url = Mediator.getDriverProxy().getServiceDescriptionURI(udn,service.getId());
+                }                    
+                Util.openUrl(url);   
+            }
+        })).setText("Show Description");
+        addPopupMenuListener(this);
+
+    }
+    
+    public void popupMenuCanceled(PopupMenuEvent e){}
+    public void popupMenuWillBecomeInvisible(PopupMenuEvent e){}
+    public void popupMenuWillBecomeVisible(PopupMenuEvent e){
+        if (Mediator.getDriverProxy().isDriverAvailable()){
+        UPnPDeviceTreeNode selectedNode = (UPnPDeviceTreeNode)tree.getLastSelectedPathComponent();              
+            if (selectedNode.category.equals(UPnPDeviceTreeNode.DEVICE)
+                ||selectedNode.category.equals(UPnPDeviceTreeNode.ROOT_DEVICE)
+                ||selectedNode.category.equals(UPnPDeviceTreeNode.SERVICE))
+            {
+                item.setEnabled(true);
+            } 
+            else
+                item.setEnabled(false);
+        }
+        else
+            item.setEnabled(false);
+           
+    }
+}

Propchange: felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/TreeViewer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/TreeViewer.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: felix/trunk/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/TreeViewer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain