Search in sources :

Example 1 with DeviceNode

use of org.apache.felix.upnp.tester.discovery.DeviceNode in project felix by apache.

the class LinkCellRenderer method getDataLink.

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;
        }
    }
}
Also used : JTree(javax.swing.JTree) DeviceNode(org.apache.felix.upnp.tester.discovery.DeviceNode) Point(java.awt.Point)

Example 2 with DeviceNode

use of org.apache.felix.upnp.tester.discovery.DeviceNode in project felix by apache.

the class SubscriptionPanel method getDeviceId.

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;
}
Also used : DeviceNode(org.apache.felix.upnp.tester.discovery.DeviceNode)

Example 3 with DeviceNode

use of org.apache.felix.upnp.tester.discovery.DeviceNode in project felix by apache.

the class TreeNodeCellRenderer method setToolTip.

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);
}
Also used : DeviceNode(org.apache.felix.upnp.tester.discovery.DeviceNode)

Example 4 with DeviceNode

use of org.apache.felix.upnp.tester.discovery.DeviceNode in project felix by apache.

the class TreePopup method doNodeAction.

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);
    }
}
Also used : DeviceNode(org.apache.felix.upnp.tester.discovery.DeviceNode) UPnPDevice(org.osgi.service.upnp.UPnPDevice) UPnPStateVariable(org.osgi.service.upnp.UPnPStateVariable) UPnPService(org.osgi.service.upnp.UPnPService) UPnPAction(org.osgi.service.upnp.UPnPAction)

Example 5 with DeviceNode

use of org.apache.felix.upnp.tester.discovery.DeviceNode in project felix by apache.

the class TreePopup method rootDeviceUnplugged.

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);
        }
    }
}
Also used : Enumeration(java.util.Enumeration) DeviceNode(org.apache.felix.upnp.tester.discovery.DeviceNode)

Aggregations

DeviceNode (org.apache.felix.upnp.tester.discovery.DeviceNode)5 Point (java.awt.Point)1 Enumeration (java.util.Enumeration)1 JTree (javax.swing.JTree)1 UPnPAction (org.osgi.service.upnp.UPnPAction)1 UPnPDevice (org.osgi.service.upnp.UPnPDevice)1 UPnPService (org.osgi.service.upnp.UPnPService)1 UPnPStateVariable (org.osgi.service.upnp.UPnPStateVariable)1