List of usage examples for com.google.gwt.user.client.ui TabPanel getTabBar
public TabBar getTabBar()
From source file:com.google.appinventor.client.wizards.ComponentImportWizard.java
License:Open Source License
public ComponentImportWizard() { super(MESSAGES.componentImportWizardCaption(), true, false); final CellTable compTable = createCompTable(); final FileUpload fileUpload = createFileUpload(); final Grid urlGrid = createUrlGrid(); final TabPanel tabPanel = new TabPanel(); tabPanel.add(fileUpload, "From my computer"); tabPanel.add(urlGrid, "URL"); tabPanel.selectTab(FROM_MY_COMPUTER_TAB); tabPanel.addStyleName("ode-Tabpanel"); VerticalPanel panel = new VerticalPanel(); panel.add(tabPanel);/* www . ja v a 2s. c o m*/ addPage(panel); getConfirmButton().setText("Import"); setPagePanelHeight(150); setPixelSize(200, 150); setStylePrimaryName("ode-DialogBox"); initFinishCommand(new Command() { @Override public void execute() { final long projectId = ode.getCurrentYoungAndroidProjectId(); final Project project = ode.getProjectManager().getProject(projectId); final YoungAndroidAssetsFolder assetsFolderNode = ((YoungAndroidProjectNode) project.getRootNode()) .getAssetsFolder(); if (tabPanel.getTabBar().getSelectedTab() == URL_TAB) { TextBox urlTextBox = (TextBox) urlGrid.getWidget(1, 0); String url = urlTextBox.getText(); if (url.trim().isEmpty()) { Window.alert(MESSAGES.noUrlError()); return; } ode.getComponentService().importComponentToProject(url, projectId, assetsFolderNode.getFileId(), new ImportComponentCallback()); } else if (tabPanel.getTabBar().getSelectedTab() == FROM_MY_COMPUTER_TAB) { if (!fileUpload.getFilename().endsWith(COMPONENT_ARCHIVE_EXTENSION)) { Window.alert(MESSAGES.notComponentArchiveError()); return; } String url = GWT.getModuleBaseURL() + ServerLayout.UPLOAD_SERVLET + "/" + ServerLayout.UPLOAD_COMPONENT + "/" + trimLeadingPath(fileUpload.getFilename()); Uploader.getInstance().upload(fileUpload, url, new OdeAsyncCallback<UploadResponse>() { @Override public void onSuccess(UploadResponse uploadResponse) { String toImport = uploadResponse.getInfo(); ode.getComponentService().importComponentToProject(toImport, projectId, assetsFolderNode.getFileId(), new ImportComponentCallback()); } }); return; } } private String trimLeadingPath(String filename) { // Strip leading path off filename. // We need to support both Unix ('/') and Windows ('\\') separators. return filename.substring(Math.max(filename.lastIndexOf('/'), filename.lastIndexOf('\\')) + 1); } }); }
From source file:com.qualogy.qafe.gwt.client.ui.renderer.TabPanelRenderer.java
License:Apache License
public UIObject render(ComponentGVO component, String uuid, String parent, String context) { TabPanel uiObject = null; if (component != null) { if (component instanceof TabPanelGVO) { TabPanelGVO gvo = (TabPanelGVO) component; if (gvo.getMenu() != null) { final ComponentGVO finalComponentGVO = component; final String finalUuid = uuid; final String finalParent = parent; uiObject = new TabPanel() { @Override// w w w. j a v a 2 s. com public void onBrowserEvent(Event event) { if (event.getTypeInt() == Event.ONCONTEXTMENU) { DOM.eventPreventDefault(event); applyContextMenu(event, finalComponentGVO, finalUuid, finalParent); } super.onBrowserEvent(event); } @Override protected void setElement(Element elem) { super.setElement(elem); sinkEvents(Event.ONCONTEXTMENU); } }; } else { uiObject = new TabPanel(); } uiObject.setAnimationEnabled(gvo.isAnimationEnabled()); RendererHelper.fillIn(component, uiObject, uuid, parent, context); TabGVO[] tabs = gvo.getTabs(); if (tabs != null) { for (int i = 0; i < tabs.length; i++) { TabGVO tabGVO = tabs[i]; // since the panel renderer is used, the title (not null) will create a titledPanel. // The tab already has the title so that is overkill String title = tabGVO.getTitle(); tabGVO.setTitle(null); UIObject tabUI = renderChildComponent(tabGVO, uuid, parent, context); tabGVO.setTitle(title); if (tabUI instanceof Widget) { uiObject.add((Widget) tabUI, title); setTabVisibility(uiObject, i, tabGVO.getVisible(), tabUI); int tabCount = uiObject.getTabBar().getTabCount(); UIObject tabComponent = (UIObject) uiObject.getTabBar().getTab(tabCount - 1); RendererHelper.addAttributesRequiredByEventHandling(tabGVO, tabComponent, uuid, parent, context); RendererHelper.addEvents(tabGVO, tabComponent, uuid); } } } if (uiObject.getWidgetCount() > 0) { uiObject.selectTab(0); } } } return uiObject; }
From source file:com.qualogy.qafe.gwt.client.ui.renderer.TabPanelRenderer.java
License:Apache License
public static void setTabVisibility(TabPanel tabs, int index, boolean visible, UIObject tabUI) { try {/*w w w .jav a 2 s . c om*/ if (index >= tabs.getTabBar().getTabCount() || index < 0) return; // Native Google implementation of TabBar uses an HorizontalPanel, // so, the DOM primary element is a table element (with just one tr) Element table = tabs.getTabBar().getElement(); Element tr = DOM.getFirstChild(DOM.getFirstChild(table)); // (index + 1) to account for 'first' placeholder td. Element td = DOM.getChild(tr, index + 1); UIObject.setVisible(td, visible); tabUI.setVisible(visible); } catch (Exception e) { LOG.log(Level.WARNING, "Not sure what can go wrong, but setting tab visibility might have failed", e); } }
From source file:com.qualogy.qafe.gwt.client.vo.functions.execute.SetPropertyExecute.java
License:Apache License
private void processProperty(UIObject uiObject, BuiltInComponentGVO builtInComponentGVO, SetPropertyGVO setProperty) {//from w w w. ja v a 2 s . com if (QAMLConstants.PROPERTY_ENABLED.equals(setProperty.getProperty()) || QAMLConstants.PROPERTY_DISABLED.equals(setProperty.getProperty())) { boolean value = Boolean.valueOf(setProperty.getValue()).booleanValue(); if (QAMLConstants.PROPERTY_DISABLED.equals(setProperty.getProperty())) { value = !value; } if (uiObject instanceof HasEnabled) { HasEnabled hasEnabled = (HasEnabled) uiObject; hasEnabled.setEnabled(value); } else if (uiObject instanceof HasWidgets) { SetMaskHelper.setMaskEnable(uiObject.getElement().getAttribute(QAMLConstants.PROPERTY_ID), value, true); DOM.setElementPropertyBoolean(uiObject.getElement(), QAMLConstants.PROPERTY_DISABLED, !value); } else if (uiObject instanceof QSuggestBox) { QSuggestBox suggestField = (QSuggestBox) uiObject; suggestField.getTextBox().setEnabled(value); } else if (uiObject instanceof SpreadsheetCell) { SpreadsheetCell cell = (SpreadsheetCell) uiObject; cell.setEditable(value); } } else if (QAMLConstants.PROPERTY_EDITABLE.equals(setProperty.getProperty())) { boolean editable = Boolean.valueOf(setProperty.getValue()).booleanValue(); HasEditable hasEditable = null; if (uiObject instanceof HasEditable) { hasEditable = (HasEditable) uiObject; } else if (uiObject instanceof TextBoxBase) { TextBoxBase textboxBase = (TextBoxBase) uiObject; if (textboxBase.getParent() instanceof HasEditable) { hasEditable = (HasEditable) textboxBase.getParent(); } else { textboxBase.setReadOnly(!editable); } } if (hasEditable != null) { hasEditable.setEditable(editable); } } else if (QAMLConstants.PROPERTY_VISIBLE.equals(setProperty.getProperty())) { boolean value = Boolean.valueOf(setProperty.getValue()).booleanValue(); if (uiObject instanceof HasVisible) { ((HasVisible) uiObject).processVisible(value); } else if (uiObject instanceof HasDataGridMethods) { HasDataGridMethods hasDataGridMethods = (HasDataGridMethods) uiObject; boolean resolved = false; String uuid = builtInComponentGVO.getComponentIdUUID(); if (uuid != null) { boolean containsColumn = uuid.contains("."); if (containsColumn) { String columnId = uuid.replaceFirst(".+\\.", "").replaceFirst("\\|.+", ""); hasDataGridMethods.setColumnVisible(columnId, value); resolved = true; } } if (!resolved) { uiObject.setVisible(value); hasDataGridMethods.redraw(); } } else { uiObject.setVisible(value); if (uiObject instanceof Panel) { Panel p = (Panel) uiObject; Widget parent = p.getParent(); if (parent != null && parent instanceof DeckPanel) { DeckPanel deckPanel = (DeckPanel) parent; int widgetIndex = deckPanel.getWidgetIndex(p); if (widgetIndex != -1) { if (deckPanel.getParent() != null && deckPanel.getParent().getParent() != null && deckPanel.getParent().getParent() instanceof TabPanel) { TabPanel tabs = ((TabPanel) (deckPanel.getParent().getParent())); TabPanelRenderer.setTabVisibility(tabs, widgetIndex, value, uiObject); } } } } } } else if (QAMLConstants.PROPERTY_HEIGHT.equals(setProperty.getProperty())) { try { String height = setProperty.getValue(); if (!QAMLUtil.containsUnitIdentifier(height)) { height += QAMLUtil.DEFAULT_UNIT; } uiObject.setHeight(height); } catch (Exception e) { ClientApplicationContext.getInstance().log("Set Property on height failed", "Please check value of height (" + setProperty.getValue() + ")", true); } } else if (QAMLConstants.PROPERTY_WIDTH.equals(setProperty.getProperty())) { try { String width = setProperty.getValue(); if (!QAMLUtil.containsUnitIdentifier(width)) { width += QAMLUtil.DEFAULT_UNIT; } uiObject.setWidth(width); } catch (Exception e) { ClientApplicationContext.getInstance().log("Set Property on width failed", "Please check value of width (" + setProperty.getValue() + ")", true); } } else if (QAMLConstants.PROPERTY_TOOLTIP.equals(setProperty.getProperty())) { uiObject.setTitle(setProperty.getValue()); } else if (QAMLConstants.PROPERTY_TITLE.equals(setProperty.getProperty())) { if (uiObject instanceof CaptionPanel) { CaptionPanel p = (CaptionPanel) uiObject; p.setCaptionText(setProperty.getValue()); } } else if (QAMLConstants.PROPERTY_DISPLAYNAME.equals(setProperty.getProperty())) { if (uiObject instanceof HasDataGridMethods) { HasDataGridMethods hasDataGridMethods = (HasDataGridMethods) uiObject; String uuid = builtInComponentGVO.getComponentIdUUID(); if (uuid != null) { boolean containsColumn = uuid.contains("."); if (containsColumn) { String columnId = uuid.replaceFirst(".+\\.", "").replaceFirst("\\|.+", ""); String value = setProperty.getValue(); hasDataGridMethods.setColumnLabel(columnId, value); } } } else if (uiObject instanceof PushButton) { ((PushButton) uiObject).getUpFace().setText(setProperty.getValue()); ((PushButton) uiObject).getDownFace().setText(setProperty.getValue()); } else if (uiObject instanceof HasText) { HasText t = (HasText) uiObject; t.setText(setProperty.getValue()); } else if (uiObject instanceof VerticalPanel) { VerticalPanel vp = (VerticalPanel) uiObject; Widget tabPanelWidget = vp.getParent().getParent().getParent(); if (tabPanelWidget instanceof TabPanel) { TabPanel tp = (TabPanel) tabPanelWidget; TabBar tb = tp.getTabBar(); int tabCount = tp.getWidgetCount(); for (int i = 0; i < tabCount; i++) { Widget w = tp.getWidget(i); if (w == vp) { tb.setTabText(i, setProperty.getValue()); } } } } else if (uiObject instanceof QWindowPanel) { QWindowPanel p = (QWindowPanel) uiObject; p.setCaption(setProperty.getValue()); } } else if (QAMLConstants.PROPERTY_SELECTED_ROW.equals(setProperty.getProperty())) { if (uiObject instanceof HasDataGridMethods) { HasDataGridMethods hasDataGridMethods = (HasDataGridMethods) uiObject; try { int rowNr = Integer.parseInt(setProperty.getValue()); hasDataGridMethods.selectRow(rowNr); } catch (Exception e) { ClientApplicationContext.getInstance() .log("Set property on the datagrid selected row: the value (" + setProperty.getValue() + ") cannot be translated into an integer", e); } } } else if (QAMLConstants.PROPERTY_SELECTED.equals(setProperty.getProperty())) { if (uiObject instanceof CheckBox) { boolean value = Boolean.valueOf(setProperty.getValue()).booleanValue(); ((CheckBox) (uiObject)).setValue(value); } else if (uiObject instanceof ListBox) { ListBox listBox = (ListBox) uiObject; int size = listBox.getItemCount(); boolean selected = false; for (int i = 0; i < size && !selected; i++) { if (listBox.getValue(i).equals(setProperty.getValue())) { selected = true; listBox.setSelectedIndex(i); } } } } else if (QAMLConstants.PROPERTY_CURRENT_PAGE.equals(setProperty.getProperty())) { if (uiObject instanceof HasDataGridMethods) { HasDataGridMethods dataGridSortableTable = (HasDataGridMethods) uiObject; try { if (setProperty.getValue() != null) { dataGridSortableTable.setCurrentPage(Integer.parseInt(setProperty.getValue())); } } catch (Exception e) { e.printStackTrace(); } } } else if (QAMLConstants.PROPERTY_PAGESIZE.equals(setProperty.getProperty())) { if (uiObject instanceof HasDataGridMethods) { HasDataGridMethods dataGridSortableTable = (HasDataGridMethods) uiObject; try { if (setProperty.getValue() != null) { dataGridSortableTable.setPageSize(Integer.parseInt(setProperty.getValue())); } } catch (Exception e) { e.printStackTrace(); } } } else if (QAMLConstants.PROPERTY_MAX_TICKS.equals(setProperty.getProperty())) { if (uiObject instanceof QSliderBar) { QSliderBar slider = (QSliderBar) uiObject; slider.setMaxValue(Double.valueOf(setProperty.getValue())); } } else if (QAMLConstants.PROPERTY_MIN_TICKS.equals(setProperty.getProperty())) { if (uiObject instanceof QSliderBar) { QSliderBar slider = (QSliderBar) uiObject; slider.setMinValue(Double.valueOf(setProperty.getValue())); } } else if (QAMLConstants.PROPERTY_TICKSIZE.equals(setProperty.getProperty())) { if (uiObject instanceof QSliderBar) { QSliderBar slider = (QSliderBar) uiObject; slider.setStepSize(Integer.valueOf(setProperty.getValue())); } } else if (QAMLConstants.PROPERTY_TICK_LABELS.equals(setProperty.getProperty())) { if (uiObject instanceof QSliderBar) { QSliderBar slider = (QSliderBar) uiObject; slider.setTickLabels(Integer.valueOf(setProperty.getValue())); } } }
From source file:com.qualogy.qafe.gwt.client.vo.handlers.SetPropertyHandler.java
License:Apache License
private void handleDisplayName(UIObject uiObject, BuiltInComponentGVO builtInComponentGVO, String value) { if (uiObject instanceof HasDataGridMethods) { HasDataGridMethods hasDataGridMethods = (HasDataGridMethods) uiObject; String uuid = builtInComponentGVO.getComponentIdUUID(); if (uuid != null) { boolean containsColumn = uuid.contains("."); if (containsColumn) { String columnId = uuid.replaceFirst(".+\\.", "").replaceFirst("\\|.+", ""); hasDataGridMethods.setColumnLabel(columnId, value); }/*from w w w . j av a 2s . c o m*/ } } else if (uiObject instanceof PushButton) { ((PushButton) uiObject).getUpFace().setText(value); ((PushButton) uiObject).getDownFace().setText(value); } else if (uiObject instanceof HasText) { HasText t = (HasText) uiObject; t.setText(value); } else if (uiObject instanceof VerticalPanel) { VerticalPanel vp = (VerticalPanel) uiObject; Widget tabPanelWidget = vp.getParent().getParent().getParent(); if (tabPanelWidget instanceof TabPanel) { TabPanel tp = (TabPanel) tabPanelWidget; TabBar tb = tp.getTabBar(); int tabCount = tp.getWidgetCount(); for (int i = 0; i < tabCount; i++) { Widget w = tp.getWidget(i); if (w == vp) { tb.setTabText(i, value); } } } } else if (uiObject instanceof QWindowPanel) { QWindowPanel p = (QWindowPanel) uiObject; p.setCaption(value); } }
From source file:net.officefloor.demo.stocks.client.StockGraphWidget.java
License:Open Source License
/** * Initiate./*from www . j a v a 2 s . co m*/ * * @param historyPeriod * Time in milliseconds to display history of prices. * @param redrawPeriod * Time in milliseconds to allow before complete redraw of the * graph. * @param width * Width. * @param height * Height. * @param stocks * {@link Stock} instances to graph. */ public StockGraphWidget(final long historyPeriod, final long redrawPeriod, final String width, final String height, Stock... stocks) { // Create sorted copy of stocks final Stock[] orderedStocks = new Stock[stocks.length]; for (int i = 0; i < orderedStocks.length; i++) { orderedStocks[i] = stocks[i]; } Arrays.sort(orderedStocks, new Comparator<Stock>() { @Override public int compare(Stock a, Stock b) { return String.CASE_INSENSITIVE_ORDER.compare(a.getName(), b.getName()); } }); // Load the chart visualisation Runnable loadGraph = new Runnable() { @Override public void run() { // Provide tab panel for graphs TabPanel tab = new TabPanel(); tab.setWidth(width); tab.getTabBar().setWidth(width); tab.getDeckPanel().setWidth(width); StockGraphWidget.this.add(tab); // Load each graph onto a tab final StockGraph[] graphs = new StockGraph[orderedStocks.length]; for (int i = 0; i < orderedStocks.length; i++) { Stock stock = orderedStocks[i]; // Create the stock graph StockGraph graph = new StockGraph(stock, historyPeriod, redrawPeriod, width, height); graphs[i] = graph; // Add the stock graph tab.add(graph.getChart(), stock.getName()); } // Provide the selection handler tab.addSelectionHandler(new SelectionHandler<Integer>() { @Override public void onSelection(SelectionEvent<Integer> event) { // Unselect all graphs for (StockGraph graph : graphs) { graph.setSelected(false); } // Select the graph for the tab Integer tabIndex = event.getSelectedItem(); graphs[tabIndex.intValue()].setSelected(true); } }); // Display first tab selected (also sets up graph) tab.selectTab(0); } }; VisualizationUtils.loadVisualizationApi(loadGraph, AnnotatedTimeLine.PACKAGE); }
From source file:org.freemedsoftware.gwt.client.screen.patient.SummaryScreen.java
License:Open Source License
public SummaryScreen() { final FlexTable flexTable = new FlexTable(); initWidget(flexTable);/* w ww . j a v a2 s. com*/ flexTable.setSize("100%", "100%"); final VerticalPanel verticalPanel = new VerticalPanel(); verticalPanel.setWidth("70%"); flexTable.setWidget(0, 0, verticalPanel); /* * final Label actionItemsLabel = new Label("ACTION ITEMS"); * actionItemsLabel.setStylePrimaryName("label_bold"); * verticalPanel.add(actionItemsLabel); final SimplePanel cActionItems = * new SimplePanel(); * cActionItems.setStylePrimaryName("freemed-PatientSummaryContainer"); * verticalPanel.add(cActionItems); * verticalPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP); */ // Adding messages panel actionItemsBox = new ActionItemsBox(false); actionItemsBox.setWidth("100%"); actionItemsBox.setEnableCollapse(false); verticalPanel.add(actionItemsBox); final CustomTable customSortableTable = new CustomTable(); verticalPanel.add(customSortableTable); final VerticalPanel problemContainer = new VerticalPanel(); problemContainer.setWidth("70%"); // final Label problemLabel = new Label("Problems"); // problemLabel.setStylePrimaryName("freemed-PatientSummaryHeading"); // problemContainer.add(problemLabel); final SimplePanel cProblemList = new SimplePanel(); cProblemList.setStylePrimaryName("freemed-PatientSummaryContainer"); problemList = new PatientProblemList(); problemList.setPatientScreen(patientScreen); cProblemList.setWidget(problemList); problemContainer.add(cProblemList); flexTable.setWidget(1, 0, problemContainer); final VerticalPanel verticalPanel_1 = new VerticalPanel(); verticalPanel_1.setWidth("70%"); flexTable.setWidget(2, 0, verticalPanel_1); // final Label clinicalInformationLabel = new // Label("Clinical Information"); // clinicalInformationLabel // .setStylePrimaryName("freemed-PatientSummaryHeading"); // clinicalInformationLabel.setWidth("78%"); // verticalPanel_1.add(clinicalInformationLabel); final SimplePanel cClinicalInformation = new SimplePanel(); // cClinicalInformation // .setStylePrimaryName("freemed-PatientSummaryContainer"); cClinicalInformation.setWidth("100%"); verticalPanel_1.add(cClinicalInformation); verticalPanel_1.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP); final TabPanel clinicalInformationTabPanel = new TabPanel(); clinicalInformationTabPanel.setSize("100%", "100%"); TabBar tbar = clinicalInformationTabPanel.getTabBar(); Element tabBarFirstChild = tbar.getElement().getFirstChildElement().getFirstChildElement() .getFirstChildElement(); tabBarFirstChild.setAttribute("width", "100%"); tabBarFirstChild.setInnerHTML(_("CLINICAL INFORMATION")); tabBarFirstChild.setClassName("label_bold"); cClinicalInformation.setWidget(clinicalInformationTabPanel); final SimplePanel clinicalTagsPanel = new SimplePanel(); patientTags = new PatientTagsWidget(); clinicalTagsPanel.add(patientTags); addChildWidget(patientTags); final Image tagsLabel = new Image(); tagsLabel.setUrl("resources/images/dashboard.16x16.png"); tagsLabel.setTitle(_("Patient Tags")); clinicalInformationTabPanel.add(clinicalTagsPanel, tagsLabel); /* * final SimplePanel clinicalPhotoIdPanel = new SimplePanel(); final * Image photoIdLabel = new Image(); * photoIdLabel.setUrl("resources/images/patient.16x16.png"); * photoIdLabel.setTitle("Photo Identification"); photoId = new Image(); * photoId.setWidth("230px"); clinicalPhotoIdPanel.add(photoId); * clinicalInformationTabPanel.add(clinicalPhotoIdPanel, photoIdLabel); */ final SimplePanel clinicalMedicationsPanel = new SimplePanel(); recentMedicationsList = new RecentMedicationsList(); clinicalMedicationsPanel.add(recentMedicationsList); addChildWidget(recentMedicationsList); final Image medicationsLabel = new Image(); medicationsLabel.setUrl("resources/images/rx_prescriptions.16x16.png"); medicationsLabel.setTitle(_("Medications")); clinicalInformationTabPanel.add(clinicalMedicationsPanel, medicationsLabel); final SimplePanel clinicalAllergiesPanel = new SimplePanel(); recentAllergiesList = new RecentAllergiesList(); clinicalAllergiesPanel.add(recentAllergiesList); addChildWidget(recentAllergiesList); final Image allergiesLabel = new Image(); allergiesLabel.setUrl("resources/images/allergy.16x16.png"); allergiesLabel.setTitle(_("Allergies")); clinicalInformationTabPanel.add(clinicalAllergiesPanel, allergiesLabel); final VerticalPanel verticalPanel_2 = new VerticalPanel(); verticalPanel_2.setWidth("70%"); flexTable.setWidget(3, 0, verticalPanel_2); financialWidget = new FinancialWidget(); final SimplePanel cFinancial = new SimplePanel(); cFinancial.setStylePrimaryName("freemed-PatientSummaryContainer"); cFinancial.setWidget(financialWidget); verticalPanel_2.add(cFinancial); JsonUtil.debug("selectTab(0)"); clinicalInformationTabPanel.selectTab(0); }
From source file:org.jboss.as.console.client.shared.deployment.DeploymentStep1.java
License:Open Source License
public Widget asWidget() { final TabPanel tabs = new TabPanel(); tabs.setStyleName("default-tabpanel"); // -------//from ww w. j a v a2 s .c om VerticalPanel layout = new VerticalPanel(); layout.setStyleName("window-content"); // Create a FormPanel and point it at a service. final FormPanel form = new FormPanel(); String url = Console.getBootstrapContext().getProperty(BootstrapContext.DEPLOYMENT_API); form.setAction(url); form.setEncoding(FormPanel.ENCODING_MULTIPART); form.setMethod(FormPanel.METHOD_POST); // Create a panel to hold all of the form widgets. VerticalPanel panel = new VerticalPanel(); panel.getElement().setAttribute("style", "width:100%"); form.setWidget(panel); // Create a FileUpload widget. final FileUpload upload = new FileUpload(); upload.setName("uploadFormElement"); panel.add(upload); final HTML errorMessages = new HTML("Please chose a file!"); errorMessages.setStyleName("error-panel"); errorMessages.setVisible(false); panel.add(errorMessages); // Add a 'submit' button. ClickHandler cancelHandler = new ClickHandler() { @Override public void onClick(ClickEvent event) { window.hide(); } }; ClickHandler submitHandler = new ClickHandler() { @Override public void onClick(ClickEvent event) { errorMessages.setVisible(false); // verify form String filename = upload.getFilename(); if (tabs.getTabBar().getSelectedTab() == 1) { // unmanaged content if (unmanagedForm.validate().hasErrors()) { return; } else { wizard.onCreateUnmanaged(unmanagedForm.getUpdatedEntity()); } } else if (filename != null && !filename.equals("")) { loading = Feedback.loading(Console.CONSTANTS.common_label_plaseWait(), Console.CONSTANTS.common_label_requestProcessed(), new Feedback.LoadingCallback() { @Override public void onCancel() { } }); form.submit(); } else { errorMessages.setVisible(true); } } }; DialogueOptions options = new DialogueOptions(Console.CONSTANTS.common_label_next(), submitHandler, Console.CONSTANTS.common_label_cancel(), cancelHandler); // Add an event handler to the form. form.addSubmitCompleteHandler(new FormPanel.SubmitCompleteHandler() { @Override public void onSubmitComplete(FormPanel.SubmitCompleteEvent event) { getLoading().hide(); String html = event.getResults(); // Step 1: upload content, retrieve hash value try { String json = html; try { if (!GWT.isScript()) // TODO: Formpanel weirdness json = html.substring(html.indexOf(">") + 1, html.lastIndexOf("<")); } catch (StringIndexOutOfBoundsException e) { // if I get this exception it means I shouldn't strip out the html // this issue still needs more research Log.debug("Failed to strip out HTML. This should be preferred?"); } JSONObject response = JSONParser.parseLenient(json).isObject(); JSONObject result = response.get("result").isObject(); String hash = result.get("BYTES_VALUE").isString().stringValue(); // step2: assign name and group wizard.onUploadComplete(upload.getFilename(), hash); } catch (Exception e) { Log.error(Console.CONSTANTS.common_error_failedToDecode() + ": " + html, e); } // Option 2: Unmanaged content } }); String stepText = "<h3>" + Console.CONSTANTS.common_label_step() + "1/2: " + Console.CONSTANTS.common_label_deploymentSelection() + "</h3>"; layout.add(new HTML(stepText)); HTML description = new HTML(); description.setHTML(Console.CONSTANTS.common_label_chooseFile()); description.getElement().setAttribute("style", "padding-bottom:15px;"); layout.add(description); layout.add(form); // Unmanaged form VerticalPanel unmanagedPanel = new VerticalPanel(); unmanagedPanel.setStyleName("window-content"); String unmanagedText = "<h3>" + Console.CONSTANTS.common_label_step() + "1/1: Specify Deployment</h3>"; unmanagedPanel.add(new HTML(unmanagedText)); unmanagedForm = new Form<DeploymentRecord>(DeploymentRecord.class); TextAreaItem path = new TextAreaItem("path", "Path"); TextBoxItem relativeTo = new TextBoxItem("relativeTo", "Relative To", false); TextBoxItem name = new TextBoxItem("name", "Name"); TextBoxItem runtimeName = new TextBoxItem("runtimeName", "Runtime Name"); CheckBoxItem archive = new CheckBoxItem("archive", "Is Archive?"); archive.setValue(true); unmanagedForm.setFields(path, relativeTo, archive, name, runtimeName); unmanagedPanel.add(unmanagedForm.asWidget()); // Composite view tabs.add(layout, "Managed"); tabs.add(unmanagedPanel, "Unmanaged"); tabs.selectTab(0); return new WindowContentBuilder(tabs, options).build(); }
From source file:org.xwiki.gwt.user.client.TabPanelSelector.java
License:Open Source License
@Override public void onBeforeSelection(BeforeSelectionEvent<Integer> event) { if (!event.isCanceled()) { TabPanel tabPanel = (TabPanel) event.getSource(); int selectedTabIndex = tabPanel.getTabBar().getSelectedTab(); // Check if there is a selected tab and the tab to be selected is not the same. if (selectedTabIndex >= 0 && selectedTabIndex != event.getItem()) { Widget selectedTab = tabPanel.getDeckPanel().getWidget(selectedTabIndex); if (selectedTab instanceof Selectable && ((Selectable) selectedTab).isSelected()) { // Notify the tab before it is hidden. ((Selectable) selectedTab).setSelected(false); }/*w w w. j a va 2s .co m*/ } } }
From source file:ro.zg.opengroups.gwt.client.views.EntityUserActionsTabView.java
License:Apache License
private void addCommandDefinitionsList(final CommandDefinitionsList cdl, final List<Integer> desiredActionPath, final TabPanel tabPanel) { final Map<Integer, CommandDefinition> commandsMap = new LinkedHashMap<Integer, CommandDefinition>(); final Map<Integer, BaseGwtView> viewsMap = new HashMap<Integer, BaseGwtView>(); if (cdl != null) { int tabIndex = 0; for (CommandDefinition cd : cdl.getCommandDefinitions().values()) { commandsMap.put(tabIndex, cd); if (cd instanceof CommandDefinitionsList) { EntityUserActionsTabView newView = (EntityUserActionsTabView) createViewForType( ViewsTypes.ENTITY_USER_ACTIONS_TAB_VIEW, this); TabPanel currentTabPanel = newView.construct(); currentTabPanel.getTabBar().setStylePrimaryName("og-CommandsTabBar"); currentTabPanel.getDeckPanel().setStylePrimaryName("og-CommandsTabPanelBottom"); tabPanel.add(currentTabPanel, cd.getDisplayName()); viewsMap.put(tabIndex, newView); } else { BaseGwtView newView = (BaseGwtView) createViewForCommand(cd.getActionName(), this); tabPanel.add(newView.construct(), cd.getDisplayName()); viewsMap.put(tabIndex, newView); }/* www . j a va 2 s.c om*/ tabIndex++; } /* set the selection listener */ handlerReg = tabPanel.addSelectionHandler(new SelectionHandler<Integer>() { public void onSelection(SelectionEvent<Integer> event) { Integer si = event.getSelectedItem(); updateCurrentActionPath(si); BaseGwtView view = viewsMap.get(si); if (view instanceof EntityUserActionsTabView) { ((EntityUserActionsTabView) view).update((CommandDefinitionsList) commandsMap.get(si), desiredActionPath, new ArrayList<Integer>(currentActionPath)); } else { CommandDefinition cd = commandsMap.get(si); UserEvent userEvent = new UserEvent(); userEvent.setSourceViewType(getViewType()); userEvent.setElementId(COMMANDS_TAB); userEvent.setEventType(UserEvent.CLICK); userEvent.addEventParam(UserEventParams.COMMAND_ID, cd.getUniqueCommandDesc()); userEvent.addEventParam(OpenGroupsParams.CURRENT_TAB_ACTION_PATH, new ArrayList<Integer>(currentActionPath)); userEvent.setTargetViewId(view.getId()); System.out.println(userEvent.getFullEventType()); dispatchEventToManager(userEvent); } } }); /* if didn't tell otherwise, select the first action */ int nextIndex = 0; /* select the desired action */ if (desiredActionPath != null && desiredActionPath.size() > 0) { nextIndex = desiredActionPath.remove(0); } currentActionPath.add(nextIndex); tabPanel.selectTab(nextIndex); } }