From 83a33734d277f2b7c7209aa48a6f004357fd424d Mon Sep 17 00:00:00 2001 From: nitind Date: Wed, 12 Jan 2011 19:37:21 +0000 Subject: This commit was manufactured by cvs2svn to create tag 'v201101121937'. --- .../wst/css/core/internal/CSSCoreMessages.java | 31 - .../wst/css/core/internal/CSSCorePlugin.java | 62 - .../internal/CSSCorePluginResources.properties | 14 - .../org/eclipse/wst/css/core/internal/Logger.java | 156 - .../core/internal/cleanup/CSSCleanupStrategy.java | 98 - .../internal/cleanup/CSSCleanupStrategyImpl.java | 190 -- .../core/internal/cleanup/CleanupProcessorCSS.java | 101 - .../core/internal/contentmodel/IMediaGroupID.java | 34 - .../wst/css/core/internal/contentmodel/IValID.java | 285 -- .../internal/contentmodel/PropCMContainer.java | 164 -- .../internal/contentmodel/PropCMFontProperty.java | 198 -- .../core/internal/contentmodel/PropCMFunction.java | 89 - .../css/core/internal/contentmodel/PropCMNode.java | 1521 ---------- .../core/internal/contentmodel/PropCMNumber.java | 219 -- .../core/internal/contentmodel/PropCMProperty.java | 440 --- .../core/internal/contentmodel/PropCMString.java | 85 - .../internal/contentmodel/PropCMSubProperty.java | 122 - .../core/internal/contentmodel/PropCMURange.java | 81 - .../css/core/internal/contentmodel/PropCMUtil.java | 48 - .../contentproperties/CSSContentProperties.java | 194 -- .../CSSContentPropertiesManager.java | 239 -- .../css/core/internal/contenttype/ByteReader.java | 109 - .../internal/contenttype/CSSHeadTokenizer.java | 1440 ---------- .../contenttype/CSSHeadTokenizerConstants.java | 19 - .../contenttype/CSSResourceEncodingDetector.java | 367 --- .../contenttype/ContentDescriberForCSS.java | 200 -- .../core/internal/contenttype/EncodingGuesser.java | 173 -- .../core/internal/contenttype/HeadParserToken.java | 44 - .../css/core/internal/contenttype/IntStack.java | 114 - .../internal/document/AbstractCSSNodeList.java | 63 - .../css/core/internal/document/CSSAttrImpl.java | 133 - .../core/internal/document/CSSCharsetRuleImpl.java | 79 - .../document/CSSDeclarationItemParser.java | 1075 ------- .../core/internal/document/CSSDocumentImpl.java | 163 -- .../internal/document/CSSFontFaceRuleImpl.java | 67 - .../core/internal/document/CSSImportRuleImpl.java | 227 -- .../core/internal/document/CSSMediaRuleImpl.java | 230 -- .../internal/document/CSSModelCreationContext.java | 155 - .../internal/document/CSSModelDeletionContext.java | 266 -- .../css/core/internal/document/CSSModelImpl.java | 627 ---- .../core/internal/document/CSSModelNodeFeeder.java | 126 - .../css/core/internal/document/CSSModelParser.java | 1317 --------- .../internal/document/CSSModelUpdateContext.java | 416 --- .../core/internal/document/CSSModelUpdater.java | 518 ---- .../css/core/internal/document/CSSModelUtil.java | 291 -- .../internal/document/CSSNamedNodeMapImpl.java | 48 - .../css/core/internal/document/CSSNodeImpl.java | 470 --- .../core/internal/document/CSSNodeListImpl.java | 27 - .../core/internal/document/CSSPageRuleImpl.java | 98 - .../internal/document/CSSPrimitiveContainer.java | 39 - .../internal/document/CSSPrimitiveValueImpl.java | 362 --- .../core/internal/document/CSSRegionContainer.java | 202 -- .../internal/document/CSSRuleDeclContainer.java | 56 - .../css/core/internal/document/CSSRuleImpl.java | 80 - .../core/internal/document/CSSRuleListImpl.java | 45 - .../css/core/internal/document/CSSSelector.java | 415 --- .../internal/document/CSSSelectorCombinator.java | 76 - .../core/internal/document/CSSSelectorItem.java | 42 - .../internal/document/CSSSelectorListImpl.java | 207 -- .../core/internal/document/CSSSelectorParser.java | 335 --- .../core/internal/document/CSSSimpleSelector.java | 281 -- .../CSSStructuredDocumentRegionContainer.java | 229 -- .../internal/document/CSSStyleDeclItemImpl.java | 272 -- .../CSSStyleDeclarationFactoryContext.java | 69 - .../internal/document/CSSStyleDeclarationImpl.java | 272 -- .../core/internal/document/CSSStyleRuleImpl.java | 98 - .../core/internal/document/CSSStyleSheetImpl.java | 654 ----- .../core/internal/document/CSSUnknownRuleImpl.java | 70 - .../css/core/internal/document/CounterImpl.java | 124 - .../wst/css/core/internal/document/DOMCSSImpl.java | 49 - .../css/core/internal/document/MediaListImpl.java | 155 - .../css/core/internal/document/RGBColorImpl.java | 104 - .../wst/css/core/internal/document/RectImpl.java | 118 - .../core/internal/document/StyleSheetListImpl.java | 44 - .../encoding/CSSDocumentCharsetDetector.java | 126 - .../core/internal/encoding/CSSDocumentLoader.java | 91 - .../css/core/internal/event/ICSSStyleListener.java | 32 - .../css/core/internal/event/ICSSStyleNotifier.java | 40 - .../eventimpl/CSSEmbededStyleNotifyAdapter.java | 60 - .../internal/eventimpl/CSSStyleEventDeliverer.java | 155 - .../internal/eventimpl/CSSStyleNotifyAdapter.java | 174 -- .../core/internal/format/FormatProcessorCSS.java | 123 - .../formatter/AbstractCSSSourceFormatter.java | 1021 ------- .../core/internal/formatter/AttrChangeContext.java | 29 - .../css/core/internal/formatter/AttrFormatter.java | 168 -- .../css/core/internal/formatter/CSSFormatUtil.java | 165 -- .../internal/formatter/CSSSourceFormatter.java | 48 - .../formatter/CSSSourceFormatterFactory.java | 81 - .../internal/formatter/CSSSourceGenerator.java | 61 - .../internal/formatter/CharsetRuleFormatter.java | 184 -- .../core/internal/formatter/CompoundRegion.java | 58 - .../core/internal/formatter/CounterFormatter.java | 319 --- .../internal/formatter/DeclContainerFormatter.java | 119 - .../formatter/DefaultCSSSourceFormatter.java | 108 - .../internal/formatter/FontFaceRuleFormatter.java | 97 - .../css/core/internal/formatter/FormatRegion.java | 71 - .../core/internal/formatter/FunctionFormatter.java | 184 -- .../internal/formatter/ImportRuleFormatter.java | 339 --- .../internal/formatter/MediaListFormatter.java | 211 -- .../internal/formatter/MediaRuleFormatter.java | 357 --- .../core/internal/formatter/PageRuleFormatter.java | 194 -- .../formatter/PrimitiveValueFormatter.java | 273 -- .../css/core/internal/formatter/RGBFormatter.java | 44 - .../css/core/internal/formatter/RectFormatter.java | 44 - .../internal/formatter/StyleDeclItemFormatter.java | 406 --- .../formatter/StyleDeclarationFormatter.java | 325 --- .../internal/formatter/StyleRuleFormatter.java | 166 -- .../internal/formatter/StyleSheetFormatter.java | 264 -- .../internal/formatter/UnknownRuleFormatter.java | 86 - .../css/core/internal/metamodel/CSSMMCategory.java | 16 - .../core/internal/metamodel/CSSMMCharsetRule.java | 18 - .../core/internal/metamodel/CSSMMContainer.java | 18 - .../core/internal/metamodel/CSSMMDescriptor.java | 20 - .../core/internal/metamodel/CSSMMFontFaceRule.java | 18 - .../css/core/internal/metamodel/CSSMMFunction.java | 18 - .../core/internal/metamodel/CSSMMImportRule.java | 18 - .../css/core/internal/metamodel/CSSMMKeyword.java | 18 - .../core/internal/metamodel/CSSMMMediaRule.java | 18 - .../wst/css/core/internal/metamodel/CSSMMNode.java | 51 - .../css/core/internal/metamodel/CSSMMNumber.java | 18 - .../css/core/internal/metamodel/CSSMMPageRule.java | 18 - .../css/core/internal/metamodel/CSSMMProperty.java | 22 - .../css/core/internal/metamodel/CSSMMSelector.java | 29 - .../css/core/internal/metamodel/CSSMMString.java | 17 - .../core/internal/metamodel/CSSMMStyleRule.java | 18 - .../core/internal/metamodel/CSSMMStyleSheet.java | 18 - .../wst/css/core/internal/metamodel/CSSMMUnit.java | 18 - .../css/core/internal/metamodel/CSSMetaModel.java | 37 - .../css/core/internal/metamodel/CSSProfile.java | 31 - .../internal/metamodel/CSSProfileRegistry.java | 84 - .../internal/metamodel/util/CSSFunctionID.java | 22 - .../core/internal/metamodel/util/CSSKeywordID.java | 261 -- .../metamodel/util/CSSMMTypeCollector.java | 62 - .../internal/metamodel/util/CSSMediaGroupID.java | 29 - .../metamodel/util/CSSMetaModelFinder.java | 51 - .../metamodel/util/CSSMetaModelTraverser.java | 92 - .../internal/metamodel/util/CSSMetaModelUtil.java | 120 - .../core/internal/metamodel/util/CSSNumberID.java | 23 - .../internal/metamodel/util/CSSProfileFinder.java | 90 - .../internal/metamodel/util/CSSPropertyID.java | 137 - .../core/internal/metamodel/util/CSSStringID.java | 22 - .../core/internal/metamodel/util/CSSUnitID.java | 34 - .../internal/metamodelimpl/CSSMMCategoryImpl.java | 75 - .../metamodelimpl/CSSMMCharsetRuleImpl.java | 45 - .../internal/metamodelimpl/CSSMMContainerImpl.java | 63 - .../metamodelimpl/CSSMMDescriptorImpl.java | 75 - .../metamodelimpl/CSSMMFontFaceRuleImpl.java | 45 - .../internal/metamodelimpl/CSSMMFunctionImpl.java | 96 - .../metamodelimpl/CSSMMImportRuleImpl.java | 44 - .../internal/metamodelimpl/CSSMMKeywordImpl.java | 75 - .../internal/metamodelimpl/CSSMMMediaRuleImpl.java | 41 - .../core/internal/metamodelimpl/CSSMMNodeImpl.java | 148 - .../internal/metamodelimpl/CSSMMNumberImpl.java | 52 - .../internal/metamodelimpl/CSSMMPageRuleImpl.java | 50 - .../internal/metamodelimpl/CSSMMPropertyImpl.java | 76 - .../metamodelimpl/CSSMMPseudoClassImpl.java | 33 - .../metamodelimpl/CSSMMPseudoElementImpl.java | 42 - .../metamodelimpl/CSSMMSelectorExpressionImpl.java | 49 - .../internal/metamodelimpl/CSSMMSelectorImpl.java | 81 - .../internal/metamodelimpl/CSSMMStringImpl.java | 86 - .../internal/metamodelimpl/CSSMMStyleRuleImpl.java | 50 - .../metamodelimpl/CSSMMStyleSheetImpl.java | 50 - .../core/internal/metamodelimpl/CSSMMUnitImpl.java | 108 - .../internal/metamodelimpl/CSSMetaModelImpl.java | 95 - .../internal/metamodelimpl/CSSProfileImpl.java | 263 -- .../internal/metamodelimpl/CSSProfileTest.java | 73 - .../internal/metamodelimpl/MetaModelErrors.java | 30 - .../css/core/internal/metamodelimpl/NodePool.java | 171 -- .../internal/metamodelimpl/ProfileHandler.java | 302 -- .../internal/metamodelimpl/ProfileKeywords.java | 58 - .../core/internal/metamodelimpl/ProfileLoader.java | 72 - .../internal/metamodelimpl/RegistryReader.java | 113 - .../internal/metamodelimpl/ValueCollector.java | 50 - .../core/internal/metamodelimpl/XMLReaderUtil.java | 38 - .../core/internal/modelhandler/CSSModelLoader.java | 54 - .../internal/modelhandler/ModelHandlerForCSS.java | 56 - .../css/core/internal/parser/CSSRegionUtil.java | 51 - .../css/core/internal/parser/CSSSourceParser.java | 255 -- .../parser/CSSStructuredDocumentRegionFactory.java | 27 - .../wst/css/core/internal/parser/CSSTokenizer.java | 1942 ------------- .../css/core/internal/parser/ICSSTokenizer.java | 37 - .../parser/regions/CSSTextRegionFactory.java | 35 - .../core/internal/parserz/CSSRegionContexts.java | 80 - .../css/core/internal/parserz/CSSTextParser.java | 101 - .../css/core/internal/parserz/CSSTextToken.java | 23 - .../preferences/CSSCorePreferenceInitializer.java | 73 - .../preferences/CSSCorePreferenceNames.java | 144 - .../provisional/adapters/ICSSModelAdapter.java | 24 - .../provisional/adapters/IModelProvideAdapter.java | 35 - .../adapters/IStyleDeclarationAdapter.java | 25 - .../adapters/IStyleSelectorAdapter.java | 33 - .../provisional/adapters/IStyleSheetAdapter.java | 41 - .../adapters/IStyleSheetListAdapter.java | 41 - .../contenttype/ContentTypeIdForCSS.java | 30 - .../internal/provisional/document/ICSSAccess.java | 26 - .../internal/provisional/document/ICSSAttr.java | 40 - .../provisional/document/ICSSCharsetRule.java | 23 - .../provisional/document/ICSSDocument.java | 94 - .../provisional/document/ICSSImportRule.java | 34 - .../provisional/document/ICSSMediaRule.java | 22 - .../internal/provisional/document/ICSSModel.java | 46 - .../provisional/document/ICSSNamedNodeMap.java | 26 - .../internal/provisional/document/ICSSNode.java | 68 - .../provisional/document/ICSSNodeList.java | 26 - .../provisional/document/ICSSPageRule.java | 22 - .../provisional/document/ICSSPrimitiveValue.java | 46 - .../provisional/document/ICSSRuleContainer.java | 60 - .../provisional/document/ICSSSelector.java | 62 - .../document/ICSSSelectorCombinator.java | 29 - .../provisional/document/ICSSSelectorItem.java | 32 - .../provisional/document/ICSSSelectorList.java | 62 - .../provisional/document/ICSSSimpleSelector.java | 77 - .../provisional/document/ICSSStyleDeclItem.java | 73 - .../provisional/document/ICSSStyleDeclaration.java | 24 - .../provisional/document/ICSSStyleRule.java | 22 - .../provisional/document/ICSSStyleSheet.java | 56 - .../internal/provisional/document/ICSSValue.java | 26 - .../provisional/document/ICSSValueList.java | 35 - .../internal/provisional/document/ICounter.java | 49 - .../document/IDOMImplementationCSS.java | 23 - .../provisional/document/IDocumentStyle.java | 62 - .../preferences/CSSPreferenceHelper.java | 229 -- .../provisional/text/ICSSPartitionTypes.java | 25 - .../core/internal/tasks/CSSFileTaskScanner.java | 36 - .../text/CSSStructuredDocumentReParser.java | 418 --- .../text/CSSStructuredDocumentRegionFactory.java | 39 - .../internal/text/StructuredDocumentWalker.java | 169 -- .../text/StructuredTextPartitionerForCSS.java | 60 - .../core/internal/util/AbstractCssTraverser.java | 181 -- .../css/core/internal/util/CSSClassTraverser.java | 114 - .../css/core/internal/util/CSSLinkConverter.java | 188 -- .../wst/css/core/internal/util/CSSPathService.java | 77 - .../core/internal/util/CSSSelectorListFactory.java | 35 - .../internal/util/CSSStyleDeclarationFactory.java | 61 - .../wst/css/core/internal/util/CSSUtil.java | 335 --- .../core/internal/util/ImportRuleCollector.java | 71 - .../css/core/internal/util/ImportedCollector.java | 61 - .../wst/css/core/internal/util/RegionIterator.java | 140 - .../css/core/internal/util/SelectionCollector.java | 76 - .../css/core/internal/util/SelectorValidator.java | 97 - .../css/core/internal/util/SelectorsCollector.java | 101 - .../wst/css/core/internal/util/URLHelper.java | 210 -- .../core/internal/util/URLModelProviderCSS.java | 387 --- .../BackgroundPositionXSubStyleAdapter.java | 142 - .../BackgroundPositionYSubStyleAdapter.java | 150 - .../declaration/BackgroundShorthandAdapter.java | 179 -- .../declaration/BorderBottomShorthandAdapter.java | 140 - .../declaration/BorderColorShorthandAdapter.java | 158 -- .../declaration/BorderLeftShorthandAdapter.java | 140 - .../declaration/BorderRightShorthandAdapter.java | 140 - .../util/declaration/BorderShorthandAdapter.java | 140 - .../declaration/BorderStyleShorthandAdapter.java | 130 - .../declaration/BorderTopShorthandAdapter.java | 140 - .../declaration/BorderWidthShorthandAdapter.java | 130 - .../util/declaration/CSSPropertyContext.java | 2997 -------------------- .../declaration/ClipBottomSubStyleAdapter.java | 53 - .../util/declaration/ClipLeftSubStyleAdapter.java | 53 - .../util/declaration/ClipRightSubStyleAdapter.java | 53 - .../util/declaration/ClipSubStyleAdapter.java | 132 - .../util/declaration/ClipTopSubStyleAdapter.java | 53 - .../util/declaration/FontShorthandAdapter.java | 240 -- .../internal/util/declaration/ICSS2Properties.java | 127 - .../util/declaration/IShorthandAdapter.java | 31 - .../util/declaration/ISubPropertyAdapter.java | 29 - .../declaration/ListStyleShorthandAdapter.java | 110 - .../util/declaration/MarginShorthandAdapter.java | 129 - .../util/declaration/PaddingShorthandAdapter.java | 129 - .../core/internal/util/declaration/ValueData.java | 45 - .../eclipse/wst/css/core/text/ICSSPartitions.java | 25 - 269 files changed, 41146 deletions(-) delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/CSSCoreMessages.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/CSSCorePlugin.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/CSSCorePluginResources.properties delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/Logger.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/cleanup/CSSCleanupStrategy.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/cleanup/CSSCleanupStrategyImpl.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/cleanup/CleanupProcessorCSS.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/IMediaGroupID.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/IValID.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMContainer.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMFontProperty.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMFunction.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMNode.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMNumber.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMProperty.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMString.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMSubProperty.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMURange.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMUtil.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentproperties/CSSContentProperties.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentproperties/CSSContentPropertiesManager.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/ByteReader.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/CSSHeadTokenizer.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/CSSHeadTokenizerConstants.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/CSSResourceEncodingDetector.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/ContentDescriberForCSS.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/EncodingGuesser.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/HeadParserToken.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/IntStack.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/AbstractCSSNodeList.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSAttrImpl.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSCharsetRuleImpl.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSDeclarationItemParser.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSDocumentImpl.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSFontFaceRuleImpl.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSImportRuleImpl.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSMediaRuleImpl.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelCreationContext.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelDeletionContext.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelImpl.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelNodeFeeder.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelParser.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelUpdateContext.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelUpdater.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelUtil.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSNamedNodeMapImpl.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSNodeImpl.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSNodeListImpl.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSPageRuleImpl.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSPrimitiveContainer.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSPrimitiveValueImpl.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSRegionContainer.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSRuleDeclContainer.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSRuleImpl.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSRuleListImpl.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSSelector.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSSelectorCombinator.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSSelectorItem.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSSelectorListImpl.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSSelectorParser.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSSimpleSelector.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSStructuredDocumentRegionContainer.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSStyleDeclItemImpl.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSStyleDeclarationFactoryContext.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSStyleDeclarationImpl.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSStyleRuleImpl.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSStyleSheetImpl.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSUnknownRuleImpl.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CounterImpl.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/DOMCSSImpl.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/MediaListImpl.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/RGBColorImpl.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/RectImpl.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/StyleSheetListImpl.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/encoding/CSSDocumentCharsetDetector.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/encoding/CSSDocumentLoader.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/event/ICSSStyleListener.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/event/ICSSStyleNotifier.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/eventimpl/CSSEmbededStyleNotifyAdapter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/eventimpl/CSSStyleEventDeliverer.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/eventimpl/CSSStyleNotifyAdapter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/format/FormatProcessorCSS.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/AbstractCSSSourceFormatter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/AttrChangeContext.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/AttrFormatter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/CSSFormatUtil.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/CSSSourceFormatter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/CSSSourceFormatterFactory.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/CSSSourceGenerator.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/CharsetRuleFormatter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/CompoundRegion.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/CounterFormatter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/DeclContainerFormatter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/DefaultCSSSourceFormatter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/FontFaceRuleFormatter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/FormatRegion.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/FunctionFormatter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/ImportRuleFormatter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/MediaListFormatter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/MediaRuleFormatter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/PageRuleFormatter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/PrimitiveValueFormatter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/RGBFormatter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/RectFormatter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/StyleDeclItemFormatter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/StyleDeclarationFormatter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/StyleRuleFormatter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/StyleSheetFormatter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/UnknownRuleFormatter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMCategory.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMCharsetRule.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMContainer.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMDescriptor.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMFontFaceRule.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMFunction.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMImportRule.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMKeyword.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMMediaRule.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMNode.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMNumber.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMPageRule.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMProperty.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMSelector.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMString.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMStyleRule.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMStyleSheet.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMUnit.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMetaModel.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSProfile.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSProfileRegistry.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/util/CSSFunctionID.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/util/CSSKeywordID.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/util/CSSMMTypeCollector.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/util/CSSMediaGroupID.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/util/CSSMetaModelFinder.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/util/CSSMetaModelTraverser.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/util/CSSMetaModelUtil.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/util/CSSNumberID.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/util/CSSProfileFinder.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/util/CSSPropertyID.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/util/CSSStringID.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/util/CSSUnitID.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMCategoryImpl.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMCharsetRuleImpl.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMContainerImpl.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMDescriptorImpl.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMFontFaceRuleImpl.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMFunctionImpl.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMImportRuleImpl.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMKeywordImpl.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMMediaRuleImpl.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMNodeImpl.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMNumberImpl.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMPageRuleImpl.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMPropertyImpl.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMPseudoClassImpl.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMPseudoElementImpl.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMSelectorExpressionImpl.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMSelectorImpl.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMStringImpl.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMStyleRuleImpl.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMStyleSheetImpl.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMUnitImpl.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMetaModelImpl.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSProfileImpl.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSProfileTest.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/MetaModelErrors.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/NodePool.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/ProfileHandler.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/ProfileKeywords.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/ProfileLoader.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/RegistryReader.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/ValueCollector.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/XMLReaderUtil.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/modelhandler/CSSModelLoader.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/modelhandler/ModelHandlerForCSS.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/parser/CSSRegionUtil.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/parser/CSSSourceParser.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/parser/CSSStructuredDocumentRegionFactory.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/parser/CSSTokenizer.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/parser/ICSSTokenizer.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/parser/regions/CSSTextRegionFactory.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/parserz/CSSRegionContexts.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/parserz/CSSTextParser.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/parserz/CSSTextToken.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/preferences/CSSCorePreferenceInitializer.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/preferences/CSSCorePreferenceNames.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/adapters/ICSSModelAdapter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/adapters/IModelProvideAdapter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/adapters/IStyleDeclarationAdapter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/adapters/IStyleSelectorAdapter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/adapters/IStyleSheetAdapter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/adapters/IStyleSheetListAdapter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/contenttype/ContentTypeIdForCSS.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSAccess.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSAttr.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSCharsetRule.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSDocument.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSImportRule.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSMediaRule.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSModel.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSNamedNodeMap.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSNode.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSNodeList.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSPageRule.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSPrimitiveValue.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSRuleContainer.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSSelector.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSSelectorCombinator.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSSelectorItem.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSSelectorList.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSSimpleSelector.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSStyleDeclItem.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSStyleDeclaration.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSStyleRule.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSStyleSheet.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSValue.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSValueList.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICounter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/IDOMImplementationCSS.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/IDocumentStyle.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/preferences/CSSPreferenceHelper.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/text/ICSSPartitionTypes.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/tasks/CSSFileTaskScanner.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/text/CSSStructuredDocumentReParser.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/text/CSSStructuredDocumentRegionFactory.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/text/StructuredDocumentWalker.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/text/StructuredTextPartitionerForCSS.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/AbstractCssTraverser.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/CSSClassTraverser.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/CSSLinkConverter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/CSSPathService.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/CSSSelectorListFactory.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/CSSStyleDeclarationFactory.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/CSSUtil.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/ImportRuleCollector.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/ImportedCollector.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/RegionIterator.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/SelectionCollector.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/SelectorValidator.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/SelectorsCollector.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/URLHelper.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/URLModelProviderCSS.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/BackgroundPositionXSubStyleAdapter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/BackgroundPositionYSubStyleAdapter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/BackgroundShorthandAdapter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/BorderBottomShorthandAdapter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/BorderColorShorthandAdapter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/BorderLeftShorthandAdapter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/BorderRightShorthandAdapter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/BorderShorthandAdapter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/BorderStyleShorthandAdapter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/BorderTopShorthandAdapter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/BorderWidthShorthandAdapter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/CSSPropertyContext.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/ClipBottomSubStyleAdapter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/ClipLeftSubStyleAdapter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/ClipRightSubStyleAdapter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/ClipSubStyleAdapter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/ClipTopSubStyleAdapter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/FontShorthandAdapter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/ICSS2Properties.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/IShorthandAdapter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/ISubPropertyAdapter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/ListStyleShorthandAdapter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/MarginShorthandAdapter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/PaddingShorthandAdapter.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/ValueData.java delete mode 100644 bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/text/ICSSPartitions.java (limited to 'bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css') diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/CSSCoreMessages.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/CSSCoreMessages.java deleted file mode 100644 index b967a902b1..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/CSSCoreMessages.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2006 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal; - -import org.eclipse.osgi.util.NLS; - -/** - * Strings used by CSS Core - * - * @plannedfor 1.0 - */ -public class CSSCoreMessages extends NLS { - private static final String BUNDLE_NAME = "org.eclipse.wst.css.core.internal.CSSCorePluginResources";//$NON-NLS-1$ - - public static String You_cannot_use_CSSStyleShe_UI_; - public static String CSSContentPropertiesManager_Updating; - public static String CSSContentPropertiesManager_Problems_Updating; - - static { - // load message values from bundle file - NLS.initializeMessages(BUNDLE_NAME, CSSCoreMessages.class); - } -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/CSSCorePlugin.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/CSSCorePlugin.java deleted file mode 100644 index f992edfaca..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/CSSCorePlugin.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal; - -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.Plugin; -import org.eclipse.wst.css.core.internal.contentproperties.CSSContentPropertiesManager; -import org.osgi.framework.BundleContext; - -/** - * The main plugin class to be used in the desktop. - */ -public class CSSCorePlugin extends Plugin { - // The shared instance. - private static CSSCorePlugin plugin; - - /** - * The constructor. - */ - public CSSCorePlugin() { - super(); - plugin = this; - } - - /** - * Returns the shared instance. - */ - public static CSSCorePlugin getDefault() { - return plugin; - } - - /** - * Returns the workspace instance. - */ - public static IWorkspace getWorkspace() { - return ResourcesPlugin.getWorkspace(); - } - - public void start(BundleContext context) throws Exception { - super.start(context); - - // listen for resource changes to update content properties keys - CSSContentPropertiesManager.startup(); - } - - public void stop(BundleContext context) throws Exception { - // stop listenning for resource changes to update content properties - // keys - CSSContentPropertiesManager.shutdown(); - - super.stop(context); - } -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/CSSCorePluginResources.properties b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/CSSCorePluginResources.properties deleted file mode 100644 index e18d1fdd2b..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/CSSCorePluginResources.properties +++ /dev/null @@ -1,14 +0,0 @@ -############################################################################### -# Copyright (c) 2004, 2006 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 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -############################################################################### -You_cannot_use_CSSStyleShe_UI_=You cannot use CSSStyleSheet.getOwnerRule() because of many referencers of this rule\nPlease use getOnwerRules() -# -CSSContentPropertiesManager_Updating=Updating CSS Content Settings -CSSContentPropertiesManager_Problems_Updating=Problem saving CSS Content Settings for {0} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/Logger.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/Logger.java deleted file mode 100644 index ebffda092d..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/Logger.java +++ /dev/null @@ -1,156 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal; - - - -import com.ibm.icu.util.StringTokenizer; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Status; -import org.osgi.framework.Bundle; - -/** - * Small convenience class to log messages to plugin's log file and also, if - * desired, the console. This class should only be used by classes in this - * plugin. Other plugins should make their own copy, with appropriate ID. - */ -public class Logger { - private static final String PLUGIN_ID = "org.eclipse.wst.css.core"; //$NON-NLS-1$ - - private static final String TRACEFILTER_LOCATION = "/debug/tracefilter"; //$NON-NLS-1$ - - public static final int OK = IStatus.OK; // 0 - public static final int INFO = IStatus.INFO; // 1 - public static final int WARNING = IStatus.WARNING; // 2 - public static final int ERROR = IStatus.ERROR; // 4 - - public static final int OK_DEBUG = 200 + OK; - public static final int INFO_DEBUG = 200 + INFO; - public static final int WARNING_DEBUG = 200 + WARNING; - public static final int ERROR_DEBUG = 200 + ERROR; - - /** - * Adds message to log. - * - * @param level - * severity level of the message (OK, INFO, WARNING, ERROR, - * OK_DEBUG, INFO_DEBUG, WARNING_DEBUG, ERROR_DEBUG) - * @param message - * text to add to the log - * @param exception - * exception thrown - */ - protected static void _log(int level, String message, Throwable exception) { - if (level == OK_DEBUG || level == INFO_DEBUG || level == WARNING_DEBUG || level == ERROR_DEBUG) { - if (!isDebugging()) - return; - } - - int severity = IStatus.OK; - switch (level) { - case INFO_DEBUG : - case INFO : - severity = IStatus.INFO; - break; - case WARNING_DEBUG : - case WARNING : - severity = IStatus.WARNING; - break; - case ERROR_DEBUG : - case ERROR : - severity = IStatus.ERROR; - } - message = (message != null) ? message : "null"; //$NON-NLS-1$ - Status statusObj = new Status(severity, PLUGIN_ID, severity, message, exception); - Bundle bundle = Platform.getBundle(PLUGIN_ID); - if (bundle != null) - Platform.getLog(bundle).log(statusObj); - } - - /** - * Prints message to log if category matches /debug/tracefilter option. - * - * @param message - * text to print - * @param category - * category of the message, to be compared with - * /debug/tracefilter - */ - protected static void _trace(String category, String message, Throwable exception) { - if (isTracing(category)) { - message = (message != null) ? message : "null"; //$NON-NLS-1$ - Status statusObj = new Status(IStatus.OK, PLUGIN_ID, IStatus.OK, message, exception); - Bundle bundle = Platform.getBundle(PLUGIN_ID); - if (bundle != null) - Platform.getLog(bundle).log(statusObj); - } - } - - /** - * @return true if the platform is debugging - */ - public static boolean isDebugging() { - return Platform.inDebugMode(); - } - - /** - * Determines if currently tracing a category - * - * @param category - * @return true if tracing category, false otherwise - */ - public static boolean isTracing(String category) { - if (!isDebugging()) - return false; - - String traceFilter = Platform.getDebugOption(PLUGIN_ID + TRACEFILTER_LOCATION); - if (traceFilter != null) { - StringTokenizer tokenizer = new StringTokenizer(traceFilter, ","); //$NON-NLS-1$ - while (tokenizer.hasMoreTokens()) { - String cat = tokenizer.nextToken().trim(); - if (category.equals(cat)) { - return true; - } - } - } - return false; - } - - public static void log(int level, String message) { - _log(level, message, null); - } - - public static void log(int level, String message, Throwable exception) { - _log(level, message, exception); - } - - public static void logException(String message, Throwable exception) { - _log(ERROR, message, exception); - } - - public static void logException(Throwable exception) { - _log(ERROR, exception.getMessage(), exception); - } - - public static void traceException(String category, String message, Throwable exception) { - _trace(category, message, exception); - } - - public static void traceException(String category, Throwable exception) { - _trace(category, exception.getMessage(), exception); - } - - public static void trace(String category, String message) { - _trace(category, message, null); - } -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/cleanup/CSSCleanupStrategy.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/cleanup/CSSCleanupStrategy.java deleted file mode 100644 index eb6d86e67b..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/cleanup/CSSCleanupStrategy.java +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.cleanup; - - - -public interface CSSCleanupStrategy { - - static final short ASIS = 0; - static final short LOWER = 1; - static final short UPPER = 2; - - /** - * - * @return short - */ - short getIdentCase(); - - /** - * - * @return short - */ - short getPropNameCase(); - - /** - * - * @return short - */ - short getPropValueCase(); - - /** - * - * @return short - */ - short getSelectorTagCase(); - - /** - * - * @return boolean - */ - boolean isFormatSource(); - - /** - * - * @return boolean - */ - boolean isQuoteValues(); - - /** - * - * @param formatSource - * boolean - */ - void setFormatSource(boolean formatSource); - - /** - * - * @param identCase - * short - */ - void setIdentCase(short identCase); - - /** - * - * @param propNameCase - * short - */ - void setPropNameCase(short propNameCase); - - /** - * - * @param propValueCase - * short - */ - void setPropValueCase(short propValueCase); - - /** - * - * @param quoteValues - * boolean - */ - void setQuoteValues(boolean quoteValues); - - /** - * - * @param selectorTagCase - * short - */ - void setSelectorTagCase(short selectorTagCase); -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/cleanup/CSSCleanupStrategyImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/cleanup/CSSCleanupStrategyImpl.java deleted file mode 100644 index 5b190f4ebc..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/cleanup/CSSCleanupStrategyImpl.java +++ /dev/null @@ -1,190 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.cleanup; - -import org.eclipse.core.runtime.Preferences; -import org.eclipse.wst.css.core.internal.CSSCorePlugin; -import org.eclipse.wst.css.core.internal.preferences.CSSCorePreferenceNames; - - - -public class CSSCleanupStrategyImpl implements CSSCleanupStrategy { - - static private CSSCleanupStrategy instance = null; - // initialize with defaults - protected short fIdentCase = ASIS; - protected short fPropNameCase = ASIS; - protected short fPropValueCase = ASIS; - protected short fSelectorTagCase = UPPER; - protected boolean fQuoteValues = true; - protected boolean fFormatSource = true; - - /** - * CSSCleanupStrategyImpl constructor comment. - */ - protected CSSCleanupStrategyImpl() { - super(); - initialize(); - } - - /** - * - * @return short - */ - public short getIdentCase() { - return fIdentCase; - } - - /** - * - * @return org.eclipse.wst.css.core.internal.cleanup.CSSCleanupStrategy - */ - public synchronized static CSSCleanupStrategy getInstance() { - if (instance == null) - instance = new CSSCleanupStrategyImpl(); - return instance; - } - - /** - * - * @return short - */ - public short getPropNameCase() { - return fPropNameCase; - } - - /** - * - * @return short - */ - public short getPropValueCase() { - return fPropValueCase; - } - - /** - * - * @return short - */ - public short getSelectorTagCase() { - return fSelectorTagCase; - } - - /** - * - */ - private void initialize() { - Preferences prefs = CSSCorePlugin.getDefault().getPluginPreferences(); - fIdentCase = getCleanupCaseValue(prefs.getInt(CSSCorePreferenceNames.CLEANUP_CASE_IDENTIFIER)); - fPropNameCase = getCleanupCaseValue(prefs.getInt(CSSCorePreferenceNames.CLEANUP_CASE_PROPERTY_NAME)); - fPropValueCase = getCleanupCaseValue(prefs.getInt(CSSCorePreferenceNames.CLEANUP_CASE_PROPERTY_VALUE)); - fSelectorTagCase = getCleanupCaseValue(prefs.getInt(CSSCorePreferenceNames.CLEANUP_CASE_SELECTOR)); - fQuoteValues = prefs.getBoolean(CSSCorePreferenceNames.QUOTE_ATTR_VALUES); - fFormatSource = prefs.getBoolean(CSSCorePreferenceNames.FORMAT_SOURCE); - } - - /** - * Return the CSSCleanupStrategy equivalent case short value when given an - * int - * - * @param value - * @return equivalent case short or ASIS if cannot be determined - */ - private short getCleanupCaseValue(int value) { - switch (value) { - case CSSCorePreferenceNames.LOWER : - return LOWER; - case CSSCorePreferenceNames.UPPER : - return UPPER; - } - return ASIS; - } - - /** - * - * @return boolean - */ - public boolean isFormatSource() { - return fFormatSource; - } - - /** - * - * @return boolean - */ - public boolean isQuoteValues() { - return fQuoteValues; - } - - /** - * - * @param formatSource - * boolean - */ - public void setFormatSource(boolean formatSource) { - fFormatSource = formatSource; - } - - /** - * - * @param identCase - * short - */ - public void setIdentCase(short identCase) { - fIdentCase = identCase; - } - - /** - * - * @param propNameCase - * short - */ - public void setPropNameCase(short propNameCase) { - fPropNameCase = propNameCase; - } - - /** - * - * @param propValueCase - * short - */ - public void setPropValueCase(short propValueCase) { - fPropValueCase = propValueCase; - } - - /** - * - * @param quoteValues - * boolean - */ - public void setQuoteValues(boolean quoteValues) { - fQuoteValues = quoteValues; - } - - /** - * - * @param selectorTagCase - * short - */ - public void setSelectorTagCase(short selectorTagCase) { - fSelectorTagCase = selectorTagCase; - } - - // TODO: a saveOptions should be added to CSSCleanupStrategy interface - public void saveOptions() { - CSSCorePlugin.getDefault().getPluginPreferences().setValue(CSSCorePreferenceNames.CLEANUP_CASE_IDENTIFIER, fIdentCase); - CSSCorePlugin.getDefault().getPluginPreferences().setValue(CSSCorePreferenceNames.CLEANUP_CASE_PROPERTY_NAME, fPropNameCase); - CSSCorePlugin.getDefault().getPluginPreferences().setValue(CSSCorePreferenceNames.CLEANUP_CASE_PROPERTY_VALUE, fPropValueCase); - CSSCorePlugin.getDefault().getPluginPreferences().setValue(CSSCorePreferenceNames.CLEANUP_CASE_SELECTOR, fSelectorTagCase); - CSSCorePlugin.getDefault().getPluginPreferences().setValue(CSSCorePreferenceNames.QUOTE_ATTR_VALUES, fQuoteValues); - CSSCorePlugin.getDefault().getPluginPreferences().setValue(CSSCorePreferenceNames.FORMAT_SOURCE, fFormatSource); - CSSCorePlugin.getDefault().savePluginPreferences(); - } -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/cleanup/CleanupProcessorCSS.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/cleanup/CleanupProcessorCSS.java deleted file mode 100644 index 1fadf348c8..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/cleanup/CleanupProcessorCSS.java +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.cleanup; - -import java.io.IOException; -import java.util.List; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jface.text.IDocument; -import org.eclipse.wst.css.core.internal.formatter.CSSFormatUtil; -import org.eclipse.wst.css.core.internal.formatter.CSSSourceFormatter; -import org.eclipse.wst.css.core.internal.formatter.CSSSourceFormatterFactory; -import org.eclipse.wst.css.core.internal.provisional.contenttype.ContentTypeIdForCSS; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSDocument; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSModel; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode; -import org.eclipse.wst.sse.core.internal.cleanup.AbstractStructuredCleanupProcessor; -import org.eclipse.wst.sse.core.internal.cleanup.IStructuredCleanupHandler; -import org.eclipse.wst.sse.core.internal.format.IStructuredFormatProcessor; -import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier; -import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; -import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; -import org.w3c.dom.Node; - - -public class CleanupProcessorCSS extends AbstractStructuredCleanupProcessor { - - public void cleanupModel(IStructuredModel structuredModel, int start, int length) { - CSSFormatUtil formatUtil = CSSFormatUtil.getInstance(); - if (structuredModel instanceof ICSSModel) { - ICSSDocument doc = ((ICSSModel) structuredModel).getDocument(); - CSSSourceFormatter formatter = CSSSourceFormatterFactory.getInstance().getSourceFormatter((INodeNotifier) doc); - StringBuffer buf = formatter.cleanup(doc); - if (buf != null) { - int startOffset = ((IndexedRegion) doc).getStartOffset(); - int endOffset = ((IndexedRegion) doc).getEndOffset(); - formatUtil.replaceSource(doc.getModel(), startOffset, endOffset - startOffset, buf.toString()); - } - } - else if (structuredModel instanceof IDOMModel) { - List cssnodes = formatUtil.collectCSSNodes(structuredModel, start, length); - if (cssnodes != null && !cssnodes.isEmpty()) { - ICSSModel model = null; - for (int i = 0; i < cssnodes.size(); i++) { - ICSSNode node = (ICSSNode) cssnodes.get(i); - CSSSourceFormatter formatter = CSSSourceFormatterFactory.getInstance().getSourceFormatter((INodeNotifier) node); - StringBuffer buf = formatter.cleanup(node); - if (buf != null) { - int startOffset = ((IndexedRegion) node).getStartOffset(); - int endOffset = ((IndexedRegion) node).getEndOffset(); - if (model == null) { - model = node.getOwnerDocument().getModel(); - } - formatUtil.replaceSource(model, startOffset, endOffset - startOffset, buf.toString()); - } - } - } - } - } - - protected String getContentType() { - return ContentTypeIdForCSS.ContentTypeID_CSS; - } - - public void cleanupModel(IStructuredModel structuredModel) { - int start = 0; - int length = structuredModel.getStructuredDocument().getLength(); - - cleanupModel(structuredModel, start, length); - } - - public void cleanupDocument(IDocument document) throws IOException, CoreException { - // TODO should implement, or delete? - - } - - public void cleanupDocument(IDocument document, int start, int length) throws IOException, CoreException { - // TODO should implement, or delete? - - } - - protected IStructuredCleanupHandler getCleanupHandler(Node node) { - return null; - } - - protected IStructuredFormatProcessor getFormatProcessor() { - return null; - } - - protected void refreshCleanupPreferences() { - } -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/IMediaGroupID.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/IMediaGroupID.java deleted file mode 100644 index 8d02ac886b..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/IMediaGroupID.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.contentmodel; - - - -/** - * - */ -public interface IMediaGroupID { - - public final static String M_CONTINUOUS = "continuous"; //$NON-NLS-1$ - public final static String M_PAGED = "paged"; //$NON-NLS-1$ - - public final static String M_VISUAL = "visual"; //$NON-NLS-1$ - public final static String M_AURAL = "aural"; //$NON-NLS-1$ - public final static String M_TACTILE = "tactile"; //$NON-NLS-1$ - - public final static String M_GRID = "grid"; //$NON-NLS-1$ - public final static String M_BITMAP = "bitmap"; //$NON-NLS-1$ - - public final static String M_INTERACTIVE = "interactive"; //$NON-NLS-1$ - public final static String M_STATIC = "static"; //$NON-NLS-1$ - - public final static String M_ALL = "all"; //$NON-NLS-1$ -} \ No newline at end of file diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/IValID.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/IValID.java deleted file mode 100644 index 113e855904..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/IValID.java +++ /dev/null @@ -1,285 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2010 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.contentmodel; - - - -/** - * - */ -public interface IValID { - - public final static String V_1 = "1";//$NON-NLS-1$ - public final static String V_100 = "100"; //$NON-NLS-1$ - public final static String V_200 = "200"; //$NON-NLS-1$ - public final static String V_300 = "300"; //$NON-NLS-1$ - public final static String V_400 = "400"; //$NON-NLS-1$ - public final static String V_500 = "500"; //$NON-NLS-1$ - public final static String V_600 = "600"; //$NON-NLS-1$ - public final static String V_700 = "700"; //$NON-NLS-1$ - public final static String V_800 = "800"; //$NON-NLS-1$ - public final static String V_900 = "900"; //$NON-NLS-1$ - public final static String V_ABOVE = "above"; //$NON-NLS-1$ - public final static String V_ABSOLUTE = "absolute"; //$NON-NLS-1$ - public final static String V_ACTIVEBORDER = "ActiveBorder"; //$NON-NLS-1$ - public final static String V_ACTIVECAPTION = "ActiveCaption"; //$NON-NLS-1$ - public final static String V_ALL = "all"; //$NON-NLS-1$ - public final static String V_ALWAYS = "always"; //$NON-NLS-1$ - public final static String V_APPWORKSPACE = "AppWorkspace"; //$NON-NLS-1$ - public final static String V_AQUA = "aqua"; //$NON-NLS-1$ - public final static String V_ARMENIAN = "armenian"; //$NON-NLS-1$ - public final static String V_AUTO = "auto"; //$NON-NLS-1$ - public final static String V_AVOID = "avoid"; //$NON-NLS-1$ - public final static String V_BACKGROUND = "Background"; //$NON-NLS-1$ - public final static String V_BALANCE = "balance";//$NON-NLS-1$ - public final static String V_BASELINE = "baseline"; //$NON-NLS-1$ - public final static String V_BEHIND = "behind"; //$NON-NLS-1$ - public final static String V_BELOW = "below"; //$NON-NLS-1$ - public final static String V_BIDI_OVERRIDE = "bidi-override"; //$NON-NLS-1$ - public final static String V_BLACK = "black"; //$NON-NLS-1$ - public final static String V_BLINK = "blink"; //$NON-NLS-1$ - public final static String V_BLOCK = "block"; //$NON-NLS-1$ - public final static String V_BLUE = "blue"; //$NON-NLS-1$ - public final static String V_BOLD = "bold"; //$NON-NLS-1$ - public final static String V_BOLDER = "bolder"; //$NON-NLS-1$ - public final static String V_BORDER_BOX = "border-box"; //$NON-NLS-1$ - public final static String V_BOTH = "both"; //$NON-NLS-1$ - public final static String V_BOTTOM = "bottom"; //$NON-NLS-1$ - public final static String V_BUTTONFACE = "ButtonFace"; //$NON-NLS-1$ - public final static String V_BUTTONHIGHLIGHT = "ButtonHighlight"; //$NON-NLS-1$ - public final static String V_BUTTONSHADOW = "ButtonShadow"; //$NON-NLS-1$ - public final static String V_BUTTONTEXT = "ButtonText"; //$NON-NLS-1$ - public final static String V_CAPITALIZE = "capitalize"; //$NON-NLS-1$ - public final static String V_CAPTION = "caption"; //$NON-NLS-1$ - public final static String V_CAPTIONTEXT = "CaptionText"; //$NON-NLS-1$ - public final static String V_CENTER = "center"; //$NON-NLS-1$ - public final static String V_CENTER_LEFT = "center-left"; //$NON-NLS-1$ - public final static String V_CENTER_RIGHT = "center-right"; //$NON-NLS-1$ - public final static String V_CHILD = "child"; //$NON-NLS-1$ - public final static String V_CIRCLE = "circle"; //$NON-NLS-1$ - public final static String V_CJK_IDEOGRAPHIC = "cjk-ideographic"; //$NON-NLS-1$ - public final static String V_CLIP = "clip"; //$NON-NLS-1$ - public final static String V_CLOSE_QUOTE = "close-quote"; //$NON-NLS-1$ - public final static String V_CODE = "code"; //$NON-NLS-1$ - public final static String V_CONDENSED = "condensed"; //$NON-NLS-1$ - public final static String V_COLLAPSE = "collapse"; //$NON-NLS-1$ - public final static String V_COMPACT = "compact"; //$NON-NLS-1$ - public final static String V_CONTAIN = "contain"; //$NON-NLS-1$ - public final static String V_CONTENT_BOX = "content-box"; //$NON-NLS-1$ - public final static String V_CONTINUOUS = "continuous"; //$NON-NLS-1$ - public final static String V_COVER = "cover"; //$NON-NLS-1$ - public final static String V_CROP = "crop"; //$NON-NLS-1$ - public final static String V_CROSS = "cross"; //$NON-NLS-1$ - public final static String V_CROSSHAIR = "crosshair"; //$NON-NLS-1$ - public final static String V_CURSIVE = "cursive"; //$NON-NLS-1$ - public final static String V_DASHED = "dashed"; //$NON-NLS-1$ - public final static String V_DECIMAL = "decimal"; //$NON-NLS-1$ - public final static String V_DECIMAL_LEADING_ZERO = "decimal-leading-zero"; //$NON-NLS-1$ - public final static String V_DEFAULT = "default"; //$NON-NLS-1$ - public final static String V_DIGITS = "digits"; //$NON-NLS-1$ - public final static String V_DISC = "disc"; //$NON-NLS-1$ - public final static String V_DOTTED = "dotted"; //$NON-NLS-1$ - public final static String V_DOUBLE = "double"; //$NON-NLS-1$ - public final static String V_E_RESIZE = "e-resize"; //$NON-NLS-1$ - public final static String V_ELLIPSIS = "ellipsis"; //$NON-NLS-1$ - public final static String V_EMBED = "embed"; //$NON-NLS-1$ - public final static String V_EXPANDED = "expanded"; //$NON-NLS-1$ - public final static String V_EXTRA_CONDENSED = "extra-condensed"; //$NON-NLS-1$ - public final static String V_EXTRA_EXPANDED = "extra-expanded"; //$NON-NLS-1$ - public final static String V_FANTASY = "fantasy"; //$NON-NLS-1$ - public final static String V_FAR_LEFT = "far-left"; //$NON-NLS-1$ - public final static String V_FAR_RIGHT = "far-right"; //$NON-NLS-1$ - public final static String V_FAST = "fast"; //$NON-NLS-1$ - public final static String V_FASTER = "faster"; //$NON-NLS-1$ - public final static String V_FEMALE = "female"; //$NON-NLS-1$ - public final static String V_FIXED = "fixed"; //$NON-NLS-1$ - public final static String V_FUCHSIA = "fuchsia"; //$NON-NLS-1$ - public final static String V_GEORGIAN = "georgian"; //$NON-NLS-1$ - public final static String V_GRAY = "gray"; //$NON-NLS-1$ - public final static String V_GRAYTEXT = "GrayText"; //$NON-NLS-1$ - public final static String V_GREEN = "green"; //$NON-NLS-1$ - public final static String V_GROOVE = "groove"; //$NON-NLS-1$ - public final static String V_HEBREW = "hebrew"; //$NON-NLS-1$ - public final static String V_HELP = "help"; //$NON-NLS-1$ - public final static String V_HIDDEN = "hidden"; //$NON-NLS-1$ - public final static String V_HIDE = "hide"; //$NON-NLS-1$ - public final static String V_HIGH = "high"; //$NON-NLS-1$ - public final static String V_HIGHLIGHT = "Highlight"; //$NON-NLS-1$ - public final static String V_HIGHLIGHTTEXT = "HighlightText"; //$NON-NLS-1$ - public final static String V_HIGHER = "higher"; //$NON-NLS-1$ - public final static String V_HIRAGANA = "hiragana"; //$NON-NLS-1$ - public final static String V_HIRAGANA_IROHA = "hiragana-iroha"; //$NON-NLS-1$ - public final static String V_HORIZONTAL = "horizontal"; //$NON-NLS-1$ - public final static String V_ICON = "icon"; //$NON-NLS-1$ - public final static String V_INACTIVEBORDER = "InactiveBorder"; //$NON-NLS-1$ - public final static String V_INACTIVECAPTION = "InactiveCaption"; //$NON-NLS-1$ - public final static String V_INACTIVECAPTIONTEXT = "InactiveCaptionText"; //$NON-NLS-1$ - public final static String V_INFOBACKGROUND = "InfoBackground"; //$NON-NLS-1$ - public final static String V_INFOTEXT = "InfoText"; //$NON-NLS-1$ - public final static String V_INLINE = "inline"; //$NON-NLS-1$ - public final static String V_INLINE_BLOCK = "inline-block"; //$NON-NLS-1$ - public final static String V_INLINE_TABLE = "inline-table"; //$NON-NLS-1$ - public final static String V_INSET = "inset"; //$NON-NLS-1$ - public final static String V_INSIDE = "inside"; //$NON-NLS-1$ - public final static String V_INVERT = "invert"; //$NON-NLS-1$ - public final static String V_ITALIC = "italic"; //$NON-NLS-1$ - public final static String V_JUSTIFY = "justify"; //$NON-NLS-1$ - public final static String V_KATAKANA = "katakana"; //$NON-NLS-1$ - public final static String V_KATAKANA_IROHA = "katakana-iroha"; //$NON-NLS-1$ - public final static String V_LANDSCAPE = "landscape"; //$NON-NLS-1$ - public final static String V_LARGE = "large"; //$NON-NLS-1$ - public final static String V_LARGER = "larger"; //$NON-NLS-1$ - public final static String V_LEFT = "left"; //$NON-NLS-1$ - public final static String V_LEFT_SIDE = "left-side"; //$NON-NLS-1$ - public final static String V_LEFTWARDS = "leftwards"; //$NON-NLS-1$ - public final static String V_LEVEL = "level"; //$NON-NLS-1$ - public final static String V_LIGHTER = "lighter"; //$NON-NLS-1$ - public final static String V_LIME = "lime"; //$NON-NLS-1$ - public final static String V_LINE_THROUGH = "line-through"; //$NON-NLS-1$ - public final static String V_LIST_ITEM = "list-item"; //$NON-NLS-1$ - public final static String V_LOCAL = "local"; //$NON-NLS-1$ - public final static String V_LOUD = "loud"; //$NON-NLS-1$ - public final static String V_LOW = "low"; //$NON-NLS-1$ - public final static String V_LOWER = "lower"; //$NON-NLS-1$ - public final static String V_LOWER_ALPHA = "lower-alpha"; //$NON-NLS-1$ - public final static String V_LOWER_GREEK = "lower-greek"; //$NON-NLS-1$ - public final static String V_LOWER_LATIN = "lower-latin"; //$NON-NLS-1$ - public final static String V_LOWER_ROMAN = "lower-roman"; //$NON-NLS-1$ - public final static String V_LOWERCASE = "lowercase"; //$NON-NLS-1$ - public final static String V_LTR = "ltr"; //$NON-NLS-1$ - public final static String V_MALE = "male"; //$NON-NLS-1$ - public final static String V_MARKER = "marker"; //$NON-NLS-1$ - public final static String V_MAROON = "maroon"; //$NON-NLS-1$ - public final static String V_MEDIUM = "medium"; //$NON-NLS-1$ - public final static String V_MENU = "menu"; //$NON-NLS-1$ - public final static String V_MENUTEXT = "MenuText"; //$NON-NLS-1$ - public final static String V_MESSAGE_BOX = "message-box"; //$NON-NLS-1$ - public final static String V_MIDDLE = "middle"; //$NON-NLS-1$ - public final static String V_MIX = "mix"; //$NON-NLS-1$ - public final static String V_MONOSPACE = "monospace"; //$NON-NLS-1$ - public final static String V_MOVE = "move"; //$NON-NLS-1$ - public final static String V_N_RESIZE = "n-resize"; //$NON-NLS-1$ - public final static String V_NARROWER = "narrower"; //$NON-NLS-1$ - public final static String V_NAVY = "navy"; //$NON-NLS-1$ - public final static String V_NE_RESIZE = "ne-resize"; //$NON-NLS-1$ - public final static String V_NO_CLOSE_QUOTE = "no-close-quote"; //$NON-NLS-1$ - public final static String V_NO_OPEN_QUOTE = "no-open-quote"; //$NON-NLS-1$ - public final static String V_NO_REPEAT = "no-repeat"; //$NON-NLS-1$ - public final static String V_NONE = "none"; //$NON-NLS-1$ - public final static String V_NORMAL = "normal"; //$NON-NLS-1$ - public final static String V_NOWRAP = "nowrap"; //$NON-NLS-1$ - public final static String V_NW_RESIZE = "nw-resize"; //$NON-NLS-1$ - public final static String V_OBLIQUE = "oblique"; //$NON-NLS-1$ - public final static String V_OLIVE = "olive"; //$NON-NLS-1$ - public final static String V_ONCE = "once"; //$NON-NLS-1$ - public final static String V_OPEN_QUOTE = "open-quote"; //$NON-NLS-1$ - public final static String V_ORANGE = "orange"; //$NON-NLS-1$ - public final static String V_OUTSET = "outset"; //$NON-NLS-1$ - public final static String V_OUTSIDE = "outside"; //$NON-NLS-1$ - public final static String V_OVERLINE = "overline"; //$NON-NLS-1$ - public final static String V_PADDING_BOX = "padding-box"; //$NON-NLS-1$ - public final static String V_POINTER = "pointer"; //$NON-NLS-1$ - public final static String V_PORTRAIT = "portrait"; //$NON-NLS-1$ - public final static String V_PRE = "pre"; //$NON-NLS-1$ - public final static String V_PRE_LINE = "pre-line"; //$NON-NLS-1$ - public final static String V_PRE_WRAP = "pre-wrap"; //$NON-NLS-1$ - public final static String V_PROGRESS = "progress"; //$NON-NLS-1$ - public final static String V_PURPLE = "purple"; //$NON-NLS-1$ - public final static String V_RED = "red"; //$NON-NLS-1$ - public final static String V_RELATIVE = "relative"; //$NON-NLS-1$ - public final static String V_REPEAT = "repeat"; //$NON-NLS-1$ - public final static String V_REPEAT_X = "repeat-x"; //$NON-NLS-1$ - public final static String V_REPEAT_Y = "repeat-y"; //$NON-NLS-1$ - public final static String V_RIDGE = "ridge"; //$NON-NLS-1$ - public final static String V_RIGHT = "right"; //$NON-NLS-1$ - public final static String V_RIGHT_SIDE = "right-side"; //$NON-NLS-1$ - public final static String V_RIGHTWARDS = "rightwards"; //$NON-NLS-1$ - public final static String V_ROUND = "round"; //$NON-NLS-1$ - public final static String V_RTL = "rtl"; //$NON-NLS-1$ - public final static String V_RUN_IN = "run-in"; //$NON-NLS-1$ - public final static String V_S_RESIZE = "s-resize"; //$NON-NLS-1$ - public final static String V_SANS_SERIF = "sans-serif"; //$NON-NLS-1$ - public final static String V_SCROLL = "scroll"; //$NON-NLS-1$ - public final static String V_SCROLLBAR = "Scrollbar"; //$NON-NLS-1$ - public final static String V_SE_RESIZE = "se-resize"; //$NON-NLS-1$ - public final static String V_SEMI_CONDENSED = "semi-condensed"; //$NON-NLS-1$ - public final static String V_SEMI_EXPANDED = "semi-expanded"; //$NON-NLS-1$ - public final static String V_SEPARATE = "separate"; //$NON-NLS-1$ - public final static String V_SERIF = "serif"; //$NON-NLS-1$ - public final static String V_SHOW = "show"; //$NON-NLS-1$ - public final static String V_SILENT = "silent"; //$NON-NLS-1$ - public final static String V_SILVER = "silver"; //$NON-NLS-1$ - public final static String V_SLOW = "slow"; //$NON-NLS-1$ - public final static String V_SLOWER = "slower"; //$NON-NLS-1$ - public final static String V_SMALL = "small"; //$NON-NLS-1$ - public final static String V_SMALL_CAPS = "small-caps"; //$NON-NLS-1$ - public final static String V_SMALL_CAPTION = "small-caption"; //$NON-NLS-1$ - public final static String V_SMALLER = "smaller"; //$NON-NLS-1$ - public final static String V_SOFT = "soft"; //$NON-NLS-1$ - public final static String V_SOLID = "solid"; //$NON-NLS-1$ - public final static String V_SPACE = "space"; //$NON-NLS-1$ - public final static String V_SPELL_OUT = "spell-out"; //$NON-NLS-1$ - public final static String V_SQUARE = "square"; //$NON-NLS-1$ - public final static String V_STATIC = "static"; //$NON-NLS-1$ - public final static String V_STATUS_BAR = "status-bar"; //$NON-NLS-1$ - public final static String V_SUB = "sub"; //$NON-NLS-1$ - public final static String V_SUPER = "super"; //$NON-NLS-1$ - public final static String V_SW_RESIZE = "sw-resize"; //$NON-NLS-1$ - public final static String V_TABLE = "table"; //$NON-NLS-1$ - public final static String V_TABLE_CAPTION = "table-caption"; //$NON-NLS-1$ - public final static String V_TABLE_CELL = "table-cell"; //$NON-NLS-1$ - public final static String V_TABLE_COLUMN = "table-column"; //$NON-NLS-1$ - public final static String V_TABLE_COLUMN_GROUP = "table-column-group"; //$NON-NLS-1$ - public final static String V_TABLE_FOOTER_GROUP = "table-footer-group"; //$NON-NLS-1$ - public final static String V_TABLE_HEADER_GROUP = "table-header-group"; //$NON-NLS-1$ - public final static String V_TABLE_ROW = "table-row"; //$NON-NLS-1$ - public final static String V_TABLE_ROW_GROUP = "table-row-group"; //$NON-NLS-1$ - public final static String V_TEAL = "teal"; //$NON-NLS-1$ - public final static String V_TEXT = "text"; //$NON-NLS-1$ - public final static String V_TEXT_TOP = "text-top"; //$NON-NLS-1$ - public final static String V_TEXT_BOTTOM = "text-bottom"; //$NON-NLS-1$ - public final static String V_THICK = "thick"; //$NON-NLS-1$ - public final static String V_THIN = "thin"; //$NON-NLS-1$ - public final static String V_THREEDDARKSHADOW = "ThreeDDarkShadow"; //$NON-NLS-1$ - public final static String V_THREEDFACE = "ThreeDFace"; //$NON-NLS-1$ - public final static String V_THREEDHIGHLIGHT = "ThreeDHighlight"; //$NON-NLS-1$ - public final static String V_THREEDLIGHTSHADOW = "ThreeDLightShadow"; //$NON-NLS-1$ - public final static String V_THREEDSHADOW = "ThreeDShadow"; //$NON-NLS-1$ - public final static String V_TOP = "top"; //$NON-NLS-1$ - public final static String V_TRANSPARENT = "transparent"; //$NON-NLS-1$ - public final static String V_ULTRA_CONDENSED = "ultra-condensed"; //$NON-NLS-1$ - public final static String V_ULTRA_EXPANDED = "ultra-expanded"; //$NON-NLS-1$ - public final static String V_UNDERLINE = "underline"; //$NON-NLS-1$ - public final static String V_UPPER_ALPHA = "upper-alpha"; //$NON-NLS-1$ - public final static String V_UPPER_LATIN = "upper-latin"; //$NON-NLS-1$ - public final static String V_UPPER_ROMAN = "upper-roman"; //$NON-NLS-1$ - public final static String V_UPPERCASE = "uppercase"; //$NON-NLS-1$ - public final static String V_VERTICAL = "vertical";//$NON-NLS-1$ - public final static String V_VISIBLE = "visible"; //$NON-NLS-1$ - public final static String V_W_RESIZE = "w-resize"; //$NON-NLS-1$ - public final static String V_WAIT = "wait"; //$NON-NLS-1$ - public final static String V_WHITE = "white"; //$NON-NLS-1$ - public final static String V_WIDER = "wider"; //$NON-NLS-1$ - public final static String V_WINDOW = "Window"; //$NON-NLS-1$ - public final static String V_WINDOWFRAME = "WindowFrame"; //$NON-NLS-1$ - public final static String V_WINDOWTEXT = "WindowText"; //$NON-NLS-1$ - public final static String V_X_FAST = "x-fast"; //$NON-NLS-1$ - public final static String V_X_HIGH = "x-high"; //$NON-NLS-1$ - public final static String V_X_LARGE = "x-large"; //$NON-NLS-1$ - public final static String V_X_LOUD = "x-loud"; //$NON-NLS-1$ - public final static String V_X_LOW = "x-low"; //$NON-NLS-1$ - public final static String V_X_SLOW = "x-slow"; //$NON-NLS-1$ - public final static String V_X_SMALL = "x-small"; //$NON-NLS-1$ - public final static String V_X_SOFT = "x-soft"; //$NON-NLS-1$ - public final static String V_XX_SMALL = "xx-small"; //$NON-NLS-1$ - public final static String V_XX_LARGE = "xx-large"; //$NON-NLS-1$ - public final static String V_YELLOW = "yellow"; //$NON-NLS-1$ -} \ No newline at end of file diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMContainer.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMContainer.java deleted file mode 100644 index d013f7ca6e..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMContainer.java +++ /dev/null @@ -1,164 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.contentmodel; - - - -import java.util.Collection; -import java.util.Hashtable; -import java.util.Set; -import java.util.Vector; - -/** - * - */ -public class PropCMContainer extends PropCMNode { - - private java.util.Vector nodes = new Vector(); - private static java.util.Hashtable instances = null; - public final static String VAL_ABSOLUTE_SIZE = "absolute-size";//$NON-NLS-1$ - public final static String VAL_BORDER_STYLE = "border-style";//$NON-NLS-1$ - public final static String VAL_BORDER_WIDTH = "border-width";//$NON-NLS-1$ - public final static String VAL_COLOR = "color";//$NON-NLS-1$ - public final static String VAL_SYSTEM_COLOR = "system-color";//$NON-NLS-1$ - public final static String VAL_GENERIC_FAMILY = "generic-family";//$NON-NLS-1$ - public final static String VAL_GENERIC_VOICE = "generic-voice";//$NON-NLS-1$ - public final static String VAL_MARGIN_WIDTH = "margin-width";//$NON-NLS-1$ - public final static String VAL_PADDING_WIDTH = "padding-width";//$NON-NLS-1$ - public final static String VAL_RELATIVE_SIZE = "relative-size";//$NON-NLS-1$ - - /** - * - */ - protected PropCMContainer(String name) { - super(name); - } - - /** - * - */ - Object appendChild(Object node) { - if (!nodes.contains(node)) - nodes.add(node); - return node; - } - - /** - * - */ - public boolean canHave(String identifier) { - int nChild = getNumChild(); - for (int i = 0; i < nChild; i++) { - Object child = getChildAt(i); - if (child instanceof String && identifier.equalsIgnoreCase((String) child)) - return true; - if (child instanceof PropCMContainer && ((PropCMContainer) child).canHave(identifier)) - return true; - } - return false; - } - - /** - * - */ - public Object getChildAt(int index) { - if (nodes == null || index < 0 || nodes.size() <= index) - return null; - return nodes.elementAt(index); - } - - /** - * - */ - static PropCMContainer getContInstanceOf(String name) { - if (name == null) - return null; - - // initialize - if (instances == null) - instances = new Hashtable(20); - - // Initialize of DB - if (isNeedInitialize()) - PropCMNode.initPropertyCM(); - - // query - Object node = instances.get(name); - if (node != null) - return (PropCMContainer) node; - - if (PropCMNode.isLoading()) { - // register - node = new PropCMContainer(name); - instances.put(name, node); - } - - return (PropCMContainer) node; - } - - /** - * - */ - void getIdentifiers(Set idents) { - if (idents == null) - return; - int nChildren = nodes.size(); - for (int i = 0; i < nChildren; i++) { - Object node = nodes.elementAt(i); - if (node instanceof PropCMNode) - ((PropCMNode) node).getIdentifiers(idents); - else if (node instanceof String) - idents.add(node); - } - } - - /** - * - */ - public int getNumChild() { - if (nodes == null) - return 0; - return nodes.size(); - } - - /** - * - */ - public short getType() { - return VAL_CONTAINER; - } - - /** - * - */ - void getValues(Collection values) { - if (values == null) - return; - int nChildren = nodes.size(); - for (int i = 0; i < nChildren; i++) { - Object node = nodes.elementAt(i); - if (node instanceof PropCMNode) - ((PropCMNode) node).getValues(values); - else if (node instanceof String) { - if (!values.contains(node)) - values.add(node); - } - } - } - - /** - * - */ - Object removeChild(Object node) { - nodes.remove(node); - return node; - } -} \ No newline at end of file diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMFontProperty.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMFontProperty.java deleted file mode 100644 index a28e21da9f..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMFontProperty.java +++ /dev/null @@ -1,198 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.contentmodel; - - - -import java.util.Collection; -import java.util.Enumeration; -import java.util.HashSet; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.List; -import java.util.Vector; - -/** - * - */ -public class PropCMFontProperty extends PropCMProperty { - - // static fields - private static java.util.Hashtable instances = null; - private static java.util.Hashtable cachedIdMap = null; - // selecting properties - public final static String PF_FONT_FAMILY = "font-family";//$NON-NLS-1$ - public final static String PF_FONT_STYLE = "font-style";//$NON-NLS-1$ - public final static String PF_FONT_VARIANT = "font-variant";//$NON-NLS-1$ - public final static String PF_FONT_WEIGHT = "font-weight";//$NON-NLS-1$ - public final static String PF_FONT_STRETCH = "font-stretch";//$NON-NLS-1$ - public final static String PF_FONT_SIZE = "font-size";//$NON-NLS-1$ - // qualification properties - public final static String PF_UNICODE_RANGE = "unicode-range";//$NON-NLS-1$ - // numeric properties - public final static String PF_UNITS_PER_EM = "units-per-em";//$NON-NLS-1$ - // referencing properties - public final static String PF_SRC = "src";//$NON-NLS-1$ - // matching properties - public final static String PF_PANOSE_1 = "panose-1";//$NON-NLS-1$ - public final static String PF_STEMV = "stemv";//$NON-NLS-1$ - public final static String PF_STEMH = "stemh";//$NON-NLS-1$ - public final static String PF_SLOPE = "slope";//$NON-NLS-1$ - public final static String PF_CAP_HEIGHT = "cap-height";//$NON-NLS-1$ - public final static String PF_X_HEIGHT = "x-height";//$NON-NLS-1$ - public final static String PF_ASCENT = "ascent";//$NON-NLS-1$ - public final static String PF_DESCENT = "descent";//$NON-NLS-1$ - // synthesis properties - public final static String PF_WIDTHS = "widths";//$NON-NLS-1$ - public final static String PF_BBOX = "bbox";//$NON-NLS-1$ - public final static String PF_DEFINITION_SRC = "definition-src";//$NON-NLS-1$ - // alignment properties - public final static String PF_BASELINE = "baseline";//$NON-NLS-1$ - public final static String PF_CENTERLINE = "centerline";//$NON-NLS-1$ - public final static String PF_MATHLINE = "mathline";//$NON-NLS-1$ - public final static String PF_TOPLINE = "topline";//$NON-NLS-1$ - - /** - * - */ - protected PropCMFontProperty(String name) { - super(name); - } - - /** - * - */ - public static PropCMProperty getInstanceOf(String name) { - // initialize - if (instances == null) - instances = new Hashtable(10); - - // Initialize of DB - if (isNeedInitialize()) - PropCMNode.initPropertyCM(); - - // query - Object node = instances.get(name); - if (node != null) - return (PropCMProperty) node; - - // register - if (PropCMNode.isLoading()) { - node = new PropCMFontProperty(name); - instances.put(name, node); - } - - return (PropCMProperty) node; - } - - /** - * - */ - public static Enumeration getNameEnum() { - // Initialize of DB - if (isNeedInitialize()) - PropCMNode.initPropertyCM(); - - return instances.keys(); - } - - /** - * - */ - public static Enumeration getPropertyEnum() { - // Initialize of DB - if (isNeedInitialize()) - PropCMNode.initPropertyCM(); - - return instances.elements(); - } - - /** - * - */ - public short getType() { - return VAL_FONTPROPERTY; - } - - /** - * - */ - public static Vector names() { - // Initialize of DB - if (isNeedInitialize()) - PropCMNode.initPropertyCM(); - - return new Vector(instances.keySet()); - } - - /** - * - */ - public static List names(Object mediaGroup) { - if (mediaGroup == null) - return names(); - - // Initialize of DB - if (isNeedInitialize()) - PropCMNode.initPropertyCM(); - - Vector properties = new Vector(); - - Iterator it = instances.values().iterator(); - while (it.hasNext()) { - PropCMProperty prop = (PropCMProperty) it.next(); - if (prop.getMediaGroups().contains(mediaGroup)) - properties.add(prop.getName()); - } - - return properties; - } - - /** - * If itentifier is null, get all properties - */ - public static Vector propertiesFor(String identifier, boolean shorthands) { - // Initialize of DB - if (isNeedInitialize()) - PropCMNode.initPropertyCM(); - - // if identifier is null, get all properties - if (identifier == null) - return new Vector(instances.values()); - - if (cachedIdMap == null) { - // start cacheing - cachedIdMap = new Hashtable(); - } - else { - // search cached - Object ret = cachedIdMap.get(identifier + String.valueOf(shorthands)); - if (ret != null) - return new Vector((Collection) ret); - } - - // create - Enumeration properties = getPropertyEnum(); - HashSet set = new HashSet(); - while (properties.hasMoreElements()) { - PropCMProperty prop = (PropCMProperty) properties.nextElement(); - if (!shorthands && prop.isShorthand()) - continue; - if (prop.canHave(identifier)) - set.add(prop); - } - - // cache - cachedIdMap.put(identifier + String.valueOf(shorthands), set); - - return new Vector(set); - } -} \ No newline at end of file diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMFunction.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMFunction.java deleted file mode 100644 index 03efc91c06..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMFunction.java +++ /dev/null @@ -1,89 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.contentmodel; - - - -import java.util.Collection; -import java.util.Hashtable; -import java.util.Set; - -/** - * - */ -public class PropCMFunction extends PropCMNode { - - private static java.util.Hashtable instances = null; - public final static String VAL_ATTR = "attr";//$NON-NLS-1$ - public final static String VAL_COUNTER = "counter";//$NON-NLS-1$ - public final static String VAL_RGB = "rgb";//$NON-NLS-1$ - public final static String VAL_SHAPE = "rect";//$NON-NLS-1$ - public final static String VAL_URI = "url";//$NON-NLS-1$ - public final static String VAL_FORMAT = "format";//$NON-NLS-1$ - public final static String VAL_LOCAL = "local";//$NON-NLS-1$ - - /** - * - */ - protected PropCMFunction(String name) { - super(name); - } - - /** - * - */ - void getIdentifiers(Set indents) { - } - - /** - * - */ - static public PropCMFunction getInstanceOf(String name) { - if (name == null) - return null; - - // initialize - if (instances == null) - instances = new Hashtable(10); - - // Initialize of DB - if (isNeedInitialize()) - PropCMNode.initPropertyCM(); - - // query - Object node = instances.get(name); - if (node != null) - return (PropCMFunction) node; - - // register - if (PropCMNode.isLoading()) { - node = new PropCMFunction(name); - instances.put(name, node); - } - - return (PropCMFunction) node; - } - - /** - * - */ - public short getType() { - return VAL_FUNC; - } - - /** - * - */ - void getValues(Collection values) { - if (values != null && !values.contains(this)) - values.add(this); - } -} \ No newline at end of file diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMNode.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMNode.java deleted file mode 100644 index 476ead2d36..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMNode.java +++ /dev/null @@ -1,1521 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2010 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.contentmodel; - - - -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; -import java.util.Vector; - -/** - * - */ -public abstract class PropCMNode { - - public final static short VAL_IDENTIFIER = 0; - public final static short VAL_PROPERTY = 1; - public final static short VAL_NUMBER = 2; - public final static short VAL_STRING = 3; - public final static short VAL_FUNC = 4; - public final static short VAL_CONTAINER = 5; - public final static short VAL_SUBPROPERTY = 6; - public final static short VAL_FONTPROPERTY = 7; - public final static short VAL_UNICODE_RANGE = 8; - protected java.lang.String name = null; - private static short LOADING = 0; // 0 : not initialized, 1 : under - // initializing, 2 : initialize-done - // and fix DB - - /** - * - */ - public PropCMNode(String name) { - super(); - this.name = name; - } - - /** - * - */ - public Set getIdentifiers() { - HashSet ids = new HashSet(); - getIdentifiers(ids); - return ids; - } - - /** - * - */ - abstract void getIdentifiers(Set indents); - - /** - * - */ - public String getName() { - return name; - } - - /** - * - */ - public abstract short getType(); - - /** - * - */ - public Collection getValues() { - Vector vals = new Vector(); - getValues(vals); - return vals; - } - - /** - * - */ - abstract void getValues(Collection values); - - /** - * - */ - protected static void initPropertyCM() { - if (!isNeedInitialize()) - return; - LOADING = 1; - - PropCMNumber.initNumberCMDim(); - - // azimuth - PropCMProperty prop = PropCMProperty.getInstanceOf(PropCMProperty.P_AZIMUTH); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_ANGLE)); - prop.appendChild(IValID.V_LEFT_SIDE); - prop.appendChild(IValID.V_FAR_LEFT); - prop.appendChild(IValID.V_LEFT); - prop.appendChild(IValID.V_CENTER_LEFT); - prop.appendChild(IValID.V_CENTER); - prop.appendChild(IValID.V_CENTER_RIGHT); - prop.appendChild(IValID.V_RIGHT); - prop.appendChild(IValID.V_FAR_RIGHT); - prop.appendChild(IValID.V_RIGHT_SIDE); - prop.appendChild(IValID.V_BEHIND); - prop.appendChild(IValID.V_LEFTWARDS); - prop.appendChild(IValID.V_RIGHTWARDS); - prop.appendMediaGroup(IMediaGroupID.M_AURAL); - prop.setMaxValueCount(2); - - // background - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BG); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BG_COLOR)); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BG_IMAGE)); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BG_REPEAT)); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BG_ATTACHMENT)); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BG_POSITION)); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - prop.setMaxValueCount(6); - - // background-attachment - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BG_ATTACHMENT); - prop.appendChild(IValID.V_SCROLL); - prop.appendChild(IValID.V_FIXED); - prop.appendChild(IValID.V_LOCAL); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // background-clip - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BG_CLIP); - prop.appendChild(IValID.V_BORDER_BOX); - prop.appendChild(IValID.V_CONTENT_BOX); - prop.appendChild(IValID.V_PADDING_BOX); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // background-color - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BG_COLOR); - prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_COLOR)); - prop.appendChild(IValID.V_TRANSPARENT); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // background-image - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BG_IMAGE); - prop.appendChild(PropCMFunction.getInstanceOf(PropCMFunction.VAL_URI)); - prop.appendChild(IValID.V_NONE); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // background-origin - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BG_ORIGIN); - prop.appendChild(IValID.V_PADDING_BOX); - prop.appendChild(IValID.V_BORDER_BOX); - prop.appendChild(IValID.V_CONTENT_BOX); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // background-position ---- sub-properties horizontal - prop = PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_BG_POSITION_X); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH)); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_PERCENTAGE)); - prop.appendChild(IValID.V_LEFT); - prop.appendChild(IValID.V_CENTER); - prop.appendChild(IValID.V_RIGHT); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // background-position ---- sub-properties vertical - prop = PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_BG_POSITION_Y); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH)); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_PERCENTAGE)); - prop.appendChild(IValID.V_TOP); - prop.appendChild(IValID.V_CENTER); - prop.appendChild(IValID.V_BOTTOM); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // background-position - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BG_POSITION); - prop.appendChild(PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_BG_POSITION_X)); - prop.appendChild(PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_BG_POSITION_Y)); - prop.setMaxValueCount(2); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // background-repeat - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BG_REPEAT); - prop.appendChild(IValID.V_REPEAT); - prop.appendChild(IValID.V_REPEAT_X); - prop.appendChild(IValID.V_REPEAT_Y); - prop.appendChild(IValID.V_SPACE); - prop.appendChild(IValID.V_ROUND); - prop.appendChild(IValID.V_NO_REPEAT); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // background-size - prop = PropCMSubProperty.getInstanceOf(PropCMProperty.P_BG_SIZE); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH)); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_PERCENTAGE)); - prop.appendChild(IValID.V_CONTAIN); - prop.appendChild(IValID.V_COVER); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // border - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_WIDTH)); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_STYLE)); - // prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_COLOR)); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_COLOR)); - prop.setMaxValueCount(9); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // border-collapse - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_COLLAPSE); - prop.appendChild(IValID.V_COLLAPSE); - prop.appendChild(IValID.V_SEPARATE); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // border-color - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_COLOR); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_TOP_COLOR)); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_RIGHT_COLOR)); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_BOTTOM_COLOR)); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_LEFT_COLOR)); - // prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_COLOR)); - prop.appendChild(IValID.V_TRANSPARENT); - prop.setMaxValueCount(4); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // border-spacing - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_SPACING); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH)); - prop.setMaxValueCount(2); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // border-style - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_STYLE); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_TOP_STYLE)); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_RIGHT_STYLE)); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_BOTTOM_STYLE)); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_LEFT_STYLE)); - // prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_BORDER_STYLE)); - prop.setMaxValueCount(4); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // border-top - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_TOP); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_TOP_WIDTH)); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_TOP_STYLE)); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_TOP_COLOR)); - prop.setMaxValueCount(3); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // border-right - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_RIGHT); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_RIGHT_WIDTH)); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_RIGHT_STYLE)); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_RIGHT_COLOR)); - prop.setMaxValueCount(3); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // border-bottom - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_BOTTOM); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_BOTTOM_WIDTH)); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_BOTTOM_STYLE)); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_BOTTOM_COLOR)); - prop.setMaxValueCount(3); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // border-left - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_LEFT); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_LEFT_WIDTH)); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_LEFT_STYLE)); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_LEFT_COLOR)); - prop.setMaxValueCount(3); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // border-top-color - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_TOP_COLOR); - prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_COLOR)); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // border-top-style - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_TOP_STYLE); - prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_BORDER_STYLE)); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // border-top-width - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_TOP_WIDTH); - prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_BORDER_WIDTH)); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // border-right-color - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_RIGHT_COLOR); - prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_COLOR)); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // border-right-style - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_RIGHT_STYLE); - prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_BORDER_STYLE)); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // border-right-width - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_RIGHT_WIDTH); - prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_BORDER_WIDTH)); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // border-bottom-color - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_BOTTOM_COLOR); - prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_COLOR)); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // border-bottom-style - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_BOTTOM_STYLE); - prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_BORDER_STYLE)); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // border-bottom-width - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_BOTTOM_WIDTH); - prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_BORDER_WIDTH)); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // border-left-color - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_LEFT_COLOR); - prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_COLOR)); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // border-left-style - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_LEFT_STYLE); - prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_BORDER_STYLE)); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // border-left-width - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_LEFT_WIDTH); - prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_BORDER_WIDTH)); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // border-width - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_WIDTH); - // prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_BORDER_WIDTH)); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_TOP_WIDTH)); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_RIGHT_WIDTH)); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_BOTTOM_WIDTH)); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_LEFT_WIDTH)); - prop.setMaxValueCount(4); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // border-top-left-radius - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_TOP_LEFT_RADIUS); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH)); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // border-top-right-radius - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_TOP_RIGHT_RADIUS); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH)); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // border-bottom-left-radius - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_BOTTOM_LEFT_RADIUS); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH)); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // border-bottom-right-radius - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_BOTTOM_RIGHT_RADIUS); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH)); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_RADIUS); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_TOP_LEFT_RADIUS)); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_TOP_RIGHT_RADIUS)); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_BOTTOM_LEFT_RADIUS)); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_BOTTOM_RIGHT_RADIUS)); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - prop.setMaxValueCount(4); - - // bottom - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BOTTOM); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH)); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_PERCENTAGE)); - prop.appendChild(IValID.V_AUTO); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // box-shadow - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BOX_SHADOW); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH)); - // prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_COLOR)); - prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_COLOR)); - prop.setMaxValueCount(4); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // box-shadow - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BOX_SIZING); - prop.appendChild(IValID.V_BORDER_BOX); - prop.appendChild(IValID.V_CONTENT_BOX); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // caption-side - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_CAPTION_SIDE); - prop.appendChild(IValID.V_TOP); - prop.appendChild(IValID.V_BOTTOM); - prop.appendChild(IValID.V_LEFT); - prop.appendChild(IValID.V_RIGHT); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // clear - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_CLEAR); - prop.appendChild(IValID.V_LEFT); - prop.appendChild(IValID.V_RIGHT); - prop.appendChild(IValID.V_BOTH); - prop.appendChild(IValID.V_STATIC); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // clip ---- sub-properties top - prop = PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_CLIP_TOP); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH)); - prop.appendChild(IValID.V_AUTO); - ((PropCMSubProperty) prop).setContainer(PropCMProperty.getInstanceOf(PropCMProperty.P_CLIP)); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // clip ---- sub-properties right - prop = PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_CLIP_RIGHT); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH)); - prop.appendChild(IValID.V_AUTO); - ((PropCMSubProperty) prop).setContainer(PropCMProperty.getInstanceOf(PropCMProperty.P_CLIP)); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // clip ---- sub-properties bottom - prop = PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_CLIP_BOTTOM); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH)); - prop.appendChild(IValID.V_AUTO); - ((PropCMSubProperty) prop).setContainer(PropCMProperty.getInstanceOf(PropCMProperty.P_CLIP)); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // clip ---- sub-properties left - prop = PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_CLIP_LEFT); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH)); - prop.appendChild(IValID.V_AUTO); - ((PropCMSubProperty) prop).setContainer(PropCMProperty.getInstanceOf(PropCMProperty.P_CLIP)); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // clip - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_CLIP); - prop.appendChild(PropCMFunction.getInstanceOf(PropCMFunction.VAL_SHAPE)); - prop.appendChild(IValID.V_AUTO); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // color - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_COLOR); - prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_COLOR)); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // columns - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_COLUMNS); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_COLUMN_WIDTH)); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_COLUMN_COUNT)); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // column-width - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_COLUMN_WIDTH); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH)); - prop.appendChild(IValID.V_AUTO); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // column-count - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_COLUMN_COUNT); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_INTEGER)); - prop.appendChild(IValID.V_AUTO); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // column-fill - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_COLUMN_FILL); - prop.appendChild(IValID.V_AUTO); - prop.appendChild(IValID.V_BALANCE); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // column-gap - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_COLUMN_GAP); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH)); - prop.appendChild(IValID.V_NORMAL); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // column-rule - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_COLUMN_RULE); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_COLUMN_RULE_WIDTH)); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_COLUMN_RULE_STYLE)); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_COLUMN_RULE_COLOR)); - prop.setMaxValueCount(3); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // column-rule-color - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_COLUMN_RULE_COLOR); - prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_COLOR)); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // column-rule-style - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_COLUMN_RULE_STYLE); - prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_BORDER_STYLE)); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // column-rule-width - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_COLUMN_RULE_WIDTH); - prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_BORDER_WIDTH)); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // column-span - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_COLUMN_SPAN); - prop.appendChild(IValID.V_1); - prop.appendChild(IValID.V_ALL); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // content - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_CONTENT); - prop.appendChild(PropCMString.getInstanceOf(PropCMString.VAL_ANY)); - prop.appendChild(PropCMFunction.getInstanceOf(PropCMFunction.VAL_URI)); - prop.appendChild(PropCMFunction.getInstanceOf(PropCMFunction.VAL_COUNTER)); - prop.appendChild(PropCMFunction.getInstanceOf(PropCMFunction.VAL_ATTR)); - prop.appendChild(IValID.V_OPEN_QUOTE); - prop.appendChild(IValID.V_CLOSE_QUOTE); - prop.appendChild(IValID.V_NO_OPEN_QUOTE); - prop.appendChild(IValID.V_NO_CLOSE_QUOTE); - prop.appendChild(IValID.V_NONE); - prop.appendChild(IValID.V_NORMAL); - prop.setMaxValueCount(-1); // infinite - prop.appendMediaGroup(IMediaGroupID.M_ALL); - - // counter-increment - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_COUNTER_INCREMENT); - prop.appendChild(PropCMString.getInstanceOf(PropCMString.VAL_COUNTER_ID)); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_INTEGER)); - prop.appendChild(IValID.V_NONE); - prop.setMaxValueCount(-1); - prop.appendMediaGroup(IMediaGroupID.M_ALL); - - // counter-reset - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_COUNTER_RESET); - prop.appendChild(PropCMString.getInstanceOf(PropCMString.VAL_COUNTER_ID)); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_INTEGER)); - prop.appendChild(IValID.V_NONE); - prop.setMaxValueCount(-1); - prop.appendMediaGroup(IMediaGroupID.M_ALL); - - // cue - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_CUE); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_CUE_BEFORE)); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_CUE_AFTER)); - prop.setMaxValueCount(2); - prop.appendMediaGroup(IMediaGroupID.M_AURAL); - - // cue-after - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_CUE_AFTER); - prop.appendChild(PropCMFunction.getInstanceOf(PropCMFunction.VAL_URI)); - prop.appendChild(IValID.V_NONE); - prop.appendMediaGroup(IMediaGroupID.M_AURAL); - - // cue-before - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_CUE_BEFORE); - prop.appendChild(PropCMFunction.getInstanceOf(PropCMFunction.VAL_URI)); - prop.appendChild(IValID.V_NONE); - prop.appendMediaGroup(IMediaGroupID.M_AURAL); - - // cursor - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_CURSOR); - prop.appendChild(PropCMFunction.getInstanceOf(PropCMFunction.VAL_URI)); - prop.appendChild(IValID.V_AUTO); - prop.appendChild(IValID.V_CROSSHAIR); - prop.appendChild(IValID.V_DEFAULT); - prop.appendChild(IValID.V_POINTER); - prop.appendChild(IValID.V_PROGRESS); - prop.appendChild(IValID.V_MOVE); - prop.appendChild(IValID.V_E_RESIZE); - prop.appendChild(IValID.V_NE_RESIZE); - prop.appendChild(IValID.V_NW_RESIZE); - prop.appendChild(IValID.V_N_RESIZE); - prop.appendChild(IValID.V_SE_RESIZE); - prop.appendChild(IValID.V_SW_RESIZE); - prop.appendChild(IValID.V_S_RESIZE); - prop.appendChild(IValID.V_W_RESIZE); - prop.appendChild(IValID.V_TEXT); - prop.appendChild(IValID.V_WAIT); - prop.appendChild(IValID.V_HELP); - prop.setMaxValueCount(-1); // infinite - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - prop.appendMediaGroup(IMediaGroupID.M_INTERACTIVE); - - // direction - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_DIRECTION); - prop.appendChild(IValID.V_LTR); - prop.appendChild(IValID.V_RTL); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // display - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_DISPLAY); - prop.appendChild(IValID.V_INLINE); - prop.appendChild(IValID.V_INLINE_BLOCK); - prop.appendChild(IValID.V_BLOCK); - prop.appendChild(IValID.V_LIST_ITEM); - prop.appendChild(IValID.V_RUN_IN); - prop.appendChild(IValID.V_COMPACT); - prop.appendChild(IValID.V_MARKER); - prop.appendChild(IValID.V_TABLE); - prop.appendChild(IValID.V_INLINE_TABLE); - prop.appendChild(IValID.V_TABLE_ROW_GROUP); - prop.appendChild(IValID.V_TABLE_HEADER_GROUP); - prop.appendChild(IValID.V_TABLE_FOOTER_GROUP); - prop.appendChild(IValID.V_TABLE_ROW); - prop.appendChild(IValID.V_TABLE_COLUMN_GROUP); - prop.appendChild(IValID.V_TABLE_COLUMN); - prop.appendChild(IValID.V_TABLE_CELL); - prop.appendChild(IValID.V_TABLE_CAPTION); - prop.appendChild(IValID.V_NONE); - prop.appendMediaGroup(IMediaGroupID.M_ALL); - - // elevation - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_ELEVATION); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_ANGLE)); - prop.appendChild(IValID.V_BELOW); - prop.appendChild(IValID.V_LEVEL); - prop.appendChild(IValID.V_ABOVE); - prop.appendChild(IValID.V_HIGHER); - prop.appendChild(IValID.V_LOWER); - prop.appendMediaGroup(IMediaGroupID.M_AURAL); - - // empty-cells - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_EMPTY_CELLS); - prop.appendChild(IValID.V_SHOW); - prop.appendChild(IValID.V_HIDE); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // float - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_FLOAT); - prop.appendChild(IValID.V_LEFT); - prop.appendChild(IValID.V_RIGHT); - prop.appendChild(IValID.V_NONE); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // font - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_FONT); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_FONT_STYLE)); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_FONT_VARIANT)); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_FONT_WEIGHT)); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_FONT_SIZE)); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_LINE_HEIGHT)); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_FONT_FAMILY)); - prop.appendChild(IValID.V_CAPTION); - prop.appendChild(IValID.V_ICON); - prop.appendChild(IValID.V_MENU); - prop.appendChild(IValID.V_MESSAGE_BOX); - prop.appendChild(IValID.V_SMALL_CAPTION); - prop.appendChild(IValID.V_STATUS_BAR); - prop.setMaxValueCount(-1); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // font-family - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_FONT_FAMILY); - prop.appendChild(PropCMString.getInstanceOf(PropCMString.VAL_FONT)); - prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_GENERIC_FAMILY)); - prop.setMaxValueCount(-1); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // font-size - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_FONT_SIZE); - prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_ABSOLUTE_SIZE)); - prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_RELATIVE_SIZE)); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH)); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_PERCENTAGE)); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // font-size-adjust - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_FONT_SIZE_ADJUST); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_NUM)); - prop.appendChild(IValID.V_NONE); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // font-stretch - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_FONT_STRETCH); - prop.appendChild(IValID.V_NORMAL); - prop.appendChild(IValID.V_WIDER); - prop.appendChild(IValID.V_NARROWER); - prop.appendChild(IValID.V_ULTRA_CONDENSED); - prop.appendChild(IValID.V_EXTRA_CONDENSED); - prop.appendChild(IValID.V_CONDENSED); - prop.appendChild(IValID.V_SEMI_CONDENSED); - prop.appendChild(IValID.V_SEMI_EXPANDED); - prop.appendChild(IValID.V_EXPANDED); - prop.appendChild(IValID.V_EXTRA_EXPANDED); - prop.appendChild(IValID.V_ULTRA_EXPANDED); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // font-style - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_FONT_STYLE); - prop.appendChild(IValID.V_ITALIC); - prop.appendChild(IValID.V_OBLIQUE); - prop.appendChild(IValID.V_NORMAL); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // font-variant - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_FONT_VARIANT); - prop.appendChild(IValID.V_SMALL_CAPS); - prop.appendChild(IValID.V_NORMAL); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // font-weight - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_FONT_WEIGHT); - prop.appendChild(IValID.V_BOLD); - prop.appendChild(IValID.V_100); - prop.appendChild(IValID.V_200); - prop.appendChild(IValID.V_300); - prop.appendChild(IValID.V_400); - prop.appendChild(IValID.V_500); - prop.appendChild(IValID.V_600); - prop.appendChild(IValID.V_700); - prop.appendChild(IValID.V_800); - prop.appendChild(IValID.V_900); - prop.appendChild(IValID.V_LIGHTER); - prop.appendChild(IValID.V_BOLDER); - prop.appendChild(IValID.V_NORMAL); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // height - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_HEIGHT); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH)); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_PERCENTAGE)); - prop.appendChild(IValID.V_AUTO); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // leftt - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_LEFT); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH)); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_PERCENTAGE)); - prop.appendChild(IValID.V_AUTO); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // letter-spacing - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_LETTER_SPACING); - prop.appendChild(IValID.V_NORMAL); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH)); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // line-height - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_LINE_HEIGHT); - prop.appendChild(IValID.V_NORMAL); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_NUM)); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH)); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_PERCENTAGE)); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // list-style - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_LIST_STYLE); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_LIST_STYLE_TYPE)); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_LIST_STYLE_POSITION)); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_LIST_STYLE_IMAGE)); - prop.setMaxValueCount(3); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // list-style-image - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_LIST_STYLE_IMAGE); - prop.appendChild(PropCMFunction.getInstanceOf(PropCMFunction.VAL_URI)); - prop.appendChild(IValID.V_NONE); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // list-style-position - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_LIST_STYLE_POSITION); - prop.appendChild(IValID.V_INSIDE); - prop.appendChild(IValID.V_OUTSIDE); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // list-style-type - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_LIST_STYLE_TYPE); - prop.appendChild(IValID.V_DISC); - prop.appendChild(IValID.V_CIRCLE); - prop.appendChild(IValID.V_SQUARE); - prop.appendChild(IValID.V_DECIMAL); - prop.appendChild(IValID.V_DECIMAL_LEADING_ZERO); - prop.appendChild(IValID.V_LOWER_ROMAN); - prop.appendChild(IValID.V_UPPER_ROMAN); - prop.appendChild(IValID.V_LOWER_GREEK); - prop.appendChild(IValID.V_LOWER_ALPHA); - prop.appendChild(IValID.V_LOWER_LATIN); - prop.appendChild(IValID.V_UPPER_ALPHA); - prop.appendChild(IValID.V_UPPER_LATIN); - prop.appendChild(IValID.V_HEBREW); - prop.appendChild(IValID.V_ARMENIAN); - prop.appendChild(IValID.V_GEORGIAN); - prop.appendChild(IValID.V_CJK_IDEOGRAPHIC); - prop.appendChild(IValID.V_HIRAGANA); - prop.appendChild(IValID.V_KATAKANA); - prop.appendChild(IValID.V_HIRAGANA_IROHA); - prop.appendChild(IValID.V_KATAKANA_IROHA); - prop.appendChild(IValID.V_NONE); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // margin - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_MARGIN); - // prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_MARGIN_WIDTH)); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_MARGIN_TOP)); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_MARGIN_RIGHT)); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_MARGIN_BOTTOM)); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_MARGIN_LEFT)); - prop.setMaxValueCount(4); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // margin-top - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_MARGIN_TOP); - prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_MARGIN_WIDTH)); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // margin-right - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_MARGIN_RIGHT); - prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_MARGIN_WIDTH)); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // margin-bottom - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_MARGIN_BOTTOM); - prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_MARGIN_WIDTH)); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // margin-left - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_MARGIN_LEFT); - prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_MARGIN_WIDTH)); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // marker-offset - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_MARKER_OFFSET); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH)); - prop.appendChild(IValID.V_AUTO); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // marks - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_MARKS); - prop.appendChild(IValID.V_CROP); - prop.appendChild(IValID.V_CROSS); - prop.appendChild(IValID.V_NONE); - prop.setMaxValueCount(2); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - prop.appendMediaGroup(IMediaGroupID.M_PAGED); - - // max-height - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_MAX_HEIGHT); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH)); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_PERCENTAGE)); - prop.appendChild(IValID.V_NONE); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // max-width - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_MAX_WIDTH); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH)); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_PERCENTAGE)); - prop.appendChild(IValID.V_NONE); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // min-height - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_MIN_HEIGHT); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH)); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_PERCENTAGE)); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // min-width - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_MIN_WIDTH); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH)); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_PERCENTAGE)); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // opacity - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_OPACITY); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_NUM)); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // orphans - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_ORPHANS); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_INTEGER)); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - prop.appendMediaGroup(IMediaGroupID.M_PAGED); - - // outline - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_OUTLINE); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_OUTLINE_COLOR)); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_OUTLINE_STYLE)); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_OUTLINE_WIDTH)); - prop.setMaxValueCount(3); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - prop.appendMediaGroup(IMediaGroupID.M_INTERACTIVE); - - // outline-color - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_OUTLINE_COLOR); - prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_COLOR)); - prop.appendChild(IValID.V_INVERT); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - prop.appendMediaGroup(IMediaGroupID.M_INTERACTIVE); - - // outline-style - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_OUTLINE_STYLE); - prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_BORDER_STYLE)); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - prop.appendMediaGroup(IMediaGroupID.M_INTERACTIVE); - - // outline-width - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_OUTLINE_WIDTH); - prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_BORDER_WIDTH)); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - prop.appendMediaGroup(IMediaGroupID.M_INTERACTIVE); - - // overflow - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_OVERFLOW); - prop.appendChild(IValID.V_VISIBLE); - prop.appendChild(IValID.V_HIDDEN); - prop.appendChild(IValID.V_SCROLL); - prop.appendChild(IValID.V_AUTO); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // padding - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_PADDING); - // prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_PADDING_WIDTH)); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_PADDING_TOP)); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_PADDING_RIGHT)); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_PADDING_BOTTOM)); - prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_PADDING_LEFT)); - prop.setMaxValueCount(4); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // padding-top - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_PADDING_TOP); - prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_PADDING_WIDTH)); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // padding-right - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_PADDING_RIGHT); - prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_PADDING_WIDTH)); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // padding-bottom - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_PADDING_BOTTOM); - prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_PADDING_WIDTH)); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // padding-left - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_PADDING_LEFT); - prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_PADDING_WIDTH)); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // page - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_PAGE); - prop.appendChild(PropCMString.getInstanceOf(PropCMString.VAL_PAGE_ID)); - prop.appendChild(IValID.V_AUTO); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - prop.appendMediaGroup(IMediaGroupID.M_PAGED); - - // page-break-after - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_PAGE_BREAK_AFTER); - prop.appendChild(IValID.V_AUTO); - prop.appendChild(IValID.V_ALWAYS); - prop.appendChild(IValID.V_AVOID); - prop.appendChild(IValID.V_LEFT); - prop.appendChild(IValID.V_RIGHT); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - prop.appendMediaGroup(IMediaGroupID.M_PAGED); - - // page-break-before - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_PAGE_BREAK_BEFORE); - prop.appendChild(IValID.V_AUTO); - prop.appendChild(IValID.V_ALWAYS); - prop.appendChild(IValID.V_AVOID); - prop.appendChild(IValID.V_LEFT); - prop.appendChild(IValID.V_RIGHT); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - prop.appendMediaGroup(IMediaGroupID.M_PAGED); - - // page-break-inside - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_PAGE_BREAK_INSIDE); - prop.appendChild(IValID.V_AVOID); - prop.appendChild(IValID.V_AUTO); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - prop.appendMediaGroup(IMediaGroupID.M_PAGED); - - // pause - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_PAUSE); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_TIME)); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_PERCENTAGE)); - prop.setMaxValueCount(2); - prop.appendMediaGroup(IMediaGroupID.M_AURAL); - - // pause-after - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_PAUSE_AFTER); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_TIME)); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_PERCENTAGE)); - prop.appendMediaGroup(IMediaGroupID.M_AURAL); - - // pause-before - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_PAUSE_BEFORE); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_TIME)); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_PERCENTAGE)); - prop.appendMediaGroup(IMediaGroupID.M_AURAL); - - // pitch - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_PITCH); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_FREQUENCY)); - prop.appendChild(IValID.V_X_LOW); - prop.appendChild(IValID.V_LOW); - prop.appendChild(IValID.V_MEDIUM); - prop.appendChild(IValID.V_HIGH); - prop.appendChild(IValID.V_X_HIGH); - prop.appendMediaGroup(IMediaGroupID.M_AURAL); - - // pitch-range - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_PITCH_RANGE); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_NUM)); - prop.appendMediaGroup(IMediaGroupID.M_AURAL); - - // play-during - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_PLAY_DURING); - prop.appendChild(PropCMFunction.getInstanceOf(PropCMFunction.VAL_URI)); - prop.appendChild(IValID.V_MIX); - prop.appendChild(IValID.V_REPEAT); - prop.appendChild(IValID.V_AUTO); - prop.appendChild(IValID.V_NONE); - prop.setMaxValueCount(3); - prop.appendMediaGroup(IMediaGroupID.M_AURAL); - - // position - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_POSITION); - prop.appendChild(IValID.V_ABSOLUTE); - prop.appendChild(IValID.V_RELATIVE); - prop.appendChild(IValID.V_FIXED); - prop.appendChild(IValID.V_STATIC); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // quotes - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_QUOTES); - prop.appendChild(PropCMString.getInstanceOf(PropCMString.VAL_ANY)); - prop.appendChild(IValID.V_NONE); - prop.setMaxValueCount(-1); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // resize - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_RESIZE); - prop.appendChild(IValID.V_BOTH); - prop.appendChild(IValID.V_HORIZONTAL); - prop.appendChild(IValID.V_NONE); - prop.appendChild(IValID.V_VERTICAL); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // richness - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_RICHNESS); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_NUM)); - prop.appendMediaGroup(IMediaGroupID.M_AURAL); - - // right - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_RIGHT); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH)); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_PERCENTAGE)); - prop.appendChild(IValID.V_AUTO); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // size - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_SIZE); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH)); - prop.appendChild(IValID.V_AUTO); - prop.appendChild(IValID.V_PORTRAIT); - prop.appendChild(IValID.V_LANDSCAPE); - prop.setMaxValueCount(2); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - prop.appendMediaGroup(IMediaGroupID.M_PAGED); - - // speak - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_SPEAK); - prop.appendChild(IValID.V_NORMAL); - prop.appendChild(IValID.V_NONE); - prop.appendChild(IValID.V_SPELL_OUT); - prop.appendMediaGroup(IMediaGroupID.M_AURAL); - - // speak-header - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_SPEAK_HEADER); - prop.appendChild(IValID.V_ONCE); - prop.appendChild(IValID.V_ALWAYS); - prop.appendMediaGroup(IMediaGroupID.M_AURAL); - - // speak-numeral - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_SPEAK_NUMERAL); - prop.appendChild(IValID.V_DIGITS); - prop.appendChild(IValID.V_CONTINUOUS); - prop.appendMediaGroup(IMediaGroupID.M_AURAL); - - // speak-punctuation - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_SPEAK_PUNCTUATION); - prop.appendChild(IValID.V_CODE); - prop.appendChild(IValID.V_NONE); - prop.appendMediaGroup(IMediaGroupID.M_AURAL); - - // speech-rate - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_SPEECH_RATE); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_NUM)); - prop.appendChild(IValID.V_X_SLOW); - prop.appendChild(IValID.V_SLOW); - prop.appendChild(IValID.V_MEDIUM); - prop.appendChild(IValID.V_FAST); - prop.appendChild(IValID.V_X_FAST); - prop.appendMediaGroup(IMediaGroupID.M_AURAL); - - // stress - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_STRESS); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_NUM)); - prop.appendMediaGroup(IMediaGroupID.M_AURAL); - - // table-layout - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_TABLE_LAYOUT); - prop.appendChild(IValID.V_AUTO); - prop.appendChild(IValID.V_FIXED); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // text-align - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_TEXT_ALIGN); - prop.appendChild(IValID.V_LEFT); - prop.appendChild(IValID.V_CENTER); - prop.appendChild(IValID.V_RIGHT); - prop.appendChild(IValID.V_JUSTIFY); - prop.appendChild(PropCMString.getInstanceOf(PropCMString.VAL_ANY)); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // text-decoration - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_TEXT_DECORATION); - prop.appendChild(IValID.V_UNDERLINE); - prop.appendChild(IValID.V_OVERLINE); - prop.appendChild(IValID.V_LINE_THROUGH); - prop.appendChild(IValID.V_BLINK); - prop.appendChild(IValID.V_NONE); - prop.setMaxValueCount(4); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // text-indent - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_TEXT_INDENT); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH)); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_PERCENTAGE)); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // text-overflow - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_TEXT_OVERFLOW); - prop.appendChild(IValID.V_CLIP); - prop.appendChild(IValID.V_ELLIPSIS); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // text-shadow - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_TEXT_SHADOW); - prop.appendChild(IValID.V_NONE); - prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_COLOR)); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH)); - prop.setMaxValueCount(-1); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // text-transform - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_TEXT_TRANSFORM); - prop.appendChild(IValID.V_CAPITALIZE); - prop.appendChild(IValID.V_UPPERCASE); - prop.appendChild(IValID.V_LOWERCASE); - prop.appendChild(IValID.V_NONE); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // top - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_TOP); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH)); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_PERCENTAGE)); - prop.appendChild(IValID.V_AUTO); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // unicode-bidi - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_UNICODE_BIDI); - prop.appendChild(IValID.V_NORMAL); - prop.appendChild(IValID.V_EMBED); - prop.appendChild(IValID.V_BIDI_OVERRIDE); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // vertical-align - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_VERTICAL_ALIGN); - prop.appendChild(IValID.V_BOTTOM); - prop.appendChild(IValID.V_TEXT_BOTTOM); - prop.appendChild(IValID.V_SUB); - prop.appendChild(IValID.V_BASELINE); - prop.appendChild(IValID.V_MIDDLE); - prop.appendChild(IValID.V_SUPER); - prop.appendChild(IValID.V_TEXT_TOP); - prop.appendChild(IValID.V_TOP); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_PERCENTAGE)); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH)); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // visibility - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_VISIBILITY); - prop.appendChild(IValID.V_VISIBLE); - prop.appendChild(IValID.V_HIDDEN); - prop.appendChild(IValID.V_COLLAPSE); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // voice-family - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_VOICE_FAMILY); - prop.appendChild(PropCMString.getInstanceOf(PropCMString.VAL_VOICE)); - prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_GENERIC_VOICE)); - prop.setMaxValueCount(-1); - prop.appendMediaGroup(IMediaGroupID.M_AURAL); - - // volume - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_VOLUME); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_NUM)); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_PERCENTAGE)); - prop.appendChild(IValID.V_SILENT); - prop.appendChild(IValID.V_X_SOFT); - prop.appendChild(IValID.V_SOFT); - prop.appendChild(IValID.V_MEDIUM); - prop.appendChild(IValID.V_LOUD); - prop.appendChild(IValID.V_X_LOUD); - prop.appendMediaGroup(IMediaGroupID.M_AURAL); - - // white-space - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_WHITE_SPACE); - prop.appendChild(IValID.V_NORMAL); - prop.appendChild(IValID.V_PRE); - prop.appendChild(IValID.V_PRE_LINE); - prop.appendChild(IValID.V_PRE_WRAP); - prop.appendChild(IValID.V_NOWRAP); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // widows - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_WIDOWS); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_INTEGER)); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - prop.appendMediaGroup(IMediaGroupID.M_PAGED); - - // width - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_WIDTH); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH)); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_PERCENTAGE)); - prop.appendChild(IValID.V_AUTO); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // word-spacing - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_WORD_SPACING); - prop.appendChild(IValID.V_NORMAL); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH)); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - // z-index - prop = PropCMProperty.getInstanceOf(PropCMProperty.P_Z_INDEX); - prop.appendChild(IValID.V_AUTO); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_INTEGER)); - prop.appendMediaGroup(IMediaGroupID.M_VISUAL); - - /** ******** font properties ********* */ - // font-family - prop = PropCMFontProperty.getInstanceOf(PropCMFontProperty.PF_FONT_FAMILY); - prop.appendChild(PropCMString.getInstanceOf(PropCMString.VAL_FONT)); - prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_GENERIC_FAMILY)); - prop.setMaxValueCount(-1); - - // font-style - prop = PropCMFontProperty.getInstanceOf(PropCMFontProperty.PF_FONT_STYLE); - prop.appendChild(IValID.V_ITALIC); - prop.appendChild(IValID.V_OBLIQUE); - prop.appendChild(IValID.V_NORMAL); - prop.appendChild(IValID.V_ALL); - prop.setMaxValueCount(-1); - - // font-variant - prop = PropCMFontProperty.getInstanceOf(PropCMFontProperty.PF_FONT_VARIANT); - prop.appendChild(IValID.V_SMALL_CAPS); - prop.appendChild(IValID.V_NORMAL); - prop.setMaxValueCount(-1); - - // font-weight - prop = PropCMFontProperty.getInstanceOf(PropCMFontProperty.PF_FONT_WEIGHT); - prop.appendChild(IValID.V_BOLD); - prop.appendChild(IValID.V_100); - prop.appendChild(IValID.V_200); - prop.appendChild(IValID.V_300); - prop.appendChild(IValID.V_400); - prop.appendChild(IValID.V_500); - prop.appendChild(IValID.V_600); - prop.appendChild(IValID.V_700); - prop.appendChild(IValID.V_800); - prop.appendChild(IValID.V_900); - prop.appendChild(IValID.V_NORMAL); - prop.appendChild(IValID.V_ALL); - prop.setMaxValueCount(-1); - - // font-stretch - prop = PropCMFontProperty.getInstanceOf(PropCMFontProperty.PF_FONT_STRETCH); - prop.appendChild(IValID.V_NORMAL); - prop.appendChild(IValID.V_ULTRA_CONDENSED); - prop.appendChild(IValID.V_EXTRA_CONDENSED); - prop.appendChild(IValID.V_CONDENSED); - prop.appendChild(IValID.V_SEMI_CONDENSED); - prop.appendChild(IValID.V_SEMI_EXPANDED); - prop.appendChild(IValID.V_EXPANDED); - prop.appendChild(IValID.V_EXTRA_EXPANDED); - prop.appendChild(IValID.V_ULTRA_EXPANDED); - prop.appendChild(IValID.V_ALL); - prop.setMaxValueCount(-1); - - // font-size - prop = PropCMFontProperty.getInstanceOf(PropCMFontProperty.PF_FONT_SIZE); - prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_ABSOLUTE_SIZE)); - prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_RELATIVE_SIZE)); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH)); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_PERCENTAGE)); - prop.appendChild(IValID.V_ALL); - prop.setMaxValueCount(-1); - - // unicode-range - prop = PropCMFontProperty.getInstanceOf(PropCMFontProperty.PF_UNICODE_RANGE); - prop.appendChild(PropCMURange.getInstanceOf(PropCMURange.VAL_URANGE)); - prop.setMaxValueCount(-1); - - // units-per-em - prop = PropCMFontProperty.getInstanceOf(PropCMFontProperty.PF_UNITS_PER_EM); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_NUM)); - - // src - prop = PropCMFontProperty.getInstanceOf(PropCMFontProperty.PF_SRC); - prop.appendChild(PropCMFunction.getInstanceOf(PropCMFunction.VAL_URI)); - prop.appendChild(PropCMFunction.getInstanceOf(PropCMFunction.VAL_FORMAT)); - prop.appendChild(PropCMFunction.getInstanceOf(PropCMFunction.VAL_LOCAL)); - prop.setMaxValueCount(-1); - - // panose-1 - prop = PropCMFontProperty.getInstanceOf(PropCMFontProperty.PF_PANOSE_1); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_INTEGER)); - prop.setMaxValueCount(10); - - // stemv - prop = PropCMFontProperty.getInstanceOf(PropCMFontProperty.PF_STEMV); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_NUM)); - - // stemh - prop = PropCMFontProperty.getInstanceOf(PropCMFontProperty.PF_STEMH); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_NUM)); - - // slope - prop = PropCMFontProperty.getInstanceOf(PropCMFontProperty.PF_SLOPE); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_NUM)); - - // cap-height - prop = PropCMFontProperty.getInstanceOf(PropCMFontProperty.PF_CAP_HEIGHT); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_NUM)); - - // x-height - prop = PropCMFontProperty.getInstanceOf(PropCMFontProperty.PF_X_HEIGHT); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_NUM)); - - // ascent - prop = PropCMFontProperty.getInstanceOf(PropCMFontProperty.PF_ASCENT); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_NUM)); - - // descent - prop = PropCMFontProperty.getInstanceOf(PropCMFontProperty.PF_DESCENT); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_NUM)); - - // widths - prop = PropCMFontProperty.getInstanceOf(PropCMFontProperty.PF_WIDTHS); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_NUM)); - prop.appendChild(PropCMURange.getInstanceOf(PropCMURange.VAL_URANGE)); - prop.setMaxValueCount(-1); - - // bbox - prop = PropCMFontProperty.getInstanceOf(PropCMFontProperty.PF_BBOX); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_NUM)); - prop.setMaxValueCount(4); - prop.setMaxValueCount(4); - - // definition-src - prop = PropCMFontProperty.getInstanceOf(PropCMFontProperty.PF_DEFINITION_SRC); - prop.appendChild(PropCMFunction.getInstanceOf(PropCMFunction.VAL_URI)); - - // baseline - prop = PropCMFontProperty.getInstanceOf(PropCMFontProperty.PF_BASELINE); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_NUM)); - - // centerline - prop = PropCMFontProperty.getInstanceOf(PropCMFontProperty.PF_CENTERLINE); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_NUM)); - - // mathline - prop = PropCMFontProperty.getInstanceOf(PropCMFontProperty.PF_MATHLINE); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_NUM)); - - // topline - prop = PropCMFontProperty.getInstanceOf(PropCMFontProperty.PF_TOPLINE); - prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_NUM)); - - /** ******** containers ********* */ - - // absolute-size - PropCMContainer cont = PropCMContainer.getContInstanceOf(PropCMContainer.VAL_ABSOLUTE_SIZE); - cont.appendChild(IValID.V_XX_SMALL); - cont.appendChild(IValID.V_X_SMALL); - cont.appendChild(IValID.V_SMALL); - cont.appendChild(IValID.V_MEDIUM); - cont.appendChild(IValID.V_LARGE); - cont.appendChild(IValID.V_X_LARGE); - cont.appendChild(IValID.V_XX_LARGE); - - // border-style - cont = PropCMContainer.getContInstanceOf(PropCMContainer.VAL_BORDER_STYLE); - cont.appendChild(IValID.V_SOLID); - cont.appendChild(IValID.V_DASHED); - cont.appendChild(IValID.V_DOTTED); - cont.appendChild(IValID.V_DOUBLE); - cont.appendChild(IValID.V_GROOVE); - cont.appendChild(IValID.V_RIDGE); - cont.appendChild(IValID.V_INSET); - cont.appendChild(IValID.V_OUTSET); - cont.appendChild(IValID.V_HIDDEN); - cont.appendChild(IValID.V_NONE); - - // border-width - cont = PropCMContainer.getContInstanceOf(PropCMContainer.VAL_BORDER_WIDTH); - cont.appendChild(IValID.V_THIN); - cont.appendChild(IValID.V_MEDIUM); - cont.appendChild(IValID.V_THICK); - cont.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH)); - - // color - cont = PropCMContainer.getContInstanceOf(PropCMContainer.VAL_COLOR); - cont.appendChild(IValID.V_AQUA); - cont.appendChild(IValID.V_BLACK); - cont.appendChild(IValID.V_BLUE); - cont.appendChild(IValID.V_FUCHSIA); - cont.appendChild(IValID.V_GRAY); - cont.appendChild(IValID.V_GREEN); - cont.appendChild(IValID.V_LIME); - cont.appendChild(IValID.V_MAROON); - cont.appendChild(IValID.V_NAVY); - cont.appendChild(IValID.V_OLIVE); - cont.appendChild(IValID.V_ORANGE); - cont.appendChild(IValID.V_PURPLE); - cont.appendChild(IValID.V_RED); - cont.appendChild(IValID.V_SILVER); - cont.appendChild(IValID.V_TEAL); - cont.appendChild(IValID.V_WHITE); - cont.appendChild(IValID.V_YELLOW); - cont.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_SYSTEM_COLOR)); - cont.appendChild(PropCMFunction.getInstanceOf(PropCMFunction.VAL_RGB)); - cont.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_HASH)); - - // system color - cont = PropCMContainer.getContInstanceOf(PropCMContainer.VAL_SYSTEM_COLOR); - cont.appendChild(IValID.V_ACTIVEBORDER); - cont.appendChild(IValID.V_ACTIVECAPTION); - cont.appendChild(IValID.V_APPWORKSPACE); - cont.appendChild(IValID.V_BACKGROUND); - cont.appendChild(IValID.V_BUTTONFACE); - cont.appendChild(IValID.V_BUTTONHIGHLIGHT); - cont.appendChild(IValID.V_BUTTONSHADOW); - cont.appendChild(IValID.V_BUTTONTEXT); - cont.appendChild(IValID.V_CAPTIONTEXT); - cont.appendChild(IValID.V_GRAYTEXT); - cont.appendChild(IValID.V_HIGHLIGHT); - cont.appendChild(IValID.V_HIGHLIGHTTEXT); - cont.appendChild(IValID.V_INACTIVEBORDER); - cont.appendChild(IValID.V_INACTIVECAPTION); - cont.appendChild(IValID.V_INACTIVECAPTIONTEXT); - cont.appendChild(IValID.V_INFOBACKGROUND); - cont.appendChild(IValID.V_INFOTEXT); - cont.appendChild(IValID.V_MENU); - cont.appendChild(IValID.V_MENUTEXT); - cont.appendChild(IValID.V_SCROLLBAR); - cont.appendChild(IValID.V_THREEDDARKSHADOW); - cont.appendChild(IValID.V_THREEDFACE); - cont.appendChild(IValID.V_THREEDHIGHLIGHT); - cont.appendChild(IValID.V_THREEDLIGHTSHADOW); - cont.appendChild(IValID.V_THREEDSHADOW); - cont.appendChild(IValID.V_WINDOW); - cont.appendChild(IValID.V_WINDOWFRAME); - cont.appendChild(IValID.V_WINDOWTEXT); - - // generic-family - cont = PropCMContainer.getContInstanceOf(PropCMContainer.VAL_GENERIC_FAMILY); - cont.appendChild(IValID.V_SERIF); - cont.appendChild(IValID.V_SANS_SERIF); - cont.appendChild(IValID.V_CURSIVE); - cont.appendChild(IValID.V_FANTASY); - cont.appendChild(IValID.V_MONOSPACE); - - // generic-voice - cont = PropCMContainer.getContInstanceOf(PropCMContainer.VAL_GENERIC_VOICE); - cont.appendChild(IValID.V_MALE); - cont.appendChild(IValID.V_FEMALE); - cont.appendChild(IValID.V_CHILD); - - // margin-width - cont = PropCMContainer.getContInstanceOf(PropCMContainer.VAL_MARGIN_WIDTH); - cont.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH)); - cont.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_PERCENTAGE)); - cont.appendChild(IValID.V_AUTO); - - // padding-width - cont = PropCMContainer.getContInstanceOf(PropCMContainer.VAL_PADDING_WIDTH); - cont.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH)); - cont.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_PERCENTAGE)); - - // relative-size - cont = PropCMContainer.getContInstanceOf(PropCMContainer.VAL_RELATIVE_SIZE); - cont.appendChild(IValID.V_SMALLER); - cont.appendChild(IValID.V_LARGER); - - LOADING = 2; - } - - /** - * - */ - protected static boolean isLoading() { - return LOADING == 1; - } - - /** - * - */ - protected static boolean isNeedInitialize() { - return LOADING == 0; - } - - /** - * - */ - public String toString() { - return getName(); - } -} \ No newline at end of file diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMNumber.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMNumber.java deleted file mode 100644 index 3896bb53c7..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMNumber.java +++ /dev/null @@ -1,219 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.contentmodel; - - - -import java.util.Collection; -import java.util.HashSet; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.Set; -import java.util.Vector; - -import org.eclipse.wst.css.core.internal.provisional.document.ICSSPrimitiveValue; -import org.w3c.dom.css.CSSPrimitiveValue; - - -/** - * - */ -public class PropCMNumber extends PropCMNode { - - private static java.util.Hashtable instances = null; - public final static java.lang.String VAL_ANGLE = "angle";//$NON-NLS-1$ - public final static java.lang.String VAL_FREQUENCY = "frequency";//$NON-NLS-1$ - public final static java.lang.String VAL_INTEGER = "integer";//$NON-NLS-1$ - public final static java.lang.String VAL_LENGTH = "length";//$NON-NLS-1$ - public final static java.lang.String VAL_PERCENTAGE = "percentage";//$NON-NLS-1$ - public final static java.lang.String VAL_TIME = "time";//$NON-NLS-1$ - public final static java.lang.String VAL_HASH = "hash"; //$NON-NLS-1$ - public final static java.lang.String VAL_NUM = "number";//$NON-NLS-1$ - public final static String DIM_CM = "cm";//$NON-NLS-1$ - public final static String DIM_DEG = "deg";//$NON-NLS-1$ - public final static String DIM_EMS = "em";//$NON-NLS-1$ - public final static String DIM_EXS = "ex";//$NON-NLS-1$ - public final static String DIM_GRAD = "grad";//$NON-NLS-1$ - public final static String DIM_HASH = "#";//$NON-NLS-1$ - public final static String DIM_HZ = "Hz";//$NON-NLS-1$ - public final static String DIM_IN = "in";//$NON-NLS-1$ - public final static String DIM_INTEGER = "INTEGER";//$NON-NLS-1$ - public final static String DIM_KHZ = "kHz";//$NON-NLS-1$ - public final static String DIM_MM = "mm";//$NON-NLS-1$ - public final static String DIM_MS = "ms";//$NON-NLS-1$ - public final static String DIM_NUMBER = "NUMBER";//$NON-NLS-1$ - public final static String DIM_PC = "pc";//$NON-NLS-1$ - public final static String DIM_PERCENTAGE = "%";//$NON-NLS-1$ - public final static String DIM_PT = "pt";//$NON-NLS-1$ - public final static String DIM_PX = "px";//$NON-NLS-1$ - public final static String DIM_RAD = "rad";//$NON-NLS-1$ - public final static String DIM_S = "s";//$NON-NLS-1$ - private java.util.Vector fDims = new Vector(); - - /** - * - */ - protected PropCMNumber(String name) { - super(name); - } - - /** - * - */ - public static String getDimension(short primitiveType) { - switch (primitiveType) { - case CSSPrimitiveValue.CSS_CM : - return DIM_CM; - case CSSPrimitiveValue.CSS_DEG : - return DIM_DEG; - case CSSPrimitiveValue.CSS_EMS : - return DIM_EMS; - case CSSPrimitiveValue.CSS_EXS : - return DIM_EXS; - case CSSPrimitiveValue.CSS_GRAD : - return DIM_GRAD; - case ICSSPrimitiveValue.CSS_HASH : - return DIM_HASH; // prefix dimension .... - case CSSPrimitiveValue.CSS_HZ : - return DIM_HZ; - case CSSPrimitiveValue.CSS_IN : - return DIM_IN; - case ICSSPrimitiveValue.CSS_INTEGER : - return "";//$NON-NLS-1$ - case CSSPrimitiveValue.CSS_KHZ : - return DIM_KHZ; - case CSSPrimitiveValue.CSS_MM : - return DIM_MM; - case CSSPrimitiveValue.CSS_MS : - return DIM_MS; - case CSSPrimitiveValue.CSS_NUMBER : - return "";//$NON-NLS-1$ - case CSSPrimitiveValue.CSS_PC : - return DIM_PC; - case CSSPrimitiveValue.CSS_PERCENTAGE : - return DIM_PERCENTAGE; - case CSSPrimitiveValue.CSS_PT : - return DIM_PT; - case CSSPrimitiveValue.CSS_PX : - return DIM_PX; - case CSSPrimitiveValue.CSS_RAD : - return DIM_RAD; - case CSSPrimitiveValue.CSS_S : - return DIM_S; - } - - return null; - } - - /** - * - */ - public Set getDimensions() { - HashSet vals = new HashSet(); - Iterator it = fDims.iterator(); - while (it.hasNext()) { - vals.add(it.next()); - } - - return vals; - } - - /** - * - */ - void getIdentifiers(Set indents) { - } - - /** - * - */ - static public PropCMNumber getInstanceOf(String name) { - if (name == null) - return null; - - // initialize - if (instances == null) - instances = new Hashtable(20); - - // Initialize of DB - if (isNeedInitialize()) - PropCMNode.initPropertyCM(); - - // query - Object node = instances.get(name); - if (node != null) - return (PropCMNumber) node; - - // register - if (PropCMNode.isLoading()) { - node = new PropCMNumber(name); - instances.put(name, node); - } - - return (PropCMNumber) node; - } - - /** - * - */ - public short getType() { - return VAL_NUMBER; - } - - /** - * - */ - void getValues(Collection values) { - if (values != null && !values.contains(this)) - values.add(this); - } - - /** - * - */ - static void initNumberCMDim() { - PropCMNumber num = getInstanceOf(VAL_ANGLE); - num.fDims.add(DIM_DEG); - num.fDims.add(DIM_GRAD); - num.fDims.add(DIM_RAD); - - num = getInstanceOf(VAL_FREQUENCY); - num.fDims.add(DIM_HZ); - num.fDims.add(DIM_KHZ); - - num = getInstanceOf(VAL_HASH); - num.fDims.add(DIM_HASH); - - // num = getInstanceOf(VAL_INTEGER); - // num.fDims.add(DIM_INTEGER); - - num = getInstanceOf(VAL_LENGTH); - num.fDims.add(DIM_CM); - num.fDims.add(DIM_EMS); - num.fDims.add(DIM_EXS); - num.fDims.add(DIM_IN); - num.fDims.add(DIM_MM); - num.fDims.add(DIM_PC); - num.fDims.add(DIM_PT); - num.fDims.add(DIM_PX); - - // num = getInstanceOf(VAL_NUMBER); - // num.fDims.add(DIM_NUMBER); - - num = getInstanceOf(VAL_PERCENTAGE); - num.fDims.add(DIM_PERCENTAGE); - - num = getInstanceOf(VAL_TIME); - num.fDims.add(DIM_MS); - num.fDims.add(DIM_S); - - } -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMProperty.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMProperty.java deleted file mode 100644 index 54cd4fb173..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMProperty.java +++ /dev/null @@ -1,440 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2010 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.contentmodel; - - - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Enumeration; -import java.util.HashSet; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.List; -import java.util.Vector; - -/** - * - */ -public class PropCMProperty extends PropCMContainer { - - // static fields - private static java.util.Hashtable instances = null; - private static java.util.Hashtable cachedIdMap = null; - public final static String P_AZIMUTH = "azimuth";//$NON-NLS-1$ - public final static String P_BG = "background";//$NON-NLS-1$ - public final static String P_BG_ATTACHMENT = "background-attachment";//$NON-NLS-1$ - public final static String P_BG_CLIP = "background-clip"; //$NON-NLS-1$ - public final static String P_BG_COLOR = "background-color";//$NON-NLS-1$ - public final static String P_BG_IMAGE = "background-image";//$NON-NLS-1$ - public final static String P_BG_ORIGIN = "background-origin"; //$NON-NLS-1$ - public final static String P_BG_POSITION = "background-position";//$NON-NLS-1$ - public final static String P_BG_REPEAT = "background-repeat";//$NON-NLS-1$ - public final static String P_BG_SIZE = "background-size"; //$NON-NLS-1$ - public final static String P_BORDER = "border";//$NON-NLS-1$ - public final static String P_BORDER_COLLAPSE = "border-collapse";//$NON-NLS-1$ - public final static String P_BORDER_COLOR = "border-color";//$NON-NLS-1$ - public final static String P_BORDER_SPACING = "border-spacing";//$NON-NLS-1$ - public final static String P_BORDER_STYLE = "border-style";//$NON-NLS-1$ - public final static String P_BORDER_TOP = "border-top";//$NON-NLS-1$ - public final static String P_BORDER_RIGHT = "border-right";//$NON-NLS-1$ - public final static String P_BORDER_BOTTOM = "border-bottom";//$NON-NLS-1$ - public final static String P_BORDER_LEFT = "border-left";//$NON-NLS-1$ - public final static String P_BORDER_TOP_COLOR = "border-top-color";//$NON-NLS-1$ - public final static String P_BORDER_RIGHT_COLOR = "border-right-color";//$NON-NLS-1$ - public final static String P_BORDER_BOTTOM_COLOR = "border-bottom-color";//$NON-NLS-1$ - public final static String P_BORDER_LEFT_COLOR = "border-left-color";//$NON-NLS-1$ - public final static String P_BORDER_TOP_STYLE = "border-top-style";//$NON-NLS-1$ - public final static String P_BORDER_RIGHT_STYLE = "border-right-style";//$NON-NLS-1$ - public final static String P_BORDER_BOTTOM_STYLE = "border-bottom-style";//$NON-NLS-1$ - public final static String P_BORDER_LEFT_STYLE = "border-left-style";//$NON-NLS-1$ - public final static String P_BORDER_TOP_WIDTH = "border-top-width";//$NON-NLS-1$ - public final static String P_BORDER_RIGHT_WIDTH = "border-right-width";//$NON-NLS-1$ - public final static String P_BORDER_BOTTOM_WIDTH = "border-bottom-width";//$NON-NLS-1$ - public final static String P_BORDER_LEFT_WIDTH = "border-left-width";//$NON-NLS-1$ - public final static String P_BORDER_WIDTH = "border-width";//$NON-NLS-1$ - public final static String P_BORDER_RADIUS = "border-radius"; //$NON-NLS-1$ - public final static String P_BORDER_TOP_LEFT_RADIUS = "border-top-left-radius"; //$NON-NLS-1$ - public final static String P_BORDER_TOP_RIGHT_RADIUS = "border-top-right-radius"; //$NON-NLS-1$ - public final static String P_BORDER_BOTTOM_LEFT_RADIUS = "border-bottom-left-radius"; //$NON-NLS-1$ - public final static String P_BORDER_BOTTOM_RIGHT_RADIUS = "border-bottom-right-radius"; //$NON-NLS-1$ - public final static String P_BOTTOM = "bottom";//$NON-NLS-1$ - public final static String P_BOX_SHADOW = "box-shadow"; //$NON-NLS-1$ - public final static String P_BOX_SIZING = "box-sizing"; //$NON-NLS-1$ - public final static String P_CAPTION_SIDE = "caption-side";//$NON-NLS-1$ - public final static String P_CLEAR = "clear";//$NON-NLS-1$ - public final static String P_CLIP = "clip";//$NON-NLS-1$ - public final static String P_COLOR = "color";//$NON-NLS-1$ - public final static String P_COLUMNS = "columns";//$NON-NLS-1$ - public final static String P_COLUMN_COUNT = "column-count";//$NON-NLS-1$ - public final static String P_COLUMN_FILL = "column-fill";//$NON-NLS-1$ - public final static String P_COLUMN_GAP = "column-gap";//$NON-NLS-1$ - public final static String P_COLUMN_RULE = "column-rule";//$NON-NLS-1$ - public final static String P_COLUMN_RULE_COLOR = "column-rule-color";//$NON-NLS-1$ - public final static String P_COLUMN_RULE_STYLE = "column-rule-styler";//$NON-NLS-1$ - public final static String P_COLUMN_RULE_WIDTH = "column-rule-width";//$NON-NLS-1$ - public final static String P_COLUMN_SPAN = "column-span";//$NON-NLS-1$ - public final static String P_COLUMN_WIDTH = "column-width";//$NON-NLS-1$ - public final static String P_CONTENT = "content";//$NON-NLS-1$ - public final static String P_COUNTER_INCREMENT = "counter-increment";//$NON-NLS-1$ - public final static String P_COUNTER_RESET = "counter-reset";//$NON-NLS-1$ - public final static String P_CUE = "cue";//$NON-NLS-1$ - public final static String P_CUE_AFTER = "cue-after";//$NON-NLS-1$ - public final static String P_CUE_BEFORE = "cue-before";//$NON-NLS-1$ - public final static String P_CURSOR = "cursor";//$NON-NLS-1$ - public final static String P_DIRECTION = "direction";//$NON-NLS-1$ - public final static String P_DISPLAY = "display";//$NON-NLS-1$ - public final static String P_ELEVATION = "elevation";//$NON-NLS-1$ - public final static String P_EMPTY_CELLS = "empty-cells";//$NON-NLS-1$ - public final static String P_FLOAT = "float";//$NON-NLS-1$ - public final static String P_FONT = "font";//$NON-NLS-1$ - public final static String P_FONT_FAMILY = "font-family";//$NON-NLS-1$ - public final static String P_FONT_SIZE = "font-size";//$NON-NLS-1$ - public final static String P_FONT_SIZE_ADJUST = "font-size-adjust";//$NON-NLS-1$ - public final static String P_FONT_STRETCH = "font-stretch";//$NON-NLS-1$ - public final static String P_FONT_STYLE = "font-style";//$NON-NLS-1$ - public final static String P_FONT_VARIANT = "font-variant";//$NON-NLS-1$ - public final static String P_FONT_WEIGHT = "font-weight";//$NON-NLS-1$ - public final static String P_HEIGHT = "height";//$NON-NLS-1$ - public final static String P_LEFT = "left";//$NON-NLS-1$ - public final static String P_LETTER_SPACING = "letter-spacing";//$NON-NLS-1$ - public final static String P_LINE_HEIGHT = "line-height";//$NON-NLS-1$ - public final static String P_LIST_STYLE = "list-style";//$NON-NLS-1$ - public final static String P_LIST_STYLE_IMAGE = "list-style-image";//$NON-NLS-1$ - public final static String P_LIST_STYLE_POSITION = "list-style-position";//$NON-NLS-1$ - public final static String P_LIST_STYLE_TYPE = "list-style-type";//$NON-NLS-1$ - public final static String P_MARGIN = "margin";//$NON-NLS-1$ - public final static String P_MARGIN_TOP = "margin-top";//$NON-NLS-1$ - public final static String P_MARGIN_RIGHT = "margin-right";//$NON-NLS-1$ - public final static String P_MARGIN_BOTTOM = "margin-bottom";//$NON-NLS-1$ - public final static String P_MARGIN_LEFT = "margin-left";//$NON-NLS-1$ - public final static String P_MARKER_OFFSET = "marker-offset";//$NON-NLS-1$ - public final static String P_MARKS = "marks";//$NON-NLS-1$ - public final static String P_MAX_HEIGHT = "max-height";//$NON-NLS-1$ - public final static String P_MAX_WIDTH = "max-width";//$NON-NLS-1$ - public final static String P_MIN_HEIGHT = "min-height";//$NON-NLS-1$ - public final static String P_MIN_WIDTH = "min-width";//$NON-NLS-1$ - public final static String P_OPACITY = "opacity"; //$NON-NLS-1$ - public final static String P_ORPHANS = "orphans";//$NON-NLS-1$ - public final static String P_OUTLINE = "outline";//$NON-NLS-1$ - public final static String P_OUTLINE_COLOR = "outline-color";//$NON-NLS-1$ - public final static String P_OUTLINE_STYLE = "outline-style";//$NON-NLS-1$ - public final static String P_OUTLINE_WIDTH = "outline-width";//$NON-NLS-1$ - public final static String P_OVERFLOW = "overflow";//$NON-NLS-1$ - public final static String P_PADDING = "padding";//$NON-NLS-1$ - public final static String P_PADDING_TOP = "padding-top";//$NON-NLS-1$ - public final static String P_PADDING_RIGHT = "padding-right";//$NON-NLS-1$ - public final static String P_PADDING_BOTTOM = "padding-bottom";//$NON-NLS-1$ - public final static String P_PADDING_LEFT = "padding-left";//$NON-NLS-1$ - public final static String P_PAGE = "page";//$NON-NLS-1$ - public final static String P_PAGE_BREAK_AFTER = "page-break-after";//$NON-NLS-1$ - public final static String P_PAGE_BREAK_BEFORE = "page-break-before";//$NON-NLS-1$ - public final static String P_PAGE_BREAK_INSIDE = "page-break-inside";//$NON-NLS-1$ - public final static String P_PAUSE = "pause";//$NON-NLS-1$ - public final static String P_PAUSE_AFTER = "pause-after";//$NON-NLS-1$ - public final static String P_PAUSE_BEFORE = "pause-before";//$NON-NLS-1$ - public final static String P_PITCH = "pitch";//$NON-NLS-1$ - public final static String P_PITCH_RANGE = "pitch-range";//$NON-NLS-1$ - public final static String P_PLAY_DURING = "play-during";//$NON-NLS-1$ - public final static String P_POSITION = "position";//$NON-NLS-1$ - public final static String P_QUOTES = "quotes";//$NON-NLS-1$ - public final static String P_RESIZE = "resize"; //$NON-NLS-1$ - public final static String P_RICHNESS = "richness";//$NON-NLS-1$ - public final static String P_RIGHT = "right";//$NON-NLS-1$ - public final static String P_SIZE = "size";//$NON-NLS-1$ - public final static String P_SPEAK = "speak";//$NON-NLS-1$ - public final static String P_SPEAK_HEADER = "speak-header";//$NON-NLS-1$ - public final static String P_SPEAK_NUMERAL = "speak-numeral";//$NON-NLS-1$ - public final static String P_SPEAK_PUNCTUATION = "speak-punctuation";//$NON-NLS-1$ - public final static String P_SPEECH_RATE = "speech-rate";//$NON-NLS-1$ - public final static String P_STRESS = "stress";//$NON-NLS-1$ - public final static String P_TABLE_LAYOUT = "table-layout";//$NON-NLS-1$ - public final static String P_TEXT_ALIGN = "text-align";//$NON-NLS-1$ - public final static String P_TEXT_DECORATION = "text-decoration";//$NON-NLS-1$ - public final static String P_TEXT_INDENT = "text-indent";//$NON-NLS-1$ - public final static String P_TEXT_OVERFLOW = "text-overflow"; //$NON-NLS-1$ - public final static String P_TEXT_SHADOW = "text-shadow";//$NON-NLS-1$ - public final static String P_TEXT_TRANSFORM = "text-transform";//$NON-NLS-1$ - public final static String P_TOP = "top";//$NON-NLS-1$ - public final static String P_UNICODE_BIDI = "unicode-bidi";//$NON-NLS-1$ - public final static String P_VERTICAL_ALIGN = "vertical-align";//$NON-NLS-1$ - public final static String P_VISIBILITY = "visibility";//$NON-NLS-1$ - public final static String P_VOICE_FAMILY = "voice-family";//$NON-NLS-1$ - public final static String P_VOLUME = "volume";//$NON-NLS-1$ - public final static String P_WHITE_SPACE = "white-space";//$NON-NLS-1$ - public final static String P_WIDOWS = "widows";//$NON-NLS-1$ - public final static String P_WIDTH = "width";//$NON-NLS-1$ - public final static String P_WORD_SPACING = "word-spacing";//$NON-NLS-1$ - public final static String P_Z_INDEX = "z-index";//$NON-NLS-1$ - // instance fields - private int fMinValueCount = 1; - private int fMaxValueCount = 1; - private Object[] mediaGroups; - protected List containers; - - /** - * - */ - protected PropCMProperty(String name) { - super(name); - } - - /** - * - */ - Object appendChild(Object node) { - Object ret = super.appendChild(node); - if (node instanceof PropCMProperty) { - // register shorthand container - PropCMProperty cm = (PropCMProperty) node; - if (cm.containers == null) - cm.containers = new Vector(); - if (!cm.containers.contains(this)) - cm.containers.add(this); - } - return ret; - } - - /** - * - */ - void appendMediaGroup(Object mg) { - if (mediaGroups == null) - mediaGroups = new Object[1]; - else { - Object[] oldMediaGroups = mediaGroups; - mediaGroups = new Object[oldMediaGroups.length + 1]; - System.arraycopy(oldMediaGroups, 0, mediaGroups, 0, oldMediaGroups.length); - } - mediaGroups[mediaGroups.length - 1] = mg; - } - - /** - * - */ - public static PropCMProperty getInstanceOf(String name) { - // initialize - if (instances == null) - instances = new Hashtable(200); - - // Initialize of DB - if (isNeedInitialize()) - PropCMNode.initPropertyCM(); - - // query - Object node = instances.get(name); - if (node != null) - return (PropCMProperty) node; - - // register - if (PropCMNode.isLoading()) { - node = new PropCMProperty(name); - instances.put(name, node); - } - - return (PropCMProperty) node; - } - - /** - * - */ - public int getMaxValueCount() { - return fMaxValueCount; - } - - /** - * - */ - public List getMediaGroups() { - if (mediaGroups != null) - return Arrays.asList(mediaGroups); - else - return new ArrayList(); - } - - /** - * - */ - public int getMinValueCount() { - return fMinValueCount; - } - - /** - * - */ - public static Enumeration getNameEnum() { - // Initialize of DB - if (isNeedInitialize()) - PropCMNode.initPropertyCM(); - - return instances.keys(); - } - - /** - * - */ - public static Enumeration getPropertyEnum() { - // Initialize of DB - if (isNeedInitialize()) - PropCMNode.initPropertyCM(); - - return instances.elements(); - } - - /** - * - */ - public int getShorthandContainerCount() { - return (containers == null) ? 0 : containers.size(); - } - - /** - * - */ - public short getType() { - return VAL_PROPERTY; - } - - /** - * - */ - public boolean isShorthand() { - int nChild = getNumChild(); - for (int i = 0; i < nChild; i++) { - Object obj = getChildAt(i); - if (obj instanceof PropCMProperty && !(obj instanceof PropCMSubProperty)) - return true; - } - return false; - } - - /** - * - */ - public static Vector names() { - // Initialize of DB - if (isNeedInitialize()) - PropCMNode.initPropertyCM(); - - return new Vector(instances.keySet()); - } - - /** - * - */ - public static List names(Object mediaGroup) { - if (mediaGroup == null) - return names(); - - // Initialize of DB - if (isNeedInitialize()) - PropCMNode.initPropertyCM(); - - Vector properties = new Vector(); - - Iterator it = instances.values().iterator(); - while (it.hasNext()) { - PropCMProperty prop = (PropCMProperty) it.next(); - if (prop.getMediaGroups().contains(mediaGroup)) - properties.add(prop.getName()); - } - - return properties; - } - - /** - * If identifier is null, get all properties - */ - public static Vector propertiesFor(String identifier, boolean shorthands) { - // Initialize of DB - if (isNeedInitialize()) - PropCMNode.initPropertyCM(); - - // if identifier is null, get all properties - if (identifier == null) - return new Vector(instances.values()); - - if (cachedIdMap == null) { - // start cacheing - cachedIdMap = new Hashtable(); - } - else { - // search cached - Object ret = cachedIdMap.get(identifier + String.valueOf(shorthands)); - if (ret != null) - return new Vector((Collection) ret); - } - - // create - Enumeration propertyEnum = getPropertyEnum(); - HashSet set = new HashSet(); - while (propertyEnum.hasMoreElements()) { - PropCMProperty prop = (PropCMProperty) propertyEnum.nextElement(); - if (!shorthands && prop.isShorthand()) - continue; - if (prop.canHave(identifier)) - set.add(prop); - } - - // cache - cachedIdMap.put(identifier + String.valueOf(shorthands), set); - - return new Vector(set); - } - - /** - * - */ - protected void setMaxValueCount(int newMaxValueCount) { - fMaxValueCount = newMaxValueCount; - } - - /** - * - */ - protected void setMinValueCount(int newMinValueCount) { - fMinValueCount = newMinValueCount; - } - - /** - * - */ - public PropCMProperty shorthandContainerAt(int i) { - if (containers == null) - return null; - if (i < 0 || containers.size() <= i) - return null; - return (PropCMProperty) containers.get(i); - } - - /** - * - */ - public Iterator shorthandContainerIterator() { - if (containers == null) { - return new Iterator() { - public boolean hasNext() { - return false; - } - - public Object next() { - return null; - } - - public void remove() { - } - }; - } - else - return containers.iterator(); - } -} \ No newline at end of file diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMString.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMString.java deleted file mode 100644 index 00a1e82008..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMString.java +++ /dev/null @@ -1,85 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.contentmodel; - - - -import java.util.Collection; -import java.util.Hashtable; -import java.util.Set; - -/** - * - */ -public class PropCMString extends PropCMNode { - - private static java.util.Hashtable instances = null; - public final static java.lang.String VAL_FONT = "font";//$NON-NLS-1$ - public final static java.lang.String VAL_COUNTER_ID = "counterId";//$NON-NLS-1$ - public final static java.lang.String VAL_PAGE_ID = "pageId";//$NON-NLS-1$ - public final static java.lang.String VAL_VOICE = "voice";//$NON-NLS-1$ - public final static java.lang.String VAL_ANY = "any"; //$NON-NLS-1$ - - /** - * - */ - protected PropCMString(String name) { - super(name); - } - - /** - * - */ - void getIdentifiers(Set indents) { - } - - /** - * - */ - static public PropCMString getInstanceOf(String name) { - if (name == null) - return null; - - // initialize - if (instances == null) - instances = new Hashtable(10); - - // Initialize of DB - if (isNeedInitialize()) - PropCMNode.initPropertyCM(); - - // query - Object node = instances.get(name); - if (node != null) - return (PropCMString) node; - - // register - node = new PropCMString(name); - instances.put(name, node); - - return (PropCMString) node; - } - - /** - * - */ - public short getType() { - return VAL_STRING; - } - - /** - * - */ - void getValues(Collection values) { - if (values != null && !values.contains(this)) - values.add(this); - } -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMSubProperty.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMSubProperty.java deleted file mode 100644 index 81ebb3733d..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMSubProperty.java +++ /dev/null @@ -1,122 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.contentmodel; - - - -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.Vector; - -/** - * - */ -public class PropCMSubProperty extends PropCMProperty { - - // static fields - private static java.util.Hashtable instances = null; - public final static String PSUB_BG_POSITION_X = "background-positionH";//$NON-NLS-1$ - public final static String PSUB_BG_POSITION_Y = "background-positionV";//$NON-NLS-1$ - public final static String PSUB_CLIP_TOP = "clipTop";//$NON-NLS-1$ - public final static String PSUB_CLIP_RIGHT = "clipRight";//$NON-NLS-1$ - public final static String PSUB_CLIP_BOTTOM = "clipBottom";//$NON-NLS-1$ - public final static String PSUB_CLIP_LEFT = "clipLeft";//$NON-NLS-1$ - - /** - * - */ - protected PropCMSubProperty(String name) { - super(name); - } - - /** - * - */ - public PropCMProperty getContainer() { - return shorthandContainerAt(0); - } - - /** - * - */ - public static PropCMProperty getInstanceOf(String name) { - // initialize - if (instances == null) - instances = new Hashtable(10); - - // Initialize of DB - if (isNeedInitialize()) - PropCMNode.initPropertyCM(); - - // query - Object node = instances.get(name); - if (node != null) - return (PropCMProperty) node; - - // register - if (PropCMNode.isLoading()) { - node = new PropCMSubProperty(name); - instances.put(name, node); - } - - return (PropCMProperty) node; - } - - /** - * - */ - public static Enumeration getNameEnum() { - // Initialize of DB - if (isNeedInitialize()) - PropCMNode.initPropertyCM(); - - return instances.keys(); - } - - /** - * - */ - public static Enumeration getPropertyEnum() { - // Initialize of DB - if (isNeedInitialize()) - PropCMNode.initPropertyCM(); - - return instances.elements(); - } - - /** - * - */ - public short getType() { - return VAL_SUBPROPERTY; - } - - /** - * - */ - public static Vector names() { - // Initialize of DB - if (isNeedInitialize()) - PropCMNode.initPropertyCM(); - - return new Vector(instances.keySet()); - } - - /** - * - */ - public void setContainer(PropCMProperty prop) { - if (containers == null) - containers = new Vector(); - containers.clear(); - containers.add(prop); - } -} \ No newline at end of file diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMURange.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMURange.java deleted file mode 100644 index 3375715d5e..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMURange.java +++ /dev/null @@ -1,81 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.contentmodel; - - - -import java.util.Collection; -import java.util.Hashtable; -import java.util.Set; - -/** - * - */ -public class PropCMURange extends PropCMNode { - - private static java.util.Hashtable instances = null; - public final static String VAL_URANGE = "urange";//$NON-NLS-1$ - - /** - * - */ - protected PropCMURange(String name) { - super(name); - } - - /** - * - */ - void getIdentifiers(Set indents) { - } - - /** - * - */ - public static PropCMURange getInstanceOf(String name) { - if (name == null) - return null; - - // initialize - if (instances == null) - instances = new Hashtable(10); - - // Initialize of DB - if (isNeedInitialize()) - PropCMNode.initPropertyCM(); - - // query - Object node = instances.get(name); - if (node != null) - return (PropCMURange) node; - - // register - node = new PropCMURange(name); - instances.put(name, node); - - return (PropCMURange) node; - } - - /** - * - */ - public short getType() { - return VAL_UNICODE_RANGE; - } - - /** - * - */ - void getValues(Collection values) { - if (values != null && !values.contains(this)) - values.add(this); - } -} \ No newline at end of file diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMUtil.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMUtil.java deleted file mode 100644 index 816ba377c6..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMUtil.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.contentmodel; - - - -import java.util.Collection; -import java.util.Iterator; - -/** - * - */ -public class PropCMUtil { - - /** - * - */ - public static void minus(Collection src, Collection ref) { - Iterator it = ref.iterator(); - while (it.hasNext()) { - Object obj = it.next(); - if (src.contains(obj)) - src.remove(obj); - } - return; - } - - /** - * - */ - public static void plus(Collection src, Collection ref) { - Iterator it = ref.iterator(); - while (it.hasNext()) { - Object obj = it.next(); - if (!src.contains(obj)) - src.add(obj); - } - return; - } -} \ No newline at end of file diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentproperties/CSSContentProperties.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentproperties/CSSContentProperties.java deleted file mode 100644 index 3bbc582ac6..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentproperties/CSSContentProperties.java +++ /dev/null @@ -1,194 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.contentproperties; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.ProjectScope; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Status; -import org.eclipse.wst.css.core.internal.CSSCorePlugin; -import org.eclipse.wst.css.core.internal.Logger; -import org.osgi.service.prefs.BackingStoreException; -import org.osgi.service.prefs.Preferences; - -/** - * Properties constants used by CSS. Clients should only read and modify the - * CSS properties programmatically using this class. - * - * @since 1.1 - */ -public class CSSContentProperties { - static final String CSSCORE_ID = CSSCorePlugin.getDefault().getBundle().getSymbolicName(); - private static final String PROJECT_KEY = ""; //$NON-NLS-1$ - - /** - * The default css profile to use when none is specified. - *

- * Value is of type String. - *

- */ - public static final String CSS_PROFILE = "css-profile"; //$NON-NLS-1$ - - /** - * Generates a preference key based on resourcePath - * - * @param resourcePath - * the path the key will be based off of - * @return preference key based on resourcePath (basically the - * resourcePath without the filename); PROJECT_KEY if resourcePath - * is null - */ - static String getKeyFor(IPath resourcePath) { - String key = PROJECT_KEY; - if (resourcePath != null && resourcePath.segmentCount() > 1) { - key = resourcePath.removeFirstSegments(1).toString(); - } - return key; - } - - /** - * Get the preferences node associated with the given project scope and - * preference key (subNode) If create is true, the preference node will be - * created if one does not already exist - * - * @param project - * the project the preference node is under - * @param preferenceKey - * the subnode/category the preference node is located in - * @param create - * if true, a preference node will be created if one does not - * already exist - * @return Preferences associated with the given project scope and - * preference key. null if one could not be found and create is - * false - */ - static Preferences getPreferences(IProject project, String preferenceKey, boolean create) { - if (create) - // create all nodes down to the one we are interested in - return new ProjectScope(project).getNode(CSSCORE_ID).node(preferenceKey); - // be careful looking up for our node so not to create any nodes as - // side effect - Preferences node = Platform.getPreferencesService().getRootNode().node(ProjectScope.SCOPE); - try { - // TODO once bug 90500 is fixed, should be as simple as this: - // String path = project.getName() + IPath.SEPARATOR + - // ResourcesPlugin.PI_RESOURCES + IPath.SEPARATOR + - // ENCODING_PREF_NODE; - // return node.nodeExists(path) ? node.node(path) : null; - // for now, take the long way - if (!node.nodeExists(project.getName())) - return null; - node = node.node(project.getName()); - if (!node.nodeExists(CSSCORE_ID)) - return null; - node = node.node(CSSCORE_ID); - if (!node.nodeExists(preferenceKey)) - return null; - return node.node(preferenceKey); - } - catch (BackingStoreException e) { - // nodeExists failed - Logger.log(Logger.WARNING_DEBUG, "Could not retrieve preference node", e); //$NON-NLS-1$ - } - return null; - } - - /** - * Returns the value for the given key in the given context. - * - * @param key - * The property key - * @param resource - * The current context or null if no context is - * available and the workspace setting should be taken. Note - * that passing null should be avoided. - * @param recurse - * whether the parent should be queried till property is found - * @return Returns the current value for the key. - * @since 1.1 - */ - public static String getProperty(String key, IResource resource, boolean recurse) { - String val = null; - // boolean preferenceFound = false; - if (resource != null) { - IProject project = resource.getProject(); - if (project != null) { - Preferences preferences = getPreferences(project, key, false); - if (preferences != null) { - val = internalGetProperty(resource, recurse, preferences); - // preferenceFound = true; - } - } - } - // Workbench preference may not be needed so leave out for now - // // no preferences found - for performance reasons, - // // short-circuit - // // lookup by falling back to workspace's default - // // setting - // if (!preferenceFound) - // val = getWorkbenchPreference(key); - return val; - } - - private static String internalGetProperty(IResource resource, boolean recurse, Preferences preferences) { - String value = preferences.get(getKeyFor(resource.getFullPath()), null); - if (value == null && resource != resource.getProject() && recurse) { - value = preferences.get(getKeyFor(null), null); - } - - // Workbench preference may not be needed so leave out for now - // // ensure we default to the workspace preference if none is found - // return value == null ? getWorkbenchPreference(key) : value; - return value; - } - - /** - * Sets the value for the given key in the given context. - * - * @param key - * The property key - * @param resource - * The current context. Note context cannot be - * null. - * @param value - * The value to set for the key. If value is null - * the key is removed from properties. - * @since 1.1 - */ - public static void setProperty(String key, IResource resource, String value) throws CoreException { - if (resource != null) { - IProject project = resource.getProject(); - if (project != null) { - Preferences preferences = getPreferences(project, key, true); - if (value == null || value.trim().length() == 0) - preferences.remove(getKeyFor(resource.getFullPath())); - else - preferences.put(getKeyFor(resource.getFullPath()), value); - try { - // save changes - preferences.flush(); - } - catch (BackingStoreException e) { - throw new CoreException(new Status(IStatus.ERROR, CSSCORE_ID, IStatus.ERROR, "Unable to set property", e)); //$NON-NLS-1$ - } - } - } - // Workbench preference may not be needed so leave out for now - // just set a preference in the instance scope - // if (!preferenceFound) { - // setWorkbenchPreference(key); - // } - } -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentproperties/CSSContentPropertiesManager.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentproperties/CSSContentPropertiesManager.java deleted file mode 100644 index 25a4b8d9a8..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentproperties/CSSContentPropertiesManager.java +++ /dev/null @@ -1,239 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.contentproperties; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResourceChangeEvent; -import org.eclipse.core.resources.IResourceChangeListener; -import org.eclipse.core.resources.IResourceDelta; -import org.eclipse.core.resources.IResourceStatus; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.MultiStatus; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.OperationCanceledException; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.osgi.util.NLS; -import org.eclipse.wst.css.core.internal.CSSCoreMessages; -import org.eclipse.wst.css.core.internal.Logger; -import org.osgi.framework.Bundle; -import org.osgi.service.prefs.BackingStoreException; -import org.osgi.service.prefs.Preferences; - -public class CSSContentPropertiesManager { - public CSSContentPropertiesManager() { - super(); - fResourceChangeListener = new ResourceChangeListener(); - fJob = new ContentPropertiesManagerJob(); - } - - private static CSSContentPropertiesManager _instance = null; - private IResourceChangeListener fResourceChangeListener; - ContentPropertiesManagerJob fJob; - - /** - * This job implementation is used to allow the resource change listener - * to schedule operations that need to modify the workspace. - */ - private class ContentPropertiesManagerJob extends Job { - private static final int PROPERTIES_UPDATE_DELAY = 500; - private List asyncChanges = new ArrayList(); - - public ContentPropertiesManagerJob() { - super(CSSCoreMessages.CSSContentPropertiesManager_Updating); - setSystem(true); - setPriority(Job.INTERACTIVE); - } - - public void addChanges(Set newChanges) { - if (newChanges.isEmpty()) - return; - synchronized (asyncChanges) { - asyncChanges.addAll(newChanges); - asyncChanges.notify(); - } - schedule(PROPERTIES_UPDATE_DELAY); - } - - public IProject getNextChange() { - synchronized (asyncChanges) { - return asyncChanges.isEmpty() ? null : (IProject) asyncChanges.remove(asyncChanges.size() - 1); - } - } - - protected IStatus run(IProgressMonitor monitor) { - MultiStatus result = new MultiStatus(CSSContentProperties.CSSCORE_ID, IResourceStatus.FAILED_SETTING_CHARSET, CSSCoreMessages.CSSContentPropertiesManager_Updating, null); - monitor = monitor == null ? new NullProgressMonitor() : monitor; - try { - monitor.beginTask(CSSCoreMessages.CSSContentPropertiesManager_Updating, asyncChanges.size()); - try { - IProject next; - while ((next = getNextChange()) != null) { - // just exit if the system is shutting down or has - // been shut down - // it is too late to change the workspace at this - // point anyway - if (Platform.getBundle("org.eclipse.osgi").getState() != Bundle.ACTIVE) //$NON-NLS-1$ - return Status.OK_STATUS; - try { - // save the preferences nodes - if (next.isAccessible()) { - // save css profile preferences - Preferences projectPrefs = CSSContentProperties.getPreferences(next, CSSContentProperties.CSS_PROFILE, false); - if (projectPrefs != null) - projectPrefs.flush(); - - } - } - catch (BackingStoreException e) { - // we got an error saving - String detailMessage = NLS.bind(CSSCoreMessages.CSSContentPropertiesManager_Problems_Updating, next.getFullPath()); - result.add(new Status(1 << (IResourceStatus.FAILED_SETTING_CHARSET % 100 / 33), ResourcesPlugin.PI_RESOURCES, IResourceStatus.FAILED_SETTING_CHARSET, detailMessage, e)); - } - } - monitor.worked(1); - } - catch (OperationCanceledException e) { - throw e; - } - } - finally { - monitor.done(); - } - return result; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.core.runtime.jobs.Job#shouldRun() - */ - public boolean shouldRun() { - synchronized (asyncChanges) { - return !asyncChanges.isEmpty(); - } - } - } - - class ResourceChangeListener implements IResourceChangeListener { - private void processEntryChanges(IResourceDelta projectDelta, Set projectsToSave) { - // check each resource with css content setting to see if it has - // been moved/deleted - boolean resourceChanges = false; - - // project affected - IProject currentProject = (IProject) projectDelta.getResource(); - - resourceChanges = processPreferences(currentProject, CSSContentProperties.CSS_PROFILE, projectDelta, projectsToSave); - - // if there was a preference key change, need to save preferences - if (resourceChanges) - projectsToSave.add(currentProject); - } - - /** - * Goes through all the resource-dependent preferences associated with - * currentProject & key and updates the preference keys if needed - * based on projectDelta - * - * @param currentProject - * current project of the preferences to be looked at - * @param key - * current key/subcategory of the preferences to be looked - * at - * @param projectDelta - * the changes to process the preference keys against - * @param projectsToSave - * the projects that need to be updated/saved - * @return true if currentProject's preferences were modified - */ - private boolean processPreferences(IProject currentProject, String key, IResourceDelta projectDelta, Set projectsToSave) { - boolean resourceChanges = false; - - // get the project-key preference node - Preferences projectPrefs = CSSContentProperties.getPreferences(currentProject, key, false); - if (projectPrefs == null) - // no preferences for this project-key, just bail - return false; - String[] affectedResources; - try { - affectedResources = projectPrefs.keys(); - } - catch (BackingStoreException e) { - // problems with the project scope... we gonna miss the - // changes (but will log) - Logger.log(Logger.WARNING_DEBUG, "Problem retreiving JSP Fragment preferences", e); //$NON-NLS-1$ - return false; - } - - // go through each preference key (which is really a file name) - for (int i = 0; i < affectedResources.length; i++) { - // see if preference key/file name was file that was changed - IResourceDelta memberDelta = projectDelta.findMember(new Path(affectedResources[i])); - // no changes for the given resource - if (memberDelta == null) - continue; - if (memberDelta.getKind() == IResourceDelta.REMOVED) { - resourceChanges = true; - // remove the setting for the original location - String currentValue = projectPrefs.get(affectedResources[i], null); - projectPrefs.remove(affectedResources[i]); - if ((memberDelta.getFlags() & IResourceDelta.MOVED_TO) != 0) { - // if moving, copy the setting for the new location - IProject targetProject = ResourcesPlugin.getWorkspace().getRoot().getProject(memberDelta.getMovedToPath().segment(0)); - Preferences targetPrefs = CSSContentProperties.getPreferences(targetProject, key, true); - targetPrefs.put(CSSContentProperties.getKeyFor(memberDelta.getMovedToPath()), currentValue); - if (targetProject != currentProject) - projectsToSave.add(targetProject); - } - } - } - return resourceChanges; - } - - /** - * For any change to the encoding file or any resource with encoding - * set, just discard the cache for the corresponding project. - */ - public void resourceChanged(IResourceChangeEvent event) { - IResourceDelta delta = event.getDelta(); - if (delta == null) - return; - IResourceDelta[] projectDeltas = delta.getAffectedChildren(); - // process each project in the delta - Set projectsToSave = new HashSet(); - for (int i = 0; i < projectDeltas.length; i++) - // nothing to do if a project has been added/removed/moved - if (projectDeltas[i].getKind() == IResourceDelta.CHANGED && (projectDeltas[i].getFlags() & IResourceDelta.OPEN) == 0) - processEntryChanges(projectDeltas[i], projectsToSave); - fJob.addChanges(projectsToSave); - } - } - - public synchronized static void startup() { - _instance = new CSSContentPropertiesManager(); - ResourcesPlugin.getWorkspace().addResourceChangeListener(_instance.fResourceChangeListener, IResourceChangeEvent.POST_CHANGE); - } - - public synchronized static void shutdown() { - ResourcesPlugin.getWorkspace().removeResourceChangeListener(_instance.fResourceChangeListener); - _instance = null; - } -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/ByteReader.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/ByteReader.java deleted file mode 100644 index 72b876bdd8..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/ByteReader.java +++ /dev/null @@ -1,109 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2006 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * Jens Lukowski/Innoopract - initial renaming/restructuring - * - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.contenttype; - -import java.io.IOException; -import java.io.InputStream; -import java.io.Reader; - -import org.eclipse.wst.sse.core.internal.encoding.CodedIO; - -/** - * This is an "adapter" class, simply to get in input stream to act like a - * reader. We could not use InputStreamReader directly because its internal - * buffers are not controllable, and it sometimes pulls too much out of input - * stream (even when it wasn't needed for our purposes). - * - * The use of this class is highly specialized and by no means meant to be - * general purpose. Its use is restricted to those cases where the input - * stream can be regarded as ascii just long enough to determine what the real - * encoding should be. - */ - -public class ByteReader extends Reader { - - - public static final int DEFAULT_BUFFER_SIZE = CodedIO.MAX_BUF_SIZE; - - protected byte[] fBuffer; - - protected InputStream fInputStream; - - protected ByteReader() { - super(); - } - - public ByteReader(InputStream inputStream) { - this(inputStream, DEFAULT_BUFFER_SIZE); - if (!inputStream.markSupported()) { - throw new IllegalArgumentException("ByteReader is required to have a resettable stream"); //$NON-NLS-1$ - } - } - - public ByteReader(InputStream inputStream, int size) { - this.fInputStream = inputStream; - if (!inputStream.markSupported()) { - throw new IllegalArgumentException("ByteReader is required to have a resettable stream"); //$NON-NLS-1$ - } - this.fBuffer = new byte[size]; - - } - - public void close() throws IOException { - this.fInputStream.close(); - } - - public void mark(int readAheadLimit) { - this.fInputStream.mark(readAheadLimit); - } - - public boolean markSupported() { - return true; - } - - public int read() throws IOException { - int b0 = this.fInputStream.read(); - return (b0 & 0x00FF); - } - - public int read(char ch[], int offset, int length) throws IOException { - if (length > this.fBuffer.length) { - length = this.fBuffer.length; - } - - int count = this.fInputStream.read(this.fBuffer, 0, length); - - for (int i = 0; i < count; i++) { - int b0 = this.fBuffer[i]; - // the 0x00FF is to "lose" the negative bits filled in the byte to - // int conversion - // (and which would be there if cast directly from byte to char). - char c0 = (char) (b0 & 0x00FF); - ch[offset + i] = c0; - } - return count; - } - - public boolean ready() throws IOException { - return this.fInputStream.available() > 0; - } - - public void reset() throws IOException { - this.fInputStream.reset(); - } - - public long skip(long n) throws IOException { - return this.fInputStream.skip(n); - } - -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/CSSHeadTokenizer.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/CSSHeadTokenizer.java deleted file mode 100644 index dbdffeccbc..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/CSSHeadTokenizer.java +++ /dev/null @@ -1,1440 +0,0 @@ -/* The following code was generated by JFlex 1.2.2 on 7/28/08 5:19 PM */ - -/******************************************************************************* - * Copyright (c) 2004, 2008 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/*nlsXXX*/ -package org.eclipse.wst.css.core.internal.contenttype; -import java.io.IOException; -import java.io.Reader; - -import org.eclipse.wst.xml.core.internal.contenttype.EncodingParserConstants; -import org.eclipse.wst.xml.core.internal.contenttype.XMLHeadTokenizerConstants; - - - - -/** - * This class is a scanner generated by - * JFlex 1.2.2 - * on 7/28/08 5:19 PM from the specification file - * file:/D:/workspaces/wtp301/workspace/org.eclipse.wst.sse.core/DevTimeSupport/HeadParsers/CSSHeadTokenizer/CSSHeadTokenizer.jFlex - */ -public class CSSHeadTokenizer { - - /** this character denotes the end of file */ - final public static int YYEOF = -1; - - /** lexical states */ - final public static int YYINITIAL = 0; - final public static int UnDelimitedString = 12; - final public static int DQ_STRING = 8; - final public static int SQ_STRING = 10; - final public static int ST_XMLDecl = 2; - final public static int QuotedAttributeValue = 6; - final public static int CHARSET_RULE = 4; - - /** - * YY_LEXSTATE[l] is the state in the DFA for the lexical state l - * YY_LEXSTATE[l+1] is the state in the DFA for the lexical state l - * at the beginning of a line - * l is of the form l = 2*k, k a non negative integer - */ - private final static int YY_LEXSTATE[] = { - 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7 - }; - - /** - * Translates characters to character classes - */ - final private static String yycmap_packed = - "\1\11\10\0\1\6\1\10\2\0\1\7\22\0\1\6\1\0\1\37"+ - "\2\0\1\42\1\0\1\40\7\0\1\41\13\0\1\36\1\13\1\12"+ - "\1\35\1\14\1\20\1\23\1\0\1\21\1\32\1\26\1\0\1\34"+ - "\1\22\1\33\2\0\1\17\1\16\1\30\1\31\2\0\1\24\1\25"+ - "\1\27\3\0\1\15\10\0\1\23\1\0\1\21\1\32\1\26\1\0"+ - "\1\34\1\22\1\33\2\0\1\17\1\16\1\30\1\31\2\0\1\24"+ - "\1\25\1\27\3\0\1\15\102\0\1\4\3\0\1\5\17\0\1\3"+ - "\16\0\1\1\20\0\1\3\16\0\1\1\1\2\170\0\1\2\ufe87\0"; - - /** - * Translates characters to character classes - */ - final private static char [] yycmap = yy_unpack_cmap(yycmap_packed); - - - /* error codes */ - final private static int YY_UNKNOWN_ERROR = 0; - final private static int YY_ILLEGAL_STATE = 1; - final private static int YY_NO_MATCH = 2; - final private static int YY_PUSHBACK_2BIG = 3; - - /* error messages for the codes above */ - final private static String YY_ERROR_MSG[] = { - "Unkown internal scanner error", - "Internal error: unknown state", - "Error: could not match input", - "Error: pushback value was too large" - }; - - /** the input device */ - private java.io.Reader yy_reader; - - /** the current state of the DFA */ - private int yy_state; - - /** the current lexical state */ - private int yy_lexical_state = YYINITIAL; - - /** this buffer contains the current text to be matched and is - the source of the yytext() string */ - private char yy_buffer[] = new char[16384]; - - /** the textposition at the last accepting state */ - private int yy_markedPos; - - /** the textposition at the last state to be included in yytext */ - private int yy_pushbackPos; - - /** the current text position in the buffer */ - private int yy_currentPos; - - /** startRead marks the beginning of the yytext() string in the buffer */ - private int yy_startRead; - - /** endRead marks the last character in the buffer, that has been read - from input */ - private int yy_endRead; - - /** number of newlines encountered up to the start of the matched text */ -// private int yyline; - - /** the number of characters up to the start of the matched text */ - private int yychar; - - /** - * the number of characters from the last newline up to the start of the - * matched text - */ -// private int yycolumn; - - /** - * yy_atBOL == true <=> the scanner is currently at the beginning of a line - */ - private boolean yy_atBOL; - - /** yy_atEOF == true <=> the scanner has returned a value for EOF */ - private boolean yy_atEOF; - - /** denotes if the user-EOF-code has already been executed */ - private boolean yy_eof_done; - - /* user code: */ - - - private boolean hasMore = true; - private final static int MAX_TO_SCAN = 8000; - StringBuffer string = new StringBuffer(); - // state stack for easier state handling - private IntStack fStateStack = new IntStack(); - private String valueText = null; - - - - public CSSHeadTokenizer() { - super(); - } - - public void reset (Reader in) { - /* the input device */ - yy_reader = in; - - /* the current state of the DFA */ - yy_state = 0; - - /* the current lexical state */ - yy_lexical_state = YYINITIAL; - - /* this buffer contains the current text to be matched and is - the source of the yytext() string */ - java.util.Arrays.fill(yy_buffer, (char)0); - - /* the textposition at the last accepting state */ - yy_markedPos = 0; - - /* the textposition at the last state to be included in yytext */ - yy_pushbackPos = 0; - - /* the current text position in the buffer */ - yy_currentPos = 0; - - /* startRead marks the beginning of the yytext() string in the buffer */ - yy_startRead = 0; - - /** - * endRead marks the last character in the buffer, that has been read - * from input - */ - yy_endRead = 0; - - /* number of newlines encountered up to the start of the matched text */ -// yyline = 0; - - /* the number of characters up to the start of the matched text */ - yychar = 0; - - /** - * the number of characters from the last newline up to the start - * of the matched text - */ -// yycolumn = 0; - - /** - * yy_atBOL == true <=> the scanner is currently at the beginning - * of a line - */ - yy_atBOL = false; - - /* yy_atEOF == true <=> the scanner has returned a value for EOF */ - yy_atEOF = false; - - /* denotes if the user-EOF-code has already been executed */ - yy_eof_done = false; - - - fStateStack.clear(); - - hasMore = true; - - // its a little wasteful to "throw away" first char array generated - // by class init (via auto generated code), but we really do want - // a small buffer for our head parsers. - if (yy_buffer.length != MAX_TO_SCAN) { - yy_buffer = new char[MAX_TO_SCAN]; - } - - - } - - - public final HeadParserToken getNextToken() throws IOException { - String context = null; - context = primGetNextToken(); - HeadParserToken result = null; - if (valueText != null) { - result = createToken(context, yychar, valueText); - valueText = null; - } else { - result = createToken(context, yychar, yytext()); - } - return result; - } - - public final boolean hasMoreTokens() { - return hasMore && yychar < MAX_TO_SCAN; - } - private void pushCurrentState() { - fStateStack.push(yystate()); - - } - - private void popState() { - yybegin(fStateStack.pop()); - } - private HeadParserToken createToken(String context, int start, String text) { - return new HeadParserToken(context, start, text); - } - - - - - /** - * Creates a new scanner - * There is also a java.io.InputStream version of this constructor. - * - * @param in the java.io.Reader to read input from. - */ - public CSSHeadTokenizer(java.io.Reader in) { - this.yy_reader = in; - } - - /** - * Creates a new scanner. - * There is also java.io.Reader version of this constructor. - * - * @param in the java.io.Inputstream to read input from. - */ - public CSSHeadTokenizer(java.io.InputStream in) { - this(new java.io.InputStreamReader(in)); - } - - /** - * Unpacks the compressed character translation table. - * - * @param packed the packed character translation table - * @return the unpacked character translation table - */ - private static char [] yy_unpack_cmap(String packed) { - char [] map = new char[0x10000]; - int i = 0; /* index in packed string */ - int j = 0; /* index in unpacked array */ - while (i < 160) { - int count = packed.charAt(i++); - char value = packed.charAt(i++); - do map[j++] = value; while (--count > 0); - } - return map; - } - - - /** - * Gets the next input character. - * - * @return the next character of the input stream, EOF if the - * end of the stream is reached. - * @exception IOException if any I/O-Error occurs - */ - private int yy_advance() throws java.io.IOException { - - /* standard case */ - if (yy_currentPos < yy_endRead) return yy_buffer[yy_currentPos++]; - - /* if the eof is reached, we don't need to work hard */ - if (yy_atEOF) return YYEOF; - - /* otherwise: need to refill the buffer */ - - /* first: make room (if you can) */ - if (yy_startRead > 0) { - System.arraycopy(yy_buffer, yy_startRead, - yy_buffer, 0, - yy_endRead-yy_startRead); - - /* translate stored positions */ - yy_endRead-= yy_startRead; - yy_currentPos-= yy_startRead; - yy_markedPos-= yy_startRead; - yy_pushbackPos-= yy_startRead; - yy_startRead = 0; - } - - /* is the buffer big enough? */ - if (yy_currentPos >= yy_buffer.length) { - /* if not: blow it up */ - char newBuffer[] = new char[yy_currentPos*2]; - System.arraycopy(yy_buffer, 0, newBuffer, 0, yy_buffer.length); - yy_buffer = newBuffer; - } - - /* finally: fill the buffer with new input */ - int numRead = yy_reader.read(yy_buffer, yy_endRead, - yy_buffer.length-yy_endRead); - - if ( numRead == -1 ) return YYEOF; - - yy_endRead+= numRead; - - return yy_buffer[yy_currentPos++]; - } - - - /** - * Closes the input stream. - */ - final public void yyclose() throws java.io.IOException { - yy_atEOF = true; /* indicate end of file */ - yy_endRead = yy_startRead; /* invalidate buffer */ - yy_reader.close(); - } - - - /** - * Returns the current lexical state. - */ - final public int yystate() { - return yy_lexical_state; - } - - /** - * Enters a new lexical state - * - * @param newState the new lexical state - */ - final public void yybegin(int newState) { - yy_lexical_state = newState; - } - - - /** - * Returns the text matched by the current regular expression. - */ - final public String yytext() { - return new String( yy_buffer, yy_startRead, yy_markedPos-yy_startRead ); - } - - /** - * Returns the length of the matched text region. - */ - final public int yylength() { - return yy_markedPos-yy_startRead; - } - - - /** - * Reports an error that occured while scanning. - * - * @param errorCode the code of the errormessage to display - */ - private void yy_ScanError(int errorCode) { - try { - System.out.println(YY_ERROR_MSG[errorCode]); - } - catch (ArrayIndexOutOfBoundsException e) { - System.out.println(YY_ERROR_MSG[YY_UNKNOWN_ERROR]); - } - - } - - - /** - * Pushes the specified amount of characters back into the input stream. - * - * They will be read again by then next call of the scanning method - * - * @param number the number of characters to be read again. - * This number must not be greater than yylength()! - */ - private void yypushback(int number) { - if ( number > yylength() ) - yy_ScanError(YY_PUSHBACK_2BIG); - - yy_markedPos -= number; - } - - - /** - * Contains user EOF-code, which will be executed exactly once, - * when the end of file is reached - */ - private void yy_do_eof() { - if (!yy_eof_done) { - yy_eof_done = true; - hasMore=false; - - } - } - - - /** - * Resumes scanning until the next regular expression is matched, - * the end of input is encountered or an I/O-Error occurs. - * - * @return the next token - * @exception IOException if any I/O-Error occurs - */ - public String primGetNextToken() throws java.io.IOException { - int yy_input; - int yy_action; - - - while (true) { - - yychar+= yylength(); - - yy_atBOL = yy_markedPos <= 0 || yy_buffer[yy_markedPos-1] == '\n'; - if (!yy_atBOL && yy_buffer[yy_markedPos-1] == '\r') { - yy_atBOL = yy_advance() != '\n'; - if (!yy_atEOF) yy_currentPos--; - } - - yy_action = -1; - - yy_currentPos = yy_startRead = yy_markedPos; - - if (yy_atBOL) - yy_state = YY_LEXSTATE[yy_lexical_state+1]; - else - yy_state = YY_LEXSTATE[yy_lexical_state]; - - - yy_forAction: { - while (true) { - - yy_input = yy_advance(); - - if ( yy_input == YYEOF ) break yy_forAction; - - yy_input = yycmap[yy_input]; - - boolean yy_isFinal = false; - boolean yy_noLookAhead = false; - - yy_forNext: { switch (yy_state) { - case 0: - switch (yy_input) { - case 1: yy_isFinal = true; yy_state = 9; break yy_forNext; - case 2: yy_isFinal = true; yy_state = 10; break yy_forNext; - case 3: yy_isFinal = true; yy_state = 11; break yy_forNext; - default: yy_isFinal = true; yy_noLookAhead = true; yy_state = 8; break yy_forNext; - } - - case 1: - switch (yy_input) { - case 1: yy_isFinal = true; yy_state = 9; break yy_forNext; - case 2: yy_isFinal = true; yy_state = 10; break yy_forNext; - case 3: yy_isFinal = true; yy_state = 11; break yy_forNext; - case 6: - case 7: - case 8: yy_isFinal = true; yy_state = 12; break yy_forNext; - case 9: yy_isFinal = true; yy_state = 13; break yy_forNext; - case 11: yy_isFinal = true; yy_state = 14; break yy_forNext; - case 16: yy_isFinal = true; yy_state = 15; break yy_forNext; - default: yy_isFinal = true; yy_noLookAhead = true; yy_state = 8; break yy_forNext; - } - - case 2: - switch (yy_input) { - case 9: yy_isFinal = true; yy_state = 16; break yy_forNext; - case 12: yy_isFinal = true; yy_state = 17; break yy_forNext; - case 22: yy_isFinal = true; yy_state = 18; break yy_forNext; - default: yy_isFinal = true; yy_noLookAhead = true; yy_state = 8; break yy_forNext; - } - - case 3: - switch (yy_input) { - case 6: - case 7: - case 8: yy_isFinal = true; yy_state = 19; break yy_forNext; - case 9: yy_isFinal = true; yy_state = 20; break yy_forNext; - case 30: yy_isFinal = true; yy_state = 21; break yy_forNext; - default: yy_isFinal = true; yy_noLookAhead = true; yy_state = 8; break yy_forNext; - } - - case 4: - switch (yy_input) { - case 6: - case 7: yy_isFinal = true; yy_state = 23; break yy_forNext; - case 8: yy_isFinal = true; yy_state = 24; break yy_forNext; - case 9: yy_isFinal = true; yy_state = 25; break yy_forNext; - case 31: yy_isFinal = true; yy_state = 26; break yy_forNext; - case 32: yy_isFinal = true; yy_state = 27; break yy_forNext; - default: yy_isFinal = true; yy_noLookAhead = true; yy_state = 22; break yy_forNext; - } - - case 5: - switch (yy_input) { - case 7: - case 8: - case 11: - case 29: yy_isFinal = true; yy_state = 29; break yy_forNext; - case 9: yy_isFinal = true; yy_state = 30; break yy_forNext; - case 12: - case 33: yy_isFinal = true; yy_state = 31; break yy_forNext; - case 30: yy_isFinal = true; yy_state = 32; break yy_forNext; - case 31: yy_isFinal = true; yy_state = 33; break yy_forNext; - default: yy_isFinal = true; yy_noLookAhead = true; yy_state = 28; break yy_forNext; - } - - case 6: - switch (yy_input) { - case 7: - case 8: - case 11: - case 29: yy_isFinal = true; yy_state = 29; break yy_forNext; - case 33: yy_isFinal = true; yy_state = 31; break yy_forNext; - case 30: yy_isFinal = true; yy_state = 32; break yy_forNext; - case 32: yy_isFinal = true; yy_state = 33; break yy_forNext; - case 9: yy_isFinal = true; yy_state = 34; break yy_forNext; - case 34: yy_isFinal = true; yy_state = 35; break yy_forNext; - default: yy_isFinal = true; yy_noLookAhead = true; yy_state = 28; break yy_forNext; - } - - case 7: - switch (yy_input) { - case 11: - case 29: yy_isFinal = true; yy_state = 29; break yy_forNext; - case 33: yy_isFinal = true; yy_state = 31; break yy_forNext; - case 12: yy_isFinal = true; yy_state = 35; break yy_forNext; - case 6: - case 7: - case 8: yy_isFinal = true; yy_state = 36; break yy_forNext; - case 9: yy_isFinal = true; yy_state = 37; break yy_forNext; - case 30: yy_isFinal = true; yy_state = 38; break yy_forNext; - case 31: - case 32: yy_isFinal = true; yy_state = 39; break yy_forNext; - default: yy_isFinal = true; yy_noLookAhead = true; yy_state = 28; break yy_forNext; - } - - case 9: - switch (yy_input) { - case 2: yy_isFinal = true; yy_noLookAhead = true; yy_state = 40; break yy_forNext; - default: break yy_forAction; - } - - case 10: - switch (yy_input) { - case 1: yy_isFinal = true; yy_noLookAhead = true; yy_state = 41; break yy_forNext; - default: break yy_forAction; - } - - case 11: - switch (yy_input) { - case 4: yy_state = 42; break yy_forNext; - default: break yy_forAction; - } - - case 12: - switch (yy_input) { - case 6: - case 7: - case 8: yy_state = 43; break yy_forNext; - case 9: yy_state = 44; break yy_forNext; - case 11: yy_state = 45; break yy_forNext; - case 16: yy_state = 46; break yy_forNext; - default: break yy_forAction; - } - - case 13: - switch (yy_input) { - case 6: - case 7: - case 8: yy_state = 43; break yy_forNext; - case 11: yy_state = 45; break yy_forNext; - case 16: yy_state = 46; break yy_forNext; - case 9: yy_state = 47; break yy_forNext; - default: break yy_forAction; - } - - case 14: - switch (yy_input) { - case 9: yy_state = 48; break yy_forNext; - case 12: yy_state = 49; break yy_forNext; - default: break yy_forAction; - } - - case 15: - switch (yy_input) { - case 9: yy_state = 50; break yy_forNext; - case 17: yy_state = 51; break yy_forNext; - default: break yy_forAction; - } - - case 16: - switch (yy_input) { - case 12: yy_state = 52; break yy_forNext; - case 22: yy_state = 53; break yy_forNext; - default: break yy_forAction; - } - - case 17: - switch (yy_input) { - case 9: yy_state = 54; break yy_forNext; - case 29: yy_isFinal = true; yy_state = 55; break yy_forNext; - default: break yy_forAction; - } - - case 18: - switch (yy_input) { - case 9: yy_state = 56; break yy_forNext; - case 24: yy_state = 57; break yy_forNext; - default: break yy_forAction; - } - - case 19: - switch (yy_input) { - case 6: - case 7: - case 8: yy_isFinal = true; yy_state = 19; break yy_forNext; - case 9: yy_isFinal = true; yy_state = 58; break yy_forNext; - default: break yy_forAction; - } - - case 20: - switch (yy_input) { - case 6: - case 7: - case 8: yy_isFinal = true; yy_state = 19; break yy_forNext; - case 30: yy_isFinal = true; yy_state = 21; break yy_forNext; - default: break yy_forAction; - } - - case 21: - switch (yy_input) { - case 9: yy_isFinal = true; yy_noLookAhead = true; yy_state = 59; break yy_forNext; - default: break yy_forAction; - } - - case 23: - switch (yy_input) { - case 6: - case 7: yy_isFinal = true; yy_state = 23; break yy_forNext; - case 8: yy_state = 60; break yy_forNext; - case 9: yy_isFinal = true; yy_state = 61; break yy_forNext; - default: yy_isFinal = true; yy_noLookAhead = true; yy_state = 22; break yy_forNext; - } - - case 24: - switch (yy_input) { - case 6: - case 7: yy_isFinal = true; yy_state = 23; break yy_forNext; - case 8: yy_state = 60; break yy_forNext; - case 9: yy_isFinal = true; yy_state = 61; break yy_forNext; - default: yy_isFinal = true; yy_noLookAhead = true; yy_state = 22; break yy_forNext; - } - - case 25: - switch (yy_input) { - case 31: yy_isFinal = true; yy_state = 26; break yy_forNext; - case 32: yy_isFinal = true; yy_state = 27; break yy_forNext; - case 6: - case 7: - case 8: yy_state = 60; break yy_forNext; - default: break yy_forAction; - } - - case 26: - switch (yy_input) { - case 9: yy_isFinal = true; yy_noLookAhead = true; yy_state = 62; break yy_forNext; - default: break yy_forAction; - } - - case 27: - switch (yy_input) { - case 9: yy_isFinal = true; yy_noLookAhead = true; yy_state = 63; break yy_forNext; - default: break yy_forAction; - } - - case 29: - switch (yy_input) { - case 9: yy_isFinal = true; yy_noLookAhead = true; yy_state = 64; break yy_forNext; - default: break yy_forAction; - } - - case 30: - switch (yy_input) { - case 7: - case 8: - case 11: - case 29: yy_isFinal = true; yy_state = 29; break yy_forNext; - case 30: yy_isFinal = true; yy_state = 32; break yy_forNext; - case 31: yy_isFinal = true; yy_state = 33; break yy_forNext; - case 12: - case 33: yy_state = 65; break yy_forNext; - default: break yy_forAction; - } - - case 31: - switch (yy_input) { - case 29: yy_isFinal = true; yy_state = 32; break yy_forNext; - case 9: yy_state = 66; break yy_forNext; - default: break yy_forAction; - } - - case 32: - switch (yy_input) { - case 9: yy_isFinal = true; yy_noLookAhead = true; yy_state = 67; break yy_forNext; - default: break yy_forAction; - } - - case 33: - switch (yy_input) { - case 9: yy_isFinal = true; yy_noLookAhead = true; yy_state = 68; break yy_forNext; - default: break yy_forAction; - } - - case 34: - switch (yy_input) { - case 7: - case 8: - case 11: - case 29: yy_isFinal = true; yy_state = 29; break yy_forNext; - case 30: yy_isFinal = true; yy_state = 32; break yy_forNext; - case 32: yy_isFinal = true; yy_state = 33; break yy_forNext; - case 33: yy_state = 65; break yy_forNext; - case 34: yy_state = 69; break yy_forNext; - default: break yy_forAction; - } - - case 35: - switch (yy_input) { - case 29: yy_isFinal = true; yy_state = 29; break yy_forNext; - case 9: yy_state = 70; break yy_forNext; - default: break yy_forAction; - } - - case 36: - switch (yy_input) { - case 9: yy_isFinal = true; yy_noLookAhead = true; yy_state = 71; break yy_forNext; - default: break yy_forAction; - } - - case 37: - switch (yy_input) { - case 11: - case 29: yy_isFinal = true; yy_state = 29; break yy_forNext; - case 6: - case 7: - case 8: yy_isFinal = true; yy_state = 36; break yy_forNext; - case 30: yy_isFinal = true; yy_state = 38; break yy_forNext; - case 31: - case 32: yy_isFinal = true; yy_state = 39; break yy_forNext; - case 33: yy_state = 65; break yy_forNext; - case 12: yy_state = 69; break yy_forNext; - default: break yy_forAction; - } - - case 38: - switch (yy_input) { - case 9: yy_isFinal = true; yy_noLookAhead = true; yy_state = 72; break yy_forNext; - default: break yy_forAction; - } - - case 39: - switch (yy_input) { - case 9: yy_isFinal = true; yy_noLookAhead = true; yy_state = 73; break yy_forNext; - default: break yy_forAction; - } - - case 42: - switch (yy_input) { - case 5: yy_isFinal = true; yy_noLookAhead = true; yy_state = 74; break yy_forNext; - default: break yy_forAction; - } - - case 43: - switch (yy_input) { - case 6: - case 7: - case 8: yy_state = 43; break yy_forNext; - case 9: yy_state = 44; break yy_forNext; - case 11: yy_state = 45; break yy_forNext; - case 16: yy_state = 46; break yy_forNext; - default: break yy_forAction; - } - - case 44: - switch (yy_input) { - case 6: - case 7: - case 8: yy_state = 43; break yy_forNext; - case 11: yy_state = 45; break yy_forNext; - case 16: yy_state = 46; break yy_forNext; - case 9: yy_state = 47; break yy_forNext; - default: break yy_forAction; - } - - case 45: - switch (yy_input) { - case 9: yy_state = 48; break yy_forNext; - case 12: yy_state = 49; break yy_forNext; - default: break yy_forAction; - } - - case 46: - switch (yy_input) { - case 9: yy_state = 50; break yy_forNext; - case 17: yy_state = 51; break yy_forNext; - default: break yy_forAction; - } - - case 47: - switch (yy_input) { - case 11: yy_state = 45; break yy_forNext; - case 16: yy_state = 46; break yy_forNext; - default: break yy_forAction; - } - - case 48: - switch (yy_input) { - case 12: yy_state = 49; break yy_forNext; - default: break yy_forAction; - } - - case 49: - switch (yy_input) { - case 9: yy_state = 75; break yy_forNext; - case 13: yy_state = 76; break yy_forNext; - default: break yy_forAction; - } - - case 50: - switch (yy_input) { - case 17: yy_state = 51; break yy_forNext; - default: break yy_forAction; - } - - case 51: - switch (yy_input) { - case 9: yy_state = 77; break yy_forNext; - case 18: yy_state = 78; break yy_forNext; - default: break yy_forAction; - } - - case 52: - switch (yy_input) { - case 9: yy_state = 54; break yy_forNext; - case 29: yy_isFinal = true; yy_state = 55; break yy_forNext; - default: break yy_forAction; - } - - case 53: - switch (yy_input) { - case 9: yy_state = 56; break yy_forNext; - case 24: yy_state = 57; break yy_forNext; - default: break yy_forAction; - } - - case 54: - switch (yy_input) { - case 29: yy_isFinal = true; yy_state = 55; break yy_forNext; - default: break yy_forAction; - } - - case 55: - switch (yy_input) { - case 9: yy_isFinal = true; yy_noLookAhead = true; yy_state = 79; break yy_forNext; - default: break yy_forAction; - } - - case 56: - switch (yy_input) { - case 24: yy_state = 57; break yy_forNext; - default: break yy_forAction; - } - - case 57: - switch (yy_input) { - case 9: yy_state = 80; break yy_forNext; - case 17: yy_state = 81; break yy_forNext; - default: break yy_forAction; - } - - case 58: - switch (yy_input) { - case 6: - case 7: - case 8: yy_isFinal = true; yy_state = 19; break yy_forNext; - case 9: yy_state = 82; break yy_forNext; - default: break yy_forAction; - } - - case 60: - switch (yy_input) { - case 6: - case 7: yy_isFinal = true; yy_state = 23; break yy_forNext; - case 8: yy_state = 60; break yy_forNext; - case 9: yy_isFinal = true; yy_state = 61; break yy_forNext; - default: yy_isFinal = true; yy_noLookAhead = true; yy_state = 22; break yy_forNext; - } - - case 61: - switch (yy_input) { - case 6: - case 7: yy_isFinal = true; yy_state = 23; break yy_forNext; - case 8: yy_state = 60; break yy_forNext; - case 9: yy_isFinal = true; yy_state = 83; break yy_forNext; - default: yy_isFinal = true; yy_noLookAhead = true; yy_state = 22; break yy_forNext; - } - - case 65: - switch (yy_input) { - case 29: yy_isFinal = true; yy_state = 32; break yy_forNext; - case 9: yy_state = 66; break yy_forNext; - default: break yy_forAction; - } - - case 66: - switch (yy_input) { - case 29: yy_isFinal = true; yy_state = 32; break yy_forNext; - default: break yy_forAction; - } - - case 69: - switch (yy_input) { - case 29: yy_isFinal = true; yy_state = 29; break yy_forNext; - case 9: yy_state = 70; break yy_forNext; - default: break yy_forAction; - } - - case 70: - switch (yy_input) { - case 29: yy_isFinal = true; yy_state = 29; break yy_forNext; - default: break yy_forAction; - } - - case 75: - switch (yy_input) { - case 13: yy_state = 76; break yy_forNext; - default: break yy_forAction; - } - - case 76: - switch (yy_input) { - case 9: yy_state = 84; break yy_forNext; - case 14: yy_state = 85; break yy_forNext; - default: break yy_forAction; - } - - case 77: - switch (yy_input) { - case 18: yy_state = 78; break yy_forNext; - default: break yy_forAction; - } - - case 78: - switch (yy_input) { - case 9: yy_state = 86; break yy_forNext; - case 19: yy_state = 87; break yy_forNext; - default: break yy_forAction; - } - - case 80: - switch (yy_input) { - case 17: yy_state = 81; break yy_forNext; - default: break yy_forAction; - } - - case 81: - switch (yy_input) { - case 9: yy_state = 88; break yy_forNext; - case 25: yy_state = 89; break yy_forNext; - default: break yy_forAction; - } - - case 82: - switch (yy_input) { - case 6: - case 7: - case 8: yy_isFinal = true; yy_state = 19; break yy_forNext; - default: break yy_forAction; - } - - case 83: - switch (yy_input) { - case 6: - case 7: - case 8: yy_state = 60; break yy_forNext; - default: break yy_forAction; - } - - case 84: - switch (yy_input) { - case 14: yy_state = 85; break yy_forNext; - default: break yy_forAction; - } - - case 85: - switch (yy_input) { - case 9: yy_state = 90; break yy_forNext; - case 15: yy_state = 91; break yy_forNext; - default: break yy_forAction; - } - - case 86: - switch (yy_input) { - case 19: yy_state = 87; break yy_forNext; - default: break yy_forAction; - } - - case 87: - switch (yy_input) { - case 9: yy_state = 92; break yy_forNext; - case 20: yy_state = 93; break yy_forNext; - default: break yy_forAction; - } - - case 88: - switch (yy_input) { - case 25: yy_state = 89; break yy_forNext; - default: break yy_forAction; - } - - case 89: - switch (yy_input) { - case 9: yy_state = 94; break yy_forNext; - case 26: yy_state = 95; break yy_forNext; - default: break yy_forAction; - } - - case 90: - switch (yy_input) { - case 15: yy_state = 91; break yy_forNext; - default: break yy_forAction; - } - - case 91: - switch (yy_input) { - case 6: - case 7: - case 8: yy_isFinal = true; yy_state = 96; break yy_forNext; - case 9: yy_state = 97; break yy_forNext; - default: break yy_forAction; - } - - case 92: - switch (yy_input) { - case 20: yy_state = 93; break yy_forNext; - default: break yy_forAction; - } - - case 93: - switch (yy_input) { - case 9: yy_state = 98; break yy_forNext; - case 21: yy_state = 99; break yy_forNext; - default: break yy_forAction; - } - - case 94: - switch (yy_input) { - case 26: yy_state = 95; break yy_forNext; - default: break yy_forAction; - } - - case 95: - switch (yy_input) { - case 9: yy_state = 100; break yy_forNext; - case 27: yy_state = 101; break yy_forNext; - default: break yy_forAction; - } - - case 96: - switch (yy_input) { - case 6: - case 7: - case 8: yy_isFinal = true; yy_state = 96; break yy_forNext; - case 9: yy_isFinal = true; yy_state = 102; break yy_forNext; - default: break yy_forAction; - } - - case 97: - switch (yy_input) { - case 6: - case 7: - case 8: yy_isFinal = true; yy_state = 96; break yy_forNext; - case 9: yy_state = 103; break yy_forNext; - default: break yy_forAction; - } - - case 98: - switch (yy_input) { - case 21: yy_state = 99; break yy_forNext; - default: break yy_forAction; - } - - case 99: - switch (yy_input) { - case 9: yy_state = 104; break yy_forNext; - case 22: yy_state = 105; break yy_forNext; - default: break yy_forAction; - } - - case 100: - switch (yy_input) { - case 27: yy_state = 101; break yy_forNext; - default: break yy_forAction; - } - - case 101: - switch (yy_input) { - case 9: yy_state = 106; break yy_forNext; - case 24: yy_state = 107; break yy_forNext; - default: break yy_forAction; - } - - case 102: - switch (yy_input) { - case 6: - case 7: - case 8: yy_isFinal = true; yy_state = 96; break yy_forNext; - case 9: yy_state = 103; break yy_forNext; - default: break yy_forAction; - } - - case 103: - switch (yy_input) { - case 6: - case 7: - case 8: yy_isFinal = true; yy_state = 96; break yy_forNext; - default: break yy_forAction; - } - - case 104: - switch (yy_input) { - case 22: yy_state = 105; break yy_forNext; - default: break yy_forAction; - } - - case 105: - switch (yy_input) { - case 9: yy_state = 108; break yy_forNext; - case 23: yy_isFinal = true; yy_state = 109; break yy_forNext; - default: break yy_forAction; - } - - case 106: - switch (yy_input) { - case 24: yy_state = 107; break yy_forNext; - default: break yy_forAction; - } - - case 107: - switch (yy_input) { - case 9: yy_state = 110; break yy_forNext; - case 28: yy_state = 111; break yy_forNext; - default: break yy_forAction; - } - - case 108: - switch (yy_input) { - case 23: yy_isFinal = true; yy_state = 109; break yy_forNext; - default: break yy_forAction; - } - - case 109: - switch (yy_input) { - case 9: yy_isFinal = true; yy_noLookAhead = true; yy_state = 112; break yy_forNext; - default: break yy_forAction; - } - - case 110: - switch (yy_input) { - case 28: yy_state = 111; break yy_forNext; - default: break yy_forAction; - } - - case 111: - switch (yy_input) { - case 6: - case 7: - case 8: yy_state = 111; break yy_forNext; - case 9: yy_state = 113; break yy_forNext; - case 10: yy_isFinal = true; yy_state = 114; break yy_forNext; - default: break yy_forAction; - } - - case 113: - switch (yy_input) { - case 6: - case 7: - case 8: yy_state = 111; break yy_forNext; - case 10: yy_isFinal = true; yy_state = 114; break yy_forNext; - case 9: yy_state = 115; break yy_forNext; - default: break yy_forAction; - } - - case 114: - switch (yy_input) { - case 6: - case 7: - case 8: yy_isFinal = true; yy_state = 116; break yy_forNext; - case 9: yy_state = 117; break yy_forNext; - default: break yy_forAction; - } - - case 115: - switch (yy_input) { - case 6: - case 7: - case 8: yy_state = 111; break yy_forNext; - default: break yy_forAction; - } - - case 116: - switch (yy_input) { - case 9: yy_isFinal = true; yy_state = 114; break yy_forNext; - case 6: - case 7: - case 8: yy_isFinal = true; yy_state = 116; break yy_forNext; - default: break yy_forAction; - } - - case 117: - switch (yy_input) { - case 6: - case 7: - case 8: yy_isFinal = true; yy_state = 116; break yy_forNext; - default: break yy_forAction; - } - - default: - yy_ScanError(YY_ILLEGAL_STATE); - break; - } } - - if ( yy_isFinal ) { - yy_action = yy_state; - yy_markedPos = yy_currentPos; - if ( yy_noLookAhead ) break yy_forAction; - } - - } - } - - - switch (yy_action) { - - case 29: - case 64: - { yypushback(yylength());popState(); valueText = string.toString(); return EncodingParserConstants.InvalidTerminatedStringValue; } - case 119: break; - case 22: - case 23: - case 25: - case 61: - case 83: - { yypushback(yylength()); yybegin(UnDelimitedString); string.setLength(0); } - case 120: break; - case 21: - case 59: - { yybegin(YYINITIAL); hasMore = false; return CSSHeadTokenizerConstants.RuleEnd; } - case 121: break; - case 39: - case 73: - { yypushback(yylength());popState(); valueText = string.toString(); return EncodingParserConstants.InvalidTermintatedUnDelimitedStringValue; } - case 122: break; - case 109: - case 112: - { if (yychar == 0 ) {yybegin(CHARSET_RULE); return CSSHeadTokenizerConstants.CHARSET_RULE;} } - case 123: break; - case 96: - case 102: - { if (yychar == 0 ) {yybegin(ST_XMLDecl); return XMLHeadTokenizerConstants.XMLDeclStart;} } - case 124: break; - case 8: - case 9: - case 10: - case 11: - case 12: - case 13: - case 14: - case 15: - case 16: - case 17: - case 18: - case 20: - case 24: - case 30: - case 34: - case 37: - { if(yychar > MAX_TO_SCAN) {hasMore=false; return EncodingParserConstants.MAX_CHARS_REACHED;} } - case 125: break; - case 55: - case 79: - { yybegin(YYINITIAL); return XMLHeadTokenizerConstants.XMLDeclEnd; } - case 126: break; - case 114: - case 116: - { pushCurrentState(); yybegin(QuotedAttributeValue); return XMLHeadTokenizerConstants.XMLDelEncoding; } - case 127: break; - case 3: - case 19: - case 58: - { pushCurrentState(); yybegin(QuotedAttributeValue); } - case 128: break; - case 40: - { hasMore = false; return EncodingParserConstants.UTF16BE; } - case 129: break; - case 41: - { hasMore = false; return EncodingParserConstants.UTF16LE; } - case 130: break; - case 74: - { hasMore = false; return EncodingParserConstants.UTF83ByteBOM; } - case 131: break; - case 28: - case 31: - case 35: - { string.append( yytext() ); } - case 132: break; - case 27: - case 63: - { yybegin(SQ_STRING); string.setLength(0); } - case 133: break; - case 26: - case 62: - { yybegin(DQ_STRING); string.setLength(0); } - case 134: break; - case 32: - case 67: - { yypushback(yylength()); popState(); valueText = string.toString(); return EncodingParserConstants.InvalidTerminatedStringValue; } - case 135: break; - case 33: - case 68: - { popState(); valueText = string.toString(); return EncodingParserConstants.StringValue; } - case 136: break; - case 36: - case 71: - { yypushback(yylength());popState(); valueText = string.toString(); return EncodingParserConstants.UnDelimitedStringValue; } - case 137: break; - case 38: - case 72: - { yypushback(yylength()); popState(); valueText = string.toString(); return EncodingParserConstants.UnDelimitedStringValue; } - case 138: break; - default: - if (yy_input == YYEOF && yy_startRead == yy_currentPos) { - yy_atEOF = true; - yy_do_eof(); - { hasMore = false; return EncodingParserConstants.EOF; } - } - else { - yy_ScanError(YY_NO_MATCH); - } - } - } - } - - /** - * Runs the scanner on input files. - * - * This main method is the debugging routine for the scanner. - * It prints each returned token to System.out until the end of - * file is reached, or an error occured. - * - * @param argv the command line, contains the filenames to run - * the scanner on. - */ - public static void main(String argv[]) { - for (int i = 0; i < argv.length; i++) { - CSSHeadTokenizer scanner = null; - try { - scanner = new CSSHeadTokenizer( new java.io.FileReader(argv[i]) ); - } - catch (java.io.FileNotFoundException e) { - System.out.println("File not found : \""+argv[i]+"\""); - System.exit(1); - } - catch (java.io.IOException e) { - System.out.println("Error opening file \""+argv[i]+"\""); - System.exit(1); - } - catch (ArrayIndexOutOfBoundsException e) { - System.out.println("Usage : java CSSHeadTokenizer "); - System.exit(1); - } - - try { - do { - System.out.println(scanner.primGetNextToken()); - } while (!scanner.yy_atEOF); - - } - catch (java.io.IOException e) { - System.out.println("An I/O error occured while scanning :"); - System.out.println(e); - System.exit(1); - } - catch (Exception e) { - e.printStackTrace(); - System.exit(1); - } - } - } - - -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/CSSHeadTokenizerConstants.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/CSSHeadTokenizerConstants.java deleted file mode 100644 index a991a03fa9..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/CSSHeadTokenizerConstants.java +++ /dev/null @@ -1,19 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.contenttype; - - -public interface CSSHeadTokenizerConstants { - - String RuleEnd = "RuleEnd"; //$NON-NLS-1$ - String CHARSET_RULE = "CHARSET_RULE"; //$NON-NLS-1$ - -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/CSSResourceEncodingDetector.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/CSSResourceEncodingDetector.java deleted file mode 100644 index 16f5fbdf40..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/CSSResourceEncodingDetector.java +++ /dev/null @@ -1,367 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2008 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.contenttype; - -import java.io.BufferedInputStream; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.Reader; -import java.nio.charset.Charset; -import java.nio.charset.IllegalCharsetNameException; -import java.nio.charset.UnsupportedCharsetException; - -import org.eclipse.core.resources.IStorage; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.content.IContentDescription; -import org.eclipse.wst.sse.core.internal.encoding.CodedIO; -import org.eclipse.wst.sse.core.internal.encoding.EncodingMemento; -import org.eclipse.wst.sse.core.internal.encoding.IResourceCharsetDetector; -import org.eclipse.wst.sse.core.internal.encoding.NonContentBasedEncodingRules; -import org.eclipse.wst.xml.core.internal.contenttype.EncodingParserConstants; - - - -public class CSSResourceEncodingDetector implements IResourceCharsetDetector { - class NullMemento extends EncodingMemento { - /** - * - */ - public NullMemento() { - super(); - String defaultCharset = NonContentBasedEncodingRules.useDefaultNameRules(null); - setJavaCharsetName(defaultCharset); - setAppropriateDefault(defaultCharset); - setDetectedCharsetName(null); - } - } - - - private CSSHeadTokenizer fTokenizer; - private EncodingMemento fEncodingMemento; - private boolean fHeaderParsed; - private Reader fReader; - - /** - * There is no spec defined encoding for CSS, so Null is returned. - */ - public String getSpecDefaultEncoding() { - // should match what's in plugin.xml (or look it up from there). - return null; - } - - private boolean canHandleAsUnicodeStream(String tokenType) { - boolean canHandleAsUnicodeStream = false; - if (tokenType == EncodingParserConstants.UTF83ByteBOM) { - canHandleAsUnicodeStream = true; - String enc = "UTF-8"; //$NON-NLS-1$ - createEncodingMemento(enc, EncodingMemento.DETECTED_STANDARD_UNICODE_BYTES); - fEncodingMemento.setUTF83ByteBOMUsed(true); - } - else if (tokenType == EncodingParserConstants.UTF16BE || tokenType == EncodingParserConstants.UTF16LE) { - canHandleAsUnicodeStream = true; - String enc = "UTF-16"; //$NON-NLS-1$ - byte[] bom = (tokenType == EncodingParserConstants.UTF16BE) ? IContentDescription.BOM_UTF_16BE : IContentDescription.BOM_UTF_16LE; - createEncodingMemento(enc, EncodingMemento.DETECTED_STANDARD_UNICODE_BYTES); - fEncodingMemento.setUnicodeStream(true); - fEncodingMemento.setUnicodeBOM(bom); - } - return canHandleAsUnicodeStream; - } - - /** - * @return Returns the tokenizer. - */ - private CSSHeadTokenizer getTokenizer() { - if (fTokenizer == null) { - fTokenizer = new CSSHeadTokenizer(); - } - return fTokenizer; - } - - private boolean isLegalString(String valueTokenType) { - boolean result = false; - if (valueTokenType != null) { - result = valueTokenType.equals(EncodingParserConstants.StringValue) || valueTokenType.equals(EncodingParserConstants.UnDelimitedStringValue) || valueTokenType.equals(EncodingParserConstants.InvalidTerminatedStringValue) || valueTokenType.equals(EncodingParserConstants.InvalidTermintatedUnDelimitedStringValue); - } - return result; - } - - private void parseInput() throws IOException { - checkInContents(); - if (fEncodingMemento == null) { - checkHeuristics(); - } - } - - private void checkInContents() throws IOException { - CSSHeadTokenizer tokenizer = getTokenizer(); - tokenizer.reset(fReader); - HeadParserToken token = null; - String tokenType = null; - do { - token = tokenizer.getNextToken(); - tokenType = token.getType(); - if (canHandleAsUnicodeStream(tokenType)) { - // side effect of canHandle is to create appropriate memento - } - else if (tokenType == CSSHeadTokenizerConstants.CHARSET_RULE) { - if (tokenizer.hasMoreTokens()) { - HeadParserToken valueToken = tokenizer.getNextToken(); - String valueTokenType = valueToken.getType(); - if (isLegalString(valueTokenType)) { - createEncodingMemento(valueToken.getText(), EncodingMemento.FOUND_ENCODING_IN_CONTENT); - - } - } - } - - } - while (tokenizer.hasMoreTokens()); - } - - /** - * - */ - private void checkHeuristics() throws IOException { - boolean noHeuristic = false; - String heuristicEncoding = null; - try { - fReader.reset(); - byte[] bytes = new byte[3]; - int nRead = 0; - for (int i = 0; i < bytes.length; i++) { - if (fReader.ready()) { - int oneByte = fReader.read(); - nRead++; - if (oneByte <= 0xFF) { - bytes[i] = (byte) oneByte; - } - else { - noHeuristic = true; - } - } - else { - noHeuristic = true; - break; - } - } - if (!noHeuristic && nRead == 3) { - heuristicEncoding = EncodingGuesser.guessEncoding(bytes, 3); - } - } - catch (IOException e) { - // if any IO exception, then not a heuristic case - } - finally { - fReader.reset(); - } - if (heuristicEncoding != null) { - createEncodingMemento(heuristicEncoding, EncodingMemento.GUESSED_ENCODING_FROM_STREAM); - } - - } - - /** - * Note: once this instance is created, trace info still needs to be - * appended by caller, depending on the context its created. - */ - private void createEncodingMemento(String detectedCharsetName) { - fEncodingMemento = new EncodingMemento(); - fEncodingMemento.setJavaCharsetName(getAppropriateJavaCharset(detectedCharsetName)); - fEncodingMemento.setDetectedCharsetName(detectedCharsetName); - // TODO: if detectedCharset and spec default is - // null, need to use "work - // bench based" defaults. - fEncodingMemento.setAppropriateDefault(getSpecDefaultEncoding()); - } - - /** - * convience method all subclasses can use (but not override) - * - * @param detectedCharsetName - * @param reason - */ - private void createEncodingMemento(String detectedCharsetName, String reason) { - createEncodingMemento(detectedCharsetName); - } - - /** - * convience method all subclasses can use (but not override) - */ - private final void ensureInputSet() { - if (fReader == null) { - throw new IllegalStateException("input must be set before use"); //$NON-NLS-1$ - } - } - - /** - * This method can return null, if invalid charset name (in which case - * "appropriateDefault" should be used, if a name is really need for some - * "save anyway" cases). - * - * @param detectedCharsetName - * @return - */ - private String getAppropriateJavaCharset(String detectedCharsetName) { - String result = null; - // 1. Check explicit mapping overrides from - // property file -- its here we pick up "rules" for cases - // that are not even in Java - result = CodedIO.checkMappingOverrides(detectedCharsetName); - // 2. Use the "canonical" name from JRE mappings - // Note: see Charset JavaDoc, the name you get one - // with can be alias, - // the name you get back is "standard" name. - Charset javaCharset = null; - try { - javaCharset = Charset.forName(detectedCharsetName); - } - catch (UnsupportedCharsetException e) { - // only set invalid, if result is same as detected -- they won't - // be equal if - // overridden - if (result != null && result.equals(detectedCharsetName)) { - fEncodingMemento.setInvalidEncoding(detectedCharsetName); - } - } - catch (IllegalCharsetNameException e) { - // only set invalid, if result is same as detected -- they won't - // be equal if - // overridden - if (result != null && result.equals(detectedCharsetName)) { - fEncodingMemento.setInvalidEncoding(detectedCharsetName); - } - } - // give priority to java cononical name, if present - if (javaCharset != null) { - result = javaCharset.name(); - // but still allow overrides - result = CodedIO.checkMappingOverrides(result); - } - return result; - } - - public String getEncoding() throws IOException { - return getEncodingMemento().getDetectedCharsetName(); - } - - public EncodingMemento getEncodingMemento() throws IOException { - ensureInputSet(); - if (!fHeaderParsed) { - parseInput(); - // we keep track of if header's already been - // parse, so can make - // multiple 'get' calls, without causing - // reparsing. - fHeaderParsed = true; - // Note: there is a "hidden assumption" here - // that an empty - // string in content should be treated same as - // not present. - } - if (fEncodingMemento == null) { - handleSpecDefault(); - } - if (fEncodingMemento == null) { - // safty net - fEncodingMemento = new NullMemento(); - } - return fEncodingMemento; - } - - public EncodingMemento getSpecDefaultEncodingMemento() { - resetAll(); - EncodingMemento result = null; - String enc = getSpecDefaultEncoding(); - if (enc != null) { - createEncodingMemento(enc, EncodingMemento.DEFAULTS_ASSUMED_FOR_EMPTY_INPUT); - fEncodingMemento.setAppropriateDefault(enc); - result = fEncodingMemento; - } - return result; - } - - private void handleSpecDefault() { - String encodingName; - encodingName = getSpecDefaultEncoding(); - if (encodingName != null) { - // createEncodingMemento(encodingName, - // EncodingMemento.USED_CONTENT_TYPE_DEFAULT); - fEncodingMemento = new EncodingMemento(); - fEncodingMemento.setJavaCharsetName(encodingName); - fEncodingMemento.setAppropriateDefault(encodingName); - } - } - - /** - * - */ - private void resetAll() { - fReader = null; - fHeaderParsed = false; - fEncodingMemento = null; - } - - /** - * - */ - public void set(InputStream inputStream) { - resetAll(); - fReader = new ByteReader(inputStream); - try { - fReader.mark(CodedIO.MAX_MARK_SIZE); - } - catch (IOException e) { - // impossible, since we know ByteReader - // supports marking - throw new Error(e); - } - } - - /** - * - */ - public void set(IStorage iStorage) throws CoreException { - resetAll(); - InputStream inputStream = iStorage.getContents(); - InputStream resettableStream = new BufferedInputStream(inputStream, CodedIO.MAX_BUF_SIZE); - resettableStream.mark(CodedIO.MAX_MARK_SIZE); - set(resettableStream); - // TODO we'll need to "remember" IFile, or - // get its (or its project's) settings, in case - // those are needed to handle cases when the - // encoding is not in the file stream. - } - - /** - * Note: this is not part of interface to help avoid confusion ... it - * expected this Reader is a well formed character reader ... that is, its - * all ready been determined to not be a unicode marked input stream. And, - * its assumed to be in the correct position, at position zero, ready to - * read first character. - */ - public void set(Reader reader) { - resetAll(); - fReader = reader; - if (!fReader.markSupported()) { - fReader = new BufferedReader(fReader); - } - try { - fReader.mark(CodedIO.MAX_MARK_SIZE); - } - catch (IOException e) { - // impossble, since we just checked if markable - throw new Error(e); - } - } - -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/ContentDescriberForCSS.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/ContentDescriberForCSS.java deleted file mode 100644 index d04863d3ae..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/ContentDescriberForCSS.java +++ /dev/null @@ -1,200 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.contenttype; - -import java.io.IOException; -import java.io.InputStream; -import java.io.Reader; - -import org.eclipse.core.runtime.QualifiedName; -import org.eclipse.core.runtime.content.IContentDescriber; -import org.eclipse.core.runtime.content.IContentDescription; -import org.eclipse.core.runtime.content.ITextContentDescriber; -import org.eclipse.wst.sse.core.internal.encoding.EncodingMemento; -import org.eclipse.wst.sse.core.internal.encoding.IContentDescriptionExtended; -import org.eclipse.wst.sse.core.internal.encoding.IResourceCharsetDetector; - - -public final class ContentDescriberForCSS implements ITextContentDescriber { - final private static QualifiedName[] SUPPORTED_OPTIONS = {IContentDescription.CHARSET, IContentDescription.BYTE_ORDER_MARK, IContentDescriptionExtended.DETECTED_CHARSET, IContentDescriptionExtended.UNSUPPORTED_CHARSET, IContentDescriptionExtended.APPROPRIATE_DEFAULT}; - - public int describe(InputStream contents, IContentDescription description) throws IOException { - int result = IContentDescriber.INDETERMINATE; - - if (description == null) { - result = computeValidity(contents); - } - else { - calculateSupportedOptions(contents, description); - result = computeValidity(contents); - } - return result; - } - - public int describe(Reader contents, IContentDescription description) throws IOException { - int result = IContentDescriber.INDETERMINATE; - - if (description == null) { - result = computeValidity(contents); - } - else { - calculateSupportedOptions(contents, description); - result = computeValidity(contents); - } - return result; - } - - public QualifiedName[] getSupportedOptions() { - - return SUPPORTED_OPTIONS; - } - - private void calculateSupportedOptions(InputStream contents, IContentDescription description) throws IOException { - if (isRelevent(description)) { - IResourceCharsetDetector detector = getDetector(); - detector.set(contents); - handleCalculations(description, detector); - } - } - - /** - * @param contents - * @param description - * @throws IOException - */ - private void calculateSupportedOptions(Reader contents, IContentDescription description) throws IOException { - if (isRelevent(description)) { - IResourceCharsetDetector detector = getDetector(); - detector.set(contents); - handleCalculations(description, detector); - } - } - - private int computeValidity(InputStream inputStream) { - // currently no specific check for validilty - // based on contents. - return IContentDescriber.INDETERMINATE; - } - - private int computeValidity(Reader reader) { - // currently no specific check for validilty - // based on contents. - return IContentDescriber.INDETERMINATE; - } - - private IResourceCharsetDetector getDetector() { - return new CSSResourceEncodingDetector(); - } - - /** - * @param description - * @param detector - * @throws IOException - */ - private void handleCalculations(IContentDescription description, IResourceCharsetDetector detector) throws IOException { - // note: if we're asked for one, we set them all. I need to be sure if - // called - // mulitiple times (one for each, say) that we don't waste time - // processing same - // content again. - EncodingMemento encodingMemento = ((CSSResourceEncodingDetector) detector).getEncodingMemento(); - // TODO: I need to verify to see if this BOM work is always done - // by text type. - Object detectedByteOrderMark = encodingMemento.getUnicodeBOM(); - if (detectedByteOrderMark != null) { - Object existingByteOrderMark = description.getProperty(IContentDescription.BYTE_ORDER_MARK); - // not sure why would ever be different, so if is different, may - // need to "push" up into base. - if (!detectedByteOrderMark.equals(existingByteOrderMark)) - description.setProperty(IContentDescription.BYTE_ORDER_MARK, detectedByteOrderMark); - } - - - if (!encodingMemento.isValid()) { - // note: after setting here, its the mere presence of - // IContentDescriptionExtended.UNSUPPORTED_CHARSET - // in the resource's description that can be used to determine if - // invalid - // in those cases, the "detected" property contains an - // "appropriate default" to use. - description.setProperty(IContentDescriptionExtended.UNSUPPORTED_CHARSET, encodingMemento.getInvalidEncoding()); - description.setProperty(IContentDescriptionExtended.APPROPRIATE_DEFAULT, encodingMemento.getAppropriateDefault()); - } - - Object detectedCharset = encodingMemento.getDetectedCharsetName(); - Object javaCharset = encodingMemento.getJavaCharsetName(); - - // we always include detected, if its different than java - handleDetectedSpecialCase(description, detectedCharset, javaCharset); - - if (javaCharset != null) { - Object existingCharset = description.getProperty(IContentDescription.CHARSET); - if (javaCharset.equals(existingCharset)) { - handleDetectedSpecialCase(description, detectedCharset, javaCharset); - } - else { - // we may need to add what we found, but only need to add - // if different from default.the - Object defaultCharset = getDetector().getSpecDefaultEncoding(); - if (defaultCharset != null) { - if (!defaultCharset.equals(javaCharset)) { - description.setProperty(IContentDescription.CHARSET, javaCharset); - } - } - else { - // assuming if there is no spec default, we always need to - // add, I'm assuming - description.setProperty(IContentDescription.CHARSET, javaCharset); - } - } - } - - } - - private void handleDetectedSpecialCase(IContentDescription description, Object detectedCharset, Object javaCharset) { - // since equal, we don't need to add, but if our detected version is - // different than javaCharset, then we should add it. This will - // happen, for example, if there's differences in case, or differences - // due to override properties - if (detectedCharset != null) { - - // Once we detected a charset, we should set the property even - // though it's the same as javaCharset - // because there are clients that rely on this property to - // determine if the charset is actually detected in file or not. - description.setProperty(IContentDescriptionExtended.DETECTED_CHARSET, detectedCharset); - } - } - - /** - * @param description - * @return - */ - private boolean isRelevent(IContentDescription description) { - boolean result = false; - if (description == null) - result = false; - else if (description.isRequested(IContentDescription.BYTE_ORDER_MARK)) - result = true; - else if (description.isRequested(IContentDescription.CHARSET)) - result = true; - else if (description.isRequested(IContentDescriptionExtended.APPROPRIATE_DEFAULT)) - result = true; - else if (description.isRequested(IContentDescriptionExtended.DETECTED_CHARSET)) - result = true; - else if (description.isRequested(IContentDescriptionExtended.UNSUPPORTED_CHARSET)) - result = true; - // else if - // (description.isRequested(IContentDescriptionExtended.ENCODING_MEMENTO)) - // result = true; - return result; - } -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/EncodingGuesser.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/EncodingGuesser.java deleted file mode 100644 index 130800eec8..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/EncodingGuesser.java +++ /dev/null @@ -1,173 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * Jens Lukowski/Innoopract - initial renaming/restructuring - * - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.contenttype; - -/** - * - * This is ported from PageDesigner's hpbcom/Kanji.cpp's - * Kanji::guess_kanji_code(), - * - */ -public class EncodingGuesser { - private static final int ASCII = 0; // ASCII - // ISO-2022-JP - private static final int ASCII_IN = 8; // This is after ISO2022's change - // Shift-JIS - private static final int EUC_HALFKANA = 6; // This is Half Kana in EUC-JP - private static final int EUC_JP = 3; // This is EUC-JP - private static final int ISO2022_JP = 4; // This is ISO-2022-JP - private static final int JIS_HALFKANA = 7; // THis is Half Kana in - private static final byte KT_EUC1 = 0x40; - private static final byte KT_EUC2 = (byte) 0x80; - // ASCII - private static final byte KT_JIN = 0x01; - private static final byte KT_JOUT = 0x02; - // private static final byte KT_ESC = 0x04; - // private static final byte KT_JIS = 0x08; - private static final byte KT_SFT1 = 0x10; - private static final byte KT_SFT2 = 0x20; - private static final byte ktype[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 00 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 10 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x09, 0x08, 0x08, 0x08, /* !"#$%&' *//* " */ - 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, /* ()*+,-./ */ - 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, /* 01234567 */ - 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, /* 89:; <=>? */ - 0x29, 0x28, 0x2b, 0x28, 0x28, 0x28, 0x28, 0x28, /* @ABCDEFG */ - 0x2a, 0x28, 0x2a, 0x28, 0x28, 0x28, 0x28, 0x28, /* HIJKLMNO */ - 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, /* PQRSTUVW */ - 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, /* XYZ[\]^_ */ - 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, /* abcdefg */ - 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, /* hijklmno */ - 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, /* pqrstuvw */ - 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x00, /* xyz{|}~ */ - 0x20, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, /* 80 */ - 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, /* 90 */ - 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x20, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, /* A0 */ - (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, /* B0 */ - (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, /* C0 */ - (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, /* D0 */ - (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xf0, (byte) 0xf0, (byte) 0xf0, (byte) 0xf0, (byte) 0xf0, (byte) 0xf0, (byte) 0xf0, (byte) 0xf0, /* E0 */ - (byte) 0xf0, (byte) 0xf0, (byte) 0xf0, (byte) 0xf0, (byte) 0xf0, (byte) 0xf0, (byte) 0xf0, (byte) 0xf0, (byte) 0xf0, (byte) 0xf0, (byte) 0xf0, (byte) 0xf0, (byte) 0xf0, (byte) 0xf0, (byte) 0xf0, (byte) 0xf0, /* F0 */ - (byte) 0xf0, (byte) 0xf0, (byte) 0xf0, (byte) 0xf0, (byte) 0xf0, (byte) 0xc0, (byte) 0xc0, 0x00,}; - // private static final int ISO8859_1 = 1; // ISO-1 - private static final int SHIFT_JIS = 2; // This is Shift-JIS - private static final int SJIS_HALFKANA = 5; // This is Half Kana in - - /** - * Currently, only Japanese encodings are supported. - */ - private static final int UNKNOWN = -1; // Unknown - - /** - * @return java.lang.String - * @param code - * int - * - * Convert private int to IANA Encoding name. - */ - private static String convertToIANAEncodingName(int code) { - String encoding = null; - - switch (code) { - case SHIFT_JIS : - case SJIS_HALFKANA : - encoding = "Shift_JIS";//$NON-NLS-1$ - break; - case EUC_JP : - case EUC_HALFKANA : - encoding = "EUC-JP";//$NON-NLS-1$ - break; - case ISO2022_JP : - case JIS_HALFKANA : - encoding = "ISO-2022-JP";//$NON-NLS-1$ - default : - break; - } - - return encoding; - } - - /** - * Return guessed Java Encoding name target: bytes to be inspected length: - * length of target - */ - public static String guessEncoding(byte[] target, int length) { - int code = UNKNOWN; - - // Currently, only Japanese is supported. - String system_ctype = java.util.Locale.getDefault().getLanguage(); - String jp_ctype = java.util.Locale.JAPANESE.getLanguage(); - if (system_ctype.compareTo(jp_ctype) == 0) { - // Ok, I'm under ja_JP. - code = ASCII; - int pos = 0; - while ((code == ASCII) && (length > 0)) { - int ch1 = target[pos]; - ch1 = ch1 & 0x000000FF; - int ch2 = (length >= 2) ? target[pos + 1] : 0; - ch2 = ch2 & 0x000000FF; - int ch3 = (length >= 3) ? target[pos + 2] : 0; - ch3 = ch3 & 0x000000FF; - code = guessJapaneseKanjiCode(ch1, ch2, ch3, 0); - pos++; - length--; - } - switch (code) { - case ISO2022_JP : - case JIS_HALFKANA : - code = ISO2022_JP; - break; - case EUC_JP : - code = EUC_JP; - break; - default : - code = SHIFT_JIS; - } - } - return (convertToIANAEncodingName(code)); - } - - /** - * Guess the encoding. halfkana_flag = 0x01 ( detect SJIS half kana ) - * halfkana_flag = 0x02 ( detect EUC half kana ) - */ - private static int guessJapaneseKanjiCode(int ch1, int ch2, int ch3, int halfkana_flag) { - boolean sjis_hankaku_flag = ((halfkana_flag & 0x01) != 0) ? true : false; - boolean euc_hankaku_flag = ((halfkana_flag & 0x02) != 0) ? true : false; - - if (ch1 == 0) - return UNKNOWN; - if (sjis_hankaku_flag && ch1 >= 0xa1 && ch1 <= 0xdf) - return SJIS_HALFKANA; - else if (euc_hankaku_flag && ch1 == 0x8e && ch2 >= 0xa1 && ch2 <= 0xdf) - return EUC_HALFKANA; - else if (((ktype[ch1] & KT_SFT1) != 0) && ((ktype[ch2] & KT_SFT2) != 0)) - return SHIFT_JIS; - else if (((ktype[ch1] & KT_EUC1) != 0) && ((ktype[ch2] & KT_EUC2) != 0)) - return EUC_JP; - else if (ch1 == 0x1b && ((ktype[ch2] & KT_JIN) != 0)) - return ISO2022_JP; - else if (ch1 >= 0xa1 && ch1 <= 0xdf) - return SJIS_HALFKANA; - else if (ch1 == 0x1b && ch2 == 0x28/* '(' */&& ch3 == 0x49/* 'I' */) - return JIS_HALFKANA; - else if (ch1 == 0x1b && ch2 == 0x28/* '(' */&& ((ktype[ch3] & KT_JOUT) != 0)) - return ASCII_IN; - - return ASCII; - } - - public EncodingGuesser() { - super(); - } -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/HeadParserToken.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/HeadParserToken.java deleted file mode 100644 index 51dc01cce1..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/HeadParserToken.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * Jens Lukowski/Innoopract - initial renaming/restructuring - * - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.contenttype; - -public class HeadParserToken { - private int fStart; - - private String fText; - private String fType; - - protected HeadParserToken() { - super(); - } - - public HeadParserToken(String type, int start, String text) { - this(); - fType = type; - fStart = start; - fText = text; - - } - - public String getText() { - return fText; - } - - public String getType() { - return fType; - } - - public String toString() { - return ("text: " + fText + " offset: " + fStart + " type: " + fType); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - } -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/IntStack.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/IntStack.java deleted file mode 100644 index f2830b946a..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/IntStack.java +++ /dev/null @@ -1,114 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * Jens Lukowski/Innoopract - initial renaming/restructuring - * - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.contenttype; - -/* - * - * A non-resizable class implementing the behavior of java.util.Stack, but - * directly for the integer primitive. - */ -import java.util.EmptyStackException; - -public class IntStack { - private int[] list = null; - - private int size = 0; - - public IntStack() { - this(100); - } - - public IntStack(int maxdepth) { - super(); - list = new int[maxdepth]; - initialize(); - } - - public void clear() { - initialize(); - } - - public boolean empty() { - return size == 0; - } - - public int get(int slot) { - return list[slot]; - } - - private void initialize() { - for (int i = 0; i < list.length; i++) - list[i] = -1; - } - - /** - * Returns the int at the top of the stack without removing it - * - * @return int at the top of this stack. - * @exception EmptyStackException - * when empty. - */ - public int peek() { - if (size == 0) - throw new EmptyStackException(); - return list[size - 1]; - } - - /** - * Removes and returns the int at the top of the stack - * - * @return int at the top of this stack. - * @exception EmptyStackException - * when empty. - */ - public int pop() { - int value = peek(); - list[size - 1] = -1; - size--; - return value; - } - - /** - * Pushes an item onto the top of this stack. - * - * @param newValue - - * the int to be pushed onto this stack. - * @return the newValue argument. - */ - public int push(int newValue) { - if (size == list.length) { - throw new StackOverflowError(); - } - list[size++] = newValue; - return newValue; - } - - public int size() { - return size; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - public String toString() { - StringBuffer s = new StringBuffer(getClass().getName() + ":" +size + " ["); - for (int i = 0; i < size; i++) { - s.append(list[i]); - if(i < size - 1) { - s.append(", "); - } - } - s.append("]"); - return s.toString(); - } -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/AbstractCSSNodeList.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/AbstractCSSNodeList.java deleted file mode 100644 index 007991b97b..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/AbstractCSSNodeList.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.document; - -import java.util.Vector; - -import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode; - - -/** - * - */ -abstract class AbstractCSSNodeList { - - protected Vector nodes = null; - - ICSSNode appendNode(ICSSNode node) { - if (node == null) - return null; - if (this.nodes == null) - this.nodes = new Vector(); - this.nodes.addElement(node); - return node; - } - - /** - * @return int - */ - public int getLength() { - if (this.nodes == null) - return 0; - return this.nodes.size(); - } - - - protected ICSSNode itemImpl(int index) { - if (this.nodes == null) - return null; - if (index < 0 || index >= this.nodes.size()) - return null; - return (ICSSNode) this.nodes.elementAt(index); - } - - - ICSSNode removeNode(int index) { - if (this.nodes == null) - return null; // no node - if (index < 0 || index >= this.nodes.size()) - return null; // invalid parameter - - ICSSNode removed = (ICSSNode) this.nodes.elementAt(index); - this.nodes.removeElementAt(index); - return removed; - } -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSAttrImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSAttrImpl.java deleted file mode 100644 index 9a04a4f6c0..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSAttrImpl.java +++ /dev/null @@ -1,133 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.document; - -import org.eclipse.wst.css.core.internal.provisional.document.ICSSAttr; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSDocument; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSNamedNodeMap; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode; - -/** - * - */ -class CSSAttrImpl extends CSSRegionContainer implements ICSSAttr { - - private String fName = null; - private String fValue = null; - private CSSNodeImpl ownerCSSNode = null; - - CSSAttrImpl(CSSAttrImpl that) { - super(that); - this.fName = that.fName; - this.setValue(that.fValue); - } - - /** - * CSSAttr constructor comment. - */ - CSSAttrImpl(String name) { - super(); - this.fName = name; - } - - public ICSSNode cloneNode(boolean deep) { - return new CSSAttrImpl(this); - } - - /** - * @return org.eclipse.wst.css.core.model.interfaces.ICSSNamedNodeMap - */ - public ICSSNamedNodeMap getAttributes() { - return null; - } - - /** - * @return java.lang.String - */ - public java.lang.String getName() { - return fName; - } - - /** - * @return short - */ - public short getNodeType() { - return ATTR_NODE; - } - - public ICSSNode getOwnerCSSNode() { - return ownerCSSNode; - } - - /** - * @return java.lang.String - */ - public java.lang.String getValue() { - return fValue; - } - - /** - * @return boolean - * @param name - * java.lang.String - */ - protected boolean matchName(String name) { - if (name == null) - return /* (this.name == null) */false; - if (this.fName == null) - return false; - return this.fName.equals(name); - } - - /** - * - */ - protected void notifyValueChanged(String oldValue) { - if (this.ownerCSSNode == null) - return; - - // for model - ICSSDocument doc = ownerCSSNode.getContainerDocument(); - if (doc == null) - return; - CSSModelImpl model = (CSSModelImpl) doc.getModel(); - if (model == null) - return; - model.valueChanged(this, oldValue); - - // for adapters - String value = getValue(); - this.ownerCSSNode.notify(CHANGE, this, oldValue, value, this.ownerCSSNode.getStartOffset()); - } - - /** - * @param newName - * java.lang.String - */ - protected void setName(java.lang.String newName) { - fName = newName; - } - - protected void setOwnerCSSNode(CSSNodeImpl newOwnerCSSNode) { - ownerCSSNode = newOwnerCSSNode; - } - - /** - * @param newValue - * java.lang.String - */ - public void setValue(java.lang.String newValue) { - String oldValue = fValue; - fValue = newValue; - - notifyValueChanged(oldValue); - } -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSCharsetRuleImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSCharsetRuleImpl.java deleted file mode 100644 index 676c305bf0..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSCharsetRuleImpl.java +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.document; - - - -import org.eclipse.wst.css.core.internal.CSSCorePlugin; -import org.eclipse.wst.css.core.internal.preferences.CSSCorePreferenceNames; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSCharsetRule; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode; -import org.eclipse.wst.css.core.internal.util.CSSUtil; - - -/** - * - */ -class CSSCharsetRuleImpl extends CSSRuleImpl implements ICSSCharsetRule { - - /** - * - */ - CSSCharsetRuleImpl() { - super(); - } - - CSSCharsetRuleImpl(CSSCharsetRuleImpl that) { - super(that); - } - - public ICSSNode cloneNode(boolean deep) { - CSSCharsetRuleImpl cloned = new CSSCharsetRuleImpl(this); - - return cloned; - } - - /** - * The encoding information used in this @charset rule. - * @exception org.w3c.dom.DOMException - * SYNTAX_ERR: Raised if the specified encoding value has a - * syntax error and is unparsable.
- * NO_MODIFICATION_ALLOWED_ERR: Raised if this encoding - * rule is readonly. - */ - public String getEncoding() { - return CSSUtil.extractStringContents(getAttribute(ENCODING)); - } - - /** - * @return short - */ - public short getNodeType() { - return CHARSETRULE_NODE; - } - - /** - * The type of the rule, as defined above. The expectation is that - * binding-specific casting methods can be used to cast down from an - * instance of the CSSRule interface to the specific - * derived interface implied by the type. - */ - public short getType() { - return CHARSET_RULE; - } - - public void setEncoding(String encoding) throws org.w3c.dom.DOMException { - String quote = CSSCorePlugin.getDefault().getPluginPreferences().getString(CSSCorePreferenceNames.FORMAT_QUOTE); - String enc = CSSUtil.extractStringContents(encoding); - quote = CSSUtil.detectQuote(enc, quote); - setAttribute(ENCODING, quote + enc + quote); - } -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSDeclarationItemParser.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSDeclarationItemParser.java deleted file mode 100644 index 4e450416c6..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSDeclarationItemParser.java +++ /dev/null @@ -1,1075 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2010 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.document; - -import java.util.Iterator; - -import org.eclipse.wst.css.core.internal.contentmodel.PropCMProperty; -import org.eclipse.wst.css.core.internal.parserz.CSSRegionContexts; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSDocument; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSPrimitiveValue; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclItem; -import org.eclipse.wst.css.core.internal.provisional.document.ICounter; -import org.eclipse.wst.css.core.internal.util.CSSUtil; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList; -import org.eclipse.wst.sse.core.internal.text.TextRegionListImpl; -import org.w3c.dom.css.CSSPrimitiveValue; - - -/** - * - */ -class CSSDeclarationItemParser { - /** - * - */ - final class FloatInfo { - /** - * - */ - FloatInfo(String text) { - parse(text); - } - - /** - * - */ - void parse(String text) { - StringBuffer bufValue = new StringBuffer(); - StringBuffer bufIdent = new StringBuffer(); - boolean bNum = true; - int len = text.length(); - for (int i = 0; i < len; i++) { - char c = text.charAt(i); - if (bNum) { - // Only add +/- if it's the first character in the value buffer - if ('0' <= c && c <= '9' || c == '.' || ((c == '+' || c == '-') && i == 0)) { - bufValue.append(c); - } - else { - bufIdent.append(c); - bNum = false; - } - } - else { - bufIdent.append(c); - } - } - String valueStr = bufValue.toString(); - try { - fValue = Float.valueOf(valueStr).floatValue(); - } - catch (NumberFormatException e) { - bufIdent.insert(0, valueStr); - } - fIdentifier = bufIdent.toString(); - fType = getFloatValueType(valueStr, fIdentifier); - } - - /** - * - */ - float getValue() { - return fValue; - } - - /** - * - */ - String getIdentifier() { - return fIdentifier; - } - - /** - * - */ - short getValueType() { - return fType; - } - - private float fValue = 0.0f; - private String fIdentifier = null; - private short fType = CSSPrimitiveValue.CSS_UNKNOWN; - } - - final static int S_NORMAL = 0; - final static int S_FUNCTION = 1; - final static int S_FONT_SLASH = 2; - final static int S_COMMA_SEPARATION = 3; - private ICSSDocument fDocument = null; - private IStructuredDocumentRegion fParentRegion = null; - private boolean fTempStructuredDocument = false; - private CSSModelUpdateContext fUpdateContext = null; - - /** - * CSSDeclarationItemParser constructor comment. - */ - CSSDeclarationItemParser(ICSSDocument doc) { - super(); - fDocument = doc; - } - - /** - * - */ - private CSSPrimitiveValueImpl createAttrValue(ITextRegionList regions) { - String funcName = getFunctionName(regions); - if (funcName == null || !funcName.toLowerCase().equals("attr")) { //$NON-NLS-1$ - return null; - } - String accepts[] = {CSSRegionContexts.CSS_DECLARATION_VALUE_IDENT}; - ITextRegionList valueRegions = getFunctionParameters(regions, accepts); - if (valueRegions.size() != 1) { - return null; - } - - CSSPrimitiveValueImpl value = getCSSPrimitiveValue(CSSPrimitiveValue.CSS_ATTR); - if (value == null) { - return null; - } - - ITextRegion region = valueRegions.get(0); - value.setValue(getText(region)); - - return value; - } - - /** - * - */ - private CSSPrimitiveValueImpl createCountersValue(ITextRegionList regions) { - String funcName = getFunctionName(regions); - if (funcName == null || !funcName.toLowerCase().equals("counters")) { //$NON-NLS-1$ - return null; - } - - String accepts[] = {CSSRegionContexts.CSS_DECLARATION_VALUE_IDENT, CSSRegionContexts.CSS_DECLARATION_VALUE_STRING}; - ITextRegionList valueRegions = getFunctionParameters(regions, accepts); - int size = valueRegions.size(); - if (size != 2 && size != 3) { - return null; - } - - CounterImpl value = getCounter(); - if (value == null) { - return null; - } - - for (int i = 0; i < size; i++) { - ITextRegion region = valueRegions.get(i); - String text = getText(region); - CSSAttrImpl attr = null; - switch (i) { - case 0 : - value.setIdentifier(text); - attr = value.getAttributeNode(ICounter.IDENTIFIER); - break; - case 1 : - value.setSeparator(text); - attr = value.getAttributeNode(ICounter.SEPARATOR); - break; - case 2 : - value.setListStyle(text); - attr = value.getAttributeNode(ICounter.LISTSTYLE); - break; - default : - break; - } - if (attr != null) { - attr.setRangeRegion(fParentRegion, region, region); - } - } - - return value; - } - - /** - * - */ - private CSSPrimitiveValueImpl createCounterValue(ITextRegionList regions) { - String funcName = getFunctionName(regions); - if (funcName == null || !funcName.toLowerCase().equals("counter")) { //$NON-NLS-1$ - return null; - } - - String accepts[] = {CSSRegionContexts.CSS_DECLARATION_VALUE_IDENT}; - ITextRegionList valueRegions = getFunctionParameters(regions, accepts); - int size = valueRegions.size(); - if (size != 1 && size != 2) { - return null; - } - - CounterImpl value = getCounter(); - if (value == null) { - return null; - } - - for (int i = 0; i < size; i++) { - ITextRegion region = valueRegions.get(i); - String text = getText(region); - CSSAttrImpl attr = null; - switch (i) { - case 0 : - value.setIdentifier(text); - attr = value.getAttributeNode(ICounter.IDENTIFIER); - break; - case 1 : - value.setListStyle(text); - attr = value.getAttributeNode(ICounter.LISTSTYLE); - break; - default : - break; - } - if (attr != null) { - attr.setRangeRegion(fParentRegion, region, region); - } - } - - return value; - } - - /** - * - */ - private CSSStyleDeclItemImpl createDeclarationItem(ITextRegionList nodeRegions) { - CSSStyleDeclItemImpl item = null; - String name = getPropertyName(nodeRegions); - if (name != null) { - item = getCSSStyleDeclItem(name); - } - return item; - } - - /** - * - */ - private CSSPrimitiveValueImpl createFloatValue(String text, String type) { - FloatInfo info = new FloatInfo(text); - CSSPrimitiveValueImpl value = getCSSPrimitiveValue(info.getValueType()); - if (value != null) { - value.setValue(info.getValue()); - } - return value; - } - - /** - * - */ - private CSSPrimitiveValueImpl createFormatValue(ITextRegionList regions) { - String funcName = getFunctionName(regions); - if (funcName == null || !funcName.toLowerCase().equals("format")) { //$NON-NLS-1$ - return null; - } - String accepts[] = {CSSRegionContexts.CSS_DECLARATION_VALUE_STRING}; - ITextRegionList valueRegions = getFunctionParameters(regions, accepts); - // format can take variable args. - if (valueRegions.size() == 0) { - return null; - } - - CSSPrimitiveValueImpl value = getCSSPrimitiveValue(ICSSPrimitiveValue.CSS_FORMAT); - if (value == null) { - return null; - } - - ITextRegion region = valueRegions.get(0); - value.setValue(CSSUtil.extractStringContents(getText(region))); - - return value; - - } - - /** - * - */ - private CSSPrimitiveValueImpl createLocalValue(ITextRegionList regions) { - String funcName = getFunctionName(regions); - if (funcName == null || !funcName.toLowerCase().equals("local")) { //$NON-NLS-1$ - return null; - } - String accepts[] = {CSSRegionContexts.CSS_DECLARATION_VALUE_STRING}; - ITextRegionList valueRegions = getFunctionParameters(regions, accepts); - if (valueRegions.size() != 1) { - return null; - } - - CSSPrimitiveValueImpl value = getCSSPrimitiveValue(ICSSPrimitiveValue.CSS_LOCAL); - if (value == null) { - return null; - } - - ITextRegion region = valueRegions.get(0); - value.setValue(CSSUtil.extractStringContents(getText(region))); - - return value; - } - - /** - * - */ - private CSSPrimitiveValueImpl createPrimitiveValue(ITextRegion region) { - if (region == null) { - return null; - } - CSSPrimitiveValueImpl value = null; - String type = region.getType(); - String text = getText(region); - if (isBlank(type)) { - value = null; - } - else if (type == CSSRegionContexts.CSS_DECLARATION_VALUE_NUMBER || type == CSSRegionContexts.CSS_DECLARATION_VALUE_DIMENSION || type == CSSRegionContexts.CSS_DECLARATION_VALUE_PERCENTAGE) { - value = createFloatValue(text, type); - } - else if (type == CSSRegionContexts.CSS_DECLARATION_VALUE_STRING || type == CSSRegionContexts.CSS_DECLARATION_VALUE_URI || type == CSSRegionContexts.CSS_DECLARATION_VALUE_IDENT || type == CSSRegionContexts.CSS_DECLARATION_VALUE_HASH) { - value = createStringValue(text, type); - } - - if (value == null) { - value = createStringValue(text, type); - } - - if (!fTempStructuredDocument && value != null) { - value.setRangeRegion(fParentRegion, region, region); - } - - return value; - } - - /** - * - */ - private CSSPrimitiveValueImpl createPrimitiveValue(ITextRegionList regions) { - CSSPrimitiveValueImpl value = null; - CSSUtil.stripSurroundingSpace(regions); - if (regions.isEmpty()) { - return null; - } - ITextRegion region = regions.get(0); - if (region == null) { - return null; - } - String type = region.getType(); - if (type == CSSRegionContexts.CSS_DECLARATION_VALUE_FUNCTION) { - String text = getText(region).toLowerCase(); - if (text.equals("rgb(")) { //$NON-NLS-1$ - value = createRgbValue(regions); - } - else if (text.equals("counter(")) { //$NON-NLS-1$ - value = createCounterValue(regions); - } - else if (text.equals("counters(")) { //$NON-NLS-1$ - value = createCountersValue(regions); - } - else if (text.equals("attr(")) { //$NON-NLS-1$ - value = createAttrValue(regions); - } - else if (text.equals("format(")) { //$NON-NLS-1$ - value = createFormatValue(regions); - } - else if (text.equals("local(")) { //$NON-NLS-1$ - value = createLocalValue(regions); - } - else if (text.equals("rect(")) { //$NON-NLS-1$ - value = createRectValue(regions); - } - if (value == null) { - value = createStringValue(regions); - } - } - else { - value = createStringValue(regions); - } - - if (!fTempStructuredDocument && value != null) { - value.setRangeRegion(fParentRegion, regions.get(0), regions.get(regions.size() - 1)); - } - - return value; - } - - /** - * - */ - private CSSPrimitiveValueImpl createRectValue(ITextRegionList regions) { - String funcName = getFunctionName(regions); - if (funcName == null || !funcName.toLowerCase().equals("rect")) { //$NON-NLS-1$ - return null; - } - String accepts[] = {CSSRegionContexts.CSS_DECLARATION_VALUE_NUMBER, CSSRegionContexts.CSS_DECLARATION_VALUE_DIMENSION, CSSRegionContexts.CSS_DECLARATION_VALUE_IDENT}; // IDENT: - // for - // 'auto' - ITextRegionList valueRegions = getFunctionParameters(regions, accepts); - if (valueRegions.size() != 4) { - return null; - } - - RectImpl value = getRect(); - if (value == null) { - return null; - } - - for (int i = 0; i < 4; i++) { - ITextRegion region = valueRegions.get(i); - CSSPrimitiveValueImpl childValue = null; - switch (i) { - case 0 : - childValue = (CSSPrimitiveValueImpl) value.getTop(); - break; - case 1 : - childValue = (CSSPrimitiveValueImpl) value.getRight(); - break; - case 2 : - childValue = (CSSPrimitiveValueImpl) value.getBottom(); - break; - case 3 : - childValue = (CSSPrimitiveValueImpl) value.getLeft(); - break; - default : - break; - } - if (childValue == null) { - return null; - } - String text = getText(region); - String type = region.getType(); - if (type == CSSRegionContexts.CSS_DECLARATION_VALUE_IDENT) { - setStringValue(childValue, text, type); - } - else { - setFloatValue(childValue, text, type); - } - if (!fTempStructuredDocument) { - childValue.setRangeRegion(fParentRegion, region, region); - } - } - - return value; - } - - /** - * - */ - private CSSPrimitiveValueImpl createRgbValue(ITextRegionList regions) { - String funcName = getFunctionName(regions); - if (funcName == null || !funcName.toLowerCase().equals("rgb")) { //$NON-NLS-1$ - return null; - } - String accepts[] = {CSSRegionContexts.CSS_DECLARATION_VALUE_NUMBER, CSSRegionContexts.CSS_DECLARATION_VALUE_PERCENTAGE}; - ITextRegionList valueRegions = getFunctionParameters(regions, accepts); - if (valueRegions.size() != 3) { - return null; - } - - RGBColorImpl value = getRGBColor(); - if (value == null) { - return null; - } - - for (int i = 0; i < 3; i++) { - ITextRegion region = valueRegions.get(i); - CSSPrimitiveValueImpl childValue = null; - switch (i) { - case 0 : - childValue = (CSSPrimitiveValueImpl) value.getRed(); - break; - case 1 : - childValue = (CSSPrimitiveValueImpl) value.getGreen(); - break; - case 2 : - childValue = (CSSPrimitiveValueImpl) value.getBlue(); - break; - default : - break; - } - if (childValue == null) { - return null; - } - setFloatValue(childValue, getText(region), region.getType()); - if (!fTempStructuredDocument) { - childValue.setRangeRegion(fParentRegion, region, region); - } - } - - return value; - } - - /** - * - */ - private CSSPrimitiveValueImpl createStringValue(String text, String type) { - short valueType = getStringValueType(text, type); - CSSPrimitiveValueImpl value = getCSSPrimitiveValue(valueType); - if (value != null) { - if (valueType == CSSPrimitiveValue.CSS_URI) { - text = CSSUtil.extractUriContents(text); - } - else if (valueType == CSSPrimitiveValue.CSS_STRING) { - text = CSSUtil.extractStringContents(text); - } - value.setValue(text); - } - return value; - } - - /** - * - */ - private CSSPrimitiveValueImpl createStringValue(ITextRegionList regions) { - String type = CSSRegionContexts.CSS_DECLARATION_VALUE_IDENT; - if (regions.size() == 1) { - ITextRegion region = regions.get(0); - type = region.getType(); - } - return createStringValue(makeString(regions), type); - } - - /** - * - */ - private CounterImpl getCounter() { - CounterImpl node; - if (fUpdateContext != null && fUpdateContext.isActive()) { - node = fUpdateContext.getCounter(); - } - else { - node = (CounterImpl) fDocument.createCSSPrimitiveValue(CSSPrimitiveValue.CSS_COUNTER); - } - return node; - } - - /** - * - */ - private CSSPrimitiveValueImpl getCSSPrimitiveValue(short type) { - CSSPrimitiveValueImpl node; - if (fUpdateContext != null && fUpdateContext.isActive()) { - node = fUpdateContext.getCSSPrimitiveValue(type); - } - else { - node = (CSSPrimitiveValueImpl) fDocument.createCSSPrimitiveValue(type); - } - return node; - } - - /** - * - */ - private CSSStyleDeclItemImpl getCSSStyleDeclItem(String propertyName) { - CSSStyleDeclItemImpl node; - if (fUpdateContext != null && fUpdateContext.isActive()) { - node = fUpdateContext.getCSSStyleDeclItem(propertyName); - } - else { - node = (CSSStyleDeclItemImpl) fDocument.createCSSStyleDeclItem(propertyName); - } - return node; - } - - /** - * - */ - static short getFloatValueType(String ident) { - ident = ident.toLowerCase(); - short valueType; - if (ident.length() == 0) { - valueType = CSSPrimitiveValue.CSS_NUMBER; - } - else if (ident.equals("%")) { //$NON-NLS-1$ - valueType = CSSPrimitiveValue.CSS_PERCENTAGE; - } - else if (ident.equalsIgnoreCase("em")) { //$NON-NLS-1$ - valueType = CSSPrimitiveValue.CSS_EMS; - } - else if (ident.equalsIgnoreCase("ex")) { //$NON-NLS-1$ - valueType = CSSPrimitiveValue.CSS_EXS; - } - else if (ident.equalsIgnoreCase("px")) { //$NON-NLS-1$ - valueType = CSSPrimitiveValue.CSS_PX; - } - else if (ident.equalsIgnoreCase("cm")) { //$NON-NLS-1$ - valueType = CSSPrimitiveValue.CSS_CM; - } - else if (ident.equalsIgnoreCase("mm")) { //$NON-NLS-1$ - valueType = CSSPrimitiveValue.CSS_MM; - } - else if (ident.equalsIgnoreCase("in")) { //$NON-NLS-1$ - valueType = CSSPrimitiveValue.CSS_IN; - } - else if (ident.equalsIgnoreCase("pt")) { //$NON-NLS-1$ - valueType = CSSPrimitiveValue.CSS_PT; - } - else if (ident.equalsIgnoreCase("pc")) { //$NON-NLS-1$ - valueType = CSSPrimitiveValue.CSS_PC; - } - else if (ident.equalsIgnoreCase("deg")) { //$NON-NLS-1$ - valueType = CSSPrimitiveValue.CSS_DEG; - } - else if (ident.equalsIgnoreCase("rad")) { //$NON-NLS-1$ - valueType = CSSPrimitiveValue.CSS_RAD; - } - else if (ident.equalsIgnoreCase("grad")) { //$NON-NLS-1$ - valueType = CSSPrimitiveValue.CSS_GRAD; - } - else if (ident.equalsIgnoreCase("ms")) { //$NON-NLS-1$ - valueType = CSSPrimitiveValue.CSS_MS; - } - else if (ident.equalsIgnoreCase("s")) { //$NON-NLS-1$ - valueType = CSSPrimitiveValue.CSS_S; - } - else if (ident.equalsIgnoreCase("hz")) { //$NON-NLS-1$ - valueType = CSSPrimitiveValue.CSS_HZ; - } - else if (ident.equalsIgnoreCase("khz")) { //$NON-NLS-1$ - valueType = CSSPrimitiveValue.CSS_KHZ; - } - else { - valueType = CSSPrimitiveValue.CSS_DIMENSION; - } - return valueType; - } - - /** - * - */ - static short getFloatValueType(String value, String ident) { - ident = ident.toLowerCase(); - short valueType; - if (ident.length() == 0) { - if (0 <= value.indexOf('.')) { - valueType = CSSPrimitiveValue.CSS_NUMBER; - } - else { - valueType = ICSSPrimitiveValue.CSS_INTEGER; - } - } - else if (ident.equals("%")) { //$NON-NLS-1$ - valueType = CSSPrimitiveValue.CSS_PERCENTAGE; - } - else if (ident.equalsIgnoreCase("em")) { //$NON-NLS-1$ - valueType = CSSPrimitiveValue.CSS_EMS; - } - else if (ident.equalsIgnoreCase("ex")) { //$NON-NLS-1$ - valueType = CSSPrimitiveValue.CSS_EXS; - } - else if (ident.equalsIgnoreCase("px")) { //$NON-NLS-1$ - valueType = CSSPrimitiveValue.CSS_PX; - } - else if (ident.equalsIgnoreCase("cm")) { //$NON-NLS-1$ - valueType = CSSPrimitiveValue.CSS_CM; - } - else if (ident.equalsIgnoreCase("mm")) { //$NON-NLS-1$ - valueType = CSSPrimitiveValue.CSS_MM; - } - else if (ident.equalsIgnoreCase("in")) { //$NON-NLS-1$ - valueType = CSSPrimitiveValue.CSS_IN; - } - else if (ident.equalsIgnoreCase("pt")) { //$NON-NLS-1$ - valueType = CSSPrimitiveValue.CSS_PT; - } - else if (ident.equalsIgnoreCase("pc")) { //$NON-NLS-1$ - valueType = CSSPrimitiveValue.CSS_PC; - } - else if (ident.equalsIgnoreCase("deg")) { //$NON-NLS-1$ - valueType = CSSPrimitiveValue.CSS_DEG; - } - else if (ident.equalsIgnoreCase("rad")) { //$NON-NLS-1$ - valueType = CSSPrimitiveValue.CSS_RAD; - } - else if (ident.equalsIgnoreCase("grad")) { //$NON-NLS-1$ - valueType = CSSPrimitiveValue.CSS_GRAD; - } - else if (ident.equalsIgnoreCase("ms")) { //$NON-NLS-1$ - valueType = CSSPrimitiveValue.CSS_MS; - } - else if (ident.equalsIgnoreCase("s")) { //$NON-NLS-1$ - valueType = CSSPrimitiveValue.CSS_S; - } - else if (ident.equalsIgnoreCase("hz")) { //$NON-NLS-1$ - valueType = CSSPrimitiveValue.CSS_HZ; - } - else if (ident.equalsIgnoreCase("khz")) { //$NON-NLS-1$ - valueType = CSSPrimitiveValue.CSS_KHZ; - } - else { - valueType = CSSPrimitiveValue.CSS_DIMENSION; - } - return valueType; - } - - /** - * - */ - private String getFunctionName(ITextRegionList regions) { - if (regions == null || regions.size() < 2) { - return null; - } - ITextRegion firstRegion = regions.get(0); - if (firstRegion.getType() != CSSRegionContexts.CSS_DECLARATION_VALUE_FUNCTION) { - return null; - } - ITextRegion lastRegion = regions.get(regions.size() - 1); - if (lastRegion.getType() != CSSRegionContexts.CSS_DECLARATION_VALUE_PARENTHESIS_CLOSE) { - return null; - } - String text = getText(firstRegion); - return text.substring(0, text.length() - 1); - } - - /** - * this method has no validation check, then regions must be passed - * getFunctionName()... - */ - private ITextRegionList getFunctionParameters(ITextRegionList regions, String[] accepts) { - ITextRegionList newRegions = new TextRegionListImpl(); - int nAccepts = (accepts != null) ? accepts.length : 0; - Iterator i = regions.iterator(); - i.next(); // skip FUNCTION - while (i.hasNext()) { - ITextRegion region = (ITextRegion) i.next(); - if (region == null) { - continue; - } - String type = region.getType(); - if (isBlank(type)) { - continue; - } - if (nAccepts == 0) { - newRegions.add(region); - } - else { - for (int iAccept = 0; iAccept < nAccepts; iAccept++) { - if (type == accepts[iAccept]) { - newRegions.add(region); - break; - } - } - } - } - return newRegions; - } - - /** - * - */ - // private String getPropertyName(IStructuredDocumentRegion flatNode) { - // Vector nodeRegions = new Vector(flatNode.getRegions()); - // return getPropertyName(nodeRegions); - // } - /** - * - */ - private String getPropertyName(ITextRegionList nodeRegions) { - ITextRegionList nameRegions = new TextRegionListImpl(); - String name = null; - while (!nodeRegions.isEmpty()) { - ITextRegion region = nodeRegions.remove(0); - if (region == null) { - continue; - } - String type = region.getType(); - if (type == CSSRegionContexts.CSS_DECLARATION_SEPARATOR) { - CSSUtil.stripSurroundingSpace(nameRegions); - name = makeString(nameRegions); - break; - } - else { - nameRegions.add(region); - } - } - return name; - } - - /** - * - */ - private RectImpl getRect() { - RectImpl node; - if (fUpdateContext != null && fUpdateContext.isActive()) { - node = fUpdateContext.getRect(); - } - else { - node = (RectImpl) fDocument.createCSSPrimitiveValue(CSSPrimitiveValue.CSS_RECT); - } - return node; - } - - /** - * - */ - private RGBColorImpl getRGBColor() { - RGBColorImpl node; - if (fUpdateContext != null && fUpdateContext.isActive()) { - node = fUpdateContext.getRGBColor(); - } - else { - node = (RGBColorImpl) fDocument.createCSSPrimitiveValue(CSSPrimitiveValue.CSS_RGBCOLOR); - } - return node; - } - - /** - * - */ - private short getStringValueType(String text, String type) { - short valueType; - if (text.toLowerCase().equals("inherit")) { //$NON-NLS-1$ - valueType = ICSSPrimitiveValue.CSS_INHERIT_PRIMITIVE; - } - else if (type == CSSRegionContexts.CSS_DECLARATION_VALUE_URI) { - valueType = CSSPrimitiveValue.CSS_URI; - } - else if (type == CSSRegionContexts.CSS_DECLARATION_VALUE_STRING) { - valueType = CSSPrimitiveValue.CSS_STRING; - } - else if (type == CSSRegionContexts.CSS_DECLARATION_VALUE_HASH) { - valueType = ICSSPrimitiveValue.CSS_HASH; - } - else if (type == CSSRegionContexts.CSS_DECLARATION_VALUE_OPERATOR && text.equals(",")) { //$NON-NLS-1$ - valueType = ICSSPrimitiveValue.CSS_COMMA; - } - else if (type == CSSRegionContexts.CSS_DECLARATION_VALUE_OPERATOR && text.equals("/")) { //$NON-NLS-1$ - valueType = ICSSPrimitiveValue.CSS_SLASH; - } - else if (type == CSSRegionContexts.CSS_DECLARATION_VALUE_UNICODE_RANGE) { - valueType = ICSSPrimitiveValue.CSS_URANGE; - } - else { - valueType = CSSPrimitiveValue.CSS_IDENT; - } - return valueType; - } - - /** - * - */ - private String makeString(ITextRegionList regions) { - StringBuffer buf = new StringBuffer(); - boolean bSpace = false; - for (Iterator i = regions.iterator(); i.hasNext();) { - ITextRegion region = (ITextRegion) i.next(); - String type = region.getType(); - if (!bSpace && isBlank(type)) { - buf.append(" "); //$NON-NLS-1$ - bSpace = true; - } - else { - // [274945] Multiple regions should have the spaces between collapsed - String text = i.hasNext() ? getCollapsedText(region) : getText(region); - buf.append(text); - bSpace = false; - } - } - - return buf.toString(); - } - - /** - * - */ - void setStructuredDocumentTemporary(boolean bTemp) { - fTempStructuredDocument = bTemp; - } - - /** - * - */ - private void setFloatValue(CSSPrimitiveValueImpl value, String text, String type) { - FloatInfo info = new FloatInfo(text); - value.setFloatValue(info.getValueType(), info.getValue()); - } - - /** - * - */ - private void setStringValue(CSSPrimitiveValueImpl value, String text, String type) { - short valueType = getStringValueType(text, type); - value.setStringValue(valueType, text); - } - - - /** - * - */ - void setUpdateContext(CSSModelUpdateContext updateContext) { - fUpdateContext = updateContext; - } - - /** - * - */ - public static boolean hasColonSeparator(IStructuredDocumentRegion flatNode) { - if (flatNode == null) { - return false; - } - ITextRegionList regions = flatNode.getRegions(); - if (regions == null || regions.size() == 0) { - return false; - } - - for (Iterator i = regions.iterator(); i.hasNext();) { - ITextRegion region = (ITextRegion) i.next(); - if (region == null) { - continue; - } - if (region.getType() == CSSRegionContexts.CSS_DECLARATION_SEPARATOR) { - return true; - } - } - - return false; - } - - /** - * - */ - CSSStyleDeclItemImpl setupDeclarationItem(IStructuredDocumentRegion flatNode) { - if (flatNode == null) { - return null; - } - if (!hasColonSeparator(flatNode)) { - return null; - } - - fParentRegion = flatNode; - - ITextRegionList nodeRegions = new TextRegionListImpl(flatNode.getRegions()); // make - // copy - CSSStyleDeclItemImpl newItem = createDeclarationItem(nodeRegions); - if (newItem == null) { - return null; - } - if (!fTempStructuredDocument && flatNode != null) { - newItem.setRangeStructuredDocumentRegion(flatNode, flatNode); - } - - CSSUtil.stripSurroundingSpace(nodeRegions); - // Now, nodeRegions just has regions for value. - setupValues(newItem, nodeRegions); - return newItem; - } - - void setupValues(ICSSStyleDeclItem item, IStructuredDocumentRegion parentRegion, ITextRegionList nodeRegions) { - fParentRegion = parentRegion; - setupValues(item, nodeRegions); - } - - /** - * nodeRegions must be broken. If you need after, make copy of them. - */ - private void setupValues(ICSSStyleDeclItem item, ITextRegionList nodeRegions) { - if (item == null) { - return; - } - - ICSSPrimitiveValue value; - ITextRegionList regionBuf = new TextRegionListImpl(); - - String propertyName = item.getPropertyName().toLowerCase(); - boolean bFont = (propertyName.equals(PropCMProperty.P_FONT)); - // (short-hand) font - int status = (propertyName.equals(PropCMProperty.P_VOICE_FAMILY) || propertyName.equals(PropCMProperty.P_FONT_FAMILY)) ? S_COMMA_SEPARATION : S_NORMAL; - while (!nodeRegions.isEmpty()) { - value = null; - ITextRegion region = nodeRegions.remove(0); - if (region == null) { - continue; - } - String type = region.getType(); - // if (type == CSSRegionContexts.CSS_DECLARATION_DELIMITER || type - // == CSSRegionContexts.CSS_RBRACE) { - // break; - // } - switch (status) { - case S_NORMAL : - if (type == CSSRegionContexts.CSS_DECLARATION_VALUE_FUNCTION) { - regionBuf.add(region); - status = S_FUNCTION; - } - else if (bFont && type == CSSRegionContexts.CSS_DECLARATION_VALUE_OPERATOR && fParentRegion.getText(region).equals("/")) { //$NON-NLS-1$ - value = createPrimitiveValue(region); - status = S_FONT_SLASH; - } - else if (!isBlank(type)) { - value = createPrimitiveValue(region); - } - break; - case S_FUNCTION : - if (type == CSSRegionContexts.CSS_DECLARATION_VALUE_PARENTHESIS_CLOSE) { - regionBuf.add(region); - value = createPrimitiveValue(regionBuf); - regionBuf.clear(); - status = S_NORMAL; - } - else if (!isBlank(type)) { - regionBuf.add(region); - } - break; - case S_FONT_SLASH : - if (type == CSSRegionContexts.CSS_DECLARATION_VALUE_DIMENSION) { - value = createPrimitiveValue(region); - status = S_COMMA_SEPARATION; - } - else if (!isBlank(type)) { - value = createPrimitiveValue(region); - } - break; - case S_COMMA_SEPARATION : - if (type == CSSRegionContexts.CSS_DECLARATION_VALUE_OPERATOR && fParentRegion.getText(region).equals(",")) { //$NON-NLS-1$ - value = createPrimitiveValue(regionBuf); - regionBuf.clear(); - if (value != null) { - if (fUpdateContext == null || !fUpdateContext.isActive()) { - item.appendValue(value); - } - } - value = createPrimitiveValue(region); - } - else { - regionBuf.add(region); - } - break; - default : - break; - } - if (value != null) { - if (fUpdateContext == null || !fUpdateContext.isActive()) { - item.appendValue(value); - } - } - } - if (!regionBuf.isEmpty()) { - value = createPrimitiveValue(regionBuf); - if (fUpdateContext == null || !fUpdateContext.isActive()) { - item.appendValue(value); - } - } - } - - private String getCollapsedText(ITextRegion region) { - if (fParentRegion == null) - return ""; //$NON-NLS-1$ - StringBuffer text = new StringBuffer(fParentRegion.getFullText(region)); - if (region.getLength() > region.getTextLength()) - text.replace(region.getTextLength(), region.getLength(), " "); //$NON-NLS-1$ - return text.toString(); - } - - private String getText(ITextRegion region) { - return (fParentRegion != null) ? fParentRegion.getText(region) : ""; //$NON-NLS-1$ - } - - private static boolean isBlank(String type) { - return (type == CSSRegionContexts.CSS_S || type == CSSRegionContexts.CSS_COMMENT || type == CSSRegionContexts.CSS_DECLARATION_VALUE_S); - } - -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSDocumentImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSDocumentImpl.java deleted file mode 100644 index e3a543bc83..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSDocumentImpl.java +++ /dev/null @@ -1,163 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.document; - - - -import org.eclipse.wst.css.core.internal.provisional.document.ICSSCharsetRule; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSDocument; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSImportRule; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSMediaRule; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSModel; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSPageRule; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSPrimitiveValue; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclItem; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclaration; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleRule; -import org.w3c.dom.css.CSSFontFaceRule; -import org.w3c.dom.css.CSSPrimitiveValue; -import org.w3c.dom.css.CSSRule; -import org.w3c.dom.css.CSSUnknownRule; -import org.w3c.dom.stylesheets.MediaList; - - -/** - * - */ -abstract class CSSDocumentImpl extends CSSStructuredDocumentRegionContainer implements ICSSDocument { - - private CSSModelImpl fModel = null; - - /** - * CSSDocumentImpl constructor comment. - */ - CSSDocumentImpl() { - super(); - } - - - CSSDocumentImpl(CSSDocumentImpl that) { - super(that); - } - - ICSSNode createCSSAttr(String name) { - CSSAttrImpl attr = new CSSAttrImpl(name); - attr.setOwnerDocument(this); - - return attr; - } - - /** - * @return org.w3c.dom.css.CSSCharsetRule - */ - public ICSSCharsetRule createCSSCharsetRule() { - return null; - } - - /** - * @return org.w3c.dom.css.CSSFontFaceRule - */ - public CSSFontFaceRule createCSSFontFaceRule() { - return null; - } - - /** - * @return org.w3c.dom.css.CSSImportRule - */ - public ICSSImportRule createCSSImportRule() { - return null; - } - - /** - * @return org.w3c.dom.css.ICSSMediaRule - */ - public ICSSMediaRule createCSSMediaRule() { - return null; - } - - /** - * @return org.w3c.dom.css.CSSPageRule - */ - public ICSSPageRule createCSSPageRule() { - return null; - } - - /** - * @return org.w3c.dom.css.CSSPrimitiveValue - */ - public ICSSPrimitiveValue createCSSPrimitiveValue(short primitiveType) { - CSSPrimitiveValueImpl value = null; - if (primitiveType == CSSPrimitiveValue.CSS_COUNTER) - value = new CounterImpl(); - else if (primitiveType == CSSPrimitiveValue.CSS_RECT) - value = new RectImpl(); - else if (primitiveType == CSSPrimitiveValue.CSS_RGBCOLOR) - value = new RGBColorImpl(); - else - value = new CSSPrimitiveValueImpl(primitiveType); - value.setOwnerDocument(this); - - return value; - } - - /** - * @return org.w3c.dom.css.CSSRule - * @param rule - * java.lang.String - */ - public CSSRule createCSSRule(String rule) { - return null; - } - - /** - * @return org.w3c.dom.css.CSSStyleDeclaration - */ - public ICSSStyleDeclaration createCSSStyleDeclaration() { - return null; - } - - public ICSSStyleDeclItem createCSSStyleDeclItem(String propertyName) { - CSSStyleDeclItemImpl item = new CSSStyleDeclItemImpl(propertyName); - item.setOwnerDocument(this); - - return item; - } - - /** - * @return org.w3c.dom.css.CSSStyleRule - */ - public ICSSStyleRule createCSSStyleRule() { - return null; - } - - /** - * @return org.w3c.dom.css.CSSUnknownRule - */ - public CSSUnknownRule createCSSUnknownRule() { - return null; - } - - /** - * @return org.w3c.dom.stylesheets.MediaList - */ - public MediaList createMediaList() { - return null; - } - - public ICSSModel getModel() { - return fModel; - } - - void setModel(CSSModelImpl model) { - this.fModel = model; - } -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSFontFaceRuleImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSFontFaceRuleImpl.java deleted file mode 100644 index 10cd9f7f61..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSFontFaceRuleImpl.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.document; - - - -import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode; -import org.w3c.dom.css.CSSFontFaceRule; - - -/** - * - */ -class CSSFontFaceRuleImpl extends CSSRuleDeclContainer implements CSSFontFaceRule { - - /** - * - */ - CSSFontFaceRuleImpl() { - super(); - } - - CSSFontFaceRuleImpl(CSSFontFaceRuleImpl that) { - super(that); - } - - public ICSSNode cloneNode(boolean deep) { - CSSFontFaceRuleImpl cloned = new CSSFontFaceRuleImpl(this); - - if (deep) - cloneChildNodes(cloned, deep); - - return cloned; - } - - /** - * @return java.lang.String - */ - String extractPreString() { - return "@font-face";//$NON-NLS-1$ - } - - /** - * @return short - */ - public short getNodeType() { - return FONTFACERULE_NODE; - } - - /** - * The type of the rule, as defined above. The expectation is that - * binding-specific casting methods can be used to cast down from an - * instance of the CSSRule interface to the specific - * derived interface implied by the type. - */ - public short getType() { - return FONT_FACE_RULE; - } -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSImportRuleImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSImportRuleImpl.java deleted file mode 100644 index 4fa385b825..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSImportRuleImpl.java +++ /dev/null @@ -1,227 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.document; - - - -import org.eclipse.wst.css.core.internal.Logger; -import org.eclipse.wst.css.core.internal.provisional.adapters.IModelProvideAdapter; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSImportRule; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSModel; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleSheet; -import org.eclipse.wst.css.core.internal.util.CSSLinkConverter; -import org.eclipse.wst.css.core.internal.util.CSSUtil; -import org.eclipse.wst.css.core.internal.util.URLModelProviderCSS; -import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier; -import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode; -import org.w3c.dom.DOMException; -import org.w3c.dom.css.CSSStyleSheet; -import org.w3c.dom.stylesheets.MediaList; - - -/** - * currently public but may be made default access protected in future. - */ -public class CSSImportRuleImpl extends CSSRuleImpl implements ICSSImportRule { - - private boolean fDirty = true; - private ICSSStyleSheet fStyleSheet; - - /** - * currently public but may be made default access protected in future. - */ - public CSSImportRuleImpl() { - super(); - } - /** - * currently public but may be made default access protected in future. - */ - public CSSImportRuleImpl(CSSImportRuleImpl that) { - super(that); - } - - public ICSSNode cloneNode(boolean deep) { - CSSImportRuleImpl cloned = new CSSImportRuleImpl(this); - - if (deep) - cloneChildNodes(cloned, deep); - - return cloned; - } - - /** - * - */ - void closeStyleSheet() { - if (fStyleSheet != null) { - ICSSStyleSheet sheet = fStyleSheet; - fStyleSheet = null; // to prevent loop, we must reset fStyleSheet - // before all closing action - - sheet.getModel().removeStyleListener(getOwnerDocument().getModel()); - // get ModelProvideAdapter - IModelProvideAdapter adapter = (IModelProvideAdapter) getAdapterFor(IModelProvideAdapter.class); - // if (getOwnerDocument().getModel().getStyleSheetType() == - // ICSSModel.EMBEDDED) { // case STYLE tag - // adapter = (ModelProvideAdapter) - // ((INodeNotifier)getOwnerDocument().getModel().getOwnerDOMNode()).getAdapterFor(ModelProvideAdapter.class); - // } - if (adapter != null) - adapter.modelRemoved(sheet.getModel()); - - sheet.getModel().releaseFromRead(); - } - } - - /** - * The location of the style sheet to be imported. The attribute will not - * contain the "url(...)" specifier around the URI. - */ - public String getHref() { - return CSSUtil.extractUriContents(getAttribute(HREF)); - } - - /** - * A list of media types for which this style sheet may be used. - */ - public org.w3c.dom.stylesheets.MediaList getMedia() { - ICSSNode media = getFirstChild(); - if (media != null) { - if (media instanceof MediaList) { - return (MediaList) media; - } - } - - // THIS CASE IS ERROR CASE - return null; - } - - /** - * @return short - */ - public short getNodeType() { - return IMPORTRULE_NODE; - } - - /** - * The style sheet referred to by this rule, if it has been loaded. The - * value of this attribute is null if the style sheet has - * not yet been loaded or if it will not be loaded (e.g. if the style - * sheet is for a media type not supported by the user agent). - */ - public CSSStyleSheet getStyleSheet() { - - if (fDirty) { - // NOTE: try/catch block is a TEMP fix to avoid compile errors: - try { - closeStyleSheet(); - - if (getHref() == null || getHref().length() <= 0) { - fDirty = false; - return null; - } - - IStructuredModel baseModel = getOwnerDocument().getModel(); - if (getOwnerDocument().getModel().getStyleSheetType() == ICSSModel.EMBEDDED) { // case - // STYLE - // tag - baseModel = ((IDOMNode) getOwnerDocument().getModel().getOwnerDOMNode()).getModel(); - } - // get ModelProvideAdapter - IModelProvideAdapter adapter = (IModelProvideAdapter) getAdapterFor(IModelProvideAdapter.class); - // if (getOwnerDocument().getModel().getStyleSheetType() == - // ICSSModel.EMBEDDED) { // case STYLE tag - // adapter = (ModelProvideAdapter) - // ((INodeNotifier)getOwnerDocument().getModel().getOwnerDOMNode()).getAdapterFor(ModelProvideAdapter.class); - // } - - // load model from IModelManager - URLModelProviderCSS provider = new URLModelProviderCSS(); - IStructuredModel newModel = provider.getModelForRead(baseModel, getHref()); - fDirty = false; - - if (newModel == null) - return null; - if (!(newModel instanceof ICSSModel)) { - newModel.releaseFromRead(); - return null; - } - - // notify adapter - if (adapter != null) - adapter.modelProvided(newModel); - - fStyleSheet = (ICSSStyleSheet) ((ICSSModel) newModel).getDocument(); - if (fStyleSheet != null) - fStyleSheet.getModel().addStyleListener(getOwnerDocument().getModel()); - } - catch (java.io.IOException e) { - Logger.logException(e); - } - } - return fStyleSheet; - } - - /** - * The type of the rule, as defined above. The expectation is that - * binding-specific casting methods can be used to cast down from an - * instance of the CSSRule interface to the specific - * derived interface implied by the type. - */ - public short getType() { - return IMPORT_RULE; - } - - /** - * - */ - public void refreshStyleSheet() { - if (!fDirty) { - closeStyleSheet(); - fDirty = true; - notify(INodeNotifier.CHANGE, getAttributeNode(HREF), null, null, getStartOffset()); - } - } - - /** - */ - void releaseRule() { - if (fStyleSheet != null) { - ICSSStyleSheet sheet = fStyleSheet; - fStyleSheet = null; // to prevent loop, we must reset fStyleSheet - // before all closing action - - sheet.getModel().removeStyleListener(getOwnerDocument().getModel()); - // get ModelProvideAdapter - IModelProvideAdapter adapter = (IModelProvideAdapter) getAdapterFor(IModelProvideAdapter.class); - // if (getOwnerDocument().getModel().getStyleSheetType() == - // ICSSModel.EMBEDDED) { // case STYLE tag - // adapter = (ModelProvideAdapter) - // ((INodeNotifier)getOwnerDocument().getModel().getOwnerDOMNode()).getAdapterFor(ModelProvideAdapter.class); - // } - if (adapter != null) - adapter.modelReleased(sheet.getModel()); - - sheet.getModel().releaseFromRead(); - } - } - - /** - * @param href - * java.lang.String - */ - public void setHref(String href) throws DOMException { - fDirty = true; - setAttribute(HREF, CSSLinkConverter.addFunc(href)); - } -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSMediaRuleImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSMediaRuleImpl.java deleted file mode 100644 index 0175c877e3..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSMediaRuleImpl.java +++ /dev/null @@ -1,230 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.document; - - - -import org.eclipse.wst.css.core.internal.provisional.document.ICSSMediaRule; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode; -import org.w3c.dom.DOMException; -import org.w3c.dom.css.CSSRule; -import org.w3c.dom.css.CSSRuleList; -import org.w3c.dom.stylesheets.MediaList; - - -/** - * - */ -class CSSMediaRuleImpl extends CSSRuleImpl implements ICSSMediaRule { - - /** - * - */ - CSSMediaRuleImpl() { - super(); - } - - CSSMediaRuleImpl(CSSMediaRuleImpl that) { - super(that); - } - - /** - * @return org.w3c.dom.css.CSSRule - * @param rule - * org.w3c.dom.css.CSSRule - * @exception org.w3c.dom.DOMException - * The exception description. - */ - public org.w3c.dom.css.CSSRule appendRule(org.w3c.dom.css.CSSRule rule) throws org.w3c.dom.DOMException { - if (rule == null) - return null; - - CSSRule ret = (CSSRule) appendChild((CSSNodeImpl) rule); - return ret; - } - - public ICSSNode cloneNode(boolean deep) { - CSSMediaRuleImpl cloned = new CSSMediaRuleImpl(this); - - if (deep) - cloneChildNodes(cloned, deep); - - return cloned; - } - - /** - * Used to delete a rule from the media block. - * - * @param index - * The index within the media block's rule collection of the - * rule to remove. - * @exception DOMException - * INDEX_SIZE_ERR: Raised if the specified index does not - * correspond to a rule in the media rule list.
- * NO_MODIFICATION_ALLOWED_ERR: Raised if this media rule - * is readonly. - */ - public void deleteRule(int index) throws DOMException { - CSSNodeImpl node = getIndexedRule(index); - if (node != null) - removeChild(node); - } - - /** - * A list of all CSS rules contained within the media block. - */ - public CSSRuleList getCssRules() { - CSSRuleListImpl list = new CSSRuleListImpl(); - - for (ICSSNode node = getFirstChild(); node != null; node = node.getNextSibling()) { - if (node instanceof CSSRule) - list.appendNode(node); - } - - return list; - } - - CSSRuleImpl getIndexedRule(int index) { - if (index < 0) - return null; - - int i = 0; - for (ICSSNode node = getFirstChild(); node != null; node = node.getNextSibling()) { - if (node instanceof CSSRule) { - if (i++ == index) - return (CSSRuleImpl) node; - } - } - return null; - } - - /** - * A list of media types for this rule. - */ - public MediaList getMedia() { - for (ICSSNode node = getFirstChild(); node != null; node = node.getNextSibling()) { - if (node instanceof MediaListImpl) - return (MediaList) node; - } - - return null; - } - - /** - * @return short - */ - public short getNodeType() { - return MEDIARULE_NODE; - } - - /** - * The type of the rule, as defined above. The expectation is that - * binding-specific casting methods can be used to cast down from an - * instance of the CSSRule interface to the specific - * derived interface implied by the type. - */ - public short getType() { - return MEDIA_RULE; - } - - /** - * Used to insert a new rule into the media block. - * - * @param rule - * The parsable text representing the rule. For rule sets this - * contains both the selector and the style declaration. For - * at-rules, this specifies both the at-identifier and the rule - * content. - * @param index - * The index within the media block's rule collection of the - * rule before which to insert the specified rule. If the - * specified index is equal to the length of the media blocks's - * rule collection, the rule will be added to the end of the - * media block. - * @return The index within the media block's rule collection of the newly - * inserted rule. - * @exception DOMException - * HIERARCHY_REQUEST_ERR: Raised if the rule cannot be - * inserted at the specified index, e.g., if an - * @import rule is inserted after a standard rule set or other - * at-rule.
- * INDEX_SIZE_ERR: Raised if the specified index is not a valid - * insertion point.
- * NO_MODIFICATION_ALLOWED_ERR: Raised if this media rule is - * readonly.
- * SYNTAX_ERR: Raised if the specified rule has a syntax error and - * is unparsable. - */ - public int insertRule(String rule, int index) throws DOMException { - int length = getCssRules().getLength(); - if (index < 0 || length < index) - throw new DOMException(DOMException.INDEX_SIZE_ERR, "");//$NON-NLS-1$ - - CSSRuleImpl refRule = (length != index) ? getIndexedRule(index) : null; - - CSSRuleImpl newRule = (CSSRuleImpl) getOwnerDocument().createCSSRule(rule); - - // prevent from nesting @media rule - if (newRule.getType() == CSSRule.MEDIA_RULE) - throw new DOMException(DOMException.SYNTAX_ERR, "");//$NON-NLS-1$ - - insertBefore(newRule, refRule); - - return index; - } - - /** - * @return org.w3c.dom.css.CSSRule - * @param newRule - * org.w3c.dom.css.CSSRule - * @param refRule - * org.w3c.dom.css.CSSRule - */ - public org.w3c.dom.css.CSSRule insertRuleBefore(org.w3c.dom.css.CSSRule newRule, org.w3c.dom.css.CSSRule refRule) throws org.w3c.dom.DOMException { - if (newRule == null && refRule == null) - return null; - - CSSRule ret = (CSSRule) insertBefore((CSSNodeImpl) newRule, (CSSNodeImpl) refRule); - return ret; - } - - /** - * @return org.w3c.dom.css.CSSRule - * @param rule - * org.w3c.dom.css.CSSRule - * @exception org.w3c.dom.DOMException - * The exception description. - */ - public org.w3c.dom.css.CSSRule removeRule(org.w3c.dom.css.CSSRule rule) throws org.w3c.dom.DOMException { - if (rule == null) - return null; - - CSSRule ret = (CSSRule) removeChild((CSSNodeImpl) rule); - return ret; - } - - /** - * @return org.w3c.dom.css.CSSRule - * @param newChild - * org.w3c.dom.css.CSSRule - * @param oldChild - * org.w3c.dom.css.CSSRule - * @exception org.w3c.dom.DOMException - * The exception description. - */ - public org.w3c.dom.css.CSSRule replaceRule(org.w3c.dom.css.CSSRule newRule, org.w3c.dom.css.CSSRule oldRule) throws org.w3c.dom.DOMException { - if (newRule == null && oldRule == null) - return null; - - CSSRule ret = (CSSRule) replaceChild((CSSNodeImpl) newRule, (CSSNodeImpl) oldRule); - return ret; - } -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelCreationContext.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelCreationContext.java deleted file mode 100644 index 8494a09af6..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelCreationContext.java +++ /dev/null @@ -1,155 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.document; - - - -import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; - - -/** - * currently public but may be made default access protected in future. - */ -public class CSSModelCreationContext { - - private CSSNodeImpl fRootNode = null; - private CSSNodeImpl fTargetNode = null; - private CSSNodeImpl fNextNode = null; - private int fReparseStart = -1; - private int fReparseEnd = -1; - - /** - * CSSModelContext constructor comment. - */ - CSSModelCreationContext(CSSNodeImpl rootNode) { - super(); - - fRootNode = rootNode; - } - - /** - * - */ - void clear() { - fNextNode = null; - fTargetNode = null; - resetReparseRange(); - } - - /** - * currently public but may be made default access protected in future. - */ - public CSSNodeImpl getNextNode() { - return fNextNode; - } - - /** - * - */ - int getReparseEnd() { - return fReparseEnd; - } - - /** - * - */ - int getReparseStart() { - return fReparseStart; - } - - /** - * - */ - CSSNodeImpl getRootNode() { - return fRootNode; - } - - /** - * currently public but may be made default access protected in future. - */ - public CSSNodeImpl getTargetNode() { - return fTargetNode; - } - - /** - * - */ - boolean isToReparse() { - return (0 <= getReparseStart() && 0 <= getReparseEnd()); - } - - /** - * - */ - void resetReparseRange() { - fReparseStart = fReparseEnd = -1; - } - - /** - * - */ - void setLast() { - fNextNode = null; - - if (!(fRootNode instanceof CSSStructuredDocumentRegionContainer)) { - fTargetNode = fRootNode; - } - else { - IStructuredDocumentRegion lastStructuredDocumentRegion = ((CSSStructuredDocumentRegionContainer) fRootNode).getLastStructuredDocumentRegion(); - CSSNodeImpl node = fRootNode; - while (node != null) { - ICSSNode lastChild = node.getLastChild(); - if (lastChild instanceof CSSStructuredDocumentRegionContainer && ((CSSStructuredDocumentRegionContainer) lastChild).getLastStructuredDocumentRegion() == lastStructuredDocumentRegion) { - node = (CSSNodeImpl) lastChild; - } - else { - break; - } - } - fTargetNode = node; - } - } - - /** - * - */ - void setNextNode(ICSSNode node) { - fNextNode = (CSSNodeImpl) node; - if (fNextNode != null) { - fTargetNode = (CSSNodeImpl) fNextNode.getParentNode(); - } - } - - /** - * - */ - void setReparseEnd(int end) { - fReparseEnd = end; - } - - /** - * - */ - void setReparseStart(int start) { - fReparseStart = start; - } - - /** - * - */ - void setTargetNode(ICSSNode node) { - fTargetNode = (CSSNodeImpl) node; - if (fNextNode != null && fNextNode.getParentNode() != fTargetNode) { - fNextNode = null; - } - } -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelDeletionContext.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelDeletionContext.java deleted file mode 100644 index 5858bec7ee..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelDeletionContext.java +++ /dev/null @@ -1,266 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.document; - - - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Enumeration; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; - -import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode; -import org.eclipse.wst.css.core.internal.util.CSSUtil; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegionList; - - -/** - * - */ -class CSSModelDeletionContext { - - private int fOldStart = -1; - private int fOldLength = 0; - private int fNewStart = -1; - private int fNewLength = 0; - private int fLengthDifference = 0; - // private ICSSNode fRootNode = null; - private int fRemovedRangeBegin = -1; - private int fRemovedRangeEnd = -1; - private CSSNodeListImpl fNodesToBeRemoved = new CSSNodeListImpl(); - private Set fOldRegionsList; - - /** - * CSSModelDeletionContext constructor comment. - */ - CSSModelDeletionContext(ICSSNode rootNode) { - super(); - - // fRootNode = rootNode; - } - - /** - * - */ - boolean addNodeToBeRemoved(ICSSNode node) { - int nNodes = fNodesToBeRemoved.getLength(); - for (int i = 0; i < nNodes; i++) { - ICSSNode parent = fNodesToBeRemoved.item(i); - if (CSSModelUtil.isParentOf(parent, node)) { - return false; - } - } - fNodesToBeRemoved.appendNode(node); - return true; - } - - /** - * - */ - void expandRemovedRangeBegin(IStructuredDocumentRegion flatNode) { - if (flatNode == null) { - return; - } - int newBegin = flatNode.getStart(); // fOldStart == fNewStart, right?? - if (fRemovedRangeBegin < 0 || newBegin < fRemovedRangeBegin) { - fRemovedRangeBegin = newBegin; - } - } - - /** - * - */ - void expandRemovedRangeEnd(IStructuredDocumentRegion flatNode) { - if (flatNode == null) { - return; - } - int newEnd = flatNode.getEnd() + ((isOldNode(flatNode)) ? fLengthDifference : 0); - if (fRemovedRangeEnd < 0 || fRemovedRangeEnd < newEnd) { - fRemovedRangeEnd = newEnd; - } - } - - /** - * - */ - private CSSStructuredDocumentRegionContainer findContainer(CSSNodeImpl parent, IStructuredDocumentRegion flatNode) { - if (parent instanceof CSSStructuredDocumentRegionContainer) { - // Am i a container of flatNode? - IStructuredDocumentRegion firstNode = ((CSSStructuredDocumentRegionContainer) parent).getFirstStructuredDocumentRegion(); - IStructuredDocumentRegion lastNode = ((CSSStructuredDocumentRegionContainer) parent).getLastStructuredDocumentRegion(); - int firstStart = getOriginalOffset(firstNode); - int lastStart = getOriginalOffset(lastNode); - int start = flatNode.getStart(); - - if (firstStart <= start && start <= lastStart) { - // I am a container, is my child a container ? - for (ICSSNode node = parent.getFirstChild(); node != null; node = node.getNextSibling()) { - if (node instanceof CSSNodeImpl) { - CSSStructuredDocumentRegionContainer container = findContainer((CSSNodeImpl) node, flatNode); - if (container != null) { - return container; - } - } - } - return (CSSStructuredDocumentRegionContainer) parent; - } - } - - return null; - } - - /** - * - */ - CSSStructuredDocumentRegionContainer findDeletionTarget(CSSNodeImpl parent, IStructuredDocumentRegion flatNode) { - CSSStructuredDocumentRegionContainer target = findContainer(parent, flatNode); - if (target == null) { - return null; - } - - // System.out.print(flatNode.toString() + ": "); - - // child a(=====)b(=====)c - // parent (================) a,c can remove parent, but b cannot. - - ICSSNode child; - - for (child = target.getFirstChild(); child != null && !(child instanceof CSSStructuredDocumentRegionContainer); child = child.getNextSibling()) { - // just advancing - } - - if (child == null) { - // System.out.println("target has no children."); // TESTBYCOZY - return target; // has no child containers. - } - else { - IStructuredDocumentRegion firstNode = ((CSSStructuredDocumentRegionContainer) child).getFirstStructuredDocumentRegion(); - if (flatNode.getStart() < getOriginalOffset(firstNode)) { - // System.out.println("flatNode is in front of first child"); - // // TESTBYCOZY - return target; // a - } - } - - for (child = target.getLastChild(); child != null && !(child instanceof CSSStructuredDocumentRegionContainer); child = child.getPreviousSibling()) { - // just advancing - } - - if (child == null) { - // System.out.println("target has no children."); // TESTBYCOZY - return target; // has no child containers. - } - else { - IStructuredDocumentRegion firstNode = ((CSSStructuredDocumentRegionContainer) child).getFirstStructuredDocumentRegion(); - if (getOriginalOffset(firstNode) < flatNode.getStart()) { - // System.out.println("flatNode is in after of last child"); - // // TESTBYCOZY - return target; // c - } - } - - // System.out.println("flatNode inner of children"); // TESTBYCOZY - return null; // b - } - - /** - * - */ - Iterator getNodesToBeRemoved() { - Collection nodes = new ArrayList(); - int nNodes = fNodesToBeRemoved.getLength(); - for (int i = 0; i < nNodes; i++) { - nodes.add(fNodesToBeRemoved.item(i)); - } - return nodes.iterator(); - } - - /** - * - */ - private int getOriginalOffset(IStructuredDocumentRegion flatNode) { - int offset = 0; - if (flatNode != null) { - offset = flatNode.getStart(); - if (0 <= fLengthDifference) { - if (fNewStart + fNewLength < offset) { - offset -= fLengthDifference; - } - } - else { - if (fOldStart + fOldLength <= offset || (fNewStart < 0 && fOldStart <= offset && !isOldNode(flatNode)) || (0 <= fNewStart && fNewStart + fNewLength <= offset && !isOldNode(flatNode))) { - offset -= fLengthDifference; - } - } - } - - return offset; - } - - /** - * - */ - int getRemovedRangeBegin() { - return fRemovedRangeBegin; - } - - /** - * - */ - int getRemovedRangeEnd() { - return fRemovedRangeEnd; - } - - /** - * - */ - private boolean isOldNode(IStructuredDocumentRegion flatNode) { - return fOldRegionsList.contains(flatNode); - } - - /** - * - */ - void setupContext(IStructuredDocumentRegionList newStructuredDocumentRegions, IStructuredDocumentRegionList oldStructuredDocumentRegions) { - IStructuredDocumentRegion flatNode = null; - fOldLength = CSSUtil.getTextLength(oldStructuredDocumentRegions); - if (oldStructuredDocumentRegions != null && 0 < oldStructuredDocumentRegions.getLength() && (flatNode = oldStructuredDocumentRegions.item(0)) != null) { - fOldStart = flatNode.getStart(); - } - else { - fOldStart = -1; - } - fNewLength = CSSUtil.getTextLength(newStructuredDocumentRegions); - if (newStructuredDocumentRegions != null && 0 < newStructuredDocumentRegions.getLength() && (flatNode = newStructuredDocumentRegions.item(0)) != null) { - fNewStart = flatNode.getStart(); - fRemovedRangeBegin = fNewStart; - fRemovedRangeEnd = fNewStart + fNewLength; - } - else { - fNewStart = -1; - fRemovedRangeBegin = fRemovedRangeEnd = -1; - } - fLengthDifference = fNewLength - fOldLength; - - fOldRegionsList = new HashSet(); - final Enumeration elements = oldStructuredDocumentRegions.elements(); - while (elements.hasMoreElements()) { - fOldRegionsList.add(elements.nextElement()); - } - // cleanup nodes - while (0 < fNodesToBeRemoved.getLength()) { - fNodesToBeRemoved.removeNode(0); - } - } -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelImpl.java deleted file mode 100644 index c8e7b5d941..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelImpl.java +++ /dev/null @@ -1,627 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2010 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.document; - - - -import java.util.Iterator; -import java.util.List; -import java.util.Vector; - -import org.eclipse.wst.css.core.internal.event.ICSSStyleListener; -import org.eclipse.wst.css.core.internal.eventimpl.CSSEmbededStyleNotifyAdapter; -import org.eclipse.wst.css.core.internal.eventimpl.CSSStyleNotifyAdapter; -import org.eclipse.wst.css.core.internal.parser.CSSSourceParser; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSAttr; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSDocument; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSImportRule; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSModel; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSSelector; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorList; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclaration; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleRule; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSValue; -import org.eclipse.wst.css.core.internal.util.ImportRuleCollector; -import org.eclipse.wst.css.core.internal.util.ImportedCollector; -import org.eclipse.wst.css.core.internal.util.SelectorsCollector; -import org.eclipse.wst.sse.core.internal.ltk.parser.RegionParser; -import org.eclipse.wst.sse.core.internal.model.AbstractStructuredModel; -import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; -import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion; -import org.eclipse.wst.sse.core.internal.provisional.events.IStructuredDocumentListener; -import org.eclipse.wst.sse.core.internal.provisional.events.NewDocumentEvent; -import org.eclipse.wst.sse.core.internal.provisional.events.NoChangeEvent; -import org.eclipse.wst.sse.core.internal.provisional.events.RegionChangedEvent; -import org.eclipse.wst.sse.core.internal.provisional.events.RegionsReplacedEvent; -import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentRegionsReplacedEvent; -import org.eclipse.wst.sse.core.internal.provisional.exceptions.ResourceInUse; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegionList; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList; -import org.eclipse.wst.sse.core.internal.util.Assert; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - - - -public class CSSModelImpl extends AbstractStructuredModel implements ICSSModel, IStructuredDocumentListener { - - private CSSDocumentImpl document = null; - private org.w3c.dom.Node ownerNode = null; - private CSSStyleNotifyAdapter styleNotifier = null; - private CSSModelParser fParser = null; - private CSSModelUpdater fUpdater = null; - private boolean fStructuredDocumentUpdate = false; - private final static String ID_NON_EXTERNAL_CSS = "**_NON_EXTERNAL_CSS_***";//$NON-NLS-1$ - - /** - * CSSModelImpl constructor comment. - * - */ - public CSSModelImpl() { - super(); - } - - /** - * @param listener - * org.eclipse.wst.css.core.event.CSSStyleListener - */ - public void addStyleListener(ICSSStyleListener listener) { - getStyleNotifier().addStyleListener(listener); - } - - void attrReplaced(CSSNodeImpl parentNode, CSSNodeImpl newAttr, CSSNodeImpl oldAttr) { - if (!fStructuredDocumentUpdate) { - CSSModelUpdater updater = getUpdater(); - updater.attrReplaced(parentNode, newAttr, oldAttr); - } - - ICSSSelector removed[] = null, added[] = null; - if (oldAttr != null && oldAttr.getNodeType() == ICSSNode.ATTR_NODE && ((CSSAttrImpl) oldAttr).getName().equals(ICSSStyleRule.SELECTOR)) { - CSSAttrImpl attr = (CSSAttrImpl) oldAttr; - // collect changed selector - ICSSSelectorList list = new CSSSelectorListImpl(attr.getValue()); - removed = new ICSSSelector[list.getLength()]; - for (int i = 0; i < list.getLength(); i++) - removed[i] = list.getSelector(i); - } - if (newAttr != null && newAttr.getNodeType() == ICSSNode.ATTR_NODE && ((CSSAttrImpl) newAttr).getName().equals(ICSSStyleRule.SELECTOR)) { - CSSAttrImpl attr = (CSSAttrImpl) newAttr; - // collect changed selector - ICSSSelectorList list = new CSSSelectorListImpl(attr.getValue()); - added = new ICSSSelector[list.getLength()]; - for (int i = 0; i < list.getLength(); i++) - added[i] = list.getSelector(i); - } - if (removed != null || added != null || getDocument().getNodeType() == ICSSNode.STYLEDECLARATION_NODE) { - getStyleNotifier().fire(removed, added, null); - } - // for href attribute - if (getStyleListeners() != null && getStyleListeners().size() > 0) { - boolean update = false; - if (oldAttr != null && oldAttr.getNodeType() == ICSSNode.ATTR_NODE && ((CSSAttrImpl) oldAttr).getName().equals(ICSSImportRule.HREF)) { - update = true; - } - if (newAttr != null && newAttr.getNodeType() == ICSSNode.ATTR_NODE && ((CSSAttrImpl) newAttr).getName().equals(ICSSImportRule.HREF)) { - update = true; - } - if (update) - ((ICSSImportRule) parentNode).getStyleSheet(); - } - } - - /** - * - */ - public void beginRecording(Object requester, String label, String description) { - getStyleNotifier().beginRecording(); - - Node node = getOwnerDOMNode(); - if (node != null && node instanceof IDOMNode) { - IStructuredModel model = ((IDOMNode) node).getModel(); - if (model != null) { - model.beginRecording(requester, label, description); - return; - } - } - super.beginRecording(requester, label, description); - } - - void childReplaced(CSSNodeImpl parentNode, CSSNodeImpl newChild, CSSNodeImpl oldChild) { - if (!fStructuredDocumentUpdate) { - CSSModelUpdater updater = getUpdater(); - updater.childReplaced(parentNode, newChild, oldChild); - } - - // always check and send selector event - ICSSSelector removed[] = null, added[] = null; - if (parentNode.getNodeType() == ICSSNode.STYLESHEET_NODE || parentNode.getNodeType() == ICSSNode.MEDIARULE_NODE) { - // collect old selectors - SelectorsCollector selTrav = new SelectorsCollector(); - selTrav.apply(oldChild); - int nSel = selTrav.getSelectors().size(); - if (nSel > 0) { - removed = new ICSSSelector[nSel]; - for (int i = 0; i < nSel; i++) - removed[i] = (ICSSSelector) selTrav.getSelectors().get(i); - } - // collect new selectors - selTrav = new SelectorsCollector(); - selTrav.apply(newChild); - nSel = selTrav.getSelectors().size(); - if (nSel > 0) { - added = new ICSSSelector[nSel]; - for (int i = 0; i < nSel; i++) - added[i] = (ICSSSelector) selTrav.getSelectors().get(i); - } - } - else { - // modification - ICSSNode rule = parentNode; - while (rule != null) { - if (rule instanceof ICSSStyleRule) - break; - rule = rule.getParentNode(); - } - if (rule != null) { - ICSSSelectorList list = ((ICSSStyleRule) rule).getSelectors(); - added = new ICSSSelector[list.getLength()]; - for (int i = 0; i < list.getLength(); i++) - added[i] = list.getSelector(i); - } - } - if (removed != null || added != null || getDocument().getNodeType() == ICSSNode.STYLEDECLARATION_NODE) { - // send selector changed event - getStyleNotifier().fire(removed, added, null); - } - // close removed import-rule's external style sheets - { - ImportRuleCollector trav = new ImportRuleCollector(); - trav.apply(oldChild); - Iterator it = trav.getRules().iterator(); - while (it.hasNext()) { - ((CSSImportRuleImpl) it.next()).closeStyleSheet(); - } - } - // send events to listener for new import-rules - if (getStyleListeners() != null && getStyleListeners().size() > 0) { - ImportedCollector trav = new ImportedCollector(); - trav.apply(newChild); - } - } - - /** - * - */ - private void closeImported() { - if (!isShared()) { - // release listeners - if (getStyleListeners() != null) { - Vector toRemove = new Vector(getStyleListeners()); - Iterator it = toRemove.iterator(); - while (it.hasNext()) { - removeStyleListener((ICSSStyleListener) it.next()); - } - } - // close import rules - ImportRuleCollector trav = new ImportRuleCollector(); - trav.apply(getDocument()); - Iterator it2 = trav.getRules().iterator(); - while (it2.hasNext()) { - ((CSSImportRuleImpl) it2.next()).releaseRule(); - } - } - } - - private CSSDocumentImpl createDocument() { - CSSDocumentImpl doc = null; - int parserMode = CSSSourceParser.MODE_STYLESHEET; - if (ownerNode == null) { - // this case is external CSS file - doc = (CSSStyleSheetImpl) DOMCSSImpl.createCSSStyleSheet(null, null); // parameters - // are - // for - // STYLE-tag - parserMode = CSSSourceParser.MODE_STYLESHEET; - } - else if (ownerNode instanceof org.w3c.dom.Element && ((Element) ownerNode).getTagName().toUpperCase().equals("STYLE")) {//$NON-NLS-1$ - // this case is STYLE-tag - Element style = (Element) ownerNode; - doc = (CSSStyleSheetImpl) DOMCSSImpl.createCSSStyleSheet(style.getAttribute("TITLE"), //$NON-NLS-1$ - style.getAttribute("MEDIA"));//$NON-NLS-1$ - parserMode = CSSSourceParser.MODE_STYLESHEET; - } - else if (ownerNode instanceof org.w3c.dom.Element || ownerNode instanceof org.w3c.dom.Attr) { - // Inline attributes - doc = (CSSStyleDeclarationImpl) DOMCSSImpl.createCSSStyleDeclaration(); - parserMode = CSSSourceParser.MODE_DECLARATION; - } - RegionParser regionParser = getStructuredDocument().getParser(); - if (regionParser instanceof CSSSourceParser) { - ((CSSSourceParser) regionParser).setParserMode(parserMode); - } - return doc; - } - - /** - * - */ - public void endRecording(Object requester) { - Node node = getOwnerDOMNode(); - if (node != null && node instanceof IDOMNode) { - IStructuredModel model = ((IDOMNode) node).getModel(); - if (model != null) { - model.endRecording(requester); - return; - } - } - super.endRecording(requester); - - getStyleNotifier().endRecording(); - } - - public ICSSDocument getDocument() { - if (document == null) { - this.document = createDocument(); - this.document.setModel(this); - } - return this.document; - } - - public IStructuredDocument getStructuredDocument() { - IStructuredDocument structuredDocument = null; - structuredDocument = super.getStructuredDocument(); - if (structuredDocument != null) - return structuredDocument; - - // the first time - Assert.isNotNull(getModelHandler()); - structuredDocument = (IStructuredDocument) getModelHandler().getDocumentLoader().createNewStructuredDocument(); - - setStructuredDocument(structuredDocument); - return structuredDocument; - } - - /** - * getNode method comment. - */ - public IndexedRegion getIndexedRegion(int offset) { - if (getDocument() == null) - return null; - return ((CSSStructuredDocumentRegionContainer) getDocument()).getContainerNode(offset); - } - - /** - * @return org.w3c.dom.Node - */ - public Node getOwnerDOMNode() { - return ownerNode; - } - - /** - * @param ownerNode - * org.w3c.dom.Node if the case of external CSS model, you - * should set null, else if internal css, you should set - * STYLE-tag node, else if inline css, you should set the - * element that is the owner of style-attribute. - */ - public void setOwnerDOMNode(Node node) { - // prohibit owner change - Assert.isTrue(ownerNode == null); - ownerNode = node; - if (ownerNode != null) { // for internal/inline CSS context - try { - setId(ID_NON_EXTERNAL_CSS); - } - catch (ResourceInUse e) { - // impossible - } - } - } - - /** - * currently public but may be made default access protected in future. - */ - protected CSSModelParser getParser() { - if (fParser == null) { - if (getDocument() != null) { - fParser = new CSSModelParser(document); - } - } - return fParser; - } - - /** - * @return java.util.List - */ - public List getStyleListeners() { - return getStyleNotifier().getStyleListeners(); - } - - /** - * - * @return java.lang.Object - */ - public java.lang.Object getStyleSheetType() { - if (getDocument() instanceof ICSSStyleDeclaration) - return INLINE; - if (getOwnerDOMNode() != null) - return EMBEDDED; - else - return EXTERNAL; - } - - private CSSStyleNotifyAdapter getStyleNotifier() { - if (styleNotifier == null) { - styleNotifier = (ownerNode != null) ? new CSSEmbededStyleNotifyAdapter(this) : new CSSStyleNotifyAdapter(this); - } - return styleNotifier; - } - - /** - * - */ - private CSSModelUpdater getUpdater() { - if (fUpdater == null) { - fUpdater = new CSSModelUpdater(this); - fUpdater.setParser(getParser()); - } - return fUpdater; - } - - /** - */ - public boolean isRecording() { - return getStyleNotifier().isRecording(); - } - - /** - * This function returns true if there are other references to the - * underlying model. - */ - public boolean isShared() { - return (getStyleSheetType() == EXTERNAL) && super.isShared(); - } - - public void newModel(NewDocumentEvent structuredDocumentEvent) { - if (structuredDocumentEvent == null) - return; - IStructuredDocument structuredDocument = structuredDocumentEvent.getStructuredDocument(); - if (structuredDocument == null) - return; - // this should not happen, but for the case - if (structuredDocument != getStructuredDocument()) - setStructuredDocument(structuredDocument); - IStructuredDocumentRegionList flatNodes = structuredDocument.getRegionList(); - if (flatNodes == null) - return; - if (getDocument() == null) - return; - - fStructuredDocumentUpdate = true; - - ((CSSStructuredDocumentRegionContainer) getDocument()).removeChildNodes(); - - CSSModelParser parser = getParser(); - parser.setStructuredDocumentEvent(structuredDocumentEvent); - parser.replaceStructuredDocumentRegions(flatNodes, null); - - fStructuredDocumentUpdate = false; - } - - /** - * noChange method comment. - */ - public void noChange(NoChangeEvent structuredDocumentEvent) { - // nop - } - - public void nodesReplaced(StructuredDocumentRegionsReplacedEvent structuredDocumentEvent) { - if (structuredDocumentEvent == null) { - return; - } - IStructuredDocumentRegionList oldStructuredDocumentRegions = structuredDocumentEvent.getOldStructuredDocumentRegions(); - IStructuredDocumentRegionList newStructuredDocumentRegions = structuredDocumentEvent.getNewStructuredDocumentRegions(); - if (oldStructuredDocumentRegions == null && newStructuredDocumentRegions == null) { - return; - } - - fStructuredDocumentUpdate = true; - - CSSModelParser parser = getParser(); - parser.setStructuredDocumentEvent(structuredDocumentEvent); - if (structuredDocumentEvent.isEntireDocumentReplaced()) - parser.replaceDocument(newStructuredDocumentRegions); - else - parser.replaceStructuredDocumentRegions(newStructuredDocumentRegions, oldStructuredDocumentRegions); - - fStructuredDocumentUpdate = false; - } - - /** - * cleanup -> rebuild CSS Nodes This is pre-beta fix for 178176. - */ - public void refreshNodes() { - // cleanup old nodes - fStructuredDocumentUpdate = true; - ((CSSStructuredDocumentRegionContainer) getDocument()).removeChildNodes(); - fStructuredDocumentUpdate = false; - - getParser().cleanupUpdateContext(); - - IStructuredDocument structuredDocument = getStructuredDocument(); - String source = structuredDocument.getText(); - - structuredDocument.replaceText(this, 0, source.length(), null); - structuredDocument.replaceText(this, 0, 0, source); - } - - public void regionChanged(RegionChangedEvent structuredDocumentEvent) { - if (structuredDocumentEvent == null) { - return; - } - IStructuredDocumentRegion flatNode = structuredDocumentEvent.getStructuredDocumentRegion(); - if (flatNode == null) { - return; - } - ITextRegion region = structuredDocumentEvent.getRegion(); - if (region == null) { - return; - } - - fStructuredDocumentUpdate = true; - - CSSModelParser parser = getParser(); - parser.setStructuredDocumentEvent(structuredDocumentEvent); - parser.changeRegion(flatNode, region); - - fStructuredDocumentUpdate = false; - } - - public void regionsReplaced(RegionsReplacedEvent structuredDocumentEvent) { - if (structuredDocumentEvent == null) - return; - IStructuredDocumentRegion flatNode = structuredDocumentEvent.getStructuredDocumentRegion(); - if (flatNode == null) - return; - ITextRegionList oldRegions = structuredDocumentEvent.getOldRegions(); - ITextRegionList newRegions = structuredDocumentEvent.getNewRegions(); - if (oldRegions == null && newRegions == null) - return; - - fStructuredDocumentUpdate = true; - - CSSModelParser parser = getParser(); - parser.setStructuredDocumentEvent(structuredDocumentEvent); - parser.replaceRegions(flatNode, newRegions, oldRegions); - - fStructuredDocumentUpdate = false; - - } - - /** - * - */ - public void releaseFromEdit() { - closeImported(); - if (getStyleSheetType() == EXTERNAL) { - super.releaseFromEdit(); - } - } - - /** - * - */ - public void releaseFromRead() { - closeImported(); - if (getStyleSheetType() == EXTERNAL) { - super.releaseFromRead(); - } - } - - /** - * @param listener - * org.eclipse.wst.css.core.event.CSSStyleListener - */ - public void removeStyleListener(ICSSStyleListener listener) { - getStyleNotifier().removeStyleListener(listener); - } - - public void setStructuredDocument(IStructuredDocument newStructuredDocument) { - IStructuredDocument oldStructuredDocument = super.getStructuredDocument(); - if (newStructuredDocument == oldStructuredDocument) - return; // noting to do - - if (oldStructuredDocument != null) - oldStructuredDocument.removeDocumentChangingListener(this); - super.setStructuredDocument(newStructuredDocument); - - if (newStructuredDocument != null) { - if (newStructuredDocument.getLength() > 0) { - newModel(new NewDocumentEvent(newStructuredDocument, this)); - } - newStructuredDocument.addDocumentChangingListener(this); - } - } - - /** - * @param srcModel - * com.imb.sed.css.mode.intefaces.ICSSModel - * @param removed - * org.eclipse.wst.css.core.model.interfaces.ICSSSelector[] - * @param added - * org.eclipse.wst.css.core.model.interfaces.ICSSSelector[] - */ - public void styleChanged(ICSSModel srcModel, ICSSSelector[] removed, ICSSSelector[] added, String media) { - getStyleNotifier().styleChanged(srcModel, removed, added, media); - } - - /** - * @param srcModel - * org.eclipse.wst.css.core.model.interfaces.ICSSModel - */ - public void styleUpdate(ICSSModel srcModel) { - getStyleNotifier().styleUpdate(srcModel); - } - - void valueChanged(CSSNodeImpl node, String oldValue) { - if (!fStructuredDocumentUpdate) { - CSSModelUpdater updater = getUpdater(); - updater.valueChanged(node, oldValue); - } - - ICSSSelector removed[] = null, added[] = null; - if (node != null) { - if (node.getNodeType() == ICSSNode.ATTR_NODE && ((CSSAttrImpl) node).getName().equals(ICSSStyleRule.SELECTOR)) { - CSSAttrImpl attr = (CSSAttrImpl) node; - // collect changed selector - ICSSSelectorList list = new CSSSelectorListImpl(attr.getValue()); - added = new ICSSSelector[list.getLength()]; - for (int i = 0; i < list.getLength(); i++) - added[i] = list.getSelector(i); - - // get old value - list = new CSSSelectorListImpl(oldValue); - removed = new ICSSSelector[list.getLength()]; - for (int i = 0; i < list.getLength(); i++) - removed[i] = list.getSelector(i); - } - else if (node instanceof ICSSValue) { - ICSSNode rule = node; - while (rule != null) { - if (rule instanceof ICSSStyleRule) - break; - rule = rule.getParentNode(); - } - if (rule != null) { - ICSSSelectorList list = ((ICSSStyleRule) rule).getSelectors(); - added = new ICSSSelector[list.getLength()]; - for (int i = 0; i < list.getLength(); i++) - added[i] = list.getSelector(i); - } - } - } - if (removed != null || added != null || getDocument().getNodeType() == ICSSNode.STYLEDECLARATION_NODE) { - // send selector changed event - getStyleNotifier().fire(removed, added, null); - } - // for href attribute - if (getStyleListeners() != null && getStyleListeners().size() > 0) { - if (node != null && node.getNodeType() == ICSSNode.ATTR_NODE && ((CSSAttrImpl) node).getName().equals(ICSSImportRule.HREF)) { - ((ICSSImportRule) ((ICSSAttr) node).getOwnerCSSNode()).getStyleSheet(); - } - } - } -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelNodeFeeder.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelNodeFeeder.java deleted file mode 100644 index d6e6486406..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelNodeFeeder.java +++ /dev/null @@ -1,126 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.document; - -import org.eclipse.wst.css.core.internal.provisional.document.ICSSDocument; - - -/** - * - */ -class CSSModelNodeFeeder { - /** - * currently ICSSDocument is used but may go back to CSSDocumentImpl in future. - */ - ICSSDocument fDocument = null; - CSSModelUpdateContext fUpdateContext = null; - - /** - * CSSModelNodeFeeder constructor comment. - */ - CSSModelNodeFeeder() { - super(); - } - - /** - * CSSModelNodeFeeder constructor comment. - * currently ICSSDocument is used but may go back to CSSDocumentImpl in future. - */ - CSSModelNodeFeeder(ICSSDocument document, CSSModelUpdateContext updateContext) { - super(); - fDocument = document; - fUpdateContext = updateContext; - } - - /** - * - */ - CSSCharsetRuleImpl getCSSCharsetRule() { - CSSCharsetRuleImpl node; - if (fUpdateContext.isActive()) { - node = fUpdateContext.getCSSCharsetRule(); - } - else { - node = (CSSCharsetRuleImpl) fDocument.createCSSCharsetRule(); - } - return node; - } - - /** - * - */ - CSSFontFaceRuleImpl getCSSFontFaceRule() { - CSSFontFaceRuleImpl node; - if (fUpdateContext.isActive()) { - node = fUpdateContext.getCSSFontFaceRule(); - } - else { - node = (CSSFontFaceRuleImpl) fDocument.createCSSFontFaceRule(); - } - return node; - } - - /** - * - */ - CSSImportRuleImpl getCSSImportRule() { - CSSImportRuleImpl node; - if (fUpdateContext.isActive()) { - node = fUpdateContext.getCSSImportRule(); - } - else { - node = (CSSImportRuleImpl) fDocument.createCSSImportRule(); - } - return node; - } - - /** - * - */ - CSSMediaRuleImpl getCSSMediaRule() { - CSSMediaRuleImpl node; - if (fUpdateContext.isActive()) { - node = fUpdateContext.getCSSMediaRule(); - } - else { - node = (CSSMediaRuleImpl) fDocument.createCSSMediaRule(); - } - return node; - } - - /** - * - */ - CSSPageRuleImpl getCSSPageRule() { - CSSPageRuleImpl node; - if (fUpdateContext.isActive()) { - node = fUpdateContext.getCSSPageRule(); - } - else { - node = (CSSPageRuleImpl) fDocument.createCSSPageRule(); - } - return node; - } - - /** - * - */ - CSSStyleRuleImpl getCSSStyleRule() { - CSSStyleRuleImpl node; - if (fUpdateContext.isActive()) { - node = fUpdateContext.getCSSStyleRule(); - } - else { - node = (CSSStyleRuleImpl) fDocument.createCSSStyleRule(); - } - return node; - } -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelParser.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelParser.java deleted file mode 100644 index a9e971e221..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelParser.java +++ /dev/null @@ -1,1317 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2010 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.document; - -import java.util.Collection; -import java.util.Enumeration; -import java.util.HashSet; -import java.util.Iterator; - -import org.eclipse.wst.css.core.internal.parserz.CSSRegionContexts; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSCharsetRule; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSDocument; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSImportRule; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSMediaRule; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSModel; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSPageRule; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSRuleContainer; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclItem; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleRule; -import org.eclipse.wst.css.core.internal.text.StructuredDocumentWalker; -import org.eclipse.wst.css.core.internal.util.CSSUtil; -import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegionList; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList; -import org.eclipse.wst.sse.core.internal.text.BasicStructuredDocumentRegion; -import org.eclipse.wst.sse.core.internal.text.CoreNodeList; -import org.eclipse.wst.sse.core.internal.text.TextRegionListImpl; -import org.eclipse.wst.sse.core.internal.util.Assert; -import org.w3c.dom.css.CSSFontFaceRule; -import org.w3c.dom.css.CSSRule; -import org.w3c.dom.css.CSSStyleDeclaration; - - -/** - * currently public but may be made default access protected in future. - */ -public class CSSModelParser { - - private ICSSDocument fDocument = null; - private CSSModelCreationContext fCreationContext = null; - private CSSModelDeletionContext fDeletionContext = null; - private CSSModelUpdateContext fUpdateContext = null; - private CSSModelNodeFeeder fFeeder = null; - private StructuredDocumentWalker fStructuredDocumentWalker = null; - private boolean fParseFloating = false; - - /** - * CSSModelParser constructor comment. - */ - private CSSModelParser() { - super(); - } - - /** - * currently provded this method but may be removed in future. - */ - protected boolean isParseFloating(){ - return fParseFloating; - } - /** - * currently provded this method but may be removed in future. - */ - protected CSSModelCreationContext getCreationContext(){ - return fCreationContext; - } - /** - * currently provded this method but may be removed in future. - */ - protected boolean isUpdateContextActive(){ - return fUpdateContext != null ? fUpdateContext.isActive() : false; - } - /** - * currently public but may be made default access protected in future. - */ - public CSSModelParser(ICSSDocument doc) { - this(); - fDocument = doc; - fCreationContext = new CSSModelCreationContext((CSSNodeImpl)doc); - fDeletionContext = new CSSModelDeletionContext(doc); - fUpdateContext = new CSSModelUpdateContext(); - fFeeder = new CSSModelNodeFeeder(doc, fUpdateContext); - } - - /** - * - */ - void changeStructuredDocumentRegion(IStructuredDocumentRegion flatNode) { - replaceStructuredDocumentRegions(new CoreNodeList(flatNode, flatNode), new CoreNodeList(flatNode, flatNode)); - } - - /** - * - */ - void changeRegion(IStructuredDocumentRegion flatNode, ITextRegion region) { - if (flatNode == null || region == null) { - return; - } - if (fDocument == null) { - return; - } - - changeStructuredDocumentRegion(flatNode); - } - - /** - * - */ - private void checkNextNode(IStructuredDocumentRegion flatNode, String type) { - IStructuredDocumentRegion next = CSSUtil.findNextSignificantNode(flatNode); - if (CSSUtil.getStructuredDocumentRegionType(next) == type) { - fCreationContext.setReparseStart(flatNode.getEnd()); - fCreationContext.setReparseEnd(next.getEnd()); - } - } - - /** - * - */ - private void cleanupDeletionContext() { - // setupDeletionContext(null); - } - - /** - * - */ - boolean cleanupFirstNode(IStructuredDocumentRegion firstNode, CSSStructuredDocumentRegionContainer target) { - if (firstNode == null || target == null) { - return false; - } - - if (firstNode == target.getFirstStructuredDocumentRegion()) { - IStructuredDocumentRegion nextNode = fStructuredDocumentWalker.getNextNodeInCurrent(firstNode); - IStructuredDocumentRegion lastNode = target.getLastStructuredDocumentRegion(); - if (lastNode == null || fStructuredDocumentWalker.isOldNode(lastNode) || nextNode == null || lastNode.getStartOffset() < nextNode.getStartOffset()) { - target.setRangeStructuredDocumentRegion(null, null); - } - else { - target.setFirstStructuredDocumentRegion(nextNode); - } - ICSSNode parent = target.getParentNode(); - if (parent instanceof CSSStructuredDocumentRegionContainer) { - cleanupFirstNode(firstNode, (CSSStructuredDocumentRegionContainer) parent); - return true; - } - } - - return false; - } - - /** - * - */ - boolean cleanupLastNode(IStructuredDocumentRegion lastNode, CSSStructuredDocumentRegionContainer target) { - if (lastNode == null || target == null) { - return false; - } - - if (lastNode == target.getLastStructuredDocumentRegion()) { - IStructuredDocumentRegion prevNode = fStructuredDocumentWalker.getPrevNodeInCurrent(lastNode); - IStructuredDocumentRegion firstNode = target.getFirstStructuredDocumentRegion(); - if (firstNode == null || fStructuredDocumentWalker.isOldNode(firstNode) || prevNode == null || prevNode.getStartOffset() < firstNode.getStartOffset()) { - target.setRangeStructuredDocumentRegion(null, null); - } - else { - target.setLastStructuredDocumentRegion(prevNode); - } - ICSSNode parent = target.getParentNode(); - if (parent instanceof CSSStructuredDocumentRegionContainer) { - cleanupLastNode(lastNode, (CSSStructuredDocumentRegionContainer) parent); - return true; - } - } - - return false; - } - - /** - * - */ - int cleanupUpdateContext() { - int remains = fUpdateContext.getNodeCount(); - fUpdateContext.cleanupContext(); - return remains; - } - - /** - * create floating CSS rule (owner document will be set) this is for - * CSSStyleSheet.createCSSRule(String) - * - * @return org.w3c.dom.css.CSSRule - */ - CSSRule createCSSRule(IStructuredDocumentRegionList flatNodes) { - if (flatNodes == null) { - return null; - } - - fParseFloating = true; - - // setup creation context - fCreationContext.clear(); - fCreationContext.setTargetNode(null); - fCreationContext.setNextNode(null); - CSSRuleImpl parentRule = null; - - for (Enumeration e = flatNodes.elements(); e.hasMoreElements();) { - IStructuredDocumentRegion flatNode = (IStructuredDocumentRegion) e.nextElement(); - if (flatNode == null) { - continue; - } - CSSNodeImpl modified = insertStructuredDocumentRegion(flatNode); - if (parentRule == null && modified instanceof CSSRuleImpl) { - parentRule = (CSSRuleImpl) modified; - } - } - - fParseFloating = false; - - if (parentRule != null) { - CSSModelUtil.cleanupContainer(parentRule); - } - - return parentRule; - } - - /** - * - */ - private IStructuredDocumentRegion findBraceClose(int depth, IStructuredDocumentRegion start, boolean bBreakSibling) { - IStructuredDocumentRegion result = null; - int braceLevel = 0; - IStructuredDocumentRegion prevNode = null; - IStructuredDocumentRegion region = start.getNext(); - for (; region != null; region = region.getNext()) { - int offset = region.getStart(); - if (offset < 0) { - Assert.isTrue(false); - break; - } - CSSNodeImpl node = getNodeAt(offset); - int depthHit = (node != null) ? CSSModelUtil.getDepth(node) : -1; - if (depth <= depthHit) { - // sibling is found before "}" - if (bBreakSibling) { - CSSNodeImpl parent = (CSSNodeImpl) node.getParentNode(); - while (depth <= CSSModelUtil.getDepth(parent)) { - node = parent; - parent = (CSSNodeImpl) parent.getParentNode(); - } - if (parent != null && node != null) { - parent.removeChild(node); - } - } - else { - result = prevNode; - break; - } - } - String type = CSSUtil.getStructuredDocumentRegionType(region); - if (type == CSSRegionContexts.CSS_LBRACE) { - braceLevel++; - } - if (type == CSSRegionContexts.CSS_RBRACE) { - braceLevel--; - if (braceLevel < 0) { - result = region; - break; - } - } - prevNode = region; - } - - if (result == null && region == null) { - // reach the end of document - result = prevNode; - } - - return result; - } - - /** - * - */ - private IStructuredDocumentRegionList getStructuredDocumentRegionList(int start, int end) { - IStructuredDocumentRegionList nodeList = null; - if (0 <= start && start <= end) { - ICSSModel model = fDocument.getModel(); - if (model instanceof CSSModelImpl) { - IStructuredDocument structuredDocument = ((CSSModelImpl) model).getStructuredDocument(); - if (structuredDocument != null) { - IStructuredDocumentRegion startNode = structuredDocument.getRegionAtCharacterOffset(start); - IStructuredDocumentRegion endNode = structuredDocument.getRegionAtCharacterOffset(end - 1); - if (startNode != null && endNode != null) { - nodeList = new CoreNodeList(startNode, endNode); - } - } - } - } - - return nodeList; - } - - /** - * - */ - private CSSNodeImpl getNodeAt(int offset) { - CSSNodeImpl rootNode = fCreationContext.getRootNode(); - ICSSNode target = rootNode.getNodeAt(offset); - if (target instanceof CSSNodeImpl) { - return (CSSNodeImpl) target; - } - else { - return null; - } - } - - /** - * - */ - private CSSNodeImpl insertBraceClose(IStructuredDocumentRegion region) { - ICSSNode target = CSSModelUtil.findBraceContainer(fCreationContext.getTargetNode()); - - if (!(target instanceof CSSStructuredDocumentRegionContainer)) { - return null; - } - - CSSStructuredDocumentRegionContainer parent = (CSSStructuredDocumentRegionContainer) target; - if (CSSModelUtil.isInterruption(parent, region)) { - ICSSNode node = parent.getParentNode(); - if (node instanceof CSSNodeImpl) { - fCreationContext.setReparseStart(parent.getStartOffset()); - fCreationContext.setReparseEnd(parent.getEndOffset()); - ((CSSNodeImpl) node).removeChild(parent); - } - return null; - } - - if (parent instanceof ICSSPageRule || parent instanceof ICSSMediaRule || parent instanceof CSSFontFaceRule || parent instanceof ICSSStyleRule) { - CSSModelUtil.expandStructuredDocumentRegionContainer(parent, region); - if (!CSSModelUtil.isBraceClosed(target)) { - fCreationContext.setTargetNode(parent.getParentNode()); - fCreationContext.setNextNode(parent.getNextSibling()); - return parent; - } - } - - return null; - } - - /** - * - */ - private CSSNodeImpl insertBraceOpen(IStructuredDocumentRegion region) { - IStructuredDocumentRegion keyRegion = CSSUtil.findPreviousSignificantNode(region); - if (keyRegion == null) { - return null; - } - if (!fParseFloating) { - CSSNodeImpl node = getNodeAt(keyRegion.getStartOffset()); - if (node != null && !(node instanceof ICSSRuleContainer)) { - return null; - } - } - String type = CSSUtil.getStructuredDocumentRegionType(keyRegion); - - CSSNodeImpl inserted = null; - if (type == CSSRegionContexts.CSS_PAGE) { - inserted = insertPageRule(keyRegion, region); - } - else if (type == CSSRegionContexts.CSS_MEDIA) { - inserted = insertMediaRule(keyRegion, region); - } - else if (type == CSSRegionContexts.CSS_FONT_FACE) { - inserted = insertFontFaceRule(keyRegion, region); - } - else if (CSSUtil.isSelectorText(keyRegion)) { - inserted = insertStyleRule(keyRegion, region); - } - - if (inserted instanceof CSSStructuredDocumentRegionContainer) { - // CSSModelUtil.expandStructuredDocumentRegionContainer((CSSStructuredDocumentRegionContainer)inserted, - // flatNode); - IStructuredDocumentRegion braceClose = findBraceClose(CSSModelUtil.getDepth(inserted), region, (type == CSSRegionContexts.CSS_MEDIA)); - if (braceClose != null) { - fCreationContext.setReparseStart(region.getEnd()); - fCreationContext.setReparseEnd(braceClose.getEnd()); - } - } - - return inserted; - } - - /** - * - */ - private CSSNodeImpl insertCharsetRule(IStructuredDocumentRegion beginDocRegion, IStructuredDocumentRegion endDocRegion) { - CSSNodeImpl parent = fCreationContext.getTargetNode(); - if (!fParseFloating && !(parent instanceof ICSSRuleContainer)) { - return null; - } - - ITextRegionList regions = new TextRegionListImpl(beginDocRegion.getRegions()); - regions.remove(0); // must be "@charset" - ITextRegion encodingRegion = null; - while (!regions.isEmpty()) { - ITextRegion textRegion = regions.remove(0); - if (textRegion == null) { - continue; - } - String type = textRegion.getType(); - if (type == CSSRegionContexts.CSS_S || type == CSSRegionContexts.CSS_COMMENT) { - continue; - } - if (type == CSSRegionContexts.CSS_STRING) { - encodingRegion = textRegion; - break; - } - else { - break; - } - } - if (encodingRegion == null) { - return null; - } - - CSSCharsetRuleImpl rule = fFeeder.getCSSCharsetRule(); - if (rule == null) { - return null; - } - - if (!fUpdateContext.isActive()) { - rule.setAttribute(ICSSCharsetRule.ENCODING, beginDocRegion.getText(encodingRegion)); - } - - // setup flat container - rule.setRangeStructuredDocumentRegion(beginDocRegion, endDocRegion); - CSSAttrImpl attr = rule.getAttributeNode(ICSSCharsetRule.ENCODING); - if (attr != null) { - attr.setRangeRegion(beginDocRegion, encodingRegion, encodingRegion); - } - - // insert to tree - if (!fUpdateContext.isActive() && parent != null) { - propagateRangePreInsert(parent, rule); - CSSNodeImpl next = fCreationContext.getNextNode(); - if (next != null) { - parent.insertBefore(rule, next); - } - else { - parent.appendChild(rule); - } - } - - return rule; - } - - /** - * currently public but may be made default access protected in future. - */ - protected CSSNodeImpl insertStructuredDocumentRegion(IStructuredDocumentRegion region) { - if (fCreationContext == null || region == null) { - return null; - } - - String type = ((BasicStructuredDocumentRegion) region).getType(); - CSSNodeImpl modified = null; - - ICSSNode target = fCreationContext.getTargetNode(); - - if ((fParseFloating && target == null) || target instanceof ICSSRuleContainer) { - if (type == CSSRegionContexts.CSS_DELIMITER) { - modified = insertSemiColonForRule(region); - } - else if (type == CSSRegionContexts.CSS_LBRACE) { - modified = insertBraceOpen(region); - } - else if (type == CSSRegionContexts.CSS_RBRACE) { - modified = insertBraceClose(region); - } - else if (type == CSSRegionContexts.CSS_MEDIA || type == CSSRegionContexts.CSS_PAGE || type == CSSRegionContexts.CSS_FONT_FACE || CSSUtil.isSelectorText(region)) { - checkNextNode(region, CSSRegionContexts.CSS_LBRACE); - } - else if (type == CSSRegionContexts.CSS_IMPORT || type == CSSRegionContexts.CSS_CHARSET) { - checkNextNode(region, CSSRegionContexts.CSS_DELIMITER); - } - } - else if ((target instanceof CSSRuleDeclContainer || target instanceof CSSStyleDeclaration) && type == CSSRegionContexts.CSS_DECLARATION_PROPERTY) { - modified = insertStyleDeclarationItem(region); - } - else if (target instanceof ICSSStyleDeclItem && type == CSSRegionContexts.CSS_DECLARATION_DELIMITER) { - modified = insertSemiColonForStyleDeclarationItem(region); - } - else if (type == CSSRegionContexts.CSS_RBRACE) { - modified = insertBraceClose(region); - } - - // post process - if (modified != null) { - if (modified instanceof CSSStructuredDocumentRegionContainer) { - ((CSSStructuredDocumentRegionContainer) modified).propagateRangeStructuredDocumentRegion(); - } - } - - return modified; - } - - /** - * - */ - private void insertStructuredDocumentRegions(IStructuredDocumentRegionList regionList) { - for (Enumeration e = regionList.elements(); e.hasMoreElements();) { - IStructuredDocumentRegion region = (IStructuredDocumentRegion) e.nextElement(); - if (region == null) { - continue; - } - insertStructuredDocumentRegion(region); - if (fCreationContext.isToReparse()) { - int origStart = region.getEnd(); - int origEnd = regionList.item(regionList.getLength() - 1).getEnd(); - int newStart = fCreationContext.getReparseStart(); - int newEnd = fCreationContext.getReparseEnd(); - if (newStart < origStart || origEnd < newEnd) { - IStructuredDocumentRegionList newNodeList = getStructuredDocumentRegionList(newStart, newEnd); - setupCreationContext(newNodeList.item(0)); - insertStructuredDocumentRegions(newNodeList); - return; - } - else { - fCreationContext.resetReparseRange(); - } - } - } - } - - /** - * - */ - private CSSNodeImpl insertFontFaceRule(IStructuredDocumentRegion region, IStructuredDocumentRegion braceNode) { - CSSNodeImpl parent = fCreationContext.getTargetNode(); - if (!fParseFloating && !(parent instanceof ICSSRuleContainer)) { - return null; - } - - CSSFontFaceRuleImpl rule = fFeeder.getCSSFontFaceRule(); - if (rule == null) { - return null; - } - - // setup flat container - rule.setRangeStructuredDocumentRegion(region, braceNode); - - // insert to tree - if (!fUpdateContext.isActive() && parent != null) { - propagateRangePreInsert(parent, rule); - CSSNodeImpl next = fCreationContext.getNextNode(); - if (next != null) { - parent.insertBefore(rule, next); - } - else { - parent.appendChild(rule); - } - } - - fCreationContext.setTargetNode(rule); - // TargetNext is set to null automatically - - return rule; - } - - /** - * - */ - private CSSNodeImpl insertImportRule(IStructuredDocumentRegion beginDocRegion, IStructuredDocumentRegion endDocRegion) { - CSSNodeImpl parent = fCreationContext.getTargetNode(); - if (!fParseFloating && !(parent instanceof ICSSRuleContainer)) { - return null; - } - - ITextRegionList regions = new TextRegionListImpl(beginDocRegion.getRegions()); - regions.remove(0); // must be "@import" - ITextRegion hrefRegion = null; - while (!regions.isEmpty()) { - ITextRegion textRegion = regions.remove(0); - if (textRegion == null) { - continue; - } - String type = textRegion.getType(); - if (type == CSSRegionContexts.CSS_S || type == CSSRegionContexts.CSS_COMMENT) { - continue; - } - if (type == CSSRegionContexts.CSS_URI || type == CSSRegionContexts.CSS_STRING) { - hrefRegion = textRegion; - break; - } - else { - break; - } - } - if (hrefRegion == null) { - return null; - } - - CSSImportRuleImpl rule = fFeeder.getCSSImportRule(); - if (rule == null) { - return null; - } - - CSSUtil.stripSurroundingSpace(regions); - MediaListImpl mediaList = (MediaListImpl) rule.getMedia(); - setMediaList(mediaList, beginDocRegion, regions); - - if (!fUpdateContext.isActive()) { - rule.setAttribute(ICSSImportRule.HREF, beginDocRegion.getText(hrefRegion)); - } - - // setup flat container - rule.setRangeStructuredDocumentRegion(beginDocRegion, endDocRegion); - CSSAttrImpl attr = rule.getAttributeNode(ICSSImportRule.HREF); - if (attr != null) { - attr.setRangeRegion(beginDocRegion, hrefRegion, hrefRegion); - } - - // insert to tree - if (!fUpdateContext.isActive() && parent != null) { - propagateRangePreInsert(parent, rule); - CSSNodeImpl next = fCreationContext.getNextNode(); - if (next != null) { - parent.insertBefore(rule, next); - } - else { - parent.appendChild(rule); - } - } - - return rule; - } - - /** - * - */ - private CSSNodeImpl insertMediaRule(IStructuredDocumentRegion flatNode, IStructuredDocumentRegion braceNode) { - CSSNodeImpl parent = fCreationContext.getTargetNode(); - if (!fParseFloating && !(parent instanceof ICSSRuleContainer)) { - return null; - } - - CSSMediaRuleImpl rule = fFeeder.getCSSMediaRule(); - if (rule == null) { - return null; - } - - ITextRegionList regions = new TextRegionListImpl(flatNode.getRegions()); - regions.remove(0); // must be "@media" - - CSSUtil.stripSurroundingSpace(regions); - MediaListImpl mediaList = (MediaListImpl) rule.getMedia(); - setMediaList(mediaList, flatNode, regions); - - // setup flat container - rule.setRangeStructuredDocumentRegion(flatNode, braceNode); - - // insert to tree - if (!fUpdateContext.isActive() && parent != null) { - propagateRangePreInsert(parent, rule); - CSSNodeImpl next = fCreationContext.getNextNode(); - if (next != null) { - parent.insertBefore(rule, next); - } - else { - parent.appendChild(rule); - } - } - - fCreationContext.setTargetNode(rule); - // TargetNext is set to null automatically - - return rule; - } - - /** - * - */ - private CSSNodeImpl insertPageRule(IStructuredDocumentRegion flatNode, IStructuredDocumentRegion braceNode) { - CSSNodeImpl parent = fCreationContext.getTargetNode(); - if (!fParseFloating && !(parent instanceof ICSSRuleContainer)) { - return null; - } - - // get selector regions - ITextRegionList selectorRegions = new TextRegionListImpl(flatNode.getRegions()); - selectorRegions.remove(0); // must be "@page" - CSSUtil.stripSurroundingSpace(selectorRegions); - - CSSPageRuleImpl rule = fFeeder.getCSSPageRule(); - if (rule == null) { - return null; - } - - if (!fUpdateContext.isActive()) { - String selectorStr = CSSUtil.getRegionText(flatNode, selectorRegions); - if (0 < selectorStr.length()) { - rule.setSelectorText(selectorStr); - } - } - - // setup flat container - rule.setRangeStructuredDocumentRegion(flatNode, braceNode); - CSSAttrImpl attr = rule.getAttributeNode(ICSSPageRule.SELECTOR); - if (attr != null && selectorRegions != null && !selectorRegions.isEmpty()) { - attr.setRangeRegion(flatNode, selectorRegions.get(0), selectorRegions.get(selectorRegions.size() - 1)); - } - - // insert to tree - if (!fUpdateContext.isActive() && parent != null) { - propagateRangePreInsert(parent, rule); - CSSNodeImpl next = fCreationContext.getNextNode(); - if (next != null) { - parent.insertBefore(rule, next); - } - else { - parent.appendChild(rule); - } - } - - fCreationContext.setTargetNode(rule); - // TargetNext is set to null automatically - - return rule; - } - - /** - * - */ - private CSSNodeImpl insertSemiColonForRule(IStructuredDocumentRegion region) { - IStructuredDocumentRegion keyRegion = CSSUtil.findPreviousSignificantNode(region); - String type = CSSUtil.getStructuredDocumentRegionType(keyRegion); - - CSSNodeImpl inserted = null; - if (type == CSSRegionContexts.CSS_IMPORT) { - inserted = insertImportRule(keyRegion, region); - } - else if (type == CSSRegionContexts.CSS_CHARSET) { - inserted = insertCharsetRule(keyRegion, region); - } - - return inserted; - } - - /** - * - */ - private CSSNodeImpl insertSemiColonForStyleDeclarationItem(IStructuredDocumentRegion region) { - // only target/net node is changed. nothing to do. - - CSSNodeImpl targetNode = fCreationContext.getTargetNode(); - if (targetNode instanceof ICSSStyleDeclItem) { - int offset = targetNode.getStartOffset(); - // widen document region range - // ((CSSStyleDeclItemImpl)targetNode).setLastStructuredDocumentRegion(region); - CSSModelUtil.expandStructuredDocumentRegionContainer((CSSStyleDeclItemImpl) targetNode, region); - // psStructuredDocumentRegion indicates CSSStyleDeclItem - ICSSNode parentNode = targetNode.getParentNode(); - fCreationContext.setTargetNode(parentNode); - ICSSNode next = null; - if (parentNode.hasChildNodes()) { - for (ICSSNode child = targetNode.getFirstChild(); child != null; child = child.getNextSibling()) { - if (child instanceof CSSStructuredDocumentRegionContainer && offset < ((CSSStructuredDocumentRegionContainer) child).getStartOffset()) { - next = child; - break; - } - } - } - fCreationContext.setNextNode(next); - - return targetNode; - } - - return null; - } - - /** - * - */ - private CSSNodeImpl insertStyleDeclarationItem(IStructuredDocumentRegion docRegion) { - CSSStyleDeclarationImpl parent = null; - CSSNodeImpl node = fCreationContext.getTargetNode(); - if (node instanceof CSSRuleDeclContainer) { - CSSRuleDeclContainer declContainer = (CSSRuleDeclContainer) node; - parent = (CSSStyleDeclarationImpl) declContainer.getStyle(); - } - else if (node instanceof CSSStyleDeclarationImpl) { - parent = (CSSStyleDeclarationImpl) node; - } - - CSSDeclarationItemParser itemParser = new CSSDeclarationItemParser(parent.getOwnerDocument()); - itemParser.setStructuredDocumentTemporary(false); - itemParser.setUpdateContext(fUpdateContext); - CSSStyleDeclItemImpl declItem = itemParser.setupDeclarationItem(docRegion); - if (declItem == null) { - return null; - } - - // setup flat container - declItem.setRangeStructuredDocumentRegion(docRegion, docRegion); - - // insert to tree - if (!fUpdateContext.isActive()) { - propagateRangePreInsert(parent, declItem); - CSSNodeImpl next = fCreationContext.getNextNode(); - if (next != null) { - parent.insertBefore(declItem, next); - } - else { - parent.appendChild(declItem); - } - } - - fCreationContext.setTargetNode(declItem); - // TargetNext is set to null automatically - - return declItem; - } - - /** - * - */ - private CSSNodeImpl insertStyleRule(IStructuredDocumentRegion flatNode, IStructuredDocumentRegion braceNode) { - CSSNodeImpl parent = fCreationContext.getTargetNode(); - if (!fParseFloating && !(parent instanceof ICSSRuleContainer)) { - return null; - } - - // get selector regions - ITextRegionList selectorRegions = new TextRegionListImpl(flatNode.getRegions()); - CSSUtil.stripSurroundingSpace(selectorRegions); - - CSSStyleRuleImpl rule = fFeeder.getCSSStyleRule(); - if (rule == null) { - return null; - } - - if (!fUpdateContext.isActive()) { - String selectorStr = CSSUtil.getRegionText(flatNode, selectorRegions); - if (selectorStr != null && 0 < selectorStr.length()) { - rule.setSelectorText(selectorStr); - } - } - - // setup flat container - rule.setRangeStructuredDocumentRegion(flatNode, braceNode); - CSSAttrImpl attr = rule.getAttributeNode(ICSSPageRule.SELECTOR); - if (attr != null && selectorRegions != null && !selectorRegions.isEmpty()) { - attr.setRangeRegion(flatNode, selectorRegions.get(0), selectorRegions.get(selectorRegions.size() - 1)); - } - - // insert to tree - if (!fUpdateContext.isActive() && parent != null) { - propagateRangePreInsert(parent, rule); - CSSNodeImpl next = fCreationContext.getNextNode(); - if (next != null) { - parent.insertBefore(rule, next); - } - else { - parent.appendChild(rule); - } - } - - fCreationContext.setTargetNode(rule); - // TargetNext is set to null automatically - - return rule; - } - - /** - * - */ - private void pretendRemoveNode() { - CSSStructuredDocumentRegionContainer node = (CSSStructuredDocumentRegionContainer) fUpdateContext.getDeletionTarget(); - if (node == null) { - return; - } - - IStructuredDocumentRegion firstNode = node.getFirstStructuredDocumentRegion(); - if (firstNode != null) { - fDeletionContext.expandRemovedRangeBegin(firstNode); - } - IStructuredDocumentRegion lastNode = node.getLastStructuredDocumentRegion(); - if (lastNode != null) { - fDeletionContext.expandRemovedRangeEnd(lastNode); - } - - shrinkContainer((CSSStructuredDocumentRegionContainer) fUpdateContext.getDeletionTargetParent(), node); - } - - /** - * currently public but may be made default access protected in future. - * - * @param parent - * org.eclipse.wst.css.core.model.CSSNodeImpl - * @param child - * org.eclipse.wst.css.core.model.CSSNodeImpl - */ - protected void propagateRangePreInsert(CSSNodeImpl parent, CSSNodeImpl child) { - if (!(child instanceof CSSStructuredDocumentRegionContainer) || !(parent instanceof CSSStructuredDocumentRegionContainer)) { - return; - } - - CSSStructuredDocumentRegionContainer parentContainer = (CSSStructuredDocumentRegionContainer) parent; - CSSStructuredDocumentRegionContainer childContainer = (CSSStructuredDocumentRegionContainer) child; - IStructuredDocumentRegion firstNode = childContainer.getFirstStructuredDocumentRegion(); - IStructuredDocumentRegion lastNode = childContainer.getLastStructuredDocumentRegion(); - if (firstNode == null || lastNode == null) { - return; - } - - boolean bModified = parentContainer.includeRangeStructuredDocumentRegion(firstNode, lastNode); - if (bModified) { - parentContainer.propagateRangeStructuredDocumentRegion(); - } - } - - /** - * - */ - private void removeStructuredDocumentRegion(IStructuredDocumentRegion flatNode) { - String type = CSSUtil.getStructuredDocumentRegionType(flatNode); - if (type == CSSRegionContexts.CSS_DELIMITER || type == CSSRegionContexts.CSS_DECLARATION_DELIMITER) { - do { - flatNode = fStructuredDocumentWalker.getPrevNode(flatNode); - type = (flatNode != null) ? CSSUtil.getStructuredDocumentRegionType(flatNode) : null; - } - while (type != null && (type == CSSRegionContexts.CSS_S || type == CSSRegionContexts.CSS_COMMENT)); - } - if (flatNode == null) { - return; - } - - // if (fDeletionContext.isInRemovedRange(flatNode)) { // already - // removed - // return; - // } - - CSSStructuredDocumentRegionContainer node = fDeletionContext.findDeletionTarget((CSSNodeImpl)fDocument, flatNode); - if (node == null || node == fDocument) { - return; // not attached with any treeNode - } - - if (node instanceof CSSStyleDeclarationImpl) { - ICSSNode rule = node.getParentNode(); - if (rule instanceof CSSStyleRuleImpl) { - node = (CSSStructuredDocumentRegionContainer) rule; - } - else { - return; - } - } - - // ICSSNode p = node.getParentNode(); - // if (p == null || ! (p instanceof - // CSSStructuredDocumentRegionContainer)) { - // return; - // } - // CSSStructuredDocumentRegionContainer parent = - // (CSSStructuredDocumentRegionContainer)p; - - if (fDeletionContext.addNodeToBeRemoved(node)) { - IStructuredDocumentRegion firstNode = node.getFirstStructuredDocumentRegion(); - if (firstNode != null) { - fDeletionContext.expandRemovedRangeBegin(firstNode); - } - IStructuredDocumentRegion lastNode = node.getLastStructuredDocumentRegion(); - if (lastNode != null) { - fDeletionContext.expandRemovedRangeEnd(lastNode); - } - } - - // shrinkContainer(node); - // parent.removeChild(node); - } - - /** - * - */ - private void removeStructuredDocumentRegions(IStructuredDocumentRegionList flatNodes) { - for (Enumeration e = flatNodes.elements(); e.hasMoreElements();) { - IStructuredDocumentRegion flatNode = (IStructuredDocumentRegion) e.nextElement(); - if (flatNode == null) { - continue; - } - removeStructuredDocumentRegion(flatNode); - } - - Iterator i = fDeletionContext.getNodesToBeRemoved(); - while (i.hasNext()) { - CSSNodeImpl node = (CSSNodeImpl) i.next(); - if (!(node instanceof CSSStructuredDocumentRegionContainer)) { - continue; - } - CSSNodeImpl parent = (CSSNodeImpl) node.getParentNode(); - if (!(parent instanceof CSSStructuredDocumentRegionContainer)) { - continue; - } - shrinkContainer((CSSStructuredDocumentRegionContainer) parent, (CSSStructuredDocumentRegionContainer) node); - parent.removeChild(node); - } - } - - void replaceDocument(IStructuredDocumentRegionList newStructuredDocumentRegions) { - if (fDocument == null || fCreationContext == null) - return; - ((CSSDocumentImpl) fDocument).removeChildNodes(); - - if (newStructuredDocumentRegions != null && 0 < newStructuredDocumentRegions.getLength()) { - setupCreationContext(newStructuredDocumentRegions.item(0)); - insertStructuredDocumentRegions(newStructuredDocumentRegions); - } - - IStructuredDocument structuredDocument = fStructuredDocumentWalker.getStructuredDocument(); - ((CSSStructuredDocumentRegionContainer)fDocument).setRangeStructuredDocumentRegion(structuredDocument.getFirstStructuredDocumentRegion(), structuredDocument.getLastStructuredDocumentRegion()); - } - - /** - * - */ - void replaceStructuredDocumentRegions(IStructuredDocumentRegionList newStructuredDocumentRegions, IStructuredDocumentRegionList oldStructuredDocumentRegions) { - if (fDocument == null || fCreationContext == null) { - return; - } - - if (oldStructuredDocumentRegions != null && 0 < oldStructuredDocumentRegions.getLength()) { - setupDeletionContext(newStructuredDocumentRegions, oldStructuredDocumentRegions); - short updateMode = fUpdateContext.getUpdateMode(); - if (updateMode == CSSModelUpdateContext.UPDATE_IDLE) { - removeStructuredDocumentRegions(oldStructuredDocumentRegions); - } - else { - pretendRemoveNode(); - } - newStructuredDocumentRegions = getStructuredDocumentRegionList(fDeletionContext.getRemovedRangeBegin(), fDeletionContext.getRemovedRangeEnd()); - cleanupDeletionContext(); - } - - if (newStructuredDocumentRegions != null && 0 < newStructuredDocumentRegions.getLength()) { - /* when removing old nodes the creation context should be set up based on them - * else creation context is that of the new nodes - */ - if( oldStructuredDocumentRegions != null && oldStructuredDocumentRegions.getLength() < 0) { - setupCreationContext(oldStructuredDocumentRegions.item(0)); - } else { - setupCreationContext(newStructuredDocumentRegions.item(0)); - } - insertStructuredDocumentRegions(newStructuredDocumentRegions); - } - - // make document hold whole structuredDocument - /* - * boolean bUpdate = false; IStructuredDocumentRegion flatNode; - * flatNode = fDocument.getFirstStructuredDocumentRegion(); bUpdate = - * bUpdate || (flatNode == null || - * fStructuredDocumentWalker.isOldNode(flatNode) || - * flatNode.getPrevious() != null); flatNode = - * fDocument.getLastStructuredDocumentRegion(); bUpdate = bUpdate || - * (flatNode == null || fStructuredDocumentWalker.isOldNode(flatNode) || - * flatNode.getNext() != null); - */ - IStructuredDocument structuredDocument = fStructuredDocumentWalker.getStructuredDocument(); - ((CSSStructuredDocumentRegionContainer)fDocument).setRangeStructuredDocumentRegion(structuredDocument.getFirstStructuredDocumentRegion(), structuredDocument.getLastStructuredDocumentRegion()); - /* } */ - - // remove in official release - // CSSModelUtil.diagnoseTree(fDocument, - // fStructuredDocumentWalker.getStructuredDocument()); - } - - /** - * - */ - void replaceRegions(IStructuredDocumentRegion flatNode, ITextRegionList newRegions, ITextRegionList oldRegions) { - if (flatNode == null) { - return; - } - if (newRegions == null || oldRegions == null) { - return; - } - if (fDocument == null) { - return; - } - - changeStructuredDocumentRegion(flatNode); - } - - /** - */ - private void resetCreationTarget(IStructuredDocumentRegion newStructuredDocumentRegion) { - if (newStructuredDocumentRegion == null || newStructuredDocumentRegion.getStartOffset() <= 0) { - // top of document - fCreationContext.setTargetNode(fDocument); - fCreationContext.setNextNode(fDocument.getFirstChild()); - return; - } - - int cursorPos = newStructuredDocumentRegion.getStartOffset(); - CSSNodeImpl cursorNode = getNodeAt(cursorPos); - if (cursorNode == null) { // end of document - cursorNode = (CSSNodeImpl)fDocument; - } - - // find edge of tree node - CSSNodeImpl node = null; - // boolean bOverSemiColon = false; - boolean bOverOpenBrace = false; - IStructuredDocumentRegion flatNode; - for (flatNode = newStructuredDocumentRegion; flatNode != null; flatNode = flatNode.getPrevious()) { - node = getNodeAt(flatNode.getStartOffset()); - if (node == null) { - node = (CSSNodeImpl)fDocument; - } - if (node != cursorNode || node.getStartOffset() == flatNode.getStartOffset()) { - break; - } - if (flatNode != newStructuredDocumentRegion) { - String type = CSSUtil.getStructuredDocumentRegionType(flatNode); - // if (type == CSSRegionContexts.CSS_DELIMITER || - // type == CSSRegionContexts.CSS_DECLARATION_DELIMITER) { - // bOverSemiColon = true; - // } else - if (type == CSSRegionContexts.CSS_LBRACE) { - bOverOpenBrace = true; - } - } - } - - CSSNodeImpl targetNode = null; - - // if (flatNode == null) { - // v<--| - // AAAAAA - // BBBBBBBBBB cursorNode:A , node:B -> target is A - // targetNode = (node == null) ? fDocument : node; - // } else - if (cursorNode == node) { - // v<--| - // AAAAAA - // BBBBBBBBBB cursorNode:A , node:B -> target is A - if (bOverOpenBrace && cursorNode instanceof CSSRuleDeclContainer) { - targetNode = (CSSNodeImpl) ((CSSRuleDeclContainer) cursorNode).getStyle(); - } - else { - targetNode = cursorNode; - } - } - else { - // v<--| - // AAA - // BBBBBBBBBB cursorNode:B , node:A -> depend on A's node type - short nodeType = node.getNodeType(); - if (nodeType == ICSSNode.STYLEDECLITEM_NODE || nodeType == ICSSNode.CHARSETRULE_NODE || nodeType == ICSSNode.IMPORTRULE_NODE) { - // targetNode = (CSSNodeImpl)((bOverSemiColon) ? - // node.getParentNode() : node); // NP - String regionType = CSSUtil.getStructuredDocumentRegionType(flatNode); - if (regionType == CSSRegionContexts.CSS_DELIMITER || regionType == CSSRegionContexts.CSS_DECLARATION_DELIMITER) { - targetNode = (CSSNodeImpl) node.getParentNode(); - } - else { - targetNode = node; - } - } - else if (CSSUtil.getStructuredDocumentRegionType(flatNode) == CSSRegionContexts.CSS_RBRACE) { - targetNode = (CSSNodeImpl) node.getParentNode(); - } - else { - targetNode = node; - } - } - - fCreationContext.setTargetNode(targetNode); - ICSSNode next = null; - if (targetNode.hasChildNodes()) { - for (ICSSNode child = targetNode.getFirstChild(); child != null; child = child.getNextSibling()) { - if (child instanceof CSSStructuredDocumentRegionContainer && cursorPos < ((CSSStructuredDocumentRegionContainer) child).getStartOffset()) { - next = child; - break; - } - } - } - fCreationContext.setNextNode(next); - - } - - /** - */ - private void resetReparseRange() { - fCreationContext.clear(); - } - - void setStructuredDocumentEvent(StructuredDocumentEvent event) { - if (fStructuredDocumentWalker == null) { - fStructuredDocumentWalker = new StructuredDocumentWalker(); - } - fStructuredDocumentWalker.initialize(event); - } - - /** - * regions: surrounding spaces should be removed. Q. Why did you set - * mediaTable ? A. MediaList may have two or more medium that have same - * value, then searcing in MediaList is not perfect. Q. - * fUpdateContext.isActive() is not care. Are you OK? A. OK. - */ - private void setMediaList(MediaListImpl mediaList, IStructuredDocumentRegion region, ITextRegionList textRegions) { - if (mediaList == null || textRegions == null) { - return; - } - Collection mediaTable = new HashSet(); - CSSNodeListImpl attrs = mediaList.getMedia(); - for (int i = 0; i != attrs.getLength(); i++) { - mediaTable.add(attrs.item(i)); - } - - ITextRegion start = null; - ITextRegion end = null; - - Iterator i = textRegions.iterator(); - ITextRegion textRegion = (ITextRegion) ((i.hasNext()) ? i.next() : null); - while (textRegion != null) { - if (textRegion.getType() == CSSRegionContexts.CSS_MEDIUM) { - String mediumStr = region.getText(textRegion); - if (0 < mediumStr.length()) { - CSSAttrImpl attr = null; - // is the medium already set ? - Iterator iTable = mediaTable.iterator(); - while (iTable.hasNext()) { - CSSAttrImpl cai = (CSSAttrImpl) iTable.next(); - if (mediumStr.equalsIgnoreCase(cai.getValue())) { - attr = cai; - mediaTable.remove(cai); - break; - } - } - if (attr == null) { - // is not set. create new attribute - String key = "mediumP" + mediaList.mediumCounter++; //$NON-NLS-1$ - mediaList.setAttribute(key, mediumStr); - attr = mediaList.getAttributeNode(key); - } - attr.setRangeRegion(region, textRegion, textRegion); - if (start == null) { - start = textRegion; - } - end = textRegion; - } - } - textRegion = (ITextRegion) ((i.hasNext()) ? i.next() : null); - } - - if (start != null && end != null) { - mediaList.setRangeRegion(region, start, end); - } - } - - /** - * - */ - private void setupCreationContext(IStructuredDocumentRegion region) { - resetReparseRange(); - resetCreationTarget(region); - } - - /** - * - */ - private void setupDeletionContext(IStructuredDocumentRegionList newStructuredDocumentRegions, IStructuredDocumentRegionList oldStructuredDocumentRegions) { - fDeletionContext.setupContext(newStructuredDocumentRegions, oldStructuredDocumentRegions); - } - - /** - * - */ - void setupUpdateContext(short updateMode, ICSSNode parentNode, ICSSNode targetNode) { - fUpdateContext.setupContext(updateMode, parentNode, targetNode); - } - - /** - * - */ - void shrinkContainer(CSSStructuredDocumentRegionContainer parent, CSSStructuredDocumentRegionContainer child) { - if (child == null) { - return; - } - - boolean bModified = false; - bModified = bModified || cleanupLastNode(child.getLastStructuredDocumentRegion(), parent); - bModified = bModified || cleanupFirstNode(child.getFirstStructuredDocumentRegion(), parent); - - if (bModified) { - if (parent != null) { - for (ICSSNode node = parent.getFirstChild(); node != null; node = node.getNextSibling()) { - if (child != node && node instanceof CSSStructuredDocumentRegionContainer) { - ((CSSStructuredDocumentRegionContainer) node).propagateRangeStructuredDocumentRegion(); - } - } - } - } - - child.setRangeStructuredDocumentRegion(null, null); - } -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelUpdateContext.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelUpdateContext.java deleted file mode 100644 index e7f4e9352d..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelUpdateContext.java +++ /dev/null @@ -1,416 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.document; - - - -import java.util.LinkedList; - -import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSPrimitiveValue; -import org.eclipse.wst.css.core.internal.util.AbstractCssTraverser; -import org.eclipse.wst.css.core.internal.util.CSSUtil; -import org.w3c.dom.DOMException; -import org.w3c.dom.css.CSSPrimitiveValue; - - -/** - * - */ -class CSSModelUpdateContext { - - - class CSSNodeUpdateTraverser extends AbstractCssTraverser { - public CSSNodeUpdateTraverser() { - super(); - setTraverseImported(false); - setTraverseImportFirst(false); - } - - public LinkedList getNodeList() { - return fTravNodeList; - } - - protected void begin(ICSSNode node) { - fTravNodeList = new LinkedList(); - } - - protected short preNode(ICSSNode node) { - if (node instanceof CSSStyleDeclarationImpl || node instanceof CSSAttrImpl || node instanceof MediaListImpl) { - // skip - } - else { - fTravNodeList.add(node); - } - if (node instanceof CSSPrimitiveContainer) { - return TRAV_PRUNE; - } - else { - return TRAV_CONT; - } - } - - LinkedList fTravNodeList = null; - } - - ICSSNode fLastNode = null; - ICSSNode fDeletionTargetParent = null; - ICSSNode fDeletionTarget = null; - LinkedList fNodeList = null; - private short fUpdateMode = UPDATE_IDLE; - static final short UPDATE_IDLE = 0; - static final short UPDATE_INSERT_FNCONTAINER = 1; - static final short UPDATE_INSERT_RCONTAINER = 2; - static final short UPDATE_REMOVE_FNCONTAINER = 3; - static final short UPDATE_REMOVE_RCONTAINER = 4; - static final short UPDATE_CHANGE_RCONTAINER = 5; - - /** - * CSSNodeUpdateQueue constructor comment. - */ - CSSModelUpdateContext() { - super(); - } - - /** - * - */ - void cleanupContext() { - fNodeList = null; - fDeletionTarget = null; - fDeletionTargetParent = null; - fUpdateMode = UPDATE_IDLE; - } - - /** - * - */ - CounterImpl getCounter() { - ICSSNode node = getNode(); - if (node instanceof CounterImpl) { - return (CounterImpl) node; - } - else { - CSSUtil.debugOut("CounterImpl is expected, but " + //$NON-NLS-1$ - CSSUtil.getClassString(node)); - ungetNode(); - throw new DOMException(DOMException.INVALID_MODIFICATION_ERR, "");//$NON-NLS-1$ - } - } - - /** - * - */ - CSSCharsetRuleImpl getCSSCharsetRule() { - ICSSNode node = getNode(); - if (node instanceof CSSCharsetRuleImpl) { - return (CSSCharsetRuleImpl) node; - } - else { - CSSUtil.debugOut("CSSCharsetRuleImpl is expected, but " + //$NON-NLS-1$ - CSSUtil.getClassString(node)); - ungetNode(); - throw new DOMException(DOMException.INVALID_MODIFICATION_ERR, "");//$NON-NLS-1$ - } - } - - /** - * - */ - CSSFontFaceRuleImpl getCSSFontFaceRule() { - ICSSNode node = getNode(); - if (node instanceof CSSFontFaceRuleImpl) { - return (CSSFontFaceRuleImpl) node; - } - else { - CSSUtil.debugOut("CSSFontFaceRuleImpl is expected, but " + //$NON-NLS-1$ - CSSUtil.getClassString(node)); - ungetNode(); - throw new DOMException(DOMException.INVALID_MODIFICATION_ERR, "");//$NON-NLS-1$ - } - } - - /** - * - */ - CSSImportRuleImpl getCSSImportRule() { - ICSSNode node = getNode(); - if (node instanceof CSSImportRuleImpl) { - return (CSSImportRuleImpl) node; - } - else { - CSSUtil.debugOut("CSSImportRuleImpl is expected, but " + //$NON-NLS-1$ - CSSUtil.getClassString(node)); - ungetNode(); - throw new DOMException(DOMException.INVALID_MODIFICATION_ERR, "");//$NON-NLS-1$ - } - } - - /** - * - */ - CSSMediaRuleImpl getCSSMediaRule() { - ICSSNode node = getNode(); - if (node instanceof CSSMediaRuleImpl) { - return (CSSMediaRuleImpl) node; - } - else { - CSSUtil.debugOut("CSSMediaRuleImpl is expected, but " + //$NON-NLS-1$ - CSSUtil.getClassString(node)); - ungetNode(); - throw new DOMException(DOMException.INVALID_MODIFICATION_ERR, "");//$NON-NLS-1$ - } - } - - /** - * - */ - CSSPageRuleImpl getCSSPageRule() { - ICSSNode node = getNode(); - if (node instanceof CSSPageRuleImpl) { - return (CSSPageRuleImpl) node; - } - else { - CSSUtil.debugOut("CSSPageRuleImpl is expected, but " + //$NON-NLS-1$ - CSSUtil.getClassString(node)); - ungetNode(); - throw new DOMException(DOMException.INVALID_MODIFICATION_ERR, "");//$NON-NLS-1$ - } - } - - /** - * - */ - CSSPrimitiveValueImpl getCSSPrimitiveValue(short type) { - ICSSNode node = getNode(); - if (node instanceof CSSPrimitiveValueImpl) { - short nodeType = ((CSSPrimitiveValueImpl) node).getPrimitiveType(); - if (nodeType == type || ((nodeType == CSSPrimitiveValue.CSS_NUMBER || nodeType == ICSSPrimitiveValue.CSS_INTEGER) && (type == CSSPrimitiveValue.CSS_NUMBER || type == ICSSPrimitiveValue.CSS_INTEGER))) { - return (CSSPrimitiveValueImpl) node; - } - } - - if (node instanceof CSSPrimitiveValueImpl) { - CSSPrimitiveValueImpl value = (CSSPrimitiveValueImpl) node; - CSSUtil.debugOut("CSSPrimitiveValueImpl [" + type + //$NON-NLS-1$ - "] is expected, but type is [" + //$NON-NLS-1$ - value.getPrimitiveType() + "]: \"" + value.generateSource() + "\"");//$NON-NLS-2$//$NON-NLS-1$ - } - else { - CSSUtil.debugOut("CSSPrimitiveValueImpl(" + type + //$NON-NLS-1$ - ") is expected, but " + //$NON-NLS-1$ - CSSUtil.getClassString(node)); - } - - ungetNode(); - throw new DOMException(DOMException.INVALID_MODIFICATION_ERR, "");//$NON-NLS-1$ - } - - /** - * - */ - CSSPrimitiveValueImpl getCSSPrimitiveValueAny() { - ICSSNode node = getNode(); - if (node instanceof CSSPrimitiveValueImpl) { - return (CSSPrimitiveValueImpl) node; - } - else { - CSSUtil.debugOut("CSSPrimitiveValueImpl is expected, but " + //$NON-NLS-1$ - CSSUtil.getClassString(node)); - ungetNode(); - throw new DOMException(DOMException.INVALID_MODIFICATION_ERR, "");//$NON-NLS-1$ - } - } - - /** - * - */ - CSSStyleDeclItemImpl getCSSStyleDeclItem(String propertyName) { - ICSSNode node = getNode(); - if (node instanceof CSSStyleDeclItemImpl && ((CSSStyleDeclItemImpl) node).getPropertyName().equalsIgnoreCase(propertyName)) { - return (CSSStyleDeclItemImpl) node; - } - else { - CSSUtil.debugOut("CSSStyleDeclItemImpl(" + propertyName + //$NON-NLS-1$ - ") is expected, but " + CSSUtil.getClassString(node));//$NON-NLS-1$ - ungetNode(); - throw new DOMException(DOMException.INVALID_MODIFICATION_ERR, "");//$NON-NLS-1$ - } - } - - /** - * - */ - CSSStyleRuleImpl getCSSStyleRule() { - ICSSNode node = getNode(); - if (node instanceof CSSStyleRuleImpl) { - return (CSSStyleRuleImpl) node; - } - else { - CSSUtil.debugOut("CSSStyleRuleImpl is expected, but " + //$NON-NLS-1$ - CSSUtil.getClassString(node)); - ungetNode(); - throw new DOMException(DOMException.INVALID_MODIFICATION_ERR, "");//$NON-NLS-1$ - } - } - - /** - * @return org.eclipse.wst.css.core.model.interfaces.ICSSNode - */ - ICSSNode getDeletionTarget() { - return fDeletionTarget; - } - - /** - * @return org.eclipse.wst.css.core.model.interfaces.ICSSNode - */ - ICSSNode getDeletionTargetParent() { - return fDeletionTargetParent; - } - - /** - * - */ - private ICSSNode getNode() { - ICSSNode node = null; - if (fNodeList != null && 0 < fNodeList.size()) { - node = (ICSSNode) fNodeList.removeFirst(); - } - fLastNode = node; - return node; - } - - /** - * - */ - int getNodeCount() { - if (fNodeList != null) { - return fNodeList.size(); - } - else { - return -1; - } - } - - /** - * - */ - // ICSSNode getParentNode() { - // return fParentNode; - // } - /** - * - */ - RectImpl getRect() { - ICSSNode node = getNode(); - if (node instanceof RectImpl) { - return (RectImpl) node; - } - else { - CSSUtil.debugOut("RectImpl is expected, but " + //$NON-NLS-1$ - CSSUtil.getClassString(node)); - ungetNode(); - throw new DOMException(DOMException.INVALID_MODIFICATION_ERR, "");//$NON-NLS-1$ - } - } - - /** - * - */ - RGBColorImpl getRGBColor() { - ICSSNode node = getNode(); - if (node instanceof RGBColorImpl) { - return (RGBColorImpl) node; - } - else { - CSSUtil.debugOut("RGBColorImpl is expected, but " + //$NON-NLS-1$ - CSSUtil.getClassString(node)); - ungetNode(); - throw new DOMException(DOMException.INVALID_MODIFICATION_ERR, "");//$NON-NLS-1$ - } - } - - /** - * @return short - */ - short getUpdateMode() { - return fUpdateMode; - } - - /** - * - */ - boolean isActive() { - return (fNodeList != null); - } - - /** - * - */ - void setupContext(short updateMode, ICSSNode parentNode, ICSSNode targetNode) { - fUpdateMode = updateMode; - - ICSSNode traverseRoot; - if (updateMode == UPDATE_REMOVE_RCONTAINER || updateMode == UPDATE_INSERT_RCONTAINER || updateMode == UPDATE_CHANGE_RCONTAINER) { - traverseRoot = parentNode; - while (traverseRoot instanceof CSSRegionContainer) { - traverseRoot = traverseRoot.getParentNode(); - } - } - else { - traverseRoot = targetNode; - } - - if (updateMode == UPDATE_REMOVE_RCONTAINER || updateMode == UPDATE_INSERT_RCONTAINER || // region - // insert - // => - // replace - // flat - // node - updateMode == UPDATE_CHANGE_RCONTAINER || updateMode == UPDATE_REMOVE_FNCONTAINER) { - fDeletionTarget = traverseRoot; - if (fDeletionTarget == targetNode) { - fDeletionTargetParent = parentNode; - } - else { - fDeletionTargetParent = fDeletionTarget.getParentNode(); - } - } - else { - fDeletionTarget = null; - fDeletionTargetParent = null; - } - - if (updateMode == UPDATE_INSERT_RCONTAINER || updateMode == UPDATE_INSERT_FNCONTAINER || updateMode == UPDATE_REMOVE_RCONTAINER || // region - // remove - // => - // re-insert - // flat - // node - updateMode == UPDATE_CHANGE_RCONTAINER) { - CSSNodeUpdateTraverser traverser = new CSSNodeUpdateTraverser(); - traverser.apply(traverseRoot); - fNodeList = traverser.getNodeList(); - } - else { - fNodeList = null; - } - } - - /** - * - */ - private void ungetNode() { - if (fNodeList != null && fLastNode != null) { - fNodeList.addFirst(fLastNode); - } - } -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelUpdater.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelUpdater.java deleted file mode 100644 index 5bb8a8b453..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelUpdater.java +++ /dev/null @@ -1,518 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2010 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.document; - - - -import org.eclipse.wst.css.core.internal.formatter.AttrChangeContext; -import org.eclipse.wst.css.core.internal.formatter.CSSSourceFormatterFactory; -import org.eclipse.wst.css.core.internal.formatter.CSSSourceGenerator; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSAttr; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode; -import org.eclipse.wst.css.core.internal.util.CSSUtil; -import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier; -import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; -import org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument; - - -/** - * - */ -class CSSModelUpdater { - - private CSSModelImpl fModel = null; - private CSSModelParser fParser = null; - - /** - * CSSModelUpdater constructor comment. - */ - CSSModelUpdater() { - super(); - } - - /** - * - */ - CSSModelUpdater(CSSModelImpl model) { - super(); - fModel = model; - } - - /** - * @param parentNode - * org.eclipse.wst.css.core.model.CSSNodeImpl - * @param node - * org.eclipse.wst.css.core.model.CSSNodeImpl - */ - private void attrInserted(CSSNodeImpl parentNode, CSSAttrImpl attr) { - CSSSourceGenerator formatter = CSSSourceFormatterFactory.getInstance().getSourceFormatter(parentNode); - - if (formatter == null) { - CSSUtil.debugOut("Cannot get format adapter : " + parentNode.getClass().toString());//$NON-NLS-1$ - return; - } - - short updateMode = CSSModelUpdateContext.UPDATE_INSERT_RCONTAINER; - fParser.setupUpdateContext(updateMode, parentNode, attr); - - // get formatted info - AttrChangeContext region = new AttrChangeContext(); - String text = new String(formatter.formatAttrChanged(parentNode, attr, true, region)); - - // set text - insertText(region.start, region.end - region.start, text); - - fParser.cleanupUpdateContext(); - } - - /** - * @param parentNode - * org.eclipse.wst.css.core.model.CSSNodeImpl - * @param node - * org.eclipse.wst.css.core.model.CSSNodeImpl - */ - private void attrRemoved(CSSNodeImpl parentNode, CSSAttrImpl attr) { - CSSSourceGenerator formatter = CSSSourceFormatterFactory.getInstance().getSourceFormatter(parentNode); - - if (formatter == null) { - CSSUtil.debugOut("Cannot get format adapter : " + parentNode.getClass().toString());//$NON-NLS-1$ - return; - } - - short updateMode = CSSModelUpdateContext.UPDATE_REMOVE_RCONTAINER; - fParser.setupUpdateContext(updateMode, parentNode, attr); - - // get formatted info - AttrChangeContext region = new AttrChangeContext(); - String text = new String(formatter.formatAttrChanged(parentNode, attr, false, region)); - - // set text - insertText(region.start, region.end - region.start, text); - - fParser.cleanupUpdateContext(); - } - - /** - * - */ - void attrReplaced(CSSNodeImpl parentNode, CSSNodeImpl newAttr, CSSNodeImpl oldAttr) { - if (parentNode == null) { - return; - } - - if (oldAttr != null) { - attrRemoved(parentNode, (CSSAttrImpl) oldAttr); - } - - if (newAttr != null) { - attrInserted(parentNode, (CSSAttrImpl) newAttr); - } - } - - /** - * - */ - private void childInserted(CSSNodeImpl parentNode, CSSNodeImpl node) { - short updateMode = CSSModelUpdateContext.UPDATE_IDLE; - - if (node instanceof CSSStructuredDocumentRegionContainer) { - updateMode = CSSModelUpdateContext.UPDATE_INSERT_FNCONTAINER; - } - else if (node instanceof CSSRegionContainer) { - updateMode = CSSModelUpdateContext.UPDATE_INSERT_RCONTAINER; - } - else { - CSSUtil.debugOut("What's this node? : " + node.getClass().toString());//$NON-NLS-1$ - return; - } - - fParser.setupUpdateContext(updateMode, parentNode, node); - - defaultInserted(parentNode, node); - - fParser.cleanupUpdateContext(); - } - - /** - * - */ - private void childRemoved(CSSNodeImpl parentNode, CSSNodeImpl node) { - short updateMode = CSSModelUpdateContext.UPDATE_IDLE; - - if (node instanceof CSSStructuredDocumentRegionContainer) { - updateMode = CSSModelUpdateContext.UPDATE_REMOVE_FNCONTAINER; - } - else if (node instanceof CSSRegionContainer) { - updateMode = CSSModelUpdateContext.UPDATE_REMOVE_RCONTAINER; - } - else { - CSSUtil.debugOut("What's this node? : " + node.getClass().toString());//$NON-NLS-1$ - return; - } - - fParser.setupUpdateContext(updateMode, parentNode, node); - - CSSNodeImpl prev = getOldPrevious(parentNode, node); - CSSNodeImpl next = getOldNext(parentNode, node); - int insertPos = -1, endPos = -1; - String source = "";//$NON-NLS-1$ - if (prev != null) { - insertPos = prev.getEndOffset(); - } - else { - insertPos = node.getStartOffset(); - insertPos -= nearestSpaceLengthBefore(parentNode, insertPos); - } - if (next != null) { - endPos = next.getStartOffset(); - } - else { - endPos = node.getEndOffset(); - endPos += nearestSpaceLengthAfter(parentNode, endPos); - } - source = getSpaceBefore(parentNode, next, node); - if (source.length() > 0) { - insertText(insertPos, endPos - insertPos, source); - } - else { - removeText(insertPos, endPos - insertPos); - } - - fParser.cleanupUpdateContext(); - } - - /** - * - */ - void childReplaced(CSSNodeImpl parentNode, CSSNodeImpl newChild, CSSNodeImpl oldChild) { - if (parentNode == null) { - return; - } - - if (oldChild != null) { - childRemoved(parentNode, oldChild); - } - - if (newChild != null) { - childInserted(parentNode, newChild); - } - } - - /** - * - */ - private StructuredDocumentEvent defaultInserted(CSSNodeImpl parentNode, CSSNodeImpl node) { - int insertPos = -1; - ICSSNode sibling; - String preSpace = "", postSpace = "";//$NON-NLS-2$//$NON-NLS-1$ - int length = 0; - - if (insertPos < 0) { - if ((sibling = node.getPreviousSibling()) != null) { - // after previous child - insertPos = getTextEnd(sibling); - } - } - - if (insertPos < 0) { - if ((sibling = node.getNextSibling()) != null) { - // before next child - insertPos = getTextStart(sibling); - } - } - - if (insertPos < 0) { - // position of parent - insertPos = getChildInsertPos(parentNode); - } - - if (insertPos < 0) { - // firsttime - insertPos = 0; - } - - // format previous spaces - length = nearestSpaceLengthBefore(parentNode, insertPos); - insertPos -= length; - preSpace = getSpaceBefore(parentNode, node, null); - // format post spaces - length += nearestSpaceLengthAfter(parentNode, insertPos + length); - postSpace = getSpaceBefore(parentNode, node.getNextSibling(), null); - - // set text - String text = preSpace + node.generateSource().trim() + postSpace; - return insertText(insertPos, length, text); - } - - /** - * @return int - * @param node - * org.eclipse.wst.css.core.model.CSSNodeImpl - */ - private int getChildInsertPos(CSSNodeImpl node) { - CSSSourceGenerator formatter = CSSSourceFormatterFactory.getInstance().getSourceFormatter(node); - if (formatter != null) - return formatter.getChildInsertPos(node); - else - return node.getEndOffset(); - } - - /** - * @return org.eclipse.wst.css.core.model.CSSNodeImpl - * @param parentNode - * org.eclipse.wst.css.core.model.CSSNodeImpl - * @param node - * org.eclipse.wst.css.core.model.CSSNodeImpl - */ - private CSSNodeImpl getOldNext(CSSNodeImpl parentNode, CSSNodeImpl node) { - CSSNodeImpl child = (CSSNodeImpl) parentNode.getLastChild(); - CSSNodeImpl ret = null; - while (child != null) { - if (node.getEndOffset() < child.getEndOffset()) - ret = child; - else - break; - child = (CSSNodeImpl) child.getPreviousSibling(); - } - return ret; - } - - /** - * @return org.eclipse.wst.css.core.model.CSSNodeImpl - * @param parentNode - * org.eclipse.wst.css.core.model.CSSNodeImpl - * @param node - * org.eclipse.wst.css.core.model.CSSNodeImpl - */ - private CSSNodeImpl getOldPrevious(CSSNodeImpl parentNode, CSSNodeImpl node) { - CSSNodeImpl child = (CSSNodeImpl) parentNode.getFirstChild(); - CSSNodeImpl ret = null; - while (child != null) { - if (child.getStartOffset() < node.getStartOffset()) - ret = child; - else - break; - child = (CSSNodeImpl) child.getNextSibling(); - } - return ret; - } - - /** - * @return java.lang.String - * @param parentNode - * org.eclipse.wst.css.core.model.CSSNodeImpl - * @param node - * org.eclipse.wst.css.core.model.CSSNodeImpl - */ - private String getSpaceBefore(ICSSNode parentNode, ICSSNode node, ICSSNode toRemove) { - CSSSourceGenerator formatter = CSSSourceFormatterFactory.getInstance().getSourceFormatter((INodeNotifier) parentNode); - - if (formatter != null) { - org.eclipse.jface.text.IRegion exceptFor = null; - if (toRemove != null) { - CSSNodeImpl remove = (CSSNodeImpl) toRemove; - exceptFor = new org.eclipse.jface.text.Region(remove.getStartOffset(), remove.getEndOffset() - remove.getStartOffset()); - } - return formatter.formatBefore(parentNode, node, exceptFor).toString(); - } - else - return "";//$NON-NLS-1$ - } - - /** - * - */ - private int getTextEnd(ICSSNode node) { - int end = -1; - if (node != null) { - if (node instanceof CSSStructuredDocumentRegionContainer) { - end = ((CSSStructuredDocumentRegionContainer) node).getEndOffset(); - } - else if (node instanceof CSSRegionContainer) { - end = ((CSSRegionContainer) node).getEndOffset(); - } - } - return end; - } - - /** - * - */ - private int getTextStart(ICSSNode node) { - int start = -1; - if (node != null) { - if (node instanceof CSSStructuredDocumentRegionContainer) { - start = ((CSSStructuredDocumentRegionContainer) node).getStartOffset(); - } - else if (node instanceof CSSRegionContainer) { - start = ((CSSRegionContainer) node).getStartOffset(); - } - } - return start; - } - - /** - * - */ - private StructuredDocumentEvent insertText(int start, int oldLength, String text) { - StructuredDocumentEvent result = null; - BasicStructuredDocument structuredDocument = (BasicStructuredDocument) fModel.getStructuredDocument(); - if (structuredDocument != null) { - if (text != null && 0 < oldLength && start + oldLength <= structuredDocument.getLength()) { - // minimize text change - String delText = structuredDocument.get(start, oldLength); - int newLength = text.length(); - int shorterLen = Math.min(oldLength, newLength); - int stMatchLen; - for (stMatchLen = 0; stMatchLen < shorterLen && text.charAt(stMatchLen) == delText.charAt(stMatchLen); stMatchLen++) { - // - } - if (0 < stMatchLen && stMatchLen < shorterLen && text.charAt(stMatchLen - 1) == 0x000d && (text.charAt(stMatchLen) == 0x000a || delText.charAt(stMatchLen) == 0x000a)) { - // must not divide 0d->0a sequence - stMatchLen--; - } - if (stMatchLen == shorterLen) { - if (oldLength < newLength) { // just insert - oldLength = 0; - start += stMatchLen; - text = text.substring(stMatchLen); - } - else if (newLength < oldLength) { // just remove - oldLength -= stMatchLen; - start += stMatchLen; - text = null; - } - else { // nothing to do - oldLength = 0; - text = null; - } - } - else { - int edMatchLen; - for (edMatchLen = 0; stMatchLen + edMatchLen < shorterLen && text.charAt(newLength - edMatchLen - 1) == delText.charAt(oldLength - edMatchLen - 1); edMatchLen++) { - // - } - if (0 < edMatchLen && text.charAt(newLength - edMatchLen) == 0x000a && ((edMatchLen < newLength && text.charAt(newLength - edMatchLen - 1) == 0x000d) || (edMatchLen < oldLength && delText.charAt(oldLength - edMatchLen - 1) == 0x000d))) { - // must not divide 0d->0a sequence - edMatchLen--; - } - oldLength -= stMatchLen + edMatchLen; - start += stMatchLen; - if (stMatchLen + edMatchLen < newLength) { - text = text.substring(stMatchLen, newLength - edMatchLen); - } - else { - text = null; - } - } - } - if (0 < oldLength || text != null) { - // String delText = structuredDocument.get(start, oldLength); - result = structuredDocument.replaceText(fModel, start, oldLength, text); - } - } - return result; - } - - /** - * @return int - * @param insertPos - * int - */ - private int nearestSpaceLengthAfter(CSSNodeImpl node, int insertPos) { - CSSSourceGenerator formatter = CSSSourceFormatterFactory.getInstance().getSourceFormatter(node); - if (formatter != null) { - return formatter.getLengthToReformatAfter(node, insertPos); - } - else - return 0; - } - - /** - * @return int - * @param insertPos - * int - */ - private int nearestSpaceLengthBefore(CSSNodeImpl node, int insertPos) { - CSSSourceGenerator formatter = CSSSourceFormatterFactory.getInstance().getSourceFormatter(node); - if (formatter != null) { - return formatter.getLengthToReformatBefore(node, insertPos); - } - else - return 0; - } - - /** - * - */ - private StructuredDocumentEvent removeText(int start, int length) { - StructuredDocumentEvent result = null; - IStructuredDocument structuredDocument = fModel.getStructuredDocument(); - if (structuredDocument != null) { - result = structuredDocument.replaceText(fModel, start, length, new String(""));//$NON-NLS-1$ - } - return result; - } - - /** - * - */ - void setParser(CSSModelParser parser) { - fParser = parser; - } - - /** - * - */ - void valueChanged(CSSNodeImpl node, String oldValue) { - if (!(node instanceof CSSRegionContainer)) { - CSSUtil.debugOut("Too Bad.." + //$NON-NLS-1$ - ((node == null) ? "null" : node.getClass().toString()));//$NON-NLS-1$ - return; - } - - int start = node.getStartOffset(); - - if (node.getNodeType() == ICSSNode.ATTR_NODE) { - ICSSAttr attr = (ICSSAttr) node; - CSSSourceGenerator formatter = CSSSourceFormatterFactory.getInstance().getSourceFormatter((INodeNotifier) attr.getOwnerCSSNode()); - if (formatter != null) - start = formatter.getAttrInsertPos(attr.getOwnerCSSNode(), attr.getName()); - } - - int oldLength = (oldValue == null) ? 0 : oldValue.length(); - // flash old IStructuredDocumentRegion/ITextRegion - if (node instanceof CSSStructuredDocumentRegionContainer) { - ((CSSStructuredDocumentRegionContainer) node).setFirstStructuredDocumentRegion(null); - ((CSSStructuredDocumentRegionContainer) node).setLastStructuredDocumentRegion(null); - } - else if (node instanceof CSSRegionContainer) { - ((CSSRegionContainer) node).setRangeRegion(null, null, null); - } - // generate new source - String newValue = node.generateSource(); - - ICSSNode parent; - if (node.getNodeType() == ICSSNode.ATTR_NODE) { - parent = ((ICSSAttr) node).getOwnerCSSNode(); - } - else { - parent = node.getParentNode(); - } - - fParser.setupUpdateContext(CSSModelUpdateContext.UPDATE_CHANGE_RCONTAINER, parent, node); - - insertText(start, oldLength, newValue); - - fParser.cleanupUpdateContext(); - } -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelUtil.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelUtil.java deleted file mode 100644 index d87b011eb8..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelUtil.java +++ /dev/null @@ -1,291 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.document; - -import java.util.Iterator; -import java.util.Vector; - -import org.eclipse.wst.css.core.internal.parserz.CSSRegionContexts; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSAttr; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSNodeList; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSRuleContainer; -import org.eclipse.wst.css.core.internal.util.CSSUtil; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; - -/** - * - */ -class CSSModelUtil { - - /** - * - */ - static boolean canContainBrace(ICSSNode node) { - return (node != null && (node instanceof ICSSRuleContainer || node instanceof CSSRuleDeclContainer)) ? true : false; - } - - /** - * @param parent - * org.eclipse.wst.css.core.model.interfaces.ICSSNode - */ - static void cleanupContainer(ICSSNode parent) { - if (parent == null) { - return; - } - for (ICSSNode child = parent.getFirstChild(); child != null; child = child.getNextSibling()) { - cleanupContainer(child); - } - if (parent instanceof CSSStructuredDocumentRegionContainer) { - ((CSSStructuredDocumentRegionContainer) parent).setRangeStructuredDocumentRegion(null, null); - } - else if (parent instanceof CSSRegionContainer) { - ((CSSRegionContainer) parent).setRangeRegion(null, null, null); - } - } - - static boolean diagnoseNode(ICSSNode parent, IStructuredDocument structuredDocument) { - // check this - Vector errors = new Vector(); - if (parent instanceof CSSStructuredDocumentRegionContainer) { - CSSStructuredDocumentRegionContainer node = (CSSStructuredDocumentRegionContainer) parent; - String nodeText = CSSUtil.getClassString(node) + ": ";//$NON-NLS-1$ - IStructuredDocumentRegion flatNode = node.getFirstStructuredDocumentRegion(); - if (flatNode == null && (!(node instanceof CSSStyleDeclarationImpl || node instanceof CSSStyleSheetImpl) || node.getFirstChild() != null)) { - errors.add(nodeText + "first flat node is null."); //$NON-NLS-1$ - } - else if (flatNode != null) { - IStructuredDocumentRegion modelNode = structuredDocument.getRegionAtCharacterOffset(flatNode.getStart()); - if (flatNode != modelNode) { - errors.add(nodeText + "first flat node is not in model."); //$NON-NLS-1$ - } - } - flatNode = node.getLastStructuredDocumentRegion(); - if (flatNode == null && (!(node instanceof CSSStyleDeclarationImpl || node instanceof CSSStyleSheetImpl) || node.getFirstChild() != null)) { - errors.add(nodeText + "last flat node is null."); //$NON-NLS-1$ - } - else if (flatNode != null) { - IStructuredDocumentRegion modelNode = structuredDocument.getRegionAtCharacterOffset(flatNode.getStart()); - if (flatNode != modelNode) { - errors.add(nodeText + "last flat node is not in model."); //$NON-NLS-1$ - } - } - } - else if (parent instanceof CSSRegionContainer) { - CSSRegionContainer node = (CSSRegionContainer) parent; - String nodeText = CSSUtil.getClassString(node) + ": ";//$NON-NLS-1$ - ITextRegion region = node.getFirstRegion(); - IStructuredDocumentRegion parentRegion = node.getDocumentRegion(); - if (region == null && (!(node instanceof MediaListImpl) || node.getFirstChild() != null)) { - errors.add(nodeText + "first region is null."); //$NON-NLS-1$ - } - else if (region != null) { - int offset = parentRegion.getStartOffset(region); - IStructuredDocumentRegion modelNode = structuredDocument.getRegionAtCharacterOffset(offset); - ITextRegion modelRegion = modelNode.getRegionAtCharacterOffset(offset); - if (region != modelRegion) { - errors.add(nodeText + "first region is not in model."); //$NON-NLS-1$ - } - } - region = node.getLastRegion(); - if (region == null && (!(node instanceof MediaListImpl) || node.getFirstChild() != null)) { - errors.add(nodeText + "last region is null."); //$NON-NLS-1$ - } - else if (region != null) { - int offset = parentRegion.getStartOffset(region); - IStructuredDocumentRegion modelNode = structuredDocument.getRegionAtCharacterOffset(offset); - ITextRegion modelRegion = modelNode.getRegionAtCharacterOffset(offset); - if (region != modelRegion) { - errors.add(nodeText + "last region is not in model."); //$NON-NLS-1$ - } - } - } - - ICSSNodeList attrs = parent.getAttributes(); - int nAttrs = attrs.getLength(); - for (int i = 0; i < nAttrs; i++) { - ICSSAttr attr = (ICSSAttr) attrs.item(i); - CSSRegionContainer node = (CSSRegionContainer) attr; - String nodeText = CSSUtil.getClassString(node) + "(" + attr.getName() + "): ";//$NON-NLS-2$//$NON-NLS-1$ - ITextRegion region = node.getFirstRegion(); - IStructuredDocumentRegion parentRegion = node.getDocumentRegion(); - if (region == null && 0 < attr.getValue().length()) { - errors.add(nodeText + "first region is null."); //$NON-NLS-1$ - } - else if (region != null) { - int offset = parentRegion.getStartOffset(region); - IStructuredDocumentRegion modelNode = structuredDocument.getRegionAtCharacterOffset(offset); - ITextRegion modelRegion = modelNode.getRegionAtCharacterOffset(offset); - if (region != modelRegion) { - errors.add(nodeText + "first region is not in model."); //$NON-NLS-1$ - } - } - region = node.getLastRegion(); - if (region == null && 0 < attr.getValue().length()) { - errors.add(nodeText + "last region is null."); //$NON-NLS-1$ - } - else if (region != null) { - int offset = parentRegion.getStartOffset(region); - IStructuredDocumentRegion modelNode = structuredDocument.getRegionAtCharacterOffset(offset); - ITextRegion modelRegion = modelNode.getRegionAtCharacterOffset(offset); - if (region != modelRegion) { - errors.add(nodeText + "last region is not in model."); //$NON-NLS-1$ - } - } - } - - if (!errors.isEmpty()) { - Iterator i = errors.iterator(); - while (i.hasNext()) { - CSSUtil.debugOut((String) i.next()); - } - return false; - } - else { - return true; - } - } - - /** - * @return boolean - * @param node - * org.eclipse.wst.css.core.model.interfaces.ICSSNode - */ - static boolean diagnoseTree(ICSSNode parent, IStructuredDocument structuredDocument) { - if (parent == null) { - return false; - } - // check children - for (ICSSNode child = parent.getFirstChild(); child != null; child = child.getNextSibling()) { - diagnoseTree(child, structuredDocument); - } - - diagnoseNode(parent, structuredDocument); - - return true; - } - - /** - * If needed, modify last flat node - */ - static void expandStructuredDocumentRegionContainer(CSSStructuredDocumentRegionContainer target, IStructuredDocumentRegion flatNode) { - if (target == null || flatNode == null) { - return; - } - - IStructuredDocumentRegion lastNode = target.getLastStructuredDocumentRegion(); - if (lastNode == flatNode) { - return; - } - if (lastNode == null || lastNode.getStart() < flatNode.getStart()) { - target.setLastStructuredDocumentRegion(flatNode); - } - } - - /* - * - */ - static ICSSNode findBraceContainer(ICSSNode node) { - for (ICSSNode i = node; i != null; i = i.getParentNode()) { - if (CSSModelUtil.canContainBrace(i)) { - return i; - } - } - return null; - } - - /** - * - */ - static int getDepth(ICSSNode node) { - int depth = -1; - while (node != null) { - depth++; - node = node.getParentNode(); - } - return depth; - } - - /** - * - */ - static boolean isBraceClosed(ICSSNode node) { - boolean bClosed = true; - if (!(node instanceof CSSStructuredDocumentRegionContainer)) { - return bClosed; - } - - IStructuredDocumentRegion first = ((CSSStructuredDocumentRegionContainer) node).getFirstStructuredDocumentRegion(); - IStructuredDocumentRegion last = ((CSSStructuredDocumentRegionContainer) node).getLastStructuredDocumentRegion(); - if (first == null || last == null) { - return bClosed; - } - if (last.getStart() < first.getStart()) { - return bClosed; - } - - IStructuredDocumentRegion flatNode = first; - int nOpen = 0; - int nClose = 0; - do { - String type = CSSUtil.getStructuredDocumentRegionType(flatNode); - if (type == CSSRegionContexts.CSS_LBRACE) { - nOpen++; - } - else if (type == CSSRegionContexts.CSS_RBRACE) { - nClose++; - } - flatNode = flatNode.getNext(); - } - while (flatNode != null && flatNode != last); - - if ((nOpen == 0 && nClose == 0) || nClose < nOpen) { - bClosed = false; - } - - return bClosed; - } - - /** - * only for insertion.. - */ - static boolean isInterruption(CSSStructuredDocumentRegionContainer target, IStructuredDocumentRegion flatNode) { - if (target == null || flatNode == null) { - return false; - } - int start = flatNode.getStart(); - IStructuredDocumentRegion firstNode = target.getFirstStructuredDocumentRegion(); - IStructuredDocumentRegion lastNode = target.getLastStructuredDocumentRegion(); - if (firstNode != null && firstNode.getStart() < start && lastNode != null && start < lastNode.getStart()) { - return true; - } - return false; - } - - /** - * - */ - static boolean isParentOf(ICSSNode parent, ICSSNode child) { - if (parent == null || child == null) { - return false; - } - - for (ICSSNode node = child; node != null; node = node.getParentNode()) { - if (parent == node) { - return true; - } - } - - return false; - } -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSNamedNodeMapImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSNamedNodeMapImpl.java deleted file mode 100644 index 9d21149b4d..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSNamedNodeMapImpl.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.document; - - - -import java.util.Iterator; - -import org.eclipse.wst.css.core.internal.provisional.document.ICSSNamedNodeMap; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode; - - -/** - * - */ -public class CSSNamedNodeMapImpl extends CSSNodeListImpl implements ICSSNamedNodeMap { - - /** - * CSSNamedNodeMapImpl constructor comment. - */ - CSSNamedNodeMapImpl() { - super(); - } - - /** - * @return org.eclipse.wst.css.core.model.interfaces.ICSSNode - * @param name - * java.lang.String - */ - public ICSSNode getNamedItem(String name) { - Iterator it = nodes.iterator(); - while (it.hasNext()) { - Object obj = it.next(); - if (obj instanceof CSSAttrImpl && ((CSSAttrImpl) obj).getName().compareToIgnoreCase(name) == 0) { - return (ICSSNode) obj; - } - } - return null; - } -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSNodeImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSNodeImpl.java deleted file mode 100644 index 0f37dac06c..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSNodeImpl.java +++ /dev/null @@ -1,470 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.document; - - - -import java.util.Iterator; - -import org.eclipse.wst.css.core.internal.formatter.CSSSourceFormatterFactory; -import org.eclipse.wst.css.core.internal.formatter.CSSSourceGenerator; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSDocument; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSModel; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSNamedNodeMap; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSNodeList; -import org.eclipse.wst.css.core.internal.util.ImportRuleCollector; -import org.eclipse.wst.sse.core.internal.model.FactoryRegistry; -import org.eclipse.wst.sse.core.internal.provisional.AbstractNotifier; -import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion; -import org.w3c.dom.DOMException; - - -/** - * - */ -public abstract class CSSNodeImpl extends AbstractNotifier implements ICSSNode, IndexedRegion { - - private CSSDocumentImpl fOwnerDocument = null; - private CSSNodeImpl fParentNode = null; - private CSSNodeImpl fNextSibling = null; - private CSSNodeImpl fPreviousSibling = null; - private CSSNodeImpl fFirstChild = null; - private CSSNodeImpl fLastChild = null; - protected CSSNamedNodeMapImpl fAttrs = null; - - /** - * CSSNodeImpl constructor comment. - */ - CSSNodeImpl() { - super(); - } - - CSSNodeImpl(CSSNodeImpl that) { - if (that != null) { - this.fOwnerDocument = that.fOwnerDocument; - if (that.fAttrs != null) { - int nAttrs = that.fAttrs.getLength(); - for (int i = 0; i < nAttrs; i++) { - CSSAttrImpl attr = (CSSAttrImpl) that.fAttrs.item(i); - setAttribute(attr.getName(), attr.getValue()); - } - } - } - } - /** - * currently public but may be made default access protected in future. - */ - public CSSNodeImpl appendChild(CSSNodeImpl newChild) throws org.w3c.dom.DOMException { - return insertBefore(newChild, null); - } - /** - * currently public but may be made default access protected in future. - */ - protected void cloneChildNodes(ICSSNode newParent, boolean deep) { - if (newParent == null || newParent == this) - return; - - CSSNodeImpl container = (CSSNodeImpl) newParent; - container.removeChildNodes(); - - for (ICSSNode child = getFirstChild(); child != null; child = child.getNextSibling()) { - CSSNodeImpl cloned = (CSSNodeImpl) child.cloneNode(deep); - if (cloned != null) - container.appendChild(cloned); - } - } - - /** - * @return boolean - * @param offset - * int - */ - public boolean contains(int offset) { - return (getStartOffset() <= offset && offset < getEndOffset()); - } - - /** - * - * currently public but may be made default access protected in future. - * - * @return java.lang.String - */ - protected String generateSource() { - CSSSourceGenerator formatter = CSSSourceFormatterFactory.getInstance().getSourceFormatter(this); - return formatter.format(this).toString(); - } - - /** - * - * currently public but may be made default access protected in future. - * - * @return java.lang.String - * @param name - * java.lang.String - */ - protected String getAttribute(String name) { - CSSAttrImpl attr = getAttributeNode(name); - if (attr != null) - return attr.getValue(); - return null; - } - - protected CSSAttrImpl getAttributeNode(String name) { - if (fAttrs == null) - return null; - - int nAttrs = fAttrs.getLength(); - for (int i = 0; i < nAttrs; i++) { - CSSAttrImpl attr = (CSSAttrImpl) fAttrs.item(i); - if (attr.matchName(name)) - return attr; - } - return null; - } - - /** - * @return org.eclipse.wst.css.core.model.interfaces.ICSSNamedNodeMap - */ - public ICSSNamedNodeMap getAttributes() { - if (fAttrs == null) - fAttrs = new CSSNamedNodeMapImpl(); - return fAttrs; - } - - public ICSSNodeList getChildNodes() { - CSSNodeListImpl list = new CSSNodeListImpl(); - for (ICSSNode node = getFirstChild(); node != null; node = node.getNextSibling()) { - list.appendNode(node); - } - return list; - } - - ICSSNode getCommonAncestor(ICSSNode node) { - if (node == null) - return null; - - for (ICSSNode na = node; na != null; na = na.getParentNode()) { - for (ICSSNode ta = this; ta != null; ta = ta.getParentNode()) { - if (ta == na) - return ta; - } - } - - return null; // not found - } - - CSSDocumentImpl getContainerDocument() { - for (ICSSNode node = this; node != null; node = node.getParentNode()) { - if (node instanceof CSSDocumentImpl) { - CSSDocumentImpl doc = (CSSDocumentImpl) node; - if (doc.isDocument()) - return doc; - } - } - return null; - } - - CSSNodeImpl getContainerNode(int offset) { - if (!contains(offset)) - return null; - - for (ICSSNode child = getFirstChild(); child != null; child = child.getNextSibling()) { - ICSSNode found = ((CSSNodeImpl) child).getContainerNode(offset); - if (found != null) - return (CSSNodeImpl) found; - } - - return this; - } - - /** - */ - public FactoryRegistry getFactoryRegistry() { - ICSSModel model = getOwnerDocument().getModel(); - if (model != null) { - FactoryRegistry reg = model.getFactoryRegistry(); - if (reg != null) - return reg; - } - return null; - } - - public ICSSNode getFirstChild() { - return this.fFirstChild; - } - - public ICSSNode getLastChild() { - return this.fLastChild; - } - - public ICSSNode getNextSibling() { - return this.fNextSibling; - } - - ICSSNode getNodeAt(int offset) { - // the same as getContainerNode() - return getContainerNode(offset); - } - - public ICSSDocument getOwnerDocument() { - return this.fOwnerDocument; - } - - public ICSSNode getParentNode() { - return this.fParentNode; - } - - public ICSSNode getPreviousSibling() { - return this.fPreviousSibling; - } - - ICSSNode getRootNode() { - CSSNodeImpl parent = (CSSNodeImpl) getParentNode(); - if (parent == null) - return this; - return parent.getRootNode(); - } - - /** - * @return boolean - */ - public boolean hasChildNodes() { - return (this.fFirstChild != null); - } - - /** - * @return boolean - */ - public boolean hasProperties() { - return false; - } - /** - * currently public but may be made default access protected in future. - */ - public CSSNodeImpl insertBefore(CSSNodeImpl newChild, CSSNodeImpl refChild) throws org.w3c.dom.DOMException { - if (newChild == null) - return null; - - CSSNodeImpl child = newChild; - CSSNodeImpl next = refChild; - CSSNodeImpl prev = null; - if (next == null) { - prev = this.fLastChild; - this.fLastChild = child; - } - else { - prev = (CSSNodeImpl) next.getPreviousSibling(); - next.setPreviousSibling(child); - } - - if (prev == null) - this.fFirstChild = child; - else - prev.setNextSibling(child); - child.setPreviousSibling(prev); - child.setNextSibling(next); - child.setParentNode(this); - - notifyChildReplaced(child, null); - - return newChild; - } - - protected void notifyAttrReplaced(CSSNodeImpl newAttr, CSSNodeImpl oldAttr) { - // for model - ICSSDocument doc = getContainerDocument(); - if (doc == null) - return; - CSSModelImpl model = (CSSModelImpl) doc.getModel(); - if (model == null) - return; - model.attrReplaced(this, newAttr, oldAttr); - - // for adapters - int type = CHANGE; - if (newAttr == null) - type = REMOVE; - else if (oldAttr == null) - type = ADD; - notify(type, oldAttr, oldAttr, newAttr, getStartOffset()); - } - - protected void notifyChildReplaced(CSSNodeImpl newChild, CSSNodeImpl oldChild) { - // for model - ICSSDocument doc = getContainerDocument(); - if (doc == null) - return; - CSSModelImpl model = (CSSModelImpl) doc.getModel(); - if (model == null) - return; - model.childReplaced(this, newChild, oldChild); - - // for adapters - int type = CHANGE; - if (newChild == null) - type = REMOVE; - else if (oldChild == null) - type = ADD; - notify(type, oldChild, oldChild, newChild, getStartOffset()); - } - - void removeAttributeNode(CSSNodeImpl attr) { - // find - int nAttrs = fAttrs.getLength(); - for (int i = 0; i < nAttrs; i++) { - if (fAttrs.item(i) == attr) { - fAttrs.removeNode(i); - notifyAttrReplaced(null, attr); - return; - } - } - } - - protected CSSNodeImpl removeChild(CSSNodeImpl oldChild) throws org.w3c.dom.DOMException { - if (oldChild == null) - return null; - if (oldChild.getParentNode() != this) - return null; - - // close import rules - ImportRuleCollector trav = new ImportRuleCollector(); - trav.apply(oldChild); - Iterator it = trav.getRules().iterator(); - while (it.hasNext()) { - ((CSSImportRuleImpl) it.next()).closeStyleSheet(); - } - - CSSNodeImpl child = oldChild; - CSSNodeImpl prev = (CSSNodeImpl) child.getPreviousSibling(); - CSSNodeImpl next = (CSSNodeImpl) child.getNextSibling(); - - if (prev == null) - this.fFirstChild = next; - else - prev.setNextSibling(next); - - if (next == null) - this.fLastChild = prev; - else - next.setPreviousSibling(prev); - - child.setPreviousSibling(null); - child.setNextSibling(null); - child.setParentNode(null); - - notifyChildReplaced(null, child); - - return child; - } - - /** - * - */ - void removeChildNodes() { - ICSSNode nextChild = null; - for (ICSSNode child = getFirstChild(); child != null; child = nextChild) { - nextChild = child.getNextSibling(); - removeChild((CSSNodeImpl) child); - } - } - - protected CSSNodeImpl replaceChild(CSSNodeImpl newChild, CSSNodeImpl oldChild) throws org.w3c.dom.DOMException { - if (oldChild == null) - return newChild; - if (newChild != null) - insertBefore(newChild, oldChild); - return removeChild(oldChild); - } - - /** - * - * currently public but may be made default access protected in future. - * - * @param name - * java.lang.String - * @param value - * java.lang.String - */ - public void setAttribute(String name, String value) { - if (name == null) - return; - - CSSAttrImpl attr = getAttributeNode(name); - if (attr != null) { - String oldValue = attr.getValue(); - if (value != null && value.equals(oldValue)) - return; - if (value == null) { - if (oldValue != null) { - removeAttributeNode(attr); - } - return; - } - } - else { - if (value == null) - return; - if (fAttrs == null) - fAttrs = new CSSNamedNodeMapImpl(); - CSSDocumentImpl doc = (CSSDocumentImpl) getOwnerDocument(); - if (doc == null) - return; - attr = (CSSAttrImpl) doc.createCSSAttr(name); - attr.setOwnerCSSNode(this); - fAttrs.appendNode(attr); - notifyAttrReplaced(attr, null); - } - attr.setValue(value); - } - - /** - * @param cssText - * java.lang.String - */ - public void setCssText(String cssText) { - // TODO : call flat model parser and replace myself with new three!! - throw new DOMException(DOMException.INVALID_MODIFICATION_ERR, "");//$NON-NLS-1$ - } - - private void setNextSibling(ICSSNode nextSibling) { - this.fNextSibling = (CSSNodeImpl) nextSibling; - } - /** - * currently public but may be made default access protected in future. - */ - public void setOwnerDocument(ICSSDocument ownerDocument) { - this.fOwnerDocument = (CSSDocumentImpl) ownerDocument; - } - - private void setParentNode(ICSSNode parentNode) { - this.fParentNode = (CSSNodeImpl) parentNode; - } - - private void setPreviousSibling(ICSSNode previousSibling) { - this.fPreviousSibling = (CSSNodeImpl) previousSibling; - } - - public int getLength() { - int result = -1; - int start = getStartOffset(); - if (start >= 0) { - int end = getEndOffset(); - if (end >= 0) { - result = end - start; - if (result < -1) { - result = -1; - } - } - } - return result; - } -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSNodeListImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSNodeListImpl.java deleted file mode 100644 index ed13871af7..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSNodeListImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.document; - - - -import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSNodeList; - -class CSSNodeListImpl extends AbstractCSSNodeList implements ICSSNodeList { - - CSSNodeListImpl() { - super(); - } - - public ICSSNode item(int index) { - return itemImpl(index); - } -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSPageRuleImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSPageRuleImpl.java deleted file mode 100644 index e49d5789ee..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSPageRuleImpl.java +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.document; - - - -import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSPageRule; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorList; - - -/** - * - */ -class CSSPageRuleImpl extends CSSRuleDeclContainer implements ICSSPageRule { - - ICSSSelectorList fSelectorList = new CSSSelectorListImpl(null); - - /** - * - */ - CSSPageRuleImpl() { - super(); - } - - CSSPageRuleImpl(CSSPageRuleImpl that) { - super(that); - } - - public ICSSNode cloneNode(boolean deep) { - CSSPageRuleImpl cloned = new CSSPageRuleImpl(this); - - if (deep) - cloneChildNodes(cloned, deep); - - return cloned; - } - - /** - * @return java.lang.String - */ - String extractPreString() { - StringBuffer preStr = new StringBuffer("@page ");//$NON-NLS-1$ - preStr.append(getSelectorText()); - - return preStr.toString(); - } - - /** - * @return short - */ - public short getNodeType() { - return PAGERULE_NODE; - } - - public ICSSSelectorList getSelectors() { - return fSelectorList; - } - - /** - * The parsable textual representation of the page selector for the rule. - * - * @exception org.w3c.dom.DOMException - * SYNTAX_ERR: Raised if the specified CSS string value has - * a syntax error and is unparsable.
- * NO_MODIFICATION_ALLOWED_ERR: Raised if this rule is - * readonly. - */ - public String getSelectorText() { - return getAttribute(SELECTOR); - } - - /** - * The type of the rule, as defined above. The expectation is that - * binding-specific casting methods can be used to cast down from an - * instance of the CSSRule interface to the specific - * derived interface implied by the type. - */ - public short getType() { - return PAGE_RULE; - } - - /** - * - */ - public void setSelectorText(String selectorText) throws org.w3c.dom.DOMException { - setAttribute(SELECTOR, selectorText); - fSelectorList = new CSSSelectorListImpl(selectorText); - } -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSPrimitiveContainer.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSPrimitiveContainer.java deleted file mode 100644 index 8d1f18699f..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSPrimitiveContainer.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.document; - - - -import org.eclipse.wst.css.core.internal.provisional.document.ICSSDocument; - -/** - * - */ -abstract class CSSPrimitiveContainer extends CSSPrimitiveValueImpl { - - CSSPrimitiveContainer(CSSPrimitiveContainer that) { - super(that); - } - - CSSPrimitiveContainer(short primitiveType) { - super(primitiveType); - } - - protected abstract void initPrimitives(); - /** - * currently public but may be made default access protected in future. - */ - public void setOwnerDocument(ICSSDocument ownerDocument) { - super.setOwnerDocument(ownerDocument); - - initPrimitives(); - } -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSPrimitiveValueImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSPrimitiveValueImpl.java deleted file mode 100644 index 1bbc097a53..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSPrimitiveValueImpl.java +++ /dev/null @@ -1,362 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.document; - - - -import org.eclipse.wst.css.core.internal.provisional.document.ICSSDocument; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSPrimitiveValue; -import org.w3c.dom.DOMException; -import org.w3c.dom.css.Counter; -import org.w3c.dom.css.RGBColor; -import org.w3c.dom.css.Rect; - - -/** - * - */ -class CSSPrimitiveValueImpl extends CSSRegionContainer implements ICSSPrimitiveValue { - - protected short fPrimitiveType = CSS_UNKNOWN; - private float fFloatValue = 0.0f; - private String fStringValue = null; - - CSSPrimitiveValueImpl(CSSPrimitiveValueImpl that) { - super(that); - - this.fPrimitiveType = that.fPrimitiveType; - this.fFloatValue = that.fFloatValue; - this.fStringValue = that.fStringValue; - } - - CSSPrimitiveValueImpl(short primitiveType) { - super(); - fPrimitiveType = primitiveType; - } - - public ICSSNode cloneNode(boolean deep) { - CSSPrimitiveValueImpl cloned = new CSSPrimitiveValueImpl(this); - - return cloned; - } - - /** - * This method is used to get the Counter value. If this CSS value doesn't - * contain a counter value, a DOMException is raised. - * Modification to the corresponding style property can be achieved using - * the Counter interface. - * - * @return The Counter value. - * @exception DOMException - * INVALID_ACCESS_ERR: Raised if the CSS value doesn't - * contain a Counter value (e.g. this is not - * CSS_COUNTER). - */ - public Counter getCounterValue() throws DOMException { - throw new DOMException(DOMException.INVALID_ACCESS_ERR, "");//$NON-NLS-1$ - } - - /** - * @return java.lang.String - */ - public java.lang.String getCSSValueText() { - return getCssText(); - } - - /** - * A code defining the type of the value as defined above. - */ - public short getCssValueType() { - if (getPrimitiveType() == CSS_INHERIT_PRIMITIVE) { - return CSS_INHERIT; - } - else { - return CSS_PRIMITIVE_VALUE; - } - } - - /** - * This method is used to get a float value in a specified unit. If this - * CSS value doesn't contain a float value or can't be converted into the - * specified unit, a DOMException is raised. - * - * @param unitType - * A unit code to get the float value. The unit code can only - * be a float unit type (i.e. CSS_NUMBER, - * CSS_PERCENTAGE,CSS_EMS, - * CSS_EXS,CSS_PX, - * CSS_CM,CSS_MM, - * CSS_IN,CSS_PT, - * CSS_PC,CSS_DEG, - * CSS_RAD,CSS_GRAD, - * CSS_MS,CSS_S, - * CSS_HZ,CSS_KHZ, - * CSS_DIMENSION). - * @return The float value in the specified unit. - * @exception DOMException - * INVALID_ACCESS_ERR: Raised if the CSS value doesn't - * contain a float value or if the float value can't be - * converted into the specified unit. - */ - public float getFloatValue(short unitType) throws DOMException { - switch (fPrimitiveType) { - case CSS_NUMBER : - case CSS_PERCENTAGE : - case CSS_EMS : - case CSS_EXS : - case CSS_PX : - case CSS_CM : - case CSS_MM : - case CSS_IN : - case CSS_PT : - case CSS_PC : - case CSS_DEG : - case CSS_RAD : - case CSS_GRAD : - case CSS_MS : - case CSS_S : - case CSS_HZ : - case CSS_KHZ : - case CSS_DIMENSION : - case CSS_INTEGER : - case CSS_HASH : - return fFloatValue; - default : - throw new DOMException(DOMException.INVALID_ACCESS_ERR, "");//$NON-NLS-1$ - } - } - - /** - * Insert the method's description here. Creation date: (2001/01/17 - * 12:12:18) - * - * @return short - */ - public short getNodeType() { - return PRIMITIVEVALUE_NODE; - } - - /** - * The type of the value as defined by the constants specified above. - */ - public short getPrimitiveType() { - return fPrimitiveType; - } - - /** - * This method is used to get the Rect value. If this CSS value doesn't - * contain a rect value, a DOMException is raised. - * Modification to the corresponding style property can be achieved using - * the Rect interface. - * - * @return The Rect value. - * @exception DOMException - * INVALID_ACCESS_ERR: Raised if the CSS value doesn't - * contain a Rect value. (e.g. this is not - * CSS_RECT). - */ - public Rect getRectValue() throws DOMException { - throw new DOMException(DOMException.INVALID_ACCESS_ERR, "");//$NON-NLS-1$ - } - - /** - * This method is used to get the RGB color. If this CSS value doesn't - * contain a RGB color value, a DOMException is raised. - * Modification to the corresponding style property can be achieved using - * the RGBColor interface. - * - * @return the RGB color value. - * @exception DOMException - * INVALID_ACCESS_ERR: Raised if the attached property - * can't return a RGB color value (e.g. this is not - * CSS_RGBCOLOR). - */ - public RGBColor getRGBColorValue() throws DOMException { - throw new DOMException(DOMException.INVALID_ACCESS_ERR, "");//$NON-NLS-1$ - } - - /** - * This method is used to get the string value. If the CSS value doesn't - * contain a string value, a DOMException is raised. Some - * properties (like 'font-family' or 'voice-family') convert a whitespace - * separated list of idents to a string. - * - * @return The string value in the current unit. The current - * primitiveType can only be a string unit type - * (i.e. CSS_STRING,CSS_URI, - * CSS_IDENT and CSS_ATTR). - * @exception DOMException - * INVALID_ACCESS_ERR: Raised if the CSS value doesn't - * contain a string value. - */ - public String getStringValue() throws DOMException { - switch (fPrimitiveType) { - case CSS_STRING : - case CSS_URI : - case CSS_IDENT : - case CSS_ATTR : - case CSS_URANGE : - case CSS_FORMAT : - case CSS_LOCAL : - case CSS_HASH : - case CSS_COMMA : - case CSS_SLASH : - case CSS_INHERIT_PRIMITIVE : - return fStringValue; - default : - throw new DOMException(DOMException.INVALID_ACCESS_ERR, "");//$NON-NLS-1$ - } - } - - /** - * - */ - protected void notifyValueChanged(String oldValue) { - // for model - ICSSDocument doc = getContainerDocument(); - if (doc == null) - return; - CSSModelImpl model = (CSSModelImpl) doc.getModel(); - if (model == null) - return; - model.valueChanged(this, oldValue); - - // for adapters - notify(CHANGE, new Short(fPrimitiveType), null, null, getStartOffset()); - } - - /** - * A method to set the float value with a specified unit. If the property - * attached with this value can not accept the specified unit or the float - * value, the value will be unchanged and a DOMException - * will be raised. - * - * @param unitType - * A unit code as defined above. The unit code can only be a - * float unit type (i.e. CSS_NUMBER, - * CSS_PERCENTAGE,CSS_EMS, - * CSS_EXS,CSS_PX, - * CSS_CM,CSS_MM, - * CSS_IN,CSS_PT, - * CSS_PC,CSS_DEG, - * CSS_RAD,CSS_GRAD, - * CSS_MS,CSS_S, - * CSS_HZ,CSS_KHZ, - * CSS_DIMENSION). - * @param floatValue - * The new float value. - * @exception DOMException - * INVALID_ACCESS_ERR: Raised if the attached property - * doesn't support the float value or the unit type.
- * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is - * readonly. - */ - public void setFloatValue(short unitType, float floatValue) throws DOMException { - switch (unitType) { - case CSS_NUMBER : - case CSS_PERCENTAGE : - case CSS_EMS : - case CSS_EXS : - case CSS_PX : - case CSS_CM : - case CSS_MM : - case CSS_IN : - case CSS_PT : - case CSS_PC : - case CSS_DEG : - case CSS_RAD : - case CSS_GRAD : - case CSS_MS : - case CSS_S : - case CSS_HZ : - case CSS_KHZ : - case CSS_DIMENSION : - case CSS_INTEGER : - String oldValue = getCSSValueText(); - fPrimitiveType = unitType; - fFloatValue = floatValue; - notifyValueChanged(oldValue); - break; - default : - throw new DOMException(DOMException.INVALID_ACCESS_ERR, "");//$NON-NLS-1$ - } - } - - /** - * A method to set the string value with the specified unit. If the - * property attached to this value can't accept the specified unit or the - * string value, the value will be unchanged and a - * DOMException will be raised. - * - * @param stringType - * A string code as defined above. The string code can only be - * a string unit type (i.e. CSS_STRING, - * CSS_URI,CSS_IDENT, and - * CSS_ATTR). - * @param stringValue - * The new string value. - * @exception DOMException - * INVALID_ACCESS_ERR: Raised if the CSS value doesn't - * contain a string value or if the string value can't be - * converted into the specified unit.
- * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is - * readonly. - */ - public void setStringValue(short stringType, String stringValue) throws DOMException { - switch (stringType) { - case CSS_STRING : - case CSS_URI : - case CSS_IDENT : - case CSS_ATTR : - case CSS_URANGE : - case CSS_FORMAT : - case CSS_LOCAL : - case CSS_HASH : - case CSS_COMMA : - case CSS_SLASH : - case CSS_INHERIT_PRIMITIVE : - String oldValue = getCSSValueText(); - fPrimitiveType = stringType; - fStringValue = stringValue; - notifyValueChanged(oldValue); - break; - default : - throw new DOMException(DOMException.INVALID_ACCESS_ERR, "");//$NON-NLS-1$ - } - } - - /** - * Insert the method's description here. Creation date: (2001/01/24 - * 15:06:25) - * - * @param floatValue - * float - * @exception org.w3c.dom.DOMException - * The exception description. - */ - public void setValue(float floatValue) throws org.w3c.dom.DOMException { - setFloatValue(getPrimitiveType(), floatValue); - } - - /** - * Insert the method's description here. Creation date: (2001/01/24 - * 15:06:25) - * - * @param stringValue - * java.lang.String - * @exception org.w3c.dom.DOMException - * The exception description. - */ - public void setValue(java.lang.String stringValue) throws org.w3c.dom.DOMException { - setStringValue(getPrimitiveType(), stringValue); - } -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSRegionContainer.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSRegionContainer.java deleted file mode 100644 index 3e5caefe96..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSRegionContainer.java +++ /dev/null @@ -1,202 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.document; - - - -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList; - -/** - * - */ -abstract class CSSRegionContainer extends CSSNodeImpl { - - private ITextRegion fFirstRegion = null; - private ITextRegion fLastRegion = null; - private IStructuredDocumentRegion fParentRegion = null; - - /** - * CSSRegionContainer constructor comment. - */ - CSSRegionContainer() { - super(); - } - - CSSRegionContainer(CSSRegionContainer that) { - super(that); - } - - /** - * @return java.lang.String - */ - public String getCssText() { - if (fFirstRegion == null || fLastRegion == null) - return generateSource(); - - ITextRegionList regions = fParentRegion.getRegions(); - StringBuffer source = new StringBuffer(); - boolean bIn = false; - for (int i = 0; i < regions.size(); i++) { - ITextRegion current = regions.get(i); - if (bIn) { - source.append(fParentRegion.getFullText(current)); - if (current == fLastRegion) - break; - } - else { - if (current == fFirstRegion) { - bIn = true; - source.append(fParentRegion.getFullText(current)); - if (current == fLastRegion) - break; - } - } - } - return source.toString(); - } - - /** - * @return int - */ - public int getEndOffset() { - int result = -1; - ITextRegion region = getLastRegion(); - if (!(region == null || fParentRegion == null)) { - result = fParentRegion.getEndOffset(region); - } - return result; - } - - IStructuredDocumentRegion getDocumentRegion() { - return fParentRegion; - } - - ITextRegion getFirstRegion() { - return fFirstRegion; - } - - ITextRegion getLastRegion() { - return fLastRegion; - } - - ITextRegion getRegion(int index) { - if (getFirstRegion() == null) - return null; - ITextRegionList regions = fParentRegion.getRegions(); - - for (int i = 0; i < regions.size(); i++) { - if (regions.get(i) == getFirstRegion()) { - if (i + index < regions.size()) { - ITextRegion target = regions.get(i + index); - if (target.getStart() <= getLastRegion().getStart()) - return target; - } - return null; - } - } - return null; - } - - /** - * @return int - */ - int getRegionCount() { - validateRange(); - - if (getFirstRegion() == null) - return 0; - if (getFirstRegion() == getLastRegion()) - return 1; - ITextRegionList regions = fParentRegion.getRegions(); - - int j = 0; - for (int i = 0; i < regions.size(); i++) { - ITextRegion current = regions.get(i); - if (j != 0 || current == getFirstRegion()) - j++; - if (current == getLastRegion()) - break; - } - return j; - } - - /** - * @return int - */ - public int getStartOffset() { - int result = -1; - ITextRegion region = getFirstRegion(); - if (!(region == null || fParentRegion == null)) { - result = fParentRegion.getStartOffset(region); - } - return result; - } - - - - /** - * @deprecated - */ - ITextRegion setFirstRegion(ITextRegion region) { - this.fFirstRegion = region; - return region; - } - - /** - * @deprecated - */ - ITextRegion setLastRegion(ITextRegion lastRegion) { - this.fLastRegion = lastRegion; - return lastRegion; - } - - void setRangeRegion(IStructuredDocumentRegion parentRegion, ITextRegion firstRegion, ITextRegion lastRegion) { - this.fParentRegion = parentRegion; - this.fFirstRegion = firstRegion; - this.fLastRegion = lastRegion; - - if (firstRegion == null && lastRegion == null) { - setFirstRegion(null); - setLastRegion(null); - } - else { // range validation - validateRange(); - } - } - - /** - * @return boolean - */ - private boolean validateRange() { - boolean bModified = false; - - if (this.fFirstRegion != null || this.fLastRegion != null) { - if (this.fFirstRegion == null) { - this.fFirstRegion = this.fLastRegion; - bModified = true; - } - else if (this.fLastRegion == null) { - this.fLastRegion = this.fFirstRegion; - bModified = true; - } - else if (this.fFirstRegion.getStart() > this.fLastRegion.getStart()) { - // need to swap first for last - ITextRegion reg = fFirstRegion; - fFirstRegion = fLastRegion; - fLastRegion = reg; - bModified = true; - } - } - return bModified; - } -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSRuleDeclContainer.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSRuleDeclContainer.java deleted file mode 100644 index 64381642dc..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSRuleDeclContainer.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.document; - - - -import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode; -import org.w3c.dom.css.CSSStyleDeclaration; - - -/** - * - */ -abstract class CSSRuleDeclContainer extends CSSRuleImpl { - - /** - * CSSRuleDeclContainer constructor comment. - */ - CSSRuleDeclContainer() { - super(); - } - - /** - * CSSRuleDeclContainer constructor comment. - * - */ - CSSRuleDeclContainer(CSSRuleDeclContainer that) { - super(that); - } - - /** - * @return java.lang.String - */ - abstract String extractPreString(); - - /** - * @return org.w3c.dom.css.CSSStyleDeclaration - */ - public CSSStyleDeclaration getStyle() { - - for (ICSSNode node = getFirstChild(); node != null; node = node.getNextSibling()) { - if (node instanceof CSSStyleDeclaration) - return (CSSStyleDeclaration) node; - } - - return null; - } -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSRuleImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSRuleImpl.java deleted file mode 100644 index 32e6e38290..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSRuleImpl.java +++ /dev/null @@ -1,80 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.document; - - - -import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode; -import org.w3c.dom.css.CSSRule; -import org.w3c.dom.css.CSSStyleSheet; - - -/** - * - */ -abstract class CSSRuleImpl extends CSSStructuredDocumentRegionContainer implements CSSRule { - - /** - * - */ - CSSRuleImpl() { - super(); - } - - CSSRuleImpl(CSSRuleImpl that) { - super(that); - } - - /** - * If this rule is contained inside another rule (e.g. a style rule inside - * an - * - * @media block), this is the containing rule. If this rule is not nested - * inside any other rules, this returns null. - */ - public CSSRule getParentRule() { - ICSSNode rule = getParentNode(); - - // parent rule is used only if parent is media rule - if (rule instanceof CSSMediaRuleImpl) - return (CSSRule) rule; - - return null; - } - - /** - * The style sheet that contains this rule. - */ - public CSSStyleSheet getParentStyleSheet() { - ICSSNode parent = getParentNode(); - while (parent != null) { - if (parent instanceof CSSStyleSheetImpl) - return (CSSStyleSheet) parent; - parent = parent.getParentNode(); - } - return null; - } - - /** - * The type of the rule, as defined above. The expectation is that - * binding-specific casting methods can be used to cast down from an - * instance of the CSSRule interface to the specific - * derived interface implied by the type. - */ - public abstract short getType(); - - /** - * @return boolean - */ - public boolean hasProperties() { - return true; - } -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSRuleListImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSRuleListImpl.java deleted file mode 100644 index 51f15a490b..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSRuleListImpl.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.document; - - - -import org.w3c.dom.css.CSSRule; -import org.w3c.dom.css.CSSRuleList; - -/** - * - */ -public class CSSRuleListImpl extends AbstractCSSNodeList implements CSSRuleList { - - /** - * - */ - CSSRuleListImpl() { - super(); - } - - /** - * Used to retrieve a CSS rule by ordinal index. The order in this - * collection represents the order of the rules in the CSS style sheet. If - * index is greater than or equal to the number of rules in the list, this - * returns null. - * - * @param indexIndex - * into the collection - * @return The style rule at the index position in the - * CSSRuleList, or null if that is - * not a valid index. - */ - public CSSRule item(int index) { - return (CSSRule) itemImpl(index); - } -} \ No newline at end of file diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSSelector.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSSelector.java deleted file mode 100644 index 4f039a5522..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSSelector.java +++ /dev/null @@ -1,415 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2011 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.document; - - - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.wst.css.core.internal.provisional.adapters.IStyleSelectorAdapter; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSSelector; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorCombinator; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorItem; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSSimpleSelector; -import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier; -import org.eclipse.wst.xml.core.internal.provisional.NameValidator; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - -import com.ibm.icu.util.StringTokenizer; - -class CSSSelector implements ICSSSelector { - - private int fSpecificity = -1; - private String fCachedString = null; - private List fTokens = null; - private List fItems = null; - private List fParseErrors = null; - private List fNameErrors = null; - - CSSSelector(List tokens) { - fTokens = new ArrayList(tokens); - } - - /** - * @return boolean - * @param obj - * java.lang.Object - */ - public boolean equals(Object obj) { - if (this == obj) - return true; - - if (obj == null || this.getClass() != obj.getClass()) - return false; - - CSSSelector foreign = (CSSSelector) obj; - - // if (fSpecificity != foreign.fSpecificity) return false; - - if (getLength() != foreign.getLength()) - return false; - - for (int i = 0; i < getLength(); i++) { - if (!getItem(i).equals(foreign.getItem(i))) - return false; - } - - return true; - } - - public ICSSSelectorItem getItem(int index) { - if (fItems == null) { - fItems = parseSelector(fTokens); - } - if (fItems != null && 0 <= index && index < fItems.size()) { - return (ICSSSelectorItem) fItems.get(index); - } - else { - return null; - } - } - - /** - * @return java.util.Iterator - */ - public Iterator getIterator() { - if (fItems == null) { - fItems = parseSelector(fTokens); - } - return (fItems != null) ? fItems.iterator() : null; - } - - /** - * @return int - */ - public int getLength() { - if (fItems == null) { - fItems = parseSelector(fTokens); - } - return (fItems != null) ? fItems.size() : 0; - } - - /** - * @return org.w3c.dom.Element - */ - private Element getParentElement(Element element) { - Node node = element.getParentNode(); - if (node != null && node.getNodeType() == Node.ELEMENT_NODE) { - return (Element) node; - } - return null; - } - - /** - * @return org.w3c.dom.Element - */ - private Element getPreviousElement(Element element) { - Element p = null; - for (Node node = element.getPreviousSibling(); node != null; node = node.getPreviousSibling()) { - if (node.getNodeType() == Node.ELEMENT_NODE) { - p = (Element) node; - break; - } - } - return p; - } - - /** - * Calculate a selector's specificity a = the number of ID attributes in - * the selector b = the number of other attributes and pseudo-classes in - * the selector c = the number of element names in the selector (ignore - * pseudo-elements) Concatenating the three numbers a-b-c (in a number - * system with a large base) gives the specificity. - * - * @return int - */ - public int getSpecificity() { - if (fSpecificity < 0) { - int nIDs = 0; - int nAttributes = 0; - int nElements = 0; - Iterator i = getIterator(); - while (i.hasNext()) { - ICSSSelectorItem item = (ICSSSelectorItem) i.next(); - if (item instanceof CSSSimpleSelector) { - CSSSimpleSelector selector = (CSSSimpleSelector) item; - nIDs += selector.getNumOfIDs(); - nAttributes += selector.getNumOfAttributes(); - nAttributes += selector.getNumOfClasses(); - nAttributes += selector.getNumOfPseudoNames(); - if (!selector.isUniversal()) { - nElements++; - } - } - } - fSpecificity = nIDs * 10000 + nAttributes * 100 + nElements; - } - - return fSpecificity; - } - - /** - * @return java.lang.String - */ - public String getString() { - if (fCachedString == null) { - StringBuffer buf = new StringBuffer(); - Iterator i = getIterator(); - while (i.hasNext()) { - ICSSSelectorItem item = (ICSSSelectorItem) i.next(); - if (item instanceof CSSSelectorCombinator) { - // If item is DESCENDANT combinator, it is just single - // space. - // Then, you dont have to append string.. - if (((CSSSelectorCombinator) item).getCombinatorType() != ICSSSelectorCombinator.DESCENDANT) { - buf.append(" ");//$NON-NLS-1$ - buf.append(item.getString()); - } - buf.append(" ");//$NON-NLS-1$ - } - else { - buf.append(item.getString()); - } - } - fCachedString = buf.toString(); - } - - return fCachedString; - } - - /** - * @return boolean - * @param element - * org.w3c.dom.Element - */ - public boolean match(org.w3c.dom.Element element, java.lang.String pseudoName) { - Element target = element; - char combinatorType = ICSSSelectorCombinator.UNKNOWN; - Element chunkStartElement = null; // for CHILD and ADJACENT - // combinator - int chunkStartItem = -1; // for CHILD and ADJACENT combinator - int numItems = getLength(); - for (int iItem = numItems - 1; iItem >= 0; iItem--) { - // Check Selector Items - ICSSSelectorItem item = getItem(iItem); - if (item instanceof ICSSSimpleSelector) { - // Simple Selector - if (target == null) - return false; - if (!matchExactly((ICSSSimpleSelector) item, target, pseudoName)) { - switch (combinatorType) { - case ICSSSelectorCombinator.DESCENDANT : - do { - target = getParentElement(target); - if (target == null) - return false; - } - while (!matchExactly((ICSSSimpleSelector) item, target, pseudoName)); - break; - case ICSSSelectorCombinator.CHILD : - case ICSSSelectorCombinator.ADJACENT : - if (chunkStartElement != null && chunkStartElement != element) { - // previous conbinator must be DESCENDENT. - // goto parent - target = getParentElement(chunkStartElement); - iItem = chunkStartItem + 1; - chunkStartElement = null; - chunkStartItem = -1; - break; - } - default : - // other combinators are not supported yet. - return false; - } - } - } - else if (item instanceof ICSSSelectorCombinator) { - // Combinator ( "+", ">", " ", ...) - if (iItem == numItems - 1) - return false; // last item is combinator - - ICSSSelectorCombinator sc = (ICSSSelectorCombinator) item; - combinatorType = sc.getCombinatorType(); - switch (combinatorType) { - case ICSSSelectorCombinator.DESCENDANT : - target = getParentElement(target); - break; - case ICSSSelectorCombinator.CHILD : - case ICSSSelectorCombinator.ADJACENT : - if (chunkStartElement == null) { - chunkStartElement = target; - chunkStartItem = iItem + 1; // safe because this - // is not a last item. - } - if (combinatorType == ICSSSelectorCombinator.CHILD) { - target = getParentElement(target); - } - else { - target = getPreviousElement(target); - } - break; - } - } - else { - // what is this item ??? - return false; - } - } - // OK this selector maches the element. - return true; - - } - - /** - * @return boolean - */ - private boolean matchExactly(ICSSSimpleSelector selector, Element element, String pseudoName) { - IStyleSelectorAdapter adapter = (IStyleSelectorAdapter) ((INodeNotifier) element).getAdapterFor(IStyleSelectorAdapter.class); - if (adapter != null) { - return adapter.match(selector, element, pseudoName); - } - - if (element == null) - return false; - int i; - String key; - - // TODO: PseudoName - - // check tag name - if (!selector.isUniversal() && !element.getNodeName().equals(selector.getName())) - return false; - - // check id - i = selector.getNumOfIDs(); - if (i > 0) { - if (i > 1) - return false; - if (!element.hasAttribute("id") || (key = element.getAttribute("id")).length() == 0)//$NON-NLS-1$ //$NON-NLS-2$ - return false; - if (!selector.getID(0).equals(key)) - return false; - } - - // check class - i = selector.getNumOfClasses(); - if (i > 0) { - if (!element.hasAttribute("class") || (key = element.getAttribute("class")).length() == 0) //$NON-NLS-1$ //$NON-NLS-2$ - return false; - StringTokenizer tokenizer = new StringTokenizer(key); - for (i = i - 1; i >= 0; i--) { - boolean ok = false; - while (tokenizer.hasMoreTokens()) { - if (selector.getClass(i).equals(tokenizer.nextToken())) { - ok = true; - break; - } - } - if (!ok) - return false; - } - } - - // check attributes - for (i = selector.getNumOfAttributes() - 1; i >= 0; i--) { - StringTokenizer tokenizer = new StringTokenizer(selector.getAttribute(i), "=~| \t\r\n\f");//$NON-NLS-1$ - int countTokens = tokenizer.countTokens(); - if (countTokens > 0) { - String attrName = tokenizer.nextToken(); - String attrValue = null; - if (!element.hasAttribute(attrName) || (attrValue = element.getAttribute(attrName)).length() == 0) - return false; - if (countTokens > 1) { - String token = tokenizer.nextToken("= \t\r\n\f");//$NON-NLS-1$ - StringTokenizer attrValueTokenizer = null; - if (token.equals("~")) {//$NON-NLS-1$ - attrValueTokenizer = new StringTokenizer(attrValue); - } - else if (token.equals("|")) {//$NON-NLS-1$ - attrValueTokenizer = new StringTokenizer(attrValue, "-");//$NON-NLS-1$ - } - if (attrValueTokenizer != null) { - if (tokenizer.hasMoreTokens()) { - token = tokenizer.nextToken(); - boolean ok = false; - while (attrValueTokenizer.hasMoreTokens()) { - if (token.equals(attrValueTokenizer.nextToken())) { - ok = true; - break; - } - } - if (!ok) - return false; - } - } - else { - if (!attrValue.equals(token)) - return false; - } - } - } - } - - return true; - } - - private List parseSelector(List tokens) { - CSSSelectorParser parser = new CSSSelectorParser(tokens); - List selector = parser.getSelector(); - Iterator i = parser.getErrors(); - fParseErrors = new ArrayList(); - while (i.hasNext()) { - fParseErrors.add(i.next()); - } - return selector; - } - - public Iterator getErrors() { - if (fNameErrors == null) { - fNameErrors = new ArrayList(); - Iterator iItem = getIterator(); - while (iItem.hasNext()) { - ICSSSelectorItem item = (ICSSSelectorItem) iItem.next(); - if (item instanceof ICSSSimpleSelector) { - if (!((ICSSSimpleSelector) item).isUniversal()) { - String name = ((ICSSSimpleSelector) item).getName(); - if (!NameValidator.isValid(name)) { - fNameErrors.add(item); - } - } - } - } - } - List errors = new ArrayList(fParseErrors); - errors.addAll(fNameErrors); - return errors.iterator(); - } - - public String toString() { - return getString(); - } - - /** - * @see ICSSSelector#getErrorCount() - */ - public int getErrorCount() { - int nErrors = 0; - Iterator i = getErrors(); - while (i.hasNext()) { - nErrors++; - i.next(); - } - return nErrors; - } -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSSelectorCombinator.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSSelectorCombinator.java deleted file mode 100644 index d015aa515a..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSSelectorCombinator.java +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.document; - - - -import org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorCombinator; - -/** - * - */ -class CSSSelectorCombinator extends CSSSelectorItem implements ICSSSelectorCombinator { - - char fType = ICSSSelectorCombinator.UNKNOWN; - - /** - * CSSSelectorCombinator constructor comment. - */ - public CSSSelectorCombinator(char type) { - super(); - setCombinatorType(type); - } - - /** - * @return boolean - * @param obj - * java.lang.Object - */ - public boolean equals(Object obj) { - if (this == obj) - return true; - - if (obj == null || this.getClass() != obj.getClass()) - return false; - - CSSSelectorCombinator foreign = (CSSSelectorCombinator) obj; - - return (getCombinatorType() == foreign.getCombinatorType()); - - } - - /** - * @return int - */ - public char getCombinatorType() { - return fType; - } - - /** - * @return int - */ - public int getItemType() { - return COMBINATOR; - } - - /** - * @return java.lang.String - */ - public String getString() { - StringBuffer buf = new StringBuffer(); - buf.append(fType); - return buf.toString(); - } - - void setCombinatorType(char type) { - fType = type; - } -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSSelectorItem.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSSelectorItem.java deleted file mode 100644 index 3436661aa0..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSSelectorItem.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.document; - - - -import org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorItem; - -/** - * - */ -abstract class CSSSelectorItem implements ICSSSelectorItem { - - /** - * CSSSelectorItem constructor comment. - */ - public CSSSelectorItem() { - super(); - } - - /** - * @return int - */ - public int getItemType() { - return 0; - } - - /** - * @return java.lang.String - */ - public String getString() { - return null; - } -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSSelectorListImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSSelectorListImpl.java deleted file mode 100644 index ed231f9f5a..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSSelectorListImpl.java +++ /dev/null @@ -1,207 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.document; - - - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.wst.css.core.internal.parserz.CSSRegionContexts; -import org.eclipse.wst.css.core.internal.parserz.CSSTextParser; -import org.eclipse.wst.css.core.internal.parserz.CSSTextToken; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSSelector; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorList; -import org.w3c.dom.Element; - - -/** - * - */ -public class CSSSelectorListImpl implements ICSSSelectorList { - - private String fText = null; - private String fCachedString = null; // normalized string - private List fSelectors = null; - - public CSSSelectorListImpl(String cssText) { - super(); - fText = cssText; - parseSelectorText(); - } - - /** - * @return boolean - * @param obj - * java.lang.Object - */ - public boolean equals(Object obj) { - if (this == obj) - return true; - - if (obj == null || this.getClass() != obj.getClass()) - return false; - - CSSSelectorListImpl foreign = (CSSSelectorListImpl) obj; - - if (getLength() != foreign.getLength()) - return false; - - for (int i = 0; i < getLength(); i++) { - if (!getSelector(i).equals(foreign.getSelector(i))) - return false; - } - - return true; - } - - /** - * @return java.util.Iterator - */ - public Iterator getIterator() { - return getSelectors().iterator(); - } - - /** - * @return int - */ - public int getLength() { - return getSelectors().size(); - } - - public ICSSSelector getSelector(int index) { - List selectors = getSelectors(); - if (0 <= index && index < selectors.size()) { - return (ICSSSelector) selectors.get(index); - } - else { - return null; - } - } - - private List getSelectors() { - if (fSelectors == null) { - parseSelectorText(); - } - return fSelectors; - } - - /** - * @return java.lang.String - */ - public String getString() { - if (fCachedString == null) { - StringBuffer buf = new StringBuffer(); - boolean bFirst = true; - // groups is list of comma-separated selectors - Iterator i = getSelectors().iterator(); - while (i.hasNext()) { - if (!bFirst) { - buf.append(", ");//$NON-NLS-1$ - } - ICSSSelector item = (ICSSSelector) i.next(); - buf.append(item.getString()); - bFirst = false; - } - fCachedString = buf.toString(); - } - return fCachedString; - } - - /** - * @return boolean - * @param element - * org.w3c.dom.Element - */ - public boolean match(Element element, String pseudoName) { - int nSelectors = getLength(); - for (int iSelector = 0; iSelector < nSelectors; iSelector++) { - // Check each Selector Lists - ICSSSelector selector = getSelector(iSelector); - if (selector.match(element, pseudoName)) - return true; - } - return false; - } - - /** - * - */ - private void parseSelectorText() { - fSelectors = new ArrayList(); - if (fText == null) { - return; - } - - CSSTextParser parser = new CSSTextParser(CSSTextParser.MODE_STYLESHEET, fText); - CSSTextToken[] tokens = parser.getTokens(); - if (tokens.length <= 0) { - return; - } - - List tokenGroup = new ArrayList(); - for (int i = 0; i < tokens.length; i++) { - CSSTextToken token = tokens[i]; - if (token.kind == CSSRegionContexts.CSS_SELECTOR_SEPARATOR && 0 < tokenGroup.size()) { - ICSSSelector selector = new CSSSelector(tokenGroup); - if (selector != null) { - fSelectors.add(selector); - } - tokenGroup.clear(); - } - else { - tokenGroup.add(tokens[i]); - } - } - if (0 < tokenGroup.size()) { - ICSSSelector selector = new CSSSelector(tokenGroup); - if (selector != null) { - fSelectors.add(selector); - } - } - } - - /** - * - */ - public String toString() { - return getString(); - } - - /** - * - */ - public Iterator getErrors() { - List errors = new ArrayList(); - Iterator iSelector = getSelectors().iterator(); - while (iSelector.hasNext()) { - Iterator iError = ((ICSSSelector) iSelector.next()).getErrors(); - while (iError.hasNext()) { - errors.add(iError.next()); - } - } - return errors.iterator(); - } - - /** - * - */ - public int getErrorCount() { - int nErrors = 0; - Iterator i = getErrors(); - while (i.hasNext()) { - nErrors++; - i.next(); - } - return nErrors; - } -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSSelectorParser.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSSelectorParser.java deleted file mode 100644 index b605610a89..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSSelectorParser.java +++ /dev/null @@ -1,335 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.document; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.wst.css.core.internal.parserz.CSSRegionContexts; -import org.eclipse.wst.css.core.internal.parserz.CSSTextToken; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorCombinator; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorItem; - - -/** - * - */ -public class CSSSelectorParser { - - private final static int IDLE = 0; - private final static int ATTRIBUTE = 1; - private final static int SIMPLE = 2; - - private List fTokens = null; - private List fItems = null; - private List fErrors = null; - - /** - * - */ - CSSSelectorParser(List tokens) { - super(); - fTokens = new ArrayList(tokens); - } - - /** - * - */ - List getSelector() { - if (fItems == null) { - parseSelector(); - } - return fItems; - } - - /** - * - */ - private void parseSelector() { - fItems = new ArrayList(); - - List attrBuf = null; - CSSSimpleSelector item = null; - - int status = IDLE; - Iterator i = fTokens.iterator(); - while (i.hasNext()) { - CSSTextToken token = (CSSTextToken) i.next(); - if (token == null || token.kind == CSSRegionContexts.CSS_S || token.kind == CSSRegionContexts.CSS_COMMENT) { - continue; - } - switch (status) { - case IDLE : - if (isTag(token)) { - item = createSimple(); - appendTag(item, token); - status = SIMPLE; - } - else if (isID(token)) { - item = createSimple(); - appendID(item, token); - status = SIMPLE; - } - else if (isClass(token)) { - item = createSimple(); - appendClass(item, token); - status = SIMPLE; - } - else if (isPseudo(token)) { - item = createSimple(); - appendPseudo(item, token); - status = SIMPLE; - } - else if (isAttributeBegin(token)) { - item = createSimple(); - status = ATTRIBUTE; - } - else { - addError(token); - } - break; - case SIMPLE : - if (isID(token)) { - appendID(item, token); - } - else if (isClass(token)) { - appendClass(item, token); - } - else if (isPseudo(token)) { - appendPseudo(item, token); - } - else if (isAttributeBegin(token)) { - status = ATTRIBUTE; - } - else if (isCombinator(token)) { // combinator - closeItem(item); - closeItem(createCombinator(token)); - status = IDLE; - } - else { - addError(token); - } - break; - case ATTRIBUTE : - if (isAttributeEnd(token)) { - appendAttribute(item, attrBuf); - attrBuf = null; - status = SIMPLE; - } - else { - if (attrBuf == null) { - attrBuf = new ArrayList(); - } - attrBuf.add(token); - if (!isAttributeContent(token)) { - addError(token); - } - } - break; - default : - break; - } - } - - closeItem(item); - } - - /** - * @param token - * @return - */ - private boolean isAttributeContent(CSSTextToken token) { - String type = token.kind; - return (type == CSSRegionContexts.CSS_SELECTOR_ATTRIBUTE_NAME || type == CSSRegionContexts.CSS_SELECTOR_ATTRIBUTE_OPERATOR || type == CSSRegionContexts.CSS_SELECTOR_ATTRIBUTE_VALUE); - } - - /** - * @param token - * @return - */ - private boolean isAttributeEnd(CSSTextToken token) { - String type = token.kind; - return (type == CSSRegionContexts.CSS_SELECTOR_ATTRIBUTE_END); - } - - /** - * @param token - * @return - */ - private boolean isAttributeBegin(CSSTextToken token) { - String type = token.kind; - return (type == CSSRegionContexts.CSS_SELECTOR_ATTRIBUTE_START); - } - - /** - * @param token - * @return - */ - private boolean isCombinator(CSSTextToken token) { - String type = token.kind; - return (type == CSSRegionContexts.CSS_SELECTOR_COMBINATOR); - } - - /** - * @param token - * @return - */ - private boolean isPseudo(CSSTextToken token) { - String type = token.kind; - return (type == CSSRegionContexts.CSS_SELECTOR_PSEUDO); - } - - /** - * @param token - * @return - */ - private boolean isClass(CSSTextToken token) { - String type = token.kind; - return (type == CSSRegionContexts.CSS_SELECTOR_CLASS); - } - - /** - * @param token - * @return - */ - private boolean isID(CSSTextToken token) { - String type = token.kind; - return (type == CSSRegionContexts.CSS_SELECTOR_ID); - } - - /** - * @param token - * @return - */ - private boolean isTag(CSSTextToken token) { - String type = token.kind; - return (type == CSSRegionContexts.CSS_SELECTOR_ELEMENT_NAME || type == CSSRegionContexts.CSS_SELECTOR_UNIVERSAL || type == CSSRegionContexts.CSS_UNKNOWN); - } - - private CSSSimpleSelector createSimple() { - return new CSSSimpleSelector(); - } - - /** - * if " " or "+" or ">" appeared, close simpleselector and add new - * combinator - */ - private CSSSelectorCombinator createCombinator(CSSTextToken token) { - char type = 0; - - String str = token.image; - if (str.trim().length() == 0) { // space - type = ICSSSelectorCombinator.DESCENDANT; - } - else if (str.equals("+")) { //$NON-NLS-1$ - type = ICSSSelectorCombinator.ADJACENT; - } - else if (str.equals(">")) { //$NON-NLS-1$ - type = ICSSSelectorCombinator.CHILD; - } - - if (0 < type) { - return new CSSSelectorCombinator(type); - } - else { - return null; - } - } - - /** - * - */ - private void closeItem(ICSSSelectorItem item) { - if (item != null) { - fItems.add(item); - } - } - - private void appendTag(CSSSimpleSelector item, CSSTextToken token) { - item.setName(token.image); - if (token.kind == CSSRegionContexts.CSS_UNKNOWN) { - addError(token); - } - } - - /** - * if "#xxxx" appeared, add ID to current selector - */ - private void appendID(CSSSimpleSelector item, CSSTextToken token) { - String text = token.toString(); - String idContent = text.substring(1, text.length()); - item.addID(idContent); - } - - /** - * if ".xxxx" appeared, add Class to current selector - */ - private void appendClass(CSSSimpleSelector item, CSSTextToken token) { - String text = token.toString(); - String classContent = text.substring(1, text.length()); - item.addClass(classContent); - if (Character.isDigit(classContent.charAt(0))) { - addError(token); - } - } - - /** - * if ":xxxx" appeared, add Pseudo(element/class) to current selector - */ - private void appendPseudo(CSSSimpleSelector item, CSSTextToken token) { - String text = token.toString(); - String pseudoContent = text.substring(1, text.length()); - item.addPseudoName(pseudoContent); - } - - /** - * - */ - private void appendAttribute(CSSSimpleSelector item, List tokens) { - StringBuffer buf = new StringBuffer(); - - CSSTextToken token; - Iterator i = tokens.iterator(); - while (i.hasNext()) { - token = (CSSTextToken) i.next(); - buf.append(token.image); - } - - item.addAttribute(buf.toString()); - } - - /** - * - */ - List getSelectorTags() { - List tagList = new ArrayList(); - return tagList; - } - - /** - * - */ - private void addError(CSSTextToken token) { - if (fErrors == null) { - fErrors = new ArrayList(); - } - fErrors.add(token); - } - - /** - * - */ - Iterator getErrors() { - return (fErrors == null) ? Collections.EMPTY_LIST.iterator() : fErrors.iterator(); - } -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSSimpleSelector.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSSimpleSelector.java deleted file mode 100644 index 5928e90dfe..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSSimpleSelector.java +++ /dev/null @@ -1,281 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.document; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.wst.css.core.internal.provisional.document.ICSSSimpleSelector; - - -/** - * - */ -class CSSSimpleSelector extends CSSSelectorItem implements ICSSSimpleSelector { - - private String fName = null; - private String fCachedString = null; - private StringBuffer fStringBuf = null; - private List fPseudoName = null; - private List fAttribute = null; - private List fClass = null; - private List fID = null; - - /** - * CSSSimpleSelector constructor comment. - */ - public CSSSimpleSelector() { - super(); - } - - /** - * - */ - void addAttribute(String attribute) { - if (fAttribute == null) { - fAttribute = new ArrayList(); - } - fAttribute.add(attribute); - addToBuf("[");//$NON-NLS-1$ - addToBuf(attribute); - addToBuf("]");//$NON-NLS-1$ - fCachedString = null; - } - - /** - * - */ - void addClass(String cls) { - if (fClass == null) { - fClass = new ArrayList(); - } - fClass.add(cls); - addToBuf(".");//$NON-NLS-1$ - addToBuf(cls); - fCachedString = null; - } - - /** - * - */ - void addID(String id) { - if (fID == null) { - fID = new ArrayList(); - } - fID.add(id); - addToBuf("#");//$NON-NLS-1$ - addToBuf(id); - fCachedString = null; - } - - /** - * - */ - void addPseudoName(String cls) { - if (fPseudoName == null) { - fPseudoName = new ArrayList(); - } - fPseudoName.add(cls); - addToBuf(":");//$NON-NLS-1$ - addToBuf(cls); - fCachedString = null; - } - - /** - * - */ - private void addToBuf(String str) { - if (fStringBuf == null) { - fStringBuf = new StringBuffer(); - } - fStringBuf.append(str); - } - - /** - * @return boolean - * @param obj - * java.lang.Object - */ - public boolean equals(Object obj) { - if (this == obj) - return true; - - if (obj == null || this.getClass() != obj.getClass()) - return false; - - CSSSimpleSelector foreign = (CSSSimpleSelector) obj; - - if (getName().compareToIgnoreCase(foreign.getName()) != 0) - return false; - - int i; - - // compare pseudo-classes / pseudo-elements - if (getNumOfPseudoNames() != foreign.getNumOfPseudoNames()) - return false; - for (i = 0; i < getNumOfPseudoNames(); i++) { - if (getPseudoName(i).compareToIgnoreCase(foreign.getPseudoName(i)) != 0) - return false; - } - - // compare classes - if (getNumOfClasses() != foreign.getNumOfClasses()) - return false; - for (i = 0; i < getNumOfClasses(); i++) { - if (getClass(i).compareToIgnoreCase(foreign.getClass(i)) != 0) - return false; - } - - // compare IDs - if (getNumOfIDs() != foreign.getNumOfIDs()) - return false; - for (i = 0; i < getNumOfIDs(); i++) { - if (getID(i).compareToIgnoreCase(foreign.getID(i)) != 0) - return false; - } - - // compare Attributes - if (getNumOfAttributes() != foreign.getNumOfAttributes()) - return false; - for (i = 0; i < getNumOfAttributes(); i++) { - if (getAttribute(i).compareToIgnoreCase(foreign.getAttribute(i)) != 0) - return false; - } - return true; - } - - /** - * @return java.lang.String - * @param index - * int - */ - public String getAttribute(int index) { - if (fAttribute != null && 0 <= index && index < fAttribute.size()) { - return (String) fAttribute.get(index); - } - else { - return "";//$NON-NLS-1$ - } - } - - /** - * @return java.lang.String - * @param index - * int - */ - public String getClass(int index) { - if (fClass != null && 0 <= index && index < fClass.size()) { - return (String) fClass.get(index); - } - else { - return "";//$NON-NLS-1$ - } - } - - /** - * @return java.lang.String - * @param index - * int - */ - public String getID(int index) { - if (fID != null && 0 <= index && index < fID.size()) { - return (String) fID.get(index); - } - else { - return "";//$NON-NLS-1$ - } - } - - /** - * @return int - */ - public int getItemType() { - return SIMPLE; - } - - /** - * @return java.lang.String - */ - public String getName() { - return (fName != null) ? fName : "";//$NON-NLS-1$ - } - - /** - * @return boolean - */ - public int getNumOfAttributes() { - return (fAttribute != null) ? fAttribute.size() : 0; - } - - /** - * @return boolean - */ - public int getNumOfClasses() { - return (fClass != null) ? fClass.size() : 0; - } - - /** - * @return boolean - */ - public int getNumOfIDs() { - return (fID != null) ? fID.size() : 0; - } - - /** - * @return boolean - */ - public int getNumOfPseudoNames() { - return (fPseudoName != null) ? fPseudoName.size() : 0; - } - - /** - * @return java.lang.String - * @param index - * int - */ - public String getPseudoName(int index) { - if (fPseudoName != null && 0 <= index && index < fPseudoName.size()) { - return (String) fPseudoName.get(index); - } - else { - return "";//$NON-NLS-1$ - } - } - - /** - * @return java.lang.String - */ - public String getString() { - if (fCachedString == null) { - StringBuffer buf = new StringBuffer(getName()); - if (fStringBuf != null) { - buf.append(fStringBuf.toString()); - } - fCachedString = buf.toString(); - } - return fCachedString; - } - - /** - * @return boolean - */ - public boolean isUniversal() { - return (fName == null || fName.equals("*"));//$NON-NLS-1$ - } - - /** - * - */ - void setName(String name) { - fName = name; - fCachedString = null; - } -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSStructuredDocumentRegionContainer.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSStructuredDocumentRegionContainer.java deleted file mode 100644 index 07bf389b2b..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSStructuredDocumentRegionContainer.java +++ /dev/null @@ -1,229 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.document; - - - -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; - -/** - * currently public but may be made default access protected in future. - */ -public abstract class CSSStructuredDocumentRegionContainer extends CSSNodeImpl { - - private IStructuredDocumentRegion firstStructuredDocumentRegion = null; - private IStructuredDocumentRegion lastStructuredDocumentRegion = null; - - /** - * CSSContainer constructor comment. - * currently public but may be made default access protected in future. - */ - public CSSStructuredDocumentRegionContainer() { - super(); - } - /** - * currently public but may be made default access protected in future. - */ - public CSSStructuredDocumentRegionContainer(CSSStructuredDocumentRegionContainer that) { - super(that); - } - - /** - * @return java.lang.String - */ - public String getCssText() { - if (getFirstStructuredDocumentRegion() == null) - return generateSource(); - - StringBuffer str = new StringBuffer(getFirstStructuredDocumentRegion().getText()); - IStructuredDocumentRegion node = getFirstStructuredDocumentRegion(); - - while (node != getLastStructuredDocumentRegion()) { - node = node.getNext(); - str.append(node.getText()); - } - - return str.toString(); - } - - /** - * @return int - */ - public int getEndOffset() { - IStructuredDocumentRegion flatNode = getLastStructuredDocumentRegion(); - if (flatNode != null) - return flatNode.getEnd(); - return -1; - } - - IStructuredDocumentRegion getFirstStructuredDocumentRegion() { - return firstStructuredDocumentRegion; - } - - IStructuredDocumentRegion getStructuredDocumentRegion(int index) { - IStructuredDocumentRegion node = firstStructuredDocumentRegion; - for (int i = index; i > 0; i--) { - if (node == null) - return null; - node = node.getNext(); - } - return node; - } - - /** - * @return int - */ - int getStructuredDocumentRegionCount() { - if (firstStructuredDocumentRegion == null) - return 0; - - IStructuredDocumentRegion node = firstStructuredDocumentRegion; - int i = 0; - for (; node != null; i++) - node = node.getNext(); - return i; - } - - IStructuredDocumentRegion getLastStructuredDocumentRegion() { - return lastStructuredDocumentRegion; - } - - /** - * @return int - */ - public int getStartOffset() { - IStructuredDocumentRegion flatNode = getFirstStructuredDocumentRegion(); - if (flatNode != null) - return flatNode.getStart(); - return -1; - } - - boolean includeRangeStructuredDocumentRegion(IStructuredDocumentRegion first, IStructuredDocumentRegion last) { - boolean bModified = false; - - // validate range of parameters - if (first != null && last != null) { - if (first.getStart() > last.getStart()) { - IStructuredDocumentRegion node = first; - first = last; - last = node; - } - } - - // validate mine - boolean b = validateRange(); - bModified = b || bModified; - - if (first != null) { - if (getFirstStructuredDocumentRegion() == null || getFirstStructuredDocumentRegion().getStart() > first.getStart()) { - setFirstStructuredDocumentRegion(first); - bModified = true; - } - } - - if (last != null) { - if (getLastStructuredDocumentRegion() == null || getLastStructuredDocumentRegion().getStart() < last.getStart()) { - setLastStructuredDocumentRegion(last); - bModified = true; - } - } - - // re-validate - if (bModified) - validateRange(); - - return bModified; - } - - /** - * - */ - public boolean propagateRangeStructuredDocumentRegion() { - boolean bModified = false; - - CSSStructuredDocumentRegionContainer parent = (CSSStructuredDocumentRegionContainer) getParentNode(); - if (parent == null) - return bModified; - - boolean b = parent.includeRangeStructuredDocumentRegion(getFirstStructuredDocumentRegion(), getLastStructuredDocumentRegion()); - bModified = b || bModified; - - if (b) - parent.propagateRangeStructuredDocumentRegion(); - // else need not update range of ancestors - - return bModified; - } - - /** - * @param cssText - * java.lang.String - */ - public void setCssText(String cssText) { - if (firstStructuredDocumentRegion != null) { - getOwnerDocument().getModel().getStructuredDocument().replaceText(this, getStartOffset(), getEndOffset() - getStartOffset(), cssText); - } - else - super.setCssText(cssText); - } - - IStructuredDocumentRegion setFirstStructuredDocumentRegion(IStructuredDocumentRegion node) { - firstStructuredDocumentRegion = node; - return node; - } - - IStructuredDocumentRegion setLastStructuredDocumentRegion(IStructuredDocumentRegion node) { - lastStructuredDocumentRegion = node; - return node; - } - - public void setRangeStructuredDocumentRegion(IStructuredDocumentRegion firstNode, IStructuredDocumentRegion lastNode) { - if (firstNode != null) - setFirstStructuredDocumentRegion(firstNode); - if (lastNode != null) - setLastStructuredDocumentRegion(lastNode); - - if (firstNode == null && lastNode == null) { - setFirstStructuredDocumentRegion(null); - setLastStructuredDocumentRegion(null); - } - else { // range validation - validateRange(); - } - } - - /** - * @return boolean - */ - private boolean validateRange() { - boolean bModified = false; - - if (firstStructuredDocumentRegion != null || lastStructuredDocumentRegion != null) { - if (this.firstStructuredDocumentRegion == null) { - this.firstStructuredDocumentRegion = this.lastStructuredDocumentRegion; - bModified = true; - } - else if (this.lastStructuredDocumentRegion == null) { - this.lastStructuredDocumentRegion = this.firstStructuredDocumentRegion; - bModified = true; - } - else if (this.firstStructuredDocumentRegion.getStart() > this.lastStructuredDocumentRegion.getStart()) { - // need to swap first for last - IStructuredDocumentRegion node = firstStructuredDocumentRegion; - firstStructuredDocumentRegion = lastStructuredDocumentRegion; - lastStructuredDocumentRegion = node; - bModified = true; - } - } - - return bModified; - } -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSStyleDeclItemImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSStyleDeclItemImpl.java deleted file mode 100644 index 94a5cc60b3..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSStyleDeclItemImpl.java +++ /dev/null @@ -1,272 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.document; - - - -import org.eclipse.wst.css.core.internal.contentmodel.PropCMProperty; -import org.eclipse.wst.css.core.internal.encoding.CSSDocumentLoader; -import org.eclipse.wst.css.core.internal.formatter.CSSSourceFormatterFactory; -import org.eclipse.wst.css.core.internal.formatter.CSSSourceGenerator; -import org.eclipse.wst.css.core.internal.formatter.StyleDeclItemFormatter; -import org.eclipse.wst.css.core.internal.parser.CSSSourceParser; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSPrimitiveValue; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclItem; -import org.eclipse.wst.sse.core.internal.document.IDocumentLoader; -import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList; -import org.eclipse.wst.sse.core.internal.text.TextRegionListImpl; -import org.w3c.dom.DOMException; -import org.w3c.dom.css.CSSValue; - - -/** - * - */ -class CSSStyleDeclItemImpl extends CSSStructuredDocumentRegionContainer implements ICSSStyleDeclItem { - - private java.lang.String fPropertyName; - - /** - * CSSStyleDeclItemImpl constructor comment. - * - */ - CSSStyleDeclItemImpl(CSSStyleDeclItemImpl that) { - super(that); - this.fPropertyName = that.fPropertyName; - } - - /** - * CSSStyleDeclItemImpl constructor comment. - */ - CSSStyleDeclItemImpl(String propertyName) { - super(); - this.fPropertyName = propertyName; - } - - /** - * @return org.w3c.dom.css.CSSPrimitiveValue - * @param value - * org.w3c.dom.css.CSSPrimitiveValue - */ - public ICSSPrimitiveValue appendValue(ICSSPrimitiveValue value) throws DOMException { - return insertValueBefore(value, null); - } - - /** - * @param deep - * boolean - */ - public ICSSNode cloneNode(boolean deep) { - CSSStyleDeclItemImpl cloned = new CSSStyleDeclItemImpl(this); - - if (deep) - cloneChildNodes(cloned, deep); - - return cloned; - } - - /** - * @return java.lang.String - */ - String generateValueSource() { - CSSSourceGenerator formatter = CSSSourceFormatterFactory.getInstance().getSourceFormatter(this); - if (formatter != null && formatter instanceof StyleDeclItemFormatter) - return ((StyleDeclItemFormatter) formatter).formatValue(this).toString(); - else - return "";//$NON-NLS-1$ - } - - /** - * @return org.w3c.dom.css.CSSValue - */ - public CSSValue getCSSValue() { - int nValue = getLength(); - if (nValue <= 0) - return null; - else if (nValue == 1) - return item(0); - else - return this; - } - - /** - * @return java.lang.String - */ - public java.lang.String getCSSValueText() { - if (getFirstChild() == null) - return "";//$NON-NLS-1$ - // check whether children has flatnodes - ICSSNode child = getFirstChild(); - while (child != null) { - if (((IndexedRegion) child).getEndOffset() <= 0) - return generateValueSource(); - child = child.getNextSibling(); - } - - IStructuredDocumentRegion node = getFirstStructuredDocumentRegion(); - int start = ((IndexedRegion) getFirstChild()).getStartOffset() - node.getStartOffset(); - int end = ((IndexedRegion) getLastChild()).getEndOffset() - node.getStartOffset(); - return node.getText().substring(start, end); - } - - /** - * @return short - */ - public short getCssValueType() { - return CSS_VALUE_LIST; - } - - /** - * @return int - */ - public int getLength() { - int i = 0; - for (ICSSNode node = getFirstChild(); node != null; node = node.getNextSibling()) { - if (node instanceof CSSPrimitiveValueImpl) - i++; - } - return i; - } - - /** - * @return short - */ - public short getNodeType() { - return STYLEDECLITEM_NODE; - } - - /** - * @return java.lang.String - */ - public java.lang.String getPriority() { - return getAttribute(IMPORTANT); - } - - /** - * @return java.lang.String - */ - public String getPropertyName() { - String name = fPropertyName.trim(); - return PropCMProperty.getInstanceOf(name) != null ? fPropertyName.trim().toLowerCase() : name; - } - - /** - * @return org.w3c.dom.css.CSSPrimitiveValue - * @param newValue - * org.w3c.dom.css.CSSPrimitiveValue - * @param refValue - * org.w3c.dom.css.CSSPrimitiveValue - */ - ICSSPrimitiveValue insertValueBefore(ICSSPrimitiveValue newValue, ICSSPrimitiveValue refValue) { - ICSSNode node = insertBefore((CSSNodeImpl) newValue, (CSSNodeImpl) refValue); - return (ICSSPrimitiveValue) node; - } - - /** - * @return org.w3c.dom.css.CSSValue - * @param index - * int - */ - public CSSValue item(int index) { - int i = 0; - for (ICSSNode node = getFirstChild(); node != null; node = node.getNextSibling()) { - if (node instanceof CSSPrimitiveValueImpl) { - if (i++ == index) - return (CSSValue) node; - } - } - return null; - } - - /** - * @return org.w3c.dom.css.CSSPrimitiveValue - * @param value - * org.w3c.dom.css.CSSPrimitiveValue - */ - public ICSSPrimitiveValue removeValue(ICSSPrimitiveValue value) throws DOMException { - ICSSNode node = removeChild((CSSNodeImpl) value); - return (ICSSPrimitiveValue) node; - } - - /** - * @return org.w3c.dom.css.CSSPrimitiveValue - * @param newValue - * org.w3c.dom.css.CSSPrimitiveValue - * @param oldValue - * org.w3c.dom.css.CSSPrimitiveValue - */ - public ICSSPrimitiveValue replaceValue(ICSSPrimitiveValue newValue, ICSSPrimitiveValue oldValue) throws DOMException { - if (oldValue == null) - return newValue; - if (newValue != null) - insertValueBefore(newValue, oldValue); - return removeValue(oldValue); - } - - /** - * @param value - * java.lang.String - * @exception org.w3c.dom.DOMException - * The exception description. - */ - public void setCssValueText(String value) throws DOMException { - ICSSNode child = getFirstChild(); - while (child != null) { - ICSSNode next = child.getNextSibling(); - if (child instanceof ICSSPrimitiveValue) { - removeChild((CSSNodeImpl) child); - } - child = next; - } - setCssValueTextCore(value); - } - - private void setCssValueTextCore(String value) throws DOMException { - // use temporary document - synchronized (CSSStyleDeclarationImpl.class) { - if (sharedStructuredDocument == null) { - IDocumentLoader loader = new CSSDocumentLoader(); - sharedStructuredDocument = (IStructuredDocument) loader.createNewStructuredDocument(); - ((CSSSourceParser) sharedStructuredDocument.getParser()).setParserMode(CSSSourceParser.MODE_DECLARATION_VALUE); - - } - sharedStructuredDocument.set(value); - IStructuredDocumentRegion node = sharedStructuredDocument.getFirstStructuredDocumentRegion(); - - if (node == null) { - return; - } - if (node.getNext() != null) { - throw new DOMException(DOMException.INVALID_MODIFICATION_ERR, "");//$NON-NLS-1$ - } - - CSSDeclarationItemParser itemParser = new CSSDeclarationItemParser(getOwnerDocument()); - itemParser.setStructuredDocumentTemporary(true); - // make a copy of nodelist because setupValues will destroy list - ITextRegionList nodeList = new TextRegionListImpl(node.getRegions()); - itemParser.setupValues(this, node, nodeList); - } - } - - private static IStructuredDocument sharedStructuredDocument; - - /** - * @param newPriority - * java.lang.String - */ - public void setPriority(java.lang.String newPriority) throws DOMException { - setAttribute(IMPORTANT, newPriority); - } -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSStyleDeclarationFactoryContext.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSStyleDeclarationFactoryContext.java deleted file mode 100644 index 1d56480f10..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSStyleDeclarationFactoryContext.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.document; - - - -import org.eclipse.wst.css.core.internal.provisional.document.ICSSDocument; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclaration; - -public abstract class CSSStyleDeclarationFactoryContext { - - protected ICSSDocument fOwnerDocument = null; - - /** - * - */ - protected void cloneChildNodes(ICSSNode src, ICSSNode dest) { - if (fOwnerDocument == null) { - return; - } - if (!(dest instanceof CSSNodeImpl)) { - return; - } - - CSSNodeImpl container = (CSSNodeImpl) dest; - container.removeChildNodes(); - - for (ICSSNode child = src.getFirstChild(); child != null; child = child.getNextSibling()) { - if (child instanceof CSSStyleDeclItemImpl) { - // extract shorthand property .. - // --> Temp - ICSSNode cloned = child.cloneNode(false); - if (cloned instanceof CSSNodeImpl) { - ((CSSNodeImpl) cloned).setOwnerDocument(fOwnerDocument); - container.appendChild((CSSNodeImpl) cloned); - cloneChildNodes(child, cloned); - } - // <-- Temp - } - else { - ICSSNode cloned = child.cloneNode(false); - if (cloned instanceof CSSNodeImpl) { - ((CSSNodeImpl) cloned).setOwnerDocument(fOwnerDocument); - container.appendChild((CSSNodeImpl) cloned); - cloneChildNodes(child, cloned); - } - } - } - } - - /** - * @return org.eclipse.wst.css.core.model.interfaces.ICSSStyleDeclaration - */ - public ICSSStyleDeclaration createStyleDeclaration() { - CSSStyleDeclarationImpl decl = new CSSStyleDeclarationImpl(true); - decl.setOwnerDocument(decl); - return decl; - } - -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSStyleDeclarationImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSStyleDeclarationImpl.java deleted file mode 100644 index 90aed46160..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSStyleDeclarationImpl.java +++ /dev/null @@ -1,272 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.document; - - - -import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclItem; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclaration; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSValue; -import org.w3c.dom.DOMException; -import org.w3c.dom.css.CSSRule; -import org.w3c.dom.css.CSSValue; - - -/** - * - */ -class CSSStyleDeclarationImpl extends CSSDocumentImpl implements ICSSStyleDeclaration { - - private boolean fIsDocument; - - CSSStyleDeclarationImpl(CSSStyleDeclarationImpl that) { - super(that); - this.fIsDocument = that.fIsDocument; - if (fIsDocument) { - setOwnerDocument(this); - } - } - - CSSStyleDeclarationImpl(boolean isDocument) { - super(); - fIsDocument = isDocument; - if (fIsDocument) { - setOwnerDocument(this); - } - } - - public ICSSNode cloneNode(boolean deep) { - CSSStyleDeclarationImpl cloned = new CSSStyleDeclarationImpl(this); - - if (deep) - cloneChildNodes(cloned, deep); - - return cloned; - } - - public ICSSStyleDeclItem getDeclItemNode(String propertyName) { - ICSSNode node = getLastChild(); - propertyName = propertyName.trim(); - while (node != null) { - if (node instanceof CSSStyleDeclItemImpl) { - ICSSStyleDeclItem item = (ICSSStyleDeclItem) node; - if (propertyName.compareToIgnoreCase(item.getPropertyName().trim()) == 0) - return item; - } - node = node.getPreviousSibling(); - } - return null; - } - - /** - * @return int - */ - public int getLength() { - int i = 0; - ICSSNode node = getFirstChild(); - while (node != null) { - if (node instanceof CSSStyleDeclItemImpl) - i++; - node = node.getNextSibling(); - } - return i; - } - - /** - * @return short - */ - public short getNodeType() { - return STYLEDECLARATION_NODE; - } - - /** - * The CSS rule that contains this declaration block or null - * if this CSSStyleDeclaration is not attached to a - * CSSRule. - */ - public CSSRule getParentRule() { - ICSSNode parent = getParentNode(); - if (parent instanceof CSSRule) - return (CSSRule) parent; - return null; - } - - /** - * Used to retrieve the object representation of the value of a CSS - * property if it has been explicitly set within this declaration block. - * This method returns null if the property is a shorthand - * property. Shorthand property values can only be accessed and modified - * as strings, using the getPropertyValue and - * setProperty methods. - * - * @param propertyName - * The name of the CSS property. See the CSS property index. - * @return Returns the value of the property if it has been explicitly set - * for this declaration block. Returns null if the - * property has not been set. - */ - public CSSValue getPropertyCSSValue(String propertyName) { - ICSSStyleDeclItem item = getDeclItemNode(propertyName); - if (item != null) - return item.getCSSValue(); - return null; - } - - /** - * Used to retrieve the priority of a CSS property (e.g. the - * "important" qualifier) if the property has been - * explicitly set in this declaration block. - * - * @param propertyName - * The name of the CSS property. See the CSS property index. - * @return A string representing the priority (e.g. - * "important") if one exists. The empty string if - * none exists. - */ - public String getPropertyPriority(String propertyName) { - ICSSStyleDeclItem item = getDeclItemNode(propertyName); - if (item != null) - return item.getPriority(); - return null; - } - - /** - * Used to retrieve the value of a CSS property if it has been explicitly - * set within this declaration block. - * - * @param propertyName - * The name of the CSS property. See the CSS property index. - * @return Returns the value of the property if it has been explicitly set - * for this declaration block. Returns the empty string if the - * property has not been set. - */ - public String getPropertyValue(String propertyName) { - CSSValue value = getPropertyCSSValue(propertyName); - if (value != null) - return ((ICSSValue) value).getCSSValueText(); - return null; - } - - /** - * @return boolean - */ - public boolean isDocument() { - return fIsDocument; - } - - /** - * Used to retrieve the properties that have been explicitly set in this - * declaration block. The order of the properties retrieved using this - * method does not have to be the order in which they were set. This - * method can be used to iterate over all properties in this declaration - * block. - * - * @param index - * Index of the property name to retrieve. - * @return The name of the property at this ordinal position. The empty - * string if no property exists at this position. - */ - public String item(int index) { - if (index < 0) - return null; - - int i = 0; - ICSSNode node = getFirstChild(); - while (node != null) { - if (node instanceof CSSStyleDeclItemImpl) { - if (i != index) - i++; - else { - CSSStyleDeclItemImpl item = (CSSStyleDeclItemImpl) node; - return item.getPropertyName(); - } - } - node = node.getNextSibling(); - } - return null; - } - - public ICSSStyleDeclItem removeDeclItemNode(ICSSStyleDeclItem oldDecl) throws DOMException { - return (ICSSStyleDeclItem) removeChild((CSSNodeImpl) oldDecl); - } - - /** - * Used to remove a CSS property if it has been explicitly set within this - * declaration block. - * - * @param propertyName - * The name of the CSS property. See the CSS property index. - * @return Returns the value of the property if it has been explicitly set - * for this declaration block. Returns the empty string if the - * property has not been set or the property name does not - * correspond to a known CSS property. - * @exception DOMException - * NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration - * is readonly or the property is readonly. - */ - public String removeProperty(String propertyName) throws DOMException { - ICSSStyleDeclItem item = getDeclItemNode(propertyName); - if (item != null) { - removeChild((CSSNodeImpl) item); - return item.getCssText(); - } - return null; - } - - public ICSSStyleDeclItem setDeclItemNode(ICSSStyleDeclItem newDecl) throws DOMException { - if (newDecl == null) - return null; - - ICSSStyleDeclItem item = getDeclItemNode(newDecl.getPropertyName()); - if (item != null) - return (ICSSStyleDeclItem) replaceChild((CSSNodeImpl) newDecl, (CSSNodeImpl) item); - else - return (ICSSStyleDeclItem) appendChild((CSSNodeImpl) newDecl); - } - - /** - * Used to set a property value and priority within this declaration - * block. - * - * @param propertyName - * The name of the CSS property. See the CSS property index. - * @param value - * The new value of the property. - * @param priority - * The new priority of the property (e.g. - * "important"). - * @exception DOMException - * SYNTAX_ERR: Raised if the specified value has a syntax - * error and is unparsable.
- * NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration - * is readonly or the property is readonly. - */ - public void setProperty(String propertyName, String value, String priority) throws DOMException { - if (propertyName.equals("")) //$NON-NLS-1$ - throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, ""); //$NON-NLS-1$ - - // You can use this only if CSSValue.setCssText() is implemented - CSSStyleDeclItemImpl item = (CSSStyleDeclItemImpl) getDeclItemNode(propertyName); - if (item == null) { - item = (CSSStyleDeclItemImpl) getOwnerDocument().createCSSStyleDeclItem(propertyName); - appendChild(item); - } - - // ICSSNode next = item.getNextSibling(); - // removeChild(item); - - item.setCssValueText(value); - item.setPriority(priority); - - // insertBefore(item, (CSSNodeImpl)next); - } -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSStyleRuleImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSStyleRuleImpl.java deleted file mode 100644 index 3366f09e5a..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSStyleRuleImpl.java +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.document; - - - -import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorList; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleRule; -import org.w3c.dom.DOMException; - - -/** - * - */ -class CSSStyleRuleImpl extends CSSRuleDeclContainer implements ICSSStyleRule { - - ICSSSelectorList fSelectorList = new CSSSelectorListImpl(null); - - /** - * - */ - CSSStyleRuleImpl() { - super(); - } - - CSSStyleRuleImpl(CSSStyleRuleImpl that) { - super(that); - } - - public ICSSNode cloneNode(boolean deep) { - CSSStyleRuleImpl cloned = new CSSStyleRuleImpl(this); - - if (deep) - cloneChildNodes(cloned, deep); - - return cloned; - } - - /** - * @return java.lang.String - */ - String extractPreString() { - return getSelectorText(); - } - - /** - * @return short - */ - public short getNodeType() { - return STYLERULE_NODE; - } - - public ICSSSelectorList getSelectors() { - return fSelectorList; - } - - /** - * The textual representation of the selector for the rule set. The - * implementation may have stripped out insignificant whitespace while - * parsing the selector. - * - * @exception DOMException - * SYNTAX_ERR: Raised if the specified CSS string value has - * a syntax error and is unparsable.
- * NO_MODIFICATION_ALLOWED_ERR: Raised if this rule is - * readonly. - */ - public String getSelectorText() { - return getAttribute(SELECTOR); - } - - /** - * The type of the rule, as defined above. The expectation is that - * binding-specific casting methods can be used to cast down from an - * instance of the CSSRule interface to the specific - * derived interface implied by the type. - */ - public short getType() { - return STYLE_RULE; - } - - /** - * - */ - public void setSelectorText(String selectorText) throws DOMException { - setAttribute(SELECTOR, selectorText); - fSelectorList = new CSSSelectorListImpl(selectorText); - } -} diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSStyleSheetImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSStyleSheetImpl.java deleted file mode 100644 index 2e66af5d66..0000000000 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSStyleSheetImpl.java +++ /dev/null @@ -1,654 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 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 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.css.core.internal.document; - -import java.util.Iterator; -import java.util.List; -import java.util.Stack; -import java.util.Vector; - -import org.eclipse.wst.css.core.internal.CSSCoreMessages; -import org.eclipse.wst.css.core.internal.encoding.CSSDocumentLoader; -import org.eclipse.wst.css.core.internal.provisional.adapters.IStyleSheetAdapter; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSCharsetRule; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSImportRule; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSMediaRule; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSModel; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSPageRule; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclaration; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleRule; -import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleSheet; -import org.eclipse.wst.css.core.internal.util.ImportRuleCollector; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; -import org.eclipse.wst.sse.core.internal.util.Assert; -import org.w3c.dom.DOMException; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.w3c.dom.css.CSSFontFaceRule; -import org.w3c.dom.css.CSSRule; -import org.w3c.dom.css.CSSRuleList; -import org.w3c.dom.css.CSSStyleSheet; -import org.w3c.dom.css.CSSUnknownRule; -import org.w3c.dom.stylesheets.MediaList; -import org.w3c.dom.stylesheets.StyleSheet; -import org.w3c.dom.stylesheets.StyleSheetList; - -/** - * - */ -class CSSStyleSheetImpl extends CSSDocumentImpl implements ICSSStyleSheet { - - - class InternalNodeList implements NodeList { - - Vector nodes = new Vector(); - - public int getLength() { - if (nodes == null) - return 0; - else - return nodes.size(); - } - - public Node item(int i) { - if (nodes == null) - return null; - if (i < 0 || nodes.size() <= i) - return null; - return (Node) nodes.get(i); - } - } - - class InternalStyleSheetList extends AbstractCSSNodeList implements StyleSheetList { - - public ICSSNode appendNode(ICSSNode node) { - if (nodes == null || !nodes.contains(node)) - return super.appendNode(node); - else - return node; - } - - public StyleSheet item(int i) { - return (StyleSheet) itemImpl(i); - } - } - - private boolean fDisabled = false; - - /** - * - */ - CSSStyleSheetImpl() { - super(); - setOwnerDocument(this); - } - - CSSStyleSheetImpl(CSSStyleSheetImpl that) { - super(that); - setOwnerDocument(this); - } - - /** - * @return org.w3c.dom.css.CSSRule - * @param rule - * org.w3c.dom.css.CSSRule - * @exception org.w3c.dom.DOMException - * The exception description. - */ - public org.w3c.dom.css.CSSRule appendRule(org.w3c.dom.css.CSSRule rule) throws org.w3c.dom.DOMException { - if (rule == null) - return null; - - CSSRule ret = (CSSRule) appendChild((CSSNodeImpl) rule); - return ret; - } - - public ICSSNode cloneNode(boolean deep) { - CSSStyleSheetImpl cloned = new CSSStyleSheetImpl(this); - - if (deep) - cloneChildNodes(cloned, deep); - - return cloned; - } - - /** - * @return org.w3c.dom.css.CSSCharsetRule - */ - public ICSSCharsetRule createCSSCharsetRule() { - CSSCharsetRuleImpl rule = new CSSCharsetRuleImpl(); - rule.setOwnerDocument(this); - return rule; - } - - /** - * @return org.w3c.dom.css.CSSFontFaceRule - */ - public CSSFontFaceRule createCSSFontFaceRule() { - CSSFontFaceRuleImpl rule = new CSSFontFaceRuleImpl(); - CSSStyleDeclarationImpl style = (CSSStyleDeclarationImpl) createCSSStyleDeclaration(); - - rule.appendChild(style); - rule.setOwnerDocument(this); - - return rule; - } - - /** - * @return org.w3c.dom.css.CSSImportRule - */ - public ICSSImportRule createCSSImportRule() { - CSSImportRuleImpl rule = new CSSImportRuleImpl(); - MediaListImpl media = (MediaListImpl) createMediaList(); - - rule.appendChild(media); - rule.setOwnerDocument(this); - - return rule; - } - - /** - * @return org.w3c.dom.css.ICSSMediaRule - */ - public ICSSMediaRule createCSSMediaRule() { - CSSMediaRuleImpl rule = new CSSMediaRuleImpl(); - MediaListImpl media = (MediaListImpl) createMediaList(); - - rule.insertBefore(media, (CSSNodeImpl) rule.getFirstChild()); // media - // must - // be - // the - // top - // of - // children - // list - rule.setOwnerDocument(this); - - return rule; - } - - /** - * @return org.w3c.dom.css.CSSPageRule - */ - public ICSSPageRule createCSSPageRule() { - CSSPageRuleImpl rule = new CSSPageRuleImpl(); - CSSStyleDeclarationImpl style = (CSSStyleDeclarationImpl) createCSSStyleDeclaration(); - - rule.appendChild(style); - rule.setOwnerDocument(this); - - return rule; - } - - /** - * @return org.w3c.dom.css.CSSRule - * @param rule - * java.lang.String - */ - public CSSRule createCSSRule(String rule) { - CSSDocumentLoader loader = new CSSDocumentLoader(); - IStructuredDocument structuredDocument = (IStructuredDocument) loader.createNewStructuredDocument(); - structuredDocument.set(rule); - - //CSSModelParser modelParser = new CSSModelParser((CSSDocumentImpl) getOwnerDocument()); - CSSModelParser modelParser = new CSSModelParser(getOwnerDocument()); - return modelParser.createCSSRule(structuredDocument.getRegionList()); - } - - /** - * @return org.w3c.dom.css.CSSStyleDeclaration - */ - public ICSSStyleDeclaration createCSSStyleDeclaration() { - CSSStyleDeclarationImpl decl = new CSSStyleDeclarationImpl(false); - decl.setOwnerDocument(this); - - return decl; - } - - /** - * @return org.w3c.dom.css.CSSStyleRule - */ - public ICSSStyleRule createCSSStyleRule() { - CSSStyleRuleImpl rule = new CSSStyleRuleImpl(); - CSSStyleDeclarationImpl style = (CSSStyleDeclarationImpl) createCSSStyleDeclaration(); - - rule.appendChild(style); - rule.setOwnerDocument(this); - - return rule; - } - - /** - * @return org.w3c.dom.css.CSSUnknownRule - */ - public CSSUnknownRule createCSSUnknownRule() { - CSSUnknownRuleImpl rule = new CSSUnknownRuleImpl(); - rule.setOwnerDocument(this); - - return rule; - } - - /** - * @return org.w3c.dom.stylesheets.MediaList - */ - public MediaList createMediaList() { - MediaListImpl media = new MediaListImpl(); - media.setOwnerDocument(this); - - return media; - } - - /** - * Used to delete a rule from the style sheet. - * - * @param index - * The index within the style sheet's rule list of the rule to - * remove. - * @exception DOMException - * INDEX_SIZE_ERR: Raised if the specified index does not - * correspond to a rule in the style sheet's rule list. - *
- * NO_MODIFICATION_ALLOWED_ERR: Raised if this style sheet - * is readonly. - */ - public void deleteRule(int index) throws DOMException { - CSSNodeImpl node = getIndexedRule(index); - if (node != null) - removeChild(node); - } - - /** - * The list of all CSS rules contained within the style sheet. This - * includes both rule sets and at-rules. - */ - public CSSRuleList getCssRules() { - CSSRuleListImpl list = new CSSRuleListImpl(); - - for (ICSSNode node = getFirstChild(); node != null; node = node.getNextSibling()) { - if (node instanceof CSSRule) { - list.appendNode(node); - } - } - - return list; - } - - public CSSRuleList getCssRules(boolean shouldImport) { - if (!shouldImport) - return getCssRules(); - - CSSRuleListImpl list = new CSSRuleListImpl(); - Stack refs = new Stack(); - getRules(list, this, refs); - return list; - } - - private void getRules(CSSRuleListImpl list, ICSSStyleSheet sheet, Stack refs) { - String href = sheet.getHref(); - if (href != null) { - // Avoid circular @imports - if (refs.contains(href)) - return; - refs.push(href); - } - boolean acceptImports = true; - for (ICSSNode node = sheet.getFirstChild(); node != null; node = node.getNextSibling()) { - // Import the stylesheet into the list - // @import rules must precede all other rules, according to the spec - if (node.getNodeType() == ICSSNode.IMPORTRULE_NODE && acceptImports) { - CSSStyleSheet importSheet = ((ICSSImportRule) node).getStyleSheet(); - if (importSheet instanceof ICSSStyleSheet) - getRules(list, (ICSSStyleSheet) importSheet, refs); - else - list.appendNode(node); - } - // Add the rule to the list - else if (node instanceof CSSRule) { - list.appendNode(node); - if (node.getNodeType() != ICSSNode.CHARSETRULE_NODE) - acceptImports = false; - } - } - if (href != null) - refs.pop(); - } - - /** - * false if the style sheet is applied to the document. - * true if it is not. Modifying this attribute may cause a - * new resolution of style for the document. A stylesheet only applies if - * both an appropriate medium definition is present and the disabled - * attribute is false. So, if the media doesn't apply to the current user - * agent, the disabled attribute is ignored. - */ - public boolean getDisabled() { - return fDisabled; - } - - /** - * If the style sheet is a linked style sheet, the value of its attribute - * is its location. For inline style sheets, the value of this attribute - * is null. See the href attribute definition for the - * LINK element in HTML 4.0, and the href pseudo-attribute - * for the XML style sheet processing instruction. - */ - public String getHref() { - ICSSModel model = getModel(); - if (model != null && model.getStyleSheetType() == ICSSModel.EXTERNAL) { - return model.getBaseLocation(); - /* - * Object id = model.getId(); if (id != null) { if (id instanceof - * IResource) { // TODO: need to check whether this is correct or - * not, later. return ((IResource)id).getFullPath().toString(); } - * return id.toString(); } - */} - return null; - } - - CSSRuleImpl getIndexedRule(int index) { - if (index < 0) - return null; - - int i = 0; - for (ICSSNode node = getFirstChild(); node != null; node = node.getNextSibling()) { - if (node instanceof CSSRule) { - if (i++ == index) - return (CSSRuleImpl) node; - } - } - return null; - } - - /** - * The intended destination media for style information. The media is - * often specified in the ownerNode. If no media has been - * specified, the MediaList will be empty. See the media - * attribute definition for the LINK element in HTML 4.0, - * and the media pseudo-attribute for the XML style sheet processing - * instruction . Modifying the media list may cause a change to the - * attribute disabled. - */ - public MediaList getMedia() { - return null; - } - - /** - * @return short - */ - public short getNodeType() { - return STYLESHEET_NODE; - } - - /** - * The node that associates this style sheet with the document. For HTML, - * this may be the corresponding LINK or STYLE - * element. For XML, it may be the linking processing instruction. For - * style sheets that are included by other style sheets, the value of this - * attribute is null. - */ - public Node getOwnerNode() { - // for tag or