From 37af2d2413f0fc18177469d580e9f3a627471fd0 Mon Sep 17 00:00:00 2001 From: Massimiliano Assante Date: Wed, 27 Jun 2018 15:03:05 +0000 Subject: [PATCH] Updated select context menu enabling filtering as you type git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/admin/resource-management@169505 82a268e6-3cf1-43bd-a215-b396298e98cf --- .classpath | 10 ++-- .settings/org.eclipse.jdt.core.prefs | 2 +- .settings/org.eclipse.wst.common.component | 3 ++ .tern-project | 18 ++++++- distro/changelog.xml | 4 ++ pom.xml | 8 ++- .../client/ContexClientModel.java | 27 ++++++++++ .../client/ResourceManagementPortlet.java | 47 +++++++++++++++-- .../client/utils/Callbacks.java | 51 +++++++++---------- src/main/webapp/ResourceManagementPortlet.css | 5 ++ 10 files changed, 136 insertions(+), 39 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/admin/resourcemanagement/client/ContexClientModel.java diff --git a/.classpath b/.classpath index 87e3b03..986a415 100644 --- a/.classpath +++ b/.classpath @@ -1,12 +1,12 @@ - + - + @@ -34,10 +34,10 @@ - + - + - + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 443e085..b257af7 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,6 +1,6 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.compliance=1.7 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 83aa556..c7cf8a6 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -4,6 +4,9 @@ + + uses + diff --git a/.tern-project b/.tern-project index a185ba0..61348cc 100644 --- a/.tern-project +++ b/.tern-project @@ -1 +1,17 @@ -{"ide":{"scriptPaths":[]},"plugins":{"aui":{},"liferay":{},"yui":{}},"libs":["ecma5","browser"]} \ No newline at end of file +{ + "plugins": { + "aui": { + + }, + "liferay": { + + }, + "yui": { + + } + }, + "libs": [ + "ecma5", + "browser" + ] +} \ No newline at end of file diff --git a/distro/changelog.xml b/distro/changelog.xml index 848b83c..5e86cfb 100644 --- a/distro/changelog.xml +++ b/distro/changelog.xml @@ -1,5 +1,9 @@ + + Updated select context menu enabling filtering as you type + Changed codes for AuthZ framework diff --git a/pom.xml b/pom.xml index a090a05..12d4835 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ org.gcube.portlets.admin resource-management - 6.4.0-SNAPSHOT + 6.5.0-SNAPSHOT war gCube Resource Management Portlet @@ -63,6 +63,12 @@ ${gwtVersion} provided + + com.google.gwt + gwt-dev + ${gwtVersion} + provided + org.gcube.portlets.user gcube-widgets diff --git a/src/main/java/org/gcube/portlets/admin/resourcemanagement/client/ContexClientModel.java b/src/main/java/org/gcube/portlets/admin/resourcemanagement/client/ContexClientModel.java new file mode 100644 index 0000000..96a4d7b --- /dev/null +++ b/src/main/java/org/gcube/portlets/admin/resourcemanagement/client/ContexClientModel.java @@ -0,0 +1,27 @@ +package org.gcube.portlets.admin.resourcemanagement.client; + +import com.extjs.gxt.ui.client.data.BaseModelData; +import com.google.gwt.user.client.rpc.IsSerializable; + +@SuppressWarnings("serial") +public class ContexClientModel extends BaseModelData implements IsSerializable { + + public ContexClientModel() { + } + public ContexClientModel(final String id, final String name) { + set("id", id); + set("name", name); + } + public String getId() { + return get("id"); + } + public String getName() { + return get("name"); + } + public void setId(final String id) { + set("id", id); + } + public void setName(final String name) { + set("name", name); + } +} diff --git a/src/main/java/org/gcube/portlets/admin/resourcemanagement/client/ResourceManagementPortlet.java b/src/main/java/org/gcube/portlets/admin/resourcemanagement/client/ResourceManagementPortlet.java index b9adf0a..534c260 100644 --- a/src/main/java/org/gcube/portlets/admin/resourcemanagement/client/ResourceManagementPortlet.java +++ b/src/main/java/org/gcube/portlets/admin/resourcemanagement/client/ResourceManagementPortlet.java @@ -50,15 +50,22 @@ import com.extjs.gxt.ui.client.Style.Scroll; import com.extjs.gxt.ui.client.event.ComponentEvent; import com.extjs.gxt.ui.client.event.Listener; import com.extjs.gxt.ui.client.event.MessageBoxEvent; +import com.extjs.gxt.ui.client.event.SelectionChangedEvent; +import com.extjs.gxt.ui.client.event.SelectionChangedListener; +import com.extjs.gxt.ui.client.store.ListStore; import com.extjs.gxt.ui.client.util.Margins; +import com.extjs.gxt.ui.client.widget.Component; import com.extjs.gxt.ui.client.widget.ContentPanel; import com.extjs.gxt.ui.client.widget.Dialog; +import com.extjs.gxt.ui.client.widget.Html; import com.extjs.gxt.ui.client.widget.Label; import com.extjs.gxt.ui.client.widget.MessageBox; import com.extjs.gxt.ui.client.widget.ProgressBar; import com.extjs.gxt.ui.client.widget.Status; import com.extjs.gxt.ui.client.widget.Text; import com.extjs.gxt.ui.client.widget.button.Button; +import com.extjs.gxt.ui.client.widget.form.ComboBox; +import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction; import com.extjs.gxt.ui.client.widget.layout.AccordionLayout; import com.extjs.gxt.ui.client.widget.layout.BorderLayout; import com.extjs.gxt.ui.client.widget.layout.FitLayout; @@ -74,6 +81,7 @@ import com.extjs.gxt.ui.client.widget.toolbar.ToolBar; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.RunAsyncCallback; +import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.event.logical.shared.ResizeEvent; import com.google.gwt.event.logical.shared.ResizeHandler; import com.google.gwt.event.shared.HandlerManager; @@ -654,11 +662,42 @@ public class ResourceManagementPortlet implements EntryPoint { statusbar.add(new SeparatorToolItem()); if (StatusHandler.getStatus().getRunningMode() != RunningMode.PORTAL) { - Button btnScope = new Button("Available Scopes"); - btnScope.setMenu(new Menu()); - WidgetsRegistry.registerWidget(UIIdentifiers.BUTTON_AVAILABLE_SCOPES_ID, btnScope); + //Your View Class + final ListStore yourStore = new ListStore(){ + @Override + public ContexClientModel findModel(final ContexClientModel model) { + if(model.getId()!=null&&!model.getId().isEmpty()){ + for (final ContexClientModel m : all) { + if(model.getId().equals(m.getId())) { + return m; + } + } + } + return null; + } + }; + + final ComboBox< ContexClientModel > select = new ComboBox< ContexClientModel >(); + select.setAllowBlank(false); + select.setStore(yourStore); + select.setDisplayField("name"); + select.setValueField("id"); + select.setTriggerAction(TriggerAction.ALL); + select.setMaxHeight(500); + select.setWidth("310px"); + select.setEmptyText("Available Contexts"); + select.addSelectionChangedListener(new SelectionChangedListener() { + @Override + public void selectionChanged(SelectionChangedEvent se) { + Commands.doLoadResourceTree(this, se.getSelectedItem().getId()); + GWT.log("doLoadResourceTree"); + } + }); + WidgetsRegistry.registerWidget(UIIdentifiers.BUTTON_AVAILABLE_SCOPES_ID, select); // Checks that this menu item is permitted to the current user - statusbar.add(btnScope); + statusbar.add(new Html("   ")); + statusbar.add(select); + } else { statusbar.add(new Label("Current role: " + StatusHandler.getStatus().getCredentials())); } diff --git a/src/main/java/org/gcube/portlets/admin/resourcemanagement/client/utils/Callbacks.java b/src/main/java/org/gcube/portlets/admin/resourcemanagement/client/utils/Callbacks.java index e1ca147..afc7092 100644 --- a/src/main/java/org/gcube/portlets/admin/resourcemanagement/client/utils/Callbacks.java +++ b/src/main/java/org/gcube/portlets/admin/resourcemanagement/client/utils/Callbacks.java @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import org.gcube.portlets.admin.resourcemanagement.client.ContexClientModel; import org.gcube.portlets.admin.resourcemanagement.client.views.profile.ResourceProfilePanel; import org.gcube.portlets.admin.resourcemanagement.client.views.resourcedetails.ResourceDetailsPanel; import org.gcube.portlets.admin.resourcemanagement.client.views.resourcedetails.ResourceGridFactory; @@ -38,15 +39,13 @@ import org.gcube.resourcemanagement.support.shared.types.Tuple; import org.gcube.resourcemanagement.support.shared.types.datamodel.CompleteResourceProfile; import com.extjs.gxt.ui.client.data.ModelData; -import com.extjs.gxt.ui.client.event.ComponentEvent; +import com.extjs.gxt.ui.client.store.ListStore; import com.extjs.gxt.ui.client.widget.ContentPanel; import com.extjs.gxt.ui.client.widget.Dialog; import com.extjs.gxt.ui.client.widget.MessageBox; -import com.extjs.gxt.ui.client.widget.button.Button; +import com.extjs.gxt.ui.client.widget.form.ComboBox; import com.extjs.gxt.ui.client.widget.grid.Grid; import com.extjs.gxt.ui.client.widget.layout.FitLayout; -import com.extjs.gxt.ui.client.widget.menu.Menu; -import com.extjs.gxt.ui.client.widget.menu.MenuItem; import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.rpc.AsyncCallback; @@ -69,27 +68,25 @@ public class Callbacks { Commands.unmask(UIIdentifiers.MAIN_CONTAINER_VIEWPORT_ID); return; } - Button btnScopes = (Button) WidgetsRegistry.getWidget(UIIdentifiers.BUTTON_AVAILABLE_SCOPES_ID); - - Menu scrollMenu = new Menu(); - scrollMenu.setMaxHeight(200); + + @SuppressWarnings("unchecked") + ComboBox select = (ComboBox) WidgetsRegistry.getWidget(UIIdentifiers.BUTTON_AVAILABLE_SCOPES_ID); LocalStatus.getInstance().getAvailableScopes().clear(); - + final ListStore yourStore = select.getStore(); for (String scope : result) { final String currScope = scope; LocalStatus.getInstance().getAvailableScopes().add(currScope); - scrollMenu.add(new MenuItem(currScope) { - @Override - protected void onClick(final ComponentEvent be) { - super.onClick(be); - Commands.doLoadResourceTree(this, currScope); - } - }); + String splits[] = currScope.split("/"); + String context = splits[splits.length-1]; + if (splits.length > 3) { //VRE + context += " ("+splits[2]+")"; + } else if (splits.length == 3) { //VO + context += " ("+splits[1]+")"; + } + yourStore.add(new ContexClientModel(scope, context)); + Commands.unmask(UIIdentifiers.MAIN_CONTAINER_VIEWPORT_ID); } - - btnScopes.setMenu(scrollMenu); - Commands.unmask(UIIdentifiers.MAIN_CONTAINER_VIEWPORT_ID); } public void onFailure(final Throwable caught) { Commands.unmask(UIIdentifiers.MAIN_CONTAINER_VIEWPORT_ID); @@ -148,7 +145,7 @@ public class Callbacks { * Here implemented the logics for that. */ public static final AsyncCallback>> handleLoadResourceTree = - new AsyncCallback>>() { + new AsyncCallback>>() { public void onSuccess(final HashMap> result) { builtResourceTree(result, true); } @@ -169,7 +166,7 @@ public class Callbacks { * Here implemented the logics for that. */ public static final AsyncCallback>> handleReloadResourceTree = - new AsyncCallback>>() { + new AsyncCallback>>() { public void onSuccess(final HashMap> result) { builtResourceTree(result, false); } @@ -190,13 +187,13 @@ public class Callbacks { * they will be shown inside a grid that is created here. */ public static final AsyncCallback> handleLoadResourceDetailsGrid = - new AsyncCallback>() { + new AsyncCallback>() { public void onSuccess(final List result) { Commands.mask( "Rendering grid", WidgetsRegistry.getPanel(UIIdentifiers.RESOURCE_DETAIL_GRID_PANEL).getContainer() - ); + ); try { ResourceDetailsPanel resGrid = Commands.getResourceDetailPanel(); Grid grid = ResourceGridFactory.createGrid(StatusHandler.getStatus().getCurrentResourceType(), @@ -226,7 +223,7 @@ public class Callbacks { public static final AsyncCallback> handleFilterResourceDetailsGrid = - new AsyncCallback>() { + new AsyncCallback>() { public void onSuccess(final List result) { try { ResourceDetailsPanel resGrid = Commands.getResourceDetailPanel(); @@ -258,7 +255,7 @@ public class Callbacks { public static final AsyncCallback handleGetResourceProfile = - new AsyncCallback() { + new AsyncCallback() { public void onSuccess(final CompleteResourceProfile result) { Dialog dlg = new Dialog(); @@ -285,7 +282,7 @@ public class Callbacks { //result.getType() + ": " + result.getTitle(), result.getTitle(), "resource-profile-taskbar-item", - "profile-big-icon"); + "profile-big-icon"); tkItem.getRelatedWindow().setMainWidget( new ResourceProfilePanel( result.getType(), @@ -308,7 +305,7 @@ public class Callbacks { public static final AsyncCallback> handleGetDeploymentReport = - new AsyncCallback>() { + new AsyncCallback>() { public void onSuccess(final Tuple result) { diff --git a/src/main/webapp/ResourceManagementPortlet.css b/src/main/webapp/ResourceManagementPortlet.css index b94faf9..8e2218a 100644 --- a/src/main/webapp/ResourceManagementPortlet.css +++ b/src/main/webapp/ResourceManagementPortlet.css @@ -2,6 +2,11 @@ /*@import url(openbio.css);*/ @import url(coherence.css); + +div.x-form-field-wrap .x-form-trigger { + left: -15px !important; +} + /* Fix the scrollbar background style*/ .x-progress-text div { background-color: transparent !important;