private boolean rememberMe() { final String accountName = Cookies.getCookie(COOKIE_RM_ACCOUNT); final String token = Cookies.getCookie(COOKIE_RM_TOKEN); if (accountName != null && token != null) { RPC.getAccountManagementRPC() .login( accountName, token, new AsyncCallback<LoginResponse>() { @Override public void onSuccess(LoginResponse result) { handleLoginResponse(result, accountName, true); } @Override public void onFailure(Throwable caught) { throw new IllegalStateException(caught); } }); return true; } else { return false; } }
public adresses_dispo() { initWidget(uiBinder.createAndBindUi(this)); charger_plage(); MonNom.setText( "Vous etes :" + Cookies.getCookie("nomutilisateur") + " " + Cookies.getCookie("prenomutilisateur")); }
public User() { // load info from cookie Username = Cookies.getCookie("USER_NAME"); Password = Cookies.getCookie("USER_PASSWORD"); // check values if (Username == null) { Username = ""; } if (Password == null) { Password = ""; } }
/** Parse and store the user credentials to the appropriate fields. */ private void parseUserCredentials() { Configuration conf = (Configuration) GWT.create(Configuration.class); String cookie = conf.authCookie(); String auth = Cookies.getCookie(cookie); if (auth == null) { authenticateUser(); // Redundant, but silences warnings about possible auth NPE, below. return; } int sepIndex = auth.indexOf(conf.cookieSeparator()); if (sepIndex == -1) authenticateUser(); token = auth.substring(sepIndex + 1); final String username = auth.substring(0, sepIndex); if (username == null) authenticateUser(); refreshWebDAVPassword(); DeferredCommand.addCommand( new Command() { @Override public void execute() { fetchUser(username); } }); }
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); }
/** * ************************************* Performs the login with the data from the input fields. */ protected void login() { aLoginButton.setEnabled(false); String sUserName = bReauthenticate ? Cookies.getCookie(sUserCookie) : aUserField.getText(); String sPassword = aPasswordField.getText(); setUserNameCookie(sUserName); ServiceRegistry.getCommandService() .executeCommand( AuthenticatedService.LOGIN, createLoginData(sUserName, sPassword), new AsyncCallback<DataElementList>() { @Override public void onFailure(Throwable rCaught) { handleLoginFailure(rCaught); } @Override public void onSuccess(DataElementList rResult) { handleLoginSuccess(rResult); } }); }
/** * Creates the center view in viewport by the user role, if the role is building modeler, then * show the building modeler view, else show the ui designer view. * * @param authority the authority */ private void createCenter(Authority authority) { List<String> roles = authority.getRoles(); modelerContainer = new LayoutContainer(); modelerContainer.setLayout(new FitLayout()); WidgetSelectionUtil widgetSelectionUtil = new WidgetSelectionUtil(eventBus); if (roles.contains(Role.ROLE_ADMIN) || (roles.contains(Role.ROLE_DESIGNER) && roles.contains(Role.ROLE_MODELER))) { this.buildingModelerView = new BuildingModelerView(eventBus); this.uiDesignerView = new UIDesignerView(widgetSelectionUtil); this.uiDesignerPresenter = new UIDesignerPresenter(eventBus, this.uiDesignerView, widgetSelectionUtil); if (Role.ROLE_DESIGNER.equals(Cookies.getCookie(Constants.CURRETN_ROLE))) { modelerContainer.add(uiDesignerView); } else { modelerContainer.add(buildingModelerView); } } else if (roles.contains(Role.ROLE_MODELER) && !roles.contains(Role.ROLE_DESIGNER)) { this.buildingModelerView = new BuildingModelerView(eventBus); modelerContainer.add(buildingModelerView); } else if (roles.contains(Role.ROLE_DESIGNER) && !roles.contains(Role.ROLE_MODELER)) { this.uiDesignerView = new UIDesignerView(widgetSelectionUtil); this.uiDesignerPresenter = new UIDesignerPresenter(eventBus, this.uiDesignerView, widgetSelectionUtil); modelerContainer.add(uiDesignerView); } BorderLayoutData data = new BorderLayoutData(Style.LayoutRegion.CENTER); data.setMargins(new Margins(0, 5, 0, 5)); viewport.add(modelerContainer, data); }
public void refreshWebDAVPassword() { Configuration conf = (Configuration) GWT.create(Configuration.class); String domain = Window.Location.getHostName(); String path = Window.Location.getPath(); String cookie = conf.webdavCookie(); webDAVPassword = Cookies.getCookie(cookie); Cookies.setCookie(cookie, "", null, domain, path, false); }
public void start(AcceptsOneWidget container, EventBus eventBus) { display.setListener(this); display.setLoginErrorMessage(""); sessionID = Cookies.getCookie("sid"); container.setWidget(display.asWidget()); }
public static void displayCookies() { StringBuilder cookies = new StringBuilder(); for (String name : Cookies.getCookieNames()) { String value = Cookies.getCookie(name); cookies.append(name).append(" = ").append(value).append("<br/>"); } Info.display("Cookies", cookies.toString()); }
public int getPeriod() { String speriod = Cookies.getCookie(Heliostat.REFRESH_PERIOD); if (speriod == null) { speriod = "1000"; Cookies.setCookie(Heliostat.REFRESH_PERIOD, speriod); } int period = Integer.parseInt(speriod); return period; }
/** * ************************************* Creates a new data element containing the login data. The * default implementation creates a string data element with the user name as it's name and the * password as it's value. It also adds the user info created by {@link #createLoginUserInfo()} as * a property with the property name {@link AuthenticatedService#LOGIN_USER_INFO} and an existing * session ID (from the session cookie) with the property {@link AuthenticatedService#SESSION_ID}. * * @param sUserName The login user name * @param sPassword The login password * @return The login data object */ protected StringDataElement createLoginData(String sUserName, String sPassword) { String sSessionId = Cookies.getCookie(sSessionCookie); StringDataElement aLoginData = new StringDataElement(sUserName, sPassword); aLoginData.setProperty(AuthenticatedService.LOGIN_USER_INFO, createLoginUserInfo()); if (sSessionId != null) { aLoginData.setProperty(AuthenticatedService.SESSION_ID, sSessionId); } return aLoginData; }
private void selectLastTab() { try { int tab = Integer.valueOf(Cookies.getCookie("UniTime:CourseFinderCourses")); if (tab >= 0 || tab < iCourseDetailsTabPanel.getTabCount() && tab != iCourseDetailsTabPanel.getSelectedTab()) iCourseDetailsTabPanel.selectTab(tab); else iCourseDetailsTabPanel.selectTab(0); } catch (Exception e) { iCourseDetailsTabPanel.selectTab(0); } }
/** * Creates combobox used to select molecular viewer. * * @return viewer selector */ private ComboBox<String> createViewerTypeCombobox() { ListStore<String> store = new ListStore<String>( new ModelKeyProvider<String>() { @Override public String getKey(String item) { return item; } }); store.add(AppPropertiesManager.CONSTANTS.viewer_local()); store.add(AppPropertiesManager.CONSTANTS.viewer_jmol()); store.add(AppPropertiesManager.CONSTANTS.viewer_pse()); final ComboBox<String> viewerTypeComboBox = new ComboBox<String>( store, new LabelProvider<String>() { @Override public String getLabel(String item) { return item; } }); viewerTypeComboBox.setId("viewercombo"); viewerTypeComboBox.setTriggerAction(TriggerAction.ALL); viewerTypeComboBox.setEditable(false); viewerTypeComboBox.setWidth(100); viewerTypeComboBox.setToolTipConfig(createViewerTypeComboBoxToolTipConfig()); String viewerCookie = Cookies.getCookie("crkviewer"); if (viewerCookie != null) { viewerTypeComboBox.setValue(viewerCookie); } else { viewerTypeComboBox.setValue(AppPropertiesManager.CONSTANTS.viewer_jmol()); } ApplicationContext.setSelectedViewer(viewerTypeComboBox.getValue()); viewerTypeComboBox.addSelectionHandler( new SelectionHandler<String>() { @Override public void onSelection(SelectionEvent<String> event) { Cookies.setCookie("crkviewer", event.getSelectedItem()); ApplicationContext.setSelectedViewer(event.getSelectedItem()); } }); return viewerTypeComboBox; }
private void sendEvent() { // Delete cookies: this should actually happen on // the server and NOT on the client. However, I // (rodrigo) was unable to get it to work. For some // unknown reason, the cookies aren't clearing when // cleared on the server! This is a temporary solution // TODO: fix it if (Cookies.getCookie("uid") != null) { GWT.log("LogoutHandler - Cookie didn't clear on the server!!", null); } Cookies.removeCookie("uid"); GWT.log("LogoutHandler - Logging out, sending GotUserEvent with null user", null); BooksPicker.eventBus.fireEvent(new GotUserEvent(null)); }
/** * Creates the button that can convert to building modeler view. * * @return the toggle button */ private ToggleButton createBMButton() { final ToggleButton bmButton = new ToggleButton(); bmButton.setToolTip("Building Modeler"); bmButton.setIcon(icons.bmIcon()); bmButton.addSelectionListener( new SelectionListener<ButtonEvent>() { public void componentSelected(ButtonEvent ce) { if (!bmButton.isPressed()) { bmButton.toggle(true); } else { modelerContainer.remove(uiDesignerView); modelerContainer.add(buildingModelerView); Cookies.setCookie(Constants.CURRETN_ROLE, Role.ROLE_MODELER); modelerContainer.layout(); } } }); bmButton.setToggleGroup("modeler-switch"); if (Cookies.getCookie(Constants.CURRETN_ROLE) == null || Role.ROLE_MODELER.equals(Cookies.getCookie(Constants.CURRETN_ROLE))) { bmButton.toggle(true); } return bmButton; }
public UploadJob_BeforeAddingOverwrite(int tab) { String sessionID = Cookies.getCookie("sid"); if (sessionID != null) { this.tab = tab; initWidget(vPanel); userCtx = (ClientContext) RPCClientContext.get(); if (userCtx != null) { currentUser = userCtx.getCurrentUser(); if (currentUser != null) { setProjects(); } } } else { Login login = new Login(); login.displayLoginBox(); } }
public Reports() { // initializing the widgets initWidget(this.ProfileContent); String authLevel = Cookies.getCookie("authLevel"); System.out.println(authLevel); if ("0".equals(authLevel)) { profileTitle.setStyleName("error"); profileTitle.setText("You are not authorized to view this content"); this.ProfileContent.add(profileTitle); } else { this.ProfileContent.add(profileTitle); SpeciesReportServiceClientImpl table = new SpeciesReportServiceClientImpl(GWT.getModuleBaseURL() + "speciesreportservice"); this.ProfileContent.add(table.getSpeciesCellTableUI()); } }
/** ************************************* {@inheritDoc} */ @Override protected void addComponents() { ContainerBuilder<Panel> aBuilder = createLoginComponentsPanel(AlignedPosition.CENTER); String sUserName = Cookies.getCookie(sUserCookie); addLoginPanelHeader(aBuilder, AlignedPosition.TOP); aUserField = addUserComponents(aBuilder, sUserName, bReauthenticate); aPasswordField = addPasswortComponents(aBuilder); aFailureMessage = addFailureMessageComponents(aBuilder); aLoginButton = addSubmitLoginComponents(aBuilder); if (aUserField != null) { aUserField.addEventListener(EventType.ACTION, this); } aPasswordField.addEventListener(EventType.ACTION, this); aLoginButton.addEventListener(EventType.ACTION, this); aFailureMessage.setVisible(false); }
private void initUserList(final ClientUser[] list) { // The user listing is downloaded by an async call. final RootPanel userPanel = RootPanel.get("email"); userPanel.add(users); users.addChangeHandler( new ChangeHandler() { @Override public void onChange(final ChangeEvent event) { userChanged(); } }); users.addItem(SELECT_USER_STRING, ""); userInfo.clear(); for (final ClientUser user : list) { users.addItem(user.getName(), user.getEmail()); userInfo.put(user.getEmail(), user); } // Select the user according to the cookie stored final String userEmail = Cookies.getCookie("email"); selectUser(userEmail); }
/** This is the entry point method. */ public void onModuleLoad() { // Pointer to CSS manager. It has to go first! GWT.<Resources>create(Resources.class).css().ensureInjected(); // Log messages logger.fine("Loading eMarkingWeb interface"); logger.fine(Navigator.getPlatform()); logger.fine(Navigator.getUserAgent()); logger.fine(Navigator.getAppName()); logger.fine(Navigator.getAppCodeName()); logger.fine(Navigator.getAppVersion()); // List of errors after trying to initialize ArrayList<String> errors = new ArrayList<String>(); // Get id for eMarkingWeb's DIV tag final String eMarkingDivId = "emarking"; if (RootPanel.get(eMarkingDivId) == null) { errors.add("Can not initalize. eMarkingWeb requires an existing DIV tag with id: emarking."); return; } RootPanel.get(eMarkingDivId).add(new Label("Loading")); int draftId = 0; int preferredWidth = 860; boolean showRubric = true; boolean showColors = false; try { // First, if there's a URL parameter, replace the value if (Window.Location.getParameter("id") != null) { draftId = Integer.parseInt(Window.Location.getParameter("id")); } // Validate that the submission id is a positive integer if (draftId <= 0) { errors.add("Submission id must be a non negative integer."); } String cookie_width = Cookies.getCookie("emarking_width"); if (cookie_width != null) { preferredWidth = Integer.parseInt(cookie_width); } // Validate that the preferredWidth is a positive integer greater than 10 if (preferredWidth <= 10) { errors.add("Preferred width should be a positive integer greater than 10."); } // Validate that the preferredWidth is a positive integer greater than 10 if (preferredWidth <= 10) { errors.add("Preferred width should be a positive integer greater than 10."); } String cookie_showrubric = Cookies.getCookie("emarking_showrubric"); if (cookie_showrubric != null) { showRubric = Integer.parseInt(cookie_showrubric) == 1; } String cookie_showcolors = Cookies.getCookie("emarking_showcolors"); if (cookie_showcolors != null) { showColors = Integer.parseInt(cookie_showcolors) == 1; } logger.fine( "ShowRubric: " + showRubric + " Show colors:" + showColors + " Preferred width:" + preferredWidth); } catch (Exception e) { logger.severe(e.getMessage()); errors.add( "Error in HTML for eMarkingWeb can not initalize. Invalid submissionId value (must be integer)."); } // Read div attribute for readonly String moodleurl = null; if (RootPanel.get(eMarkingDivId).getElement().getAttribute("moodleurl") != null) moodleurl = RootPanel.get(eMarkingDivId).getElement().getAttribute("moodleurl"); logger.fine("Moodle ajax url: " + moodleurl); if (moodleurl == null) errors.add("Invalid Moodle ajax url"); // If there are errors die with a configuration message if (errors.size() > 0) { Label errorsLabel = new Label(); String text = ""; for (int i = 0; i < errors.size(); i++) { text += "\n" + errors.get(i); } errorsLabel.setText(text); errorsLabel.setTitle("Fatal error while initializing eMarking-Web"); RootPanel.get(eMarkingDivId).clear(); RootPanel.get(eMarkingDivId).add(errorsLabel); } else { // Set eMarking's main interface submission id according to HTML MarkingInterface.setDraftId(draftId); EMarkingConfiguration.setShowRubricOnLoad(showRubric); EMarkingConfiguration.setColoredRubric(showColors); // Ajax URL in moodle AjaxRequest.moodleUrl = moodleurl; // Automagically resize popup to use most of the window int width = screenWidth(); int height = screenHeight(); // Preferred width can not be bigger than the screen if (width < preferredWidth) { preferredWidth = width; } // Resize the popup window and move it to the top left corner Window.resizeTo(preferredWidth, height); Window.moveTo(0, 0); // Initialize eMarking's interface markingInterface = new MarkingInterface(); markingInterfacetwo = new MarkingInterface(); // Add eMarking to the browser RootPanel.get(eMarkingDivId).clear(); RootPanel.get(eMarkingDivId).add(markingInterface); RootPanel.getBodyElement().focus(); } }
/* * (non-Javadoc) * * @see cc.kune.core.client.cookies.CookiesManager#getAnonCookie() */ @Override public String getAnonCookie() { return Cookies.getCookie(ANON); }
private String getSessionCookie() { return Cookies.getCookie(SESSION_COOKIE); }
/* * (non-Javadoc) * * @see cc.kune.core.client.cookies.CookiesManager#getAuthCookie() */ @Override public String getAuthCookie() { return Cookies.getCookie(SessionConstants.USERHASH); }
@Override public String getUsername() { return Cookies.getCookie("username"); }
private Widget buildLoginPanel(boolean openInNewWindowDefault) { userTextBox.setWidth("100%"); // $NON-NLS-1$ passwordTextBox.setWidth("100%"); // $NON-NLS-1$ usersListBox.setWidth("100%"); // $NON-NLS-1$ userTextBox.setStyleName("login-panel-label"); passwordTextBox.setStyleName("login-panel-label"); newWindowChk.setStyleName("login-panel-label"); VerticalPanel credentialsPanel = new VerticalPanel(); credentialsPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); credentialsPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP); SimplePanel spacer; if (showUsersList) { // populate default users list box addDefaultUsers(); Label sampleUsersLabel = new Label(Messages.getString("sampleUser") + ":"); sampleUsersLabel.setStyleName("login-panel-label"); credentialsPanel.add(sampleUsersLabel); // $NON-NLS-1$ //$NON-NLS-2$ credentialsPanel.add(usersListBox); spacer = new SimplePanel(); spacer.setHeight("8px"); // $NON-NLS-1$ credentialsPanel.add(spacer); } Label usernameLabel = new Label(Messages.getString("username") + ":"); usernameLabel.setStyleName("login-panel-label"); credentialsPanel.add(usernameLabel); // $NON-NLS-1$ //$NON-NLS-2$ credentialsPanel.add(userTextBox); spacer = new SimplePanel(); spacer.setHeight("8px"); // $NON-NLS-1$ credentialsPanel.add(spacer); credentialsPanel.setCellHeight(spacer, "8px"); // $NON-NLS-1$ HTML passwordLabel = new HTML(Messages.getString("password") + ":"); passwordLabel.setStyleName("login-panel-label"); credentialsPanel.add(passwordLabel); // $NON-NLS-1$ //$NON-NLS-2$ credentialsPanel.add(passwordTextBox); boolean reallyShowNewWindowOption = showNewWindowOption; String showNewWindowOverride = Window.Location.getParameter("showNewWindowOption"); // $NON-NLS-1$ if (showNewWindowOverride != null && !"".equals(showNewWindowOverride)) { // $NON-NLS-1$ // if the override is set, we MUST obey it above all else reallyShowNewWindowOption = "true".equals(showNewWindowOverride); // $NON-NLS-1$ } else if (getReturnLocation() != null && !"".equals(getReturnLocation())) { // $NON-NLS-1$ StringTokenizer st = new StringTokenizer(getReturnLocation(), "?&"); // $NON-NLS-1$ // first token will be ignored, it is 'up to the ?' for (int i = 1; i < st.countTokens(); i++) { StringTokenizer paramTokenizer = new StringTokenizer(st.tokenAt(i), "="); // $NON-NLS-1$ if (paramTokenizer.countTokens() == 2) { // we've got a name=value token if (paramTokenizer.tokenAt(0).equalsIgnoreCase("showNewWindowOption")) { // $NON-NLS-1$ reallyShowNewWindowOption = "true".equals(paramTokenizer.tokenAt(1)); // $NON-NLS-1$ break; } } } } // New Window checkbox if (reallyShowNewWindowOption) { spacer = new SimplePanel(); spacer.setHeight("8px"); // $NON-NLS-1$ credentialsPanel.add(spacer); credentialsPanel.setCellHeight(spacer, "8px"); // $NON-NLS-1$ newWindowChk.setText(Messages.getString("launchInNewWindow")); // $NON-NLS-1$ String cookieCheckedVal = Cookies.getCookie("loginNewWindowChecked"); // $NON-NLS-1$ if (cookieCheckedVal != null) { newWindowChk.setValue(Boolean.parseBoolean(cookieCheckedVal)); } else { // default is false, per BISERVER-2384 newWindowChk.setValue(openInNewWindowDefault); } credentialsPanel.add(newWindowChk); } userTextBox.setTabIndex(1); passwordTextBox.setTabIndex(2); if (reallyShowNewWindowOption) { newWindowChk.setTabIndex(3); } passwordTextBox.setText(""); // $NON-NLS-1$ setFocusWidget(userTextBox); Image lockImage = new Image(GWT.getModuleBaseURL() + "images/icon_login_lock.png"); HorizontalPanel loginPanel = new HorizontalPanel(); loginPanel.setSpacing(5); loginPanel.setStyleName("login-panel"); loginPanel.add(lockImage); loginPanel.add(credentialsPanel); return loginPanel; }
@Override public void onModuleLoad() { /** * Seuls les profils Super Adminisatreur et CA peuvent se connecter à cette page * */ if (Cookies.getCookie("profil") == null) { Window.Location.replace(GWT.getHostPageBaseURL() + "Connexion.html" + Constantes.SUFFIXE_URL); } else if (Cookies.getCookie("client") == null) Window.Location.replace( GWT.getHostPageBaseURL() + "Accueil_superadmin.html" + Constantes.SUFFIXE_URL); else if (Cookies.getCookie("profil").equals("CU")) { Window.Location.replace( GWT.getHostPageBaseURL() + "Accueil_applifit.html" + Constantes.SUFFIXE_URL); } else { // Ajouter le menu à la page MenuForm menu = new MenuForm(Constantes.USER); Document.get().getBody().appendChild(menu.getElement()); /** * action de deconnexion ** */ Anchor deconnexionWrapper = Anchor.wrap(menu.getDeconnexion()); deconnexionWrapper.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { Utils.deconnexion(); } }); /** * action Rubrique accueil ** */ Anchor accueilWrapper = Anchor.wrap(menu.getAccueil()); accueilWrapper.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { if (Cookies.getCookie("profil").equals("SA")) Window.Location.replace( GWT.getHostPageBaseURL() + "Accueil_superadmin.html" + Constantes.SUFFIXE_URL); else Window.Location.replace( GWT.getHostPageBaseURL() + "Accueil_applifit.html" + Constantes.SUFFIXE_URL); } }); /** * action de rubrique formulaire ** */ Anchor formulaireWrapper = Anchor.wrap(menu.getFormulaire()); formulaireWrapper.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { if (Cookies.getCookie("profil").equals("SA") || Cookies.getCookie("profil").equals("CA")) Window.Location.replace( GWT.getHostPageBaseURL() + "Formulaire_menu_applifit.html" + Constantes.SUFFIXE_URL); else Window.Location.replace( GWT.getHostPageBaseURL() + "Formulaire_consulter_applifit.html" + Constantes.SUFFIXE_URL); } }); // Ajouter la zone de recherche à la page Document.get().getBody().insertAfter(recherche.getElement(), menu.getElement()); nativeMethod("datepicker"); // Remplire la liste des formulaires par les formulaires actifs liés // à la société courante FormulaireController.alimenterListeForm( FORMULAIRE_URL + "listerFormulaire/entreprise/" + Cookies.getCookie("client"), recherche); // Ajouter action por le button de recherche Anchor search = Anchor.wrap(recherche.getSearch_link()); search.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { final ListBox lb = ListBox.wrap(recherche.getFormulaire()); // Vider la liste lb.clear(); lb.addItem("Choisir un formulaire...", ""); // Lancer la recherche du formulaire selon le nom et la date // de création FormulaireController.rechercheForm(recherche); // Ajouter action on change de la liste des formulaires , // affichant le formulaire selectionné final ListBox lb2 = ListBox.wrap(recherche.getFormulaire()); lb2.addChangeHandler( new ChangeHandler() { @SuppressWarnings("rawtypes") @Override public void onChange(ChangeEvent event) { elements = new ArrayList(); parametres = new ArrayList(); choices = new ArrayList(); options = new ArrayList(); // Si la ligne selectionnée n'est pas le prompt de // la liste if (lb.getSelectedIndex() != 0) { // Récuperer la valeur selectionnée formulaire_id = Long.parseLong(lb.getValue(lb.getSelectedIndex())); // Récuperer les elements et parametres du // formulaire et les afficher dans la zone de // modification chargerFormulaire(); } } }); } }); // Ajouter action on change de la liste des formulaires , affichant // le formulaire selectionné final ListBox lb = ListBox.wrap(recherche.getFormulaire()); lb.addChangeHandler( new ChangeHandler() { @SuppressWarnings("rawtypes") @Override public void onChange(ChangeEvent event) { elements = new ArrayList(); parametres = new ArrayList(); choices = new ArrayList(); options = new ArrayList(); // Si la ligne selectionnée n'est pas le prompt de la liste if (lb.getSelectedIndex() != 0) { // Récuperer la valeur selectionnée formulaire_id = Long.parseLong(lb.getValue(lb.getSelectedIndex())); // Récuperer les elements et parametres du formulaire et // les afficher dans la zone de modification chargerFormulaire(); } } }); } }
// Remplir les deux zones de la liste par les comptes @SuppressWarnings("rawtypes") private void alimenterList() { final ArrayList comptes = new ArrayList(); final ArrayList allocation = new ArrayList(); // Récuperer la liste de tous les comptes CA et CU RequestBuilder builder = new RequestBuilder( RequestBuilder.GET, COMPTE_URL + "listerCompteEntrepriseAU/client/" + Cookies.getCookie("client")); builder.setHeader("Content-Type", "application/json"); try { builder.sendRequest( null, new RequestCallback() { public void onError(Request request, Throwable exception) { Window.alert("erreur de récupération du formulaire"); } @SuppressWarnings({"deprecation", "unchecked"}) public void onResponseReceived(Request request, Response response) { JSONValue comptesAsJSONValue = JSONParser.parse(response.getText()); JSONArray comptesAsJSONArray = comptesAsJSONValue.isArray(); // Alimenter la liste for (int i = 0; i < comptesAsJSONArray.size(); i++) { JSONValue compteAsJSONValue = comptesAsJSONArray.get(i); JSONObject compteAsJSONObject = compteAsJSONValue.isObject(); ArrayList compte = new ArrayList(); compte.add( compteAsJSONObject.get("nom").isString().stringValue() + " " + compteAsJSONObject.get("prenom").isString().stringValue()); compte.add(compteAsJSONObject.get("id").isNumber().toString()); comptes.add(compte); } // Récuperer la liste des comptes pour lesquels, nous avons // allouer cette version du formulaire RequestBuilder builder = new RequestBuilder( RequestBuilder.GET, FORMULAIRE_URL + "listerCompteAllocation/formulaire/" + formulaire_id); builder.setHeader("Content-Type", "application/json"); try { builder.sendRequest( null, new RequestCallback() { public void onError(Request request, Throwable exception) { Window.alert("erreur de récupération du formulaire"); } public void onResponseReceived(Request request, Response response) { JSONValue comptesAsJSONValue = JSONParser.parse(response.getText()); JSONArray comptesAsJSONArray = comptesAsJSONValue.isArray(); for (int i = 0; i < comptesAsJSONArray.size(); i++) { JSONValue compteAsJSONValue = comptesAsJSONArray.get(i); JSONObject compteAsJSONObject = compteAsJSONValue.isObject(); ArrayList compte = new ArrayList(); compte.add( compteAsJSONObject.get("nom").isString().stringValue() + " " + compteAsJSONObject.get("prenom").isString().stringValue()); compte.add(compteAsJSONObject.get("id").isNumber().toString()); allocation.add(compte); } dualListBox.setLIST_SIZE(comptes.size()); dualListBox.construire("10em"); // Ajouter la liste des comptes auxquels nous // avons alloué le formulaire à la zone droite for (int i = 0; i < allocation.size(); i++) { comptes.remove(allocation.get(i)); ArrayList compte = (ArrayList) allocation.get(i); dualListBox.addRight(compte.get(0).toString(), compte.get(1).toString()); } // Ajouter la liste des comptes auxquels nous // n'avons pas encore alloué le formulaire à la // zone gauche for (int i = 0; i < comptes.size(); i++) { ArrayList compte = (ArrayList) comptes.get(i); dualListBox.addLeft(compte.get(0).toString(), compte.get(1).toString()); } } }); } catch (RequestException e) { Window.alert("RequestException"); } } }); } catch (RequestException e) { Window.alert("RequestException"); } }