comparison dwtx/jface/text/source/SourceViewer.d @ 162:1a5b8f8129df

...
author Frank Benoit <benoit@tionex.de>
date Mon, 08 Sep 2008 00:51:37 +0200
parents 3678e4f1a766
children c3583c6ec027
comparison
equal deleted inserted replaced
161:f8d52b926852 162:1a5b8f8129df
227 protected final static String _SELECTION_POSITION_CATEGORY= "__selection_category"; //$NON-NLS-1$ 227 protected final static String _SELECTION_POSITION_CATEGORY= "__selection_category"; //$NON-NLS-1$
228 /** 228 /**
229 * Key of the model annotation model inside the visual annotation model. 229 * Key of the model annotation model inside the visual annotation model.
230 * @since 3.0 230 * @since 3.0
231 */ 231 */
232 protected final static Object MODEL_ANNOTATION_MODEL= new Object(); 232 private static Object MODEL_ANNOTATION_MODEL_;
233 protected static Object MODEL_ANNOTATION_MODEL(){
234 if( MODEL_ANNOTATION_MODEL_ is null ){
235 synchronized(SourceViewer.classinfo ){
236 if( MODEL_ANNOTATION_MODEL_ is null ){
237 MODEL_ANNOTATION_MODEL_ = new Object();
238 }
239 }
240 }
241 return MODEL_ANNOTATION_MODEL_;
242 }
233 243
234 /** The viewer's content assistant */ 244 /** The viewer's content assistant */
235 protected IContentAssistant fContentAssistant; 245 protected IContentAssistant fContentAssistant;
236 /** 246 /**
237 * The viewer's facade to its content assistant. 247 * The viewer's facade to its content assistant.
263 protected IAnnotationHover fAnnotationHover; 273 protected IAnnotationHover fAnnotationHover;
264 /** 274 /**
265 * Stack of saved selections in the underlying document 275 * Stack of saved selections in the underlying document
266 * @since 3.0 276 * @since 3.0
267 */ 277 */
268 protected final Stack fSelections= new Stack(); 278 protected const Stack fSelections;
269 /** 279 /**
270 * Position updater for saved selections 280 * Position updater for saved selections
271 * @since 3.0 281 * @since 3.0
272 */ 282 */
273 protected IPositionUpdater fSelectionUpdater= null; 283 protected IPositionUpdater fSelectionUpdater= null;
342 * @param styles the DWT style bits for the viewer's control, 352 * @param styles the DWT style bits for the viewer's control,
343 * <em>if <code>DWT.WRAP</code> is set then a custom document adapter needs to be provided, see {@link #createDocumentAdapter()} 353 * <em>if <code>DWT.WRAP</code> is set then a custom document adapter needs to be provided, see {@link #createDocumentAdapter()}
344 * @since 2.1 354 * @since 2.1
345 */ 355 */
346 public this(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler, bool showAnnotationsOverview, int styles) { 356 public this(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler, bool showAnnotationsOverview, int styles) {
357 fSelections= new Stack();
347 super(); 358 super();
348 359
349 fVerticalRuler= verticalRuler; 360 fVerticalRuler= verticalRuler;
350 fIsVerticalRulerVisible= (verticalRuler !is null); 361 fIsVerticalRulerVisible= (verticalRuler !is null);
351 fOverviewRuler= overviewRuler; 362 fOverviewRuler= overviewRuler;
792 803
793 final Point selection= getSelectedRange(); 804 final Point selection= getSelectedRange();
794 final IDocument document= getDocument(); 805 final IDocument document= getDocument();
795 806
796 if (fSelections.isEmpty()) { 807 if (fSelections.isEmpty()) {
797 fSelectionCategory= _SELECTION_POSITION_CATEGORY + toHash(); 808 fSelectionCategory= _SELECTION_POSITION_CATEGORY ~ Integer.toString(toHash());
798 fSelectionUpdater= new NonDeletingPositionUpdater(fSelectionCategory); 809 fSelectionUpdater= new NonDeletingPositionUpdater(fSelectionCategory);
799 document.addPositionCategory(fSelectionCategory); 810 document.addPositionCategory(fSelectionCategory);
800 document.addPositionUpdater(fSelectionUpdater); 811 document.addPositionUpdater(fSelectionUpdater);
801 } 812 }
802 813
908 919
909 if ( cast(IContentFormatterExtension)fContentFormatter ) { 920 if ( cast(IContentFormatterExtension)fContentFormatter ) {
910 final IContentFormatterExtension extension= cast(IContentFormatterExtension) fContentFormatter; 921 final IContentFormatterExtension extension= cast(IContentFormatterExtension) fContentFormatter;
911 context= createFormattingContext(); 922 context= createFormattingContext();
912 if (selection.y is 0) { 923 if (selection.y is 0) {
913 context.setProperty(FormattingContextProperties.CONTEXT_DOCUMENT, Boolean.TRUE); 924 context.setProperty(stringcast(FormattingContextProperties.CONTEXT_DOCUMENT), Boolean.TRUE);
914 } else { 925 } else {
915 context.setProperty(FormattingContextProperties.CONTEXT_DOCUMENT, Boolean.FALSE); 926 context.setProperty(stringcast(FormattingContextProperties.CONTEXT_DOCUMENT), Boolean.FALSE);
916 context.setProperty(FormattingContextProperties.CONTEXT_REGION, new Region(selection.x, selection.y)); 927 context.setProperty(stringcast(FormattingContextProperties.CONTEXT_REGION), new Region(selection.x, selection.y));
917 } 928 }
918 extension.format(document, context); 929 extension.format(document, context);
919 } else { 930 } else {
920 IRegion r; 931 IRegion r;
921 if (selection.y is 0) { 932 if (selection.y is 0) {