List of usage examples for com.google.gwt.user.cellview.client CellTable CellTable
public CellTable(int pageSize, ProvidesKey<T> keyProvider)
From source file:eu.riscoss.client.rdr.ContactCell.java
License:Apache License
public void onModuleLoad() { RiscossJsonClient.listEntities(new JsonCallback() { @Override/*from w w w . j a v a2 s . c o m*/ public void onFailure(Method method, Throwable exception) { // TODO Auto-generated method stub } @Override public void onSuccess(Method method, JSONValue response) { listEntities = new ArrayList<>(); for (int i = 0; i < response.isArray().size(); ++i) { if (!response.isArray().get(i).isObject().get("name").isString().stringValue().equals("-")) listEntities.add(response.isArray().get(i).isObject()); } cellList = new CellTable<JSONObject>(15, (Resources) GWT.create(TableResources.class)); cellList.setStyleName("list"); cellList.setPageSize(30); cellList.setKeyboardPagingPolicy(KeyboardPagingPolicy.INCREASE_RANGE); cellList.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.BOUND_TO_SELECTION); final SingleSelectionModel<JSONObject> selectionModel = new SingleSelectionModel<JSONObject>(); cellList.setSelectionModel(selectionModel); selectionModel.addSelectionChangeHandler(new Handler() { @Override public void onSelectionChange(SelectionChangeEvent arg0) { ppg.setSelectedEntity( selectionModel.getSelectedObject().get("name").isString().stringValue()); } }); Column<JSONObject, String> t = new Column<JSONObject, String>(new TextCell()) { @Override public String getValue(JSONObject arg0) { return arg0.get("name").isString().stringValue(); } }; Column<JSONObject, String> t2 = new Column<JSONObject, String>(new TextCell()) { @Override public String getValue(JSONObject arg0) { return arg0.get("layer").isString().stringValue(); } }; cellList.addColumn(t, "Entity"); cellList.addColumn(t2, "Layer"); cellList.setWidth("100%"); if (listEntities.size() > 0) cellList.setRowData(0, listEntities); else { listEntities.add(new JSONObject()); cellList.setRowData(0, listEntities); listEntities.remove(0); } cellList.setStyleName("table"); dataProvider = new ListDataProvider<JSONObject>(); dataProvider.addDataDisplay(cellList); for (int i = 0; i < listEntities.size(); i++) { dataProvider.getList().add(listEntities.get(i)); } pager = new SimplePager(); pager.setDisplay(cellList); ppg = new EntityDataBox(); dock.setWidth("100%"); dock.add(cellList, DockPanel.CENTER); dock.add(ppg.asWidget(), DockPanel.EAST); dock.setCellWidth(ppg.asWidget(), "60%"); mainView.setStyleName("mainViewLayer"); //mainView.setWidth("100%"); leftPanel.setStyleName("leftPanelLayer"); leftPanel.setWidth("400px"); //leftPanel.setHeight("100%"); rightPanel.setStyleName("rightPanelLayer"); page.setWidth("100%"); Label title = new Label("Risk Data Repository"); title.setStyleName("title"); page.add(title); leftPanel.add(cellList); leftPanel.add(pager); rightPanel.add(ppg); rightPanel.setWidth("90%"); mainView.add(leftPanel); mainView.add(rightPanel); page.add(mainView); RootPanel.get().add(page); } }); }
From source file:eu.riscoss.client.riskanalysis.EntitySelectionPanel.java
License:Apache License
public EntitySelectionPanel() { exportJS();// w w w. ja va 2 s. c o m table = new CellTable<EntityInfo>(15, (Resources) GWT.create(TableResources.class)); table.addColumn(new Column<EntityInfo, SafeHtml>(new SafeHtmlCell()) { @Override public SafeHtml getValue(EntityInfo object) { return new LinkHtml(object.getName(), "javascript:setSelectedEntity(\"" + object.getName() + "\")"); }; }, "Entities"); table.addColumn(new Column<EntityInfo, SafeHtml>(new SafeHtmlCell()) { @Override public SafeHtml getValue(EntityInfo object) { return new HtmlString("" + object.getLayer()); }; }, "Layer"); entityDataProvider = new ListDataProvider<EntityInfo>(); entityDataProvider.addDataDisplay(table); SimplePager pager = new SimplePager(); pager.setDisplay(table); tablePanel.add(table); tablePanel.add(pager); }
From source file:eu.riscoss.client.riskanalysis.RASSelectionPanel.java
License:Apache License
public RASSelectionPanel() { exportJS();//from www. ja v a2 s . co m table = new CellTable<JRASInfo>(15, (Resources) GWT.create(TableResources.class)); table.addColumn(new Column<JRASInfo, SafeHtml>(new SafeHtmlCell()) { @Override public SafeHtml getValue(JRASInfo object) { return new LinkHtml(object.getName(), "javascript:setSelectedRAS(\"" + object.getId() + "\")"); }; }, "Available Risk Analysis Sessions"); Column<JRASInfo, String> c = new Column<JRASInfo, String>(new ButtonCell()) { @Override public String getValue(JRASInfo object) { return "Delete"; } }; c.setFieldUpdater(new FieldUpdater<JRASInfo, String>() { @Override public void update(int index, JRASInfo object, String value) { deleteRAS(object); } }); table.addColumn(c, ""); dataProvider = new ListDataProvider<JRASInfo>(); dataProvider.addDataDisplay(table); Button button = new Button("Create New"); button.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { onNewSessionRequested(); } }); SimplePager pager = new SimplePager(); pager.setDisplay(table); VerticalPanel tablePanel = new VerticalPanel(); tablePanel.add(table); tablePanel.add(pager); panel.add(button, DockPanel.NORTH); panel.add(tablePanel, DockPanel.CENTER); }
From source file:eu.riscoss.client.riskanalysis.RCSelectionPanel.java
License:Apache License
public RCSelectionPanel() { exportJS();/*from w w w . j a v a 2 s. c o m*/ table = new CellTable<ModelInfo>(15, (Resources) GWT.create(TableResources.class)); table.addColumn(new Column<ModelInfo, SafeHtml>(new SafeHtmlCell()) { @Override public SafeHtml getValue(ModelInfo object) { return new LinkHtml(object.getName(), "javascript:setSelectedRC(\"" + object.getName() + "\")"); }; }, "Available Risk Configurations"); modelDataProvider = new ListDataProvider<ModelInfo>(); modelDataProvider.addDataDisplay(table); SimplePager pager = new SimplePager(); pager.setDisplay(table); tablePanel.add(table); tablePanel.add(pager); }
From source file:eu.riscoss.client.riskanalysis.RiskAnalysisModule.java
License:Apache License
public void onModuleLoad() { exportJS();//from w ww. j a va 2 s . c om entityTable = new CellTable<EntityInfo>(15, (Resources) GWT.create(TableResources.class)); entityTable.setStyleName("leftPanel"); modelTable = new CellTable<ModelInfo>(15, (Resources) GWT.create(TableResources.class)); modelTable.setStyleName("rightPanel"); entityTable.addColumn(new Column<EntityInfo, SafeHtml>(new SafeHtmlCell()) { @Override public SafeHtml getValue(EntityInfo object) { return new LinkHtml(object.getName(), "javascript:setSelectedEntity(\"" + object.getName() + "\")"); }; }, "Entity"); modelTable.addColumn(new Column<ModelInfo, SafeHtml>(new SafeHtmlCell()) { @Override public SafeHtml getValue(ModelInfo object) { return new LinkHtml(object.getName(), "javascript:setSelectedRC(\"" + object.getName() + "\")"); }; }, "Risk Configuration"); // entityDataProvider = new ListDataProvider<EntityInfo>(); entityDataProvider.addDataDisplay(entityTable); modelDataProvider = new ListDataProvider<ModelInfo>(); modelDataProvider.addDataDisplay(modelTable); Grid grid = new Grid(3, 2); Button btn = new Button("RUN ANALYSIS", new ClickHandler() { public void onClick(ClickEvent event) { runAnalysis(); } }); btn.setStyleName("button"); Label selEnt = new Label("Selected entity:"); selEnt.setStyleName("tag"); grid.setWidget(0, 0, selEnt); Label selRc = new Label("Selected risk configuration:"); selRc.setStyleName("tag"); grid.setWidget(1, 0, selRc); entityLabel.setStyleName("tagSelected"); grid.setWidget(0, 1, entityLabel); rcLabel.setStyleName("tagSelected"); grid.setWidget(1, 1, rcLabel); grid.setWidget(2, 1, btn); grid.setStyleName("gridRisk"); mainView.setStyleName("mainViewLayer"); mainView.setWidth("100%"); page.setWidth("100%"); Label title = new Label("One-layer Analysis"); title.setStyleName("title"); page.add(title); entityTable.setWidth("100%"); mainView.add(entityTable); modelTable.setWidth("50%"); mainView.add(modelTable); page.add(mainView); page.add(grid); RootPanel.get().add(page); loadEntities(); }
From source file:eu.riscoss.client.riskconfs.RiskConfsModule.java
License:Apache License
private void loadRiskConfsTable(JSONValue response) { tablePanel.clear();/*from w ww. ja va2 s. c o m*/ table = new CellTable<RCInfo>(15, (Resources) GWT.create(TableResources.class)); table.addColumn(new Column<RCInfo, SafeHtml>(new SafeHtmlCell()) { @Override public SafeHtml getValue(RCInfo object) { return new LinkHtml(object.name, "javascript:selectRC(\"" + object.name + "\")"); }; }, "Risk Configuration"); table.setWidth("100%"); dataProvider = new ListDataProvider<RCInfo>(); dataProvider.addDataDisplay(table); GWT.log(response.toString()); if (response.isArray() != null) { for (int i = 0; i < response.isArray().size(); i++) { JSONObject o = (JSONObject) response.isArray().get(i); dataProvider.getList().add(new RCInfo(o.get("name").isString().stringValue())); } } SimplePager pager = new SimplePager(); pager.setDisplay(table); tablePanel.add(table); tablePanel.add(pager); tablePanel.setWidth("100%"); spTable.setWidget(tablePanel); }
From source file:n3phele.client.view.AccountListView.java
License:Open Source License
public AccountListView() { super(new MenuItem(N3phele.n3pheleResource.accountIcon(), "Accounts", null), new MenuItem(N3phele.n3pheleResource.accountAddIcon(), "create a new account", "account:null")); if (resource == null) resource = GWT.create(ClickableCellTableResource.class); cellTable = new CellTable<Account>(15, resource); cellTable.setSize("455px", ""); TextColumn<Account> nameColumn = new TextColumn<Account>() { @Override/*from w ww . j a v a 2 s.c om*/ public String getValue(Account item) { String result = ""; if (item != null) return item.getName(); return result; } }; cellTable.addColumn(nameColumn, "Name"); TextColumn<Account> descriptionColumn = new TextColumn<Account>() { @Override public String getValue(Account item) { String result = ""; if (item != null) return item.getDescription(); return result; } }; cellTable.addColumn(descriptionColumn, "Description"); TextColumn<Account> cloudColumn = new TextColumn<Account>() { @Override public String getValue(Account item) { String result = ""; if (item != null) { result = item.getCloudName(); // String s= item.getCloud(); // if(cloudMap.containsKey(s)) // return cloudMap.get(s); // else // return s; } return result; } }; cellTable.addColumn(cloudColumn, "Cloud"); // Add a selection model to handle user selection. final SingleSelectionModel<Account> selectionModel = new SingleSelectionModel<Account>(); cellTable.setSelectionModel(selectionModel); selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { public void onSelectionChange(SelectionChangeEvent event) { Account selected = selectionModel.getSelectedObject(); if (selected != null) { if (accountListActivity != null) { accountListActivity.onSelect(selected); } } } }); Column<Account, Account> cancelColumn = new Column<Account, Account>( new CancelButtonCell<Account>(new Delegate<Account>() { @Override public void execute(Account value) { if (value != null) { cellTable.getSelectionModel().setSelected(value, false); getDialog(value).show(); } } }, "delete Account")) { @Override public Account getValue(Account object) { return object; } }; cellTable.addColumn(cancelColumn); cellTable.setColumnWidth(cancelColumn, "26px"); cellTable.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED); this.add(cellTable); }
From source file:n3phele.client.view.ProcessView.java
License:Open Source License
public ProcessView() { super(new MenuItem(N3phele.n3pheleResource.activityIcon(), "Activity", null)); table = new FlexTable(); table.setCellPadding(2);//from w w w . j a v a2 s . c om this.add(table); table.setWidth("100%"); Label lblNewLabel_4 = new Label("name"); table.setWidget(0, 0, lblNewLabel_4); name = new Label(""); table.setWidget(0, 1, name); iconStatus = new CellWidget<IconText>(new IconTextCell<IconText>(32, 32, 15)); table.setWidget(0, 2, iconStatus); table.getColumnFormatter().setWidth(0, "60px"); table.getColumnFormatter().setWidth(2, "170px"); Label lblNewLabel = new Label("running"); table.setWidget(1, 0, lblNewLabel); command = new Hyperlink("", ""); table.setWidget(1, 1, command); table.getFlexCellFormatter().setColSpan(1, 1, 2); // description = new Label("-description-"); // table.setWidget(1, 2, description); Label lblNewLabel_3 = new Label("started"); table.setWidget(2, 0, lblNewLabel_3); startdate = new CellWidget<Date>( new DateCell(DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_TIME_SHORT))); table.setWidget(2, 1, startdate); //table.getFlexCellFormatter().setColSpan(2, 1, 2); Label lblNewLabel_6 = new Label("completed"); table.setWidget(3, 0, lblNewLabel_6); completedate = new CellWidget<Date>( new DateCell(DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_TIME_SHORT))); table.setWidget(3, 1, completedate); //table.getFlexCellFormatter().setColSpan(3, 1, 2); duration = new Label(".duration"); table.setWidget(3, 2, duration); if (resource == null) resource = GWT.create(NarrativeListCellTableResource.class); narrativeTable = new CellTable<Narrative>(15, resource); this.add(narrativeTable); narrativeTable.setWidth("100%", true); final Map<String, ImageResource> mapper = new HashMap<String, ImageResource>(); mapper.put("info", N3phele.n3pheleResource.narrativeInfo()); mapper.put("warning", N3phele.n3pheleResource.narrativeWarning()); mapper.put("error", N3phele.n3pheleResource.narrativeError()); state = new Column<Narrative, ImageResource>(new ImageResourceCell()) { @Override public ImageResource getValue(Narrative object) { return mapper.get(object.getState()); } }; state.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); state.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); narrativeTable.addColumn(state); narrativeTable.setColumnWidth(state, "8%"); Column<Narrative, Date> date = new Column<Narrative, Date>( new DateCell(DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_TIME_SHORT))) { @Override public Date getValue(Narrative object) { return object.getStamp(); } }; narrativeTable.addColumn(date); narrativeTable.setColumnWidth(date, "15%"); Column<Narrative, Hyperlink> id = new Column<Narrative, Hyperlink>(new HyperlinkCell()) { @Override public Hyperlink getValue(Narrative object) { if (object == null) return null; String name = object.getTag(); String historyToken = presenter.getToken(object.getProcessUri()); return new Hyperlink(name, historyToken); } }; id.setFieldUpdater(new FieldUpdater<Narrative, Hyperlink>() { @Override public void update(int index, Narrative object, Hyperlink value) { ProcessView.this.narrativeTable.setFocus(false); } }); id.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); id.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); narrativeTable.addColumn(id); narrativeTable.setColumnWidth(id, "20%"); TextColumn<Narrative> msg = new TextColumn<Narrative>() { @Override public String getValue(Narrative object) { return object.getText(); } }; msg.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); msg.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); narrativeTable.addColumn(msg); narrativeTable.setColumnWidth(msg, "60%"); }
From source file:n3phele.client.view.ProgressView.java
License:Open Source License
public ProgressView() { super(new MenuItem(N3phele.n3pheleResource.activityIcon(), "Activity", null)); table = new FlexTable(); table.setCellPadding(2);/* ww w. j a v a 2 s .c o m*/ this.add(table); //table.setSize("478px", "260px"); Label lblNewLabel_4 = new Label("name"); table.setWidget(0, 0, lblNewLabel_4); name = new Label(""); table.setWidget(0, 1, name); iconStatus = new CellWidget<IconText>(new IconTextCell<IconText>(32, 32, 15)); // { // @Override // public IconText getValue(Progress progress) { // String status = progress.getStatus(); // ImageResource icon = statusVizualization.get(status); // if(icon != null) return new IconText(icon, progress.getName()); // return new IconText(getTemplate().statusBar(getPercentComplete(progress), barUrl ), progress.getName()); // make progress bar // } // }; table.setWidget(0, 2, iconStatus); Label lblNewLabel = new Label("running"); table.setWidget(1, 0, lblNewLabel); command = new Hyperlink("", ""); table.setWidget(1, 1, command); description = new Label("-description-"); table.setWidget(1, 2, description); Label lblNewLabel_3 = new Label("started"); table.setWidget(2, 0, lblNewLabel_3); startdate = new CellWidget<Date>( new DateCell(DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_TIME_SHORT))); table.setWidget(2, 1, startdate); table.getFlexCellFormatter().setColSpan(2, 1, 2); Label lblNewLabel_6 = new Label("completed"); table.setWidget(3, 0, lblNewLabel_6); completedate = new CellWidget<Date>( new DateCell(DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_TIME_SHORT))); table.setWidget(3, 1, completedate); table.getFlexCellFormatter().setColSpan(3, 1, 2); Label lblNewLabel_7 = new Label("estimated duration", true); table.setWidget(4, 0, lblNewLabel_7); duration = new Label(".duration"); table.setWidget(4, 1, duration); table.getFlexCellFormatter().setColSpan(4, 1, 2); if (resource == null) resource = GWT.create(NarrativeListCellTableResource.class); narrativeTable = new CellTable<Narrative>(15, resource); this.add(narrativeTable); narrativeTable.setWidth("100%", true); final Map<String, ImageResource> mapper = new HashMap<String, ImageResource>(); mapper.put("info", N3phele.n3pheleResource.narrativeInfo()); mapper.put("warning", N3phele.n3pheleResource.narrativeWarning()); mapper.put("error", N3phele.n3pheleResource.narrativeError()); state = new Column<Narrative, ImageResource>(new ImageResourceCell()) { @Override public ImageResource getValue(Narrative object) { return mapper.get(object.getState()); } }; state.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); state.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); narrativeTable.addColumn(state); narrativeTable.setColumnWidth(state, "8%"); Column<Narrative, Date> date = new Column<Narrative, Date>( new DateCell(DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_TIME_SHORT))) { @Override public Date getValue(Narrative object) { return object.getStamp(); } }; narrativeTable.addColumn(date); narrativeTable.setColumnWidth(date, "15%"); TextColumn<Narrative> id = new TextColumn<Narrative>() { @Override public String getValue(Narrative object) { return object.getId(); } }; id.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); id.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); narrativeTable.addColumn(id); narrativeTable.setColumnWidth(id, "20%"); TextColumn<Narrative> msg = new TextColumn<Narrative>() { @Override public String getValue(Narrative object) { return object.getText(); } }; msg.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); msg.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); narrativeTable.addColumn(msg); narrativeTable.setColumnWidth(msg, "60%"); }
From source file:n3phele.client.view.RepoListView.java
License:Open Source License
public RepoListView() { super(new MenuItem(N3phele.n3pheleResource.repositoryIcon(), "File Repositories", null), new MenuItem( N3phele.n3pheleResource.repositoryAddIcon(), "create a new repository", "repository:")); if (resource == null) resource = GWT.create(ClickableCellTableResource.class); cellTable = new CellTable<Repository>(15, resource); cellTable.setSize("455px", ""); //this.scrollPanel.add(this.cellTable); TextColumn<Repository> nameColumn = new TextColumn<Repository>() { @Override// www . j a va 2 s .c o m public String getValue(Repository item) { String result = ""; if (item != null) return item.getName(); return result; } }; cellTable.addColumn(nameColumn, "Name"); TextColumn<Repository> descriptionColumn = new TextColumn<Repository>() { @Override public String getValue(Repository item) { String result = ""; if (item != null) return item.getDescription(); return result; } }; cellTable.addColumn(descriptionColumn, "Description"); // Add a selection model to handle user selection. final SingleSelectionModel<Repository> selectionModel = new SingleSelectionModel<Repository>(); cellTable.setSelectionModel(selectionModel); selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { public void onSelectionChange(SelectionChangeEvent event) { Repository selected = selectionModel.getSelectedObject(); if (selected != null) { if (repositoryListActivity != null) { repositoryListActivity.onSelect(selected); } } } }); cellTable.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED); this.add(cellTable); Column<Repository, Repository> cancelColumn = new Column<Repository, Repository>( new CancelButtonCell<Repository>(new Delegate<Repository>() { @Override public void execute(Repository value) { if (value != null) { cellTable.getSelectionModel().setSelected(value, false); getDialog(value).show(); } } }, "remove repository")) { @Override public Repository getValue(Repository object) { return object; } }; cellTable.addColumn(cancelColumn); cellTable.setColumnWidth(cancelColumn, "26px"); }