Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Option: DialogBox as 3x3 table with GWT Styles #769

Merged
merged 1 commit into from

2 participants

@happyalu

Creates a DialogBox with 3x3 table with
(0,1) -> caption
(1,1) -> widget

Other elements are empty DIVs, with GWT CSS classes that can be used for styling.

See: http://google-web-toolkit.googlecode.com/svn/javadoc/latest/com/google/gwt/user/client/ui/DialogBox.html

To use it, create with DialogBox(..., gwt_cells=True)

@xtfxme
Owner

this appears to maintain the expected API if the gwt_cells params is not passed, yes? it looks alright to me, but in general i'm trying to keep the existing libs stable while we figure out how to make the jump to GWT 2.x or higher ...

is there a specific version the 3x3 stuff was added? this widget is probably based on GWT 1.5-1.6 ... if the widget was changed to 3x3 in a specific version, i'd like the kwarg to reflect that, say gwt17strict or simply gwt17.

@happyalu

It seems the 3x3 stuff was added in 1.5 http://google-web-toolkit.googlecode.com/svn/javadoc/1.5/com/google/gwt/user/client/ui/DialogBox.html

and the current one is based probably on 1.4 http://google-web-toolkit.googlecode.com/svn/javadoc/1.4/com/google/gwt/user/client/ui/DialogBox.html

I could change the gwt_cells parameter to gwt15. But if pyjs has a roadmap for GWT2.x jump, I guess this change could wait until then :) I had this code in my repo since I was using a stylesheet generated by http://gwt-theme-generator.appspot.com/ so thought I'll send a pull request :)

@xtfxme
Owner

nah, the road map is not that set in stone, i think this may be useful in the interim.

can you change the param to gwt15, git commit --amend, and git push -f? then i'll go ahead and pull.

thanks @happyalu!

@happyalu

@xtfxme Will do that.

I was looking at the GWT sources, and am now wondering if these changes are the right things to do, or whether I should create, in the style of GWT, these files:

pyjamas.ui.DecoratorPanel (the thing that creates 3x3)
pyjamas.ui.DecoratedPopupPanel
and then

GWT's DialogBox by default inherits from DecoratedPopupPanel, but we can let the current version stay as it is for stability and create a new thing called pyjamas.ui.DecoratedDialogBox.

Let me know if doing this (or something else) is better, or whether I should just change the current commit keyword and edit the request.

@xtfxme Thanks!

@happyalu happyalu Option: DialogBox as 3x3 table with GWT Styles
Creates a DialogBox with 3x3 table with
(0,1) -> caption
(1,1) -> widget

Other elements are empty DIVs, with classes like GWT that can be used for styling.
a7bd9af
@happyalu

@xtfxme Changed the keyword arg.

@xtfxme
Owner

hi :-)

is this still current/relevant? or have you implemented something else?

if you give the thumbs up for "still needed", i'll go ahead and merge. thanks!

@happyalu

hi :-)

I didn't implement anything else to this effect, and I think this is useful. (Well, I am using it :-P). Please merge if you think it's appropriate. Thanks!

@xtfxme
Owner

LGTM, save a few tweaks i'll make after the fact ... thanks!

@xtfxme xtfxme merged commit 2ed250c into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 3, 2012
  1. @happyalu

    Option: DialogBox as 3x3 table with GWT Styles

    happyalu authored
    Creates a DialogBox with 3x3 table with
    (0,1) -> caption
    (1,1) -> widget
    
    Other elements are empty DIVs, with classes like GWT that can be used for styling.
This page is out of date. Refresh to see the latest.
Showing with 57 additions and 10 deletions.
  1. +57 −10 library/pyjamas/ui/DialogBox.py
View
67 library/pyjamas/ui/DialogBox.py
@@ -1,5 +1,6 @@
# Copyright 2006 James Tauber and contributors
# Copyright (C) 2009, 2010 Luke Kenneth Casson Leighton <lkcl@lkcl.net>
+# Copyright (C) 2012 Alok Parlikar <aup@cs.cmu.edu>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -18,6 +19,7 @@
from pyjamas.ui.PopupPanel import PopupPanel
from pyjamas.ui.HTML import HTML
from pyjamas.ui.FlexTable import FlexTable
+from pyjamas.ui.SimplePanel import SimplePanel
from pyjamas.ui import HasHorizontalAlignment
from pyjamas.ui import HasVerticalAlignment
from pyjamas.ui import GlassWidget
@@ -41,22 +43,61 @@ def __init__(self, autoHide=None, modal=True, centered=False,
CellPadding="0",
CellSpacing="0",
)
+
cf = self.panel.getCellFormatter()
- cf.setHeight(1, 0, "100%")
- cf.setWidth(1, 0, "100%")
- cf.setAlignment(
- 1, 0,
- HasHorizontalAlignment.ALIGN_CENTER,
- HasVerticalAlignment.ALIGN_MIDDLE,
- )
+ rf = self.panel.getRowFormatter()
# Arguments section
self.modal = modal
self.caption = HTML()
- self.panel.setWidget(0, 0, self.caption)
self.caption.setStyleName("Caption")
self.caption.addMouseListener(self)
+ try:
+ self.generate_gwt15 = kwargs['gwt15']
+ # Make the DialogBox a 3x3 table, like GWT does, with
+ # empty elements with specific style names. These can be
+ # used with CSS to, for example, create border around the
+ # dialog box.
+ except:
+ self.generate_gwt15 = False
+
+ if not self.generate_gwt15:
+ cf.setHeight(1, 0, "100%")
+ cf.setWidth(1, 0, "100%")
+ cf.setAlignment(
+ 1, 0,
+ HasHorizontalAlignment.ALIGN_CENTER,
+ HasVerticalAlignment.ALIGN_MIDDLE,
+ )
+ self.panel.setWidget(0, 0, self.caption)
+ else:
+ row_labels = ['Top', 'Middle', 'Bottom']
+ col_labels = ['Left', 'Center', 'Right']
+
+ for r in range(3):
+ rf.setStyleName(r, 'dialog%s' % row_labels[r])
+ for c in range(3):
+ cf.setStyleName(r, c, 'dialog%s%s' % (row_labels[r],
+ col_labels[c]))
+ sp = SimplePanel()
+ sp.setStyleName('dialog%s%sInner' % (row_labels[r],
+ col_labels[c]))
+ self.panel.setWidget(r, c, sp)
+
+ cf.setAlignment(
+ 1, 1,
+ HasHorizontalAlignment.ALIGN_CENTER,
+ HasVerticalAlignment.ALIGN_MIDDLE,
+ )
+
+ self.dialog_content = SimplePanel()
+ self.dialog_content.setStyleName('dialogContent')
+
+ self.panel.getWidget(0, 1).add(self.caption)
+ self.panel.getWidget(1, 1).add(self.dialog_content)
+ del kwargs['gwt15']
+
# Finalize
kwargs['StyleName'] = kwargs.get('StyleName', "gwt-DialogBox")
PopupPanel.__init__(self, autoHide, modal, **kwargs)
@@ -155,10 +196,16 @@ def doDetachChildren(self):
def setWidget(self, widget):
if self.child is not None:
- self.panel.remove(self.child)
+ if not self.generate_gwt15:
+ self.panel.remove(self.child)
+ else:
+ self.dialog_content.remove(self.child)
if widget is not None:
- self.panel.setWidget(1, 0, widget)
+ if not self.generate_gwt15:
+ self.panel.setWidget(1, 0, widget)
+ else:
+ self.dialog_content.setWidget(widget)
self.child = widget
Something went wrong with that request. Please try again.