/******************************************************************************* * Copyright (c) 2000, 2011 IBM Corporation 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: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.ui.actions; import org.eclipse.swt.widgets.Shell; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.text.ITextSelection; import org.eclipse.ui.IWorkbenchSite; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.texteditor.IEditorStatusLine; import org.eclipse.jdt.core.ITypeRoot; import org.eclipse.jdt.ui.JavaUI; import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; import org.eclipse.jdt.internal.ui.actions.ActionMessages; import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor; import org.eclipse.jdt.internal.ui.javaeditor.JavaTextSelection; /** * Action to find all break/continue targets for a given break or continue statement. *
* This class may be instantiated; it is not intended to be subclassed. *
* * @since 3.4 * * @noextend This class is not intended to be subclassed by clients. */ public class FindBreakContinueTargetOccurrencesAction extends SelectionDispatchAction { public JavaEditor fEditor; /** * Note: This constructor is for internal use only. Clients should not call this constructor. * * @param editor the Java editor * * @noreference This constructor is not intended to be referenced by clients. */ public FindBreakContinueTargetOccurrencesAction(JavaEditor editor) { this(editor.getEditorSite()); fEditor= editor; setEnabled(getEditorInput(editor) != null); } /** * Creates a new {@link FindBreakContinueTargetOccurrencesAction}. The action * requires that the selection provided by the site's selection provider is of type *IStructuredSelection
.
*
* @param site the site providing context information for this action
*/
public FindBreakContinueTargetOccurrencesAction(IWorkbenchSite site) {
super(site);
setText(ActionMessages.FindBreakContinueTargetOccurrencesAction_label);
setToolTipText(ActionMessages.FindBreakContinueTargetOccurrencesAction_tooltip);
PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.FIND_BREAK_CONTINUE_TARGET_OCCURRENCES);
}
//---- Text Selection ----------------------------------------------------------------------
/**
* {@inheritDoc}
*/
@Override
public void selectionChanged(ITextSelection selection) {
setEnabled(true);
}
/**
* Note: This method is for internal use only. Clients should not call this method.
*
* @param selection the selection
*
* @noreference This method is not intended to be referenced by clients.
*/
@Override
public void selectionChanged(JavaTextSelection selection) {
selection.generated_3985285739337536814(this);
}
/**
* {@inheritDoc}
*/
@Override
public void selectionChanged(IStructuredSelection selection) {
setEnabled(false);
}
/* (non-JavaDoc)
* Method declared in SelectionDispatchAction.
*/
@Override
public final void run(ITextSelection ts) {
fEditor.generated_1675003029481672430(this, ts);
}
public static ITypeRoot getEditorInput(JavaEditor editor) {
return JavaUI.getEditorInputTypeRoot(editor.getEditorInput());
}
public static void showMessage(Shell shell, JavaEditor editor, String msg) {
IEditorStatusLine statusLine= (IEditorStatusLine) editor.getAdapter(IEditorStatusLine.class);
if (statusLine != null)
statusLine.setMessage(true, msg, null);
shell.getDisplay().beep();
}
}