Java 类net.sf.jasperreports.engine.type.SortFieldTypeEnum 实例源码

项目:jasperreports    文件:JRSortFieldFactory.java   
@Override
public Object createObject(Attributes atts)
{
    JRDesignSortField sortField = new JRDesignSortField();

    sortField.setName(atts.getValue(JRXmlConstants.ATTRIBUTE_name));

    SortOrderEnum order = SortOrderEnum.getByName(atts.getValue(JRXmlConstants.ATTRIBUTE_order));
    if (order != null)
    {
        sortField.setOrder(order);
    }

    SortFieldTypeEnum type = SortFieldTypeEnum.getByName(atts.getValue(JRXmlConstants.ATTRIBUTE_type));
    if (type != null)
    {
        sortField.setType(type);
    }

    return sortField;
}
项目:jasperreports    文件:SortComponentFill.java   
protected FilterTypesEnum getFilterType()
{
    SortFieldTypeEnum type = sortComponent.getSortFieldType();
    String name = sortComponent.getSortFieldName();
    JRFillDataset dataset = fillContext.getFillDataset();

    FilterTypesEnum filterType = null;
    if (SortFieldTypeEnum.FIELD.equals(type))
    {
        JRFillField field = dataset.getFillField(name);
        filterType = SortElementUtils.getFilterType(field.getValueClass());
    }
    else if (SortFieldTypeEnum.VARIABLE.equals(type))
    {
        JRFillVariable variable = dataset.getFillVariable(name);
        filterType = SortElementUtils.getFilterType(variable.getValueClass());
    }
    return filterType;
}
项目:PDFReporter-Studio    文件:DeleteVariableCommand.java   
@Override
public void execute() {
    elementPosition = jrDataset.getVariablesList().indexOf(jrVariable);
    jrDataset.removeVariable(jrVariable);

    if (jrSortField == null)
        for (JRSortField sf : jrDataset.getSortFieldsList()) {
            if (sf.getType().equals(SortFieldTypeEnum.VARIABLE) && sf.getName().equals(jrVariable.getName())) {
                jrSortField = sf;
                break;
            }
        }
    if (jrSortField != null) {
        oldSortFieldindex = jrDataset.getSortFieldsList().indexOf(jrSortField);
        jrDataset.removeSortField(jrSortField);
    }
}
项目:PDFReporter-Studio    文件:MSortField.java   
public void setPropertyValue(Object id, Object value) {
    JRDesignSortField jrField = (JRDesignSortField) getValue();
    if (id.equals(JRDesignSortField.PROPERTY_NAME)) {
        if (!value.equals("")) { //$NON-NLS-1$
            String oldName = jrField.getName();
            String oldType = jrField.getType().getName();
            String newName = (String) value;
            //The type is the same
            changeNameAndType(oldName, oldType, newName,  jrField.getType(), jrField);
        }
    } else if (id.equals(JRDesignSortField.PROPERTY_ORDER))
        jrField.setOrder((SortOrderEnum) orderD.getEnumValue(value));
    else if (id.equals(JRDesignSortField.PROPERTY_TYPE)) {
        SortFieldTypeEnum type = (SortFieldTypeEnum) typeD.getEnumValue(value);
        selectFirstAvailableName(type);
    }
}
项目:PDFReporter-Studio    文件:DeleteFieldCommand.java   
@Override
public void execute() {
    canceled = Boolean.FALSE;
    elementPosition = jrDataset.getFieldsList().indexOf(jrField);
    jrDataset.removeField(jrField);

    if (jrSortField == null)
        for (JRSortField sf : jrDataset.getSortFieldsList()) {
            if (sf.getType().equals(SortFieldTypeEnum.FIELD) && sf.getName().equals(jrField.getName())) {
                jrSortField = sf;
                break;
            }
        }
    if (jrSortField != null) {
        oldSortFieldindex = jrDataset.getSortFieldsList().indexOf(jrSortField);
        jrDataset.removeSortField(jrSortField);
    }
}
项目:Genji    文件:ReportOverviewJasperDesign.java   
/**
 * Add a sort order field to jasperDesign
 * 
 * @param jasperDesign
 * @param sortField
 * @param sortOrder
 */
private static void addSortOrder(JasperDesign jasperDesign, SortFieldTO sortField) {
    if (sortField != null) {
        // not a pseudo field
        // the name of the field from XML to sort by
        String sortFieldName = sortField.getName();
        if (ReportBeansToXML.hasExtraSortField(sortField.getFieldID())) {
            sortFieldName = sortFieldName + TReportLayoutBean.PSEUDO_COLUMN_NAMES.ORDER;
        }
        SortOrderEnum sortOrderEnum = null;
        if (sortField.isDescending()) {
            sortOrderEnum = SortOrderEnum.DESCENDING;
        } else {
            sortOrderEnum = SortOrderEnum.ASCENDING;
        }
        try {
            jasperDesign.addSortField(new JRDesignSortField(sortFieldName, SortFieldTypeEnum.FIELD, sortOrderEnum));
        } catch (JRException e) {
            LOGGER.warn("Adding the sort field " + sortFieldName + " for sorting failed with " + e.getMessage());
            LOGGER.debug(ExceptionUtils.getStackTrace(e));
        }
    }
}
项目:jasperreports    文件:JRBaseSortField.java   
@SuppressWarnings("deprecation")
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
{
    in.defaultReadObject();

    if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_3_7_2)
    {
        orderValue = SortOrderEnum.getByValue((byte)(order + 1));
    }

    if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_3_7_5)
    {
        type = SortFieldTypeEnum.FIELD;
    }
}
项目:jasperreports    文件:JRXmlWriter.java   
/**
 *
 */
private void writeSortField(JRSortField sortField) throws IOException
{
    writer.startElement(JRXmlConstants.ELEMENT_sortField);
    writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_name, sortField.getName());
    writer.addAttribute(JRXmlConstants.ATTRIBUTE_order, sortField.getOrderValue(), SortOrderEnum.ASCENDING);
    if(isNewerVersionOrEqual(JRConstants.VERSION_3_7_5))
    {
        writer.addAttribute(JRXmlConstants.ATTRIBUTE_type, sortField.getType(), SortFieldTypeEnum.FIELD);
    }
    writer.closeElement();
}
项目:jasperreports    文件:JRApiWriter.java   
/**
 *
 */
private void writeSortField( JRSortField sortField, String sortFieldName)
{
    if(sortField != null)
    {
        write( "JRDesignSortField " + sortFieldName + " = new JRDesignSortField();\n");
        write( sortFieldName + ".setName(\"{0}\");\n", JRStringUtil.escapeJavaStringLiteral(sortField.getName()));
        write( sortFieldName + ".setOrder({0});\n", sortField.getOrderValue(), SortOrderEnum.ASCENDING);
        write( sortFieldName + ".setType({0});\n", sortField.getType(), SortFieldTypeEnum.FIELD);
        flush();
    }
}
项目:jasperreports    文件:JRDesignSortField.java   
/**
 *
 */
public JRDesignSortField(
    String name,
    SortFieldTypeEnum type,
    SortOrderEnum order
    )
{
    this.name = name;
    this.type = type;
    this.orderValue = order;
}
项目:jasperreports    文件:JRDesignSortField.java   
/**
 *
 */
public void setType(SortFieldTypeEnum type)
{
    Object old = this.type;
    this.type = type;
    getEventSupport().firePropertyChange(PROPERTY_TYPE, old, this.type);
}
项目:jasperreports    文件:SortComponentSymbolFactory.java   
@Override
public Object createObject(Attributes atts) throws JRException
{
    SortComponent sortComponent = (SortComponent)digester.peek();

    // Set the text color
    String attrValue = atts.getValue(SortComponent.PROPERTY_HANDLER_COLOR);
    if (attrValue != null && attrValue.length() > 0)
    {
        Color color = JRColorUtil.getColor(attrValue, null);
        sortComponent.setHandlerColor(color);
    }

    sortComponent.setSortFieldName(atts.getValue(SortComponent.PROPERTY_COLUMN_NAME));

    SortFieldTypeEnum fieldType = SortFieldTypeEnum.getByName(atts.getValue(SortComponent.PROPERTY_COLUMN_TYPE));
    if (fieldType != null)
    {
        sortComponent.setSortFieldType(fieldType);
    }

    HorizontalImageAlignEnum hAlign = HorizontalImageAlignEnum.getByName(atts.getValue(SortComponent.PROPERTY_HANDLER_HORIZONTAL_ALIGN));
    if (hAlign != null)
    {
        sortComponent.setHandlerHorizontalImageAlign(hAlign);
    }

    VerticalImageAlignEnum vAlign = VerticalImageAlignEnum.getByName(atts.getValue(SortComponent.PROPERTY_HANDLER_VERTICAL_ALIGN));
    if (vAlign != null)
    {
        sortComponent.setHandlerVerticalImageAlign(vAlign);
    }

    return sortComponent;
}
项目:jasperreports    文件:SortComponent.java   
/**
 * @param sortFieldType the sort field type to set
 */
public void setSortFieldType(SortFieldTypeEnum sortFieldType) {
    Object old = this.sortFieldType;
    this.sortFieldType = sortFieldType;
    getEventSupport().firePropertyChange(PROPERTY_COLUMN_TYPE, 
            old, this.sortFieldType);
}
项目:PDFReporter-Studio    文件:MSort.java   
@Override
public JRDesignComponentElement createJRElement(JasperDesign jasperDesign) {
    JRDesignComponentElement jrcomponent = new JRDesignComponentElement();
    SortComponent component = new SortComponent();
    component.setSortFieldType(SortFieldTypeEnum.FIELD);
    jrcomponent.setComponent(component);
    jrcomponent.setComponentKey(new ComponentKey("http://jasperreports.sourceforge.net/jasperreports/components", "c", "sort")); //$NON-NLS-1$

    DefaultManager.INSTANCE.applyDefault(this.getClass(), jrcomponent);

    return jrcomponent;
}
项目:PDFReporter-Studio    文件:MSort.java   
@Override
public void setPropertyValue(Object id, Object value) {
    JRDesignComponentElement jrElement = (JRDesignComponentElement) getValue();
    SortComponent component = (SortComponent) jrElement.getComponent();

    if (id.equals(SortComponent.PROPERTY_HANDLER_COLOR))
        component.setHandlerColor(Colors.getAWT4SWTRGBColor((AlfaRGB) value));
    else if (id.equals(SortComponent.PROPERTY_COLUMN_NAME))
        component.setSortFieldName((String) value);
    else if (id.equals(SortComponent.PROPERTY_COLUMN_TYPE))
        component.setSortFieldType((SortFieldTypeEnum) EnumHelper
                .getSetValue(SortFieldTypeEnum.values(), value, 0, false));

    else if (id.equals(SortComponent.PROPERTY_EVALUATION_TIME))
        component.setEvaluationTime((EvaluationTimeEnum) EnumHelper
                .getSetValue(EvaluationTimeEnum.values(), value, 1, false));
    else if (id.equals(SortComponent.PROPERTY_EVALUATION_GROUP)) {
        component.setEvaluationGroup((String) value);
    } else if (id.equals(SortComponent.PROPERTY_HANDLER_HORIZONTAL_ALIGN)) {
        component
                .setHandlerHorizontalAlign((HorizontalAlignEnum) EnumHelper
                        .getSetValue(HorizontalAlignEnum.values(), value,
                                1, false));
    } else if (id.equals(SortComponent.PROPERTY_HANDLER_VERTICAL_ALIGN)) {
        component.setHandlerVerticalAlign((VerticalAlignEnum) EnumHelper
                .getSetValue(VerticalAlignEnum.values(), value, 1, false));
    } else
        super.setPropertyValue(id, value);
}
项目:PDFReporter-Studio    文件:SortFieldsTable.java   
public Image getColumnImage(Object element, int columnIndex) {
    JRDesignSortField field = (JRDesignSortField) element;
    switch (columnIndex) {
    case 0:
        if (field.getType().equals(SortFieldTypeEnum.FIELD))
            return JaspersoftStudioPlugin.getInstance().getImage(MField.getIconDescriptor().getIcon16());
        else
            return JaspersoftStudioPlugin.getInstance().getImage(MVariable.getIconDescriptor().getIcon16());
    }
    return null; //$NON-NLS-1$
}
项目:PDFReporter-Studio    文件:PostSetVariableName.java   
/**
 * Get a list of all the Sortfield that are using a variable, and if one of them is using
 * the renamed variable then its name also is updated with the new one
 */
@Override
public Command postSetValue(IPropertySource target, Object prop, Object newValue, Object oldValue) {
    JSSCompoundCommand c = new JSSCompoundCommand(null);
    if (target instanceof MVariable && prop.equals(JRDesignVariable.PROPERTY_NAME)) {
        MVariable targetNode = (MVariable) target;
        c.setReferenceNodeIfNull(targetNode);
        JRDesignDataset d = ModelUtils.getDataset(targetNode);
        if (d != null){
            for(INode field : ModelUtils.getSortFields(targetNode)){
                APropertyNode sortField = (APropertyNode)field;
                JRDesignSortField jrField = (JRDesignSortField) sortField.getValue();
                if (jrField != null){
                    Object fieldName = jrField.getName();
                    Object fieldType = jrField.getType();
                    if (SortFieldTypeEnum.VARIABLE.equals(fieldType) && fieldName != null && fieldName.equals(oldValue)){
                        SetValueCommand updateSFCommand = new SetValueCommand();
                        updateSFCommand.setTarget(sortField);
                        updateSFCommand.setPropertyId(JRDesignSortField.PROPERTY_NAME);
                        updateSFCommand.setPropertyValue(newValue);
                        c.add(updateSFCommand);
                    }
                }
            }
        }
    }
    return c;
}
项目:PDFReporter-Studio    文件:MSortField.java   
public ImageDescriptor getImagePath() {
    if (getValue() != null) {
        JRDesignSortField sortField = (JRDesignSortField) getValue();
        if (sortField.getType().equals(SortFieldTypeEnum.FIELD))
            return MField.getIconDescriptor().getIcon16();
        if (sortField.getType().equals(SortFieldTypeEnum.VARIABLE))
            return MVariable.getIconDescriptor().getIcon16();
    }
    return getIconDescriptor().getIcon16();
}
项目:PDFReporter-Studio    文件:MSortField.java   
/**
 * Creates the property descriptors.
 * 
 * @param desc
 *          the desc
 */
@Override
public void createPropertyDescriptors(List<IPropertyDescriptor> desc, Map<String, Object> defaultsMap) {
    nameD = new RComboBoxPropertyDescriptor(JRDesignSortField.PROPERTY_NAME, Messages.common_name, new String[] { "" }); //$NON-NLS-1$
    nameD.setDescription(Messages.MSortField_name_description);
    desc.add(nameD);

    typeD = new JSSEnumPropertyDescriptor(JRDesignSortField.PROPERTY_TYPE, Messages.MSortField_typeTitle,
            SortFieldTypeEnum.class, NullEnum.NOTNULL) {
        public ASPropertyWidget createWidget(Composite parent, AbstractSection section) {
            Image[] images = new Image[] {
                    JaspersoftStudioPlugin.getInstance().getImage("icons/resources/fields-sort-16.png"), //$NON-NLS-1$
                    JaspersoftStudioPlugin.getInstance().getImage("icons/resources/variables-sort-16.png") }; //$NON-NLS-1$
            return new SPToolBarEnum(parent, section, this, images, false);
        }
    };
    typeD.setDescription("Sort field type"); //$NON-NLS-1$
    desc.add(typeD);

    orderD = new JSSEnumPropertyDescriptor(JRDesignSortField.PROPERTY_ORDER, Messages.common_order,
            SortOrderEnum.class, NullEnum.NOTNULL) {
        public ASPropertyWidget createWidget(Composite parent, AbstractSection section) {
            Image[] images = new Image[] {
                    JaspersoftStudioPlugin.getInstance().getImage("icons/resources/sort-number-column.png"), //$NON-NLS-1$
                    JaspersoftStudioPlugin.getInstance().getImage("icons/resources/sort-number-descending.png") }; //$NON-NLS-1$
            return new SPToolBarEnum(parent, section, this, images, false);
        }
    };
    orderD.setDescription(Messages.MSortField_order_description);
    desc.add(orderD);

    defaultsMap.put(JRDesignSortField.PROPERTY_ORDER, typeD.getEnumValue(SortOrderEnum.ASCENDING));
    defaultsMap.put(JRDesignSortField.PROPERTY_TYPE, orderD.getEnumValue(SortFieldTypeEnum.FIELD));

    setHelpPrefix(desc, "net.sf.jasperreports.doc/docs/schema.reference.html?cp=0_1#sortField"); //$NON-NLS-1$
}
项目:PDFReporter-Studio    文件:MSortField.java   
/**
 * Change the name and the type of the sortfields updating also its entry
 * in the dataset map
 * 
 * @param oldName the old name
 * @param oldType the old type
 * @param newName the new name
 * @param newType the new type
 * @param field the field
 */
private void changeNameAndType(String oldName, String oldType, String newName, SortFieldTypeEnum newType, JRSortField field){
    JRDesignDataset d = ModelUtils.getDataset(this);
    if (d != null) {
        String oldKey = getSortFieldKey(oldName, oldType);
        d.getSortFieldsMap().remove(oldKey);
        d.getSortFieldsMap().put(getSortFieldKey(newName, newType.getName()), field);
        JRDesignSortField jrField = (JRDesignSortField) field;
        jrField.setName(newName);
        jrField.setType(newType);
    }
}
项目:PDFReporter-Studio    文件:ChangeSortFieldTypeCommand.java   
@Override
public void execute() {
    if (jrField != null) {
        oldName = jrField.getName();
        oldType = jrField.getType();
        jrDataSet.getSortFieldsMap().remove(getSortFieldKey(jrField));

        SortFieldWizard wizard = new SortFieldWizard();
        JRDesignSortField dummyField = new JRDesignSortField();
        wizard.init(jrDataSet, dummyField);
        if (jrField.getType() == SortFieldTypeEnum.FIELD) {
            dummyField.setType(SortFieldTypeEnum.VARIABLE);
            wizard.setShownElementsType(SHOW_TYPE.VARIABLES);
        } else {
            dummyField.setType(SortFieldTypeEnum.FIELD);
            wizard.setShownElementsType(SHOW_TYPE.FIELDS);
        }
        WizardDialog dialog = new WizardDialog(UIUtils.getShell(), wizard);
        dialog.create();
        if (dialog.open() != Dialog.OK) {
            oldName = null;
            oldType = null;
        } else {
            jrField.setType(dummyField.getType());
            jrField.setName(dummyField.getName());
        }
        jrDataSet.getSortFieldsMap().put(getSortFieldKey(jrField), jrField);
    }
}
项目:PDFReporter-Studio    文件:WizardSortFieldPage.java   
public void widgetSelected(SelectionEvent e) {
    IStructuredSelection sel = (IStructuredSelection) tableView.getSelection();
    Object obj = sel.getFirstElement();
    if (obj instanceof JRField) {
        jrSortfield.setName(((JRField) obj).getName());
        jrSortfield.setType(SortFieldTypeEnum.FIELD);
    } else if (obj instanceof JRVariable) {
        jrSortfield.setName(((JRVariable) obj).getName());
        jrSortfield.setType(SortFieldTypeEnum.VARIABLE);
    }
}
项目:PDFReporter-Studio    文件:PostSetFieldName.java   
/**
 * Get a list of all the Sortfield that are using a field, and if one of them is using
 * the renamed field then its name also is updated with the new one
 */
@Override
public Command postSetValue(IPropertySource target, Object prop, Object newValue, Object oldValue) {
    JSSCompoundCommand c = new JSSCompoundCommand(null);
    if (target instanceof MField && prop.equals(JRDesignField.PROPERTY_NAME)) {
        MField targetNode = (MField) target;
        c.setReferenceNodeIfNull(targetNode);
        JRDesignDataset d = ModelUtils.getDataset(targetNode);
        if (d != null){
            for(INode field : ModelUtils.getSortFields(targetNode)){
                APropertyNode sortField = (APropertyNode)field;
                JRDesignSortField jrField = (JRDesignSortField) sortField.getValue();
                if (jrField != null){
                    Object sortFieldName = jrField.getName();
                    Object sortFieldType = jrField.getType();
                    if (SortFieldTypeEnum.FIELD.equals(sortFieldType) && sortFieldName != null && sortFieldName.equals(oldValue)){
                        SetValueCommand updateSFCommand = new SetValueCommand();
                        updateSFCommand.setTarget(sortField);
                        updateSFCommand.setPropertyId(JRDesignSortField.PROPERTY_NAME);
                        updateSFCommand.setPropertyValue(newValue);
                        c.add(updateSFCommand);
                    }
                }
            }
        }
    }
    return c;
}
项目:PDFReporter-Studio    文件:SortFieldSection.java   
public Image getColumnImage(Object element, int columnIndex) {
    switch (columnIndex) {
    case 0:
        if (((JRSortField) element).getType().equals(SortFieldTypeEnum.FIELD))
            return JaspersoftStudioPlugin.getInstance().getImage(MField.getIconDescriptor().getIcon16());
        return JaspersoftStudioPlugin.getInstance().getImage(MVariable.getIconDescriptor().getIcon16());
    }
    return null;
}
项目:ireport-fork    文件:ColumnProperty.java   
@Override
public void setPropertyValue(Object value) {

    if (value == null)
    {
        component.setSortFieldName(null);
        component.setSortFieldType(null);
    }
    else
    {
        if (value instanceof String && ((String)value).startsWith("F"))
        {
            component.setSortFieldName(((String)value).substring(1));
            component.setSortFieldType(SortFieldTypeEnum.FIELD);
        }
        else if (value instanceof String && ((String)value).startsWith("V"))
        {
            component.setSortFieldName(((String)value).substring(1));
            component.setSortFieldType(SortFieldTypeEnum.VARIABLE);
        }
        else
        {
            component.setSortFieldName(null);
            component.setSortFieldType(null);
        }
    }
}
项目:ireport-fork    文件:SortFieldDialog.java   
private void jButtonOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonOKActionPerformed

    Object obj = this.jComboBoxSortBy.getSelectedItem();

    if (obj == null)
    {
        javax.swing.JOptionPane.showMessageDialog(this,
                //I18n.getString("sortFieldDialog.messageNotValidField",
                I18n.getString("SortFieldDialog.Message.Error"),
                //I18n.getString("sortFieldDialog.messageTitleNotValidField",
                I18n.getString("SortFieldDialog.Message.Error2"),
                javax.swing.JOptionPane.WARNING_MESSAGE );
        return;
    }

    String fieldName = "";
    tmpSortField = new JRDesignSortField();

    if (obj instanceof JRDesignField)
    {
        fieldName = ((JRDesignField)obj).getName();
        tmpSortField.setType(SortFieldTypeEnum.FIELD);
    }
    else if (obj instanceof JRDesignVariable)
    {
        fieldName = ((JRDesignVariable)obj).getName();
        tmpSortField.setType(SortFieldTypeEnum.VARIABLE);
    }


    tmpSortField.setName(fieldName);
    tmpSortField.setOrder( (jComboBoxSortType.getSelectedIndex() == 1) ? 
                SortOrderEnum.DESCENDING : SortOrderEnum.ASCENDING);

    setVisible(false);
    this.setDialogResult( javax.swing.JOptionPane.OK_OPTION);
    dispose();
}
项目:ireport-fork    文件:SortFieldDialog.java   
public void setSortField(JRDesignSortField sortField) {
    this.tmpSortField = new JRDesignSortField();
    this.tmpSortField.setName(  sortField.getName() );
    this.tmpSortField.setOrder(  sortField.getOrderValue() );
    this.tmpSortField.setType( sortField.getType() );
    this.tmpSortField.setName( sortField.getName());

    for (int i=0; i<jComboBoxSortBy.getItemCount(); ++i)
    {
        Object item = jComboBoxSortBy.getItemAt(i);

        if (item instanceof JRDesignField &&
            sortField.getType() == SortFieldTypeEnum.FIELD &&
            ((JRDesignField)item).getName().equals(sortField.getName()))
        {
            jComboBoxSortBy.setSelectedIndex(i);
            break;
        }
        else if (item instanceof JRDesignVariable &&
            sortField.getType() == SortFieldTypeEnum.VARIABLE &&
            ((JRDesignVariable)item).getName().equals(sortField.getName()))
        {
            jComboBoxSortBy.setSelectedIndex(i);
            break;
        }
    }

    this.jComboBoxSortType.setSelectedIndex( ((tmpSortField.getOrderValue() == SortOrderEnum.DESCENDING) ? 1 : 0) );
}
项目:jasperreports    文件:JRBaseSortField.java   
@Override
public SortFieldTypeEnum getType()
{
    return type;
}
项目:jasperreports    文件:HeaderToolbarElementJsonHandler.java   
private static FilterData getFilterData(
    JasperReportsContext jasperReportsContext,
    JRDesignDataset dataset,
    String columnName,
    String columnType,
    FilterTypesEnum filterType,
    String columnValuePattern,
    Locale locale,
    TimeZone timeZone
    ) 
{
    // get existing filter as JSON string
    String serializedFilters = "[]";
    JRPropertiesMap propertiesMap = dataset.getPropertiesMap();
    if (propertiesMap.getProperty(FilterCommand.DATASET_FILTER_PROPERTY) != null) {
        serializedFilters = propertiesMap.getProperty(FilterCommand.DATASET_FILTER_PROPERTY);
    }

    List<DatasetFilter> filters = new ArrayList<DatasetFilter>();

    List<? extends DatasetFilter> existingFilters = JacksonUtil.getInstance(jasperReportsContext).loadList(serializedFilters, FieldFilter.class);
    if (existingFilters.size() > 0) {
        for (DatasetFilter filter: existingFilters) {
            if (((FieldFilter)filter).getField().equals(columnName)) {
                filters.add(filter);
                break;
            }
        }
    }

    FilterData filterData = new FilterData();
    filterData.setFieldName(columnName);
    filterData.setFilterType(filterType.getName());
    filterData.setIsField(SortFieldTypeEnum.FIELD.equals(SortFieldTypeEnum.getByName(columnType)));

    if (filters.size() > 0) 
    {
        FieldFilter ff = (FieldFilter)filters.get(0);
        filterData.setFieldValueStart(ff.getFilterValueStart());
        filterData.setFieldValueEnd(ff.getFilterValueEnd());
        filterData.setFilterTypeOperator(ff.getFilterTypeOperator());
        filterData.setFilterType(ff.getFilterType());
        filterData.setFilterPattern(ff.getFilterPattern());
        filterData.setLocaleCode(ff.getLocaleCode());
        filterData.setTimeZoneId(ff.getTimeZoneId());
    }

    if (filterType.getName().equals(filterData.getFilterType()))
    {
        String filterPattern = HeaderToolbarElementUtils.getFilterPattern(jasperReportsContext, locale, filterType);

        if (FilterTypesEnum.NUMERIC.equals(filterType) && DURATION_PATTERN.equals(columnValuePattern)) {
            filterPattern = DURATION_PATTERN;
        }

        HeaderToolbarElementUtils.updateFilterData(
            filterData,
            filterPattern,
            locale,
            timeZone
            );
    }
    else
    {
        //FIXMEJIVE should we raise error?
    }

    return filterData;
}
项目:jasperreports    文件:SortComponent.java   
/**
 * @return the columnType
 */
public SortFieldTypeEnum getSortFieldType() {
    return sortFieldType;
}
项目:jasperreports    文件:SortCommand.java   
@Override
public void execute() throws CommandException 
{
    SortOrderEnum sortOrder = HeaderToolbarElementUtils.getSortOrder(sortData.getSortOrder());//FIXMEJIVE use labels in JR enum, even if they are longer

    JRDesignSortField newSortField = 
        new JRDesignSortField(
            sortData.getSortColumnName(),
            SortFieldTypeEnum.getByName(sortData.getSortColumnType()),
            sortOrder
            );

    JRSortField oldSortField = null;
    List<JRSortField> sortFields = dataset.getSortFieldsList();
    if (
        JRPropertiesUtil.getInstance(jasperReportsContext).getBooleanProperty(dataset, PROPERTY_CREATE_SORT_FIELDS_FOR_GROUPS, false)
        && (sortFields == null || sortFields.isEmpty())
        )
    {
        List<JRGroup> groups = dataset.getGroupsList();
        for (JRGroup group : groups)
        {
            JRExpression expression = group.getExpression();
            if (expression != null)
            {
                JRExpressionChunk[] chunks = expression.getChunks();
                if (chunks != null && chunks.length == 1)
                {
                    JRExpressionChunk chunk = chunks[0];
                    if (
                        chunk.getType() == JRExpressionChunk.TYPE_FIELD
                        || chunk.getType() == JRExpressionChunk.TYPE_VARIABLE
                        )
                    {
                        JRDesignSortField groupSortField = 
                            new JRDesignSortField(
                                chunk.getText(),
                                chunk.getType() == JRExpressionChunk.TYPE_FIELD 
                                    ? SortFieldTypeEnum.FIELD
                                    : SortFieldTypeEnum.VARIABLE,
                                SortOrderEnum.ASCENDING
                                );
                        individualCommandStack.execute(new AddSortFieldCommand(dataset, groupSortField));
                    }
                }
            }
        }
    }

    for (JRSortField crtSortField : sortFields)
    {
        if (
            newSortField.getName().equals(crtSortField.getName())
            && newSortField.getType() == crtSortField.getType()
            )
        {
            oldSortField = crtSortField;
            break;
        }
    }

    if (oldSortField != null)
    {
        individualCommandStack.execute(new RemoveSortFieldCommand(dataset, oldSortField));
    }

    if (sortOrder != null)
    {
        individualCommandStack.execute(new AddSortFieldCommand(dataset, newSortField));
    }
}
项目:PDFReporter-Studio    文件:MSort.java   
/**
 * Creates the property descriptors.
 * 
 * @param desc
 *            the desc
 */
@Override
public void createPropertyDescriptors(List<IPropertyDescriptor> desc,
        Map<String, Object> defaultsMap) {
    super.createPropertyDescriptors(desc, defaultsMap);

    ComboBoxPropertyDescriptor evaluationTimeD = new ComboBoxPropertyDescriptor(
            SortComponent.PROPERTY_EVALUATION_TIME,
            Messages.common_evaluation_time, EnumHelper.getEnumNames(
                    EvaluationTimeEnum.values(), NullEnum.NOTNULL));
    evaluationTimeD
            .setDescription(Messages.MGenericElement_evaluation_time_description);
    desc.add(evaluationTimeD);

    evaluationGroupNameD = new RComboBoxPropertyDescriptor(
            SortComponent.PROPERTY_EVALUATION_GROUP,
            Messages.MGenericElement_evaluation_group_name,
            new String[] { "" }); //$NON-NLS-2$
    evaluationGroupNameD
            .setDescription(Messages.MGenericElement_evaluation_group_name_description);
    desc.add(evaluationGroupNameD);

    ColorPropertyDescriptor color = new ColorPropertyDescriptor(
            SortComponent.PROPERTY_HANDLER_COLOR, "Handler Color",
            NullEnum.NULL);
    color.setDescription("Handler color");
    desc.add(color);

    ComboBoxPropertyDescriptor horizAlign = new ComboBoxPropertyDescriptor(
            SortComponent.PROPERTY_HANDLER_HORIZONTAL_ALIGN,
            "Handler Horizontal Alignement", EnumHelper.getEnumNames(
                    HorizontalAlignEnum.values(), NullEnum.NOTNULL));
    horizAlign.setDescription("Handler horizontal alignement");
    desc.add(horizAlign);

    ComboBoxPropertyDescriptor vertAlign = new ComboBoxPropertyDescriptor(
            SortComponent.PROPERTY_HANDLER_VERTICAL_ALIGN,
            "Handler Vertical Alignement", EnumHelper.getEnumNames(
                    VerticalAlignEnum.values(), NullEnum.NOTNULL));
    vertAlign.setDescription("Handler vertical alignement");
    desc.add(vertAlign);

    ComboBoxPropertyDescriptor sortFieldType = new ComboBoxPropertyDescriptor(
            SortComponent.PROPERTY_COLUMN_TYPE, "SortField Type",
            EnumHelper.getEnumNames(SortFieldTypeEnum.values(),
                    NullEnum.NOTNULL));
    sortFieldType.setDescription("SortField type");
    desc.add(sortFieldType);

    NTextPropertyDescriptor sortFieldName = new NTextPropertyDescriptor(
            SortComponent.PROPERTY_COLUMN_NAME, "SortField Name");
    sortFieldName.setDescription("SortField name");
    desc.add(sortFieldName);

    color.setCategory("Sort Properties");
    sortFieldType.setCategory("Sort Properties");
    sortFieldName.setCategory("Sort Properties");

    horizAlign.setCategory("Sort Properties");
    vertAlign.setCategory("Sort Properties");
    evaluationTimeD.setCategory("Sort Properties");
    evaluationGroupNameD.setCategory("Sort Properties");

    defaultsMap.put(SortComponent.PROPERTY_HANDLER_VERTICAL_ALIGN,
            VerticalAlignEnum.MIDDLE);
    defaultsMap.put(SortComponent.PROPERTY_HANDLER_HORIZONTAL_ALIGN,
            HorizontalAlignEnum.LEFT);
    defaultsMap.put(SortComponent.PROPERTY_EVALUATION_TIME,
            EvaluationTimeEnum.NOW);
    defaultsMap.put(SortComponent.PROPERTY_HANDLER_COLOR, null);
    defaultsMap.put(SortComponent.PROPERTY_COLUMN_TYPE,
            SortFieldTypeEnum.FIELD);

}
项目:ireport-fork    文件:ColumnProperty.java   
@Override
public Object getPropertyValue() {

    String field = component.getSortFieldName();

    if (field == null || field.length() == 0) return null;
    if (component.getSortFieldType() != null && component.getSortFieldType() == SortFieldTypeEnum.VARIABLE ) return "V"+field;
    return "F"+field;

}
项目:ireport-fork    文件:SortFieldCellRenderer.java   
@Override
public java.awt.Component getListCellRendererComponent(javax.swing.JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {

    java.awt.Component retValue;

    retValue = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);

    if (value instanceof JRDesignSortField && retValue instanceof JLabel)
    {
        JRDesignSortField sf = (JRDesignSortField)value;
        JLabel label = (JLabel)retValue;

        String t = sf.getType() == SortFieldTypeEnum.FIELD ? "Field" : "Variable";

        Color cf = Color.green.darker().darker();
        Color cv = Color.BLUE;
        String c = sf.getType() == SortFieldTypeEnum.FIELD ? getEncodedColor(cf) : getEncodedColor(cv);

        String text = "<html>" + sf.getName() + " " + ((isSelected) ? t : "<font color=\"" + c + "\">" + t + "</font>");


        label.setText( text);

        label.setIcon( sf.getOrderValue() == SortOrderEnum.DESCENDING ? descIcon : ascIcon );
    }

    return retValue;
}
项目:jasperreports    文件:JRDesignDataset.java   
/**
 * Removes a sort field from the dataset.
 * 
 * @param fieldName the field name
 * @return the removed sort field, or <code>null</code> if the sort field was not found
 * @deprecated To be removed.
 */
public JRSortField removeSortField(String fieldName)
{
    return removeSortField(sortFieldsMap.get(getSortFieldKey(new JRDesignSortField(fieldName, SortFieldTypeEnum.FIELD, SortOrderEnum.ASCENDING))));
}
项目:jasperreports    文件:JRSortField.java   
/**
 * Gets the type of the sort field.
 */
public SortFieldTypeEnum getType();