You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
133 lines
4.0 KiB
Java
133 lines
4.0 KiB
Java
package org.gcube.portlets.user.accountingdashboard.client.application.mainarea.filter;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.Date;
|
|
import java.util.logging.Level;
|
|
import java.util.logging.Logger;
|
|
|
|
import javax.inject.Inject;
|
|
|
|
import org.gcube.portlets.user.accountingdashboard.client.application.mainarea.filter.scopetree.ScopeTreeModel;
|
|
import org.gcube.portlets.user.accountingdashboard.client.resources.AppResources;
|
|
import org.gcube.portlets.user.accountingdashboard.client.resources.ScopeTreeResources;
|
|
import org.gcube.portlets.user.accountingdashboard.shared.data.ScopeData;
|
|
|
|
import com.github.gwtbootstrap.client.ui.ListBox;
|
|
import com.google.gwt.core.client.GWT;
|
|
import com.google.gwt.i18n.client.DateTimeFormat;
|
|
import com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat;
|
|
import com.google.gwt.i18n.client.LocaleInfo;
|
|
import com.google.gwt.uibinder.client.UiBinder;
|
|
import com.google.gwt.uibinder.client.UiField;
|
|
import com.google.gwt.user.cellview.client.CellTree;
|
|
import com.google.gwt.user.cellview.client.CellTree.Resources;
|
|
import com.google.gwt.user.client.ui.HTMLPanel;
|
|
import com.google.gwt.user.client.ui.Widget;
|
|
import com.google.gwt.view.client.ListDataProvider;
|
|
import com.gwtplatform.mvp.client.ViewWithUiHandlers;
|
|
|
|
/**
|
|
*
|
|
* @author Giancarlo Panichi
|
|
*
|
|
*/
|
|
public class FilterAreaView extends ViewWithUiHandlers<FilterAreaPresenter>
|
|
implements FilterAreaPresenter.FilterAreaView {
|
|
|
|
private static Logger logger = java.util.logging.Logger.getLogger("");
|
|
|
|
interface Binder extends UiBinder<Widget, FilterAreaView> {
|
|
}
|
|
|
|
@UiField
|
|
HTMLPanel periodPanel;
|
|
|
|
@UiField
|
|
HTMLPanel explorePanel;
|
|
|
|
@UiField(provided = true)
|
|
ListBox yearStart;
|
|
|
|
@UiField(provided = true)
|
|
ListBox monthStart;
|
|
|
|
@UiField(provided = true)
|
|
ListBox yearEnd;
|
|
|
|
@UiField(provided = true)
|
|
ListBox monthEnd;
|
|
|
|
@UiField(provided = true)
|
|
CellTree scopeTree;
|
|
|
|
|
|
private AppResources resources;
|
|
|
|
@Inject
|
|
FilterAreaView(Binder uiBinder, AppResources resources) {
|
|
this.resources = resources;
|
|
init();
|
|
initWidget(uiBinder.createAndBindUi(this));
|
|
|
|
}
|
|
|
|
private void init() {
|
|
yearStart = new ListBox();
|
|
yearStart.setMultipleSelect(false);
|
|
|
|
yearEnd = new ListBox();
|
|
yearEnd.setMultipleSelect(false);
|
|
|
|
|
|
Date now=new Date();
|
|
String currentYear=DateTimeFormat.getFormat(PredefinedFormat.YEAR).format(now);
|
|
logger.log(Level.FINE, "Current year: " + currentYear);
|
|
int year=Integer.parseInt(currentYear);
|
|
for(int i=2015; i<=year;i++){
|
|
yearStart.addItem(String.valueOf(i));
|
|
yearEnd.addItem(String.valueOf(i));
|
|
}
|
|
|
|
|
|
// returns a String array with localized names of the months
|
|
String[] months = LocaleInfo.getCurrentLocale().getDateTimeFormatInfo().monthsFull();
|
|
logger.log(Level.FINE, "Months: " + months.length);
|
|
monthStart = new ListBox();
|
|
monthStart.setMultipleSelect(false);
|
|
|
|
monthEnd = new ListBox();
|
|
monthEnd.setMultipleSelect(false);
|
|
|
|
for (int i = 0; i < months.length; i++) {
|
|
monthStart.addItem(months[i]);
|
|
monthEnd.addItem(months[i]);
|
|
}
|
|
|
|
ScopeData children1=new ScopeData("1","children1",null);
|
|
ScopeData children3=new ScopeData("3","children3",null);
|
|
ScopeData children4=new ScopeData("4","children4",null);
|
|
|
|
|
|
|
|
ArrayList<ScopeData> children2List=new ArrayList<>();
|
|
children2List.add(children3);
|
|
children2List.add(children4);
|
|
ScopeData children2=new ScopeData("2","children2",children2List);
|
|
|
|
ArrayList<ScopeData> rootList=new ArrayList<>();
|
|
rootList.add(children1);
|
|
rootList.add(children2);
|
|
ScopeData root=new ScopeData("0","root",rootList);
|
|
|
|
ArrayList<ScopeData> scopeDataList=new ArrayList<>();
|
|
scopeDataList.add(root);
|
|
|
|
ListDataProvider<ScopeData> dataProvider = new ListDataProvider<ScopeData>(scopeDataList);
|
|
ScopeTreeModel scopeTreeModel=new ScopeTreeModel(dataProvider);
|
|
|
|
ScopeTreeResources scopeTreeResources = GWT.create(ScopeTreeResources.class);
|
|
scopeTree=new CellTree(scopeTreeModel, null,scopeTreeResources);
|
|
}
|
|
|
|
}
|