1 11 package org.eclipse.jdt.internal.ui.propertiesfileeditor; 12 13 import org.eclipse.swt.SWT; 14 15 import org.eclipse.jface.preference.IPreferenceStore; 16 import org.eclipse.jface.util.PropertyChangeEvent; 17 18 import org.eclipse.jface.text.source.ISourceViewer; 19 20 import org.eclipse.ui.IPageLayout; 21 import org.eclipse.ui.part.IShowInTargetList; 22 23 import org.eclipse.ui.editors.text.TextEditor; 24 25 import org.eclipse.jdt.ui.JavaUI; 26 import org.eclipse.jdt.ui.actions.IJavaEditorActionDefinitionIds; 27 import org.eclipse.jdt.ui.actions.JdtActionConstants; 28 import org.eclipse.jdt.ui.text.JavaTextTools; 29 30 import org.eclipse.jdt.internal.ui.JavaPlugin; 31 32 37 public class PropertiesFileEditor extends TextEditor { 38 39 40 41 protected OpenAction fOpenAction; 42 43 44 47 public PropertiesFileEditor() { 48 setDocumentProvider(JavaPlugin.getDefault().getPropertiesFileDocumentProvider()); 49 IPreferenceStore store= JavaPlugin.getDefault().getCombinedPreferenceStore(); 50 setPreferenceStore(store); 51 JavaTextTools textTools= JavaPlugin.getDefault().getJavaTextTools(); 52 setSourceViewerConfiguration(new PropertiesFileSourceViewerConfiguration(textTools.getColorManager(), store, this, IPropertiesFilePartitions.PROPERTIES_FILE_PARTITIONING)); 53 } 54 55 56 59 protected void createActions() { 60 super.createActions(); 61 62 fOpenAction= new OpenAction(this); 63 fOpenAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_EDITOR); 64 setAction(JdtActionConstants.OPEN, fOpenAction); 65 } 66 67 70 protected void handlePreferenceStoreChanged(PropertyChangeEvent event) { 71 72 try { 73 74 ISourceViewer sourceViewer= getSourceViewer(); 75 if (sourceViewer == null) 76 return; 77 78 ((PropertiesFileSourceViewerConfiguration) getSourceViewerConfiguration()).handlePropertyChangeEvent(event); 79 80 } finally { 81 super.handlePreferenceStoreChanged(event); 82 } 83 } 84 85 88 protected boolean affectsTextPresentation(PropertyChangeEvent event) { 89 return ((PropertiesFileSourceViewerConfiguration)getSourceViewerConfiguration()).affectsTextPresentation(event) || super.affectsTextPresentation(event); 90 } 91 92 93 96 public Object getAdapter(Class adapter) { 97 if (adapter == IShowInTargetList.class) { 98 return new IShowInTargetList() { 99 public String [] getShowInTargetIds() { 100 return new String [] { JavaUI.ID_PACKAGES, IPageLayout.ID_RES_NAV }; 101 } 102 103 }; 104 } 105 return super.getAdapter(adapter); 106 } 107 108 112 public int getOrientation() { 113 return SWT.LEFT_TO_RIGHT; } 115 116 119 protected void updateStatusField(String category) { 120 super.updateStatusField(category); 121 if (getEditorSite() != null) { 122 getEditorSite().getActionBars().getStatusLineManager().setMessage(null); 123 getEditorSite().getActionBars().getStatusLineManager().setErrorMessage(null); 124 } 125 } 126 127 130 ISourceViewer internalGetSourceViewer() { 131 return getSourceViewer(); 132 } 133 134 138 protected String [] collectContextMenuPreferencePages() { 139 String [] ids= super.collectContextMenuPreferencePages(); 140 String [] more= new String [ids.length + 1]; 141 more[0]= "org.eclipse.jdt.ui.preferences.PropertiesFileEditorPreferencePage"; System.arraycopy(ids, 0, more, 1, ids.length); 143 return more; 144 } 145 } 146 | Popular Tags |