package no.uio.ifi.refaktor.handlers; import no.uio.ifi.refaktor.extractors.Prefix; import no.uio.ifi.refaktor.extractors.UnionOfLongestCommonPrefixesExtractor; import no.uio.ifi.refaktor.utils.DocumentUtils; import no.uio.ifi.refaktor.utils.SmartTextSelection; import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.ui.handlers.HandlerUtil; public class TestPropertyExtractorHandler extends AbstractHandler { @Override public Object execute(ExecutionEvent event) throws ExecutionException { SmartTextSelection smartTextSelection = DocumentUtils.getAndSetStrippedSmartTextSelectionFrom(event); UnionOfLongestCommonPrefixesExtractor extractor = new UnionOfLongestCommonPrefixesExtractor(smartTextSelection); // LongestCommonPrefixExtractor extractor = new LongestCommonPrefixExtractor(smartTextSelection); String dialogText = ""; if (extractor.selectionIsValid()) { extractor.extractProperty(); for (Prefix p: extractor.getPrefixSet()) { dialogText += p.toString() + " (" + p.getCount() + ")\n"; } // dialogText += extractor.stringProperty(); } else { dialogText = "Selection is invalid"; } MessageDialog.openInformation(HandlerUtil.getActiveWorkbenchWindowChecked(event).getShell(), "Test Property Extractor", dialogText); return null; } }