Example usage for org.apache.commons.lang StringUtils remove

List of usage examples for org.apache.commons.lang StringUtils remove

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils remove.

Prototype

public static String remove(String str, char remove) 

Source Link

Document

Removes all occurrences of a character from within the source string.

Usage

From source file:org.eclipse.wb.internal.core.databinding.model.CodeGenerationSupport.java

private static String convertName(String name) {
    if (name.startsWith("m_")) {
        name = name.substring(2);//from  w  w  w .  j  av  a 2 s  . c om
    }
    name = StringUtils.remove(name, '.');
    name = StringUtils.remove(name, '"');
    name = StringUtils.remove(name, '(');
    name = StringUtils.remove(name, ')');
    return StringUtils.capitalize(name);
}

From source file:org.eclipse.wb.internal.rcp.databinding.model.beans.observables.properties.BeanPropertiesCodeSupport.java

public final void setBeanType(Class<?> beanType) throws Exception {
    m_parserBeanType = beanType;/*from   w w w. j  a  v a2 s  . co  m*/
    if (m_parserBeanType != null && m_parserPropertyReference != null && m_parserPropertyType == null) {
        String propertyName = StringUtils.remove(m_parserPropertyReference, "\"");
        for (PropertyDescriptor descriptor : BeanSupport.getPropertyDescriptors(m_parserBeanType)) {
            if (propertyName.equals(descriptor.getName())) {
                m_parserPropertyType = descriptor.getPropertyType();
                break;
            }
        }
    }
}

From source file:org.eclipse.wb.internal.rcp.databinding.model.widgets.input.VirtualEditingSupportInfo.java

public String getCellEditorPresentationText() throws Exception {
    return isEmpty() ? ""
            : ClassUtils.getShortClassName(StringUtils.substringBefore(m_cellEditorClassName, "(")) + "."
                    + StringUtils.remove(m_cellEditorProperty, '"');
}

From source file:org.eclipse.wb.internal.rcp.databinding.model.widgets.input.VirtualEditingSupportInfo.java

public String getElementPropertyPresentationText() throws Exception {
    return isEmpty() ? ""
            : ClassUtils.getShortClassName(m_elementTypeProvider.getElementType()) + "."
                    + StringUtils.remove(m_elementProperty, '"');
}

From source file:org.eclipse.wb.internal.rcp.databinding.ui.contentproviders.InputElementUiContentProvider.java

@Override
protected void saveToObject(Class<?> choosenClass, List<PropertyAdapter> choosenProperties) throws Exception {
    // sets label provider element type
    MapsBeanObservableInfo mapsObservable = m_viewerBinding.getLabelProvider().getMapsObservable();
    mapsObservable.setElementType(choosenClass);
    // sets label provider element properties
    String[] properties = new String[choosenProperties.size()];
    for (int i = 0; i < properties.length; i++) {
        ObservePropertyAdapter adapter = (ObservePropertyAdapter) choosenProperties.get(i);
        properties[i] = StringUtils.remove(adapter.getProperty().getReference(), '"');
    }/*from w w  w  .ja  v a 2  s . c o  m*/
    mapsObservable.setProperties(properties);
    // set input element type
    setElementTypeToInput(m_viewerBinding, choosenClass);
}

From source file:org.eclipse.wb.internal.rcp.databinding.xwt.model.AttributeDocumentEditor.java

private String getValue() throws Exception {
    StringBuffer value = new StringBuffer("{Binding ");
    ////  w ww. j a v a 2  s  . c o  m
    if (m_binding.getModel() instanceof WidgetBindableInfo) {
        WidgetBindableInfo model = (WidgetBindableInfo) m_binding.getModel();
        String modelProperty = m_binding.getModelProperty().getPresentation().getText();
        value.append(" elementName=" + model.getReference() + ", Path=" + modelProperty);
    } else {
        BindableInfo modelProperty = (BindableInfo) m_binding.getModelProperty();
        String property = StringUtils.remove(modelProperty.getReference(), '"');
        //
        XmlElementBeanBindableInfo model = (XmlElementBeanBindableInfo) m_binding.getModel();
        if (!model.isDataContext()) {
            property = "{StaticResource " + property + "}";
        }
        //
        value.append(" Path=" + property);
    }
    //
    if (m_binding.getMode() != 0) {
        value.append(", Mode=" + BindingInfo.MODES[m_binding.getMode()]);
    }
    if (m_binding.getTriger() != 0) {
        value.append(", updateSourceTrigger=" + BindingInfo.TRIGGERS[m_binding.getTriger()]);
    }
    //
    m_binding.getConverter().appendValue(value);
    m_binding.getValidator().appendValue(value);
    //
    value.append("}");
    //
    return value.toString();
}

From source file:org.eclipse.wb.internal.rcp.databinding.xwt.model.ElementDocumentEditor.java

public ElementDocumentEditor(BindingInfo binding, DocumentElement element) {
    m_binding = binding;//  w  w w.  ja  va2  s.  c o m
    m_element = element;
    //
    m_editors.add(new AttributeEditor("ElementName") {
        @Override
        protected String getValue() throws Exception {
            if (m_binding.getModel() instanceof WidgetBindableInfo) {
                WidgetBindableInfo model = (WidgetBindableInfo) m_binding.getModel();
                return model.getReference();
            }
            return null;
        }
    });
    m_editors.add(new AttributeEditor("Path") {
        @Override
        protected String getValue() throws Exception {
            if (m_binding.getModel() instanceof WidgetBindableInfo) {
                return m_binding.getModelProperty().getPresentation().getText();
            }
            //
            BindableInfo modelProperty = (BindableInfo) m_binding.getModelProperty();
            String property = StringUtils.remove(modelProperty.getReference(), '"');
            //
            XmlElementBeanBindableInfo model = (XmlElementBeanBindableInfo) m_binding.getModel();
            if (!model.isDataContext()) {
                property = "{StaticResource " + property + "}";
            }
            //
            return property;
        }
    });
    m_editors.add(new AttributeEditor("Mode") {
        @Override
        protected String getValue() throws Exception {
            return m_binding.getMode() == 0 ? null : BindingInfo.MODES[m_binding.getMode()];
        }
    });
    m_editors.add(new AttributeEditor("UpdateSourceTrigger") {
        @Override
        protected String getValue() throws Exception {
            return m_binding.getTriger() == 0 ? null : BindingInfo.TRIGGERS[m_binding.getTriger()];
        }
    });
}

From source file:org.eclipse.wb.internal.rcp.model.rcp.perspective.PageLayoutInfo.java

/**
 * {@link PageLayoutInfo} uses toolkit of RCP, but it does not need SWT, JFace components on
 * palette. It needs only views and perspectives.
 */// w w  w . j a v  a  2s . com
private void addPaletteListener() {
    addBroadcastListener(new PaletteEventListener() {
        @Override
        public void canEdit(boolean[] canEdit) {
            canEdit[0] = false;
        }

        @Override
        public void categories(List<CategoryInfo> categories) throws Exception {
            categories.clear();
            // create "System" category
            {
                CategoryInfo category = new CategoryInfo("system");
                category.setName("System");
                category.setDescription("System tools");
                category.setOpen(true);
                categories.add(category);
                // add entries
                {
                    SelectionToolEntryInfo entry = new SelectionToolEntryInfo();
                    entry.setId("system.selection");
                    category.addEntry(entry);
                }
            }
            // prepare sorted list of view categories
            List<ViewCategoryInfo> viewCategories;
            {
                viewCategories = PdeUtils.getViewCategories();
                Collections.sort(viewCategories, new Comparator<ViewCategoryInfo>() {
                    public int compare(ViewCategoryInfo o1, ViewCategoryInfo o2) {
                        return getName(o1).compareTo(getName(o2));
                    }

                    private String getName(ViewCategoryInfo o1) {
                        String name = o1.getName();
                        name = StringUtils.remove(name, '&');
                        return name;
                    }
                });
            }
            // create "Views" categories
            for (ViewCategoryInfo categoryInfo : viewCategories) {
                CategoryInfo category = new CategoryInfo();
                category.setId(getIdForPaletteCategory(categoryInfo));
                category.setName(categoryInfo.getName());
                category.setDescription(categoryInfo.getId());
                category.setOpen(true);
                categories.add(category);
                // add views
                for (ViewInfo viewInfo : categoryInfo.getViews()) {
                    category.addEntry(new PerspectiveViewDropEntryInfo(viewInfo));
                }
            }
            // create "Perspectives" category
            {
                CategoryInfo category = new CategoryInfo("perspectives");
                category.setName("Perspectives");
                category.setOpen(true);
                categories.add(category);
                // add entries
                for (PerspectiveInfo perspective : PdeUtils.getPerspectives()) {
                    category.addEntry(new PerspectivePerspectiveDropEntryInfo(perspective));
                }
            }
        }

        private String getIdForPaletteCategory(ViewCategoryInfo categoryInfo) {
            String id = categoryInfo.getId();
            if (id == null) {
                id = "other";
            }
            return id;
        }
    });
}

From source file:org.eclipse.wb.tests.designer.core.eval.ExecutionFlowUtilsTest.java

private void check_getFinalExpression(String expectedSource, String[] lines) throws Exception {
    TypeDeclaration typeDeclaration;/*www.j a  v a2 s  .  c o  m*/
    Expression expression;
    {
        String source = getSource(lines);
        int expressionPosition = source.indexOf('!');
        source = StringUtils.remove(source, '!');
        typeDeclaration = createTypeDeclaration("test", "Test.java", source);
        expression = (Expression) AstNodeUtils.getEnclosingNode(typeDeclaration, expressionPosition);
    }
    //
    ExecutionFlowDescription flowDescription = new ExecutionFlowDescription(typeDeclaration.getMethods()[0]);
    Expression firstAssignment = getFinalExpression(flowDescription, expression);
    assertEquals(expectedSource, m_lastEditor.getSource(firstAssignment));
}

From source file:org.eclipse.wb.tests.designer.tests.DesignerTestCase.java

/**
 * @return the "normalized" text of {@link Action}, without accelerator specification ( text after
 *         "\t") and hot key (<code>"&"</code> character).
 * @param text/*  w w w  .j  a  v  a2  s  .c o  m*/
 * @return
 */
private static String getNormalizedActionText(String text) {
    {
        int index = text.indexOf('\t');
        if (index != -1) {
            text = text.substring(0, index);
        }
    }
    text = StringUtils.remove(text, "&");
    return text;
}