List of usage examples for com.google.gwt.user.client.ui DockPanel setHorizontalAlignment
public void setHorizontalAlignment(HorizontalAlignmentConstant align)
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>//from w ww . ja v a 2 s .c o 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.google.appinventor.client.editor.youngandroid.YaFormEditor.java
License:Open Source License
/** * Creates a new YaFormEditor.//from w w w. ja v a 2 s . co m * * @param projectEditor the project editor that contains this file editor * @param formNode the YoungAndroidFormNode associated with this YaFormEditor */ YaFormEditor(ProjectEditor projectEditor, YoungAndroidFormNode formNode) { super(projectEditor, formNode); this.formNode = formNode; COMPONENT_DATABASE = SimpleComponentDatabase.getInstance(getProjectId()); // Get reference to the source structure explorer sourceStructureExplorer = SourceStructureBox.getSourceStructureBox().getSourceStructureExplorer(); // Create UI elements for the designer panels. nonVisibleComponentsPanel = new SimpleNonVisibleComponentsPanel(); visibleComponentsPanel = new SimpleVisibleComponentsPanel(this, nonVisibleComponentsPanel); DockPanel componentsPanel = new DockPanel(); componentsPanel.setHorizontalAlignment(DockPanel.ALIGN_CENTER); componentsPanel.add(visibleComponentsPanel, DockPanel.NORTH); componentsPanel.add(nonVisibleComponentsPanel, DockPanel.SOUTH); componentsPanel.setSize("100%", "100%"); // Create palettePanel, which will be used as the content of the PaletteBox. palettePanel = new YoungAndroidPalettePanel(this); palettePanel.loadComponents(new DropTargetProvider() { @Override public DropTarget[] getDropTargets() { // TODO(markf): Figure out a good way to memorize the targets or refactor things so that // getDropTargets() doesn't get called for each component. // NOTE: These targets must be specified in depth-first order. List<DropTarget> dropTargets = form.getDropTargetsWithin(); dropTargets.add(visibleComponentsPanel); dropTargets.add(nonVisibleComponentsPanel); return dropTargets.toArray(new DropTarget[dropTargets.size()]); } }); palettePanel.setSize("100%", "100%"); addComponentDatabaseChangeListener(palettePanel); // Create designProperties, which will be used as the content of the PropertiesBox. designProperties = new PropertiesPanel(); designProperties.setSize("100%", "100%"); initWidget(componentsPanel); setSize("100%", "100%"); }
From source file:com.google.gwt.sample.kitchensink.client.Layouts.java
License:Apache License
public Layouts() { HTML contents = new HTML("This is a <code>ScrollPanel</code> contained at " + "the center of a <code>DockPanel</code>. " + "By putting some fairly large contents " + "in the middle and setting its size explicitly, it becomes a " + "scrollable area within the page, but without requiring the use of " + "an IFRAME." + "Here's quite a bit more meaningless text that will serve primarily " + "to make this thing scroll off the bottom of its visible area. " + "Otherwise, you might have to make it really, really small in order " + "to see the nifty scroll bars!"); ScrollPanel scroller = new ScrollPanel(contents); scroller.setStyleName("ks-layouts-Scroller"); DockPanel dock = new DockPanel(); dock.setHorizontalAlignment(DockPanel.ALIGN_CENTER); HTML north0 = new HTML("This is the <i>first</i> north component", true); HTML east = new HTML("<center>This<br>is<br>the<br>east<br>component</center>", true); HTML south = new HTML("This is the south component"); HTML west = new HTML("<center>This<br>is<br>the<br>west<br>component</center>", true); HTML north1 = new HTML("This is the <b>second</b> north component", true); dock.add(north0, DockPanel.NORTH);//w w w .java2s . c o m dock.add(east, DockPanel.EAST); dock.add(south, DockPanel.SOUTH); dock.add(west, DockPanel.WEST); dock.add(north1, DockPanel.NORTH); dock.add(scroller, DockPanel.CENTER); FlowPanel flow = new FlowPanel(); for (int i = 0; i < 8; ++i) flow.add(new CheckBox("Flow " + i)); HorizontalPanel horz = new HorizontalPanel(); horz.setVerticalAlignment(VerticalPanel.ALIGN_MIDDLE); horz.add(new Button("Button")); horz.add(new HTML("<center>This is a<br>very<br>tall thing</center>", true)); horz.add(new Button("Button")); VerticalPanel vert = new VerticalPanel(); vert.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER); vert.add(new Button("Small")); vert.add(new Button("--- BigBigBigBig ---")); vert.add(new Button("tiny")); MenuBar menu = new MenuBar(); MenuBar menu0 = new MenuBar(true), menu1 = new MenuBar(true); menu.addItem("menu0", menu0); menu.addItem("menu1", menu1); menu0.addItem("child00", (Command) null); menu0.addItem("child01", (Command) null); menu0.addItem("child02", (Command) null); menu1.addItem("child10", (Command) null); menu1.addItem("child11", (Command) null); menu1.addItem("child12", (Command) null); String id = HTMLPanel.createUniqueId(); HTMLPanel html = new HTMLPanel("This is an <code>HTMLPanel</code>. It allows you to add " + "components inside existing HTML, like this:" + "<span id='" + id + "'></span>" + "Notice how the menu just fits snugly in there? Cute."); DOM.setStyleAttribute(menu.getElement(), "display", "inline"); html.add(menu, id); VerticalPanel panel = new VerticalPanel(); panel.setSpacing(8); panel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER); panel.add(makeLabel("Dock Panel")); panel.add(dock); panel.add(makeLabel("Flow Panel")); panel.add(flow); panel.add(makeLabel("Horizontal Panel")); panel.add(horz); panel.add(makeLabel("Vertical Panel")); panel.add(vert); panel.add(makeLabel("HTML Panel")); panel.add(html); initWidget(panel); setStyleName("ks-layouts"); }
From source file:com.google.gwt.sample.showcase.client.content.panels.CwDockPanel.java
License:Apache License
/** * Initialize this example./*from www. j av a 2 s. c o m*/ */ @ShowcaseSource @Override public Widget onInitialize() { // Create a Dock Panel DockPanel dock = new DockPanel(); dock.setStyleName("cw-DockPanel"); dock.setSpacing(4); dock.setHorizontalAlignment(DockPanel.ALIGN_CENTER); // Add text all around dock.add(new HTML(constants.cwDockPanelNorth1()), DockPanel.NORTH); dock.add(new HTML(constants.cwDockPanelSouth1()), DockPanel.SOUTH); dock.add(new HTML(constants.cwDockPanelEast()), DockPanel.EAST); dock.add(new HTML(constants.cwDockPanelWest()), DockPanel.WEST); dock.add(new HTML(constants.cwDockPanelNorth2()), DockPanel.NORTH); dock.add(new HTML(constants.cwDockPanelSouth2()), DockPanel.SOUTH); // Add scrollable text in the center HTML contents = new HTML(constants.cwDockPanelCenter()); ScrollPanel scroller = new ScrollPanel(contents); scroller.setSize("400px", "100px"); dock.add(scroller, DockPanel.CENTER); // Return the content dock.ensureDebugId("cwDockPanel"); return dock; }
From source file:com.qualogy.qafe.gwt.client.ui.renderer.PanelRenderer.java
License:Apache License
public UIObject render(ComponentGVO component, String uuid, String parent, String context) { UIObject panel = null;//from ww w. j av a 2 s . co m if (component != null) { if (component instanceof PanelGVO) { final ComponentGVO finalComponentGVO = component; final String finalUuid = uuid; final String finalParent = parent; final PanelGVO root = (PanelGVO) component; LayoutGVO layout = root.getLayout(); if (layout instanceof AutoLayoutGVO) { if (root.getMenu() != null && !(component instanceof RootPanelGVO)) { panel = new FlexTable() { @Override public void onBrowserEvent(Event event) { if (event.getTypeInt() == Event.ONCONTEXTMENU) { DOM.eventPreventDefault(event); applyContextMenu(event, finalComponentGVO, finalUuid, finalParent); } super.onBrowserEvent(event); } @Override protected void setElement(Element elem) { super.setElement(elem); sinkEvents(Event.ONCONTEXTMENU); } }; } else { panel = new FlexTable(); } panel.setTitle(component.getTooltip()); AutoLayoutGVO autoLayoutGVO = (AutoLayoutGVO) layout; int columns = autoLayoutGVO.getCols() != null ? autoLayoutGVO.getCols().intValue() : 1; UIObject[] children = renderChildComponents(layout.getComponents(), uuid, parent, context); if (children != null) { int nrOfRows = (children.length / columns) + 1; for (int i = 0; i < nrOfRows; i++) { for (int j = 0; j < columns; j++) { int element = (i * columns) + j; if (element < children.length) { if (children[element] != null) { if (children[element] instanceof Widget) { ((FlexTable) panel).setWidget(i, j, (Widget) children[element]); } } } } } } } else if (layout instanceof AbsoluteLayoutGVO) { AbsoluteLayoutGVO absoluteLayout = (AbsoluteLayoutGVO) layout; if (root.getMenu() != null && !(component instanceof RootPanelGVO)) { panel = new AbsolutePanel() { @Override public void onBrowserEvent(Event event) { if (event.getTypeInt() == Event.ONCONTEXTMENU) { DOM.eventPreventDefault(event); applyContextMenu(event, finalComponentGVO, finalUuid, finalParent); } super.onBrowserEvent(event); } @Override protected void setElement(Element elem) { super.setElement(elem); sinkEvents(Event.ONCONTEXTMENU); } }; } else { panel = new AbsolutePanel(); } AbsolutePanel absolutePanel = (AbsolutePanel) panel; ElementGVO[] elementGVOs = absoluteLayout.getElements(); if (elementGVOs != null) { for (int i = 0; i < elementGVOs.length; i++) { UIObject uiObject = super.renderChildComponent(elementGVOs[i].getComponent(), uuid, parent, context); if (uiObject instanceof Widget) { absolutePanel.add((Widget) uiObject, elementGVOs[i].getX(), elementGVOs[i].getY()); } } } } else if (layout instanceof GridLayoutGVO) { GridLayoutGVO gridLayout = (GridLayoutGVO) layout; if (root.getMenu() != null && !(component instanceof RootPanelGVO)) { panel = new FlexTable() { @Override public void onBrowserEvent(Event event) { if (event.getTypeInt() == Event.ONCONTEXTMENU) { DOM.eventPreventDefault(event); applyContextMenu(event, finalComponentGVO, finalUuid, finalParent); } super.onBrowserEvent(event); } @Override protected void setElement(Element elem) { super.setElement(elem); sinkEvents(Event.ONCONTEXTMENU); } }; } else { panel = new FlexTable(); } ElementGVO[] elementGVOs = gridLayout.getElements(); if (elementGVOs != null) { int maxX = 0; int maxY = 0; for (int i = 0; i < elementGVOs.length; i++) { if (maxX < elementGVOs[i].getX()) { maxX = elementGVOs[i].getX(); } if (maxY < elementGVOs[i].getY()) { maxY = elementGVOs[i].getY(); } } RendererHelper.addMenu(component, panel, uuid, parent); FlexTable flexTable = (FlexTable) panel; flexTable.setTitle(root.getTooltip()); for (int i = 0; i < elementGVOs.length; i++) { UIObject uiObject = super.renderChildComponent(elementGVOs[i].getComponent(), uuid, parent, context); if (uiObject instanceof Widget) { flexTable.setWidget(elementGVOs[i].getY(), elementGVOs[i].getX(), (Widget) uiObject); if (elementGVOs[i].getStyleClass() != null && elementGVOs[i].getStyleClass().length() > 0) { flexTable.getFlexCellFormatter().setStyleName(elementGVOs[i].getY(), elementGVOs[i].getX(), elementGVOs[i].getStyleClass()); } Element gvoElement = flexTable.getFlexCellFormatter() .getElement(elementGVOs[i].getY(), elementGVOs[i].getX()); RendererHelper.setStyleForElement(gvoElement, elementGVOs[i].getStyleProperties()); if (elementGVOs[i].getGridwidth() > 0) { flexTable.getFlexCellFormatter().setColSpan(elementGVOs[i].getY(), elementGVOs[i].getX(), elementGVOs[i].getGridwidth()); } if (elementGVOs[i].getGridheight() > 0) { flexTable.getFlexCellFormatter().setRowSpan(elementGVOs[i].getY(), elementGVOs[i].getX(), elementGVOs[i].getGridheight()); } } } } } else if (layout instanceof HorizontalLayoutGVO) { if (root.getMenu() != null && !(component instanceof RootPanelGVO)) { panel = new HorizontalPanel() { @Override public void onBrowserEvent(Event event) { if (event.getTypeInt() == Event.ONCONTEXTMENU) { DOM.eventPreventDefault(event); applyContextMenu(event, finalComponentGVO, finalUuid, finalParent); } super.onBrowserEvent(event); } @Override protected void setElement(Element elem) { super.setElement(elem); sinkEvents(Event.ONCONTEXTMENU); } }; } else { panel = new HorizontalPanel(); } performCommonTasks(root, panel, uuid, parent); } else if (layout instanceof VerticalLayoutGVO) { if (root.getMenu() != null && !(component instanceof RootPanelGVO)) { panel = new VerticalPanel() { @Override public void onBrowserEvent(Event event) { if (event.getTypeInt() == Event.ONCONTEXTMENU) { DOM.eventPreventDefault(event); applyContextMenu(event, finalComponentGVO, finalUuid, finalParent); } super.onBrowserEvent(event); } @Override protected void setElement(Element elem) { super.setElement(elem); sinkEvents(Event.ONCONTEXTMENU); } }; } else { panel = new VerticalPanel(); } performCommonTasks(root, panel, uuid, parent); } else if (layout instanceof AbsoluteLayoutGVO) { if (root.getMenu() != null && !(component instanceof RootPanelGVO)) { panel = new DockPanel() { @Override public void onBrowserEvent(Event event) { if (event.getTypeInt() == Event.ONCONTEXTMENU) { DOM.eventPreventDefault(event); applyContextMenu(event, finalComponentGVO, finalUuid, finalParent); } super.onBrowserEvent(event); } @Override protected void setElement(Element elem) { super.setElement(elem); sinkEvents(Event.ONCONTEXTMENU); } }; } else { panel = new DockPanel(); } performCommonTasks(root, (Panel) panel, uuid, parent); } else if (layout instanceof BorderLayoutGVO) { if (root.getMenu() != null && !(component instanceof RootPanelGVO)) { panel = new DockPanel() { @Override public void onBrowserEvent(Event event) { if (event.getTypeInt() == Event.ONCONTEXTMENU) { DOM.eventPreventDefault(event); applyContextMenu(event, finalComponentGVO, finalUuid, finalParent); } super.onBrowserEvent(event); } @Override protected void setElement(Element elem) { super.setElement(elem); sinkEvents(Event.ONCONTEXTMENU); } }; } else { panel = new DockPanel(); } DockPanel dockPanel = (DockPanel) panel; dockPanel.setHorizontalAlignment(DockPanel.ALIGN_CENTER); dockPanel.setSpacing(3); BorderLayoutGVO borderLayoutGVO = (BorderLayoutGVO) layout; if (borderLayoutGVO.getNorth() != null) { dockPanel.add( (Widget) renderChildComponent(borderLayoutGVO.getNorth(), uuid, parent, context), DockPanel.NORTH); } if (borderLayoutGVO.getSouth() != null) { dockPanel.add( (Widget) renderChildComponent(borderLayoutGVO.getSouth(), uuid, parent, context), DockPanel.SOUTH); } if (borderLayoutGVO.getEast() != null) { dockPanel.add( (Widget) renderChildComponent(borderLayoutGVO.getEast(), uuid, parent, context), DockPanel.EAST); } if (borderLayoutGVO.getWest() != null) { dockPanel.add( (Widget) renderChildComponent(borderLayoutGVO.getWest(), uuid, parent, context), DockPanel.WEST); } if (borderLayoutGVO.getCenter() != null) { dockPanel.add( (Widget) renderChildComponent(borderLayoutGVO.getCenter(), uuid, parent, context), DockPanel.CENTER); } } if (root.getConcurrentModificationEnabled() && (root.getFieldName() != null) && !root.getFieldName().isEmpty()) { addChecksum(panel); } if (root.getFieldName() != null && root.getFieldName().length() > 0 && root.getShowdatacontrol() != null && root.getShowdatacontrol().booleanValue()) { DockPanel dockPanel = null; if (root.getMenu() != null && !(component instanceof RootPanelGVO)) { dockPanel = new DockPanel() { @Override public void onBrowserEvent(Event event) { if (event.getTypeInt() == Event.ONCONTEXTMENU) { DOM.eventPreventDefault(event); applyContextMenu(event, finalComponentGVO, finalUuid, finalParent); } super.onBrowserEvent(event); } @Override protected void setElement(Element elem) { super.setElement(elem); sinkEvents(Event.ONCONTEXTMENU); } }; } else { dockPanel = new DockPanel(); } dockPanel.add(createDataPanelToolBar(root, uuid, parent), DockPanel.NORTH); dockPanel.add((Widget) panel, DockPanel.NORTH); panel = dockPanel; } if (root.getDisclosure()) { DisclosurePanel disclosurePanel = new DisclosurePanel(root.getTitle()); disclosurePanel.setAnimationEnabled(true); disclosurePanel.add((Widget) panel); panel = disclosurePanel; } else if (root.getTitle() != null && root.getTitle().length() > 0) { CaptionPanel titledPanel = null; if (root.getMenu() != null && !(component instanceof RootPanelGVO)) { titledPanel = new CaptionPanel(root.getTitle()) { @Override public void onBrowserEvent(Event event) { if (event.getTypeInt() == Event.ONCONTEXTMENU) { DOM.eventPreventDefault(event); applyContextMenu(event, finalComponentGVO, finalUuid, finalParent); } super.onBrowserEvent(event); } @Override protected void setElement(Element elem) { super.setElement(elem); sinkEvents(Event.ONCONTEXTMENU); } }; } else { titledPanel = new CaptionPanel(root.getTitle()); } titledPanel.add((Widget) panel); panel = titledPanel; } RendererHelper.fillIn(component, panel, uuid, parent, context); } } return panel; }
From source file:com.sun.labs.aura.music.wsitm.client.Main.java
License:Open Source License
Widget getMainPanel() { DockPanel mainPanel = new DockPanel(); mainPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER); mainPanel.setWidth("95%"); ArrayList<MenuItem> menuItems = new ArrayList<MenuItem>(); contentPanel = new FlowPanel(); Swidget serverInfo = new ServerInfoSwidget(cdm); registerTokenHeaders(serverInfo);/*ww w . j av a 2s. c om*/ cdm.registerSwidget(serverInfo); Swidget userPref = new ProfileSwidget(cdm); registerTokenHeaders(userPref); cdm.registerSwidget(userPref); Swidget dashboard = new DashboardSwidget(cdm); registerTokenHeaders(dashboard); cdm.registerSwidget(dashboard); menuItems.add(dashboard.getMenuItem()); Swidget steeringRec = new SteeringSwidget(cdm); registerTokenHeaders(steeringRec); cdm.registerSwidget(steeringRec); menuItems.add(steeringRec.getMenuItem()); Swidget artistSearch = new SimpleSearchSwidget(cdm); registerTokenHeaders(artistSearch); menuItems.add(artistSearch.getMenuItem()); PageHeaderWidget uP = new PageHeaderWidget(cdm); cdm.registerSwidget(uP); cdm.setWidgets(uP); Swidget homePage = new HomeSwidget(cdm); registerTokenHeaders(homePage); mainPanel.add(uP, DockPanel.NORTH); mainPanel.add(contentPanel, DockPanel.CENTER); uP.setMenuItems(menuItems); VerticalPanel footer = new VerticalPanel(); footer.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER); String disclaimers = "<a href=\"http://www.sun.com/privacy/\">Privacy</a> | " + "<a href=\"http://www.sun.com/termsofuse.html\">Terms of Use</a> | " + "<a href=\"http://www.sun.com/suntrademarks/\"> Trademarks</a> | " + "<a href=\"http://www.tastekeeper.com\"> More Info</a> | " + "<a href=\"mailto:explaura@sun.com\">Contact Us</a>"; footer.add(new HTML( "<br/><hr/><center><div class=\"bottomUrl\">Powered by <a href=\"http://www.sun.com\">Sun Microsystems</a>, " + "<a href=\"http://www.last.fm\">Last.fm</a>, <a href=\"http://www.spotify.com\">Spotify</a>, " + "<a href=\"http://www.wikipedia.org\">Wikipedia</a>, <a href=\"http://www.flickr.com\">Flickr</a>, " + "<a href=\"http://www.youtube.com\">Youtube</a>, <a href=\"http://www.yahoo.com\">Yahoo</a>, " + "<a href=\"http://musicbrainz.org\">Musicbrainz</a>, <a href=\"http://upcoming.yahoo.com\">Upcoming</a>, " + "<a href=\"http://the.echonest.com\">The Echo Nest</a> and <a href=\"http://www.amazon.com\">Amazon</a><br/>" + disclaimers + "<br/>" + "</div></center>")); // if performance monitoring is enabled, add a button to the footer // that will show us the stats if (PerformanceTimer.isEnabled()) { HorizontalPanel hP = new HorizontalPanel(); hP.setSpacing(5); // Add the server info link SpannedLabel perfmon = new SpannedLabel("PerfMon"); perfmon.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent ce) { PerformanceTimer.showPopup(); } }); hP.add(perfmon); // Add the server info link SpannedLabel sI = new SpannedLabel("ServerInfo"); sI.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent ce) { History.newItem("serverinfo:"); } }); hP.add(sI); footer.add(hP); } // // Hack to allow opening the spotify link while preventing losing the GWT state footer.add(new HTML("<iframe name=\"spotifyFrame\" height=\"0px\" frameborder=\"0\" />")); footer.setStyleName("footer"); mainPanel.add(footer, DockPanel.SOUTH); mainPanel.setStyleName("main"); return mainPanel; }
From source file:gate.mimir.gus.client.Application.java
License:Open Source License
/** * Initialisation of the GUI elements and the <code>History</code>. *//*from ww w . jav a 2 s.com*/ public void onModuleLoad() { // initialize the connection with the server gusService = (GusServiceAsync) GWT.create(GusService.class); ServiceDefTarget endpoint = (ServiceDefTarget) gusService; String rpcUrl = GWT.getHostPageBaseURL() + "gusRpc"; endpoint.setServiceEntryPoint(rpcUrl); //create the search box searchBox = new TextArea(); searchBox.setCharacterWidth(60); searchBox.setVisibleLines(5); searchBox.setText(getInputQuery()); //wrap the search box into a suggest box suggestBox = new SuggestBox(new MimirOracle(), searchBox); suggestBox.setTitle("Press Escape to hide suggestions list; press Ctrl+Space to show it again."); RootPanel.get("searchbox").add(suggestBox); suggestBox.addKeyUpHandler(new KeyUpHandler() { @Override public void onKeyUp(KeyUpEvent event) { int keyCode = event.getNativeKeyCode(); if (keyCode == KeyCodes.KEY_ENTER && event.isControlKeyDown()) { // CTRL-ENTER -> fire the query processQuery(searchBox.getText()); } else if (keyCode == KeyCodes.KEY_ESCAPE) { ((SuggestBox.DefaultSuggestionDisplay) suggestBox.getSuggestionDisplay()).hideSuggestions(); } else if (keyCode == ' ' && event.isControlKeyDown()) { // CTRL-Space: show suggestions suggestBox.showSuggestionList(); } if (((SuggestBox.DefaultSuggestionDisplay) suggestBox.getSuggestionDisplay()) .isSuggestionListShowing()) { // gobble up navigation keys if (keyCode == KeyCodes.KEY_UP || keyCode == KeyCodes.KEY_DOWN || keyCode == KeyCodes.KEY_ENTER) { event.stopPropagation(); event.preventDefault(); } } } }); suggestBox.addKeyDownHandler(new KeyDownHandler() { @Override public void onKeyDown(KeyDownEvent event) { int keyCode = event.getNativeKeyCode(); if (((SuggestBox.DefaultSuggestionDisplay) suggestBox.getSuggestionDisplay()) .isSuggestionListShowing()) { // gobble up navigation keys if (keyCode == KeyCodes.KEY_UP || keyCode == KeyCodes.KEY_DOWN || keyCode == KeyCodes.KEY_ENTER) { event.stopPropagation(); event.preventDefault(); } } } }); suggestBox.addKeyPressHandler(new KeyPressHandler() { @Override public void onKeyPress(KeyPressEvent event) { int keyCode = event.getNativeEvent().getKeyCode(); if (((SuggestBox.DefaultSuggestionDisplay) suggestBox.getSuggestionDisplay()) .isSuggestionListShowing()) { // gobble up navigation keys if (keyCode == KeyCodes.KEY_UP || keyCode == KeyCodes.KEY_DOWN || keyCode == KeyCodes.KEY_ENTER) { event.stopPropagation(); event.preventDefault(); } } } }); // suggestBox.addKeyPressHandler(new KeyPressHandler() { // @Override // public void onKeyPress(KeyPressEvent event) { // if(event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ESCAPE) { // ((SuggestBox.DefaultSuggestionDisplay) // suggestBox.getSuggestionDisplay()).hideSuggestions(); // } else if(event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) { // if(event.isControlKeyDown()) { // processQuery(searchBox.getText()); // } else { // // gobble up the event // event.stopPropagation(); // } // } else if(event.getCharCode() == ' ' && event.isControlKeyDown()) { // // CTRL-Space: show suggestions // suggestBox.showSuggestionList(); // } // } // }); Button searchButton = new Button("Search", new ClickHandler() { @Override public void onClick(ClickEvent event) { processQuery(searchBox.getText()); } }); RootPanel.get("searchbutton").add(searchButton); // add a line with statistics for the results in the North panel statisticsLabel = new StatisticsLabel("Results", gusService); RootPanel.get("resultsbar").clear(); RootPanel.get("resultsbar").add(statisticsLabel); statisticsLabel.addResultCountListener(new StatisticsLabel.ResultCountListener() { public void resultCountChanged(int oldCount, int newCount) { numberOfResults = newCount; updateListOfPages(); } }); // dock panel split in North, West, Center, East and South panels DockPanel dockPanel = new DockPanel(); dockPanel.setWidth("100%"); //dockPanel.setSpacing(30); // add a table of results in the Center panel resultsTable = new FlexTable(); resultsTable.setCellPadding(5); resultsTable.setCellSpacing(0); resultsTable.setWidth("100%"); displayMessage("Please enter a query in the text field above and press Enter."); dockPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); dockPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP); dockPanel.add(resultsTable, DockPanel.CENTER); // add the list of pages in the South panel pageListPanel = new HorizontalPanel(); pageListPanel.setSpacing(10); skipLinksPanel = new HorizontalPanel(); skipLinksPanel.setSpacing(10); VerticalPanel paginationPanel = new VerticalPanel(); paginationPanel.setSpacing(5); paginationPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); paginationPanel.add(pageListPanel); paginationPanel.add(skipLinksPanel); dockPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); dockPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_BOTTOM); dockPanel.add(paginationPanel, DockPanel.SOUTH); // make visible the dockPanel and add it to the body of the page RootPanel.get("resultstable").clear(); RootPanel.get("resultstable").add(dockPanel); dockPanel.setVisible(true); // Add a history listener History.newItem("", false); History.addHistoryListener(this); History.fireCurrentHistoryState(); }
From source file:gov.nist.appvet.gwt.client.gui.dialog.AboutDialogBox.java
License:Open Source License
public AboutDialogBox(String version) { super(false, true); setSize("400px", "209px"); setAnimationEnabled(false);//from www . ja va2 s . co m final VerticalPanel dialogVPanel = new VerticalPanel(); dialogVPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); dialogVPanel.addStyleName("dialogVPanel"); dialogVPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); final VerticalPanel verticalPanel = new VerticalPanel(); verticalPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); verticalPanel.setStyleName("insetPanel"); dialogVPanel.add(verticalPanel); dialogVPanel.setCellVerticalAlignment(verticalPanel, HasVerticalAlignment.ALIGN_MIDDLE); dialogVPanel.setCellHorizontalAlignment(verticalPanel, HasHorizontalAlignment.ALIGN_CENTER); dialogVPanel.setCellWidth(verticalPanel, "100%"); verticalPanel.setWidth("350px"); final Image image = new Image("images/appvet_logo.png"); verticalPanel.add(image); verticalPanel.setCellHorizontalAlignment(image, HasHorizontalAlignment.ALIGN_CENTER); image.setSize("192px", "73px"); final String message = "Version " + version; final HorizontalPanel horizontalPanel = new HorizontalPanel(); verticalPanel.add(horizontalPanel); verticalPanel.setCellWidth(horizontalPanel, "100%"); horizontalPanel.setWidth("350px"); messageLabel = new Label(message); horizontalPanel.add(messageLabel); horizontalPanel.setCellHorizontalAlignment(messageLabel, HasHorizontalAlignment.ALIGN_CENTER); horizontalPanel.setCellVerticalAlignment(messageLabel, HasVerticalAlignment.ALIGN_MIDDLE); messageLabel.setStyleName("infoDialogBox"); verticalPanel.setCellVerticalAlignment(messageLabel, HasVerticalAlignment.ALIGN_MIDDLE); verticalPanel.setCellHorizontalAlignment(messageLabel, HasHorizontalAlignment.ALIGN_CENTER); messageLabel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); dialogVPanel.setCellHorizontalAlignment(messageLabel, HasHorizontalAlignment.ALIGN_CENTER); dialogVPanel.setCellVerticalAlignment(messageLabel, HasVerticalAlignment.ALIGN_MIDDLE); messageLabel.setSize("350px", "18px"); final DockPanel dockPanel = new DockPanel(); dockPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); dockPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); dockPanel.add(dialogVPanel, DockPanel.CENTER); dockPanel.setCellVerticalAlignment(dialogVPanel, HasVerticalAlignment.ALIGN_MIDDLE); dockPanel.setCellHorizontalAlignment(dialogVPanel, HasHorizontalAlignment.ALIGN_CENTER); this.setWidget(dockPanel); dockPanel.setSize("372px", "181px"); dialogVPanel.setSize("360px", "125px"); final SimplePanel simplePanel = new SimplePanel(); dockPanel.add(simplePanel, DockPanel.SOUTH); dockPanel.setCellVerticalAlignment(simplePanel, HasVerticalAlignment.ALIGN_MIDDLE); simplePanel.setStyleName("aboutDialogButtonPanel"); dialogVPanel.setCellWidth(simplePanel, "100%"); simplePanel.setWidth("340px"); closeButton = new PushButton("Close"); simplePanel.setWidget(closeButton); dialogVPanel.setCellVerticalAlignment(closeButton, HasVerticalAlignment.ALIGN_MIDDLE); closeButton.setSize("70px", "18px"); dialogVPanel.setCellHorizontalAlignment(closeButton, HasHorizontalAlignment.ALIGN_CENTER); }
From source file:gov.nist.appvet.gwt.client.gui.dialog.UsersDialogBox.java
License:Open Source License
public UsersDialogBox() { super(false, true); setSize("", "450px"); setAnimationEnabled(false);//from w w w. ja v a 2 s.co m usersSelectionModel = new SingleSelectionModel<UserInfoGwt>(); usersSelectionModel.addSelectionChangeHandler(new UserListHandler(this)); final DockPanel dockPanel = new DockPanel(); dockPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); dockPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); setWidget(dockPanel); dockPanel.setSize("", "417px"); final VerticalPanel verticalPanel = new VerticalPanel(); verticalPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); verticalPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); verticalPanel.setStyleName("usersCenterPanel"); dockPanel.add(verticalPanel, DockPanel.CENTER); dockPanel.setCellVerticalAlignment(verticalPanel, HasVerticalAlignment.ALIGN_MIDDLE); dockPanel.setCellHorizontalAlignment(verticalPanel, HasHorizontalAlignment.ALIGN_CENTER); verticalPanel.setSize("", "416px"); final HorizontalPanel horizontalPanel_1 = new HorizontalPanel(); horizontalPanel_1.setStyleName("usersHorizPanel"); horizontalPanel_1.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); horizontalPanel_1.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); verticalPanel.add(horizontalPanel_1); verticalPanel.setCellVerticalAlignment(horizontalPanel_1, HasVerticalAlignment.ALIGN_MIDDLE); verticalPanel.setCellHorizontalAlignment(horizontalPanel_1, HasHorizontalAlignment.ALIGN_CENTER); searchTextBox = new TextBox(); searchTextBox.addKeyDownHandler(new KeyDownHandler() { @Override public void onKeyDown(KeyDownEvent event) { if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) { searchMode = true; search(); } } }); horizontalPanel_1.add(searchTextBox); horizontalPanel_1.setCellVerticalAlignment(searchTextBox, HasVerticalAlignment.ALIGN_MIDDLE); searchTextBox.setSize("260px", "18px"); final PushButton searchButton = new PushButton("Search"); searchButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { } }); searchButton.setHTML("<img width=\"18px\" src=\"images/icon-search.png\" alt=\"search\" />"); searchButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { searchMode = true; search(); } }); horizontalPanel_1.add(searchButton); horizontalPanel_1.setCellVerticalAlignment(searchButton, HasVerticalAlignment.ALIGN_MIDDLE); horizontalPanel_1.setCellHorizontalAlignment(searchButton, HasHorizontalAlignment.ALIGN_CENTER); searchButton.setSize("18px", "18px"); final PushButton viewAllButton = new PushButton("View All"); viewAllButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { searchMode = false; getAllUsers(allUsers); } }); viewAllButton.setHTML("<img width=\"18px\" src=\"images/icon-view-all.png\" alt=\"view-all\" />"); horizontalPanel_1.add(viewAllButton); horizontalPanel_1.setCellHorizontalAlignment(viewAllButton, HasHorizontalAlignment.ALIGN_CENTER); horizontalPanel_1.setCellVerticalAlignment(viewAllButton, HasVerticalAlignment.ALIGN_MIDDLE); viewAllButton.setSize("18px", "18px"); final DockLayoutPanel dockLayoutPanel = new DockLayoutPanel(Unit.EM); dockLayoutPanel.setStyleName("usersDockPanel"); verticalPanel.add(dockLayoutPanel); verticalPanel.setCellVerticalAlignment(dockLayoutPanel, HasVerticalAlignment.ALIGN_MIDDLE); verticalPanel.setCellHorizontalAlignment(dockLayoutPanel, HasHorizontalAlignment.ALIGN_CENTER); dockLayoutPanel.setSize("", "380px"); usersListTable = new UsersListPagingDataGrid<UserInfoGwt>(); usersListTable.dataGrid.setSize("342px", "342px"); usersListTable.dataGrid.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED); usersListTable.dataGrid.setSelectionModel(usersSelectionModel); dockLayoutPanel.add(usersListTable); usersListTable.setWidth(""); final HorizontalPanel horizontalPanel_2 = new HorizontalPanel(); horizontalPanel_2.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); horizontalPanel_2.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); horizontalPanel_2.setStyleName("buttonPanel"); verticalPanel.add(horizontalPanel_2); verticalPanel.setCellVerticalAlignment(horizontalPanel_2, HasVerticalAlignment.ALIGN_MIDDLE); verticalPanel.setCellHorizontalAlignment(horizontalPanel_2, HasHorizontalAlignment.ALIGN_CENTER); addButton = new PushButton("Add"); addButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { editUser(true); } }); addButton.setHTML("Add"); horizontalPanel_2.add(addButton); horizontalPanel_2.setCellHorizontalAlignment(addButton, HasHorizontalAlignment.ALIGN_CENTER); horizontalPanel_2.setCellVerticalAlignment(addButton, HasVerticalAlignment.ALIGN_MIDDLE); addButton.setSize("70px", "18px"); final PushButton editButton = new PushButton("Edit"); editButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { editUser(false); } }); final PushButton pshbtnNewButton = new PushButton("Delete"); pshbtnNewButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { final UserInfoGwt selected = usersSelectionModel.getSelectedObject(); final DeleteUserConfirmDialogBox deleteConfirmDialogBox = new DeleteUserConfirmDialogBox( selected.getUserName()); deleteConfirmDialogBox.setText("Confirm Delete"); deleteConfirmDialogBox.center(); deleteConfirmDialogBox.cancelButton.setFocus(true); deleteConfirmDialogBox.cancelButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { killDialogBox(deleteConfirmDialogBox); return; } }); deleteConfirmDialogBox.okButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { killDialogBox(deleteConfirmDialogBox); if (selected != null) { deleteUser(user.getUserName()); } } }); } }); pshbtnNewButton.setHTML("Delete"); horizontalPanel_2.add(pshbtnNewButton); horizontalPanel_2.setCellVerticalAlignment(pshbtnNewButton, HasVerticalAlignment.ALIGN_MIDDLE); horizontalPanel_2.setCellHorizontalAlignment(pshbtnNewButton, HasHorizontalAlignment.ALIGN_CENTER); pshbtnNewButton.setSize("70px", "18px"); editButton.setHTML("Edit"); horizontalPanel_2.add(editButton); horizontalPanel_2.setCellHorizontalAlignment(editButton, HasHorizontalAlignment.ALIGN_CENTER); horizontalPanel_2.setCellVerticalAlignment(editButton, HasVerticalAlignment.ALIGN_MIDDLE); editButton.setSize("70px", "18px"); doneButton = new PushButton("Done"); doneButton.setHTML("Done"); horizontalPanel_2.add(doneButton); horizontalPanel_2.setCellHorizontalAlignment(doneButton, HasHorizontalAlignment.ALIGN_CENTER); horizontalPanel_2.setCellVerticalAlignment(doneButton, HasVerticalAlignment.ALIGN_MIDDLE); doneButton.setSize("70px", "18px"); getUsersList(); }
From source file:gov.nist.appvet.gwt.client.gui.LoginPanel.java
License:Open Source License
public LoginPanel(Unit unit) { super(Unit.PX); final String version = AppVetProperties.VERSION; log.info("Starting AppVet v" + version + "..."); setSize("100%", ""); DockPanel dockPanel_1 = new DockPanel(); dockPanel_1.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); addNorth(dockPanel_1, 32.0);//from w ww . j a va2s.c om dockPanel_1.setWidth("100%"); Image image = new Image("images/nist-gray.png"); image.setStyleName("nistLoginLogo"); dockPanel_1.add(image, DockPanel.EAST); dockPanel_1.setCellVerticalAlignment(image, HasVerticalAlignment.ALIGN_MIDDLE); dockPanel_1.setCellHorizontalAlignment(image, HasHorizontalAlignment.ALIGN_RIGHT); final VerticalPanel centerVerticalPanel = new VerticalPanel(); centerVerticalPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); centerVerticalPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); add(centerVerticalPanel); centerVerticalPanel.setSize("100%", "90%"); final DecoratorPanel decoratorPanel = new DecoratorPanel(); centerVerticalPanel.add(decoratorPanel); centerVerticalPanel.setCellWidth(decoratorPanel, "100%"); decoratorPanel.setSize("", ""); centerVerticalPanel.setCellHorizontalAlignment(decoratorPanel, HasHorizontalAlignment.ALIGN_CENTER); centerVerticalPanel.setCellVerticalAlignment(decoratorPanel, HasVerticalAlignment.ALIGN_MIDDLE); final DockPanel dockPanel = new DockPanel(); dockPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); dockPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); decoratorPanel.setWidget(dockPanel); dockPanel.setSize("100%", "200px"); final VerticalPanel verticalPanel = new VerticalPanel(); verticalPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); verticalPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); dockPanel.add(verticalPanel, DockPanel.NORTH); dockPanel.setCellWidth(verticalPanel, "100%"); dockPanel.setCellVerticalAlignment(verticalPanel, HasVerticalAlignment.ALIGN_MIDDLE); dockPanel.setCellHorizontalAlignment(verticalPanel, HasHorizontalAlignment.ALIGN_CENTER); verticalPanel.setSize("300px", "90px"); final Image appVetImage = new Image("images/appvet_logo.png"); appVetImage.setStyleName("loginPanelLogo"); verticalPanel.add(appVetImage); verticalPanel.setCellHorizontalAlignment(appVetImage, HasHorizontalAlignment.ALIGN_CENTER); verticalPanel.setCellVerticalAlignment(appVetImage, HasVerticalAlignment.ALIGN_MIDDLE); appVetImage.setSize("192px", "73px"); loginStatusLabel.setStyleName("submissionRequirementsLabel"); verticalPanel.add(loginStatusLabel); loginStatusLabel.setVisible(true); loginStatusLabel.setSize("200px", "20px"); verticalPanel.setCellHorizontalAlignment(loginStatusLabel, HasHorizontalAlignment.ALIGN_CENTER); final Grid grid = new Grid(2, 2); grid.setStyleName("loginGrid"); dockPanel.add(grid, DockPanel.CENTER); dockPanel.setCellWidth(grid, "100%"); grid.setHeight(""); dockPanel.setCellVerticalAlignment(grid, HasVerticalAlignment.ALIGN_MIDDLE); dockPanel.setCellHorizontalAlignment(grid, HasHorizontalAlignment.ALIGN_CENTER); final Label usernameLabel = new Label("USERNAME"); usernameLabel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); grid.setWidget(0, 0, usernameLabel); usernameLabel.setSize("100px", "20px"); grid.getCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_LEFT); grid.getCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE); grid.setWidget(0, 1, userNameTextBox); userNameTextBox.setSize("180px", "15px"); grid.getCellFormatter().setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_RIGHT); grid.getCellFormatter().setVerticalAlignment(0, 1, HasVerticalAlignment.ALIGN_MIDDLE); final Label passwordLabel = new Label("PASSWORD"); passwordLabel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); grid.setWidget(1, 0, passwordLabel); passwordLabel.setSize("100px", "20px"); grid.getCellFormatter().setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_LEFT); grid.getCellFormatter().setVerticalAlignment(1, 0, HasVerticalAlignment.ALIGN_MIDDLE); grid.setWidget(1, 1, passwordTextBox); passwordTextBox.setSize("180px", "15px"); grid.getCellFormatter().setHorizontalAlignment(1, 1, HasHorizontalAlignment.ALIGN_RIGHT); grid.getCellFormatter().setVerticalAlignment(1, 1, HasVerticalAlignment.ALIGN_MIDDLE); passwordTextBox.addKeyPressHandler(new KeyPressHandler() { @Override public void onKeyPress(KeyPressEvent event_) { final boolean enterPressed = KeyCodes.KEY_ENTER == event_.getNativeEvent().getKeyCode(); if (enterPressed) { getUserInput(); } } }); final SimplePanel simplePanel_3 = new SimplePanel(); simplePanel_3.setStyleName("buttonPanel"); dockPanel.add(simplePanel_3, DockPanel.SOUTH); simplePanel_3.setHeight("28px"); dockPanel.setCellVerticalAlignment(simplePanel_3, HasVerticalAlignment.ALIGN_MIDDLE); dockPanel.setCellHorizontalAlignment(simplePanel_3, HasHorizontalAlignment.ALIGN_CENTER); loginButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { getUserInput(); } }); simplePanel_3.setWidget(loginButton); loginButton.setText("LOGIN"); loginButton.setSize("78px", "26px"); }