Java 类org.eclipse.core.commands.ParameterValueConversionException 实例源码

项目:birt    文件:CommandUtils.java   
public static Parameterization createParameter( Command command,
        String parameterId, Object value ) throws NotDefinedException,
        ExecutionException, ParameterValueConversionException
{
    ParameterType parameterType = command.getParameterType( parameterId );
    if ( parameterType == null )
    {
        throw new ExecutionException( "Command does not have a parameter type for the given parameter" ); //$NON-NLS-1$
    }

    IParameter param = command.getParameter( parameterId );
    AbstractParameterValueConverter valueConverter = parameterType.getValueConverter( );
    if ( valueConverter == null )
    {
        throw new ExecutionException( "Command does not have a value converter" ); //$NON-NLS-1$
    }

    String valueString = valueConverter.convertToString( value );
    Parameterization parm = new Parameterization( param, valueString );
    return parm;
}
项目:neoscada    文件:ParameterConverter.java   
@Override
public String convertToString ( final Object parameterValue ) throws ParameterValueConversionException
{
    if ( parameterValue instanceof Map )
    {
        final Gson gson = this.builder.create ();
        return gson.toJson ( parameterValue );
    }
    throw new ParameterValueConversionException ( "Unable to convert type " + parameterValue.getClass () );
}
项目:birt    文件:SlotHandleConverter.java   
public Object convertToObject( String parameterValue )
        throws ParameterValueConversionException
{
    String elementId = parameterValue.substring( 0,
            parameterValue.indexOf( "#" ) ); //$NON-NLS-1$
    String slotId = parameterValue.substring( parameterValue.indexOf( "#" ) + 1, //$NON-NLS-1$
            parameterValue.length( ) );
    return SessionHandleAdapter.getInstance( )
            .getReportDesignHandle( )
            .getElementByID( Long.parseLong( elementId ) )
            .getSlot( Integer.parseInt( slotId ) );
}
项目:birt    文件:SlotHandleConverter.java   
public String convertToString( Object parameterValue )
        throws ParameterValueConversionException
{

    return ( (SlotHandle) parameterValue ).getElement( ).getID( )
            + "#" //$NON-NLS-1$
            + ( (SlotHandle) parameterValue ).getSlotID( );
}
项目:birt    文件:CommandUtils.java   
public static Object executeCommand( String commandId, Map paramMap )
        throws NotDefinedException, ExecutionException,
        ParameterValueConversionException, NotEnabledException,
        NotHandledException
{
    Command cmd = CommandUtils.getCommand( commandId );
    List paramList = new ArrayList( );
    if ( paramMap != null )
    {
        for ( Iterator iter = paramMap.entrySet( ).iterator( ); iter.hasNext( ); )
        {
            Map.Entry entry = (Entry) iter.next( );
            String paramId = entry.getKey( ).toString( );
            Object value = entry.getValue( );
            if ( value != null )
            {
                paramList.add( createParameter( cmd, paramId, value ) );
            }
        }
    }
    if ( paramList.size( ) > 0 )
    {
        ParameterizedCommand paramCommand = new ParameterizedCommand( cmd,
                (Parameterization[]) paramList.toArray( new Parameterization[paramList.size( )] ) );

        return getHandlerService( ).executeCommand( paramCommand, null );
    }
    else
    {
        return getHandlerService( ).executeCommand( commandId, null );
    }
}
项目:birt    文件:IntegerConverter.java   
public String convertToString( Object parameterValue )
        throws ParameterValueConversionException
{
    String retString = ""; //$NON-NLS-1$
    Integer integer = (Integer)parameterValue;
    retString = integer.toString();
    return retString;
}
项目:e4macs    文件:IntegerConverter.java   
/**
 * @see org.eclipse.core.commands.AbstractParameterValueConverter#convertToObject(java.lang.String)
 */
@Override
public Object convertToObject(String parameterValue) throws ParameterValueConversionException {
    Integer result = null;
    try {
        result = new Integer(parameterValue);
    } catch (NumberFormatException e) {
        result = new Integer(1);
    }
    return result;
}
项目:e4macs    文件:IntegerConverter.java   
/**
 * @see org.eclipse.core.commands.AbstractParameterValueConverter#convertToString(java.lang.Object)
 */
@Override
public String convertToString(Object parameterValue) throws ParameterValueConversionException {
    String result = "1";    //$NON-NLS-1$ // default to 1 execution
    if (parameterValue instanceof Integer) {
        result = ((Integer)parameterValue).toString();
    } else if (parameterValue instanceof String) {
        result = (String)parameterValue;
    }
    return result;
}
项目:e4macs    文件:StringConverter.java   
/**
 * @see org.eclipse.core.commands.AbstractParameterValueConverter#convertToString(java.lang.Object)
 */
@Override
public String convertToString(Object parameterValue) throws ParameterValueConversionException {
    String result = EmacsPlusUtils.EMPTY_STR;
    if (parameterValue != null) {
        result = parameterValue.toString();
    }
    return result;
}
项目:elexis-3-core    文件:TreeToStringConverter.java   
@Override
public String convertToString(Object parameterValue) throws ParameterValueConversionException{
    if (parameterValue instanceof Tree) {
        String ret = StringTool.unique(getClass().getName());
        map.put(ret, (Tree<?>) parameterValue);
        return ret;
    }
    throw new ParameterValueConversionException("Parameter was not instance of Tree");
}
项目:neoscada    文件:ParameterConverter.java   
@Override
public Object convertToObject ( final String parameterValue ) throws ParameterValueConversionException
{
    final Gson gson = this.builder.create ();
    return gson.fromJson ( parameterValue, new TypeToken<Map<String, String>> () {}.getType () );
}
项目:Eclipse-Postfix-Code-Completion    文件:JavaElementReferenceConverter.java   
@Override
public String convertToString(Object parameterValue) throws ParameterValueConversionException {

    if (!(parameterValue instanceof IJavaElement)) {
        throw new ParameterValueConversionException("parameterValue must be an IJavaElement"); //$NON-NLS-1$
    }

    IJavaElement javaElement= (IJavaElement) parameterValue;

    IJavaProject javaProject= javaElement.getJavaProject();
    if (javaProject == null) {
        throw new ParameterValueConversionException("Could not get IJavaProject for element"); //$NON-NLS-1$
    }

    StringBuffer buffer;

    if (javaElement instanceof IType) {
        IType type= (IType) javaElement;
        buffer= composeTypeReference(type);
    } else
        if (javaElement instanceof IMethod) {
            IMethod method= (IMethod) javaElement;
            buffer= composeTypeReference(method.getDeclaringType());
            buffer.append(TYPE_END_CHAR);
            buffer.append(method.getElementName());
            String[] parameterTypes= method.getParameterTypes();
            buffer.append(PARAM_START_CHAR);
            for (int i= 0; i < parameterTypes.length; i++) {
                buffer.append(parameterTypes[i]);
            }
            buffer.append(PARAM_END_CHAR);
        } else
            if (javaElement instanceof IField) {
                IField field= (IField) javaElement;
                buffer= composeTypeReference(field.getDeclaringType());
                buffer.append(TYPE_END_CHAR);
                buffer.append(field.getElementName());
            } else {
                throw new ParameterValueConversionException("Unsupported IJavaElement type"); //$NON-NLS-1$
            }

    return buffer.toString();
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavaElementReferenceConverter.java   
@Override
public String convertToString(Object parameterValue) throws ParameterValueConversionException {

    if (!(parameterValue instanceof IJavaElement)) {
        throw new ParameterValueConversionException("parameterValue must be an IJavaElement"); //$NON-NLS-1$
    }

    IJavaElement javaElement= (IJavaElement) parameterValue;

    IJavaProject javaProject= javaElement.getJavaProject();
    if (javaProject == null) {
        throw new ParameterValueConversionException("Could not get IJavaProject for element"); //$NON-NLS-1$
    }

    StringBuffer buffer;

    if (javaElement instanceof IType) {
        IType type= (IType) javaElement;
        buffer= composeTypeReference(type);
    } else
        if (javaElement instanceof IMethod) {
            IMethod method= (IMethod) javaElement;
            buffer= composeTypeReference(method.getDeclaringType());
            buffer.append(TYPE_END_CHAR);
            buffer.append(method.getElementName());
            String[] parameterTypes= method.getParameterTypes();
            buffer.append(PARAM_START_CHAR);
            for (int i= 0; i < parameterTypes.length; i++) {
                buffer.append(parameterTypes[i]);
            }
            buffer.append(PARAM_END_CHAR);
        } else
            if (javaElement instanceof IField) {
                IField field= (IField) javaElement;
                buffer= composeTypeReference(field.getDeclaringType());
                buffer.append(TYPE_END_CHAR);
                buffer.append(field.getElementName());
            } else {
                throw new ParameterValueConversionException("Unsupported IJavaElement type"); //$NON-NLS-1$
            }

    return buffer.toString();
}
项目:birt    文件:IntegerConverter.java   
public Object convertToObject( String parameterValue )
        throws ParameterValueConversionException
{
    return new Integer(parameterValue);
}
项目:birt    文件:StringConverter.java   
public Object convertToObject( String parameterValue )
        throws ParameterValueConversionException
{
    return parameterValue;
}
项目:birt    文件:StringConverter.java   
public String convertToString( Object parameterValue )
        throws ParameterValueConversionException
{
    return parameterValue != null ? parameterValue.toString( ) : ""; //$NON-NLS-1$
}
项目:birt    文件:BooleanConverter.java   
public Object convertToObject( String parameterValue )
        throws ParameterValueConversionException
{
    return Boolean.valueOf( parameterValue );
}
项目:birt    文件:BooleanConverter.java   
public String convertToString( Object parameterValue )
        throws ParameterValueConversionException
{
    boolean value = ((Boolean)parameterValue).booleanValue( );
    return Boolean.toString( value );
}
项目:e4macs    文件:StringConverter.java   
/**
 * @see org.eclipse.core.commands.AbstractParameterValueConverter#convertToObject(java.lang.String)
 */
@Override
public Object convertToObject(String parameterValue) throws ParameterValueConversionException {
    return parameterValue;
}
项目:e4macs    文件:BooleanConverter.java   
/**
 * @see org.eclipse.core.commands.AbstractParameterValueConverter#convertToObject(java.lang.String)
 */
@Override
public Object convertToObject(String parameterValue) throws ParameterValueConversionException {
    return Boolean.valueOf(parameterValue);
}
项目:e4macs    文件:BooleanConverter.java   
/**
 * @see org.eclipse.core.commands.AbstractParameterValueConverter#convertToString(java.lang.Object)
 */
@Override
public String convertToString(Object parameterValue) throws ParameterValueConversionException {
    return parameterValue.toString(); 
}
项目:elexis-3-core    文件:ErstelleRnnCommand.java   
@SuppressWarnings("unchecked")
public Object execute(ExecutionEvent eev) throws ExecutionException{
    Tree<?> tSelection = null;
    String px = eev.getParameter("ch.elexis.RechnungErstellen.parameter"); //$NON-NLS-1$
    try {
        tSelection = (Tree<?>) new TreeToStringConverter().convertToObject(px);
    } catch (ParameterValueConversionException pe) {
        throw new ExecutionException("Bad parameter " + pe.getMessage()); //$NON-NLS-1$
    }
    IProgressMonitor monitor = Handler.getMonitor(eev);
    Result<Rechnung> res = null;
    for (Tree tPat = tSelection.getFirstChild(); tPat != null; tPat = tPat.getNextSibling()) {
        int rejected = 0;
        for (Tree tFall = tPat.getFirstChild(); tFall != null; tFall = tFall.getNextSibling()) {
            Fall fall = (Fall) tFall.contents;
            if (CoreHub.userCfg.get(Preferences.LEISTUNGSCODES_BILLING_STRICT, true)) {
                if (!fall.isValid()) {
                    rejected++;
                    continue;
                }
            }
            Collection<Tree> lt = tFall.getChildren();

            List<Konsultation> lb = new ArrayList<Konsultation>(lt.size() + 1);
            for (Tree t : lt) {
                lb.add((Konsultation) t.contents);
            }

            List<Konsultation> toBill = BillingUtil.getKonsultationsFromSameYear(lb);
            if (toBill.size() > 0 && toBill.size() != lb.size()) {
                if (!MessageDialog.openQuestion(HandlerUtil.getActiveShell(eev),
                    "Rechnung Validierung",
                    "Eine Rechnung kann nur Leistungen innerhalb eines Jahres beinhalten.\n\nWollen Sie mit der Erstellung der Rechnung für das Jahr "
                        + new TimeTool(toBill.get(0).getDatum()).get(TimeTool.YEAR)
                        + " fortsetzen ?")) {
                    LoggerFactory.getLogger(ErstelleRnnCommand.class)
                        .warn("Invoice creation canceled by user");
                    return null;
                }
            }

            res = Rechnung.build(toBill);
            if (monitor != null) {
                monitor.worked(1);
            }
            if (!res.isOK()) {
                ErrorDialog.openError(HandlerUtil.getActiveShell(eev),
                    Messages.KonsZumVerrechnenView_errorInInvoice,

                    NLS.bind(Messages.KonsZumVerrechnenView_invoiceForCase, new Object[] {
                        fall.getLabel(), fall.getPatient().getLabel()
                    }), ResultAdapter.getResultAsStatus(res));
            } else {
                tPat.remove(tFall);
            }
        }
        if (rejected != 0) {
            SWTHelper.showError(Messages.ErstelleRnnCommand_BadCaseDefinition,
                Integer.toString(rejected)
                    + Messages.ErstelleRnnCommand_BillsNotCreatedMissingData
                    + Messages.ErstelleRnnCommand_ErstelleRnnCheckCaseDetails);
        } else {
            tSelection.remove(tPat);
        }
    }
    return res;
}
项目:elexis-3-core    文件:PersistentObjectConverter.java   
@Override
public Object convertToObject(String parameterValue) throws ParameterValueConversionException{
    return CoreHub.poFactory.createFromString(parameterValue);
}
项目:elexis-3-core    文件:PersistentObjectConverter.java   
@Override
public String convertToString(Object parameterValue) throws ParameterValueConversionException{
    return ((PersistentObject) parameterValue).storeToString();
}
项目:elexis-3-core    文件:TreeToStringConverter.java   
@Override
public Object convertToObject(String parameterValue) throws ParameterValueConversionException{
    Tree<?> ret = map.get(parameterValue);
    return ret;
}
项目:redmine.rap    文件:EditorInputConverter.java   
/**
 * Converts a command parameter value object into a string that encodes a
 * reference to the object or serialization of the object.
 * 
 * @param parameterValue
 *            an object to convert into an identifying string; may be
 *            <code>null</code>
 * @return a string describing the provided object; may be <code>null</code>
 * @throws ParameterValueConversionException
 *             if a string reference or serialization cannot be provided for
 *             the <code>parameterValue</code>
 */
@Override
public String convertToString(Object parameterValue)
                       throws ParameterValueConversionException {
    // Retrieve parameter as IEditorInput object
    IEditorInput editorInput = (IEditorInput) parameterValue;
    String id = Integer.toString(editorInput.hashCode());

    map.put(id, editorInput);

    return id;
}
项目:Eclipse-Postfix-Code-Completion    文件:JavaElementReferenceConverter.java   
/**
 * Throws a <code>ParameterValueConversionException</code> if the java
 * element reference string does not meet some well-formedness condition.
 *
 * @param assertion
 *            a boolean check for well-formedness
 * @throws ParameterValueConversionException
 */
private void assertWellFormed(boolean assertion) throws ParameterValueConversionException {
    if (!assertion) {
        throw new ParameterValueConversionException("Malformed parameterValue"); //$NON-NLS-1$
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:JavaElementReferenceConverter.java   
/**
 * Throws a <code>ParameterValueConversionException</code> if the java
 * element reference string identifies an element that does not exist.
 *
 * @param javaElement
 *            an element to check for existence
 * @throws ParameterValueConversionException
 */
private void assertExists(IJavaElement javaElement) throws ParameterValueConversionException {
    if ((javaElement == null) || (!javaElement.exists())) {
        throw new ParameterValueConversionException("parameterValue must reference an existing IJavaElement"); //$NON-NLS-1$
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavaElementReferenceConverter.java   
/**
 * Throws a <code>ParameterValueConversionException</code> if the java
 * element reference string does not meet some well-formedness condition.
 *
 * @param assertion
 *            a boolean check for well-formedness
 * @throws ParameterValueConversionException
 */
private void assertWellFormed(boolean assertion) throws ParameterValueConversionException {
    if (!assertion) {
        throw new ParameterValueConversionException("Malformed parameterValue"); //$NON-NLS-1$
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavaElementReferenceConverter.java   
/**
 * Throws a <code>ParameterValueConversionException</code> if the java
 * element reference string identifies an element that does not exist.
 *
 * @param javaElement
 *            an element to check for existence
 * @throws ParameterValueConversionException
 */
private void assertExists(IJavaElement javaElement) throws ParameterValueConversionException {
    if ((javaElement == null) || (!javaElement.exists())) {
        throw new ParameterValueConversionException("parameterValue must reference an existing IJavaElement"); //$NON-NLS-1$
    }
}
项目:redmine.rap    文件:EditorInputConverter.java   
/**
 * Converts a string encoded command parameter value into the parameter
 * value object.
 * 
 * @param parameterValue
 *            a command parameter value string describing an object; may be
 *            <code>null</code>
 * @return the object described by the command parameter value string; may
 *         be <code>null</code>
 * @throws ParameterValueConversionException
 *             if an object cannot be produced from the
 *             <code>parameterValue</code> string
 */
@Override
public Object convertToObject(String parameterValue)
                       throws ParameterValueConversionException {
    return (IEditorInput) map.get(parameterValue);
}