| author | szarnekow | 2009-02-13 05:00:50 (EST) |
|---|---|---|
| committer | sefftinge | 2009-02-13 05:00:50 (EST) |
| commit | 0a27ae9927c4fd791e3f2caaea251577a6c812e4 (patch) (side-by-side diff) | |
| tree | a01b75b5c7c02386780c3dfd6c946e995cfcbf69 | |
| parent | fae8e4f834d8f1a42145739371468022a8f4d1b6 (diff) | |
| download | org.eclipse.xtext-0a27ae9927c4fd791e3f2caaea251577a6c812e4.zip org.eclipse.xtext-0a27ae9927c4fd791e3f2caaea251577a6c812e4.tar.gz org.eclipse.xtext-0a27ae9927c4fd791e3f2caaea251577a6c812e4.tar.bz2 | |
Housekeeping: removed a bunch of eclipse warnings, added copyright notice
15 files changed, 149 insertions, 120 deletions
diff --git a/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/ContentAssistContextFactory.java b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/ContentAssistContextFactory.java index b548038..163b347 100644 --- a/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/ContentAssistContextFactory.java +++ b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/ContentAssistContextFactory.java @@ -1,3 +1,11 @@ +/******************************************************************************* + * Copyright (c) 2008 itemis AG (http://www.itemis.eu) 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 + * + *******************************************************************************/ package org.eclipse.xtext.ui.common.editor.contentassist.impl; import org.eclipse.core.runtime.Assert; @@ -14,18 +22,17 @@ public class ContentAssistContextFactory { public static IContentAssistContext create(XtextResource resource, int offset, String prefix) { IParseResult parseResult = resource.getParseResult(); Assert.isNotNull(parseResult); - + CompositeNode rootNode = parseResult.getRootNode(); - + AbstractNode referenceNode = ParseTreeUtil.getLastCompleteNodeByOffset(rootNode, offset); - - EObject model = (referenceNode instanceof AbstractNode ? NodeUtil - .getNearestSemanticObject((AbstractNode) referenceNode) : referenceNode); - + + EObject model = NodeUtil.getNearestSemanticObject(referenceNode); + AbstractNode node = ParseTreeUtil.getCurrentOrFollowingNodeByOffset(rootNode, offset); - + return new ContentAssistContext(model, offset, prefix, node, referenceNode, rootNode); } - + } diff --git a/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/DefaultContentAssistCalculator.java b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/DefaultContentAssistCalculator.java index 84cb091..3fd3fca 100644 --- a/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/DefaultContentAssistCalculator.java +++ b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/DefaultContentAssistCalculator.java @@ -41,13 +41,13 @@ import org.eclipse.xtext.util.XtextSwitch; import com.google.inject.Inject; /** - * Provides a default implementation of interface {@link IContentAssistContext} designed as <b>Switch</b> over the - * Xtext ecore inheritance hierarchy to calculate and resolve (or flatten) 'container' level elements like + * Provides a default implementation of interface {@link IContentAssistContext} designed as <b>Switch</b> over the + * Xtext ecore inheritance hierarchy to calculate and resolve (or flatten) 'container' level elements like * <code>Group</code> or <code>Alternatives</code> to gather potential completion proposal candidates. - * + * * It supports the call {@link #doSwitch(EObject) doSwitch(object)} instead of * typical <code>if (x instanceof y)</code> code blocks. - * + * * @author Michael Clay - Initial contribution and API * @see org.eclipse.xtext.util.XtextSwitch */ @@ -55,13 +55,13 @@ public class DefaultContentAssistCalculator extends XtextSwitch<List<AbstractEle @Inject private ILinkingService linkingService; - + public List<AbstractElement> computeProposalElements(IContentAssistContext contentAssistContext) { - + List<AbstractElement> computedElementList = new ArrayList<AbstractElement>(); - + Set<AbstractElement> nextValidElementSet = new LinkedHashSet<AbstractElement>(); - + AbstractNode referenceNode=contentAssistContext.getReferenceNode(); /** * in case of a cross reference which isn't linked properly we evaluate or @@ -71,14 +71,14 @@ public class DefaultContentAssistCalculator extends XtextSwitch<List<AbstractEle nextValidElementSet.add(getAbstractElement(referenceNode)); nextValidElementSet.addAll(ParseTreeUtil.getElementSetValidFromOffset(contentAssistContext.getRootNode(), referenceNode, contentAssistContext.getOffSet())); - } - /** - * in case of 'at-the-end' of the previous,completed element we evaluate - * it again for 'right-to-left-backtracking' cases (e.g. for keyword - * 'kind' kind>|< |=cursorpos) - */ - else if (referenceNode == contentAssistContext.getNode()) { - + } else if (referenceNode == contentAssistContext.getNode()) { + if (referenceNode == null) + throw new NullPointerException("Unexpected: referenceNode is null."); + /** + * in case of 'at-the-end' of the previous,completed element we evaluate + * it again for 'right-to-left-backtracking' cases (e.g. for keyword + * 'kind' kind>|< |=cursorpos) + */ Assignment containingAssignment = GrammarUtil.containingAssignment(referenceNode.getGrammarElement()); if (referenceNode.getGrammarElement() instanceof RuleCall && containingAssignment != null) { @@ -101,10 +101,10 @@ public class DefaultContentAssistCalculator extends XtextSwitch<List<AbstractEle AbstractElement abstractElement = iterator.next(); computedElementList.addAll(doSwitch(abstractElement)); } - + return computedElementList; } - + @Override public List<AbstractElement> caseAlternatives(Alternatives alternatives) { @@ -145,7 +145,7 @@ public class DefaultContentAssistCalculator extends XtextSwitch<List<AbstractEle @Override public List<AbstractElement> caseRuleCall(RuleCall ruleCall) { List<AbstractElement> elementList = new ArrayList<AbstractElement>(); - + elementList.add(ruleCall); AbstractRule abstractRule = ruleCall.getRule(); @@ -155,7 +155,7 @@ public class DefaultContentAssistCalculator extends XtextSwitch<List<AbstractEle } return elementList; } - + @Override public List<AbstractElement> caseCrossReference(CrossReference crossReference) { return Collections.singletonList(((AbstractElement)crossReference.eContainer())); @@ -171,12 +171,12 @@ public class DefaultContentAssistCalculator extends XtextSwitch<List<AbstractEle source.addAll(list); } } - + private AbstractElement getAbstractElement(AbstractNode lastCompleteNode) { return (AbstractElement) (lastCompleteNode.getGrammarElement() instanceof ParserRule ? ((ParserRule)lastCompleteNode.getGrammarElement()).getAlternatives(): lastCompleteNode.getGrammarElement()); } - + private boolean isLinked(AbstractNode lastCompleteNode) { EObject semanticModel = NodeUtil.getNearestSemanticObject(lastCompleteNode); CrossReference crossReference = (CrossReference) lastCompleteNode.getGrammarElement(); @@ -193,10 +193,10 @@ public class DefaultContentAssistCalculator extends XtextSwitch<List<AbstractEle return false; } } - + private boolean isOptional(AbstractElement groupElement) { boolean isOptional = true; - + if ((groupElement instanceof Group || groupElement instanceof Alternatives) && !GrammarUtil.isOptionalCardinality(groupElement)) { EList<AbstractElement> abstractTokens = groupElement instanceof Group ? ((Group) groupElement) @@ -213,5 +213,5 @@ public class DefaultContentAssistCalculator extends XtextSwitch<List<AbstractEle return isOptional; } - + } diff --git a/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/DefaultContentAssistProcessor.java b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/DefaultContentAssistProcessor.java index 2f1f192..c702f96 100644 --- a/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/DefaultContentAssistProcessor.java +++ b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/DefaultContentAssistProcessor.java @@ -48,7 +48,7 @@ import com.google.inject.Inject; /** * The default implementation of interface {@link IContentAssistProcessor} provided with Xtext. - * + * * @author Michael Clay - Initial contribution and API * @author Heiko Behrens * @author Jan Köhnlein @@ -57,16 +57,16 @@ public class DefaultContentAssistProcessor implements IContentAssistProcessor { // logger available to subclasses protected final Logger logger = Logger.getLogger(getClass()); - + @Inject protected ITemplateContentAssistProcessor templateContentAssistProcessor; @Inject protected IContentAssistCalculator contentAssistCalculator; - + @Inject protected IProposalProvider proposalProvider; - + /** * Computes the possible grammar elements following the one at the given offset and calls the respective methods on * the proposal provider. @@ -74,7 +74,7 @@ public class DefaultContentAssistProcessor implements IContentAssistProcessor { public ICompletionProposal[] computeCompletionProposals(final ITextViewer viewer, final int offset) { IXtextDocument document = (IXtextDocument) viewer.getDocument(); - + return document.readOnly(new UnitOfWork<ICompletionProposal[]>() { public ICompletionProposal[] exec(XtextResource resource) throws Exception { @@ -141,12 +141,12 @@ public class DefaultContentAssistProcessor implements IContentAssistProcessor { public IContextInformationValidator getContextInformationValidator() { return new ContextInformationValidator(this); } - - - + + + /** * adds templates to the list of proposals - * + * * @param viewer the viewer whose document is used to compute the proposals * @param offset an offset within the document for which completions should be computed * @param contentAssistContext the current context of the content assist proposal request @@ -162,7 +162,7 @@ public class DefaultContentAssistProcessor implements IContentAssistProcessor { viewer, offset))); } } - + protected List<ICompletionProposal> collectCompletionProposals(List<AbstractElement> computeProposalElements, IContentAssistContext contentAssistContext) { List<ICompletionProposal> completionProposalList = new ArrayList<ICompletionProposal>(); for (AbstractElement computeProposalElement : computeProposalElements) { @@ -184,7 +184,7 @@ public class DefaultContentAssistProcessor implements IContentAssistProcessor { } return completionProposalList; } - + protected List<TemplateContextType> collectTemplateContextTypes(List<AbstractElement> computeProposalElements, IContentAssistContext contentAssistContext) { List<TemplateContextType> templateContextTypes = new ArrayList<TemplateContextType>(); @@ -212,10 +212,10 @@ public class DefaultContentAssistProcessor implements IContentAssistProcessor { } return templateContextTypes; } - + /** * Creates a new <code>IContentAssistContext</code> with all required informations for the current CA request. - * + * * @param resource the underlying EMF resource to read (parse) from * @param viewer the viewer whose document is used to compute the proposals * @param offset an offset within the document for which the context should be created @@ -228,33 +228,32 @@ public class DefaultContentAssistProcessor implements IContentAssistProcessor { Assert.isNotNull(parseResult); CompositeNode rootNode = parseResult.getRootNode(); - + AbstractNode referenceNode = ParseTreeUtil.getLastCompleteNodeByOffset(rootNode, offset); - - EObject model = (referenceNode instanceof AbstractNode ? NodeUtil - .getNearestSemanticObject((AbstractNode) referenceNode) : referenceNode); - + + EObject model = NodeUtil.getNearestSemanticObject(referenceNode); + AbstractNode node = ParseTreeUtil.getCurrentOrFollowingNodeByOffset(rootNode, offset); String matchingString = node == null ? "" : calculateMatchString(viewer, offset, node); /** - * + * * if cursor is behind a complete keyword, accept any input => empty - * + * * TODO: Find a way to distinguish between keywords like "+" or "-" and * "extends" or "class" in the latter case, the prefix "" would not * always be sufficient - * + * XXX SZ: the formatter may help to answer this question */ - if (node.getGrammarElement() instanceof Keyword + if (node != null && node.getGrammarElement() instanceof Keyword && (node instanceof LeafNode && ((LeafNode) node).getText().equals(matchingString))) { matchingString = ""; } return new ContentAssistContext(model, offset, matchingString, node, referenceNode, rootNode); } - + /** * Calculates the match string of the current <code>IContentAssistContext</code> based on the * specified location within the text viewer. @@ -278,7 +277,7 @@ public class DefaultContentAssistProcessor implements IContentAssistProcessor { return prefix; } - + } diff --git a/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/XtextTemplateContextType.java b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/XtextTemplateContextType.java index 941f9cc..6728fd0 100644 --- a/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/XtextTemplateContextType.java +++ b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/XtextTemplateContextType.java @@ -23,9 +23,9 @@ import org.eclipse.xtext.IMetamodelAccess; import org.eclipse.xtext.crossref.IScopedElement; /** - * Provides a convenience base type for <code>TemplateContextType's</code> preconfigured with several handy - * Xtext <code>TemplateVariableResolver</code> . - * + * Provides a convenience base type for <code>TemplateContextType's</code> preconfigured with several handy + * Xtext <code>TemplateVariableResolver</code> . + * * @author Michael Clay - Initial contribution and API */ public class XtextTemplateContextType extends TemplateContextType { @@ -41,13 +41,14 @@ public class XtextTemplateContextType extends TemplateContextType { addResolver(new GlobalTemplateVariables.User()); addResolver(new GlobalTemplateVariables.Cursor()); } - + public static class CrossReferenceTemplateVariableResolver extends TemplateVariableResolver { - + public CrossReferenceTemplateVariableResolver() { super("CrossReference", "TemplateVariableResolver for CrossReferences"); } - + + @Override public void resolve(TemplateVariable variable, TemplateContext context) { XtextTemplateContext xtextTemplateContext = (XtextTemplateContext) context; @@ -68,7 +69,7 @@ public class XtextTemplateContextType extends TemplateContextType { names.add(scopedElement.name()); } - String[] bindings = (String[]) names.toArray(new String[] {}); + String[] bindings = names.toArray(new String[names.size()]); if (bindings.length != 0) variable.setValues(bindings); diff --git a/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/hover/XtextTextHover.java b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/hover/XtextTextHover.java index ac50300..08424ee 100644 --- a/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/hover/XtextTextHover.java +++ b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/hover/XtextTextHover.java @@ -17,6 +17,7 @@ import org.eclipse.jface.text.ITextViewer; */ public class XtextTextHover implements ITextHover { + @Deprecated public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) { // TODO Auto-generated method stub return null; diff --git a/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/outline/XtextContentOutlinePage.java b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/outline/XtextContentOutlinePage.java index 2d2e929..b4da639 100644 --- a/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/outline/XtextContentOutlinePage.java +++ b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/outline/XtextContentOutlinePage.java @@ -15,6 +15,7 @@ import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.source.ISourceViewer; +import org.eclipse.jface.viewers.AbstractTreeViewer; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TreeViewer; @@ -45,16 +46,16 @@ import com.google.inject.Inject; /** * An outline page for Xtext resources. - * + * * This class is not intended to be subclassed. It is designed to be configured * with a domain specific combined label and content provider (which is * automatically injected to the {@link #provider} field). - * + * * The outline page can synchronize itself with the associated editor. * Selections made in the outline will be propagated to the editor at any time, * whereas the synchronization from the editor to the outline can be controlled * by the user using the "Link with Editor" button. - * + * * @author Peter Friese - Initial contribution and API */ public class XtextContentOutlinePage extends LazyVirtualContentOutlinePage implements ISourceViewerAware { @@ -78,7 +79,7 @@ public class XtextContentOutlinePage extends LazyVirtualContentOutlinePage imple private void configureViewer() { TreeViewer viewer = getTreeViewer(); - viewer.setAutoExpandLevel(TreeViewer.ALL_LEVELS); + viewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS); } protected void configureProviders() { @@ -86,7 +87,7 @@ public class XtextContentOutlinePage extends LazyVirtualContentOutlinePage imple getTreeViewer().setContentProvider(provider); getTreeViewer().setLabelProvider(provider); } - + private void configureDocument() { if (sourceViewer != null) { IDocument document = sourceViewer.getDocument(); @@ -128,7 +129,7 @@ public class XtextContentOutlinePage extends LazyVirtualContentOutlinePage imple IToolBarManager toolBarManager = actionBars.getToolBarManager(); if (toolBarManager != null) { toolBarManager.add(new ToggleLinkWithEditorAction(this)); - + // sort button only available if provider offers sorting facilities if (provider instanceof ISortableContentProvider) { toolBarManager.add(new LexicalSortingAction(this)); diff --git a/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/outline/impl/DefaultSemanticModelTransformer.java b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/outline/impl/DefaultSemanticModelTransformer.java index d57ef1b..cba18ff 100644 --- a/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/outline/impl/DefaultSemanticModelTransformer.java +++ b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/outline/impl/DefaultSemanticModelTransformer.java @@ -22,17 +22,18 @@ import com.google.inject.Inject; * @author Peter Friese - Initial contribution and API */ public class DefaultSemanticModelTransformer extends AbstractSemanticModelTransformer { - + final static Logger logger = Logger.getLogger(AbstractSemanticModelTransformer.class); - - private ILocationInFileProvider locationProvider; - + + private final ILocationInFileProvider locationProvider; + @Inject public DefaultSemanticModelTransformer(ILocationInFileProvider locationProvider, ILabelProvider labelProvider) { super(labelProvider); this.locationProvider = locationProvider; } + @Override public boolean consumeSemanticNode(EObject semanticNode) { if (semanticNode != null) { String name = semanticNode.eClass().getName(); @@ -41,11 +42,10 @@ public class DefaultSemanticModelTransformer extends AbstractSemanticModelTransf } return true; } - else { - return false; - } + return false; } + @Override public boolean consumeSemanticChildNodes(EObject semanticNode) { if (semanticNode != null) { String name = semanticNode.eClass().getName(); @@ -54,11 +54,9 @@ public class DefaultSemanticModelTransformer extends AbstractSemanticModelTransf } return true; } - else { - return false; - } + return false; } - + @Override protected boolean doSortChildren(EObject semanticNode) { return false; @@ -89,14 +87,14 @@ public class DefaultSemanticModelTransformer extends AbstractSemanticModelTransf * able to get the corresponding ContentOutlineNode. This is needed e.g. * when we want to synch the outline with the currently selected editor * position. - * + * * XXX SZ: is this feasible? What if I want to create more than one one outline node * per semantic node? Can't we use the offset information of the outline node * and the editor to synchronize them? - * PF: Reason for using an adapter was to not need to traverse a (more or less) + * PF: Reason for using an adapter was to not need to traverse a (more or less) * large part the outline model when syncing the outline to the editor selection. - * However, SZ and I agreed on leaving it as-is and look into a tree traversal - * approach if we run into memory problems. + * However, SZ and I agreed on leaving it as-is and look into a tree traversal + * approach if we run into memory problems. */ ContentOutlineNodeAdapter outlineAdapter = (ContentOutlineNodeAdapter) ContentOutlineNodeAdapterFactory.INSTANCE .adapt(semanticNode, ContentOutlineNode.class); diff --git a/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/outline/impl/LazyVirtualContentOutlinePage.java b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/outline/impl/LazyVirtualContentOutlinePage.java index 38c0df9..aefa6e3 100644 --- a/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/outline/impl/LazyVirtualContentOutlinePage.java +++ b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/outline/impl/LazyVirtualContentOutlinePage.java @@ -1,3 +1,10 @@ +/******************************************************************************* + * Copyright (c) 2008 itemis AG (http://www.itemis.eu) 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 + *******************************************************************************/ package org.eclipse.xtext.ui.common.editor.outline.impl; import org.eclipse.core.runtime.ListenerList; @@ -25,22 +32,22 @@ import org.eclipse.ui.views.contentoutline.IContentOutlinePage; * This class should be subclassed. * </p> * <p> - * Internally, each content outline page consists of a standard tree viewer; - * selections made in the tree viewer are reported as selection change events - * by the page (which is a selection provider). The tree viewer is not created + * Internally, each content outline page consists of a standard tree viewer; + * selections made in the tree viewer are reported as selection change events + * by the page (which is a selection provider). The tree viewer is not created * until <code>createPage</code> is called; consequently, subclasses must extend - * <code>createControl</code> to configure the tree viewer with a proper content + * <code>createControl</code> to configure the tree viewer with a proper content * provider, label provider, and input element. * </p> * <p> * Note that those wanting to use a control other than internally created - * <code>TreeViewer</code> will need to implement + * <code>TreeViewer</code> will need to implement * <code>IContentOutlinePage</code> directly rather than subclassing this class. - * </p> + * </p> */ public abstract class LazyVirtualContentOutlinePage extends Page implements IContentOutlinePage, ISelectionChangedListener { - private ListenerList selectionChangedListeners = new ListenerList(); + private final ListenerList selectionChangedListeners = new ListenerList(); private TreeViewer treeViewer; @@ -59,13 +66,14 @@ public abstract class LazyVirtualContentOutlinePage extends Page implements } /** - * The <code>ContentOutlinePage</code> implementation of this + * The <code>ContentOutlinePage</code> implementation of this * <code>IContentOutlinePage</code> method creates a tree viewer. Subclasses - * must extend this method configure the tree viewer with a proper content + * must extend this method configure the tree viewer with a proper content * provider, label provider, and input element. * @param parent */ - public void createControl(Composite parent) { + @Override + public void createControl(Composite parent) { treeViewer = new TreeViewer(parent, SWT.VIRTUAL | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); treeViewer.addSelectionChangedListener(this); @@ -97,7 +105,8 @@ public abstract class LazyVirtualContentOutlinePage extends Page implements /* (non-Javadoc) * Method declared on IPage (and Page). */ - public Control getControl() { + @Override + public Control getControl() { if (treeViewer == null) { return null; } @@ -117,7 +126,7 @@ public abstract class LazyVirtualContentOutlinePage extends Page implements /** * Returns this page's tree viewer. * - * @return this page's tree viewer, or <code>null</code> if + * @return this page's tree viewer, or <code>null</code> if * <code>createControl</code> has not been called yet */ protected TreeViewer getTreeViewer() { @@ -128,7 +137,8 @@ public abstract class LazyVirtualContentOutlinePage extends Page implements * (non-Javadoc) * @see org.eclipse.ui.part.IPageBookViewPage#init(org.eclipse.ui.part.IPageSite) */ - public void init(IPageSite pageSite) { + @Override + public void init(IPageSite pageSite) { super.init(pageSite); pageSite.setSelectionProvider(this); } @@ -152,7 +162,8 @@ public abstract class LazyVirtualContentOutlinePage extends Page implements /** * Sets focus to a part in the page. */ - public void setFocus() { + @Override + public void setFocus() { treeViewer.getControl().setFocus(); } diff --git a/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/outline/impl/LexicalSortingAction.java b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/outline/impl/LexicalSortingAction.java index f395d4f..d8ae5fb 100644 --- a/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/outline/impl/LexicalSortingAction.java +++ b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/outline/impl/LexicalSortingAction.java @@ -1,3 +1,10 @@ +/******************************************************************************* + * Copyright (c) 2008 itemis AG (http://www.itemis.eu) 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 + *******************************************************************************/ package org.eclipse.xtext.ui.common.editor.outline.impl; import org.eclipse.jface.action.Action; @@ -23,15 +30,16 @@ public class LexicalSortingAction extends Action { valueChanged(checked, false); } + @Override public void run() { valueChanged(isChecked(), true); } - + private void valueChanged(final boolean on, boolean store) { setChecked(on); - + outlinePage.setSorted(on); - + if (store) { Activator.getDefault().getPreferenceStore().setValue("LexicalSortingAction.isChecked", on); //$NON-NLS-1$ } diff --git a/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/outline/impl/ToggleLinkWithEditorAction.java b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/outline/impl/ToggleLinkWithEditorAction.java index 121422d..a52fac0 100644 --- a/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/outline/impl/ToggleLinkWithEditorAction.java +++ b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/outline/impl/ToggleLinkWithEditorAction.java @@ -4,7 +4,6 @@ * 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 - * *******************************************************************************/ package org.eclipse.xtext.ui.common.editor.outline.impl; @@ -29,15 +28,16 @@ public class ToggleLinkWithEditorAction extends Action { setImageDescriptor(XtextPluginImages.DESC_LINK_WITH_EDITOR); setDisabledImageDescriptor(XtextPluginImages.DESC_LINK_WITH_EDITOR_DISABLED); } - + protected boolean isLinkingEnabled() { return outlinePage.isLinkingEnabled(); } - + protected void setLinkingEnabled(boolean enabled) { outlinePage.setLinkingEnabled(enabled); } + @Override public void run() { setLinkingEnabled(isChecked()); if (isLinkingEnabled()) { diff --git a/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/syntaxcoloring/EditorUtils.java b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/syntaxcoloring/EditorUtils.java index 8525c25..c448d71 100644 --- a/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/syntaxcoloring/EditorUtils.java +++ b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/syntaxcoloring/EditorUtils.java @@ -20,10 +20,10 @@ import org.eclipse.swt.graphics.RGB; /** * @author Dennis Hübner - Initial contribution and API - * + * */ public class EditorUtils { - + private static final Logger log = Logger.getLogger(EditorUtils.class); public static Font fontFromFontData(FontData[] fontDataArray) { @@ -36,7 +36,6 @@ public class EditorUtils { Font font = JFaceResources.getFontRegistry().get(fontData); return font; } - ; return null; } diff --git a/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/syntaxcoloring/PreferenceStoreAccessor.java b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/syntaxcoloring/PreferenceStoreAccessor.java index fb4c350..3a20b65 100644 --- a/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/syntaxcoloring/PreferenceStoreAccessor.java +++ b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/syntaxcoloring/PreferenceStoreAccessor.java @@ -22,8 +22,8 @@ import org.eclipse.swt.graphics.FontData; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.widgets.Display; import org.eclipse.ui.editors.text.EditorsUI; -import org.eclipse.ui.editors.text.TextEditor; import org.eclipse.ui.preferences.ScopedPreferenceStore; +import org.eclipse.ui.texteditor.AbstractTextEditor; import org.eclipse.xtext.Constants; import org.eclipse.xtext.ui.common.editor.preferencepage.CommonPreferenceConstants; import org.eclipse.xtext.ui.core.editor.utils.TextStyle; @@ -34,10 +34,9 @@ import com.google.inject.name.Named; /** * @author Dennis Hübner - Initial contribution and API - * */ public class PreferenceStoreAccessor { - private String PREFERENCE_TAG; + private final String PREFERENCE_TAG; private static ScopedPreferenceStore preferenceStore; @Inject @@ -61,13 +60,13 @@ public class PreferenceStoreAccessor { // DefaultDefault IPreferenceStore editorsStore = EditorsUI.getPreferenceStore(); - RGB fontColorDefaultDefault = editorsStore.getBoolean(TextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT) ? getDisplay() + RGB fontColorDefaultDefault = editorsStore.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT) ? getDisplay() .getSystemColor(SWT.COLOR_LIST_FOREGROUND).getRGB() - : PreferenceConverter.getColor(editorsStore, TextEditor.PREFERENCE_COLOR_FOREGROUND); + : PreferenceConverter.getColor(editorsStore, AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND); RGB backgrounColorDefaultDefault = editorsStore - .getBoolean(TextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT) ? getDisplay().getSystemColor( + .getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT) ? getDisplay().getSystemColor( SWT.COLOR_LIST_BACKGROUND).getRGB() : PreferenceConverter.getColor(editorsStore, - TextEditor.PREFERENCE_COLOR_BACKGROUND); + AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND); FontData[] fontDataDefaultDefault = JFaceResources.getTextFont().getFontData(); // set defaults diff --git a/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/syntaxcoloring/TokenTypeDefDetailsPart.java b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/syntaxcoloring/TokenTypeDefDetailsPart.java index cef2147..a8098d1 100644 --- a/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/syntaxcoloring/TokenTypeDefDetailsPart.java +++ b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/syntaxcoloring/TokenTypeDefDetailsPart.java @@ -42,6 +42,7 @@ public class TokenTypeDefDetailsPart extends AbstractDetailsPart { { "Italic", String.valueOf(SWT.ITALIC) }, { "Bold", String.valueOf(SWT.BOLD) }, { "Underline", String.valueOf(TextAttribute.UNDERLINE) }, { "Strike through", String.valueOf(TextAttribute.STRIKETHROUGH) }, }, getFieldEditorParent(), true) { + @Override protected String calculateResult(String[][] settings) { int result = SWT.NORMAL; for (int i = 0; i < settings.length; i++) { diff --git a/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/syntaxcoloring/TokenTypeDefMasterDetailFieldEditor.java b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/syntaxcoloring/TokenTypeDefMasterDetailFieldEditor.java index 15f0694..2e131fd 100644 --- a/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/syntaxcoloring/TokenTypeDefMasterDetailFieldEditor.java +++ b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/syntaxcoloring/TokenTypeDefMasterDetailFieldEditor.java @@ -17,7 +17,7 @@ import org.eclipse.xtext.ui.core.editor.preferences.fields.AbstractMasterDetails /** * @author Dennis Hübner - Initial contribution and API - * + * */ public class TokenTypeDefMasterDetailFieldEditor extends AbstractMasterDetailsFieldEditor { @@ -26,12 +26,14 @@ public class TokenTypeDefMasterDetailFieldEditor extends AbstractMasterDetailsFi super(name, labelText, composite, preferenceStore, list); } + @Override protected String label(Object object) { if (object instanceof ITokenStyle) return ((ITokenStyle) object).getName(); return object.toString(); } + @Override protected String identifier(Object object) { if (object instanceof ITokenStyle) return ((ITokenStyle) object).getID(); diff --git a/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/internal/Activator.java b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/internal/Activator.java index 0d798bb..8920e97 100644 --- a/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/internal/Activator.java +++ b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/internal/Activator.java @@ -11,9 +11,9 @@ public class Activator extends AbstractUIPlugin { // The plug-in ID public static final String PLUGIN_ID = "org.eclipse.xtext.ui.common"; - + private static Logger log = Logger.getLogger(Activator.class); - + // The shared instance private static Activator plugin; @@ -23,6 +23,7 @@ public class Activator extends AbstractUIPlugin { public Activator() { } + @Override public void start(BundleContext context) throws Exception { super.start(context); setDefault(this); @@ -35,6 +36,7 @@ public class Activator extends AbstractUIPlugin { plugin = activator; } + @Override public void stop(BundleContext context) throws Exception { log.debug("Stopping Xtext UI Common bundle."); setDefault(null); @@ -43,7 +45,7 @@ public class Activator extends AbstractUIPlugin { /** * Returns the shared instance - * + * * @return the shared instance */ public static Activator getDefault() { @@ -67,7 +69,7 @@ public class Activator extends AbstractUIPlugin { public static IWorkbenchWindow getActiveWorkbenchWindow() { return getDefault().getWorkbench().getActiveWorkbenchWindow(); } - + /** * Returns an image descriptor for the image file at the given * plug-in relative path |

