Changeset 3933


Ignore:
Timestamp:
Nov 1, 2010, 1:42:25 PM (13 years ago)
Author:
olle
Message:

Refs #547. Refs #287. First version of limited number of items in the
"Select Project" menu in Proteios SE:

  1. New class/file action/DummyAction.java in client/servlet/ added.

It does nothing, and returns directly. It is Intended to be used
for action links in menus, where one wants a menu item with a comment
but no action, but does not want the action link to be disabled,
as this would make the entry to be dimmed, and hard to read.

  1. Class/file gui/MainMenu.java in client/servlet/ updated:
  2. New private constant final int MAX_NUM_PROJECT_ITEMS added.

Its value is set to 20.

  1. Private method Node createSelectProjectNode() updated to limit

the number of displayed project items to the set limit. If the
number of projects is larger, the list will be truncated, and
an ellipsis item, a separator, and a new "more projects" item
added. However, if the active project is not among the projects
listed by default, it will be inserted after the ellipsis item
and the separator, while the last project item is the default list
will be omitted. The "more projects" item will display the number
of projects not listed, e.g. "6 more" if 6 more projects exist.
Clicking on the "more projects" menu will redirect the user
to a listing of all available projects.

  1. English dictionary file locale/en/dictionary in client/servlet/

updated with new entries for various string keys.

Location:
trunk/client/servlet/src
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/client/servlet/src/locale/en/dictionary

    r3924 r3933  
    149149Download=Download
    150150Edit=Edit
     151EllipsisMenuItem=…
    151152email=email
    152153Email=E-mail
     
    410411Model=Model
    411412Modifications=Modifications
     413MoreProjectsMenuItem=more
    412414Move=Move
    413415MsFile=MS File
  • trunk/client/servlet/src/org/proteios/gui/MainMenu.java

    r3725 r3933  
    1717import org.proteios.action.ActionFactory;
    1818import org.proteios.action.ConfigureTableFactory2;
     19import org.proteios.action.DummyAction;
    1920import org.proteios.action.ProteiosAction;
    2021import org.proteios.action.ShowTable;
     
    132133  private static final Node separator = new Node().setActionLink(empty);
    133134  private SessionControl sc;
     135  private final int MAX_NUM_PROJECT_ITEMS = 20;
    134136 
    135137
     
    249251  {
    250252    // Define
    251     Node rootN, noActiveProjectN;
    252     List<Node> projectNodeList;
     253    Node rootN, noActiveProjectN, ellipsisN, moreProjectsN;
     254    List<Node> projectNodeList; 
    253255    String label;
    254256    ActionLink actionLink;
    255257    boolean selected;
    256258    ItemQuery<Project> query;
     259    int maxNumProjectItems = MAX_NUM_PROJECT_ITEMS;
    257260    // Create
    258261    rootN = new Node().setLabel("SelectProject");
    259262    projectNodeList = new ArrayList<Node>(0);
    260263    selected = false;
     264    //
    261265    label = "NoActiveProjectMenuItem";
    262266    actionLink = actionFactory
    263267      .getActionLink(DeactivateProject.class, label);
    264268    noActiveProjectN = new Node(actionLink, label + "id");
     269    //
     270    label = "EllipsisMenuItem";
     271    actionLink = actionFactory
     272      .getActionLink(DummyAction.class, label);
     273    ellipsisN = new Node(actionLink, label + "id");
     274    //
    265275    // Use
    266276    // Set selection flag
     
    283293      .parameter("closed")));
    284294    query.setParameter("closed", true, null);
     295    int numProjects = query.count(dc);
     296    int numAddedProjectItems = 0;
     297    boolean selectedFound = false;
     298    boolean ellipsisItemAdded = false;
    285299    for (Project project : query.list(dc))
    286300    {
     
    290304      {
    291305        selected = true;
     306        selectedFound = true;
    292307      }
    293308      label = project.getName();
     
    301316      projectN.setLocalizationUsed(false);
    302317      // Add project node to list
    303       projectNodeList.add(projectN);
    304     }
     318      // Restrict number of added project items; always add selected project
     319      if (numAddedProjectItems < (maxNumProjectItems - 1))
     320      {
     321        // Place for more than one more project item
     322        projectNodeList.add(projectN);
     323        numAddedProjectItems++;
     324      }
     325      else if (numAddedProjectItems == (maxNumProjectItems - 1))
     326      {
     327        // Place for one more project item
     328        if (selectedFound)
     329        {
     330          // Add last project item, selected project in list
     331          projectNodeList.add(projectN);
     332          numAddedProjectItems++;
     333        }
     334        else if (activeProject == null)
     335        {
     336          // No project selected, add last project item
     337          projectNodeList.add(projectN);
     338          numAddedProjectItems++;
     339        }
     340        else
     341        {
     342          // Selected project item exists, but is not current item
     343          // Add ellipsis item once, waiting for the selected item
     344          if (!ellipsisItemAdded)
     345          {
     346            // Add "..." ellipsis item
     347            projectNodeList.add(ellipsisN);
     348            ellipsisItemAdded = true;
     349          }
     350        }
     351      }
     352    }
     353    // Check if not all projects in menu
     354    if (numProjects > maxNumProjectItems)
     355    {
     356      // Add "..." ellipsis item, if not already added
     357      if (!ellipsisItemAdded)
     358      {
     359        // Add "..." ellipsis item
     360        projectNodeList.add(ellipsisN);
     361        ellipsisItemAdded = true;
     362      }
     363      // Add separator item
     364      projectNodeList.add(separator);
     365      // Add "<number of unlisted projects> more" node
     366      String moreLabel = locale.get("MoreProjectsMenuItem");
     367      int numMoreProjects = numProjects - numAddedProjectItems;
     368      label = new String(numMoreProjects + " " + moreLabel);
     369      actionLink = actionFactory
     370        .getActionLink(ListMyProjects.class, label);
     371      moreProjectsN = new Node(actionLink, label + "id");
     372      projectNodeList.add(moreProjectsN);
     373    }
     374    // Add menu items to hierarchical menu
    305375    for (int i = 0; i < projectNodeList.size(); i++)
    306376    {
Note: See TracChangeset for help on using the changeset viewer.