use of org.eclipse.wst.sse.ui.internal.search.FindOccurrencesProcessor in project webtools.sourceediting by eclipse.
the class HTMLFindOccurrencesHandler method execute.
public Object execute(ExecutionEvent event) throws ExecutionException {
IEditorPart editor = HandlerUtil.getActiveEditor(event);
ITextEditor textEditor = null;
boolean okay = false;
if (editor instanceof ITextEditor)
textEditor = (ITextEditor) editor;
else {
Object o = editor.getAdapter(ITextEditor.class);
if (o != null)
textEditor = (ITextEditor) o;
}
if (textEditor != null) {
IDocument document = textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput());
if (document != null) {
ITextSelection textSelection = getTextSelection(textEditor);
FindOccurrencesProcessor findOccurrenceProcessor = getProcessorForCurrentSelection(document, textSelection);
if (findOccurrenceProcessor != null) {
if (textEditor.getEditorInput() instanceof IFileEditorInput) {
IFile file = ((IFileEditorInput) textEditor.getEditorInput()).getFile();
okay = findOccurrenceProcessor.findOccurrences(document, textSelection, file);
}
}
}
}
if (okay) {
// clear status message
PlatformStatusLineUtil.clearStatusLine();
} else {
// $NON-NLS-1$
String errorMessage = SSEUIMessages.FindOccurrencesActionProvider_0;
if (textEditor instanceof StructuredTextEditor) {
PlatformStatusLineUtil.displayTemporaryErrorMessage(((StructuredTextEditor) textEditor).getTextViewer(), errorMessage);
} else {
PlatformStatusLineUtil.displayErrorMessage(errorMessage);
PlatformStatusLineUtil.addOneTimeClearListener();
}
}
return null;
}
use of org.eclipse.wst.sse.ui.internal.search.FindOccurrencesProcessor in project webtools.sourceediting by eclipse.
the class HTMLFindOccurrencesHandler method getProcessorForCurrentSelection.
/**
* Get the appropriate find occurrences processor
*
* @param document -
* assumes not null
* @param textSelection
* @return
*/
private FindOccurrencesProcessor getProcessorForCurrentSelection(IDocument document, ITextSelection textSelection) {
// check if we have an action that's enabled on the current partition
ITypedRegion tr = getPartition(document, textSelection);
// $NON-NLS-1$
String partition = tr != null ? tr.getType() : "";
Iterator it = getProcessors().iterator();
FindOccurrencesProcessor processor = null;
while (it.hasNext()) {
processor = (FindOccurrencesProcessor) it.next();
// we just choose the first action that can handle the partition
if (processor.enabledForParitition(partition))
return processor;
}
List extendedFindOccurrencesProcessors = ExtendedConfigurationBuilder.getInstance().getConfigurations(FindOccurrencesProcessor.class.getName(), partition);
for (int i = 0; i < extendedFindOccurrencesProcessors.size(); i++) {
Object o = extendedFindOccurrencesProcessors.get(i);
if (o instanceof FindOccurrencesProcessor) {
/*
* We just choose the first registered processor that
* explicitly says it can handle the partition
*/
processor = (FindOccurrencesProcessor) o;
if (processor.enabledForParitition(partition))
return processor;
}
}
return null;
}
use of org.eclipse.wst.sse.ui.internal.search.FindOccurrencesProcessor in project webtools.sourceediting by eclipse.
the class FindOccurrencesHandler method execute.
public Object execute(ExecutionEvent event) throws ExecutionException {
IEditorPart editorPart = HandlerUtil.getActiveEditor(event);
ITextEditor textEditor = null;
if (editorPart instanceof ITextEditor)
textEditor = (ITextEditor) editorPart;
else {
Object o = editorPart.getAdapter(ITextEditor.class);
if (o != null)
textEditor = (ITextEditor) o;
}
boolean okay = false;
if (textEditor != null) {
IDocument document = textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput());
if (document != null) {
ITextSelection textSelection = getTextSelection(textEditor);
FindOccurrencesProcessor findOccurrenceProcessor = getProcessorForCurrentSelection(document, textSelection);
if (findOccurrenceProcessor != null) {
if (textEditor.getEditorInput() instanceof IFileEditorInput) {
IFile file = ((IFileEditorInput) textEditor.getEditorInput()).getFile();
okay = findOccurrenceProcessor.findOccurrences(document, textSelection, file);
}
}
}
}
if (okay) {
// clear status message
PlatformStatusLineUtil.clearStatusLine();
} else {
// $NON-NLS-1$
String errorMessage = SSEUIMessages.FindOccurrencesActionProvider_0;
if (textEditor instanceof StructuredTextEditor) {
PlatformStatusLineUtil.displayTemporaryErrorMessage(((StructuredTextEditor) textEditor).getTextViewer(), errorMessage);
} else {
PlatformStatusLineUtil.displayErrorMessage(errorMessage);
PlatformStatusLineUtil.addOneTimeClearListener();
}
}
return null;
}
use of org.eclipse.wst.sse.ui.internal.search.FindOccurrencesProcessor in project webtools.sourceediting by eclipse.
the class XMLFindOccurencesHandler method getProcessorForCurrentSelection.
/**
* Get the appropriate find occurrences processor
*
* @param document -
* assumes not null
* @param textSelection
* @return FindOccurrencesProcessor
*/
private FindOccurrencesProcessor getProcessorForCurrentSelection(IDocument document, ITextSelection textSelection) {
// check if we have an action that's enabled on the current partition
ITypedRegion tr = getPartition(document, textSelection);
// $NON-NLS-1$
String partition = tr != null ? tr.getType() : "";
Iterator it = getProcessors().iterator();
FindOccurrencesProcessor processor = null;
while (it.hasNext()) {
processor = (FindOccurrencesProcessor) it.next();
// we just choose the first action that can handle the partition
if (processor.enabledForParitition(partition))
return processor;
}
List extendedFindOccurrencesProcessors = ExtendedConfigurationBuilder.getInstance().getConfigurations(FindOccurrencesProcessor.class.getName(), partition);
for (int i = 0; i < extendedFindOccurrencesProcessors.size(); i++) {
Object o = extendedFindOccurrencesProcessors.get(i);
if (o instanceof FindOccurrencesProcessor) {
/*
* We just choose the first registered processor that
* explicitly says it can handle the partition
*/
processor = (FindOccurrencesProcessor) o;
if (processor.enabledForParitition(partition))
return processor;
}
}
return null;
}
use of org.eclipse.wst.sse.ui.internal.search.FindOccurrencesProcessor in project webtools.sourceediting by eclipse.
the class XMLFindOccurencesHandler method execute.
public Object execute(ExecutionEvent event) throws ExecutionException {
IEditorPart editor = HandlerUtil.getActiveEditor(event);
ITextEditor textEditor = null;
boolean okay = false;
if (editor instanceof ITextEditor)
textEditor = (ITextEditor) editor;
else {
Object o = editor.getAdapter(ITextEditor.class);
if (o != null)
textEditor = (ITextEditor) o;
}
if (textEditor != null) {
IDocument document = textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput());
if (document != null) {
ITextSelection textSelection = getTextSelection(textEditor);
FindOccurrencesProcessor findOccurrenceProcessor = getProcessorForCurrentSelection(document, textSelection);
if (findOccurrenceProcessor != null) {
if (textEditor.getEditorInput() instanceof IFileEditorInput) {
IFile file = ((IFileEditorInput) textEditor.getEditorInput()).getFile();
okay = findOccurrenceProcessor.findOccurrences(document, textSelection, file);
}
}
}
}
if (okay) {
// clear status message
PlatformStatusLineUtil.clearStatusLine();
} else {
// $NON-NLS-1$
String errorMessage = SSEUIMessages.FindOccurrencesActionProvider_0;
if (textEditor instanceof StructuredTextEditor) {
PlatformStatusLineUtil.displayTemporaryErrorMessage(((StructuredTextEditor) textEditor).getTextViewer(), errorMessage);
} else {
PlatformStatusLineUtil.displayErrorMessage(errorMessage);
PlatformStatusLineUtil.addOneTimeClearListener();
}
}
return null;
}
Aggregations