Example usage for com.google.gwt.user.client.ui FocusPanel addKeyboardListener

List of usage examples for com.google.gwt.user.client.ui FocusPanel addKeyboardListener

Introduction

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

Prototype

@Deprecated
public void addKeyboardListener(KeyboardListener listener) 

Source Link

Usage

From source file:ca.upei.ic.timetable.client.PanelUtils.java

License:Apache License

/**
 * Create a Focus Panel/*w  ww . ja  va  2s. co m*/
 * 
 * @param widget
 * @param clickListener
 * @param focusListener
 * @param keyboardListener
 * @param mouseListener
 * @return
 */
public static FocusPanel focusPanel(Widget widget, ClickListener clickListener, FocusListener focusListener,
        KeyboardListener keyboardListener, MouseListener mouseListener) {
    FocusPanel panel = GWT.create(FocusPanel.class);
    if (clickListener != null)
        panel.addClickListener(clickListener);
    if (focusListener != null)
        panel.addFocusListener(focusListener);
    if (keyboardListener != null)
        panel.addKeyboardListener(keyboardListener);
    if (mouseListener != null)
        panel.addMouseListener(mouseListener);
    panel.setWidget(widget);
    return panel;
}

From source file:com.pronoiahealth.olhie.client.widgets.rating.RateItWidget.java

License:Open Source License

public RateItWidget(double rating, int maxRating, Image normalImage, Image ratedImage, Image normalZeroImage,
        Image ratedZeroImage, Image[] ratingImages) {
    FocusPanel panel = new FocusPanel();
    panel.addMouseListener(new MouseListenerAdapter() {
        public void onMouseLeave(Widget sender) {
            if (isRated()) {
                drawRating(getUserRating());
            } else {
                setup();/*from w ww.java2  s.c o m*/
            }
        }
    });
    panel.addKeyboardListener(new KeyboardListenerAdapter() {

        public void onKeyUp(Widget sender, char keyCode, int modifiers) {
            if (keyCode == KeyboardListener.KEY_RIGHT) {
                RateItWidget.this.setUserRating(RateItWidget.this.getUserRating() + 1, true);
            } else if (keyCode == KeyboardListener.KEY_LEFT) {
                RateItWidget.this.setUserRating(RateItWidget.this.getUserRating() - 1, true);
            } else if (keyCode >= '0' && keyCode <= '9') {
                RateItWidget.this.setUserRating(keyCode - '0', true);
            }
        }
    });
    grid = new Grid(1, maxRating + 1) {
        public boolean clearCell(int row, int column) {
            boolean retValue = super.clearCell(row, column);

            Element td = getCellFormatter().getElement(row, column);
            DOM.setInnerHTML(td, "");
            return retValue;
        }
    };
    grid.setCellSpacing(0);
    grid.setCellPadding(0);
    this.normalImage = normalImage;
    this.ratedImage = ratedImage;
    this.normalZeroImage = normalZeroImage;
    this.ratedZeroImage = ratedZeroImage;
    this.ratingImages = ratingImages;
    this.rating = rating;
    this.userRating = 0;
    setup();
    panel.add(grid);
    setWidget(panel);
    setStyleName("RateItWidget");
}

From source file:com.xpn.xwiki.cbdf.client.CBDF.java

License:Open Source License

/**
* Method that initializes all the variables and creates the html required for the color picker and so on.
*///www  .j a  v a  2  s  . c  o m
private void InitComponents() {
    apanel = new AbsolutePanel();
    FocusPanel focus = new FocusPanel();
    DockPanel panel = new DockPanel();

    lastPosition[0] = 0;
    lastPosition[1] = 0;

    isMovable = false;
    isTransformable = false;

    transformPoints = new VirtualGroup();
    transformPointers = new GraphicObject[9];

    currRotation = 0.0;

    this.currentFontFamily = new ListBox();
    this.currentFontFamily.setMultipleSelect(false);
    this.currentFontFamily.insertItem("Arial", 0);
    this.currentFontFamily.insertItem("Courier", 1);
    this.currentFontFamily.insertItem("Times New Roman", 2);
    this.currentFontFamily.insertItem("Verdana", 3);
    this.currentFontFamily.insertItem("Georgia", 4);
    this.currentFontFamily.setSelectedIndex(0);
    this.currentFontFamily.addChangeListener(this);

    this.currentFontSize = new ListBox();
    this.currentFontSize.setMultipleSelect(false);
    this.currentFontSize.insertItem("8", 0);
    this.currentFontSize.insertItem("10", 1);
    this.currentFontSize.insertItem("12", 2);
    this.currentFontSize.insertItem("14", 3);
    this.currentFontSize.insertItem("16", 4);
    this.currentFontSize.insertItem("18", 5);
    this.currentFontSize.insertItem("20", 6);
    this.currentFontSize.insertItem("24", 7);
    this.currentFontSize.insertItem("28", 8);
    this.currentFontSize.insertItem("36", 9);
    this.currentFontSize.insertItem("48", 10);
    this.currentFontSize.insertItem("72", 11);
    this.currentFontSize.setSelectedIndex(2);
    this.currentFontSize.addChangeListener(this);

    this.currentFontStyle = new ListBox();
    this.currentFontStyle.setMultipleSelect(false);
    this.currentFontStyle.insertItem("normal", 0);
    this.currentFontStyle.insertItem("italic", 1);
    this.currentFontStyle.setSelectedIndex(0);
    this.currentFontStyle.addChangeListener(this);

    this.currentFontWeight = new ListBox();
    this.currentFontWeight.setMultipleSelect(false);
    this.currentFontWeight.insertItem("normal", 0);
    this.currentFontWeight.insertItem("bold", 1);
    this.currentFontWeight.setSelectedIndex(0);
    this.currentFontWeight.addChangeListener(this);

    this.updateFont();

    canvas = new GraphicCanvas();
    canvas.setStyleName("drawboard");
    canvas.setPixelSize(width, height);
    canvas.addGraphicObjectListener(this);

    saver = new SVGFormatter("1.1", "http://www.w3.org/2000/svg", "demo", width, height);

    buttonPanel = new VerticalPanel();
    buttonPanel.setSpacing(0);

    Grid gridShape = new Grid(4, 2);
    gridShape.setCellSpacing(2);
    gridShape.setCellPadding(2);

    Grid gridTransform = new Grid(3, 2);
    gridTransform.setCellPadding(2);
    gridTransform.setCellSpacing(2);

    fill = new HTML(" ");
    DOM.setStyleAttribute(fill.getElement(), "backgroundColor", this.currentFillColor.toHex());
    DOM.setStyleAttribute(fill.getElement(), "border", "solid");
    DOM.setStyleAttribute(fill.getElement(), "borderWidth", "thin");
    DOM.setStyleAttribute(fill.getElement(), "borderColor", "#000000");
    fill.setSize("30px", "30px");
    fill.addClickListener(this);

    stroke = new HTML(" ");
    DOM.setStyleAttribute(stroke.getElement(), "backgroundColor", this.currentStrokeColor.toHex());
    DOM.setStyleAttribute(stroke.getElement(), "border", "solid");
    DOM.setStyleAttribute(stroke.getElement(), "borderWidth", "thin");
    DOM.setStyleAttribute(stroke.getElement(), "borderColor", "#000000");
    stroke.setSize("30px", "30px");
    stroke.addClickListener(this);

    HTML fake = new HTML("&nbsp;&nbsp;&nbsp;");
    DOM.setStyleAttribute(fake.getElement(), "backgroundColor", "#FFFFFF");
    fake.setSize("30px", "30px");

    HTML fake2 = new HTML("&nbsp;&nbsp;&nbsp;");
    DOM.setStyleAttribute(fake2.getElement(), "backgroundColor", "#FFFFFF");
    fake2.setSize("30px", "30px");

    buttonPanel.add(gridShape);
    buttonPanel.add(fake);
    buttonPanel.add(fake2);

    this.strokeButton = new Image("gfx/color.gif");
    this.strokeButton.setTitle("Choose the stroke");
    this.strokeButton.setSize("34px", "34px");
    this.strokeButton.addClickListener(this);

    buttonPanel.add(this.strokeButton);
    buttonPanel.setCellHorizontalAlignment(this.strokeButton, VerticalPanel.ALIGN_CENTER);

    buttonPanel.add(gridTransform);

    fillOpacity = new Slider(Slider.HORIZONTAL, 0, 255, 255, true);
    fillOpacity.addChangeListener(this);

    strokeOpacity = new Slider(Slider.HORIZONTAL, 0, 255, 255, true);
    strokeOpacity.addChangeListener(this);

    currentStrokeSize = new Slider(Slider.HORIZONTAL, 0, 50, 1, true);
    currentStrokeSize.addChangeListener(this);

    /** This adds the buttons to the two grids */
    selectButton = addToGrid(gridShape, 0, 0, "Select object", "gfx/select.gif");
    pencilButton = addToGrid(gridShape, 0, 1, "Draw with Pencil", "gfx/pencil.gif");
    lineButton = addToGrid(gridShape, 1, 0, "Draw a Line", "gfx/line.gif");
    rectButton = addToGrid(gridShape, 1, 1, "Draw a Rect", "gfx/rect.gif");
    circleButton = addToGrid(gridShape, 2, 0, "Draw a Circle", "gfx/circle.gif");
    ellipseButton = addToGrid(gridShape, 2, 1, "Draw a Ellipse", "gfx/ellipse.gif");
    polylineButton = addToGrid(gridShape, 3, 0, "Draw a Path", "gfx/polyline.gif");
    textButton = addToGrid(gridShape, 3, 1, "Write Text", "gfx/text.gif");

    deleteButton = addToGrid(gridTransform, 0, 0, "Delete object", "gfx/delete.gif");
    saveButton = addToGrid(gridTransform, 0, 1, "Save SVG to page", "gfx/save.gif");
    backButton = addToGrid(gridTransform, 1, 0, "Send object Back", "gfx/back.gif");
    frontButton = addToGrid(gridTransform, 1, 1, "Send object Front", "gfx/front.gif");

    apanel.add(focus);

    focus.add(panel);
    panel.add(this.canvas, DockPanel.CENTER);
    panel.add(this.buttonPanel, DockPanel.WEST);
    panel.add(this.currentFontFamily, DockPanel.SOUTH);
    panel.add(this.currentFontSize, DockPanel.SOUTH);
    panel.add(this.currentFontStyle, DockPanel.SOUTH);
    panel.add(this.currentFontWeight, DockPanel.SOUTH);
    this.apanel.setSize("100%", "100%");
    focus.addKeyboardListener(this);
    focus.setSize("100%", "100%");
}

From source file:com.xpn.xwiki.wysiwyg.client.widget.ListBox.java

License:Open Source License

/**
 * Creates a new list box.// w w w . jav a2  s.c o  m
 */
public ListBox() {
    FocusPanel panel = new FocusPanel(list);
    panel.addClickListener(this);
    panel.addKeyboardListener(this);

    initWidget(panel);
    setStylePrimaryName("xListBox");
}

From source file:org.gems.ajax.client.event.UIEventConnector.java

License:Open Source License

public UIEventConnector(FocusPanel fp, DiagramElement element) {
    super();// ww w .  ja  v a 2s  .  c  o  m
    element_ = element;

    fp.addMouseListener(this);
    fp.addKeyboardListener(this);
}

From source file:org.imb.client.RateItWidget.java

License:Open Source License

public RateItWidget(double rating, int maxRating, Image normalImage, Image ratedImage, Image normalZeroImage,
        Image ratedZeroImage, Image[] ratingImages) {
    FocusPanel panel = new FocusPanel();
    panel.addMouseListener(new MouseListenerAdapter() {
        @Override//  ww  w. ja  v a 2  s  .  c  o m
        public void onMouseLeave(Widget sender) {
            if (isRated()) {
                drawRating(getUserRating());
            } else {
                setup();
            }
        }
    });
    panel.addKeyboardListener(new KeyboardListenerAdapter() {

        @Override
        public void onKeyUp(Widget sender, char keyCode, int modifiers) {
            if (keyCode == KeyboardListener.KEY_RIGHT) {
                RateItWidget.this.setUserRating(RateItWidget.this.getUserRating() + 1, true);
            } else if (keyCode == KeyboardListener.KEY_LEFT) {
                RateItWidget.this.setUserRating(RateItWidget.this.getUserRating() - 1, true);
            } else if (keyCode >= '0' && keyCode <= '9') {
                RateItWidget.this.setUserRating(keyCode - '0', true);
            }
        }
    });
    grid = new Grid(1, maxRating + 1) {
        @Override
        public boolean clearCell(int row, int column) {
            boolean retValue = super.clearCell(row, column);

            Element td = getCellFormatter().getElement(row, column);
            DOM.setInnerHTML(td, "");
            return retValue;
        }
    };
    grid.setCellSpacing(0);
    grid.setCellPadding(0);

    this.normalImage = normalImage;
    this.ratedImage = ratedImage;
    this.normalZeroImage = normalZeroImage;
    this.ratingImages = ratingImages;
    this.rating = rating;
    this.userRating = 0;

    setup();
    panel.add(grid);
    initWidget(panel);
    setStyleName("RateItWidget");
}