Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 252861 | Differences between
and this patch

Collapse All | Expand All

(-)plugin.xml (-26 / +30 lines)
Lines 53-126 Link Here
53
53
54
	<extension point="org.eclipse.jst.pagedesigner.pageDesignerExtension">
54
	<extension point="org.eclipse.jst.pagedesigner.pageDesignerExtension">
55
		<linkCreator class="org.eclipse.jst.pagedesigner.actions.link.HtmlLinkCreator" linkIdentifier="Html Link"/>
55
		<linkCreator class="org.eclipse.jst.pagedesigner.actions.link.HtmlLinkCreator" linkIdentifier="Html Link"/>
56
  <tagTransformOperation
56
    <tagTransformOperation
57
        class="org.eclipse.jst.pagedesigner.dtmanager.converter.operations.internal.AppendChildElementOperation"
57
        class="org.eclipse.jst.pagedesigner.dtmanager.converter.operations.internal.AppendChildElementOperation"
58
        id="AppendChildElementOperation">
58
        id="AppendChildElementOperation">
59
  </tagTransformOperation>
59
    </tagTransformOperation>
60
    <tagTransformOperation
60
    <tagTransformOperation
61
        class="org.eclipse.jst.pagedesigner.dtmanager.converter.operations.internal.AppendChildTextFromXPathOperation"
61
        class="org.eclipse.jst.pagedesigner.dtmanager.converter.operations.internal.AppendChildTextFromXPathOperation"
62
        id="AppendChildTextFromXPathOperation">
62
        id="AppendChildTextFromXPathOperation">
63
  </tagTransformOperation>
63
    </tagTransformOperation>
64
    <tagTransformOperation
64
    <tagTransformOperation
65
        class="org.eclipse.jst.pagedesigner.dtmanager.converter.operations.internal.AppendChildTextOperation"
65
        class="org.eclipse.jst.pagedesigner.dtmanager.converter.operations.internal.AppendChildTextOperation"
66
        id="AppendChildTextOperation">
66
        id="AppendChildTextOperation">
67
  </tagTransformOperation>
67
    </tagTransformOperation>
68
    <tagTransformOperation
68
    <tagTransformOperation
69
        class="org.eclipse.jst.pagedesigner.dtmanager.converter.operations.internal.ConvertAttributeToTextOperation"
69
        class="org.eclipse.jst.pagedesigner.dtmanager.converter.operations.internal.ConvertAttributeToTextOperation"
70
        id="ConvertAttributeToTextOperation">
70
        id="ConvertAttributeToTextOperation">
71
  </tagTransformOperation>
71
    </tagTransformOperation>
72
    <tagTransformOperation
72
    <tagTransformOperation
73
        class="org.eclipse.jst.pagedesigner.dtmanager.converter.operations.internal.CopyAllAttributesOperation"
73
        class="org.eclipse.jst.pagedesigner.dtmanager.converter.operations.internal.CopyAllAttributesOperation"
74
        id="CopyAllAttributesOperation">
74
        id="CopyAllAttributesOperation">
75
  </tagTransformOperation>
75
    </tagTransformOperation>
76
    <tagTransformOperation
76
    <tagTransformOperation
77
        class="org.eclipse.jst.pagedesigner.dtmanager.converter.operations.internal.CopyAttributeOperation"
77
        class="org.eclipse.jst.pagedesigner.dtmanager.converter.operations.internal.CopyAttributeOperation"
78
        id="CopyAttributeOperation">
78
        id="CopyAttributeOperation">
79
  </tagTransformOperation>
79
    </tagTransformOperation>
80
    <tagTransformOperation
80
    <tagTransformOperation
81
          class="org.eclipse.jst.pagedesigner.dtmanager.converter.operations.internal.CopyAttributeWithRenameOperation"
81
        class="org.eclipse.jst.pagedesigner.dtmanager.converter.operations.internal.CopyAttributeWithRenameOperation"
82
          id="CopyAttributeWithRenameOperation">
82
        id="CopyAttributeWithRenameOperation">
83
    </tagTransformOperation>
83
    </tagTransformOperation>
84
    <tagTransformOperation
84
    <tagTransformOperation
85
        class="org.eclipse.jst.pagedesigner.dtmanager.converter.operations.internal.CopyChildrenOperation"
85
        class="org.eclipse.jst.pagedesigner.dtmanager.converter.operations.internal.CopyChildrenOperation"
86
        id="CopyChildrenOperation">
86
        id="CopyChildrenOperation">
87
  </tagTransformOperation>
87
    </tagTransformOperation>
88
    <tagTransformOperation
88
    <tagTransformOperation
89
        class="org.eclipse.jst.pagedesigner.dtmanager.converter.operations.internal.CreateAttributeFromXPathOperation"
89
        class="org.eclipse.jst.pagedesigner.dtmanager.converter.operations.internal.CreateAttributeFromXPathOperation"
90
        id="CreateAttributeFromXPathOperation">
90
        id="CreateAttributeFromXPathOperation">
91
  </tagTransformOperation>
91
    </tagTransformOperation>
92
    <tagTransformOperation
92
    <tagTransformOperation
93
        class="org.eclipse.jst.pagedesigner.dtmanager.converter.operations.internal.CreateAttributeOperation"
93
        class="org.eclipse.jst.pagedesigner.dtmanager.converter.operations.internal.CreateAttributeOperation"
94
        id="CreateAttributeOperation">
94
        id="CreateAttributeOperation">
95
  </tagTransformOperation>
95
    </tagTransformOperation>
96
      <tagTransformOperation
96
    <tagTransformOperation
97
        class="org.eclipse.jst.pagedesigner.dtmanager.converter.operations.internal.CreateElementOperation"
97
        class="org.eclipse.jst.pagedesigner.dtmanager.converter.operations.internal.CreateElementOperation"
98
        id="CreateElementOperation">
98
        id="CreateElementOperation">
99
  </tagTransformOperation>
99
    </tagTransformOperation>
100
      <tagTransformOperation
100
    <tagTransformOperation
101
        class="org.eclipse.jst.pagedesigner.dtmanager.converter.operations.internal.IfNotOperation"
101
        class="org.eclipse.jst.pagedesigner.dtmanager.converter.operations.internal.IfNotOperation"
102
        id="IfNotOperation">
102
        id="IfNotOperation">
103
  </tagTransformOperation>
103
    </tagTransformOperation>
104
      <tagTransformOperation
104
    <tagTransformOperation
105
        class="org.eclipse.jst.pagedesigner.dtmanager.converter.operations.internal.IfOperation"
105
        class="org.eclipse.jst.pagedesigner.dtmanager.converter.operations.internal.IfOperation"
106
        id="IfOperation">
106
        id="IfOperation">
107
  </tagTransformOperation>
107
    </tagTransformOperation>
108
      <tagTransformOperation
108
    <tagTransformOperation
109
        class="org.eclipse.jst.pagedesigner.dtmanager.converter.operations.internal.IterateOverElementsOperation"
109
        class="org.eclipse.jst.pagedesigner.dtmanager.converter.operations.internal.IterateOverElementsOperation"
110
        id="IterateOverElementsOperation">
110
        id="IterateOverElementsOperation">
111
  </tagTransformOperation>
111
    </tagTransformOperation>
112
      <tagTransformOperation
112
    <tagTransformOperation
113
        class="org.eclipse.jst.pagedesigner.dtmanager.converter.operations.internal.MakeParentElementCurrentOperation"
113
        class="org.eclipse.jst.pagedesigner.dtmanager.converter.operations.internal.MakeParentElementCurrentOperation"
114
        id="MakeParentElementCurrentOperation">
114
        id="MakeParentElementCurrentOperation">
115
  </tagTransformOperation>
115
    </tagTransformOperation>
116
      <tagTransformOperation
116
    <tagTransformOperation
117
        class="org.eclipse.jst.pagedesigner.dtmanager.converter.operations.internal.RemoveAttributeOperation"
117
        class="org.eclipse.jst.pagedesigner.dtmanager.converter.operations.internal.RemoveAttributeOperation"
118
        id="RemoveAttributeOperation">
118
        id="RemoveAttributeOperation">
119
  </tagTransformOperation>
119
    </tagTransformOperation>
120
      <tagTransformOperation
120
    <tagTransformOperation
121
        class="org.eclipse.jst.pagedesigner.dtmanager.converter.operations.internal.RenameAttributeOperation"
121
        class="org.eclipse.jst.pagedesigner.dtmanager.converter.operations.internal.RenameAttributeOperation"
122
        id="RenameAttributeOperation">
122
        id="RenameAttributeOperation">
123
  </tagTransformOperation>
123
    </tagTransformOperation>
124
    <tagTransformOperation
125
        class="org.eclipse.jst.pagedesigner.dtmanager.converter.operations.internal.CheckModeOperation"
126
        id="CheckModeOperation">
127
    </tagTransformOperation>
124
	</extension>
128
	</extension>
125
	
129
	
126
	<extension id="org.eclipse.jst.pagedesigner.commands" point="org.eclipse.ui.commands">
130
	<extension id="org.eclipse.jst.pagedesigner.commands" point="org.eclipse.ui.commands">
(-)src/org/eclipse/jst/pagedesigner/dtmanager/converter/internal/DTTagConverterContext.java (+20 lines)
Lines 11-16 Link Here
11
package org.eclipse.jst.pagedesigner.dtmanager.converter.internal;
11
package org.eclipse.jst.pagedesigner.dtmanager.converter.internal;
12
12
13
import org.eclipse.jst.pagedesigner.converter.ConvertPosition;
13
import org.eclipse.jst.pagedesigner.converter.ConvertPosition;
14
import org.eclipse.jst.pagedesigner.converter.IConverterFactory;
14
import org.eclipse.jst.pagedesigner.dtmanager.converter.AbstractTagConverterContext;
15
import org.eclipse.jst.pagedesigner.dtmanager.converter.AbstractTagConverterContext;
15
import org.w3c.dom.Element;
16
import org.w3c.dom.Element;
16
import org.w3c.dom.Node;
17
import org.w3c.dom.Node;
Lines 76-79 Link Here
76
		}
77
		}
77
	}
78
	}
78
79
80
	/**
81
	 * Utility method to get the current converter mode. Values are
82
	 * defined in <code>IConverterFactory</code>.
83
	 * 
84
	 * <br>This method is available on the DTTagConverter but was not
85
	 * part of the ITagConverter and not available as a public API.
86
	 * The addition of this method allows an ITransformOperation for
87
	 * a DTTagConverter to get at the mode.
88
	 * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=252861 
89
	 * 
90
	 * @return the converter mode. If unable to get the mode, return -1.
91
	 */
92
	public int getMode() {
93
		if (tagConverter != null) {
94
			return ((DTTagConverter) tagConverter).getMode();
95
		}
96
97
		return IConverterFactory.MODE_DESIGNER;
98
	}
79
}
99
}
(-)src/org/eclipse/jst/pagedesigner/dtmanager/converter/operations/internal/CheckModeOperation.java (+81 lines)
Added Link Here
1
/*******************************************************************************
2
* Copyright (c) 2010 Oracle Corporation and others.
3
* All rights reserved. This program and the accompanying materials
4
* are made available under the terms of the Eclipse Public License v1.0
5
* which accompanies this distribution, and is available at
6
* http://www.eclipse.org/legal/epl-v10.html
7
*
8
* Contributors:
9
*    Oracle Corporation - initial API and implementation and/or initial documentation
10
*******************************************************************************/
11
package org.eclipse.jst.pagedesigner.dtmanager.converter.operations.internal;
12
13
import org.eclipse.core.runtime.Assert;
14
import org.eclipse.jst.pagedesigner.converter.IConverterFactory;
15
import org.eclipse.jst.pagedesigner.dtmanager.converter.internal.DTTagConverterContext;
16
import org.eclipse.jst.pagedesigner.dtmanager.converter.operations.AbstractTransformOperation;
17
import org.w3c.dom.Element;
18
19
20
/**
21
 * Transform operation that executes child ITransformOperation
22
 * instances if the view mode matches the argument (parameter) provided.
23
 * 
24
 * <br><b>Note:</b> requires ITransformOperation.setTagConverterContext() to
25
 * have been called to provide a valid ITagConverterContext instance prior to
26
 * a call to the transform() method.
27
 */
28
public class CheckModeOperation extends AbstractTransformOperation {
29
30
    /**
31
     * Constant indicating the current render mode is design
32
     */
33
    public static final String MODE_DESIGN = "design"; //$NON-NLS-1$
34
    /**
35
     * Constant indicating the current render mode is preview
36
     */
37
    public static final String MODE_PREVIEW = "preview"; //$NON-NLS-1$
38
39
    /*
40
     * (non-Javadoc)
41
     * @see org.eclipse.jst.pagedesigner.dtmanager.converter.ITransformOperation#transform(org.w3c.dom.Element, org.w3c.dom.Element)
42
     */
43
    @Override
44
    public Element transform(Element srcElement, Element curElement) {
45
        if (getParameters().length < 1) {
46
            getLog().error("Warning.TransformOperationFactory.TooFewParameters", //$NON-NLS-1$
47
                           getTransformOperationID());
48
            return null;
49
        }
50
        
51
        String modeParam = getParameters()[0];
52
        Assert.isNotNull(modeParam);
53
54
        int currentMode = getMode();
55
        if ((MODE_DESIGN.equals(modeParam) && currentMode == IConverterFactory.MODE_DESIGNER)
56
                || (MODE_PREVIEW.equals(modeParam) && currentMode == IConverterFactory.MODE_PREVIEW)) {
57
            return executeChildOperations(srcElement, curElement);
58
        }
59
60
        // if we haven't transformed the element at all, and this is 
61
        // just the initial transform, return null
62
        if (srcElement == curElement) {
63
            return null;
64
        }
65
66
        // otherwise, return the currently transformed element
67
        return curElement;
68
    }
69
70
    /**
71
     * @return the converter mode. If unable to get the mode, return -1.
72
     */
73
    protected int getMode() {
74
        if (tagConverterContext != null
75
                && tagConverterContext instanceof DTTagConverterContext) {
76
            return ((DTTagConverterContext) tagConverterContext).getMode();
77
        }
78
79
        return -1;
80
    }
81
}

Return to bug 252861