Skip to content
Snippets Groups Projects
Commit 2b4a49f9 authored by buczekp's avatar buczekp
Browse files

[LMS-786] remove left menu and related code

SVN: 10260
parent 6c111c3c
No related branches found
No related tags found
No related merge requests found
/*
* Copyright 2008 ETH Zuerich, CISD
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ch.systemsx.cisd.openbis.generic.client.web.client.application;
import java.util.List;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.framework.CategoriesBuilder.MenuCategoryKind;
/**
* Category in the menu.
*
* @author Izabela Adamczyk
*/
public class MenuCategory
{
private final String name;
private final List<MenuElement> elements;
private final String partOfId;
public MenuCategory(final MenuCategoryKind partOfId, final String name,
final List<MenuElement> elements)
{
this.partOfId = partOfId.name();
this.name = name;
this.elements = elements;
}
public String getName()
{
return name;
}
public List<MenuElement> getElements()
{
return elements;
}
public String getPartOfId()
{
return partOfId;
}
}
/*
* Copyright 2008 ETH Zuerich, CISD
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ch.systemsx.cisd.openbis.generic.client.web.client.application;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.framework.ITabItemFactory;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.framework.CategoriesBuilder.MenuElementKind;
/**
* Element of the {@link MenuCategory}.
*
* @author Izabela Adamczyk
*/
public final class MenuElement
{
private final String title;
private final ITabItemFactory tabItemFactory;
private final String partOfId;
public MenuElement(final MenuElementKind partOfId, final String title,
final ITabItemFactory tabItemFactory)
{
this.partOfId = partOfId.name();
this.title = title;
this.tabItemFactory = tabItemFactory;
}
public String getTitle()
{
return title;
}
public ITabItemFactory getTabItem()
{
return tabItemFactory;
}
public String getPartOfId()
{
return partOfId;
}
}
......@@ -21,7 +21,6 @@ import com.extjs.gxt.ui.client.mvc.AppEvent;
import com.extjs.gxt.ui.client.mvc.Controller;
import com.extjs.gxt.ui.client.mvc.View;
import com.extjs.gxt.ui.client.util.Margins;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Viewport;
import com.extjs.gxt.ui.client.widget.layout.BorderLayout;
import com.extjs.gxt.ui.client.widget.layout.BorderLayoutData;
......@@ -42,16 +41,12 @@ final class AppView extends View
private Viewport viewport;
private ContentPanel west;
private MainTabPanel center;
private TopMenu north;
private ComponentProvider componentProvider;
private CategoriesBuilder categoriesBuilder;
AppView(final Controller controller, final CommonViewContext viewContext)
{
super(controller);
......@@ -74,7 +69,6 @@ final class AppView extends View
viewport = new Viewport();
viewport.setLayout(new BorderLayout());
createNorth();
createWest();
createCenter();
createSouth();
RootPanel.get().clear();
......@@ -88,14 +82,6 @@ final class AppView extends View
viewport.add(north, data);
}
private final void createWest()
{
west = new LeftMenu(categoriesBuilder.getCategories());
final BorderLayoutData data = new BorderLayoutData(LayoutRegion.WEST, 200, 150, 350);
data.setMargins(new Margins(5, 0, 5, 5));
viewport.add(west, data);
}
private final void createCenter()
{
center = new MainTabPanel(viewContext);
......@@ -119,7 +105,7 @@ final class AppView extends View
protected final void initialize()
{
componentProvider = new ComponentProvider(viewContext);
categoriesBuilder = new CategoriesBuilder(componentProvider);
// categoriesBuilder = new CategoriesBuilder(componentProvider);
}
@Override
......
/*
* Copyright 2008 ETH Zuerich, CISD
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ch.systemsx.cisd.openbis.generic.client.web.client.application.framework;
import java.util.ArrayList;
import java.util.List;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.MenuCategory;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.MenuElement;
/**
* Allows to define categories which will be displayed in {@link LeftMenu}.
*
* @author Izabela Adamczyk
*/
public class CategoriesBuilder
{
private static final String IMPORT_LABEL = "Import";
private static final String LABEL_REGISTER = "New";
private static final String LABEL_BROWSE = "Browse";
private static final String BROWSE_TYPES_LABEL = "Types";
public static enum MenuCategoryKind
{
VOCABULARIES, MATERIALS, EXPERIMENTS, PERSONS, PROJECTS, GROUPS, ROLES, SAMPLES, DATA_SETS,
PROPERTY_TYPES;
}
public static enum MenuElementKind
{
ADD_ROLE, ASSIGN, ASSIGN_STPT, ASSIGN_ETPT, REGISTER, IMPORT, BROWSE, BROWSE_TYPES, MANAGE,
LIST_ASSIGNMENTS, SEARCH;
}
public final ComponentProvider provider;
public final List<MenuCategory> categories;
CategoriesBuilder(final ComponentProvider provider)
{
this.provider = provider;
categories = new ArrayList<MenuCategory>();
defineCategories();
}
private void defineCategories()
{
categories.add(createSampleCategory());
categories.add(createExperimentCategory());
categories.add(createMaterialCategory());
categories.add(createPropertyTypesCategory());
categories.add(createVocabulariesCategory());
categories.add(createProjectsTypesCategory());
categories.add(createDataSetsCategory());
categories.add(createGroupsCategory());
categories.add(createPersonsCategory());
categories.add(createRolesCategory());
}
private MenuCategory createSampleCategory()
{
final List<MenuElement> elements = new ArrayList<MenuElement>();
elements.add(new MenuElement(MenuElementKind.BROWSE, LABEL_BROWSE, provider
.getSampleBrowser()));
elements.add(new MenuElement(MenuElementKind.REGISTER, LABEL_REGISTER, provider
.getSampleRegistration()));
elements.add(new MenuElement(MenuElementKind.IMPORT, IMPORT_LABEL, provider
.getSampleBatchRegistration()));
elements.add(new MenuElement(MenuElementKind.BROWSE_TYPES, BROWSE_TYPES_LABEL, provider
.getSampleTypeBrowser()));
return new MenuCategory(MenuCategoryKind.SAMPLES, "Samples", elements);
}
private MenuCategory createRolesCategory()
{
final List<MenuElement> elements = new ArrayList<MenuElement>();
elements
.add(new MenuElement(MenuElementKind.BROWSE, LABEL_BROWSE, provider.getRolesView()));
return new MenuCategory(MenuCategoryKind.ROLES, "Roles", elements);
}
private MenuCategory createGroupsCategory()
{
final List<MenuElement> elements = new ArrayList<MenuElement>();
elements
.add(new MenuElement(MenuElementKind.BROWSE, LABEL_BROWSE, provider.getGroupsView()));
return new MenuCategory(MenuCategoryKind.GROUPS, "Groups", elements);
}
private MenuCategory createProjectsTypesCategory()
{
final List<MenuElement> elements = new ArrayList<MenuElement>();
elements.add(new MenuElement(MenuElementKind.BROWSE, LABEL_BROWSE, provider
.getProjectBrowser()));
elements.add(new MenuElement(MenuElementKind.REGISTER, LABEL_REGISTER, provider
.getProjectRegistration()));
return new MenuCategory(MenuCategoryKind.PROJECTS, "Projects", elements);
}
private MenuCategory createPersonsCategory()
{
final List<MenuElement> elements = new ArrayList<MenuElement>();
elements.add(new MenuElement(MenuElementKind.BROWSE, LABEL_BROWSE, provider
.getPersonsView()));
return new MenuCategory(MenuCategoryKind.PERSONS, "Persons", elements);
}
private MenuCategory createPropertyTypesCategory()
{
final List<MenuElement> elements = new ArrayList<MenuElement>();
elements.add(new MenuElement(MenuElementKind.BROWSE, LABEL_BROWSE, provider
.getPropertyTypeBrowser()));
elements.add(new MenuElement(MenuElementKind.LIST_ASSIGNMENTS, "Browse Assignments",
provider.getPropertyTypeAssignmentBrowser()));
elements.add(new MenuElement(MenuElementKind.REGISTER, LABEL_REGISTER, provider
.getPropertyTypeRegistration()));
elements.add(new MenuElement(MenuElementKind.ASSIGN_ETPT, "Assign to Experiment Type",
provider.getPropertyTypeExperimentTypeAssignmentForm()));
elements.add(new MenuElement(MenuElementKind.ASSIGN_STPT, "Assign to Sample Type", provider
.getPropertyTypeSampleTypeAssignmentForm()));
return new MenuCategory(MenuCategoryKind.PROPERTY_TYPES, "Property Types", elements);
}
private MenuCategory createDataSetsCategory()
{
final List<MenuElement> elements = new ArrayList<MenuElement>();
elements
.add(new MenuElement(MenuElementKind.SEARCH, "Search", provider.getDataSetSearch()));
return new MenuCategory(MenuCategoryKind.DATA_SETS, "Data Sets", elements);
}
private MenuCategory createVocabulariesCategory()
{
final List<MenuElement> elements = new ArrayList<MenuElement>();
elements.add(new MenuElement(MenuElementKind.BROWSE, LABEL_BROWSE, provider
.getVocabularyBrowser()));
elements.add(new MenuElement(MenuElementKind.REGISTER, LABEL_REGISTER, provider
.getVocabularyRegistration()));
return new MenuCategory(MenuCategoryKind.VOCABULARIES, "Vocabularies", elements);
}
private MenuCategory createMaterialCategory()
{
final List<MenuElement> elements = new ArrayList<MenuElement>();
elements.add(new MenuElement(MenuElementKind.BROWSE, LABEL_BROWSE, provider
.getMaterialBrowser()));
elements.add(new MenuElement(MenuElementKind.IMPORT, IMPORT_LABEL, provider
.getMaterialBatchRegistration()));
elements.add(new MenuElement(MenuElementKind.BROWSE_TYPES, BROWSE_TYPES_LABEL, provider
.getMaterialTypeBrowser()));
return new MenuCategory(MenuCategoryKind.MATERIALS, "Materials", elements);
}
private MenuCategory createExperimentCategory()
{
final List<MenuElement> elements = new ArrayList<MenuElement>();
elements.add(new MenuElement(MenuElementKind.BROWSE, LABEL_BROWSE, provider
.getExperimentBrowser()));
elements.add(new MenuElement(MenuElementKind.REGISTER, LABEL_REGISTER, provider
.getExperimentRegistration()));
elements.add(new MenuElement(MenuElementKind.BROWSE_TYPES, BROWSE_TYPES_LABEL, provider
.getExperimentTypeBrowser()));
return new MenuCategory(MenuCategoryKind.EXPERIMENTS, "Experiments", elements);
}
public List<MenuCategory> getCategories()
{
return categories;
}
}
\ No newline at end of file
/*
* Copyright 2008 ETH Zuerich, CISD
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ch.systemsx.cisd.openbis.generic.client.web.client.application.framework;
import java.util.List;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.TreeEvent;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.layout.AccordionLayout;
import com.extjs.gxt.ui.client.widget.tree.Tree;
import com.extjs.gxt.ui.client.widget.tree.TreeItem;
import com.google.gwt.user.client.Event;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.GenericConstants;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.MenuCategory;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.MenuElement;
/**
* User menu allowing to get to wanted functionality of application (e.g. sample listing).
*
* @author Izabela Adamczyk
*/
public class LeftMenu extends ContentPanel
{
public static final String ID = GenericConstants.ID_PREFIX + "left-menu";
public static final String TREE_SUFFIX = "_tree";
private final List<MenuCategory> categories;
LeftMenu(final List<MenuCategory> categories)
{
this.categories = categories;
setId(ID);
setBodyBorder(true);
setLayoutOnChange(true);
setCollapsible(true);
setHeaderVisible(false);
setLayout(new AccordionLayout());
addCategories();
}
final void addCategories()
{
for (final MenuCategory menuCategory : categories)
{
final String categoryId = ID + "_" + menuCategory.getPartOfId();
final SubMenu subMenu = new SubMenu(menuCategory.getName(), categoryId);
for (final MenuElement me : menuCategory.getElements())
{
subMenu.addCommand(categoryId + "_" + me.getPartOfId(), me.getTitle(), me
.getTabItem());
}
add(subMenu);
}
}
//
// Helper classes
//
private final static class SubMenu extends ContentPanel
{
public static final String TAB_ITEM_KEY = "tabItemKey";
private final Tree tree;
SubMenu(final String title, final String id)
{
setHeading(title);
setId(id);
tree = new Tree();
tree.setId(id + TREE_SUFFIX);
tree.addListener(Event.ONCLICK, new Listener<TreeEvent>()
{
//
// Listener
//
public final void handleEvent(final TreeEvent be)
{
TreeItem selectedItem = tree.getSelectedItem();
if (selectedItem == null)
{
return;
}
if (selectedItem.isLeaf())
{
ITabItemFactory tab = selectedItem.getData(TAB_ITEM_KEY);
DispatcherHelper.dispatchNaviEvent(tab);
} else
{
selectedItem.setExpanded(true);
}
}
});
tree.setAnimate(false);
setBodyStyleName("pad-text");
tree.getStyle().setNodeCloseIconStyle("");
tree.getStyle().setNodeOpenIconStyle("");
add(tree);
}
private final void addCommand(final String id, final String name,
final ITabItemFactory tabItemFactory)
{
final TreeItem item = new TreeItem(name);
item.setId(id);
item.setData(TAB_ITEM_KEY, tabItemFactory);
tree.getRootItem().add(item);
}
}
}
\ No newline at end of file
......@@ -42,8 +42,6 @@ import com.extjs.gxt.ui.client.widget.menu.Menu;
import com.extjs.gxt.ui.client.widget.menu.MenuItem;
import com.extjs.gxt.ui.client.widget.toolbar.AdapterToolItem;
import com.extjs.gxt.ui.client.widget.toolbar.ToolItem;
import com.extjs.gxt.ui.client.widget.tree.Tree;
import com.extjs.gxt.ui.client.widget.tree.TreeItem;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.ui.ComplexPanel;
import com.google.gwt.user.client.ui.ListBox;
......@@ -324,9 +322,6 @@ public final class GWTTestUtil
} else if (widget instanceof Menu)
{
return new MenuHandler(this).handle((Menu) widget);
} else if (widget instanceof Tree)
{
return new TreeHandler(this).handle((Tree) widget);
} else if (widget instanceof Container)
{
return new ContainerHandler(this).handle((Container<Component>) widget);
......@@ -469,33 +464,6 @@ public final class GWTTestUtil
}
private static final class TreeHandler implements IWidgetHandler<Tree>
{
private final IWidgetHandler<Widget> handler;
TreeHandler(final IWidgetHandler<Widget> handler)
{
this.handler = handler;
}
//
// IWidgetHandler
//
public final boolean handle(final Tree tree)
{
for (final TreeItem i : tree.getAllItems())
{
if (handler.handle(i))
{
return true;
}
}
return false;
}
}
private static final class ComplexPanelHandler implements IWidgetHandler<ComplexPanel>
{
private final IWidgetHandler<Widget> handler;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment