Java 类net.sf.jasperreports.engine.JRCloneable 实例源码

项目:jasperreports    文件:JRCloneUtils.java   
/**
 * Clones a list of objects.
 * 
 * The list elements are assumed to implement {@link JRCloneable}.
 * 
 * @param items the list to clone
 * @return a new list which contains clones of the elements in the original list
 */
public static <T extends JRCloneable> List<T> cloneList(List<T> items)
{
    List<T> clone;
    if (items == null)
    {
        clone = null;
    }
    else
    {
        clone = new ArrayList<T>(items.size());
        for (T item : items)
        {
            clone.add(JRCloneUtils.nullSafeClone(item));
        }
    }
    return clone;
}
项目:jasperreports    文件:JRCloneUtils.java   
/**
 * Clones a list of objects.
 * 
 * The list elements are assumed to implement {@link JRCloneable}.
 * 
 * @param items the list to clone
 * @return a new list which contains clones of the elements in the original list
 */
public static <T extends JRCloneable> T[] cloneArray(T[] items)
{
    T[] clone;
    if (items == null)
    {
        clone = null;
    } 
    else
    {
        clone = items.clone();
        List<T> list = new ArrayList<T>(items.length);
        for (T item : items)
        {
            list.add(JRCloneUtils.nullSafeClone(item));
        }
        clone = list.toArray(clone);
    }
    return clone;
}
项目:PDFReporter-Studio    文件:PercentagePage.java   
@Override
public void dispose() {
    int sel = rtypeList.getSelectionIndex();
    switch (sel) {
    case 0:
        rtype = ResetTypeEnum.REPORT;
        break;
    case 1:
        rtype = ResetTypeEnum.COLUMN;
        break;
    case 2:
        rtype = ResetTypeEnum.PAGE;
        break;
    default:
        if (sel > 2) {
            String groupname = rtypes.get(sel).substring(GROUP2.length());
            group = jDesign.getGroupsMap().get(groupname);
        }
    }

    StructuredSelection s = (StructuredSelection) fieldsView.getSelection();
    if (!s.isEmpty())
        field = (JRCloneable) s.getFirstElement();

    super.dispose();
}
项目:PDFReporter-Studio    文件:CreatePercentageCommand.java   
/**
 * Creates the object.
 */
@Override
protected void createObject() {
    if (jrElement == null) {
        JRCloneable field = null;
        ResetTypeEnum rtype = ResetTypeEnum.REPORT;
        JRGroup group = null;

        PercentageWizard wizard = new PercentageWizard();
        WizardDialog dialog = new WizardDialog(Display.getDefault().getActiveShell(), wizard);
        wizard.init(jasperDesign);
        dialog.create();
        if (dialog.open() == Dialog.OK) {
            field = wizard.getField();
            rtype = wizard.getResetType();
            group = wizard.getGroup();

            super.createObject();
            if (field != null) {
                JRDesignTextField tf = (JRDesignTextField) jrElement;


                // Create the expressions based of the reset type selected by the user...
                JRDesignVariable variable = null;
                try {
                    if (field instanceof JRField)
                    {
                        variable = createVariable(((JRField) field).getName(),
                                ((JRField) field).getValueClassName(), rtype, group);

                    }
                    else if (field instanceof JRVariable)
                    {
                        variable = createVariable(((JRVariable) field).getName(),
                                ((JRVariable) field).getValueClassName(), rtype, group);
                    }

                    if (variable == null)
                    {
                        return; // we don't want to continue in this case...
                    }

                    jasperDesign.addVariable(variable);

                } catch (Exception e) {
                    UIUtils.showError(e);

                }

                JRDesignExpression expression = new JRDesignExpression();
                if (field instanceof JRField)
                    expression.setText(createExpression(((JRField) field).getName(), variable.getName(), ((JRField) field).getValueClass()));
                if (field instanceof JRVariable)
                    expression.setText(createExpression(((JRVariable) field).getName(), variable.getName(), ((JRVariable) field).getValueClass()));
                tf.setExpression(expression);
                tf.setPattern("#,##0.00%");

                // Set the evaluation time of this textfield to AUTO
                tf.setEvaluationTime( net.sf.jasperreports.engine.type.EvaluationTimeEnum.AUTO);


            }
        }
    }
}
项目:PDFReporter-Studio    文件:PercentagePage.java   
public JRCloneable getField() {
    return field;
}
项目:PDFReporter-Studio    文件:PercentageWizard.java   
public JRCloneable getField() {
    return step1.getField();
}
项目:PDFReporter-Studio    文件:FontListFieldEditor.java   
protected void exportPressed() {
    int[] selection = table.getSelectionIndices();
    if (selection != null && selection.length > 0) {
        final List<FontFamily> lst = new ArrayList<FontFamily>(selection.length);
        for (int s : selection) {
            FontFamily font = fontFamily.get(s);
            if (font instanceof JRCloneable)
                lst.add((FontFamily) ((JRCloneable) font).clone());
        }
        final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
        FileDialog fd = new FileDialog(Display.getCurrent().getActiveShell(), SWT.SAVE);
        fd.setText(Messages.FontListFieldEditor_exportToJar);
        setupLastLocation(fd);
        fd.setFilterExtensions(new String[] { "*.jar", "*.zip" }); //$NON-NLS-1$ //$NON-NLS-2$
        final String selected = fd.open();
        setLastLocation(fd, selected);
        if (selected != null) {
            Job job = new Job(Messages.FontListFieldEditor_exportToJar) {
                @Override
                protected IStatus run(IProgressMonitor monitor) {
                    monitor.beginTask(Messages.FontListFieldEditor_exportToJar, IProgressMonitor.UNKNOWN);
                    try {
                        exportJAR(lst, selected);

                        IFile[] resource = root.findFilesForLocationURI(new File(selected).toURI());
                        if (resource != null) {
                            for (IFile f : resource)
                                f.refreshLocal(1, monitor);
                        }
                    } catch (final Exception e) {
                        e.printStackTrace();
                        UIUtils.getDisplay().asyncExec(new Runnable() {
                            public void run() {
                                IStatus status = new OperationStatus(IStatus.ERROR, JaspersoftStudioPlugin.getUniqueIdentifier(), 1,
                                        "Error saving file.", e.getCause()); //$NON-NLS-1$
                                ErrorDialog.openError(Display.getDefault().getActiveShell(), Messages.FontListFieldEditor_errorSave,
                                        null, status);
                            }
                        });
                    } finally {
                        monitor.done();
                    }
                    return Status.OK_STATUS;
                }
            };
            job.setPriority(Job.LONG);
            job.schedule();
        }
    }
}
项目:jasperreports    文件:JRCloneUtils.java   
/**
 * Clones an object after checking whether the argument is null.
 * 
 * @param original the object to be cloned
 * @return a clone of the argument, or <code>null</code> if the argument was
 * <code>null</code>
 */
public static <T extends JRCloneable> T nullSafeClone(T original)
{
    return original == null ? null : (T)original.clone();
}