Search in sources :

Example 1 with Media

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();
    }
}
Also used : FlattenedForm(com.servoy.j2db.persistence.FlattenedForm) Set(java.util.Set) IPersist(com.servoy.j2db.persistence.IPersist) Media(com.servoy.j2db.persistence.Media) IFormController(com.servoy.j2db.IFormController) Solution(com.servoy.j2db.persistence.Solution)

Example 2 with Media

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();
}
Also used : Media(com.servoy.j2db.persistence.Media) Point(java.awt.Point)

Example 3 with Media

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();
    }
}
Also used : Media(com.servoy.j2db.persistence.Media) ByteArrayResource(com.servoy.j2db.server.headlessclient.ByteArrayResource) IOException(java.io.IOException) IOException(java.io.IOException)

Example 4 with Media

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);
            }
        }
    }
}
Also used : Media(com.servoy.j2db.persistence.Media) Point(java.awt.Point) IOException(java.io.IOException)

Example 5 with Media

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();
}
Also used : Media(com.servoy.j2db.persistence.Media) Point(java.awt.Point)

Aggregations

Media (com.servoy.j2db.persistence.Media)29 FlattenedSolution (com.servoy.j2db.FlattenedSolution)10 IOException (java.io.IOException)8 Point (java.awt.Point)7 Solution (com.servoy.j2db.persistence.Solution)4 JSFunction (org.mozilla.javascript.annotations.JSFunction)3 FormController (com.servoy.j2db.FormController)2 RepositoryException (com.servoy.j2db.persistence.RepositoryException)2 ByteArrayResource (com.servoy.j2db.server.headlessclient.ByteArrayResource)2 Image (java.awt.Image)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 InputStream (java.io.InputStream)2 URLConnection (java.net.URLConnection)2 ArrayList (java.util.ArrayList)2 JSONException (org.json.JSONException)2 AbstractActiveSolutionHandler (com.servoy.j2db.AbstractActiveSolutionHandler)1 IForm (com.servoy.j2db.IForm)1 IFormController (com.servoy.j2db.IFormController)1 IScriptExecuter (com.servoy.j2db.IScriptExecuter)1 IDisplayData (com.servoy.j2db.dataprocessing.IDisplayData)1