public Widget draw() { VerticalPanel vp = new VerticalPanel(); vp.getElement().setAttribute("style", "padding-top: 5px;"); vp.setSize("100%", "100%"); FindAllAuthors callback = new FindAllAuthors(); CellTable<Author> table = callback.getTable( new FieldUpdater<Author, String>() { public void update(int index, Author object, String value) { if (session.isPerunAdmin()) { session.getTabManager().addTab(new UsersPublicationsTabItem(object.getId())); } } }); table.addStyleName("perun-table"); ScrollPanel sp = new ScrollPanel(); sp.add(table); sp.addStyleName("perun-tableScrollPanel"); vp.add(sp); // resize perun table to correct size on screen session.getUiElements().resizeSmallTabPanel(sp, 350, this); this.contentWidget.setWidget(vp); return getWidget(); }
public Widget draw() { // main panel VerticalPanel vp = new VerticalPanel(); vp.getElement().setAttribute("style", "padding-top: 5px;"); vp.setSize("100%", "100%"); FindAllPublicationSystems call = new FindAllPublicationSystems(); call.setCheckable(false); CellTable<PublicationSystem> table = call.getTable(); table.addStyleName("perun-table"); ScrollPanel sp = new ScrollPanel(); sp.add(table); sp.addStyleName("perun-tableScrollPanel"); vp.add(sp); // resize perun table to correct size on screen session.getUiElements().resizeSmallTabPanel(sp, 350, this); this.contentWidget.setWidget(vp); return getWidget(); }
private Widget appendComment(DiscussionRecord r) { SmallLabel hrd = new SmallLabel(constants.smallCommentBy0On1Small(r.author, new Date(r.timestamp))); hrd.addStyleName("discussion-header"); commentList.add(hrd); String[] parts = r.note.split("\n"); if (parts.length > 0) { StringBuilder txtBuilder = new StringBuilder(); for (int i = 0; i < parts.length; i++) { txtBuilder.append(parts[i]); if (i != parts.length - 1) { txtBuilder.append("<br/>"); } } HTML hth = new HTML(txtBuilder.toString()); hth.setStyleName("form-field"); commentList.add(hth); } else { Label lbl = new Label(r.note); lbl.setStyleName("form-field"); commentList.add(lbl); } commentList.add(new HTML("<br/>")); return hrd; }
private Panel createNewNameInput(final ScrollPanel contentPanel) { VerticalPanel form = new VerticalPanel(); HorizontalPanel nameForm = new HorizontalPanel(); nameForm.add(new Label("Name")); final TextBox nameTextBox = new TextBox(); nameTextBox.setName("personName"); nameForm.add(nameTextBox); form.add(nameForm); Button saveButton = new Button( "Store", new ClickListener() { public void onClick(Widget sender) { String name = nameTextBox.getText(); RaffleServiceGwtRemoteAsync service = RaffleServiceGwtRemote.App.getInstance(); AsyncCallback callback = new AsyncCallback() { public void onFailure(Throwable caught) { GWT.log("Failure while creating a new name", caught); } public void onSuccess(Object result) { contentPanel.setWidget(new Label("Name is stored")); } }; service.storeName(name, callback); } }); form.add(saveButton); return form; }
public void run(final RootPanel rp, final String nick) { if (Cookies.getCookie(nick) == null) Cookies.setCookie(nick, "" + 0); cl.setPageSize(500); final Button sendMessage = new Button( "sendMessage", new ClickHandler() { public void onClick(ClickEvent event) { if (!message.getText().equals("")) { new Post().postJson(SERVERURL, nick.toString(), message.getText()); message.setText(""); } } }); rp.get("mainDiv2").setVisible(true); message.getElement().setAttribute("placeholder", "Introduce your message"); message.getElement().setAttribute("id", "message"); cl.getElement().setAttribute("id", "chatBox"); sendMessage.getElement().setAttribute("id", "sendMessage"); sendMessage.setText("Send"); vp.getElement().setAttribute("id", "verticalPanel"); hp.getElement().setAttribute("id", "horizontalPanel"); panel.getElement().setAttribute("id", "scroller"); hp.add(message); hp.add(sendMessage); panel.add(cl); vp.add(panel); vp.add(hp); rp.get("mainDiv2").add(vp); Timer t = new Timer() { @Override public void run() { getMessages(); if (chatList != null && Integer.parseInt(Cookies.getCookie(nick)) < chatList.size()) { cl.setRowCount(chatList.size() + 1, true); cl.setRowData( Integer.parseInt(Cookies.getCookie(nick)), chatList.subList(Integer.parseInt(Cookies.getCookie(nick)), chatList.size())); panel.setVerticalScrollPosition(panel.getMaximumVerticalScrollPosition() - 1); Cookies.setCookie(nick, "" + chatList.size()); } } }; t.scheduleRepeating(1000); }
private void showAddNewComment() { newCommentLayout.clear(); final TextArea comment = new TextArea(); comment.setWidth("100%"); newCommentLayout.add(comment); Button ok = new Button(constants.OK()); Button cancel = new Button(constants.Cancel()); ok.addClickHandler( new ClickHandler() { public void onClick(ClickEvent sender) { sendNewComment(comment.getText()); } }); cancel.addClickHandler( new ClickHandler() { public void onClick(ClickEvent sender) { showNewCommentButton(); } }); HorizontalPanel hp = new HorizontalPanel(); hp.add(ok); hp.add(cancel); newCommentLayout.add(hp); comment.setFocus(true); }
@Override protected void onAttach() { super.onAttach(); Image img = new Image( getBaseImageUrl() + "?merchant_id=" + getMerchantId() + "&w=" + getWidth() + "&h=" + getHeight() + "&style=" + getStyle() + "&variant=" + getVariant() + "&loc=" + getLoc()); img.setTitle("Fast checkout through Google"); PushButton pb = new PushButton(img); pb.addClickHandler(this); vpanel.clear(); vpanel.add(pb); }
/** Constructor that builds the view that holds a title and all the phone calls if they exist. */ public PhoneBillView() { VerticalPanel panel = new VerticalPanel(); panel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); panel.add(new HTML("<h2>View the Phone Bill</h2>")); panel.add(table); initWidget(panel); }
private List<Parameter> getCurrentParameters() { List<Parameter> parameters = new ArrayList<Parameter>(); for (int i = 0; i < parametersPanel.getWidgetCount(); i++) { HorizontalPanel entry = (HorizontalPanel) parametersPanel.getWidget(i); parameters.add(new Parameter(getParameterKey(entry), getParameterValue(entry))); } return parameters; }
private void showNewCommentButton() { newCommentLayout.clear(); HorizontalPanel hp = new HorizontalPanel(); Button createNewComment = new Button(constants.AddADiscussionComment()); createNewComment.setEnabled(!this.readOnly); hp.add(createNewComment); if (UserCapabilities.INSTANCE.hasCapability(Capability.SHOW_ADMIN)) { Button adminClearAll = new Button(constants.EraseAllComments()); adminClearAll.setEnabled(!readOnly); hp.add(adminClearAll); adminClearAll.addClickHandler( new ClickHandler() { public void onClick(ClickEvent sender) { if (Window.confirm(constants.EraseAllCommentsWarning())) { assetService.clearAllDiscussionsForAsset( artifact.getUuid(), new GenericCallback<java.lang.Void>() { public void onSuccess(Void v) { updateCommentList(new ArrayList<DiscussionRecord>()); } }); } } }); } final String feedURL = GWT.getModuleBaseURL() + "feed/discussion?package=" + ((Asset) artifact).getMetaData().getModuleName() + "&assetName=" + URL.encode(artifact.getName()) + "&viewUrl=" + Util.getSelfURL(); Image image = new Image(images.feed()); image.addClickHandler( new ClickHandler() { public void onClick(ClickEvent arg0) { Window.open(feedURL, "_blank", null); } }); hp.add(image); newCommentLayout.add(hp); newCommentLayout.setCellHorizontalAlignment(hp, HasHorizontalAlignment.ALIGN_RIGHT); createNewComment.addClickHandler( new ClickHandler() { public void onClick(ClickEvent sender) { showAddNewComment(); } }); }
private void initialize() { this.container = new VerticalPanel(); container.setWidth("100%"); //noinspection GWTStyleCheck this.container.addStyleName("rhea-RheaViewer"); String msg = "Loading the Rhea structure. Please wait..."; container.add(getMessage(Images.INSTANCE.getLoadingImage(), msg)); initWidget(container); }
private void refreshParameters() { getSelectedConfiguration().clearParameters(); for (int i = parametersPanel.getWidgetCount() - 1; i >= 0; i--) { HorizontalPanel entry = (HorizontalPanel) parametersPanel.getWidget(i); String key = getParameterKey(entry); if (mustDiscardParameter(key)) removeParameter(entry); else getSelectedConfiguration().addParameter(new Parameter(key, getParameterValue(entry))); } }
private void sendNewComment(String text) { newCommentLayout.clear(); newCommentLayout.add(new Image(images.spinner())); assetService.addToDiscussionForAsset( artifact.getUuid(), text, new GenericCallback<List<DiscussionRecord>>() { public void onSuccess(List<DiscussionRecord> result) { showNewCommentButton(); updateCommentList(result); } }); }
@UiHandler("runButton") void runSQLCode(ClickEvent event) { resultStatusTextBox.setVisible(false); presenter.runSQLCode(codeEditor.getValue()); loadingBar.setVisible(true); quickCodeResult.setVisible(false); }
/** * Sets the content widget which can be opened and closed by this panel. If there is a preexisting * content widget, it will be detached. * * @param content the widget to be used as the content panel */ public void setContent(final Widget content) { final Widget currentContent = this.content; // Remove existing content widget. if (currentContent != null) { mainPanel.remove(currentContent); currentContent.removeStyleName(STYLENAME_CONTENT); } // Add new content widget if != null. this.content = content; if (content != null) { mainPanel.add(content); content.addStyleName(STYLENAME_CONTENT); setContentDisplay(); } }
private void setupSettingsPanel() { SplitLayoutPanel root = (SplitLayoutPanel) widget; root.setWidgetToggleDisplayAllowed(settingsPanel, true); testsMetricsPanel.showWidget(0); sessionPlotPanel = new SessionPlotPanel(plotPanel); sessionScopePlotList.add(sessionPlotPanel); }
private void updateCommentList(List<DiscussionRecord> ls) { if (ls.size() == lastCount) return; // don't want to over do it boys... commentList.clear(); lastCount = ls.size(); for (int rcdCounter = lastCount - 1; rcdCounter >= 0; rcdCounter--) { DiscussionRecord dr = ls.get(rcdCounter); appendComment(dr); } }
public DebugAgentsMessagesMapWindow() { statusBar.add(mousexLabel); statusBar.add(mouseyLabel); mousexLabel.setWidth("100px"); infoWindow = MessageInfoWindowOnCanvas.getInstance(); infoWindow.setCanvas(gwtBitsCanvas); calculatePositions(); mainAgentsPanel.add(gwtBitsCanvas); mainAgentsPanel.add(statusBar); mainAgentsPanel.add(propertyPanel); initWidget(mainAgentsPanel); gwtBitsCanvas.addMouseMoveHandler( new MouseMoveHandler() { public void onMouseMove(MouseMoveEvent event) { mouseX = event.getRelativeX(gwtBitsCanvas.getElement()); mouseY = event.getRelativeY(gwtBitsCanvas.getElement()); mousexLabel.setText("" + mouseX); mouseyLabel.setText("" + mouseY); // // IAgent newagent =getSelectedAgent(); // if (currentAgent != newagent){ // setNewAgentSelected(newagent); // } } }); gwtBitsCanvas.addMouseOverAgentHandler( new MouseOverCanvasItemHandler() { @Override public void mouseOverCanvasItem(GwtBitsCanvasItemBaseClass canvasItem) { propertyPanel.clear(); propertyPanel.add(new Label(canvasItem.getDebugString())); } }); Esb.register(this); Esb.registerScreenPosition(this, 0.9, 0.9); }
/** This is the entry point method. */ public void onModuleLoad() { sendButton = new Button("Send"); nameField = new TextBox(); nameField.setText("GWT User"); errorLabel = new Label(); // We can add style names to widgets sendButton.addStyleName("sendButton"); // Add the nameField and sendButton to the RootPanel // Use RootPanel.get() to get the entire body element RootPanel.get("nameFieldContainer").add(nameField); RootPanel.get("sendButtonContainer").add(sendButton); RootPanel.get("errorLabelContainer").add(errorLabel); // Focus the cursor on the name field when the app loads nameField.setFocus(true); nameField.selectAll(); // Create the popup dialog box dialogBox = new DialogBox(); dialogBox.setText("Remote Procedure Call"); dialogBox.setAnimationEnabled(true); closeButton = new Button("Close"); // We can set the id of a widget by accessing its Element closeButton.getElement().setId("closeButton"); textToServerLabel = new Label(); serverResponseLabel = new HTML(); VerticalPanel dialogVPanel = new VerticalPanel(); dialogVPanel.addStyleName("dialogVPanel"); dialogVPanel.add(new HTML("<b>Sending name to the server:</b>")); dialogVPanel.add(textToServerLabel); dialogVPanel.add(new HTML("<br><b>Server replies:</b>")); dialogVPanel.add(serverResponseLabel); dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_RIGHT); dialogVPanel.add(closeButton); dialogBox.setWidget(dialogVPanel); // Add a handler to close the DialogBox final ClickHandler buttonClickHandler = new ClickHandler() { public void onClick(ClickEvent event) { dialogBox.hide(); sendButton.setEnabled(true); sendButton.setFocus(true); } }; closeButton.addClickHandler(buttonClickHandler); // Add a handler to send the name to the server ChangeEventHandler handler = new ChangeEventHandler(); sendButton.addClickHandler(handler); nameField.addKeyUpHandler(handler); }
@Override protected Widget createMainWidget() { VerticalPanel panel = new VerticalPanel(); panel.setStyleName(ThemeStyles.INSTANCE.fileUploadPanel()); // directory panel HorizontalPanel directoryPanel = new HorizontalPanel(); directoryPanel.setWidth("100%"); directoryPanel.setStyleName(ThemeStyles.INSTANCE.fileUploadField()); // directory name (informational field) panel.add(new Label("Target directory:")); directoryNameWidget_ = new DirectoryNameWidget(); directoryNameWidget_.setDirectory(targetDirectory_); directoryPanel.add(directoryNameWidget_); // browse directory button // JJA: removed browse button (was causing confusion for users who // thought it was what they should press to browse local files) /* Button browseButton = new Button("Browse...", new BrowseDirectoryClickHandler()); browseButton.getElement().getStyle().setMarginRight(5, Unit.PX); directoryPanel.add(browseButton); directoryPanel.setCellHorizontalAlignment( browseButton, HasHorizontalAlignment.ALIGN_RIGHT); */ panel.add(directoryPanel); // filename field panel.add(new Label("File to upload:")); fileUpload_ = new FileUpload(); fileUpload_.setStyleName(ThemeStyles.INSTANCE.fileUploadField()); fileUpload_.setName("file"); panel.add(fileUpload_); // zip file tip field HTML tip = new HTML( "<b>TIP</b>: To upload multiple files or a " + "directory, create a zip file. The zip file will " + "be automatically expanded after upload."); tip.addStyleName(ThemeStyles.INSTANCE.fileUploadField()); tip.addStyleName(ThemeStyles.INSTANCE.fileUploadTipLabel()); panel.add(tip); // target directory hidden field targetDirectoryHidden_ = new Hidden("targetDirectory", targetDirectory_.getPath()); panel.add(targetDirectoryHidden_); return panel; }
private void setNewAgentSelected(IAgent newagent) { currentAgent = newagent; propertyPanel.clear(); propertyPanel.add(new Label(newagent.getAgentDescription())); messagesFromAgent = new ArrayList<EsbHistoryItem>(); for (EsbHistoryItem currentHistoryItem : Esb.getHistory()) { if (currentHistoryItem.senderAgent == newagent) { messagesFromAgent.add(currentHistoryItem); } } messagesToAgent = new ArrayList<EsbHistoryItem>(); for (EsbHistoryItem currentHistoryItem : Esb.getHistory()) { for (IAgent receiverAgent : currentHistoryItem.receiverAgents) { if (receiverAgent == newagent) { messagesToAgent.add(currentHistoryItem); } } } }
private void init( final boolean isOpen, final DisclosurePanelImages images, final String headerText) { this.isOpen = isOpen; clickableHeader = new DefaultHeader(images, headerText); initWidget(mainPanel); headerPanel.add(clickableHeader); headerPanel.add(staticHeader); mainPanel.add(headerPanel); setStyleName(STYLENAME_DEFAULT); setContentDisplay(); }
public DiscussionWidget(final Artifact artifact, boolean readOnly) { this.artifact = artifact; this.readOnly = readOnly; DecoratedDisclosurePanel discussionPanel = new DecoratedDisclosurePanel(constants.Discussion()); discussionPanel.setWidth("100%"); commentList.setWidth("100%"); VerticalPanel discussionLayout = new VerticalPanel(); discussionLayout.setWidth("90%"); newCommentLayout.setWidth("100%"); refreshDiscussion(); showNewCommentButton(); discussionLayout.add(newCommentLayout); discussionLayout.add(commentList); discussionPanel.setContent(discussionLayout); pushNotify = new ServerPushNotification() { public void messageReceived(PushResponse response) { if ("discussion".equals(response.messageType) && artifact.getUuid().equals(response.message)) { System.err.println("Refreshing discussion..."); refreshDiscussion(); } } }; PushClient.instance().subscribe(pushNotify); initWidget(discussionPanel); }
/** * This is called to display the success (and a download option). * * @param buildResults */ private void showSuccessfulBuild(Panel buildResults) { buildResults.clear(); VerticalPanel vert = new VerticalPanel(); vert.add( new HTML( AbstractImagePrototype.create(images.greenTick()).getHTML() + "<i>" + constants.PackageBuiltSuccessfully() + " " + conf.getLastModified() + "</i>")); final String hyp = getDownloadLink(this.conf); HTML html = new HTML( "<a href='" + hyp + "' target='_blank'>" + constants.DownloadBinaryPackage() + "</a>"); vert.add(html); buildResults.add(vert); }
public void onModuleLoad() { // Create table for stock data. stocksFlexTable.setText(0, 0, "Symbol"); stocksFlexTable.setText(0, 1, "Price"); stocksFlexTable.setText(0, 2, "Change"); stocksFlexTable.setText(0, 3, "Remove"); // Assemble Add Stock panel. addPanel.add(newSymbolTextBox); addPanel.add(addStockButton); // Assemble Main panel. mainPanel.add(stocksFlexTable); mainPanel.add(addPanel); mainPanel.add(lastUpdateLabel); // Associate the Main panel with the HTML host page. RootPanel.get("stockList").add(mainPanel); // Move cursor focus to the input box. newSymbolTextBox.setFocus(true); initHandlers(); }
public EditorController(String divID, int width, int height) { VerticalPanel vp = new VerticalPanel(); HorizontalPanel hp = new HorizontalPanel(); SimplePanel topToolBoxWrapper = new SimplePanel(); ToggleButtonListener toggleButtonListener = new ToggleButtonListener(); topToolBox = new TopToolBox(this, toggleButtonListener); topToolBox.setStyleName("jsmoleditor-topToolBox"); topToolBoxWrapper.setWidget(topToolBox); topToolBoxWrapper.setStyleName("jsmoleditor-topTooBoxWrapper"); topToolBoxWrapper.setWidth(width + "px"); SimplePanel sideToolBoxWrapper = new SimplePanel(); elementToolBox = new ElementToolBox(this, toggleButtonListener); sideToolBoxWrapper.setWidget(elementToolBox); sideToolBoxWrapper.setStyleName("jsmoleditor-elementToolBoxWrapper"); sideToolBoxWrapper.setHeight((height - 24) + "px"); VerticalPanel vp2 = new VerticalPanel(); ExtendedCanvas canvas = new ExtendedCanvas(width - 24, height - 48); StatusBar statusBar = new StatusBar(width - 24, 24); statusBar.setHTML("Copyright chemhack.com"); renderer = new CanvasRenderer(this, canvas); vp2.add(canvas); vp2.add(statusBar); hp.add(sideToolBoxWrapper); hp.add(vp2); vp.add(topToolBoxWrapper); vp.add(hp); RootPanel rootPanel = RootPanel.get(divID); rootPanel.setPixelSize(width, height); rootPanel.add(vp); KeyboardShortCutEventPreview preview = new KeyboardShortCutEventPreview(this); // TODO deal with multiple editor instance? DOM.addEventPreview(preview); EditorMouseListener listener = new EditorMouseListener(this); canvas.addMouseListener(listener); canvas.addMouseWheelListener(listener); }
public SingleLightboxImagePanel() { VerticalPanel panel = new VerticalPanel(); panel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER); panel.setVerticalAlignment(VerticalPanel.ALIGN_MIDDLE); Label headerLabel = new Label("Single Image Demo"); panel.add(headerLabel); panel.add(getDescription()); Image image = new Image("image.jpg"); image.setTitle("Image Title"); // Not required, but will be used as caption LightboxImage lightboxImage = new LightboxImage(image); panel.add(lightboxImage); panel.add(getCodeSnippet()); initWidget(panel); }
/** Main class */ public void onModuleLoad() { // basic settings session.setUiElements(new UiElements(null)); // Get web page's BODY RootLayoutPanel body = RootLayoutPanel.get(); // check RPC url if (session.getRpcUrl().isEmpty()) { VerticalPanel bodyContents = new VerticalPanel(); bodyContents.setSize("100%", "300px"); bodyContents.add( new HTML(new Image(LargeIcons.INSTANCE.errorIcon()) + "<h2>RPC SERVER NOT FOUND!</h2>")); bodyContents.setCellHorizontalAlignment( bodyContents.getWidget(0), HasHorizontalAlignment.ALIGN_CENTER); bodyContents.setCellVerticalAlignment( bodyContents.getWidget(0), HasVerticalAlignment.ALIGN_BOTTOM); body.add(bodyContents); return; } // WEB PAGE SPLITTER body.add(bodySplitter); // left menu leftMenu = new ApplicationFormLeftMenu(); // show loading box loadingBox = session.getUiElements().perunLoadingBox(); loadingBox.show(); // switch menu event JsonCallbackEvents events = new JsonCallbackEvents() { @Override public void onFinished(JavaScriptObject jso) { bodySplitter.clear(); bodySplitter.addSouth(getFooter(), 23); ArrayList<Application> apps = JsonUtils.jsoAsList(jso); if (apps != null && !apps.isEmpty()) { // show menu bodySplitter.addWest(leftMenu, 280); } // else don't show menu // MAIN CONTENT contentPanel.setSize("100%", "100%"); contentPanel.add(leftMenu.getContent()); bodySplitter.add(contentPanel); // Append more GUI elements from UiElements class which are not part of splitted design // WE DON'T WANT TO CONFUSE USER WITH STATUS MESSAGES // bodySplitter.getElement().appendChild(session.getUiElements().getStatus().getElement()); // status // starts loading isUserMemberOfVo(); // hides the loading box loadingBox.hide(); } @Override public void onError(PerunError error) { // MAIN CONTENT bodySplitter.clear(); bodySplitter.addSouth(getFooter(), 23); contentPanel.clear(); contentPanel.setSize("100%", "100%"); contentPanel.add(leftMenu.getContent()); bodySplitter.add(contentPanel); // Append more GUI elements from UiElements class which are not part of splitted design // bodySplitter.getElement().appendChild(session.getUiElements().getStatus().getElement()); // status // starts loading isUserMemberOfVo(); // hides the loading box loadingBox.hide(); } }; // load VO to check if exists loadVo(events); }
public Widget draw() { this.titleWidget.setText( Utils.getStrippedStringWithEllipsis(group.getName()) + ": " + "ext sources"); // main panel VerticalPanel vp = new VerticalPanel(); vp.setSize("100%", "100%"); // HORIZONTAL MENU TabMenu menu = new TabMenu(); menu.addWidget(UiElements.getRefreshButton(this)); // get VO resources final GetGroupExtSources extSources = new GetGroupExtSources(groupId); // refresh table event final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(extSources); // create ext source button CustomButton addButton = TabMenu.getPredefinedButton( ButtonType.ADD, true, ButtonTranslation.INSTANCE.addExtSource(), new ClickHandler() { public void onClick(ClickEvent event) { session .getTabManager() .addTabToCurrentTab(new AddGroupExtSourceTabItem(groupId), true); } }); if (session.isVoAdmin(voId)) { menu.addWidget(addButton); } final CustomButton removeButton = TabMenu.getPredefinedButton( ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeExtSource()); removeButton.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { final ArrayList<ExtSource> extSourcesToRemove = extSources.getTableSelectedList(); String text = "Following external sources will be removed from Group. You won't be able to import members from them anymore."; UiElements.showDeleteConfirm( extSourcesToRemove, text, new ClickHandler() { @Override public void onClick(ClickEvent clickEvent) { // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !! for (int i = 0; i < extSourcesToRemove.size(); i++) { RemoveExtSource request; if (i == extSourcesToRemove.size() - 1) { request = new RemoveExtSource( JsonCallbackEvents.disableButtonEvents(removeButton, events)); } else { request = new RemoveExtSource( JsonCallbackEvents.disableButtonEvents(removeButton)); } request.removeGroupExtSource(groupId, extSourcesToRemove.get(i).getId()); } } }); } }); if (session.isVoAdmin(voId)) { menu.addWidget(removeButton); } // authorization - enable buttons for vo admin only. if (!session.isVoAdmin(voId)) { addButton.setEnabled(false); removeButton.setEnabled(false); extSources.setCheckable(false); } menu.addFilterWidget( new ExtendedSuggestBox(extSources.getOracle()), new PerunSearchEvent() { @Override public void searchFor(String text) { extSources.filterTable(text); } }, "Filter external sources by name or type"); // add menu to the main panel vp.add(menu); vp.setCellHeight(menu, "30px"); CellTable<ExtSource> table = extSources.getTable(); if (session.isVoAdmin(voId)) { removeButton.setEnabled(false); JsonUtils.addTableManagedButton(extSources, table, removeButton); } table.addStyleName("perun-table"); table.setWidth("100%"); ScrollPanel sp = new ScrollPanel(table); sp.addStyleName("perun-tableScrollPanel"); vp.add(sp); session.getUiElements().resizePerunTable(sp, 350, this); this.contentWidget.setWidget(vp); return getWidget(); }
public Widget draw() { titleWidget.setText( Utils.getStrippedStringWithEllipsis(facility.getName()) + " (" + facility.getType() + "): create resource"); VerticalPanel vp = new VerticalPanel(); vp.setSize("100%", "100%"); // form inputs final ExtendedTextBox nameTextBox = new ExtendedTextBox(); final TextBox descriptionTextBox = new TextBox(); final ListBoxWithObjects<VirtualOrganization> vosDropDown = new ListBoxWithObjects<VirtualOrganization>(); // send button final CustomButton createButton = TabMenu.getPredefinedButton(ButtonType.CREATE, ButtonTranslation.INSTANCE.createResource()); // local events fills the listbox of Vos and Slds JsonCallbackEvents event = new JsonCallbackEvents() { @Override public void onFinished(JavaScriptObject jso) { // fill VOs listbox vosDropDown.clear(); ArrayList<VirtualOrganization> vos = JsonUtils.jsoAsList(jso); vos = new TableSorter<VirtualOrganization>().sortByName(vos); for (VirtualOrganization vo : vos) { vosDropDown.addItem(vo); } if (!vos.isEmpty()) createButton.setEnabled(true); } @Override public void onLoadingStart() { vosDropDown.clear(); vosDropDown.addItem("Loading..."); createButton.setEnabled(false); } @Override public void onError(PerunError error) { vosDropDown.clear(); vosDropDown.addItem("Error while loading"); createButton.setEnabled(false); } }; // load available VOs final GetVos vos = new GetVos(event); vos.setForceAll(true); vos.retrieveData(); // layout FlexTable layout = new FlexTable(); layout.setStyleName("inputFormFlexTable"); FlexCellFormatter cellFormatter = layout.getFlexCellFormatter(); // Add some standard form options layout.setHTML(0, 0, "Name:"); layout.setWidget(0, 1, nameTextBox); layout.setHTML(1, 0, "Description:"); layout.setWidget(1, 1, descriptionTextBox); layout.setHTML(2, 0, "VO:"); layout.setWidget(2, 1, vosDropDown); layout.setHTML(3, 0, "Facility:"); layout.setHTML(3, 1, facility.getName() + " (" + facility.getType() + ")"); for (int i = 0; i < layout.getRowCount(); i++) { cellFormatter.addStyleName(i, 0, "itemName"); } layout.setWidth("350px"); TabMenu menu = new TabMenu(); final ExtendedTextBox.TextBoxValidator validator = new ExtendedTextBox.TextBoxValidator() { @Override public boolean validateTextBox() { if (nameTextBox.getTextBox().getText().trim().isEmpty()) { nameTextBox.setError("Name can't be empty."); return false; } nameTextBox.setOk(); return true; } }; nameTextBox.setValidator(validator); createButton.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { // loads new tab when creating successful, also disable button JsonCallbackEvents localEvents = new JsonCallbackEvents() { public void onLoadingStart() { (JsonCallbackEvents.disableButtonEvents(createButton)).onLoadingStart(); } public void onFinished(JavaScriptObject jso) { (JsonCallbackEvents.disableButtonEvents(createButton)).onFinished(jso); Resource res = (Resource) jso; session .getTabManager() .addTabToCurrentTab( new CreateFacilityResourceManageServicesTabItem(facility, res), true); } public void onError(PerunError error) { (JsonCallbackEvents.disableButtonEvents(createButton)).onError(error); } }; if (validator.validateTextBox()) { // request CreateResource request = new CreateResource(localEvents); request.createResource( nameTextBox.getTextBox().getText().trim(), descriptionTextBox.getText().trim(), facility.getId(), vosDropDown.getSelectedObject().getId()); } } }); menu.addWidget(createButton); final TabItem tab = this; menu.addWidget( TabMenu.getPredefinedButton( ButtonType.CANCEL, "", new ClickHandler() { @Override public void onClick(ClickEvent clickEvent) { session.getTabManager().closeTab(tab, false); } })); vp.add(layout); vp.add(menu); vp.setCellHorizontalAlignment(menu, HasHorizontalAlignment.ALIGN_RIGHT); this.contentWidget.setWidget(vp); return getWidget(); }