Example usage for com.google.gwt.user.client.ui DockPanel add

List of usage examples for com.google.gwt.user.client.ui DockPanel add

Introduction

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

Prototype

public void add(IsWidget widget, DockLayoutConstant direction) 

Source Link

Document

Overloaded version for IsWidget.

Usage

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

License:Apache License

public ApplicationView(ApplicationController app) {
    app_ = app;/*w ww .  j  a  va 2 s .  co m*/

    // hide the root panel first
    hide();

    // create the application view elements
    // we are using a horizontal split panel to host the left side (course view)
    // and the right side (calendar view)
    DockPanel panel = GWT.create(DockPanel.class);
    panel.setSize("980px", "580px");

    final View findCourseView = app_.getFindCourseController().getView();

    // find course button
    final Button findCourseButton = GWT.create(Button.class);
    findCourseButton.setText("Find Course...");
    findCourseButton.setPixelSize(250, 28);
    findCourseButton.addClickListener(new ClickListener() {

        public void onClick(Widget sender) {
            findCourseView.show();
        }

    });
    // message view
    final View messageView = app_.getMessageController().getView();

    // course view
    final View courseView = app_.getCourseController().getView();
    courseView.getWidget().setWidth("340px");

    // calendar view
    final View calendarView = app_.getCourseCalendarController().getView();

    // top panel
    HorizontalPanel topPanel = GWT.create(HorizontalPanel.class);
    topPanel.add(findCourseButton);
    headerPanel_ = GWT.create(HorizontalPanel.class);
    SimplePanel topleft = PanelUtils.simplePanel(new HTML(""), 61, 28);
    headerPanel_.add(topleft);

    // add headers
    for (int i = 1; i < 6; i++) {
        SimplePanel header = GWT.create(SimplePanel.class);
        header.addStyleName("gridHeaderCell");
        header.setPixelSize(128, 28);
        header.add(new HTML(headerStrings[i]));
        headerPanel_.add(header);
    }

    topPanel.add(headerPanel_);

    // add elements to the dock panel
    // to north (top bar)
    panel.add(PanelUtils.horizontalPanel(findCourseButton, headerPanel_), DockPanel.NORTH);
    // to west (left side bar)
    panel.add(PanelUtils.verticalPanel(
            PanelUtils.decoratorPanel(PanelUtils.scrollPanel(courseView.getWidget(), 240, 555)),
            PanelUtils.horizontalPanel(ButtonUtils.button("Clear", 125, 25, new ClickListener() {
                public void onClick(Widget sender) {
                    app_.getCourseController().clear();
                }
            }, null), ButtonUtils.button("Print...", 125, 25, new ClickListener() {
                public void onClick(Widget sender) {
                    Element wrapper = DOM.createDiv();
                    Element header = (Element) headerPanel_.getElement().cloneNode(true);
                    wrapper.appendChild(header);
                    CalendarPanel calendar = (CalendarPanel) app_.getCourseCalendarController().getView()
                            .getWidget();
                    int height = calendar.getRealHeight();
                    Element calendarElement = (Element) calendar.getElement().cloneNode(true);
                    DOM.setStyleAttribute(calendarElement, "page-break-inside", "avoid");
                    DOM.setStyleAttribute(calendarElement, "height", (height + 50) + "px");
                    wrapper.appendChild(calendarElement);
                    app_.print("Main.css", wrapper.getInnerHTML());
                }
            }, null))), DockPanel.WEST);
    // to center (content)
    panel.add(calendarView.getWidget(), DockPanel.CENTER);

    // to footer (copyright)
    panel.add(new HTML(
            "&copy; 2008 University of Prince Edward Island. This is an <a href=\"http://github.com/upei/\">open-source project</a> licensed under Apache License 2.0."),
            DockPanel.SOUTH);

    // add the horizontal panel
    RootPanel.get().add(panel);
}

From source file:com.apress.progwt.client.calculator.Calculator.java

License:Apache License

public Calculator() {

    DockPanel dockPanel = new DockPanel();

    Grid controls = new Grid(5, 2);
    Grid numbersP = new Grid(4, 3);

    // initialize the 1-9 buttons
    for (int row = 0; row < 3; row++) {
        for (int col = 0; col < 3; col++) {
            numbersP.setWidget(row, col, new NumberButton(this, row * 3 + col + 1));
        }//w  w w.  j  a  v a 2s  .c  om
    }
    numbersP.setWidget(3, 0, new NumberButton(this, 0));
    numbersP.setWidget(3, 1, new NumberButton(this, "."));
    numbersP.setWidget(3, 2, new ControlButton(this, new ControlAction(this, "+/-") {
        @Override
        public boolean isMultiArg() {
            return false;
        }

        @Override
        public double performAction(ControlAction lastAction, double previous, double current) {
            return -1 * current;
        }
    }));

    controls.setWidget(0, 0, new ControlButton(this, new ControlAction(this, "/") {

        @Override
        public double performAction(ControlAction lastAction, double previous, double current) {
            return previous / current;
        }
    }));

    controls.setWidget(0, 1, new ControlButton(this, new ControlAction(this, "sqrt") {
        @Override
        public boolean isMultiArg() {
            return false;
        }

        @Override
        public double performAction(ControlAction lastAction, double previous, double current) {
            return Math.sqrt(current);
        }
    }));

    controls.setWidget(1, 0, new ControlButton(this, new ControlAction(this, "*") {
        @Override
        public double performAction(ControlAction lastAction, double previous, double current) {
            return previous * current;
        }
    }));
    controls.setWidget(1, 1, new ControlButton(this, new ControlAction(this, "%") {
        @Override
        public double performAction(ControlAction lastAction, double previous, double current) {
            return previous % current;
        }
    }));
    controls.setWidget(2, 0, new ControlButton(this, new ControlAction(this, "-") {
        @Override
        public double performAction(ControlAction lastAction, double previous, double current) {
            return previous - current;
        }
    }));
    controls.setWidget(2, 1, new ControlButton(this, new ControlAction(this, "1/x") {
        @Override
        public boolean isMultiArg() {
            return false;
        }

        @Override
        public double performAction(ControlAction lastAction, double previous, double current) {
            return 1 / current;
        }
    }));
    controls.setWidget(3, 0, new ControlButton(this, new ControlAction(this, "+") {
        @Override
        public double performAction(ControlAction lastAction, double previous, double current) {
            return previous + current;
        }
    }));
    controls.setWidget(3, 1, new ControlButton(this, new ControlAction(this, "=") {
        @Override
        public boolean isMultiArg() {
            return false;
        }

        @Override
        public double performAction(ControlAction lastAction, double previous, double current) {
            if (lastAction == null) {
                return current;
            }
            return lastAction.performAction(null, previous, current);
        }

    }));

    controls.setWidget(4, 0, new ControlButton(this, new ControlAction(this, "bksp") {
        @Override
        public boolean isMultiArg() {
            return false;
        }

        @Override
        public double performAction(ControlAction lastAction, double previous, double current) {
            String cStr = current + "";
            if (cStr.endsWith(".0")) {
                cStr = cStr.substring(0, cStr.length() - 3);
            } else {
                cStr = cStr.substring(0, cStr.length() - 1);
            }
            if (cStr.equals("")) {
                cStr = "0";
            }
            return Double.parseDouble(cStr);
        }

    }));

    controls.setWidget(4, 1, new ControlButton(this, new ControlAction(this, "clear") {
        @Override
        public boolean isMultiArg() {
            return false;
        }

        @Override
        public double performAction(ControlAction lastAction, double previous, double current) {
            return 0;
        }
    }));

    dockPanel.add(numbersP, DockPanel.CENTER);
    dockPanel.add(controls, DockPanel.EAST);

    inputBox = new TextBox();
    inputBox.addStyleName("ResultBox");
    dockPanel.add(inputBox, DockPanel.NORTH);

    ticker = new TextArea();
    ticker.setSize("7em", "140px");

    MultiWordSuggestOracle oracle = new MultiWordSuggestOracle();
    oracle.add("Jill");
    oracle.add("Jeff");
    oracle.add("James");
    oracle.add("Jennifer");

    SuggestBox box = new SuggestBox(oracle);
    box.addEventHandler(new SuggestionHandler() {
        public void onSuggestionSelected(SuggestionEvent suggE) {
            String selected = suggE.getSelectedSuggestion().getReplacementString();
            // do something with selected suggestion
        }
    });

    dockPanel.add(box, DockPanel.SOUTH);

    HorizontalPanel mainP = new HorizontalPanel();
    mainP.add(dockPanel);
    mainP.add(ticker);

    initWidget(mainP);

    setResult(0);

}

From source file:com.audata.client.admin.SetPasswordDialog.java

License:Open Source License

public SetPasswordDialog(UserPanel parent) {
    this.setText(LANG.set_password_Text());

    DockPanel outer = new DockPanel();
    outer.setSpacing(4);//from   w  ww .  j  a  v a  2 s  .  c om

    outer.add(new Image("images/48x48/security.gif"), DockPanel.WEST);

    VerticalPanel formPanel = new VerticalPanel();

    HorizontalPanel pass1Panel = new HorizontalPanel();
    Label l1 = new Label(LANG.password_Text());
    l1.addStyleName("audoc-label");
    l1.setWidth("120px");

    pass1Panel.add(l1);
    this.pass1 = new PasswordTextBox();
    pass1Panel.add(this.pass1);
    formPanel.add(pass1Panel);

    HorizontalPanel pass2Panel = new HorizontalPanel();

    Label l2 = new Label(LANG.password_reenter_Text());
    l2.addStyleName("audoc-label");
    l2.setWidth("120px");
    pass2Panel.add(l2);
    this.pass2 = new PasswordTextBox();
    pass2Panel.add(this.pass2);
    formPanel.add(pass2Panel);

    HorizontalPanel buttonPanel = new HorizontalPanel();
    buttonPanel.setSpacing(5);

    this.setButton = new Button(LANG.set_password_Text());
    this.setButton.addClickListener(this);
    buttonPanel.add(this.setButton);

    this.cancelButton = new Button(LANG.cancel_Text());
    this.cancelButton.addClickListener(this);
    buttonPanel.add(this.cancelButton);

    formPanel.add(buttonPanel);
    formPanel.setCellHorizontalAlignment(buttonPanel, HasHorizontalAlignment.ALIGN_RIGHT);

    outer.add(formPanel, DockPanel.SOUTH);
    formPanel.setSpacing(4);
    outer.setSpacing(8);
    setWidget(outer);
}

From source file:com.audata.client.authentication.LoginDialog.java

License:Open Source License

public LoginDialog(AuDoc parent) {
    this.parent = parent;
    setText(CONSTANTS.welcome_Text());

    // Create a DockPanel to contain the 'about' label and the 'OK' button.
    DockPanel outer = new DockPanel();
    outer.setSpacing(4);/*w  w  w .  ja  va  2 s .  com*/

    outer.add(new Image("images/48x48/security.gif"), DockPanel.WEST);

    VerticalPanel formPanel = new VerticalPanel();
    formPanel.setSpacing(1);

    HorizontalPanel userPanel = new HorizontalPanel();
    this.username = new TextBox();
    Label l = new Label(CONSTANTS.username_Text());
    l.addStyleName("audoc-label");
    l.setWidth("85px");
    userPanel.add(l);
    userPanel.add(this.username);
    formPanel.add(userPanel);

    HorizontalPanel passPanel = new HorizontalPanel();
    this.password = new PasswordTextBox();
    l = new Label(CONSTANTS.password_Text());
    l.addStyleName("audoc-label");
    l.setWidth("85px");
    passPanel.add(l);
    passPanel.add(this.password);
    formPanel.add(passPanel);

    HorizontalPanel langPanel = new HorizontalPanel();
    l = new Label(CONSTANTS.lang_Text());
    l.addStyleName("audoc-label");
    l.setWidth("85px");
    langPanel.add(l);
    formPanel.add(langPanel);

    this.languages = new ListBox();
    this.populateLocales();
    this.languages.setWidth("146px");

    langPanel.add(this.languages);

    this.languages.addChangeListener(new ChangeListener() {
        public void onChange(Widget sender) {
            //refreshes the browser in the selected locale
            Location loc = WindowUtils.getLocation();
            String path = loc.getProtocol() + "//" + loc.getHost() + loc.getPath();
            String locale = languages.getValue(languages.getSelectedIndex());
            Window.open(path + "?locale=" + locale, "_self", "");
        }
    });

    this.loginButton = new Button(CONSTANTS.login_Text(), this);
    formPanel.add(loginButton);
    formPanel.setCellHorizontalAlignment(this.loginButton, HasAlignment.ALIGN_RIGHT);
    outer.add(formPanel, DockPanel.SOUTH);

    HTML text = new HTML(CONSTANTS.message_Text());
    text.setStyleName("audoc-LoginDialogText");
    outer.add(text, DockPanel.CENTER);

    // Add a bit of spacing and margin to the dock to keep the components from
    // being placed too closely together.
    outer.setSpacing(8);
    this.setWidget(outer);
}

From source file:com.audata.client.feedback.SimpleDialog.java

License:Open Source License

private SimpleDialog(int type, String title, String message, ResponseListener listener) {
    this.listener = listener;
    this.type = type;
    this.setText(title);
    this.addStyleName("audoc-simpleDialog");

    DockPanel main = new DockPanel();

    main.setSpacing(4);/* w w  w  .jav a  2 s .com*/
    HorizontalPanel butPanel = new HorizontalPanel();
    butPanel.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT);
    butPanel.setSpacing(4);
    switch (type) {
    case SimpleDialog.TYPE_ERROR:
        main.add(new Image("images/48x48/error.gif"), DockPanel.WEST);
        this.close = new Button("Close");
        this.close.addClickListener(this);
        butPanel.add(this.close);
        break;
    case SimpleDialog.TYPE_MESSAGE:
        main.add(new Image("images/48x48/udf.gif"), DockPanel.WEST);
        this.close = new Button("Close");
        this.close.addClickListener(this);
        butPanel.add(this.close);
        break;
    case SimpleDialog.TYPE_QUERY:
        main.add(new Image("images/48x48/help.gif"), DockPanel.WEST);
        this.ok = new Button("Ok");
        this.ok.addClickListener(this);
        this.cancel = new Button("Cancel");
        this.cancel.addClickListener(this);
        butPanel.add(this.ok);
        butPanel.add(this.cancel);
        break;
    }
    VerticalPanel p = new VerticalPanel();
    p.setSpacing(15);
    p.add(new Label(message));
    p.add(butPanel);
    p.setCellHorizontalAlignment(butPanel, HasAlignment.ALIGN_RIGHT);
    main.add(p, DockPanel.EAST);
    this.setWidget(main);
    this.setPopupPosition(0, 0);
}

From source file:com.audata.client.rapidbooking.RapidBookingDialog.java

License:Open Source License

public RapidBookingDialog() {
    setText(CONSTANTS.rapid_title_Text());
    DockPanel outer = new DockPanel();
    outer.setSpacing(4);//from w  w  w.ja  v  a 2s . c o  m

    outer.add(new Image("images/48x48/checkout.gif"), DockPanel.WEST);

    VerticalPanel form = new VerticalPanel();
    form.setSpacing(4);

    this.checkin = new RadioButton("ActionGroup", CONSTANTS.check_in_Text());
    this.checkin.addClickListener(this);
    this.checkin.setChecked(true);
    this.checkin.addStyleName("audoc-label");
    form.add(this.checkin);
    this.checkout = new RadioButton("ActionGroup", CONSTANTS.checkout_Text());
    this.checkout.addClickListener(this);
    this.checkout.addStyleName("audoc-label");
    form.add(this.checkout);

    this.userPanel = new HorizontalPanel();
    Label l = new Label(CONSTANTS.user_Text());
    l.addStyleName("audoc-label");
    userPanel.add(l);
    this.users = new ListBox();
    userPanel.add(this.users);
    userPanel.setCellWidth(l, "100px");
    this.userPanel.setVisible(false);
    form.add(this.userPanel);

    HorizontalPanel recnumPanel = new HorizontalPanel();
    Label r = new Label(CONSTANTS.rec_num_Text());
    r.addStyleName("audoc-label");
    recnumPanel.add(r);
    this.recnum = new TextBox();
    recnumPanel.add(this.recnum);
    recnumPanel.setCellWidth(r, "100px");
    form.add(recnumPanel);

    HorizontalPanel butPanel = new HorizontalPanel();
    butPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
    butPanel.setSpacing(4);
    this.closeButton = new Button(CONSTANTS.close_Text());
    this.closeButton.addClickListener(this);
    butPanel.add(this.closeButton);

    this.okButton = new Button(CONSTANTS.ok_Text());
    this.okButton.addClickListener(this);
    butPanel.add(this.okButton);
    //       butPanel.setWidth("100%");
    form.add(butPanel);

    String template = "<span class=\"rapid_processed\">#0 #1</span>";
    this.processed = new HTMLButtonList("images/16x16/treerec.gif", template, false);
    this.processed.setWidth("100%");
    this.processed.setHeight("75px");
    form.add(this.processed);

    outer.add(form, DockPanel.NORTH);
    if (AuDoc.state.getItem("isAdmin") == "true") {
        this.getUsers();
    } else {
        String username = (String) AuDoc.state.getItem("username");
        String forename = (String) AuDoc.state.getItem("forename");
        String surname = (String) AuDoc.state.getItem("surname");
        this.users.addItem(surname + ", " + forename, username);
    }
    this.setWidget(outer);
}

From source file:com.bramosystems.oss.player.core.client.PlayerUtil.java

License:Apache License

/**
 * Returns a widget that may be used to notify the user when a required plugin
 * is not available.  The widget provides a link to the plugin download page.
 *
 * <h4>CSS Style Rules</h4>// w  w  w.  j  a va 2 s . co m
 * <ul>
 * <li>.player-MissingPlugin { the missing plugin widget }</li>
 * <li>.player-MissingPlugin-title { the title section }</li>
 * <li>.player-MissingPlugin-message { the message section }</li>
 * </ul>
 *
 * @param plugin the missing plugin
 * @param title the title of the message
 * @param message descriptive message to notify user about the missing plugin
 * @param asHTML {@code true} if {@code message} should be interpreted as HTML,
 *          {@code false} otherwise.
 *
 * @return missing plugin widget.
 * @since 0.6
 */
public static Widget getMissingPluginNotice(final Plugin plugin, String title, String message, boolean asHTML) {
    DockPanel dp = new DockPanel() {

        @Override
        public void onBrowserEvent(Event event) {
            super.onBrowserEvent(event);
            switch (event.getTypeInt()) {
            case Event.ONCLICK:
                if (plugin.getDownloadURL().length() > 0) {
                    Window.open(plugin.getDownloadURL(), "dwnload", "");
                }
            }
        }
    };
    dp.setHorizontalAlignment(DockPanel.ALIGN_LEFT);
    dp.sinkEvents(Event.ONCLICK);
    dp.setWidth("200px");

    Label titleLb = null, msgLb = null;
    if (asHTML) {
        titleLb = new HTML(title);
        msgLb = new HTML(message);
    } else {
        titleLb = new Label(title);
        msgLb = new Label(message);
    }

    dp.add(titleLb, DockPanel.NORTH);
    dp.add(msgLb, DockPanel.CENTER);

    titleLb.setStylePrimaryName("player-MissingPlugin-title");
    msgLb.setStylePrimaryName("player-MissingPlugin-message");
    dp.setStylePrimaryName("player-MissingPlugin");

    DOM.setStyleAttribute(dp.getElement(), "cursor", "pointer");
    return dp;
}

From source file:com.bramosystems.oss.player.core.client.skin.CustomPlayerControl.java

License:Apache License

private Widget getPlayerWidget(final UIStyleResource imgPack) {
    imgPack.ensureInjected();//  w w w .j av a2 s  . c  o  m

    seekbar = new CSSSeekBar(5);
    seekbar.setStylePrimaryName(STYLE_NAME);
    seekbar.addStyleDependentName("seekbar");
    seekbar.setWidth("95%");
    seekbar.addSeekChangeHandler(new SeekChangeHandler() {

        @Override
        public void onSeekChanged(SeekChangeEvent event) {
            player.setPlayPosition(event.getSeekPosition() * player.getMediaDuration());
        }
    });

    playTimer = new Timer() {

        @Override
        public void run() {
            updateSeekState();
        }
    };

    play = new CPCButton(imgPack.playDisabled(), new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            switch (playState) {
            case Stop:
            case Pause:
                try { // play media...
                    play.setEnabled(false); // avoid multiple clicks
                    player.playMedia();
                } catch (PlayException ex) {
                    DebugEvent.fire(player, DebugEvent.MessageType.Error, ex.getMessage());
                }
                break;
            case Playing:
                player.pauseMedia();
            }
        }
    });
    play.setStyleName(imgPack.play());
    play.setEnabled(false);

    stop = new CPCButton(imgPack.stopDisabled(), new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            player.stopMedia();
        }
    });
    stop.setStyleName(imgPack.stop());
    stop.setEnabled(false);

    prev = new CPCButton(imgPack.prevDisabled(), new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            if (player instanceof PlaylistSupport) {
                try {
                    ((PlaylistSupport) player).playPrevious();
                } catch (PlayException ex) {
                    next.setEnabled(false);
                    DebugEvent.fire(player, DebugEvent.MessageType.Info, ex.getMessage());
                }
            }
        }
    });
    prev.setStyleName(imgPack.prev());
    prev.setEnabled(false);

    next = new CPCButton(imgPack.nextDisabled(), new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            if (player instanceof PlaylistSupport) {
                try {
                    ((PlaylistSupport) player).playNext();
                } catch (PlayException ex) {
                    next.setEnabled(false);
                    DebugEvent.fire(player, DebugEvent.MessageType.Info, ex.getMessage());
                }
            }
        }
    });
    next.setStyleName(imgPack.next());
    next.setEnabled(false);

    vc = new VolumeControl(5);
    vc.setStyleName(imgPack.volume());
    vc.setPopupStyleName(STYLE_NAME + "-volumeControl");
    vc.addVolumeChangeHandler(new VolumeChangeHandler() {

        @Override
        public void onVolumeChanged(VolumeChangeEvent event) {
            player.setVolume(event.getNewVolume());
        }
    });

    player.addLoadingProgressHandler(new LoadingProgressHandler() {

        @Override
        public void onLoadingProgress(LoadingProgressEvent event) {
            seekbar.setLoadingProgress(event.getProgress());
            vc.setVolume(player.getVolume());
            updateSeekState();
        }
    });
    player.addPlayStateHandler(new PlayStateHandler() {

        @Override
        public void onPlayStateChanged(PlayStateEvent event) {
            int index = event.getItemIndex();
            switch (event.getPlayState()) {
            case Paused:
                toPlayState(PlayState.Pause, imgPack);
                next.setEnabled(index < (((PlaylistSupport) player).getPlaylistSize() - 1));
                prev.setEnabled(index > 0);
                break;
            case Started:
                toPlayState(PlayState.Playing, imgPack);
                next.setEnabled(index < (((PlaylistSupport) player).getPlaylistSize() - 1));
                prev.setEnabled(index > 0);
                break;
            case Stopped:
            case Finished:
                toPlayState(PlayState.Stop, imgPack);
                next.setEnabled(false);
                prev.setEnabled(false);
                break;
            }
        }
    });
    player.addPlayerStateHandler(new PlayerStateHandler() {

        @Override
        public void onPlayerStateChanged(PlayerStateEvent event) {
            switch (event.getPlayerState()) {
            case Ready:
                play.setEnabled(true);
                vc.setVolume(player.getVolume());
            }
        }
    });

    // Time label..
    timeLabel = new Label("--:-- / --:--");
    timeLabel.setWordWrap(false);
    timeLabel.setHorizontalAlignment(Label.ALIGN_CENTER);

    // build the UI...
    DockPanel face = new DockPanel();
    face.setStyleName("");
    face.setVerticalAlignment(DockPanel.ALIGN_MIDDLE);
    face.setSpacing(3);
    face.add(vc, DockPanel.WEST);
    face.add(play, DockPanel.WEST);
    face.add(stop, DockPanel.WEST);
    face.add(prev, DockPanel.WEST);
    face.add(next, DockPanel.WEST);
    face.add(timeLabel, DockPanel.EAST);
    face.add(seekbar, DockPanel.CENTER);

    face.setCellWidth(seekbar, "100%");
    face.setCellHorizontalAlignment(seekbar, DockPanel.ALIGN_CENTER);
    return face;
}

From source file:com.bramosystems.oss.player.provider.sample.client.Capsule.java

License:Apache License

/**
 * Constructs <code>Capsule</code> player to automatically playback the
 * media located at {@code mediaURL}, if {@code autoplay} is {@code true} using
 * the specified {@code plugin}.//w  w w .  j a va  2  s  .com
 *
 * @param plugin plugin to use for playback.
 * @param mediaURL the URL of the media to playback
 * @param autoplay {@code true} to start playing automatically, {@code false} otherwise
 * @param uiResource the CSS resource to use for the UI
 *
 * @throws PluginVersionException if the required plugin version is not installed on the client.
 * @throws PluginNotFoundException if the plugin is not installed on the client.
 *
 * @see Plugin
 * @since 1.2
 */
public Capsule(Plugin plugin, String mediaURL, boolean autoplay, CapsuleUIResource uiResource)
        throws PluginNotFoundException, PluginVersionException, LoadException { // TODO: remove LoadEx on API 2.0.3 release ...
    super(plugin, mediaURL, autoplay, "64px", "100%");
    uiRes = uiResource;
    uiRes.ensureInjected();
    playState = PlayState.Stop;
    mItems = new ArrayList<MediaInfo.MediaInfoKey>();

    progress = new ProgressBar();
    progress.setWidth("95%");

    playTimer = new Timer() {

        @Override
        public void run() {
            progress.setTime(getPlayPosition(), getMediaDuration());
        }
    };
    infoTimer = new Timer() {

        @Override
        public void run() {
            if (mItems.size() > 0) {
                MediaInfo.MediaInfoKey item = mItems.get(infoIndex);
                progress.setInfo(item.toString() + ": " + mInfo.getItem(item));
                infoIndex++;
                infoIndex %= mItems.size();
            } else {
                cancel();
            }
        }

        @Override
        public void cancel() {
            super.cancel();
            progress.setInfo("");
        }
    };

    play = new CButton(uiRes.pauseDisabled(), new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            switch (playState) {
            case Stop:
            case Pause:
                try { // play media...
                    play.setEnabled(false);
                    playMedia();
                } catch (PlayException ex) {
                    fireError(ex.getMessage());
                }
                break;
            case Playing:
                pauseMedia();
            }
        }
    });
    play.setStyleName(uiRes.play());
    play.setEnabled(false);

    stop = new CButton(uiRes.stopDisabled(), new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            stopMedia();
        }
    });
    stop.setStyleName(uiRes.stop());
    stop.setEnabled(false);

    vc = new VolumeControl(5);
    vc.setStyleName(uiRes.volume());
    vc.addVolumeChangeHandler(new VolumeChangeHandler() {

        @Override
        public void onVolumeChanged(VolumeChangeEvent event) {
            setVolume(event.getNewVolume());
        }
    });
    vc.setPopupStyleName("player-Capsule-volumeControl");

    addLoadingProgressHandler(new LoadingProgressHandler() {

        @Override
        public void onLoadingProgress(LoadingProgressEvent event) {
            double prog = event.getProgress();
            progress.setLoadingProgress(prog);
            if (prog == 1.0) {
                progress.setTime(0, getMediaDuration());
                vc.setVolume(getVolume());
            }
        }
    });
    addPlayStateHandler(new PlayStateHandler() {

        @Override
        public void onPlayStateChanged(PlayStateEvent event) {
            switch (event.getPlayState()) {
            case Stopped:
            case Finished:
                toPlayState(PlayState.Stop);
                break;
            case Paused:
                toPlayState(PlayState.Pause);
                break;
            case Started:
                toPlayState(PlayState.Playing);
                break;
            }
        }
    });
    addPlayerStateHandler(new PlayerStateHandler() {

        @Override
        public void onPlayerStateChanged(PlayerStateEvent event) {
            switch (event.getPlayerState()) {
            case BufferingFinished:
            case BufferingStarted:
                break;
            case Ready:
                play.setEnabled(true);
                vc.setVolume(getVolume());
            }
        }
    });

    // build the UI...
    DockPanel main = new DockPanel();
    main.setStyleName("player-Capsule");
    main.setSpacing(0);
    main.setVerticalAlignment(DockPanel.ALIGN_MIDDLE);
    main.setSize("100%", "64px");

    main.add(new CEdge(uiRes.leftEdge()), DockPanel.WEST);
    main.add(play, DockPanel.WEST);
    main.add(stop, DockPanel.WEST);
    main.add(new CEdge(uiRes.rightEdge()), DockPanel.EAST);
    main.add(vc, DockPanel.EAST);
    main.add(progress, DockPanel.CENTER);
    main.setCellWidth(progress, "100%");
    main.setCellHorizontalAlignment(progress, DockPanel.ALIGN_CENTER);
    setPlayerControlWidget(main);
    setWidth("100%");
}

From source file:com.dimdim.conference.ui.common.client.list.ListEntryHoverPopupPanel.java

License:Open Source License

public ListEntryHoverPopupPanel() {
    super(false);
    this.setStyleName("dm-hover-popup");

    //pane.setSize("100%","100%");
    //      pane.addMouseListener(this);
    //      pane.addFocusListener(this);

    DockPanel outer = new DockPanel();
    //      outer.setSize("100%","100%");
    outer.setStyleName("dm-hover-popup-body");
    //      pane.add(outer);

    headerPanel.setStyleName("dm-hover-popup-header");
    outer.add(headerPanel, DockPanel.NORTH);
    outer.setCellWidth(headerPanel, "100%");

    this.contentPanel.setStyleName("dm-hover-popup-content");
    outer.add(contentPanel, DockPanel.NORTH);
    //      outer.setCellWidth(contentPanel,"100%");
    outer.setCellHeight(contentPanel, "100%");

    this.linksPanel.setStyleName("dm-hover-popup-links-panel");
    outer.add(linksPanel, DockPanel.SOUTH);
    //      outer.setCellWidth(contentPanel,"100%");
    outer.setCellHeight(linksPanel, "100%");

    //      this.add(pane);
    this.add(outer);
    this.addPopupListener(this);
}