List of usage examples for com.google.gwt.cell.client TextInputCell TextInputCell
public TextInputCell()
From source file:com.google.gwt.examples.cellview.CellListValueUpdaterExample.java
License:Apache License
public void onModuleLoad() { // Create a cell that will interact with a value updater. TextInputCell inputCell = new TextInputCell(); // Create a CellList that uses the cell. CellList<String> cellList = new CellList<String>(inputCell); // Create a value updater that will be called when the value in a cell // changes./*from w w w .j ava 2 s .co m*/ ValueUpdater<String> valueUpdater = new ValueUpdater<String>() { public void update(String newValue) { Window.alert("You typed: " + newValue); } }; // Add the value updater to the cellList. cellList.setValueUpdater(valueUpdater); // Set the total row count. This isn't strictly necessary, but it affects // paging calculations, so its good habit to keep the row count up to date. cellList.setRowCount(DAYS.size(), true); // Push the data into the widget. cellList.setRowData(0, DAYS); // Add it to the root panel. RootPanel.get().add(cellList); }
From source file:com.google.gwt.examples.cellview.CellTableFieldUpdaterExample.java
License:Apache License
@Override public void onModuleLoad() { // Create a CellTable with a key provider. final CellTable<Contact> table = new CellTable<Contact>(KEY_PROVIDER); // Add a text input column to edit the name. final TextInputCell nameCell = new TextInputCell(); Column<Contact, String> nameColumn = new Column<Contact, String>(nameCell) { @Override/*from w ww .j av a2 s. c o m*/ public String getValue(Contact object) { // Return the name as the value of this column. return object.name; } }; table.addColumn(nameColumn, "Name"); // Add a field updater to be notified when the user enters a new name. nameColumn.setFieldUpdater(new FieldUpdater<Contact, String>() { @Override public void update(int index, Contact object, String value) { // Inform the user of the change. Window.alert("You changed the name of " + object.name + " to " + value); // Push the changes into the Contact. At this point, you could send an // asynchronous request to the server to update the database. object.name = value; // Redraw the table with the new data. table.redraw(); } }); // Push the data into the widget. table.setRowData(CONTACTS); // Add it to the root panel. RootPanel.get().add(table); }
From source file:com.google.gwt.examples.cellview.CellTableFieldUpdaterExampleComplex.java
License:Apache License
@Override public void onModuleLoad() { // Create a CellTable with a key provider. final CellTable<Contact> table = new CellTable<Contact>(KEY_PROVIDER); table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED); // Add a text input column to edit the name. final TextInputCell nameCell = new TextInputCell(); Column<Contact, String> nameColumn = new Column<Contact, String>(nameCell) { @Override//from ww w . j a v a 2 s . c om public String getValue(Contact object) { return object.name; } }; table.addColumn(nameColumn, "Name"); // Add a field updater to be notified when the user enters a new name. nameColumn.setFieldUpdater(new FieldUpdater<Contact, String>() { @Override public void update(int index, Contact object, String value) { // Validate the data. if (value.length() < 3) { Window.alert("Names must be at least three characters long."); /* * Clear the view data. The view data contains the pending change and * allows the table to render with the pending value until the data is * committed. If the data is committed into the object, the view data * is automatically cleared out. If the data is not committed because * it is invalid, you must delete. */ nameCell.clearViewData(KEY_PROVIDER.getKey(object)); // Redraw the table. table.redraw(); return; } // Inform the user of the change. Window.alert("You changed the name of " + object.name + " to " + value); // Push the changes into the Contact. At this point, you could send an // asynchronous request to the server to update the database. object.name = value; // Redraw the table with the new data. table.redraw(); } }); // Add a date column to show the birthday. Column<Contact, Date> dateColumn = new Column<Contact, Date>(new DatePickerCell()) { @Override public Date getValue(Contact object) { return object.birthday; } }; table.addColumn(dateColumn, "Birthday"); // Add a field updater to be notified when the user enters a new birthday. dateColumn.setFieldUpdater(new FieldUpdater<Contact, Date>() { @Override public void update(int index, Contact object, Date value) { Window.alert("You changed the birthday of " + object.name + " to " + DateTimeFormat.getFormat(PredefinedFormat.DATE_LONG).format(value)); // Push the changes into the Contact. object.birthday = value; // Redraw the table with the new data. table.redraw(); } }); // Add a text column to show the address. TextColumn<Contact> addressColumn = new TextColumn<Contact>() { @Override public String getValue(Contact object) { return object.address; } }; table.addColumn(addressColumn, "Address"); // Set the total row count. This isn't strictly necessary, but it affects // paging calculations, so its good habit to keep the row count up to date. table.setRowCount(CONTACTS.size(), true); // Push the data into the widget. table.setRowData(0, CONTACTS); // Add it to the root panel. RootPanel.get().add(table); }
From source file:com.google.gwt.sample.showcase.client.content.cell.CwCellSampler.java
License:Apache License
/** * Initialize this example./* w w w . j a va2 s . c o m*/ */ @ShowcaseSource @Override public Widget onInitialize() { Images images = GWT.create(Images.class); // Create the table. editableCells = new ArrayList<AbstractEditableCell<?, ?>>(); contactList = new DataGrid<ContactInfo>(25, ContactInfo.KEY_PROVIDER); contactList.setMinimumTableWidth(140, Unit.EM); ContactDatabase.get().addDataDisplay(contactList); // CheckboxCell. final Category[] categories = ContactDatabase.get().queryCategories(); addColumn(new CheckboxCell(), "Checkbox", new GetValue<Boolean>() { @Override public Boolean getValue(ContactInfo contact) { // Checkbox indicates that the contact is a relative. // Index 0 = Family. return contact.getCategory() == categories[0]; } }, new FieldUpdater<ContactInfo, Boolean>() { @Override public void update(int index, ContactInfo object, Boolean value) { if (value) { // If a relative, use the Family Category. pendingChanges.add(new CategoryChange(object, categories[0])); } else { // If not a relative, use the Contacts Category. pendingChanges.add(new CategoryChange(object, categories[categories.length - 1])); } } }); // TextCell. addColumn(new TextCell(), "Text", new GetValue<String>() { @Override public String getValue(ContactInfo contact) { return contact.getFullName(); } }, null); // EditTextCell. Column<ContactInfo, String> editTextColumn = addColumn(new EditTextCell(), "EditText", new GetValue<String>() { @Override public String getValue(ContactInfo contact) { return contact.getFirstName(); } }, new FieldUpdater<ContactInfo, String>() { @Override public void update(int index, ContactInfo object, String value) { pendingChanges.add(new FirstNameChange(object, value)); } }); contactList.setColumnWidth(editTextColumn, 16.0, Unit.EM); // TextInputCell. Column<ContactInfo, String> textInputColumn = addColumn(new TextInputCell(), "TextInput", new GetValue<String>() { @Override public String getValue(ContactInfo contact) { return contact.getLastName(); } }, new FieldUpdater<ContactInfo, String>() { @Override public void update(int index, ContactInfo object, String value) { pendingChanges.add(new LastNameChange(object, value)); } }); contactList.setColumnWidth(textInputColumn, 16.0, Unit.EM); // ClickableTextCell. addColumn(new ClickableTextCell(), "ClickableText", new GetValue<String>() { @Override public String getValue(ContactInfo contact) { return "Click " + contact.getFirstName(); } }, new FieldUpdater<ContactInfo, String>() { @Override public void update(int index, ContactInfo object, String value) { Window.alert("You clicked " + object.getFullName()); } }); // ActionCell. addColumn(new ActionCell<ContactInfo>("Click Me", new ActionCell.Delegate<ContactInfo>() { @Override public void execute(ContactInfo contact) { Window.alert("You clicked " + contact.getFullName()); } }), "Action", new GetValue<ContactInfo>() { @Override public ContactInfo getValue(ContactInfo contact) { return contact; } }, null); // ButtonCell. addColumn(new ButtonCell(), "Button", new GetValue<String>() { @Override public String getValue(ContactInfo contact) { return "Click " + contact.getFirstName(); } }, new FieldUpdater<ContactInfo, String>() { @Override public void update(int index, ContactInfo object, String value) { Window.alert("You clicked " + object.getFullName()); } }); // DateCell. DateTimeFormat dateFormat = DateTimeFormat.getFormat(PredefinedFormat.DATE_MEDIUM); addColumn(new DateCell(dateFormat), "Date", new GetValue<Date>() { @Override public Date getValue(ContactInfo contact) { return contact.getBirthday(); } }, null); // DatePickerCell. addColumn(new DatePickerCell(dateFormat), "DatePicker", new GetValue<Date>() { @Override public Date getValue(ContactInfo contact) { return contact.getBirthday(); } }, new FieldUpdater<ContactInfo, Date>() { @Override public void update(int index, ContactInfo object, Date value) { pendingChanges.add(new BirthdayChange(object, value)); } }); // NumberCell. Column<ContactInfo, Number> numberColumn = addColumn(new NumberCell(), "Number", new GetValue<Number>() { @Override public Number getValue(ContactInfo contact) { return contact.getAge(); } }, null); numberColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LOCALE_END); // IconCellDecorator. addColumn(new IconCellDecorator<String>(images.contactsGroup(), new TextCell()), "Icon", new GetValue<String>() { @Override public String getValue(ContactInfo contact) { return contact.getCategory().getDisplayName(); } }, null); // ImageCell. addColumn(new ImageCell(), "Image", new GetValue<String>() { @Override public String getValue(ContactInfo contact) { return "contact.jpg"; } }, null); // SelectionCell. List<String> options = new ArrayList<String>(); for (Category category : categories) { options.add(category.getDisplayName()); } addColumn(new SelectionCell(options), "Selection", new GetValue<String>() { @Override public String getValue(ContactInfo contact) { return contact.getCategory().getDisplayName(); } }, new FieldUpdater<ContactInfo, String>() { @Override public void update(int index, ContactInfo object, String value) { for (Category category : categories) { if (category.getDisplayName().equals(value)) { pendingChanges.add(new CategoryChange(object, category)); break; } } } }); // Create the UiBinder. Binder uiBinder = GWT.create(Binder.class); Widget widget = uiBinder.createAndBindUi(this); // Add handlers to redraw or refresh the table. redrawButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { contactList.redraw(); } }); commitButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { // Commit the changes. for (PendingChange<?> pendingChange : pendingChanges) { pendingChange.commit(); } pendingChanges.clear(); // Push the changes to the views. ContactDatabase.get().refreshDisplays(); } }); return widget; }
From source file:com.tasktop.c2c.server.tasks.client.widgets.admin.customfields.CustomFieldValuesEditor.java
License:Open Source License
private void initTableColumns() { DelegateCell<String> moveUpCell = new DelegateCell<String>(new DelegateCell.RenderDelegate<String>() { @Override//from w ww .j a v a 2s .c om public SafeHtml render(Cell.Context context, String value, SafeHtmlBuilder sb) { return SafeHtmlUtils.fromSafeConstant("<span class=\"order-control\"><a class=\"up\"/></span>"); } }, new DelegateCell.ActionDelegate<String>() { @Override public void execute(Cell.Context object) { int index = object.getIndex(); if (index > 0) { dataProvider.getList().get(index).setSortkey((short) (index - 1)); dataProvider.getList().get(index - 1).setSortkey((short) index); Collections.sort(dataProvider.getList()); refreshDisplays(); } } }); Column<CustomFieldValue, String> moveUpColumn = new Column<CustomFieldValue, String>(moveUpCell) { @Override public String getValue(CustomFieldValue object) { return null; } @Override public void render(Cell.Context context, CustomFieldValue object, SafeHtmlBuilder sb) { if (context.getIndex() != 0) { super.render(context, object, sb); } } }; cellTable.addColumn(moveUpColumn); cellTable.setColumnWidth(moveUpColumn, 22, Unit.PX); DelegateCell<String> moveDownCell = new DelegateCell<String>(new DelegateCell.RenderDelegate<String>() { @Override public SafeHtml render(Cell.Context context, String value, SafeHtmlBuilder sb) { return SafeHtmlUtils.fromSafeConstant("<span class=\"order-control\"><a class=\"down\"/></span>"); } }, new DelegateCell.ActionDelegate<String>() { @Override public void execute(Cell.Context object) { Short index = (short) object.getIndex(); if (index < dataProvider.getList().size() - 1) { dataProvider.getList().get(index).setSortkey((short) (index + 1)); dataProvider.getList().get(index + 1).setSortkey((short) index); Collections.sort(dataProvider.getList()); refreshDisplays(); } } }); Column<CustomFieldValue, String> moveDownColumn = new Column<CustomFieldValue, String>(moveDownCell) { @Override public String getValue(CustomFieldValue object) { return null; } @Override public void render(Cell.Context context, CustomFieldValue object, SafeHtmlBuilder sb) { if (context.getIndex() != dataProvider.getList().size() - 1) { super.render(context, object, sb); } } }; cellTable.addColumn(moveDownColumn); cellTable.setColumnWidth(moveDownColumn, 22, Unit.PX); Column<CustomFieldValue, String> nameColumn = new Column<CustomFieldValue, String>(new TextInputCell()) { @Override public String getValue(CustomFieldValue value) { return value.getValue(); } }; nameColumn.setFieldUpdater(new FieldUpdater<CustomFieldValue, String>() { @Override public void update(int index, CustomFieldValue customFieldValue, String value) { customFieldValue.setValue(value); } }); cellTable.addColumn(nameColumn); DelegateCell<String> removeCell = new DelegateCell<String>(new DelegateCell.RenderDelegate<String>() { @Override public SafeHtml render(Cell.Context context, String value, SafeHtmlBuilder sb) { final CustomFieldValue referenced = dataProvider.getList().get(context.getIndex()); if (referenced != null && "---".equals(referenced.getValue())) { return SafeHtmlUtils.fromSafeConstant("<a class=\"delete-disabled\"><span/></a>"); } return SafeHtmlUtils.fromSafeConstant("<a class=\"misc-icon cancel\"><span/></a>"); } }, new DelegateCell.ActionDelegate<String>() { @Override public void execute(final Cell.Context object) { final CustomFieldValue toRemove = dataProvider.getList().get(object.getIndex()); if (toRemove == null) { return; } if ("---".equals(toRemove.getValue())) { return; } dataProvider.getList().remove(toRemove); } }); Column<CustomFieldValue, String> removeColumn = new Column<CustomFieldValue, String>(removeCell) { @Override public String getValue(CustomFieldValue object) { return null; } @Override public void render(Cell.Context context, CustomFieldValue object, SafeHtmlBuilder sb) { if (dataProvider.getList().size() == 1) { sb.appendHtmlConstant("<a><span/></a>"); } else { super.render(context, object, sb); } } }; cellTable.addColumn(removeColumn); cellTable.setColumnWidth(removeColumn, 30, Unit.PX); DelegateCell<String> addCell = new DelegateCell<String>(new DelegateCell.RenderDelegate<String>() { @Override public SafeHtml render(Cell.Context context, String value, SafeHtmlBuilder sb) { return SafeHtmlUtils.fromSafeConstant("<a class=\"misc-icon add right\"><span/></a>"); } }, new DelegateCell.ActionDelegate<String>() { @Override public void execute(Cell.Context object) { addNewValue(); } }); Column<CustomFieldValue, String> addColumn = new Column<CustomFieldValue, String>(addCell) { @Override public String getValue(CustomFieldValue object) { return null; } @Override public void render(Cell.Context context, CustomFieldValue object, SafeHtmlBuilder sb) { if (context.getIndex() == dataProvider.getList().size() - 1) { super.render(context, object, sb); } else { sb.appendHtmlConstant("<a><span/></a>"); } } }; cellTable.addColumn(addColumn); cellTable.setColumnWidth(addColumn, 30, Unit.PX); }
From source file:cz.filmtit.client.dialogs.AddSubtitleItemDialog.java
License:Open Source License
/** * create the table/*from w ww . ja v a2s. c o m*/ */ private void initTable() { // create columns Column<SrtTime, String> hColumn = new Column<SrtTime, String>(new TextInputCell()) { @Override public String getValue(SrtTime time) { return time.getStringH(); } }; Column<SrtTime, String> mColumn = new Column<SrtTime, String>(new TextInputCell()) { @Override public String getValue(SrtTime time) { return time.getStringM(); } }; Column<SrtTime, String> sColumn = new Column<SrtTime, String>(new TextInputCell()) { @Override public String getValue(SrtTime time) { return time.getStringS(); } }; Column<SrtTime, String> tColumn = new Column<SrtTime, String>(new TextInputCell()) { @Override public String getValue(SrtTime time) { return time.getStringT(); } }; // add column styles hColumn.setCellStyleNames("numerical2digits"); mColumn.setCellStyleNames("numerical2digits"); sColumn.setCellStyleNames("numerical2digits"); tColumn.setCellStyleNames("numerical3digits"); // add column update handlers hColumn.setFieldUpdater(new FieldUpdater<SrtTime, String>() { @Override public void update(int index, SrtTime time, String value) { try { time.setH(value); } catch (InvalidValueException e) { Window.alert(e.getLocalizedMessage()); } } }); mColumn.setFieldUpdater(new FieldUpdater<SrtTime, String>() { @Override public void update(int index, SrtTime time, String value) { try { time.setM(value); } catch (InvalidValueException e) { Window.alert(e.getLocalizedMessage()); } } }); sColumn.setFieldUpdater(new FieldUpdater<SrtTime, String>() { @Override public void update(int index, SrtTime time, String value) { try { time.setS(value); } catch (InvalidValueException e) { Window.alert(e.getLocalizedMessage()); } } }); tColumn.setFieldUpdater(new FieldUpdater<SrtTime, String>() { @Override public void update(int index, SrtTime time, String value) { try { time.setT(value); } catch (InvalidValueException e) { Window.alert(e.getLocalizedMessage()); } } }); // add columns to table //timesTable = new CellTable<SrtTime>(); timesTable.addColumn(hColumn, "hour"); timesTable.addColumn(mColumn, "minute"); timesTable.addColumn(sColumn, "second"); timesTable.addColumn(tColumn, "milisecond"); // add the data ArrayList<SrtTime> rowData = new ArrayList<SrtTime>(2); rowData.add(startTimeWorking); rowData.add(endTimeWorking); // timesTable.setRowData(rowData); // timesTable.setRowCount(2, true); //timesTable.setVisibleRange(new Range(0, 2)); timesTable.setRowData(0, rowData); // show the table timesTable.redraw(); }
From source file:cz.filmtit.client.dialogs.TimeEditDialog.java
License:Open Source License
/** * create the table/*from w w w .j a v a 2 s. c o m*/ */ private void initTable() { // create columns Column<SrtTime, String> hColumn = new Column<SrtTime, String>(new TextInputCell()) { @Override public String getValue(SrtTime time) { return time.getStringH(); } }; Column<SrtTime, String> mColumn = new Column<SrtTime, String>(new TextInputCell()) { @Override public String getValue(SrtTime time) { return time.getStringM(); } }; Column<SrtTime, String> sColumn = new Column<SrtTime, String>(new TextInputCell()) { @Override public String getValue(SrtTime time) { return time.getStringS(); } }; Column<SrtTime, String> tColumn = new Column<SrtTime, String>(new TextInputCell()) { @Override public String getValue(SrtTime time) { return time.getStringT(); } }; // add column styles hColumn.setCellStyleNames("numerical2digits"); mColumn.setCellStyleNames("numerical2digits"); sColumn.setCellStyleNames("numerical2digits"); tColumn.setCellStyleNames("numerical3digits"); // add column update handlers hColumn.setFieldUpdater(new FieldUpdater<SrtTime, String>() { @Override public void update(int index, SrtTime time, String value) { try { time.setH(value); } catch (InvalidValueException e) { Window.alert(e.getLocalizedMessage()); } } }); mColumn.setFieldUpdater(new FieldUpdater<SrtTime, String>() { @Override public void update(int index, SrtTime time, String value) { try { time.setM(value); } catch (InvalidValueException e) { Window.alert(e.getLocalizedMessage()); } } }); sColumn.setFieldUpdater(new FieldUpdater<SrtTime, String>() { @Override public void update(int index, SrtTime time, String value) { try { time.setS(value); } catch (InvalidValueException e) { Window.alert(e.getLocalizedMessage()); } } }); tColumn.setFieldUpdater(new FieldUpdater<SrtTime, String>() { @Override public void update(int index, SrtTime time, String value) { try { time.setT(value); } catch (InvalidValueException e) { Window.alert(e.getLocalizedMessage()); } } }); // add columns to table //timesTable = new CellTable<SrtTime>(); timesTable.addColumn(hColumn, "hour"); timesTable.addColumn(mColumn, "minute"); timesTable.addColumn(sColumn, "second"); timesTable.addColumn(tColumn, "milisecond"); // add the data ArrayList<SrtTime> rowData = new ArrayList<SrtTime>(2); rowData.add(startTimeWorking); rowData.add(endTimeWorking); // timesTable.setRowData(rowData); // timesTable.setRowCount(2, true); //timesTable.setVisibleRange(new Range(0, 2)); timesTable.setRowData(0, rowData); // show the table timesTable.redraw(); }
From source file:n3phele.client.widgets.TypedParameterInputCell.java
License:Open Source License
public static TypedParameterInputCell create() { final TextInputCell value = new TextInputCell(); final ValidInputIndicatorCell valid = new ValidInputIndicatorCell(N3phele.n3pheleResource.inputErrorIcon()); HasCell<TypedParameter, String> valueHasCell = new HasCell<TypedParameter, String>() { @Override/*from ww w.j a va2 s .c om*/ public Cell<String> getCell() { return value; } @Override public FieldUpdater<TypedParameter, String> getFieldUpdater() { return new FieldUpdater<TypedParameter, String>() { @Override public void update(int index, TypedParameter object, String value) { } }; } @Override public String getValue(TypedParameter object) { return object.getValue(); } }; HasCell<TypedParameter, String> validHasCell = new HasCell<TypedParameter, String>() { @Override public Cell<String> getCell() { return valid; } @Override public FieldUpdater<TypedParameter, String> getFieldUpdater() { return new FieldUpdater<TypedParameter, String>() { @Override public void update(int index, TypedParameter object, String value) { validateTypedParameter(object, value); } }; } @Override public String getValue(TypedParameter object) { return "some random text"; //return null; } }; List<HasCell<TypedParameter, ?>> arg = new ArrayList<HasCell<TypedParameter, ?>>(2); arg.add(validHasCell); arg.add(valueHasCell); return new TypedParameterInputCell(arg); }
From source file:org.apache.oozie.tools.workflowgenerator.client.property.action.FSPropertyTable.java
License:Apache License
/** * Create a table showing fs operations/*from w ww . j ava2s . c o m*/ * * @param data * @return */ protected CellTable<FSActionData> createFSActionTable(List<FSActionData> data) { final CellTable<FSActionData> table = new CellTable<FSActionData>(); final ListDataProvider<FSActionData> dataProvider = new ListDataProvider<FSActionData>(); dataProvider.setList(data); dataProvider.addDataDisplay(table); // Add Name column Column<FSActionData, String> nameCol = null; nameCol = new Column<FSActionData, String>( new SelectionCell(Arrays.asList("", "delete", "mkdir", "move", "chmod", "touchz"))) { @Override public String getValue(FSActionData object) { return object.getOp(); } }; // set event for updating value nameCol.setFieldUpdater(new FieldUpdater<FSActionData, String>() { @Override public void update(int index, FSActionData object, String value) { FSActionData d = dataProvider.getList().get(index); d.setOp(value); table.redraw(); } }); table.addColumn(nameCol, "operation"); Column<FSActionData, String> label1Col = new Column<FSActionData, String>(new TextCell()) { @Override public String getValue(FSActionData object) { String rel = "Path"; String op = object.getOp(); if (op.equals("move")) { rel = "Source Path"; } return rel; } }; table.addColumn(label1Col); // Add Column for 1st parameter of delete/mkdir/chmod/move/touchz Column<FSActionData, String> param1Col = new Column<FSActionData, String>(new TextInputCell()) { @Override public String getValue(FSActionData object) { String op = object.getOp(); if (op.equals("delete") || op.equals("mkdir") || op.equals("chmod") || op.equals("touchz")) { if (object.getParams().containsKey("path") && object.getParams().get("path") != null) return object.getParams().get("path"); } else if (op.equals("move")) { if (object.getParams().containsKey("source") && object.getParams().get("source") != null) return object.getParams().get("source"); } return ""; } }; param1Col.setFieldUpdater(new FieldUpdater<FSActionData, String>() { @Override public void update(int index, FSActionData object, String value) { FSActionData d = dataProvider.getList().get(index); String op = d.getOp(); if (op.equals("delete") || op.equals("mkdir") || op.equals("chmod") || op.equals("touchz")) { d.getParams().put("path", value); } else if (op.equals("move")) { d.getParams().put("source", value); } } }); table.addColumn(param1Col, ""); // Add Label for 2rd parameter of move and chmod Column<FSActionData, String> label2Col = new Column<FSActionData, String>(new TextCell()) { public void render(Context context, SafeHtml value, SafeHtmlBuilder sb) { if (value != null) { FSActionData data = (FSActionData) context.getKey(); if (data.getOp().equals("move") || data.getOp().equals("chmod")) sb.append(value); } } @Override public String getValue(FSActionData object) { String rel = null; String op = object.getOp(); if (op.equals("move")) { rel = "Target Path"; } else if (op.equals("chmod")) { rel = "Permissions"; } return rel; } }; table.addColumn(label2Col); // Add Column for 2nd parameter of move and chmod Column<FSActionData, String> param2Col = new Column<FSActionData, String>(new CustomEditTextCell()) { @Override public String getValue(FSActionData object) { String op = object.getOp(); if (op.equals("move")) { if (object.getParams().containsKey("target") && object.getParams().get("target") != null) return object.getParams().get("target"); } else if (op.equals("chmod")) { if (object.getParams().containsKey("permissions") && object.getParams().get("permissions") != null) return object.getParams().get("permissions"); } return ""; } }; param2Col.setFieldUpdater(new FieldUpdater<FSActionData, String>() { @Override public void update(int index, FSActionData object, String value) { FSActionData d = dataProvider.getList().get(index); String op = d.getOp(); if (op.equals("move")) { d.getParams().put("target", value); } else if (op.equals("chmod")) { d.getParams().put("permissions", value); } } }); table.addColumn(param2Col, ""); // Add Label for 3rd parameter of chmod Column<FSActionData, String> label3Col = new Column<FSActionData, String>(new TextCell()) { public void render(Context context, SafeHtml value, SafeHtmlBuilder sb) { if (value != null) { FSActionData data = (FSActionData) context.getKey(); if (data.getOp().equals("chmod")) sb.append(value); } } @Override public String getValue(FSActionData object) { String rel = null; String op = object.getOp(); if (op.equals("chmod")) rel = "Chmod files within directory?(dir-files)"; return rel; } }; table.addColumn(label3Col); // Add Column for 3rd parameter of chmod // ( Recursive option not implemented in this version. need to add // another column for that. ) Column<FSActionData, String> param3Col = new Column<FSActionData, String>( new CustomSelectionCell(Arrays.asList("true", "false"))) { @Override public String getValue(FSActionData object) { String rel = null; String op = object.getOp(); if (op.equals("chmod")) rel = object.getParams().get("dir-files"); return rel; } }; param3Col.setFieldUpdater(new FieldUpdater<FSActionData, String>() { @Override public void update(int index, FSActionData object, String value) { FSActionData d = dataProvider.getList().get(index); String op = d.getOp(); if (op.equals("chmod")) { d.getParams().put("dir-files", value); } } }); table.addColumn(param3Col, ""); // Button to add row Column<FSActionData, String> addCol = new Column<FSActionData, String>(new ButtonCell()) { @Override public String getValue(FSActionData object) { return " + "; } }; addCol.setFieldUpdater(new FieldUpdater<FSActionData, String>() { @Override public void update(int index, FSActionData object, String value) { dataProvider.getList().add(index + 1, new FSActionData()); } }); table.addColumn(addCol, ""); // Button to delete row Column<FSActionData, String> delCol = new Column<FSActionData, String>(new ButtonCell()) { @Override public String getValue(FSActionData object) { return " - "; } }; delCol.setFieldUpdater(new FieldUpdater<FSActionData, String>() { @Override public void update(int index, FSActionData object, String value) { List<FSActionData> li = dataProvider.getList(); if (li.size() == 1) { FSActionData p = li.get(0); p.clear(); table.redraw(); } else { dataProvider.getList().remove(index); } } }); table.addColumn(delCol, ""); return table; }
From source file:org.apache.oozie.tools.workflowgenerator.client.property.action.SSHPropertyTable.java
License:Apache License
/** * Create a table showing list of arguments added by a user * * @param data/*from ww w.j av a 2 s . c o m*/ * @return */ protected CellTable<String> createArgsTable(List<String> data) { final CellTable<String> table = new CellTable<String>(); final ListDataProvider<String> dataProvider = new ListDataProvider<String>(); dataProvider.setList(data); dataProvider.addDataDisplay(table); // Add Name column Column<String, String> argCol = null; // when editText is used for name column argCol = new Column<String, String>(new TextInputCell()) { @Override public String getValue(String object) { return object; } }; // set event for updating value argCol.setFieldUpdater(new FieldUpdater<String, String>() { @Override public void update(int index, String object, String value) { List<String> li = dataProvider.getList(); li.remove(index); li.add(index, value); } }); table.addColumn(argCol, ""); // Button to add row Column<String, String> addCol = new Column<String, String>(new ButtonCell()) { @Override public String getValue(String object) { return " + "; } }; addCol.setFieldUpdater(new FieldUpdater<String, String>() { @Override public void update(int index, String object, String value) { List<String> li = dataProvider.getList(); li.add(index + 1, new String(" ")); } }); table.addColumn(addCol, ""); // Button to delete row Column<String, String> delCol = new Column<String, String>(new ButtonCell()) { @Override public String getValue(String object) { return " - "; } }; delCol.setFieldUpdater(new FieldUpdater<String, String>() { @Override public void update(int index, String object, String value) { List<String> li = dataProvider.getList(); li.remove(index); if (li.size() == 0) { li.add(" "); table.redraw(); } } }); table.addColumn(delCol, ""); return table; }