public void onSave() { // TODO: validate if the XML is valid RuleContentText rct = new RuleContentText(); rct.content = text.getText(); asset.content = rct; }
public void onSave(SaveCommand saveCommand) { data.content = ""; for (EnumRow enumRow : dataProvider.getList()) { data.content += enumRow.getText() + "\n"; } saveCommand.save(); }
public DefaultRuleContentWidget(RuleAsset a, int visibleLines) { asset = a; data = (RuleContentText) asset.getContent(); if (data.content == null) { data.content = ""; } text = new TextArea(); text.setWidth("100%"); text.setVisibleLines((visibleLines == -1) ? 16 : visibleLines); text.setText(data.content); text.getElement().setAttribute("spellcheck", "false"); // NON-NLS text.setStyleName("default-text-Area"); // NON-NLS text.addChangeHandler( new ChangeHandler() { public void onChange(ChangeEvent event) { data.content = text.getText(); makeDirty(); } }); text.addKeyDownHandler( new KeyDownHandler() { public void onKeyDown(KeyDownEvent event) { if (event.getNativeKeyCode() == KeyCodes.KEY_TAB) { int pos = text.getCursorPos(); insertText("\t"); text.setCursorPos(pos + 1); text.cancelKey(); text.setFocus(true); } } }); initWidget(text); }
public XmlFileWidget(final RuleAsset asset, final RuleViewer viewer) { super(asset, viewer); data = (RuleContentText) asset.getContent(); if (data.content == null) { data.content = ""; } text = new TextArea(); text.setWidth("100%"); text.setVisibleLines(16); text.setText(data.content); text.setStyleName("default-text-Area"); text.addChangeHandler( new ChangeHandler() { public void onChange(ChangeEvent event) { data.content = text.getText(); } }); layout.addRow(text); }
public void onSave() { data.content = text.getText(); asset.setContent(data); }
public WorkitemDefinitionEditor(RuleAsset a, int visibleLines) { asset = a; data = (RuleContentText) asset.getContent(); if (data.content == null) { data.content = "Empty!"; } Grid layout = new Grid(1, 2); WorkitemDefinitionElementsBrowser browser = new WorkitemDefinitionElementsBrowser( new WorkitemDefinitionElementSelectedListener() { public void onElementSelected(String elementName, String pasteValue) { insertText(pasteValue, true); } }); layout.setWidget(0, 0, browser); text = new TextArea(); text.setWidth("100%"); text.setVisibleLines((visibleLines == -1) ? 25 : visibleLines); text.setText(data.content); text.getElement().setAttribute("spellcheck", "false"); // NON-NLS text.setStyleName("default-text-Area"); // NON-NLS text.addChangeHandler( new ChangeHandler() { public void onChange(ChangeEvent event) { data.content = text.getText(); makeDirty(); } }); text.addKeyDownHandler( new KeyDownHandler() { public void onKeyDown(KeyDownEvent event) { if (event.getNativeKeyCode() == KeyCodes.KEY_TAB) { event.preventDefault(); event.stopPropagation(); int pos = text.getCursorPos(); insertText("\t", false); text.setCursorPos(pos + 1); text.cancelKey(); text.setFocus(true); } } }); layout.setWidget(0, 1, text); layout.getColumnFormatter().setWidth(0, "10%"); layout.getColumnFormatter().setWidth(1, "90%"); layout .getCellFormatter() .setAlignment(0, 0, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_TOP); layout .getCellFormatter() .setAlignment(0, 1, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_TOP); layout.setWidth("95%"); initWidget(layout); }
public EnumEditor(Asset a, int visibleLines) { data = (RuleContentText) a.getContent(); if (data.content == null) { data.content = ""; } cellTable = new CellTable<EnumRow>(); cellTable.setWidth("100%"); panel = new VerticalPanel(); String[] array = data.content.split("\n"); for (String line : array) { EnumRow enumRow = new EnumRow(line); dataProvider.getList().add(enumRow); } DeleteButtonCell deleteButton = new DeleteButtonCell(); Column<EnumRow, String> delete = new Column<EnumRow, String>(deleteButton) { @Override public String getValue(EnumRow enumRow1) { return ""; } }; Column<EnumRow, String> columnFirst = new Column<EnumRow, String>(new EditTextCell()) { @Override public String getValue(EnumRow enumRow) { return enumRow.getFactName(); } }; Column<EnumRow, String> columnSecond = new Column<EnumRow, String>(new EditTextCell()) { @Override public String getValue(EnumRow enumRow) { return enumRow.getFieldName(); } }; Column<EnumRow, String> columnThird = new Column<EnumRow, String>(new EditTextCell()) { @Override public String getValue(EnumRow enumRow) { return enumRow.getContext(); } }; columnFirst.setFieldUpdater( new FieldUpdater<EnumRow, String>() { public void update(int index, EnumRow object, String value) { object.setFactName(value); } }); columnSecond.setFieldUpdater( new FieldUpdater<EnumRow, String>() { public void update(int index, EnumRow object, String value) { object.setFieldName(value); } }); columnThird.setFieldUpdater( new FieldUpdater<EnumRow, String>() { public void update(int index, EnumRow object, String value) { object.setContext(value); } }); cellTable.addColumn(delete); cellTable.addColumn(columnFirst, "Fact"); cellTable.addColumn(columnSecond, "Field"); cellTable.addColumn(columnThird, "Context"); // Connect the table to the data provider. dataProvider.addDataDisplay(cellTable); delete.setFieldUpdater( new FieldUpdater<EnumRow, String>() { public void update(int index, EnumRow object, String value) { dataProvider.getList().remove(object); } }); Button addButton = new Button( "+", new ClickHandler() { public void onClick(ClickEvent clickEvent) { EnumRow enumRow = new EnumRow(""); dataProvider.getList().add(enumRow); } }); panel.add(cellTable); panel.add(addButton); initWidget(panel); }