diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/AppController.java b/src/main/java/org/gcube/portlets/user/workspace/client/AppController.java index 38ebdc7..81e6ba0 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/AppController.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/AppController.java @@ -7,6 +7,10 @@ import java.util.List; import org.gcube.portlets.user.workspace.client.ConstantsExplorer.ViewSwitchType; import org.gcube.portlets.user.workspace.client.ConstantsPortlet.ViewSwitchTypeInResult; +import org.gcube.portlets.user.workspace.client.event.AccountingHistoryEvent; +import org.gcube.portlets.user.workspace.client.event.AccountingHistoryEventHandler; +import org.gcube.portlets.user.workspace.client.event.AccountingReadersEvent; +import org.gcube.portlets.user.workspace.client.event.AccountingReadersEventHandler; import org.gcube.portlets.user.workspace.client.event.ActiveGroupingView; import org.gcube.portlets.user.workspace.client.event.ActiveGroupingViewHandler; import org.gcube.portlets.user.workspace.client.event.AddFolderEvent; @@ -152,6 +156,33 @@ public class AppController implements SubscriberInterface { } }); + eventBus.addHandler(AccountingHistoryEvent.TYPE, new AccountingHistoryEventHandler() { + + @Override + public void onAccountingHistoryShow(AccountingHistoryEvent accountingHistoryEvent) { + + FileGridModel fileItem = getGridSelectedItem(); + + if(fileItem!=null){ + AppControllerExplorer.getEventBus().fireEvent(new AccountingHistoryEvent(fileItem.getIdentifier())); + } + } + }); + + eventBus.addHandler(AccountingReadersEvent.TYPE, new AccountingReadersEventHandler() { + + @Override + public void onAccountingReadersShow(AccountingReadersEvent accountingReadersEvent) { + + + FileGridModel fileItem = getGridSelectedItem(); + + if(fileItem!=null){ + AppControllerExplorer.getEventBus().fireEvent(new AccountingReadersEvent(fileItem.getIdentifier())); + } + } + }); + eventBus.addHandler(GetInfoEvent.TYPE, new GetInfoEventHandler() { @Override @@ -231,9 +262,17 @@ public class AppController implements SubscriberInterface { @Override public void onGridElementSelected(GridElementSelectedEvent event) { doElementGridSelected(true, event.getSourceFile()); + + FileGridModel fileItem = getGridSelectedItem(); + + if(fileItem!=null){ + accountingSetItemAsRead(fileItem.isMarkAsRead()); + } + //setFileDetailsInView(event.getSourceFile().getIdentifier()); } + }); eventBus.addHandler(LoadAllScopeEvent.TYPE, new LoadAllScopeEventHandler() { @@ -515,6 +554,10 @@ public class AppController implements SubscriberInterface { } }); } + + private void accountingSetItemAsRead(boolean read) { + wsPortlet.getToolBarItemDetails().setRead(read); + } private void doElementGridSelected(boolean isSelected, FileModel target) { @@ -537,6 +580,10 @@ public class AppController implements SubscriberInterface { } } + + private FileGridModel getGridSelectedItem(){ + return wsPortlet.getGridGroupContainer().getSelectedItem(); + } /** diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/WorskpacePortlet.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/WorskpacePortlet.java index 9698b81..c528a92 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/WorskpacePortlet.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/WorskpacePortlet.java @@ -6,6 +6,7 @@ import org.gcube.portlets.user.workspace.client.view.panels.GxtBorderLayoutPanel import org.gcube.portlets.user.workspace.client.view.panels.GxtCardLayoutResultPanel; import org.gcube.portlets.user.workspace.client.view.panels.GxtSeachAndFilterPanel; import org.gcube.portlets.user.workspace.client.view.toolbars.GxtPathPanel; +import org.gcube.portlets.user.workspace.client.view.toolbars.GxtToolBarItemAccounting; /** @@ -18,7 +19,7 @@ public class WorskpacePortlet { private GxtBasicTabPanel basicTabContainer = null; // private GxtToolBarFunctionsPanel toolbarPanelContainer = null; private ExplorerPanel explorerPanel = null; - private GxtDetailsContainer detailsContainer; + private GxtToolBarItemAccounting toolBarItemDetails; private GxtListView listViewContainer; private GxtPathPanel toolBarPathPanel; private GxtGridFilterGroupPanel gridFilterGroupContainer; @@ -34,10 +35,10 @@ public class WorskpacePortlet { this.gridFilterGroupContainer = new GxtGridFilterGroupPanel(activeGroup); this.listViewContainer = new GxtListView(); - this.detailsContainer = new GxtDetailsContainer(); + this.toolBarItemDetails = new GxtToolBarItemAccounting(); - this.gxtCardLayoutResultPanel = new GxtCardLayoutResultPanel(gridFilterGroupContainer, listViewContainer, detailsContainer); + this.gxtCardLayoutResultPanel = new GxtCardLayoutResultPanel(gridFilterGroupContainer, listViewContainer, toolBarItemDetails); } @@ -45,7 +46,7 @@ public class WorskpacePortlet { this(activeGroup); this.explorerPanel = expPanel; - this.borderLayoutContainer = new GxtBorderLayoutPanel(this.searchAndFilterContainer, this.explorerPanel, this.gxtCardLayoutResultPanel, this.detailsContainer); + this.borderLayoutContainer = new GxtBorderLayoutPanel(this.searchAndFilterContainer, this.explorerPanel, this.gxtCardLayoutResultPanel, this.toolBarItemDetails); } public GxtBorderLayoutPanel getBorderLayoutContainer() { @@ -56,8 +57,8 @@ public class WorskpacePortlet { return basicTabContainer; } - public GxtDetailsContainer getDetailsContainer() { - return detailsContainer; + public GxtToolBarItemAccounting getDetailsContainer() { + return toolBarItemDetails; } @@ -83,4 +84,8 @@ public class WorskpacePortlet { public GxtCardLayoutResultPanel getGxtCardLayoutResultPanel() { return gxtCardLayoutResultPanel; } + + public GxtToolBarItemAccounting getToolBarItemDetails() { + return toolBarItemDetails; + } } diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/panels/GxtBorderLayoutPanel.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/panels/GxtBorderLayoutPanel.java index af4cfc5..493398f 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/panels/GxtBorderLayoutPanel.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/panels/GxtBorderLayoutPanel.java @@ -3,6 +3,7 @@ package org.gcube.portlets.user.workspace.client.view.panels; import org.gcube.portlets.user.workspace.client.ConstantsPortlet; import org.gcube.portlets.user.workspace.client.view.ExplorerPanel; import org.gcube.portlets.user.workspace.client.view.GxtDetailsContainer; +import org.gcube.portlets.user.workspace.client.view.toolbars.GxtToolBarItemAccounting; import com.extjs.gxt.ui.client.Style.LayoutRegion; import com.extjs.gxt.ui.client.Style.Scroll; @@ -26,7 +27,7 @@ public class GxtBorderLayoutPanel extends ContentPanel { private ContentPanel center = new ContentPanel(); private ContentPanel east = new ContentPanel(); private ContentPanel south = new ContentPanel(); - private GxtDetailsContainer detailsContainer = null; + private GxtToolBarItemAccounting toolBarItemDetails = null; private ExplorerPanel expPanel = null; //TODO change position private GxtSeachAndFilterPanel searchAndFilterContainer; private GxtCardLayoutResultPanel gxtCardLayoutResultPanel; @@ -36,12 +37,12 @@ public class GxtBorderLayoutPanel extends ContentPanel { GxtSeachAndFilterPanel searchAndFilterContainer2, ExplorerPanel explorerPanel, GxtCardLayoutResultPanel gxtCardLayoutResultPanel, - GxtDetailsContainer detailsContainer2) { + GxtToolBarItemAccounting detailsContainer2) { this.searchAndFilterContainer = searchAndFilterContainer2; this.expPanel = explorerPanel; this.gxtCardLayoutResultPanel = gxtCardLayoutResultPanel; - this.detailsContainer = detailsContainer2; + this.toolBarItemDetails = detailsContainer2; this.initLayout(); this.createLayouts(); @@ -62,12 +63,14 @@ public class GxtBorderLayoutPanel extends ContentPanel { north.setHeaderVisible(false); west.setHeading(ConstantsPortlet.EXPLORER); - south.setHeading(ConstantsPortlet.DETAILS); + + south.setHeading(ConstantsPortlet.DETAILS); + south.setHeaderVisible(false); south.setLayout(new FitLayout()); east.setVisible(false); - south.setVisible(false); +// south.setVisible(false); this.createLayouts(); } @@ -104,9 +107,9 @@ public class GxtBorderLayoutPanel extends ContentPanel { eastData.setCollapsible(true); eastData.setMargins(new Margins(0,0,0,1)); - BorderLayoutData southData = new BorderLayoutData(LayoutRegion.SOUTH, 140,140,140); + BorderLayoutData southData = new BorderLayoutData(LayoutRegion.SOUTH, 30,30,30); southData.setSplit(true); - southData.setCollapsible(true); + southData.setCollapsible(false); southData.setMargins(new Margins(1, 0, 0, 0)); north.add(this.searchAndFilterContainer); @@ -116,7 +119,7 @@ public class GxtBorderLayoutPanel extends ContentPanel { center.add(this.gxtCardLayoutResultPanel); - south.add(this.detailsContainer); +// south.add(this.toolBarItemDetails); west.addListener(Events.Resize, new Listener(){ @@ -136,5 +139,6 @@ public class GxtBorderLayoutPanel extends ContentPanel { add(west, westData); add(center, centerData); add(east, eastData); +// add(south, southData); } } \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/panels/GxtCardLayoutResultPanel.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/panels/GxtCardLayoutResultPanel.java index 57fa0ff..bb363fb 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/panels/GxtCardLayoutResultPanel.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/panels/GxtCardLayoutResultPanel.java @@ -4,7 +4,8 @@ import org.gcube.portlets.user.workspace.client.ConstantsPortlet.ViewSwitchTypeI import org.gcube.portlets.user.workspace.client.view.GxtDetailsContainer; import org.gcube.portlets.user.workspace.client.view.GxtListView; import org.gcube.portlets.user.workspace.client.view.grids.GxtGridFilterGroupPanel; -import org.gcube.portlets.user.workspace.client.view.toolbars.GxtToolBarItem; +import org.gcube.portlets.user.workspace.client.view.toolbars.GxtToolBarItemAccounting; +import org.gcube.portlets.user.workspace.client.view.toolbars.GxtToolBarItemFunctionality; import com.extjs.gxt.ui.client.widget.ContentPanel; import com.extjs.gxt.ui.client.widget.LayoutContainer; @@ -23,23 +24,24 @@ public class GxtCardLayoutResultPanel extends LayoutContainer{ private GxtListView iconsViewContainer; private GxtGridFilterGroupPanel gridGroupViewContainer; private ContentPanel activePanel = null; - private GxtToolBarItem toolBarItem; + private GxtToolBarItemFunctionality toolBarItemFunct; + private GxtToolBarItemAccounting toolBarItemDetails; public GxtCardLayoutResultPanel( GxtGridFilterGroupPanel gridFilterGroupContainer, GxtListView listViewContainer, - GxtDetailsContainer detailsContainer) { + GxtToolBarItemAccounting toolBarItemDetails) { this.iconsViewContainer = listViewContainer; this.gridGroupViewContainer = gridFilterGroupContainer; - + this.toolBarItemDetails = toolBarItemDetails; instanceItemsPanel(); } private void instanceItemsPanel(){ - this.toolBarItem = new GxtToolBarItem(gridGroupViewContainer); //instance toolbar - this.itemPanel = new GxtItemsPanel(iconsViewContainer, gridGroupViewContainer, toolBarItem); + this.toolBarItemFunct = new GxtToolBarItemFunctionality(gridGroupViewContainer); //instance toolbar + this.itemPanel = new GxtItemsPanel(iconsViewContainer, gridGroupViewContainer, toolBarItemFunct, toolBarItemDetails); } @@ -85,8 +87,8 @@ public class GxtCardLayoutResultPanel extends LayoutContainer{ } - public GxtToolBarItem getToolBarItem() { - return toolBarItem; + public GxtToolBarItemFunctionality getToolBarItem() { + return toolBarItemFunct; } public ContentPanel getActivePanel(){ diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/panels/GxtItemsPanel.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/panels/GxtItemsPanel.java index afdd364..e229384 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/panels/GxtItemsPanel.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/panels/GxtItemsPanel.java @@ -2,7 +2,8 @@ package org.gcube.portlets.user.workspace.client.view.panels; import org.gcube.portlets.user.workspace.client.view.GxtListView; import org.gcube.portlets.user.workspace.client.view.grids.GxtGridFilterGroupPanel; -import org.gcube.portlets.user.workspace.client.view.toolbars.GxtToolBarItem; +import org.gcube.portlets.user.workspace.client.view.toolbars.GxtToolBarItemAccounting; +import org.gcube.portlets.user.workspace.client.view.toolbars.GxtToolBarItemFunctionality; import com.extjs.gxt.ui.client.widget.ContentPanel; import com.extjs.gxt.ui.client.widget.layout.FitLayout; @@ -12,25 +13,49 @@ import com.extjs.gxt.ui.client.widget.layout.FitLayout; * */ public class GxtItemsPanel extends ContentPanel{ - private GxtToolBarItem toolBarItem; + private GxtToolBarItemFunctionality toolBarItemFunct; private GxtListView iconsViewContainer; private GxtGridFilterGroupPanel gridGroupViewContainer; + private GxtToolBarItemAccounting toolBarItemDetails; - public GxtItemsPanel(GxtListView iconsViewContainer, GxtGridFilterGroupPanel gridGroupViewContainer, GxtToolBarItem toolBarItem) { + public GxtItemsPanel(GxtListView iconsViewContainer, GxtGridFilterGroupPanel gridGroupViewContainer, GxtToolBarItemFunctionality toolBarItem, GxtToolBarItemAccounting toolBarItemDetails) { this.iconsViewContainer = iconsViewContainer; this.gridGroupViewContainer = gridGroupViewContainer; - this.toolBarItem = toolBarItem; + this.toolBarItemFunct = toolBarItem; + this.toolBarItemDetails = toolBarItemDetails; setBorders(false); setBodyBorder(false); setHeaderVisible(false); this.setLayout(new FitLayout()); - setTopComponent(this.toolBarItem.getToolBar()); + setTopComponent(this.toolBarItemFunct.getToolBar()); add(gridGroupViewContainer); + + setBottomComponent(this.toolBarItemDetails); } + + + public GxtToolBarItemFunctionality getToolBarItemFunct() { + return toolBarItemFunct; + } + + + public GxtListView getIconsViewContainer() { + return iconsViewContainer; + } + + + public GxtGridFilterGroupPanel getGridGroupViewContainer() { + return gridGroupViewContainer; + } + + + public GxtToolBarItemAccounting getToolBarItemDetails() { + return toolBarItemDetails; + } } diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/toolbars/GxtToolBarItemAccounting.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/toolbars/GxtToolBarItemAccounting.java new file mode 100644 index 0000000..b285671 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/toolbars/GxtToolBarItemAccounting.java @@ -0,0 +1,96 @@ +package org.gcube.portlets.user.workspace.client.view.toolbars; + +import org.gcube.portlets.user.workspace.client.AppController; +import org.gcube.portlets.user.workspace.client.event.AccountingHistoryEvent; +import org.gcube.portlets.user.workspace.client.event.AccountingReadersEvent; +import org.gcube.portlets.user.workspace.client.resources.Resources; + +import com.extjs.gxt.ui.client.event.ButtonEvent; +import com.extjs.gxt.ui.client.event.SelectionListener; +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.TextField; +import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem; +import com.extjs.gxt.ui.client.widget.toolbar.ToolBar; + +/** + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * + */ +public class GxtToolBarItemAccounting extends ToolBar{ + + private TextField txfName = new TextField(); + private Text txtOwner = new Text("Empty"); + private Text txtCreationTime = new Text("Empty"); + private Text txtDimension = new Text("Empty"); + + private Button bHistory; + private Button bRead; + + public GxtToolBarItemAccounting(){ + super(); + initToolbar(); + } + + private void initToolbar(){ + + bHistory = new Button("History"); + bHistory.setIcon(Resources.getIconHistory()); + + bHistory.addSelectionListener(new SelectionListener() { + + @Override + public void componentSelected(ButtonEvent ce) { + + AppController.getEventBus().fireEvent(new AccountingHistoryEvent(null)); + + } + }); + + bRead = new Button("Read"); + bRead.setIcon(Resources.getIconNotRead()); + + bRead.addSelectionListener(new SelectionListener() { + + @Override + public void componentSelected(ButtonEvent ce) { + + AppController.getEventBus().fireEvent(new AccountingReadersEvent(null)); + + } + }); + + add(bHistory); + add(new SeparatorToolItem()); + add(bRead); + } + + public void resetDetails(){ + + this.txtDimension.setText(""); + this.txtCreationTime.setText(""); + this.txfName.reset(); + this.txtOwner.setText(""); + } + + public void setDetails(String itemName, String description, String dimension, String creationTime, String owner){ + + this.resetDetails(); + + this.txtDimension.setText(dimension); + this.txtCreationTime.setText(creationTime); + this.txfName.setValue(itemName); + this.txtOwner.setText(owner); + + } + + /** + * @param markAsRead + */ + public void setRead(boolean markAsRead) { + if(markAsRead) + bRead.setIcon(Resources.getIconRead()); + else + bRead.setIcon(Resources.getIconNotRead()); + } +} diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/toolbars/GxtToolBarItem.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/toolbars/GxtToolBarItemFunctionality.java similarity index 98% rename from src/main/java/org/gcube/portlets/user/workspace/client/view/toolbars/GxtToolBarItem.java rename to src/main/java/org/gcube/portlets/user/workspace/client/view/toolbars/GxtToolBarItemFunctionality.java index d462f02..f5e76c5 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/toolbars/GxtToolBarItem.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/toolbars/GxtToolBarItemFunctionality.java @@ -36,7 +36,7 @@ import com.extjs.gxt.ui.client.widget.toolbar.ToolBar; * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * */ -public class GxtToolBarItem { +public class GxtToolBarItemFunctionality { private Button btnAddFolder = null; private Button btnRemoveItem = null; @@ -56,12 +56,12 @@ public class GxtToolBarItem { private ToggleButton btnGridView; private Button btnGetInfo; - public GxtToolBarItem() { + public GxtToolBarItemFunctionality() { initToolBar(); addSelectionListenersOnToolBar(); } - public GxtToolBarItem(GxtGridFilterGroupPanel gridFilterGroupContainer) { + public GxtToolBarItemFunctionality(GxtGridFilterGroupPanel gridFilterGroupContainer) { this(); this.gridGroupViewContainer = gridFilterGroupContainer; }