diff --git a/build/org.eclipse.cdt.make.ui/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.make.ui/META-INF/MANIFEST.MF index eab1be0f42e..33d4748fe5d 100644 --- a/build/org.eclipse.cdt.make.ui/META-INF/MANIFEST.MF +++ b/build/org.eclipse.cdt.make.ui/META-INF/MANIFEST.MF @@ -7,6 +7,7 @@ Bundle-Activator: org.eclipse.cdt.make.internal.ui.MakeUIPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin Export-Package: org.eclipse.cdt.make.internal.ui, + org.eclipse.cdt.make.internal.ui.compare, org.eclipse.cdt.make.internal.ui.editor, org.eclipse.cdt.make.internal.ui.part, org.eclipse.cdt.make.internal.ui.preferences, @@ -32,5 +33,6 @@ Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.2.0,4.0.0)", org.eclipse.cdt.make.core;bundle-version="[4.0.0,5.0.0)", org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)", org.eclipse.debug.ui;bundle-version="[3.2.0,4.0.0)", - org.eclipse.ui.navigator;bundle-version="[3.2.0,4.0.0)";resolution:=optional + org.eclipse.ui.navigator;bundle-version="[3.2.0,4.0.0)";resolution:=optional, + org.eclipse.compare;bundle-version="[3.3.0,4.0.0)" Eclipse-LazyStart: true diff --git a/build/org.eclipse.cdt.make.ui/plugin.xml b/build/org.eclipse.cdt.make.ui/plugin.xml index 0fda4f74001..4e006e1bf32 100644 --- a/build/org.eclipse.cdt.make.ui/plugin.xml +++ b/build/org.eclipse.cdt.make.ui/plugin.xml @@ -361,10 +361,7 @@ - + - + @@ -481,4 +475,18 @@ + + + + + + + + diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeResources.properties b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeResources.properties index e8e6aa22936..d4a0a0b25b7 100644 --- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeResources.properties +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeResources.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2003, 2006 QNX Software Systems and others. +# Copyright (c) 2003, 2007 QNX Software Systems 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 @@ -7,7 +7,7 @@ # # Contributors: # QNX Software Systems - initial API and implementation -# Wind River Systems - fix for bugzilla 135150 +# Wind River Systems - fix for bugzilla 135150 and 194198 # Tianchao Li (tianchao.li@gmail.com) - arbitrary build directory (bug #136136) ############################################################################### @@ -279,3 +279,6 @@ CopyDiscoveredPathAction.tooltip=Copy as text MultipleInputDialog.0=&Browse... MultipleInputDialog.1=Select a file: MultipleInputDialog.2=Varia&bles... + +# --- Compare --- +MakefileMergeViewer.title=Make Compare Viewer diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeUIPlugin.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeUIPlugin.java index fbd9bce6e5c..f7d39c5e45c 100644 --- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeUIPlugin.java +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeUIPlugin.java @@ -8,6 +8,7 @@ * Contributors: * QNX Software Systems - Initial API and implementation * Markus Schorn (Wind River Systems) + * Anton Leherbauer (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.make.internal.ui; @@ -26,13 +27,16 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.jface.dialogs.ErrorDialog; +import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PreferenceConverter; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.editors.text.EditorsUI; import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.eclipse.ui.texteditor.ChainedPreferenceStore; import org.osgi.framework.BundleContext; /** @@ -251,7 +255,19 @@ public class MakeUIPlugin extends AbstractUIPlugin { return fWorkingCopyManager; } - + /** + * Returns a combined preference store, this store is read-only. + * + * @return the combined preference store + */ + public IPreferenceStore getCombinedPreferenceStore() { + IPreferenceStore[] stores = new IPreferenceStore[2]; + stores[0] = getPreferenceStore(); + stores[1] = EditorsUI.getPreferenceStore(); + ChainedPreferenceStore chainedStore = new ChainedPreferenceStore(stores); + return chainedStore; + } + public void start(BundleContext context) throws Exception { super.start(context); diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/compare/MakefileContentViewerCreator.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/compare/MakefileContentViewerCreator.java new file mode 100644 index 00000000000..fbc1dd0ded2 --- /dev/null +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/compare/MakefileContentViewerCreator.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2005 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * QNX Software System + *******************************************************************************/ +package org.eclipse.cdt.make.internal.ui.compare; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; + + +import org.eclipse.compare.CompareConfiguration; +import org.eclipse.compare.IViewerCreator; + + +import org.eclipse.jface.viewers.Viewer; + + +/** + * Required when creating a MakefileMergeViewer from the plugin.xml file. + */ +public class MakefileContentViewerCreator implements IViewerCreator { + + public Viewer createViewer(Composite parent, CompareConfiguration mp) { + return new MakefileMergeViewer(parent, SWT.NULL, mp); + } +} \ No newline at end of file diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/compare/MakefileMergeViewer.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/compare/MakefileMergeViewer.java new file mode 100644 index 00000000000..3a3dbf9936a --- /dev/null +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/compare/MakefileMergeViewer.java @@ -0,0 +1,167 @@ +/******************************************************************************* + * Copyright (c) 2007 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Anton Leherbauer (Wind River Systems) - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.make.internal.ui.compare; + +import org.eclipse.cdt.make.internal.ui.MakeUIPlugin; +import org.eclipse.cdt.make.internal.ui.editor.MakefileDocumentSetupParticipant; +import org.eclipse.cdt.make.internal.ui.editor.MakefileSourceConfiguration; +import org.eclipse.cdt.make.internal.ui.text.ColorManager; +import org.eclipse.cdt.make.internal.ui.text.makefile.MakefilePartitionScanner; +import org.eclipse.compare.CompareConfiguration; +import org.eclipse.compare.contentmergeviewer.TextMergeViewer; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.preference.PreferenceConverter; +import org.eclipse.jface.text.IDocumentPartitioner; +import org.eclipse.jface.text.TextViewer; +import org.eclipse.jface.text.rules.FastPartitioner; +import org.eclipse.jface.text.source.SourceViewer; +import org.eclipse.jface.text.source.SourceViewerConfiguration; +import org.eclipse.jface.util.IPropertyChangeListener; +import org.eclipse.jface.util.PropertyChangeEvent; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.texteditor.AbstractTextEditor; + +/** + * A merge viewer for Makefiles. + */ +public class MakefileMergeViewer extends TextMergeViewer { + + private MakefileSourceConfiguration fSourceViewerConfiguration; + private IPropertyChangeListener fPreferenceChangeListener; + private IPreferenceStore fPreferenceStore; + + protected boolean fUseSystemColors; + + /** + * Creates a color from the information stored in the given preference store. + * Returns null if there is no such information available. + */ + protected static RGB createColor(IPreferenceStore store, String key) { + if (!store.contains(key)) + return null; + if (store.isDefault(key)) + return PreferenceConverter.getDefaultColor(store, key); + return PreferenceConverter.getColor(store, key); + } + + /** + * Create a new merge viewer. + * + * @param parent + * @param style + * @param configuration + */ + public MakefileMergeViewer(Composite parent, int style, CompareConfiguration configuration) { + super(parent, style | SWT.LEFT_TO_RIGHT, configuration); + + IPreferenceStore store = getPreferenceStore(); + + fUseSystemColors= store.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT); + if (!fUseSystemColors) { + RGB bg= createColor(store, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND); + setBackgroundColor(bg); + RGB fg= createColor(store, ColorManager.MAKE_DEFAULT_COLOR); + setForegroundColor(fg); + } + + } + + protected IPreferenceStore getPreferenceStore() { + if (fPreferenceStore == null) { + fPreferenceStore= MakeUIPlugin.getDefault().getCombinedPreferenceStore(); + fPreferenceChangeListener= new IPropertyChangeListener() { + public void propertyChange(PropertyChangeEvent event) { + handlePropertyChange(event); + } + }; + fPreferenceStore.addPropertyChangeListener(fPreferenceChangeListener); + } + return fPreferenceStore; + } + + protected void handleDispose(DisposeEvent event) { + if (fPreferenceChangeListener != null) { + fPreferenceStore.removePropertyChangeListener(fPreferenceChangeListener); + fPreferenceChangeListener= null; + } + super.handleDispose(event); + } + + protected void handlePropertyChange(PropertyChangeEvent event) { + + String key= event.getProperty(); + + if (key.equals(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND)) { + if (!fUseSystemColors) { + RGB bg= createColor(fPreferenceStore, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND); + setBackgroundColor(bg); + } + + } else if (key.equals(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT)) { + fUseSystemColors= fPreferenceStore.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT); + if (fUseSystemColors) { + setBackgroundColor(null); + setForegroundColor(null); + } else { + RGB bg= createColor(fPreferenceStore, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND); + setBackgroundColor(bg); + RGB fg= createColor(fPreferenceStore, ColorManager.MAKE_DEFAULT_COLOR); + setForegroundColor(fg); + } + } else if (key.equals(ColorManager.MAKE_DEFAULT_COLOR)) { + if (!fUseSystemColors) { + RGB fg= createColor(fPreferenceStore, ColorManager.MAKE_DEFAULT_COLOR); + setForegroundColor(fg); + } + } + + if (fSourceViewerConfiguration != null && fSourceViewerConfiguration.affectsBehavior(event)) { + fSourceViewerConfiguration.adaptToPreferenceChange(event); + invalidateTextPresentation(); + } + + } + + protected String getDocumentPartitioning() { + return MakefileDocumentSetupParticipant.MAKEFILE_PARTITIONING; + } + + protected IDocumentPartitioner getDocumentPartitioner() { + return new FastPartitioner(new MakefilePartitionScanner(), MakefilePartitionScanner.MAKE_PARTITIONS); + } + + protected void configureTextViewer(TextViewer textViewer) { + if (textViewer instanceof SourceViewer) { + ((SourceViewer)textViewer).configure(getSourceViewerConfiguration()); + } + } + + /* + * @see org.eclipse.compare.contentmergeviewer.ContentMergeViewer#getTitle() + */ + public String getTitle() { + return MakeUIPlugin.getResourceString("MakefileMergeViewer.title"); //$NON-NLS-1$ + } + + /** + * @return a source configuration for the viewer + */ + protected SourceViewerConfiguration getSourceViewerConfiguration() { + if (fSourceViewerConfiguration == null) { + fSourceViewerConfiguration= new MakefileSourceConfiguration(getPreferenceStore(), null); + } + return fSourceViewerConfiguration; + } + +} diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/MakefileEditor.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/MakefileEditor.java index 7885758e897..e5b48e631c4 100644 --- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/MakefileEditor.java +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/MakefileEditor.java @@ -22,17 +22,34 @@ import org.eclipse.core.runtime.ListenerList; import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.text.*; +import org.eclipse.jface.text.BadLocationException; +import org.eclipse.jface.text.FindReplaceDocumentAdapter; +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.IRegion; +import org.eclipse.jface.text.ITextOperationTarget; +import org.eclipse.jface.text.ITextViewerExtension; import org.eclipse.jface.text.rules.IWordDetector; -import org.eclipse.jface.text.source.*; -import org.eclipse.jface.text.source.projection.*; +import org.eclipse.jface.text.source.IOverviewRuler; +import org.eclipse.jface.text.source.ISourceViewer; +import org.eclipse.jface.text.source.IVerticalRuler; +import org.eclipse.jface.text.source.SourceViewerConfiguration; +import org.eclipse.jface.text.source.projection.ProjectionAnnotationModel; +import org.eclipse.jface.text.source.projection.ProjectionSupport; +import org.eclipse.jface.text.source.projection.ProjectionViewer; import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.jface.viewers.*; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.*; -import org.eclipse.ui.editors.text.EditorsUI; +import org.eclipse.ui.IPartService; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.editors.text.TextEditor; -import org.eclipse.ui.texteditor.*; +import org.eclipse.ui.texteditor.DefaultRangeIndicator; +import org.eclipse.ui.texteditor.ITextEditorActionConstants; +import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds; +import org.eclipse.ui.texteditor.TextOperationAction; import org.eclipse.ui.views.contentoutline.IContentOutlinePage; public class MakefileEditor extends TextEditor implements ISelectionChangedListener, IReconcilingParticipant { @@ -107,10 +124,7 @@ public class MakefileEditor extends TextEditor implements ISelectionChangedListe setEditorContextMenuId("#MakefileEditorContext"); //$NON-NLS-1$ setRulerContextMenuId("#MakefileRulerContext"); //$NON-NLS-1$ setDocumentProvider(MakeUIPlugin.getDefault().getMakefileDocumentProvider()); - IPreferenceStore[] stores = new IPreferenceStore[2]; - stores[0] = MakeUIPlugin.getDefault().getPreferenceStore(); - stores[1] = EditorsUI.getPreferenceStore(); - ChainedPreferenceStore chainedStore = new ChainedPreferenceStore(stores); + IPreferenceStore chainedStore = MakeUIPlugin.getDefault().getCombinedPreferenceStore(); setPreferenceStore(chainedStore); setSourceViewerConfiguration(new MakefileSourceConfiguration(chainedStore, this)); } diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/MakefileSourceConfiguration.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/MakefileSourceConfiguration.java index d2ffcbd7be2..a255c1ca4e5 100644 --- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/MakefileSourceConfiguration.java +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/MakefileSourceConfiguration.java @@ -82,23 +82,26 @@ public class MakefileSourceConfiguration extends TextSourceViewerConfiguration { * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getContentAssistant(ISourceViewer) */ public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) { - ContentAssistant assistant = new ContentAssistant(); - assistant.setContentAssistProcessor(new MakefileCompletionProcessor(fEditor), IDocument.DEFAULT_CONTENT_TYPE); - assistant.setContentAssistProcessor(new MakefileCompletionProcessor(fEditor), MakefilePartitionScanner.MAKEFILE_COMMENT_PARTITION); - assistant.setContentAssistProcessor(new MakefileCompletionProcessor(fEditor), MakefilePartitionScanner.MAKEFILE_DEF_BLOCK_PARTITION); - assistant.setContentAssistProcessor(new MakefileCompletionProcessor(fEditor), MakefilePartitionScanner.MAKEFILE_IF_BLOCK_PARTITION); - assistant.setContentAssistProcessor(new MakefileCompletionProcessor(fEditor), MakefilePartitionScanner.MAKEFILE_INCLUDE_BLOCK_PARTITION); - assistant.setContentAssistProcessor(new MakefileCompletionProcessor(fEditor), MakefilePartitionScanner.MAKEFILE_MACRO_ASSIGNEMENT_PARTITION); + if (fEditor != null && fEditor.isEditable()) { + ContentAssistant assistant = new ContentAssistant(); + assistant.setContentAssistProcessor(new MakefileCompletionProcessor(fEditor), IDocument.DEFAULT_CONTENT_TYPE); + assistant.setContentAssistProcessor(new MakefileCompletionProcessor(fEditor), MakefilePartitionScanner.MAKEFILE_COMMENT_PARTITION); + assistant.setContentAssistProcessor(new MakefileCompletionProcessor(fEditor), MakefilePartitionScanner.MAKEFILE_DEF_BLOCK_PARTITION); + assistant.setContentAssistProcessor(new MakefileCompletionProcessor(fEditor), MakefilePartitionScanner.MAKEFILE_IF_BLOCK_PARTITION); + assistant.setContentAssistProcessor(new MakefileCompletionProcessor(fEditor), MakefilePartitionScanner.MAKEFILE_INCLUDE_BLOCK_PARTITION); + assistant.setContentAssistProcessor(new MakefileCompletionProcessor(fEditor), MakefilePartitionScanner.MAKEFILE_MACRO_ASSIGNEMENT_PARTITION); + + assistant.enableAutoActivation(true); + assistant.setAutoActivationDelay(500); + + assistant.setProposalPopupOrientation(IContentAssistant.CONTEXT_INFO_BELOW); + assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_BELOW); + //Set to Carolina blue + assistant.setContextInformationPopupBackground(colorManager.getColor(new RGB(0, 191, 255))); - assistant.enableAutoActivation(true); - assistant.setAutoActivationDelay(500); - - assistant.setProposalPopupOrientation(IContentAssistant.CONTEXT_INFO_BELOW); - assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_BELOW); - //Set to Carolina blue - assistant.setContextInformationPopupBackground(colorManager.getColor(new RGB(0, 191, 255))); - - return assistant; + return assistant; + } + return null; } protected MakefileCodeScanner getCodeScanner() { @@ -167,13 +170,19 @@ public class MakefileSourceConfiguration extends TextSourceViewerConfiguration { * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getTextHover(org.eclipse.jface.text.source.ISourceViewer, java.lang.String) */ public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) { - return new MakefileTextHover(fEditor); + if (fEditor != null) { + return new MakefileTextHover(fEditor); + } + return super.getTextHover(sourceViewer, contentType); } /* (non-Javadoc) * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getAnnotationHover(org.eclipse.jface.text.source.ISourceViewer) */ public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) { - return new MakefileAnnotationHover(fEditor); + if (fEditor != null) { + return new MakefileAnnotationHover(fEditor); + } + return super.getAnnotationHover(sourceViewer); } /** diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginResources.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginResources.properties index ef1f7e06ee7..c3e114ba63e 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginResources.properties +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginResources.properties @@ -171,6 +171,7 @@ CElementProperties.elf_needed=needed CMergeViewer.title=C Compare Viewer CStructureCreator.name=C Compare +AsmMergeViewer.title=Assembly Compare Viewer # ------- OpenIncludeDeclarationAction------------