origVolume = volumeConverter.getVolume(volumeSlider.getValue());
// Figure out whether there already exists a server state for the
// component. If not, then create one.
CellServerState cellServerState = editor.getCellServerState();
PortalComponentServerState state =
(PortalComponentServerState) cellServerState.getComponentServerState(
PortalComponentServerState.class);
if (state == null) {
//state = new PortalComponentServerState();
return;
}
// Set the values in the server state from the text fields. If the text
// fields are empty, they will return an empty string (""), this is
// converted to null to set in the server state.
state.setServerURL(origServerURL);
// Set the location on the server state
state.setLocation(new Vector3f(origX, origY, origZ));
// Set the destination look direction from the text field. If the text
// field is empty, then set the server state as a zero rotation.
Quaternion look = new Quaternion();
Vector3f axis = new Vector3f(0.0f, 1.0f, 0.0f);
float angle = (float) Math.toRadians(origLookDirection);
look.fromAngleAxis((float) angle, axis);
state.setLook(look);
state.setAudioSourceType(origAudioSourceType);
state.setAudioSource(origAudioSource);
state.setUploadFile(true);
state.setVolume(origVolume);
File image = cspp.getImage();
String uri=cspp.getImageURL();
if(image!=null) {
uri = uploadImage(image);
}
state.setBackgroundColor(cspp.getBackColor());
state.setTextColor(cspp.getTextColor());
state.setImageURL(uri);
state.setMessage(cspp.getMessage());
String cacheFilePath;
switch (audioSourceType) {
case FILE:
try {
cacheFilePath = audioCacheHandler.cacheFile(origAudioSource);
} catch (AudioCacheHandlerException e) {
break;
}
try {
audioCacheHandler.uploadFileAudioSource(origAudioSource);
} catch (AudioCacheHandlerException e) {
}
state.setCachedAudioSource(cacheFilePath);
break;
case CONTENT_REPOSITORY:
try {
cacheFilePath =
audioCacheHandler.cacheContent(urlTF.getText().trim(), origAudioSource);
} catch (AudioCacheHandlerException e) {
break;
}
state.setCachedAudioSource(cacheFilePath);
break;
case URL:
try {
cacheFilePath = audioCacheHandler.cacheURL(new URL(origAudioSource));
} catch (Exception e) {
errorMessage("Cache URL", "Unable to cache URL: " + e.getMessage());
break;
}
state.setCachedAudioSource(cacheFilePath);
break;
}
editor.addToUpdateList(state);
setPanelDirty();