List of usage examples for com.google.gwt.user.client.ui DockPanel setVerticalAlignment
public void setVerticalAlignment(VerticalAlignmentConstant align)
From source file:com.bramosystems.oss.player.core.client.skin.CustomPlayerControl.java
License:Apache License
private Widget getPlayerWidget(final UIStyleResource imgPack) { imgPack.ensureInjected();/*from w ww . j av a 2 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.co m * * @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.google.gwt.sample.kitchensink.client.Images.java
License:Apache License
public Images() { image.addLoadListener(this); prevButton.addClickListener(this); nextButton.addClickListener(this); DockPanel topPanel = new DockPanel(); topPanel.setVerticalAlignment(DockPanel.ALIGN_MIDDLE); topPanel.add(prevButton, DockPanel.WEST); topPanel.add(nextButton, DockPanel.EAST); topPanel.add(loadingImage, DockPanel.CENTER); VerticalPanel panel = new VerticalPanel(); panel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER); panel.add(new HTML("<h2>A Bit of Rembrandt</h2>", true)); panel.add(topPanel);/* www.j a v a2 s. c om*/ panel.add(image); panel.setWidth("100%"); initWidget(panel); image.setStyleName("ks-images-Image"); nextButton.setStyleName("ks-images-Button"); prevButton.setStyleName("ks-images-Button"); loadImage(0); }
From source file:gate.mimir.gus.client.Application.java
License:Open Source License
/** * Initialisation of the GUI elements and the <code>History</code>. *//*from w ww. j a v a 2s . c o m*/ 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.AppVetPanel.java
License:Open Source License
public AppVetPanel(Unit unit, final ConfigInfoGwt configInfo, List<AppInfoGwt> initialApps) { super(Unit.PX); Window.addResizeHandler(new ResizeHandler() { Timer resizeTimer = new Timer() { @Override/* w ww . j a v a2s . c o m*/ public void run() { resizeComponents(); } }; @Override public void onResize(ResizeEvent event) { resizeTimer.cancel(); resizeTimer.schedule(250); } }); userInfo = configInfo.getUserInfo(); userName = userInfo.getUserName(); allApps = initialApps; sinkEvents(Event.ONCLICK); sessionId = configInfo.getSessionId(); sessionExpirationLong = configInfo.getSessionExpirationLong(); MAX_SESSION_IDLE_DURATION = configInfo.getMaxIdleTime(); POLLING_INTERVAL = configInfo.getUpdatesDelay(); setSize("100%", ""); setStyleName("mainDockPanel"); SERVLET_URL = configInfo.getAppVetServletUrl(); HOST_URL = configInfo.getAppVetHostUrl(); appSelectionModel = new SingleSelectionModel<AppInfoGwt>(); appSelectionModel.addSelectionChangeHandler(new AppListHandler(this, configInfo)); if (configInfo.getAvailableToolNames() == null) { log.severe("Available tools is null"); } availableToolNames = configInfo.getAvailableToolNames(); availableToolIDs = configInfo.getAvailableToolIDs(); availableToolTypes = configInfo.getAvailableToolTypes(); final VerticalPanel northAppVetPanel = new VerticalPanel(); northAppVetPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); northAppVetPanel.setStyleName("northAppVetPanel"); northAppVetPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); addNorth(northAppVetPanel, 125.0); northAppVetPanel.setSize("100%", ""); final HorizontalPanel horizontalPanel_5 = new HorizontalPanel(); horizontalPanel_5.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); horizontalPanel_5.setStyleName("appVetHeaderPanel"); northAppVetPanel.add(horizontalPanel_5); northAppVetPanel.setCellVerticalAlignment(horizontalPanel_5, HasVerticalAlignment.ALIGN_MIDDLE); horizontalPanel_5.setWidth("100%"); northAppVetPanel.setCellWidth(horizontalPanel_5, "100%"); final InlineHTML nlnhtmlNewInlinehtml_1 = new InlineHTML( "<img border=\"0\" width=\"192px\" src=\"images/appvet_logo.png\" alt=\"appvet\" />"); nlnhtmlNewInlinehtml_1.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); nlnhtmlNewInlinehtml_1.setStyleName(""); horizontalPanel_5.add(nlnhtmlNewInlinehtml_1); horizontalPanel_5.setCellWidth(nlnhtmlNewInlinehtml_1, "33%"); horizontalPanel_5.setCellVerticalAlignment(nlnhtmlNewInlinehtml_1, HasVerticalAlignment.ALIGN_MIDDLE); final HorizontalPanel horizontalPanel_6 = new HorizontalPanel(); horizontalPanel_6.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); horizontalPanel_6.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); horizontalPanel_5.add(horizontalPanel_6); horizontalPanel_6.setWidth(""); horizontalPanel_5.setCellWidth(horizontalPanel_6, "34%"); horizontalPanel_5.setCellHorizontalAlignment(horizontalPanel_6, HasHorizontalAlignment.ALIGN_CENTER); horizontalPanel_5.setCellVerticalAlignment(horizontalPanel_6, HasVerticalAlignment.ALIGN_MIDDLE); searchTextBox = new TextBox(); searchTextBox.setText("Search"); searchTextBox.setStyleName("searchTextBox"); searchTextBox.setTitle("Search by app ID, name, release kit, etc."); searchTextBox.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { searchTextBox.setText(""); } }); searchTextBox.addKeyPressHandler(new KeyPressHandler() { @Override public void onKeyPress(KeyPressEvent event_) { final boolean enterPressed = KeyCodes.KEY_ENTER == event_.getNativeEvent().getKeyCode(); final String searchString = searchTextBox.getText(); if (enterPressed) { final int numFound = search(); if (numFound > 0) { appsLabel.setText("Search Results for \"" + searchString + "\""); } } } }); searchTextBox.setSize("300px", "22px"); horizontalPanel_6.add(searchTextBox); horizontalPanel_6.setCellVerticalAlignment(searchTextBox, HasVerticalAlignment.ALIGN_MIDDLE); final PushButton searchButton = new PushButton("Search"); searchButton.setTitle("Search by app ID, name, release kit, etc."); searchButton.getUpFace().setHTML(""); searchButton.setSize("18px", "18px"); searchButton.setHTML("<img width=\"18px\" src=\"images/icon-search.png\" alt=\"search\" />"); searchButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { final String searchString = searchTextBox.getText(); final int numFound = search(); if (numFound > 0) { appsLabel.setText("Search Results for \"" + searchString + "\""); } } }); horizontalPanel_6.add(searchButton); horizontalPanel_6.setCellHorizontalAlignment(searchButton, HasHorizontalAlignment.ALIGN_CENTER); horizontalPanel_6.setCellVerticalAlignment(searchButton, HasVerticalAlignment.ALIGN_MIDDLE); Image image = new Image("images/nist-gray.png"); horizontalPanel_5.add(image); horizontalPanel_5.setCellHorizontalAlignment(image, HasHorizontalAlignment.ALIGN_RIGHT); horizontalPanel_5.setCellWidth(image, "33%"); final HorizontalPanel horizontalPanel_3 = new HorizontalPanel(); northAppVetPanel.add(horizontalPanel_3); northAppVetPanel.setCellHorizontalAlignment(horizontalPanel_3, HasHorizontalAlignment.ALIGN_CENTER); horizontalPanel_3.setWidth("100%"); northAppVetPanel.setCellWidth(horizontalPanel_3, "100%"); final MenuBar appVetMenuBar = new MenuBar(false); horizontalPanel_3.add(appVetMenuBar); appVetMenuBar.setStyleName("appVetMenuBar"); appVetMenuBar.setAutoOpen(true); appVetMenuBar.setWidth("250px"); appVetMenuBar.setAnimationEnabled(false); final MenuBar userMenuBar = new MenuBar(true); accountMenuItem = new MenuItem(userInfo.getNameWithLastNameInitial(), true, userMenuBar); accountMenuItem.setStyleName("AccountMenuItem"); final MenuItem accountSettingsMenuItem = new MenuItem("Account Settings", false, new Command() { @Override public void execute() { updateUserInfo(); } }); userMenuBar.addItem(accountSettingsMenuItem); final MenuItem myAppsMenuItem = new MenuItem("My Apps", false, new Command() { @Override public void execute() { searchTextBox.setText(userInfo.getUserName()); final int numFound = search(); if (numFound > 0) { appsLabel.setText("My Apps"); } } }); userMenuBar.addItem(myAppsMenuItem); final MenuItemSeparator separator = new MenuItemSeparator(); userMenuBar.addSeparator(separator); final MenuItem logoutMenuItem = new MenuItem("Logout", false, new Command() { @Override public void execute() { appVetServiceAsync.removeSession(sessionId, new AsyncCallback<Boolean>() { @Override public void onFailure(Throwable caught) { AppVetPanel.showMessageDialog("AppVet Error", "App list retrieval error", true); errorDialogBox.closeButton.setFocus(true); errorDialogBox.closeButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { killDialogBox(errorDialogBox); } }); } @Override public void onSuccess(Boolean result) { if (result == false) { AppVetPanel.showMessageDialog("AppVet Error", "Could not remove session", true); errorDialogBox.closeButton.setFocus(true); errorDialogBox.closeButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { killDialogBox(errorDialogBox); } }); } else { pollingTimer.cancel(); final LoginPanel loginPanel = new LoginPanel(Unit.PX); final RootLayoutPanel rootLayoutPanel = RootLayoutPanel.get(); rootLayoutPanel.clear(); rootLayoutPanel.add(loginPanel); System.gc(); } } }); } }); userMenuBar.addItem(logoutMenuItem); appVetMenuBar.addItem(accountMenuItem); final MenuBar helpMenuBar = new MenuBar(true); final MenuItem helpMenuItem = new MenuItem("Help", true, helpMenuBar); final MenuItem aboutMenuItem = new MenuItem("About", false, new Command() { @Override public void execute() { aboutDialogBox = new AboutDialogBox(configInfo.getAppVetVersion()); aboutDialogBox.setText("About"); aboutDialogBox.center(); aboutDialogBox.closeButton.setFocus(true); aboutDialogBox.closeButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { killDialogBox(aboutDialogBox); } }); } }); final MenuItem documentationMenuItem = new MenuItem("Documentation", false, new Command() { @Override public void execute() { Window.open("http://csrc.nist.gov/projects/appvet/", "_blank", null); } }); helpMenuBar.addItem(documentationMenuItem); appVetMenuBar.addItem(helpMenuItem); helpMenuBar.addItem(aboutMenuItem); horizontalPanel_3.add(statusMessageLabel); horizontalPanel_3.setCellVerticalAlignment(statusMessageLabel, HasVerticalAlignment.ALIGN_MIDDLE); horizontalPanel_3.setCellHorizontalAlignment(statusMessageLabel, HasHorizontalAlignment.ALIGN_RIGHT); horizontalPanel_3.setCellWidth(statusMessageLabel, "100%"); statusMessageLabel.setStyleName("devModeIndicator"); statusMessageLabel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); statusMessageLabel.setSize("420px", "18"); final MenuBar adminMenuBar = new MenuBar(true); final MenuItem adminMenuItem = new MenuItem("Admin", true, adminMenuBar); final MenuItem mntmAppVetLog = new MenuItem("AppVet Log", false, new Command() { @Override public void execute() { final String dateString = "?nocache" + new Date().getTime(); final String url = SERVLET_URL + dateString + "&command=GET_APPVET_LOG&sessionid=" + sessionId; Window.open(url, "_blank", ""); } }); adminMenuBar.addItem(mntmAppVetLog); final MenuItem usersMenuItem = new MenuItem("Users", false, new Command() { @Override public void execute() { usersDialogBox = new UsersDialogBox(); usersDialogBox.setText("Users"); usersDialogBox.center(); usersDialogBox.doneButton.setFocus(true); usersDialogBox.doneButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { killDialogBox(usersDialogBox); } }); } }); adminMenuBar.addItem(usersMenuItem); if (userInfo.getRole().equals("ADMIN")) { appVetMenuBar.addItem(adminMenuItem); } // Remove first element containing the lastUpdate timestamp AppInfoGwt timeStampObject = null; if (initialApps != null && initialApps.size() > 0) { timeStampObject = initialApps.remove(0); lastAppsListUpdate = timeStampObject.getLastAppUpdate(); } final HorizontalPanel horizontalPanel_2 = new HorizontalPanel(); horizontalPanel_2.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); horizontalPanel_2.setStyleName("footerPanel"); addSouth(horizontalPanel_2, 35.0); horizontalPanel_2.setSize("100%", ""); // final Label lastUpdatedLabel = new Label("Last updated: " // + configInfo.getLastUpdated()); // lastUpdatedLabel // .setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); // lastUpdatedLabel.setStyleName("lastUpdated"); // horizontalPanel_2.add(lastUpdatedLabel); // lastUpdatedLabel.setWidth("200px"); // horizontalPanel_2.setCellWidth(lastUpdatedLabel, "100%"); // horizontalPanel_2.setCellVerticalAlignment(lastUpdatedLabel, // HasVerticalAlignment.ALIGN_MIDDLE); final HorizontalSplitPanel centerAppVetSplitPanel = new HorizontalSplitPanel(); centerAppVetSplitPanel.setSplitPosition("64%"); centerAppVetSplitPanel.setSize("", ""); final SimplePanel leftCenterPanel = new SimplePanel(); centerAppVetSplitPanel.setLeftWidget(leftCenterPanel); leftCenterPanel.setSize("", "95%"); final DockPanel dockPanel_1 = new DockPanel(); dockPanel_1.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); leftCenterPanel.setWidget(dockPanel_1); dockPanel_1.setSize("100%", ""); rightCenterPanel = new SimplePanel(); centerAppVetSplitPanel.setRightWidget(rightCenterPanel); rightCenterPanel.setSize("", "630px"); final VerticalPanel appInfoVerticalPanel = new VerticalPanel(); appInfoVerticalPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); rightCenterPanel.setWidget(appInfoVerticalPanel); appInfoVerticalPanel.setSize("99%", ""); final HorizontalPanel horizontalPanel_1 = new HorizontalPanel(); horizontalPanel_1.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); horizontalPanel_1.setStyleName("iconPanel"); appInfoVerticalPanel.add(horizontalPanel_1); appInfoVerticalPanel.setCellWidth(horizontalPanel_1, "100%"); horizontalPanel_1.setSize("", ""); appInfoIcon = new Image(""); appInfoIcon.setVisible(false); appInfoIcon.setAltText(""); horizontalPanel_1.add(appInfoIcon); horizontalPanel_1.setCellVerticalAlignment(appInfoIcon, HasVerticalAlignment.ALIGN_MIDDLE); appInfoIcon.setSize("70px", "70px"); final VerticalPanel verticalPanel = new VerticalPanel(); horizontalPanel_1.add(verticalPanel); appInfoName = new HTML("", true); appInfoName.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); verticalPanel.add(appInfoName); appInfoName.setStyleName("appInfoName"); appInfoName.setWidth(""); horizontalPanel_1.setCellVerticalAlignment(appInfoName, HasVerticalAlignment.ALIGN_MIDDLE); appInfoVersion = new HTML("", true); appInfoVersion.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); appInfoVersion.setStyleName("appInfoVersion"); verticalPanel.add(appInfoVersion); appsListButtonPanel = new HorizontalPanel(); appsListButtonPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); dockPanel_1.add(appsListButtonPanel, DockPanel.NORTH); dockPanel_1.setCellHorizontalAlignment(appsListButtonPanel, HasHorizontalAlignment.ALIGN_CENTER); dockPanel_1.setCellWidth(appsListButtonPanel, "100%"); dockPanel_1.setCellVerticalAlignment(appsListButtonPanel, HasVerticalAlignment.ALIGN_MIDDLE); appsListButtonPanel.setStyleName("appListButtonPanel"); appsListButtonPanel.setSize("100%", ""); appsLabel = new InlineLabel("Apps"); appsLabel.setStyleName("AppsLabel"); appsListButtonPanel.add(appsLabel); appsListButtonPanel.setCellWidth(appsLabel, "50%"); appsListButtonPanel.setCellVerticalAlignment(appsLabel, HasVerticalAlignment.ALIGN_MIDDLE); appsLabel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); appsLabel.setWidth("60px"); final HorizontalPanel horizontalPanel = new HorizontalPanel(); horizontalPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); horizontalPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); horizontalPanel.setStyleName("appFunctionButtonPanel"); appsListButtonPanel.add(horizontalPanel); appsListButtonPanel.setCellWidth(horizontalPanel, "50%"); appsListButtonPanel.setCellVerticalAlignment(horizontalPanel, HasVerticalAlignment.ALIGN_MIDDLE); appsListButtonPanel.setCellHorizontalAlignment(horizontalPanel, HasHorizontalAlignment.ALIGN_RIGHT); horizontalPanel.setWidth(""); final PushButton submitButton = new PushButton("Submit"); submitButton.setTitle("Submit App"); submitButton.setHTML("<img width=\"18px\" src=\"images/icon-submit.png\" alt=\"Submit\" />"); submitButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { appUploadDialogBox = new AppUploadDialogBox(sessionId, SERVLET_URL); appUploadDialogBox.setText("Submit App"); appUploadDialogBox.center(); appUploadDialogBox.cancelButton.setFocus(true); appUploadDialogBox.cancelButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { killDialogBox(appUploadDialogBox); } }); appUploadDialogBox.uploadAppForm.addFormHandler(new AppUploadFormHandler(appUploadDialogBox)); } }); final PushButton viewAllButton = new PushButton("View All"); viewAllButton.setTitle("View All"); viewAllButton.setHTML("<img width=\"18px\" src=\"images/icon-view-all.png\" alt=\"view-all\" />"); viewAllButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { searchMode = false; setAllApps(); } }); horizontalPanel.add(viewAllButton); horizontalPanel.setCellHorizontalAlignment(viewAllButton, HasHorizontalAlignment.ALIGN_CENTER); horizontalPanel.setCellVerticalAlignment(viewAllButton, HasVerticalAlignment.ALIGN_MIDDLE); viewAllButton.setSize("18px", "18px"); horizontalPanel.add(submitButton); horizontalPanel.setCellVerticalAlignment(submitButton, HasVerticalAlignment.ALIGN_MIDDLE); horizontalPanel.setCellHorizontalAlignment(submitButton, HasHorizontalAlignment.ALIGN_CENTER); submitButton.setSize("18px", "18px"); downloadButton = new PushButton("Download"); downloadButton.setTitle("Download Reports"); downloadButton.setHTML("<img width=\"18px\" src=\"images/icon-download.png\" alt=\"Download\" />"); horizontalPanel.add(downloadButton); downloadButton.setEnabled(true); downloadButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { final AppInfoGwt selected = appSelectionModel.getSelectedObject(); if (selected == null) { showMessageDialog("AppVet Error", "No app is selected", true); } else { final String appId = selected.appId; final String dateString = "?nocache" + new Date().getTime(); final String url = SERVLET_URL + dateString + "&command=DOWNLOAD_REPORTS&appid=" + appId + "&sessionid=" + sessionId; Window.open(url, "_self", ""); // downloadDialog = new DownloadDialogBox(sessionId, selected); // downloadDialog.setText("Download reports"); // downloadDialog.center(); // downloadDialog.cancelButton.setFocus(true); // downloadDialog.cancelButton // .addClickHandler(new ClickHandler() { // @Override // public void onClick(ClickEvent event) { // killDialogBox(downloadDialog); // } // }); // downloadDialog.downloadButton // .addClickHandler(new ClickHandler() { // @Override // public void onClick(ClickEvent event) { // if (downloadDialog.selected_apk_radio_button // .isChecked()) { // final AppInfoGwt selected = appSelectionModel // .getSelectedObject(); // final String appId = selected.appId; // final String apk = selected.appName; // final String dateString = "?nocache" // + new Date().getTime(); // final String url = SERVLET_URL // + dateString // + "&command=DOWNLOAD_APP&appid=" // + appId + "&sessionid=" // + sessionId + "&appname=" + apk // + ".apk"; // Window.open(url, "_self", ""); // killDialogBox(downloadDialog); // } else if (downloadDialog.selected_report_radio_button // .isChecked()) { // final AppInfoGwt selected = appSelectionModel // .getSelectedObject(); // final String appId = selected.appId; // final String dateString = "?nocache" // + new Date().getTime(); // final String url = SERVLET_URL // + dateString // + "&command=DOWNLOAD_REPORTS&appid=" // + appId + "&sessionid=" // + sessionId; // Window.open(url, "_self", ""); // killDialogBox(downloadDialog); // } // } // }); } } }); horizontalPanel.setCellHorizontalAlignment(downloadButton, HasHorizontalAlignment.ALIGN_CENTER); horizontalPanel.setCellVerticalAlignment(downloadButton, HasVerticalAlignment.ALIGN_MIDDLE); appsListButtonPanel.setCellHorizontalAlignment(downloadButton, HasHorizontalAlignment.ALIGN_CENTER); downloadButton.setSize("18px", "18px"); addReportButton = new PushButton("Add Report"); horizontalPanel.add(addReportButton); horizontalPanel.setCellVerticalAlignment(addReportButton, HasVerticalAlignment.ALIGN_MIDDLE); addReportButton.setTitle("Override Report"); addReportButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { final AppInfoGwt selected = appSelectionModel.getSelectedObject(); if (selected == null) { showMessageDialog("AppVet Error", "No app is selected", true); } else { reportUploadDialogBox = new ReportUploadDialogBox(userName, sessionId, selected.appId, SERVLET_URL, availableToolNames, availableToolIDs); reportUploadDialogBox.setText("Override Report"); reportUploadDialogBox.center(); reportUploadDialogBox.cancelButton.setFocus(true); reportUploadDialogBox.cancelButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { killDialogBox(reportUploadDialogBox); } }); reportUploadDialogBox.uploadReportForm.addFormHandler( new ReportUploadFormHandler(reportUploadDialogBox, userName, selected.appId)); } } }); addReportButton.setSize("18px", "18px"); addReportButton.setHTML("<img width=\"18px\" src=\"images/icon-submit-report.png\" alt=\"Add Report\" />"); deleteButton = new PushButton("Delete"); horizontalPanel.add(deleteButton); horizontalPanel.setCellVerticalAlignment(deleteButton, HasVerticalAlignment.ALIGN_MIDDLE); deleteButton.setHTML("<img width=\"18px\" src=\"images/icon-delete.png\" alt=\"delete\" />"); deleteButton.setTitle("Delete App"); deleteButton.setVisible(true); deleteButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { final AppInfoGwt selected = appSelectionModel.getSelectedObject(); deleteConfirmDialogBox = new DeleteAppConfirmDialogBox(selected.appId, selected.appName); 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) { deleteApp(selected.appId, userName); } } }); } }); deleteButton.setSize("18px", "18px"); logButton = new PushButton("Log"); horizontalPanel.add(logButton); horizontalPanel.setCellVerticalAlignment(logButton, HasVerticalAlignment.ALIGN_MIDDLE); logButton.setTitle("View Log"); logButton.setHTML("<img width=\"18px\" src=\"images/icon-log.png\" alt=\"log\" />"); logButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { final AppInfoGwt selected = appSelectionModel.getSelectedObject(); if (selected != null) { final String appId = selected.appId; final String dateString = "?nocache" + new Date().getTime(); final String url = SERVLET_URL + dateString + "&command=GET_APP_LOG&appid=" + appId + "&sessionid=" + sessionId; Window.open(url, "_blank", ""); } } }); logButton.setSize("18px", "18px"); appsListTable = new AppsListPagingDataGrid<AppInfoGwt>(); appsListTable.dataGrid.setStyleName("dataGrid"); dockPanel_1.add(appsListTable, DockPanel.CENTER); dockPanel_1.setCellHorizontalAlignment(appsListTable, HasHorizontalAlignment.ALIGN_CENTER); dockPanel_1.setCellVerticalAlignment(appsListTable, HasVerticalAlignment.ALIGN_MIDDLE); appsListTable.setAppVetHostUrl(HOST_URL); appsListTable.dataGrid.setSize("99%", ""); appsListTable.setDataList(initialApps); appsListTable.setSize("", ""); appsListTable.dataGrid.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED); appsListTable.dataGrid.setSelectionModel(appSelectionModel); addReportButton.setVisible(true); logButton.setVisible(true); // final Label lblNewLabel_1 = new Label("*See log for system errors"); // lblNewLabel_1.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); // appInfoVerticalPanel.add(lblNewLabel_1); // lblNewLabel_1.setWidth("200px"); // appInfoVerticalPanel.setCellWidth(lblNewLabel_1, "100%"); toolResultsHtml = new HTML("", true); appInfoVerticalPanel.add(toolResultsHtml); appInfoVerticalPanel.setCellWidth(toolResultsHtml, "100%"); toolResultsHtml.setWidth("100%"); toolResultsHtml.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); toolResultsHtml.setStyleName("toolResultsHtml"); add(centerAppVetSplitPanel); /* // Add logo in bottom-right corner final InlineHTML nlnhtmlNewInlinehtml = new InlineHTML( "<a href=\"http://www.example.com\"><img border=\"0\" width=\"75px\" src=\"exampleImage.png\" alt=\"example\" /></a>" ); nlnhtmlNewInlinehtml .setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); nlnhtmlNewInlinehtml.setStyleName("mainTaLogo"); horizontalPanel_2.add(nlnhtmlNewInlinehtml); nlnhtmlNewInlinehtml.setWidth(""); horizontalPanel_2.setCellHorizontalAlignment(nlnhtmlNewInlinehtml, HasHorizontalAlignment.ALIGN_RIGHT); horizontalPanel_2.setCellVerticalAlignment(nlnhtmlNewInlinehtml, HasVerticalAlignment.ALIGN_MIDDLE); */ if ((initialApps != null) && (initialApps.size() > 0)) { appSelectionModel.setSelected(initialApps.get(0), true); } else { logButton.setEnabled(false); addReportButton.setEnabled(false); deleteButton.setEnabled(false); downloadButton.setEnabled(false); } pollServer(userName); scheduleResize(); }
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);/*www. j av a 2s .com*/ 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 .j a va 2s. c o 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 w w . jav a2 s. 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"); }