当前位置: 首页>>代码示例>>Java>>正文


Java JRDesignField类代码示例

本文整理汇总了Java中net.sf.jasperreports.engine.design.JRDesignField的典型用法代码示例。如果您正苦于以下问题:Java JRDesignField类的具体用法?Java JRDesignField怎么用?Java JRDesignField使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JRDesignField类属于net.sf.jasperreports.engine.design包,在下文中一共展示了JRDesignField类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getFields

import net.sf.jasperreports.engine.design.JRDesignField; //导入依赖的package包/类
@Override
public List<JRDesignField> getFields(DataAdapterService con, JasperReportsConfiguration jConfig, JRDataset jDataset) throws JRException, UnsupportedOperationException {
	Throwable t = null;
	ArrayList<JRDesignField> fields = new ArrayList<JRDesignField>();
	try {
		String fileName = getDataAdapter().getFileName();
		Document doc = JRXmlUtils.parse(new URL(fileName), XMLUtils.isNamespaceAware(getDataAdapter(), jConfig.getJasperDesign()));
		fields.addAll(getFieldsFromDocument(doc, jConfig, jDataset));
	} catch (IOException e) {
		t = e;
	}

	if (t != null) {
		UIUtils.showError(t);
	}
	return fields;
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:18,代码来源:RemoteXMLDataAdapterDescriptor.java

示例2: getFields

import net.sf.jasperreports.engine.design.JRDesignField; //导入依赖的package包/类
@Override
public List<JRDesignField> getFields(DataAdapterService con, JasperReportsConfiguration jConfig, JRDataset jDataset) throws JRException, UnsupportedOperationException {
	
	Map<String, Object> parameters = new HashMap<String, Object>();
	parameters.put("REPORT_PARAMETERS_MAP", new HashMap<String, Object>());
	try {
		//Here there is the password of the connection
		con.contributeParameters(parameters);
	} catch (JRException e) {
		e.printStackTrace();
	}
	ParameterUtil.setParameters(jConfig, jDataset, parameters);
	parameters.put(JRParameter.REPORT_MAX_COUNT, 2);
	Map<String,? extends JRValueParameter> tmpMap  = ParameterUtil.convertMap(parameters, jDataset);

	JRXmlaQueryExecuter qe = new JRXmlaQueryExecuter(jConfig, jDataset, tmpMap);
	JROlapResult result = qe.getResult();
	return OlapFieldsProviderSupport.getFieldsFromResult(result);
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:20,代码来源:XmlaFieldsProvider.java

示例3: extractFields

import net.sf.jasperreports.engine.design.JRDesignField; //导入依赖的package包/类
/**
 * Given a JSON selection query, extracts from the result set 
 * the list of possible fields that can be used in a report.
 * 
 * @param query the JSON query text
 * @return a list of fields
 */
public List<JRDesignField> extractFields(String query){
	JsonQueryHelper jsonQueryHelper=new JsonQueryHelper(mapper);
	try{
		JsonNode jsonData = jsonQueryHelper.getJsonData(jsonRoot, query);
		if(jsonData!=null){
			if(jsonData.isArray()){
				return getFieldsFromArrayNode((ArrayNode)jsonData);
			}
			else if(jsonData.isObject()){
				return getFieldsFromObjectNode((ObjectNode)jsonData);
			}
		}
	}catch (JRException e){
		// Do not care about error in node selection
	}
	return new ArrayList<JRDesignField>();
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:25,代码来源:JsonDataManager.java

示例4: getFieldsFromDocument

import net.sf.jasperreports.engine.design.JRDesignField; //导入依赖的package包/类
/**
 * Returns the list of fields provided by an XML document and the related
 * query.
 * 
 * @param doc
 *          the W3C XML document
 * @param jConfig
 *          the JasperReports configuration instance
 * @param jDataset
 *          the current dataset
 * @return the list of fields
 * @throws JRException
 */
protected List<JRDesignField> getFieldsFromDocument(Document doc, JasperReportsConfiguration jConfig, JRDataset jDataset) throws JRException {
	JRXPathExecuterFactory xPathExecuterFactory = JRXPathExecuterUtils.getXPathExecuterFactory(jConfig);
	JRXPathExecuter xPathExecuter = xPathExecuterFactory.getXPathExecuter();
	NodeList nodes = xPathExecuter.selectNodeList(doc, jDataset.getQuery().getText());
	LinkedHashMap<String, JRDesignField> fieldsMap = new LinkedHashMap<String, JRDesignField>();
	for (int nIdx = 0; nIdx < nodes.getLength(); nIdx++) {
		Node currNode = nodes.item(nIdx);
		findDirectChildrenAttributes(currNode,fieldsMap,"");
		if(currNode.getNodeType() == Node.ELEMENT_NODE) {
			NodeList childNodes = currNode.getChildNodes();
			findChildFields(childNodes, fieldsMap,"");
		}
	}
	return new ArrayList<JRDesignField>(fieldsMap.values());
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:29,代码来源:XMLDataAdapterDescriptor.java

示例5: findChildFields

import net.sf.jasperreports.engine.design.JRDesignField; //导入依赖的package包/类
private void findChildFields(NodeList nodes, LinkedHashMap<String, JRDesignField> fieldsMap,String prefix) {
	if(nodes!=null) {
		List<String> childrenNames = new ArrayList<String>(); // temp list to avoid duplicates at the same level
		for (int i = 0; i < nodes.getLength(); i++) {
			Node item = nodes.item(i);
			String nodeName = item.getNodeName();
			if((item.getNodeType() == Node.ELEMENT_NODE || item.getNodeType() == Node.ATTRIBUTE_NODE) && 
					!childrenNames.contains(nodeName)) {
				if(recursiveFind) {
					findDirectChildrenAttributes(item,fieldsMap,prefix+nodeName+"/");
				}
				addNewField(nodeName, fieldsMap, item, prefix);
				if(recursiveFind && item.hasChildNodes()){
					findChildFields(item.getChildNodes(), fieldsMap,prefix+nodeName+"/");
				}
			}
		}
	}
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:20,代码来源:XMLDataAdapterDescriptor.java

示例6: getFields

import net.sf.jasperreports.engine.design.JRDesignField; //导入依赖的package包/类
@Override
public List<JRDesignField> getFields(DataAdapterService con, JasperReportsConfiguration jConfig, JRDataset jDataset) throws JRException, UnsupportedOperationException {
	Map<String, Object> parameters = new HashMap<String, Object>();
	con.contributeParameters(parameters);

	ParameterUtil.setParameters(jConfig, jDataset, parameters);
	parameters.put(JRParameter.REPORT_MAX_COUNT, 0);

	// JasperReports query executer instances require
	// REPORT_PARAMETERS_MAP parameter to be defined and not null
	Map<String, JRValueParameter> tmpMap = ParameterUtil.convertMap(parameters, jDataset);
	tmpMap.put(JRParameter.REPORT_PARAMETERS_MAP, new SimpleValueParameter(new HashMap<String, JRValueParameter>()));

	JRMondrianQueryExecuter qe = new JRMondrianQueryExecuter(jConfig, jDataset, tmpMap);
	qe.createDatasource();

	JRMondrianResult result = new JRMondrianResult(qe.getResult());
	return OlapFieldsProviderSupport.getFieldsFromResult(result);
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:20,代码来源:MondrianFieldsProvider.java

示例7: readFields

import net.sf.jasperreports.engine.design.JRDesignField; //导入依赖的package包/类
@Override
public List<JRDesignField> readFields() throws Exception {
	if (getDataAdapterDescriptor() != null && getDataAdapterDescriptor() instanceof IFieldsProvider) {
		try {
			return ((IFieldsProvider) getDataAdapterDescriptor()).getFields(
					DataAdapterServiceUtil.getInstance(getJasperReportsConfiguration()).getService(
							getDataAdapterDescriptor().getDataAdapter()), getJasperReportsConfiguration(), getDataset());

		} catch (JRException ex) {
			// Cleanup of the error. JRException are a very low meaningful exception when working
			// with data, what the user is interested into is the underline error (i.e. an SQL error).
			// That's why we rise the real cause, if any instead of rising the highlevel exception...
			if (ex.getCause() != null && ex.getCause() instanceof Exception) {
				throw (Exception) ex.getCause();
			}
			throw ex;
		}
	}
	return new ArrayList<JRDesignField>();
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:21,代码来源:EmptyWizardDataEditorComposite.java

示例8: getNameForField

import net.sf.jasperreports.engine.design.JRDesignField; //导入依赖的package包/类
/**
 * Creates a valid name for a JRField element.
 * <p>
 * It searches the existing fields in order to check for field name validity. If no other field is found with the same
 * name, then the <code>namePrefix</code> itself is used.
 * 
 * @param fields
 *          list of already existing fields
 * @param namePrefix
 *          name prefix for new field name
 * @return a valid name for the JRField
 */
public static String getNameForField(List<JRDesignField> fields, String namePrefix) {
	boolean match = false;
	String tmp = namePrefix;
	for (int i = 0; i < 100000; i++) {
		if (i != 0)
			tmp = ModelUtils.getNameFormat(namePrefix, i);
		for (JRField f : fields) {
			match = f.getName().equals(tmp);
			if (match)
				break;
		}
		if (!match)
			break;
	}
	return tmp;
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:29,代码来源:ModelUtils.java

示例9: setPropertyValue

import net.sf.jasperreports.engine.design.JRDesignField; //导入依赖的package包/类
public void setPropertyValue(Object id, Object value) {
	JRDesignField jrField = (JRDesignField) getValue();
	if (id.equals(JRDesignParameter.PROPERTY_NAME)) {
		if (!value.equals("")) {
			jrField.setName((String) value);
		}
	} else if (id.equals(JRDesignParameter.PROPERTY_VALUE_CLASS_NAME)){
		jrField.setValueClassName((String) value);
	}
	else if (id.equals(JRDesignParameter.PROPERTY_DESCRIPTION)){
		jrField.setDescription((String) value);
	}
	else if (id.equals(PROPERTY_MAP)) {
		JRPropertiesMap v = (JRPropertiesMap) value;
		String[] names = jrField.getPropertiesMap().getPropertyNames();
		for (int i = 0; i < names.length; i++) {
			jrField.getPropertiesMap().removeProperty(names[i]);
		}
		names = v.getPropertyNames();
		for (int i = 0; i < names.length; i++)
			jrField.getPropertiesMap().setProperty(names[i], v.getProperty(names[i]));
		this.getPropertyChangeSupport().firePropertyChange(PROPERTY_MAP, false, true);
	}
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:25,代码来源:MField.java

示例10: storeSettings

import net.sf.jasperreports.engine.design.JRDesignField; //导入依赖的package包/类
public void storeSettings(Object settings) {
    getWizardPanel().getWizard().putProperty("table_type", jRadioButton1.isSelected() ? 0 : 1);
    getWizardPanel().getWizard().putProperty("dataset", jComboBoxDataset.getSelectedItem());
    if (jComboBoxDataset.getSelectedItem() != null)
    {
        List<JRDesignField> list = new ArrayList<JRDesignField>();
        List fieldsList = ((JRDesignDataset)jComboBoxDataset.getSelectedItem()).getFieldsList();
        for (int i=0; i<fieldsList.size(); ++i)
        {
            list.add((JRDesignField)fieldsList.get(i));
        }
        getWizardPanel().getWizard().putProperty("discoveredFields", list );
        getWizardPanel().getWizard().putProperty("discoveredFieldsNeedRefresh","true");
    }
    getWizardPanel().getWizard().putProperty("columns", jSpinner1.getValue());
}
 
开发者ID:JockiHendry,项目名称:ireport-fork,代码行数:17,代码来源:TableVisualPanel1.java

示例11: propertyChange

import net.sf.jasperreports.engine.design.JRDesignField; //导入依赖的package包/类
public void propertyChange(PropertyChangeEvent evt) {
    
    com.jaspersoft.ireport.designer.IReportManager.getInstance().notifyReportChange();
    if (evt.getPropertyName() == null) return;
    if (evt.getPropertyName().equals( JRDesignField.PROPERTY_NAME ))
    {
        super.setName(getField().getName());
        this.setDisplayName(getField().getName());
        // update sorting of childrens...
        if (this.getParentNode() != null && this.getParentNode() instanceof FieldsNode)
        {
            SwingUtilities.invokeLater(new Runnable() {

                public void run() {
                    ((FieldsNode)(FieldNode.this.getParentNode())).updateSorting();
                }
            });
        }
    }
    
    // Update the sheet
    this.firePropertyChange(evt.getPropertyName(), evt.getOldValue(), evt.getNewValue() );
}
 
开发者ID:JockiHendry,项目名称:ireport-fork,代码行数:24,代码来源:FieldNode.java

示例12: recalculateKeys

import net.sf.jasperreports.engine.design.JRDesignField; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void recalculateKeys() {
    
    List l = (List)lock();
    l.clear();
    l.addAll(dataset.getFieldsList());
    if (getNode() != null && getNode() instanceof FieldsNode)
    {
        if (((FieldsNode)getNode()).isSort())
        {
            // Order elements by name...
            Object[] fields = dataset.getFieldsList().toArray();
            Arrays.sort(fields, new Comparator() {

                public int compare(Object o1, Object o2) {
                    return ((JRDesignField)o1).getName().compareToIgnoreCase(((JRDesignField)o2).getName());
                }
            });
            l.clear();
            l.addAll(Arrays.asList(fields));
        }
    }

    update();
}
 
开发者ID:JockiHendry,项目名称:ireport-fork,代码行数:26,代码来源:FieldsChildren.java

示例13: createReportElement

import net.sf.jasperreports.engine.design.JRDesignField; //导入依赖的package包/类
@Override
public JRDesignElement createReportElement(JasperDesign jasperDesign)
{
    JRDesignTextField element = (JRDesignTextField)super.createReportElement( jasperDesign );

    JRDesignField field = (JRDesignField)getPaletteItem().getData();

    ((JRDesignExpression)element.getExpression()).setText("$F{"+ field.getName() + "}");
    setMatchingClassExpression(
        ((JRDesignExpression)element.getExpression()), 
        field.getValueClassName(), 
        true
        );

    return element;
}
 
开发者ID:JockiHendry,项目名称:ireport-fork,代码行数:17,代码来源:CreateTextFieldFromFieldAction.java

示例14: fieldAlreadyExists

import net.sf.jasperreports.engine.design.JRDesignField; //导入依赖的package包/类
private boolean fieldAlreadyExists(JRDesignField field)
{
    boolean found = false;
        for (int j=0; j<getJTableFields().getRowCount(); ++j)
        {
           Object ff = getJTableFields().getValueAt(j, 0);
           if ( ff instanceof JRDesignField )
           {
               if ( ((JRDesignField)ff).getName().equals(field.getName()))
               {
                   found = true;
                   break;
               }
           }
        }
    
    return found;
}
 
开发者ID:JockiHendry,项目名称:ireport-fork,代码行数:19,代码来源:OlapBrowser.java

示例15: getFields

import net.sf.jasperreports.engine.design.JRDesignField; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public Vector getFields(Object obj)
{
    
    Vector fields = new Vector();
    java.beans.PropertyDescriptor[] pd = org.apache.commons.beanutils.PropertyUtils.getPropertyDescriptors(obj.getClass());
    for (int nd =0; nd < pd.length; ++nd)
    {
               String fieldName = pd[nd].getName();
               if (pd[nd].getPropertyType() != null && pd[nd].getReadMethod() != null)
               {
                   String returnType =  pd[nd].getPropertyType().getName();
                   JRDesignField field = new JRDesignField();
                   field.setName(fieldName);
                   field.setValueClassName(Misc.getJRFieldType(returnType));
                   //field.setDescription(""); //Field returned by " +methods[i].getName() + " (real type: "+ returnType +")");
                   fields.addElement(field);
               }
    }
    
    return fields;
    
    
}
 
开发者ID:JockiHendry,项目名称:ireport-fork,代码行数:25,代码来源:EJBQLFieldsReader.java


注:本文中的net.sf.jasperreports.engine.design.JRDesignField类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。