Example usage for com.google.gwt.user.client.ui HorizontalPanel setCellWidth

List of usage examples for com.google.gwt.user.client.ui HorizontalPanel setCellWidth

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui HorizontalPanel setCellWidth.

Prototype

public void setCellWidth(IsWidget w, String width) 

Source Link

Document

Overloaded version for IsWidget.

Usage

From source file:asquare.gwt.tk.demo.client.DebugPanel.java

License:Apache License

public DebugPanel() {
    HorizontalPanel outer = new HorizontalPanel();

    setWidget(outer);/*from   ww w .j ava  2 s  . c o m*/

    Widget docPanel = createDocPanel();
    outer.add(docPanel);
    outer.setCellWidth(docPanel, "33%");

    Widget controlPanel = createControlPanel(m_eventListener);
    outer.add(controlPanel);
    outer.setCellWidth(controlPanel, "33%");

    Widget widgetPanel = createWidgetPanel();
    outer.add(widgetPanel);

    m_eventListener.install();
}

From source file:asquare.gwt.tk.demo.client.DropDownPanelPanel.java

License:Apache License

public DropDownPanelPanel() {
    HorizontalPanel outer = new HorizontalPanel();
    outer.setSize("100%", "100%");

    setWidget(outer);/*ww  w .  ja  v a2 s  .  c o  m*/

    BasicPanel left = new BasicPanel();
    DOM.setAttribute(left.getElement(), "id", "dropDown-left");

    DropDownPanel dropDown1 = new DropDownPanel();
    DOM.setAttribute(dropDown1.getElement(), "id", "dropDown-1");
    dropDown1.setHeaderText("Drop Down 1", false);
    Image image = new Image("icecube.jpg");
    image.setSize("100px", "100px");
    dropDown1.add(image);
    dropDown1.setOpen(true);
    left.add(dropDown1);

    DropDownPanel dropDown2 = new DropDownPanel();
    DOM.setAttribute(dropDown2.getElement(), "id", "dropDown-2");
    dropDown2.setHeaderText("Drop Down 2", true);
    image = new Image("icecube.jpg");
    image.setSize("100px", "250px");
    dropDown2.add(image);
    left.add(dropDown2);

    outer.add(left);
    outer.setCellWidth(left, "1px");

    String content = "<H2>Drop Down Panel</H2>"
            + "<p>This widget consists of a hideable content DIV and an optional header DIV.</p>"
            + "<p>The content can be <span id='open'></span>&nbsp;&amp; <span id='close'></span>&nbsp;programatically.</p>"
            + "<p>The headers prevent selection of the text within them. In IE this is done in a special implementation using an <code>onselectstart</code> listener which returns <code>false</code>. In other browsers, <code>DOM.eventPreventDefault(Event)</code> for <code>Event.ONMOUSEDOWN</code> suffices. </p>"
            + "<p>You can add a listener to the DropDownPanel and make layout changes when the it opens/closes (e.g. maximize its parent element when it opens). </p>"
            + "<p>The tip-down arrows on the left are background images applied through CSS rules. <em>Note: we cannot put a border around the header itself because in IE the background image would be obscured by the border.</em></p>"
            + "<h4>Known problems</h4>"
            + "<ul><li>In IE, the cursor reverts to the system arrow after opening the headers on the left. This is a result of changing the tipdown arrow background image. (Alternative: insert the image with <code>DropDownPanel.setHeaderText()</code> and then change it via a DropDownListener.)</li></ul>"
            + "<p>Tested in IE 6 (Win), Firefox 1.5 (Win), Opera 8 (win) and Safari 2.0.4 (Mac) in Strict and Quirks modes.</p>";
    DropDownPanel dropDown3 = new DropDownPanel();
    DOM.setAttribute(dropDown3.getElement(), "id", "dropDown-3");
    dropDown3.setHeaderText("Drop&nbsp;Down&nbsp;3", true);
    HTMLPanel center = new HTMLPanel(content);
    SimpleHyperLink close = new SimpleHyperLink("hidden");
    SimpleHyperLink open = new SimpleHyperLink("shown");
    center.add(close, "close");
    center.add(open, "open");
    dropDown3.add(center);
    dropDown3.setOpen(true);
    outer.add(dropDown3);

    final DropDownPanel dropDown4 = new DropDownPanel();
    DOM.setAttribute(dropDown4.getElement(), "id", "dropDown-4");
    image = new Image("icecube.jpg");
    image.setSize("200px", "250px");
    dropDown4.add(image);
    outer.add(dropDown4);
    outer.setCellWidth(dropDown4, "1px");

    open.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            dropDown4.setOpen(true);
        }
    });
    close.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            dropDown4.setOpen(false);
        }
    });
}

From source file:asquare.gwt.tkdemo.client.demos.DialogPanel.java

License:Apache License

private Widget createModalDialogDemo() {
    BasicPanel panel = new BasicPanel("div", "block");
    panel.setStyleName("example division");
    DomUtil.setStyleAttribute(panel, "whiteSpace", "nowrap");

    panel.add(new HTML("<h4>ModalDialog examples</h4>"));

    class CloseListener implements ClickHandler {
        private final ModalDialog m_dialog;

        public CloseListener(ModalDialog dialog) {
            m_dialog = dialog;//from w w w .  j  a va  2s . c  o  m
        }

        public void onClick(ClickEvent event) {
            m_dialog.hide();
        }
    }

    class CloseButton extends Button {
        public CloseButton(ModalDialog dialog) {
            super("Close");
            addClickHandler(new CloseListener(dialog));
        }

        public CloseButton(ModalDialog dialog, String text) {
            super(text);
            addClickHandler(new CloseListener(dialog));
        }
    }

    final Button plainDialog = new Button("Plain");
    plainDialog.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            final ModalDialog dialog = new ModalDialog();
            dialog.setCaption("Caption area", false);
            dialog.add(new Label("Content area"));
            dialog.add(new CloseButton(dialog));
            dialog.show(plainDialog);
        }
    });
    panel.add(plainDialog);

    final Button verboseDialog = new Button("Verbose");
    verboseDialog.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            final ModalDialog dialog = new ModalDialog();
            dialog.setCaption("Verbose dialog", false);
            dialog.add(new Label("Twas brillig, and the slithy toves " + "  Did gyre and gimble in the wabe: "
                    + "All mimsy were the borogoves, " + "  And the mome raths outgrabe "
                    + "Beware the Jabberwock, my son! " + "The jaws that bite, the claws that catch! "
                    + "Beware the Jubjub bird, and shun " + "The frumious Bandersnatch!"));
            dialog.add(new CloseButton(dialog));
            dialog.show(verboseDialog);
        }
    });
    panel.add(verboseDialog);

    final Button captionLessDialog = new Button("No caption");
    captionLessDialog.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            final ModalDialog dialog = new ModalDialog();
            dialog.add(new Label("Captionless dialog"));
            dialog.add(new CloseButton(dialog));
            dialog.show(captionLessDialog);
        }
    });
    panel.add(captionLessDialog);

    final Button loadingDialog = new Button("Loading...");
    loadingDialog.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            final ModalDialog dialog = new ModalDialog();
            final Label label = new Label("0% loaded");
            dialog.add(label);
            dialog.show(loadingDialog);
            new Timer() {
                private int m_count = 0;

                public void run() {
                    label.setText(++m_count + "% loaded");
                    if (m_count == 100) {
                        dialog.hide();
                        cancel();
                    }
                }
            }.scheduleRepeating(1);
        }
    });
    panel.add(loadingDialog);

    final Button undraggableDialog = new Button("Drag disabled");
    undraggableDialog.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            final ModalDialog dialog = new ModalDialog() {
                protected List<Controller> createCaptionControllers() {
                    List<Controller> result = new ArrayList<Controller>();
                    result.add(ControlSurfaceController.getInstance());
                    return result;
                }
            };
            dialog.setCaption("Drag disabled", false);
            dialog.add(new Label(
                    "This dialog uses a custom controller in the header which does not provide drag support."));
            dialog.add(new CloseButton(dialog));
            dialog.show(undraggableDialog);
        }
    });
    panel.add(undraggableDialog);

    final Button styledDragDialog = new Button("Drag style");
    styledDragDialog.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            final ModalDialog dialog = new ModalDialog();
            String oldPrimaryName = dialog.getStylePrimaryName();
            dialog.setStylePrimaryName("dialog-dragstyle");
            dialog.addStyleName(oldPrimaryName);
            dialog.setCaption("Drag me", false);
            dialog.add(new Label(
                    "This dialog employs the \"tk-ModalDialog-dragging\" style which is applied while dragging. "));
            dialog.add(new CloseButton(dialog));
            dialog.show(styledDragDialog);
        }
    });
    panel.add(styledDragDialog);

    final Button focusManagementDialog = new Button("Focus management");
    focusManagementDialog.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            final ModalDialog dialog = new ModalDialog();
            dialog.setCaption("Register", false);
            FocusModel fModel = dialog.getFocusModel();

            final int FIELD_COUNT = 3;
            Grid table = new Grid(FIELD_COUNT, 2);
            dialog.add(table);
            Widget[] labels = new Widget[FIELD_COUNT];
            labels[0] = new Label("User name: ");
            labels[1] = new Label("Password: ");
            labels[2] = new Label("Retype password: ");

            FocusWidget[] fields = new FocusWidget[FIELD_COUNT];
            fields[0] = new TextBox();
            fields[1] = new PasswordTextBox();
            fields[2] = new PasswordTextBox();

            CellFormatter formatter = table.getCellFormatter();
            for (int i = 0; i < labels.length; i++) {
                table.setWidget(i, 0, labels[i]);
                formatter.setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_LEFT);
                table.setWidget(i, 1, fields[i]);

                /*
                 * Manually add fields to focus cycle. (The dialog does not
                 * scan the children of panels for focusable widgets.)
                 */
                fModel.add(fields[i]);
            }

            // this widget will be focused when the dialog is shown
            fModel.setFocusWidget(fields[0]);

            ColumnPanel buttonPanel = new ColumnPanel();
            buttonPanel.setWidth("100%");
            dialog.add(buttonPanel);

            Button closeButton = new CloseButton(dialog, "Register!");
            fModel.add(closeButton);
            buttonPanel.add(closeButton);

            Button cancelButton = new CloseButton(dialog, "Cancel");
            fModel.add(cancelButton);
            buttonPanel.addWidget(cancelButton, false);
            buttonPanel.setCellHorizontalAlignment(ColumnPanel.ALIGN_RIGHT);

            dialog.show(focusManagementDialog);
        }
    });
    panel.add(focusManagementDialog);

    final Button explicitlyPositionedDialog = new Button("Explicitly positioned");
    explicitlyPositionedDialog.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            final ModalDialog dialog = new ModalDialog();
            dialog.removeController(dialog.getController(ModalDialog.PositionDialogController.class));
            int contentWidth = 300;
            int contentHeight = 100;
            dialog.setContentWidth(contentWidth + "px");
            dialog.setContentHeight(contentHeight + "px");
            dialog.setPopupPosition(100, 100);
            dialog.setCaption("Explicitly positioned dialog", false);
            dialog.add(new Label(
                    "Automatic positioning is disabled. Dimensions and position are set explicitly. "));
            dialog.add(new CloseButton(dialog));
            dialog.show(explicitlyPositionedDialog);
        }
    });
    panel.add(explicitlyPositionedDialog);

    final Button multipleDialogs = new Button("Multiple dialogs");
    multipleDialogs.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            ModalDialog dialog = new ModalDialog();
            dialog.setCaption("First dialog", false);
            FocusModel fModel = dialog.getFocusModel();
            RowPanel outer = new RowPanel();

            dialog.add(new HTML(""));

            final UrlLocation urlBox = new UrlLocation();
            urlBox.setText("http://www.asquare.net");
            urlBox.setWidth("350px");
            fModel.add(urlBox);
            outer.add(urlBox);

            Button goButton = new Button("Go");
            fModel.add(goButton);
            fModel.setFocusWidget(goButton);
            outer.addWidget(goButton, false);

            ListBox addressList = new ListBox();
            addressList.addItem("Select an address");
            addressList.addItem("http://www.asquare.net");
            addressList.addItem("http://www.google.com");
            addressList.addItem("http://www.sourceforge.net");
            addressList.addItem("http://www.apache.org");
            fModel.add(addressList);
            outer.add(addressList);

            final Frame frame = new Frame();
            frame.setSize("400px", "200px");
            outer.add(frame);
            urlBox.addChangeHandler(new ChangeHandler() {
                public void onChange(ChangeEvent event) {
                    frame.setUrl(urlBox.getURL());
                }
            });
            goButton.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent event) {
                    frame.setUrl(urlBox.getURL());
                }
            });
            addressList.addChangeHandler(new ChangeHandler() {
                public void onChange(ChangeEvent event) {
                    ListBox list = (ListBox) event.getSource();
                    if (list.getSelectedIndex() > 0) {
                        urlBox.setText(list.getItemText(list.getSelectedIndex()));
                        frame.setUrl(list.getItemText(list.getSelectedIndex()));
                    }
                }
            });
            final Button secondDialog = new Button("Show second dialog");
            secondDialog.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent event) {
                    final ModalDialog dialog = new ModalDialog();
                    dialog.setCaption("Second dialog", false);
                    dialog.add(new Label("Note that you cannot manipulate the widgets in the first dialog. "));
                    dialog.add(new CloseButton(dialog));
                    dialog.show(secondDialog);
                }
            });
            fModel.add(secondDialog);
            outer.add(secondDialog);
            Button closeButton = new CloseButton(dialog);
            fModel.add(closeButton);
            outer.add(closeButton);
            dialog.add(outer);
            dialog.show(multipleDialogs);
        }
    });
    panel.add(multipleDialogs);

    final Button styledDialog = new Button("Styled");
    styledDialog.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            final ModalDialog dialog = new ModalDialog();
            dialog.addStyleName("dialog-styled");
            HorizontalPanel caption = new HorizontalPanel();
            caption.setWidth("100%");
            Label captionText = new Label("Oopsie!");
            caption.add(captionText);
            caption.setCellWidth(captionText, "100%");
            Image close = new Image("close.gif");
            close.addClickHandler(new CloseListener(dialog));
            caption.add(close);
            dialog.setCaption(caption);
            dialog.add(new Label("I've been a bad, bad browser."));
            dialog.add(new Button("Deny ice cream", new CloseListener(dialog)));
            dialog.show(styledDialog);
        }
    });
    panel.add(styledDialog);

    return panel;
}

From source file:asquare.gwt.tkdemo.client.demos.DropDownPanelPanel.java

License:Apache License

public DropDownPanelPanel() {
    HorizontalPanel outer = new HorizontalPanel();
    outer.setSize("100%", "100%");

    initWidget(outer);/* w  ww  .  ja  v a2  s. co m*/

    BasicPanel left = new BasicPanel();
    left.addStyleName("division");
    DomUtil.setAttribute(left, "id", "dropDown-left");

    DropDownPanel dropDown1 = new DropDownPanel();
    DomUtil.setAttribute(dropDown1, "id", "dropDown-1");
    dropDown1.setHeaderText("Drop Down 1", false);
    HTML dd1Content = new HTML("This DropDownPanel uses CSS to change the header image.");
    dropDown1.add(dd1Content);
    dropDown1.setOpen(true);
    left.add(dropDown1);

    final DropDownPanel dropDown2 = new DropDownPanel();
    DomUtil.setAttribute(dropDown2, "id", "dropDown-2");
    final String closedHeader = "<img src='triangle.gif'/>&nbsp;Drop Down 2";
    final String openHeader = "<img src='opentriangle.gif'/>&nbsp;Drop Down 2";
    dropDown2.setHeaderText(closedHeader, true);
    dropDown2.addDropDownListener(new DropDownListener() {
        public void dropDownClosed(DropDownPanel sender) {
            dropDown2.setHeaderText(closedHeader, true);
        }

        public void dropDownOpened(DropDownPanel sender) {
            dropDown2.setHeaderText(openHeader, true);
        }
    });
    HTML dd2Content = new HTML("This DropDownPanel uses a listener to change the header image.");
    dropDown2.add(dd2Content);
    dropDown2.setOpen(true);
    left.add(dropDown2);

    outer.add(left);
    outer.setCellWidth(left, "1px");

    String content = "<H2>DropDownPanel</H2>"
            + "<p>This widget consists of a hideable content DIV and an optional header DIV.</p>"
            + "<p>The content can be <span id='open'></span>&nbsp;&amp; <span id='close'></span>&nbsp;programatically.</p>"
            + "<p>The headers prevent selection of the text within them. In IE this is done in a special implementation using an <code>onselectstart</code> listener which returns <code>false</code>. In other browsers, <code>DOM.eventPreventDefault(Event)</code> for <code>Event.ONMOUSEDOWN</code> suffices. </p>"
            + "<p>You can add a listener to the DropDownPanel and make layout changes when the it opens/closes (e.g. maximize its parent element when it opens). </p>"
            + "<p><em>Note: we cannot put a border around the Drop Down 1 header because in IE the background image would be obscured by the border.</em></p>";
    DropDownPanel dropDown3 = new DropDownPanel();
    dropDown3.addStyleName("division");
    DomUtil.setAttribute(dropDown3, "id", "dropDown-3");
    dropDown3.setHeaderText("Drop&nbsp;Down&nbsp;3", true);
    HTMLPanel center = new HTMLPanel(content);
    center.addStyleName("description");
    SimpleHyperLink close = new SimpleHyperLink("hidden");
    SimpleHyperLink open = new SimpleHyperLink("shown");
    center.add(close, "close");
    center.add(open, "open");
    dropDown3.add(center);
    dropDown3.setOpen(true);
    outer.add(dropDown3);

    final DropDownPanel dropDown4 = new DropDownPanel();
    dropDown4.addStyleName("division");
    DomUtil.setAttribute(dropDown4, "id", "dropDown-4");
    Image image = new Image("icecube.jpg");
    image.setSize("200px", "250px");
    dropDown4.add(image);
    outer.add(dropDown4);
    outer.setCellWidth(dropDown4, "1px");

    open.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            dropDown4.setOpen(true);
        }
    });
    close.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            dropDown4.setOpen(false);
        }
    });
}

From source file:asquare.gwt.tkdemo.client.demos.MiscPanel.java

License:Apache License

public MiscPanel() {
    HorizontalPanel outer = new HorizontalPanel();
    DomUtil.setAttribute(outer, "id", "miscPanel");
    initWidget(outer);//from  ww  w .  jav  a  2 s  .  c  om

    BasicPanel left = new BasicPanel();
    BasicPanel right = new BasicPanel();

    left.add(new FocusCycleDemo());
    left.add(createSimpleHyperLinkDemo());
    right.add(new GlassPanelDemo());
    right.add(createExternalHyperLinkDemo());

    outer.add(left);
    outer.setCellWidth(left, "50%");
    outer.add(right);
    outer.setCellWidth(right, "50%");
}

From source file:at.ait.dme.yuma.client.colorpicker.ColorPicker.java

License:Artistic License

public ColorPicker() {
    // UI Drawing
    //------------------

    hue = 0;/*from  ww  w .  j a va 2s . c om*/
    saturation = 100;
    brightness = 100;
    red = 255;
    green = 0;
    blue = 0;

    HorizontalPanel panel = new HorizontalPanel();
    FlexTable table = new FlexTable();

    // Add the large slider map
    slidermap = new SliderMap(this);
    panel.add(slidermap);
    panel.setCellWidth(slidermap, "258px");
    panel.setCellHeight(slidermap, "258px");

    // Add the small slider bar
    sliderbar = new SliderBar(this);
    panel.add(sliderbar);
    panel.setCellWidth(sliderbar, "40px");
    panel.setCellHeight(sliderbar, "258px");

    // Define the Flextable's content
    // Color preview at the top
    colorpreview = new HTML("");
    colorpreview.setWidth("50px");
    colorpreview.setHeight("50px");
    DOM.setStyleAttribute(colorpreview.getElement(), "border", "1px solid black");

    // Radio buttons
    rbHue = new RadioButton("color", "H:");
    rbHue.addClickHandler(this);
    rbSaturation = new RadioButton("color", "S:");
    rbSaturation.addClickHandler(this);
    rbBrightness = new RadioButton("color", "V:");
    rbBrightness.addClickHandler(this);
    rbRed = new RadioButton("color", "R:");
    rbRed.addClickHandler(this);
    rbGreen = new RadioButton("color", "G:");
    rbGreen.addClickHandler(this);
    rbBlue = new RadioButton("color", "B:");
    rbBlue.addClickHandler(this);

    // Textboxes
    tbHue = new TextBox();
    tbHue.setText(new Integer(hue).toString());
    tbHue.setMaxLength(3);
    tbHue.setVisibleLength(4);
    tbHue.addKeyPressHandler(this);
    tbHue.addChangeHandler(this);
    tbSaturation = new TextBox();
    tbSaturation.setText(new Integer(saturation).toString());
    tbSaturation.setMaxLength(3);
    tbSaturation.setVisibleLength(4);
    tbSaturation.addKeyPressHandler(this);
    tbSaturation.addChangeHandler(this);
    tbBrightness = new TextBox();
    tbBrightness.setText(new Integer(brightness).toString());
    tbBrightness.setMaxLength(3);
    tbBrightness.setVisibleLength(4);
    tbBrightness.addKeyPressHandler(this);
    tbBrightness.addChangeHandler(this);
    tbRed = new TextBox();
    tbRed.setText(new Integer(red).toString());
    tbRed.setMaxLength(3);
    tbRed.setVisibleLength(4);
    tbRed.addKeyPressHandler(this);
    tbRed.addChangeHandler(this);
    tbGreen = new TextBox();
    tbGreen.setText(new Integer(green).toString());
    tbGreen.setMaxLength(3);
    tbGreen.setVisibleLength(4);
    tbGreen.addKeyPressHandler(this);
    tbGreen.addChangeHandler(this);
    tbBlue = new TextBox();
    tbBlue.setText(new Integer(blue).toString());
    tbBlue.setMaxLength(3);
    tbBlue.setVisibleLength(4);
    tbBlue.addKeyPressHandler(this);
    tbBlue.addChangeHandler(this);
    tbHexColor = new TextBox();
    tbHexColor.setText("ff0000");
    tbHexColor.setMaxLength(6);
    tbHexColor.setVisibleLength(6);
    tbHexColor.addKeyPressHandler(this);
    tbHexColor.addChangeHandler(this);

    // Put together the FlexTable
    table.setWidget(0, 0, colorpreview);
    table.getFlexCellFormatter().setColSpan(0, 0, 3);
    table.setWidget(1, 0, rbHue);
    table.setWidget(1, 1, tbHue);
    table.setWidget(1, 2, new HTML("&deg;"));
    table.setWidget(2, 0, rbSaturation);
    table.setWidget(2, 1, tbSaturation);
    table.setText(2, 2, "%");
    table.setWidget(3, 0, rbBrightness);
    table.setWidget(3, 1, tbBrightness);
    table.setText(3, 2, "%");
    table.setWidget(4, 0, rbRed);
    table.setWidget(4, 1, tbRed);
    table.setWidget(5, 0, rbGreen);
    table.setWidget(5, 1, tbGreen);
    table.setWidget(6, 0, rbBlue);
    table.setWidget(6, 1, tbBlue);
    table.setText(7, 0, "#:");
    table.setWidget(7, 1, tbHexColor);
    table.getFlexCellFormatter().setColSpan(7, 1, 2);

    // Final setup
    panel.add(table);
    rbSaturation.setValue(true);
    setPreview("ff0000");
    DOM.setStyleAttribute(colorpreview.getElement(), "cursor", "default");

    // First event
    onClick(rbSaturation);

    initWidget(panel);
}

From source file:ch.unifr.pai.twice.widgets.mpproxyframe.client.ComplexMPFrame.java

License:Apache License

public ComplexMPFrame() {
    super();/*from  www. ja va  2  s. c  om*/
    HorizontalPanel p = new HorizontalPanel();
    p.add(back);
    p.add(forward);
    p.add(url);
    p.add(reload);
    p.setWidth("100%");
    p.setHeight("100%");

    back.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent arg0) {
            frame.back();
        }
    });

    forward.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent arg0) {
            frame.forward();
        }
    });

    reload.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent arg0) {
            frame.reload();
        }
    });
    p.setCellWidth(url, "100%");

    addNorth(p, 30);
    url.addValueChangeHandler(new ValueChangeHandler<String>() {
        @Override
        public void onValueChange(ValueChangeEvent<String> arg0) {
            frame.setUrl(arg0.getValue());
        }
    });
    addSouth(controller, 170);
    add(frame);
}

From source file:cl.uai.client.page.EditMarkDialog.java

License:Open Source License

/**
 * Creates a comment dialog at a specific position
 * /*  w  w w  .  ja v  a  2s. c o m*/
 * @param posx Top position for the dialog
 * @param posy Left position for the dialog
 * @param level An optional rubric level in case we are editing one
 */
public EditMarkDialog(int posx, int posy, int level, int regradeid) {
    super(true, false);

    this.regradeId = regradeid;

    this.levelId = level;
    Level lvl = MarkingInterface.submissionData.getLevelById(levelId);

    if (EMarkingConfiguration.getKeywords() != null && EMarkingConfiguration.getKeywords().length() > 0) {
        logger.fine("Keywords: " + EMarkingConfiguration.getKeywords());
    }
    if (!EMarkingConfiguration.getKeywords().equals("") && (level > 0 || regradeid > 0)) {
        feedbackArray = new ArrayList<FeedbackObject>();
        feedbackPanel = new FeedbackInterface();
        feedbackPanel.setParent(this);
    } else {
        simplePanel = true;
    }

    superPanel = new HorizontalPanel();
    superPanel.addStyleName(Resources.INSTANCE.css().feedbackdialog());

    feedbackForStudent = new VerticalPanel();
    feedbackForStudent.addStyleName(Resources.INSTANCE.css().feedbackforstudent());

    feedbackSummary = new ScrollPanel(feedbackForStudent);
    feedbackSummary.addStyleName(Resources.INSTANCE.css().feedbacksummary());

    mainPanel = new VerticalPanel();
    mainPanel.addStyleName(Resources.INSTANCE.css().editmarkdialog());

    // Adds the CSS style and other settings
    this.addStyleName(Resources.INSTANCE.css().commentdialog());
    this.setAnimationEnabled(true);
    this.setGlassEnabled(true);

    bonusTxt = new TextBox();
    bonusTxt.addStyleName(Resources.INSTANCE.css().bonuslist());

    this.levelsList = new ListBox();
    this.levelsList.addStyleName(Resources.INSTANCE.css().levelslist());
    this.levelsList.addChangeHandler(new ChangeHandler() {
        @Override
        public void onChange(ChangeEvent event) {
            int levelid = Integer.parseInt(levelsList.getValue(levelsList.getSelectedIndex()));
            levelId = levelid;
            Level lvl = MarkingInterface.submissionData.getLevelById(levelId);
            setBonus(lvl.getBonus());
        }
    });

    // If there's a rubric level we should edit a Mark
    // otherwise we are just editing its comment
    if (this.levelId == 0) {
        this.setHTML(MarkingInterface.messages.AddEditComment());
    } else {
        this.setHTML(MarkingInterface.messages.AddEditMark() + "<br/>" + lvl.getCriterion().getDescription());
    }

    // Position the dialog
    if (simplePanel) {
        this.setPopupPosition(posx, posy);
    } else {
        // The Dialog is more big, so we need to fix the position
        this.setPopupPosition((int) (Window.getClientWidth() * 0.08), (int) (Window.getClientHeight() * 0.15));
    }

    if (this.levelId > 0) {

        loadLevelsList();

        HorizontalPanel hpanelLevels = new HorizontalPanel();
        hpanelLevels.setWidth("100%");
        Label messages = new Label(MarkingInterface.messages.Level());
        hpanelLevels.add(messages);
        hpanelLevels.add(levelsList);
        hpanelLevels.setCellHorizontalAlignment(levelsList, HasHorizontalAlignment.ALIGN_RIGHT);
        mainPanel.add(hpanelLevels);
        mainPanel.setCellHorizontalAlignment(hpanelLevels, HasHorizontalAlignment.ALIGN_RIGHT);
    }

    // Save button
    Button btnSave = new Button(MarkingInterface.messages.Save());
    btnSave.addStyleName(Resources.INSTANCE.css().btnsave());
    btnSave.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            if (levelId > 0 && !bonusIsValid()) {
                Window.alert(MarkingInterface.messages.InvalidBonusValue());
                return;
            }
            cancelled = false;
            hide();
        }
    });

    // Cancel button
    Button btnCancel = new Button(MarkingInterface.messages.Cancel());
    btnSave.addStyleName(Resources.INSTANCE.css().btncancel());
    btnCancel.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            cancelled = true;
            hide();
        }
    });

    // The comment text box
    TextArea txt = new TextArea();
    txt.setVisibleLines(5);
    txt.getElement().getStyle().setMarginBottom(5, Unit.PT);
    txtComment = new SuggestBox(EMarkingWeb.markingInterface.previousCommentsOracle, txt);
    txtComment.setAutoSelectEnabled(false);
    txtComment.addStyleName(Resources.INSTANCE.css().editmarksuggestbox());

    HorizontalPanel hpanelComment = new HorizontalPanel();
    hpanelComment.setWidth("100%");
    hpanelComment.add(new Label(MarkingInterface.messages.Comment()));
    hpanelComment.add(txtComment);
    hpanelComment.setCellHorizontalAlignment(txtComment, HasHorizontalAlignment.ALIGN_RIGHT);
    mainPanel.add(hpanelComment);
    mainPanel.setCellHorizontalAlignment(hpanelComment, HasHorizontalAlignment.ALIGN_RIGHT);

    // If the rubric level is not null then create the bonus list and add it to the dialog 
    if (this.levelId > 0) {
        setBonus(lvl.getBonus());

        HorizontalPanel hpanelBonus = new HorizontalPanel();
        hpanelBonus.setWidth("100%");
        hpanelBonus.add(new Label(MarkingInterface.messages.SetBonus()));
        hpanelBonus.add(bonusTxt);
        hpanelBonus.setCellHorizontalAlignment(bonusTxt, HasHorizontalAlignment.ALIGN_RIGHT);
        if (EMarkingConfiguration.isFormativeFeedbackOnly()) {
            hpanelBonus.setVisible(false);
        }
        mainPanel.add(hpanelBonus);
        mainPanel.setCellHorizontalAlignment(hpanelBonus, HasHorizontalAlignment.ALIGN_RIGHT);
    }

    // The regrade comment text box
    txt = new TextArea();
    txt.setVisibleLines(5);
    txt.getElement().getStyle().setMarginBottom(5, Unit.PT);
    txtRegradeComment = new SuggestBox(EMarkingWeb.markingInterface.previousCommentsOracle, txt);

    if (this.regradeId > 0) {

        mainPanel.add(new HTML("<hr>"));
        mainPanel.add(new Label(MarkingInterface.messages.Regrade()));

        // Add the textbox
        HorizontalPanel hpanelRegradeComment = new HorizontalPanel();
        hpanelRegradeComment.setWidth("100%");
        hpanelRegradeComment.add(new Label(MarkingInterface.messages.RegradeComment()));
        hpanelRegradeComment.add(txtRegradeComment);
        hpanelRegradeComment.setCellHorizontalAlignment(txtRegradeComment, HasHorizontalAlignment.ALIGN_RIGHT);
        mainPanel.add(hpanelRegradeComment);
        mainPanel.setCellHorizontalAlignment(hpanelRegradeComment, HasHorizontalAlignment.ALIGN_RIGHT);
    }

    // Add buttons
    HorizontalPanel hpanel = new HorizontalPanel();
    hpanel.setSpacing(2);
    hpanel.setWidth("100%");
    hpanel.add(btnSave);
    hpanel.add(btnCancel);
    hpanel.setCellWidth(btnSave, "100%");
    hpanel.setCellWidth(btnCancel, "0px");
    hpanel.setCellHorizontalAlignment(btnCancel, HasHorizontalAlignment.ALIGN_RIGHT);
    hpanel.setCellHorizontalAlignment(btnSave, HasHorizontalAlignment.ALIGN_RIGHT);
    mainPanel.add(hpanel);
    mainPanel.setCellHorizontalAlignment(hpanel, HasHorizontalAlignment.ALIGN_RIGHT);

    if (simplePanel) {
        // No feedback
        this.setWidget(mainPanel);
    } else {
        // Remove CSS Style
        mainPanel.removeStyleName(Resources.INSTANCE.css().editmarkdialog());
        mainPanel.addStyleName(Resources.INSTANCE.css().editmarkdialogWithFeedback());

        bonusTxt.removeStyleName(Resources.INSTANCE.css().bonuslist());
        bonusTxt.addStyleName(Resources.INSTANCE.css().bonuslistWithFeedback());

        this.levelsList.removeStyleName(Resources.INSTANCE.css().levelslist());
        this.levelsList.addStyleName(Resources.INSTANCE.css().levelslistWithFeedback());

        txtComment.removeStyleName(Resources.INSTANCE.css().editmarksuggestbox());
        txtComment.addStyleName(Resources.INSTANCE.css().editmarksuggestboxWithFeedback());

        // Add feedback panel
        mainPanel.add(new HTML("<h4>Feedback</h4>"));
        mainPanel.add(feedbackSummary);

        superPanel.add(mainPanel);
        superPanel.add(feedbackPanel);
        this.setWidget(superPanel);
    }
}

From source file:com.allen_sauer.gwt.log.client.DivLogger.java

License:Apache License

/**
 * @deprecated/*from ww  w .java  2s  . co  m*/
 */
@Deprecated
private FocusPanel makeHeader() {
    FocusPanel header;
    header = new FocusPanel();
    HorizontalPanel masterPanel = new HorizontalPanel();
    masterPanel.setWidth("100%");
    header.add(masterPanel);

    final Label titleLabel = new Label("gwt-log", false);
    titleLabel.setStylePrimaryName(LogClientBundle.INSTANCE.css().logTitle());

    HorizontalPanel buttonPanel = new HorizontalPanel();
    levelButtons = new Button[levels.length];
    for (int i = 0; i < levels.length; i++) {
        final int level = levels[i];
        levelButtons[i] = new Button(LogUtil.levelToString(level));
        buttonPanel.add(levelButtons[i]);
        levelButtons[i].addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                ((Button) event.getSource()).setFocus(false);
                Log.setCurrentLogLevel(level);
            }
        });
    }

    Button clearButton = new Button("Clear");
    clearButton.addStyleName(LogClientBundle.INSTANCE.css().logClearButton());
    DOM.setStyleAttribute(clearButton.getElement(), "color", "#00c");
    clearButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            ((Button) event.getSource()).setFocus(false);
            Log.clear();
        }
    });
    buttonPanel.add(clearButton);

    Button aboutButton = new Button("About");
    aboutButton.addStyleName(LogClientBundle.INSTANCE.css().logClearAbout());
    aboutButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            ((Button) event.getSource()).setFocus(false);

            Log.diagnostic("\n" //
                    + "gwt-log-" + Log.getVersion() //
                    + " - Runtime logging for your Google Web Toolkit projects\n" + //
            "Copyright 2007 Fred Sauer\n" + //
            "The original software is available from:\n" + //
            "\u00a0\u00a0\u00a0\u00a0http://allen-sauer.com/gwt/\n", null);
        }
    });

    Button closeButton = new Button("X");
    closeButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            logDockPanel.removeFromParent();
        }
    });

    masterPanel.add(titleLabel);
    masterPanel.add(buttonPanel);
    masterPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
    masterPanel.add(aboutButton);
    masterPanel.add(closeButton);

    masterPanel.setCellHeight(titleLabel, "100%");
    masterPanel.setCellWidth(titleLabel, "50%");
    masterPanel.setCellWidth(aboutButton, "50%");

    new MouseDragHandler(titleLabel);

    return header;
}

From source file:com.anzsoft.client.ui.UserIndicator.java

License:Open Source License

public UserIndicator(final String nick) {
    createStatusMenu();/*w w w . ja v  a 2s  . co  m*/
    setWidth("100%");
    setCellPadding(0);
    setCellSpacing(0);
    setStyleName("indicator");
    FlexCellFormatter formatter = getFlexCellFormatter();

    // Setup the links cell
    /*
    linksPanel = new HorizontalPanel();
    setWidget(0, 0, linksPanel);
    formatter.setStyleName(0, 0, "indicator-links");
    formatter.setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    formatter.setColSpan(0, 0, 2);
    */

    // Setup the title cell
    setTitleWidget(null);
    formatter.setStyleName(0, 0, "indicator-title");

    getRowFormatter().setVerticalAlign(0, HasVerticalAlignment.ALIGN_TOP);
    getRowFormatter().setVerticalAlign(1, HasVerticalAlignment.ALIGN_TOP);

    final ChatIcons icons = ChatIcons.App.getInstance();
    statusImg = new Image();
    statusImg.setWidth("16px");
    statusImg.setHeight("16px");
    icons.online().applyTo(statusImg);

    avatarImg = new Image("images/default_avatar.png");
    avatarImg.setWidth("32px");
    avatarImg.setHeight("32px");
    avatarImg.setStyleName("handler");
    avatarImg.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            JabberApp.instance().showInfoSelf();
        }

    });

    nickName = new Label(nick);
    nickName.setDirection(Direction.LTR);
    nickName.setWidth("100%");

    statusLabel = new Label();
    statusLabel.setStyleName("status_label");
    statusLabel.setWidth("100%");

    statusEditor = new TextBox();
    statusEditor.setVisible(false);
    statusEditor.setWidth("100%");

    statusButton = new Button();
    statusButton.setMenu(statusMenu);
    statusButton.setStyleName("Status-Menu-Button");

    //statusMenuLabel = new Label();
    //statusMenuLabel.setStyleName("status_menu_label");

    //addLink(new HTML("<a href=\"http://samespace.anzsoft.com\">SameSpace</a>"));
    // Add the title and some images to the title bar
    HorizontalPanel titlePanel = new HorizontalPanel();
    titlePanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    titlePanel.setWidth("100%");
    titlePanel.setSpacing(3);

    VerticalPanel statusPanel = new VerticalPanel();
    statusPanel.setWidth("100%");
    statusPanel.add(nickName);

    HorizontalPanel hPanel = new HorizontalPanel();
    hPanel.setWidth("100%");
    hPanel.setSpacing(2);
    hPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
    hPanel.add(statusLabel);
    hPanel.add(statusEditor);
    hPanel.add(statusButton);

    statusPanel.add(hPanel);

    titlePanel.add(statusImg);
    titlePanel.add(statusPanel);
    titlePanel.add(avatarImg);

    titlePanel.setCellWidth(statusImg, "20px");
    titlePanel.setCellWidth(statusPanel, "100%");
    titlePanel.setCellWidth(avatarImg, "32px");
    setTitleWidget(titlePanel);

    JabberApp.instance().getSession().getUser().addUserListener(new XmppUserListener() {
        public void onPresenceChanged(XmppPresence presence) {
            String show = new String("");
            PresenceShow presenceShow = presence.getShow();
            if (presenceShow != null)
                show = presenceShow.toString();
            String statusString = presence.getStatus();
            int priority = presence.getPriority();
            boolean avaiable = true;
            String type = presence.getType();
            if (type != null && !type.isEmpty()) {
                if (type.equalsIgnoreCase("unavailable"))
                    avaiable = false;
            }
            status = new XmppContactStatus(show, statusString, priority, avaiable);
            statusLabel.setText(status.status());
            iconFromStatus(status).applyTo(statusImg);
        }
    });

    statusLabel.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            statusLabel.setVisible(false);
            statusEditor.setVisible(true);
            statusEditor.setText(statusLabel.getText());
        }

    });

    statusEditor.addKeyboardListener(new KeyboardListener() {

        public void onKeyDown(Widget sender, char keyCode, int modifiers) {

        }

        public void onKeyPress(Widget sender, char keyCode, int modifiers) {

        }

        public void onKeyUp(Widget sender, char keyCode, int modifiers) {
            if (keyCode == 13)
                doneChangeStatusString();
        }

    });

    statusEditor.addFocusListener(new FocusListener() {
        public void onFocus(Widget sender) {
        }

        public void onLostFocus(Widget sender) {
            doneChangeStatusString();
        }

    });

    XmppVCardFactory.instance().addVCardListener(new VCardListener() {
        public void onVCard(XmppID jid, XmppVCard vcard) {
            if (jid.toStringNoResource().equalsIgnoreCase(JabberApp.instance().getJid().toStringNoResource())) {
                if (!vcard.nickName().isEmpty())
                    nickName.setText(vcard.fullName());
                else if (!vcard.fullName().isEmpty())
                    nickName.setText(vcard.fullName());
                String photoData = vcard.photo();
                if (!photoData.isEmpty() && !GXT.isIE) {
                    ImageElement imgEl = avatarImg.getElement().cast();
                    imgEl.removeAttribute("src");
                    imgEl.setSrc("data:image;base64," + photoData);
                }

            }
        }

    });
}