Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Masking like in GWT-EXT

    Is it possible to mask any visual component like in GWT-EXT?

    Especially when we have window manager we want a modal window
    to mask only its parent and not whole desktop.

    Thanks,
    --MG

    #2
    Making table

    Another issue would be to mask grid when it is refreshed by pagination control
    or server side sorting.

    It would be nice to have some Ajax activity indicator in it while it is masked.

    Is this supported as well?

    Thanks,
    --MG

    Comment


      #3
      the only masking i have seen/used is for modal windows

      Code:
      winModal.setShowModalMask(true);
      i am sure you could create one using the animation packages

      Comment


        #4
        Right now SmartGWT has full-screen masking only, with a few possible visual appearances (see RPCRequest.setShowPrompt(), setPromptStyle()).

        There is some currently internal support for per-component masking. Most people shy away from it when they realize how complex it can be trying to handle events on other components while one component is in a transitional state :) But if it's a hard requirement, you can contact Isomorphic about having it added as a supported feature.

        Comment


          #5
          Well, component masking worked for us quite well in GWT-EXT. :(

          Comment


            #6
            I'd love to see component masking as well... at least for the grid. Another nice feature in GWT-Ext was the masking done for modal windows... there was no ambiguity when a modal window was displayed that it was the only one that would receive events until it was dismissed.

            Thanks for such great work!

            Comment


              #7
              There's masking for modal windows, it's setShowModalMask(true).

              On per-component masking for modal sub-windows, this would be pretty easy to add. When you launch a modal sub-window, put a translucent (setOpacity(), setBackgroundColor()) Canvas over the original Window, and destroy() it when the modal sub-window is dismissed.

              Comment


                #8
                I would also want a masking feature like in gwt-ext where you could mask by components and also we had the faded background (this one is important!)

                Comment


                  #9
                  Just to clarify, setShowModalMask() on a modal Window does cause it to fade the background of the entire application. For per-component masking, the previous post explains how you can achieve the same effect for an individual component.

                  Comment


                    #10
                    When setShowModalMask(true) is called the background is set to gray. Is there a way to set it to a different color?

                    Comment


                      #11
                      Yes - see skin_styles.css in whatever skin you're using. The style is called ".modalMask".

                      Comment


                        #12
                        setShowModalMask(true) is not working for me.

                        Code:
                                 Window dlg = new Window();
                                        dlg.setTitle("Blahhhh");
                                        dlg.setShowTitle(true);
                                        RichTextEditor editor = new RichTextEditor();
                                        editor.setWidth100();
                                        editor.setHeight100();
                                        dlg.setWidth("65%");
                                        dlg.setHeight("65%");
                                        dlg.addMember(editor);
                                        dlg.setShowModalMask(true);
                                        dlg.setIsModal(true);
                                        dlg.show();
                        I don't get any Masking? I checked in firebug skins_styles.css is loading and does have the correct definition.

                        Comment


                          #13
                          I made a class to help me emulate the masking that was available in GWT-EXT. It is very useful to me so I want to share it with you, maybe you'll also find it useful.

                          So to mask a certain window (Canvas) I create

                          Code:
                          // create an instance of my class given the window that I want to mask
                          ModalWindow modalWindow = new ModalWindow(myWindow);
                          
                          // ask to mask the window and show the loading image without any message
                          modalWindow.show(true);
                          
                          // ask to mask the window using a message and true to show the loading image
                          modalWindow.show("A espera do servidor", true);
                          
                          // to remove the masking from the window
                          modalWindow.hide();
                          The class used above is (just copy paste):

                          Code:
                          package pt.gedi.base.interfaceClient.client.widgets;
                          
                          import com.smartgwt.client.types.Alignment;
                          import com.smartgwt.client.widgets.Canvas;
                          import com.smartgwt.client.widgets.Label;
                          import com.smartgwt.client.widgets.layout.HStack;
                          
                          /**
                           * Class that supports masking an entire {@link Canvas} and adds the possibility
                           * to display a message during masking and a loading image
                           * 
                           * @author Mihai Ile
                           * 
                           */
                          public class ModalWindow {
                          
                          	/**
                          	 * The canvas to be masked
                          	 */
                          	private final Canvas canvas;
                          
                          	/**
                          	 * The modal layer
                          	 */
                          	private HStack modal;
                          
                          	/**
                          	 * The reference to the transparent layer inside the modal HStack
                          	 */
                          	private Canvas transparent;
                          
                          	/**
                          	 * Creates a new {@link ModalWindow} given the canvas to be masked (an
                          	 * {@link Canvas#addChild(Canvas)} will be called to add the masking layer
                          	 * above the given canvas)
                          	 * 
                          	 * @param canvas
                          	 *            the canvas to be masked
                          	 */
                          	public ModalWindow(Canvas canvas) {
                          		this.canvas = canvas;
                          		createModalPanel();
                          	}
                          
                          	/**
                          	 * Mask the {@link Canvas} with a transparent color
                          	 * 
                          	 * @param showLoading
                          	 *            whether to show a box with a loading indicator above the
                          	 *            background
                          	 */
                          	public void show(boolean showLoading) {
                          		clearLabel();
                          		Label label = createLabel(showLoading);
                          		modal.addMember(label);
                          		modal.show();
                          	}
                          
                          	/**
                          	 * Mask the {@link Canvas} with a transparent color and display a message
                          	 * above it
                          	 * 
                          	 * @param message
                          	 *            the message to display above the background
                          	 * @param showLoading
                          	 *            whether to show a box with a loading indicator above the
                          	 *            background
                          	 */
                          	public void show(String message, boolean showLoading) {
                          		clearLabel();
                          		Label label = createLabel(showLoading);
                          		label.setContents(message);
                          		modal.addMember(label);
                          		modal.show();
                          	}
                          
                          	/**
                          	 * Hide the masking layer from the {@link Canvas}
                          	 */
                          	public void hide() {
                          		modal.hide();
                          	}
                          
                          	private void clearLabel() {
                          		Canvas[] children = modal.getChildren();
                          		for (Canvas canvas : children) {
                          			if (canvas instanceof Label) {
                          				Label label = (Label) canvas;
                          				modal.removeChild(label);
                          				label.destroy();
                          			}
                          		}
                          	}
                          
                          	private void createModalPanel() {
                          		modal = new HStack();
                          		modal.setWidth100();
                          		modal.setHeight100();
                          		modal.setDefaultLayoutAlign(Alignment.CENTER);
                          		modal.hide();
                          
                          		transparent = new Canvas();
                          		transparent.setWidth100();
                          		transparent.setHeight100();
                          		transparent.setBackgroundColor("#555");
                          		transparent.setOpacity(30);
                          
                          		modal.addChild(transparent);
                          		canvas.addChild(modal);
                          	}
                          
                          	private Label createLabel(boolean showLoading) {
                          		Label label = new Label();
                          		label.setWrap(false);
                          		label.setPadding(5);
                          		label.setWidth100();
                          		label.setHeight(25);
                          		label.setBackgroundColor("#fff");
                          		label.setShowEdges(true);
                          		label.setAlign(Alignment.CENTER);
                          		if (showLoading) {
                          			label.setIcon("loading.gif");
                          		}
                          		label.setZIndex(transparent.getZIndex() + 2);
                          		return label;
                          	}
                          
                          	/**
                          	 * Destroy the {@link ModalWindow} freeing up resources
                          	 */
                          	public void destroy() {
                          		modal.destroy();
                          	}
                          }
                          P.S: the loading.gif is the one from gwt-ext and in my progect is placed in public/images/loading.gif

                          Comment


                            #14
                            Mihai,
                            Can you add this to the smartgwt-extensions project (preferably with a sample)?

                            Thanks,
                            Sanjiv

                            Comment


                              #15
                              I will do that, I'm just making it a little more customizable (opacity value, colors used, etc) and then I will post with an example.

                              Comment

                              Working...
                              X