本文整理汇总了Java中net.sf.jasperreports.data.DataAdapterServiceUtil类的典型用法代码示例。如果您正苦于以下问题:Java DataAdapterServiceUtil类的具体用法?Java DataAdapterServiceUtil怎么用?Java DataAdapterServiceUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DataAdapterServiceUtil类属于net.sf.jasperreports.data包,在下文中一共展示了DataAdapterServiceUtil类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readFields
import net.sf.jasperreports.data.DataAdapterServiceUtil; //导入依赖的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
示例2: dataAdapterQualification
import net.sf.jasperreports.data.DataAdapterServiceUtil; //导入依赖的package包/类
protected String dataAdapterQualification(JRDataset dataset, DataAdapter dataAdapter)
{
ParameterContributorContext contributorContext = new ParameterContributorContext(context,
dataset, Collections.<String, Object>emptyMap());
DataAdapterServiceUtil serviceUtil = DataAdapterServiceUtil.getInstance(contributorContext);
DataAdapterService service = serviceUtil.getService(dataAdapter);
return service instanceof Designated ? ((Designated) service).getDesignation() : null;
}
示例3: getExcelColumns
import net.sf.jasperreports.data.DataAdapterServiceUtil; //导入依赖的package包/类
/**
* This method will populate the data model with the Excel columns This also
* checks the button "Skip the first line " and enables the delete button
*
* @throws Exception
*/
private void getExcelColumns() throws Exception {
if (textFileName.getText().length() > 0) {
DataAdapterDescriptor da = getDataAdapter();
if (jConfig == null)
jConfig = JasperReportsConfiguration.getDefaultJRConfig();
DataAdapterService das = DataAdapterServiceUtil.getInstance(jConfig).getService(da.getDataAdapter());
((AbstractDataAdapterService) das).getDataAdapter();
jConfig.setJasperDesign(new JasperDesign());
// The get fields method call once a next on the data adapter to get the
// first line and from that is read the
// fields name. But is useFirstRowAsHeader flag is set to false than the
// next call will skip the first line
// that is the only one read to get the fields, so it will return an empty
// set of column names. For this
// reason this flag must be force to true if the data adapter is used to
// get the column names
XlsDataAdapter xlsAdapter = (XlsDataAdapter) da.getDataAdapter();
boolean useRowHeader = xlsAdapter.isUseFirstRowAsHeader();
xlsAdapter.setUseFirstRowAsHeader(true);
List<JRDesignField> fields = ((IFieldsProvider) da).getFields(das, jConfig, new JRDesignDataset(jConfig, false));
xlsAdapter.setUseFirstRowAsHeader(useRowHeader);
rows.clear();
int columnIndex = 0;
for (JRDesignField f : fields) {
rows.add(new String[] { f.getName(), String.valueOf(columnIndex++) });
}
tableViewer.setInput(rows);
tableViewer.refresh();
setTableSelection(-1);
btnDelete.setEnabled(true);
}
}
示例4: getExcelColumns
import net.sf.jasperreports.data.DataAdapterServiceUtil; //导入依赖的package包/类
/**
* This method will populate the data model with the Excel columns This also
* checks the button "Skip the first line " and enables the delete button
*
* @throws Exception
*/
private void getExcelColumns() throws Exception {
if (textFileName.getText().length() > 0) {
DataAdapterDescriptor da = getDataAdapter();
if (jConfig == null)
jConfig = JasperReportsConfiguration.getDefaultJRConfig();
DataAdapterService das = DataAdapterServiceUtil.getInstance(jConfig).getService(da.getDataAdapter());
jConfig.setJasperDesign(new JasperDesign());
//The get fields method call once a next on the data adapter to get the first line and from that is read the
//fields name. But is useFirstRowAsHeader flag is set to false than the next call will skip the first line
//that is the only one read to get the fields, so it will return an empty set of column names. For this
//reason this flag must be force to true if the data adapter is used to get the column names
XlsxDataAdapter xlsAdapter = (XlsxDataAdapter)da.getDataAdapter();
boolean useRowHeader = xlsAdapter.isUseFirstRowAsHeader();
xlsAdapter.setUseFirstRowAsHeader(true);
List<JRDesignField> fields = ((IFieldsProvider) da).getFields(das, jConfig, new JRDesignDataset(jConfig, false));
xlsAdapter.setUseFirstRowAsHeader(useRowHeader);
rows.clear();
int columnIndex = 0;
for (JRDesignField f : fields) {
rows.add(new String[] { f.getName(), String.valueOf(columnIndex++) });
}
tableViewer.setInput(rows);
tableViewer.refresh();
setTableSelection(-1);
btnDelete.setEnabled(true);
}
}
示例5: getExcelColumns
import net.sf.jasperreports.data.DataAdapterServiceUtil; //导入依赖的package包/类
/**
* This method will populate the data model with the Excel columns This also
* checks the button "Skip the first line " and enables the delete button
*
* @throws Exception
*/
private void getExcelColumns() throws Exception {
if (textFileName.getText().length() > 0) {
DataAdapterDescriptor da = getDataAdapter();
if (jConfig == null)
jConfig = JasperReportsConfiguration.getDefaultJRConfig();
DataAdapterService das = DataAdapterServiceUtil.getInstance(jConfig).getService(da.getDataAdapter());
((AbstractDataAdapterService) das).getDataAdapter();
jConfig.setJasperDesign(new JasperDesign());
//The get fields method call once a next on the data adapter to get the first line and from that is read the
//fields name. But is useFirstRowAsHeader flag is set to false than the next call will skip the first line
//that is the only one read to get the fields, so it will return an empty set of column names. For this
//reason this flag must be force to true if the data adapter is used to get the column names
XlsDataAdapter xlsAdapter = (XlsDataAdapter)da.getDataAdapter();
boolean useRowHeader = xlsAdapter.isUseFirstRowAsHeader();
xlsAdapter.setUseFirstRowAsHeader(true);
List<JRDesignField> fields = ((IFieldsProvider) da).getFields(das, jConfig, new JRDesignDataset(jConfig, false));
xlsAdapter.setUseFirstRowAsHeader(useRowHeader);
rows.clear();
int columnIndex = 0;
for (JRDesignField f : fields) {
rows.add(new String[] { f.getName(), String.valueOf(columnIndex++) });
}
tableViewer.setInput(rows);
tableViewer.refresh();
setTableSelection(-1);
btnDelete.setEnabled(true);
}
}
示例6: doGetFields
import net.sf.jasperreports.data.DataAdapterServiceUtil; //导入依赖的package包/类
@Override
protected void doGetFields(IProgressMonitor monitor) {
final DataAdapterDescriptor da = dscombo.getSelected();
if (da != null && da instanceof IFieldsProvider && ((IFieldsProvider) da).supportsGetFieldsOperation(jConfig)) {
qStatus.showInfo("");
monitor.beginTask(Messages.DataQueryAdapters_jobname, -1);
ClassLoader oldClassloader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(jConfig.getClassLoader());
DataAdapterService das = DataAdapterServiceUtil.getInstance(jConfig).getService(da.getDataAdapter());
try {
final List<JRDesignField> fields = ((IFieldsProvider) da).getFields(das, jConfig, newdataset);
if (fields != null) {
monitor.setTaskName("Setting Fields");
Display.getDefault().syncExec(new Runnable() {
public void run() {
setFields(fields);
}
});
monitor.setTaskName("Fields set");
}
} catch (Exception e) {
if (e.getCause() != null)
qStatus.showError(e.getCause().getMessage(), e);
else
qStatus.showError(e);
} finally {
Thread.currentThread().setContextClassLoader(oldClassloader);
das.dispose();
monitor.done();
}
}
}
示例7: readFields
import net.sf.jasperreports.data.DataAdapterServiceUtil; //导入依赖的package包/类
/**
* Return the fields.
*
* If the dataAdapterDescriptor implements IFieldsProvider, this interface is used to get the fields automatically.
*
* This method is invoked on a thread which is not in the UI event thread, so no UI update should be performed without
* using a proper async thread.
*
* return the result of IFieldsProvider.getFields() or an empty list of JRField is the DataAdapterDescriptor does not
* implement the IFieldsProvider interface.
*/
public List<JRDesignField> readFields() throws Exception {
List<JRDesignField> fields = null;
if (getDataAdapterDescriptor() != null && getDataAdapterDescriptor() instanceof IFieldsProvider) {
questionReturnCode = SWT.OK;
JasperReportsConfiguration jContext = getJasperReportsConfiguration();
DataAdapterService das = DataAdapterServiceUtil.getInstance(jContext).getService(
getDataAdapterDescriptor().getDataAdapter());
try {
JRDesignDataset tmpDataset = getDataset();
if (tmpDataset.getQuery().getText() == null || tmpDataset.getQuery().getText().trim().length() == 0) {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
MessageBox dialog = new MessageBox(UIUtils.getShell(), SWT.ICON_QUESTION | SWT.OK
| SWT.CANCEL);
dialog.setText(Messages.SimpleQueryWizardDataEditorComposite_noQueryProvidedTitle);
dialog.setMessage(Messages.SimpleQueryWizardDataEditorComposite_noQueryProvidedText);
questionReturnCode = dialog.open();
}
});
if (questionReturnCode != SWT.OK) {
throw JSSWizardRunnablePage.USER_CANCEL_EXCEPTION;
}
}
else {
fields = ((IFieldsProvider) getDataAdapterDescriptor()).getFields(das, jContext, dataset);
}
} catch (final JRException ex) {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
// 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 high-level exception...
String errorMsg = ex.getMessage();
if (ex.getCause() != null && ex.getCause() instanceof Exception) {
errorMsg=ex.getCause().getMessage();
}
page.setErrorMessage(errorMsg);
boolean answer =
MessageDialog.openQuestion(UIUtils.getShell(), Messages.SimpleQueryWizardDataEditorComposite_QueryErrorTitle, NLS.bind(Messages.SimpleQueryWizardDataEditorComposite_QueryErrorMsg,errorMsg));
questionReturnCode = (answer) ? SWT.OK : SWT.CANCEL;
}
});
if (questionReturnCode != SWT.OK) {
throw JSSWizardRunnablePage.USER_CANCEL_EXCEPTION;
}
} finally {
das.dispose();
}
}
return Misc.nvl(fields, new ArrayList<JRDesignField>());
}
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:70,代码来源:SimpleQueryWizardDataEditorComposite.java
示例8: createPartControl
import net.sf.jasperreports.data.DataAdapterServiceUtil; //导入依赖的package包/类
@Override
public void createPartControl(Composite parent) {
Composite c = new Composite(parent, SWT.NONE);
RowLayout rowLayout = new RowLayout();
rowLayout.type = SWT.VERTICAL;
rowLayout.justify = false;
rowLayout.pack = true;
rowLayout.fill = true;
c.setLayout(rowLayout);
nameComposite = new NameComposite(c, SWT.NONE, jrContext);
if (descriptor != null) {
editor = descriptor.getEditor();
dacomposite = editor.getComposite(c, SWT.NONE, null, jrContext);
PlatformUI.getWorkbench().getHelpSystem().setHelp(c, editor.getHelpContextId());
nameComposite.addModifyListener(modelListener);
dacomposite.addModifyListener(modelListener);
editor.setDataAdapter(descriptor);
nameComposite.setDataAdapter(descriptor);
final Button btnTest = new Button(c, SWT.PUSH);
btnTest.setText(Messages.DataAdapterEditorPart_testButton);
btnTest.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
try {
IProject project = ((IFileEditorInput) getEditorInput()).getFile().getProject();
if(project.hasNature(JavaCore.NATURE_ID)) {
ClassLoader cl = JavaProjectClassLoader.instance(JavaCore.create(project));
if (cl != null)
Thread.currentThread().setContextClassLoader(cl);
}
DataAdapterServiceUtil.getInstance(jrContext).getService(editor.getDataAdapter().getDataAdapter()).test();
MessageBox mb = new MessageBox(btnTest.getShell(), SWT.ICON_INFORMATION | SWT.OK);
mb.setText(Messages.DataAdapterWizard_testbutton);
mb.setMessage(Messages.DataAdapterWizard_testsuccesful);
mb.open();
} catch (Exception e1) {
UIUtils.showError(e1);
} finally {
Thread.currentThread().setContextClassLoader(oldCL);
}
}
});
}
}