Example usage for org.apache.commons.lang3 StringUtils capitalize

List of usage examples for org.apache.commons.lang3 StringUtils capitalize

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils capitalize.

Prototype

public static String capitalize(final String str) 

Source Link

Document

Capitalizes a String changing the first letter to title case as per Character#toTitleCase(char) .

Usage

From source file:gr.demokritos.iit.textforms.json.Tweet.java

private void swapSymbols(String[] tokens) {
    Iterator ith = this.hashtags.iterator();
    Iterator itm = this.mentions.iterator();

    for (int i = 0; i < tokens.length; i++) {
        if (tokens[i].startsWith("@") && itm.hasNext()) {
            tokens[i] = "@" + StringUtils.capitalize(itm.next().toString());
        } else if (tokens[i].startsWith("#") && ith.hasNext()) {
            tokens[i] = "#" + StringUtils.capitalize(ith.next().toString());
        }/*w  w w  .  j a v  a  2 s .  c o m*/
    }
}

From source file:de.knightsoftnet.validators.rebind.GwtSpecificValidatorCreator.java

public static String asGetter(final PropertyDescriptor propertyDescriptor) {
    return "get" + StringUtils.capitalize(propertyDescriptor.getPropertyName());
}

From source file:com.sunchenbin.store.feilong.core.lang.StringUtil.java

/**
 * ???./*from  w w w .  j  ava2s  . co  m*/
 * 
 * <p>
 * Example 1: jinxin ---> Jinxin
 * </p>
 * 
 * <pre>
 * StringUtils.capitalize(null)  = null
 * StringUtils.capitalize(&quot;&quot;)    = &quot;&quot;
 * StringUtils.capitalize(&quot;cat&quot;) = &quot;Cat&quot;
 * StringUtils.capitalize(&quot;cAt&quot;) = &quot;CAt&quot;
 * </pre>
 * 
 * @param word
 *            ??
 * @return ???
 * @see org.apache.commons.lang3.StringUtils#swapCase(String)
 * @see org.apache.commons.lang3.StringUtils#capitalize(String)
 */
public static String firstCharToUpperCase(String word) {
    return StringUtils.capitalize(word);
}

From source file:com.thoughtworks.go.config.exceptions.EntityType.java

public String idCannotBeBlank() {
    return StringUtils.capitalize(this.entityType) + " " + nameOrId.descriptor + " cannot be blank.";
}

From source file:com.bluepowermod.recipe.LogicRecipes.java

public static void init() {

    // Components
    GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BPItems.bluestone_wire_tile, 1), "#", "W", '#',
            "dustTeslatite", 'W', BPOredictNames.STONE_TILE));
    GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BPItems.bluestone_anode_tile, 3), " # ", "###",
            "WWW", '#', "dustTeslatite", 'W', BPOredictNames.STONE_TILE));
    GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BPItems.bluestone_cathode_tile, 1), "T#T", " W ",
            'T', "dustTeslatite", '#', Blocks.redstone_torch, 'W', BPOredictNames.STONE_TILE));
    GameRegistry.addRecipe(//  w  ww  .  j  a v a 2 s . c o  m
            new ShapedOreRecipe(new ItemStack(BPItems.bluestone_pointer_tile, 1), " S ", "T#T", " W ", 'S',
                    "stone", '#', Blocks.redstone_torch, 'W', BPOredictNames.STONE_TILE, 'T', "dustTeslatite"));
    GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BPItems.bluestone_pointer_tile, 1), "S", "T", 'S',
            "stone", 'T', BPOredictNames.BLUESTONE_CATHODE));

    GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BPItems.redstone_wire_tile, 1), "#", "W", '#',
            "dustRedstone", 'W', BPOredictNames.STONE_TILE));
    GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BPItems.redstone_anode_tile, 3), " # ", "###",
            "WWW", '#', "dustRedstone", 'W', BPOredictNames.STONE_TILE));
    GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BPItems.redstone_cathode_tile, 1), "#", "W", '#',
            Blocks.redstone_torch, 'W', BPOredictNames.STONE_TILE));
    GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BPItems.redstone_pointer_tile, 1), "S", "#", "W",
            'S', "stone", '#', Blocks.redstone_torch, 'W', BPOredictNames.STONE_TILE));
    GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BPItems.redstone_pointer_tile, 1), "S", "T", 'S',
            "stone", 'T', BPOredictNames.REDSTONE_CATHODE));

    GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BPItems.silicon_chip_tile, 1), " # ", "WWW", '#',
            BPItems.blue_doped_wafer, 'W', BPOredictNames.STONE_TILE));
    // GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BPItems.plate_assembly, 1), " # ", "SRS", "#C#", '#', BPOredictNames.STONE_TILE,
    // 'S',
    // "stickWood", 'R', BPItems.red_alloy_ingot, 'C', BPItems.stone_cathode)));
    GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(BPItems.tainted_silicon_chip_tile, 1),
            BPOredictNames.SILICON_CHIP, Items.glowstone_dust));
    GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BPItems.quartz_resonator_tile, 3), " # ", "###",
            "WWW", '#', "gemQuartz", 'W', BPOredictNames.STONE_TILE));

    GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BPItems.stone_bundle, 1), "#", "W", '#',
            "wireBundled", 'W', BPOredictNames.STONE_TILE));

    GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(BPItems.infused_teslatite_dust, 1),
            BPOredictNames.DUST_TESLATITE, Items.redstone));

    {
        for (RedwireType t : RedwireType.values()) {
            int i = 0;
            for (MinecraftColor c : MinecraftColor.WIRE_COLORS) {
                ItemStack stack = PartManager.getPartInfo(
                        "wire." + t.getName() + (c == MinecraftColor.NONE ? "" : "." + c.name().toLowerCase()))
                        .getStack(12);
                ItemStack freestanding = PartManager.getPartInfo("wire.freestanding." + t.getName()
                        + (c == MinecraftColor.NONE ? "" : "." + c.name().toLowerCase())).getStack(1);

                if (c == MinecraftColor.NONE) {
                    GameRegistry
                            .addRecipe(new ShapedOreRecipe(stack.copy(), "iii", 'i', t.getIngotOredictName()));
                    GameRegistry.addRecipe(
                            new ShapedOreRecipe(stack.copy(), "i", "i", "i", 'i', t.getIngotOredictName()));
                } else {
                    GameRegistry.addRecipe(new ShapedOreRecipe(stack.copy(), "www", "iii", "www", 'i',
                            t.getIngotOredictName(), 'w', new ItemStack(Blocks.wool, 1, i)));
                    GameRegistry.addRecipe(new ShapedOreRecipe(stack.copy(), "wiw", "wiw", "wiw", 'i',
                            t.getIngotOredictName(), 'w', new ItemStack(Blocks.wool, 1, i)));
                }
                GameRegistry.addRecipe(new ShapedOreRecipe(freestanding, " s ", "sws", " s ", 's', "stickWood",
                        'w', stack.copy()));
                i++;
            }
        }
    }
    // Bundled wire

    for (RedwireType t : RedwireType.values()) {
        ItemStack bundled = PartManager.getPartInfo("wire." + t.getName() + ".bundled").getStack(1);
        ItemStack freestanding = PartManager.getPartInfo("wire.freestanding." + t.getName() + ".bundled")
                .getStack(1);

        GameRegistry.addRecipe(new ShapedOreRecipe(bundled, "sws", "www", "sws", 'w', t.getName() + "Insulated",
                's', Items.string));
        GameRegistry.addRecipe(
                new ShapedOreRecipe(freestanding, " s ", "sws", " s ", 's', "stickWood", 'w', bundled.copy()));

        for (MinecraftColor c : MinecraftColor.VALID_COLORS) {
            ItemStack stack = PartManager.getPartInfo("wire." + t.getName() + ".bundled"
                    + (c == MinecraftColor.NONE ? "" : "." + c.name().toLowerCase())).getStack(8);
            GameRegistry.addRecipe(new ShapedOreRecipe(stack, "www", "wdw", "www", 'w', bundled, 'd',
                    "dye" + StringUtils.capitalize(ItemDye.field_150923_a[15 - c.ordinal()])));
        }
    }

    // Blocks
    GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BPBlocks.circuit_table), "WIW", "WCW", "WPW", 'W',
            "plankWood", 'I', PartManager.getPartInfo("integratedCircuit3x3").getStack(), 'C', Blocks.chest,
            'P', BPBlocks.project_table));

    // Gates and Circuits
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("and").getStack(), "ACA", "CCC", "#W#",
            '#', BPOredictNames.STONE_TILE, 'A', BPOredictNames.BLUESTONE_ANODE, 'C',
            BPOredictNames.BLUESTONE_CATHODE, 'W', BPOredictNames.BLUESTONE_TILE));
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("buffer").getStack(), "ACA", "WCW",
            "#W#", '#', BPOredictNames.STONE_TILE, 'A', BPOredictNames.BLUESTONE_ANODE, 'C',
            BPOredictNames.BLUESTONE_CATHODE, 'W', BPOredictNames.BLUESTONE_TILE));
    // craftManager.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("bustransceiver"), "BBB", "N#N", "BBB", '#', BPOredictNames.STONE_TILE,
    // 'B',
    // BPItems.stone_bundle, 'N', BPItems.red_doped_wafer));
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("counter").getStack(), "#W#", "CPC",
            "#W#", '#', BPOredictNames.STONE_TILE, 'C', BPOredictNames.BLUESTONE_CATHODE, 'W',
            BPOredictNames.BLUESTONE_TILE, 'P', BPOredictNames.BLUESTONE_POINTER));
    // craftManager.addRecipe(PartManager.getPartInfo("invert"), "#R#", "ROR", "#R#", '#', BPOredictNames.STONE_TILE, 'O',
    // BPItems.plate_assembly, 'R', BPItems.stone_redwire));
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("lightCell").getStack(), "#W#", "#B#",
            "###", '#', BPOredictNames.STONE_TILE, 'B', BPItems.blue_doped_wafer, 'W',
            BPOredictNames.BLUESTONE_TILE));
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("multiplexer").getStack(), "ACA", "C#C",
            "ACW", '#', BPOredictNames.STONE_TILE, 'A', BPOredictNames.BLUESTONE_ANODE, 'C',
            BPOredictNames.BLUESTONE_CATHODE, 'W', BPOredictNames.BLUESTONE_TILE));
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("nand").getStack(), "AAA", "CCC", "#W#",
            '#', BPOredictNames.STONE_TILE, 'A', BPOredictNames.BLUESTONE_ANODE, 'C',
            BPOredictNames.BLUESTONE_CATHODE, 'W', BPOredictNames.BLUESTONE_TILE));
    // craftManager.addRecipe(PartManager.getPartInfo("noninvert"), "#R#", "ROR", "#RC", '#', BPOredictNames.STONE_TILE, 'C',
    // BPItems.stone_cathode, 'O', BPItems.plate_assembly, 'R', BPItems.stone_redwire));
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("nor").getStack(), "#A#", "WCW", "#W#",
            '#', BPOredictNames.STONE_TILE, 'A', BPOredictNames.BLUESTONE_ANODE, 'C',
            BPOredictNames.BLUESTONE_CATHODE, 'W', BPOredictNames.BLUESTONE_TILE));
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("not").getStack(), "#A#", "ACA", "#W#",
            '#', BPOredictNames.STONE_TILE, 'A', BPOredictNames.BLUESTONE_ANODE, 'C',
            BPOredictNames.BLUESTONE_CATHODE, 'W', BPOredictNames.BLUESTONE_TILE));
    // craftManager.addRecipe(PartManager.getPartInfo("null"), "#R#", "RRR", "#R#", '#', BPOredictNames.STONE_TILE, 'R',
    // BPItems.stone_redwire));
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("or").getStack(), "#C#", "WCW", "#W#",
            '#', BPOredictNames.STONE_TILE, 'C', BPOredictNames.BLUESTONE_CATHODE, 'W',
            BPOredictNames.BLUESTONE_TILE));
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("randomizer").getStack(), "#T#", "WWW",
            "TWT", '#', BPOredictNames.STONE_TILE, 'T', BPOredictNames.TAINTED_SILICON_CHIP, 'W',
            BPOredictNames.BLUESTONE_TILE));
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("pulseformer").getStack(), "ACA", "CAC",
            "WW#", '#', BPOredictNames.STONE_TILE, 'A', BPOredictNames.BLUESTONE_ANODE, 'C',
            BPOredictNames.BLUESTONE_CATHODE, 'W', BPOredictNames.BLUESTONE_TILE));
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("repeater").getStack(), "#CW", "#AW",
            "#WC", '#', BPOredictNames.STONE_TILE, 'A', BPOredictNames.BLUESTONE_ANODE, 'C',
            BPOredictNames.BLUESTONE_CATHODE, 'W', BPOredictNames.BLUESTONE_TILE));
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("rs").getStack(), "WWA", "C#C", "AWW",
            '#', BPOredictNames.STONE_TILE, 'A', BPOredictNames.BLUESTONE_ANODE, 'C',
            BPOredictNames.BLUESTONE_CATHODE, 'W', BPOredictNames.BLUESTONE_TILE));
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("sequencer").getStack(), "#C#", "CPC",
            "#C#", '#', BPOredictNames.STONE_TILE, 'C', BPOredictNames.BLUESTONE_CATHODE, 'P',
            BPOredictNames.BLUESTONE_POINTER));
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("state").getStack(), "#AC", "WXP", "#W#",
            '#', BPOredictNames.STONE_TILE, 'A', BPOredictNames.BLUESTONE_ANODE, 'C',
            BPOredictNames.BLUESTONE_CATHODE, 'P', BPOredictNames.BLUESTONE_POINTER, 'W',
            BPOredictNames.BLUESTONE_TILE, 'X', BPOredictNames.SILICON_CHIP));
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("synchronizer").getStack(), "WCW", "XAX",
            "WWW", 'A', BPOredictNames.BLUESTONE_ANODE, 'C', BPOredictNames.BLUESTONE_CATHODE, 'W',
            BPOredictNames.BLUESTONE_TILE, 'X', BPOredictNames.SILICON_CHIP));
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("timer").getStack(), "#W#", "WPW", "ACA",
            '#', BPOredictNames.STONE_TILE, 'A', BPOredictNames.BLUESTONE_ANODE, 'C',
            BPOredictNames.BLUESTONE_CATHODE, 'W', BPOredictNames.BLUESTONE_TILE, 'P',
            BPOredictNames.BLUESTONE_POINTER));
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("toggle").getStack(), "C##", "WLW",
            "C##", '#', BPOredictNames.STONE_TILE, 'C', BPOredictNames.BLUESTONE_CATHODE, 'W',
            BPOredictNames.BLUESTONE_TILE, 'L', Blocks.lever));
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("transparent").getStack(), "ACW", "CCC",
            "CW#", '#', BPOredictNames.STONE_TILE, 'A', BPOredictNames.BLUESTONE_ANODE, 'C',
            BPOredictNames.BLUESTONE_CATHODE, 'W', BPOredictNames.BLUESTONE_TILE));
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("xnor").getStack(), "ACA", "CAC", "WCW",
            'A', BPOredictNames.BLUESTONE_ANODE, 'C', BPOredictNames.BLUESTONE_CATHODE, 'W',
            BPOredictNames.BLUESTONE_TILE));
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("xor").getStack(), "AWA", "CAC", "WCW",
            'A', BPOredictNames.BLUESTONE_ANODE, 'C', BPOredictNames.BLUESTONE_CATHODE, 'W',
            BPOredictNames.BLUESTONE_TILE));

    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("comparator").getStack(), "TCT", "WRW",
            "CAC", 'A', BPOredictNames.REDSTONE_ANODE, 'C', BPOredictNames.REDSTONE_CATHODE, 'W',
            BPOredictNames.REDSTONE_TILE, 'T', BPOredictNames.STONE_TILE, 'R',
            BPOredictNames.QUARTZ_RESONATOR));
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("inverter").getStack(), "#A#", "ACA",
            "#W#", '#', BPOredictNames.STONE_TILE, 'A', BPOredictNames.REDSTONE_ANODE, 'C',
            BPOredictNames.REDSTONE_CATHODE, 'W', BPOredictNames.REDSTONE_TILE));
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("regulabletorch").getStack(), "#W#",
            "#P#", "###", '#', BPOredictNames.STONE_TILE, 'P', BPOredictNames.REDSTONE_POINTER, 'W',
            BPOredictNames.REDSTONE_TILE));

    GameRegistry.addRecipe(new ShapedOreRecipe(GateNullCell.getStackWithData(new GateNullCell()), "SSS", "S S",
            "WWW", 'S', "stickWood", 'W', BPOredictNames.STONE_TILE));

    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("integratedCircuit3x3").getStack(),
            "TST", "SSS", "TST", 'T', BPOredictNames.STONE_TILE, 'S', BPOredictNames.SILICON_CHIP));
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("integratedCircuit5x5").getStack(), "II",
            "II", 'I', PartManager.getPartInfo("integratedCircuit3x3").getStack()));
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("integratedCircuit7x7").getStack(), "II",
            "II", 'I', PartManager.getPartInfo("integratedCircuit5x5").getStack()));
    GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BPBlocks.circuit_database, 1), "#C#", "BTB", "###",
            '#', "ingotIron", 'C', PartManager.getPartInfo("integratedCircuit7x7").getStack(), 'B',
            Blocks.bookshelf, 'T', BPBlocks.circuit_table));

    // Custom crafting for nullcells
    GameRegistry.addRecipe(RecipeNullCell.instance);
}

From source file:fr.esrf.icat.manager.core.part.EntityEditDialog.java

@Override
protected Control createDialogArea(final Composite parent) {
    final Composite container = (Composite) super.createDialogArea(parent);
    GridLayout layout = new GridLayout(3, false);
    layout.marginRight = 5;/*from w  w w  .  ja  va2  s  .  c  o  m*/
    layout.marginLeft = 10;
    container.setLayout(layout);
    comboMapping = new HashMap<>();
    fieldValues = new HashMap<>();
    // we are sure we have at least one entity, use the 1st one for anything general (field types, etc.)
    final WrappedEntityBean firstEntity = entities.get(0);
    for (final String field : firstEntity.getMutableFields()) {
        Label lblAuthn = new Label(container, SWT.NONE);
        lblAuthn.setText(StringUtils.capitalize(field) + ":");
        final Button checkEdit = new Button(container, SWT.CHECK);
        checkEdit.setEnabled(false);
        checkEdit.setVisible(false);
        final Class<?> clazz = firstEntity.getReturnType(field);
        Object initialValue = null;
        boolean notSet = true;
        for (WrappedEntityBean entity : entities) {
            try {
                Object value = entity.get(field);
                if (notSet) {
                    initialValue = value;
                    notSet = false;
                } else if ((null == value && null != initialValue)
                        || (null != value && !value.equals(initialValue))) {
                    initialValue = null;
                    checkEdit.setImage(MULTI_IMAGE);
                    checkEdit.setSelection(false);
                    checkEdit.setEnabled(true);
                    checkEdit.setVisible(true);
                    break;
                }
            } catch (Exception e) {
                LOG.error("Error getting initial value for " + field, e);
            }
        }
        final boolean hasInitialValue = initialValue != null;
        if (firstEntity.isEntity(field)) {
            final Combo combo = new Combo(container, SWT.DROP_DOWN | SWT.BORDER);
            new Label(container, SWT.NONE); //empty left label
            final Label label = new Label(container, SWT.RIGHT);
            label.setLayoutData(new GridData(SWT.END, SWT.CENTER, true, false));
            label.setImage(WARNING_IMAGE);
            final Label warningLabel = new Label(container, SWT.LEFT);
            warningLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false));
            combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
            final EntityListProposalContentProvider proposalProvider = new EntityListProposalContentProvider(
                    client, firstEntity.getReturnType(field).getSimpleName(), initialValue, label, warningLabel,
                    container);
            warningLabel.setText(proposalProvider.getCurrentFilter());
            final ContentProposalAdapter contentProposalAdapter = new ContentProposalAdapter(combo,
                    new ComboContentAdapter(), proposalProvider, DEFAULT_KEYSTROKE, DEFAULT_ACTIVATION_CHARS);
            contentProposalAdapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
            contentProposalAdapter.setPropagateKeys(true);
            contentProposalAdapter.setAutoActivationDelay(1000);
            contentProposalAdapter.addContentProposalListener(new IContentProposalListener2() {
                @Override
                public void proposalPopupOpened(ContentProposalAdapter adapter) {
                }

                @Override
                public void proposalPopupClosed(ContentProposalAdapter adapter) {
                    // when the proposal popup closes we set the content of the combo to the proposals
                    final String[] currentItems = proposalProvider.getCurrentItems();
                    if (currentItems != null && currentItems.length > 0) {
                        combo.setItems(currentItems);
                    }
                    final String currentText = proposalProvider.getCurrentText();
                    final int caretPosition = proposalProvider.getCaretPosition();
                    combo.setText(currentText);
                    combo.setSelection(new Point(caretPosition, caretPosition));
                }
            });
            combo.setItems(proposalProvider.getInitialItems());
            if (hasInitialValue) {
                combo.select(0);
            }
            comboMapping.put(field,
                    new ImmutablePair<Object[], Combo>(new Object[] { proposalProvider }, combo));
            if (checkEdit.isEnabled()) {
                combo.setEnabled(false);
                checkEdit.addSelectionListener(new SelectionAdapter() {
                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        combo.setEnabled(checkEdit.getSelection());
                    }
                });
            }

        } else if (Enum.class.isAssignableFrom(clazz)) {
            final Combo combo = new Combo(container, SWT.DROP_DOWN | SWT.BORDER);
            final Object[] c = clazz.getEnumConstants();
            final String[] s = new String[c.length];
            int selected = -1;
            for (int i = 0; i < c.length; i++) {
                s[i] = c[i].toString();
                if (initialValue != null && c[i].equals(initialValue)) {
                    selected = i;
                }
            }
            // replacement for AutocompleteComboSelector to avoid selecting the 1st value in the combo when
            // no proposal is accepted (or field is emptied)
            new AutocompleteCombo(combo) {
                @Override
                protected AutocompleteContentProposalProvider getContentProposalProvider(String[] proposals) {
                    return new AutocompleteSelectorContentProposalProvider(proposals, this.combo);
                }

            };
            combo.setItems(s);
            if (selected >= 0) {
                combo.select(selected);
            }
            combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
            comboMapping.put(field, new ImmutablePair<Object[], Combo>(c, combo));
            if (checkEdit.isEnabled()) {
                combo.setEnabled(false);
                checkEdit.addSelectionListener(new SelectionAdapter() {
                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        combo.setEnabled(checkEdit.getSelection());
                    }
                });
            }

        } else if (clazz.equals(Boolean.class) || clazz.equals(boolean.class)) {
            final Button btn = new Button(container, SWT.CHECK);
            btn.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
            if (null == initialValue) {
                if (isSingle) {
                    try {
                        firstEntity.set(field, Boolean.FALSE);
                    } catch (Exception e) {
                        LOG.error("Error setting " + field + " to " + Boolean.FALSE);
                    }
                }
            } else {
                btn.setSelection((Boolean) initialValue);
            }
            btn.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                    boolean value = btn.getSelection();
                    fieldValues.put(field, value);
                }
            });
            if (checkEdit.isEnabled()) {
                btn.setEnabled(false);
                checkEdit.addSelectionListener(new SelectionAdapter() {
                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        final boolean selected = checkEdit.getSelection();
                        btn.setEnabled(selected);
                        if (selected) {
                            fieldValues.put(field, btn.getSelection());
                        } else {
                            fieldValues.remove(field);
                        }
                    }
                });
            }

        } else if (Calendar.class.isAssignableFrom(clazz) || Date.class.isAssignableFrom(clazz)
                || XMLGregorianCalendar.class.isAssignableFrom(clazz)) {

            final CDateTime cdt = new CDateTime(container,
                    CDT.BORDER | CDT.SPINNER | CDT.TAB_FIELDS | CDT.DATE_MEDIUM | CDT.TIME_MEDIUM);
            cdt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
            if (null != initialValue) {
                Date initialDate = null;
                if (initialValue instanceof Calendar) {
                    initialDate = ((Calendar) initialValue).getTime();
                } else if (initialValue instanceof XMLGregorianCalendar) {
                    initialDate = ((XMLGregorianCalendar) initialValue).toGregorianCalendar().getTime();
                } else if (initialValue instanceof Date) {
                    initialDate = (Date) initialValue;
                }
                cdt.setSelection(initialDate);
            }

            cdt.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                    fieldValues.put(field, makeCorrectDateValue(clazz, cdt.getSelection()));
                }
            });
            if (checkEdit.isEnabled()) {
                cdt.setEnabled(false);
                checkEdit.addSelectionListener(new SelectionAdapter() {
                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        final boolean selected = checkEdit.getSelection();
                        cdt.setEnabled(selected);
                        if (selected) {
                            fieldValues.put(field, makeCorrectDateValue(clazz, cdt.getSelection()));
                        } else {
                            fieldValues.remove(field);
                        }
                    }
                });
            }

        } else if (Number.class.isAssignableFrom(clazz)) {
            final Text text = new Text(container, SWT.BORDER);
            text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
            if (null != initialValue) {
                text.setText(initialValue.toString());
            }
            final Color original = text.getForeground();
            text.addModifyListener(new ModifyListener() {
                @Override
                public void modifyText(ModifyEvent e) {
                    text.setForeground(original);
                    String value = text.getText();
                    if (null == value) {
                        value = ICATEntity.EMPTY_STRING;
                    }
                    final Object numVal = makeCorrectNumericValue(clazz, value);
                    if (null == numVal) {
                        text.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
                    } else {
                        fieldValues.put(field, numVal);
                    }
                }
            });
            if (checkEdit.isEnabled()) {
                text.setEnabled(false);
                checkEdit.addSelectionListener(new SelectionAdapter() {
                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        final boolean selected = checkEdit.getSelection();
                        text.setEnabled(selected);
                        if (selected) {
                            fieldValues.put(field, makeCorrectNumericValue(clazz, text.getText()));
                        } else {
                            fieldValues.remove(field);
                        }
                    }
                });
            }

        } else { // Assumes String
            final Text text = new Text(container, SWT.BORDER);
            text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
            if (null == initialValue) {
                if (isSingle) {
                    try {
                        firstEntity.set(field, ICATEntity.EMPTY_STRING);
                    } catch (Exception e) {
                        LOG.error("Error setting " + field + " to EMPTY_STRING");
                    }
                }
            } else {
                text.setText(initialValue.toString());
            }
            text.addModifyListener(new ModifyListener() {
                @Override
                public void modifyText(ModifyEvent e) {
                    String value = text.getText();
                    if (null == value) {
                        value = ICATEntity.EMPTY_STRING;
                    }
                    fieldValues.put(field, value);
                }
            });
            if (checkEdit.isEnabled()) {
                text.setEnabled(false);
                checkEdit.addSelectionListener(new SelectionAdapter() {
                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        final boolean selected = checkEdit.getSelection();
                        text.setEnabled(selected);
                        if (selected) {
                            fieldValues.put(field, text.getText());
                        } else {
                            fieldValues.remove(field);
                        }
                    }
                });
            }
        }
    }
    return container;
}

From source file:net.eledge.android.europeana.search.SearchController.java

public List<FacetItem> getBreadcrumbs(Context context) {
    List<FacetItem> breadcrumbs = new ArrayList<>();
    FacetItem crumb;// w  w  w  . j  a  v a  2 s.c  o m
    for (String term : terms) {
        crumb = new FacetItem();
        crumb.itemType = FacetItemType.BREADCRUMB;
        crumb.facetType = FacetType.TEXT;
        crumb.description = term;
        crumb.facet = term;
        if (StringUtils.contains(term, ":")) {
            FacetType type = FacetType.safeValueOf(StringUtils.substringBefore(term, ":"));
            if (type != null) {
                crumb.facetType = type;
                crumb.description = StringUtils
                        .capitalize(StringUtils.lowerCase(GuiUtils.getString(context, type.resId))) + ":"
                        + type.createFacetLabel(context, StringUtils.substringAfter(term, ":"));
            }
        }
        breadcrumbs.add(crumb);
    }
    return breadcrumbs;
}

From source file:edu.usu.sdl.openstorefront.usecase.ValidationUseCase.java

private <T> Map<String, Object> mapParameters(T example, String parentFieldName) {
    Map<String, Object> parameterMap = new HashMap<>();
    try {/*from   w ww .j a v  a 2 s .  c o m*/
        Map fieldMap = BeanUtils.describe(example);
        for (Object field : fieldMap.keySet()) {

            if ("class".equalsIgnoreCase(field.toString()) == false) {
                Object value = fieldMap.get(field);
                if (value != null) {

                    Method method = example.getClass()
                            .getMethod("get" + StringUtils.capitalize(field.toString()), (Class<?>[]) null);
                    Object returnObj = method.invoke(example, (Object[]) null);
                    if (ReflectionUtil.isComplexClass(returnObj.getClass())) {
                        if (StringUtils.isNotBlank(parentFieldName)) {
                            parentFieldName = parentFieldName + "_";
                        }
                        parentFieldName = parentFieldName + field;
                        parameterMap.putAll(mapParameters(returnObj, parentFieldName));
                    } else {
                        String fieldName = field.toString();
                        if (StringUtils.isNotBlank(parentFieldName)) {
                            fieldName = parentFieldName + "_" + fieldName;
                        }
                        parameterMap.put(fieldName + "Param", value);
                    }
                }
            }
        }
    } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException ex) {
        throw new RuntimeException(ex);
    }
    return parameterMap;
}

From source file:at.beris.jarcommander.helper.ModelViewController.java

public Method getPropertyGetter(Object object, String propertyName) {
    try {// ww w  .j  a v  a2s.c  o  m
        return object.getClass().getDeclaredMethod("get" + StringUtils.capitalize(propertyName));
    } catch (NoSuchMethodException e) {
        logException(e);
    }
    return null;
}

From source file:info.magnolia.configuration.app.overview.ConfigOverviewSubApp.java

private String getCapitalizedPluralName(DefinitionType definitionType) {
    return StringUtils.capitalize(English.plural(definitionType.name()).toLowerCase());
}