private int[] getSelectedRows(int[] selectedRowsNumber, Map[] selectedRowsKeys, Tab tab) { if (selectedRowsKeys == null || selectedRowsKeys.length == 0) return new int[0]; // selectedRowsNumber is the most performant so we use it when possible else if (selectedRowsNumber.length == selectedRowsKeys.length) return selectedRowsNumber; else { // find the rows from the selectedKeys // This has a poor performance, but it covers the case when the selected // rows are not loaded for the tab, something that can occurs if the user // select rows and afterwards reorder the list. try { int[] s = new int[selectedRowsKeys.length]; List selectedKeys = Arrays.asList(selectedRowsKeys); int end = tab.getTableModel().getTotalSize(); int x = 0; for (int i = 0; i < end; i++) { Map key = (Map) tab.getTableModel().getObjectAt(i); if (selectedKeys.contains(key)) { s[x] = i; x++; } } return s; } catch (Exception ex) { log.warn(XavaResources.getString("fails_selected"), ex); throw new XavaException("fails_selected"); } } }
public void movePropertyToLeft(int index) { if (propertiesNames == null) return; if (index <= 0) return; Object aux = propertiesNames.get(index); propertiesNames.set(index, propertiesNames.get(index - 1)); propertiesNames.set(index - 1, aux); resetAfterAddRemoveProperty(); }
public void movePropertyToRight(int index) { if (propertiesNames == null) return; if (index >= propertiesNames.size() - 1) return; Object aux = propertiesNames.get(index); propertiesNames.set(index, propertiesNames.get(index + 1)); propertiesNames.set(index + 1, aux); resetAfterAddRemoveProperty(); }
public List<String> getPropertiesNamesWithKeyAndHidden() throws XavaException { if (propertiesNamesWithKeyAndHidden == null) { propertiesNamesWithKeyAndHidden = new ArrayList<String>(); propertiesNamesWithKeyAndHidden.addAll(getMetaModel().getAllKeyPropertiesNames()); propertiesNamesWithKeyAndHidden.addAll(getPropertiesNames()); propertiesNamesWithKeyAndHidden.addAll(getHiddenPropertiesNames()); } return propertiesNamesWithKeyAndHidden; }
// assert(!areAllProperties()); private List createPropertiesNames() { StringTokenizer st = new StringTokenizer(removeTotalProperties(properties), ",;"); List result = new ArrayList(); while (st.hasMoreTokens()) { String name = st.nextToken().trim(); if (name.endsWith("+")) { name = name.substring(0, name.length() - 1); if (sumPropertiesNames == null) sumPropertiesNames = new HashSet(); sumPropertiesNames.add(name); } result.add(name); } return result; }
private boolean calculateWithValidValues() { Iterator it = metaProperties.iterator(); while (it.hasNext()) { MetaProperty m = (MetaProperty) it.next(); if (m.hasValidValues()) return true; } return false; }
public List namesToMetaProperties(Collection names) throws XavaException { List metaProperties = new ArrayList(); Iterator it = names.iterator(); int i = -1; while (it.hasNext()) { i++; String name = (String) it.next(); MetaProperty metaPropertyTab = null; try { MetaProperty metaProperty = getMetaModel().getMetaProperty(name).cloneMetaProperty(); metaProperty.setQualifiedName(name); String labelId = null; if (representCollection()) { labelId = getId() + "." + name; // If there is no specific translation for the collection, // we take the translation from the default tab. if (!Labels.existsExact(labelId)) { labelId = getIdForDefaultTab() + ".properties." + name; } } else { labelId = getId() + ".properties." + name; } if (Labels.exists(labelId)) { metaProperty.setLabelId(labelId); } else if (metaPropertiesTab != null) { // By now only the label overwritten from the property of tab metaPropertyTab = (MetaProperty) metaPropertiesTab.get(name); if (metaPropertyTab != null) { metaProperty = metaProperty.cloneMetaProperty(); metaProperty.setLabel(metaPropertyTab.getLabel()); } } metaProperties.add(metaProperty); } catch (ElementNotFoundException ex) { MetaProperty notInEntity = new MetaProperty(); notInEntity.setName(name); notInEntity.setTypeName("java.lang.Object"); if (metaPropertyTab != null) { notInEntity.setLabel(metaPropertyTab.getLabel()); } metaProperties.add(notInEntity); } } return metaProperties; }
private List createAllPropertiesNames() throws XavaException { List result = new ArrayList(); // First the properties from a possible @EmbeddedId for (Iterator itRef = getMetaModel().getMetaReferencesKey().iterator(); itRef.hasNext(); ) { MetaReference ref = (MetaReference) itRef.next(); if (ref.isAggregate()) { for (Iterator itKey = ref.getMetaModelReferenced() .getPropertiesNamesWithoutHiddenNorTransient() .iterator(); itKey.hasNext(); ) { result.add(ref.getName() + "." + itKey.next()); } } } // Now the plain properties result.addAll(getMetaModel().getPropertiesNamesWithoutHiddenNorTransient()); return result; }
/** * Hidden ones are not included * * @return Not null, read only and of type <tt>MetaProperty</tt>. */ public Collection getMetaPropertiesCalculated() throws XavaException { if (metaPropertiesCalculated == null) { metaPropertiesCalculated = new ArrayList(); Iterator it = getMetaProperties().iterator(); while (it.hasNext()) { MetaProperty metaProperty = (MetaProperty) it.next(); if (metaProperty.isCalculated()) { metaPropertiesCalculated.add(metaProperty); } } } return metaPropertiesCalculated; }
private MetaProperty getMetaProperty(int i) { return (MetaProperty) metaProperties.get(i); }
public List getRemainingPropertiesNames() throws XavaException { List result = new ArrayList(getMetaModel().getRecursiveQualifiedPropertiesNames()); result.removeAll(getPropertiesNames()); return result; }
/** For dynamically remove all properties to this tab */ public void clearProperties() { if (propertiesNames == null) return; propertiesNames.clear(); resetAfterAddRemoveProperty(); }
/** For dynamically remove properties to this tab */ public void removeProperty(int index) { if (propertiesNames == null) return; propertiesNames.remove(index); resetAfterAddRemoveProperty(); }
/** For dynamically remove properties to this tab */ public void removeProperty(String propertyName) { if (propertiesNames == null) return; propertiesNames.remove(propertyName); resetAfterAddRemoveProperty(); }
/** For dynamically add properties to this tab */ public void addProperty(int index, String propertyName) { if (propertiesNames == null) return; propertiesNames.add(index, propertyName); resetAfterAddRemoveProperty(); }