| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012, the Dart project authors. | 2 * Copyright (c) 2012, the Dart project authors. |
| 3 * | 3 * |
| 4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u
se this file except | 4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u
se this file except |
| 5 * in compliance with the License. You may obtain a copy of the License at | 5 * in compliance with the License. You may obtain a copy of the License at |
| 6 * | 6 * |
| 7 * http://www.eclipse.org/legal/epl-v10.html | 7 * http://www.eclipse.org/legal/epl-v10.html |
| 8 * | 8 * |
| 9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License | 9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License |
| 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express | 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express |
| 11 * or implied. See the License for the specific language governing permissions a
nd limitations under | 11 * or implied. See the License for the specific language governing permissions a
nd limitations under |
| 12 * the License. | 12 * the License. |
| 13 */ | 13 */ |
| 14 package com.google.dart.tools.ui.web.utils; | 14 package com.google.dart.tools.ui.web.utils; |
| 15 | 15 |
| 16 import com.google.dart.tools.core.DartCore; | |
| 17 import com.google.dart.tools.ui.DartToolsPlugin; | 16 import com.google.dart.tools.ui.DartToolsPlugin; |
| 18 import com.google.dart.tools.ui.PreferenceConstants; | 17 import com.google.dart.tools.ui.PreferenceConstants; |
| 19 import com.google.dart.tools.ui.internal.text.editor.saveactions.RemoveTrailingW
hitespaceAction; | 18 import com.google.dart.tools.ui.internal.text.editor.saveactions.RemoveTrailingW
hitespaceAction; |
| 20 import com.google.dart.tools.ui.internal.text.functions.PreferencesAdapter; | |
| 21 | 19 |
| 22 import org.eclipse.core.resources.IFile; | 20 import org.eclipse.core.resources.IFile; |
| 23 import org.eclipse.core.runtime.IProgressMonitor; | 21 import org.eclipse.core.runtime.IProgressMonitor; |
| 24 import org.eclipse.jface.action.IMenuManager; | 22 import org.eclipse.jface.action.IMenuManager; |
| 25 import org.eclipse.jface.preference.IPreferenceStore; | 23 import org.eclipse.jface.preference.IPreferenceStore; |
| 26 import org.eclipse.jface.text.DocumentEvent; | 24 import org.eclipse.jface.text.DocumentEvent; |
| 27 import org.eclipse.jface.text.IDocument; | 25 import org.eclipse.jface.text.IDocument; |
| 28 import org.eclipse.jface.text.IDocumentListener; | 26 import org.eclipse.jface.text.IDocumentListener; |
| 29 import org.eclipse.jface.text.IRegion; | 27 import org.eclipse.jface.text.IRegion; |
| 30 import org.eclipse.swt.widgets.Composite; | 28 import org.eclipse.swt.widgets.Composite; |
| 31 import org.eclipse.ui.IEditorInput; | 29 import org.eclipse.ui.IEditorInput; |
| 32 import org.eclipse.ui.IFileEditorInput; | 30 import org.eclipse.ui.IFileEditorInput; |
| 33 import org.eclipse.ui.editors.text.EditorsUI; | |
| 34 import org.eclipse.ui.editors.text.TextEditor; | 31 import org.eclipse.ui.editors.text.TextEditor; |
| 35 import org.eclipse.ui.texteditor.ChainedPreferenceStore; | |
| 36 import org.eclipse.ui.texteditor.ITextEditorActionConstants; | 32 import org.eclipse.ui.texteditor.ITextEditorActionConstants; |
| 37 | 33 |
| 38 import java.lang.reflect.InvocationTargetException; | 34 import java.lang.reflect.InvocationTargetException; |
| 39 import java.util.ArrayList; | |
| 40 import java.util.List; | |
| 41 | 35 |
| 42 /** | 36 /** |
| 43 * The abstract superclass of the html and css editors. | 37 * The abstract superclass of the html and css editors. |
| 44 */ | 38 */ |
| 45 public abstract class WebEditor extends TextEditor { | 39 public abstract class WebEditor extends TextEditor { |
| 46 | 40 |
| 47 public final static String MATCHING_BRACKETS = "matchingBrackets"; | 41 public final static String MATCHING_BRACKETS = "matchingBrackets"; |
| 48 public final static String MATCHING_BRACKETS_COLOR = "matchingBracketsColor"; | 42 public final static String MATCHING_BRACKETS_COLOR = "matchingBracketsColor"; |
| 49 | 43 |
| 50 /** | 44 /** |
| 51 * Removes trailing whitespace on editor saves. | 45 * Removes trailing whitespace on editor saves. |
| 52 */ | 46 */ |
| 53 private RemoveTrailingWhitespaceAction removeTrailingWhitespaceAction; | 47 private RemoveTrailingWhitespaceAction removeTrailingWhitespaceAction; |
| 54 | 48 |
| 55 public WebEditor() { | 49 public WebEditor() { |
| 56 setPreferenceStore(createPreferenceStore()); | 50 // Enable bracket highlighting in the preference store. |
| 51 IPreferenceStore store = getPreferenceStore(); |
| 52 |
| 53 store.setDefault(MATCHING_BRACKETS, true); |
| 54 store.setDefault(MATCHING_BRACKETS_COLOR, "128,128,128"); |
| 57 } | 55 } |
| 58 | 56 |
| 59 @Override | 57 @Override |
| 60 public void createPartControl(Composite parent) { | 58 public void createPartControl(Composite parent) { |
| 61 super.createPartControl(parent); | 59 super.createPartControl(parent); |
| 62 | 60 |
| 63 getDocument().addDocumentListener(new IDocumentListener() { | 61 getDocument().addDocumentListener(new IDocumentListener() { |
| 64 @Override | 62 @Override |
| 65 public void documentAboutToBeChanged(DocumentEvent event) { | 63 public void documentAboutToBeChanged(DocumentEvent event) { |
| 66 | 64 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 } | 151 } |
| 154 | 152 |
| 155 @Override | 153 @Override |
| 156 protected void rulerContextMenuAboutToShow(IMenuManager menu) { | 154 protected void rulerContextMenuAboutToShow(IMenuManager menu) { |
| 157 super.rulerContextMenuAboutToShow(menu); | 155 super.rulerContextMenuAboutToShow(menu); |
| 158 | 156 |
| 159 // Remove the Preferences menu item | 157 // Remove the Preferences menu item |
| 160 menu.remove(ITextEditorActionConstants.RULER_PREFERENCES); | 158 menu.remove(ITextEditorActionConstants.RULER_PREFERENCES); |
| 161 } | 159 } |
| 162 | 160 |
| 163 private IPreferenceStore createPreferenceStore() { | |
| 164 List<IPreferenceStore> stores = new ArrayList<IPreferenceStore>(); | |
| 165 | |
| 166 stores.add(DartToolsPlugin.getDefault().getPreferenceStore()); | |
| 167 stores.add(new PreferencesAdapter(DartCore.getPlugin().getPluginPreferences(
))); | |
| 168 stores.add(EditorsUI.getPreferenceStore()); | |
| 169 | |
| 170 return new ChainedPreferenceStore(stores.toArray(new IPreferenceStore[stores
.size()])); | |
| 171 } | |
| 172 | |
| 173 } | 161 } |
| OLD | NEW |