List of usage examples for com.google.gwt.user.cellview.client Column setFieldUpdater
public void setFieldUpdater(FieldUpdater<T, C> fieldUpdater)
From source file:n3phele.client.view.AccountHyperlinkView.java
License:Open Source License
public AccountHyperlinkView(String uri) { super(new MenuItem(N3phele.n3pheleResource.accountIcon(), "Account", null), new MenuItem(N3phele.n3pheleResource.accountAddIcon(), "Account Edit", "account:" + uri)); if (resource == null) resource = GWT.create(DataGridResource.class); // TABLE/*from www .ja v a 2s.c om*/ table = new FlexTable(); table.setCellPadding(10); errorsOnPage = new ValidInputIndicatorWidget( "check for missing or invalid parameters marked with this icon", false); setTableData(); table.getFlexCellFormatter().setRowSpan(0, 1, 2); table.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE); table.getFlexCellFormatter().setVerticalAlignment(0, 1, HasVerticalAlignment.ALIGN_MIDDLE); table.getFlexCellFormatter().setVerticalAlignment(1, 0, HasVerticalAlignment.ALIGN_MIDDLE); table.getColumnFormatter().setWidth(0, "220px"); table.getColumnFormatter().setWidth(1, "290px"); table.setCellPadding(1); table.setCellSpacing(1); // DATAGRID dataGrid = new DataGrid<ActivityData>(15, resource); dataGrid.setSize("495px", "100px"); TextColumn<ActivityData> nameColumn = new TextColumn<ActivityData>() { @Override public String getValue(ActivityData item) { String result = ""; if (item != null) { result += item.getName(); } return result; } }; dataGrid.addColumn(nameColumn, "Name"); dataGrid.setColumnWidth(nameColumn, "130px"); // TODO: Working on Activity column Column<ActivityData, String> activityColumn = new Column<ActivityData, String>(new ClickableTextCell()) { @Override public String getValue(ActivityData item) { return item.getNameTop(); } }; activityColumn.setFieldUpdater(new FieldUpdater<ActivityData, String>() { @Override public void update(int index, ActivityData obj, String value) { presenter.onSelect(obj); } }); activityColumn.setCellStyleNames(N3phele.n3pheleResource.css().clickableTextCellEffect()); dataGrid.addColumn(activityColumn, "Activity"); dataGrid.setColumnWidth(activityColumn, "100px"); TextColumn<ActivityData> ageColumn = new TextColumn<ActivityData>() { @Override public String getValue(ActivityData item) { return item.getAge(); } }; dataGrid.addColumn(ageColumn, "Age"); dataGrid.setColumnWidth(ageColumn, "80px"); TextColumn<ActivityData> priceColumn = new TextColumn<ActivityData>() { @Override public String getValue(ActivityData item) { return item.getCost(); } }; dataGrid.addColumn(priceColumn, "Total Cost"); dataGrid.setColumnWidth(priceColumn, "75px"); // Add a selection model to handle user selection. final SingleSelectionModel<ActivityData> selectionModel = new SingleSelectionModel<ActivityData>(); dataGrid.setSelectionModel(selectionModel); selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { public void onSelectionChange(SelectionChangeEvent event) { selectionModel.getSelectedObject(); } }); Column<ActivityData, ActivityData> cancelColumn = new Column<ActivityData, ActivityData>( new CancelButtonCell<ActivityData>(new Delegate<ActivityData>() { @Override public void execute(ActivityData value) { if (value != null) { dataGrid.getSelectionModel().setSelected(value, false); getDialog(value).show(); } } }, "delete virtual machine")) { @Override public ActivityData getValue(ActivityData object) { return object; } }; cancelColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); dataGrid.addColumn(cancelColumn); dataGrid.setColumnWidth(cancelColumn, "50px"); // CALL onModuleLoad() chartPanel = get(); chartPanel.add(table); chartPanel.add(new SectionPanel("History")); chartPanel.add(historyTable); chartPanel.add(new SectionPanel("Active Machines")); chartPanel.add(vsTable); chartPanel = get(); setChartTableData(); onModuleLoad(); }
From source file:n3phele.client.view.CommandDetailView.java
License:Open Source License
public CellTable<TypedParameter> createParameterTable() { final ProvidesKey<TypedParameter> KEY_PROVIDER = new ProvidesKey<TypedParameter>() { public Object getKey(TypedParameter item) { return item.getName(); }// w ww. j a v a 2 s. c om }; final CellTable<TypedParameter> table; table = new CellTable<TypedParameter>(KEY_PROVIDER); table.setWidth("100%"); table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED); TextColumn<TypedParameter> descriptionColumn = new TextColumn<TypedParameter>() { @Override public String getValue(TypedParameter command) { String result = ""; if (command != null) return command.getDescription(); return result; } }; table.addColumn(descriptionColumn); this.parameterTextInputCell = new DisappearingTextInputCell(); this.parameterCheckboxCell = new DisappearingCheckBoxCell(); final ValidInputIndicatorCell valid = new ValidInputIndicatorCell(N3phele.n3pheleResource.inputErrorIcon()); HasCell<TypedParameter, ?> valueHasCell = new HasCell<TypedParameter, String>() { @Override public Cell<String> getCell() { return CommandDetailView.this.parameterTextInputCell; } @Override public FieldUpdater<TypedParameter, String> getFieldUpdater() { return new FieldUpdater<TypedParameter, String>() { // Needs to exist so that the cell level updater is invoked @Override public void update(int index, TypedParameter object, String value) { } }; } @Override public String getValue(TypedParameter object) { if (object != null) { if (!object.getType().equalsIgnoreCase("boolean")) { String result = object.getValue(); if (isNullOrBlank(result)) result = object.getDefaultValue(); if (result == null) result = ""; return result; } } return null; } }; HasCell<TypedParameter, ?> validHasCell = new HasCell<TypedParameter, String>() { @Override public Cell<String> getCell() { return valid; } @Override public FieldUpdater<TypedParameter, String> getFieldUpdater() { return null; } @Override public String getValue(TypedParameter object) { String errTooltip; errTooltip = errorMessageMap().get(object.getType()); if (checkParameterValue(object)) { return "-" + errTooltip; } else { return "+" + errTooltip; } } }; HasCell<TypedParameter, ?> booleanHasCell = new HasCell<TypedParameter, Boolean>() { @Override public Cell<Boolean> getCell() { return parameterCheckboxCell; } @Override public FieldUpdater<TypedParameter, Boolean> getFieldUpdater() { return new FieldUpdater<TypedParameter, Boolean>() { // Needs to exist so that the cell level updater is invoked @Override public void update(int index, TypedParameter object, Boolean value) { } }; } @Override public Boolean getValue(TypedParameter object) { if (object != null) { if (object.getType().equalsIgnoreCase("boolean")) { String result = object.getValue(); if (isNullOrBlank(result)) result = object.getDefaultValue(); return Boolean.valueOf(result); } } return null; } }; List<HasCell<TypedParameter, ?>> arg = new ArrayList<HasCell<TypedParameter, ?>>(2); arg.add(validHasCell); arg.add(valueHasCell); arg.add(booleanHasCell); Column<TypedParameter, TypedParameter> valueColumn = new Column<TypedParameter, TypedParameter>( new TypedPropertyComposite(arg)) { @Override public TypedParameter getValue(TypedParameter parameter) { return parameter; } }; valueColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); table.addColumn(valueColumn); table.setWidth("100%", true); table.setColumnWidth(valueColumn, "210px"); valueColumn.setFieldUpdater(new FieldUpdater<TypedParameter, TypedParameter>() { public void update(int index, final TypedParameter object, final TypedParameter value) { GWT.runAsync(new RunAsyncCallback() { @Override public void onSuccess() { updateRunButton(true); } @Override public void onFailure(Throwable reason) { // } }); } }); return table; }
From source file:n3phele.client.view.CommandDetailView.java
License:Open Source License
public CellTable<CloudProfile> createAccountTable(/*final SingleSelectionModel<ExtendedCloudProfile> selectionModel*/) { final SensitiveCheckBoxCell checkbox = new SensitiveCheckBoxCell(true, true); final ProvidesKey<CloudProfile> KEY_PROVIDER = new ProvidesKey<CloudProfile>() { public Object getKey(CloudProfile item) { return item.id(); }/* w ww .j av a2 s. c o m*/ }; final CellTable<CloudProfile> table = new CellTable<CloudProfile>(KEY_PROVIDER); table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED); Column<CloudProfile, Boolean> checkColumn = new Column<CloudProfile, Boolean>(checkbox) { @Override public Boolean getValue(CloudProfile profile) { return (profile.getId().equals(CommandDetailView.this.selectedProfile)) && (profile.getAccountUri().equals(CommandDetailView.this.selectedAccountURI)); } }; checkColumn.setFieldUpdater(new FieldUpdater<CloudProfile, Boolean>() { @Override public void update(int index, CloudProfile profile, Boolean value) { if (profile != null) { if (value) { CommandDetailView.this.selectedProfile = profile.getId(); CommandDetailView.this.selectedAccountURI = profile.getAccountUri(); } else { if (profile.getId().equals(CommandDetailView.this.selectedProfile)) { CommandDetailView.this.selectedProfile = null; CommandDetailView.this.selectedAccountURI = null; } } table.redraw(); String visible = value ? "-" : "+"; CommandDetailView.this.gotExecutionSelection.setValue( visible + CommandDetailView.this.gotExecutionSelection.getValue().substring(1)); updateRunButton(true); } else { checkbox.clearViewData(KEY_PROVIDER.getKey(profile)); table.redraw(); updateRunButton(false); CommandDetailView.this.gotExecutionSelection .setValue("+" + CommandDetailView.this.gotExecutionSelection.getValue().substring(1)); } } }); table.addColumn(checkColumn); TextColumn<CloudProfile> accountColumn = new TextColumn<CloudProfile>() { @Override public String getValue(CloudProfile profile) { String result = ""; if (profile != null) return profile.getAccountName(); return result; } }; table.addColumn(accountColumn); TextColumn<CloudProfile> nameColumn = new TextColumn<CloudProfile>() { @Override public String getValue(CloudProfile profile) { String result = ""; if (profile != null) { return profile.getCloudName(); } return result; } }; table.addColumn(nameColumn); TextColumn<CloudProfile> descriptionColumn = new TextColumn<CloudProfile>() { @Override public String getValue(CloudProfile profile) { if (profile != null) return profile.getDescription(); else return null; } }; table.addColumn(descriptionColumn); return table; }
From source file:n3phele.client.view.CommandListGridView.java
License:Open Source License
public CommandListGridView() { super(new MenuItem(N3phele.n3pheleResource.commandIcon(), "Commands", null)); String html = "<img style='border:none; vertical-align:bottom; margin:-2px; padding-right:2px;' width=20 height=20 src='" + N3phele.n3pheleResource.commandIcon().getURL() + "'/>create a new command"; Button addDataSet = new Button(html, new ClickHandler() { @Override/*from ww w . j ava 2 s .c o m*/ public void onClick(ClickEvent event) { createUploadPopup(); } }); addDataSet.setStyleName(N3phele.n3pheleResource.css().newCommandButton()); this.strip.add(addDataSet); HorizontalPanel heading = new HorizontalPanel(); heading.setWidth("500px"); heading.setStyleName(N3phele.n3pheleResource.css().sectionPanelHeader()); add(heading); SimplePager.Resources pagerResources = GWT.create(SimplePager.Resources.class); simplePager = new SimplePager(TextLocation.CENTER, pagerResources, false, 0, true); heading.add(simplePager); textBox = new TextBox(); textBox.setTitle("search for a command"); heading.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); heading.add(textBox); heading.setCellHorizontalAlignment(textBox, HorizontalPanel.ALIGN_RIGHT); textBox.addKeyPressHandler(new KeyPressHandler() { public void onKeyPress(KeyPressEvent event) { if (KeyCodes.KEY_ENTER == event.getNativeEvent().getKeyCode()) { commandActivity.fetch(0, searchText = textBox.getText(), !allVersions.getValue()); } } }); Image searchIcon = new Image(N3phele.n3pheleResource.searchIcon().getURL()); searchIcon.setPixelSize(20, 20); PushButton search = new PushButton(searchIcon); search.setTitle("search for a command"); search.setStyleName(N3phele.n3pheleResource.css().commandSearchButton()); heading.add(search); search.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { commandActivity.fetch(0, searchText = textBox.getText(), !allVersions.getValue()); } }); heading.setCellHorizontalAlignment(simplePager, HorizontalPanel.ALIGN_CENTER); DisclosurePanel more = new DisclosurePanel("advanced"); more.setStyleName(N3phele.n3pheleResource.css().sectionPanelHeader()); heading.add(more); heading.setCellHorizontalAlignment(more, HorizontalPanel.ALIGN_LEFT); HorizontalPanel disclosed = new HorizontalPanel(); more.add(disclosed); disclosed.add(new InlineLabel("Search all versions")); allVersions = new SimpleCheckBox(); allVersions.setName("allVersions"); allVersions.setFormValue("Search all versions"); disclosed.add(allVersions); grid = new CellTable<List<Command>>(); grid.setWidth("100%", true); HasCell<Command, ?> nameHasCell = new HasCell<Command, Command>() { @Override public Cell<Command> getCell() { return new CommandTextCell(CommandNameRenderer.getInstance()); } @Override public FieldUpdater<Command, Command> getFieldUpdater() { return new FieldUpdater<Command, Command>() { @Override public void update(int index, Command object, Command value) { // if(value != null) { // GWT.log("got-139 "+index+" "+value.getName()); // commandActivity.goTo(new CommandPlace(value.getUri())); // } } }; } @Override public Command getValue(Command object) { return object; } }; HasCell<Command, ?> versionHasCell = new HasCell<Command, Command>() { @Override public Cell<Command> getCell() { return new CommandTextCell(CommandVersionRenderer.getInstance()); } @Override public FieldUpdater<Command, Command> getFieldUpdater() { return new FieldUpdater<Command, Command>() { @Override public void update(int index, Command object, Command value) { // if(value != null) { // GWT.log("got-166 "+index+" "+value.getName()); // commandActivity.goTo(new CommandPlace(value.getUri())); // } } }; } @Override public Command getValue(Command object) { return object; } }; List<HasCell<Command, ?>> hasCells = new ArrayList<HasCell<Command, ?>>(2); hasCells.add(nameHasCell); hasCells.add(versionHasCell); for (int i = 0; i < ROWLENGTH; i++) { Column<List<Command>, Command> c = new Column<List<Command>, Command>(new CommandIconTextCell( N3phele.n3pheleResource.scriptIcon(), new CompositeCell<Command>(hasCells), i)) { @Override public Command getValue(List<Command> object) { int index = ((CommandIconTextCell) this.getCell()).getIndex(); if (index < object.size()) { return object.get(index); } else { return null; } } }; c.setFieldUpdater(new FieldUpdater<List<Command>, Command>() { @Override public void update(int index, List<Command> object, Command value) { if (value != null) { GWT.log("got-201 " + index + " " + value.getName()); commandActivity.goTo(new CommandPlace(value.getUri())); } } }); grid.addColumn(c); grid.setColumnWidth(c, 100.0 / ROWLENGTH, Unit.PCT); } grid.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED); simplePager.setDisplay(grid); simplePager.setPageSize(PAGESIZE); grid.addRangeChangeHandler(new RangeChangeEvent.Handler() { /* (non-Javadoc) * @see com.google.gwt.view.client.RangeChangeEvent.Handler#onRangeChange(com.google.gwt.view.client.RangeChangeEvent) */ @Override public void onRangeChange(RangeChangeEvent event) { if (suppressEvent) return; Range range = grid.getVisibleRange(); GWT.log("Table range is " + range.getStart() + " length " + range.getLength()); int start = range.getStart(); if (start > total) start = total; // if(data == null || (data.size() < start) ){ commandActivity.fetch(start, searchText, !allVersions.getValue()); // } else { // if(length+start > data.size()) // length = data.size()-start; // GWT.log("data available start="+start); // grid.setRowData(start, chunk(data.subList(start, start+length))); // } } }); this.add(grid); }
From source file:n3phele.client.view.CommandListView.java
License:Open Source License
public CommandListView() { super(new MenuItem(N3phele.n3pheleResource.commandIcon(), "Commands", null)); cellTable = new CellTable<Command>(); cellTable.setSize("455px", ""); // TextColumn<Command> nameColumn = new TextColumn<Command>() { // @Override // public String getValue(Command command) { // String result = ""; // if(command != null) // return command.getName(); // return result; // }/*from www. j a v a2 s . c o m*/ // }; // cellTable.addColumn(nameColumn, "Name"); Column<Command, Hyperlink> nameColumn = new Column<Command, Hyperlink>(new HyperlinkCell()) { @Override public Hyperlink getValue(Command command) { if (command == null) return null; String name = command.getName(); String historyToken = commandActivity.getToken(command); return new Hyperlink(name, historyToken); } }; nameColumn.setFieldUpdater(new FieldUpdater<Command, Hyperlink>() { @Override public void update(int index, Command object, Hyperlink value) { CommandListView.this.commandActivity.goTo(new CommandPlace(object.getUri())); } }); cellTable.addColumn(nameColumn, "Name"); TextColumn<Command> descriptionColumn = new TextColumn<Command>() { @Override public String getValue(Command command) { String result = ""; if (command != null) return command.getDescription(); return result; } }; cellTable.addColumn(descriptionColumn, "Description"); // // Add a selection model to handle user selection. // final SingleSelectionModel<Command> selectionModel = new SingleSelectionModel<Command>(); // cellTable.setSelectionModel(selectionModel); // selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { // public void onSelectionChange(SelectionChangeEvent event) { // Command selected = selectionModel.getSelectedObject(); // if (selected != null) { // if(commandActivity != null) { // commandActivity.onSelect(selected); // } // } // } // }); cellTable.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED); this.add(cellTable); }
From source file:n3phele.client.view.CreateServiceView.java
License:Open Source License
public CellTable<CommandCloudAccount> createAccountTable() { final SensitiveCheckBoxCell checkbox = new SensitiveCheckBoxCell(true, true); final ProvidesKey<CommandCloudAccount> KEY_PROVIDER = new ProvidesKey<CommandCloudAccount>() { public Object getKey(CommandCloudAccount item) { return item.getAccountUri(); }//w w w . j a va 2s . c o m }; final CellTable<CommandCloudAccount> table = new CellTable<CommandCloudAccount>(KEY_PROVIDER); table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED); Column<CommandCloudAccount, Boolean> checkColumn = new Column<CommandCloudAccount, Boolean>(checkbox) { @Override public Boolean getValue(CommandCloudAccount profile) { return (profile.getAccountUri().equals(CreateServiceView.this.selectedAccountURI)); } }; checkColumn.setFieldUpdater(new FieldUpdater<CommandCloudAccount, Boolean>() { @Override public void update(int index, CommandCloudAccount profile, Boolean value) { if (profile != null) { if (value) { CreateServiceView.this.selectedImplementation = profile.getImplementation(); CreateServiceView.this.selectedAccountURI = profile.getAccountUri().toString(); } else { if (profile.getImplementation().equals(CreateServiceView.this.selectedImplementation)) { CreateServiceView.this.selectedImplementation = null; CreateServiceView.this.selectedAccountURI = null; } } table.redraw(); String visible = value ? "-" : "+"; CreateServiceView.this.gotExecutionSelection.setValue( visible + CreateServiceView.this.gotExecutionSelection.getValue().substring(1)); updateRunButton(true); validateAccount(true); } else { checkbox.clearViewData(KEY_PROVIDER.getKey(profile)); table.redraw(); updateRunButton(false); validateAccount(false); GWT.log("update account"); CreateServiceView.this.gotExecutionSelection .setValue("+" + CreateServiceView.this.gotExecutionSelection.getValue().substring(1)); } } }); table.addColumn(checkColumn); table.setColumnWidth(checkColumn, "40px"); TextColumn<CommandCloudAccount> accountColumn = new TextColumn<CommandCloudAccount>() { @Override public String getValue(CommandCloudAccount profile) { String result = ""; if (profile != null) return profile.getAccountName(); return result; } }; table.addColumn(accountColumn); TextColumn<CommandCloudAccount> nameColumn = new TextColumn<CommandCloudAccount>() { @Override public String getValue(CommandCloudAccount profile) { String result = ""; if (profile != null) { return profile.getImplementation(); } return result; } }; table.addColumn(nameColumn); table.setWidth("400px"); table.addStyleName(N3phele.n3pheleResource.css().lineBreakStyle()); table.setTableLayoutFixed(true); return table; }
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 ava 2 s.com*/ 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.RepoContentView.java
License:Open Source License
protected Widget createDatasetTable() { grid = new CellTable<List<FileNode>>(); grid.setWidth("100%"); grid.setTableLayoutFixed(true);/*from w ww. j ava 2 s. com*/ for (int i = 0; i < ROWLENGTH; i++) { Column<List<FileNode>, FileNode> icon = new Column<List<FileNode>, FileNode>(new FileNodeIconCell(i)) { @Override public FileNode getValue(List<FileNode> object) { int index = ((FileNodeIconCell) this.getCell()).getIndex(); if (index < object.size()) { FileNode value = object.get(index); return value; } else { return null; } } }; icon.setFieldUpdater(new FieldUpdater<List<FileNode>, FileNode>() { @Override public void update(int index, List<FileNode> object, FileNode value) { if (value != null) { String type = value.getMime(); PopupPanel popup; if (!type.endsWith("Folder") && !type.endsWith("Placeholder")) { GWT.log("got filename on row " + index + " " + value.toFormattedString()); popup = createFileDetailsPopup(value); } else { GWT.log("got folder on row " + index + " " + value.toFormattedString()); popup = createFileDetailsPopup(value); } if (popup != null) { int column = 0; for (int i = 0; i < ROWLENGTH && i < object.size(); i++) { FileNode n = object.get(i); if (n.getName() != null && n.getName().equals(value.getName())) { column = i; GWT.log("Found at " + column); break; } } popup.showRelativeTo(new ElementWrapper(grid.getRowElement(index).getChild(column * 2) .getFirstChild().getParentElement().getFirstChildElement())); popup.addAutoHidePartner(grid.getRowElement(index).getChild(column * 2).getFirstChild() .getParentElement()); } } } }); Column<List<FileNode>, FileNode> text = new Column<List<FileNode>, FileNode>(new FileNodeTextCell(i)) { @Override public FileNode getValue(List<FileNode> object) { int index = ((FileNodeTextCell) this.getCell()).getIndex(); if (index < object.size()) { FileNode value = object.get(index); return value; } else { return null; } } }; text.setFieldUpdater(new FieldUpdater<List<FileNode>, FileNode>() { @Override public void update(int index, List<FileNode> object, FileNode value) { if (value != null) { if (isFile(value)) { GWT.log("got filename on row " + index + " " + value.toFormattedString()); } else { GWT.log("got folder on row " + index + " " + value.toFormattedString()); RepoContentView.this.presenter.selectFolder(value); } } } }); grid.addColumn(icon); grid.setColumnWidth(icon, 50, Unit.PX); grid.addColumn(text); text.setCellStyleNames(N3phele.n3pheleResource.css().repoTextCell()); grid.setColumnWidth(text, (100.0 / ROWLENGTH), Unit.PCT); } grid.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED); emptyTable = grid.getEmptyTableWidget(); return grid; }
From source file:n3phele.client.view.ServiceDetailsView.java
License:Open Source License
public ServiceDetailsView() { super(new MenuItem(N3phele.n3pheleResource.serviceIcon(), "Service Details", null)); // ******************************************* table = new FlexTable(); table.setCellPadding(10);/* w w w .j a v a2s . co m*/ noStack = new Label("There's no stacks on this service!"); // Selected service. lblNewLabel = new Label(""); table.setWidget(0, 0, lblNewLabel); table.setWidget(1, 2, cancel); table.getFlexCellFormatter().setHorizontalAlignment(1, 2, HasHorizontalAlignment.ALIGN_RIGHT); table.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_RIGHT); table.getFlexCellFormatter().setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_CENTER); table.getColumnFormatter().setWidth(0, "25%"); table.getColumnFormatter().setWidth(1, "18px"); table.getColumnFormatter().setWidth(4, "16px"); table.setCellPadding(1); table.setCellSpacing(5); HorizontalPanel heading = new HorizontalPanel(); heading.setWidth("500px"); heading.setStyleName(N3phele.n3pheleResource.css().sectionPanelHeader()); //add(heading); SimplePager.Resources pagerResources = GWT.create(SimplePager.Resources.class); simplePager = new SimplePager(TextLocation.CENTER, pagerResources, false, 0, true); heading.add(simplePager); textBox = new TextBox(); textBox.setTitle("search for a command"); heading.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); heading.add(textBox); heading.setCellHorizontalAlignment(textBox, HorizontalPanel.ALIGN_RIGHT); textBox.addKeyPressHandler(new KeyPressHandler() { public void onKeyPress(KeyPressEvent event) { if (KeyCodes.KEY_ENTER == event.getNativeEvent().getKeyCode()) { commandActivity.getProcess(); } } }); grid = new CellTable<List<Stack>>(); grid.setWidth("100%", true); HasCell<Stack, ?> nameHasCell = new HasCell<Stack, Stack>() { @Override public Cell<Stack> getCell() { return new StackTextCell(StackNameRenderer.getInstance()); } @Override public FieldUpdater<Stack, Stack> getFieldUpdater() { return new FieldUpdater<Stack, Stack>() { @Override public void update(int index, Stack object, Stack value) { presenter.onSelect(value); } }; } @Override public Stack getValue(Stack object) { return object; } }; HasCell<Stack, ?> versionHasCell = new HasCell<Stack, Stack>() { @Override public Cell<Stack> getCell() { return new StackTextCell(StackVersionRenderer.getInstance()); } @Override public FieldUpdater<Stack, Stack> getFieldUpdater() { return new FieldUpdater<Stack, Stack>() { @Override public void update(int index, Stack object, Stack value) { presenter.onSelect(value); } }; } @Override public Stack getValue(Stack object) { return object; } }; List<HasCell<Stack, ?>> hasCells = new ArrayList<HasCell<Stack, ?>>(2); hasCells.add(nameHasCell); hasCells.add(versionHasCell); for (int i = 0; i < ROWLENGTH; i++) { Column<List<Stack>, Stack> c = new Column<List<Stack>, Stack>(new CommandIconTextCell( N3phele.n3pheleResource.stackIcon(), new CompositeCell<Stack>(hasCells), i)) { @Override public Stack getValue(List<Stack> object) { int index = ((CommandIconTextCell) this.getCell()).getIndex(); if (index < object.size()) { return object.get(index); } else { return null; } } }; c.setFieldUpdater(new FieldUpdater<List<Stack>, Stack>() { @Override public void update(int index, List<Stack> object, Stack value) { presenter.onSelect(value); if (value != null) { GWT.log("got-201 " + index + " " + value.getName()); } } }); grid.addColumn(c); grid.setColumnWidth(c, 100.0 / ROWLENGTH, Unit.PCT); } grid.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED); simplePager.setDisplay(grid); simplePager.setPageSize(PAGESIZE); grid.addRangeChangeHandler(new RangeChangeEvent.Handler() { /* * (non-Javadoc) * * @see * com.google.gwt.view.client.RangeChangeEvent.Handler#onRangeChange * (com.google.gwt.view.client.RangeChangeEvent) */ @Override public void onRangeChange(RangeChangeEvent event) { if (suppressEvent) return; Range range = grid.getVisibleRange(); GWT.log("Table range is " + range.getStart() + " length " + range.getLength()); int start = range.getStart(); if (start > total) start = total; commandActivity.getProcess(); } }); this.add(table); this.add(grid); this.add(noStack); }
From source file:n3phele.client.widgets.FileNodeBrowserCore.java
License:Open Source License
public FileNodeBrowserCore(BrowserPresenter presenter, boolean isInput, int rowLength, int width, MenuItem heading) {//from w ww . j ava 2 s .c o m this.setWidth(width + "px"); this.ROWLENGTH = rowLength; this.isInput = isInput; this.isOptional = !isInput; this.presenter = presenter; header = new HorizontalPanel(); header.setWidth("100%"); if (heading != null) { Cell<MenuItem> cell = new IconTextCell<MenuItem>(32, 32); CellWidget<MenuItem> headerIcon = new CellWidget<MenuItem>(cell, heading); headerIcon.addStyleName(N3phele.n3pheleResource.css().workspacePanelHeader()); header.add(headerIcon); } if (!isInput) { newFolderPanel = new DisclosurePanel("New Folder"); newFolderView = NewFolderView.newInstance(); newFolderPanel.add(newFolderView); newFolderPanel.addOpenHandler(new OpenHandler<DisclosurePanel>() { @Override public void onOpen(OpenEvent<DisclosurePanel> event) { FileNodeBrowserCore.this.newFolderView.clearName(); } }); newFolderPanel.addCloseHandler(new CloseHandler<DisclosurePanel>() { @Override public void onClose(CloseEvent<DisclosurePanel> event) { String name = FileNodeBrowserCore.this.newFolderView.getFolderName(); if (name != null) { FileNodeBrowserCore.this.newFolder(name); } } }); newFolderView.setDisclosurePanel(newFolderPanel); header.add(newFolderPanel); } this.add(header); actions = new FlexTable(); this.add(actions); actions.setWidth("100%"); crumbs = new FlowPanel(); crumbs.setWidth("100%"); actions.setWidget(0, 0, crumbs); ScrollPanel gridPanel = new ScrollPanel(); gridPanel.setHeight("200px"); grid = new CellTable<List<FileNode>>(); grid.setWidth("100%"); grid.setTableLayoutFixed(true); for (int i = 0; i < ROWLENGTH; i++) { Column<List<FileNode>, FileNode> c = new Column<List<FileNode>, FileNode>( new FileNodeIconTextCell(N3phele.n3pheleResource.folderIcon(), new FileNodeTextCell(), i)) { @Override public FileNode getValue(List<FileNode> object) { int index = ((FileNodeIconTextCell) this.getCell()).getIndex(); if (index < object.size()) { return object.get(index); } else { return null; } } }; c.setFieldUpdater(new FieldUpdater<List<FileNode>, FileNode>() { @Override public void update(int index, List<FileNode> object, FileNode value) { if (value != null) { if (!value.getMime().endsWith("Folder") && !value.getMime().endsWith("Placeholder")) { FileNodeBrowserCore.this.filename.setText(value.getName()); FileNodeBrowserCore.this.openButtonValidate(!isZip); } else { FileNodeBrowserCore.this.filename.setText(null); if (FileNodeBrowserCore.this.presenter != null) { FileNodeBrowserCore.this.openButtonValidate(isZip); FileNodeBrowserCore.this.presenter.selectFolder(value); } } } GWT.log("got " + index + " " + value.toFormattedString()); } }); grid.addColumn(c); grid.setColumnWidth(c, 100.0 / ROWLENGTH, Unit.PCT); } grid.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED); gridPanel.add(grid); actions.setWidget(1, 0, gridPanel); repoList = new ListBox(false); repoList.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { FileNodeBrowserCore.this.filename.setText(null); FileNodeBrowserCore.this.openButtonValidate(false); if (FileNodeBrowserCore.this.presenter != null) { int selected = FileNodeBrowserCore.this.repoList.getSelectedIndex() + (FileNodeBrowserCore.this.isOptional ? -1 : 0); if (selected >= 0 && selected < FileNodeBrowserCore.this.repos.size()) { FileNodeBrowserCore.this.presenter .selectFolder(FileNodeBrowserCore.this.repos.get(selected)); } else { FileNodeBrowserCore.this.presenter.selectFolder((Repository) null); } } } }); actions.setWidget(2, 0, repoList); filename = new TextBox(); filename.addKeyUpHandler(new KeyUpHandler() { @Override public void onKeyUp(KeyUpEvent event) { FileNodeBrowserCore.this.enableOpenButton(false); String filename = FileNodeBrowserCore.this.filename.getText(); String repoURI = FileNodeBrowserCore.this.repoList .getValue(FileNodeBrowserCore.this.repoList.getSelectedIndex()); GWT.log("save " + filename + " on " + repoURI); if (repoURI.length() == 0) repoURI = null; if (FileNodeBrowserCore.this.presenter != null) { validateAndEnableOpenButton(filename, repoURI); } } }); actions.setWidget(2, 1, filename); filename.setWidth((width - 50) + "px"); this.openButton = getOpenButton(this.isInput); if (this.openButton != null) actions.setWidget(3, 2, this.openButton); this.cancelButton = getCancelButton(); if (this.cancelButton != null) actions.setWidget(3, 3, cancelButton); errorIndicator = new Image(N3phele.n3pheleResource.inputErrorIcon()); setErrorText(); actions.setWidget(3, 1, errorIndicator); actions.getCellFormatter().setHorizontalAlignment(3, 1, HasHorizontalAlignment.ALIGN_RIGHT); actions.getFlexCellFormatter().setWidth(3, 3, "80px"); actions.getFlexCellFormatter().setWidth(3, 2, "80px"); actions.getFlexCellFormatter().setWidth(3, 1, (width - 100) + "px"); actions.getFlexCellFormatter().setColSpan(0, 0, 4); actions.getFlexCellFormatter().setColSpan(1, 0, 4); actions.getFlexCellFormatter().setColSpan(2, 1, 3); }