List of usage examples for com.google.gwt.user.cellview.client Column setFieldUpdater
public void setFieldUpdater(FieldUpdater<T, C> fieldUpdater)
From source file:org.obiba.opal.web.gwt.app.client.magma.variable.view.CategoriesEditorModalView.java
License:Open Source License
private void renderMissingColumn() { Column<CategoryDto, Boolean> missingCol = new Column<CategoryDto, Boolean>(new CheckboxCell(true, false)) { @Override/*from w ww .ja v a 2 s. co m*/ public Boolean getValue(CategoryDto object) { // Get the value from the selection model. return object.getIsMissing(); } }; missingCol.setFieldUpdater(new FieldUpdater<CategoryDto, Boolean>() { @Override public void update(int index, CategoryDto object, Boolean value) { object.setIsMissing(value); } }); table.addColumn(missingCol, translations.missingLabel()); }
From source file:org.obiba.opal.web.gwt.app.client.magma.variable.view.CategoriesEditorModalView.java
License:Open Source License
private void renderLocalizedCategoryRows(final String localeName) { Column<CategoryDto, String> labelCol = new EditableTabableColumn<CategoryDto>() { @Override/*from w ww . j ava2 s . co m*/ public String getValue(CategoryDto object) { AttributeDto label = VariableDtos.getAttribute(object, LABEL, localeName); return label == null ? "" : Strings.nullToEmpty(label.getValue()); } }; labelCol.setFieldUpdater(new FieldUpdater<CategoryDto, String>() { @Override public void update(int index, CategoryDto object, String value) { AttributeDto label = VariableDtos.getAttribute(object, LABEL, localeName); if (label == null) { // Create new attribute VariableDtos.createAttribute(object, LABEL, localeName, value); } else { label.setValue(value); } } }); String headerString = translations.labelLabel(); if (!localeName.isEmpty()) { headerString += " (" + translations.localeMap().get(localeName) + ")"; } table.addColumn(labelCol, headerString); }
From source file:org.opennms.features.gwt.snmpselect.list.client.view.SnmpSelectTable.java
License:Open Source License
private void initializeColumns() { setRowStyles(new RowStyles<SnmpCellListItem>() { @Override//from w w w . jav a2 s. c o m public String getStyleNames(SnmpCellListItem cellListItem, int rowIndex) { String bgStyle = null; if (cellListItem.getIfAdminStatus() != 1) { bgStyle = "onms-ipinterface-status-unknown"; } else if (cellListItem.getIfAdminStatus() == 1 && cellListItem.getIfOperStatus() == 1) { bgStyle = "onms-ipinterface-status-up"; } else if (cellListItem.getIfAdminStatus() == 1 && cellListItem.getIfOperStatus() != 1) { bgStyle = "onms-ipinterface-status-down"; } return bgStyle; } }); SnmpTextColumn ifIndexColumn = new SnmpTextColumn() { @Override public String getValue(SnmpCellListItem item) { return item.getIfIndex(); } }; addColumn(ifIndexColumn, "Index"); SnmpTextColumn snmpIfType = new SnmpTextColumn() { @Override public String getValue(SnmpCellListItem item) { return item.getSnmpType(); } }; addColumn(snmpIfType, "SNMP ifType"); SnmpTextColumn snmpIfDescr = new SnmpTextColumn() { @Override public String getValue(SnmpCellListItem item) { return item.getIfDescr(); } }; addColumn(snmpIfDescr, "SNMP ifDescr"); SnmpTextColumn snmpIfName = new SnmpTextColumn() { @Override public String getValue(SnmpCellListItem item) { return item.getIfName(); } }; addColumn(snmpIfName, "SNMP ifName"); SnmpTextColumn snmpIfAlias = new SnmpTextColumn() { @Override public String getValue(SnmpCellListItem item) { return item.getIfAlias(); } }; addColumn(snmpIfAlias, "SNMP ifAlias"); List<String> collectList = new ArrayList<String>(); collectList.add("Collect"); collectList.add("Don't Collect"); collectList.add("Default"); SelectionCell collectSelection = new SelectionCell(collectList); Column<SnmpCellListItem, String> collectColumn = new Column<SnmpCellListItem, String>(collectSelection) { @Override public String getValue(SnmpCellListItem item) { if (item.getCollectFlag().equals("C") || item.getCollectFlag().equals("UC")) { return "Collect"; } else if (item.getCollectFlag().equals("N") || item.getCollectFlag().equals("UN")) { return "Don't Collect"; } else if (item.getCollectFlag().equals("Default")) { return "Default"; } else { return "Default"; } } }; collectColumn.setFieldUpdater(new FieldUpdater<SnmpCellListItem, String>() { @Override public void update(int index, SnmpCellListItem object, String value) { String newCollectFlag = object.getCollectFlag(); if (value.equals("Collect")) { newCollectFlag = "UC"; } else if (value.equals("Don't Collect")) { newCollectFlag = "UN"; } else if (value.equals("Default")) { newCollectFlag = "Default"; } object.setCollectFlag(newCollectFlag); if (getCollectUpdateHandler() != null) { getCollectUpdateHandler().onSnmpInterfaceCollectUpdated(Integer.parseInt(object.getIfIndex()), object.getCollectFlag(), newCollectFlag); } } }); addColumn(collectColumn, "Collect"); }
From source file:org.pepstock.jem.gwt.client.panels.jobs.input.InputTable.java
License:Open Source License
/** * Adds all columns to table, defining the sort columns too. *///from ww w . ja v a 2 s . c o m @Override public IndexedColumnComparator<Job> initCellTable(CellTable<Job> table) { @SuppressWarnings("unchecked") final SelectionModel<Job> selectionModel = (SelectionModel<Job>) table.getSelectionModel(); Column<Job, Boolean> checkColumn = new Column<Job, Boolean>(new CheckboxCell(true, false)) { @Override public Boolean getValue(Job job) { return selectionModel.isSelected(job); } }; CheckboxCell headerCheckBox = new CheckboxCell(true, false); Header<Boolean> checkHeader = new Header<Boolean>(headerCheckBox) { // imposta lo stato dell'header! @Override public Boolean getValue() { // se e' vuoto, niente e' selezionato/selezionabile if (getTable().getVisibleItems().isEmpty()) { return false; } // altrimenti testo for (Job j : getTable().getVisibleItems()) { // se almeno un elemento non e' selezionato, l'header non deve essere selezionato if (!getTable().getSelectionModel().isSelected(j)) { return false; } } // altrimenti se arrivo qui, tutti gli elementi sono selezionati return true; } }; // updater che seleziona o deseleziona tutti gli elementi visibili in base al "valore" dell'header checkHeader.setUpdater(new ValueUpdater<Boolean>() { @Override public void update(Boolean value) { for (Job j : getTable().getVisibleItems()) { getTable().getSelectionModel().setSelected(j, value); } } }); table.setColumnWidth(checkColumn, 23, Unit.PX); table.addColumn(checkColumn, checkHeader); /*-------------------------+ | NAME | +-------------------------*/ // construct a column that uses anchorRenderer AnchorTextColumn<Job> name = new AnchorTextColumn<Job>() { @Override public String getValue(Job object) { return object.getName(); } @Override public void onClick(int index, Job object, String value) { getInspectListener().inspect(object); } }; name.setSortable(true); if (hasFilterableHeaders()) { table.addColumn(name, new TextFilterableHeader("Name", JobFilterFields.NAME.getName())); } else { table.addColumn(name, "Name"); } /*-------------------------+ | TYPE | +-------------------------*/ TextColumn<Job> type = new TextColumn<Job>() { @Override public String getValue(Job job) { return job.getJcl().getType(); } }; type.setSortable(true); if (hasFilterableHeaders()) { table.addColumn(type, new TextFilterableHeader("Type", JobFilterFields.TYPE.getName())); } else { table.addColumn(type, "Type"); } /*-------------------------+ | USER | +-------------------------*/ TextColumn<Job> userid = new TextColumn<Job>() { @Override public String getValue(Job job) { // if surrogates, use ONLY user in JCL definition return (job.isUserSurrogated()) ? job.getJcl().getUser() : job.getUser(); } }; userid.setSortable(true); if (hasFilterableHeaders()) { table.addColumn(userid, new TextFilterableHeader("User", JobFilterFields.USER.getName())); } else { table.addColumn(userid, "User"); } /*-------------------------+ | ENVIRONMENT | +-------------------------*/ if (ClientPermissions.isAuthorized(Permissions.JOBS, Permissions.JOBS_UPDATE)) { Column<Job, String> environment = new Column<Job, String>(new EditTextCell()) { @Override public String getValue(Job object) { return object.getJcl().getEnvironment(); } }; environment.setFieldUpdater(new FieldUpdater<Job, String>() { @Override public void update(int index, Job job, String value) { if (value != null && value.trim().length() > 0) { if (!value.equalsIgnoreCase(job.getJcl().getEnvironment())) { job.getJcl().setEnvironment(value); updateJob(job); } return; } refresh(); } }); if (hasFilterableHeaders()) { table.addColumn(environment, new TextFilterableHeader("Environment", JobFilterFields.ENVIRONMENT.getName())); } else { table.addColumn(environment, "Environment"); } } else { TextColumn<Job> environment = new TextColumn<Job>() { @Override public String getValue(Job job) { Jcl jcl = job.getJcl(); return jcl.getEnvironment(); } }; environment.setSortable(true); if (hasFilterableHeaders()) { table.addColumn(environment, new TextFilterableHeader("Environment", JobFilterFields.ENVIRONMENT.getName())); } else { table.addColumn(environment, "Environment"); } } /*-------------------------+ | DOMAIN | +-------------------------*/ if (ClientPermissions.isAuthorized(Permissions.JOBS, Permissions.JOBS_UPDATE)) { Column<Job, String> domain = new Column<Job, String>(new EditTextCell()) { @Override public String getValue(Job object) { return object.getJcl().getDomain(); } }; domain.setSortable(true); domain.setFieldUpdater(new FieldUpdater<Job, String>() { @Override public void update(int index, Job job, String valueParm) { String value = valueParm; if (value != null) { if (value.trim().length() == 0) { value = Jcl.DEFAULT_DOMAIN; } if (!value.equalsIgnoreCase(job.getJcl().getDomain())) { job.getJcl().setDomain(value); updateJob(job); } return; } refresh(); } }); if (hasFilterableHeaders()) { table.addColumn(domain, new TextFilterableHeader("Domain", JobFilterFields.DOMAIN.getName())); } else { table.addColumn(domain, "Domain"); } } else { TextColumn<Job> domain = new TextColumn<Job>() { @Override public String getValue(Job job) { Jcl jcl = job.getJcl(); return jcl.getDomain(); } }; domain.setSortable(true); if (hasFilterableHeaders()) { table.addColumn(domain, new TextFilterableHeader("Domain", JobFilterFields.DOMAIN.getName())); } else { table.addColumn(domain, "Domain"); } } /*-------------------------+ | STATIC AFFINITIES | +-------------------------*/ if (ClientPermissions.isAuthorized(Permissions.JOBS, Permissions.JOBS_UPDATE)) { Column<Job, String> affinity = new Column<Job, String>(new EditTextCell()) { @Override public String getValue(Job object) { return object.getJcl().getAffinity(); } }; affinity.setSortable(true); affinity.setFieldUpdater(new FieldUpdater<Job, String>() { @Override public void update(int index, Job job, String valueParm) { String value = valueParm; if (value != null) { if (value.trim().length() == 0) { value = Jcl.DEFAULT_AFFINITY; } if (!value.equalsIgnoreCase(job.getJcl().getAffinity())) { job.getJcl().setAffinity(value); updateJob(job); } return; } refresh(); } }); if (hasFilterableHeaders()) { table.addColumn(affinity, new TextFilterableHeader("Affinity", JobFilterFields.AFFINITY.getName())); } else { table.addColumn(affinity, "Affinity"); } } else { TextColumn<Job> affinity = new TextColumn<Job>() { @Override public String getValue(Job job) { Jcl jcl = job.getJcl(); return jcl.getAffinity(); } }; affinity.setSortable(true); if (hasFilterableHeaders()) { table.addColumn(affinity, new TextFilterableHeader("Affinity", JobFilterFields.AFFINITY.getName())); } else { table.addColumn(affinity, "Affinity"); } } /*-------------------------+ | SUBMITTED DATE | +-------------------------*/ TextColumn<Job> submittedDate = new TextColumn<Job>() { @Override public String getValue(Job job) { return JemConstants.DATE_TIME_FULL.format(job.getSubmittedTime()); } }; submittedDate.setSortable(true); if (hasFilterableHeaders()) { table.addColumn(submittedDate, new TextFilterableHeader("Submitted time", JobFilterFields.SUBMITTED_TIME.getName(), JobFilterFields.SUBMITTED_TIME.getPattern())); } else { table.addColumn(submittedDate, "Submitted time"); } /*-------------------------+ | PRIORITY | +-------------------------*/ if (ClientPermissions.isAuthorized(Permissions.JOBS, Permissions.JOBS_UPDATE)) { Column<Job, String> priority = new Column<Job, String>(new EditTextCell()) { @Override public String getValue(Job job) { Jcl jcl = job.getJcl(); return String.valueOf(jcl.getPriority()); } }; priority.setSortable(true); priority.setFieldUpdater(new FieldUpdater<Job, String>() { @Override public void update(int index, Job job, String value) { if (value != null) { int prio = job.getJcl().getPriority(); try { prio = Integer.parseInt(value); if (prio != job.getJcl().getPriority()) { job.getJcl().setPriority(prio); updateJob(job); return; } } catch (Exception e) { LogClient.getInstance().warning(e.getMessage(), e); new Toast(MessageLevel.ERROR, "Value '" + value + "' assigned is NOT valid.", "Priority not changed!").show(); } } refresh(); } }); if (hasFilterableHeaders()) { table.addColumn(priority, new TextFilterableHeader("Priority", JobFilterFields.PRIORITY.getName())); } else { table.addColumn(priority, "Priority"); } } else { TextColumn<Job> priority = new TextColumn<Job>() { @Override public String getValue(Job job) { Jcl jcl = job.getJcl(); return String.valueOf(jcl.getPriority()); } }; if (hasFilterableHeaders()) { table.addColumn(priority, new TextFilterableHeader("Priority", JobFilterFields.PRIORITY.getName())); } else { table.addColumn(priority, "Priority"); } } /*-------------------------+ | MEMORY | +-------------------------*/ if (ClientPermissions.isAuthorized(Permissions.JOBS, Permissions.JOBS_UPDATE)) { Column<Job, String> memory = new Column<Job, String>(new EditTextCell()) { @Override public String getValue(Job job) { Jcl jcl = job.getJcl(); return String.valueOf(jcl.getMemory()); } }; memory.setSortable(true); memory.setFieldUpdater(new FieldUpdater<Job, String>() { @Override public void update(int index, Job job, String value) { if (value != null) { int mem = job.getJcl().getMemory(); try { mem = Integer.parseInt(value); if (mem != job.getJcl().getMemory()) { job.getJcl().setMemory(mem); updateJob(job); return; } } catch (Exception e) { LogClient.getInstance().warning(e.getMessage(), e); new Toast(MessageLevel.ERROR, "Value '" + value + "' assigned is NOT valid.", "Memory not changed!").show(); } } refresh(); } }); if (hasFilterableHeaders()) { table.addColumn(memory, new TextFilterableHeader("Memory (MB)", JobFilterFields.MEMORY.getName())); } else { table.addColumn(memory, "Memory (MB)"); } } else { TextColumn<Job> memory = new TextColumn<Job>() { @Override public String getValue(Job job) { Jcl jcl = job.getJcl(); return String.valueOf(jcl.getMemory()); } }; if (hasFilterableHeaders()) { table.addColumn(memory, new TextFilterableHeader("Memory (MB)", JobFilterFields.MEMORY.getName())); } else { table.addColumn(memory, "Memory (MB)"); } } /*-------------------------+ | HOLD | +-------------------------*/ TextColumn<Job> hold = new TextColumn<Job>() { @Override public String getValue(Job job) { Jcl jcl = job.getJcl(); return (jcl.isHold()) ? "hold" : ""; } }; hold.setSortable(true); table.addColumn(hold, "Hold"); return new InputJobComparator(1); }
From source file:org.pepstock.jem.gwt.client.panels.nodes.NodesTable.java
License:Open Source License
/** * Adds all columns to table, defining the sort columns too. */// w w w. j a v a 2s .c o m @Override public IndexedColumnComparator<NodeInfoBean> initCellTable(final CellTable<NodeInfoBean> table) { /*-------------------------+ | CHECK BOX FOR SELECTION | +-------------------------*/ @SuppressWarnings("unchecked") final SelectionModel<NodeInfoBean> selectionModel = (SelectionModel<NodeInfoBean>) table .getSelectionModel(); Column<NodeInfoBean, Boolean> checkColumn = new Column<NodeInfoBean, Boolean>( new CheckboxCell(true, false)) { @Override public Boolean getValue(NodeInfoBean nodeInfoBean) { return selectionModel.isSelected(nodeInfoBean); } }; CheckboxCell headerCheckBox = new CheckboxCell(true, false); Header<Boolean> checkHeader = new Header<Boolean>(headerCheckBox) { // imposta lo stato dell'header! @Override public Boolean getValue() { // se e' vuoto, niente e' selezionato/selezionabile if (getTable().getVisibleItems().isEmpty()) { return false; } // altrimenti testo for (NodeInfoBean n : getTable().getVisibleItems()) { // se almeno un elemento non e' selezionato, l'header non deve essere selezionato if (!getTable().getSelectionModel().isSelected(n)) { return false; } } // altrimenti se arrivo qui, tutti gli elementi sono selezionati return true; } }; // updater che seleziona o deseleziona tutti gli elementi visibili in base al "valore" dell'header checkHeader.setUpdater(new ValueUpdater<Boolean>() { @Override public void update(Boolean value) { for (NodeInfoBean n : getTable().getVisibleItems()) { getTable().getSelectionModel().setSelected(n, value); } } }); table.setColumnWidth(checkColumn, 23, Unit.PX); table.addColumn(checkColumn, checkHeader); /*-------------------------+ | IPADDRESS AND PORT | +-------------------------*/ // construct a column that uses anchorRenderer AnchorTextColumn<NodeInfoBean> name = new AnchorTextColumn<NodeInfoBean>() { @Override public String getValue(NodeInfoBean object) { return object.getLabel(); } @Override public void onClick(int index, NodeInfoBean object, String value) { getInspectListener().inspect(object); } }; name.setSortable(true); table.addColumn(name, new TextFilterableHeader("Name", NodeFilterFields.NAME.getName())); /*-------------------------+ | HOST NAME | +-------------------------*/ TextColumn<NodeInfoBean> hostname = new TextColumn<NodeInfoBean>() { @Override public String getValue(NodeInfoBean nodeInfoBean) { return nodeInfoBean.getHostname(); } }; hostname.setSortable(true); table.addColumn(hostname, new TextFilterableHeader("Hostname", NodeFilterFields.HOSTNAME.getName())); /*-------------------------+ | DOMAIN | +-------------------------*/ if (ClientPermissions.isAuthorized(Permissions.NODES, Permissions.NODES_UPDATE)) { Column<NodeInfoBean, String> domain = new Column<NodeInfoBean, String>(new EditTextCell()) { @Override public String getValue(NodeInfoBean nodeInfoBean) { return nodeInfoBean.getExecutionEnvironment().getDomain(); } }; domain.setSortable(true); domain.setFieldUpdater(new DomainFieldUpdater()); table.addColumn(domain, new TextFilterableHeader("Domain", NodeFilterFields.DOMAIN.getName())); } else { TextColumn<NodeInfoBean> domain = new TextColumn<NodeInfoBean>() { @Override public String getValue(NodeInfoBean nodeInfoBean) { return nodeInfoBean.getExecutionEnvironment().getDomain(); } }; domain.setSortable(true); table.addColumn(domain, new TextFilterableHeader("Domain", NodeFilterFields.DOMAIN.getName())); } /*-------------------------+ | STATIC AFFINITIES | +-------------------------*/ if (ClientPermissions.isAuthorized(Permissions.NODES, Permissions.NODES_UPDATE)) { Column<NodeInfoBean, String> affinity = new Column<NodeInfoBean, String>(new EditTextCell()) { @Override public String getValue(NodeInfoBean nodeInfoBean) { return toAffinityString(nodeInfoBean.getExecutionEnvironment().getStaticAffinities()); } }; affinity.setSortable(true); affinity.setFieldUpdater(new FieldUpdater<NodeInfoBean, String>() { @Override public void update(int index, NodeInfoBean nodeInfoBean, String valueParm) { String value = valueParm; if (value != null) { if (value.trim().length() == 0) { value = Jcl.DEFAULT_AFFINITY; } nodeInfoBean.getExecutionEnvironment().getStaticAffinities().clear(); String[] affinities = value.split(","); for (int i = 0; i < affinities.length; i++) { nodeInfoBean.getExecutionEnvironment().getStaticAffinities().add(affinities[i]); } updateNode(nodeInfoBean); return; } refresh(); } }); table.addColumn(affinity, new TextFilterableHeader("Static Affinities", NodeFilterFields.STATIC_AFFINITIES.getName())); } else { TextColumn<NodeInfoBean> affinity = new TextColumn<NodeInfoBean>() { @Override public String getValue(NodeInfoBean nodeInfoBean) { return toAffinityString(nodeInfoBean.getExecutionEnvironment().getStaticAffinities()); } }; affinity.setSortable(true); table.addColumn(affinity, new TextFilterableHeader("Static Affinities", NodeFilterFields.STATIC_AFFINITIES.getName())); } /*-------------------------+ | DYNAMIC AFFINITIES | +-------------------------*/ TextColumn<NodeInfoBean> dynAffinity = new TextColumn<NodeInfoBean>() { @Override public String getValue(NodeInfoBean nodeInfoBean) { return toAffinityString(nodeInfoBean.getExecutionEnvironment().getDynamicAffinities()); } }; dynAffinity.setSortable(true); table.addColumn(dynAffinity, new TextFilterableHeader("Dynamic Affinities", NodeFilterFields.DYNAMIC_AFFINITIES.getName())); /*-------------------------+ | STATUS | +-------------------------*/ StatusColumn status = new StatusColumn(); status.setSortable(true); table.addColumn(status, new TextFilterableHeader("Status", NodeFilterFields.STATUS.getName())); /*-------------------------+ | OS NAME | +-------------------------*/ TextColumn<NodeInfoBean> systemName = new TextColumn<NodeInfoBean>() { @Override public String getValue(NodeInfoBean nodeInfoBean) { return nodeInfoBean.getSystemName(); } }; systemName.setSortable(true); table.addColumn(systemName, new TextFilterableHeader("OS", NodeFilterFields.OS.getName())); /*-------------------------+ | Memory | +-------------------------*/ if (ClientPermissions.isAuthorized(Permissions.NODES, Permissions.NODES_UPDATE)) { Column<NodeInfoBean, String> memory = new Column<NodeInfoBean, String>(new EditTextCell()) { @Override public String getValue(NodeInfoBean nodeInfoBean) { return String.valueOf(nodeInfoBean.getExecutionEnvironment().getMemory()); } }; memory.setSortable(true); memory.setFieldUpdater(new MemoryFieldUpdater()); table.addColumn(memory, new TextFilterableHeader("Memory (MB)", NodeFilterFields.MEMORY.getName())); } else { TextColumn<NodeInfoBean> memory = new TextColumn<NodeInfoBean>() { @Override public String getValue(NodeInfoBean nodeInfoBean) { return String.valueOf(nodeInfoBean.getExecutionEnvironment().getMemory()); } }; memory.setSortable(true); table.addColumn(memory, new TextFilterableHeader("Memory (MB)", NodeFilterFields.MEMORY.getName())); } /*-------------------------+ | Parallel jobs | +-------------------------*/ if (ClientPermissions.isAuthorized(Permissions.NODES, Permissions.NODES_UPDATE)) { Column<NodeInfoBean, String> parallelJobs = new Column<NodeInfoBean, String>(new EditTextCell()) { @Override public String getValue(NodeInfoBean nodeInfoBean) { return String.valueOf(nodeInfoBean.getExecutionEnvironment().getParallelJobs()); } }; parallelJobs.setSortable(true); parallelJobs.setFieldUpdater(new ParallelJobsFieldUpdater()); table.addColumn(parallelJobs, new TextFilterableHeader("Parallel Jobs", NodeFilterFields.PARALLEL_JOBS.getName())); } else { TextColumn<NodeInfoBean> parallelJobs = new TextColumn<NodeInfoBean>() { @Override public String getValue(NodeInfoBean nodeInfoBean) { return String.valueOf(nodeInfoBean.getExecutionEnvironment().getParallelJobs()); } }; parallelJobs.setSortable(true); table.addColumn(parallelJobs, new TextFilterableHeader("Parallel Jobs", NodeFilterFields.PARALLEL_JOBS.getName())); } /*-------------------------+ | CURRENT JOB | +-------------------------*/ TextColumn<NodeInfoBean> currentJob = new TextColumn<NodeInfoBean>() { @Override public String getValue(NodeInfoBean nodeInfoBean) { if (nodeInfoBean.getJobNames().isEmpty()) { return ""; } else if (nodeInfoBean.getJobNames().size() > 1) { return String.valueOf(nodeInfoBean.getJobNames().size()); } return nodeInfoBean.getJobNames().get(0); } }; currentJob.setSortable(true); table.addColumn(currentJob, new TextFilterableHeader("Running Jobs", NodeFilterFields.CURRENT_JOB.getName())); // adds a cell handler to catch the click on column of running jobs // to show the list of jobs table.addCellPreviewHandler(new JobsListCellPreviewHandler(table)); return new NodesComparator(1); }
From source file:org.pepstock.jem.gwt.client.panels.resources.inspector.widgets.CustomPropertiesTable.java
License:Open Source License
/** * Adds all columns to table, defining the sort columns too. */// w w w . j a v a 2 s. co m @Override public IndexedColumnComparator<ResourceProperty> initCellTable(final CellTable<ResourceProperty> table) { /*-------------------------+ | KEY | +-------------------------*/ Column<ResourceProperty, String> key = new Column<ResourceProperty, String>(new EditTextCell()) { @Override public String getValue(ResourceProperty property) { return property.getName(); } }; key.setSortable(false); key.setFieldUpdater(new KeyFieldUpdater()); table.addColumn(key, "Key"); table.setColumnWidth(key, 50, Unit.PCT); /*-------------------------+ | VALUE | +-------------------------*/ Column<ResourceProperty, String> value = new Column<ResourceProperty, String>(new EditTextCell()) { @Override public String getValue(ResourceProperty property) { return property.getValue(); } }; value.setSortable(false); value.setFieldUpdater(new ValueFieldUpdater()); table.addColumn(value, "Value"); table.setColumnWidth(value, 50, Unit.PCT); return new CustomPropertiesComparator(1); }
From source file:org.phrasebook.transword.client.CwAdminTerminBox.java
License:Apache License
private void initTableColumns(final SelectionModel<FixedExpression> selectionModel, ListHandler<FixedExpression> sortHandler) { // Fixed Expression Column<FixedExpression, String> fixedExpression = new Column<FixedExpression, String>(new TextCell()) { @Override//from www . ja va 2s . c o m public String getValue(FixedExpression object) { return object.getCoreString(); } }; fixedExpression.setSortable(true); sortHandler.setComparator(fixedExpression, new Comparator<FixedExpression>() { public int compare(FixedExpression o1, FixedExpression o2) { return o1.getCoreString().compareTo(o2.getCoreString()); } }); dataGrid.addColumn(fixedExpression, "Fixed Expression"); fixedExpression.setFieldUpdater(new FieldUpdater<FixedExpression, String>() { public void update(int index, FixedExpression object, String value) { // Called when the user changes the value. object.setCoreString(value); dataProvider.refresh(); } }); dataGrid.setColumnWidth(fixedExpression, 50, Unit.PCT); // Meaning Column<FixedExpression, String> meaningColumn = new Column<FixedExpression, String>(new TextCell()) { @Override public String getValue(FixedExpression object) { return object.getDefinition_short(); } }; meaningColumn.setSortable(true); sortHandler.setComparator(meaningColumn, new Comparator<FixedExpression>() { public int compare(FixedExpression o1, FixedExpression o2) { return o1.getDefinition_short().compareTo(o2.getDefinition_short()); } }); dataGrid.addColumn(meaningColumn, "Definition"); meaningColumn.setFieldUpdater(new FieldUpdater<FixedExpression, String>() { public void update(int index, FixedExpression object, String value) { // Called when the user changes the value. object.setDefinition_short(value); dataProvider.refresh(); } }); dataGrid.setColumnWidth(meaningColumn, 20, Unit.PCT); // English Translation. Column<FixedExpression, String> engColumn = new Column<FixedExpression, String>(new TextCell()) { @Override public String getValue(FixedExpression object) { return object.getEngTranslation(); } }; engColumn.setSortable(true); sortHandler.setComparator(engColumn, new Comparator<FixedExpression>() { public int compare(FixedExpression o1, FixedExpression o2) { return o1.getEngTranslation().compareTo(o2.getEngTranslation()); } }); dataGrid.addColumn(engColumn, "In English"); engColumn.setFieldUpdater(new FieldUpdater<FixedExpression, String>() { public void update(int index, FixedExpression object, String value) { // Called when the user changes the value. object.setEngTranslation(value); dataProvider.refresh(); } }); dataGrid.setColumnWidth(engColumn, 30, Unit.PCT); // Usage Style. Column<FixedExpression, String> usColumn = new Column<FixedExpression, String>(new TextCell()) { @Override public String getValue(FixedExpression object) { return object.getUsageStyle(); } }; usColumn.setSortable(true); sortHandler.setComparator(usColumn, new Comparator<FixedExpression>() { public int compare(FixedExpression o1, FixedExpression o2) { return o1.getUsageStyle().compareTo(o2.getUsageStyle()); } }); dataGrid.addColumn(usColumn, "Usage Style"); dataGrid.setColumnWidth(usColumn, 20, Unit.PCT); }
From source file:org.phrasebook.transword.client.CwDictionaryPanel.java
License:Apache License
private void initTableColumns(final SelectionModel<FixedExpression> selectionModel, ListHandler<FixedExpression> sortHandler) { int count = dataGrid.getColumnCount(); for (int i = 0; i < count; i++) { dataGrid.removeColumn(0);/* ww w.j a v a 2 s. c o m*/ } // Data Grid. // Fixed Expression Column<FixedExpression, String> fixedExpression = new Column<FixedExpression, String>(new TextCell()) { @Override public String getValue(FixedExpression object) { return object.getCoreString(); } }; fixedExpression.setSortable(true); sortHandler.setComparator(fixedExpression, new Comparator<FixedExpression>() { public int compare(FixedExpression o1, FixedExpression o2) { return o1.getCoreString().compareTo(o2.getCoreString()); } }); System.out.println("CLMN CNT:" + dataGrid.getColumnIndex(fixedExpression)); // if(dataGrid.getColumnIndex(fixedExpression)>0){ // System.out.println("CLMN CNT:"+dataGrid.getColumnIndex(fixedExpression)); // dataGrid.removeColumn(fixedExpression); // } dataGrid.addColumn(fixedExpression, "Fixed Expression"); fixedExpression.setFieldUpdater(new FieldUpdater<FixedExpression, String>() { public void update(int index, FixedExpression object, String value) { // Called when the user changes the value. object.setCoreString(value); dataProvider.refresh(); } }); dataGrid.setColumnWidth(fixedExpression, 30, Unit.PCT); if (!meanFlag) { // Meaning Column<FixedExpression, String> meaningColumn = new Column<FixedExpression, String>(new TextCell()) { @Override public String getValue(FixedExpression object) { return object.getDefinition_short(); } }; meaningColumn.setSortable(true); sortHandler.setComparator(meaningColumn, new Comparator<FixedExpression>() { public int compare(FixedExpression o1, FixedExpression o2) { return o1.getDefinition_short().compareTo(o2.getDefinition_short()); } }); // if(dataGrid.getColumnIndex(meaningColumn)>0){ // dataGrid.removeColumn(meaningColumn); // } dataGrid.addColumn(meaningColumn, "Definition"); meaningColumn.setFieldUpdater(new FieldUpdater<FixedExpression, String>() { public void update(int index, FixedExpression object, String value) { // Called when the user changes the value. object.setDefinition_short(value); dataProvider.refresh(); } }); dataGrid.setColumnWidth(meaningColumn, 20, Unit.PCT); } // English Translation. Column<FixedExpression, String> engColumn = new Column<FixedExpression, String>(new TextCell()) { @Override public String getValue(FixedExpression object) { return object.getEngTranslation(); } }; engColumn.setSortable(true); sortHandler.setComparator(engColumn, new Comparator<FixedExpression>() { public int compare(FixedExpression o1, FixedExpression o2) { return o1.getEngTranslation().compareTo(o2.getEngTranslation()); } }); dataGrid.addColumn(engColumn, "In English"); engColumn.setFieldUpdater(new FieldUpdater<FixedExpression, String>() { public void update(int index, FixedExpression object, String value) { // Called when the user changes the value. object.setEngTranslation(value); dataProvider.refresh(); } }); dataGrid.setColumnWidth(engColumn, 30, Unit.PCT); // Grammar Information if (!infoFlag) { Column<FixedExpression, String> grColumn = new Column<FixedExpression, String>(new TextCell()) { @Override public String getValue(FixedExpression object) { String grammars = ""; for (Grammar g : object.getGrammars()) { grammars += g.getGrammar() + " "; } System.out.println(grammars); return grammars; } }; grColumn.setSortable(true); sortHandler.setComparator(grColumn, new Comparator<FixedExpression>() { public int compare(FixedExpression o1, FixedExpression o2) { String grammars1 = null, grammars2 = null; for (Grammar g : o1.getGrammars()) { grammars1 += g.getGrammar(); } for (Grammar g : o1.getGrammars()) { grammars2 += g.getGrammar(); } return grammars1.compareTo(grammars2); } }); dataGrid.addColumn(grColumn, "Grammar"); dataGrid.setColumnWidth(grColumn, 20, Unit.PCT); } if (useFlag || meanFlag || infoFlag) { // Examples Column<FixedExpression, String> exColumn = new Column<FixedExpression, String>(new TextCell()) { @Override public String getValue(FixedExpression object) { String examples = ""; for (Example e : object.getExamples()) { if (!useFlag) examples += e.getExample() + " en:" + e.getEngTranslation() + "\n"; else examples += e.getExample() + "\n"; } System.out.println(examples); return examples; } }; exColumn.setSortable(true); sortHandler.setComparator(exColumn, new Comparator<FixedExpression>() { public int compare(FixedExpression o1, FixedExpression o2) { String ex1 = null, ex2 = null; for (Example e : o1.getExamples()) { ex1 += e.getExample(); } for (Example e : o2.getExamples()) { ex2 += e.getExample(); } return ex1.compareTo(ex2); } }); dataGrid.addColumn(exColumn, "Example"); dataGrid.setColumnWidth(exColumn, 20, Unit.PCT); // Collocations Column<FixedExpression, String> clColumn = new Column<FixedExpression, String>(new TextCell()) { @Override public String getValue(FixedExpression object) { String cols = ""; for (Collocation c : object.getCollocations()) { if (!useFlag) cols += c.getCollocation() + " en:" + c.getEngTranslation() + "\n"; else cols += c.getCollocation() + "\n"; } System.out.println(cols); return cols; } }; clColumn.setSortable(true); sortHandler.setComparator(exColumn, new Comparator<FixedExpression>() { public int compare(FixedExpression o1, FixedExpression o2) { String c1 = null, c2 = null; for (Collocation c : o1.getCollocations()) { c1 += c.getCollocation(); } for (Collocation c : o2.getCollocations()) { c2 += c.getCollocation(); } return c1.compareTo(c2); } }); dataGrid.addColumn(clColumn, "Collocation"); dataGrid.setColumnWidth(clColumn, 20, Unit.PCT); } if (infoFlag) { // Synonyms Column<FixedExpression, String> sColumn = new Column<FixedExpression, String>(new TextCell()) { @Override public String getValue(FixedExpression object) { String ss = ""; for (Synonym s : object.getSynonyms()) { ss += s.getSynonym() + " "; } System.out.println(ss); return ss; } }; sColumn.setSortable(true); sortHandler.setComparator(sColumn, new Comparator<FixedExpression>() { public int compare(FixedExpression o1, FixedExpression o2) { String s1 = null, s2 = null; for (Synonym s : o1.getSynonyms()) { s1 += s.getSynonym(); } for (Synonym s : o1.getSynonyms()) { s2 += s.getSynonym(); } return s1.compareTo(s2); } }); dataGrid.addColumn(sColumn, "Synonym"); dataGrid.setColumnWidth(sColumn, 20, Unit.PCT); // Antonyms Column<FixedExpression, String> aColumn = new Column<FixedExpression, String>(new TextCell()) { @Override public String getValue(FixedExpression object) { String as = ""; for (Antonym a : object.getAntonyms()) { as += a.getAntonym() + " "; } System.out.println(as); return as; } }; aColumn.setSortable(true); sortHandler.setComparator(aColumn, new Comparator<FixedExpression>() { public int compare(FixedExpression o1, FixedExpression o2) { String a1 = null, a2 = null; for (Antonym a : o1.getAntonyms()) { a1 += a.getAntonym(); } for (Antonym a : o1.getAntonyms()) { a2 += a.getAntonym(); } return a1.compareTo(a2); } }); dataGrid.addColumn(aColumn, "Antonym"); dataGrid.setColumnWidth(aColumn, 20, Unit.PCT); } }
From source file:org.rstudio.core.client.widget.ModifyKeyboardShortcutsWidget.java
License:Open Source License
private Column<KeyboardShortcutEntry, String> editableTextColumn(String name, final ValueGetter<KeyboardShortcutEntry> getter) { EditTextCell editTextCell = new EditTextCell() { @Override//from ww w. ja v a 2 s . co m public void onBrowserEvent(final Context context, final Element parent, final String value, final NativeEvent event, final ValueUpdater<String> updater) { // GWT's EditTextCell will reset the text of the cell to the last // entered text on an Escape keypress. We don't desire that // behaviour (we want to restore the _first_ value presented when // the user opened the widget); so instead we just blur the input // element (thereby committing the current selection) and ensure // that selection has been appropriately reset in an earlier preview // handler. if (event.getType().equals("keyup") && event.getKeyCode() == KeyCodes.KEY_ESCAPE) { parent.getFirstChildElement().blur(); return; } super.onBrowserEvent(context, parent, value, event, updater); } }; Column<KeyboardShortcutEntry, String> column = new Column<KeyboardShortcutEntry, String>(editTextCell) { @Override public String getValue(KeyboardShortcutEntry binding) { return getter.getValue(binding); } }; column.setFieldUpdater(new FieldUpdater<KeyboardShortcutEntry, String>() { @Override public void update(int index, KeyboardShortcutEntry binding, String value) { KeySequence keys = KeySequence.fromShortcutString(value); // Differentiate between resetting the key sequence and // adding a new key sequence. if (keys.equals(binding.getOriginalKeySequence())) { changes_.remove(binding); binding.restoreOriginalKeySequence(); } else { KeyboardShortcutEntry newBinding = new KeyboardShortcutEntry(binding.getId(), binding.getName(), keys, binding.getCommandType(), true, binding.getContext()); changes_.put(binding, newBinding); binding.setKeySequence(keys); } table_.setKeyboardSelectedColumn(0); updateData(dataProvider_.getList()); } }); column.setSortable(true); table_.addColumn(column, new TextHeader(name)); return column; }
From source file:org.rstudio.studio.client.workbench.views.environment.view.EnvironmentObjectDisplay.java
License:Open Source License
protected void attachClickToInvoke(Column<RObjectEntry, String> column) { column.setFieldUpdater(new FieldUpdater<RObjectEntry, String>() { @Override// ww w .ja va2s . co m public void update(int index, RObjectEntry object, String value) { if (object.getCategory() == RObjectEntry.Categories.Data && host_.enableClickableObjects()) { observer_.viewObject(object.rObject.getName()); } } }); }