diff --git a/src/main/java/org/gcube/portlets/user/td/tablewidget/client/progress/TemplateApplyProgressBarUpdater.java b/src/main/java/org/gcube/portlets/user/td/tablewidget/client/progress/TemplateApplyProgressBarUpdater.java deleted file mode 100644 index 8aacadd..0000000 --- a/src/main/java/org/gcube/portlets/user/td/tablewidget/client/progress/TemplateApplyProgressBarUpdater.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * - */ -package org.gcube.portlets.user.td.tablewidget.client.progress; - - - - -import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; - -import com.allen_sauer.gwt.log.client.Log; -import com.sencha.gxt.widget.core.client.ProgressBar; - -/** - * - * @author "Giancarlo Panichi" - * g.panichi@isti.cnr.it - * - */ -public class TemplateApplyProgressBarUpdater implements TemplateApplyProgressListener { - - protected ProgressBar progressBar; - - /** - * Creates a new {@link ProgressBar} updater. - * @param progressBar the {@link ProgressBar} to update. - */ - public TemplateApplyProgressBarUpdater(ProgressBar progressBar) { - this.progressBar = progressBar; - } - - - /** - * {@inheritDoc} - */ - public void operationComplete(TRId trId) { - Log.info("Completed"); - progressBar.updateProgress(1, "Completed"); - - } - - /** - * {@inheritDoc} - */ - public void operationFailed(Throwable caught, String reason, String failureDetails) { - Log.info("Failed"); - progressBar.updateText("Failed"); - } - - public void operationInitializing() { - Log.info("Inizializing"); - progressBar.updateProgress(0, "Initializing..."); - } - - public void operationUpdate(float elaborated) { - Log.info("Import elaborated: "+elaborated); - if (elaborated == 0) progressBar.updateProgress(0, "Initializing..."); - if (elaborated>0 && elaborated<1) { - Log.trace("progress "+elaborated); - int elab=new Float(elaborated*100).intValue(); - progressBar.updateProgress(elaborated,elab+"% Progress..."); - } - if (elaborated == 1) progressBar.updateProgress(1, "Completing..."); - - } - - - @Override - public void operationStopped(TRId trId,String reason, String details) { - Log.debug("Operation Stopped: ["+trId.toString()+", "+reason+", "+details+"]"); - progressBar.updateText("Validations failed"); - - } - -} diff --git a/src/main/java/org/gcube/portlets/user/td/tablewidget/client/progress/TemplateApplyProgressDialog.java b/src/main/java/org/gcube/portlets/user/td/tablewidget/client/progress/TemplateApplyProgressDialog.java deleted file mode 100644 index 5965379..0000000 --- a/src/main/java/org/gcube/portlets/user/td/tablewidget/client/progress/TemplateApplyProgressDialog.java +++ /dev/null @@ -1,129 +0,0 @@ -package org.gcube.portlets.user.td.tablewidget.client.progress; - -import org.gcube.portlets.user.td.tablewidget.client.template.TemplateApplyDialog; -import org.gcube.portlets.user.td.tablewidget.client.util.UtilsGXT3; -import org.gcube.portlets.user.td.widgetcommonevent.client.event.ChangeTableRequestEvent; -import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableRequestType; -import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; - -import com.allen_sauer.gwt.log.client.Log; -import com.google.web.bindery.event.shared.EventBus; -import com.sencha.gxt.core.client.util.Margins; -import com.sencha.gxt.widget.core.client.FramedPanel; -import com.sencha.gxt.widget.core.client.ProgressBar; -import com.sencha.gxt.widget.core.client.Window; -import com.sencha.gxt.widget.core.client.button.TextButton; -import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer; -import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData; -import com.sencha.gxt.widget.core.client.event.SelectEvent; -import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler; - - - -/** - * LabelColumnProgressDialog is a Dialog that show progress of change the column label - * - * @author "Giancarlo Panichi" - * g.panichi@isti.cnr.it - * - */ -public class TemplateApplyProgressDialog extends Window implements TemplateApplyProgressListener { - public static final int STATUS_POLLING_DELAY = 1000; - protected String WIDTH = "400px"; - protected String HEIGHT = "120px"; - protected TemplateApplyDialog dialog; - protected EventBus eventBus; - protected TemplateApplyProgressUpdater progressUpdater; - protected TextButton ok; - protected TRId trId; - - public TemplateApplyProgressDialog(TemplateApplyDialog dialog, EventBus eventBus) { - this.dialog=dialog; - this.eventBus=eventBus; - setWidth(WIDTH); - setHeight(HEIGHT); - setBodyBorder(false); - setResizable(true); - setModal(true); - setHeadingText("Template Apply Progress"); - - trId=null; - - FramedPanel panel=new FramedPanel(); - panel.setHeaderVisible(false); - panel.setBodyBorder(false); - - VerticalLayoutContainer v = new VerticalLayoutContainer(); - - - ProgressBar progressBar = new ProgressBar(); - - ok=new TextButton("OK"); - ok.addSelectHandler(new SelectHandler() { - - public void onSelect(SelectEvent event) { - updateInvocation(); - - } - }); - - v.add(progressBar, new VerticalLayoutData(1, - 1, new Margins(5, 5, 5, 5))); - - panel.add(v); - panel.addButton(ok); - add(panel); - - - progressUpdater = new TemplateApplyProgressUpdater(); - progressUpdater.addListener(new TemplateApplyProgressBarUpdater(progressBar)); - - progressUpdater.addListener(this); - progressUpdater.scheduleRepeating(STATUS_POLLING_DELAY); - show(); - ok.setVisible(false); - - } - - public void operationInitializing() { - // TODO Auto-generated method stub - - } - - public void operationUpdate(float elaborated) { - // TODO Auto-generated method stub - - } - - public void operationComplete(TRId trId) { - Log.debug("Operation Complete return: "+trId.toString()); - this.trId=trId; - updateInvocation(); - } - - public void operationFailed(Throwable caught, String reason, - String failureDetails) { - ok.setVisible(true); - this.trId=null; - UtilsGXT3.alert("Error in Template Apply", reason); - - } - - public void updateInvocation(){ - if(trId!=null){ - ChangeTableRequestEvent changeTableRequestEvent= - new ChangeTableRequestEvent(ChangeTableRequestType.TEMPLATEAPPLY, trId); - eventBus.fireEvent(changeTableRequestEvent); - } - dialog.hide(); - hide(); - - } - - @Override - public void operationStopped(TRId trId,String reason, String details) { - Log.debug("Operation Stopped: ["+trId.toString()+", "+reason+", "+details+"]"); - ok.setVisible(true); - this.trId=trId; - } -} diff --git a/src/main/java/org/gcube/portlets/user/td/tablewidget/client/progress/TemplateApplyProgressListener.java b/src/main/java/org/gcube/portlets/user/td/tablewidget/client/progress/TemplateApplyProgressListener.java deleted file mode 100644 index 94951cd..0000000 --- a/src/main/java/org/gcube/portlets/user/td/tablewidget/client/progress/TemplateApplyProgressListener.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * - */ -package org.gcube.portlets.user.td.tablewidget.client.progress; - -import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; - - - -/** - * Defines a listener for operation progress. - * - * @author "Giancarlo Panichi" - * g.panichi@isti.cnr.it - * - */ -public interface TemplateApplyProgressListener { - - /** - * Called when the operation is starting. - */ - public void operationInitializing(); - - /** - * Called when there is a progress for the operation. - * @param elaborated the elaborated part. - */ - public void operationUpdate(float elaborated); - - - /** - * Called when the operation is complete. - */ - public void operationComplete(TRId trId); - - /** - * Called when the operation is failed. - * @param caught the failure exception. - * @param reason the failure reason. - */ - public void operationFailed(Throwable caught, String reason, String failureDetails); - - /** - * Called when the operation is stopped - * - * @param trId - * @param reason - * @param details - */ - public void operationStopped(TRId trId, String reason, String details); - -} diff --git a/src/main/java/org/gcube/portlets/user/td/tablewidget/client/progress/TemplateApplyProgressUpdater.java b/src/main/java/org/gcube/portlets/user/td/tablewidget/client/progress/TemplateApplyProgressUpdater.java deleted file mode 100644 index aed9b9d..0000000 --- a/src/main/java/org/gcube/portlets/user/td/tablewidget/client/progress/TemplateApplyProgressUpdater.java +++ /dev/null @@ -1,181 +0,0 @@ -/** - * - */ -package org.gcube.portlets.user.td.tablewidget.client.progress; - -import java.util.ArrayList; - -import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync; -import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateApplyMonitor; -import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; - -import com.allen_sauer.gwt.log.client.Log; -import com.google.gwt.user.client.Timer; -import com.google.gwt.user.client.rpc.AsyncCallback; - - -/** - * - * @author "Giancarlo Panichi" - * g.panichi@isti.cnr.it - * - */ -public class TemplateApplyProgressUpdater extends Timer { - - protected ArrayList listeners = new ArrayList(); - - /** - * {@inheritDoc} - */ - @Override - public void run() { - Log.debug("requesting operation progress"); - TDGWTServiceAsync.INSTANCE - .getTemplateApplyMonitor(new AsyncCallback() { - - - public void onFailure(Throwable caught) { - cancel(); - Log.error("Error retrieving the operation state", - caught); - String message = getStack(caught); - fireOperationFailed(caught, - "Failed getting operation updates", message); - } - - public void onSuccess(TemplateApplyMonitor result) { - Log.info("retrieved TemplateApplyMonitor: " - + result.getStatus()); - switch (result.getStatus()) { - case INITIALIZING: - Log.info("Initializing..."); - fireOperationInitializing(); - break; - case ABORTED: - cancel(); - Log.info("Template Apply Operation Aborted"); - break; - case IN_PROGRESS: - fireOperationUpdate(result.getProgress()); - break; - case VALIDATING_RULES: - fireOperationUpdate(result.getProgress()); - break; - case STOPPED: - cancel(); - stopMessage(result); - break; - case FAILED: - cancel(); - errorMessage(result); - break; - case SUCCEDED: - cancel(); - Log.info("Fisnish TableId :" - + result.getTrId()); - fireOperationComplete(result.getTrId()); - break; - default: - Log.info("Unknow State"); - break; - } - - } - - - - }); - - } - - protected void errorMessage(TemplateApplyMonitor result) { - Log.info("Template Apply Failed"); - Throwable th = null; - String failure = null; - String details = null; - if (result.getError() != null) { - th = result.getError(); - failure = "Failed Client Library applying template"; - details = result.getError().getLocalizedMessage(); - } else { - th = new Throwable("Failed"); - failure = "Failed Client Library applying template"; - details = "Template Apply failed"; - } - - fireOperationFailed(th, failure, details); - } - - protected void stopMessage(TemplateApplyMonitor result) { - Log.info("Template Apply Stopped"); - String failure = null; - String details = null; - if (result.getError() != null) { - failure = "Stopped applying template"; - details = result.getError().getLocalizedMessage(); - } else { - failure = "Stopped applying template"; - details = "Apply template stopped"; - } - - fireOperationStopped(result.getTrId(),failure, details); - } - - - protected String getStack(Throwable e) { - String message = e.getLocalizedMessage() + " ->
"; - Throwable c = e.getCause(); - if (c != null) - message += getStack(c); - return message; - } - - protected void fireOperationInitializing() { - for (TemplateApplyProgressListener listener : listeners) - listener.operationInitializing(); - } - - protected void fireOperationUpdate(float elaborated) { - for (TemplateApplyProgressListener listener : listeners) - listener.operationUpdate(elaborated); - } - - protected void fireOperationComplete(TRId trId) { - for (TemplateApplyProgressListener listener : listeners) - listener.operationComplete(trId); - } - - protected void fireOperationFailed(Throwable caught, String failure, - String failureDetails) { - for (TemplateApplyProgressListener listener : listeners) - listener.operationFailed(caught, failure, failureDetails); - } - - protected void fireOperationStopped(TRId trId, String reason, String details) { - for (TemplateApplyProgressListener listener : listeners) - listener.operationStopped(trId,reason, details); - } - - - /** - * Add a new {@link TemplateApplyProgressListener} to this - * {@link TemplateApplyProgressUpdater}. - * - * @param listener - * the listener to add. - */ - public void addListener(TemplateApplyProgressListener listener) { - listeners.add(listener); - } - - /** - * Removes the specified {@link TemplateApplyProgressListener} from this - * {@link TemplateApplyProgressUpdater}. - * - * @param listener - * the listener to remove. - */ - public void removeListener(TemplateApplyProgressListener listener) { - listeners.remove(listener); - } -} diff --git a/src/main/java/org/gcube/portlets/user/td/tablewidget/client/template/TemplateApplyDialog.java b/src/main/java/org/gcube/portlets/user/td/tablewidget/client/template/TemplateApplyDialog.java deleted file mode 100644 index bff103b..0000000 --- a/src/main/java/org/gcube/portlets/user/td/tablewidget/client/template/TemplateApplyDialog.java +++ /dev/null @@ -1,110 +0,0 @@ -package org.gcube.portlets.user.td.tablewidget.client.template; - -import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync; -import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateApplySession; -import org.gcube.portlets.user.td.tablewidget.client.progress.TemplateApplyProgressDialog; -import org.gcube.portlets.user.td.tablewidget.client.resources.ResourceBundle; -import org.gcube.portlets.user.td.tablewidget.client.util.UtilsGXT3; -import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; - -import com.allen_sauer.gwt.log.client.Log; -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.google.web.bindery.event.shared.EventBus; -import com.sencha.gxt.widget.core.client.Window; -import com.sencha.gxt.widget.core.client.event.SelectEvent; -import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler; - - -/** - * - * @author "Giancarlo Panichi" - * g.panichi@isti.cnr.it - * - */ -public class TemplateApplyDialog extends Window { - protected String WIDTH = "650px"; - protected String HEIGHT = "530px"; - protected TemplateApplySession templateApplySession; - protected TRId trId; - protected EventBus eventBus; - - public TemplateApplyDialog(TRId trId, EventBus eventBus) { - this.trId=trId; - this.eventBus=eventBus; - initWindow(); - - TemplateApplyPanel templateApplyPanel= new TemplateApplyPanel(this,trId, eventBus); - add(templateApplyPanel); - } - - protected void initWindow() { - setWidth(WIDTH); - setHeight(HEIGHT); - setBodyBorder(false); - setResizable(false); - setHeadingText("Apply Template"); - setClosable(true); - setModal(true); - forceLayoutOnResize = true; - getHeader().setIcon(ResourceBundle.INSTANCE.templateApply()); - - } - - /** - * {@inheritDoc} - */ - @Override - protected void initTools() { - super.initTools(); - - closeBtn.addSelectHandler(new SelectHandler() { - - - public void onSelect(SelectEvent event) { - close(); - } - }); - - } - - protected void close (){ - hide(); - } - - - protected void applyTemplate(final TemplateApplySession templateApplySession){ - this.templateApplySession=templateApplySession; - - TDGWTServiceAsync.INSTANCE.startTemplateApply(templateApplySession, - new AsyncCallback() { - public void onFailure(Throwable caught) { - Log.debug("Apply Template Error: " - + caught.getLocalizedMessage()); - UtilsGXT3.alert("Apply Template Error ", - "Error in invocation of apply template operation!"); - - } - - public void onSuccess(Void result) { - callApplyTemplateProgressDialog(); - } - - }); - - - } - - - - - protected void callApplyTemplateProgressDialog() { - TemplateApplyProgressDialog d = new TemplateApplyProgressDialog( - this, eventBus); - d.show(); - } - - - - - -} diff --git a/src/main/java/org/gcube/portlets/user/td/tablewidget/client/template/TemplateApplyPanel.java b/src/main/java/org/gcube/portlets/user/td/tablewidget/client/template/TemplateApplyPanel.java deleted file mode 100644 index 2176852..0000000 --- a/src/main/java/org/gcube/portlets/user/td/tablewidget/client/template/TemplateApplyPanel.java +++ /dev/null @@ -1,336 +0,0 @@ -package org.gcube.portlets.user.td.tablewidget.client.template; - -import java.util.ArrayList; -import java.util.List; - -import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync; -import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateApplySession; -import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateData; -import org.gcube.portlets.user.td.tablewidget.client.resources.ResourceBundle; -import org.gcube.portlets.user.td.tablewidget.client.util.UtilsGXT3; -import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; - -import com.allen_sauer.gwt.log.client.Log; -import com.google.gwt.core.client.GWT; -import com.google.gwt.core.client.Scheduler; -import com.google.gwt.core.client.Scheduler.ScheduledCommand; -import com.google.gwt.event.dom.client.KeyUpEvent; -import com.google.gwt.event.dom.client.KeyUpHandler; -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.google.web.bindery.event.shared.EventBus; -import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign; -import com.sencha.gxt.core.client.IdentityValueProvider; -import com.sencha.gxt.core.client.Style.SelectionMode; -import com.sencha.gxt.core.client.resources.ThemeStyles; -import com.sencha.gxt.core.client.util.Margins; -import com.sencha.gxt.data.client.loader.RpcProxy; -import com.sencha.gxt.data.shared.ListStore; -import com.sencha.gxt.data.shared.ModelKeyProvider; -import com.sencha.gxt.data.shared.Store; -import com.sencha.gxt.data.shared.Store.StoreFilter; -import com.sencha.gxt.data.shared.loader.ListLoadConfig; -import com.sencha.gxt.data.shared.loader.ListLoadResult; -import com.sencha.gxt.data.shared.loader.ListLoadResultBean; -import com.sencha.gxt.data.shared.loader.ListLoader; -import com.sencha.gxt.data.shared.loader.LoadResultListStoreBinding; -import com.sencha.gxt.widget.core.client.FramedPanel; -import com.sencha.gxt.widget.core.client.button.TextButton; -import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData; -import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutPack; -import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer; -import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer.HBoxLayoutAlign; -import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer; -import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData; -import com.sencha.gxt.widget.core.client.event.SelectEvent; -import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler; -import com.sencha.gxt.widget.core.client.form.TextField; -import com.sencha.gxt.widget.core.client.grid.CheckBoxSelectionModel; -import com.sencha.gxt.widget.core.client.grid.ColumnConfig; -import com.sencha.gxt.widget.core.client.grid.ColumnModel; -import com.sencha.gxt.widget.core.client.grid.Grid; -import com.sencha.gxt.widget.core.client.toolbar.LabelToolItem; -import com.sencha.gxt.widget.core.client.toolbar.ToolBar; - -public class TemplateApplyPanel extends FramedPanel { - protected String WIDTH = "560px"; - protected String HEIGHT = "520px"; - protected EventBus eventBus; - protected TemplateApplyDialog parent; - protected TRId trId; - protected TemplateApplySession templateApplySession; - - private TextButton btnApply; - private TextButton btnClose; - - protected ListLoader> loader; - protected Grid grid; - protected ExtendedListStore store; - - public TemplateApplyPanel(TemplateApplyDialog parent, TRId trId, - EventBus eventBus) { - this.parent = parent; - this.trId = trId; - Log.debug("TemplateApplyPanel"); - setWidth(WIDTH); - setHeight(HEIGHT); - setHeaderVisible(false); - setBodyBorder(false); - this.eventBus = eventBus; - - create(); - - } - - protected void create() { - ToolBar toolBarHead = new ToolBar(); - toolBarHead.add(new LabelToolItem("Search: ")); - final TextField searchField = new TextField(); - toolBarHead.add(searchField); - - TextButton btnReload = new TextButton(); - //btnReload.setText("Reload"); - btnReload.setIcon(ResourceBundle.INSTANCE.refresh()); - btnReload.setToolTip("Reload"); - toolBarHead.add(btnReload); - - - IdentityValueProvider identity = new IdentityValueProvider(); - CheckBoxSelectionModel sm = new CheckBoxSelectionModel( - identity); - - TemplateDataProperties props = GWT.create(TemplateDataProperties.class); - - ColumnConfig nameCol = new ColumnConfig( - props.name(), 120, "Name"); - ColumnConfig categoryCol = new ColumnConfig( - props.category(), 60, "Category"); - - ColumnConfig agencyCol = new ColumnConfig( - props.agency(), 100, "Agency"); - - ColumnConfig descriptionCol = new ColumnConfig( - props.description(), 120, "Description"); - - List> l = new ArrayList>(); - l.add(nameCol); - l.add(categoryCol); - l.add(agencyCol); - l.add(descriptionCol); - - ColumnModel cm = new ColumnModel(l); - - store = new ExtendedListStore(props.id()); - - searchField.addKeyUpHandler(new KeyUpHandler() { - - public void onKeyUp(KeyUpEvent event) { - Log.trace("searchTerm: "+searchField.getCurrentValue()); - store.applyFilters(); - } - }); - - store.addFilter(new StoreFilter() { - - @Override - public boolean select(Store store, - TemplateData parent, TemplateData item) { - String searchTerm = searchField.getCurrentValue(); - if (searchTerm == null) return true; - return TemplateApplyPanel.this.select(item, searchTerm); - } - }); - - store.setEnableFilters(true); - - - RpcProxy> proxy = new RpcProxy>() { - - public void load(ListLoadConfig loadConfig, - final AsyncCallback> callback) { - loadData(loadConfig, callback); - } - }; - loader = new ListLoader>( - proxy); - - loader.setRemoteSort(false); - loader.addLoadHandler(new LoadResultListStoreBinding>( - store) { - }); - - - SelectHandler sh = new SelectHandler() { - public void onSelect(SelectEvent event) { - loader.load(); - } - }; - - btnReload.addSelectHandler(sh); - - grid = new Grid(store, cm) { - @Override - protected void onAfterFirstAttach() { - super.onAfterFirstAttach(); - Scheduler.get().scheduleDeferred(new ScheduledCommand() { - - public void execute() { - loader.load(); - } - }); - } - }; - - sm.setSelectionMode(SelectionMode.SINGLE); - grid.setLoader(loader); - grid.setSelectionModel(sm); - grid.setHeight("384px"); - grid.getView().setStripeRows(true); - grid.getView().setColumnLines(true); - grid.getView().setAutoFill(true); - grid.setBorders(false); - grid.setLoadMask(true); - grid.setColumnReordering(true); - grid.setColumnResize(true); - grid.getView().setAutoExpandColumn(descriptionCol); - - - - - ToolBar toolBar = new ToolBar(); - toolBar.add(grid); - toolBar.addStyleName(ThemeStyles.getStyle().borderTop()); - toolBar.getElement().getStyle().setProperty("borderBottom", "none"); - - btnApply = new TextButton("Apply"); - btnApply.setIcon(ResourceBundle.INSTANCE.templateApply()); - btnApply.setIconAlign(IconAlign.RIGHT); - btnApply.setTitle("Apply Template"); - btnApply.addSelectHandler(new SelectHandler() { - - public void onSelect(SelectEvent event) { - Log.debug("Pressed Apply"); - apply(); - - } - }); - - btnClose = new TextButton("Close"); - btnClose.setIcon(ResourceBundle.INSTANCE.close()); - btnClose.setIconAlign(IconAlign.RIGHT); - btnClose.setTitle("Cancel filter"); - btnClose.addSelectHandler(new SelectHandler() { - - public void onSelect(SelectEvent event) { - Log.debug("Pressed Close"); - close(); - } - }); - - HBoxLayoutContainer flowButton = new HBoxLayoutContainer(); - flowButton.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE); - flowButton.setPack(BoxLayoutPack.CENTER); - - flowButton.add(btnApply, new BoxLayoutData(new Margins(2, 4, 2, 4))); - flowButton.add(btnClose, new BoxLayoutData(new Margins(2, 4, 2, 4))); - - VerticalLayoutContainer v = new VerticalLayoutContainer(); - v.add(toolBarHead, new VerticalLayoutData(1, -1, new Margins(0))); - v.add(grid, new VerticalLayoutData(-1, -1, new Margins(0))); - v.add(toolBar, new VerticalLayoutData(1, 25, new Margins(0))); - v.add(flowButton, new VerticalLayoutData(-1, 36, - new Margins(5, 2, 5, 2))); - add(v); - - } - - protected void loadData(ListLoadConfig loadConfig, - final AsyncCallback> callback) { - - TDGWTServiceAsync.INSTANCE - .getTemplates(new AsyncCallback>() { - - public void onFailure(Throwable caught) { - Log.error("load templates failure:" - + caught.getLocalizedMessage()); - UtilsGXT3.alert("Error retrieving templates", - "Error retrieving templates"); - callback.onFailure(caught); - } - - public void onSuccess(ArrayList result) { - Log.trace("loaded " + result.size() + " Occurences"); - callback.onSuccess(new ListLoadResultBean( - result)); - - } - - }); - - } - - - - /* - * protected void setMenu() { Menu contextMenu = new Menu(); - * - * MenuItem deleteTemplateItem = new MenuItem("Delete"); - * deleteTemplateItem.setId("DeleteTemplate"); - * deleteTemplateItem.setIcon(ResourceBundle.INSTANCE.removeTemplate()); - * deleteTemplateItem.addSelectionHandler(new SelectionHandler() { - * - * @Override public void onSelection(SelectionEvent event) { - * Log.debug("Delete Template"); TemplateData templateDesc = - * getSelectedItem(); - * - * } }); - * - * grid.setContextMenu(contextMenu); } - */ - - protected TemplateData getSelectedItem() { - return grid.getSelectionModel().getSelectedItem(); - } - - protected void apply() { - templateApplySession = new TemplateApplySession(); - TemplateData template = getSelectedItem(); - if (template == null) { - UtilsGXT3.info("Attention", "Select the template to apply"); - } else { - templateApplySession.setTemplateData(getSelectedItem()); - templateApplySession.setTrId(trId); - Log.debug("applyTemplateSession: " + templateApplySession); - parent.applyTemplate(templateApplySession); - } - } - - protected void close() { - parent.close(); - } - - protected class ExtendedListStore extends ListStore { - - public ExtendedListStore(ModelKeyProvider keyProvider) { - super(keyProvider); - } - - public void applyFilters() - { - super.applyFilters(); - } - - } - - public void gridReload(){ - grid.getLoader().load(); - } - - protected boolean select(TemplateData item, String searchTerm) { - if (item.getName()!=null && item.getName().toLowerCase().contains(searchTerm.toLowerCase())) return true; - if (item.getCategory()!=null &&item.getCategory().toLowerCase().contains(searchTerm.toLowerCase())) return true; - if (item.getAgency()!=null &&item.getAgency().toLowerCase().contains(searchTerm.toLowerCase())) return true; - if (item.getDescription()!=null && item.getDescription().toLowerCase().contains(searchTerm.toLowerCase())) return true; - return false; - } - -} diff --git a/src/main/java/org/gcube/portlets/user/td/tablewidget/client/template/TemplateDataProperties.java b/src/main/java/org/gcube/portlets/user/td/tablewidget/client/template/TemplateDataProperties.java deleted file mode 100644 index 52333d6..0000000 --- a/src/main/java/org/gcube/portlets/user/td/tablewidget/client/template/TemplateDataProperties.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.gcube.portlets.user.td.tablewidget.client.template; - - - -import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateData; - -import com.google.gwt.editor.client.Editor.Path; -import com.sencha.gxt.core.client.ValueProvider; -import com.sencha.gxt.data.shared.ModelKeyProvider; -import com.sencha.gxt.data.shared.PropertyAccess; - -public interface TemplateDataProperties extends PropertyAccess { - - @Path("id") - ModelKeyProvider id(); - - ValueProvider name(); - ValueProvider agency(); - ValueProvider description(); - ValueProvider category(); - - -} - diff --git a/src/main/java/org/gcube/portlets/user/td/tablewidget/client/template/TemplateDeleteDialog.java b/src/main/java/org/gcube/portlets/user/td/tablewidget/client/template/TemplateDeleteDialog.java deleted file mode 100644 index 287eb95..0000000 --- a/src/main/java/org/gcube/portlets/user/td/tablewidget/client/template/TemplateDeleteDialog.java +++ /dev/null @@ -1,96 +0,0 @@ -package org.gcube.portlets.user.td.tablewidget.client.template; - -import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync; -import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateDeleteSession; -import org.gcube.portlets.user.td.tablewidget.client.resources.ResourceBundle; -import org.gcube.portlets.user.td.tablewidget.client.util.UtilsGXT3; - -import com.allen_sauer.gwt.log.client.Log; -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.google.web.bindery.event.shared.EventBus; -import com.sencha.gxt.widget.core.client.Window; -import com.sencha.gxt.widget.core.client.event.SelectEvent; -import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler; - - -/** - * - * @author "Giancarlo Panichi" - * g.panichi@isti.cnr.it - * - */ -public class TemplateDeleteDialog extends Window { - protected String WIDTH = "650px"; - protected String HEIGHT = "530px"; - protected TemplateDeleteSession templateDeleteSession; - protected EventBus eventBus; - - public TemplateDeleteDialog(EventBus eventBus) { - this.eventBus=eventBus; - initWindow(); - - TemplateDeletePanel templateDeletePanel= new TemplateDeletePanel(this, eventBus); - add(templateDeletePanel); - } - - protected void initWindow() { - setWidth(WIDTH); - setHeight(HEIGHT); - setBodyBorder(false); - setResizable(false); - setHeadingText("Delete Template"); - setClosable(true); - setModal(true); - forceLayoutOnResize = true; - getHeader().setIcon(ResourceBundle.INSTANCE.templateDelete()); - - } - - /** - * {@inheritDoc} - */ - @Override - protected void initTools() { - super.initTools(); - - closeBtn.addSelectHandler(new SelectHandler() { - - - public void onSelect(SelectEvent event) { - close(); - } - }); - - } - - protected void close (){ - hide(); - } - - - protected void templatesDelete(final TemplateDeleteSession templateDeleteSession){ - this.templateDeleteSession=templateDeleteSession; - - TDGWTServiceAsync.INSTANCE.startTemplateDelete(templateDeleteSession, - new AsyncCallback() { - public void onFailure(Throwable caught) { - Log.debug("Delete Template Error: " - + caught.getLocalizedMessage()); - UtilsGXT3.alert("Apply Template Error ", - "Error in invocation of delete template operation!"); - - } - - public void onSuccess(Void result) { - UtilsGXT3.info("Delete Template", - "Template deleted!"); - close(); - } - - }); - - - } - - -} diff --git a/src/main/java/org/gcube/portlets/user/td/tablewidget/client/template/TemplateDeletePanel.java b/src/main/java/org/gcube/portlets/user/td/tablewidget/client/template/TemplateDeletePanel.java deleted file mode 100644 index 61c231c..0000000 --- a/src/main/java/org/gcube/portlets/user/td/tablewidget/client/template/TemplateDeletePanel.java +++ /dev/null @@ -1,341 +0,0 @@ -package org.gcube.portlets.user.td.tablewidget.client.template; - -import java.util.ArrayList; -import java.util.List; - -import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync; -import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateData; -import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateDeleteSession; -import org.gcube.portlets.user.td.tablewidget.client.resources.ResourceBundle; -import org.gcube.portlets.user.td.tablewidget.client.util.UtilsGXT3; - -import com.allen_sauer.gwt.log.client.Log; -import com.google.gwt.core.client.GWT; -import com.google.gwt.core.client.Scheduler; -import com.google.gwt.core.client.Scheduler.ScheduledCommand; -import com.google.gwt.event.dom.client.KeyUpEvent; -import com.google.gwt.event.dom.client.KeyUpHandler; -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.google.web.bindery.event.shared.EventBus; -import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign; -import com.sencha.gxt.core.client.IdentityValueProvider; -import com.sencha.gxt.core.client.Style.SelectionMode; -import com.sencha.gxt.core.client.resources.ThemeStyles; -import com.sencha.gxt.core.client.util.Margins; -import com.sencha.gxt.data.client.loader.RpcProxy; -import com.sencha.gxt.data.shared.ListStore; -import com.sencha.gxt.data.shared.ModelKeyProvider; -import com.sencha.gxt.data.shared.Store; -import com.sencha.gxt.data.shared.Store.StoreFilter; -import com.sencha.gxt.data.shared.loader.ListLoadConfig; -import com.sencha.gxt.data.shared.loader.ListLoadResult; -import com.sencha.gxt.data.shared.loader.ListLoadResultBean; -import com.sencha.gxt.data.shared.loader.ListLoader; -import com.sencha.gxt.data.shared.loader.LoadResultListStoreBinding; -import com.sencha.gxt.widget.core.client.FramedPanel; -import com.sencha.gxt.widget.core.client.button.TextButton; -import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData; -import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutPack; -import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer; -import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer.HBoxLayoutAlign; -import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer; -import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData; -import com.sencha.gxt.widget.core.client.event.SelectEvent; -import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler; -import com.sencha.gxt.widget.core.client.form.TextField; -import com.sencha.gxt.widget.core.client.grid.CheckBoxSelectionModel; -import com.sencha.gxt.widget.core.client.grid.ColumnConfig; -import com.sencha.gxt.widget.core.client.grid.ColumnModel; -import com.sencha.gxt.widget.core.client.grid.Grid; -import com.sencha.gxt.widget.core.client.toolbar.LabelToolItem; -import com.sencha.gxt.widget.core.client.toolbar.ToolBar; - -public class TemplateDeletePanel extends FramedPanel { - protected String WIDTH = "560px"; - protected String HEIGHT = "520px"; - protected EventBus eventBus; - protected TemplateDeleteDialog parent; - protected TemplateDeleteSession templateDeleteSession; - - private TextButton btnDelete; - private TextButton btnClose; - - protected ListLoader> loader; - protected Grid grid; - protected ExtendedListStore store; - - public TemplateDeletePanel(TemplateDeleteDialog parent, - EventBus eventBus) { - this.parent = parent; - Log.debug("TemplateDeletePanel"); - setWidth(WIDTH); - setHeight(HEIGHT); - setHeaderVisible(false); - setBodyBorder(false); - this.eventBus = eventBus; - - create(); - - } - - protected void create() { - ToolBar toolBarHead = new ToolBar(); - toolBarHead.add(new LabelToolItem("Search: ")); - final TextField searchField = new TextField(); - toolBarHead.add(searchField); - - TextButton btnReload = new TextButton(); - //btnReload.setText("Reload"); - btnReload.setIcon(ResourceBundle.INSTANCE.refresh()); - btnReload.setToolTip("Reload"); - toolBarHead.add(btnReload); - - - - IdentityValueProvider identity = new IdentityValueProvider(); - CheckBoxSelectionModel sm = new CheckBoxSelectionModel( - identity); - - TemplateDataProperties props = GWT.create(TemplateDataProperties.class); - - ColumnConfig nameCol = new ColumnConfig( - props.name(), 120, "Name"); - ColumnConfig categoryCol = new ColumnConfig( - props.category(), 60, "Category"); - - - ColumnConfig agencyCol = new ColumnConfig( - props.agency(), 100, "Agency"); - - ColumnConfig descriptionCol = new ColumnConfig( - props.description(), 120, "Description"); - - List> l = new ArrayList>(); - l.add(nameCol); - l.add(categoryCol); - l.add(agencyCol); - l.add(descriptionCol); - - ColumnModel cm = new ColumnModel(l); - - store = new ExtendedListStore(props.id()); - - searchField.addKeyUpHandler(new KeyUpHandler() { - - public void onKeyUp(KeyUpEvent event) { - Log.trace("searchTerm: "+searchField.getCurrentValue()); - store.applyFilters(); - } - }); - - store.addFilter(new StoreFilter() { - - @Override - public boolean select(Store store, - TemplateData parent, TemplateData item) { - String searchTerm = searchField.getCurrentValue(); - if (searchTerm == null) return true; - return TemplateDeletePanel.this.select(item, searchTerm); - } - }); - - store.setEnableFilters(true); - - - RpcProxy> proxy = new RpcProxy>() { - - public void load(ListLoadConfig loadConfig, - final AsyncCallback> callback) { - loadData(loadConfig, callback); - } - }; - loader = new ListLoader>( - proxy); - - loader.setRemoteSort(false); - loader.addLoadHandler(new LoadResultListStoreBinding>( - store) { - }); - - SelectHandler sh = new SelectHandler() { - public void onSelect(SelectEvent event) { - loader.load(); - } - }; - - btnReload.addSelectHandler(sh); - - grid = new Grid(store, cm) { - @Override - protected void onAfterFirstAttach() { - super.onAfterFirstAttach(); - Scheduler.get().scheduleDeferred(new ScheduledCommand() { - - public void execute() { - loader.load(); - } - }); - } - }; - - sm.setSelectionMode(SelectionMode.MULTI); - grid.setLoader(loader); - grid.setSelectionModel(sm); - grid.setHeight("384px"); - grid.getView().setStripeRows(true); - grid.getView().setColumnLines(true); - grid.getView().setAutoFill(true); - grid.setBorders(false); - grid.setLoadMask(true); - grid.setColumnReordering(true); - grid.setColumnResize(true); - grid.getView().setAutoExpandColumn(descriptionCol); - - ToolBar toolBar = new ToolBar(); - toolBar.add(grid); - toolBar.addStyleName(ThemeStyles.getStyle().borderTop()); - toolBar.getElement().getStyle().setProperty("borderBottom", "none"); - - btnDelete = new TextButton("Delete"); - btnDelete.setIcon(ResourceBundle.INSTANCE.templateDelete()); - btnDelete.setIconAlign(IconAlign.RIGHT); - btnDelete.setTitle("Delete Template"); - btnDelete.addSelectHandler(new SelectHandler() { - - public void onSelect(SelectEvent event) { - Log.debug("Pressed Deletee"); - delete(); - - } - }); - - btnClose = new TextButton("Close"); - btnClose.setIcon(ResourceBundle.INSTANCE.close()); - btnClose.setIconAlign(IconAlign.RIGHT); - btnClose.setTitle("Cancel filter"); - btnClose.addSelectHandler(new SelectHandler() { - - public void onSelect(SelectEvent event) { - Log.debug("Pressed Close"); - close(); - } - }); - - HBoxLayoutContainer flowButton = new HBoxLayoutContainer(); - flowButton.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE); - flowButton.setPack(BoxLayoutPack.CENTER); - - flowButton.add(btnDelete, new BoxLayoutData(new Margins(2, 4, 2, 4))); - flowButton.add(btnClose, new BoxLayoutData(new Margins(2, 4, 2, 4))); - - VerticalLayoutContainer v = new VerticalLayoutContainer(); - v.add(toolBarHead, new VerticalLayoutData(1, -1, new Margins(0))); - v.add(grid, new VerticalLayoutData(-1, -1, new Margins(0))); - v.add(toolBar, new VerticalLayoutData(1, 25, new Margins(0))); - v.add(flowButton, new VerticalLayoutData(-1, 36, - new Margins(5, 2, 5, 2))); - add(v); - - } - - protected void loadData(ListLoadConfig loadConfig, - final AsyncCallback> callback) { - - TDGWTServiceAsync.INSTANCE - .getTemplates(new AsyncCallback>() { - - public void onFailure(Throwable caught) { - Log.error("load templates failure:" - + caught.getLocalizedMessage()); - UtilsGXT3.alert("Error retrieving templates", - "Error retrieving templates"); - callback.onFailure(caught); - } - - public void onSuccess(ArrayList result) { - Log.trace("loaded " + result.size() + " Occurences"); - callback.onSuccess(new ListLoadResultBean( - result)); - - } - - }); - - } - - - - - - /*protected void setMenu() { - Menu contextMenu = new Menu(); - - MenuItem deleteTemplateItem = new MenuItem("Delete"); - deleteTemplateItem.setId("DeleteTemplate"); - deleteTemplateItem.setIcon(ResourceBundle.INSTANCE.removeTemplate()); - deleteTemplateItem.addSelectionHandler(new SelectionHandler() { - - @Override - public void onSelection(SelectionEvent event) { - Log.debug("Delete Template"); - TemplateData templateDesc = getSelectedItem(); - - } - }); - - grid.setContextMenu(contextMenu); - }*/ - - protected ArrayList getSelectedItem() { - ArrayList templates=new ArrayList(); - for(TemplateData template:grid.getSelectionModel().getSelectedItems()){ - templates.add(template); - } - return templates; - } - - protected void delete() { - templateDeleteSession = new TemplateDeleteSession(); - ArrayList templates=getSelectedItem(); - if(templates==null|| templates.size()==0){ - UtilsGXT3.info("Attention", - "Select the template to be deleted"); - } else { - templateDeleteSession.setTemplates(getSelectedItem()); - Log.debug("templateDeleteSession: " + templateDeleteSession); - parent.templatesDelete(templateDeleteSession); - - } - - } - - protected void close() { - parent.close(); - } - - protected class ExtendedListStore extends ListStore { - - public ExtendedListStore(ModelKeyProvider keyProvider) { - super(keyProvider); - } - - public void applyFilters() - { - super.applyFilters(); - } - - } - - public void gridReload(){ - grid.getLoader().load(); - } - - protected boolean select(TemplateData item, String searchTerm) { - if (item.getName()!=null && item.getName().toLowerCase().contains(searchTerm.toLowerCase())) return true; - if (item.getCategory()!=null &&item.getCategory().toLowerCase().contains(searchTerm.toLowerCase())) return true; - if (item.getAgency()!=null &&item.getAgency().toLowerCase().contains(searchTerm.toLowerCase())) return true; - if (item.getDescription()!=null && item.getDescription().toLowerCase().contains(searchTerm.toLowerCase())) return true; - return false; - } - -}