public ConfigurationManagerBean() {
// Init panel
DevicePreferences devicePrefererences = SalsaAPI.getDevicePreferences();
ISuggestions suggestions = null;
if (devicePrefererences != null) {
String scanServer = devicePrefererences.getScanServer();
try {
suggestions = SalsaAPI.getDevicesSuggestions(scanServer);
} catch (SalsaDeviceException e) {
}
}
IDeviceListTableListener sensorListener = new IDeviceListTableListener() {
@Override
public void deviceRenamed(String oldName, String newName) {
configManager.renameSensor(oldName, newName);
}
@Override
public void deviceRemoved(String device) {
configManager.deleteSensor(device);
}
@Override
public void deviceEnabled(String device, boolean enabled) {
configManager.setSensorEnable(device, enabled);
}
@Override
public void deviceAdded(String device) {
configManager.addSensor(device);
sensorPanel.setDeviceList(configManager.getSensorsList());
}
@Override
public void devicesAdded(List<String> devices) {
if (devices != null) {
for (String device : devices) {
configManager.addSensor(device);
}
sensorPanel.setDeviceList(configManager.getSensorsList());
}
}
};
sensorPanel = new DeviceListTable(sensorListener);
if (suggestions != null) {
sensorPanel.setSuggestionList(suggestions.getSensorSuggestionList());
}
IDeviceListTableListener timeBaseListener = new IDeviceListTableListener() {
@Override
public void deviceRenamed(String oldName, String newName) {
configManager.renameTimeBase(oldName, newName);
}
@Override
public void deviceRemoved(String device) {
configManager.deleteTimeBase(device);
}
@Override
public void deviceEnabled(String device, boolean enabled) {
configManager.setTimeBaseEnable(device, enabled);
}
@Override
public void deviceAdded(String device) {
configManager.addTimeBase(device);
timeBasePanel.setDeviceList(configManager.getTimebaseList());
}
@Override
public void devicesAdded(List<String> devices) {
if (devices != null) {
for (String device : devices) {
configManager.addTimeBase(device);
}
timeBasePanel.setDeviceList(configManager.getTimebaseList());
}
}
};
timeBasePanel = new DeviceListTable(timeBaseListener);
if (suggestions != null) {
timeBasePanel.setSuggestionList(suggestions.getTimebaseSuggestionList());
}
IDeviceListTableListener actuatorXListener = new IDeviceListTableListener() {
@Override
public void deviceRenamed(String oldName, String newName) {
configManager.renameActuator(oldName, newName);
}
@Override
public void deviceRemoved(String device) {
configManager.deleteActuator(device);
}
@Override
public void deviceEnabled(String device, boolean enabled) {
configManager.setActuatorEnable(device, enabled);
}
@Override
public void deviceAdded(String device) {
configManager.addActuator(device, false);
List<IDimension> dimensionList = configManager.getDimensionList();
IDimension tmpDimension = null;
if ((dimensionList != null) && !dimensionList.isEmpty()) {
tmpDimension = dimensionList.get(0);
actuatorXPanel.setDeviceList(tmpDimension.getActuatorsList());
}
}
@Override
public void devicesAdded(List<String> devices) {
if (devices != null) {
for (String device : devices) {
configManager.addActuator(device, false);
}
List<IDimension> dimensionList = configManager.getDimensionList();
IDimension tmpDimension = null;
if ((dimensionList != null) && !dimensionList.isEmpty()) {
tmpDimension = dimensionList.get(0);
actuatorXPanel.setDeviceList(tmpDimension.getActuatorsList());
}
}
}
};
actuatorXPanel = new DeviceListTable(actuatorXListener);
if (suggestions != null) {
actuatorXPanel.setSuggestionList(suggestions.getActuatorSuggestionList());
}
IDeviceListTableListener actuatorYListener = new IDeviceListTableListener() {
@Override
public void deviceRenamed(String oldName, String newName) {
configManager.renameActuator(oldName, newName);
}
@Override
public void deviceRemoved(String device) {
configManager.deleteActuator(device);
}
@Override
public void deviceEnabled(String device, boolean enabled) {
configManager.setActuatorEnable(device, enabled);
}
@Override
public void deviceAdded(String device) {
configManager.addActuator(device, true);
List<IDimension> dimensionList = configManager.getDimensionList();
IDimension tmpDimension = null;
if ((dimensionList != null) && (dimensionList.size() > 1)) {
tmpDimension = dimensionList.get(1);
actuatorYPanel.setDeviceList(tmpDimension.getActuatorsList());
}
}
@Override
public void devicesAdded(List<String> devices) {
if (devices != null) {
for (String device : devices) {
configManager.addActuator(device, true);
}
List<IDimension> dimensionList = configManager.getDimensionList();
IDimension tmpDimension = null;
if ((dimensionList != null) && (dimensionList.size() > 1)) {
tmpDimension = dimensionList.get(1);
actuatorYPanel.setDeviceList(tmpDimension.getActuatorsList());
}
}
}
};
actuatorYPanel = new DeviceListTable(actuatorYListener);
if (suggestions != null) {
actuatorYPanel.setSuggestionList(suggestions.getActuatorSuggestionList());
}
noConfigPanel.setLayout(new BorderLayout());
noConfigPanel.add(noConfiguration, BorderLayout.CENTER);