Java 类net.sf.jasperreports.engine.design.JRDesignQuery 实例源码

项目:PDFReporter-Studio    文件:TableTemplateEngine.java   
@Override
public void setReportDataAdapter(ReportBundle bundle, DataAdapterDescriptor dataadapter, JRPropertiesMap properties) {
    JRDesignDataset tableDataset = (JRDesignDataset)bundle.getJasperDesign().getDatasetMap().get("tableDataset"); //$NON-NLS-1$
    JasperDesign jd = bundle.getJasperDesign();
    for (String key : properties.getPropertyNames()){
        jd.setProperty(key, properties.getProperty(key));
        if (key.contains("ireport")) tableDataset.setProperty(key, properties.getProperty(key)); //$NON-NLS-1$
    }
    tableDataset.setProperty(DataQueryAdapters.DEFAULT_DATAADAPTER, dataadapter.getName());
    jd.setProperty(DataQueryAdapters.DEFAULT_DATAADAPTER, dataadapter.getName());

    //Remove the main dataset query
    JRDesignDataset mainDataset = jd.getMainDesignDataset();

    ((JRDesignQuery) mainDataset.getQuery()).setText(null);
    ((JRDesignQuery) mainDataset.getQuery()).setLanguage(null);
    for (JRField field : mainDataset.getFields())
        mainDataset.removeField(field);
}
项目:PDFReporter-Studio    文件:DataQueryAdapters.java   
private void changeLanguage() {
    if (!isRefresh) {
        qStatus.showInfo("");
        String lang = langCombo.getText();
        ((JRDesignQuery) newdataset.getQuery()).setLanguage(lang);
        final IQueryDesigner designer = qdfactory.getDesigner(lang);
        langLayout.topControl = designer.getControl();
        tbLayout.topControl = designer.getToolbarControl();
        tbCompo.layout();
        langComposite.layout();
        currentDesigner = designer;
        currentDesigner.setJasperConfiguration(jConfig);
        UIUtils.getDisplay().asyncExec(new Runnable() {

            @Override
            public void run() {
                currentDesigner.setQuery(jDesign, newdataset, jConfig);
                currentDesigner.setDataAdapter(dscombo.getSelected());
            }
        });
    }
}
项目:PDFReporter-Studio    文件:JRQueryPage.java   
@Override
public void dispose() {
    String lang = "";
    int selectionIndex = langCombo.getSelectionIndex();
    if (selectionIndex < 0)
        lang = langCombo.getText().trim();
    else
        lang = langCombo.getItem(selectionIndex);
    String text = queryText.getText();

    if (lang.equals("") && (text == null || text.equals("")))
        value = new MQuery(null, null);
    else {
        JRDesignQuery jrQuery = new JRDesignQuery();
        jrQuery.setLanguage(lang);
        jrQuery.setText(text);
        value = new MQuery(jrQuery, null);
    }
    super.dispose();
}
项目:PDFReporter-Studio    文件:JRQueryPage.java   
private void setWidgets() {
    String lang = (String) value.getPropertyValue(JRDesignQuery.PROPERTY_LANGUAGE);
    if (lang == null)
        lang = "sql"; //$NON-NLS-1$
    lang = ModelUtils.getLanguage(lang);
    String[] items = langCombo.getItems();
    for (int i = 0; i < items.length; i++) {
        if (items[i].equals(lang)) {
            langCombo.select(i);
            break;
        }
    }
    if (langCombo.getSelectionIndex() < 0)
        langCombo.setText(lang);

    String text = (String) value.getPropertyValue(JRDesignQuery.PROPERTY_TEXT);
    if (text == null)
        text = ""; //$NON-NLS-1$
    queryText.setText(text);
}
项目:PDFReporter-Studio    文件:JRQueryLabelProvider.java   
@Override
public String getText(Object element) {
    if (element != null && element instanceof MQuery) {
        MQuery mQuery = (MQuery) element;
        String lang = (String) mQuery.getPropertyValue(JRDesignQuery.PROPERTY_LANGUAGE);
        if (lang == null)
            lang = "";
        else
            lang = "<" + lang + ">";
        String txt = (String) mQuery.getPropertyValue(JRDesignQuery.PROPERTY_TEXT);
        if (txt == null)
            txt = "";
        return lang + txt; //$NON-NLS-1$
    }
    if (element == null || !(element instanceof JRDesignQuery))
        return canBeNull.getName();
    JRDesignQuery query = (JRDesignQuery) element;
    return query.getText();
}
项目:ireport-fork    文件:DatasetNode.java   
public void setValue(Object val) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {

        JRDesignQuery oldValue = (JRDesignQuery)dataset.getQuery();
        String lang = (val == null) ? "SQL" : val+"";
        if (lang.trim().length() == 0) lang = "SQL";

        JRDesignQuery newValue = new JRDesignQuery();
        if (oldValue != null && oldValue.getText() != null)
        {
            newValue.setText(oldValue.getText());
        }

        newValue.setLanguage(lang);

        dataset.setQuery(newValue);

        ObjectPropertyUndoableEdit urob =
                new ObjectPropertyUndoableEdit(
                    dataset,
                    "Query", 
                    JRDesignQuery.class,
                    oldValue,newValue);
        // Find the undoRedo manager...
        IReportManager.getInstance().addUndoableEdit(urob);
}
项目:ireport-fork    文件:DatasetNode.java   
public void propertyChange(final PropertyChangeEvent evt) {

    com.jaspersoft.ireport.designer.IReportManager.getInstance().notifyReportChange();
    if (evt.getPropertyName() == null) return;

    if(acceptProperty(evt))
    {
        this.firePropertyChange(evt.getPropertyName(), evt.getOldValue(), evt.getNewValue());
        if (evt.getPropertyName().equals( JRDesignDataset.PROPERTY_NAME ))
        {
            this.fireDisplayNameChange(null, null);
        }
    }

    if (evt.getPropertyName().equals(JRDesignDataset.PROPERTY_QUERY))
    {
        firePropertyChange(JRDesignQuery.PROPERTY_TEXT, evt.getOldValue(), evt.getNewValue());
        firePropertyChange(JRDesignQuery.PROPERTY_LANGUAGE,  evt.getOldValue(), evt.getNewValue());
    }
}
项目:ireport-fork    文件:DatasetNode.java   
/**
 *  This method looks if the property name is one of those handled by this node type.
 */
public static boolean acceptProperty(PropertyChangeEvent evt) {

    if (evt.getPropertyName() == null) return false;
    if (evt.getPropertyName().equals( JRDesignDataset.PROPERTY_NAME ) ||
        evt.getPropertyName().equals( JRDesignDataset.PROPERTY_RESOURCE_BUNDLE ) ||
        evt.getPropertyName().equals( JRDesignDataset.PROPERTY_SCRIPTLET_CLASS ) ||
        evt.getPropertyName().equals( JRDesignDataset.PROPERTY_FILTER_EXPRESSION) ||
        evt.getPropertyName().equals( "WhenNoDataType") ||
        evt.getPropertyName().equals( JRDesignQuery.PROPERTY_TEXT) ||
        evt.getPropertyName().equals( JRDesignQuery.PROPERTY_LANGUAGE))
    {
        return true;
    }
    return false;
}
项目:ireport-fork    文件:JDBCConnection.java   
public List<JRDesignField> readFields(String query) throws Exception {

    SQLFieldsProvider provider = new SQLFieldsProvider();
    List<JRDesignField> result = new ArrayList<JRDesignField>();
    JRDesignDataset dataset = new JRDesignDataset(true);
    JRDesignQuery dquery = new JRDesignQuery();
    dquery.setLanguage("SQL");
    dquery.setText(query);
    dataset.setQuery(dquery);
    JRField[] fields = provider.getFields(this, dataset, new HashMap());
    for (int i=0; i<fields.length; ++i)
    {
        result.add((JRDesignField)fields[i]);
    }

    return result;
}
项目:ireport-fork    文件:JDBCNBConnection.java   
public List<JRDesignField> readFields(String query) throws Exception {

    SQLFieldsProvider provider = new SQLFieldsProvider();
    List<JRDesignField> result = new ArrayList<JRDesignField>();
    JRDesignDataset dataset = new JRDesignDataset(true);
    JRDesignQuery dquery = new JRDesignQuery();
    dquery.setLanguage("SQL");
    dquery.setText(query);
    dataset.setQuery(dquery);
    JRField[] fields = provider.getFields(this, dataset, new HashMap());
    for (int i=0; i<fields.length; ++i)
    {
        result.add((JRDesignField)fields[i]);
    }

    return result;
}
项目:ireport-fork    文件:MongoDbConnection.java   
@Override
public List<JRDesignField> readFields(String query) throws Exception {
    MongoDbFieldsProvider provider = new MongoDbFieldsProvider();
    List<JRDesignField> result = new ArrayList<JRDesignField>();
    JRDesignDataset dataset = new JRDesignDataset(true);
    JRDesignQuery designQuery = new JRDesignQuery();
    designQuery.setLanguage(MongoDbDataSource.QUERY_LANGUAGE);
    designQuery.setText(query);
    dataset.setQuery(designQuery);
    Map<String, String> parameters = new HashMap<String, String>();
    JRField[] fields = provider.getFields(this, dataset, parameters);
    for (int i = 0; i < fields.length; ++i) {
        result.add((JRDesignField) fields[i]);
    }
    return result;
}
项目:jasperreports    文件:JRQueryFactory.java   
@Override
public Object createObject(Attributes atts)
{
    JRDesignQuery query = new JRDesignQuery();

    String language = atts.getValue(JRXmlConstants.ATTRIBUTE_language);
    if (language != null)
    {
        query.setLanguage(language);
    }

    return query;
}
项目:TG-BUYME    文件:ProdutoProntoDAO.java   
@SuppressWarnings({ "rawtypes", "unchecked" })
public void gerarRelatorioEstoquePdf(String sql, int totalProdutos){
    try{
        String caminhoSalvar = "";
        DirectoryChooser directoryChooser = new DirectoryChooser();
           File selectedDirectory = directoryChooser.showDialog(null);

           if(selectedDirectory == null){
               System.out.println("N�o selecionou nada");
           }else{
               caminhoSalvar = selectedDirectory.getAbsolutePath();
           }
           if(!caminhoSalvar.isEmpty()){
            Connection conn = new ConexaoBD().getConnection();
            HashMap param = new HashMap();
            param.put("totalProdutos", totalProdutos);
            JasperDesign jd = JRXmlLoader.load("src/main/java/br/com/buyme/report/VerificaEstoque.jrxml");
            JRDesignQuery newQuery = new JRDesignQuery();
            newQuery.setText(sql);
            jd.setQuery(newQuery);
            JasperReport jr = JasperCompileManager.compileReport(jd);
            JasperPrint jp = JasperFillManager.fillReport(jr, param,conn);
            JasperExportManager.exportReportToPdfFile(jp,caminhoSalvar+"/Estoque.pdf");
            conn.close();
           }
    }catch(Exception e){
        e.printStackTrace();
    }
}
项目:TG-BUYME    文件:RelatorioMotivoPerdaLoteDAO.java   
@SuppressWarnings({ "rawtypes", "unchecked" })
public void gerarRelatorioPdf(String sql){
    try{
        String caminhoSalvar = "";
        DirectoryChooser directoryChooser = new DirectoryChooser();
           File selectedDirectory = directoryChooser.showDialog(null);

           if(selectedDirectory == null){
               System.out.println("N�o selecionou nada");
           }else{
               caminhoSalvar = selectedDirectory.getAbsolutePath();
           }
           if(!caminhoSalvar.isEmpty()){
            Connection conn = new ConexaoBD().getConnection();
            HashMap param = new HashMap();

            JasperDesign jd = JRXmlLoader.load("src/main/java/br/com/buyme/report/MotivoPerda.jrxml");
            JRDesignQuery newQuery = new JRDesignQuery();
            newQuery.setText(sql);
            jd.setQuery(newQuery);
            JasperReport jr = JasperCompileManager.compileReport(jd);
            JasperPrint jp = JasperFillManager.fillReport(jr, param,conn);
            JasperExportManager.exportReportToPdfFile(jp,caminhoSalvar+"/MotivoPerda.pdf");

            conn.close();
           }
    }catch(Exception e){
        e.printStackTrace();
    }

}
项目:PDFReporter-Studio    文件:OpenQueryHandler.java   
@Override
public void run() {
    APropertyNode reportRoot = HandlersUtil.getRootElement();
    if (reportRoot != null) {
        MDataset mdataset = (MDataset) reportRoot.getPropertyValue(JasperDesign.PROPERTY_MAIN_DATASET);
        MQuery mquery = (MQuery) mdataset.getPropertyValue(JRDesignDataset.PROPERTY_QUERY);
        PatternEditor wizard = new PatternEditor();
        wizard.setValue(mquery.getPropertyValue(JRDesignQuery.PROPERTY_TEXT).toString());
        new DatasetDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), mdataset, mquery.getJasperConfiguration(), getCommandStack()).open();
    } else
        MessageDialog.openWarning(UIUtils.getShell(), Messages.OpenQueryHandler_message_title, Messages.OpenQueryHandler_message_text);
}
项目:PDFReporter-Studio    文件:SPQueryButton.java   
/**
 * Build the button
 * 
 * @param parent
 *          composite where is placed
 * @param buttonText
 *          text on the button
 */
protected void createButton(Composite parent, String buttonText) {
    editQueryButton = section.getWidgetFactory().createButton(parent, buttonText, SWT.PUSH);
    editQueryButton.setToolTipText(pDescriptor.getDescription());
    editQueryButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            PatternEditor wizard = new PatternEditor();
            Object queryText = mquery.getPropertyValue(JRDesignQuery.PROPERTY_TEXT);
            wizard.setValue(queryText != null ? queryText.toString() : "");
            new DatasetDialog(editQueryButton.getShell(), mdataset, mquery.getJasperConfiguration(), section
                    .getEditDomain().getCommandStack()).open();
        }
    });
}
项目:PDFReporter-Studio    文件:JRQueryCellEditor.java   
@Override
protected void doSetValue(Object value) {
    super.doSetValue(value);
    if (value instanceof MQuery) {
        MQuery expression = (MQuery) value;

        text.removeModifyListener(getModifyListener());
        String pvalue = (String) expression.getPropertyValue(JRDesignQuery.PROPERTY_TEXT);
        if (pvalue == null)
            pvalue = "";
        text.setText(pvalue);
        text.addModifyListener(getModifyListener());
    }
}
项目:PDFReporter-Studio    文件:QueryDesigner.java   
protected void doSourceTextChanged() {
    if (!refresh) {
        refresh = true;
        if (jDataset != null && jDataset.getQuery() != null)
            ((JRDesignQuery) jDataset.getQuery()).setText(Misc.nvl(getQueryFromWidget()));
        refresh = false;
    }
}
项目:PDFReporter-Studio    文件:MDataset.java   
/**
 * Creates the jr dataset.
 * 
 * @param jrDesign
 *          the jr design
 * @return the jR design dataset
 */
public static JRDesignDataset createJRDataset(JasperReportsConfiguration jConfig, JasperDesign jrDesign) {
    JRDesignDataset jrDesignDataset = new JRDesignDataset(jConfig, false);
    jrDesignDataset.setName(ModelUtils.getDefaultName(jrDesign.getDatasetMap(), "Dataset")); //$NON-NLS-1$
    JRDesignQuery jrDesignQuery = new JRDesignQuery();
    jrDesignQuery.setLanguage("sql"); //$NON-NLS-1$
    jrDesignQuery.setText(""); //$NON-NLS-1$
    jrDesignDataset.setQuery(jrDesignQuery);
    return jrDesignDataset;
}
项目:PDFReporter-Studio    文件:MQuery.java   
@Override
public void createPropertyDescriptors(List<IPropertyDescriptor> desc, Map<String, Object> defaultsMap) {
    // pen
    NTextPropertyDescriptor textD = new NTextPropertyDescriptor(JRDesignQuery.PROPERTY_TEXT, Messages.common_text);
    textD.setDescription(Messages.MQuery_text_description);
    desc.add(textD);

    languageD = new RWComboBoxPropertyDescriptor(JRDesignQuery.PROPERTY_LANGUAGE, Messages.common_language,
            ModelUtils.getQueryLanguages(getJasperConfiguration()), NullEnum.NOTNULL);
    languageD.setDescription(Messages.MQuery_language_description);
    languageD.setCategory(Messages.common_report);
    desc.add(languageD);

    defaultsMap.put(JRDesignQuery.PROPERTY_LANGUAGE, "SQL"); //$NON-NLS-1$
}
项目:PDFReporter-Studio    文件:MQuery.java   
public Object getPropertyValue(Object id) {
    JRQuery jrQuery = (JRQuery) getValue();
    if (jrQuery != null) {
        if (id.equals(JRDesignQuery.PROPERTY_TEXT))
            return jrQuery.getText();
        if (id.equals(JRDesignQuery.PROPERTY_LANGUAGE))
            return jrQuery.getLanguage();
    }
    return null;
}
项目:PDFReporter-Studio    文件:MQuery.java   
public void setPropertyValue(Object id, Object value) {
    JRDesignQuery jrQuery = (JRDesignQuery) getValue();
    if (jrQuery != null) {
        if (id.equals(JRDesignQuery.PROPERTY_TEXT)) {
            jrQuery.setText((String) value);
        } else if (id.equals(JRDesignQuery.PROPERTY_LANGUAGE)) {
            String lang = Misc.nullValue((String) value);
            jrQuery.setLanguage(ModelUtils.getLanguage(lang));
        }
    }
}
项目:PDFReporter-Studio    文件:PostDatasetObjectSet.java   
@Override
public Command postSetValue(IPropertySource target, Object prop, Object newValue, Object oldValue) {
    if (target instanceof MField && prop.equals(JRDesignField.PROPERTY_NAME))
        return new RenameDatasetObjectNameCommand((MField) target, (String) oldValue);
    if (target instanceof MVariable && prop.equals(JRDesignVariable.PROPERTY_NAME))
        return new RenameDatasetObjectNameCommand((MVariable) target, (String) oldValue);
    if (target instanceof MParameter && prop.equals(JRDesignParameter.PROPERTY_NAME)
            && ((MParameter) target).getParent() != null)
        return new RenameDatasetObjectNameCommand((MParameter) target, (String) oldValue);
    if (target instanceof MDataset && prop.equals(JRDesignDataset.PROPERTY_QUERY))
        return new SyncDatasetRunCommand((MDataset) target, (MQuery) newValue, (MQuery) oldValue);
    if (target instanceof MQuery && prop.equals(JRDesignQuery.PROPERTY_LANGUAGE))
        return new SyncDatasetRunCommand((MQuery) target, (String) newValue, (String) oldValue);
    return null;
}
项目:PDFReporter-Studio    文件:RenameDatasetObjectNameCommand.java   
protected void doSetQuery(String oldVal, String newVal) {
    if (type1.equals("$P{")) {
        JRDesignQuery query = (JRDesignQuery) dataset.getQuery();
        String q = query.getText();
        // replace $P{} in query
        query.setText(q.replaceAll(type + oldVal + "}", type + newVal + "}"));
    }
}
项目:ireport-fork    文件:DatasetNode.java   
@SuppressWarnings("unchecked")
public QueryTextProperty(JRDesignDataset dataset)
{
    super(JRDesignQuery.PROPERTY_TEXT,String.class, I18n.getString("DatasetNode.Property.QueryText"), I18n.getString("DatasetNode.Property.QueryTextdetail"),true, true);
    this.dataset = dataset;
    //this.setValue("oneline", Boolean.TRUE);
}
项目:ireport-fork    文件:DatasetNode.java   
public void setValue(Object val) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {

        JRDesignQuery oldValue = (JRDesignQuery)dataset.getQuery();
        String text = (val == null) ? "" : val+"";

        JRDesignQuery newValue = new JRDesignQuery();
        if (oldValue != null && oldValue.getLanguage() != null)
        {
            newValue.setLanguage(oldValue.getLanguage());
        }
        else
        {
            newValue.setLanguage("SQL");
        }

        newValue.setText(text);

        dataset.setQuery(newValue);

        ObjectPropertyUndoableEdit urob =
                new ObjectPropertyUndoableEdit(
                    dataset,
                    "Query", 
                    JRDesignQuery.class,
                    oldValue,newValue);
        // Find the undoRedo manager...
        IReportManager.getInstance().addUndoableEdit(urob);
}
项目:ireport-fork    文件:HiveConnection.java   
@Override
public List<JRDesignField> readFields(String query) throws Exception {
    HiveFieldsProvider provider = new HiveFieldsProvider();
    List<JRDesignField> result = new ArrayList<JRDesignField>();
    JRDesignDataset dataset = new JRDesignDataset(true);
    JRDesignQuery designQuery = new JRDesignQuery();
    designQuery.setLanguage(HiveDataSource.QUERY_LANGUAGE);
    designQuery.setText(query);
    dataset.setQuery(designQuery);
    JRField[] fields = provider.getFields(this, dataset, new HashMap<Object, Object>());
    for (int i = 0; i < fields.length; ++i) {
        result.add((JRDesignField) fields[i]);
    }
    return result;
}
项目:engerek    文件:JasperReportDto.java   
public byte[] getTemplate(){
        try{
//          design.remadgetFields().
            design.getFieldsList().clear();
            design.getParametersList().clear();
            design.getFieldsMap().clear();
            design.getParametersMap().clear();
            for (JasperReportFieldDto field : fields) {
                if (field.isEmpty()){
                    continue;
                }
                JRDesignField f = new JRDesignField();
                f.setValueClassName(field.getTypeAsString());
                f.setValueClass(Class.forName(field.getTypeAsString()));
                f.setName(field.getName());
                design.addField(f);
            }

            for (JasperReportParameterDto param : parameters) {
                if (param.isEmpty()) {
                    continue;
                }
                JRDesignParameter p = new JRDesignParameter();
                p.setValueClassName(param.getTypeAsString());
                p.setValueClass(Class.forName(param.getTypeAsString()));
                p.setName(param.getName());
                p.setForPrompting(param.isForPrompting());
                p.setDescription(param.getDescription());
                p.setNestedTypeName(param.getNestedTypeAsString());
                p.setNestedType(param.getNestedType());
                p.getPropertiesMap().setBaseProperties(param.getJRProperties());
                //          p.getPropertiesMap().setProperty(propName, value);
                design.addParameter(p);
            }

            JasperDesign oldDesign = ReportTypeUtil.loadJasperDesign(jasperReportXml);
            oldDesign.getParametersList().clear();
            oldDesign.getParametersList().addAll(design.getParametersList());

            oldDesign.getFieldsList().clear();
            oldDesign.getFieldsList().addAll(design.getFieldsList());

            JRDesignQuery q = new JRDesignQuery();
            q.setLanguage("mql");
            q.setText(query);
            oldDesign.setQuery(q);

            String reportAsString = JRXmlWriter.writeReport(oldDesign, "UTF-8");
            return Base64.encodeBase64(reportAsString.getBytes("UTF-8"));

        } catch (JRException | ClassNotFoundException | SchemaException | UnsupportedEncodingException ex) {
            throw new IllegalStateException(ex.getMessage(), ex.getCause());
        }

    }
项目:PDFReporter-Studio    文件:SoapConnection.java   
private void cascadingDependencies(ResourceDescriptor ic, Set<String> icNames) {
    List<ResourceDescriptor> children = ic.getChildren();
    for (ResourceDescriptor sub_ic : children) {
        if (!InputControlsManager.isRDQuery(sub_ic))
            continue;
        String queryString = sub_ic.getSql();
        String lang = sub_ic.getResourceProperty(ResourceDescriptor.PROP_QUERY_LANGUAGE).getValue();
        if (!Misc.isNullOrEmpty(queryString)) {
            List<String> parameters = new ArrayList<String>();
            JRDesignQuery query = new JRDesignQuery();
            query.setText(queryString);
            if (lang != null)
                query.setLanguage(lang);
            for (JRQueryChunk chunk : query.getChunks()) {
                switch (chunk.getType()) {
                case JRQueryChunk.TYPE_TEXT:
                    break;
                case JRQueryChunk.TYPE_PARAMETER_CLAUSE:
                case JRQueryChunk.TYPE_PARAMETER:
                    String paramName = chunk.getText().trim();
                    if (!parameters.contains(paramName) && icNames.contains(paramName))
                        parameters.add(paramName);
                    break;
                case JRQueryChunk.TYPE_CLAUSE_TOKENS:
                    String[] tokens = chunk.getTokens();
                    if (tokens.length > 2) {
                        for (String t : tokens) {
                            t = t.trim();
                            if (!parameters.contains(t) && icNames.contains(t))
                                parameters.add(t);
                        }
                    }
                    break;
                }
            }
            if (!parameters.isEmpty())
                ic.setMasterInputControls(parameters);
        }
        break;
    }
}
项目:PDFReporter-Studio    文件:MongoDBQueryDesigner.java   
protected void queryTextAreaModified() {
    // keep the query info updated
    ((JRDesignQuery) jDataset.getQuery()).setText(queryTextArea.getText());
}
项目:PDFReporter-Studio    文件:SPQuery.java   
@Override
public void setData(APropertyNode pnode, Object b) {
    mdataset = (MDataset) pnode;
    mquery = (MQuery) b;
    super.setData(mquery, mquery.getPropertyValue(JRDesignQuery.PROPERTY_TEXT));
}
项目:PDFReporter-Studio    文件:MQuery.java   
@Override
public JRDesignQuery getValue() {
    return (JRDesignQuery) super.getValue();
}
项目:PDFReporter-Studio    文件:HBaseQueryDesigner.java   
protected void queryTextAreaModified() {
    // keep the query info updated
    ((JRDesignQuery) jDataset.getQuery()).setText(queryTextArea.getText());
}
项目:ireport-fork    文件:EditMarkerDatasetAction.java   
protected JRDesignDataset createDataset()
{

    try {

            JasperDesign jd = IReportManager.getInstance().getActiveReport();


            DatasetWizardIterator iterator = new DatasetWizardIterator();
            WizardDescriptor wizardDescriptor = new WizardDescriptor(iterator);
            iterator.initialize(wizardDescriptor, jd );
            // {0} will be replaced by WizardDescriptor.Panel.getComponent().getName()
            // {1} will be replaced by WizardDescriptor.Iterator.name()
            wizardDescriptor.setTitleFormat(new MessageFormat("{0} ({1})"));
            wizardDescriptor.setTitle("New Dataset");
            Dialog dialog = DialogDisplayer.getDefault().createDialog(wizardDescriptor);
            dialog.setVisible(true);
            dialog.toFront();
            boolean cancelled = wizardDescriptor.getValue() != WizardDescriptor.FINISH_OPTION;
            if (!cancelled) {

                JRDesignDataset newDataset = new JRDesignDataset(false);
                newDataset.setName( (String) wizardDescriptor.getProperty("dataset_name"));

                List<JRDesignField> selectedFields = (List<JRDesignField>) wizardDescriptor.getProperty("selectedFields");
                List<JRDesignField> groupFields = (List<JRDesignField>) wizardDescriptor.getProperty("groupFields");
                String query = (String) wizardDescriptor.getProperty("query");
                String queryLanguage = (String) wizardDescriptor.getProperty("queryLanguage");

                if (selectedFields == null) selectedFields = new ArrayList<JRDesignField>();
                if (groupFields == null) groupFields = new ArrayList<JRDesignField>();

                // Adding fields
                for (JRDesignField f : selectedFields)
                {
                    newDataset.addField(f);
                }

                // Query...
                if (query != null)
                {
                    JRDesignQuery designQuery = new JRDesignQuery();
                    designQuery.setText(query);
                    if (queryLanguage != null)
                    {
                        designQuery.setLanguage(queryLanguage);
                    }

                    newDataset.setQuery(designQuery);
                }

                // Adjusting groups
                for (int i=0; i<groupFields.size(); ++i)
                {
                      JRDesignGroup g =new JRDesignGroup();
                      g.setName(groupFields.get(i).getName());
                      g.setExpression(Misc.createExpression(groupFields.get(i).getValueClassName(), "$F{" + groupFields.get(i).getName() + "}"));
                      newDataset.addGroup(g);
                }


                jd.addDataset(newDataset);
                AddDatasetUndoableEdit edit = new AddDatasetUndoableEdit(newDataset, jd);
                IReportManager.getInstance().addUndoableEdit(edit);

                return newDataset;

            }

        } catch (JRException ex) {
            Exceptions.printStackTrace(ex);
        }

    return null;


}
项目:ireport-fork    文件:TableVisualPanel1.java   
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed

        try {
            DatasetWizardIterator iterator = new DatasetWizardIterator();
            WizardDescriptor wizardDescriptor = new WizardDescriptor(iterator);
            iterator.initialize(wizardDescriptor, getJasperDesign() );
            // {0} will be replaced by WizardDescriptor.Panel.getComponent().getName()
            // {1} will be replaced by WizardDescriptor.Iterator.name()
            wizardDescriptor.setTitleFormat(new MessageFormat("{0} ({1})"));
            wizardDescriptor.setTitle("New Dataset");
            Dialog dialog = DialogDisplayer.getDefault().createDialog(wizardDescriptor);
            dialog.setVisible(true);
            dialog.toFront();
            boolean cancelled = wizardDescriptor.getValue() != WizardDescriptor.FINISH_OPTION;
            if (!cancelled) {

                JRDesignDataset newDataset = new JRDesignDataset(false);
                newDataset.setName( (String) wizardDescriptor.getProperty("dataset_name"));

                List<JRDesignField> selectedFields = (List<JRDesignField>) wizardDescriptor.getProperty("selectedFields");
                List<JRDesignField> groupFields = (List<JRDesignField>) wizardDescriptor.getProperty("groupFields");
                String query = (String) wizardDescriptor.getProperty("query");
                String queryLanguage = (String) wizardDescriptor.getProperty("queryLanguage");

                if (selectedFields == null) selectedFields = new ArrayList<JRDesignField>();
                if (groupFields == null) groupFields = new ArrayList<JRDesignField>();

                // Adding fields
                for (JRDesignField f : selectedFields)
                {
                    newDataset.addField(f);
                }

                // Query...
                if (query != null)
                {
                    JRDesignQuery designQuery = new JRDesignQuery();
                    designQuery.setText(query);
                    if (queryLanguage != null)
                    {
                        designQuery.setLanguage(queryLanguage);
                    }

                    newDataset.setQuery(designQuery);
                }

                // Adjusting groups
                for (int i=0; i<groupFields.size(); ++i)
                {
                      JRDesignGroup g =new JRDesignGroup();
                      g.setName(groupFields.get(i).getName());
                      g.setExpression(Misc.createExpression(groupFields.get(i).getValueClassName(), "$F{" + groupFields.get(i).getName() + "}"));
                      newDataset.addGroup(g);
                }

                getJasperDesign().addDataset(newDataset);
                AddDatasetUndoableEdit edit = new AddDatasetUndoableEdit(newDataset, getJasperDesign());
                IReportManager.getInstance().addUndoableEdit(edit);

                updateDatasets();
                jComboBoxDataset.setSelectedItem(newDataset);
                jRadioButton1.setSelected(true);
                jRadioButton2.setSelected(false);

            }

        } catch (JRException ex) {
            Exceptions.printStackTrace(ex);
        }

    }
项目:ireport-fork    文件:ReportQueryDialog.java   
private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed

    try {
        if (stoppedChanging != null) stoppedChanging.stop();

        if ( this.getDataset() != null)
        {       
            num++; // avoid syncronization problems....

            Object obj = jComboBoxQueryType.getSelectedItem();
            //JRDesignQuery query = (JRDesignQuery)dataset.getQuery();
            JRDesignQuery query = new JRDesignQuery();

            if (obj != null && obj instanceof Tag) 
            {
                query.setLanguage(""+((Tag)obj).getValue());
            }
            else
            {
                query.setLanguage(""+obj);
            }

            query.setText(jEditorPane1.getText());

            ClassLoader origCL = Thread.currentThread().getContextClassLoader();
            Thread.currentThread().setContextClassLoader( IReportManager.getReportClassLoader());

            this.dataset.setQuery(query);

            Thread.currentThread().setContextClassLoader( origCL );


            com.jaspersoft.ireport.designer.IReportManager.getInstance().notifyReportChange();

            if ( jTableFields.getRowCount() > 0)
            {
                // Clear all the existing fields.
                this.dataset.getFieldsList().clear(); // This would not be legal...
                this.dataset.getFieldsMap().clear();
                // Add the new fields.
                for (int i=0; i<jTableFields.getRowCount(); ++i)
                {
                    JRDesignField field = (JRDesignField)this.jTableFields.getValueAt(i, 0);
                    Iterator iterFields = this.dataset.getFieldsList().iterator();
                    boolean found = false;
                    while (iterFields.hasNext()) {
                        JRDesignField f = (JRDesignField)iterFields.next();
                        if (f.getName().equalsIgnoreCase(field.getName())) {
                            found = true;
                            break;
                        }
                    }
                    if (!found) {
                        this.dataset.addField(field);
                    }
                }
            } 
       }

   } catch (Throwable ex)
        {
            ex.printStackTrace();
        }

   this.setVisible(false);

}
项目:ireport-fork    文件:AddDatasetAction.java   
protected void performAction(org.openide.nodes.Node[] activatedNodes) {

    if (activatedNodes.length > 0 &&
        activatedNodes[0] instanceof ReportNode)
    {
        try {
            ReportNode node = (ReportNode) activatedNodes[0];



            DatasetWizardIterator iterator = new DatasetWizardIterator();
            WizardDescriptor wizardDescriptor = new WizardDescriptor(iterator);
            iterator.initialize(wizardDescriptor, node.getJasperDesign() );
            // {0} will be replaced by WizardDescriptor.Panel.getComponent().getName()
            // {1} will be replaced by WizardDescriptor.Iterator.name()
            wizardDescriptor.setTitleFormat(new MessageFormat("{0} ({1})"));
            wizardDescriptor.setTitle("New Dataset");
            Dialog dialog = DialogDisplayer.getDefault().createDialog(wizardDescriptor);
            dialog.setVisible(true);
            dialog.toFront();
            boolean cancelled = wizardDescriptor.getValue() != WizardDescriptor.FINISH_OPTION;
            if (!cancelled) {

                JRDesignDataset newDataset = new JRDesignDataset(false);
                newDataset.setName( (String) wizardDescriptor.getProperty("dataset_name"));

                List<JRDesignField> selectedFields = (List<JRDesignField>) wizardDescriptor.getProperty("selectedFields");
                List<JRDesignField> groupFields = (List<JRDesignField>) wizardDescriptor.getProperty("groupFields");
                String query = (String) wizardDescriptor.getProperty("query");
                String queryLanguage = (String) wizardDescriptor.getProperty("queryLanguage");

                if (selectedFields == null) selectedFields = new ArrayList<JRDesignField>();
                if (groupFields == null) groupFields = new ArrayList<JRDesignField>();

                // Adding fields
                for (JRDesignField f : selectedFields)
                {
                    newDataset.addField(f);
                }

                // Query...
                if (query != null)
                {
                    JRDesignQuery designQuery = new JRDesignQuery();
                    designQuery.setText(query);
                    if (queryLanguage != null)
                    {
                        designQuery.setLanguage(queryLanguage);
                    }

                    newDataset.setQuery(designQuery);
                }

                // Adjusting groups
                for (int i=0; i<groupFields.size(); ++i)
                {
                      JRDesignGroup g =new JRDesignGroup();
                      g.setName(groupFields.get(i).getName());
                      g.setExpression(Misc.createExpression(groupFields.get(i).getValueClassName(), "$F{" + groupFields.get(i).getName() + "}"));
                      newDataset.addGroup(g);
                }


                node.getJasperDesign().addDataset(newDataset);
                AddDatasetUndoableEdit edit = new AddDatasetUndoableEdit(newDataset, node.getJasperDesign());
                IReportManager.getInstance().addUndoableEdit(edit);

            }

        } catch (JRException ex) {
            Exceptions.printStackTrace(ex);
        }
    }
}
项目:midpoint    文件:JasperReportDto.java   
public byte[] getTemplate(){
        try{
//          design.remadgetFields().
            design.getFieldsList().clear();
            design.getParametersList().clear();
            design.getFieldsMap().clear();
            design.getParametersMap().clear();
            for (JasperReportFieldDto field : fields) {
                if (field.isEmpty()){
                    continue;
                }
                JRDesignField f = new JRDesignField();
                f.setValueClassName(field.getTypeAsString());
                f.setValueClass(Class.forName(field.getTypeAsString()));
                f.setName(field.getName());
                design.addField(f);
            }

            for (JasperReportParameterDto param : parameters) {
                if (param.isEmpty()) {
                    continue;
                }
                JRDesignParameter p = new JRDesignParameter();
                p.setValueClassName(param.getTypeAsString());
                p.setValueClass(Class.forName(param.getTypeAsString()));
                p.setName(param.getName());
                p.setForPrompting(param.isForPrompting());
                p.setDescription(param.getDescription());
                p.setNestedTypeName(param.getNestedTypeAsString());
                p.setNestedType(param.getNestedType());
                p.getPropertiesMap().setBaseProperties(param.getJRProperties());
                //          p.getPropertiesMap().setProperty(propName, value);
                design.addParameter(p);
            }

            JasperDesign oldDesign = ReportTypeUtil.loadJasperDesign(jasperReportXml);
            oldDesign.getParametersList().clear();
            oldDesign.getParametersList().addAll(design.getParametersList());

            oldDesign.getFieldsList().clear();
            oldDesign.getFieldsList().addAll(design.getFieldsList());

            JRDesignQuery q = new JRDesignQuery();
            q.setLanguage("mql");
            q.setText(query);
            oldDesign.setQuery(q);

            String reportAsString = JRXmlWriter.writeReport(oldDesign, "UTF-8");
            return Base64.encodeBase64(reportAsString.getBytes("UTF-8"));

        } catch (JRException | ClassNotFoundException | SchemaException | UnsupportedEncodingException ex) {
            throw new IllegalStateException(ex.getMessage(), ex.getCause());
        }

    }
项目:ElasticJasper    文件:ESQueryDesigner.java   
protected void queryTextAreaModified() {
    ((JRDesignQuery) jDataset.getQuery()).setText(queryTextArea.getText());
}
项目:midpoint    文件:JasperReportDto.java   
public byte[] getTemplate(){
        try{
//          design.remadgetFields().
            design.getFieldsList().clear();
            design.getParametersList().clear();
            design.getFieldsMap().clear();
            design.getParametersMap().clear();
            for (JasperReportFieldDto field : fields) {
                if (field.isEmpty()){
                    continue;
                }
                JRDesignField f = new JRDesignField();
                f.setValueClassName(field.getTypeAsString());
                f.setValueClass(Class.forName(field.getTypeAsString()));
                f.setName(field.getName());
                design.addField(f);
            }

            for (JasperReportParameterDto param : parameters) {
                if (param.isEmpty()) {
                    continue;
                }
                JRDesignParameter p = new JRDesignParameter();
                p.setValueClassName(param.getTypeAsString());
                p.setValueClass(Class.forName(param.getTypeAsString()));
                p.setName(param.getName());
                p.setForPrompting(param.isForPrompting());
                p.setDescription(param.getDescription());
                p.setNestedTypeName(param.getNestedTypeAsString());
                p.setNestedType(param.getNestedType());
                p.getPropertiesMap().setBaseProperties(param.getJRProperties());
                //          p.getPropertiesMap().setProperty(propName, value);
                design.addParameter(p);
            }

            JasperDesign oldDesign = ReportTypeUtil.loadJasperDesign(jasperReportXml);
            oldDesign.getParametersList().clear();
            oldDesign.getParametersList().addAll(design.getParametersList());

            oldDesign.getFieldsList().clear();
            oldDesign.getFieldsList().addAll(design.getFieldsList());

            JRDesignQuery q = new JRDesignQuery();
            q.setLanguage("mql");
            q.setText(query);
            oldDesign.setQuery(q);

            String reportAsString = JRXmlWriter.writeReport(oldDesign, "UTF-8");
            return Base64.encodeBase64(reportAsString.getBytes("UTF-8"));

        } catch (JRException | ClassNotFoundException | SchemaException | UnsupportedEncodingException ex) {
            throw new IllegalStateException(ex.getMessage(), ex.getCause());
        }

    }