diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java index 9672a1c9beb..1e795615de8 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java @@ -52,7 +52,7 @@ import org.eclipse.cdt.ui.CDTUITools; import org.eclipse.cdt.ui.CElementGrouping; import org.eclipse.cdt.ui.IncludesGrouping; import org.eclipse.cdt.ui.NamespacesGrouping; - + /** * A base content provider for C elements. It provides access to the * C element hierarchy without listening to changes in the C model. @@ -83,11 +83,11 @@ public class BaseCElementContentProvider implements ITreeContentProvider { protected boolean fNamespacesGrouping= false; protected boolean fMemberGrouping= false; protected boolean fMacroGrouping= false; - + public BaseCElementContentProvider() { this(false, false); } - + public BaseCElementContentProvider(boolean provideMembers, boolean provideWorkingCopy) { fProvideMembers= provideMembers; fProvideWorkingCopy= provideWorkingCopy; @@ -161,7 +161,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider { public boolean isMemberGroupingEnabled() { return fMemberGrouping; } - + /** * Enable/disable member grouping by common namespace. * @param enable @@ -169,14 +169,14 @@ public class BaseCElementContentProvider implements ITreeContentProvider { public void setMemberGrouping(boolean enable) { fMemberGrouping = enable; } - + /** * @return whether grouping of macros is enabled */ public boolean isMacroGroupingEnabled() { return fMacroGrouping; } - + /** * Enable/disable marco grouping * @param enable @@ -188,25 +188,29 @@ public class BaseCElementContentProvider implements ITreeContentProvider { /* (non-Cdoc) * Method declared on IContentProvider. */ + @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } /* (non-Cdoc) * Method declared on IContentProvider. */ + @Override public void dispose() { } /* (non-Cdoc) * Method declared on IStructuredContentProvider. */ + @Override public Object[] getElements(Object parent) { return getChildren(parent); } - + /* (non-Cdoc) * Method declared on ITreeContentProvider. */ + @Override public Object[] getChildren(Object element) { if (!exists(element)) return NO_CHILDREN; @@ -263,6 +267,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider { * * @see ITreeContentProvider */ + @Override public boolean hasChildren(Object element) { if (fProvideMembers) { // assume TUs and binary files are never empty @@ -303,7 +308,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider { return true; } } - + if (element instanceof CElementGrouping) { return true; } @@ -311,10 +316,11 @@ public class BaseCElementContentProvider implements ITreeContentProvider { Object[] children= getChildren(element); return (children != null) && children.length > 0; } - + /* (non-Cdoc) * Method declared on ITreeContentProvider. */ + @Override public Object getParent(Object element) { if (!exists(element)) { return null; @@ -398,7 +404,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider { } return parent; } - + protected Object[] getCProjects(ICModel cModel) throws CModelException { Object[] objects = cModel.getCProjects(); try { @@ -415,7 +421,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider { protected Object[] getSourceRoots(ICProject cproject) throws CModelException { if (!cproject.getProject().isOpen()) return NO_CHILDREN; - + List list= new ArrayList(); ICElement[] children = cproject.getChildren(); for (ICElement child : children) { @@ -426,8 +432,8 @@ public class BaseCElementContentProvider implements ITreeContentProvider { list.add(c2[k]); } else if (CCorePlugin.showSourceRootsAtTopOfProject()) { list.add(child); - } else if (child instanceof ISourceRoot && - child.getResource().getParent().equals(cproject.getProject())) { + } else if (child instanceof ISourceRoot && + child.getResource().getParent().equals(cproject.getProject())) { list.add(child); } } @@ -579,7 +585,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider { } } catch (CModelException e) { } - + Object[] result = children; if (missingElements.size() > 0) { result = concatenate(result, missingElements.toArray()); @@ -593,7 +599,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider { } private List getMissingElements(ICContainer container, ICElement[] elements) { - // nested source roots may be filtered out below the project root, + // nested source roots may be filtered out below the project root, // we need to find them to add them back in List missingElements = new ArrayList(); try { @@ -643,7 +649,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider { } return filterNonCResources(members, cproject); } - + private Object[] filterNonCResources(Object[] objects, ICProject cproject) throws CModelException { ICElement[] binaries = null; ICElement[] archives = null; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CActionFilter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CActionFilter.java index 8912250fd3b..a2972590882 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CActionFilter.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CActionFilter.java @@ -25,6 +25,7 @@ public class CActionFilter implements IActionFilter { public CActionFilter() { } + @Override public boolean testAttribute(Object target, String name, String value) { ICElement element = (ICElement) target; IResource resource = element.getResource(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementAdapterFactory.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementAdapterFactory.java index f3c1983b1ba..c34d2a72a2e 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementAdapterFactory.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementAdapterFactory.java @@ -31,33 +31,35 @@ import org.eclipse.cdt.core.model.ICElement; * Implements basic UI support for C elements. */ public class CElementAdapterFactory implements IAdapterFactory { - + private static Class[] PROPERTIES= new Class[] { IPropertySource.class, IResource.class, IWorkbenchAdapter.class, IPersistableElement.class, IDeferredWorkbenchAdapter.class, - IActionFilter.class + IActionFilter.class }; - + private static CWorkbenchAdapter fgCWorkbenchAdapter; private static CActionFilter fgCActionFilter; - + /** * @see CElementAdapterFactory#getAdapterList */ + @Override public Class[] getAdapterList() { return PROPERTIES; } /** * @see CElementAdapterFactory#getAdapter - */ + */ + @Override @SuppressWarnings({ "unchecked", "rawtypes" }) public Object getAdapter(Object element, Class key) { ICElement celem = (ICElement) element; - + if (IPropertySource.class.equals(key)) { return getPropertySource(celem); } else if (IResource.class.isAssignableFrom(key)) { @@ -74,12 +76,12 @@ public class CElementAdapterFactory implements IAdapterFactory { } else if (IActionFilter.class.equals(key)) { return getActionFilter(celem); } - return null; + return null; } private IPropertySource getPropertySource(ICElement celement) { if (celement instanceof IBinary) { - return new BinaryPropertySource((IBinary)celement); + return new BinaryPropertySource((IBinary)celement); } IResource res = celement.getResource(); if (res != null) { @@ -88,7 +90,7 @@ public class CElementAdapterFactory implements IAdapterFactory { } return new ResourcePropertySource(res); } - return new CElementPropertySource(celement); + return new CElementPropertySource(celement); } private IResource getResource(ICElement celement) { @@ -105,7 +107,7 @@ public class CElementAdapterFactory implements IAdapterFactory { } return fgCWorkbenchAdapter; } - + private IActionFilter getActionFilter(ICElement celement) { if (fgCActionFilter == null) { fgCActionFilter = new CActionFilter(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementPropertySource.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementPropertySource.java index e69c13dadc8..c7bf15c4e12 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementPropertySource.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementPropertySource.java @@ -11,31 +11,32 @@ *******************************************************************************/ package org.eclipse.cdt.internal.ui; -import org.eclipse.cdt.core.model.ICElement; -import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.jface.viewers.IBasicPropertyConstants; import org.eclipse.ui.views.properties.IPropertyDescriptor; import org.eclipse.ui.views.properties.IPropertySource; import org.eclipse.ui.views.properties.PropertyDescriptor; +import org.eclipse.cdt.core.model.ICElement; +import org.eclipse.cdt.ui.CUIPlugin; + public class CElementPropertySource implements IPropertySource { - + private final static String LABEL= "CElementProperties.name"; //$NON-NLS-1$ - + private ICElement fCElement; - + // Property Descriptors static private IPropertyDescriptor[] fgPropertyDescriptors; - + static { // resource name String displayName= CUIPlugin.getResourceString(LABEL); PropertyDescriptor descriptor= new PropertyDescriptor(IBasicPropertyConstants.P_TEXT, displayName); descriptor.setAlwaysIncompatible(true); - + fgPropertyDescriptors= new IPropertyDescriptor[] { descriptor }; } - + public CElementPropertySource(ICElement elem) { fCElement= elem; } @@ -43,13 +44,15 @@ public class CElementPropertySource implements IPropertySource { /** * @see IPropertySource#getPropertyDescriptors */ + @Override public IPropertyDescriptor[] getPropertyDescriptors() { return fgPropertyDescriptors; } /** * @see IPropertySource#getPropertyValue - */ + */ + @Override public Object getPropertyValue(Object name) { if (name.equals(IBasicPropertyConstants.P_TEXT)) { return fCElement.getElementName(); @@ -59,27 +62,31 @@ public class CElementPropertySource implements IPropertySource { /** * @see IPropertySource#setPropertyValue - */ + */ + @Override public void setPropertyValue(Object name, Object value) { } /** * @see IPropertySource#getEditableValue - */ + */ + @Override public Object getEditableValue() { return null; } /** * @see IPropertySource#isPropertySet - */ + */ + @Override public boolean isPropertySet(Object property) { return false; } /** * @see IPropertySource#resetPropertyValue - */ + */ + @Override public void resetPropertyValue(Object property) { } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPerspectiveFactory.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPerspectiveFactory.java index 192f5654142..15f803aed94 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPerspectiveFactory.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPerspectiveFactory.java @@ -12,8 +12,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.ui; -import org.eclipse.cdt.internal.ui.wizards.CWizardRegistry; -import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.search.ui.NewSearchUI; import org.eclipse.ui.IFolderLayout; import org.eclipse.ui.IPageLayout; @@ -21,8 +19,12 @@ import org.eclipse.ui.IPerspectiveFactory; import org.eclipse.ui.console.IConsoleConstants; import org.eclipse.ui.navigator.resources.ProjectExplorer; +import org.eclipse.cdt.ui.CUIPlugin; + +import org.eclipse.cdt.internal.ui.wizards.CWizardRegistry; + public class CPerspectiveFactory implements IPerspectiveFactory { - + /** * Constructs a new Default layout engine. */ @@ -33,34 +35,35 @@ public class CPerspectiveFactory implements IPerspectiveFactory { /** * @see IPerspectiveFactory#createInitialLayout */ + @Override public void createInitialLayout(IPageLayout layout) { String editorArea = layout.getEditorArea(); - + IFolderLayout folder1= layout.createFolder("topLeft", IPageLayout.LEFT, (float)0.25, editorArea); //$NON-NLS-1$ folder1.addView(ProjectExplorer.VIEW_ID); folder1.addPlaceholder(CUIPlugin.CVIEW_ID); folder1.addPlaceholder(IPageLayout.ID_RES_NAV); folder1.addPlaceholder(IPageLayout.ID_BOOKMARKS); - + IFolderLayout folder2= layout.createFolder("bottom", IPageLayout.BOTTOM, (float)0.75, editorArea); //$NON-NLS-1$ folder2.addView(IPageLayout.ID_PROBLEM_VIEW); folder2.addView(IPageLayout.ID_TASK_LIST); folder2.addView(IConsoleConstants.ID_CONSOLE_VIEW); folder2.addView(IPageLayout.ID_PROP_SHEET); - + IFolderLayout folder3= layout.createFolder("topRight", IPageLayout.RIGHT,(float)0.75, editorArea); //$NON-NLS-1$ folder3.addView(IPageLayout.ID_OUTLINE); layout.addActionSet(CUIPlugin.SEARCH_ACTION_SET_ID); layout.addActionSet(CUIPlugin.ID_CELEMENT_CREATION_ACTION_SET); layout.addActionSet(IPageLayout.ID_NAVIGATE_ACTION_SET); - + // views - build console layout.addShowViewShortcut(IConsoleConstants.ID_CONSOLE_VIEW); - + // views - searching layout.addShowViewShortcut(NewSearchUI.SEARCH_VIEW_ID); - + // views - standard workbench layout.addShowViewShortcut(IPageLayout.ID_OUTLINE); layout.addShowViewShortcut(IPageLayout.ID_PROBLEM_VIEW); @@ -71,7 +74,7 @@ public class CPerspectiveFactory implements IPerspectiveFactory { addCWizardShortcuts(layout); } - + private void addCWizardShortcuts(IPageLayout layout) { // new actions - C project creation wizard String[] wizIDs = CWizardRegistry.getProjectWizardIDs(); @@ -93,6 +96,6 @@ public class CPerspectiveFactory implements IPerspectiveFactory { for (int i = 0; i < wizIDs.length; ++i) { layout.addNewWizardShortcut(wizIDs[i]); } - + } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CProjectAdapterFactory.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CProjectAdapterFactory.java index c9c3f244d39..ee355976529 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CProjectAdapterFactory.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CProjectAdapterFactory.java @@ -28,6 +28,7 @@ public class CProjectAdapterFactory implements IAdapterFactory { /* * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class) */ + @Override @SuppressWarnings("rawtypes") public Object getAdapter(Object adaptableObject, Class adapterType) { if (IProject.class.equals(adapterType)) { @@ -39,6 +40,7 @@ public class CProjectAdapterFactory implements IAdapterFactory { /* * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList() */ + @Override public Class[] getAdapterList() { return ADAPTERS; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CWorkbenchAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CWorkbenchAdapter.java index 12e2cabba1a..5fecaccf09e 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CWorkbenchAdapter.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CWorkbenchAdapter.java @@ -12,14 +12,16 @@ *******************************************************************************/ package org.eclipse.cdt.internal.ui; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.model.IWorkbenchAdapter; + import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.IParent; -import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider; import org.eclipse.cdt.ui.CElementLabelProvider; import org.eclipse.cdt.ui.CUIPlugin; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.ui.model.IWorkbenchAdapter; + +import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider; /** * An implementation of the IWorkbenchAdapter for CElements. @@ -38,6 +40,7 @@ public class CWorkbenchAdapter implements IWorkbenchAdapter { /** * @see IWorkbenchAdapter#getChildren */ + @Override public Object[] getChildren(Object o) { if (o instanceof IParent) { try { @@ -55,6 +58,7 @@ public class CWorkbenchAdapter implements IWorkbenchAdapter { /** * @see IWorkbenchAdapter#getImageDescriptor */ + @Override public ImageDescriptor getImageDescriptor(Object element) { if (element instanceof ICElement) { return fImageProvider.getCImageDescriptor( @@ -67,6 +71,7 @@ public class CWorkbenchAdapter implements IWorkbenchAdapter { /** * @see IWorkbenchAdapter#getLabel */ + @Override public String getLabel(Object o) { if (o instanceof ICElement) { return fLabelProvider.getText(o); @@ -77,6 +82,7 @@ public class CWorkbenchAdapter implements IWorkbenchAdapter { /** * @see IWorkbenchAdapter#getParent */ + @Override public Object getParent(Object o) { if (o instanceof ICElement) { return ((ICElement) o).getParent(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/DeferredCWorkbenchAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/DeferredCWorkbenchAdapter.java index 141534ced1a..a062100742a 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/DeferredCWorkbenchAdapter.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/DeferredCWorkbenchAdapter.java @@ -10,13 +10,14 @@ *******************************************************************************/ package org.eclipse.cdt.internal.ui; -import org.eclipse.cdt.core.model.ICElement; -import org.eclipse.cdt.core.model.IParent; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.jobs.ISchedulingRule; import org.eclipse.ui.progress.IDeferredWorkbenchAdapter; import org.eclipse.ui.progress.IElementCollector; +import org.eclipse.cdt.core.model.ICElement; +import org.eclipse.cdt.core.model.IParent; + public class DeferredCWorkbenchAdapter extends CWorkbenchAdapter implements IDeferredWorkbenchAdapter { private ICElement fCElement; @@ -28,11 +29,12 @@ public class DeferredCWorkbenchAdapter extends CWorkbenchAdapter implements IDef /* * (non-Javadoc) - * + * * @see org.eclipse.ui.progress.IDeferredWorkbenchAdapter#fetchDeferredChildren(java.lang.Object, * org.eclipse.jface.progress.IElementCollector, * org.eclipse.core.runtime.IProgressMonitor) */ + @Override public void fetchDeferredChildren(Object object, IElementCollector collector, IProgressMonitor monitor) { Object[] children = getChildren(object); if (monitor.isCanceled()) { @@ -44,18 +46,20 @@ public class DeferredCWorkbenchAdapter extends CWorkbenchAdapter implements IDef /* * (non-Javadoc) - * + * * @see org.eclipse.ui.progress.IDeferredWorkbenchAdapter#isContainer() */ + @Override public boolean isContainer() { return fCElement instanceof IParent; } /* * (non-Javadoc) - * + * * @see org.eclipse.ui.progress.IDeferredWorkbenchAdapter#getRule(java.lang.Object) */ + @Override public ISchedulingRule getRule(final Object object) { return fCElement.getResource(); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/LineBackgroundPainter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/LineBackgroundPainter.java index ea5364b97c4..3f287f0126b 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/LineBackgroundPainter.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/LineBackgroundPainter.java @@ -34,13 +34,13 @@ import org.eclipse.swt.graphics.Rectangle; /** * A painter for configurable background painting a range of text lines. - * Replicates also the functionality of the + * Replicates also the functionality of the * {@link org.eclipse.jface.text.CursorLinePainter} * because only one {@link LineBackgroundListener} is allowed * per {@link StyledText} widget. - * + * * @author anton.leherbauer@windriver.com - * + * * @since 4.0 */ public class LineBackgroundPainter implements IPainter, LineBackgroundListener { @@ -89,7 +89,7 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener { /** * Sets the color in which to draw the background of the given position type. - * + * * @param positionType the position type for which to specify the background color * @param color the color in which to draw the background of the given position type */ @@ -99,7 +99,7 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener { /** * Sets the color in which to draw the background of the cursor line. - * + * * @param cursorLineColor the color in which to draw the background of the cursor line */ public void setCursorLineColor(Color cursorLineColor) { @@ -108,7 +108,7 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener { /** * Sets the color in which to draw the background of untyped positions. - * + * * @param color the color in which to draw the background of untyped positions */ public void setDefaultColor(Color color) { @@ -117,7 +117,7 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener { /** * Enable/disable cursor line highlighting. - * + * * @param enable */ public void enableCursorLine(boolean enable) { @@ -131,7 +131,7 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener { /** * Set highlight positions. It is assumed that all positions * are up-to-date with respect to the text viewer document. - * + * * @param positions a list of Positions */ public void setHighlightPositions(List positions) { @@ -148,7 +148,7 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener { /** * Add highlight positions. It is assumed that all positions * are up-to-date with respect to the text viewer document. - * + * * @param positions a list of Positions */ public void addHighlightPositions(List positions) { @@ -162,7 +162,7 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener { /** * Remove highlight positions by identity. - * + * * @param positions a list of Positions */ public void removeHighlightPositions(List positions) { @@ -176,7 +176,7 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener { /** * Replace given highlight positions in one step. - * + * * @param removePositions a list of Positions to remove * @param addPositions a list of Positions to add */ @@ -232,6 +232,7 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener { /* * @see org.eclipse.jface.text.IPainter#dispose() */ + @Override public void dispose() { // no deactivate! fIsActive= false; @@ -252,10 +253,11 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener { public boolean isDisposed() { return fTextViewer == null; } - + /* * @see org.eclipse.jface.text.IPainter#paint(int) */ + @Override public void paint(int reason) { IDocument document= fTextViewer.getDocument(); if (document == null) { @@ -365,7 +367,7 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener { /** * Trigger redraw of given text positions. - * + * * @param positions */ private void redrawPositions(List positions) { @@ -429,6 +431,7 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener { /* * @see org.eclipse.jface.text.IPainter#deactivate(boolean) */ + @Override public void deactivate(boolean redraw) { if (fIsActive) { fIsActive= false; @@ -443,6 +446,7 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener { /* * @see org.eclipse.jface.text.IPainter#setPositionManager(org.eclipse.jface.text.IPaintPositionManager) */ + @Override public void setPositionManager(IPaintPositionManager manager) { fPositionManager= manager; } @@ -485,6 +489,7 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener { /* * @see org.eclipse.swt.custom.LineBackgroundListener#lineGetBackground(org.eclipse.swt.custom.LineBackgroundEvent) */ + @Override public void lineGetBackground(LineBackgroundEvent event) { if (fTextWidget != null) { Position match= findIncludingPosition(getDocumentOffset(event.lineOffset)); @@ -541,7 +546,7 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener { IDocument document= fTextViewer.getDocument(); if (document != null) { int lineNumber= document.getLineOfOffset(getDocumentOffset(fTextWidget.getCaretOffset())); - + fCursorLine.isDeleted= false; fCursorLine.offset= document.getLineOffset(lineNumber); fCursorLine.length= 0; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/PersistableCElementFactory.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/PersistableCElementFactory.java index 547ce717e01..8de110b288e 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/PersistableCElementFactory.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/PersistableCElementFactory.java @@ -27,7 +27,7 @@ import org.eclipse.ui.IPersistableElement; import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.ICElement; -/** +/** * The PersistableCElementFactory is used to save and recreate an ICElement object. * As such, it implements the IPersistableElement interface for storage * and the IElementFactory interface for recreation. @@ -66,7 +66,8 @@ public class PersistableCElementFactory implements IElementFactory, IPersistable /** * @see IElementFactory */ - public IAdaptable createElement(IMemento memento) { + @Override + public IAdaptable createElement(IMemento memento) { // Get the file name. String fileName = memento.getString(TAG_PATH); if (fileName == null) { @@ -84,7 +85,7 @@ public class PersistableCElementFactory implements IElementFactory, IPersistable if (fCElement != null) { return fCElement; } - + final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); Integer elementType= memento.getInteger(TAG_TYPE); if (elementType == null) { @@ -114,14 +115,16 @@ public class PersistableCElementFactory implements IElementFactory, IPersistable /** * @see IPersistableElement */ - public String getFactoryId() { + @Override + public String getFactoryId() { return FACTORY_ID; } /** * @see IPersistableElement */ - public void saveState(IMemento memento) { + @Override + public void saveState(IMemento memento) { if (fCElement.getResource() != null) { memento.putString(TAG_PATH, fCElement.getResource().getFullPath().toString()); memento.putInteger(TAG_TYPE, fCElement.getResource().getType()); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ResourceAdapterFactory.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ResourceAdapterFactory.java index 39049425b24..b2d80cd3231 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ResourceAdapterFactory.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ResourceAdapterFactory.java @@ -26,20 +26,22 @@ public class ResourceAdapterFactory implements IAdapterFactory { private static Class[] PROPERTIES= new Class[] { ICElement.class }; - + //private static CElementFactory celementFactory= new CElementFactory(); private static CoreModel celementFactory= CoreModel.getDefault(); /** * @see IAdapterFactory#getAdapterList - */ + */ + @Override public Class[] getAdapterList() { return PROPERTIES; } - + /** * @see IAdapterFactory#getAdapter */ + @Override @SuppressWarnings("rawtypes") public Object getAdapter(Object element, Class key) { if (ICElement.class.equals(key)) { @@ -60,5 +62,5 @@ public class ResourceAdapterFactory implements IAdapterFactory { //} } return null; - } + } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/AbstractUpdateIndexAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/AbstractUpdateIndexAction.java index bf4d34d50ac..fa5a437b9c7 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/AbstractUpdateIndexAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/AbstractUpdateIndexAction.java @@ -8,7 +8,7 @@ * Contributors: * Markus Schorn - initial API and implementation * Anton Leherbauer (Wind River Systems) - *******************************************************************************/ + *******************************************************************************/ package org.eclipse.cdt.internal.ui.actions; @@ -34,14 +34,16 @@ import org.eclipse.cdt.ui.CUIPlugin; public abstract class AbstractUpdateIndexAction implements IObjectActionDelegate { private ISelection fSelection; - + + @Override public void setActivePart(IAction action, IWorkbenchPart targetPart) { } + @Override public void run(IAction action) { if (!(fSelection instanceof IStructuredSelection)) return; - + IStructuredSelection cElements= SelectionConverter.convertSelectionToCElements(fSelection); Iterator i= cElements.iterator(); ArrayList tuSelection= new ArrayList(); @@ -52,7 +54,7 @@ public abstract class AbstractUpdateIndexAction implements IObjectActionDelegate } } ICElement[] tuArray= tuSelection.toArray(new ICElement[tuSelection.size()]); - + try { CCorePlugin.getIndexManager().update(tuArray, getUpdateOptions()); } @@ -71,6 +73,7 @@ public abstract class AbstractUpdateIndexAction implements IObjectActionDelegate /** * @see IActionDelegate#selectionChanged(IAction, ISelection) */ + @Override public void selectionChanged(IAction action, ISelection selection) { fSelection = selection; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CDTQuickMenuCreator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CDTQuickMenuCreator.java index 1b33aa414a5..d13b461c78d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CDTQuickMenuCreator.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CDTQuickMenuCreator.java @@ -11,20 +11,17 @@ *******************************************************************************/ package org.eclipse.cdt.internal.ui.actions; -import org.eclipse.swt.custom.StyledText; -import org.eclipse.swt.graphics.Point; - import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.commands.IHandler; - import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.ITextSelection; import org.eclipse.jface.text.ITextViewerExtension5; import org.eclipse.jface.text.Region; import org.eclipse.jface.text.source.ISourceViewer; - +import org.eclipse.swt.custom.StyledText; +import org.eclipse.swt.graphics.Point; import org.eclipse.ui.actions.QuickMenuCreator; import org.eclipse.cdt.internal.ui.editor.CEditor; @@ -33,7 +30,7 @@ import org.eclipse.cdt.internal.ui.text.CWordFinder; /** * C/C++ editor aware quick menu creator. In the given editor, the menu will be aligned with the word * at the current offset. - * + * * @since 5.2 */ public abstract class CDTQuickMenuCreator extends QuickMenuCreator { @@ -94,11 +91,12 @@ public abstract class CDTQuickMenuCreator extends QuickMenuCreator { /** * Returns a handler that can create and open the quick menu. - * + * * @return a handler that can create and open the quick menu */ public IHandler createHandler() { return new AbstractHandler() { + @Override public Object execute(ExecutionEvent event) throws ExecutionException { createMenu(); return null; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CreateParserLogAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CreateParserLogAction.java index 245816efe30..99d745db532 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CreateParserLogAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CreateParserLogAction.java @@ -7,7 +7,7 @@ * * Contributors: * Markus Schorn - initial API and implementation - *******************************************************************************/ + *******************************************************************************/ package org.eclipse.cdt.internal.ui.actions; import java.io.File; @@ -98,7 +98,7 @@ public class CreateParserLogAction implements IObjectActionDelegate { fProblems.add(problem); return PROCESS_SKIP; } - + @Override public int visit(IASTName name) { if (name instanceof ICPPASTQualifiedName) { @@ -117,6 +117,7 @@ public class CreateParserLogAction implements IObjectActionDelegate { } private static final Comparator COMP_INSENSITIVE= new Comparator () { + @Override public int compare(String o1, String o2) { return o1.toUpperCase().compareTo(o2.toUpperCase()); } @@ -126,20 +127,23 @@ public class CreateParserLogAction implements IObjectActionDelegate { private IWorkbenchPartSite fSite; private boolean fWroteUnresolvedTitle; - + + @Override public void setActivePart(IAction action, IWorkbenchPart targetPart) { fSite= targetPart.getSite(); } + @Override public void selectionChanged(IAction action, ISelection selection) { fSelection = selection; } + @Override public void run(IAction action) { if (!(fSelection instanceof IStructuredSelection)) return; - - final String title= action.getText().replace("&", ""); + + final String title= action.getText().replace("&", ""); IStructuredSelection cElements= SelectionConverter.convertSelectionToCElements(fSelection); Iterator i= cElements.iterator(); ArrayList tuSelection= new ArrayList(); @@ -155,36 +159,36 @@ public class CreateParserLogAction implements IObjectActionDelegate { } FileDialog dlg= new FileDialog(fSite.getShell(), SWT.SAVE); dlg.setText(title); - dlg.setFilterExtensions(new String[]{"*.log"}); + dlg.setFilterExtensions(new String[]{"*.log"}); String path= null; while(path == null) { path= dlg.open(); if (path == null) return; - File file= new File(path); + File file= new File(path); if (file.exists()) { if (!file.canWrite()) { - final String msg= NLS.bind(ActionMessages.CreateParserLogAction_readOnlyFile, path); + final String msg= NLS.bind(ActionMessages.CreateParserLogAction_readOnlyFile, path); MessageDialog.openError(fSite.getShell(), title, msg); path= null; } else { - final String msg = NLS.bind(ActionMessages.CreateParserLogAction_existingFile, path); + final String msg = NLS.bind(ActionMessages.CreateParserLogAction_existingFile, path); if (!MessageDialog.openQuestion(fSite.getShell(), title, msg)) { path= null; } } } } - + try { PrintStream out= new PrintStream(path); try { boolean needsep= false; for (ITranslationUnit tu : tuArray) { if (needsep) { - out.println(); out.println(); + out.println(); out.println(); } createLog(out, tu, new NullProgressMonitor()); needsep= true; @@ -205,6 +209,7 @@ public class CreateParserLogAction implements IObjectActionDelegate { CUIPlugin.log(e); } ASTProvider.getASTProvider().runOnAST(tu, ASTProvider.WAIT_IF_OPEN, pm, new ASTCache.ASTRunnable() { + @Override public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) throws CoreException { if (ast != null) return createLog(out, tu, lang, ast); @@ -243,11 +248,11 @@ public class CreateParserLogAction implements IObjectActionDelegate { final ExtendedScannerInfo scfg= new ExtendedScannerInfo(configureWith.getScannerInfo(true)); final MyVisitor visitor= new MyVisitor(); ast.accept(visitor); - - out.println("Project: " + projectName); - out.println("File: " + tu.getLocationURI()); - out.println("Language: " + lang.getName()); - out.println("Index Version: " + PDOM.versionString(PDOM.getDefaultVersion())); + + out.println("Project: " + projectName); + out.println("File: " + tu.getLocationURI()); + out.println("Language: " + lang.getName()); + out.println("Index Version: " + PDOM.versionString(PDOM.getDefaultVersion())); out.println("Build Configuration: " + getBuildConfig(cproject)); if (configureWith == tu) { out.println("Context: none"); @@ -255,7 +260,7 @@ public class CreateParserLogAction implements IObjectActionDelegate { out.println("Context: " + configureWith.getLocationURI()); out.println(INDENT + getLinkageName(ctxLinkage) + ", " + ctxSigMacros); } - + try { IIndexFile[] versions= index.getFiles(IndexLocationFactory.getIFL(tu)); out.println("Versions in Index: " + versions.length); @@ -271,7 +276,7 @@ public class CreateParserLogAction implements IObjectActionDelegate { output(out, "Local Include Search Path (option -iquote):", scfg.getLocalIncludePath()); output(out, "Preincluded files (option -include):", scfg.getIncludeFiles()); output(out, "Preincluded macro files (option -imacros):", scfg.getMacroFiles()); - + HashSet reported= new HashSet(); output(out, "Macro definitions (option -D):", scfg.getDefinedSymbols(), reported); output(out, "Macro definitions (from language + headers in index):", ast.getBuiltinMacroDefinitions(), reported); @@ -306,13 +311,13 @@ public class CreateParserLogAction implements IObjectActionDelegate { ICProjectDescription prefs= prjDescMgr.getProjectDescription(cproject.getProject(), false); if (prefs != null) { ICConfigurationDescription cfg= prefs.getDefaultSettingConfiguration(); - if (cfg != null) + if (cfg != null) return cfg.getName(); } return "unknown"; } - private void outputUnresolvedIncludes(ICProject prj, IIndex index, PrintStream out, + private void outputUnresolvedIncludes(ICProject prj, IIndex index, PrintStream out, IASTPreprocessorIncludeStatement[] includeDirectives, int linkageID) throws CoreException { fWroteUnresolvedTitle= false; ASTFilePathResolver resolver= new ProjectIndexerInputAdapter(prj); @@ -328,11 +333,11 @@ public class CreateParserLogAction implements IObjectActionDelegate { out.println(); } - private void outputUnresolvedIncludes(IIndex index, PrintStream out, + private void outputUnresolvedIncludes(IIndex index, PrintStream out, IIndexFileLocation ifl, IIndexFile ifile, Set handled) throws CoreException { if (ifile == null) { writeUnresolvedTitle(out); - out.println(INDENT + ifl.getURI() + " is not indexed"); + out.println(INDENT + ifl.getURI() + " is not indexed"); } else if (handled.add(ifile)) { IIndexInclude[] includes = ifile.getIncludes(); for (IIndexInclude inc : includes) { @@ -342,7 +347,7 @@ public class CreateParserLogAction implements IObjectActionDelegate { outputUnresolvedIncludes(index, out, inc.getIncludesLocation(), next, handled); } else { writeUnresolvedTitle(out); - out.println(INDENT + "Unresolved inclusion: " + inc.getFullName() + " in file " + + out.println(INDENT + "Unresolved inclusion: " + inc.getFullName() + " in file " + inc.getIncludedByLocation().getURI()); } } @@ -382,7 +387,7 @@ public class CreateParserLogAction implements IObjectActionDelegate { out.println(); } } - + private void output(PrintStream out, String label, IASTPreprocessorMacroDefinition[] defs, HashSet reported) { if (defs.length > 0) { out.println(label); @@ -399,7 +404,7 @@ public class CreateParserLogAction implements IObjectActionDelegate { out.println(); } } - + private void output(PrintStream out, String label, IASTProblem[] preprocessorProblems) { if (preprocessorProblems.length > 0) { out.println(label); @@ -409,14 +414,14 @@ public class CreateParserLogAction implements IObjectActionDelegate { out.println(); } } - + private void output(PrintStream out, String label, IProblemBinding[] list) { if (list.length > 0) { out.println(label); for (IProblemBinding problem : list) { String file= problem.getFileName(); int line = problem.getLineNumber(); - out.println(INDENT + problem.getMessage() + " in file " + file + ':' + line); + out.println(INDENT + problem.getMessage() + " in file " + file + ':' + line); } out.println(); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/DeleteResConfigsHandler.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/DeleteResConfigsHandler.java index 0f3322ca9b6..5694f23b76b 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/DeleteResConfigsHandler.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/DeleteResConfigsHandler.java @@ -58,14 +58,14 @@ import org.eclipse.cdt.ui.newui.AbstractPage; public class DeleteResConfigsHandler extends AbstractHandler { protected ArrayList objects; - private ArrayList outData; + private ArrayList outData; @Override public void setEnabled(Object context) { ISelection selection = getSelection(context); setEnabledFromSelection(selection); } - + protected ISelection getSelection(Object context) { Object s = HandlerUtil.getVariable(context, ISources.ACTIVE_MENU_SELECTION_NAME); if (s instanceof ISelection) { @@ -76,7 +76,7 @@ public class DeleteResConfigsHandler extends AbstractHandler { public void setEnabledFromSelection(ISelection selection) { objects = null; - + if ((selection != null) && !selection.isEmpty()) { // case for context menu Object[] obs = null; @@ -100,10 +100,10 @@ public class DeleteResConfigsHandler extends AbstractHandler { if (res != null) { IProject p = res.getProject(); if (!p.isOpen()) continue; - + if (!CoreModel.getDefault().isNewStyleProject(p)) continue; - + IPath path = res.getProjectRelativePath(); // getting description in read-only mode ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(p, false); @@ -121,7 +121,7 @@ public class DeleteResConfigsHandler extends AbstractHandler { } } } - } + } setBaseEnabled(objects != null); } @@ -141,19 +141,20 @@ public class DeleteResConfigsHandler extends AbstractHandler { return null; } + @Override public Object execute(ExecutionEvent event) throws ExecutionException { openDialog(); return null; } private void openDialog() { - if (objects == null || objects.size() == 0) return; + if (objects == null || objects.size() == 0) return; // create list of configurations to delete - + ListSelectionDialog dialog = new ListSelectionDialog( - CUIPlugin.getActiveWorkbenchShell(), - objects, - createSelectionDialogContentProvider(), + CUIPlugin.getActiveWorkbenchShell(), + objects, + createSelectionDialogContentProvider(), new LabelProvider() {}, ActionMessages.DeleteResConfigsAction_0); dialog.setTitle(ActionMessages.DeleteResConfigsAction_1); if (dialog.open() == Window.OK) { @@ -173,12 +174,12 @@ public class DeleteResConfigsHandler extends AbstractHandler { ICProjectDescription prjd; ICConfigurationDescription cfgd; ICResourceDescription rdesc; - + public ResCfgData(IResource res2, ICProjectDescription prjd2, ICConfigurationDescription cfgd2, ICResourceDescription rdesc2) { res = res2; prjd = prjd2; cfgd = cfgd2; rdesc = rdesc2; } - + // performs deletion public void delete() { try { @@ -191,16 +192,17 @@ public class DeleteResConfigsHandler extends AbstractHandler { return "[" + cfgd.getName() + "] for " + res.getName(); //$NON-NLS-1$ //$NON-NLS-2$ } } - - + + private IStructuredContentProvider createSelectionDialogContentProvider() { outData = null; - + return new IStructuredContentProvider() { + @Override public Object[] getElements(Object inputElement) { if (outData != null) return outData.toArray(); - + outData = new ArrayList(); List ls = (List)inputElement; Iterator it = ls.iterator(); @@ -220,16 +222,18 @@ public class DeleteResConfigsHandler extends AbstractHandler { if (cfgds != null) { for (ICConfigurationDescription cfgd : cfgds) { ICResourceDescription rd = cfgd.getResourceDescription(path, true); - if (rd != null) + if (rd != null) outData.add(new ResCfgData(res, prjd, cfgd, rd)); } } } return outData.toArray(); } + @Override public void dispose() {} + @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {} }; } - + } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ExcludeFromBuildHandler.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ExcludeFromBuildHandler.java index fe53bae4b8c..e9a85785539 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ExcludeFromBuildHandler.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ExcludeFromBuildHandler.java @@ -68,7 +68,7 @@ public class ExcludeFromBuildHandler extends AbstractHandler { ISelection selection = getSelection(context); setEnabledFromSelection(selection); } - + protected ISelection getSelection(Object context) { Object s = HandlerUtil.getVariable(context, ISources.ACTIVE_MENU_SELECTION_NAME); if (s instanceof ISelection) { @@ -81,7 +81,7 @@ public class ExcludeFromBuildHandler extends AbstractHandler { objects = null; cfgNames = null; boolean cfgsOK = true; - + if ((selection != null) && !selection.isEmpty()) { // case for context menu Object[] obs = null; @@ -97,7 +97,7 @@ public class ExcludeFromBuildHandler extends AbstractHandler { for (int i=0; i(); objects.add(res); if (cfgNames == null) { cfgNames = new ArrayList(cfgds.length); - for (int j=0; j it = objects.iterator(); while (it.hasNext()) { @@ -214,11 +215,11 @@ public class ExcludeFromBuildHandler extends AbstractHandler { } } ArrayList lst = new ArrayList(); - for (int i=0; i 0) dialog.setInitialElementSelections(lst); - + if (dialog.open() == Window.OK) { Object[] selected = dialog.getResult(); // may be empty Iterator it2 = objects.iterator(); @@ -243,7 +244,7 @@ public class ExcludeFromBuildHandler extends AbstractHandler { try { CoreModel.getDefault().setProjectDescription(p, prjd); } catch (CoreException e) { - CUIPlugin.logError(Messages.AbstractPage_11 + e.getLocalizedMessage()); + CUIPlugin.logError(Messages.AbstractPage_11 + e.getLocalizedMessage()); } AbstractPage.updateViews(res); } @@ -252,10 +253,13 @@ public class ExcludeFromBuildHandler extends AbstractHandler { private IStructuredContentProvider createSelectionDialogContentProvider() { return new IStructuredContentProvider() { + @Override public Object[] getElements(Object inputElement) { return cfgNames.toArray(); } + @Override public void dispose() {} + @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {} }; } - + } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FoldingActionGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FoldingActionGroup.java index 87ec40c3f51..2bed740d9d4 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FoldingActionGroup.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FoldingActionGroup.java @@ -30,7 +30,7 @@ import org.eclipse.cdt.internal.ui.editor.CEditor; /** * Groups the CDT folding actions. - * + * * @since 3.0 */ public class FoldingActionGroup extends ActionGroup { @@ -41,38 +41,39 @@ public class FoldingActionGroup extends ActionGroup { update(); } } - + private class FoldingAction extends PreferenceAction { FoldingAction(ResourceBundle bundle, String prefix) { super(bundle, prefix, IAction.AS_PUSH_BUTTON); } + @Override public void update() { setEnabled(FoldingActionGroup.this.isEnabled() && fViewer.isProjectionMode()); } - + } - + private ProjectionViewer fViewer; private IProjectionListener fProjectionListener; - + private TextOperationAction fToggle; private TextOperationAction fExpand; private TextOperationAction fCollapse; private TextOperationAction fExpandAll; - + // since 4.0 private TextOperationAction fCollapseAll; private PreferenceAction fRestoreDefaults; - + /** * Creates a new projection action group for editor. If the * supplied viewer is not an instance of ProjectionViewer, the * action group is disabled. - * + * * @param editor the text editor to operate on * @param viewer the viewer of the editor */ @@ -87,28 +88,30 @@ public class FoldingActionGroup extends ActionGroup { fProjectionListener= null; return; } - + fViewer= (ProjectionViewer) viewer; - + fProjectionListener= new IProjectionListener() { + @Override public void projectionEnabled() { update(); } + @Override public void projectionDisabled() { update(); } }; - + fViewer.addProjectionListener(fProjectionListener); - + fToggle= new TextOperationAction(FoldingMessages.getResourceBundle(), "Projection.Toggle.", editor, ProjectionViewer.TOGGLE, true); //$NON-NLS-1$ fToggle.setActionDefinitionId(IFoldingCommandIds.FOLDING_TOGGLE); editor.setAction("FoldingToggle", fToggle); //$NON-NLS-1$ - + fExpandAll= new TextOperationAction(FoldingMessages.getResourceBundle(), "Projection.ExpandAll.", editor, ProjectionViewer.EXPAND_ALL, true); //$NON-NLS-1$ fExpandAll.setActionDefinitionId(IFoldingCommandIds.FOLDING_EXPAND_ALL); editor.setAction("FoldingExpandAll", fExpandAll); //$NON-NLS-1$ - + fCollapseAll= new TextOperationAction(FoldingMessages.getResourceBundle(), "Projection.CollapseAll.", editor, ProjectionViewer.COLLAPSE_ALL, true); //$NON-NLS-1$ fCollapseAll.setActionDefinitionId(IFoldingCommandIds.FOLDING_COLLAPSE_ALL); editor.setAction("FoldingCollapseAll", fCollapseAll); //$NON-NLS-1$ @@ -116,7 +119,7 @@ public class FoldingActionGroup extends ActionGroup { fExpand= new TextOperationAction(FoldingMessages.getResourceBundle(), "Projection.Expand.", editor, ProjectionViewer.EXPAND, true); //$NON-NLS-1$ fExpand.setActionDefinitionId(IFoldingCommandIds.FOLDING_EXPAND); editor.setAction("FoldingExpand", fExpand); //$NON-NLS-1$ - + fCollapse= new TextOperationAction(FoldingMessages.getResourceBundle(), "Projection.Collapse.", editor, ProjectionViewer.COLLAPSE, true); //$NON-NLS-1$ fCollapse.setActionDefinitionId(IFoldingCommandIds.FOLDING_COLLAPSE); editor.setAction("FoldingCollapse", fCollapse); //$NON-NLS-1$ @@ -133,19 +136,19 @@ public class FoldingActionGroup extends ActionGroup { fRestoreDefaults.setActionDefinitionId(IFoldingCommandIds.FOLDING_RESTORE); editor.setAction("FoldingRestore", fRestoreDefaults); //$NON-NLS-1$ } - + /** - * Returns true if the group is enabled. + * Returns true if the group is enabled. *
 	 * Invariant: isEnabled() <=> fViewer and all actions are != null.
 	 * 
- * + * * @return true if the group is enabled */ protected boolean isEnabled() { return fViewer != null; } - + /* * @see org.eclipse.ui.actions.ActionGroup#dispose() */ @@ -157,7 +160,7 @@ public class FoldingActionGroup extends ActionGroup { } super.dispose(); } - + /** * Updates the actions. */ @@ -172,10 +175,10 @@ public class FoldingActionGroup extends ActionGroup { fRestoreDefaults.update(); } } - + /** * Fills the menu with all folding actions. - * + * * @param manager the menu manager for the folding submenu */ public void fillMenu(IMenuManager manager) { @@ -189,7 +192,7 @@ public class FoldingActionGroup extends ActionGroup { manager.add(fRestoreDefaults); } } - + /* * @see org.eclipse.ui.actions.ActionGroup#updateActionBars() */ diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/GotoNextBookmarkAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/GotoNextBookmarkAction.java index a0419048dd5..99078e87d47 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/GotoNextBookmarkAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/GotoNextBookmarkAction.java @@ -38,6 +38,7 @@ public class GotoNextBookmarkAction extends TextEditorAction { * Private class to handle comparison of markers using their line numbers. */ private class CompareMarker implements Comparator { + @Override public int compare(IMarker m1, IMarker m2) { int l1 = MarkerUtilities.getLineNumber(m1); int l2 = MarkerUtilities.getLineNumber(m2); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/IndentAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/IndentAction.java index df58e6d0375..49ddef1832c 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/IndentAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/IndentAction.java @@ -57,24 +57,24 @@ import org.eclipse.cdt.internal.ui.util.EditorUtility; * AST must be present, the indentation is computed using heuristics. The algorithm used is fast for * single lines, but does not store any information and therefore not so efficient for large line * ranges. - * + * * @see org.eclipse.cdt.internal.ui.text.CHeuristicScanner * @see org.eclipse.cdt.internal.ui.text.CIndenter */ public class IndentAction extends TextEditorAction { - + /** The caret offset after an indent operation. */ private int fCaretOffset; - + /** * Whether this is the action invoked by TAB. When true, indentation behaves * differently to accommodate normal TAB operation. */ private final boolean fIsTabAction; - + /** * Creates a new instance. - * + * * @param bundle the resource bundle * @param prefix the prefix to use for keys in bundle * @param editor the text editor @@ -84,7 +84,7 @@ public class IndentAction extends TextEditorAction { super(bundle, prefix, editor); fIsTabAction= isTabAction; } - + /* * @see org.eclipse.jface.action.Action#run() */ @@ -93,17 +93,17 @@ public class IndentAction extends TextEditorAction { // update has been called by the framework if (!isEnabled() || !validateEditorInputState()) return; - + ITextSelection selection= getSelection(); final IDocument document= getDocument(); - + if (document != null) { final int offset= selection.getOffset(); final int length= selection.getLength(); final Position end= new Position(offset + length); final int firstLine, nLines; fCaretOffset= -1; - + try { firstLine= document.getLineOfOffset(offset); // check for marginal (zero-length) lines @@ -115,13 +115,14 @@ public class IndentAction extends TextEditorAction { CUIPlugin.log(new Status(IStatus.ERROR, CUIPlugin.getPluginId(), IStatus.OK, "", e)); //$NON-NLS-1$ return; } - + Runnable runnable= new Runnable() { + @Override public void run() { IRewriteTarget target= (IRewriteTarget)getTextEditor().getAdapter(IRewriteTarget.class); if (target != null) target.beginCompoundChange(); - + try { CHeuristicScanner scanner= new CHeuristicScanner(document); CIndenter indenter= new CIndenter(document, scanner, getCProject()); @@ -130,7 +131,7 @@ public class IndentAction extends TextEditorAction { for (int i= 0; i < nLines; i++) { hasChanged |= indentLine(document, firstLine + i, offset, indenter, scanner, multiLine); } - + // update caret position: move to new position when indenting just one line // keep selection when indenting multiple int newOffset, newLength; @@ -141,12 +142,12 @@ public class IndentAction extends TextEditorAction { newOffset= fCaretOffset; newLength= 0; } - + // always reset the selection if anything was replaced // but not when we had a single line non-tab invocation if (newOffset != -1 && (hasChanged || newOffset != offset || newLength != length)) selectAndReveal(newOffset, newLength); - + } catch (BadLocationException e) { // will only happen on concurrent modification CUIPlugin.log(new Status(IStatus.ERROR, CUIPlugin.getPluginId(), IStatus.OK, "ConcurrentModification in IndentAction", e)); //$NON-NLS-1$ @@ -157,7 +158,7 @@ public class IndentAction extends TextEditorAction { } } }; - + if (nLines > 50) { Display display= getTextEditor().getEditorSite().getWorkbenchWindow().getShell().getDisplay(); BusyIndicator.showWhile(display, runnable); @@ -166,10 +167,10 @@ public class IndentAction extends TextEditorAction { } } } - + /** * Selects the given range on the editor. - * + * * @param newOffset the selection offset * @param newLength the selection range */ @@ -190,7 +191,7 @@ public class IndentAction extends TextEditorAction { /** * Indents a single line using the heuristic scanner. Multiline comments are * indented as specified by the CCommentAutoIndentStrategy. - * + * * @param document the document * @param line the line to be indented * @param caret the caret position @@ -204,7 +205,7 @@ public class IndentAction extends TextEditorAction { IRegion currentLine= document.getLineInformation(line); int offset= currentLine.getOffset(); int wsStart= offset; // where we start searching for non-WS; after the "//" in single line comments - + String indent= null; if (offset < document.getLength()) { ITypedRegion partition= TextUtilities.getPartition(document, ICPartitions.C_PARTITIONING, offset, true); @@ -224,9 +225,9 @@ public class IndentAction extends TextEditorAction { int slashes= 2; while (slashes < max - 1 && document.get(offset + slashes, 2).equals("//")) //$NON-NLS-1$ slashes+= 2; - + wsStart= offset + slashes; - + StringBuilder computed= indenter.computeIndentation(offset); if (computed == null) computed= new StringBuilder(0); @@ -243,15 +244,15 @@ public class IndentAction extends TextEditorAction { } else { break; } - + computed.deleteCharAt(0); } - + indent= document.get(offset, wsStart - offset) + computed; } } } - + // standard C code indentation if (indent == null) { StringBuilder computed= indenter.computeIndentation(offset); @@ -260,7 +261,7 @@ public class IndentAction extends TextEditorAction { else indent= ""; //$NON-NLS-1$ } - + // change document: // get current white space int lineLength= currentLine.getLength(); @@ -273,7 +274,7 @@ public class IndentAction extends TextEditorAction { } int length= end - offset; String currentIndent= document.get(offset, length); - + // if we are right before the text start / line end, and already after the insertion point // then just shift to the right if (fIsTabAction && caret == end && whiteSpaceLength(currentIndent) >= whiteSpaceLength(indent)) { @@ -286,13 +287,13 @@ public class IndentAction extends TextEditorAction { fCaretOffset= offset + replacement.length(); return true; } - + // set the caret offset so it can be used when setting the selection if (caret >= offset && caret <= end) fCaretOffset= offset + indent.length(); else fCaretOffset= -1; - + // only change the document if it is a real change if (!indent.equals(currentIndent)) { document.replace(offset, length, indent); @@ -303,7 +304,7 @@ public class IndentAction extends TextEditorAction { /** * Strip trailing space characters. - * + * * @param indent * @return string with trailing spaces removed */ @@ -317,7 +318,7 @@ public class IndentAction extends TextEditorAction { /** * Computes and returns the indentation for a block comment line. - * + * * @param document the document * @param line the line in document * @param scanner the scanner @@ -328,10 +329,10 @@ public class IndentAction extends TextEditorAction { private String computeCommentIndent(IDocument document, int line, CHeuristicScanner scanner, ITypedRegion partition) throws BadLocationException { return IndentUtil.computeCommentIndent(document, line, scanner, partition); } - + /** * Computes and returns the indentation for a preprocessor line. - * + * * @param document the document * @param line the line in document * @param partition the comment partition @@ -341,11 +342,11 @@ public class IndentAction extends TextEditorAction { private String computePreprocessorIndent(IDocument document, int line, ITypedRegion partition) throws BadLocationException { return IndentUtil.computePreprocessorIndent(document, line, partition); } - + /** * Returns the size in characters of a string. All characters count one, tabs count the editor's * preference for the tab display - * + * * @param indent the string to be measured. * @return the size in characters of a string */ @@ -358,27 +359,27 @@ public class IndentAction extends TextEditorAction { /** * Returns whether spaces should be used exclusively for indentation, depending on the editor and * formatter preferences. - * + * * @return true if only spaces should be used */ private boolean useSpaces() { return CCorePlugin.SPACE.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR)); } - + /** * Returns whether mixed tabs/spaces should be used for indentation, depending on the editor and * formatter preferences. - * + * * @return true if tabs and spaces should be used */ private boolean useTabsAndSpaces() { return DefaultCodeFormatterConstants.MIXED.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR)); } - + /** * Returns the tab size used by the editor, which is deduced from the * formatter preferences. - * + * * @return the tab size as defined in the current formatter preferences */ private int getTabSize() { @@ -388,7 +389,7 @@ public class IndentAction extends TextEditorAction { /** * Returns the indent size used by the editor, which is deduced from the * formatter preferences. - * + * * @return the indent size as defined in the current formatter preferences */ private int getIndentSize() { @@ -397,25 +398,25 @@ public class IndentAction extends TextEditorAction { /** * Returns true if empty lines should be indented, false otherwise. - * + * * @return true if empty lines should be indented, false otherwise */ private boolean indentEmptyLines() { return DefaultCodeFormatterConstants.TRUE.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_EMPTY_LINES)); } - + /** * Returns true if line comments at column 0 should be indented inside, false otherwise. - * + * * @return true if line comments at column 0 should be indented inside, false otherwise. */ private boolean indentInsideLineComments() { return DefaultCodeFormatterConstants.TRUE.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_INSIDE_LINE_COMMENTS)); } - + /** * Returns the possibly project-specific core preference defined under key. - * + * * @param key the key of the preference * @return the value of the preference */ @@ -429,7 +430,7 @@ public class IndentAction extends TextEditorAction { /** * Returns the possibly project-specific core preference defined under key, or * def if the value is not a integer. - * + * * @param key the key of the preference * @param def the default value * @return the value of the preference @@ -445,7 +446,7 @@ public class IndentAction extends TextEditorAction { /** * Returns the ICProject of the current editor input, or * null if it cannot be found. - * + * * @return the ICProject of the current editor input, or * null if it cannot be found */ @@ -453,13 +454,13 @@ public class IndentAction extends TextEditorAction { ITextEditor editor= getTextEditor(); if (editor == null) return null; - + return EditorUtility.getCProject(editor.getEditorInput()); } /** * Returns the editor's selection provider. - * + * * @return the editor's selection provider or null */ private ISelectionProvider getSelectionProvider() { @@ -469,14 +470,14 @@ public class IndentAction extends TextEditorAction { } return null; } - + /* * @see org.eclipse.ui.texteditor.IUpdate#update() */ @Override public void update() { super.update(); - + if (isEnabled()) { if (fIsTabAction) setEnabled(canModifyEditor() && isSmartMode() && isValidSelection()); @@ -484,29 +485,29 @@ public class IndentAction extends TextEditorAction { setEnabled(canModifyEditor() && !getSelection().isEmpty()); } } - + /** * Returns if the current selection is valid, i.e. whether it is empty and the caret in the * whitespace at the start of a line, or covers multiple lines. - * + * * @return true if the selection is valid for an indent operation */ private boolean isValidSelection() { ITextSelection selection= getSelection(); if (selection.isEmpty()) return false; - + int offset= selection.getOffset(); int length= selection.getLength(); - + IDocument document= getDocument(); if (document == null) return false; - + try { IRegion firstLine= document.getLineInformationOfOffset(offset); int lineOffset= firstLine.getOffset(); - + // either the selection has to be empty and the caret in the WS at the line start // or the selection has to extend over multiple lines if (length == 0) { @@ -516,28 +517,28 @@ public class IndentAction extends TextEditorAction { return false; // only enable for empty selections for now } catch (BadLocationException e) { } - + return false; } - + /** * Returns the smart preference state. - * + * * @return true if smart mode is on, false otherwise */ private boolean isSmartMode() { ITextEditor editor= getTextEditor(); - + if (editor instanceof ITextEditorExtension3) return ((ITextEditorExtension3) editor).getInsertMode() == ITextEditorExtension3.SMART_INSERT; - + return false; } - + /** * Returns the document currently displayed in the editor, or null if none can be * obtained. - * + * * @return the current document or null */ private IDocument getDocument() { @@ -547,15 +548,15 @@ public class IndentAction extends TextEditorAction { IEditorInput input= editor.getEditorInput(); if (provider != null && input != null) return provider.getDocument(input); - + } return null; } - + /** * Returns the selection on the editor or an invalid selection if none can be obtained. Returns * never null. - * + * * @return the current selection, never null */ private ITextSelection getSelection() { @@ -565,7 +566,7 @@ public class IndentAction extends TextEditorAction { if (selection instanceof ITextSelection) return (ITextSelection) selection; } - + // null object return TextSelection.emptySelection(); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/RebuildIndexAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/RebuildIndexAction.java index a9300c61b4e..232c32e1ecc 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/RebuildIndexAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/RebuildIndexAction.java @@ -7,7 +7,7 @@ * * Contributors: * Markus Schorn - initial API and implementation - *******************************************************************************/ + *******************************************************************************/ package org.eclipse.cdt.internal.ui.actions; @@ -27,9 +27,11 @@ public class RebuildIndexAction implements IObjectActionDelegate { private ISelection fSelection; + @Override public void setActivePart(IAction action, IWorkbenchPart targetPart) { } - + + @Override public void run(IAction action) { IStructuredSelection cElements= SelectionConverter.convertSelectionToCElements(fSelection); for (Iterator i = cElements.iterator(); i.hasNext();) { @@ -39,10 +41,11 @@ public class RebuildIndexAction implements IObjectActionDelegate { } } } - + /** * @see IActionDelegate#selectionChanged(IAction, ISelection) */ + @Override public void selectionChanged(IAction action, ISelection selection) { fSelection= selection; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SurroundWithActionGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SurroundWithActionGroup.java index 087b44ef3e5..e8e78afb963 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SurroundWithActionGroup.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SurroundWithActionGroup.java @@ -15,10 +15,11 @@ import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.text.ITextSelection; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.text.ITextSelection; import org.eclipse.ui.actions.ActionGroup; + import org.eclipse.cdt.internal.ui.editor.CEditor; public class SurroundWithActionGroup extends ActionGroup { @@ -56,6 +57,7 @@ public class SurroundWithActionGroup extends ActionGroup { menu.appendToGroup(fGroup, subMenu); subMenu.add(new Action() {}); subMenu.addMenuListener(new IMenuListener() { + @Override public void menuAboutToShow(IMenuManager manager) { manager.removeAll(); SurroundWithTemplateMenuAction.fillMenu(manager, fEditor); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SurroundWithTemplateMenuAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SurroundWithTemplateMenuAction.java index 470af5a13fa..770375a7477 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SurroundWithTemplateMenuAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SurroundWithTemplateMenuAction.java @@ -15,24 +15,12 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import org.eclipse.swt.events.MenuAdapter; -import org.eclipse.swt.events.MenuEvent; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.swt.widgets.MenuItem; -import org.eclipse.swt.widgets.Shell; - import org.eclipse.core.runtime.Assert; - import org.eclipse.jface.action.Action; import org.eclipse.jface.action.ActionContributionItem; import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.Separator; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionProvider; - import org.eclipse.jface.text.DocumentEvent; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IEditingSupport; @@ -44,7 +32,15 @@ import org.eclipse.jface.text.ITextViewer; import org.eclipse.jface.text.ITextViewerExtension; import org.eclipse.jface.text.contentassist.ICompletionProposal; import org.eclipse.jface.text.contentassist.ICompletionProposalExtension2; - +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.ISelectionProvider; +import org.eclipse.swt.events.MenuAdapter; +import org.eclipse.swt.events.MenuEvent; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Menu; +import org.eclipse.swt.widgets.MenuItem; +import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IPartListener; import org.eclipse.ui.IPartService; import org.eclipse.ui.IWorkbenchPart; @@ -55,6 +51,7 @@ import org.eclipse.ui.dialogs.PreferencesUtil; import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.ui.CUIPlugin; + import org.eclipse.cdt.internal.ui.editor.CEditor; import org.eclipse.cdt.internal.ui.text.contentassist.CContentAssistInvocationContext; import org.eclipse.cdt.internal.ui.text.contentassist.TemplateCompletionProposalComputer; @@ -68,7 +65,7 @@ public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownD private static final String TEMPLATE_GROUP= "templateGroup"; //$NON-NLS-1$ private static final String CONFIG_GROUP= "configGroup"; //$NON-NLS-1$ - + private static class ConfigureTemplatesAction extends Action { public ConfigureTemplatesAction() { @@ -103,19 +100,24 @@ public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownD private IPartService fPartService; private IPartListener fPartListener= new IPartListener() { + @Override public void partActivated(IWorkbenchPart part) { } + @Override public void partBroughtToTop(IWorkbenchPart part) { } + @Override public void partClosed(IWorkbenchPart part) { } + @Override public void partDeactivated(IWorkbenchPart part) { disposeMenuItems(); } + @Override public void partOpened(IWorkbenchPart part) { } }; @@ -136,6 +138,7 @@ public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownD /** * {@inheritDoc} */ + @Override public Menu getMenu(Menu parent) { setMenu(new Menu(parent)); fillMenu(fMenu); @@ -146,6 +149,7 @@ public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownD /** * {@inheritDoc} */ + @Override public Menu getMenu(Control parent) { setMenu(new Menu(parent)); fillMenu(fMenu); @@ -170,6 +174,7 @@ public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownD /** * {@inheritDoc} */ + @Override public void dispose() { if (fPartService != null) { fPartService.removePartListener(fPartListener); @@ -181,6 +186,7 @@ public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownD /** * {@inheritDoc} */ + @Override public void init(IWorkbenchWindow window) { if (fPartService != null) { fPartService.removePartListener(fPartListener); @@ -199,6 +205,7 @@ public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownD /** * {@inheritDoc} */ + @Override public void run(IAction action) { IWorkbenchPart activePart= CUIPlugin.getActivePage().getActivePart(); if (!(activePart instanceof CEditor)) @@ -217,6 +224,7 @@ public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownD /** * {@inheritDoc} */ + @Override public void selectionChanged(IAction action, ISelection selection) { // Default do nothing } @@ -280,18 +288,18 @@ public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownD ITextSelection textSelection= getTextSelection(editor); if (textSelection == null || textSelection.getLength() == 0) return null; - + ITranslationUnit tu= CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput()); if (tu == null) return null; TemplateCompletionProposalComputer templateComputer = new TemplateCompletionProposalComputer(); CContentAssistInvocationContext context = new CContentAssistInvocationContext( editor.getViewer(), textSelection.getOffset(), editor, true, false ); - + List proposals= templateComputer.computeCompletionProposals(context, null); if (proposals == null || proposals.isEmpty()) return null; - + return getActionsFromProposals(proposals, context.getInvocationOffset(), editor.getViewer()); } @@ -344,10 +352,12 @@ public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownD IEditingSupportRegistry registry= null; IEditingSupport helper= new IEditingSupport() { + @Override public boolean isOriginator(DocumentEvent event, IRegion focus) { return focus.getOffset() <= offset && focus.getOffset() + focus.getLength() >= offset; } + @Override public boolean ownsFocusShell() { return false; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/WorkbenchRunnableAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/WorkbenchRunnableAdapter.java index c7ac58952b9..3c5841e387f 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/WorkbenchRunnableAdapter.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/WorkbenchRunnableAdapter.java @@ -12,8 +12,6 @@ package org.eclipse.cdt.internal.ui.actions; import java.lang.reflect.InvocationTargetException; -import org.eclipse.cdt.core.model.CoreModel; -import org.eclipse.cdt.internal.ui.CUIStatus; import org.eclipse.core.resources.IWorkspaceRunnable; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; @@ -23,27 +21,30 @@ import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.ISchedulingRule; import org.eclipse.core.runtime.jobs.Job; - import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.operation.IThreadListener; +import org.eclipse.cdt.core.model.CoreModel; + +import org.eclipse.cdt.internal.ui.CUIStatus; + /** * An IRunnableWithProgress that adapts and IWorkspaceRunnable - * so that is can be executed inside IRunnableContext. OperationCanceledException + * so that is can be executed inside IRunnableContext. OperationCanceledException * thrown by the adapted runnable are caught and re-thrown as a InterruptedException. */ public class WorkbenchRunnableAdapter implements IRunnableWithProgress, IThreadListener { private IWorkspaceRunnable fWorkspaceRunnable; private ISchedulingRule fRule; private boolean fTransfer; - + /** * Runs a workspace runnable with the workspace lock. */ public WorkbenchRunnableAdapter(IWorkspaceRunnable runnable) { this(runnable, ResourcesPlugin.getWorkspace().getRoot()); } - + /** * Runs a workspace runnable with the given lock or null to run with no lock at all. */ @@ -51,11 +52,11 @@ public class WorkbenchRunnableAdapter implements IRunnableWithProgress, IThreadL fWorkspaceRunnable= runnable; fRule= rule; } - + /** * Runs a workspace runnable with the given lock or null to run with no lock at * all. - * + * * @param runnable the runnable * @param rule the scheduling rule, or null * @param transfer true iff the rule is to be transfered to the modal context @@ -71,6 +72,7 @@ public class WorkbenchRunnableAdapter implements IRunnableWithProgress, IThreadL return fRule; } + @Override public void threadChange(Thread thread) { if (fTransfer) Job.getJobManager().transferRule(fRule, thread); @@ -79,6 +81,7 @@ public class WorkbenchRunnableAdapter implements IRunnableWithProgress, IThreadL /* * @see IRunnableWithProgress#run(IProgressMonitor) */ + @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { CoreModel.run(fWorkspaceRunnable, fRule, monitor); @@ -88,9 +91,9 @@ public class WorkbenchRunnableAdapter implements IRunnableWithProgress, IThreadL throw new InvocationTargetException(e); } } - + public void runAsUserJob(String name, final Object jobFamiliy) { - Job buildJob = new Job(name){ + Job buildJob = new Job(name){ /* (non-Javadoc) * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor) */ @@ -117,9 +120,9 @@ public class WorkbenchRunnableAdapter implements IRunnableWithProgress, IThreadL } }; buildJob.setRule(fRule); - buildJob.setUser(true); + buildJob.setUser(true); buildJob.schedule(); - + // TODO: should block until user pressed 'to background' } }