List of usage examples for com.google.gwt.user.client.ui HorizontalPanel HorizontalPanel
public HorizontalPanel()
From source file:com.algorithmstudy.visualizer.client.AlgorithmVisualizer.java
License:Open Source License
/** * This is the entry point method./* w ww.ja v a 2s . c om*/ */ public void onModuleLoad() { Label programName = new Label("Algorithm Visualizer (v0.2.0)"); HTML algstudyDotCom = new HTML(); algstudyDotCom.setHTML("<a href='http://www.algorithmstudy.com'>AlgorithmStudy.com</a>"); HorizontalPanel titleBarPanel = new HorizontalPanel(); titleBarPanel.setStyleName(STYLE_TOP_BARS); titleBarPanel.setWidth("100%"); titleBarPanel.setHorizontalAlignment(HorizontalPanel.ALIGN_LEFT); titleBarPanel.add(programName); titleBarPanel.setHorizontalAlignment(HorizontalPanel.ALIGN_RIGHT); titleBarPanel.add(algstudyDotCom); contentsPanel = new VerticalPanel(); contentsPanel.setStyleName(STYLE_CONTENTS); contentsPanel.setHorizontalAlignment(VerticalPanel.ALIGN_LEFT); contentsPanel.setWidth("100%"); contentsPanel.setHeight("450px"); Panel algorithmSelectionPanel = new AlgorithmSelectionPanel(contentsPanel); algorithmSelectionPanel.setStyleName(STYLE_TOP_BARS); algorithmSelectionPanel.setWidth("100%"); VerticalPanel containingPanel = new VerticalPanel(); containingPanel.setWidth("850px"); containingPanel.setStyleName(STYLE_SUPER_CONTAINER); containingPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER); containingPanel.add(titleBarPanel); containingPanel.add(algorithmSelectionPanel); containingPanel.add(contentsPanel); RootPanel.get().add(containingPanel); }
From source file:com.algorithmstudy.visualizer.client.sort.BarChartVisualizer.java
License:Open Source License
public BarChartVisualizer(int[] elements, boolean isSingle) { setStyleName(STYLE_BAR_CHART);//from w w w.j a v a 2 s. c om HorizontalPanel timePanel = new HorizontalPanel(); timePanel.setWidth("100%"); timePanel.setHorizontalAlignment(HorizontalPanel.ALIGN_RIGHT); movesLabel = new Label(); movesLabel.setStyleName(STYLE_MOVES_LABEL); movesLabel.setText(MOVES_BASE + "0"); movesLabel.setWidth("8em"); numberOfMoves = 0; timePanel.add(movesLabel); this.add(timePanel); chart = new Chart(elements, isSingle); this.add(chart); }
From source file:com.algorithmstudy.visualizer.client.sort.SortingDisplayPanel.java
License:Open Source License
private void doReinitForTwo(SortAlgorithmType algorithm1, SortAlgorithmType algorithm2) { clearForReuse();// www . jav a 2 s.c o m sortControls.doReset(); setHorizontalAlignment(VerticalPanel.ALIGN_LEFT); sortControls.doSetNumElementsCB(VisualizerIndex.Second); this.add(sortControls); setHorizontalAlignment(VerticalPanel.ALIGN_CENTER); visualizer1 = new BarChartVisualizer(valuesToSort, false); alg1 = algorithm1.getInstance(); alg1.setVisualizer(visualizer1); alg1.setListToSort(cloneValuesToSort()); visualizer1.setAlgorithm(alg1); timer.addVisualizer(visualizer1); alg1Type = algorithm1; visualizer2 = new BarChartVisualizer(valuesToSort, false); alg2 = algorithm2.getInstance(); alg2.setVisualizer(visualizer2); alg2.setListToSort(cloneValuesToSort()); visualizer2.setAlgorithm(alg2); timer.addVisualizer(visualizer2); alg2Type = algorithm2; HorizontalPanel visPanel = new HorizontalPanel(); visPanel.setHorizontalAlignment(HorizontalPanel.ALIGN_CENTER); visPanel.add(visualizer1); visPanel.add(visualizer2); this.add(visPanel); }
From source file:com.allen_sauer.gwt.dnd.demo.client.DragStartSensitivityBehaviorPanel.java
License:Apache License
public DragStartSensitivityBehaviorPanel(final DragController dragController) { super("Drag Sensitivity", "getBehaviorDragStartSensitivity() / setBehaviorDragStartSensitivity(int)"); this.dragController = dragController; HorizontalPanel panel = new HorizontalPanel(); panel.setSpacing(5);//from ww w . j av a 2 s . co m Label label = new Label("Number of Pixels"); textBox = new TextBox(); textBox.setWidth("3em"); panel.add(label); panel.add(textBox); panel.setTitle("DragController#setBehaviorDragStartSensitivity(int)"); add(panel); textBox.setText("" + dragController.getBehaviorDragStartSensitivity()); textBox.addKeyUpHandler(new KeyUpHandler() { @Override public void onKeyUp(KeyUpEvent event) { fix(); } }); textBox.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { fix(); textBox.selectAll(); } }); textBox.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { fix(); } }); }
From source file:com.allen_sauer.gwt.dnd.demo.client.example.duallist.DualListBox.java
License:Apache License
public DualListBox(int visibleItems, String width) { HorizontalPanel horizontalPanel = new HorizontalPanel(); add(horizontalPanel);//from ww w . j a va2 s . c o m horizontalPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); VerticalPanel verticalPanel = new VerticalPanel(); verticalPanel.addStyleName(CSS_DEMO_DUAL_LIST_EXAMPLE_CENTER); verticalPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); dragController = new ListBoxDragController(this); left = new MouseListBox(dragController, LIST_SIZE); right = new MouseListBox(dragController, LIST_SIZE); left.setWidth(width); right.setWidth(width); horizontalPanel.add(left); horizontalPanel.add(verticalPanel); horizontalPanel.add(right); oneRight = new Button(">"); oneLeft = new Button("<"); allRight = new Button(">>"); allLeft = new Button("<<"); verticalPanel.add(oneRight); verticalPanel.add(oneLeft); verticalPanel.add(new HTML(" ")); verticalPanel.add(allRight); verticalPanel.add(allLeft); allRight.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { moveItems(left, right, false); } }); allLeft.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { moveItems(right, left, false); } }); oneRight.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { moveItems(left, right, true); } }); oneLeft.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { moveItems(right, left, true); } }); ListBoxDropController leftDropController = new ListBoxDropController(left); ListBoxDropController rightDropController = new ListBoxDropController(right); dragController.registerDropController(leftDropController); dragController.registerDropController(rightDropController); }
From source file:com.allen_sauer.gwt.dnd.demo.client.example.insertpanel.InsertPanelExample.java
License:Apache License
public InsertPanelExample(DemoDragHandler demoDragHandler) { addStyleName(CSS_DEMO_INSERT_PANEL_EXAMPLE); int count = 0; // use the boundary panel as this composite's widget AbsolutePanel boundaryPanel = new AbsolutePanel(); boundaryPanel.setSize("100%", "100%"); setWidget(boundaryPanel);//from w w w .j a v a 2 s.com // initialize our column drag controller PickupDragController columnDragController = new PickupDragController(boundaryPanel, false); columnDragController.setBehaviorMultipleSelection(false); columnDragController.addDragHandler(demoDragHandler); // initialize our widget drag controller PickupDragController widgetDragController = new PickupDragController(boundaryPanel, false); widgetDragController.setBehaviorMultipleSelection(false); widgetDragController.addDragHandler(demoDragHandler); // initialize horizontal panel to hold our columns HorizontalPanel horizontalPanel = new HorizontalPanel(); horizontalPanel.addStyleName(CSS_DEMO_INSERT_PANEL_EXAMPLE_CONTAINER); horizontalPanel.setSpacing(SPACING); boundaryPanel.add(horizontalPanel); // initialize our column drop controller HorizontalPanelDropController columnDropController = new HorizontalPanelDropController(horizontalPanel); columnDragController.registerDropController(columnDropController); for (int col = 1; col <= COLUMNS; col++) { // initialize a vertical panel to hold the heading and a second vertical // panel VerticalPanel columnCompositePanel = new VerticalPanel(); columnCompositePanel.addStyleName(CSS_DEMO_INSERT_PANEL_EXAMPLE_COLUMN_COMPOSITE); // initialize inner vertical panel to hold individual widgets VerticalPanel verticalPanel = new VerticalPanelWithSpacer(); verticalPanel.addStyleName(CSS_DEMO_INSERT_PANEL_EXAMPLE_CONTAINER); verticalPanel.setSpacing(SPACING); horizontalPanel.add(columnCompositePanel); // initialize a widget drop controller for the current column VerticalPanelDropController widgetDropController = new VerticalPanelDropController(verticalPanel); widgetDragController.registerDropController(widgetDropController); // Put together the column pieces Label heading = new Label("Column " + col); heading.addStyleName(CSS_DEMO_INSERT_PANEL_EXAMPLE_HEADING); columnCompositePanel.add(heading); columnCompositePanel.add(verticalPanel); // make the column draggable by its heading columnDragController.makeDraggable(columnCompositePanel, heading); for (int row = 1; row <= ROWS; row++) { // initialize a widget HTML widget = new HTML("Draggable #" + ++count); widget.addStyleName(CSS_DEMO_INSERT_PANEL_EXAMPLE_WIDGET); widget.setHeight(Random.nextInt(4) + 2 + "em"); verticalPanel.add(widget); // make the widget draggable widgetDragController.makeDraggable(widget); } } }
From source file:com.allen_sauer.gwt.log.client.DivLogger.java
License:Apache License
/** * @deprecated/*w w w . jav a 2 s . c o m*/ */ @Deprecated private FocusPanel makeHeader() { FocusPanel header; header = new FocusPanel(); HorizontalPanel masterPanel = new HorizontalPanel(); masterPanel.setWidth("100%"); header.add(masterPanel); final Label titleLabel = new Label("gwt-log", false); titleLabel.setStylePrimaryName(LogClientBundle.INSTANCE.css().logTitle()); HorizontalPanel buttonPanel = new HorizontalPanel(); levelButtons = new Button[levels.length]; for (int i = 0; i < levels.length; i++) { final int level = levels[i]; levelButtons[i] = new Button(LogUtil.levelToString(level)); buttonPanel.add(levelButtons[i]); levelButtons[i].addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { ((Button) event.getSource()).setFocus(false); Log.setCurrentLogLevel(level); } }); } Button clearButton = new Button("Clear"); clearButton.addStyleName(LogClientBundle.INSTANCE.css().logClearButton()); DOM.setStyleAttribute(clearButton.getElement(), "color", "#00c"); clearButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { ((Button) event.getSource()).setFocus(false); Log.clear(); } }); buttonPanel.add(clearButton); Button aboutButton = new Button("About"); aboutButton.addStyleName(LogClientBundle.INSTANCE.css().logClearAbout()); aboutButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { ((Button) event.getSource()).setFocus(false); Log.diagnostic("\n" // + "gwt-log-" + Log.getVersion() // + " - Runtime logging for your Google Web Toolkit projects\n" + // "Copyright 2007 Fred Sauer\n" + // "The original software is available from:\n" + // "\u00a0\u00a0\u00a0\u00a0http://allen-sauer.com/gwt/\n", null); } }); Button closeButton = new Button("X"); closeButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { logDockPanel.removeFromParent(); } }); masterPanel.add(titleLabel); masterPanel.add(buttonPanel); masterPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); masterPanel.add(aboutButton); masterPanel.add(closeButton); masterPanel.setCellHeight(titleLabel, "100%"); masterPanel.setCellWidth(titleLabel, "50%"); masterPanel.setCellWidth(aboutButton, "50%"); new MouseDragHandler(titleLabel); return header; }
From source file:com.allen_sauer.gwt.voices.demo.client.DemoSoundPanel.java
License:Apache License
public DemoSoundPanel(final ThirdPartySound thirdPartySound) { // use a horizontal panel to hold our content HorizontalPanel horizontalPanel = new HorizontalPanel(); initWidget(horizontalPanel);/*from w w w. j a v a 2 s .co m*/ // add a (temporarily disabled) play button final Button playButton = new Button("wait..."); playButton.setEnabled(false); playButton.addStyleName("voices-button"); horizontalPanel.add(playButton); final Button stopButton = new Button("wait..."); stopButton.setEnabled(false); stopButton.addStyleName("voices-button"); horizontalPanel.add(stopButton); // display a description of the sound next to the button horizontalPanel.add(new HTML(" " + thirdPartySound.toHTMLString())); // display a load state status final HTML loadStateHTML = new HTML(); horizontalPanel.add(loadStateHTML); // enable the play button once the sound has loaded thirdPartySound.getSound().addEventHandler(new SoundHandler() { @Override public void onPlaybackComplete(PlaybackCompleteEvent event) { } @Override public void onSoundLoadStateChange(final SoundLoadStateChangeEvent event) { // simulate a slight variable delay for local development new Timer() { @Override public void run() { loadStateHTML.setHTML(" (<code>" + event.getLoadState().name() + "</code>)"); switch (event.getLoadState()) { case LOAD_STATE_SUPPORTED_AND_READY: case LOAD_STATE_SUPPORTED_NOT_READY: case LOAD_STATE_SUPPORTED_MAYBE_READY: playButton.setEnabled(true); playButton.setText("play"); stopButton.setEnabled(true); stopButton.setText("stop"); break; case LOAD_STATE_NOT_SUPPORTED: playButton.setText("(sound or plugin unavailable)"); break; case LOAD_STATE_SUPPORT_NOT_KNOWN: playButton.setEnabled(true); playButton.setText("play (may not work)"); stopButton.setEnabled(true); stopButton.setText("stop"); break; case LOAD_STATE_UNINITIALIZED: default: throw new IllegalArgumentException("Unhandled state " + event.getLoadState()); } } }.schedule(Random.nextInt(500) + 200); } }); // play the sound when button is clicked playButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { thirdPartySound.getSound().play(); } }); stopButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { thirdPartySound.getSound().stop(); } }); }
From source file:com.anzsoft.client.ui.UserIndicator.java
License:Open Source License
public UserIndicator(final String nick) { createStatusMenu();//from w ww .j a va 2 s . c o m setWidth("100%"); setCellPadding(0); setCellSpacing(0); setStyleName("indicator"); FlexCellFormatter formatter = getFlexCellFormatter(); // Setup the links cell /* linksPanel = new HorizontalPanel(); setWidget(0, 0, linksPanel); formatter.setStyleName(0, 0, "indicator-links"); formatter.setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_RIGHT); formatter.setColSpan(0, 0, 2); */ // Setup the title cell setTitleWidget(null); formatter.setStyleName(0, 0, "indicator-title"); getRowFormatter().setVerticalAlign(0, HasVerticalAlignment.ALIGN_TOP); getRowFormatter().setVerticalAlign(1, HasVerticalAlignment.ALIGN_TOP); final ChatIcons icons = ChatIcons.App.getInstance(); statusImg = new Image(); statusImg.setWidth("16px"); statusImg.setHeight("16px"); icons.online().applyTo(statusImg); avatarImg = new Image("images/default_avatar.png"); avatarImg.setWidth("32px"); avatarImg.setHeight("32px"); avatarImg.setStyleName("handler"); avatarImg.addClickListener(new ClickListener() { public void onClick(Widget sender) { JabberApp.instance().showInfoSelf(); } }); nickName = new Label(nick); nickName.setDirection(Direction.LTR); nickName.setWidth("100%"); statusLabel = new Label(); statusLabel.setStyleName("status_label"); statusLabel.setWidth("100%"); statusEditor = new TextBox(); statusEditor.setVisible(false); statusEditor.setWidth("100%"); statusButton = new Button(); statusButton.setMenu(statusMenu); statusButton.setStyleName("Status-Menu-Button"); //statusMenuLabel = new Label(); //statusMenuLabel.setStyleName("status_menu_label"); //addLink(new HTML("<a href=\"http://samespace.anzsoft.com\">SameSpace</a>")); // Add the title and some images to the title bar HorizontalPanel titlePanel = new HorizontalPanel(); titlePanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); titlePanel.setWidth("100%"); titlePanel.setSpacing(3); VerticalPanel statusPanel = new VerticalPanel(); statusPanel.setWidth("100%"); statusPanel.add(nickName); HorizontalPanel hPanel = new HorizontalPanel(); hPanel.setWidth("100%"); hPanel.setSpacing(2); hPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP); hPanel.add(statusLabel); hPanel.add(statusEditor); hPanel.add(statusButton); statusPanel.add(hPanel); titlePanel.add(statusImg); titlePanel.add(statusPanel); titlePanel.add(avatarImg); titlePanel.setCellWidth(statusImg, "20px"); titlePanel.setCellWidth(statusPanel, "100%"); titlePanel.setCellWidth(avatarImg, "32px"); setTitleWidget(titlePanel); JabberApp.instance().getSession().getUser().addUserListener(new XmppUserListener() { public void onPresenceChanged(XmppPresence presence) { String show = new String(""); PresenceShow presenceShow = presence.getShow(); if (presenceShow != null) show = presenceShow.toString(); String statusString = presence.getStatus(); int priority = presence.getPriority(); boolean avaiable = true; String type = presence.getType(); if (type != null && !type.isEmpty()) { if (type.equalsIgnoreCase("unavailable")) avaiable = false; } status = new XmppContactStatus(show, statusString, priority, avaiable); statusLabel.setText(status.status()); iconFromStatus(status).applyTo(statusImg); } }); statusLabel.addClickListener(new ClickListener() { public void onClick(Widget sender) { statusLabel.setVisible(false); statusEditor.setVisible(true); statusEditor.setText(statusLabel.getText()); } }); statusEditor.addKeyboardListener(new KeyboardListener() { public void onKeyDown(Widget sender, char keyCode, int modifiers) { } public void onKeyPress(Widget sender, char keyCode, int modifiers) { } public void onKeyUp(Widget sender, char keyCode, int modifiers) { if (keyCode == 13) doneChangeStatusString(); } }); statusEditor.addFocusListener(new FocusListener() { public void onFocus(Widget sender) { } public void onLostFocus(Widget sender) { doneChangeStatusString(); } }); XmppVCardFactory.instance().addVCardListener(new VCardListener() { public void onVCard(XmppID jid, XmppVCard vcard) { if (jid.toStringNoResource().equalsIgnoreCase(JabberApp.instance().getJid().toStringNoResource())) { if (!vcard.nickName().isEmpty()) nickName.setText(vcard.fullName()); else if (!vcard.fullName().isEmpty()) nickName.setText(vcard.fullName()); String photoData = vcard.photo(); if (!photoData.isEmpty() && !GXT.isIE) { ImageElement imgEl = avatarImg.getElement().cast(); imgEl.removeAttribute("src"); imgEl.setSrc("data:image;base64," + photoData); } } } }); }
From source file:com.appspot.codsallarts.client.Application.java
License:Apache License
/** * Constructor./*from w w w. j ava 2 s . c o m*/ */ public Application() { // Setup the main layout widget FlowPanel layout = new FlowPanel(); initWidget(layout); // Setup the top panel with the title and links createTopPanel(); layout.add(topPanel); // Add the main menu bottomPanel = new HorizontalPanel(); bottomPanel.setWidth("100%"); bottomPanel.setSpacing(0); bottomPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP); layout.add(bottomPanel); // Setup the content layout contentLayout = new Grid(2, 1); contentLayout.setStyleName("Application-content-grid"); contentLayout.setCellPadding(0); contentLayout.setCellSpacing(0); contentDecorator = new DecoratorPanel(); contentDecorator.setWidget(contentLayout); contentDecorator.addStyleName(DEFAULT_STYLE_NAME + "-content-decorator"); bottomPanel.add(contentDecorator); if (LocaleInfo.getCurrentLocale().isRTL()) { bottomPanel.setCellHorizontalAlignment(contentDecorator, HasHorizontalAlignment.ALIGN_LEFT); contentDecorator.getElement().setAttribute("align", "LEFT"); } else { bottomPanel.setCellHorizontalAlignment(contentDecorator, HasHorizontalAlignment.ALIGN_RIGHT); contentDecorator.getElement().setAttribute("align", "RIGHT"); } CellFormatter formatter = contentLayout.getCellFormatter(); // Add the content title setContentTitle(new HTML("Welcome")); formatter.setStyleName(0, 0, DEFAULT_STYLE_NAME + "-content-title"); // Add the content wrapper contentWrapper = new SimplePanel(); contentLayout.setWidget(1, 0, contentWrapper); formatter.setStyleName(1, 0, DEFAULT_STYLE_NAME + "-content-wrapper"); setContent(null); //createMainMenu(); //bottomPanel.add(mainMenu); navigationPanel = new SimplePanel(); navigationPanel.addStyleName(DEFAULT_STYLE_NAME + "-nav"); bottomPanel.add(navigationPanel); // Add a window resize handler Window.addResizeHandler(this); }