Search in sources :

Example 1 with UserTreeOptions

use of org.geosdi.geoplatform.gui.impl.users.options.UserTreeOptions in project geo-platform by geosdi.

the class UserOptionsMemberView method creteLayoutData.

@Override
protected void creteLayoutData(ContentPanel panel) {
    // VBoxLayoutData layoutData = new VBoxLayoutData(new Margins(0, 0, 5, 0));
    // panel.add(new Label("Set GRATICULA"), layoutData);
    // panel.add(new Label("Set SCALE"), layoutData);
    UserTreeOptions userTreeOptions = Registry.get(UserSessionEnum.USER_TREE_OPTIONS.name());
    FormPanel formPanel = new FormPanel();
    startupStrategyCheckBox = new CheckBox();
    startupStrategyCheckBox.setFieldLabel(UserModuleConstants.INSTANCE.UserOptionsMemberView_startupStrategyLabelText());
    startupStrategyCheckBox.addListener(Events.Change, new Listener<BaseEvent>() {

        @Override
        public void handleEvent(BaseEvent be) {
            UserOptionsMemberView.super.saveButton.enable();
        }
    });
    startupStrategyCheckBox.setValue(userTreeOptions.isLoadExpandedFolders());
    formPanel.add(startupStrategyCheckBox);
    formPanel.setHeaderVisible(Boolean.FALSE);
    formPanel.setBodyBorder(Boolean.FALSE);
    formPanel.setBorders(Boolean.FALSE);
    formPanel.setWidth(400);
    super.saveButton.disable();
    panel.add(formPanel);
}
Also used : FormPanel(com.extjs.gxt.ui.client.widget.form.FormPanel) CheckBox(com.extjs.gxt.ui.client.widget.form.CheckBox) UserTreeOptions(org.geosdi.geoplatform.gui.impl.users.options.UserTreeOptions) BaseEvent(com.extjs.gxt.ui.client.event.BaseEvent)

Example 2 with UserTreeOptions

use of org.geosdi.geoplatform.gui.impl.users.options.UserTreeOptions in project geo-platform by geosdi.

the class UserOptionsMemberView method saveOptions.

@Override
public void saveOptions() {
    this.startupStrategyCheckBox.getValue();
    final UserTreeOptions userTreeOptions = Registry.get(UserSessionEnum.USER_TREE_OPTIONS.name());
    userTreeOptions.setLoadExpandedFolders(startupStrategyCheckBox.getValue());
    xsrf.getNewXsrfToken(new AsyncCallback<XsrfToken>() {

        @Override
        public void onFailure(Throwable caught) {
            try {
                throw caught;
            } catch (RpcTokenException e) {
            // Can be thrown for several reasons:
            // - duplicate session cookie, which may be a sign of a cookie
            // overwrite attack
            // - XSRF token cannot be generated because session cookie isn't
            // present
            } catch (Throwable e) {
            // unexpected
            }
        }

        @Override
        public void onSuccess(XsrfToken token) {
            ((HasRpcToken) userRemote).setRpcToken(token);
            userRemote.updateUserTreeOptions(userTreeOptions, new AsyncCallback<Long>() {

                @Override
                public void onFailure(Throwable caught) {
                    if (caught.getCause() instanceof GPSessionTimeout) {
                        GPHandlerManager.fireEvent(new GPLoginEvent(null));
                    } else {
                        GeoPlatformMessage.errorMessage(WindowsConstants.INSTANCE.errorSavingTitleText(), WindowsConstants.INSTANCE.errorMakingConnectionBodyText());
                        LayoutManager.getInstance().getStatusMap().setStatus(UserModuleConstants.INSTANCE.UserOptionsMemberView_statusErrorSavingText(), SearchStatus.EnumSearchStatus.STATUS_NO_SEARCH.toString());
                        System.out.println("Error saving view options: " + caught.toString() + " data: " + caught.getMessage());
                    }
                }

                @Override
                public void onSuccess(Long result) {
                    UserOptionsMemberView.super.saveButton.disable();
                    LayoutManager.getInstance().getStatusMap().setStatus(UserModuleConstants.INSTANCE.UserOptionsMemberView_statusSaveOptionSuccesfullyText(), SearchStatus.EnumSearchStatus.STATUS_SEARCH.toString());
                }
            });
        }
    });
}
Also used : AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) UserTreeOptions(org.geosdi.geoplatform.gui.impl.users.options.UserTreeOptions) GPSessionTimeout(org.geosdi.geoplatform.gui.utility.GPSessionTimeout) GPLoginEvent(org.geosdi.geoplatform.gui.impl.map.event.GPLoginEvent) RpcTokenException(com.google.gwt.user.client.rpc.RpcTokenException) XsrfToken(com.google.gwt.user.client.rpc.XsrfToken)

Example 3 with UserTreeOptions

use of org.geosdi.geoplatform.gui.impl.users.options.UserTreeOptions in project geo-platform by geosdi.

the class DTOSecurityConverter method convertAccountToDTO.

public IGPAccountDetail convertAccountToDTO(GPAccount account, GPAccountProject accountProject, GPViewport viewport, List<GPMessage> messages) {
    GPLoginUserDetail accountDetail = new GPLoginUserDetail();
    UserTreeOptions usertreeOptions = new UserTreeOptions();
    accountDetail.setId(account.getId());
    // Forced representation
    accountDetail.setUsername(account.getNaturalID());
    accountDetail.setOrganization(account.getOrganization().getName());
    usertreeOptions.setLoadExpandedFolders(account.isLoadExpandedFolders());
    accountDetail.setTreeOptions(usertreeOptions);
    if (account instanceof GPUser) {
        GPUser user = (GPUser) account;
        accountDetail.setName(user.getName());
        accountDetail.setEmail(user.getEmailAddress());
        this.extractGPAuthoritiesInToUser(accountDetail, account.getGPAuthorities());
    }
    if (account.getGsAccount() != null) {
        accountDetail.setAuthkey(account.getGsAccount().getAuthkey());
    }
    accountDetail.setHostXmppServer(hostXmppServer);
    if (accountProject != null) {
        accountDetail.setBaseLayer(accountProject.getBaseLayer());
    }
    if (viewport != null) {
        GPBBox serverBBOX = viewport.getBbox();
        BBoxClientInfo clientBBOX = new BBoxClientInfo(serverBBOX.getMinX(), serverBBOX.getMinY(), serverBBOX.getMaxX(), serverBBOX.getMaxY());
        GPClientViewport clientViewport = new GPClientViewport(viewport.getName(), viewport.getDescription(), clientBBOX, viewport.getZoomLevel(), viewport.isIsDefault());
        accountDetail.setViewport(clientViewport);
    }
    if (messages != null) {
        List<IGPClientMessage> unreadMessages = Lists.newArrayListWithCapacity(messages.size());
        for (GPMessage message : messages) {
            GPClientMessage clientMessage = this.convertMessage(message);
            unreadMessages.add(clientMessage);
            logger.debug("\n*** {}", clientMessage);
        }
        Collections.sort(unreadMessages);
        accountDetail.setUnreadMessages(unreadMessages);
    }
    return (IGPAccountDetail) accountDetail;
}
Also used : BBoxClientInfo(org.geosdi.geoplatform.gui.configuration.map.client.geometry.BBoxClientInfo) IGPAccountDetail(org.geosdi.geoplatform.gui.global.security.IGPAccountDetail) IGPClientMessage(org.geosdi.geoplatform.gui.model.message.IGPClientMessage) GPMessage(org.geosdi.geoplatform.core.model.GPMessage) GPUser(org.geosdi.geoplatform.core.model.GPUser) GPClientMessage(org.geosdi.geoplatform.gui.impl.message.GPClientMessage) IGPClientMessage(org.geosdi.geoplatform.gui.model.message.IGPClientMessage) GPClientViewport(org.geosdi.geoplatform.gui.configuration.map.client.GPClientViewport) UserTreeOptions(org.geosdi.geoplatform.gui.impl.users.options.UserTreeOptions) GPLoginUserDetail(org.geosdi.geoplatform.gui.client.model.security.GPLoginUserDetail) GPBBox(org.geosdi.geoplatform.core.model.GPBBox)

Aggregations

UserTreeOptions (org.geosdi.geoplatform.gui.impl.users.options.UserTreeOptions)3 BaseEvent (com.extjs.gxt.ui.client.event.BaseEvent)1 CheckBox (com.extjs.gxt.ui.client.widget.form.CheckBox)1 FormPanel (com.extjs.gxt.ui.client.widget.form.FormPanel)1 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)1 RpcTokenException (com.google.gwt.user.client.rpc.RpcTokenException)1 XsrfToken (com.google.gwt.user.client.rpc.XsrfToken)1 GPBBox (org.geosdi.geoplatform.core.model.GPBBox)1 GPMessage (org.geosdi.geoplatform.core.model.GPMessage)1 GPUser (org.geosdi.geoplatform.core.model.GPUser)1 GPLoginUserDetail (org.geosdi.geoplatform.gui.client.model.security.GPLoginUserDetail)1 GPClientViewport (org.geosdi.geoplatform.gui.configuration.map.client.GPClientViewport)1 BBoxClientInfo (org.geosdi.geoplatform.gui.configuration.map.client.geometry.BBoxClientInfo)1 IGPAccountDetail (org.geosdi.geoplatform.gui.global.security.IGPAccountDetail)1 GPLoginEvent (org.geosdi.geoplatform.gui.impl.map.event.GPLoginEvent)1 GPClientMessage (org.geosdi.geoplatform.gui.impl.message.GPClientMessage)1 IGPClientMessage (org.geosdi.geoplatform.gui.model.message.IGPClientMessage)1 GPSessionTimeout (org.geosdi.geoplatform.gui.utility.GPSessionTimeout)1