Esempio n. 1
0
    def setUp(self):
        super(ComponentAttachDetachListenerTest, self).setUp()

        # General variables
        self._attachCounter = 0
        self._attachedComponent = None
        self._attachTarget = None
        self._foundInContainer = False
        self._detachCounter = 0
        self._detachedComponent = None
        self._detachedTarget = None

        # Ordered layout specific variables
        self._indexOfComponent = -1

        # Grid layout specific variables
        self._componentArea = None

        # Absolute layout specific variables
        self._componentPosition = None

        self._olayout = HorizontalLayout()
        listener = MyAttachListener(self)
        self._olayout.addListener(listener, IComponentAttachListener)
        listener = MyDetachListener(self)
        self._olayout.addListener(listener, IComponentDetachListener)

        self._gridlayout = GridLayout()
        listener = MyAttachListener(self)
        self._gridlayout.addListener(listener, IComponentAttachListener)
        listener = MyDetachListener(self)
        self._gridlayout.addListener(listener, IComponentDetachListener)

        self._absolutelayout = AbsoluteLayout()
        listener = MyAttachListener(self)
        self._absolutelayout.addListener(listener, IComponentAttachListener)
        listener = MyDetachListener(self)
        self._absolutelayout.addListener(listener, IComponentDetachListener)

        self._csslayout = CssLayout()
        listener = MyAttachListener(self)
        self._csslayout.addListener(listener, IComponentAttachListener)
        listener = MyDetachListener(self)
        self._csslayout.addListener(listener, IComponentDetachListener)
    def testRemoveComponentFromWrongContainer(self, componentContainer=None):
        if componentContainer is None:
            containerClasses = MuntjacClasses.\
                getComponentContainersSupportingAddRemoveComponent()

            # No default constructor, special case
            containerClasses.remove(CustomLayout)
            self.testRemoveComponentFromWrongContainer(CustomLayout('dummy'))

            for c in containerClasses:
                self.testRemoveComponentFromWrongContainer( c() )
        else:
            hl = HorizontalLayout()
            label = Label()
            hl.addComponent(label)

            componentContainer.removeComponent(label)
            self.assertEquals(hl, label.getParent(), ('Parent no longer ' +
                    'correct for ' + componentContainer.__class__.__name__))
Esempio n. 3
0
    def testRemoveComponentFromWrongContainer(self, componentContainer=None):
        if componentContainer is None:
            containerClasses = MuntjacClasses.\
                getComponentContainersSupportingAddRemoveComponent()

            # No default constructor, special case
            containerClasses.remove(CustomLayout)
            self.testRemoveComponentFromWrongContainer(CustomLayout('dummy'))

            for c in containerClasses:
                self.testRemoveComponentFromWrongContainer( c() )
        else:
            hl = HorizontalLayout()
            label = Label()
            hl.addComponent(label)

            componentContainer.removeComponent(label)
            self.assertEquals(hl, label.getParent(), ('Parent no longer ' +
                    'correct for ' + componentContainer.__class__.__name__))
    def __init__(self, horizontal):
        super(SortableLayout, self).__init__()

        self._horizontal = horizontal
        if horizontal:
            self._layout = HorizontalLayout()
        else:
            self._layout = VerticalLayout()

        self._dropHandler = ReorderLayoutDropHandler(self._layout)

        pane = DragAndDropWrapper(self._layout)
        self.setCompositionRoot(pane)
 def init(self):
     mainWindow = Window('Refresher')
     self.setMainWindow(mainWindow)
     panel = Panel('Refresher example')
     layout = HorizontalLayout()
     refresher = Refresher()
     label = Label('0')
     thread = CounterThread(label)
     thread.start()
     label.setData(0)
     panel.addComponent(refresher)
     panel.addComponent(Label("<div style='margin-bottom:10px'>"
             + "The Refresher allows you to affect the UI "
             + "from external threads without "
             + "<a href='http://vaadin.com/forum/-/message_boards/message/69792' target='_blank'>"
             + "the ProgressIndicator hack</a>.</div>", Label.CONTENT_XHTML))
     panel.addComponent(layout)
     layout.setSpacing(True)
     layout.addComponent(Button('Start Counting',
                 StartClickListener(refresher, thread)))
     layout.addComponent(Button('Stop Counting',
                 StopClickListener(refresher, thread)))
     layout.addComponent(label)
     mainWindow.setContent(panel)
    def setUp(self):
        super(ComponentAttachDetachListenerTest, self).setUp()

        # General variables
        self._attachCounter = 0
        self._attachedComponent = None
        self._attachTarget = None
        self._foundInContainer = False
        self._detachCounter = 0
        self._detachedComponent = None
        self._detachedTarget = None

        # Ordered layout specific variables
        self._indexOfComponent = -1

        # Grid layout specific variables
        self._componentArea = None

        # Absolute layout specific variables
        self._componentPosition = None

        self._olayout = HorizontalLayout()
        self._olayout.addListener(MyAttachListener(self),
                IComponentAttachListener)
        self._olayout.addListener(MyDetachListener(self),
                IComponentDetachListener)

        self._gridlayout = GridLayout()
        self._gridlayout.addListener(MyAttachListener(self),
                IComponentAttachListener)
        self._gridlayout.addListener(MyDetachListener(self),
                IComponentDetachListener)

        self._absolutelayout = AbsoluteLayout()
        self._absolutelayout.addListener(MyAttachListener(self),
                IComponentAttachListener)
        self._absolutelayout.addListener(MyDetachListener(self),
                IComponentDetachListener)

        self._csslayout = CssLayout()
        self._csslayout.addListener(MyAttachListener(self),
                IComponentAttachListener)
        self._csslayout.addListener(MyDetachListener(self),
                IComponentDetachListener)
class ComponentAttachDetachListenerTest(TestCase):

    def resetVariables(self):
        # Attach
        self._attachCounter = 0
        self._attachedComponent = None
        self._attachTarget = None
        self._foundInContainer = False

        # Detach
        self._detachCounter = 0
        self._detachedComponent = None
        self._detachedTarget = None

        # Common
        self._indexOfComponent = -1
        self._componentArea = None
        self._componentPosition = None


    def setUp(self):
        super(ComponentAttachDetachListenerTest, self).setUp()

        # General variables
        self._attachCounter = 0
        self._attachedComponent = None
        self._attachTarget = None
        self._foundInContainer = False
        self._detachCounter = 0
        self._detachedComponent = None
        self._detachedTarget = None

        # Ordered layout specific variables
        self._indexOfComponent = -1

        # Grid layout specific variables
        self._componentArea = None

        # Absolute layout specific variables
        self._componentPosition = None

        self._olayout = HorizontalLayout()
        self._olayout.addListener(MyAttachListener(self),
                IComponentAttachListener)
        self._olayout.addListener(MyDetachListener(self),
                IComponentDetachListener)

        self._gridlayout = GridLayout()
        self._gridlayout.addListener(MyAttachListener(self),
                IComponentAttachListener)
        self._gridlayout.addListener(MyDetachListener(self),
                IComponentDetachListener)

        self._absolutelayout = AbsoluteLayout()
        self._absolutelayout.addListener(MyAttachListener(self),
                IComponentAttachListener)
        self._absolutelayout.addListener(MyDetachListener(self),
                IComponentDetachListener)

        self._csslayout = CssLayout()
        self._csslayout.addListener(MyAttachListener(self),
                IComponentAttachListener)
        self._csslayout.addListener(MyDetachListener(self),
                IComponentDetachListener)


    def testOrderedLayoutAttachListener(self):
        # Reset state variables
        self.resetVariables()

        # Add component -> Should trigger attach listener
        comp = Label()
        self._olayout.addComponent(comp)

        # Attach counter should get incremented
        self.assertEquals(1, self._attachCounter)

        # The attached component should be the label
        self.assertEquals(comp, self._attachedComponent)

        # The attached target should be the layout
        self.assertEquals(self._olayout, self._attachTarget)

        # The attached component should be found in the container
        self.assertTrue(self._foundInContainer)

        # The index of the component should not be -1
        self.assertFalse(self._indexOfComponent == -1)


    def testOrderedLayoutDetachListener(self):
        # Add a component to detach
        comp = Label()
        self._olayout.addComponent(comp)

        # Reset state variables (since they are set by the attach listener)
        self.resetVariables()

        # Detach the component -> triggers the detach listener
        self._olayout.removeComponent(comp)

        # Detach counter should get incremented
        self.assertEquals(1, self._detachCounter)

        # The detached component should be the label
        self.assertEquals(comp, self._detachedComponent)

        # The detached target should be the layout
        self.assertEquals(self._olayout, self._detachedTarget)

        # The detached component should not be found in the container
        self.assertFalse(self._foundInContainer)

        # The index of the component should be -1
        self.assertEquals(-1, self._indexOfComponent)


    def testGridLayoutAttachListener(self):
        # Reset state variables
        self.resetVariables()

        # Add component -> Should trigger attach listener
        comp = Label()
        self._gridlayout.addComponent(comp)

        # Attach counter should get incremented
        self.assertEquals(1, self._attachCounter)

        # The attached component should be the label
        self.assertEquals(comp, self._attachedComponent)

        # The attached target should be the layout
        self.assertEquals(self._gridlayout, self._attachTarget)

        # The attached component should be found in the container
        self.assertTrue(self._foundInContainer)

        # The grid area should not be null
        self.assertIsNotNone(self._componentArea)


    def testGridLayoutDetachListener(self):
        # Add a component to detach
        comp = Label()
        self._gridlayout.addComponent(comp)

        # Reset state variables (since they are set by the attach listener)
        self.resetVariables()

        # Detach the component -> triggers the detach listener
        self._gridlayout.removeComponent(comp)

        # Detach counter should get incremented
        self.assertEquals(1, self._detachCounter)

        # The detached component should be the label
        self.assertEquals(comp, self._detachedComponent)

        # The detached target should be the layout
        self.assertEquals(self._gridlayout, self._detachedTarget)

        # The detached component should not be found in the container
        self.assertFalse(self._foundInContainer)

        # The grid area should be null
        self.assertIsNone(self._componentArea)


    def testAbsoluteLayoutAttachListener(self):
        # Reset state variables
        self.resetVariables()

        # Add component -> Should trigger attach listener
        comp = Label()
        self._absolutelayout.addComponent(comp)

        # Attach counter should get incremented
        self.assertEquals(1, self._attachCounter)

        # The attached component should be the label
        self.assertEquals(comp, self._attachedComponent)

        # The attached target should be the layout
        self.assertEquals(self._absolutelayout, self._attachTarget)

        # The attached component should be found in the container
        self.assertTrue(self._foundInContainer)

        # The component position should not be null
        self.assertIsNotNone(self._componentPosition)


    def testAbsoluteLayoutDetachListener(self):
        # Add a component to detach
        comp = Label()
        self._absolutelayout.addComponent(comp)

        # Reset state variables (since they are set by the attach listener)
        self.resetVariables()

        # Detach the component -> triggers the detach listener
        self._absolutelayout.removeComponent(comp)

        # Detach counter should get incremented
        self.assertEquals(1, self._detachCounter)

        # The detached component should be the label
        self.assertEquals(comp, self._detachedComponent)

        # The detached target should be the layout
        self.assertEquals(self._absolutelayout, self._detachedTarget)

        # The detached component should not be found in the container
        self.assertFalse(self._foundInContainer)

        # The component position should be null
        self.assertIsNone(self._componentPosition)


    def testCSSLayoutAttachListener(self):
        # Reset state variables
        self.resetVariables()

        # Add component -> Should trigger attach listener
        comp = Label()
        self._csslayout.addComponent(comp)

        # Attach counter should get incremented
        self.assertEquals(1, self._attachCounter)

        # The attached component should be the label
        self.assertEquals(comp, self._attachedComponent)

        # The attached target should be the layout
        self.assertEquals(self._csslayout, self._attachTarget)

        # The attached component should be found in the container
        self.assertTrue(self._foundInContainer)


    def testCSSLayoutDetachListener(self):
        # Add a component to detach
        comp = Label()
        self._csslayout.addComponent(comp)

        # Reset state variables (since they are set by the attach listener)
        self.resetVariables()

        # Detach the component -> triggers the detach listener
        self._csslayout.removeComponent(comp)

        # Detach counter should get incremented
        self.assertEquals(1, self._detachCounter)

        # The detached component should be the label
        self.assertEquals(comp, self._detachedComponent)

        # The detached target should be the layout
        self.assertEquals(self._csslayout, self._detachedTarget)

        # The detached component should not be found in the container
        self.assertFalse(self._foundInContainer)
Esempio n. 8
0
    def init(self):
        # This is called whenever a colorpicker popup is closed
        main = Window()
        main.setWidth('1000px')
        self.setMainWindow(main)

        # Create an instance of the preview and add it to the window
        #        self._display = Embedded('Color preview')
        self._display = Canvas()
        self._display.setWidth('270px')
        self._display.setHeight('270px')

        # Add the foreground and background colorpickers to a layout
        self._mainLayout = mainLayout = HorizontalLayout()
        mainLayout.setMargin(True)
        mainLayout.setSpacing(True)
        main.setContent(mainLayout)

        layout = VerticalLayout()
        layout.setWidth('450px')
        layout.setSpacing(True)

        optPanel = Panel('Customize the color picker popup window',
                         GridLayout(3, 2))
        optPanel.getContent().setSizeFull()
        optPanel.getContent().setMargin(True)
        optPanel.getContent().setSpacing(True)

        self._rgbBox.addListener(RgbClickListener(self), IClickListener)
        self._rgbBox.setValue(self._rgbVisible)
        self._rgbBox.setImmediate(True)
        optPanel.getContent().addComponent(self._rgbBox)

        self._hsvBox.addListener(HsvClickListener(self), IClickListener)
        self._hsvBox.setValue(self._hsvVisible)
        self._hsvBox.setImmediate(True)
        optPanel.getContent().addComponent(self._hsvBox)

        self._swaBox.addListener(SwaClickListener(self), IClickListener)
        self._swaBox.setValue(self._swaVisible)
        self._swaBox.setImmediate(True)
        optPanel.getContent().addComponent(self._swaBox)

        self._hisBox.addListener(HisClickListener(self), IClickListener)
        self._hisBox.setValue(self._historyVisible)
        self._hisBox.setImmediate(True)
        optPanel.getContent().addComponent(self._hisBox)

        self._txtBox.addListener(TxtClickListener(self), IClickListener)
        self._txtBox.setValue(self._txtfieldVisible)
        self._txtBox.setImmediate(True)
        optPanel.getContent().addComponent(self._txtBox)

        layout.addComponent(optPanel)

        panel1 = Panel(
            'Button like colorpicker with current color and CSS code',
            HorizontalLayout())
        panel1.getContent().setSizeFull()
        panel1.getContent().setMargin(True)

        self._colorpicker1 = ColorPicker('Foreground', self._foregroundColor)
        self._colorpicker1.setWidth('100px')
        self._colorpicker1.addListener(self)
        panel1.addComponent(self._colorpicker1)
        panel1.getContent().setComponentAlignment(self._colorpicker1,
                                                  Alignment.MIDDLE_CENTER)

        self._colorpicker2 = ColorPicker('Background', self._backgroundColor)
        self._colorpicker2.addListener(self)
        self._colorpicker2.setWidth('100px')
        panel1.addComponent(self._colorpicker2)
        panel1.getContent().setComponentAlignment(self._colorpicker2,
                                                  Alignment.MIDDLE_CENTER)
        layout.addComponent(panel1)

        panel2 = Panel(
            'Button like colorpicker with current color and custom caption',
            HorizontalLayout())
        panel2.getContent().setSizeFull()
        panel2.getContent().setMargin(True)
        self._colorpicker3 = ColorPicker('Foreground', self._foregroundColor)
        self._colorpicker3.addListener(self)
        self._colorpicker3.setWidth('120px')
        self._colorpicker3.setButtonCaption('Foreground')
        panel2.addComponent(self._colorpicker3)
        panel2.getContent().setComponentAlignment(self._colorpicker3,
                                                  Alignment.MIDDLE_CENTER)

        self._colorpicker4 = ColorPicker('Background', self._backgroundColor)
        self._colorpicker4.addListener(self)
        self._colorpicker4.setWidth('120px')
        self._colorpicker4.setButtonCaption('Background')
        panel2.addComponent(self._colorpicker4)
        panel2.getContent().setComponentAlignment(self._colorpicker4,
                                                  Alignment.MIDDLE_CENTER)
        layout.addComponent(panel2)

        panel3 = Panel('Color area color picker with caption',
                       HorizontalLayout())
        panel3.getContent().setSizeFull()
        panel3.getContent().setMargin(True)

        self._colorpicker5 = ColorPicker('Foreground', self._foregroundColor)
        self._colorpicker5.setCaption('Foreground')
        self._colorpicker5.addListener(self)
        self._colorpicker5.setButtonStyle(ButtonStyle.BUTTON_AREA)
        panel3.addComponent(self._colorpicker5)
        panel3.getContent().setComponentAlignment(self._colorpicker5,
                                                  Alignment.MIDDLE_CENTER)

        self._colorpicker6 = ColorPicker('Background', self._backgroundColor)
        self._colorpicker6.setCaption('Background')
        self._colorpicker6.addListener(self)
        self._colorpicker6.setButtonStyle(ButtonStyle.BUTTON_AREA)
        panel3.addComponent(self._colorpicker6)
        panel3.getContent().setComponentAlignment(self._colorpicker6,
                                                  Alignment.MIDDLE_CENTER)
        layout.addComponent(panel3)

        mainLayout.addComponent(layout)
        mainLayout.addComponent(self._display)

        self.updateDisplay(self._foregroundColor, self._backgroundColor)
Esempio n. 9
0
class ComponentAttachDetachListenerTest(TestCase):
    def resetVariables(self):
        # Attach
        self._attachCounter = 0
        self._attachedComponent = None
        self._attachTarget = None
        self._foundInContainer = False

        # Detach
        self._detachCounter = 0
        self._detachedComponent = None
        self._detachedTarget = None

        # Common
        self._indexOfComponent = -1
        self._componentArea = None
        self._componentPosition = None

    def setUp(self):
        super(ComponentAttachDetachListenerTest, self).setUp()

        # General variables
        self._attachCounter = 0
        self._attachedComponent = None
        self._attachTarget = None
        self._foundInContainer = False
        self._detachCounter = 0
        self._detachedComponent = None
        self._detachedTarget = None

        # Ordered layout specific variables
        self._indexOfComponent = -1

        # Grid layout specific variables
        self._componentArea = None

        # Absolute layout specific variables
        self._componentPosition = None

        self._olayout = HorizontalLayout()
        listener = MyAttachListener(self)
        self._olayout.addListener(listener, IComponentAttachListener)
        listener = MyDetachListener(self)
        self._olayout.addListener(listener, IComponentDetachListener)

        self._gridlayout = GridLayout()
        listener = MyAttachListener(self)
        self._gridlayout.addListener(listener, IComponentAttachListener)
        listener = MyDetachListener(self)
        self._gridlayout.addListener(listener, IComponentDetachListener)

        self._absolutelayout = AbsoluteLayout()
        listener = MyAttachListener(self)
        self._absolutelayout.addListener(listener, IComponentAttachListener)
        listener = MyDetachListener(self)
        self._absolutelayout.addListener(listener, IComponentDetachListener)

        self._csslayout = CssLayout()
        listener = MyAttachListener(self)
        self._csslayout.addListener(listener, IComponentAttachListener)
        listener = MyDetachListener(self)
        self._csslayout.addListener(listener, IComponentDetachListener)

    def testOrderedLayoutAttachListener(self):
        # Reset state variables
        self.resetVariables()

        # Add component -> Should trigger attach listener
        comp = Label()
        self._olayout.addComponent(comp)

        # Attach counter should get incremented
        self.assertEquals(1, self._attachCounter)

        # The attached component should be the label
        self.assertEquals(comp, self._attachedComponent)

        # The attached target should be the layout
        self.assertEquals(self._olayout, self._attachTarget)

        # The attached component should be found in the container
        self.assertTrue(self._foundInContainer)

        # The index of the component should not be -1
        self.assertFalse(self._indexOfComponent == -1)

    def testOrderedLayoutDetachListener(self):
        # Add a component to detach
        comp = Label()
        self._olayout.addComponent(comp)

        # Reset state variables (since they are set by the attach listener)
        self.resetVariables()

        # Detach the component -> triggers the detach listener
        self._olayout.removeComponent(comp)

        # Detach counter should get incremented
        self.assertEquals(1, self._detachCounter)

        # The detached component should be the label
        self.assertEquals(comp, self._detachedComponent)

        # The detached target should be the layout
        self.assertEquals(self._olayout, self._detachedTarget)

        # The detached component should not be found in the container
        self.assertFalse(self._foundInContainer)

        # The index of the component should be -1
        self.assertEquals(-1, self._indexOfComponent)

    def testGridLayoutAttachListener(self):
        # Reset state variables
        self.resetVariables()

        # Add component -> Should trigger attach listener
        comp = Label()
        self._gridlayout.addComponent(comp)

        # Attach counter should get incremented
        self.assertEquals(1, self._attachCounter)

        # The attached component should be the label
        self.assertEquals(comp, self._attachedComponent)

        # The attached target should be the layout
        self.assertEquals(self._gridlayout, self._attachTarget)

        # The attached component should be found in the container
        self.assertTrue(self._foundInContainer)

        # The grid area should not be null
        self.assertIsNotNone(self._componentArea)

    def testGridLayoutDetachListener(self):
        # Add a component to detach
        comp = Label()
        self._gridlayout.addComponent(comp)

        # Reset state variables (since they are set by the attach listener)
        self.resetVariables()

        # Detach the component -> triggers the detach listener
        self._gridlayout.removeComponent(comp)

        # Detach counter should get incremented
        self.assertEquals(1, self._detachCounter)

        # The detached component should be the label
        self.assertEquals(comp, self._detachedComponent)

        # The detached target should be the layout
        self.assertEquals(self._gridlayout, self._detachedTarget)

        # The detached component should not be found in the container
        self.assertFalse(self._foundInContainer)

        # The grid area should be null
        self.assertIsNone(self._componentArea)

    def testAbsoluteLayoutAttachListener(self):
        # Reset state variables
        self.resetVariables()

        # Add component -> Should trigger attach listener
        comp = Label()
        self._absolutelayout.addComponent(comp)

        # Attach counter should get incremented
        self.assertEquals(1, self._attachCounter)

        # The attached component should be the label
        self.assertEquals(comp, self._attachedComponent)

        # The attached target should be the layout
        self.assertEquals(self._absolutelayout, self._attachTarget)

        # The attached component should be found in the container
        self.assertTrue(self._foundInContainer)

        # The component position should not be null
        self.assertIsNotNone(self._componentPosition)

    def testAbsoluteLayoutDetachListener(self):
        # Add a component to detach
        comp = Label()
        self._absolutelayout.addComponent(comp)

        # Reset state variables (since they are set by the attach listener)
        self.resetVariables()

        # Detach the component -> triggers the detach listener
        self._absolutelayout.removeComponent(comp)

        # Detach counter should get incremented
        self.assertEquals(1, self._detachCounter)

        # The detached component should be the label
        self.assertEquals(comp, self._detachedComponent)

        # The detached target should be the layout
        self.assertEquals(self._absolutelayout, self._detachedTarget)

        # The detached component should not be found in the container
        self.assertFalse(self._foundInContainer)

        # The component position should be null
        self.assertIsNone(self._componentPosition)

    def testCSSLayoutAttachListener(self):
        # Reset state variables
        self.resetVariables()

        # Add component -> Should trigger attach listener
        comp = Label()
        self._csslayout.addComponent(comp)

        # Attach counter should get incremented
        self.assertEquals(1, self._attachCounter)

        # The attached component should be the label
        self.assertEquals(comp, self._attachedComponent)

        # The attached target should be the layout
        self.assertEquals(self._csslayout, self._attachTarget)

        # The attached component should be found in the container
        self.assertTrue(self._foundInContainer)

    def testCSSLayoutDetachListener(self):
        # Add a component to detach
        comp = Label()
        self._csslayout.addComponent(comp)

        # Reset state variables (since they are set by the attach listener)
        self.resetVariables()

        # Detach the component -> triggers the detach listener
        self._csslayout.removeComponent(comp)

        # Detach counter should get incremented
        self.assertEquals(1, self._detachCounter)

        # The detached component should be the label
        self.assertEquals(comp, self._detachedComponent)

        # The detached target should be the layout
        self.assertEquals(self._csslayout, self._detachedTarget)

        # The detached component should not be found in the container
        self.assertFalse(self._foundInContainer)
    def __init__(self, initialColor):
        """Instantiates a new color picker popup."""

        #: The tabs.
        self._tabs = TabSheet()

        #: The layout.
        self._layout = VerticalLayout()

        #: The ok button.
        self._ok = Button('OK')

        #: The cancel button.
        self._cancel = Button('Cancel')

        #: The resize button.
        self._resize = Button('...')

        #: The selected color.
        self._selectedColor = Color.WHITE

        #: The history.
        self._history = None

        #: The history container.
        self._historyContainer = None

        #: The rgb gradient.
        self._rgbGradient = None

        #: The hsv gradient.
        self._hsvGradient = None

        #: The red slider.
        self._redSlider = None

        #: The green slider.
        self._greenSlider = None

        #: The blue slider.
        self._blueSlider = None

        #: The hue slider.
        self._hueSlider = None

        #: The saturation slider.
        self._saturationSlider = None

        #: The value slider.
        self._valueSlider = None

        #: The preview on the rgb tab.
        self._rgbPreview = None

        #: The preview on the hsv tab.
        self._hsvPreview = None

        #: The preview on the swatches tab.
        self._selPreview = None

        #: The color select.
        self._colorSelect = None

        #: The selectors.
        self._selectors = set()

        super(ColorPickerPopup, self).__init__()

        self._selectedColor = initialColor

        self.setWidth('250px')
        self.setScrollable(False)
        self.setStyleName(self._STYLENAME)
        self.setResizable(False)
        self.setImmediate(True)

        # Create the history
        self._history = ColorPickerHistory()
        self._history.addListener(self, IColorChangeListener)

        # Create the preview on the rgb tab
        self._rgbPreview = ColorPickerPreview(self._selectedColor)
        self._rgbPreview.setWidth('220px')
        self._rgbPreview.setHeight('20px')
        self._rgbPreview.addListener(self, IColorChangeListener)
        self._selectors.add(self._rgbPreview)

        # Create the preview on the hsv tab
        self._hsvPreview = ColorPickerPreview(self._selectedColor)
        self._hsvPreview.setWidth('220px')
        self._hsvPreview.setHeight('20px')
        self._hsvPreview.addListener(self, IColorChangeListener)
        self._selectors.add(self._hsvPreview)

        # Create the preview on the swatches tab
        self._selPreview = ColorPickerPreview(self._selectedColor)
        self._selPreview.setWidth('220px')
        self._selPreview.setHeight('20px')
        self._selPreview.addListener(self, IColorChangeListener)
        self._selectors.add(self._selPreview)

        # Set the layout
        self._layout.setSpacing(False)
        self._layout.setSizeFull()
        self.setContent(self._layout)

        # Create the tabs
        self._rgbTab = self.createRGBTab(self._selectedColor)
        self._tabs.addTab(self._rgbTab, 'RGB', None)

        self._hsvTab = self.createHSVTab(self._selectedColor)
        self._tabs.addTab(self._hsvTab, 'HSV', None)

        self._swatchesTab = self.createSelectTab()
        self._tabs.addTab(self._swatchesTab, 'Swatches', None)

        # Add the tabs
        self._tabs.setWidth('100%')

        self._layout.addComponent(self._tabs)

        # Add the history
        self._history.setWidth('97%')
        self._history.setHeight('27px')

        # Create the default colors
        defaultColors = list()
        defaultColors.append(Color.BLACK)
        defaultColors.append(Color.WHITE)

        # Create the history
        innerContainer = VerticalLayout()
        innerContainer.setSizeFull()
        innerContainer.addComponent(self._history)
        innerContainer.setExpandRatio(self._history, 1)

        outerContainer = VerticalLayout()
        outerContainer.setWidth('99%')
        outerContainer.setHeight('27px')
        outerContainer.addComponent(innerContainer)
        self._historyContainer = outerContainer

        self._layout.addComponent(self._historyContainer)

        # Add the resize button for the history
        self._resize.addListener(self, IClickListener)
        self._resize.setData(False)
        self._resize.setWidth('100%')
        self._resize.setHeight('10px')
        self._resize.setStyleName('resize-button')
        self._layout.addComponent(self._resize)

        # Add the buttons
        self._ok.setWidth('70px')
        self._ok.addListener(self, IClickListener)

        self._cancel.setWidth('70px')
        self._cancel.addListener(self, IClickListener)

        buttons = HorizontalLayout()
        buttons.addComponent(self._ok)
        buttons.addComponent(self._cancel)
        buttons.setWidth('100%')
        buttons.setHeight('30px')
        buttons.setComponentAlignment(self._ok, Alignment.MIDDLE_CENTER)
        buttons.setComponentAlignment(self._cancel, Alignment.MIDDLE_CENTER)
        self._layout.addComponent(buttons)

        self.setHeight(self.calculateHeight())