2 * Copyright (c) 2003-2004 Christopher Lenz and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * Christopher Lenz - initial API and implementation
11 * $Id: CssNode.java,v 1.1 2004-09-02 18:11:49 jsurfer Exp $
14 package net.sourceforge.phpeclipse.css.ui.internal.compare;
16 import net.sourceforge.phpeclipse.css.ui.CssUI;
17 import net.sourceforge.phpeclipse.css.ui.internal.CssUIMessages;
19 import org.eclipse.compare.ITypedElement;
20 import org.eclipse.compare.structuremergeviewer.DocumentRangeNode;
21 import org.eclipse.jface.text.IDocument;
22 import org.eclipse.swt.graphics.Image;
27 public class CssNode extends DocumentRangeNode implements ITypedElement {
29 // Constants ---------------------------------------------------------------
32 * Type code for the top-level style sheet.
34 public static final int STYLE_SHEET = 0;
37 * Type code for at rules.
39 public static final int AT_RULE = 1;
42 * Type code for style rules.
44 public static final int STYLE_RULE = 2;
47 * Type code for declarations (property-value assignment).
49 public static final int DECLARATION = 3;
51 // Instance Variables ------------------------------------------------------
54 * The display name of the node.
58 // Constructors ------------------------------------------------------------
61 * Constructor for the top-level style sheet node.
63 * @param document The document
65 public CssNode(IDocument document) {
66 super(STYLE_SHEET, "root", document, 0, //$NON-NLS-1$
67 document.getLength());
80 public CssNode(CssNode parent, int typeCode, String id, String name,
81 int start, int length) {
82 super(typeCode, parent.getId() + Integer.toString(typeCode) + id,
83 parent.getDocument(), start, length);
88 * @see org.eclipse.compare.ITypedElement#getName()
90 public String getName() {
91 if (getTypeCode() == STYLE_SHEET) {
92 return CssUIMessages.getString(
93 "CssStructureViewer.styleSheet"); //$NON-NLS-1$
99 * @see org.eclipse.compare.ITypedElement#getImage()
101 public Image getImage() {
103 switch (getTypeCode()) {
105 key = CssUI.ICON_STYLE_SHEET;
109 key = CssUI.ICON_AT_RULE;
113 key = CssUI.ICON_STYLE_RULE;
117 key = CssUI.ICON_PROPERTY;
121 // we'll just return null
124 return CssUI.getDefault().getImageRegistry().get(key);
128 * @see org.eclipse.compare.ITypedElement#getType()
130 public String getType() {
131 return "css"; //$NON-NLS-1$