Changeset 3939


Ignore:
Timestamp:
Nov 2, 2010, 1:14:31 PM (13 years ago)
Author:
Gregory Vincic
Message:

Refs #698. Removed method getViewUserPropertiesForm.

Location:
trunk/client/servlet/src/org/proteios
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/client/servlet/src/org/proteios/action/user/SaveMyProfileProperties.java

    r3838 r3939  
    11/*
    2  $Id$
    3 
    4  Copyright (C) 2006, 2007 Gregory Vincic
    5 
    6  Files are copyright by their respective authors. The contributions to
    7  files where copyright is not explicitly stated can be traced with the
    8  source code revision system.
    9 
    10  This file is part of Proteios.
    11  Available at http://www.proteios.org/
    12 
    13  Proteios-2.x is free software; you can redistribute it and/or
    14  modify it under the terms of the GNU General Public License
    15  as published by the Free Software Foundation; either version 2
    16  of the License, or (at your option) any later version.
    17 
    18  Proteios is distributed in the hope that it will be useful,
    19  but WITHOUT ANY WARRANTY; without even the implied warranty of
    20  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    21  GNU General Public License for more details.
    22 
    23  You should have received a copy of the GNU General Public License
    24  along with this program; if not, write to the Free Software
    25  Foundation, Inc., 59 Temple Place - Suite 330,
    26  Boston, MA  02111-1307, USA.
    27  */
     2    $Id$
     3               
     4    Copyright (C) 2006, 2007, 2010 Gregory Vincic
     5               
     6    Files are copyright by their respective authors. The contributions to
     7    files where copyright is not explicitly stated can be traced with the
     8    source code revision system.
     9               
     10    This file is part of Proteios.
     11    Available at http://www.proteios.org/
     12               
     13    Proteios-2.x is free software; you can redistribute it and/or
     14    modify it under the terms of the GNU General Public License
     15    as published by the Free Software Foundation; either version 2
     16    of the License, or (at your option) any later version.
     17               
     18    Proteios is distributed in the hope that it will be useful,
     19    but WITHOUT ANY WARRANTY; without even the implied warranty of
     20    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     21    GNU General Public License for more details.
     22               
     23    You should have received a copy of the GNU General Public License
     24    along with this program; if not, write to the Free Software
     25    Foundation, Inc., 59 Temple Place - Suite 330,
     26    Boston, MA  02111-1307, USA.
     27*/
    2828package org.proteios.action.user;
    2929
     
    3535import se.lu.thep.waf.constraints.InvalidParameterValue;
    3636
    37 /**
    38  * @author gregory
    39  */
    4037public class SaveMyProfileProperties
    41     extends ProteiosAction<SaveMyProfileProperties>
     38extends ProteiosAction<SaveMyProfileProperties>
    4239{
    43   @Override
    44   public void runMe()
    45       throws ActionException, InvalidParameterValue
    46   {
    47   Form form;
    48   String name, email,descr,phone,address,organisation;
    49   DbControl dc;
    50   User user;
    51 
    52     form = getFormFactory().getViewUserPropertiesForm(null);
    53     verifyParameters(form);
    54 
    55     name = getString(NameField.VPARAM);
    56     email = getString(EmailField.VPARAM);
    57     descr = getString(DescriptionField.VPARAM);
    58     phone = getString(PhoneField.VPARAM);
    59     address = getString(AddressField.VPARAM);
    60   organisation = getString(OrganisationField.VPARAM);
    61 
    62     // Save user
    63     dc = newDbControl();
    64     user = getOwner();
    65   dc.reattachItem(user);
    66 
    67     user.setName(name);
    68     user.setEmail(email);
    69     user.setDescription(descr);
    70   user.setPhone(phone);
    71   user.setAddress(address);
    72   user.setOrganisation(organisation);
    73     dc.commit();
    74 
    75     setMessage("User properties saved");   
    76 
    77     setForwardTo(ViewMyProfileAction.class);
    78   }
     40    @Override
     41    public void runMe()
     42    throws ActionException, InvalidParameterValue
     43    {
     44        Form form;
     45        String name, email,descr,phone,address,organisation;
     46        DbControl dc;
     47        User user;
     48                               
     49        form = getFormFactory().getForm(User.class);
     50        verifyParameters(form);
     51                               
     52        name = getString(NameField.VPARAM);
     53        email = getString(EmailField.VPARAM);
     54        descr = getString(DescriptionField.VPARAM);
     55        phone = getString(PhoneField.VPARAM);
     56        address = getString(AddressField.VPARAM);
     57        organisation = getString(OrganisationField.VPARAM);
     58                               
     59        user = getOwner();       
     60        user.setName(name);
     61        user.setEmail(email);
     62        user.setDescription(descr);
     63        user.setPhone(phone);
     64        user.setAddress(address);
     65        user.setOrganisation(organisation);
     66                       
     67        dc = newDbControl();
     68        dc.reattachItem(user);
     69        dc.commit();
     70                               
     71        setMessage("User properties saved");           
     72        setForwardTo(ViewMyProfileAction.class);
     73    }
    7974}
  • trunk/client/servlet/src/org/proteios/action/user/SaveUserProperties.java

    r3838 r3939  
    11/*
    2  $Id$
    3  
    4  Copyright (C) 2006, 2007 Gregory Vincic
    5  
    6  Files are copyright by their respective authors. The contributions to
    7  files where copyright is not explicitly stated can be traced with the
    8  source code revision system.
    9  
    10  This file is part of Proteios.
    11  Available at http://www.proteios.org/
    12  
    13  Proteios is free software; you can redistribute it and/or
    14  modify it under the terms of the GNU General Public License
    15  as published by the Free Software Foundation; either version 2
    16  of the License, or (at your option) any later version.
    17  
    18  Proteios is distributed in the hope that it will be useful,
    19  but WITHOUT ANY WARRANTY; without even the implied warranty of
    20  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    21  GNU General Public License for more details.
    22  
    23  You should have received a copy of the GNU General Public License
    24  along with this program; if not, write to the Free Software
    25  Foundation, Inc., 59 Temple Place - Suite 330,
    26  Boston, MA  02111-1307, USA.
    27  */
     2    $Id$
     3                
     4    Copyright (C) 2006, 2007, 2010 Gregory Vincic
     5                
     6    Files are copyright by their respective authors. The contributions to
     7    files where copyright is not explicitly stated can be traced with the
     8    source code revision system.
     9                
     10    This file is part of Proteios.
     11    Available at http://www.proteios.org/
     12                
     13    Proteios is free software; you can redistribute it and/or
     14    modify it under the terms of the GNU General Public License
     15    as published by the Free Software Foundation; either version 2
     16    of the License, or (at your option) any later version.
     17                
     18    Proteios is distributed in the hope that it will be useful,
     19    but WITHOUT ANY WARRANTY; without even the implied warranty of
     20    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     21    GNU General Public License for more details.
     22                
     23    You should have received a copy of the GNU General Public License
     24    along with this program; if not, write to the Free Software
     25    Foundation, Inc., 59 Temple Place - Suite 330,
     26    Boston, MA  02111-1307, USA.
     27*/
    2828package org.proteios.action.user;
    2929
     
    3535import se.lu.thep.waf.constraints.InvalidParameterValue;
    3636
    37 /**
    38  * @author gregory
    39  */
    4037public class SaveUserProperties
    41     extends ProteiosAction<SaveUserProperties>
     38extends ProteiosAction<SaveUserProperties>
    4239{
    43   @Override
    44   public void runMe()
    45       throws ActionException, InvalidParameterValue
    46   {
    47   Form form;
    48   Integer userId;
    49   String name, email,descr,phone,address,organisation;
    50   DbControl dc;
    51   User user;
    52 
    53     form = getFormFactory().getViewUserPropertiesForm(null);
    54     verifyParameters(form);
    55 
    56     userId = getValidInteger(FormFactory.VID);
    57     name = getString(NameField.VPARAM);
    58     email = getString(EmailField.VPARAM);
    59     descr = getString(DescriptionField.VPARAM);
    60     phone = getString(PhoneField.VPARAM);
    61     address = getString(AddressField.VPARAM);
    62   organisation = getString(OrganisationField.VPARAM);
    63 
    64     // Save user
    65     dc = newDbControl();
    66     user = User.getById(dc, userId);
    67     user.setName(name);
    68     user.setEmail(email);
    69     user.setDescription(descr);
    70   user.setPhone(phone);
    71   user.setAddress(address);
    72   user.setOrganisation(organisation);
    73     dc.commit();
    74 
    75     setMessage("User properties saved");
    76 
    77     setForwardTo(ViewActiveUser.class);
    78   }
     40    @Override
     41    public void runMe()
     42    throws ActionException, InvalidParameterValue
     43    {
     44        Form form;
     45        Integer userId;
     46        String name, email,descr,phone,address,organisation;
     47        DbControl dc;
     48        User user;
     49                               
     50        form = getFormFactory().getForm(User.class);
     51        verifyParameters(form);
     52                               
     53        userId = getValidInteger(FormFactory.VID);
     54        name = getString(NameField.VPARAM);
     55        email = getString(EmailField.VPARAM);
     56        descr = getString(DescriptionField.VPARAM);
     57        phone = getString(PhoneField.VPARAM);
     58        address = getString(AddressField.VPARAM);
     59        organisation = getString(OrganisationField.VPARAM);
     60                               
     61        // Save user
     62        dc = newDbControl();
     63        user = getItemFactory(dc).getById(dc, userId);
     64        user.setName(name);
     65        user.setEmail(email);
     66        user.setDescription(descr);
     67        user.setPhone(phone);
     68        user.setAddress(address);
     69        user.setOrganisation(organisation);
     70        dc.commit();
     71                               
     72        setMessage("User properties saved");
     73        setForwardTo(ViewActiveUser.class);
     74    }
    7975}
  • trunk/client/servlet/src/org/proteios/action/user/ViewActiveUser.java

    r3801 r3939  
    11/*
    2  $Id$
    3  
    4  Copyright (C) 2006, 2007 Gregory Vincic
    5  
    6  Files are copyright by their respective authors. The contributions to
    7  files where copyright is not explicitly stated can be traced with the
    8  source code revision system.
    9  
    10  This file is part of Proteios.
    11  Available at http://www.proteios.org/
    12  
    13  Proteios is free software; you can redistribute it and/or
    14  modify it under the terms of the GNU General Public License
    15  as published by the Free Software Foundation; either version 2
    16  of the License, or (at your option) any later version.
    17  
    18  Proteios is distributed in the hope that it will be useful,
    19  but WITHOUT ANY WARRANTY; without even the implied warranty of
    20  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    21  GNU General Public License for more details.
    22  
    23  You should have received a copy of the GNU General Public License
    24  along with this program; if not, write to the Free Software
    25  Foundation, Inc., 59 Temple Place - Suite 330,
    26  Boston, MA  02111-1307, USA.
    27  */
     2    $Id$
     3                
     4    Copyright (C) 2006, 2007, 2010 Gregory Vincic
     5                
     6    Files are copyright by their respective authors. The contributions to
     7    files where copyright is not explicitly stated can be traced with the
     8    source code revision system.
     9                
     10    This file is part of Proteios.
     11    Available at http://www.proteios.org/
     12                
     13    Proteios is free software; you can redistribute it and/or
     14    modify it under the terms of the GNU General Public License
     15    as published by the Free Software Foundation; either version 2
     16    of the License, or (at your option) any later version.
     17                
     18    Proteios is distributed in the hope that it will be useful,
     19    but WITHOUT ANY WARRANTY; without even the implied warranty of
     20    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     21    GNU General Public License for more details.
     22                
     23    You should have received a copy of the GNU General Public License
     24    along with this program; if not, write to the Free Software
     25    Foundation, Inc., 59 Temple Place - Suite 330,
     26    Boston, MA  02111-1307, USA.
     27*/
    2828package org.proteios.action.user;
    2929
     
    3333import org.proteios.core.DbControl;
    3434import org.proteios.core.User;
     35import org.proteios.gui.ColumnContainer;
     36import org.proteios.gui.RowContainer;
     37import org.proteios.gui.Title;
    3538import org.proteios.gui.Toolbar;
    36 import org.proteios.gui.Title;
    37 import org.proteios.gui.RowContainer;
    38 import org.proteios.gui.ColumnContainer;
    3939import org.proteios.gui.form.*;
    4040import org.proteios.gui.layout.RowLayout;
     
    4343import se.lu.thep.waf.constraints.VInteger;
    4444
    45 /**
    46  * @author gregory
    47  */
    4845public class ViewActiveUser
    49     extends ProteiosAction<ViewActiveUser>
     46extends ProteiosAction<ViewActiveUser>
    5047{
    51   public static final VInteger VUSERID = new VInteger("active.user.id", 1,
    52     true);
    53 
    54 
    55   @Override
    56   public void runMe()
    57       throws ActionException, InvalidParameterValue
    58   {
    59     // Define
    60     RowLayout layout;
    61     Integer id;
    62     DbControl dc;
    63     User user;
    64     Form propertiesF, passwordF, rolesF, groupsF;
    65     Toolbar tb1, tb2, tb3, tb4;
    66     ActionLink saveUser, savePwd, saveRoles, saveGroups, newGroup;
    67   RowContainer rc, rc1;
    68   ColumnContainer cc;
    69   Title title;
    70 
    71     // Create
    72     verifySessionAttributes(VUSERID);
    73     layout = getLayoutFactory().getRowLayout();
    74     id = getSessionAttribute(VUSERID);
    75     dc = newDbControl();
    76     user = User.getById(dc, id);
    77     tb1 = new Toolbar();
    78     tb2 = new Toolbar();
    79     tb3 = new Toolbar();
    80     tb4 = new Toolbar();
    81     savePwd = getActionFactory().getActionLink(ChangeUserPassword.class, "Save");
    82     saveUser = getActionFactory().getActionLink(SaveUserProperties.class, "Save");
    83     saveRoles = getActionFactory().getActionLink(SaveUserRoles.class, "Save");
    84     saveGroups = getActionFactory().getActionLink(SaveUserGroups.class, "Save");
    85     newGroup = getActionFactory().getActionLink(NewGroup.class, "New");
    86   rc = new RowContainer();
    87   rc1 = new RowContainer();
    88   cc = new ColumnContainer();
    89   title = new Title("User");
    90 
    91     passwordF = new ProfilePasswordForm(user);
    92     rolesF = new UserRolesForm(user);
    93     groupsF = new GroupsForm(user);
    94     propertiesF = getFormFactory().getViewUserPropertiesForm(user);
    95   title.setSubtitle(user.getName());
    96     // The roles form needs an open DbControl to list roles
    97     close(dc);
    98  
    99     // Use
    100     tb1.add(saveUser);
    101     tb2.add(savePwd);
    102     tb3.add(saveRoles);
    103     tb4.add(saveGroups);
    104     tb4.add(newGroup);
    105 
    106     propertiesF.setToolbar(tb1);
    107     passwordF.setToolbar(tb2);
    108     rolesF.setToolbar(tb3);
    109     groupsF.setToolbar(tb4);
    110 
    111   rc.add(propertiesF);
    112 
    113   rc1.add(passwordF);
    114   rc1.add(rolesF);
    115   rc1.add(groupsF);
    116 
    117   cc.add(rc);
    118   cc.add(rc1);
    119 
    120   layout.add(title);
    121     layout.add(cc);
    122     setLayout(layout);
    123   }
     48    public static final VInteger VUSERID = new VInteger("active.user.id", 1,
     49    true);
     50               
     51    @Override
     52    public void runMe()
     53    throws ActionException, InvalidParameterValue
     54    {
     55        RowLayout layout;
     56        Integer id;
     57        DbControl dc;
     58        User user;
     59        Form propertiesF, passwordF, rolesF, groupsF;
     60        Toolbar tb1, tb2, tb3, tb4;
     61        ActionLink saveUser, savePwd, saveRoles, saveGroups, newGroup;
     62        RowContainer rc, rc1;
     63        ColumnContainer cc;
     64        Title title;
     65                               
     66        verifySessionAttributes(VUSERID);
     67        layout = getLayoutFactory().getRowLayout();
     68        id = getSessionAttribute(VUSERID);
     69        dc = newDbControl();
     70        user = User.getById(dc, id);
     71        tb1 = new Toolbar();
     72        tb2 = new Toolbar();
     73        tb3 = new Toolbar();
     74        tb4 = new Toolbar();
     75        savePwd = getActionFactory().getActionLink(ChangeUserPassword.class, "Save");
     76        saveUser = getActionFactory().getActionLink(SaveUserProperties.class, "Save");
     77        saveRoles = getActionFactory().getActionLink(SaveUserRoles.class, "Save");
     78        saveGroups = getActionFactory().getActionLink(SaveUserGroups.class, "Save");
     79        newGroup = getActionFactory().getActionLink(NewGroup.class, "New");
     80        rc = new RowContainer();
     81        rc1 = new RowContainer();
     82        cc = new ColumnContainer();
     83        title = new Title("User");
     84                               
     85        passwordF = new ProfilePasswordForm(user);
     86        rolesF = new UserRolesForm(user);
     87        groupsF = new GroupsForm(user);
     88        propertiesF = getFormFactory().getForm(User.class, user);
     89        title.setSubtitle(user.getName());
     90        // The roles form needs an open DbControl to list roles
     91        close(dc);
     92                                 
     93        // Use
     94        tb1.add(saveUser);
     95        tb2.add(savePwd);
     96        tb3.add(saveRoles);
     97        tb4.add(saveGroups);
     98        tb4.add(newGroup);
     99                               
     100        propertiesF.setToolbar(tb1);
     101        passwordF.setToolbar(tb2);
     102        rolesF.setToolbar(tb3);
     103        groupsF.setToolbar(tb4);
     104                               
     105        rc.add(propertiesF);
     106                               
     107        rc1.add(passwordF);
     108        rc1.add(rolesF);
     109        rc1.add(groupsF);
     110                               
     111        cc.add(rc);
     112        cc.add(rc1);
     113                               
     114        layout.add(title);
     115        layout.add(cc);
     116        setLayout(layout);
     117    }
    124118}
  • trunk/client/servlet/src/org/proteios/action/user/ViewMyProfileAction.java

    r3938 r3939  
    11/*
    2  $Id$
    3 
    4  Copyright (C) 2006, 2007 Gregory Vincic
    5 
    6  Files are copyright by their respective authors. The contributions to
    7  files where copyright is not explicitly stated can be traced with the
    8  source code revision system.
    9 
    10  This file is part of Proteios.
    11  Available at http://www.proteios.org/
    12 
    13  Proteios-2.x is free software; you can redistribute it and/or
    14  modify it under the terms of the GNU General Public License
    15  as published by the Free Software Foundation; either version 2
    16  of the License, or (at your option) any later version.
    17 
    18  Proteios is distributed in the hope that it will be useful,
    19  but WITHOUT ANY WARRANTY; without even the implied warranty of
    20  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    21  GNU General Public License for more details.
    22 
    23  You should have received a copy of the GNU General Public License
    24  along with this program; if not, write to the Free Software
    25  Foundation, Inc., 59 Temple Place - Suite 330,
    26  Boston, MA  02111-1307, USA.
    27  */
     2    $Id$
     3       
     4    Copyright (C) 2006, 2007, 2010 Gregory Vincic
     5       
     6    Files are copyright by their respective authors. The contributions to
     7    files where copyright is not explicitly stated can be traced with the
     8    source code revision system.
     9       
     10    This file is part of Proteios.
     11    Available at http://www.proteios.org/
     12       
     13    Proteios-2.x is free software; you can redistribute it and/or
     14    modify it under the terms of the GNU General Public License
     15    as published by the Free Software Foundation; either version 2
     16    of the License, or (at your option) any later version.
     17       
     18    Proteios is distributed in the hope that it will be useful,
     19    but WITHOUT ANY WARRANTY; without even the implied warranty of
     20    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     21    GNU General Public License for more details.
     22       
     23    You should have received a copy of the GNU General Public License
     24    along with this program; if not, write to the Free Software
     25    Foundation, Inc., 59 Temple Place - Suite 330,
     26    Boston, MA  02111-1307, USA.
     27*/
    2828package org.proteios.action.user;
    2929
     
    3131import org.proteios.ActionLink;
    3232import org.proteios.action.ProteiosAction;
     33import org.proteios.core.DbControl;
     34import org.proteios.core.ItemQuery;
     35import org.proteios.core.Role;
    3336import org.proteios.core.User;
    34 import org.proteios.core.Role;
    35 import org.proteios.core.ItemQuery;
    36 import org.proteios.core.DbControl;
     37import org.proteios.gui.ColumnContainer;
     38import org.proteios.gui.ListItem;
     39import org.proteios.gui.Listing;
     40import org.proteios.gui.RowContainer;
    3741import org.proteios.gui.Title;
    3842import org.proteios.gui.Toolbar;
    39 import org.proteios.gui.Listing;
    40 import org.proteios.gui.ListItem;
    41 import org.proteios.gui.ColumnContainer;
    42 import org.proteios.gui.RowContainer;
    4343import org.proteios.gui.form.*;
    4444import org.proteios.gui.layout.RowLayout;
    45 
    4645import se.lu.thep.waf.ActionException;
    4746import se.lu.thep.waf.constraints.InvalidParameterValue;
    4847
    4948/**
    50  * Displays the currently logged in users profile.
    51  *
    52  * @author gregory
    53  */
     49    Displays the currently logged in users profile.
     50*/
    5451public class ViewMyProfileAction
    55     extends ProteiosAction<ViewMyProfileAction>
     52extends ProteiosAction<ViewMyProfileAction>
    5653{
    57   @Override
    58   public void runMe()
    59       throws ActionException, InvalidParameterValue
    60   {
    61     // Define
    62     User user;
    63     RowLayout layout;
    64     Title title;
    65     Form propertiesForm, pwdForm;
    66     Toolbar tb1, tb2;
    67     ActionLink save, changePassword;
    68   ColumnContainer cc;
    69   Listing roles;
    70   ListItem li;
    71   RowContainer rc;
    72   DbControl dc;
    73 
    74   dc = newDbControl();
    75     layout = getLayoutFactory().getRowLayout();
    76     user = getOwner();
    77     title = new Title("Profile");
    78     propertiesForm = getFormFactory().getForm(User.class, user);
    79     tb1 = new Toolbar();
    80     save = getActionFactory().getActionLink(SaveMyProfileProperties.class,
    81       "Save");
    82   rc = new RowContainer();
    83   cc = new ColumnContainer();
    84   roles = new Listing();
    85   roles.setTitle("Roles");
    86 
    87     title.setSubtitle(user.getLogin());
    88     propertiesForm.setToolbar(tb1);
    89     tb1.add(save);
    90 
    91   pwdForm = null;
    92     if (!user.isMultiuserAccount())
    93     {
    94       pwdForm = new ProfilePasswordForm(user);
    95       tb2 = new Toolbar();
    96       changePassword = getActionFactory().getActionLink(
    97       ChangeMyPassword.class, "ChangePassword");
    98 
    99       pwdForm.setToolbar(tb2);
    100       tb2.add(changePassword);
    101     }
    102 
    103   for(Role role : user.getRoles().list(dc))
    104   {
    105     li = new ListItem(role.getId());
    106     li.setTitle(role.getName());
    107     li.setContent(role.getDescription());
    108     roles.add(li);
    109   }
    110     layout.add(title);
    111   cc.add(propertiesForm);
    112   if(pwdForm != null) { rc.add(pwdForm); }
    113   rc.add(roles);
    114   cc.add(rc);
    115     layout.add(cc);
    116     setLayout(layout);
    117   }
    118 
    119 
    120   public @Override
    121   AbstractLink getHistoryAction()
    122   {
    123     return getActionFactory().getActionLink(ViewMyProfileAction.class,
    124       "Profile");
    125   }
     54    @Override
     55    public void runMe()
     56    throws ActionException, InvalidParameterValue
     57    {
     58        User user;
     59        RowLayout layout;
     60        Title title;
     61        Form propertiesForm, pwdForm;
     62        Toolbar tb1, tb2;
     63        ActionLink save, changePassword;
     64        ColumnContainer cc;
     65        Listing roles;
     66        ListItem li;
     67        RowContainer rc;
     68        DbControl dc;
     69                 
     70        dc = newDbControl();
     71        layout = getLayoutFactory().getRowLayout();
     72        user = getOwner();
     73        title = new Title("Profile");
     74        propertiesForm = getFormFactory().getForm(User.class, user);
     75        tb1 = new Toolbar();
     76        save = getActionFactory().getActionLink(SaveMyProfileProperties.class, "Save");
     77        rc = new RowContainer();
     78        cc = new ColumnContainer();
     79        roles = new Listing();
     80        roles.setTitle("Roles");
     81               
     82        title.setSubtitle(user.getLogin());
     83        propertiesForm.setToolbar(tb1);
     84        tb1.add(save);
     85               
     86        pwdForm = null;
     87        if (!user.isMultiuserAccount())
     88        {
     89            changePassword = getActionFactory().getActionLink(ChangeMyPassword.class, "ChangePassword");
     90            tb2 = new Toolbar();           
     91            tb2.add(changePassword);
     92           
     93            pwdForm = new ProfilePasswordForm(user);
     94            pwdForm.setToolbar(tb2);
     95        }
     96               
     97        for(Role role : user.getRoles().list(dc))
     98        {
     99            li = new ListItem(role.getId());
     100            li.setTitle(role.getName());
     101            li.setContent(role.getDescription());
     102            roles.add(li);
     103        }
     104        layout.add(title);
     105        cc.add(propertiesForm);
     106        if(pwdForm != null) { rc.add(pwdForm); }
     107        rc.add(roles);
     108        cc.add(rc);
     109        layout.add(cc);
     110        setLayout(layout);
     111    }
    126112}
  • trunk/client/servlet/src/org/proteios/gui/form/FormFactory.java

    r3938 r3939  
    11/*
    22    $Id$
    3    
     3               
    44    Copyright (C) 2006, 2007 Fredrik Levander, Gregory Vincic, Olle Mansson
    5    
     5               
    66    Files are copyright by their respective authors. The contributions to
    77    files where copyright is not explicitly stated can be traced with the
    88    source code revision system.
    9    
     9               
    1010    This file is part of Proteios.
    1111    Available at http://www.proteios.org/
    12    
     12               
    1313    proteios-2.x is free software; you can redistribute it and/or
    1414    modify it under the terms of the GNU General Public License
    1515    as published by the Free Software Foundation; either version 2
    1616    of the License, or (at your option) any later version.
    17    
     17               
    1818    Proteios is distributed in the hope that it will be useful,
    1919    but WITHOUT ANY WARRANTY; without even the implied warranty of
    2020    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    2121    GNU General Public License for more details.
    22    
     22               
    2323    You should have received a copy of the GNU General Public License
    2424    along with this program; if not, write to the Free Software
     
    173173    private static final org.apache.log4j.Logger log = org.apache.log4j.LogManager
    174174    .getLogger("org.proteios.gui.form");
    175    
     175               
    176176    /**
    177177        Default constructor. Initializes list excludedDeclMethods.
     
    184184        initExcludedDeclMethods();
    185185    }
    186    
     186               
    187187    /**
    188188        Get list of excluded getter methods declared in current class.
    189        
     189                               
    190190        @return List<String> of excluded getter methods.
    191191    */
     
    194194        return this.excludedDeclMethods;
    195195    }
    196    
     196               
    197197    /**
    198198        Set list of excluded getter methods declared in current class.
    199        
     199                               
    200200        @param excludedDeclMethods List<String> of excluded getter methods to
    201                set.
     201        set.
    202202    */
    203203    public void setExcludedDeclMethods(List<String> excludedDeclMethods)
     
    205205        this.excludedDeclMethods = excludedDeclMethods;
    206206    }
    207    
     207               
    208208    /**
    209209        Add list of excluded getter methods declared in current class.
    210        
     210                               
    211211        @param excludedDeclMethods List<String> of excluded getter methods to to
    212                add.
     212        add.
    213213    */
    214214    public void addExcludedDeclMethods(List<String> excludedDeclMethods)
     
    225225        }
    226226    }
    227    
     227               
    228228    public void setActionFactory(ActionFactory af)
    229229    {
    230230        this.actionFactory = af;
    231231    }
    232    
     232               
    233233    public String getForwardActionId()
    234234    {
    235235        return this.forwardActionId;
    236236    }
    237    
     237               
    238238    public void setForwardActionId(String forwardActionId)
    239239    {
    240240        this.forwardActionId = forwardActionId;
    241241    }
    242    
     242               
    243243    public String getSortColumnKey()
    244244    {
    245245        return this.sortColumnKey;
    246246    }
    247    
     247               
    248248    public void setSortColumnKey(String sortColumnKey)
    249249    {
    250250        this.sortColumnKey = sortColumnKey;
    251251    }
    252    
     252               
    253253    public Integer getFilterListSize()
    254254    {
    255255        return this.filterListSize;
    256256    }
    257    
     257               
    258258    public void setFilterListSize(Integer filterListSize)
    259259    {
    260260        this.filterListSize = filterListSize;
    261261    }
    262    
     262               
    263263    public List<String> getFilterKeyColumnList()
    264264    {
    265265        return this.filterKeyColumnList;
    266266    }
    267    
     267               
    268268    public void setFilterKeyColumnList(List<String> filterKeyColumnList)
    269269    {
    270270        this.filterKeyColumnList = filterKeyColumnList;
    271271    }
    272    
     272               
    273273    public HashMap<String, String> getFilterClassColumnHashMap()
    274274    {
    275275        return this.filterClassColumnHashMap;
    276276    }
    277    
     277               
    278278    public void setFilterClassColumnHashMap(
    279279    HashMap<String, String> filterClassColumnHashMap)
     
    281281        this.filterClassColumnHashMap = filterClassColumnHashMap;
    282282    }
    283    
     283               
    284284    public HashMap<String, String> getFilterConditionColumnHashMap()
    285285    {
    286286        return this.filterConditionColumnHashMap;
    287287    }
    288    
     288               
    289289    public void setFilterConditionColumnHashMap(
    290290    HashMap<String, String> filterConditionColumnHashMap)
     
    292292        this.filterConditionColumnHashMap = filterConditionColumnHashMap;
    293293    }
    294    
     294               
    295295    public HashMap<String, String> getFilterValueColumnHashMap()
    296296    {
    297297        return this.filterValueColumnHashMap;
    298298    }
    299    
     299               
    300300    public void setFilterValueColumnHashMap(
    301301    HashMap<String, String> filterValueColumnHashMap)
     
    303303        this.filterValueColumnHashMap = filterValueColumnHashMap;
    304304    }
    305    
     305               
    306306    /**
    307307        Initializes list of excluded getter methods declared in current class.
     
    320320        getExcludedDeclMethods().add("getAnnotatableParents");
    321321    }
    322    
     322               
    323323    public HttpServletRequest getRequest()
    324324    {
    325325        return request;
    326326    }
    327    
     327               
    328328    public void setRequest(HttpServletRequest request)
    329329    {
    330330        this.request = request;
    331331    }
    332    
     332               
    333333    public void modifyForPopup(Fieldset fs)
    334334    {
    335335        actionFactory.modifyForPopup(fs);
    336336    }
    337    
     337               
    338338    private FileField newFileField()
    339339    {
     
    342342        return fileF;
    343343    }
    344    
     344               
    345345    public TextField<Integer> newIdField()
    346346    {
     
    350350        return idF;
    351351    }
    352    
     352               
    353353    private TextField<String> newValueField(String setValueMethodName,
    354354    Class<?> valueClass)
     
    382382        return valueF;
    383383    }
    384    
     384               
    385385    private TextArea newValueTextArea(String setValueMethodName,
    386386    Class<?> valueClass)
     
    421421        return valueF;
    422422    }
    423    
    424 
     423               
    425424    public TextField<Integer> newHiddenItemIdField()
    426425    {
     
    428427        return field;
    429428    }
    430    
     429               
    431430    private TextField<Boolean> newHiddenReadOnlyFormField()
    432431    {
     
    435434        return field;
    436435    }
    437    
     436               
    438437    private TextField<Integer> newHiddenIntegerField(VInteger vInteger)
    439438    {
     
    442441        return field;
    443442    }
    444    
     443               
    445444    private TextField<String> newHiddenStringField(VString vString)
    446445    {
     
    449448        return field;
    450449    }
    451    
    452    
     450               
    453451    public <D extends BasicItem<?>, E extends ProteiosAction<?>> Form getAnnotationsForm(
    454452    DbControl dc, D item, Class<E> forwardAction)
     
    500498        return form;
    501499    }
    502    
     500               
    503501    /**
    504502        @return Hidden
    505                 <code>TextField<String> using the valid parameter {@link #VTYPE}.
     503        <code>TextField<String> using the valid parameter {@link #VTYPE}.
    506504    */
    507505    private TextField<String> newTypeField()
     
    510508        return field;
    511509    }
    512    
    513     public Form getViewUserPropertiesForm(User user)
    514     {
    515         return getForm(User.class, user);
    516     }
    517    
     510               
    518511    /**
    519512        Form for user preferences configuration settings. Arguments
     
    521514        holders for current values for the notification configuration and table
    522515        preferences configuration form fields.
    523        
     516                               
    524517        @param nc NotificationConfiguration object (need not be stored in
    525                database) with default field values.
     518        database) with default field values.
    526519        @return Form A form for setting user preferences configuration values.
    527520    */
     
    539532        return form;
    540533    }
    541    
     534               
    542535    /**
    543536        Fieldset for notification configuration settings. Argument
    544537        NotificationConfiguration is place holder for current values for the
    545538        notification configuration form fields.
    546        
     539                               
    547540        @param nc NotificationConfiguration object (need not be stored in
    548                database) with default field values.
     541        database) with default field values.
    549542        @return Fieldset A fieldset for setting NotificationConfiguration values.
    550543    */
     
    596589        return properties;
    597590    }
    598    
     591               
    599592    /**
    600593        Creates a select box for notification mode.
    601        
     594                               
    602595        @param modeValue int Mode value for default selection.
    603596        @return Select<VInteger> Select box for notification mode selection
     
    624617        return modeS;
    625618    }
    626    
     619               
    627620    /**
    628621        Fieldset for table preferences configuration settings. Argument
    629622        TablePreferencesConfiguration is place holder for current values for the
    630623        table preferences configuration form fields.
    631        
     624                               
    632625        @param tpc TablePreferencesConfiguration object (need not be stored in
    633                database) with default field values.
     626        database) with default field values.
    634627        @return Fieldset A field set for setting TablePreferencesConfiguration
    635                 values.
     628        values.
    636629    */
    637630    public Fieldset getTablePreferencesConfigurationFieldset(
     
    659652        return properties;
    660653    }
    661    
     654               
    662655    /**
    663656        Creates a select box for table preferences mode.
    664        
     657                               
    665658        @param modeValue int Mode value for default selection.
    666659        @return Select<VInteger> Select box for table preferences mode selection
     
    687680        return modeS;
    688681    }
    689    
     682               
    690683    /**
    691684        This will probably be removed when fixint #691
     
    786779        return form;
    787780    }
    788    
     781               
    789782    /**
    790783        @param hit Current Hit
     
    1002995        return form;
    1003996    }
    1004    
     997               
    1005998    /**
    1006999        @param a annotation
     
    10151008        return sb.toString();
    10161009    }
    1017    
     1010               
    10181011    /**
    10191012        Returns a form for selecting spectrum mass range limits.
    1020        
     1013                               
    10211014        @param massCutoffLow String The lower cutoff mass value.
    10221015        @param massCutoffHigh String The upper cutoff mass value.
     
    10641057        return form;
    10651058    }
    1066    
     1059               
    10671060    /**
    10681061        Returns a form with spectrum properties for a spectrum obtained from a
    10691062        spectrum file.
    1070        
     1063                               
    10711064        @param spectrumFile File Core file with spectrum.
    10721065        @param spectrumId String Spectrum id string.
     
    12771270        return form;
    12781271    }
    1279    
     1272               
    12801273    /**
    12811274        Returns a form with spectrum file instrument data for a spectrum file.
    1282        
     1275                               
    12831276        @param spectrumFileInstrumentList List<SpectrumFileInstrumentInterface>
    1284                Spectrum file instrument list.
     1277        Spectrum file instrument list.
    12851278        @return Form for displaying spectrum file instrument data.
    12861279    */
     
    14651458        return form;
    14661459    }
    1467    
     1460               
    14681461    /**
    14691462        Adds a table row to a table. A "value" argument that is null will be
    14701463        represented as an empty string, otherwise by its toString() value.
    1471        
     1464                               
    14721465        @param table Table The table to add a row to.
    14731466        @param nameKey String Property key string.
    14741467        @param value Object Property value object.
    14751468        @param actionClass Class<E extends ProteiosAction> Optional value cell
    1476                action.
     1469        action.
    14771470        @param itemId int The item id to use for an optional action.
    14781471    */
     
    15061499        table.addRow(row);
    15071500    }
    1508    
     1501               
    15091502    /**
    15101503        Returns a form with spectrum file contact data for a spectrum file.
    1511        
     1504                               
    15121505        @param spectrumContact Spectrum file contact
    1513                data.
     1506        data.
    15141507        @return Form for displaying spectrum file contact data.
    15151508    */
     
    15921585        return form;
    15931586    }
    1594        
     1587                   
    15951588    /**
    15961589        Returns a form for adding spectrum file sample data for a spectrum file.
    1597        
     1590                               
    15981591        @param project Project The project in whose directory a new output
    1599                directory is created.
     1592        directory is created.
    16001593        @param outputDirNameDefault String The default name of the output
    1601                directory.
     1594        directory.
    16021595        @return Form for displaying spectrum file contact data.
    16031596    */
     
    16851678        return form;
    16861679    }
    1687    
     1680               
    16881681    private <D extends Object> TextField<D> newTextField(String name, D value)
    16891682    {
     
    16941687        return field;
    16951688    }
    1696    
     1689               
    16971690    public Form getPeakListSetForm(PeakListSet pls)
    16981691    {
     
    17621755        return form;
    17631756    }
    1764    
     1757               
    17651758    public Form getExportPeakListSetForm(PeakListSet pls)
    17661759    {
     
    18091802        return form;
    18101803    }
    1811    
     1804               
    18121805    private void addAnnotationsAsFields(Fieldset to, Annotatable item,
    18131806    DbControl dc)
     
    18241817        }
    18251818    }
    1826    
     1819               
    18271820    public Fieldset getProteinAssemblyFieldset(Project project)
    18281821    {
     
    18471840        return properties;
    18481841    }
    1849    
     1842               
    18501843    public Select<VString> selectLocalSampleIdWithAllOption(DbControl dc,
    18511844    Project project)
     
    18611854        return select;
    18621855    }
    1863    
     1856               
    18641857    private Select<VInteger> newSelectLabel(LabeledExtract le, DbControl dc)
    18651858    {
     
    18821875        return select;
    18831876    }
    1884    
    1885    
     1877               
    18861878    /**
    18871879        Creates and adds a hidden field with an Integer value to the given form.
     
    18951887        form.getFieldsets().get(0).add(field);
    18961888    }
    1897    
     1889               
    18981890    /**
    18991891        Creates and adds a hidden field with an Integer value to the given table.
     
    19071899        table.add(field);
    19081900    }
    1909    
     1901               
    19101902    public Fieldset getUsedSampleFieldset(Sample sample)
    19111903    {
     
    19251917        return fs;
    19261918    }
    1927    
     1919               
    19281920    public Fieldset getUsedExtractFieldset(Extract extract)
    19291921    {
     
    19401932        return fs;
    19411933    }
    1942    
     1934               
    19431935    public Fieldset getUsedLabeledExtractFieldset(LabeledExtract extract)
    19441936    {
     
    19581950        return fs;
    19591951    }
    1960    
    1961 
     1952               
    19621953    public Form getSecondaryLabeledExtractForm(LabeledExtract extract,
    19631954    DbControl dc, LabeledExtract fromExtract)
     
    20222013        return form;
    20232014    }
    2024    
     2015               
    20252016    public Form getSetFilterForm(String filterName, String filterClass,
    20262017    String filterCondition, String filterValue)
     
    21162107        return form;
    21172108    }
    2118    
     2109               
    21192110    private void addFilterSettingsToFieldset(Fieldset fs)
    21202111    {
     
    21802171        }
    21812172    }
    2182    
     2173               
    21832174    public TextField<Float> newOriginalQuantityField()
    21842175    {
     
    21882179        return field;
    21892180    }
    2190    
     2181               
    21912182    public TextField<Float> newRemainingQuantityField(Float remainingQuantity)
    21922183    {
     
    21992190        return field;
    22002191    }
    2201    
    2202 
     2192               
    22032193    /**
    22042194        Get generic form for object.
    2205        
     2195                               
    22062196        @param template template for generic form
    22072197        @return Form for editing the object
     
    22122202            Analyze object class
    22132203        */
    2214        
     2204                               
    22152205        /*
    22162206            Get class from formTemplate itemObject or itemClass.
     
    22392229            clsName = itemClass.getSimpleName();
    22402230        }
    2241        
     2231                               
    22422232        /***********************************************************************
    22432233            Main fieldset
     
    23262316            methodArr = itemClass.getMethods();
    23272317        }
    2328        
     2318                               
    23292319        /*
    23302320            Methods declared in object class (not inherited)
     
    24952485            }
    24962486        }
    2497        
     2487                               
    24982488        /*
    24992489            Check if object supports method getAnnotationSet().
     
    25892579        return form;
    25902580    }
    2591    
     2581               
    25922582    /**
    25932583        Get DbControl for object.
    2594        
     2584                               
    25952585        @return DbControl for the object
    25962586    */
     
    26472637        return dc;
    26482638    }
    2649    
     2639               
    26502640    /**
    26512641        Fetch public method for object, or null if not found.
    2652        
     2642                               
    26532643        @param publMethodName String Name of public method to search for.
    26542644        @return Method public method for object with desired name, or null if not
    2655                 found.
     2645        found.
    26562646    */
    26572647    private Method fetchPublicMethodForObject(String publMethodName,
     
    26862676        return publMethod;
    26872677    }
    2688    
     2678               
    26892679    /**
    26902680        Returns a String corresponding to the method modifier: "static",
    26912681        "public", "protected", or "private".
    2692        
     2682                               
    26932683        @param method
    26942684        @return String for method modifier
     
    27162706        return modStr;
    27172707    }
    2718    
     2708               
    27192709    private Localizer getLocale()
    27202710    {
    27212711        return locale;
    27222712    }
    2723    
     2713               
    27242714    public void setLocale(Localizer locale)
    27252715    {
    27262716        this.locale = locale;
    27272717    }
    2728    
     2718               
    27292719    //Cleaning up from here       
    2730 
     2720           
    27312721    /**
    27322722        Form for new Protocol item. The difference between calling
     
    27392729        a convenient place holder for default values for the Protocol form
    27402730        fields.
    2741        
     2731                               
    27422732        @param protocol Protocol object (need not be stored in database) with
    2743                default field values.
     2733        default field values.
    27442734        @return Form A form for setting protocol values.
    27452735    */
     
    28242814        return form;
    28252815    }
    2826    
     2816               
     2817    public Form getForm(Class<?> cls)
     2818    {
     2819        return getForm(cls, null);
     2820    }
    28272821    /**
    28282822        Returnes a form for the given class. If obj is supplied the form is
     
    28352829    {
    28362830        if (cls == null)
    2837     {
    2838           return new NullForm();
    2839     }
     2831        {
     2832            return new NullForm();
     2833        }
    28402834        if (obj != null && !cls.equals(obj.getClass()))
    2841     {
    2842           return new NullForm();
    2843     }
     2835        {
     2836            return new NullForm();
     2837        }
    28442838        // Create forms with prefilled values from the given object
    28452839        if (cls.equals(LabeledExtract.class))
     
    29082902        {
    29092903            TextField<String> loginF = new LoginField();
    2910              loginF.setDisabled(true);
     2904            loginF.setDisabled(true);
    29112905            fs.add(fs.size()-2, loginF); // After the itemId field
    2912 
     2906                                   
    29132907            TextField<String> emailF = new EmailField();
    29142908            fs.add(fs.size()-1, emailF);
    2915            
     2909                                               
    29162910            TextField<String> phoneF = new PhoneField();
    29172911            fs.add(phoneF);
    2918            
     2912                                               
    29192913            TextField<String> addressF = new AddressField();
    29202914            fs.add(addressF);
    2921            
     2915                                               
    29222916            TextField<String> organisationF = new OrganisationField();
    29232917            fs.add(organisationF);
    2924            
     2918                                               
    29252919            if (obj != null)
    29262920            {
    29272921                User n = (User) obj;
    2928                 loginF.setValue(n.getLogin());
     2922                loginF.setValue(n.getLogin());
    29292923                emailF.setValue(n.getEmail());
    29302924                phoneF.setValue(n.getPhone());
     
    32533247        return form;
    32543248    }
    3255    
     3249               
    32563250    /**
    32573251        Creates a select box for protocols. If the class for which the protocol
     
    32613255        if the protocol is tagged to be removed. However, no other protocols
    32623256        tagged to be removed should be included in the list.
    3263        
     3257                               
    32643258        @param cls Class Class for which a protocol should be selected.
    32653259        @param obj Object Optional object with attached protocol for setting
    3266                default protocol.
     3260        default protocol.
    32673261        @return Select<VInteger> Select box for protocol selection
    32683262    */
     
    33683362        return protocolS;
    33693363    }
    3370    
     3364               
    33713365    public void setSc(SessionControl sc)
    33723366    {
     
    33753369        if (this.sc == null)
    33763370        this.sc = sc;
    3377     }   
     3371    }
    33783372}
Note: See TracChangeset for help on using the changeset viewer.