use of com.servoy.j2db.persistence.Media in project servoy-client by Servoy.
the class DebugNGClient method refreshPersists.
@Override
public void refreshPersists(Collection<IPersist> changes) {
if (isShutDown())
return;
// flush the solution model cache of the form element helper when there is a solution copy.
// so that FormComponents are recreated with the latest data once.
Solution solutionCopy = getFlattenedSolution().getSolutionCopy(false);
if (solutionCopy != null)
solutionCopy.setRuntimeProperty(FormElementHelper.SOLUTION_MODEL_CACHE, null);
Set<IFormController>[] scopesAndFormsToReload = DebugUtils.getScopesAndFormsToReload(this, changes);
for (IFormController controller : scopesAndFormsToReload[1]) {
if (controller.getForm() instanceof FlattenedForm) {
FlattenedForm ff = (FlattenedForm) controller.getForm();
ff.reload();
}
}
boolean forcePageReload = false;
if (scopesAndFormsToReload[1] == null || scopesAndFormsToReload[1].size() < 1) {
for (IPersist persist : changes) {
// that one, can also have other css included, using the 'import' statement
if (persist instanceof Media && !PersistHelper.getOrderedStyleSheets(getFlattenedSolution()).isEmpty()) {
String name = ((Media) persist).getName().toLowerCase();
if (name.endsWith(".less") || name.endsWith(".css")) {
forcePageReload = true;
break;
}
}
}
}
refreshForms(scopesAndFormsToReload[1], forcePageReload);
for (IFormController controller : scopesAndFormsToReload[0]) {
controller.getFormScope().reload();
}
}
use of com.servoy.j2db.persistence.Media in project servoy-client by Servoy.
the class WebBaseButton method setRolloverImageURL.
public void setRolloverImageURL(String imageUrl) {
this.rolloverUrl = imageUrl;
rolloverIconReference = null;
if (rolloverUrl != null) {
int index = imageUrl.indexOf(MediaURLStreamHandler.MEDIA_URL_DEF);
if (index != -1) {
String nm = rolloverUrl.substring(index + MediaURLStreamHandler.MEDIA_URL_DEF.length());
Media m = application.getFlattenedSolution().getMedia(nm);
if (m != null) {
setRolloverIcon(m.getID());
}
}
}
addRolloverBehaviors();
scriptable.getChangesRecorder().setChanged();
}
use of com.servoy.j2db.persistence.Media in project servoy-client by Servoy.
the class WebBaseLabel method onResourceRequested.
/**
* @see wicket.IResourceListener#onResourceRequested()
*/
public void onResourceRequested() {
// $NON-NLS-1$
String mediaParameter = RequestCycle.get().getRequest().getParameter("media");
if (mediaParameter != null) {
Media m;
try {
m = application.getFlattenedSolution().getMedia(mediaParameter);
byte[] bytes = m.getMediaData();
new ByteArrayResource(MimeTypes.getContentType(bytes), bytes, null).onResourceRequested();
} catch (Exception ex) {
// $NON-NLS-1$
Debug.error("Error serving media: " + mediaParameter, ex);
}
} else if (getRequest().getParameter(StripHTMLTagsConverter.BLOB_LOADER_PARAM) != null) {
String url = StripHTMLTagsConverter.getBlobLoaderUrlPart(getRequest());
try {
byte[] bytes = MediaURLStreamHandler.getBlobLoaderMedia(application, url);
if (bytes != null) {
String mime = MediaURLStreamHandler.getBlobLoaderMimeType(url);
if (mime == null)
mime = MimeTypes.getContentType(bytes);
String filename = MediaURLStreamHandler.getBlobLoaderFileName(url);
if (size != null) {
MediaResource tempIcon = new MediaResource(bytes, mediaOptions);
(tempIcon).checkResize(size);
bytes = tempIcon.resized;
}
new ByteArrayResource(mime, bytes, filename).onResourceRequested();
}
} catch (IOException ex) {
// $NON-NLS-1$
Debug.error("Error serving blobloader url: " + url, ex);
}
} else {
icon.onResourceRequested();
}
}
use of com.servoy.j2db.persistence.Media in project servoy-client by Servoy.
the class WebBaseLabel method setImageURL.
public void setImageURL(String textUrl) {
this.text_url = textUrl;
if (textUrl == null) {
icon = null;
iconReference = null;
iconUrl = null;
} else {
int index = textUrl.indexOf(MediaURLStreamHandler.MEDIA_URL_DEF);
if (index == -1) {
icon = null;
iconReference = null;
iconUrl = textUrl;
addEnabledStyleAttributeModifier();
} else {
String mediaName = textUrl.substring(index + MediaURLStreamHandler.MEDIA_URL_DEF.length());
try {
Media med = application.getFlattenedSolution().getMedia(mediaName);
if (med != null) {
setMediaIcon(med.getID());
} else if (mediaName.startsWith(MediaURLStreamHandler.MEDIA_URL_BLOBLOADER)) {
// clear previous images
icon = null;
iconReference = null;
iconUrl = null;
addEnabledStyleAttributeModifier();
}
} catch (Exception ex) {
// $NON-NLS-1$
Debug.error("Error loading media for url: " + textUrl, ex);
}
}
}
}
use of com.servoy.j2db.persistence.Media in project servoy-client by Servoy.
the class WebBaseSubmitLink method setRolloverImageURL.
public void setRolloverImageURL(String imageUrl) {
this.rolloverUrl = imageUrl;
rolloverIconReference = null;
if (rolloverUrl != null) {
int index = imageUrl.indexOf(MediaURLStreamHandler.MEDIA_URL_DEF);
if (index != -1) {
String nm = rolloverUrl.substring(index + MediaURLStreamHandler.MEDIA_URL_DEF.length());
Media m = application.getFlattenedSolution().getMedia(nm);
if (m != null) {
setRolloverIcon(m.getID());
}
}
}
addRolloverBehaviors();
}
Aggregations