/******************************************************************************* * Copyright (c) 2006-2013 The RCP Company and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * The RCP Company - initial API and implementation *******************************************************************************/ package com.rcpcompany.uibindings.internal.quickfixes; import com.rcpcompany.uibindings.IQuickfixProposalProcessor; import com.rcpcompany.uibindings.IQuickfixProposalProcessorContext; import com.rcpcompany.uibindings.quixkfixes.AbstractQuickfixProposalProcessor; /** * Quick fix proposal processor for number based problems... * * @author Tonny Madsen, The RCP Company */ public class IllegalNumberQuickfixProposalProcessor extends AbstractQuickfixProposalProcessor implements IQuickfixProposalProcessor { @Override public void getProposals(IQuickfixProposalProcessorContext context) { final String text = context.getText(); if (text == null) return; addReplacementProposal(context, "Remove illegal characters", findReplacementText(text)); } private String findReplacementText(String text) { final StringBuilder sb = new StringBuilder(40); for (int i = 0; i < text.length(); i++) { final char ch = text.charAt(i); if (Character.isDigit(ch)) { sb.append(ch); } } return sb.toString(); } }