Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 145828 Details for
Bug 274009
[fiximprove] [AppDescEditor]: No preferences for the JAD editor
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Partial fixing patch
bug274009_partial2.patch (text/plain), 32.56 KB, created by
Renato Franca
on 2009-08-27 13:59:49 EDT
(
hide
)
Description:
Partial fixing patch
Filename:
MIME Type:
Creator:
Renato Franca
Created:
2009-08-27 13:59:49 EDT
Size:
32.56 KB
patch
obsolete
>Index: src/org/eclipse/mtj/internal/ui/messages.properties >=================================================================== >--- src/org/eclipse/mtj/internal/ui/messages.properties (revision 1457) >+++ src/org/eclipse/mtj/internal/ui/messages.properties (working copy) >@@ -63,6 +63,7 @@ > EditorPreferencePage_folding_label=&Enable folding when opening a new editor > EditorPreferencePage_generalTextEditor_link=See <A>'Text Editors'</A> for the general text editor preferences. > EditorPreferencePage_localization_tab_title=&Localization Data Highlighting >+EditorPreferencePage_jad_tab_title=&Application Descriptor Highlighting > EnableLocalizationAction_dialog_title=Localization Wizard > ErrorTextWithContinueDialog_continue_label=Continue > ExceptionHandler_displayMessageDialog_message=See error log for more details. >@@ -236,6 +237,10 @@ > XMLSyntaxColorTab_tags_label=Tags > XMLSyntaxColorTab_text_label=Text > >+JADSyntaxColorTab_key_label=Key >+JADSyntaxColorTab_value_label=Values >+JADSyntaxColorTab_userkey_label=User Keys >+ > L10nAddLocaleAction_text=Locale > L10nAddLocaleEntryAction_initialKey=key > L10nAddLocaleEntryAction_initialValue=value >Index: src/org/eclipse/mtj/internal/ui/preferences/EditorPreferencePage.java >=================================================================== >--- src/org/eclipse/mtj/internal/ui/preferences/EditorPreferencePage.java (revision 1457) >+++ src/org/eclipse/mtj/internal/ui/preferences/EditorPreferencePage.java (working copy) >@@ -1,5 +1,5 @@ > /** >- * Copyright (c) 2008 Motorola. >+ * Copyright (c) 2008 - 2009 Motorola. > * > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 >@@ -8,6 +8,7 @@ > * > * Contributors: > * Diego Sandin (Motorola) - Initial Version >+ * Renato Franca (Motorola) - Adding application descriptor tab > */ > package org.eclipse.mtj.internal.ui.preferences; > >@@ -40,6 +41,7 @@ > > private ColorManager fColorManager; > private XMLSyntaxColorTab fXMLTab; >+ private JADSyntaxColorTab fJADTab; > > /** > * Create the EditorPreferencePage. >@@ -56,6 +58,7 @@ > public void dispose() { > fColorManager.disposeColors(false); > fXMLTab.dispose(); >+ fJADTab.dispose(); > super.dispose(); > } > >@@ -71,6 +74,7 @@ > @Override > public boolean performOk() { > fXMLTab.performOk(); >+ fJADTab.performOk(); > MTJUIPlugin.getDefault().savePluginPreferences(); > return super.performOk(); > } >@@ -84,6 +88,16 @@ > item.setText(MTJUIMessages.EditorPreferencePage_localization_tab_title); > item.setControl(fXMLTab.createContents(folder)); > } >+ >+ /** >+ * @param folder >+ */ >+ private void createJADTab(TabFolder folder) { >+ fJADTab = new JADSyntaxColorTab(fColorManager); >+ TabItem item = new TabItem(folder, SWT.NONE); >+ item.setText(MTJUIMessages.EditorPreferencePage_jad_tab_title); >+ item.setControl(fJADTab.createContents(folder)); >+ } > > /* (non-Javadoc) > * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite) >@@ -125,6 +139,7 @@ > folder.setLayout(new TabFolderLayout()); > folder.setLayoutData(new GridData(GridData.FILL_BOTH)); > >+ createJADTab(folder); > createXMLTab(folder); > > Dialog.applyDialogFont(getControl()); >@@ -138,6 +153,7 @@ > @Override > protected void performDefaults() { > fXMLTab.performDefaults(); >+ fJADTab.performDefaults(); > super.performDefaults(); > } > } >Index: src/org/eclipse/mtj/internal/ui/preferences/JADSyntaxColorTab.java >=================================================================== >--- src/org/eclipse/mtj/internal/ui/preferences/JADSyntaxColorTab.java (revision 0) >+++ src/org/eclipse/mtj/internal/ui/preferences/JADSyntaxColorTab.java (revision 0) >@@ -0,0 +1,91 @@ >+/** >+ * Copyright (c) 2009 Motorola. >+ * >+ * 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: >+ * Renato Augusto (Motorola) - Initial implementation >+ */ >+ >+ >+package org.eclipse.mtj.internal.ui.preferences; >+ >+import org.eclipse.jface.text.Document; >+import org.eclipse.jface.text.IDocument; >+import org.eclipse.mtj.internal.ui.MTJUIMessages; >+import org.eclipse.mtj.internal.ui.editor.context.JADDocumentSetupParticipant; >+import org.eclipse.mtj.internal.ui.editor.text.ChangeAwareSourceViewerConfiguration; >+import org.eclipse.mtj.internal.ui.editor.text.IColorManager; >+import org.eclipse.mtj.internal.ui.editor.text.IMTJColorConstants; >+import org.eclipse.mtj.internal.ui.editors.jad.source.JADSourceViewerConfiguration; >+ >+/** >+ * >+ * @author cnk378 >+ * >+ */ >+public class JADSyntaxColorTab extends SyntaxColorTab { >+ >+ private static final String[][] COLOR_STRINGS = new String[][] { >+ { MTJUIMessages.JADSyntaxColorTab_key_label, IMTJColorConstants.P_JAD_KEY}, >+ { MTJUIMessages.JADSyntaxColorTab_value_label, IMTJColorConstants.P_JAD_VALUE}, >+ { MTJUIMessages.JADSyntaxColorTab_userkey_label, IMTJColorConstants.P_JAD_USER_KEY } }; >+ >+ /** >+ * @param manager >+ */ >+ public JADSyntaxColorTab(IColorManager manager) { >+ super(manager); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * @see >+ * org.eclipse.mtj.internal.ui.preferences.SyntaxColorTab#getColorStrings() >+ */ >+ @Override >+ protected String[][] getColorStrings() { >+ return COLOR_STRINGS; >+ } >+ >+ /* >+ * (non-Javadoc) >+ * @see org.eclipse.mtj.internal.ui.preferences.SyntaxColorTab#getDocument() >+ */ >+ @Override >+ protected IDocument getDocument() { >+ >+ StringBuffer buffer = new StringBuffer(); >+ String delimiter = System.getProperty("line.separator"); //$NON-NLS-1$ >+ buffer.append("MIDlet-1: %midlet"); //$NON-NLS-1$ >+ buffer.append(delimiter); >+ buffer.append("MIDlet-Jar-URL: %jar"); //$NON-NLS-1$ >+ buffer.append(delimiter); >+ buffer.append("MIDlet-Name: %name"); //$NON-NLS-1$ >+ buffer.append(delimiter); >+ buffer.append("MIDlet-Version: 1.0.0"); //$NON-NLS-1$ >+ buffer.append(delimiter); >+ buffer.append("MicroEdition-Configuration: configuration.example"); //$NON-NLS-1$ >+ buffer.append(delimiter); >+ buffer.append("MicroEdition-Profile: profile.example"); //$NON-NLS-1$ >+ buffer.append(delimiter); >+ buffer.append("User_New_Key: Value"); //$NON-NLS-1$ >+ >+ IDocument document = new Document(buffer.toString()); >+ new JADDocumentSetupParticipant().setup(document); >+ return document; >+ } >+ >+ /* >+ * (non-Javadoc) >+ * @seeorg.eclipse.mtj.internal.ui.preferences.SyntaxColorTab# >+ * getSourceViewerConfiguration() >+ */ >+ @Override >+ protected ChangeAwareSourceViewerConfiguration getSourceViewerConfiguration() { >+ return new JADSourceViewerConfiguration(fColorManager, null); >+ } >+} >Index: src/org/eclipse/mtj/internal/ui/MTJUIMessages.java >=================================================================== >--- src/org/eclipse/mtj/internal/ui/MTJUIMessages.java (revision 1457) >+++ src/org/eclipse/mtj/internal/ui/MTJUIMessages.java (working copy) >@@ -12,6 +12,7 @@ > * Fernando Rocha(Motorola)- Add jar message error > * Fernando Rocha(Motorola)- Add messages for the new project wizard > * Daniel Olsson (Sony Ericsson) - Add messages for DeviceMatchDialog >+ * Renato Franca(Motorola)- Add JAD preference page messages > */ > package org.eclipse.mtj.internal.ui; > >@@ -289,6 +290,7 @@ > public static String EditorPreferencePage_folding_label; > public static String EditorPreferencePage_generalTextEditor_link; > public static String EditorPreferencePage_localization_tab_title; >+ public static String EditorPreferencePage_jad_tab_title; > public static String EnableLocalizationAction_dialog_title; > public static String ErrorTextWithContinueDialog_continue_label; > >@@ -894,6 +896,10 @@ > public static String XMLSyntaxColorTab_process_label; > public static String XMLSyntaxColorTab_tags_label; > public static String XMLSyntaxColorTab_text_label; >+ >+ public static String JADSyntaxColorTab_key_label; >+ public static String JADSyntaxColorTab_value_label; >+ public static String JADSyntaxColorTab_userkey_label; > > public static String buttonBarBlock_button_add; > public static String buttonBarBlock_button_remove; >Index: src/org/eclipse/mtj/internal/ui/editors/jad/form/pages/JADSourceEditorPage.java >=================================================================== >--- src/org/eclipse/mtj/internal/ui/editors/jad/form/pages/JADSourceEditorPage.java (revision 1457) >+++ src/org/eclipse/mtj/internal/ui/editors/jad/form/pages/JADSourceEditorPage.java (working copy) >@@ -1,5 +1,5 @@ > /** >- * Copyright (c) 2008 Motorola. >+ * Copyright (c) 2008 - 2009 Motorola. > * > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 >@@ -8,13 +8,19 @@ > * > * Contributors: > * Diego Sandin (Motorola) - Initial implementation >+ * Renato Franca (Motorola) - Setting preference page > */ > package org.eclipse.mtj.internal.ui.editors.jad.form.pages; > > import org.eclipse.core.resources.IMarker; > import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.jface.preference.IPreferenceStore; >+import org.eclipse.jface.util.IPropertyChangeListener; >+import org.eclipse.jface.util.PropertyChangeEvent; >+import org.eclipse.mtj.internal.ui.MTJUIPlugin; > import org.eclipse.mtj.internal.ui.editors.jad.form.JADFormEditor; > import org.eclipse.mtj.internal.ui.editors.jad.source.JADSourceEditor; >+import org.eclipse.mtj.internal.ui.editors.jad.source.JADSourceViewerConfiguration; > import org.eclipse.swt.widgets.Composite; > import org.eclipse.swt.widgets.Control; > import org.eclipse.ui.forms.IManagedForm; >@@ -45,8 +51,21 @@ > public JADSourceEditorPage(JADFormEditor editor) { > super(); > initialize(editor); >+ >+ IPreferenceStore store = MTJUIPlugin.getDefault().getPreferenceStore(); >+ store.addPropertyChangeListener(new IPropertyChangeListener() { >+ public void propertyChange(PropertyChangeEvent event) { >+ >+ //FIXME >+ } >+ }); > } > >+ @Override >+ protected boolean affectsTextPresentation(PropertyChangeEvent event) { >+ return true; >+ } >+ > /* > * (non-Javadoc) > * >@@ -131,6 +150,8 @@ > */ > public void initialize(FormEditor editor) { > this.editor = (JADFormEditor) editor; >+ >+ setSourceViewerConfiguration(new JADSourceViewerConfiguration(this)); > > } > >@@ -193,5 +214,18 @@ > this.index = index; > > } >+ >+ /* >+ * (non-Javadoc) >+ * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#collectContextMenuPreferencePages() >+ */ >+ @Override >+ protected String[] collectContextMenuPreferencePages() { >+ String[] ids = super.collectContextMenuPreferencePages(); >+ String[] more = new String[ids.length + 1]; >+ more[0] = "org.eclipse.mtj.ui.EditorPreferencePage"; //$NON-NLS-1$ >+ System.arraycopy(ids, 0, more, 1, ids.length); >+ return more; >+ } > > } >Index: src/org/eclipse/mtj/internal/ui/editors/jad/source/JADSourceEditor.java >=================================================================== >--- src/org/eclipse/mtj/internal/ui/editors/jad/source/JADSourceEditor.java (revision 1457) >+++ src/org/eclipse/mtj/internal/ui/editors/jad/source/JADSourceEditor.java (working copy) >@@ -1,5 +1,5 @@ > /** >- * Copyright (c) 2008 Motorola. >+ * Copyright (c) 2008 - 2009 Motorola. > * > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 >@@ -9,6 +9,7 @@ > * Contributors: > * Diego Sandin (Motorola) - Initial implementation > * Gang Ma (Sybase) - Add content assist support >+ * Renato Franca(Motorola) - Removing setSourceViewerConfiguration call > */ > package org.eclipse.mtj.internal.ui.editors.jad.source; > >@@ -42,8 +43,7 @@ > */ > private static ResourceBundle bundleForConstructedKeys = ResourceBundle > .getBundle(RES_BUNDLE_LOCATION); >- >- >+ > /** > * Returns the resource bundle containing the ContentAssist keys. > * >@@ -57,7 +57,6 @@ > * Creates a new Application Descriptor editor > */ > public JADSourceEditor() { >- setSourceViewerConfiguration(new JADSourceViewerConfiguration(this)); > } > > /* >Index: src/org/eclipse/mtj/internal/ui/editors/jad/source/JADSourceViewerConfiguration.java >=================================================================== >--- src/org/eclipse/mtj/internal/ui/editors/jad/source/JADSourceViewerConfiguration.java (revision 1457) >+++ src/org/eclipse/mtj/internal/ui/editors/jad/source/JADSourceViewerConfiguration.java (working copy) >@@ -1,5 +1,5 @@ > /** >- * Copyright (c) 2008 Motorola. >+ * Copyright (c) 2008 - 2009 Motorola. > * > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 >@@ -7,8 +7,9 @@ > * http://www.eclipse.org/legal/epl-v10.html > * > * Contributors: >- * Diego Sandin (Motorola) - Initial implementation >+ * Diego Sandin (Motorola) - Initial implementation > * Gang Ma (Sybase) - Add content assist support >+ * Renato Franca (Motorola) - Updating Scanner instance > */ > package org.eclipse.mtj.internal.ui.editors.jad.source; > >@@ -20,7 +21,10 @@ > import org.eclipse.jface.text.presentation.PresentationReconciler; > import org.eclipse.jface.text.rules.DefaultDamagerRepairer; > import org.eclipse.jface.text.source.ISourceViewer; >-import org.eclipse.jface.text.source.SourceViewerConfiguration; >+import org.eclipse.jface.util.PropertyChangeEvent; >+import org.eclipse.mtj.internal.ui.editor.text.ChangeAwareSourceViewerConfiguration; >+import org.eclipse.mtj.internal.ui.editor.text.ColorManager; >+import org.eclipse.mtj.internal.ui.editor.text.IColorManager; > import org.eclipse.mtj.internal.ui.editors.jad.source.contentassist.CompletionProcessor; > import org.eclipse.mtj.internal.ui.editors.jad.source.rules.JadScanner; > >@@ -29,11 +33,21 @@ > * > * @author Diego Madruga Sandin > */ >-public class JADSourceViewerConfiguration extends SourceViewerConfiguration { >+public class JADSourceViewerConfiguration extends ChangeAwareSourceViewerConfiguration { > private JADSourceEditor sourcePage; >+ private JadScanner jadScanner; > > public JADSourceViewerConfiguration(JADSourceEditor sourcePage) { >+ this(new ColorManager(), null); >+ } >+ >+ public JADSourceViewerConfiguration(IColorManager colorManager, JADSourceEditor sourcePage) { >+ >+ super(null, colorManager); > this.sourcePage = sourcePage; >+ >+ jadScanner = new JadScanner(colorManager); >+ > } > > /* >@@ -44,12 +58,14 @@ > @Override > public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) { > ContentAssistant ca = new ContentAssistant(); >- IContentAssistProcessor cap = new CompletionProcessor(sourcePage); >- ca.setContentAssistProcessor(cap, IDocument.DEFAULT_CONTENT_TYPE); >- ca.enableAutoActivation(true); >- ca >- .setInformationControlCreator(getInformationControlCreator(sourceViewer)); >- >+ >+ if (sourcePage != null) { >+ IContentAssistProcessor cap = new CompletionProcessor(sourcePage); >+ ca.setContentAssistProcessor(cap, IDocument.DEFAULT_CONTENT_TYPE); >+ ca.enableAutoActivation(true); >+ ca >+ .setInformationControlCreator(getInformationControlCreator(sourceViewer)); >+ } > return ca; > > } >@@ -64,10 +80,43 @@ > ISourceViewer sourceViewer) { > > PresentationReconciler pr = new PresentationReconciler(); >- DefaultDamagerRepairer ddr = new DefaultDamagerRepairer(new JadScanner()); >+ DefaultDamagerRepairer ddr = new DefaultDamagerRepairer(jadScanner); > pr.setRepairer(ddr, IDocument.DEFAULT_CONTENT_TYPE); > pr.setDamager(ddr, IDocument.DEFAULT_CONTENT_TYPE); > > return pr; > } >+ >+ @Override >+ public void adaptToPreferenceChange(PropertyChangeEvent event) { >+ >+ if (jadScanner == null) { >+ return; // property change before the editor is fully created >+ } >+ >+ if (affectsColorPresentation(event)) { >+ fColorManager.handlePropertyChangeEvent(event); >+ } >+ >+ jadScanner.adaptToPreferenceChange(event); >+ >+ } >+ >+ @Override >+ public boolean affectsColorPresentation(PropertyChangeEvent event) { >+ >+ return true; >+ } >+ >+ @Override >+ public boolean affectsTextPresentation(PropertyChangeEvent event) { >+ >+ return true; >+ } >+ >+ @Override >+ public void dispose() { >+ >+ } >+ > } >Index: src/org/eclipse/mtj/internal/ui/editors/jad/source/rules/JadScanner.java >=================================================================== >--- src/org/eclipse/mtj/internal/ui/editors/jad/source/rules/JadScanner.java (revision 1457) >+++ src/org/eclipse/mtj/internal/ui/editors/jad/source/rules/JadScanner.java (working copy) >@@ -1,5 +1,5 @@ > /** >- * Copyright (c) 2008 Motorola. >+ * Copyright (c) 2008-2009 Motorola. > * > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 >@@ -8,62 +8,88 @@ > * > * Contributors: > * Diego Sandin (Motorola) - Initial implementation >+ * Renato Franca (Motorola) - Class refactoring > */ > package org.eclipse.mtj.internal.ui.editors.jad.source.rules; > >-import org.eclipse.jface.resource.ColorRegistry; > import org.eclipse.jface.text.TextAttribute; > import org.eclipse.jface.text.rules.IRule; > import org.eclipse.jface.text.rules.IWhitespaceDetector; > import org.eclipse.jface.text.rules.IWordDetector; >-import org.eclipse.jface.text.rules.RuleBasedScanner; > import org.eclipse.jface.text.rules.SingleLineRule; > import org.eclipse.jface.text.rules.Token; > import org.eclipse.jface.text.rules.WhitespaceRule; > import org.eclipse.jface.text.rules.WordRule; >+import org.eclipse.jface.util.PropertyChangeEvent; > import org.eclipse.mtj.core.project.midp.DescriptorPropertyDescription; > import org.eclipse.mtj.core.project.midp.IJADDescriptorsProvider; > import org.eclipse.mtj.internal.core.project.midp.JADAttributesRegistry; >+import org.eclipse.mtj.internal.ui.editor.text.BaseMTJScanner; >+import org.eclipse.mtj.internal.ui.editor.text.IColorManager; >+import org.eclipse.mtj.internal.ui.editor.text.IMTJColorConstants; > import org.eclipse.swt.SWT; >-import org.eclipse.swt.graphics.RGB; > > /** > * A scanner programmed with a sequence of rules specific to the JAD file. > * > * @author Diego Madruga Sandin > */ >-public class JadScanner extends RuleBasedScanner { >- >- /** >- * Symbolic name for the keyword colors >- */ >- private static final String KEYWORD_COLOR= "mtj.jad.keyword.color"; //$NON-NLS-1$ >- /** >- * Symbolic name for value colors >- */ >- private static final String VALUE_COLOR= "mtj.jad.value.color"; //$NON-NLS-1$ >+public class JadScanner extends BaseMTJScanner { > >+ private Token keyToken; >+ private Token userkeyToken; >+ private Token valueToken; > >- // This is probably not the best way to handle the colors for this scanner >- // it will do until the colors are integrated with preferences. >- private static final ColorRegistry colorRegistry = new ColorRegistry(); >- static{ >- colorRegistry.put(KEYWORD_COLOR, new RGB(127,0, 85)); >- colorRegistry.put(VALUE_COLOR, new RGB(0,0, 0)); >+ public JadScanner(IColorManager colorManager) { >+ super(colorManager); >+ >+ > } >- >- /** >- * Creates a new Scanner >- */ >- public JadScanner() { >+ >+ @Override >+ public boolean affectsTextPresentation(String property) { >+ >+ return true; >+ } >+ >+ @Override >+ public Token getTokenAffected(PropertyChangeEvent event) { >+ >+ String property = event.getProperty(); >+ Token affected = null; >+ >+ if(property.startsWith(IMTJColorConstants.P_JAD_KEY)) { >+ >+ affected = keyToken; >+ >+ } else if(property.startsWith(IMTJColorConstants.P_JAD_USER_KEY)) { >+ >+ affected = userkeyToken; >+ >+ } else if(property.startsWith(IMTJColorConstants.P_JAD_VALUE)) { >+ >+ affected = valueToken; >+ } >+ >+ return affected; >+ >+ } > >- IWordDetector detector = new IWordDetector() { >+ @Override >+ protected void initialize() { >+ >+ >+ keyToken = new Token(new TextAttribute(super.getColorManager().getColor(IMTJColorConstants.P_JAD_KEY), null, SWT.BOLD )); >+ userkeyToken = new Token(new TextAttribute(super.getColorManager().getColor(IMTJColorConstants.P_JAD_USER_KEY), null, SWT.NONE )); >+ valueToken = new Token(new TextAttribute(super.getColorManager().getColor(IMTJColorConstants.P_JAD_VALUE), null, SWT.NONE )); >+ >+ IWordDetector detector = new IWordDetector() { > public boolean isWordPart(char c) { > if (c == ':') { > return false; > } > if (c == '-' ){ >- return true; >+ return true; > } > return Character.isJavaIdentifierPart(c); > } >@@ -72,25 +98,22 @@ > } > }; > >- final Token keyword = new Token(new TextAttribute(colorRegistry.get(KEYWORD_COLOR), null, SWT.BOLD )); >- final Token key = new Token(new TextAttribute(colorRegistry.get(KEYWORD_COLOR), null, SWT.NONE)); > >- WordRule rule = new WordRule(detector,key); >+ WordRule rule = new WordRule(detector,userkeyToken); > > // add tokens for each reserved word > IJADDescriptorsProvider[] providers = JADAttributesRegistry.getAllJADDescriptorProviders(); > for (int i = 0; i < providers.length; i++) { >- DescriptorPropertyDescription[] descriptions = providers[i].getDescriptorPropertyDescriptions(); >- for (int j = 0; j < descriptions.length; j++) { >- rule.addWord( descriptions[j].getPropertyName(), keyword); >- } >+ DescriptorPropertyDescription[] descriptions = providers[i].getDescriptorPropertyDescriptions(); >+ for (int j = 0; j < descriptions.length; j++) { >+ rule.addWord( descriptions[j].getPropertyName(), keyToken); >+ } > } > >- Token string = new Token(new TextAttribute(colorRegistry.get(VALUE_COLOR))); >- >- // Rule for Values >- SingleLineRule singleLineRule = new SingleLineRule(":", null, string, '\\'); //$NON-NLS-1$ >- // Add generic whitespace rule. >+ // Rule for Values >+ SingleLineRule singleLineRule = new SingleLineRule(":", null, valueToken, '\\'); //$NON-NLS-1$ >+ >+ // Add generic whitespace rule. > WhitespaceRule whiteSpaceRule = new WhitespaceRule(new IWhitespaceDetector() { > public boolean isWhitespace(char c) { > return Character.isWhitespace(c); >@@ -98,5 +121,6 @@ > }); > > setRules(new IRule[] { rule, singleLineRule, whiteSpaceRule }); >+ > } > } >Index: src/org/eclipse/mtj/internal/ui/editor/context/JADDocumentSetupParticipant.java >=================================================================== >--- src/org/eclipse/mtj/internal/ui/editor/context/JADDocumentSetupParticipant.java (revision 0) >+++ src/org/eclipse/mtj/internal/ui/editor/context/JADDocumentSetupParticipant.java (revision 0) >@@ -0,0 +1,50 @@ >+/** >+ * Copyright (c) 2009 Motorola. >+ * >+ * 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: >+ * Renato Franca (Motorola) - Initial implementation >+ */ >+ >+package org.eclipse.mtj.internal.ui.editor.context; >+ >+import org.eclipse.core.filebuffers.IDocumentSetupParticipant; >+import org.eclipse.jface.text.IDocument; >+import org.eclipse.jface.text.IDocumentExtension3; >+import org.eclipse.jface.text.IDocumentPartitioner; >+import org.eclipse.jface.text.rules.FastPartitioner; >+import org.eclipse.mtj.internal.ui.editor.text.JADPartitionScanner; >+ >+public class JADDocumentSetupParticipant implements IDocumentSetupParticipant { >+ >+ public static final String JAD_PARTITIONING = "_mtj_jad_partitioning"; //$NON-NLS-1$ >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.core.filebuffers.IDocumentSetupParticipant#setup(org.eclipse.jface.text.IDocument) >+ */ >+ public void setup(IDocument document) { >+ IDocumentPartitioner partitioner = createDocumentPartitioner(); >+ if (partitioner != null) { >+ partitioner.connect(document); >+ if (document instanceof IDocumentExtension3) { >+ IDocumentExtension3 de3 = (IDocumentExtension3) document; >+ de3.setDocumentPartitioner(JAD_PARTITIONING, partitioner); >+ } else { >+ document.setDocumentPartitioner(partitioner); >+ } >+ } >+ } >+ >+ /** >+ * @return >+ */ >+ private IDocumentPartitioner createDocumentPartitioner() { >+ return new FastPartitioner(new JADPartitionScanner(), >+ JADPartitionScanner.PARTITIONS); >+ } >+ >+} >Index: src/org/eclipse/mtj/internal/ui/editor/text/ColorManager.java >=================================================================== >--- src/org/eclipse/mtj/internal/ui/editor/text/ColorManager.java (revision 1457) >+++ src/org/eclipse/mtj/internal/ui/editor/text/ColorManager.java (working copy) >@@ -1,5 +1,5 @@ > /** >- * Copyright (c) 2000,2008 IBM Corporation and others. >+ * Copyright (c) 2000,2009 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 >@@ -9,6 +9,7 @@ > * Contributors: > * IBM Corporation - initial API and implementation > * Diego Sandin (Motorola) - Adapted code from org.eclipse.pde.ui >+ * Renato Franca (Motorola) - Adding JAD preference constants > */ > package org.eclipse.mtj.internal.ui.editor.text; > >@@ -19,7 +20,6 @@ > import org.eclipse.jdt.ui.PreferenceConstants; > import org.eclipse.jface.preference.IPreferenceStore; > import org.eclipse.jface.preference.PreferenceConverter; >-import org.eclipse.jface.resource.StringConverter; > import org.eclipse.jface.util.PropertyChangeEvent; > import org.eclipse.mtj.internal.ui.MTJUIPlugin; > import org.eclipse.swt.SWT; >@@ -64,6 +64,10 @@ > PreferenceConverter.setDefault(store, P_STRING, STRING); > PreferenceConverter.setDefault(store, P_TAG, TAG); > PreferenceConverter.setDefault(store, P_XML_COMMENT, XML_COMMENT); >+ >+ PreferenceConverter.setDefault(store, P_JAD_KEY, JAD_KEY); >+ PreferenceConverter.setDefault(store, P_JAD_USER_KEY, JAD_USER_KEY); >+ PreferenceConverter.setDefault(store, P_JAD_VALUE, JAD_VALUE); > } > > private Map<String, Color> fColorTable = new HashMap<String, Color>(5); >@@ -118,9 +122,6 @@ > Object color = event.getNewValue(); > if (color instanceof RGB) { > putColor(event.getProperty(), (RGB) color); >- } else { >- putColor(event.getProperty(), StringConverter.asRGB(color >- .toString())); > } > } > >@@ -134,6 +135,9 @@ > putColor(pstore, P_STRING); > putColor(pstore, P_TAG); > putColor(pstore, P_XML_COMMENT); >+ putColor(pstore, P_JAD_KEY); >+ putColor(pstore, P_JAD_USER_KEY); >+ putColor(pstore, P_JAD_VALUE); > pstore = PreferenceConstants.getPreferenceStore(); > for (String element : IColorManager.PROPERTIES_COLORS) { > putColor(pstore, element); >Index: src/org/eclipse/mtj/internal/ui/editor/text/IMTJColorConstants.java >=================================================================== >--- src/org/eclipse/mtj/internal/ui/editor/text/IMTJColorConstants.java (revision 1457) >+++ src/org/eclipse/mtj/internal/ui/editor/text/IMTJColorConstants.java (working copy) >@@ -1,5 +1,5 @@ > /** >- * Copyright (c) 2008 Motorola. >+ * Copyright (c) 2008 - 2009 Motorola. > * > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 >@@ -8,6 +8,7 @@ > * > * Contributors: > * Diego Sandin (Motorola) - Initial Version >+ * Renato Franca (Motorola) - Adding JAD preference constants > */ > package org.eclipse.mtj.internal.ui.editor.text; > >@@ -25,6 +26,10 @@ > RGB DEFAULT = new RGB(0, 0, 0); > RGB DEFAULT_HIGH_CONTRAST = new RGB(255, 255, 255); > RGB TAG = new RGB(0, 0, 128); >+ >+ RGB JAD_KEY = new RGB(127, 0, 85); >+ RGB JAD_VALUE = new RGB(0, 0, 0); >+ RGB JAD_USER_KEY = new RGB(127, 0, 85); > > String P_BOLD_SUFFIX = "_bold"; //$NON-NLS-1$ > String P_ITALIC_SUFFIX = "_italic"; //$NON-NLS-1$ >@@ -34,5 +39,9 @@ > String P_STRING = "editor.color.string"; //$NON-NLS-1$ > String P_DEFAULT = "editor.color.default"; //$NON-NLS-1$ > String P_TAG = "editor.color.tag"; //$NON-NLS-1$ >+ >+ String P_JAD_KEY = "editor.color.jad.key"; //$NON-NLS-1$ >+ String P_JAD_VALUE = "editor.color.jad.value"; //$NON-NLS-1$ >+ String P_JAD_USER_KEY = "editor.color.jad.userkey"; //$NON-NLS-1$ > > } >Index: src/org/eclipse/mtj/internal/ui/editor/text/BaseMTJScanner.java >=================================================================== >--- src/org/eclipse/mtj/internal/ui/editor/text/BaseMTJScanner.java (revision 1457) >+++ src/org/eclipse/mtj/internal/ui/editor/text/BaseMTJScanner.java (working copy) >@@ -9,6 +9,7 @@ > * Contributors: > * IBM Corporation - initial API and implementation > * Diego Sandin (Motorola) - Adapted code from org.eclipse.pde.ui/BasePDEScanner >+ * Renato Franca (Motorola) - Adding getColorManager method > */ > package org.eclipse.mtj.internal.ui.editor.text; > >@@ -96,6 +97,12 @@ > public void setColorManager(IColorManager manager) { > fColorManager = manager; > } >+ >+ /** >+ */ >+ public IColorManager getColorManager() { >+ return fColorManager; >+ } > > /** > * @param event >Index: src/org/eclipse/mtj/internal/ui/editor/text/JADPartitionScanner.java >=================================================================== >--- src/org/eclipse/mtj/internal/ui/editor/text/JADPartitionScanner.java (revision 0) >+++ src/org/eclipse/mtj/internal/ui/editor/text/JADPartitionScanner.java (revision 0) >@@ -0,0 +1,41 @@ >+/** >+ * Copyright (c) 2009 Motorola. >+ * >+ * 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: >+ * Renato Franca (Motorola) - Initial Version >+ */ >+ >+package org.eclipse.mtj.internal.ui.editor.text; >+ >+import org.eclipse.jface.text.rules.IPredicateRule; >+import org.eclipse.jface.text.rules.RuleBasedPartitionScanner; >+import org.eclipse.jface.text.rules.SingleLineRule; >+import org.eclipse.jface.text.rules.Token; >+ >+/** >+ * >+ * @author cnk378 >+ * >+ */ >+public class JADPartitionScanner extends RuleBasedPartitionScanner { >+ >+ public static final String JAD_HEADER = "__mf_jad_header_value"; //$NON-NLS-1$ >+ >+ public static final String[] PARTITIONS = new String[] { JAD_HEADER }; >+ >+ /** >+ * >+ */ >+ public JADPartitionScanner() { >+ IPredicateRule[] rules = new IPredicateRule[1]; >+ rules[0] = new SingleLineRule( >+ ":", null, new Token(JAD_HEADER), '\\', true); //$NON-NLS-1$ >+ setPredicateRules(rules); >+ >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
cnk378
:
review?
Actions:
View
|
Diff
Attachments on
bug 274009
:
143298
| 145828