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

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

Introduction

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

Prototype

public void setHorizontalAlignment(HorizontalAlignmentConstant align) 

Source Link

Document

Sets the default horizontal alignment to be used for widgets added to this panel.

Usage

From source file:com.nitrous.gwt.earth.client.demo.NavigationControlDemo.java

License:Apache License

/**
 * The Google earth API has loaded, start the application
 */// ww w  .jav  a 2s  .com
private void onApiLoaded() {
    // construct the UI widget
    earth = new GoogleEarthWidget();

    // register a listener to be notified when the earth plug-in has loaded
    earth.addPluginReadyListener(new GEPluginReadyListener() {
        public void pluginReady(GEPlugin ge) {
            // show map content once the plugin has loaded
            loadMapContent();
        }

        public void pluginInitFailure() {
            // failure!
            Window.alert("Failed to initialize Google Earth Plug-in");
        }
    });

    Button showButton = new Button("Show");
    showButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            visShow();
        }
    });

    Button autoShowButton = new Button("Auto Show/Hide");
    autoShowButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            visAuto();
        }
    });

    Button hideButton = new Button("Hide");
    hideButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            visHide();
        }
    });

    Button topLeftButton = new Button("TL");
    topLeftButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            posTopLeft();
        }
    });

    Button topRightButton = new Button("TR");
    topRightButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            posTopRight();
        }
    });

    Button bottomLeftButton = new Button("BL");
    bottomLeftButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            posBottomLeft();
        }
    });

    Button bottomRightButton = new Button("BR");
    bottomRightButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            posBottomRight();
        }
    });

    VerticalPanel topPanel = new VerticalPanel();
    topPanel.setWidth("100%");
    topPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);

    HorizontalPanel navLabelPanel = new HorizontalPanel();
    navLabelPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    navLabelPanel.add(new Label("Navigation Control Visibility"));
    topPanel.add(navLabelPanel);

    HorizontalPanel navButtonPanel = new HorizontalPanel();
    navButtonPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    navButtonPanel.add(showButton);
    navButtonPanel.add(autoShowButton);
    navButtonPanel.add(hideButton);
    topPanel.add(navButtonPanel);

    HorizontalPanel positionLabelPanel = new HorizontalPanel();
    positionLabelPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    positionLabelPanel.add(new Label("Position"));
    topPanel.add(positionLabelPanel);

    HorizontalPanel topPositionButtonPanel = new HorizontalPanel();
    topPositionButtonPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    topPositionButtonPanel.add(topLeftButton);
    topPositionButtonPanel.add(topRightButton);
    topPanel.add(topPositionButtonPanel);

    HorizontalPanel bottomPositionButtonPanel = new HorizontalPanel();
    bottomPositionButtonPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    bottomPositionButtonPanel.add(bottomLeftButton);
    bottomPositionButtonPanel.add(bottomRightButton);
    topPanel.add(bottomPositionButtonPanel);

    DockLayoutPanel layout = new DockLayoutPanel(Unit.PX);
    layout.addNorth(topPanel, 135D);
    layout.add(earth);
    RootLayoutPanel.get().add(layout);

    // begin loading the Google Earth Plug-in
    earth.init();
}

From source file:com.nitrous.gwt.earth.client.demo.NetworkLinkDemo.java

License:Apache License

/**
 * The Google earth API has loaded, start the application
 *//*from  w  w  w .  jav a 2  s .c o m*/
private void onApiLoaded() {
    // construct the UI widget
    earth = new GoogleEarthWidget();

    // register a listener to be notified when the earth plug-in has loaded
    earth.addPluginReadyListener(new GEPluginReadyListener() {
        public void pluginReady(GEPlugin ge) {
            // show map content once the plugin has loaded
            loadMapContent();
        }

        public void pluginInitFailure() {
            // failure!
            Window.alert("Failed to initialize Google Earth Plug-in");
        }
    });

    Button createButton = new Button("Create a Network Link!");
    createButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            createNetworkLink();
        }
    });
    HorizontalPanel buttons = new HorizontalPanel();
    buttons.add(createButton);

    HorizontalPanel topPanel = new HorizontalPanel();
    topPanel.setWidth("100%");
    topPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    topPanel.add(buttons);

    DockLayoutPanel layout = new DockLayoutPanel(Unit.PX);
    layout.addNorth(topPanel, 40D);
    layout.add(earth);
    RootLayoutPanel.get().add(layout);

    // begin loading the Google Earth Plug-in
    earth.init();
}

From source file:com.nitrous.gwt.earth.client.demo.ParseKmlInteractive.java

License:Apache License

/**
 * The Google earth API has loaded, start the application
 *///from  w  w  w.ja va2  s  .c  om
private void onApiLoaded() {
    // construct the UI widget
    earth = new GoogleEarthWidget();

    // register a listener to be notified when the earth plug-in has loaded
    earth.addPluginReadyListener(new GEPluginReadyListener() {
        public void pluginReady(GEPlugin ge) {
            // show map content once the plugin has loaded
            loadMapContent();
        }

        public void pluginInitFailure() {
            // failure!
            Window.alert("Failed to initialize Google Earth Plug-in");
        }
    });

    kmlBox = new TextArea();
    kmlBox.getElement().setAttribute("rows", "10");
    kmlBox.getElement().setAttribute("cols", "70");
    kmlBox.getElement().setAttribute("wrap", "off");
    kmlBox.getElement().setAttribute("style", "font-family: monospace; font-size: small");
    kmlBox.setValue(
            "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<kml xmlns=\"http://www.opengis.net/kml/2.2\">\n"
                    + "  <Placemark>\n" + "    <name>Test Placemark</name>\n" + "    <Point>\n"
                    + "      <coordinates>\n" + "        -122,37,0\n" + "      </coordinates>\n"
                    + "    </Point>\n" + "  </Placemark>\n" + "</kml>");

    Button parseKmlButton = new Button("Parse and Add this KML!");
    parseKmlButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            parseKmlFromTextArea();
        }
    });

    HorizontalPanel textPanel = new HorizontalPanel();
    textPanel.setSpacing(5);
    textPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    textPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
    textPanel.add(kmlBox);
    textPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    textPanel.add(parseKmlButton);

    DockLayoutPanel layout = new DockLayoutPanel(Unit.PX);
    layout.addNorth(textPanel, 220);
    layout.add(earth);
    // add the widget to the DOM
    RootLayoutPanel.get().add(layout);

    // begin loading the Google Earth Plug-in
    earth.init();
}

From source file:com.nitrous.gwt.earth.client.demo.PlacemarkStyleMapDemo.java

License:Apache License

/**
 * The Google earth API has loaded, start the application
 *///from   www. j a  v a 2 s  .co  m
private void onApiLoaded() {
    // construct the UI widget
    earth = new GoogleEarthWidget();

    // register a listener to be notified when the earth plug-in has loaded
    earth.addPluginReadyListener(new GEPluginReadyListener() {
        public void pluginReady(GEPlugin ge) {
            // show map content once the plugin has loaded
            loadMapContent();
        }

        public void pluginInitFailure() {
            // failure!
            Window.alert("Failed to initialize Google Earth Plug-in");
        }
    });

    Button applyStyleButton = new Button("Give the Placemark a StyleMap!");
    applyStyleButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            Scheduler.get().scheduleDeferred(new ScheduledCommand() {
                @Override
                public void execute() {
                    onButtonClick();
                }
            });
        }
    });
    HorizontalPanel buttons = new HorizontalPanel();
    buttons.add(applyStyleButton);

    HorizontalPanel topPanel = new HorizontalPanel();
    topPanel.setWidth("100%");
    topPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    topPanel.add(buttons);

    DockLayoutPanel layout = new DockLayoutPanel(Unit.PX);
    layout.addNorth(topPanel, 40D);
    layout.add(earth);
    RootLayoutPanel.get().add(layout);

    // begin loading the Google Earth Plug-in
    earth.init();
}

From source file:com.nitrous.gwt.earth.client.demo.SkyModeDemo.java

License:Apache License

/**
 * The Google earth API has loaded, start the application
 *///from   w  w  w .j  a  v  a  2s  .c o m
private void onApiLoaded() {
    // construct the UI widget
    earth = new GoogleEarthWidget();

    // register a listener to be notified when the earth plug-in has loaded
    earth.addPluginReadyListener(new GEPluginReadyListener() {
        public void pluginReady(GEPlugin ge) {
            // show map content once the plugin has loaded
            loadMapContent();
        }

        public void pluginInitFailure() {
            // failure!
            Window.alert("Failed to initialize Google Earth Plug-in");
        }
    });

    Button skyButton = new Button("Switch to Sky");
    skyButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            showSky();
        }
    });
    Button earthButton = new Button("Switch to Earth");
    earthButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            showEarth();
        }
    });

    HorizontalPanel topPanel = new HorizontalPanel();
    topPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    topPanel.add(skyButton);
    topPanel.add(earthButton);

    DockLayoutPanel layout = new DockLayoutPanel(Unit.PX);
    layout.addNorth(topPanel, 30D);
    layout.add(earth);
    RootLayoutPanel.get().add(layout);

    // begin loading the Google Earth Plug-in
    earth.init();
}

From source file:com.nitrous.gwt.earth.client.demo.TerrainDemo.java

License:Apache License

/**
 * The Google earth API has loaded, start the application
 *//* w  w w.  j  a va 2 s.  c  o  m*/
private void onApiLoaded() {
    // construct the UI widget
    earth = new GoogleEarthWidget();

    // register a listener to be notified when the earth plug-in has loaded
    earth.addPluginReadyListener(new GEPluginReadyListener() {
        public void pluginReady(GEPlugin ge) {
            // show map content once the plugin has loaded
            loadMapContent();
        }

        public void pluginInitFailure() {
            // failure!
            Window.alert("Failed to initialize Google Earth Plug-in");
        }
    });

    Button showButton = new Button("Show Terrain");
    showButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            showTerrain();
        }
    });

    Button hideButton = new Button("Hide Terrain");
    hideButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            hideTerrain();
        }
    });

    HorizontalPanel topPanel = new HorizontalPanel();
    topPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    topPanel.add(showButton);
    topPanel.add(hideButton);

    DockLayoutPanel layout = new DockLayoutPanel(Unit.PX);
    layout.addNorth(topPanel, 30D);
    layout.add(earth);
    RootLayoutPanel.get().add(layout);

    // begin loading the Google Earth Plug-in
    earth.init();
}

From source file:com.nitrous.gwt.earth.client.demo.ToggleEventListenerDemo.java

License:Apache License

/**
 * The Google earth API has loaded, start the application
 *///  ww w . j a  v a 2  s. co m
private void onApiLoaded() {
    // construct the UI widget
    earth = new GoogleEarthWidget();

    // register a listener to be notified when the earth plug-in has loaded
    earth.addPluginReadyListener(new GEPluginReadyListener() {
        public void pluginReady(GEPlugin ge) {
            // show map content once the plugin has loaded
            loadMapContent();
        }

        public void pluginInitFailure() {
            // failure!
            Window.alert("Failed to initialize Google Earth Plug-in");
        }
    });

    Button enableButton = new Button("Enable Click Listener");
    enableButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            enableListener();
        }
    });
    Button disableButton = new Button("Disable Click Listener");
    disableButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            disableListener();
        }
    });

    HorizontalPanel buttons = new HorizontalPanel();
    buttons.add(enableButton);
    buttons.add(disableButton);

    HorizontalPanel topPanel = new HorizontalPanel();
    topPanel.setWidth("100%");
    topPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    topPanel.add(buttons);

    DockLayoutPanel layout = new DockLayoutPanel(Unit.PX);
    layout.addNorth(topPanel, 40D);
    layout.add(earth);
    RootLayoutPanel.get().add(layout);

    // begin loading the Google Earth Plug-in
    earth.init();
}

From source file:com.nitrous.gwt.earth.client.demo.ViewChangeDemo.java

License:Apache License

/**
 * The Google earth API has loaded, start the application
 *///from w w w  .  j  a va  2 s . c  o m
private void onApiLoaded() {
    // construct the UI widget
    earth = new GoogleEarthWidget();

    // register a listener to be notified when the earth plug-in has loaded
    earth.addPluginReadyListener(new GEPluginReadyListener() {
        public void pluginReady(GEPlugin ge) {
            // show map content once the plugin has loaded
            loadMapContent();
        }

        public void pluginInitFailure() {
            // failure!
            Window.alert("Failed to initialize Google Earth Plug-in");
        }
    });

    VerticalPanel labels = new VerticalPanel();
    viewChangeEndCountLabel = new Label(CHANGE_END_TEXT + 0);
    viewChangedLabel = new Label("View Changed!");
    labels.add(viewChangeEndCountLabel);
    labels.add(viewChangedLabel);

    HorizontalPanel topPanel = new HorizontalPanel();
    topPanel.setWidth("100%");
    topPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    topPanel.add(labels);

    DockLayoutPanel layout = new DockLayoutPanel(Unit.PX);
    layout.addNorth(topPanel, 40D);
    layout.add(earth);
    RootLayoutPanel.get().add(layout);

    viewChangedLabel.getElement().setAttribute("style",
            "background-color: #a00; color: #fff; font-weight: bold;");
    viewChangedLabel.setVisible(false);

    // begin loading the Google Earth Plug-in
    earth.init();
}

From source file:com.qut.middleware.esoemanager.client.ui.nodes.NodeUI.java

License:Apache License

public void createInterface() {
    this.addStyleName(CSSConstants.esoeManagerNode);
    this.content = new VerticalPanel();

    HorizontalPanel banner = new HorizontalPanel();
    banner.addStyleName(CSSConstants.esoeManagerNodeBanner);
    banner.setSpacing(5);//  w  w w  . java 2 s  .  co m

    final HorizontalPanel subBanner = new HorizontalPanel();
    subBanner.addStyleName(CSSConstants.esoeManagerNodeSubBanner);
    subBanner.setSpacing(5);

    StyledButton showContent = new StyledButton("application", "");
    showContent.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            content.setVisible(!content.isVisible());
        }
    });

    banner.add(showContent);
    banner.add(new Label("Node - "));
    try {
        banner.add(new Label(this.nodeURL.getText()));
    } catch (InvalidContentException e) {
    }

    this.save = new ConfirmationStyledButton("Save node changes?", "save", "Save");
    this.save.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            try {
                EsoeManager.contentService.saveServiceNodeConfiguration(serviceIdentifier, getNodeIdentifier(),
                        getNodeURL(), getNodeACS(), getNodeSLS(), getNodeCCS(),
                        new ConfigChangeHandler(NodeUI.this.loader));
            } catch (InvalidContentException e) {
            }
        }
    });

    subBanner.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
    subBanner.add(this.save);

    this.toggleState = new ConfirmationStyledButton("Change node state?", "toggle", "");
    this.toggleState.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {

            if (NodeUI.this.isActive())
                EsoeManager.contentService.toggleServiceNodeState(NodeUI.this.serviceIdentifier,
                        getNodeIdentifier(), true, new StateHandler(NodeUI.this.loader));
            else
                EsoeManager.contentService.toggleServiceNodeState(NodeUI.this.serviceIdentifier,
                        getNodeIdentifier(), false, new StateHandler(NodeUI.this.loader));
        }
    });

    FlexibleTable layout = new FlexibleTable(5, 5);

    layout.insertWidget(this.nodeIdentifier.getTitle());
    layout.insertWidget(this.nodeIdentifier.getContent());
    layout.nextRow();

    layout.insertWidget(this.nodeURL.getTitle());
    layout.insertWidget(this.nodeURL.getContent());
    layout.nextRow();

    Label stateLbl = new Label("Active State");
    stateLbl.addStyleName(CSSConstants.serviceValueTitle);
    layout.insertWidget(stateLbl);

    HorizontalPanel statePanel = new HorizontalPanel();
    statePanel.setSpacing(5);
    statePanel.add(this.state);
    statePanel.add(this.toggleState);
    layout.insertWidget(statePanel);
    layout.nextRow();

    layout.insertWidget(this.nodeACS.getTitle());
    layout.insertWidget(this.nodeACS.getContent());
    layout.nextRow();

    layout.insertWidget(this.nodeSLS.getTitle());
    layout.insertWidget(this.nodeSLS.getContent());
    layout.nextRow();

    layout.insertWidget(this.nodeCCS.getTitle());
    layout.insertWidget(this.nodeCCS.getContent());
    layout.nextRow();

    this.content.add(subBanner);
    this.content.add(layout);
    this.content.setVisible(false);

    this.add(banner);
    this.add(this.content);
}

From source file:com.qut.middleware.esoemanager.client.ui.policy.RuleUI.java

License:Apache License

public void createContentInterface() {
    this.addStyleName(CSSConstants.esoeManagerPolicyRule);

    this.content = new VerticalPanel();
    this.content.addStyleName(CSSConstants.esoeManagerPolicyRuleContent);

    this.id = new HiddenIntegratedTextBox(this, 1, null, "Rules are required to have an ID", "ID",
            EsoeManagerConstants.areaID);
    this.desc = new HiddenIntegratedTextBox(this, 1, null, "Rules are required to have a description",
            "Description", EsoeManagerConstants.areaID);
    StyledButton showContent = new StyledButton("application", "");
    showContent.addClickListener(new ClickListener() {

        public void onClick(Widget sender) {

            // toggle content visibility
            content.setVisible(!content.isVisible());
        }/*from   w  w w.j av  a 2 s .co  m*/
    });

    ConfirmationStyledButton removeRule = new ConfirmationStyledButton("Really delete this rule?", "delete",
            "Delete");
    removeRule.addClickListener(new ClickListener() {

        public void onClick(Widget sender) {

            // toggle content visibility
            parent.deleteRule(RuleUI.this);
        }
    });

    HorizontalPanel banner = new HorizontalPanel();
    banner.addStyleName(CSSConstants.esoeManagerPolicyBanner);
    banner.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    HorizontalPanel bannerTitle = new HorizontalPanel();
    bannerTitle.addStyleName(CSSConstants.esoeManagerPolicyBannerTitle);
    bannerTitle.setSpacing(5);
    bannerTitle.add(showContent);
    bannerTitle.add(new Label("Rule"));
    banner.add(bannerTitle);

    banner.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
    HorizontalPanel bannerButtons = new HorizontalPanel();
    bannerButtons.setSpacing(5);
    bannerButtons.add(removeRule);
    banner.add(bannerButtons);

    FlexibleTable heading = new FlexibleTable(2, 2);
    heading.nextRow();
    heading.insertWidget(this.id.getTitle());
    heading.insertWidget(this.id.getContent());
    heading.nextRow();
    heading.insertWidget(this.desc.getTitle());
    heading.insertWidget(this.desc.getContent());

    if (this.newRule) {
        this.id.showEditor();
        this.desc.showEditor();
    }

    this.localMessages = new MessagePanel();
    this.effect = new EffectUI();
    this.actions = new ActionsUI();
    if (this.newRule)
        this.actions.addValue();

    this.resources = new ResourcesUI();
    if (this.newRule)
        this.resources.addValue();

    this.condition = new ConditionUI(this, null, this.newRule, true);

    this.content.add(this.localMessages);
    this.content.add(this.effect);
    this.content.add(this.resources.getContent());
    this.content.add(this.actions.getContent());

    this.content.add(this.condition);

    if (!this.newRule)
        this.content.setVisible(false);

    this.add(banner);
    this.add(heading);
    this.add(this.content);
}