Package org.gwt.mosaic.ui.client

Examples of org.gwt.mosaic.ui.client.ImageButton


    widget.setVisible(true);
    Log.addLogger(logger);
   
    messagePanel.add(widget);

    final ImageButton collapseBtn = new ImageButton(Caption.IMAGES.toolCollapseDown());
    messagePanel.getHeader().add(collapseBtn, Caption.CaptionRegion.RIGHT);

    collapseBtn.addClickHandler(new ClickHandler() {
      public void onClick(ClickEvent event) {
        parent.setCollapsed(messagePanel, true);
        parent.invalidate();
        parent.layout();
      }
View Full Code Here


    toolButton.addClickListener(action);
    return toolButton;
  }

  private ImageButton createImageButton(Action action) {
    ImageButton imageButton = new ImageButton(action.getImage());
    imageButton.addClickListener(action);
    return imageButton;
  }
View Full Code Here

        int h = 0;

        if (layoutData.collapse) {
          if (northCollapsedImageButton == null) {
            northCollapsedImageButton = new ImageButton(
                Caption.IMAGES.toolCollapseDown());
            northCollapsedImageButton.addStyleName("NorthCollapsedImageButton");
            northCollapsedImageButton.addClickListener(new ClickListener() {
              public void onClick(Widget sender) {
                layoutPanel.setCollapsed(northCollapsed, false);
                layoutPanel.removeImpl(northCollapsedImageButton);
                northCollapsedImageButton = null;
                if (layoutData.hasDecoratorPanel()) {
                  layoutData.decoratorPanel.setVisible(true);
                }
                northCollapsed.setVisible(true);
                layoutPanel.layout();
                return;
              }
            });
            layoutPanel.addImpl(northCollapsedImageButton);
            if (layoutData.hasDecoratorPanel()) {
              layoutData.decoratorPanel.setVisible(false);
            }
            northCollapsed = north;
            north.setVisible(false);
          }
          h = WidgetHelper.getPreferredSize(northCollapsedImageButton).height;
          WidgetHelper.setBounds(layoutPanel, northCollapsedImageButton, left,
              top, Math.max(0, right - left), h);
        } else {

          if (layoutData.preferredSize == -1.0) {
            h = WidgetHelper.getPreferredSize(north).height;
            runTwiceFlag = true;
          } else if (layoutData.preferredSize > 0.0
              && layoutData.preferredSize <= 1.0) {
            h = (int) (height * layoutData.preferredSize);
          } else {
            h = (int) layoutData.preferredSize;
          }

          int _width = Math.max(0, right - left);
          int _height = -1;
          if (layoutData.preferredSize != -1.0) {
            _height = h;
          }

          if (layoutData.hasDecoratorPanel()) {
            final Dimension decPanelBorderSize = getDecoratorFrameSize(
                layoutData.decoratorPanel, north);

            _width -= decPanelBorderSize.width;

            // increase 'h'
            h += decPanelBorderSize.height;
          }
          WidgetHelper.setBounds(layoutPanel, north, left, top, _width, _height);

          // split bar
          if (layoutData.resizable && northSplitBar.isAttached()) {
            WidgetHelper.setBounds(layoutPanel, northSplitBar, left, top + h,
                Math.max(0, right - left), spacing);
          }
        }
        top += (h + spacing);
      }

      if (south != null) {
        final BorderLayoutData layoutData = (BorderLayoutData) getLayoutData(south);

        if (layoutData.resizable && !layoutData.collapse) {
          if (southSplitBar == null) {
            southSplitBar = new SplitBar(layoutPanel, south, SplitBar.SOUTH);
            southSplitBar.setStyleName("SouthSplitBar");
            layoutPanel.addImpl(southSplitBar);
          }
        } else {
          if (southSplitBar != null) {
            layoutPanel.removeImpl(southSplitBar);
            southSplitBar = null;
          }
        }

        int h = 0;

        if (layoutData.collapse) {
          if (southCollapsedImageButton == null) {
            southCollapsedImageButton = new ImageButton(
                Caption.IMAGES.toolCollapseUp());
            southCollapsedImageButton.addStyleName("SouthCollapsedImageButton");
            southCollapsedImageButton.addClickListener(new ClickListener() {
              public void onClick(Widget sender) {
                layoutPanel.setCollapsed(southCollapsed, false);
                layoutPanel.removeImpl(southCollapsedImageButton);
                southCollapsedImageButton = null;
                if (layoutData.hasDecoratorPanel()) {
                  layoutData.decoratorPanel.setVisible(true);
                }
                southCollapsed.setVisible(true);
                layoutPanel.layout();
                return;
              }
            });
            layoutPanel.addImpl(southCollapsedImageButton);
            if (layoutData.hasDecoratorPanel()) {
              layoutData.decoratorPanel.setVisible(false);
            }
            southCollapsed = south;
            south.setVisible(false);
          }
          h = WidgetHelper.getPreferredSize(southCollapsedImageButton).height;
          WidgetHelper.setBounds(layoutPanel, southCollapsedImageButton, left,
              Math.max(0, bottom - h), Math.max(0, right - left), h);
        } else {
          if (layoutData.preferredSize == -1.0) {
            h = WidgetHelper.getPreferredSize(south).height;
            runTwiceFlag = true;
          } else if (layoutData.preferredSize > 0.0
              && layoutData.preferredSize <= 1.0) {
            h = (int) (height * layoutData.preferredSize);
          } else {
            h = (int) layoutData.preferredSize;
          }

          int _width = Math.max(0, right - left);
          int _top = Math.max(0, bottom - h);
          int _height = -1;
          if (layoutData.preferredSize != -1.0) {
            _height = h;
          }

          if (layoutData.hasDecoratorPanel()) {
            final Dimension decPanelBorderSize = getDecoratorFrameSize(
                layoutData.decoratorPanel, south);

            _width -= decPanelBorderSize.width;
            _top -= decPanelBorderSize.height;

            // increase 'h'
            h += decPanelBorderSize.height;
          }

          WidgetHelper.setBounds(layoutPanel, south, left, _top, _width,
              _height);

          // split bar
          if (layoutData.resizable && southSplitBar.isAttached()) {
            WidgetHelper.setBounds(layoutPanel, southSplitBar, left, Math.max(
                0, bottom - h)
                - spacing, Math.max(0, right - left), spacing);
          }
        }
        bottom -= (h + spacing);
      }

      if (west != null) {
        final BorderLayoutData layoutData = (BorderLayoutData) getLayoutData(west);

        if (layoutData.resizable && !layoutData.collapse) {
          if (westSplitBar == null) {
            westSplitBar = new SplitBar(layoutPanel, west, SplitBar.WEST);
            westSplitBar.setStyleName("WestSplitBar");
            layoutPanel.addImpl(westSplitBar);
          }
        } else {
          if (westSplitBar != null) {
            layoutPanel.removeImpl(westSplitBar);
            westSplitBar = null;
          }
        }

        int w = 0;

        if (layoutData.collapse) {
          if (westCollapsedImageButton == null) {
            westCollapsedImageButton = new ImageButton(
                Caption.IMAGES.toolCollapseRight());
            westCollapsedImageButton.addStyleName("WestCollapsedImageButton");
            westCollapsedImageButton.addClickListener(new ClickListener() {
              public void onClick(Widget sender) {
                layoutPanel.setCollapsed(westCollapsed, false);
                layoutPanel.removeImpl(westCollapsedImageButton);
                westCollapsedImageButton = null;
                if (layoutData.hasDecoratorPanel()) {
                  layoutData.decoratorPanel.setVisible(true);
                }
                westCollapsed.setVisible(true);
                layoutPanel.layout();
                return;
              }
            });
            layoutPanel.addImpl(westCollapsedImageButton);
            if (layoutData.hasDecoratorPanel()) {
              layoutData.decoratorPanel.setVisible(false);
            }
            westCollapsed = west;
            west.setVisible(false);
          }
          w = WidgetHelper.getPreferredSize(westCollapsedImageButton).width;
          WidgetHelper.setBounds(layoutPanel, westCollapsedImageButton, left,
              top, w, Math.max(0, bottom - top));
        } else {
          if (layoutData.preferredSize == -1.0) {
            w = WidgetHelper.getPreferredSize(west).width;
            runTwiceFlag = true;
          } else if (layoutData.preferredSize > 0.0
              && layoutData.preferredSize <= 1.0) {
            w = (int) (width * layoutData.preferredSize);
          } else {
            w = (int) layoutData.preferredSize;
          }

          int _width = -1;
          if (layoutData.preferredSize != -1.0) {
            _width = w;
          }
          int _height = Math.max(0, bottom - top);

          if (layoutData.hasDecoratorPanel()) {
            final Dimension decPanelBorderSize = getDecoratorFrameSize(
                layoutData.decoratorPanel, west);

            _height -= decPanelBorderSize.height;

            // increase 'w'
            w += decPanelBorderSize.width;
          }

          WidgetHelper.setBounds(layoutPanel, west, left, top, _width, _height);

          // split bar
          if (layoutData.resizable && westSplitBar.isAttached()) {
            WidgetHelper.setBounds(layoutPanel, westSplitBar, left + w, top,
                spacing, Math.max(0, bottom - top));
          }
        }
        left += (w + spacing);
      }

      if (east != null) {
        final BorderLayoutData layoutData = (BorderLayoutData) getLayoutData(east);

        if (layoutData.resizable && !layoutData.collapse) {
          if (eastSplitBar == null) {
            eastSplitBar = new SplitBar(layoutPanel, east, SplitBar.EAST);
            eastSplitBar.setStyleName("EastSplitBar");
            layoutPanel.addImpl(eastSplitBar);
          }
        } else {
          if (eastSplitBar != null) {
            layoutPanel.removeImpl(eastSplitBar);
            eastSplitBar = null;
          }
        }

        int w = 0;

        if (layoutData.collapse) {
          if (eastCollapsedImageButton == null) {
            eastCollapsedImageButton = new ImageButton(
                Caption.IMAGES.toolCollapseLeft());
            eastCollapsedImageButton.addStyleName("EastCollapsedImageButton");
            eastCollapsedImageButton.addClickListener(new ClickListener() {
              public void onClick(Widget sender) {
                layoutPanel.setCollapsed(eastCollapsed, false);
View Full Code Here

   *
   * @param windowPanel
   */
  public static void addMaximizeButton(final WindowPanel windowPanel,
                                       Caption.CaptionRegion captionRegion) {
    final ImageButton maximizeBtn = new ImageButton(
        Caption.IMAGES.windowMaximize());
    maximizeBtn.addClickListener(new ClickListener() {
      public void onClick(Widget sender) {
        if (windowPanel.getWindowState() == WindowPanel.WindowState.MAXIMIZED) {
          windowPanel.setWindowState(WindowPanel.WindowState.NORMAL);
        } else {
          windowPanel.setWindowState(WindowPanel.WindowState.MAXIMIZED);
        }
      }
    });
    windowPanel.addWindowStateListener(new WindowPanel.WindowStateListener() {

      public void onWindowStateChange(WindowPanel sender, WindowPanel.WindowState windowState, WindowPanel.WindowState windowState1)
      {
        if (sender.getWindowState() == WindowPanel.WindowState.MAXIMIZED) {
          maximizeBtn.setImage(Caption.IMAGES.windowRestore().createImage());
        } else {
          maximizeBtn.setImage(Caption.IMAGES.windowMaximize().createImage());
        }

      }
    });
    windowPanel.getHeader().add(maximizeBtn, captionRegion);
View Full Code Here

   *
   * @param windowPanel
   */
  public static  void addMinimizeButton(final WindowPanel windowPanel,
                                        Caption.CaptionRegion captionRegion) {
    final ImageButton minimizeBtn = new ImageButton(
        Caption.IMAGES.windowMinimize());
    minimizeBtn.addClickListener(new ClickListener() {
      public void onClick(Widget sender) {
        windowPanel.setWindowState(WindowPanel.WindowState.NORMAL);
      }
    });
    windowPanel.getHeader().add(minimizeBtn, captionRegion);
View Full Code Here

    *
    * @param windowPanel
    */
   public static void addMaximizeButton(final WindowPanel windowPanel,
       Caption.CaptionRegion captionRegion) {
     final ImageButton maximizeBtn = new ImageButton(
         Caption.IMAGES.windowMaximize());
     maximizeBtn.addClickListener(new ClickListener() {
       public void onClick(Widget sender) {
         if (windowPanel.getWindowState() == WindowPanel.WindowState.MAXIMIZED) {
           windowPanel.setWindowState(WindowPanel.WindowState.NORMAL);
         } else {
           windowPanel.setWindowState(WindowPanel.WindowState.MAXIMIZED);
         }
       }
     });
     windowPanel.addWindowStateListener(new WindowPanel.WindowStateListener() {
       public void onWindowStateChange(WindowPanel sender) {
         if (sender.getWindowState() == WindowPanel.WindowState.MAXIMIZED) {
           maximizeBtn.setImage(Caption.IMAGES.windowRestore().createImage());
         } else {
           maximizeBtn.setImage(Caption.IMAGES.windowMaximize().createImage());
         }

       }
     });
     windowPanel.getHeader().add(maximizeBtn, captionRegion);
View Full Code Here

    *
    * @param windowPanel
    */
   public static  void addMinimizeButton(final WindowPanel windowPanel,
       Caption.CaptionRegion captionRegion) {
     final ImageButton minimizeBtn = new ImageButton(
         Caption.IMAGES.windowMinimize());
     minimizeBtn.addClickListener(new ClickListener() {
       public void onClick(Widget sender) {
         windowPanel.setWindowState(WindowPanel.WindowState.NORMAL);
       }
     });
     windowPanel.getHeader().add(minimizeBtn, captionRegion);
View Full Code Here

    if (collapse) {
      if (widget == west || widget == east || widget == north
          || widget == south) {
        if (layoutData.collapsedStateWidget == null) {
          ImageButton imgBtn = null;
          if (layoutData.region == Region.NORTH) {
            imgBtn = new ImageButton(Caption.IMAGES.toolCollapseDown());
            imgBtn.addStyleName("NorthCollapsedImageButton");
            imgBtn.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT);
          } else if (layoutData.region == Region.EAST) {
            imgBtn = new ImageButton(Caption.IMAGES.toolCollapseLeft());
            imgBtn.addStyleName("EastCollapsedImageButton");
            imgBtn.setVerticalAlignment(HasAlignment.ALIGN_TOP);
          } else if (layoutData.region == Region.SOUTH) {
            imgBtn = new ImageButton(Caption.IMAGES.toolCollapseUp());
            imgBtn.addStyleName("SouthCollapsedImageButton");
            imgBtn.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT);
          } else if (layoutData.region == Region.WEST) {
            imgBtn = new ImageButton(Caption.IMAGES.toolCollapseRight());
            imgBtn.addStyleName("WestCollapsedImageButton");
            imgBtn.setVerticalAlignment(HasAlignment.ALIGN_TOP);
          }
          if (imgBtn == null) {
            return;
          }
          imgBtn.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
              layoutPanel.setCollapsed(widget, false);
              layoutPanel.invalidate(widget);
              layoutPanel.layout();
            }
View Full Code Here

 
  // ---
 
  public static ImageButton newImageButton(final String action) {
    final ImageButtonBindings bindings = new ImageButtonBindings(getActionMap().get(action));
    final ImageButton imageButton = (ImageButton) bindings.getTarget();
    bindings.bind();
    return imageButton;
  }
View Full Code Here

  }

  private ImageButtonBean targetBean;

  public ImageButtonBindings(Action source) {
    this(source, new ImageButton());
  }
View Full Code Here

TOP

Related Classes of org.gwt.mosaic.ui.client.ImageButton

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.