List of usage examples for com.google.gwt.user.client.ui Label setText
public void setText(String text)
From source file:org.dataconservancy.dcs.access.client.presenter.CuratorViewPresenter.java
License:Apache License
@Override public void bind() { userService.checkSession(null, new AsyncCallback<UserSession>() { @Override//from w w w. j ava2s . c o m public void onSuccess(final UserSession session) { if (session.getVivoId() != null) { vivoService.getAgentAffiliation(session.getVivoId(), new AsyncCallback<String>() { @Override public void onSuccess(final String repository) { registryService.getAllCOs(repository, null, SeadApp.roUrl, new AsyncCallback<List<ROMetadata>>() { @Override public void onSuccess(final List<ROMetadata> allCOs) { final Grid curatorData = new Grid(allCOs.size() + 1, 6); curatorData.setStyleName("curatorTable"); curatorData.setWidth(Window.getClientWidth() / 2 + "px"); curatorData.setWidget(0, 0, Util.label("Research Object Name", "SubsectionHeader")); curatorData.setWidget(0, 1, Util.label("Date Last Modified", "SubsectionHeader")); curatorData.setWidget(0, 2, Util.label("Current Assignment", "SubsectionHeader")); curatorData.setWidget(0, 3, Util.label("Modify Assignment", "SubsectionHeader")); curatorData.setWidget(0, 4, Util.label("Edit", "SubsectionHeader")); curatorData.setWidget(0, 5, Util.label("Publish", "SubsectionHeader")); curatorData.getRowFormatter().addStyleName(0, "curatoreHead"); int i = 1; for (final ROMetadata ro : allCOs) { if (ro.getIsObsolete() == 1) continue; Label lbName = new Label(); lbName.setText(ro.getName()); Label dateLbl = new Label(); dateLbl.setText(ro.getUpdatedDate()); curatorData.setWidget(i, 0, lbName); curatorData.setWidget(i, 1, dateLbl); final Button edit = new Button("Edit"); edit.setEnabled(false); final Button publish = new Button("Publish"); publish.setEnabled(false); final int index = i; final Button reAssign = new Button("Re-assign to me"); final Button unAssign = new Button("Unassign"); final ClickHandler publishHandler = new ClickHandler() { @Override public void onClick(ClickEvent event) { registryService.isObsolete(ro.getIdentifier(), SeadApp.registryUrl, new AsyncCallback<Boolean>() { @Override public void onSuccess(Boolean isObsolete) { if (isObsolete) { ErrorPopupPanel popupPanel = new ErrorPopupPanel( "Sorry, this RO was ingested by another curator. Please select another RO to work on."); popupPanel.show(); popupPanel.addCloseHandler( new CloseHandler<PopupPanel>() { @Override public void onClose( CloseEvent<PopupPanel> event) { History.newItem( SeadState.CURATOR .toToken( "refresh")); } }); } else { registryService.getRelation( ro.getIdentifier(), SeadApp.registryUrl, "curatedBy", new AsyncCallback<String>() { @Override public void onSuccess( String agentId) { if (agentId.equals( session.getRegistryId())) submitSip(ro .getIdentifier(), publish, edit, index, false, curatorData, unAssign); else { ErrorPopupPanel popupPanel = new ErrorPopupPanel( "Sorry, this RO was reassigned to someone else. Please select another RO to work on."); popupPanel.show(); popupPanel .addCloseHandler( new CloseHandler<PopupPanel>() { @Override public void onClose( CloseEvent<PopupPanel> event) { History.newItem( SeadState.CURATOR .toToken( "refresh")); } }); } } @Override public void onFailure( Throwable caught) { new ErrorPopupPanel( "Error:" + caught .getMessage()) .show(); } }); } } @Override public void onFailure(Throwable caught) { new ErrorPopupPanel( "Error:" + caught.getMessage()) .show(); } }); } }; final ClickHandler editClickHandler = new ClickHandler() { @Override public void onClick(ClickEvent event) { registryService.isObsolete(ro.getIdentifier(), SeadApp.registryUrl, new AsyncCallback<Boolean>() { @Override public void onSuccess(Boolean isObsolete) { if (isObsolete) { ErrorPopupPanel popupPanel = new ErrorPopupPanel( "Sorry, this RO was ingested by another curator. Please select another RO to work on."); popupPanel.show(); popupPanel.addCloseHandler( new CloseHandler<PopupPanel>() { @Override public void onClose( CloseEvent<PopupPanel> event) { History.newItem( SeadState.CURATOR .toToken( "refresh")); } }); } else { registryService.getRelation( ro.getIdentifier(), SeadApp.registryUrl, "curatedBy", new AsyncCallback<String>() { @Override public void onSuccess( String agentId) { if (agentId.equals( session.getRegistryId())) History.newItem( SeadState.EDIT .toToken( ro.getIdentifier())); else { new ErrorPopupPanel( "Sorry, this RO was reassigned to someone else. Please select another RO to work on.") .show(); History.newItem( SeadState.CURATOR .toToken( "refresh")); } } @Override public void onFailure( Throwable caught) { new ErrorPopupPanel( "Error:" + caught .getMessage()) .show(); } }); } } @Override public void onFailure(Throwable caught) { new ErrorPopupPanel( "Error:" + caught.getMessage()) .show(); } }); } }; publish.addClickHandler(publishHandler); edit.addClickHandler(editClickHandler); final Button assign = new Button("Assign to me"); ClickHandler unAssignHandler = new ClickHandler() { @Override public void onClick(ClickEvent event) { registryService.unassignFromAgent(ro.getIdentifier(), session.getRegistryId(), SeadApp.registryUrl, new AsyncCallback<Boolean>() { @Override public void onSuccess(Boolean result) { edit.setEnabled(false); publish.setEnabled(false); publish.removeStyleName("grayButton"); publish.setStyleName("gwt-Button"); curatorData.setWidget(index, 2, new Label("No one")); curatorData.setWidget(index, 3, assign); } @Override public void onFailure(Throwable caught) { unAssign.setText("Failed"); unAssign.setEnabled(false); } }); } }; unAssign.addClickHandler(unAssignHandler); assign.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { registryService.assignToAgent(ro.getIdentifier(), session.getRegistryId(), SeadApp.registryUrl, new AsyncCallback<Boolean>() { @Override public void onSuccess(Boolean result) { curatorData.setWidget(index, 2, Util.label("You", "greenFont")); curatorData.setWidget(index, 3, unAssign); assign.setEnabled(false); edit.setEnabled(true); publish.setEnabled(true); publish.setStyleName("grayButton"); } @Override public void onFailure(Throwable caught) { assign.setText("Failed"); assign.setEnabled(false); } }); } }); reAssign.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { registryService.assignToAgent(ro.getIdentifier(), session.getRegistryId(), SeadApp.registryUrl, new AsyncCallback<Boolean>() { @Override public void onSuccess(Boolean result) { curatorData.setWidget(index, 2, Util.label("You", "greenFont")); curatorData.setWidget(index, 3, unAssign); edit.setEnabled(true); publish.setEnabled(true); publish.setStyleName("grayButton"); } @Override public void onFailure(Throwable caught) { reAssign.setText("Failed"); reAssign.setEnabled(false); } }); } }); if (ro.getAgentId() == null) { curatorData.setWidget(i, 2, new Label("No one")); curatorData.setWidget(i, 3, assign); } else if (ro.getAgentId().trim() .equalsIgnoreCase(session.getRegistryId().trim())) { curatorData.setWidget(i, 2, Util.label("You", "greenFont")); curatorData.setWidget(i, 3, unAssign); edit.setEnabled(true); publish.setEnabled(true); publish.setStyleName("grayButton"); } else if (!ro.getAgentId() .equalsIgnoreCase(session.getRegistryId())) { userService.getUser(ro.getAgentId(), new AsyncCallback<Person>() { @Override public void onSuccess(Person user) { curatorData.setWidget(index, 2, Util.label( user.getFirstName() + " " + user.getLastName(), "greenFont")); curatorData.setWidget(index, 3, reAssign); } @Override public void onFailure(Throwable caught) { // TODO Auto-generated method stub } }); } curatorData.setWidget(i, 4, edit); curatorData.getRowFormatter().setStyleName(i, "CuratorRow"); curatorData.setWidget(i, 5, publish); i++; } String institution = repository; if (repository.contains("IU")) institution = "Indiana University"; display.getPublishContainer().clear(); display.getPublishContainer() .add(Util.label("Curation Objects Review for " + institution, "CurationHeader")); display.getPublishContainer().add(curatorData); } @Override public void onFailure(Throwable caught) { new ErrorPopupPanel("Error:" + caught.getMessage()).show(); } }); } @Override public void onFailure(Throwable caught) { new ErrorPopupPanel("Failed to retrieve from VIVO:" + caught.getMessage()).show(); } }); } else { new ErrorPopupPanel( "User does not have a VIVO ID, hence cannot find the Affiliation/Curator queue.") .show(); } } @Override public void onFailure(Throwable caught) { new ErrorPopupPanel("Error:" + caught.getMessage()); } }); }
From source file:org.dataconservancy.dcs.access.client.presenter.PublishDataPresenter.java
License:Apache License
private void registerPreviewUpdate() { final EntityEditEvent.Handler editHandler = new EntityEditEvent.Handler() { @Override/* w w w . j a v a 2 s . c o m*/ public void onMessageReceived(final EntityEditEvent editEvent) { // Panel outerPanel = new FlowPanel(); // outerPanel.clear(); // outerPanel.add(Util.label("Your SIP is ready for review by your Institutional Repository.", "TopHeaderText")); TreeViewModel treemodel = new DcpTree(editEvent.getDcp()); JsArray<JsDeliverableUnit> dus = editEvent.getDcp().getDeliverableUnits(); for (int i = 0; i < dus.length(); i++) { if (dus.get(i).getParents().length() == 0) { projectNameTB.setEnabled(true); abstractTB.setEnabled(true); originalTitle = dus.get(i).getCoreMd().getTitle(); originalAbstract = dus.get(i).getAbstract(); projectNameTB.setText(originalTitle); abstractTB.setText(originalAbstract); topDuId = dus.get(i).getId(); final JsDeliverableUnit du = dus.get(i); JsArray<JsAlternateId> alternateIds = dus.get(i).getAlternateIds(); boolean containsDOI = false; if (alternateIds.length() > 0) { for (int j = 0; j < alternateIds.length(); j++) { final JsAlternateId alternateId = alternateIds.get(j); if (alternateId.getTypeId().contains("doi")) { containsDOI = true; final Label warningLabel = new Label(); warningLabel.setText("It seems like this dataset was already published and " + "has an identifier." + "Would you like Virtual Archive to track provenance to this Published dataset?"); final Grid tracked = new Grid(2, 4); Label dataIdentifier = new Label("Data Identifier"); tracked.setWidget(0, 0, dataIdentifier); TextBox dataIdentifierTB = new TextBox(); dataIdentifierTB.setText(alternateId.getIdValue()); tracked.setWidget(0, 1, dataIdentifierTB); final Button trackRevision = new Button("Yes"); trackRevision.addClickHandler(new ClickHandler() { //Revision or derivation allowed @Override public void onClick(ClickEvent event) { warningLabel.setText(""); provenanceType = new Label("http://www.w3.org/ns/prov#wasDerivedFrom"); tracked.setWidget(1, 0, provenanceType); roId = new TextBox(); roId.setText(du.getId()); tracked.setWidget(1, 1, roId); warningPanel.removeStyleName("red"); tracked.remove(trackRevision); previewButton.setEnabled(true); } }); tracked.setWidget(0, 2, trackRevision); // tracked.setWidget(0, 3, new Button("No")); warningPanel.setStyleName("red"); warningPanel.add(warningLabel); warningPanel.add(tracked); break; } } } if (!containsDOI) previewButton.setEnabled(true); break; } } CellTree tree = new CellTree(treemodel, null); //tree.setStylePrimaryName("RelatedView"); tree.setHeight("90%"); tree.setAnimationEnabled(true); tree.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.BOUND_TO_SELECTION); tree.setDefaultNodeSize(50); if (tree.getRootTreeNode().getChildCount() > 0) { tree.getRootTreeNode().setChildOpen(0, editEvent.isSetOpen()); } Panel previewPanel = new ScrollPanel(); previewPanel.setWidth("95%"); previewPanel.setHeight("100%"); previewPanel.add(tree); researchObjectPanel.clear(); researchObjectPanel.add(previewPanel); ClickHandler beginIngest = new ClickHandler() { @Override public void onClick(ClickEvent event) { previewButton.setEnabled(false); if (licenseBox.getValue()) { SeadApp.userService.checkSession(null, new AsyncCallback<UserSession>() { @Override public void onSuccess(final UserSession userSession) { registryService.cleanSip(editEvent.getSipPath(), new AsyncCallback<Void>() { @Override public void onSuccess(Void result) { if (!originalTitle.equalsIgnoreCase(projectNameTB.getText()) || !originalAbstract.equalsIgnoreCase(abstractTB.getText()) || provenanceType != null) { Map<String, List<String>> changes = new HashMap<String, List<String>>(); if (provenanceType != null) { List<String> idList = new ArrayList<String>(); idList.add(roId.getText()); changes.put(provenanceType.getText(), idList); } if (!originalTitle.equalsIgnoreCase(projectNameTB.getText())) { List<String> titleList = new ArrayList<String>(); titleList.add(projectNameTB.getText()); changes.put("title", titleList); } if (!originalAbstract.equalsIgnoreCase(abstractTB.getText())) { List<String> abstractList = new ArrayList<String>(); abstractList.add(abstractTB.getText()); changes.put("abstract", abstractList); } registryService.updateSip(editEvent.getSipPath(), topDuId, changes, null, new AsyncCallback<Void>() { @Override public void onSuccess(Void result) { startWorkflow(editEvent.getSipPath(), userSession); } @Override public void onFailure(Throwable caught) { new ErrorPopupPanel("Error:" + caught.getMessage()) .show(); } }); } else { startWorkflow(editEvent.getSipPath(), userSession); } } @Override public void onFailure(Throwable caught) { new ErrorPopupPanel("Error:" + caught.getMessage()).show(); } }); } @Override public void onFailure(Throwable caught) { new ErrorPopupPanel("Error:" + caught.getMessage()).show(); } }); } else { errorMessage.setStyleName("redFont"); errorMessage.setText("*Please agree to our license terms, before publishing the data."); } } }; previewButton.addClickHandler(beginIngest); } }; EntityEditEvent.register(PublishDataView.EVENT_BUS, editHandler); }
From source file:org.dataconservancy.dcs.access.client.SeadApp.java
License:Apache License
public void onModuleLoad() { mainHorz = new FlowPanel(); accessurl_tb = new TextBox(); main = new DockLayoutPanel(Unit.PX); main.setStylePrimaryName("Main"); mainHorz.add(main);//from w w w . ja v a 2 s . c o m //header parameters header = new VerticalPanel(); header.setStylePrimaryName("TopHeader"); HTML footer = new HTML(); //Standard SEAD footer (see http://sead-data.net/) footer.setHTML("<footer id=\"colophon\" class=\"um-scope clearfix\">\n" + "<div class=\"footer-socket-wrapper clearfix\">\n" + "<div class=\"inner-wrap\">\n" + "<div class=\"footer-socket-area\">\n" + "<div class=\"copyright\"><img id=\"nsf\" src=\"http://sead-data.net/wp-content/uploads/2014/06/nsf2.png\" alt=\"NSF\" height=\"30px\" width=\"30px\">SEAD is funded by the National Science Foundation under cooperative agreement #OCI0940824.</div>\n" + "<nav class=\"small-menu\">\n" + "<div class=\"menu-footer-menu-container\"> <ul id=\"menu-footer-menu\" class=\"menu\">\n" + "<a href=\"http://sead-data.net/contactus/\">Contact Us</a></ul></div>" + "</nav>\n" + "</div>\n" + "</div>\n" + "</div>\n" + "</footer>"); outerMoreLinks = new HorizontalPanel(); outerMoreLinks.setStyleName("MoreLinkStyle"); final Grid moreLinks = new Grid(1, 4); moreLinks.setCellPadding(7); Button browseButton = new Button("Browse Data"); Button uploadButton = new Button("Publish Data"); browseButton.setStyleName("OptionButtons"); uploadButton.setStyleName("OptionButtons"); ClickHandler goUploadData1 = new ClickHandler() { public void onClick(ClickEvent event) { History.newItem(SeadState.AUTH.toToken()); } }; ClickHandler browseDataHandler = new ClickHandler() { public void onClick(ClickEvent event) { History.newItem("browse"); } }; uploadButton.addClickHandler(goUploadData1); browseButton.addClickHandler(browseDataHandler); moreLinks.setWidget(0, 1, browseButton); moreLinks.setWidget(0, 2, uploadButton); outerMoreLinks.add(moreLinks); facetOuterPanel = new FlowPanel(); facetContent = new ScrollPanel(); facetContent.setHeight("80%"); facetContent.setStyleName("CurvedPanel"); facetOuterPanel.setStyleName("FacetPanel"); facetOuterPanel.add(facetContent); loginPanel = new FlowPanel(); loginButton = new Button("LOG IN"); loginButton.setStyleName("LoginButton"); loginPanel.add(loginButton); loginButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { History.newItem("login"); } }); final Panel headerOuterPanel = new FlowPanel(); headerOuterPanel.setStyleName("HeaderOuter"); HorizontalPanel middlePanel = new HorizontalPanel(); middlePanel.setStyleName("Menu"); optionsHorz = new HorizontalPanel(); dataSearch = Util.label("Data Search", "Option"); // OptionsHorz.add(dataSearch); uploadData = Util.label("Upload Data", "Option"); // OptionsHorz.add(uploadData); home = Util.label("Home", "Option"); home.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { History.newItem(SeadState.HOME.toToken()); } }); optionsHorz.add(home); middlePanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); middlePanel.add(optionsHorz); middlePanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); headerOuterPanel.add(middlePanel); headerOuterPanel.setStyleName("Gradient"); ClickHandler goDataSearch = new ClickHandler() { public void onClick(ClickEvent event) { History.newItem(SeadState.HOME.toToken()); } }; dataSearch.addClickHandler(goDataSearch); ClickHandler goUploadData = new ClickHandler() { public void onClick(ClickEvent event) { History.newItem(SeadState.AUTH.toToken()); } }; uploadData.addClickHandler(goUploadData); adminPage = Util.label("Administration", "Option"); ClickHandler goAdminPage = new ClickHandler() { public void onClick(ClickEvent event) { History.newItem(SeadState.ADMIN.toToken()); } }; adminPage.addClickHandler(goAdminPage); curatorPage = Util.label("Curate", "Option"); ClickHandler goCuratorPage = new ClickHandler() { public void onClick(ClickEvent event) { History.newItem(SeadState.CURATOR.toToken()); } }; curatorPage.addClickHandler(goCuratorPage); activityPage = Util.label("Activity", "Option"); ClickHandler goActivityPage = new ClickHandler() { public void onClick(ClickEvent event) { History.newItem(SeadState.ACTIVITY.toToken()); } }; activityPage.addClickHandler(goActivityPage); dataHistory = Util.label("Data Ingest Monitor", "Option"); ClickHandler dataHistoryPage = new ClickHandler() { public void onClick(ClickEvent event) { History.newItem(SeadState.MONITOR.toToken()); } }; dataHistory.addClickHandler(dataHistoryPage); centerPanel = new ScrollPanel(); main.addNorth(header, 200); //Note order of insertion is important - adding south after west (and then changing the size of the west widget) // shifts the south widget to the right. If it is added first, it stays fixed. main.addSouth(footer, 51); main.addWest(facetOuterPanel, 250); main.addEast(loginPanel, 200); main.add(centerPanel); centerPanel.setStylePrimaryName("centerPanel"); uploadPanel = new TabPanel(); uploadPanel.setStylePrimaryName("UploadTabPanel"); localUpload = new FlowPanel(); mediciUpload = new FlowPanel(); bagUpload = new FlowPanel(); uploadPanel.add(localUpload, "Local Upload"); uploadPanel.add(mediciUpload, "Project Upload"); uploadPanel.selectTab(1); publishData = new FlowPanel(); publishData.addStyleName("publishPanel"); //Main SEAD menu (see http://sead-data.net/) header.add(getSeadMenu()); //The VA tab panes/menu header.add(headerOuterPanel); RootLayoutPanel.get().add(mainHorz); final AsyncCallback<UserSession> cb = new AsyncCallback<UserSession>() { public void onSuccess(UserSession result) { if (result.isSession()) { if (result.getRole() == Role.ROLE_ADMIN) { initAdminLogin(); } else if (result.getRole() == Role.ROLE_CURATOR) { initCuratorLogin(); } else { initUserLogin(); } initLogoutButton(); String displayName = ""; if (result.getfName() != null) displayName = result.getfName(); if (result.getlName() != null) displayName += " " + result.getlName(); Label displayNameLabel = new Label(); displayNameLabel.setStyleName("welcomeFont"); displayNameLabel.setText("Welcome " + displayName); loginPanel.clear(); loginPanel.add(displayNameLabel); if (!logoutButton.isAttached()) loginPanel.add(logoutButton); activityPage.setStyleName("Option"); adminPage.setStyleName("Option"); home.setStyleName("OptionSelected"); uploadData.setStyleName("Option"); curatorPage.setStyleName("Option"); } else loginPanel.add(loginButton); } public void onFailure(Throwable error) { new ErrorPopupPanel("Failed to login: " + error.getMessage()).show(); } }; History.addValueChangeHandler(new ValueChangeHandler<String>() { public void onValueChange(ValueChangeEvent<String> event) { historyChanged(event.getValue()); } }); // load config HttpGet.request(GWT.getModuleBaseURL() + "Config.properties", new HttpGet.Callback<String>() { public void failure(String error) { Window.alert("Failed to load config: " + error); } public void success(String result) { String[] pairs = result.trim().split( //"\\w*(\n|\\=)\\w*"); "\\w*\n|\\=\\w*"); for (int i = 0; i + 1 < pairs.length;) { String name = pairs[i++].trim(); String value = pairs[i++].trim(); if (name.equals("accessServiceURL")) { accessurl = value; updateAccessServiceUrl(); deposit_endpoint = accessurl + "deposit/"; } if (name.equals("datastreamServletUrl")) { datastreamUrl = value; } if (name.equals("bagItServiceURL")) { bagIturl = value; } if (name.equals("registryUrl")) { registryUrl = value; } if (name.equals("roUrl")) { roUrl = value; } if (name.equals("queryPath")) { queryPath = value; } if (name.equals("tmp")) { tmpHome = value; } if (name.equals("admins")) { String adminStr = value; admins = adminStr.split(";"); } } userService.checkSession(null, cb); History.fireCurrentHistoryState(); } }); if (Constants.predicateViewMap == null) { Constants.predicateViewMap = new HashMap<String, String>(); Constants.viewPredicateMap = new HashMap<String, String>(); HttpGet.request(GWT.getModuleBaseURL() + "CuratorDisplayConfig.properties", new HttpGet.Callback<String>() { public void failure(String error) { new ErrorPopupPanel("Failed to load config: " + error).show(); } public void success(String result) { String[] pairs = result.trim().split( //"\\w*(\n|\\=)\\w*"); "\n|\\="); for (int i = 0; i + 1 < pairs.length;) { String name = pairs[i++].trim(); String value = pairs[i++].trim(); Constants.predicateViewMap.put(name, value); Constants.viewPredicateMap.put(value, name); } } }); } //Init DB }
From source file:org.dataconservancy.dcs.access.client.SeadApp.java
License:Apache License
private void historyChanged(String token) { if (token.isEmpty()) { if (facetOuterPanel.isAttached()) { main.setWidgetSize(facetOuterPanel, 0); }//from w ww .j a v a 2s. co m if (!centerPanel.isAttached()) main.add(centerPanel); activityPage.setStyleName("Option"); adminPage.setStyleName("Option"); home.setStyleName("OptionSelected"); uploadData.setStyleName("Option"); curatorPage.setStyleName("Option"); isHome = true; selectedItems = new HashMap<String, List<String>>(); SearchInput input = new SearchInput(null, null, 0, new String[0], new String[0]); FacetedSearchPresenter.EVENT_BUS = GWT.create(SimpleEventBus.class); presenter = new FacetedSearchPresenter(new FacetedSearchView()); presenter.display(centerPanel, facetContent, header, loginPanel, notificationPanel); FacetedSearchPresenter.EVENT_BUS.fireEvent(new SearchEvent(input, false)); return; } SeadState state = SeadState.fromToken(token); final List<String> args = SeadState.tokenArguments(token); if (state == null) { handleHistoryTokenError(token); return; } //Browse appears to be the only panel that hides the login/logout panel //This will reset it whenever people go to another page/token if (state != SeadState.BROWSE) { main.setWidgetSize(loginPanel, 200); loginPanel.setVisible(true); } if (state == SeadState.HOME) { if (facetOuterPanel.isAttached()) { main.setWidgetSize(facetOuterPanel, 0); facetOuterPanel.setVisible(false); } if (!centerPanel.isAttached()) main.add(centerPanel); userService.checkSession(null, loginCallback); isHome = true; selectedItems = new HashMap<String, List<String>>(); SearchInput input = new SearchInput(null, null, 0, new String[0], new String[0]); FacetedSearchPresenter.EVENT_BUS = GWT.create(SimpleEventBus.class); presenter = new FacetedSearchPresenter(new FacetedSearchView()); presenter.display(centerPanel, facetContent, header, loginPanel, notificationPanel); FacetedSearchPresenter.EVENT_BUS.fireEvent(new SearchEvent(input, false)); } else if (state == SeadState.ADVANCED) { if (facetOuterPanel.isAttached()) { main.setWidgetSize(facetOuterPanel, 250); facetOuterPanel.setVisible(true); if (!centerPanel.isAttached()) main.add(centerPanel); dataSearch.setStyleName("OptionSelected"); uploadData.setStyleName("Option"); adminPage.setStyleName("Option"); dataHistory.setStyleName("Option"); selectedItems = new HashMap<String, List<String>>(); SearchInput input = new SearchInput(null, null, 0, new String[0], new String[0]); FacetedSearchPresenter.EVENT_BUS = GWT.create(SimpleEventBus.class); presenter = new FacetedSearchPresenter(new FacetedSearchView()); presenter.display(centerPanel, facetContent, header, loginPanel, notificationPanel); FacetedSearchPresenter.EVENT_BUS.fireEvent(new SearchEvent(input, true)); } } else if (state == SeadState.BROWSE) { if (facetOuterPanel.isAttached()) { main.setWidgetSize(facetOuterPanel, 250); facetOuterPanel.setVisible(true); } else main.addWest(facetOuterPanel, 250); facetOuterPanel.setVisible(true); if (!centerPanel.isAttached()) main.add(centerPanel); if (loginPanel.isAttached()) { main.setWidgetSize(loginPanel, 0); loginPanel.setVisible(false); } UserField[] userfields = new UserField[1]; String[] userqueries = new String[1]; String facetFields[] = new String[1]; String facetValues[] = new String[1]; userfields[0] = UserField.ABSTRACT; userqueries[0] = "'' TO *"; facetFields[0] = "entityType"; facetValues[0] = "Collection"; SearchInput input = new SearchInput(userfields, userqueries, 0, facetFields, facetValues); FacetedSearchPresenter.EVENT_BUS = GWT.create(SimpleEventBus.class); presenter = new FacetedSearchPresenter(new FacetedSearchView()); presenter.display(centerPanel, facetContent, header, loginPanel, notificationPanel); selectedItems = new HashMap<String, List<String>>(); FacetedSearchPresenter.EVENT_BUS.fireEvent(new SearchEvent(input, false)); return; } else if (state == SeadState.SEARCH) { if (facetOuterPanel.isAttached()) { main.setWidgetSize(facetOuterPanel, 250); facetOuterPanel.setVisible(true); } else main.addWest(facetOuterPanel, 250); facetOuterPanel.setVisible(true); if (!centerPanel.isAttached()) main.add(centerPanel); /* if(loginPanel.isAttached()){ main.setWidgetSize(loginPanel, 0); }*/ userService.checkSession(null, loginCallback); if (args.size() == 0) { SearchInput input = new SearchInput(null, null, 0, new String[0], new String[0]); FacetedSearchPresenter.EVENT_BUS = GWT.create(SimpleEventBus.class); presenter = new FacetedSearchPresenter(new FacetedSearchView()); presenter.display(centerPanel, facetContent, header, loginPanel, notificationPanel); selectedItems = new HashMap<String, List<String>>(); FacetedSearchPresenter.EVENT_BUS.fireEvent(new SearchEvent(input, false)); return; } /* if (args.size() < 2 || (args.size() & 1) == 0) { handleHistoryTokenError(token); return; } */ int offset = 0; //get facets args.get(args.size()-2) & args.get(args.size()-3) String[] facetFields = null; String[] facetValues = null; int facetCount = 0; try { facetCount = Integer.parseInt(args.get(args.size() - 1)); } catch (NumberFormatException e) { handleHistoryTokenError(token); return; } selectedItems = new HashMap<String, List<String>>(); isHome = false; int userFieldsLength = (args.size() - 2 - facetCount * 2) / 2; UserField[] userfields = new UserField[userFieldsLength]; String[] userqueries = new String[userFieldsLength]; int argIndex = -1; for (int i = 0; i < userFieldsLength; i++) { userfields[i] = UserField.valueOf(args.get(++argIndex)); userqueries[i] = args.get(++argIndex); if (userfields[i] == null) { handleHistoryTokenError(token); return; } } facetFields = new String[facetCount]; facetValues = new String[facetCount]; for (int i = 0; i < facetCount; i++) { facetFields[i] = args.get(++argIndex); facetValues[i] = args.get(++argIndex); List<String> childFacets = selectedItems.get(facetFields[i]); if (childFacets == null) childFacets = new ArrayList<String>(); childFacets.add(facetValues[i]); selectedItems.put(facetFields[i], childFacets); } SearchInput input = new SearchInput(userfields, userqueries, offset, facetFields, facetValues); FacetedSearchPresenter.EVENT_BUS = GWT.create(SimpleEventBus.class); presenter = new FacetedSearchPresenter(new FacetedSearchView());//); presenter.display(centerPanel, facetContent, header, loginPanel, notificationPanel); FacetedSearchPresenter.EVENT_BUS.fireEvent(new SearchEvent(input, false)); } else if (state == SeadState.ENTITY) { if (facetOuterPanel.isAttached()) { main.setWidgetSize(facetOuterPanel, 0); facetOuterPanel.setVisible(false); } if (!centerPanel.isAttached()) main.add(centerPanel); if (args.size() != 1) { handleHistoryTokenError(token); return; } userService.checkSession(null, loginCallback); presenter = new EntityPresenter(new EntityView(args.get(0))); presenter.display(centerPanel, facetContent, header, loginPanel, notificationPanel); } else if (state == SeadState.RELATED) { if (facetOuterPanel.isAttached()) { main.setWidgetSize(facetOuterPanel, 0); facetOuterPanel.setVisible(false); } if (!centerPanel.isAttached()) main.add(centerPanel); /*if(loginPanel.isAttached()){ main.setWidgetSize(loginPanel, 0); }*/ if (outerMoreLinks.isAttached()) { main.setWidgetSize(outerMoreLinks, 0); } if (args.size() != 1) { handleHistoryTokenError(token); return; } userService.checkSession(null, loginCallback); presenter = new RelationsPresenter(new RelationsView(args.get(0))); presenter.display(centerPanel, facetContent, header, loginPanel, notificationPanel); } else if (state == SeadState.CURATIONOBJECT) { if (facetOuterPanel.isAttached()) { main.setWidgetSize(facetOuterPanel, 0); facetOuterPanel.setVisible(false); } if (!centerPanel.isAttached()) main.add(centerPanel); /*if(loginPanel.isAttached()){ main.setWidgetSize(loginPanel, 0); }*/ if (outerMoreLinks.isAttached()) { main.setWidgetSize(outerMoreLinks, 0); } if (args.size() != 1) { handleHistoryTokenError(token); return; } userService.checkSession(null, loginCallback); presenter = new CurationObjectPresenter(new CurationView(args.get(0))); presenter.display(centerPanel, facetContent, header, loginPanel, notificationPanel); } else if (state == SeadState.LOGIN) { try { presenter = new LoginPresenter(new LoginPopupPanel()); presenter.display(centerPanel, facetContent, header, loginPanel, notificationPanel); } catch (Exception e) { e.printStackTrace(); } } else if (state == SeadState.LOGOUT) { if (!centerPanel.isAttached()) main.add(centerPanel); AsyncCallback<Void> cb = new AsyncCallback<Void>() { public void onSuccess(Void result) { initNoLogin(); History.newItem(SeadState.HOME.toToken()); } public void onFailure(Throwable error) { Window.alert("Failed to logout: " + error.getMessage()); } }; userService.clearSession(cb); } else if (state == SeadState.CURATOR) { if (args.size() > 0) History.newItem(SeadState.CURATOR.toToken()); if (!centerPanel.isAttached()) main.add(centerPanel); if (facetOuterPanel.isAttached()) { main.setWidgetSize(facetOuterPanel, 0); facetOuterPanel.setVisible(false); } AsyncCallback<UserSession> cb = new AsyncCallback<UserSession>() { public void onSuccess(UserSession result) { if (result.isSession()) { if (result.getRole() == Role.ROLE_CURATOR) { initCuratorLogin(); } else if (result.getRole() == Role.ROLE_ADMIN) { initAdminLogin(); } else { History.newItem(SeadState.HOME.toToken()); //no permissions } initLogoutButton(); if (!logoutButton.isAttached()) loginPanel.add(logoutButton); // History.newItem("upload"); } else History.newItem(SeadState.LOGIN.toToken()); } public void onFailure(Throwable error) { Window.alert("Failed to login: " + error.getMessage()); } }; curatorPage.setStyleName("OptionSelected"); adminPage.setStyleName("Option"); home.setStyleName("Option"); uploadData.setStyleName("Option"); userService.checkSession(null, cb); presenter = new CuratorViewPresenter(new CuratorView()); presenter.display(centerPanel, facetContent, header, loginPanel, notificationPanel); } else if (state == SeadState.PROV) { if (!centerPanel.isAttached()) main.add(centerPanel); if (facetOuterPanel.isAttached()) { main.setWidgetSize(facetOuterPanel, 0); facetOuterPanel.setVisible(false); } AsyncCallback<UserSession> cb = new AsyncCallback<UserSession>() { public void onSuccess(UserSession result) { if (result.isSession()) { if (result.getRole() == Role.ROLE_ADMIN) { initAdminLogin(); } else if (result.getRole() == Role.ROLE_CURATOR) { initCuratorLogin(); } else { initUserLogin(); } initLogoutButton(); String displayName = ""; if (result.getfName() != null) displayName = result.getfName(); if (result.getlName() != null) displayName += " " + result.getlName(); Label displayNameLabel = new Label(); displayNameLabel.setStyleName("welcomeFont"); displayNameLabel.setText("Welcome " + displayName); loginPanel.clear(); loginPanel.add(displayNameLabel); if (!logoutButton.isAttached()) loginPanel.add(logoutButton); activityPage.setStyleName("OptionSelected"); adminPage.setStyleName("Option"); home.setStyleName("Option"); uploadData.setStyleName("Option"); curatorPage.setStyleName("Option"); } else History.newItem(SeadState.LOGIN.toToken()); } public void onFailure(Throwable error) { Window.alert("Failed to login: " + error.getMessage()); } }; userService.checkSession(null, cb); presenter = new EntityProvPresenter(new EntityProvView(args.get(0))); presenter.display(centerPanel, facetContent, header, loginPanel, notificationPanel); } else if (state == SeadState.EDIT) { if (!centerPanel.isAttached()) main.add(centerPanel); if (facetOuterPanel.isAttached()) { main.setWidgetSize(facetOuterPanel, 0); facetOuterPanel.setVisible(false); } List<String> tempargs = SeadState.tokenArguments(token); curatorPage.setStyleName("OptionSelected"); adminPage.setStyleName("Option"); home.setStyleName("Option"); uploadData.setStyleName("Option"); userService.checkSession(null, logincallback2); presenter = new EditPresenter(new EditView(tempargs.get(0))); presenter.display(centerPanel, facetContent, header, loginPanel, notificationPanel); } else if (state == SeadState.ACTIVITY) { /* if(count==0){ forceReload(); count++; }*/ if (!centerPanel.isAttached()) main.add(centerPanel); if (facetOuterPanel.isAttached()) { main.setWidgetSize(facetOuterPanel, 0); facetOuterPanel.setVisible(false); } AsyncCallback<UserSession> cb = new AsyncCallback<UserSession>() { public void onSuccess(UserSession result) { if (result.isSession()) { if (result.getRole() == Role.ROLE_ADMIN) { initAdminLogin(); } else if (result.getRole() == Role.ROLE_CURATOR) { initCuratorLogin(); } else { initUserLogin(); } initLogoutButton(); String displayName = ""; if (result.getfName() != null) displayName = result.getfName(); if (result.getlName() != null) displayName += " " + result.getlName(); Label displayNameLabel = new Label(); displayNameLabel.setStyleName("welcomeFont"); displayNameLabel.setText("Welcome " + displayName); loginPanel.clear(); loginPanel.add(displayNameLabel); if (!logoutButton.isAttached()) loginPanel.add(logoutButton); activityPage.setStyleName("OptionSelected"); adminPage.setStyleName("Option"); home.setStyleName("Option"); uploadData.setStyleName("Option"); curatorPage.setStyleName("Option"); } else History.newItem(SeadState.LOGIN.toToken()); } public void onFailure(Throwable error) { Window.alert("Failed to login: " + error.getMessage()); } }; userService.checkSession(null, cb); presenter = new ActivityPresenter(new ActivityView()); presenter.display(centerPanel, facetContent, header, loginPanel, notificationPanel); } else if (state == SeadState.AUTH) { if (!centerPanel.isAttached()) main.add(centerPanel); else centerPanel.clear(); if (facetOuterPanel.isAttached()) { main.setWidgetSize(facetOuterPanel, 0); facetOuterPanel.setVisible(false); } dataSearch.setStyleName("Option"); uploadData.setStyleName("OptionSelected"); AsyncCallback<UserSession> cb = new AsyncCallback<UserSession>() { public void onSuccess(UserSession result) { if (result.isSession()) { if (result.getRole() == Role.ROLE_ADMIN) { Label logoutLbl = Util.label("Logout", "LogoutButton"); if (args.size() > 0) { ClickHandler logout = new ClickHandler() { @Override public void onClick(ClickEvent event) { loginPanel.clear(); // loginPanel.add(loginLabel); History.newItem("logout"); } }; logoutLbl.addClickHandler(logout); loginPanel.clear(); loginPanel.add(logoutLbl); } } History.newItem("upload"); } else History.newItem("login"); } public void onFailure(Throwable error) { Window.alert("Failed to login: " + error.getMessage()); } }; String argument = null; if (args.size() > 0) argument = args.get(1); userService.checkSession(argument, cb); } else if (state == SeadState.UPLOAD) { if (args.size() > 0) History.newItem(SeadState.UPLOAD.toToken()); if (facetOuterPanel.isAttached()) main.setWidgetSize(facetOuterPanel, 0); facetOuterPanel.setVisible(false); if (!centerPanel.isAttached()) main.add(centerPanel); AsyncCallback<UserSession> cb = new AsyncCallback<UserSession>() { public void onSuccess(UserSession result) { if (result.isSession()) { if (result.getRole() == Role.ROLE_ADMIN) initAdminLogin(); else if (result.getRole() == Role.ROLE_CURATOR) initCuratorLogin(); else initUserLogin(); initLogoutButton(); String displayName = ""; if (result.getfName() != null) displayName = result.getfName(); if (result.getlName() != null) displayName += " " + result.getlName(); Label displayNameLabel = new Label(); displayNameLabel.setStyleName("welcomeFont"); displayNameLabel.setText("Welcome " + displayName); loginPanel.clear(); loginPanel.add(displayNameLabel); if (!logoutButton.isAttached()) loginPanel.add(logoutButton); // History.newItem("upload"); curatorPage.setStyleName("Option"); adminPage.setStyleName("Option"); home.setStyleName("Option"); uploadData.setStyleName("OptionSelected"); } else History.newItem(SeadState.LOGIN.toToken()); } public void onFailure(Throwable error) { Window.alert("Failed to login: " + error.getMessage()); } }; userService.checkSession(null, cb); centerPanel.clear(); centerPanel.add(publishData); presenter = new PublishDataPresenter(new PublishDataView()); presenter.display(publishData, facetContent, header, loginPanel, notificationPanel); } else if (state == SeadState.ACRUPLOAD) { if (facetOuterPanel.isAttached()) main.setWidgetSize(facetOuterPanel, 0); facetOuterPanel.setVisible(false); if (!centerPanel.isAttached()) main.add(centerPanel); AsyncCallback<UserSession> cb = new AsyncCallback<UserSession>() { public void onSuccess(UserSession result) { if (result.isSession()) { if (result.getRole() == Role.ROLE_ADMIN) initAdminLogin(); else if (result.getRole() == Role.ROLE_CURATOR) initCuratorLogin(); else initUserLogin(); initLogoutButton(); String displayName = ""; if (result.getfName() != null) displayName = result.getfName(); if (result.getlName() != null) displayName += " " + result.getlName(); Label displayNameLabel = new Label(); displayNameLabel.setStyleName("welcomeFont"); displayNameLabel.setText("Welcome " + displayName); loginPanel.clear(); loginPanel.add(displayNameLabel); if (!logoutButton.isAttached()) loginPanel.add(logoutButton); // History.newItem("upload"); curatorPage.setStyleName("Option"); adminPage.setStyleName("Option"); home.setStyleName("Option"); uploadData.setStyleName("OptionSelected"); } else History.newItem(SeadState.LOGIN.toToken()); } public void onFailure(Throwable error) { Window.alert("Failed to login: " + error.getMessage()); } }; userService.checkSession(null, cb); centerPanel.clear(); centerPanel.add(publishData); presenter = new AcrPublishDataPresenter(new AcrPublishDataView()); presenter.display(publishData, facetContent, header, loginPanel, notificationPanel); } else if (state == SeadState.ADMIN) { if (!centerPanel.isAttached()) main.add(centerPanel); AsyncCallback<UserSession> cb = new AsyncCallback<UserSession>() { public void onSuccess(UserSession result) { if (result.isSession()) { if (result.getRole() == Role.ROLE_ADMIN) { initAdminLogin(); } else History.newItem(SeadState.HOME.toToken());//no permissions } else History.newItem("login"); } public void onFailure(Throwable error) { Window.alert("Failed to login: " + error.getMessage()); } }; userService.checkSession(null, cb); presenter = new AdminPresenter(new AdminView()); presenter.display(centerPanel, facetContent, header, loginPanel, notificationPanel); } else if (state == SeadState.MONITOR) { if (facetOuterPanel.isAttached()) main.setWidgetSize(facetOuterPanel, 0); facetOuterPanel.setVisible(false); if (!centerPanel.isAttached()) main.add(centerPanel); AsyncCallback<UserSession> cb = new AsyncCallback<UserSession>() { public void onSuccess(UserSession result) { if (result.isSession()) { if (result.getRole() == Role.ROLE_ADMIN) { initAdminLogin(); } else if (result.getRole() == Role.ROLE_CURATOR) { initCuratorLogin(); } else { initUserLogin(); } initLogoutButton(); String displayName = ""; if (result.getfName() != null) displayName = result.getfName(); if (result.getlName() != null) displayName += " " + result.getlName(); Label displayNameLabel = new Label(); displayNameLabel.setStyleName("welcomeFont"); displayNameLabel.setText("Welcome " + displayName); loginPanel.clear(); loginPanel.add(displayNameLabel); if (!logoutButton.isAttached()) loginPanel.add(logoutButton); dataHistory.setStyleName("OptionSelected"); adminPage.setStyleName("Option"); home.setStyleName("Option"); uploadData.setStyleName("Option"); curatorPage.setStyleName("Option"); } else History.newItem(SeadState.LOGIN.toToken()); } public void onFailure(Throwable error) { Window.alert("Failed to login: " + error.getMessage()); } }; userService.checkSession(null, cb); presenter = new ProvenancePresenter(new ProvenanceView()); presenter.display(centerPanel, facetContent, header, loginPanel, notificationPanel); } else { handleHistoryTokenError(token); return; } }
From source file:org.dataconservancy.dcs.access.client.ui.ErrorPopupPanel.java
License:Apache License
public ErrorPopupPanel(String errorMessageStr) { super(true);/*from w ww . j av a 2 s.c om*/ this.setGlassEnabled(true); this.show(); this.setStyleName("errorPopupContainer"); this.setPopupPosition((int) Math.ceil(Window.WINDOW_WIDTH / 2.5), Window.WINDOW_HEIGHT / 4); VerticalPanel outerPanel = new VerticalPanel(); outerPanel.setSpacing(10); outerPanel.setWidth("100%"); outerPanel.setHeight(Window.WINDOW_HEIGHT / 5 + "px"); outerPanel.setStyleName("errorPopupContainer"); setWidget(outerPanel); outerPanel.setHorizontalAlignment(HorizontalPanel.ALIGN_CENTER); Label errorMessage = new Label(); errorMessage.setWidth("90%"); errorMessage.setStyleName("greenFont"); errorMessage.setText(errorMessageStr); outerPanel.add(errorMessage); Button closeButton = new Button("Close"); closeButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { hide(); } }); outerPanel.add(errorMessage); outerPanel.setVerticalAlignment(HorizontalPanel.ALIGN_BOTTOM); outerPanel.add(closeButton); }
From source file:org.dataconservancy.dcs.access.client.ui.NotificationPopupPanel.java
License:Apache License
public NotificationPopupPanel(String errorMessageStr, boolean done) { super(false); this.setGlassEnabled(true); this.show();//w w w. java 2s . c om this.setStyleName("notifyPopupContainer"); this.setPopupPosition((int) Math.ceil(Window.WINDOW_WIDTH / 2.5), Window.WINDOW_HEIGHT / 2); VerticalPanel outerPanel = new VerticalPanel(); outerPanel.setSpacing(10); outerPanel.setWidth("100%"); outerPanel.setHeight(Window.WINDOW_HEIGHT / 5 + "px"); outerPanel.setStyleName("notifyPopupContainer"); setWidget(outerPanel); outerPanel.setHorizontalAlignment(HorizontalPanel.ALIGN_CENTER); Label errorMessage = new Label(); errorMessage.setWidth("90%"); errorMessage.setStyleName("greenFont"); errorMessage.setText(errorMessageStr); outerPanel.add(errorMessage); /*Button closeButton = new Button("Close"); closeButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { hide(); } });*/ Image image; if (!done) image = new Image("images/wait.gif"); else image = new Image("images/done.png"); // image.setStyleName("Pad"); Grid grid = new Grid(1, 3); grid.setWidget(0, 0, image); grid.setWidget(0, 2, errorMessage); grid.setWidth("90%"); outerPanel.add(grid); outerPanel.setVerticalAlignment(HorizontalPanel.ALIGN_BOTTOM); // outerPanel.add(closeButton); }
From source file:org.dataconservancy.dcs.access.client.ui.NotificationPopupPanel.java
License:Apache License
public NotificationPopupPanel(String errorMessageStr, String done) { super(true);//from ww w . j a v a2s.c o m this.setGlassEnabled(true); this.show(); this.setStyleName("notifyPopupContainer"); this.setPopupPosition((int) Math.ceil(Window.WINDOW_WIDTH / 2.5), Window.WINDOW_HEIGHT / 2); VerticalPanel outerPanel = new VerticalPanel(); outerPanel.setSpacing(10); outerPanel.setWidth("100%"); outerPanel.setHeight(Window.WINDOW_HEIGHT / 5 + "px"); outerPanel.setStyleName("notifyPopupContainer"); setWidget(outerPanel); outerPanel.setHorizontalAlignment(HorizontalPanel.ALIGN_CENTER); Label errorMessage = new Label(); errorMessage.setWidth("90%"); errorMessage.setStyleName("greenFont"); errorMessage.setText(errorMessageStr); outerPanel.add(errorMessage); /*Button closeButton = new Button("Close"); closeButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { hide(); } });*/ Grid grid = new Grid(1, 2); if (done.equalsIgnoreCase("failed")) grid.setWidget(0, 0, new Image("images/failed.jpg")); else grid.setWidget(0, 0, new Image("images/done.png")); grid.setWidget(0, 1, errorMessage); grid.setWidth("90%"); outerPanel.add(grid); outerPanel.setVerticalAlignment(HorizontalPanel.ALIGN_BOTTOM); // outerPanel.add(closeButton); }
From source file:org.dataconservancy.dcs.access.client.ui.SeadSimpleSearchWidget.java
License:Apache License
public SeadSimpleSearchWidget(Search.UserField[] userfields, String[] userqueries) { advancedPanel = new FlowPanel(); initWidget(advancedPanel);/*from w w w . j av a2s . com*/ final FlexTable table = new FlexTable(); table.setWidth("100%"); Label intro = new Label(); intro.setText( "Virtual Archive (SEAD-VA) is a discovery and preservation layer of the SEAD services suite. SEAD-VA federates over multiple institutional repositories and archives and provides a coherent view on published data in sustainability science."); intro.setStylePrimaryName("IntroLabel"); Label lbl = new Label(); lbl.setText("Search SEAD-VA data registry"); lbl.setStylePrimaryName("SearchLabel"); Button add = new Button("Add field"); if (SeadApp.isHome) { advancedPanel.add(intro); advancedPanel.add(lbl); } advancedPanel.add(table); // Called to search filled in query final ClickHandler searchlistener = new ClickHandler() { public void onClick(ClickEvent event) { // Build up search history token System.out.println("In search"); String[] data = new String[(table.getRowCount() * 2) + 1 + 1]; int dataindex = 0; boolean emptyquery = true; for (int i = 0; i < table.getRowCount(); i++) { // ListBox lb = (ListBox) table.getWidget(i, 2); TextBox tb = (TextBox) table.getWidget(i, 0); /* int sel = lb.getSelectedIndex(); if (sel != -1) {*/ String userquery = tb.getText().trim(); /* String userfield = Search.UserField.values()[sel] .name();*/ String userfield = "ALL"; if (userquery.isEmpty()) { userfield = null; userquery = null; } else { emptyquery = false; } System.out.println("UserField: " + userfield); System.out.println("UserAuery" + userquery); data[dataindex++] = userfield; data[dataindex++] = userquery; System.out.println("Data.0: " + data[0] + "Data.1: " + data[1]); //} } data[dataindex] = "0"; data[dataindex + 1] = "0"; if (!emptyquery) { History.newItem(SeadState.SEARCH.toToken(data)); } } }; ClickHandler addlistener = new ClickHandler() { public void onClick(ClickEvent event) { int row = table.getRowCount(); final TextBox tb = new TextBox(); tb.setStyleName("Pad"); tb.setValue("Type name, date or keyword"); table.setWidget(row, 0, tb); // table.setWidget(row, 1, new Label("in1")); // table.setWidget(row, 2 , createAdvancedSearchFieldSelector()); tb.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { // TODO Auto-generated method stub tb.setValue(null); } }); tb.addKeyDownHandler(new KeyDownHandler() { public void onKeyDown(KeyDownEvent event) { if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) { searchlistener.onClick(null); } } }); } }; add.addClickHandler(addlistener); if (userfields != null) { for (int i = 0; i < userfields.length; i++) { if (userfields[i] == null) { continue; } int row = table.getRowCount(); addlistener.onClick(null); // ListBox lb = (ListBox) table.getWidget(row,2); // lb.setItemSelected(userfields[i].ordinal(), true); TextBox tb = (TextBox) table.getWidget(row, 0); tb.setText(userqueries[i]); } } else { addlistener.onClick(null); } Grid grid = new Grid(2, 2); advancedPanel.add(grid); grid.setWidth("80%"); FlexTable flexTable = new FlexTable(); grid.setWidget(0, 0, table); Button search = new Button("Search"); search.setStyleName("SearchButton"); Label advSearch = new Label(); advSearch.setText("Advanced Search>>"); advSearch.setStyleName("PadHyperlink"); advSearch.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { History.newItem(SeadState.ADVANCED.toToken()); } }); grid.setWidget(0, 1, search); grid.setWidget(1, 0, advSearch); // search.setWidth("82px"); search.addClickHandler(searchlistener); }
From source file:org.drools.brms.client.modeldriven.ui.DSLSentenceWidget.java
License:Apache License
/** * This will take a DSL line item, and split it into widget thingamies for displaying. * One day, if this is too complex, this will have to be done on the server side. *//*w w w .j a v a2 s .co m*/ public void makeWidgets(String dslLine) { char[] chars = dslLine.toCharArray(); FieldEditor currentBox = null; Label currentLabel = null; for (int i = 0; i < chars.length; i++) { char c = chars[i]; if (c == '{') { currentLabel = null; currentBox = new FieldEditor(); addWidget(currentBox); } else if (c == '}') { currentBox.setVisibleLength(currentBox.getText().length() + 1); currentBox = null; } else { if (currentBox == null && currentLabel == null) { currentLabel = new Label(); addWidget(currentLabel); } if (currentLabel != null) { currentLabel.setText(currentLabel.getText() + c); } else if (currentBox != null) { currentBox.setText(currentBox.getText() + c); } } } }
From source file:org.drools.guvnor.client.asseteditor.drools.modeldriven.ui.DSLSentenceWidget.java
License:Apache License
public Widget getLabel(String labelDef) { Label label = new SmallLabel(); label.setText(labelDef.trim()); return label; }