List of usage examples for com.google.gwt.event.logical.shared BeforeSelectionHandler BeforeSelectionHandler
BeforeSelectionHandler
From source file:com.sencha.gxt.explorer.client.app.ui.SourceContainer.java
License:sencha.com license
@Override protected void onShow() { super.onShow(); // lazy initialize the subcontainer only when shown if (getWidgetCount() == 0) { final ContentPanel sourcePanel = new ContentPanel(); sourcePanel.setBodyStyleName("explorer-example-code"); if (GXT.isTouch()) { sourcePanel.getElement().getStyle().setOverflow(Overflow.SCROLL); } else {//ww w. ja v a 2 s . c om sourcePanel.getElement().getStyle().setOverflow(Overflow.VISIBLE); } final Frame f = new Frame(); MarginData centerData = new MarginData(); centerData.setMargins(Theme.BLUE.isActive() || Theme.GRAY.isActive() ? new Margins(5) : Theme.NEPTUNE.isActive() ? new Margins(0, 0, 0, 8) : new Margins(10)); sourcePanel.setHeading("Source Code"); sourcePanel.add(f); ContentPanel west = new ContentPanel(); west.addStyleName("explorer-example-files"); BorderLayoutData westData = new BorderLayoutData(300); westData.setMargins(Theme.BLUE.isActive() || Theme.GRAY.isActive() ? new Margins(5, 0, 5, 5) : Theme.NEPTUNE.isActive() ? new Margins(0) : new Margins(10, 0, 10, 0)); westData.setCollapseHeaderVisible(true); westData.setCollapsible(true); west.setHeading("Select File"); SourceProperties sourceProperties = GWT.create(SourceProperties.class); final TreeStore<Source> sources = new TreeStore<Source>(sourceProperties.key()); sources.addSubTree(0, example.getSources()); Tree<Source, String> tree = new Tree<Source, String>(sources, sourceProperties.nameLabel()) { @Override protected void onAfterFirstAttach() { super.onAfterFirstAttach(); Source item = example.getSources().get(0).getChildren().get(0); getSelectionModel().select(item, false); } }; tree.getSelectionModel().setSelectionMode(SelectionMode.SINGLE); tree.getSelectionModel().addBeforeSelectionHandler(new BeforeSelectionHandler<Source>() { @Override public void onBeforeSelection(BeforeSelectionEvent<Source> event) { Source m = event.getItem(); if (m.getType() == FileType.FOLDER) { event.cancel(); } } }); tree.getSelectionModel().addSelectionChangedHandler(new SelectionChangedHandler<Source>() { @Override public void onSelectionChanged(SelectionChangedEvent<Source> event) { List<Source> sels = event.getSelection(); if (sels.size() > 0) { Source m = sels.get(0); if (m.getType() != FileType.FOLDER) { sourcePanel.setHeading(m.getName()); f.setUrl(m.getUrl()); } } } }); tree.setIconProvider(new IconProvider<Source>() { @Override public ImageResource getIcon(Source model) { switch (model.getType()) { case CSS: return ExampleImages.INSTANCE.css(); case XML: return ExampleImages.INSTANCE.xml(); case JSON: return ExampleImages.INSTANCE.json(); case FOLDER: return ExampleImages.INSTANCE.folder(); case HTML: return ExampleImages.INSTANCE.html(); case JAVA: default: return ExampleImages.INSTANCE.java(); } } }); tree.setAutoExpand(true); west.add(tree); BorderLayoutContainer subcontainer = new BorderLayoutContainer(); subcontainer.addStyleName("explorer-example-source"); subcontainer.setWestWidget(west, westData); subcontainer.setCenterWidget(sourcePanel, centerData); add(subcontainer); } }
From source file:com.square.client.gwt.client.composant.onglet.scroll.DoubleTabPanelScroll.java
License:Open Source License
/** * Creates an empty tab panel./* ww w.j a va 2 s .co m*/ * @param nbOngletsStatiques nombre d'onglets statiques * @param width largeur du scrollPanel, en units CSS (e.g. "10px", "1em") */ public DoubleTabPanelScroll(int nbOngletsStatiques, int width) { this.nbOngletsStatiques = nbOngletsStatiques; dynamicTabBar = new ExtendedTabBar(); staticTabBar = new ExtendedTabBar(); tabBar = new ExtendedDoubleTabBar(staticTabBar, dynamicTabBar, nbOngletsStatiques); deck = new TabbedDeckPanel(tabBar); scrollPanel = new ExtendedScrollPanel(dynamicTabBar, width); scrollPanel.addStyleName(SquareResources.INSTANCE.css().scrollPanel()); final VerticalPanel panel = new VerticalPanel(); final FlexTable panelTabBars = new FlexTable(); panelTabBars.getFlexCellFormatter().addStyleName(0, 0, SquareResources.INSTANCE.css().ongletsStatiques()); panelTabBars.addStyleName(SquareResources.INSTANCE.css().barreOnglets()); panelTabBars.setWidget(0, 0, staticTabBar); panelTabBars.setCellPadding(0); panelTabBars.setCellSpacing(0); panelTabBars.setWidget(0, 1, scrollPanel); panelTabBars.getFlexCellFormatter().addStyleName(0, 1, SquareResources.INSTANCE.css().ongletsDynamiques()); panelTabBars.getFlexCellFormatter().setHorizontalAlignment(0, 1, HorizontalPanel.ALIGN_LEFT); panel.add(panelTabBars); panel.add(deck); panel.setCellHeight(deck, "100%"); final int idxDecalage = nbOngletsStatiques; dynamicTabBar.addSelectionHandler(new SelectionHandler<Integer>() { @Override public void onSelection(SelectionEvent<Integer> event) { staticTabBar.selectTab(-1); scrollPanel.ensureVisible((UIObject) (dynamicTabBar.getTab(event.getSelectedItem()))); scrollPanel.refreshScrollButtons(); deck.showWidget(event.getSelectedItem() + idxDecalage); fireSelectionEvent(event.getSelectedItem() + idxDecalage); } }); dynamicTabBar.addBeforeSelectionHandler(new BeforeSelectionHandler<Integer>() { @Override public void onBeforeSelection(BeforeSelectionEvent<Integer> event) { fireBeforeSelectionEvent(event.getItem() + idxDecalage); } }); staticTabBar.addSelectionHandler(new SelectionHandler<Integer>() { @Override public void onSelection(SelectionEvent<Integer> event) { dynamicTabBar.selectTab(-1); deck.showWidget(event.getSelectedItem()); fireSelectionEvent(event.getSelectedItem()); } }); staticTabBar.addBeforeSelectionHandler(new BeforeSelectionHandler<Integer>() { @Override public void onBeforeSelection(BeforeSelectionEvent<Integer> event) { fireBeforeSelectionEvent(event.getItem()); } }); initWidget(panel); setStyleName("gwt-TabPanel"); deck.setStyleName("gwt-TabPanelBottom"); // Add a11y role "tabpanel" Accessibility.setRole(deck.getElement(), Accessibility.ROLE_TABPANEL); }
From source file:com.square.client.gwt.client.composant.onglet.scroll.SimpleTabPanelScroll.java
License:Open Source License
/** * Constructeur.// w ww. j a va2s . co m * @param width largeur du scrollPanel, en units CSS (e.g. "10px", "1em") */ public SimpleTabPanelScroll(int width) { final VerticalPanel panel = new VerticalPanel(); tabBar = new UnmodifiableTabBar(); deck = new TabbedDeckPanel(tabBar); scrollPanel = new ExtendedScrollPanel(tabBar, width); scrollPanel.addStyleName(SquareResources.INSTANCE.css().scrollPanel()); panel.add(scrollPanel); panel.add(deck); panel.setCellHeight(deck, "100%"); tabBar.setWidth("100%"); tabBar.addSelectionHandler(new SelectionHandler<Integer>() { @Override public void onSelection(SelectionEvent<Integer> event) { scrollPanel.ensureVisible((UIObject) (tabBar.getTab(event.getSelectedItem()))); scrollPanel.refreshScrollButtons(); deck.showWidget(event.getSelectedItem()); fireSelectionEvent(event.getSelectedItem()); } }); tabBar.addBeforeSelectionHandler(new BeforeSelectionHandler<Integer>() { @Override public void onBeforeSelection(BeforeSelectionEvent<Integer> event) { fireBeforeSelectionEvent(event.getItem()); } }); initWidget(panel); setStyleName("gwt-TabPanel"); deck.setStyleName("gwt-TabPanelBottom"); // Add a11y role "tabpanel" Accessibility.setRole(deck.getElement(), Accessibility.ROLE_TABPANEL); }
From source file:com.square.client.gwt.client.presenter.personne.morale.GestionPersonneMoralePresenter.java
License:Open Source License
@Override public void onBind() { for (HasUpdateAideEventHandler handler : view.getListeUpdateEventHandler()) { handler.addUpdateAideEventHandler(new UpdateAideEventHandler() { @Override//from w w w . j av a 2 s . c o m public void onUpdateAide(UpdateAideEvent event) { aideService.creerOuModifierAide(event.getAide(), event.getCallBack()); } }); } for (HasDemandeAideEventHandler handler : view.getListeDemandeEventHandler()) { handler.addDemandeAideEventHandler(new DemandeAideEventHandler() { @Override public void onDemandeAide(DemandeAideEvent event) { aideService.rechercherAide(event.getIdComposant(), event.getCallBack()); } }); } view.getSbNature().addSuggestHandler(new SuggestListBoxSuggestEventHandler<IdentifiantLibelleGwt>() { @Override public void suggest(SuggestListBoxSuggestEvent<IdentifiantLibelleGwt> event) { final DimensionCriteresRechercheModel criteres = new DimensionCriteresRechercheModel(); criteres.setLibelle(event.getSuggest()); dimensionServiceRpcService.rechercherNaturePersonneMoraleParCriteres(criteres, event.getCallBack()); } }); view.getSbFormeJuridique() .addSuggestHandler(new SuggestListBoxSuggestEventHandler<IdentifiantLibelleGwt>() { @Override public void suggest(SuggestListBoxSuggestEvent<IdentifiantLibelleGwt> event) { final DimensionCriteresRechercheModel criteres = new DimensionCriteresRechercheModel(); criteres.setLibelle(event.getSuggest()); dimensionServiceRpcService.rechercherFormesJuridiques(criteres, event.getCallBack()); } }); view.getBlRpersonneMorale().addOpenEventHandler(new OpenBlocSyntheseEventHandler() { @Override public void onOpen(OpenBlocSyntheseEvent event) { if (!initPersonneMorale) { initPersonneMorale(); } } }); view.getSuggestAgence().addSuggestHandler(new SuggestListBoxSuggestEventHandler<IdentifiantLibelleGwt>() { @Override public void suggest(SuggestListBoxSuggestEvent<IdentifiantLibelleGwt> event) { final String libelleAgenceRecherchee = event.getSuggest(); final DimensionCriteresRechercheModel criteres = new DimensionCriteresRechercheModel(); criteres.setLibelle(libelleAgenceRecherchee); if (libelleAgenceRecherchee == null || "".equals(libelleAgenceRecherchee.trim())) { criteres.setMaxResults(AppControllerConstants.SUGGESTLISBBOX_NB_RESULTATS_MAX); } dimensionServiceRpcService.rechercherAgenceParCriteres(criteres, event.getCallBack()); } }); view.getSuggestCommercial() .addSuggestHandler(new SuggestListBoxSuggestEventHandler<DimensionRessourceModel>() { @Override public void suggest(SuggestListBoxSuggestEvent<DimensionRessourceModel> event) { final String libelleRessourceRecherchee = event.getSuggest(); final DimensionCriteresRechercheRessourceModel criteres = new DimensionCriteresRechercheRessourceModel(); criteres.setNom(libelleRessourceRecherchee); criteres.setPrenom(libelleRessourceRecherchee); final IdentifiantLibelleGwt agenceSelectionnee = view.getAgence().getValue(); if (agenceSelectionnee != null) { criteres.setIdAgence(agenceSelectionnee.getIdentifiant()); } if (libelleRessourceRecherchee == null || "".equals(libelleRessourceRecherchee.trim())) { criteres.setMaxResults(AppControllerConstants.SUGGESTLISBBOX_NB_RESULTATS_MAX); } dimensionServiceRpcService.rechercherRessourceParCriteres(criteres, event.getCallBack()); } }); view.getChangeAgence().addValueChangeHandler(new ValueChangeHandler<IdentifiantLibelleGwt>() { @Override public void onValueChange(ValueChangeEvent<IdentifiantLibelleGwt> event) { // On dselectionne le commercial view.getCommercial().setValue(null); } }); view.getTabPanelBeforeSelectionHandlers().addBeforeSelectionHandler(new BeforeSelectionHandler<Integer>() { @Override public void onBeforeSelection(BeforeSelectionEvent<Integer> event) { final String nomOnglet = view.getContainerTabInfos(event.getItem()); // L'event n'est plus lev.. // eventBus.addHandler(RafraichirRelationEvent.TYPE, new RafraichirRelationEventHandler() { // @Override // public void rafraichirRelation(RafraichirRelationEvent event) { // if (event.getFiltrePasDansGroupements() != null) { // for (Long idGroupement : event.getFiltrePasDansGroupements()) { // if (constantes.getIdGroupementProfessionnel().equals(idGroupement)) { // viewRelations = new PersonneRelationsModeViewImpl(); // final List<Long> filtrePasDansGroupements = new ArrayList<Long>(); // filtrePasDansGroupements.add(constantes.getIdGroupementFamiliale()); // filtrePasDansGroupements.add(constantes.getIdGroupementProfessionnel()); // if (presenterRelations == null) { // presenterRelations = new PersonneRelationsModePresenter(eventBus, viewRelations, personneRpcService, // personnePhysiqueRpcService, personneMoraleRpcService, dimensionServiceRpcService, constantes, null, // idPersonneMorale, null, idNaturePersonneMorale, filtrePasDansGroupements, 1L, // AppControllerConstants.MODE_RELATION_EDITION,aideService, deskBar); // } // presenterRelations.showPresenter(view.getContainerTab(view.getViewConstants().libelleTabRelations())); // } // } // } // } // }); if (nomOnglet.equals(view.getViewConstants().libelleTabRelations())) { final List<Long> filtrePasDansGroupements = new ArrayList<Long>(); filtrePasDansGroupements.add(constantes.getIdGroupementFamiliale()); filtrePasDansGroupements.add(constantes.getIdGroupementProfessionnel()); if (presenterRelations == null) { presenterRelations = addChildPresenter(new PersonneRelationsModePresenter(eventBus, new PersonneRelationsModeViewImpl(), personneRpcService, personnePhysiqueRpcService, personneMoraleRpcService, dimensionServiceRpcService, constantes, null, idPersonneMorale, null, idNaturePersonneMorale, filtrePasDansGroupements, 1L, AppControllerConstants.MODE_RELATION_EDITION, aideService, deskBar)); presenterRelations .showPresenter(view.getContainerTab(view.getViewConstants().libelleTabRelations())); } else { presenterRelations.switchModeEdition(AppControllerConstants.MODE_RELATION_EDITION); } } else if (nomOnglet.equals(view.getViewConstants().libelleTabActions())) { if (personneActionsPresenter == null) { personneActionsPresenter = addChildPresenter( new PersonneActionsPresenter(eventBus, actionServiceRpc, dimensionServiceRpcService, constantesRpcService, personneRpcService, new PersonneActionsViewImpl(constantes), idPersonneMorale, constantes, idActionOuvrir, null, null, numClient, ressourceConnectee, aideService)); personneActionsPresenter .showPresenter(view.getContainerTab(view.getViewConstants().libelleTabActions())); personneActionsPresenter.addEventHandlerToLocalBus(UpdateTabNameEvent.TYPE, new UpdateTabNameEventHandler() { @Override public void updateTabName(UpdateTabNameEvent event) { view.updateTabName(event.getNbItems(), event.getTabName()); } }); } else { personneActionsPresenter.initListeActions(idActionOuvrir, null, null); } } else if (nomOnglet.equals(view.getViewConstants().libelleTabCoordonnees()) && personneCoordonneesPresenter == null) { personneCoordonneesPresenter = addChildPresenter(new PersonneCoordonneesPresenter(eventBus, personneRpcService, dimensionServiceRpcService, new PersonneCoordonneesViewImpl(constantes, true, false, false), appControllerConstants, constantes, idPersonneMorale, deskBar, aideService)); personneCoordonneesPresenter .showPresenter(view.getContainerTab(view.getViewConstants().libelleTabCoordonnees())); personneCoordonneesPresenter.addEventHandlerToLocalBus(RafraichirPersonneEvent.TYPE, new RafraichirPersonneEventHandler() { @Override public void rafraichirPersonne(RafraichirPersonneEvent event) { if (idPersonneMorale.equals(event.getUidPersonne())) { initPersonneMorale(); } } }); } else if (nomOnglet.equals(view.getViewConstants().libelleTabDocuments())) { if (listeDetailleeDocumentsPresenter == null) { // FIXME : Dplacer l'instanciation du service ailleurs final DocumentsServiceGwtAsync documentService = GWT.create(DocumentsServiceGwt.class); listeDetailleeDocumentsPresenter = addChildPresenter(new ListeDetailleeDocumentsPresenter( eventBus, numClient, new ListeDetailleeDocumentsViewImpl(), documentService)); listeDetailleeDocumentsPresenter .showPresenter(view.getContainerTab(view.getViewConstants().libelleTabDocuments())); } else { listeDetailleeDocumentsPresenter.rafraichir(); } } else if (nomOnglet.equals(view.getViewConstants().libelleTabContratsPM()) && contratsPersonneMoralePresenter == null) { contratsPersonneMoralePresenter = addChildPresenter(new ContratsPersonneMoralePresenter( eventBus, new ContratsPersonneMoraleViewImpl(), idPersonneMorale)); contratsPersonneMoralePresenter .showPresenter(view.getContainerTab(view.getViewConstants().libelleTabContratsPM())); contratsPersonneMoralePresenter.addEventHandlerToLocalBus( ContratsPersonneMoraleChargesEvent.TYPE, new ContratsPersonneMoraleChargesEventHandler() { @Override public void updateContratsPersonneMoraleCharges( ContratsPersonneMoraleChargesEvent event) { if (event.getNbContratsCharges() > 0) { view.updateTabName(event.getNbContratsCharges(), view.getViewConstants().libelleTabContratsPM()); } } }); } } }); view.getBtActionsContextAddActions().addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { fireEventGlobalBus(new AjoutActionEvent(idPersonneMorale)); } }); }
From source file:de.yarkon.gwt.eventcalendar.client.EventCalendar.java
License:Open Source License
@SuppressWarnings("deprecation") private void initStackPanel() { panel = new StackLayoutPanel(Unit.EM); EventTable table;// w ww .j a v a 2 s . c o m Date date = new Date(firstYear, firstMonth, 10); DateTimeFormat dateFormatMonth = DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.MONTH); DateTimeFormat dateFormatYear = DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.YEAR_MONTH); String header; // create number_of_months stacks for (int i = 0; i < NUMBER_OF_MONTHS; i++) { // Create a new table widget for the event list int newMonth = (firstMonth + i) % 12; date.setMonth(newMonth); if (newMonth == 0 && i != 0) { date.setYear(date.getYear() + 1); } if (newMonth == 0 || i == 0) { header = dateFormatYear.format(date); } else { header = dateFormatMonth.format(date); } table = new EventTable((Date) date.clone()); ScrollPanel scrollPanel = new ScrollPanel(table); scrollPanel.addStyleName("scrollPanel"); panel.add(scrollPanel, header, 2); } /* * show current month, SHOW_PAST_MONTHS luckily is the index of the * current month */ panel.showWidget(SHOW_PAST_MONTHS, true); // event handler to fill table with data on selection panel.addBeforeSelectionHandler(new BeforeSelectionHandler<Integer>() { @Override public void onBeforeSelection(BeforeSelectionEvent<Integer> event) { ScrollPanel scrollPanel = (ScrollPanel) panel.getWidget(event.getItem()); EventTable tableWidget = (EventTable) scrollPanel.getWidget(); if (tableWidget.isTableFilled() == false) { // logger.log(Level.SEVERE, "Header Height:" + // Integer.toString(panel.getVisibleWidget().getOffsetHeight())); dataModel.getEventList(tableWidget.getMonth(), tableWidget); tableWidget.setFocus(true); } } }); // fire event to load data for current month BeforeSelectionEvent.fire(panel, SHOW_PAST_MONTHS); }
From source file:edu.caltech.ipac.fftools.core.StandaloneUI.java
private void addCoverageTab() { Map<String, String> paramMap = new HashMap<String, String>(7); WidgetFactory widgetFactory = Application.getInstance().getWidgetFactory(); paramMap.put(CommonParams.ENABLE_DEFAULT_COLUMNS, "true"); paramMap.put(CommonParams.CATALOGS_AS_OVERLAYS, "false"); paramMap.put("EVENT_WORKER_ID", "target"); covPrev = (CoveragePreview) widgetFactory.createObserverUI(WidgetFactory.COVERAGE_VIEW, paramMap); covPrev.bind(FFToolEnv.getHub());// w ww. jav a 2 s . c o m MiniPlotWidget mpw = covPrev.getMPW(); mpw.addStyleName("standard-border"); mpw.setMinSize(50, 50); mpw.setAutoTearDown(false); mpw.setSaveImageCornersAfterPlot(true); mpw.setTitleAreaAlwaysHidden(true); mpw.setInlineToolbar(true); mpw.setUseToolsButton(false); coverageTab = imageTabPane.addTab(covPrev.getDisplay(), "Coverage", "Coverage of catalog", false); imageTabPane.addBeforeSelectionHandler(new BeforeSelectionHandler<Integer>() { public void onBeforeSelection(BeforeSelectionEvent<Integer> ev) { TablePreview cview = getPreviewAtTabIdx(ev.getItem()); if (cview != null) cview.onHide(); } }); imageTabPane.addSelectionHandler(new SelectionHandler<Integer>() { public void onSelection(SelectionEvent<Integer> ev) { TablePreview cview = getPreviewAtTabIdx(ev.getSelectedItem()); if (cview != null) cview.onShow(); } }); EventHub hub = FFToolEnv.getHub(); hub.getEventManager().addListener(EventHub.ENABLE_PREVIEW, new WebEventListener() { public void eventNotify(WebEvent ev) { setPreviewEnabled((TablePreview) ev.getSource(), true); } }); hub.getEventManager().addListener(EventHub.DISABLE_PREVIEW, new WebEventListener() { public void eventNotify(WebEvent ev) { setPreviewEnabled((TablePreview) ev.getSource(), false); } }); }
From source file:edu.caltech.ipac.firefly.ui.panels.user.PreferencePanel.java
public PreferencePanel() { //populatePreferences(); String[] items = WebProp.getItems(PROP_BASE); groupPanels = new PrefGroupPanel[items.length]; int idx = 0;//w ww.ja v a 2s . c om for (String s : items) { // construct tab String title = WebProp.getTitle(PROP_BASE + "." + s); groupPanels[idx] = new PrefGroupPanel(PROP_BASE + "." + s + ".field"); tabs.addTab(groupPanels[idx], title); idx++; } panel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER); panel.add(grid); panel.addStyleName("content-panel"); WebAppProperties wap = Application.getInstance().getProperties(); hasViewAll = wap.getBooleanProperty(PROP_BASE + ".hasViewAll"); if (hasViewAll) { tabs.addTab(panel, "View All"); } // make sure preference view is in sync with the latest updates tabs.addBeforeSelectionHandler(new BeforeSelectionHandler<Integer>() { public void onBeforeSelection(BeforeSelectionEvent<Integer> ev) { int tabIndex = ev.getItem(); if (hasViewAll && tabIndex == tabs.getWidgetCount() - 1) { populatePreferences(); } lastTab = tabIndex; } }); tabs.setSize("99%", "99%"); tabs.selectTab(0); initWidget(tabs); }
From source file:edu.caltech.ipac.firefly.ui.searchui.SpacialSelectUI.java
public void makeUI() { spacialOpsTabs.addSelectionHandler(new SelectionHandler<Integer>() { public void onSelection(SelectionEvent<Integer> event) { if (tabUpdateOn) updateSelectedTab();/*from ww w .ja v a 2 s .c o m*/ } }); spacialOpsTabs.addBeforeSelectionHandler(new BeforeSelectionHandler<Integer>() { public void onBeforeSelection(BeforeSelectionEvent<Integer> ev) { preSelectedTab(ev.getItem()); } }); makeSingle(); makeIbeSingle(); makeMulti(); makeIbeMulti(); makePolygon(); makeAllSky(); reinitTabPane(true, true, true, true, true, true); mainPanel.add(spacialOpsTabs); spacialOpsTabs.setSize("100%", "100%"); // mainPanel.setSize("700px", "245px"); mainPanel.setSize("600px", NORMAL_HEIGHT_REQUIRED + "px"); GwtUtil.setStyle(mainPanel, "paddingTop", PADDING_TOP + "px"); }
From source file:edu.caltech.ipac.firefly.ui.table.PreviewTabPane.java
public PreviewTabPane(EventHub hub) { eventHub = hub == null ? new EventHub() : hub; display = new TabPane<Widget>(); display.setSize("100%", "100%"); initWidget(display);//www.ja v a 2 s.c o m display.addBeforeSelectionHandler(new BeforeSelectionHandler<Integer>() { public void onBeforeSelection(BeforeSelectionEvent<Integer> ev) { TablePreview cview = getPreviewAtTabIdx(ev.getItem()); if (cview != null) { cview.onHide(); } } }); display.addSelectionHandler(new SelectionHandler<Integer>() { public void onSelection(SelectionEvent<Integer> ev) { TablePreview cview = getPreviewAtTabIdx(ev.getSelectedItem()); if (cview != null) { cview.onShow(); } } }); eventHub.getEventManager().addListener(EventHub.ENABLE_PREVIEW, new WebEventListener() { public void eventNotify(WebEvent ev) { setPreviewEnabled((TablePreview) ev.getSource(), true); } }); eventHub.getEventManager().addListener(EventHub.DISABLE_PREVIEW, new WebEventListener() { public void eventNotify(WebEvent ev) { setPreviewEnabled((TablePreview) ev.getSource(), false); } }); }
From source file:net.opentsdb.tsd.client.QueryUi.java
License:Open Source License
/** * This is the entry point method./*from w w w . j a v a2s. co m*/ */ public void onModuleLoad() { asyncGetJson(AGGREGATORS_URL, new GotJsonCallback() { public void got(final JSONValue json) { // Do we need more manual type checking? Not sure what will happen // in the browser if something other than an array is returned. final JSONArray aggs = json.isArray(); for (int i = 0; i < aggs.size(); i++) { aggregators.add(aggs.get(i).isString().stringValue()); } ((MetricForm) metrics.getWidget(0)).setAggregators(aggregators); } }); // All UI elements need to regenerate the graph when changed. { final ValueChangeHandler<Date> vch = new ValueChangeHandler<Date>() { public void onValueChange(final ValueChangeEvent<Date> event) { refreshGraph(); } }; TextBox tb = start_datebox.getTextBox(); tb.addBlurHandler(refreshgraph); tb.addKeyPressHandler(refreshgraph); start_datebox.addValueChangeHandler(vch); tb = end_datebox.getTextBox(); tb.addBlurHandler(refreshgraph); tb.addKeyPressHandler(refreshgraph); end_datebox.addValueChangeHandler(vch); } autoreoload_interval.addBlurHandler(refreshgraph); autoreoload_interval.addKeyPressHandler(refreshgraph); yrange.addBlurHandler(refreshgraph); yrange.addKeyPressHandler(refreshgraph); y2range.addBlurHandler(refreshgraph); y2range.addKeyPressHandler(refreshgraph); ylog.addClickHandler(new AdjustYRangeCheckOnClick(ylog, yrange)); y2log.addClickHandler(new AdjustYRangeCheckOnClick(y2log, y2range)); ylog.addClickHandler(refreshgraph); y2log.addClickHandler(refreshgraph); ylabel.addBlurHandler(refreshgraph); ylabel.addKeyPressHandler(refreshgraph); y2label.addBlurHandler(refreshgraph); y2label.addKeyPressHandler(refreshgraph); yformat.addBlurHandler(refreshgraph); yformat.addKeyPressHandler(refreshgraph); y2format.addBlurHandler(refreshgraph); y2format.addKeyPressHandler(refreshgraph); wxh.addBlurHandler(refreshgraph); wxh.addKeyPressHandler(refreshgraph); horizontalkey.addClickHandler(refreshgraph); keybox.addClickHandler(refreshgraph); nokey.addClickHandler(refreshgraph); yrange.setValidationRegexp("^(" // Nothing or + "|\\[([-+.0-9eE]+|\\*)?" // "[start + ":([-+.0-9eE]+|\\*)?\\])$"); // :end]" yrange.setVisibleLength(5); yrange.setMaxLength(44); // MAX=2^26=20 chars: "[-$MAX:$MAX]" yrange.setText("[0:]"); y2range.setValidationRegexp("^(" // Nothing or + "|\\[([-+.0-9eE]+|\\*)?" // "[start + ":([-+.0-9eE]+|\\*)?\\])$"); // :end]" y2range.setVisibleLength(5); y2range.setMaxLength(44); // MAX=2^26=20 chars: "[-$MAX:$MAX]" y2range.setText("[0:]"); y2range.setEnabled(false); y2log.setEnabled(false); ylabel.setVisibleLength(10); ylabel.setMaxLength(50); // Arbitrary limit. y2label.setVisibleLength(10); y2label.setMaxLength(50); // Arbitrary limit. y2label.setEnabled(false); yformat.setValidationRegexp("^(|.*%..*)$"); // Nothing or at least one %? yformat.setVisibleLength(10); yformat.setMaxLength(16); // Arbitrary limit. y2format.setValidationRegexp("^(|.*%..*)$"); // Nothing or at least one %? y2format.setVisibleLength(10); y2format.setMaxLength(16); // Arbitrary limit. y2format.setEnabled(false); wxh.setValidationRegexp("^[1-9][0-9]{2,}x[1-9][0-9]{2,}$"); // 100x100 wxh.setVisibleLength(9); wxh.setMaxLength(11); // 99999x99999 wxh.setText((Window.getClientWidth() - 20) + "x" + (Window.getClientHeight() * 4 / 5)); final FlexTable table = new FlexTable(); table.setText(0, 0, "From"); { final HorizontalPanel hbox = new HorizontalPanel(); hbox.add(new InlineLabel("To")); final Anchor now = new Anchor("(now)"); now.addClickHandler(new ClickHandler() { public void onClick(final ClickEvent event) { end_datebox.setValue(new Date()); refreshGraph(); } }); hbox.add(now); hbox.add(autoreoload); hbox.setWidth("100%"); table.setWidget(0, 1, hbox); } autoreoload.addClickHandler(new ClickHandler() { public void onClick(final ClickEvent event) { if (autoreoload.isChecked()) { final HorizontalPanel hbox = new HorizontalPanel(); hbox.setWidth("100%"); hbox.add(new InlineLabel("Every:")); hbox.add(autoreoload_interval); hbox.add(new InlineLabel("seconds")); table.setWidget(1, 1, hbox); if (autoreoload_interval.getValue().isEmpty()) { autoreoload_interval.setValue("15"); } autoreoload_interval.setFocus(true); lastgraphuri = ""; // Force refreshGraph. refreshGraph(); // Trigger the 1st auto-reload } else { table.setWidget(1, 1, end_datebox); } } }); autoreoload_interval.setValidationRegexp("^([5-9]|[1-9][0-9]+)$"); // >=5s autoreoload_interval.setMaxLength(4); autoreoload_interval.setVisibleLength(8); table.setWidget(1, 0, start_datebox); table.setWidget(1, 1, end_datebox); { final HorizontalPanel hbox = new HorizontalPanel(); hbox.add(new InlineLabel("WxH:")); hbox.add(wxh); table.setWidget(0, 3, hbox); } { final MetricForm.MetricChangeHandler metric_change_handler = new MetricForm.MetricChangeHandler() { public void onMetricChange(final MetricForm metric) { final int index = metrics.getWidgetIndex(metric); metrics.getTabBar().setTabText(index, getTabTitle(metric)); } private String getTabTitle(final MetricForm metric) { final String metrictext = metric.getMetric(); final int last_period = metrictext.lastIndexOf('.'); if (last_period < 0) { return metrictext; } return metrictext.substring(last_period + 1); } }; final EventsHandler updatey2range = new EventsHandler() { protected <H extends EventHandler> void onEvent(final DomEvent<H> event) { for (final Widget metric : metrics) { if (!(metric instanceof MetricForm)) { continue; } if (((MetricForm) metric).x1y2().getValue()) { y2range.setEnabled(true); y2log.setEnabled(true); y2label.setEnabled(true); y2format.setEnabled(true); return; } } y2range.setEnabled(false); y2log.setEnabled(false); y2label.setEnabled(false); y2format.setEnabled(false); } }; final MetricForm metric = new MetricForm(refreshgraph); metric.x1y2().addClickHandler(updatey2range); metric.setMetricChangeHandler(metric_change_handler); metrics.add(metric, "metric 1"); metrics.selectTab(0); metrics.add(new InlineLabel("Loading..."), "+"); metrics.addBeforeSelectionHandler(new BeforeSelectionHandler<Integer>() { public void onBeforeSelection(final BeforeSelectionEvent<Integer> event) { final int item = event.getItem(); final int nitems = metrics.getWidgetCount(); if (item == nitems - 1) { // Last item: the "+" was clicked. event.cancel(); final MetricForm metric = new MetricForm(refreshgraph); metric.x1y2().addClickHandler(updatey2range); metric.setMetricChangeHandler(metric_change_handler); metric.setAggregators(aggregators); metrics.insert(metric, "metric " + nitems, item); metrics.selectTab(item); metric.setFocus(true); } } }); table.setWidget(2, 0, metrics); } table.getFlexCellFormatter().setColSpan(2, 0, 2); table.getFlexCellFormatter().setRowSpan(1, 3, 2); final DecoratedTabPanel optpanel = new DecoratedTabPanel(); optpanel.add(makeAxesPanel(), "Axes"); optpanel.add(makeKeyPanel(), "Key"); optpanel.selectTab(0); table.setWidget(1, 3, optpanel); final DecoratorPanel decorator = new DecoratorPanel(); decorator.setWidget(table); final VerticalPanel graphpanel = new VerticalPanel(); graphpanel.add(decorator); { final VerticalPanel graphvbox = new VerticalPanel(); graphvbox.add(graphstatus); graph.setVisible(false); graphvbox.add(graph); graph.addErrorHandler(new ErrorHandler() { public void onError(final ErrorEvent event) { graphstatus.setText("Oops, failed to load the graph."); } }); graphpanel.add(graphvbox); } final DecoratedTabPanel mainpanel = new DecoratedTabPanel(); mainpanel.setWidth("100%"); mainpanel.add(graphpanel, "Graph"); mainpanel.add(stats_table, "Stats"); mainpanel.add(logs, "Logs"); mainpanel.add(build_data, "Version"); mainpanel.selectTab(0); mainpanel.addBeforeSelectionHandler(new BeforeSelectionHandler<Integer>() { public void onBeforeSelection(final BeforeSelectionEvent<Integer> event) { clearError(); final int item = event.getItem(); switch (item) { case 1: refreshStats(); return; case 2: refreshLogs(); return; case 3: refreshVersion(); return; } } }); final VerticalPanel root = new VerticalPanel(); root.setWidth("100%"); root.add(current_error); current_error.setVisible(false); current_error.addStyleName("dateBoxFormatError"); root.add(mainpanel); RootPanel.get("queryuimain").add(root); // Must be done at the end, once all the widgets are attached. ensureSameWidgetSize(optpanel); }