Source Code Cross Referenced for AnnotationPreference.java in  » IDE-Eclipse » ui-workbench » org » eclipse » ui » texteditor » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Eclipse » ui workbench » org.eclipse.ui.texteditor 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*******************************************************************************
0002:         * Copyright (c) 2000, 2007 IBM Corporation and others.
0003:         * All rights reserved. This program and the accompanying materials
0004:         * are made available under the terms of the Eclipse Public License v1.0
0005:         * which accompanies this distribution, and is available at
0006:         * http://www.eclipse.org/legal/epl-v10.html
0007:         *
0008:         * Contributors:
0009:         *     IBM Corporation - initial API and implementation
0010:         *******************************************************************************/package org.eclipse.ui.texteditor;
0011:
0012:        import java.util.HashMap;
0013:        import java.util.Map;
0014:
0015:        import org.osgi.framework.Bundle;
0016:
0017:        import org.eclipse.core.runtime.CoreException;
0018:        import org.eclipse.core.runtime.IConfigurationElement;
0019:        import org.eclipse.core.runtime.Platform;
0020:
0021:        import org.eclipse.swt.graphics.RGB;
0022:
0023:        import org.eclipse.jface.resource.ImageDescriptor;
0024:
0025:        import org.eclipse.ui.internal.texteditor.TextEditorPlugin;
0026:
0027:        /**
0028:         * An annotation preference provides all the information required for handing
0029:         * the preferences for the presentation of annotations of a specified type. The
0030:         * type can be changed and retrieved using the <code>getAnnotationType</code>
0031:         * and <code>setAnnotationType</code> methods. For each preference, getter and
0032:         * setter methods are provided.
0033:         * <p>
0034:         * Preferences that may be changed by the user also have a corresponding key
0035:         * that can be used to obtain the currently set value from an
0036:         * <code>IPreferenceStore</code>.
0037:         * </p>
0038:         * <h3>The following annotation preferences are covered:</h4>
0039:         * <h4>Display Preferences controlling how and where annotations are shown</h4>
0040:         * <ul>
0041:         * <li>as text background highlighting (and respective preference key),</li>
0042:         * <li>as text decorations (and respective preference key),</li>
0043:         * <li>on the overview ruler (and respective preference key),</li>
0044:         * <li>on the overview ruler header,</li>
0045:         * <li>on the vertical ruler (and respective preference key),</li>
0046:         * </li>
0047:         * </ul>
0048:         * <h4>Additional Display Preferences</h4>
0049:         * <ul>
0050:         * <li>the base color for annotations of this type (and respective preference key),
0051:         * <li>the style of text decorations that are drawn (and respective preference
0052:         * key),</li>
0053:         * <li>the annotation image provider,</li>
0054:         * <li>the quick fix image descriptor,</li>
0055:         * <li>the image descriptor,</li>
0056:         * <li>the symbolic image name,</li>
0057:         * <li>the presentation layer.</li>
0058:         * </ul>
0059:         * <h4>Navigation Preferences</h4>
0060:         * <ul>
0061:         * <li>whether included in the "Go to Next Annotation" navigation action (and
0062:         * respective preference key),</li>
0063:         * <li>whether included in the "Go to Previous Annotation" navigation action
0064:         * (and respective preference key),</li>
0065:         * <li>whether to be shown in the "Go to Next/Previous Annotation" navigation
0066:         * toolbar drop down (and respective preference key).</li>
0067:         * </ul>
0068:         * <h4>Preference Page Preferences</h4>
0069:         * <ul>
0070:         * <li>whether the annotation type should be included on the generic annotation
0071:         * preference page,</li>
0072:         * <li>preference label.</li>
0073:         * </ul>
0074:         *
0075:         * @since 2.1
0076:         */
0077:        public class AnnotationPreference {
0078:
0079:            /* String constants for style enumeration */
0080:
0081:            /**
0082:             * Constant defining no decoration for the show in text style preference.
0083:             * @since 3.0
0084:             */
0085:            public static final String STYLE_NONE = "NONE"; //$NON-NLS-1$
0086:            /**
0087:             * Constant defining squiggly decoration for the show in text style preference.
0088:             * @since 3.0
0089:             */
0090:            public static final String STYLE_SQUIGGLES = "SQUIGGLES"; //$NON-NLS-1$
0091:            /**
0092:             * Constant defining box decoration for the show in text style preference.
0093:             * @since 3.0
0094:             */
0095:            public static final String STYLE_BOX = "BOX"; //$NON-NLS-1$
0096:
0097:            /**
0098:             * Constant defining dashed box decoration for the show in text style preference.
0099:             * @since 3.3
0100:             */
0101:            public static final String STYLE_DASHED_BOX = "DASHED_BOX"; //$NON-NLS-1$
0102:
0103:            /**
0104:             * Constant defining underline decoration for the show in text style preference.
0105:             * @since 3.0
0106:             */
0107:            public static final String STYLE_UNDERLINE = "UNDERLINE"; //$NON-NLS-1$
0108:            /**
0109:             * Constant defining i-beam decoration for the show in text style preference.
0110:             * @since 3.0
0111:             */
0112:            public static final String STYLE_IBEAM = "IBEAM"; //$NON-NLS-1$
0113:
0114:            /* IDs for presentation preference attributes */
0115:
0116:            /**
0117:             * The image to be used for drawing in the vertical ruler.
0118:             * @since 3.0
0119:             */
0120:            protected final static Object IMAGE_DESCRIPTOR = new Object();
0121:            /**
0122:             * The Quick Fix image to be used for drawing in the vertical ruler.
0123:             * @since 3.2
0124:             */
0125:            protected final static Object QUICK_FIX_IMAGE_DESCRIPTOR = new Object();
0126:            /**
0127:             * The preference label.
0128:             * @since 3.0
0129:             */
0130:            protected final static Object PREFERENCE_LABEL = new Object();
0131:            /**
0132:             * The presentation layer.
0133:             * @since 3.0
0134:             */
0135:            protected final static Object PRESENTATION_LAYER = new Object();
0136:            /**
0137:             * The symbolic name of the image to be drawn in the vertical ruler.
0138:             * @since 3.0
0139:             */
0140:            protected final static Object SYMBOLIC_IMAGE_NAME = new Object();
0141:            /**
0142:             * Indicates whether the annotation type contributed to the overview ruler's header.
0143:             * @since 3.0
0144:             */
0145:            protected final static Object HEADER_VALUE = new Object();
0146:            /**
0147:             * The annotation image provider.
0148:             * @since 3.0
0149:             */
0150:            protected final static Object IMAGE_PROVIDER = new Object();
0151:            /**
0152:             * The value for the includeOnPreferencePage property.
0153:             * @since 3.0
0154:             */
0155:            protected final static Object INCLUDE_ON_PREFERENCE_PAGE = new Object();
0156:
0157:            /* IDs for preference store access and initialization */
0158:
0159:            /**
0160:             * The preference key for the visibility inside text.
0161:             * @since 3.0
0162:             */
0163:            protected final static Object TEXT_PREFERENCE_KEY = new Object();
0164:            /**
0165:             * The visibility inside text.
0166:             * @since 3.0
0167:             */
0168:            protected final static Object TEXT_PREFERENCE_VALUE = new Object();
0169:            /**
0170:             * The preference key for the presentation color.
0171:             * @since 3.0
0172:             */
0173:            protected final static Object COLOR_PREFERENCE_KEY = new Object();
0174:            /** The presentation color.
0175:             * @since 3.0
0176:             */
0177:            protected final static Object COLOR_PREFERENCE_VALUE = new Object();
0178:            /**
0179:             * The preference key for highlighting inside text.
0180:             * @since 3.0
0181:             */
0182:            protected final static Object HIGHLIGHT_PREFERENCE_KEY = new Object();
0183:            /**
0184:             * The value for highlighting inside text.
0185:             * @since 3.0
0186:             */
0187:            protected final static Object HIGHLIGHT_PREFERENCE_VALUE = new Object();
0188:            /**
0189:             * The preference key for go to next navigation enablement.
0190:             * @since 3.0
0191:             */
0192:            protected final static Object IS_GO_TO_NEXT_TARGET_KEY = new Object();
0193:            /**
0194:             * The value for go to next navigation enablement.
0195:             * @since 3.0
0196:             */
0197:            protected final static Object IS_GO_TO_NEXT_TARGET_VALUE = new Object();
0198:            /**
0199:             * The preference key for go to previous navigation enablement.
0200:             * @since 3.0
0201:             */
0202:            protected final static Object IS_GO_TO_PREVIOUS_TARGET_KEY = new Object();
0203:            /**
0204:             * The value for go to previous navigation enablement.
0205:             * @since 3.0
0206:             */
0207:            protected final static Object IS_GO_TO_PREVIOUS_TARGET_VALUE = new Object();
0208:            /**
0209:             * The preference key for the visibility in the vertical ruler.
0210:             * @since 3.0
0211:             */
0212:            protected final static Object VERTICAL_RULER_PREFERENCE_KEY = new Object();
0213:            /**
0214:             * The visibility in the vertical ruler.
0215:             * @since 3.0
0216:             */
0217:            protected final static Object VERTICAL_RULER_PREFERENCE_VALUE = new Object();
0218:            /**
0219:             * The preference key for the visibility in the overview ruler.
0220:             * @since 3.0
0221:             */
0222:            protected final static Object OVERVIEW_RULER_PREFERENCE_KEY = new Object();
0223:            /**
0224:             * The visibility in the overview ruler.
0225:             * @since 3.0
0226:             */
0227:            protected final static Object OVERVIEW_RULER_PREFERENCE_VALUE = new Object();
0228:            /**
0229:             * The preference key for the visibility in the next/previous drop down toolbar action.
0230:             * @since 3.0
0231:             */
0232:            protected final static Object SHOW_IN_NAVIGATION_DROPDOWN_KEY = new Object();
0233:            /**
0234:             * The value for the visibility in the next/previous drop down toolbar action.
0235:             * @since 3.0
0236:             */
0237:            protected final static Object SHOW_IN_NAVIGATION_DROPDOWN_VALUE = new Object();
0238:            /**
0239:             * The preference key for the decoration style.
0240:             * @since 3.0
0241:             */
0242:            protected final static Object TEXT_STYLE_PREFERENCE_KEY = new Object();
0243:            /**
0244:             * The value for the text decoration style.
0245:             * @since 3.0
0246:             */
0247:            protected final static Object TEXT_STYLE_PREFERENCE_VALUE = new Object();
0248:
0249:            /**
0250:             * Array of all supported attributes.
0251:             * @since 3.0
0252:             */
0253:            protected final static Object[] ATTRIBUTES = new Object[] {
0254:                    IMAGE_DESCRIPTOR, QUICK_FIX_IMAGE_DESCRIPTOR,
0255:                    PREFERENCE_LABEL, PRESENTATION_LAYER, SYMBOLIC_IMAGE_NAME,
0256:                    HEADER_VALUE, IMAGE_PROVIDER, TEXT_PREFERENCE_KEY,
0257:                    TEXT_PREFERENCE_VALUE, COLOR_PREFERENCE_KEY,
0258:                    COLOR_PREFERENCE_VALUE, HIGHLIGHT_PREFERENCE_KEY,
0259:                    HIGHLIGHT_PREFERENCE_VALUE, IS_GO_TO_NEXT_TARGET_KEY,
0260:                    IS_GO_TO_NEXT_TARGET_VALUE, IS_GO_TO_PREVIOUS_TARGET_KEY,
0261:                    IS_GO_TO_PREVIOUS_TARGET_VALUE,
0262:                    VERTICAL_RULER_PREFERENCE_KEY,
0263:                    VERTICAL_RULER_PREFERENCE_VALUE,
0264:                    OVERVIEW_RULER_PREFERENCE_KEY,
0265:                    OVERVIEW_RULER_PREFERENCE_VALUE,
0266:                    SHOW_IN_NAVIGATION_DROPDOWN_KEY,
0267:                    SHOW_IN_NAVIGATION_DROPDOWN_VALUE,
0268:                    TEXT_STYLE_PREFERENCE_KEY, TEXT_STYLE_PREFERENCE_VALUE,
0269:                    INCLUDE_ON_PREFERENCE_PAGE };
0270:
0271:            /** The annotation type */
0272:            private Object fAnnotationType;
0273:            /** The marker type */
0274:            private String fMarkerType;
0275:            /** The marker severity */
0276:            private int fSeverity;
0277:            /**
0278:             * The annotation image provider.
0279:             * @since 3.0
0280:             */
0281:            public IAnnotationImageProvider fAnnotationImageProvider;
0282:            /**
0283:             * The configuration element from which to create the annotation image provider.
0284:             * @since 3.0
0285:             */
0286:            public IConfigurationElement fConfigurationElement;
0287:            /**
0288:             * The name of the attribute used to load the annotation image provider
0289:             * from the configuration element.
0290:             * @since 3.0
0291:             */
0292:            public String fAnnotationImageProviderAttribute;
0293:            /**
0294:             * The map of attributes.
0295:             * @since 3.0
0296:             */
0297:            private Map fAttributes = new HashMap();
0298:
0299:            /**
0300:             * Creates a new un-initialized annotation preference. Note that instances
0301:             * with a <code>null</code> annotation type are invalid and should not be
0302:             * used.
0303:             */
0304:            public AnnotationPreference() {
0305:            }
0306:
0307:            /**
0308:             * Creates a new annotation preference for the given annotation type.
0309:             *
0310:             * @param annotationType the annotation type
0311:             * @param colorKey the preference key for the presentation color
0312:             * @param textKey the preference key for the visibility inside text
0313:             * @param overviewRulerKey the preference key for the visibility in the
0314:             *        overview ruler
0315:             * @param presentationLayer the presentation layer
0316:             */
0317:            public AnnotationPreference(Object annotationType, String colorKey,
0318:                    String textKey, String overviewRulerKey,
0319:                    int presentationLayer) {
0320:                fAnnotationType = annotationType;
0321:                setValue(COLOR_PREFERENCE_KEY, colorKey);
0322:                setValue(TEXT_PREFERENCE_KEY, textKey);
0323:                setValue(OVERVIEW_RULER_PREFERENCE_KEY, overviewRulerKey);
0324:                setValue(PRESENTATION_LAYER, presentationLayer);
0325:            }
0326:
0327:            /**
0328:             * Sets the given value for the given attribute.
0329:             *
0330:             * @param attribute the attribute
0331:             * @param value the attribute value
0332:             * @since 3.0
0333:             */
0334:            protected void setValue(Object attribute, Object value) {
0335:                fAttributes.put(attribute, value);
0336:            }
0337:
0338:            /**
0339:             * Sets the given value for the given attribute.
0340:             *
0341:             * @param attribute the attribute
0342:             * @param value the attribute value
0343:             * @since 3.0
0344:             */
0345:            protected void setValue(Object attribute, int value) {
0346:                fAttributes.put(attribute, new Integer(value));
0347:            }
0348:
0349:            /**
0350:             * Sets the given value for the given attribute.
0351:             *
0352:             * @param attribute the attribute
0353:             * @param value the attribute value
0354:             * @since 3.0
0355:             */
0356:            protected void setValue(Object attribute, boolean value) {
0357:                fAttributes
0358:                        .put(attribute, value ? Boolean.TRUE : Boolean.FALSE);
0359:            }
0360:
0361:            /**
0362:             * Returns the value of the given attribute as string.
0363:             *
0364:             * @param attribute the attribute
0365:             * @return the attribute value
0366:             * @since 3.0
0367:             */
0368:            protected String getStringValue(Object attribute) {
0369:                Object value = fAttributes.get(attribute);
0370:                if (value instanceof  String)
0371:                    return (String) value;
0372:                return null;
0373:            }
0374:
0375:            /**
0376:             * Returns the value of the given attribute as boolean.
0377:             *
0378:             * @param attribute the attribute
0379:             * @return the attribute value
0380:             * @since 3.0
0381:             */
0382:            protected boolean getBooleanValue(Object attribute) {
0383:                Object value = fAttributes.get(attribute);
0384:                if (value instanceof  Boolean)
0385:                    return ((Boolean) value).booleanValue();
0386:                return false;
0387:            }
0388:
0389:            /**
0390:             * Returns the value of the given attribute as integer.
0391:             *
0392:             * @param attribute the attribute
0393:             * @return the attribute value
0394:             * @since 3.0
0395:             */
0396:            protected int getIntegerValue(Object attribute) {
0397:                Object value = fAttributes.get(attribute);
0398:                if (value instanceof  Integer)
0399:                    return ((Integer) value).intValue();
0400:                return 0;
0401:            }
0402:
0403:            /**
0404:             * Returns the value of the given attribute.
0405:             *
0406:             * @param attribute the attribute
0407:             * @return the attribute value
0408:             * @since 3.0
0409:             */
0410:            public Object getValue(Object attribute) {
0411:                return fAttributes.get(attribute);
0412:            }
0413:
0414:            /**
0415:             * Returns whether the given attribute is defined.
0416:             *
0417:             * @param attribute the attribute
0418:             * @return <code>true</code> if the attribute has a value <code>false</code> otherwise
0419:             * @since 3.0
0420:             */
0421:            public boolean hasValue(Object attribute) {
0422:                return fAttributes.get(attribute) != null;
0423:            }
0424:
0425:            /**
0426:             * Returns whether the given string is a preference key.
0427:             *
0428:             * @param key the string to test
0429:             * @return <code>true</code> if the string is a preference key
0430:             */
0431:            public boolean isPreferenceKey(String key) {
0432:                if (key == null)
0433:                    return false;
0434:
0435:                return key.equals(getStringValue(COLOR_PREFERENCE_KEY))
0436:                        || key
0437:                                .equals(getStringValue(OVERVIEW_RULER_PREFERENCE_KEY))
0438:                        || key.equals(getStringValue(TEXT_PREFERENCE_KEY))
0439:                        || key.equals(getStringValue(HIGHLIGHT_PREFERENCE_KEY))
0440:                        || key
0441:                                .equals(getStringValue(TEXT_STYLE_PREFERENCE_KEY))
0442:                        || key
0443:                                .equals(getStringValue(VERTICAL_RULER_PREFERENCE_KEY));
0444:            }
0445:
0446:            /**
0447:             * Returns the annotation type. Should not be null in a completely set up
0448:             * instance.
0449:             *
0450:             * @return the annotation type, <code>null</code> if the receiver has not
0451:             *         been initialized yet
0452:             */
0453:            public Object getAnnotationType() {
0454:                return fAnnotationType;
0455:            }
0456:
0457:            /**
0458:             * Returns the marker type.
0459:             *
0460:             * @return the marker type, or <code>null</code> if none is set
0461:             * @deprecated since 3.0
0462:             */
0463:            public String getMarkerType() {
0464:                return fMarkerType;
0465:            }
0466:
0467:            /**
0468:             * Returns the marker severity.
0469:             *
0470:             * @return the marker severity
0471:             * @deprecated since 3.0
0472:             */
0473:            public int getSeverity() {
0474:                return fSeverity;
0475:            }
0476:
0477:            /**
0478:             * Sets the annotation type. Note that instances with a <code>null</code>
0479:             * annotation type are considered invalid and should not be used with the
0480:             * framework.
0481:             *
0482:             * @param annotationType the annotation type
0483:             */
0484:            public void setAnnotationType(Object annotationType) {
0485:                fAnnotationType = annotationType;
0486:            }
0487:
0488:            /**
0489:             * Sets the marker type.
0490:             *
0491:             * @param markerType the marker type
0492:             */
0493:            public void setMarkerType(String markerType) {
0494:                fMarkerType = markerType;
0495:            }
0496:
0497:            /**
0498:             * Sets the marker severity.
0499:             *
0500:             * @param severity the marker severity
0501:             */
0502:            public void setSeverity(int severity) {
0503:                fSeverity = severity;
0504:            }
0505:
0506:            /**
0507:             * Returns the preference key for the presentation color.
0508:             *
0509:             * @return the preference key for the presentation color or <code>null</code>
0510:             *         if none is set
0511:             */
0512:            public String getColorPreferenceKey() {
0513:                return getStringValue(COLOR_PREFERENCE_KEY);
0514:            }
0515:
0516:            /**
0517:             * Returns the default presentation color.
0518:             *
0519:             * @return the default presentation color or <code>null</code> if none is
0520:             *         set
0521:             */
0522:            public RGB getColorPreferenceValue() {
0523:                return (RGB) getValue(COLOR_PREFERENCE_VALUE);
0524:            }
0525:
0526:            /**
0527:             * Returns the presentation string for this annotation type.
0528:             *
0529:             * @return the presentation string for this annotation type or <code>null</code>
0530:             *         if none is set
0531:             */
0532:            public String getPreferenceLabel() {
0533:                return getStringValue(PREFERENCE_LABEL);
0534:            }
0535:
0536:            /**
0537:             * Returns the preference key for the visibility in the overview ruler.
0538:             *
0539:             * @return the preference key for the visibility in the overview ruler or
0540:             *         <code>null</code> if none is set
0541:             */
0542:            public String getOverviewRulerPreferenceKey() {
0543:                return getStringValue(OVERVIEW_RULER_PREFERENCE_KEY);
0544:            }
0545:
0546:            /**
0547:             * Returns the default visibility in the overview ruler.
0548:             *
0549:             * @return the default visibility in the overview ruler
0550:             */
0551:            public boolean getOverviewRulerPreferenceValue() {
0552:                return getBooleanValue(OVERVIEW_RULER_PREFERENCE_VALUE);
0553:            }
0554:
0555:            /**
0556:             * Returns the preference key for the visibility in the vertical ruler.
0557:             *
0558:             * @return the preference key for the visibility in the vertical ruler or
0559:             *         <code>null</code> if none is set
0560:             * @since 3.0
0561:             */
0562:            public String getVerticalRulerPreferenceKey() {
0563:                return getStringValue(VERTICAL_RULER_PREFERENCE_KEY);
0564:            }
0565:
0566:            /**
0567:             * Returns the default visibility in the vertical ruler.
0568:             *
0569:             * @return the default visibility in the vertical ruler
0570:             * @since 3.0
0571:             */
0572:            public boolean getVerticalRulerPreferenceValue() {
0573:                return getBooleanValue(VERTICAL_RULER_PREFERENCE_VALUE);
0574:            }
0575:
0576:            /**
0577:             * Returns the presentation layer.
0578:             *
0579:             * @return the presentation layer
0580:             */
0581:            public int getPresentationLayer() {
0582:                return getIntegerValue(PRESENTATION_LAYER);
0583:            }
0584:
0585:            /**
0586:             * Returns the preference key for the visibility inside text.
0587:             *
0588:             * @return the preference key for the visibility inside text or <code>null</code>
0589:             *         if none is set
0590:             */
0591:            public String getTextPreferenceKey() {
0592:                return getStringValue(TEXT_PREFERENCE_KEY);
0593:            }
0594:
0595:            /**
0596:             * Returns the default visibility inside text.
0597:             *
0598:             * @return the default visibility inside text
0599:             */
0600:            public boolean getTextPreferenceValue() {
0601:                return getBooleanValue(TEXT_PREFERENCE_VALUE);
0602:            }
0603:
0604:            /**
0605:             * Returns the preference key for highlighting inside text.
0606:             *
0607:             * @return the preference key for highlighting inside text or <code>null</code>
0608:             *         if none is set
0609:             * @since 3.0
0610:             */
0611:            public String getHighlightPreferenceKey() {
0612:                return getStringValue(HIGHLIGHT_PREFERENCE_KEY);
0613:            }
0614:
0615:            /**
0616:             * Returns the default value for highlighting inside text.
0617:             *
0618:             * @return the default value for highlighting inside text
0619:             * @since 3.0
0620:             */
0621:            public boolean getHighlightPreferenceValue() {
0622:                return getBooleanValue(HIGHLIGHT_PREFERENCE_VALUE);
0623:            }
0624:
0625:            /**
0626:             * Returns whether the annotation type contributes to the header of the overview ruler.
0627:             *
0628:             * @return <code>true</code> if the annotation type contributes to the header of the overview ruler
0629:             */
0630:            public boolean contributesToHeader() {
0631:                return getBooleanValue(HEADER_VALUE);
0632:            }
0633:
0634:            /**
0635:             * Sets the preference key for the presentation color.
0636:             *
0637:             * @param colorKey the preference key
0638:             */
0639:            public void setColorPreferenceKey(String colorKey) {
0640:                setValue(COLOR_PREFERENCE_KEY, colorKey);
0641:            }
0642:
0643:            /**
0644:             * Sets the default presentation color.
0645:             *
0646:             * @param colorValue the default color
0647:             */
0648:            public void setColorPreferenceValue(RGB colorValue) {
0649:                setValue(COLOR_PREFERENCE_VALUE, colorValue);
0650:            }
0651:
0652:            /**
0653:             * Sets the presentation label of this annotation type.
0654:             *
0655:             * @param label the presentation label
0656:             */
0657:            public void setPreferenceLabel(String label) {
0658:                setValue(PREFERENCE_LABEL, label);
0659:            }
0660:
0661:            /**
0662:             * Sets the preference key for the visibility in the overview ruler.
0663:             *
0664:             * @param overviewRulerKey the preference key
0665:             */
0666:            public void setOverviewRulerPreferenceKey(String overviewRulerKey) {
0667:                setValue(OVERVIEW_RULER_PREFERENCE_KEY, overviewRulerKey);
0668:            }
0669:
0670:            /**
0671:             * Sets the default visibility in the overview ruler.
0672:             *
0673:             * @param overviewRulerValue <code>true</code> if visible by default, <code>false</code> otherwise
0674:             */
0675:            public void setOverviewRulerPreferenceValue(
0676:                    boolean overviewRulerValue) {
0677:                setValue(OVERVIEW_RULER_PREFERENCE_VALUE, overviewRulerValue);
0678:            }
0679:
0680:            /**
0681:             * Sets the preference key for the visibility in the vertical ruler.
0682:             *
0683:             * @param verticalRulerKey the preference key
0684:             * @since 3.0
0685:             */
0686:            public void setVerticalRulerPreferenceKey(String verticalRulerKey) {
0687:                setValue(VERTICAL_RULER_PREFERENCE_KEY, verticalRulerKey);
0688:            }
0689:
0690:            /**
0691:             * Sets the default visibility in the vertical ruler.
0692:             *
0693:             * @param verticalRulerValue <code>true</code> if visible by default, <code>false</code> otherwise
0694:             * @since 3.0
0695:             */
0696:            public void setVerticalRulerPreferenceValue(
0697:                    boolean verticalRulerValue) {
0698:                setValue(VERTICAL_RULER_PREFERENCE_VALUE, verticalRulerValue);
0699:            }
0700:
0701:            /**
0702:             * Sets the presentation layer.
0703:             *
0704:             * @param presentationLayer the presentation layer
0705:             */
0706:            public void setPresentationLayer(int presentationLayer) {
0707:                setValue(PRESENTATION_LAYER, presentationLayer);
0708:            }
0709:
0710:            /**
0711:             * Sets the preference key for the visibility of squiggles inside text.
0712:             *
0713:             * @param textKey the preference key
0714:             */
0715:            public void setTextPreferenceKey(String textKey) {
0716:                setValue(TEXT_PREFERENCE_KEY, textKey);
0717:            }
0718:
0719:            /**
0720:             * Sets the default visibility inside text.
0721:             *
0722:             * @param textValue <code>true</code> if visible by default, <code>false</code> otherwise
0723:             */
0724:            public void setTextPreferenceValue(boolean textValue) {
0725:                setValue(TEXT_PREFERENCE_VALUE, textValue);
0726:            }
0727:
0728:            /**
0729:             * Sets the preference key for highlighting inside text.
0730:             *
0731:             * @param highlightKey the preference key
0732:             * @since 3.0
0733:             */
0734:            public void setHighlightPreferenceKey(String highlightKey) {
0735:                setValue(HIGHLIGHT_PREFERENCE_KEY, highlightKey);
0736:            }
0737:
0738:            /**
0739:             * Sets the default value for highlighting inside text.
0740:             *
0741:             * @param highlightValue <code>true</code> if highlighted in text by default, <code>false</code> otherwise
0742:             * @since 3.0
0743:             */
0744:            public void setHighlightPreferenceValue(boolean highlightValue) {
0745:                setValue(HIGHLIGHT_PREFERENCE_VALUE, highlightValue);
0746:            }
0747:
0748:            /**
0749:             * Sets whether the annotation type contributes to the overview ruler's header.
0750:             *
0751:             * @param contributesToHeader <code>true</code> if in header, <code>false</code> otherwise
0752:             */
0753:            public void setContributesToHeader(boolean contributesToHeader) {
0754:                setValue(HEADER_VALUE, contributesToHeader);
0755:            }
0756:
0757:            /**
0758:             * Returns the default value for go to next navigation enablement.
0759:             *
0760:             * @return <code>true</code> if enabled by default
0761:             * @since 3.0
0762:             */
0763:            public boolean isGoToNextNavigationTarget() {
0764:                return getBooleanValue(IS_GO_TO_NEXT_TARGET_VALUE);
0765:            }
0766:
0767:            /**
0768:             * Sets the default value for go to next navigation enablement.
0769:             *
0770:             * @param isGoToNextNavigationTarget <code>true</code> if enabled by default
0771:             * @since 3.0
0772:             */
0773:            public void setIsGoToNextNavigationTarget(
0774:                    boolean isGoToNextNavigationTarget) {
0775:                setValue(IS_GO_TO_NEXT_TARGET_VALUE, isGoToNextNavigationTarget);
0776:            }
0777:
0778:            /**
0779:             * Returns the preference key for go to next navigation enablement.
0780:             *
0781:             * @return the preference key or <code>null</code> if the key is undefined
0782:             * @since 3.0
0783:             */
0784:            public String getIsGoToNextNavigationTargetKey() {
0785:                return getStringValue(IS_GO_TO_NEXT_TARGET_KEY);
0786:            }
0787:
0788:            /**
0789:             * Sets the preference key for go to next navigation enablement.
0790:             *
0791:             * @param isGoToNextNavigationTargetKey <code>true</code> if enabled by default
0792:             * @since 3.0
0793:             */
0794:            public void setIsGoToNextNavigationTargetKey(
0795:                    String isGoToNextNavigationTargetKey) {
0796:                setValue(IS_GO_TO_NEXT_TARGET_KEY,
0797:                        isGoToNextNavigationTargetKey);
0798:            }
0799:
0800:            /**
0801:             * Returns the default value for go to previous navigation enablement.
0802:             *
0803:             * @return <code>true</code> if enabled by default
0804:             * @since 3.0
0805:             */
0806:            public boolean isGoToPreviousNavigationTarget() {
0807:                return getBooleanValue(IS_GO_TO_PREVIOUS_TARGET_VALUE);
0808:            }
0809:
0810:            /**
0811:             * Sets the default value for go to previous navigation enablement.
0812:             *
0813:             * @param isGoToPreviousNavigationTarget <code>true</code> if enabled by default
0814:             * @since 3.0
0815:             */
0816:            public void setIsGoToPreviousNavigationTarget(
0817:                    boolean isGoToPreviousNavigationTarget) {
0818:                setValue(IS_GO_TO_PREVIOUS_TARGET_VALUE,
0819:                        isGoToPreviousNavigationTarget);
0820:            }
0821:
0822:            /**
0823:             * Returns the preference key for go to previous navigation enablement.
0824:             *
0825:             * @return the preference key or <code>null</code> if the key is undefined
0826:             * @since 3.0
0827:             */
0828:            public String getIsGoToPreviousNavigationTargetKey() {
0829:                return getStringValue(IS_GO_TO_PREVIOUS_TARGET_KEY);
0830:            }
0831:
0832:            /**
0833:             * Sets the preference key for go to previous navigation enablement.
0834:             *
0835:             * @param isGoToPreviousNavigationTargetKey the preference key
0836:             * @since 3.0
0837:             */
0838:            public void setIsGoToPreviousNavigationTargetKey(
0839:                    String isGoToPreviousNavigationTargetKey) {
0840:                setValue(IS_GO_TO_PREVIOUS_TARGET_KEY,
0841:                        isGoToPreviousNavigationTargetKey);
0842:            }
0843:
0844:            /**
0845:             * Returns the preference key for the visibility in the next/previous drop down toolbar action.
0846:             *
0847:             * @return the preference key or <code>null</code> if the key is undefined
0848:             * @since 3.0
0849:             */
0850:            public String getShowInNextPrevDropdownToolbarActionKey() {
0851:                return getStringValue(SHOW_IN_NAVIGATION_DROPDOWN_KEY);
0852:            }
0853:
0854:            /**
0855:             * Sets the preference key for the visibility in the next/previous drop down toolbar action.
0856:             *
0857:             * @param showInNextPrevDropdownToolbarActionKey the preference key
0858:             * @since 3.0
0859:             */
0860:            public void setShowInNextPrevDropdownToolbarActionKey(
0861:                    String showInNextPrevDropdownToolbarActionKey) {
0862:                setValue(SHOW_IN_NAVIGATION_DROPDOWN_KEY,
0863:                        showInNextPrevDropdownToolbarActionKey);
0864:            }
0865:
0866:            /**
0867:             * Returns the default value for the visibility in the next/previous drop down toolbar action.
0868:             *
0869:             * @return <code>true</code> if enabled by default
0870:             * @since 3.0
0871:             */
0872:            public boolean isShowInNextPrevDropdownToolbarAction() {
0873:                return getBooleanValue(SHOW_IN_NAVIGATION_DROPDOWN_VALUE);
0874:            }
0875:
0876:            /**
0877:             * Sets the default value for the visibility in the next/previous drop down toolbar action.
0878:             *
0879:             * @param showInNextPrevDropdownToolbarAction <code>true</code> if enabled by default
0880:             * @since 3.0
0881:             */
0882:            public void setShowInNextPrevDropdownToolbarAction(
0883:                    boolean showInNextPrevDropdownToolbarAction) {
0884:                setValue(SHOW_IN_NAVIGATION_DROPDOWN_VALUE,
0885:                        showInNextPrevDropdownToolbarAction);
0886:            }
0887:
0888:            /**
0889:             * Sets the preference key for the text style property.
0890:             *
0891:             * @param key the new key
0892:             * @since 3.0
0893:             */
0894:            public void setTextStylePreferenceKey(String key) {
0895:                setValue(TEXT_STYLE_PREFERENCE_KEY, key);
0896:            }
0897:
0898:            /**
0899:             * Returns the preference key for the decoration style used when the annotation is shown in text.
0900:             *
0901:             * @return the preference key for the decoration style or <code>null</code> if the key is undefined
0902:             * @since 3.0
0903:             */
0904:            public String getTextStylePreferenceKey() {
0905:                return getStringValue(TEXT_STYLE_PREFERENCE_KEY);
0906:            }
0907:
0908:            /**
0909:             * Returns the value for the decoration style used when the annotation is shown in text.
0910:             *
0911:             * @return the value for the decoration style or <code>null</code> if the key is undefined
0912:             * @since 3.0
0913:             */
0914:            public String getTextStyleValue() {
0915:                return getStringValue(TEXT_STYLE_PREFERENCE_VALUE);
0916:            }
0917:
0918:            /**
0919:             * Sets the value for the text style property.
0920:             *
0921:             * @param value the new text decoration style
0922:             * @since 3.0
0923:             */
0924:            public void setTextStyleValue(String value) {
0925:                if (!STYLE_NONE.equals(value) && !STYLE_BOX.equals(value)
0926:                        && !STYLE_DASHED_BOX.equals(value)
0927:                        && !STYLE_IBEAM.equals(value)
0928:                        && !STYLE_SQUIGGLES.equals(value)
0929:                        && !STYLE_UNDERLINE.equals(value))
0930:                    throw new IllegalArgumentException();
0931:
0932:                setValue(TEXT_STYLE_PREFERENCE_VALUE, value);
0933:            }
0934:
0935:            /**
0936:             * Returns the image descriptor for the image to be drawn in the vertical ruler. The provided
0937:             * image is only used, if <code>getAnnotationImageProvider</code> returns <code>null</code>.
0938:             *
0939:             * @return the image descriptor or <code>null</code>
0940:             * @since 3.0
0941:             */
0942:            public ImageDescriptor getImageDescriptor() {
0943:                return (ImageDescriptor) getValue(IMAGE_DESCRIPTOR);
0944:            }
0945:
0946:            /**
0947:             * Sets the image descriptor for the image to be drawn in the vertical ruler.
0948:             *
0949:             * @param descriptor the image descriptor
0950:             * @since 3.0
0951:             */
0952:            public void setImageDescriptor(ImageDescriptor descriptor) {
0953:                setValue(IMAGE_DESCRIPTOR, descriptor);
0954:            }
0955:
0956:            /**
0957:             * Returns the symbolic name of the image to be drawn in the vertical ruler.
0958:             * The image is only used if <code>getImageDescriptor</code> returns <code>null</code>.
0959:             *
0960:             * @return the symbolic name of the image or <code>null</code>
0961:             * @since 3.0
0962:             */
0963:            public String getSymbolicImageName() {
0964:                return getStringValue(SYMBOLIC_IMAGE_NAME);
0965:            }
0966:
0967:            /**
0968:             * Sets the symbolic name of the image to be drawn in the vertical ruler.
0969:             *
0970:             * @param symbolicImageName the symbolic image name
0971:             * @since 3.0
0972:             */
0973:            public void setSymbolicImageName(String symbolicImageName) {
0974:                setValue(SYMBOLIC_IMAGE_NAME, symbolicImageName);
0975:            }
0976:
0977:            /**
0978:             * Returns the annotation image provider. If no default annotation image
0979:             * provider has been set, this method checks whether the annotation image
0980:             * provider data has been set. If so, an annotation image provider is
0981:             * created if the configuration element's plug-in is loaded. When an
0982:             * annotation image provider has been created successfully, it is set as
0983:             * the default annotation image provider.
0984:             *
0985:             * @return the annotation image provider
0986:             * @since 3.0
0987:             */
0988:            public IAnnotationImageProvider getAnnotationImageProvider() {
0989:                if (fAnnotationImageProvider == null) {
0990:                    if (fConfigurationElement != null
0991:                            && fAnnotationImageProviderAttribute != null) {
0992:                        Bundle bundle = Platform
0993:                                .getBundle(fConfigurationElement
0994:                                        .getContributor().getName());
0995:                        if (bundle != null
0996:                                && bundle.getState() == Bundle.ACTIVE) {
0997:                            try {
0998:                                fAnnotationImageProvider = (IAnnotationImageProvider) fConfigurationElement
0999:                                        .createExecutableExtension(fAnnotationImageProviderAttribute);
1000:                            } catch (CoreException x) {
1001:                                TextEditorPlugin.getDefault().getLog().log(
1002:                                        x.getStatus());
1003:                            }
1004:                        }
1005:                    }
1006:                }
1007:                return fAnnotationImageProvider;
1008:            }
1009:
1010:            /**
1011:             * Sets the annotation image provider who provides images for annotations
1012:             * of the specified annotation type.
1013:             *
1014:             * @param provider the annotation image provider
1015:             * @since 3.0
1016:             */
1017:            public void setAnnotationImageProvider(
1018:                    IAnnotationImageProvider provider) {
1019:                fAnnotationImageProvider = provider;
1020:                setValue(IMAGE_PROVIDER, provider != null);
1021:            }
1022:
1023:            /**
1024:             * Sets the data needed to create the annotation image provider.
1025:             *
1026:             * @param configurationElement the configuration element
1027:             * @param annotationImageProviderAttribute the attribute of the
1028:             *            configuration element
1029:             * @since 3.0
1030:             */
1031:            public void setAnnotationImageProviderData(
1032:                    IConfigurationElement configurationElement,
1033:                    String annotationImageProviderAttribute) {
1034:                fConfigurationElement = configurationElement;
1035:                fAnnotationImageProviderAttribute = annotationImageProviderAttribute;
1036:                setValue(IMAGE_PROVIDER,
1037:                        annotationImageProviderAttribute != null);
1038:            }
1039:
1040:            /**
1041:             * Sets the property of this annotation preference whether it should be included
1042:             * on the default annotation preference page.
1043:             *
1044:             * @param includeOnPreferencePage the new value
1045:             * @since 3.0
1046:             */
1047:            public void setIncludeOnPreferencePage(
1048:                    boolean includeOnPreferencePage) {
1049:                setValue(INCLUDE_ON_PREFERENCE_PAGE, includeOnPreferencePage);
1050:            }
1051:
1052:            /**
1053:             * Returns the property of the receiver of whether it should be included on
1054:             * the default annotation preference page.
1055:             *
1056:             * @return the includeOnPreferencePage property
1057:             * @since 3.0
1058:             */
1059:            public boolean isIncludeOnPreferencePage() {
1060:                Object value = fAttributes.get(INCLUDE_ON_PREFERENCE_PAGE);
1061:                if (value instanceof  Boolean)
1062:                    return ((Boolean) value).booleanValue();
1063:                return true;
1064:            }
1065:
1066:            /**
1067:             * Merges the values of the given preference into this preference. Existing
1068:             * values will not be overwritten. Subclasses may extend.
1069:             *
1070:             * @param preference the preference to merge into this preference
1071:             * @since 3.0
1072:             */
1073:            public void merge(AnnotationPreference preference) {
1074:                if (!getAnnotationType().equals(preference.getAnnotationType()))
1075:                    return;
1076:
1077:                for (int i = 0; i < ATTRIBUTES.length; i++) {
1078:                    if (!hasValue(ATTRIBUTES[i]))
1079:                        setValue(ATTRIBUTES[i], preference
1080:                                .getValue(ATTRIBUTES[i]));
1081:                }
1082:
1083:                if (fAnnotationImageProvider == null)
1084:                    fAnnotationImageProvider = preference.fAnnotationImageProvider;
1085:                if (fConfigurationElement == null)
1086:                    fConfigurationElement = preference.fConfigurationElement;
1087:                if (fAnnotationImageProviderAttribute == null)
1088:                    fAnnotationImageProviderAttribute = preference.fAnnotationImageProviderAttribute;
1089:            }
1090:
1091:            /**
1092:             * Sets the Quick Fix image descriptor for the image to be drawn in the vertical ruler.
1093:             *
1094:             * @param descriptor the image descriptor
1095:             * @since 3.2
1096:             */
1097:            public void setQuickFixImageDescriptor(ImageDescriptor descriptor) {
1098:                setValue(QUICK_FIX_IMAGE_DESCRIPTOR, descriptor);
1099:            }
1100:
1101:            /**
1102:             * Returns the Quick Fix image descriptor for the image to be drawn in the vertical ruler. The provided
1103:             * image is only used, if <code>getAnnotationImageProvider</code> returns <code>null</code>.
1104:             *
1105:             * @return the image descriptor or <code>null</code>
1106:             * @since 3.2
1107:             */
1108:            public ImageDescriptor getQuickFixImageDescriptor() {
1109:                return (ImageDescriptor) getValue(QUICK_FIX_IMAGE_DESCRIPTOR);
1110:            }
1111:
1112:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.