JBoss Tools SVN: r9156 - in trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor: template and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: mareshkau
Date: 2008-07-16 14:21:29 -0400 (Wed, 16 Jul 2008)
New Revision: 9156
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/KeyEventManager.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-2505
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2008-07-16 15:19:39 UTC (rev 9155)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2008-07-16 18:21:29 UTC (rev 9156)
@@ -14,7 +14,6 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Properties;
-
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -142,6 +141,7 @@
import org.jboss.tools.vpe.editor.util.DocTypeUtil;
import org.jboss.tools.vpe.editor.util.SelectionUtil;
import org.jboss.tools.vpe.editor.util.VisualDomUtil;
+import org.jboss.tools.vpe.editor.util.VpeDebugUtil;
import org.jboss.tools.vpe.editor.util.VpeDndUtil;
import org.jboss.tools.vpe.messages.VpeUIMessages;
import org.jboss.tools.vpe.selbar.SelectionBar;
@@ -289,15 +289,8 @@
sourceEditor, visualSelectionController);
keyEventHandler = new KeyEventManager(sourceEditor, domMapping,
- pageContext);
+ pageContext,visualSelectionController);
- // visualKeyHandler = new VpeVisualKeyHandler(sourceEditor, domMapping,
- // pageContext) {
- // public void doSave(IProgressMonitor monitor) {
- // editPart.doSave(monitor);
- // }
- // };
-
// glory
ISelectionProvider provider = sourceEditor.getSelectionProvider();
// Max Areshkau JBIDE-1105 If selection event received after selection
@@ -1026,7 +1019,7 @@
mouseUpSelectionReasonFlag = (reason & nsISelectionListener.MOUSEUP_REASON) > 0;
if (mouseUpSelectionReasonFlag
|| reason == nsISelectionListener.NO_REASON
-// || reason == nsISelectionListener.KEYPRESS_REASON
+ || reason == nsISelectionListener.KEYPRESS_REASON
|| reason == nsISelectionListener.SELECTALL_REASON
|| (reason & nsISelectionListener.MOUSEDOWN_REASON) > 0) {
@@ -1241,7 +1234,7 @@
}
try {
- if (/* visualKeyHandler.keyPressHandler(keyEvent) */keyEventHandler
+ if (keyEventHandler
.handleKeyPress(keyEvent)) {
switcher
.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL);
@@ -2987,7 +2980,13 @@
}
return includeList;
}
-
+
+ /**
+ * Processed selection events from source editor,
+ * if reason of selection is visial editor,
+ * selection will be stopped processing by
+ * this condition (!switcher.startActiveEditor)
+ */
public void selectionChanged(SelectionChangedEvent event) {
// FIX for JBIDE-2114
if (!isVisualEditorVisible()) {
@@ -3009,6 +3008,7 @@
return;
}
try {
+
if (VpeDebug.PRINT_SOURCE_SELECTION_EVENT) {
System.out
.println(">>>>>>>>>>>>>> selectionChanged " + event.getSource()); //$NON-NLS-1$
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/KeyEventManager.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/KeyEventManager.java 2008-07-16 15:19:39 UTC (rev 9155)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/KeyEventManager.java 2008-07-16 18:21:29 UTC (rev 9156)
@@ -10,10 +10,13 @@
import org.jboss.tools.vpe.editor.mapping.VpeElementData;
import org.jboss.tools.vpe.editor.mapping.VpeElementMapping;
import org.jboss.tools.vpe.editor.mapping.VpeNodeMapping;
+import org.jboss.tools.vpe.editor.selection.VpeSelectionController;
import org.jboss.tools.vpe.editor.util.SelectionUtil;
import org.jboss.tools.vpe.editor.util.TextUtil;
+import org.jboss.tools.vpe.editor.util.VpeDebugUtil;
import org.mozilla.interfaces.nsIDOMKeyEvent;
import org.mozilla.interfaces.nsIDOMNode;
+import org.mozilla.interfaces.nsISelection;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -40,12 +43,18 @@
* page context
*/
private VpePageContext pageContext;
-
+
+ /**
+ * selection controller
+ */
+ private VpeSelectionController selectionController;
+
public KeyEventManager(StructuredTextEditor sourceEditor,
- VpeDomMapping domMapping, VpePageContext pageContext) {
+ VpeDomMapping domMapping, VpePageContext pageContext, VpeSelectionController selectionController) {
this.sourceEditor = sourceEditor;
this.domMapping = domMapping;
this.pageContext = pageContext;
+ setSelectionController(selectionController);
}
final public boolean handleKeyPress(nsIDOMKeyEvent keyEvent) {
@@ -389,8 +398,16 @@
* @return whether handled event
*/
protected boolean handleRight(nsIDOMKeyEvent keyEvent) {
+
+ getSelectionController().setCaretEnabled(true);
+
+ nsISelection selection = getSelectionController().getSelection((short)1);
+ nsIDOMNode node = selection.getAnchorNode();
+
+ VpeDebugUtil.debugInfo("Node name "+node.getNodeName()+"\n");
+ VpeDebugUtil.debugInfo("Node value "+node.getNodeValue()+"\n");
+
return false;
-
}
/**
@@ -479,4 +496,18 @@
return null;
}
+
+ /**
+ * @return the selectionController
+ */
+ private VpeSelectionController getSelectionController() {
+ return selectionController;
+ }
+
+ /**
+ * @param selectionController the selectionController to set
+ */
+ private void setSelectionController(VpeSelectionController selectionController) {
+ this.selectionController = selectionController;
+ }
}
16 years, 5 months
JBoss Tools SVN: r9155 - in trunk/jst/plugins/org.jboss.tools.jst.jsp: images/cssdialog and 12 other directories.
by jbosstools-commits@lists.jboss.org
Author: dsakovich
Date: 2008-07-16 11:19:39 -0400 (Wed, 16 Jul 2008)
New Revision: 9155
Added:
trunk/jst/plugins/org.jboss.tools.jst.jsp/images/cssdialog/
trunk/jst/plugins/org.jboss.tools.jst.jsp/images/cssdialog/color.gif
trunk/jst/plugins/org.jboss.tools.jst.jsp/images/cssdialog/color_large.gif
trunk/jst/plugins/org.jboss.tools.jst.jsp/images/cssdialog/folder.gif
trunk/jst/plugins/org.jboss.tools.jst.jsp/images/cssdialog/folder_large.gif
trunk/jst/plugins/org.jboss.tools.jst.jsp/images/cssdialog/font.gif
trunk/jst/plugins/org.jboss.tools.jst.jsp/images/cssdialog/font_large.gif
trunk/jst/plugins/org.jboss.tools.jst.jsp/images/cssdialog/left.gif
trunk/jst/plugins/org.jboss.tools.jst.jsp/images/cssdialog/right.gif
trunk/jst/plugins/org.jboss.tools.jst.jsp/images/cssdialog/sample.gif
trunk/jst/plugins/org.jboss.tools.jst.jsp/resources/org/jboss/tools/jst/
trunk/jst/plugins/org.jboss.tools.jst.jsp/resources/org/jboss/tools/jst/jsp/
trunk/jst/plugins/org.jboss.tools.jst.jsp/resources/org/jboss/tools/jst/jsp/outline/
trunk/jst/plugins/org.jboss.tools.jst.jsp/resources/org/jboss/tools/jst/jsp/outline/cssdialog/
trunk/jst/plugins/org.jboss.tools.jst.jsp/resources/org/jboss/tools/jst/jsp/outline/cssdialog/colors.xml
trunk/jst/plugins/org.jboss.tools.jst.jsp/resources/org/jboss/tools/jst/jsp/outline/cssdialog/cssElements.xml
trunk/jst/plugins/org.jboss.tools.jst.jsp/resources/org/jboss/tools/jst/jsp/outline/cssdialog/cssElementsWithCombo.xml
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/CSSDialog.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/FontFamilyDialog.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/ImageSelectionDialog.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/CSSConstants.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/Constants.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/ImageCombo.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/MessageUtil.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/Util.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/messages.properties
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/events/
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/events/TabPropertySheetMouseAdapter.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/parsers/
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/parsers/BaseListener.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/parsers/CSSElementsParser.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/parsers/ColorParser.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/parsers/ColorParserListener.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/parsers/ComboParser.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/parsers/IListener.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/parsers/Parser.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/parsers/ParserListener.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabBackgroundControl.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabBoxesControl.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabPropertySheetControl.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabQuickEditControl.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabTextControl.java
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/JspEditorPlugin.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPDialogCellEditor.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-2499
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/images/cssdialog/color.gif
===================================================================
(Binary files differ)
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.jsp/images/cssdialog/color.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/images/cssdialog/color_large.gif
===================================================================
(Binary files differ)
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.jsp/images/cssdialog/color_large.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/images/cssdialog/folder.gif
===================================================================
(Binary files differ)
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.jsp/images/cssdialog/folder.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/images/cssdialog/folder_large.gif
===================================================================
(Binary files differ)
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.jsp/images/cssdialog/folder_large.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/images/cssdialog/font.gif
===================================================================
(Binary files differ)
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.jsp/images/cssdialog/font.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/images/cssdialog/font_large.gif
===================================================================
(Binary files differ)
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.jsp/images/cssdialog/font_large.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/images/cssdialog/left.gif
===================================================================
(Binary files differ)
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.jsp/images/cssdialog/left.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/images/cssdialog/right.gif
===================================================================
(Binary files differ)
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.jsp/images/cssdialog/right.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/images/cssdialog/sample.gif
===================================================================
(Binary files differ)
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.jsp/images/cssdialog/sample.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/resources/org/jboss/tools/jst/jsp/outline/cssdialog/colors.xml
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/resources/org/jboss/tools/jst/jsp/outline/cssdialog/colors.xml (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/resources/org/jboss/tools/jst/jsp/outline/cssdialog/colors.xml 2008-07-16 15:19:39 UTC (rev 9155)
@@ -0,0 +1,147 @@
+<colors>
+ <color value="AliceBlue" name="#F0F8FF" />
+ <color value="AntiqueWhite" name="#FAEBD7" />
+ <color value="Aqua" name="#00FFFF" />
+ <color value="Aquamarine" name="#7FFFD4" />
+ <color value="Azure" name="#F0FFFF" />
+ <color value="Beige" name="#F5F5DC" />
+ <color value="Bisque" name="#FFE4C4" />
+ <color value="Black" name="#000000" />
+ <color value="BlanchedAlmond" name="#FFEBCD" />
+ <color value="Blue" name="#0000FF" />
+ <color value="BlueViolet" name="#8A2BE2" />
+ <color value="Brown" name="#A52A2A" />
+ <color value="BurlyWood" name="#DEB887" />
+ <color value="CadetBlue" name="#5F9EA0" />
+ <color value="Chartreuse" name="#7FFF00" />
+ <color value="Chocolate" name="#D2691E" />
+ <color value="Coral" name="#FF7F50" />
+ <color value="CornflowerBlue" name="#6495ED" />
+ <color value="Cornsilk" name="#FFF8DC" />
+ <color value="Crimson" name="#DC143C" />
+ <color value="Cyan" name="#00FFFF" />
+ <color value="DarkBlue" name="#00008B" />
+ <color value="DarkCyan" name="#008B8B" />
+ <color value="DarkGoldenRod" name="#B8860B" />
+ <color value="DarkGray" name="#A9A9A9" />
+ <color value="DarkGreen" name="#006400" />
+ <color value="DarkKhaki" name="#BDB76B" />
+ <color value="DarkMagenta" name="#8B008B" />
+ <color value="DarkOliveGreen" name="#556B2F" />
+ <color value="Darkorange" name="#FF8C00" />
+ <color value="DarkOrchid" name="#9932CC" />
+ <color value="DarkRed" name="#8B0000" />
+ <color value="DarkSalmon" name="#E9967A" />
+ <color value="DarkSeaGreen" name="#8FBC8F" />
+ <color value="DarkSlateBlue" name="#483D8B" />
+ <color value="DarkSlateGray" name="#2F4F4F" />
+ <color value="DarkTurquoise" name="#00CED1" />
+ <color value="DarkViolet" name="#9400D3" />
+ <color value="DeepPink" name="#FF1493" />
+ <color value="DeepSkyBlue" name="#00BFFF" />
+ <color value="DimGray" name="#696969" />
+ <color value="DimGrey" name="#696969" />
+ <color value="DodgerBlue" name="#1E90FF" />
+ <color value="FireBrick" name="#B22222" />
+ <color value="FloralWhite" name="#FFFAF0" />
+ <color value="ForestGreen" name="#228B22" />
+ <color value="Fuchsia" name="#FF00FF" />
+ <color value="Gainsboro" name="#DCDCDC" />
+ <color value="GhostWhite" name="#F8F8FF" />
+ <color value="Gold" name="#FFD700" />
+ <color value="GoldenRod" name="#DAA520" />
+ <color value="Gray" name="#808080" />
+ <color value="Grey" name="#808080" />
+ <color value="Green" name="#008000" />
+ <color value="GreenYellow" name="#ADFF2F" />
+ <color value="HoneyDew" name="#F0FFF0" />
+ <color value="HotPink" name="#FF69B4" />
+ <color value="IndianRed" name="#CD5C5C" />
+ <color value="Indigo" name="#4B0082" />
+ <color value="Ivory" name="#FFFFF0" />
+ <color value="Khaki" name="#F0E68C" />
+ <color value="Lavender" name="#E6E6FA" />
+ <color value="LavenderBlush" name="#FFF0F5" />
+ <color value="LawnGreen" name="#7CFC00" />
+ <color value="LemonChiffon" name="#FFFACD" />
+ <color value="LightBlue" name="#ADD8E6" />
+ <color value="LightCoral" name="#F08080" />
+ <color value="LightCyan" name="#E0FFFF" />
+ <color value="LightGoldenRodYellow" name="#FAFAD2" />
+ <color value="LightGray" name="#D3D3D3" />
+ <color value="LightGrey" name="#D3D3D3" />
+ <color value="LightGreen" name="#90EE90" />
+ <color value="LightPink" name="#FFB6C1" />
+ <color value="LightSalmon" name="#FFA07A" />
+ <color value="LightSeaGreen" name="#20B2AA" />
+ <color value="LightSkyBlue" name="#87CEFA" />
+ <color value="LightSlateGray" name="#778899" />
+ <color value="LightSlateGrey" name="#778899" />
+ <color value="LightSteelBlue" name="#B0C4DE" />
+ <color value="LightYellow" name="#FFFFE0" />
+ <color value="Lime" name="#00FF00" />
+ <color value="LimeGreen" name="#32CD32" />
+ <color value="Linen" name="#FAF0E6" />
+ <color value="Magenta" name="#FF00FF" />
+ <color value="Maroon" name="#800000" />
+ <color value="MediumAquaMarine" name="#66CDAA" />
+ <color value="MediumBlue" name="#0000CD" />
+ <color value="MediumOrchid" name="#BA55D3" />
+ <color value="MediumPurple" name="#9370D8" />
+ <color value="MediumSeaGreen" name="#3CB371" />
+ <color value="MediumSlateBlue" name="#7B68EE" />
+ <color value="MediumSpringGreen" name="#00FA9A" />
+ <color value="MediumTurquoise" name="#48D1CC" />
+ <color value="MediumVioletRed" name="#C71585" />
+ <color value="MidnightBlue" name="#191970" />
+ <color value="MintCream" name="#F5FFFA" />
+ <color value="MistyRose" name="#FFE4E1" />
+ <color value="Moccasin" name="#FFE4B5" />
+ <color value="NavajoWhite" name="#FFDEAD" />
+ <color value="Navy" name="#000080" />
+ <color value="OldLace" name="#FDF5E6" />
+ <color value="Olive" name="#808000" />
+ <color value="OliveDrab" name="#6B8E23" />
+ <color value="Orange" name="#FFA500" />
+ <color value="OrangeRed" name="#FF4500" />
+ <color value="Orchid" name="#DA70D6" />
+ <color value="PaleGoldenRod" name="#EEE8AA" />
+ <color value="PaleGreen" name="#98FB98" />
+ <color value="PaleTurquoise" name="#AFEEEE" />
+ <color value="PaleVioletRed" name="#D87093" />
+ <color value="PapayaWhip" name="#FFEFD5" />
+ <color value="PeachPuff" name="#FFDAB9" />
+ <color value="Peru" name="#CD853F" />
+ <color value="Pink" name="#FFC0CB" />
+ <color value="Plum" name="#DDA0DD" />
+ <color value="PowderBlue" name="#B0E0E6" />
+ <color value="Purple" name="#800080" />
+ <color value="Red" name="#FF0000" />
+ <color value="RosyBrown" name="#BC8F8F" />
+ <color value="RoyalBlue" name="#4169E1" />
+ <color value="SaddleBrown" name="#8B4513" />
+ <color value="Salmon" name="#FA8072" />
+ <color value="SandyBrown" name="#F4A460" />
+ <color value="SeaGreen" name="#2E8B57" />
+ <color value="SeaShell" name="#FFF5EE" />
+ <color value="Sienna" name="#A0522D" />
+ <color value="Silver" name="#C0C0C0" />
+ <color value="SkyBlue" name="#87CEEB" />
+ <color value="SlateBlue" name="#6A5ACD" />
+ <color value="SlateGray" name="#708090" />
+ <color value="SlateGrey" name="#708090" />
+ <color value="Snow" name="#FFFAFA" />
+ <color value="SpringGreen" name="#00FF7F" />
+ <color value="SteelBlue" name="#4682B4" />
+ <color value="Tan" name="#D2B48C" />
+ <color value="Teal" name="#008080" />
+ <color value="Thistle" name="#D8BFD8" />
+ <color value="Tomato" name="#FF6347" />
+ <color value="Turquoise" name="#40E0D0" />
+ <color value="Violet" name="#EE82EE" />
+ <color value="Wheat" name="#F5DEB3" />
+ <color value="White" name="#FFFFFF" />
+ <color value="WhiteSmoke" name="#F5F5F5" />
+ <color value="Yellow" name="#FFFF00" />
+ <color value="YellowGreen" name="#9ACD32" />
+</colors>
\ No newline at end of file
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/resources/org/jboss/tools/jst/jsp/outline/cssdialog/cssElements.xml
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/resources/org/jboss/tools/jst/jsp/outline/cssdialog/cssElements.xml (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/resources/org/jboss/tools/jst/jsp/outline/cssdialog/cssElements.xml 2008-07-16 15:19:39 UTC (rev 9155)
@@ -0,0 +1,167 @@
+<elements>
+
+ <!-- ################### Block elements #################### -->
+ <Aural>
+ <element name="azimuth"/>
+ <element name="cue"/>
+ <element name="cue-after"/>
+ <element name="cue-before"/>
+ <element name="elevation"/>
+ <element name="pause"/>
+ <element name="pause-after"/>
+ <element name="pause-before"/>
+ <element name="pitch"/>
+ <element name="pitch-range"/>
+ <element name="play-during"/>
+ <element name="richness"/>
+ <element name="speak"/>
+ <element name="speak-numeral"/>
+ <element name="speak-punctuation"/>
+ <element name="speech-rate"/>
+ <element name="stress"/>
+ <element name="voice-family"/>
+ <element name="volumn"/>
+ </Aural>
+
+ <Background>
+ <element name="background"/>
+ <element name="background-attachment"/>
+ <element name="background-color"/>
+ <element name="background-image"/>
+ <element name="background-position"/>
+ <element name="background-repeat"/>
+ </Background>
+
+ <Boxes>
+ <element name="border"/>
+ <element name="border-bottom"/>
+ <element name="border-bottom-color"/>
+ <element name="border-bottom-style"/>
+ <element name="border-bottom-width"/>
+ <element name="border-color"/>
+ <element name="border-left"/>
+ <element name="border-left-color"/>
+ <element name="border-left-style"/>
+ <element name="border-left-width"/>
+ <element name="border-right"/>
+ <element name="border-right-color"/>
+ <element name="border-right-style"/>
+ <element name="border-right-width"/>
+ <element name="border-style"/>
+ <element name="border-top"/>
+ <element name="border-top-color"/>
+ <element name="border-top-style"/>
+ <element name="border-top-width"/>
+ <element name="border-width"/>
+ <element name="margin"/>
+ <element name="margin-bottom"/>
+ <element name="margin-left"/>
+ <element name="margin-right"/>
+ <element name="margin-top"/>
+ <element name="padding"/>
+ <element name="padding-bottom"/>
+ <element name="padding-left"/>
+ <element name="padding-right"/>
+ <element name="padding-top"/>
+ </Boxes>
+
+ <Dimension>
+ <element name="height"/>
+ <element name="line-height"/>
+ <element name="max-height"/>
+ <element name="max-width"/>
+ <element name="min-height"/>
+ <element name="min-width"/>
+ <element name="vertical-align"/>
+ <element name="width"/>
+ </Dimension>
+
+ <Font>
+ <element name="font"/>
+ <element name="font-family"/>
+ <element name="font-size"/>
+ <element name="font-size-adjust"/>
+ <element name="font-stretch"/>
+ <element name="font-style"/>
+ <element name="font-variant"/>
+ <element name="font-weight"/>
+ </Font>
+
+ <Interface>
+ <element name="cursor"/>
+ <element name="outline"/>
+ <element name="outline-color"/>
+ <element name="outline-style"/>
+ <element name="outline-width"/>
+ </Interface>
+
+ <List>
+ <element name="list-style"/>
+ <element name="list-style-image"/>
+ <element name="list-style-position"/>
+ <element name="list-style-type"/>
+ <element name="marker-offset"/>
+ </List>
+
+ <Miscellaneous>
+ <element name="content"/>
+ <element name="counter-increment"/>
+ <element name="counter-reset"/>
+ <element name="quotes"/>
+ <element name="counter-increment"/>
+ <element name="counter-reset"/>
+ <element name="quotes"/>
+ </Miscellaneous>
+
+
+ <Paging>
+ <element name="marks"/>
+ <element name="orphans"/>
+ <element name="page"/>
+ <element name="page-break-after"/>
+ <element name="page-break-before"/>
+ <element name="page-break-inside"/>
+ <element name="size"/>
+ <element name="widows"/>
+ </Paging>
+
+ <Positioning>
+ <element name="bottom"/>
+ <element name="clear"/>
+ <element name="clip"/>
+ <element name="direction"/>
+ <element name="display"/>
+ <element name="float"/>
+ <element name="left"/>
+ <element name="overflow"/>
+ <element name="position"/>
+ <element name="right"/>
+ <element name="top"/>
+ <element name="unicode-bidi"/>
+ <element name="visibility"/>
+ <element name="z-index"/>
+ </Positioning>
+
+ <Tables>
+ <element name="border-collapse"/>
+ <element name="border-spacing"/>
+ <element name="caption-side"/>
+ <element name="empty-cells"/>
+ <element name="speak-header"/>
+ <element name="table-layout"/>
+ </Tables>
+
+ <Text>
+ <element name="color"/>
+ <element name="letter-spacing"/>
+ <element name="text-align"/>
+ <element name="text-decoration"/>
+ <element name="text-indent"/>
+ <element name="text-shadow"/>
+ <element name="text-transform"/>
+ <element name="white-space"/>
+ <element name="word-spacing"/>
+ </Text>
+ <!-- ############################################################ -->
+
+</elements>
\ No newline at end of file
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/resources/org/jboss/tools/jst/jsp/outline/cssdialog/cssElementsWithCombo.xml
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/resources/org/jboss/tools/jst/jsp/outline/cssdialog/cssElementsWithCombo.xml (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/resources/org/jboss/tools/jst/jsp/outline/cssdialog/cssElementsWithCombo.xml 2008-07-16 15:19:39 UTC (rev 9155)
@@ -0,0 +1,572 @@
+<elements>
+
+ <color>
+ <value name="none"/>
+ </color>
+
+ <background-color>
+ <value name="none"/>
+ </background-color>
+
+ <border-bottom-color>
+ <value name="none"/>
+ </border-bottom-color>
+
+ <border-color>
+ <value name="none"/>
+ </border-color>
+
+ <border-left-color>
+ <value name="none"/>
+ </border-left-color>
+
+ <border-right-color>
+ <value name="none"/>
+ </border-right-color>
+
+ <border-top-color>
+ <value name="none"/>
+ </border-top-color>
+
+ <outline-color>
+ <value name="none"/>
+ </outline-color>
+
+ <letter-spacing>
+ <value name="normal"/>
+ </letter-spacing>
+
+ <text-align>
+ <value name="left"/>
+ <value name="right"/>
+ <value name="center"/>
+ <value name="justify"/>
+ </text-align>
+
+ <text-decoration>
+ <value name="none"/>
+ <value name="underline"/>
+ <value name="overline"/>
+ <value name="line-through"/>
+ <value name="blink"/>
+ </text-decoration>
+
+ <text-transform>
+ <value name="none"/>
+ <value name="capitalize"/>
+ <value name="uppercase"/>
+ <value name="lowercase"/>
+ </text-transform>
+
+ <white-space>
+ <value name="normal"/>
+ <value name="pre"/>
+ <value name="nowrap"/>
+ </white-space>
+
+ <word-spacing>
+ <value name="normal"/>
+ </word-spacing>
+
+ <font-size>
+ <value name="xx-small"/>
+ <value name="x-small"/>
+ <value name="small"/>
+ <value name="medium"/>
+ <value name="large"/>
+ <value name="x-large"/>
+ <value name="xx-large"/>
+ <value name="smaller"/>
+ <value name="larger"/>
+ </font-size>
+
+ <font-size-adjust>
+ <value name="none"/>
+ </font-size-adjust>
+
+ <font-stretch>
+ <value name="normal"/>
+ <value name="wider"/>
+ <value name="narrower"/>
+ <value name="ultra-condensed"/>
+ <value name="extra-condensed"/>
+ <value name="condensed"/>
+ <value name="semi-condensed"/>
+ <value name="semi-expanded"/>
+ <value name="expanded"/>
+ <value name="extra-expanded"/>
+ <value name="ultra-expanded"/>
+ </font-stretch>
+
+ <font-style>
+ <value name="normal"/>
+ <value name="italic"/>
+ <value name="oblique"/>
+ </font-style>
+
+ <font-variant>
+ <value name="normal"/>
+ <value name="small-caps"/>
+ </font-variant>
+
+ <font-weight>
+ <value name="normal"/>
+ <value name="bold"/>
+ <value name="bolder"/>
+ <value name="lighter"/>
+ </font-weight>
+
+ <background-attachment>
+ <value name="scroll"/>
+ <value name="fixed"/>
+ </background-attachment>
+
+ <background-image>
+ <value name="none"/>
+ </background-image>
+
+ <background-repeat>
+ <value name="repeat"/>
+ <value name="repeat-x"/>
+ <value name="repeat-y"/>
+ <value name="no-repeat"/>
+ </background-repeat>
+
+ <border-bottom-style>
+ <value name="solid"/>
+ <value name="none"/>
+ <value name="hidden"/>
+ <value name="dotted"/>
+ <value name="dashed"/>
+ <value name="double"/>
+ <value name="groove"/>
+ <value name="ridge"/>
+ <value name="inset"/>
+ <value name="outset"/>
+ </border-bottom-style>
+
+ <border-bottom-width>
+ <value name="medium"/>
+ <value name="thin"/>
+ <value name="thick"/>
+ </border-bottom-width>
+
+ <border-left-style>
+ <value name="solid"/>
+ <value name="none"/>
+ <value name="hidden"/>
+ <value name="dotted"/>
+ <value name="dashed"/>
+ <value name="double"/>
+ <value name="groove"/>
+ <value name="ridge"/>
+ <value name="inset"/>
+ <value name="outset"/>
+ </border-left-style>
+
+ <border-left-width>
+ <value name="medium"/>
+ <value name="thin"/>
+ <value name="thick"/>
+ </border-left-width>
+
+ <border-right-style>
+ <value name="solid"/>
+ <value name="none"/>
+ <value name="hidden"/>
+ <value name="dotted"/>
+ <value name="dashed"/>
+ <value name="double"/>
+ <value name="groove"/>
+ <value name="ridge"/>
+ <value name="inset"/>
+ <value name="outset"/>
+ </border-right-style>
+
+ <border-right-width>
+ <value name="medium"/>
+ <value name="thin"/>
+ <value name="thick"/>
+ </border-right-width>
+
+ <border-style>
+ <value name="solid"/>
+ <value name="none"/>
+ <value name="hidden"/>
+ <value name="dotted"/>
+ <value name="dashed"/>
+ <value name="double"/>
+ <value name="groove"/>
+ <value name="ridge"/>
+ <value name="inset"/>
+ <value name="outset"/>
+ </border-style>
+
+ <border-top-style>
+ <value name="solid"/>
+ <value name="none"/>
+ <value name="hidden"/>
+ <value name="dotted"/>
+ <value name="dashed"/>
+ <value name="double"/>
+ <value name="groove"/>
+ <value name="ridge"/>
+ <value name="inset"/>
+ <value name="outset"/>
+ </border-top-style>
+
+ <border-top-width>
+ <value name="medium"/>
+ <value name="thin"/>
+ <value name="thick"/>
+ </border-top-width>
+
+ <border-width>
+ <value name="medium"/>
+ <value name="thin"/>
+ <value name="thick"/>
+ </border-width>
+
+ <margin-bottom>
+ <value name="auto"/>
+ </margin-bottom>
+
+ <margin-left>
+ <value name="auto"/>
+ </margin-left>
+
+ <margin-right>
+ <value name="auto"/>
+ </margin-right>
+
+ <margin-top>
+ <value name="auto"/>
+ </margin-top>
+
+ <list-style-image>
+ <value name="none"/>
+ </list-style-image>
+
+ <list-style-position>
+ <value name="inside"/>
+ <value name="outside"/>
+ </list-style-position>
+
+ <list-style-type>
+ <value name="disk"/>
+ <value name="circle"/>
+ <value name="square"/>
+ <value name="decimal"/>
+ <value name="decimal-leading-zero"/>
+ <value name="lower-roman"/>
+ <value name="upper-roman"/>
+ <value name="lower-alpha"/>
+ <value name="upper-alpha"/>
+ <value name="lower-greek"/>
+ <value name="lower-latin"/>
+ <value name="upper-latin"/>
+ <value name="hebrew"/>
+ <value name="armenian"/>
+ <value name="georgian"/>
+ <value name="cjk-ideographic"/>
+ <value name="hiragana"/>
+ <value name="katakana"/>
+ <value name="hiragana-iroha"/>
+ <value name="katakana-iroha"/>
+ <value name="none"/>
+ </list-style-type>
+
+ <marker-offset>
+ <value name="auto"/>
+ </marker-offset>
+
+ <line-height>
+ <value name="normal"/>
+ </line-height>
+
+ <max-height>
+ <value name="none"/>
+ </max-height>
+
+ <max-width>
+ <value name="none"/>
+ </max-width>
+
+ <vertical-align>
+ <value name="baseline"/>
+ <value name="sub"/>
+ <value name="super"/>
+ <value name="top"/>
+ <value name="text-top"/>
+ <value name="middle"/>
+ <value name="bottom"/>
+ <value name="text-bottom"/>
+ </vertical-align>
+
+ <bottom>
+ <value name="auto"/>
+ </bottom>
+
+ <clear>
+ <value name="none"/>
+ <value name="left"/>
+ <value name="right"/>
+ <value name="both"/>
+ </clear>
+
+ <clip>
+ <value name="auto"/>
+ </clip>
+
+ <direction>
+ <value name="ltr"/>
+ <value name="rtl"/>
+ </direction>
+
+ <display>
+ <value name="none"/>
+ <value name="inline"/>
+ <value name="block"/>
+ <value name="list-item"/>
+ <value name="run-in"/>
+ <value name="compact"/>
+ <value name="marker"/>
+ <value name="table"/>
+ <value name="inline-table"/>
+ <value name="table-row-group"/>
+ <value name="table-header-group"/>
+ <value name="table-footer-group"/>
+ <value name="table-row"/>
+ <value name="table-column-group"/>
+ <value name="table-column"/>
+ <value name="table-cell"/>
+ <value name="table-caption"/>
+ </display>
+
+ <float>
+ <value name="left"/>
+ <value name="right"/>
+ <value name="none"/>
+ </float>
+
+ <left>
+ <value name="auto"/>
+ </left>
+
+ <overflow>
+ <value name="visible"/>
+ <value name="hidden"/>
+ <value name="scroll"/>
+ <value name="auto"/>
+ </overflow>
+
+ <position>
+ <value name="static"/>
+ <value name="relative"/>
+ <value name="absolute"/>
+ <value name="fixed"/>
+ </position>
+
+ <right>
+ <value name="auto"/>
+ </right>
+
+ <top>
+ <value name="auto"/>
+ </top>
+
+ <unicode-bidi>
+ <value name="normal"/>
+ <value name="embed"/>
+ <value name="bidi-override"/>
+ </unicode-bidi>
+
+ <visibility>
+ <value name="visible"/>
+ <value name="hidden"/>
+ <value name="collapse"/>
+ </visibility>
+
+ <z-index>
+ <value name="auto"/>
+ </z-index>
+
+ <marks>
+ <value name="crop"/>
+ <value name="cross"/>
+ <value name="none"/>
+ </marks>
+
+ <page-break-after>
+ <value name="auto"/>
+ <value name="always"/>
+ <value name="avoid"/>
+ <value name="left"/>
+ <value name="right"/>
+ </page-break-after>
+
+ <page-break-before>
+ <value name="auto"/>
+ <value name="always"/>
+ <value name="avoid"/>
+ <value name="left"/>
+ <value name="right"/>
+ </page-break-before>
+
+ <page-break-inside>
+ <value name="avoid"/>
+ <value name="auto"/>
+ </page-break-inside>
+
+ <size>
+ <value name="auto"/>
+ <value name="portrait"/>
+ <value name="landscape"/>
+ </size>
+
+ <border-collapse>
+ <value name="collapse"/>
+ <value name="separate"/>
+ </border-collapse>
+
+ <caption-side>
+ <value name="top"/>
+ <value name="bottom"/>
+ <value name="left"/>
+ <value name="right"/>
+ </caption-side>
+
+ <empty-cells>
+ <value name="show"/>
+ <value name="hide"/>
+ </empty-cells>
+
+ <speak-header>
+ <value name="once"/>
+ <value name="always"/>
+ </speak-header>
+
+ <table-layout>
+ <value name="auto"/>
+ <value name="fixed"/>
+ </table-layout>
+
+ <cursor>
+ <value name="auto"/>
+ <value name="crosshair"/>
+ <value name="default"/>
+ <value name="pointer"/>
+ <value name="move"/>
+ <value name="e-resize"/>
+ <value name="ne-resize"/>
+ <value name="nw-resize"/>
+ <value name="n-resize"/>
+ <value name="se-resize"/>
+ <value name="sw-resize"/>
+ <value name="s-resize"/>
+ <value name="w-resize"/>
+ <value name="text"/>
+ <value name="wait"/>
+ <value name="help"/>
+ </cursor>
+
+ <outline-style>
+ <value name="solid"/>
+ <value name="none"/>
+ <value name="hidden"/>
+ <value name="dotted"/>
+ <value name="dashed"/>
+ <value name="double"/>
+ <value name="groove"/>
+ <value name="ridge"/>
+ <value name="inset"/>
+ <value name="outset"/>
+ </outline-style>
+
+ <outline-width>
+ <value name="medium"/>
+ <value name="thin"/>
+ <value name="thick"/>
+ </outline-width>
+
+ <azimuth>
+ <value name="left-side"/>
+ <value name="far-left"/>
+ <value name="left"/>
+ <value name="center-left"/>
+ <value name="center"/>
+ <value name="center-right"/>
+ <value name="right"/>
+ <value name="far-right"/>
+ <value name="rigth-side"/>
+ <value name="behind"/>
+ <value name="leftwards"/>
+ <value name="rightwards"/>
+ </azimuth>
+
+ <cue-after>
+ <value name="none"/>
+ </cue-after>
+
+ <cue-before>
+ <value name="none"/>
+ </cue-before>
+
+ <elevation>
+ <value name="below"/>
+ <value name="level"/>
+ <value name="above"/>
+ <value name="higher"/>
+ <value name="lower"/>
+ </elevation>
+
+ <pitch>
+ <value name="x-low"/>
+ <value name="low"/>
+ <value name="medium"/>
+ <value name="high"/>
+ <value name="x-high"/>
+ </pitch>
+
+ <play-during>
+ <value name="mix"/>
+ <value name="repeat"/>
+ <value name="auto"/>
+ <value name="none"/>
+ </play-during>
+
+ <speak>
+ <value name="normal"/>
+ <value name="none"/>
+ <value name="spell-out"/>
+ </speak>
+
+ <speak-numeral>
+ <value name="digits"/>
+ <value name="continuous"/>
+ </speak-numeral>
+
+ <speak-punctuation>
+ <value name="code"/>
+ <value name="none"/>
+ </speak-punctuation>
+
+ <speech-rate>
+ <value name="x-slow"/>
+ <value name="slow"/>
+ <value name="medium"/>
+ <value name="fast"/>
+ <value name="x-fast"/>
+ <value name="faster"/>
+ <value name="slower"/>
+ </speech-rate>
+
+ <volumn>
+ <value name="silent"/>
+ <value name="x-soft"/>
+ <value name="soft"/>
+ <value name="medium"/>
+ <value name="loud"/>
+ <value name="x-loud"/>
+ </volumn>
+</elements>
\ No newline at end of file
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/JspEditorPlugin.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/JspEditorPlugin.java 2008-07-16 13:59:16 UTC (rev 9154)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/JspEditorPlugin.java 2008-07-16 15:19:39 UTC (rev 9155)
@@ -11,9 +11,8 @@
package org.jboss.tools.jst.jsp;
import java.io.File;
+import java.io.IOException;
import java.net.URL;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -23,6 +22,7 @@
import org.eclipse.core.runtime.Platform;
import org.eclipse.jdt.ui.text.JavaTextTools;
import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jst.jsp.ui.internal.JSPUIPlugin;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbench;
@@ -31,6 +31,7 @@
import org.jboss.tools.common.log.IPluginLog;
import org.jboss.tools.common.text.xml.XmlEditorPlugin;
import org.jboss.tools.jst.jsp.preferences.JSPOccurrencePreferenceConstants;
+import org.osgi.framework.Bundle;
/**
* The main plugin class to be used in the desktop.
@@ -41,6 +42,7 @@
public static final String PLUGIN_ID = "org.jboss.tools.jst.jsp";
+ public static final String PLUGIN_CSSDIALOG_RESOURCES = "/resources/org/jboss/tools/jst/jsp/outline/cssdialog";
/**
* The constructor.
@@ -133,4 +135,34 @@
public static IPluginLog getPluginLog() {
return getDefault();
}
+
+ /**
+ * Returns an image descriptor for the image file at the given plug-in
+ * relative path
+ *
+ * @param path
+ * the path
+ * @return the image descriptor
+ */
+ public static ImageDescriptor getImageDescriptor(String path) {
+ return imageDescriptorFromPlugin(PLUGIN_ID, path);
+ }
+
+ /**
+ * Get plug-in resource path
+ *
+ * @return path
+ */
+ public static String getPluginCSSDialogResourcePath() {
+ Bundle bundle = Platform.getBundle(PLUGIN_ID);
+ URL url = null;
+ try {
+ url = bundle == null ? null : FileLocator.resolve(bundle
+ .getEntry(PLUGIN_CSSDIALOG_RESOURCES));
+
+ } catch (IOException e) {
+ url = bundle.getEntry(PLUGIN_CSSDIALOG_RESOURCES);
+ }
+ return (url == null) ? null : url.getPath();
+ }
}
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPDialogCellEditor.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPDialogCellEditor.java 2008-07-16 13:59:16 UTC (rev 9154)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPDialogCellEditor.java 2008-07-16 15:19:39 UTC (rev 9155)
@@ -7,121 +7,141 @@
*
* Contributors:
* Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.tools.jst.jsp.outline;
import java.util.Properties;
-import org.jboss.tools.common.kb.wtp.WtpKbConnector;
-import org.jboss.tools.common.model.ui.attribute.editor.DialogCellEditorEx;
-import org.jboss.tools.common.model.ui.objecteditor.AttributeWrapper;
-import org.jboss.tools.common.model.ui.objecteditor.ExtendedCellEditorProvider;
-import org.eclipse.jdt.internal.ui.refactoring.contentassist.*;
+import org.eclipse.jdt.internal.ui.refactoring.contentassist.ControlContentAssistHelper;
+import org.eclipse.jface.window.Window;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.contentassist.ContentAssistHandler;
import org.jboss.tools.common.meta.key.WizardKeys;
+import org.jboss.tools.common.model.ui.attribute.editor.DialogCellEditorEx;
+import org.jboss.tools.common.model.ui.objecteditor.AttributeWrapper;
+import org.jboss.tools.common.model.ui.objecteditor.ExtendedCellEditorProvider;
+import org.jboss.tools.jst.jsp.contentassist.FaceletsHtmlContentAssistProcessor;
import org.jboss.tools.jst.jsp.contentassist.JSPDialogCellEditorContentAssistProcessor;
-import org.jboss.tools.jst.jsp.contentassist.FaceletsHtmlContentAssistProcessor;
import org.jboss.tools.jst.jsp.drop.treeviewer.model.RootElement;
+import org.jboss.tools.jst.jsp.outline.cssdialog.CSSDialog;
/**
- * @author Kabanovich
- * Cell Editor for JSP attributes, of which values can be
- * provided by prompting knoledgebase.
+ * @author Kabanovich Cell Editor for JSP attributes, of which values can be
+ * provided by prompting knoledgebase.
*/
-public class JSPDialogCellEditor extends DialogCellEditorEx implements ExtendedCellEditorProvider.StoppableCellEditor {
- Properties context;
- //ValueHelper valueHelper;
- JSPDialogCellEditorContentAssistProcessor contentAssistentProcessor;
- ContentAssistHandler handler = null;
-
- boolean hasProposals = false;
-
- public JSPDialogCellEditor(Composite parent, Properties context) {
- super(parent);
- this.context = context;
- ValueHelper valueHelper = (ValueHelper)context.get("valueHelper");
+public class JSPDialogCellEditor extends DialogCellEditorEx implements
+ ExtendedCellEditorProvider.StoppableCellEditor {
+ Properties context;
+ // ValueHelper valueHelper;
+ JSPDialogCellEditorContentAssistProcessor contentAssistentProcessor;
+ ContentAssistHandler handler = null;
- contentAssistentProcessor = new JSPDialogCellEditorContentAssistProcessor();
- if(valueHelper != null) contentAssistentProcessor.setContext(context);
- handler = ContentAssistHandler.createHandlerForText(getTextField(), ControlContentAssistHelper.createJavaContentAssistant(contentAssistentProcessor));
- }
-
+ boolean hasProposals = false;
+
+ public JSPDialogCellEditor(Composite parent, Properties context) {
+ super(parent);
+ this.context = context;
+ ValueHelper valueHelper = (ValueHelper) context.get("valueHelper");
+
+ contentAssistentProcessor = new JSPDialogCellEditorContentAssistProcessor();
+ if (valueHelper != null)
+ contentAssistentProcessor.setContext(context);
+ handler = ContentAssistHandler.createHandlerForText(getTextField(),
+ ControlContentAssistHelper
+ .createJavaContentAssistant(contentAssistentProcessor));
+ }
+
public void activate() {
- checkHasProposals();
- checkButtonEnablement();
- super.activate();
+ checkHasProposals();
+ checkButtonEnablement();
+ super.activate();
+ }
+
+ void checkHasProposals() {
+ hasProposals = false;
+ if (context == null)
+ return;
+ // valueHelper = (ValueHelper)context.get("valueHelper");
+ // if(valueHelper == null) return;
+ ValueHelper valueHelper = new ValueHelper();
+ String attributeName = "" + context.getProperty("attributeName");
+ String nodeName = "" + context.getProperty("nodeName");
+ String query = "/";
+ if (valueHelper.isFacetets() && nodeName.indexOf(':') < 0) {
+ query += FaceletsHtmlContentAssistProcessor.faceletHtmlPrefixStart;
}
-
- void checkHasProposals() {
- hasProposals = false;
- if(context == null) return;
- //valueHelper = (ValueHelper)context.get("valueHelper");
- //if(valueHelper == null) return;
- ValueHelper valueHelper = new ValueHelper();
- String attributeName = "" + context.getProperty("attributeName");
- String nodeName = "" + context.getProperty("nodeName");
- String query = "/";
- if(valueHelper.isFacetets() && nodeName.indexOf(':') < 0) {
- query += FaceletsHtmlContentAssistProcessor.faceletHtmlPrefixStart;
- }
- query += nodeName + "@" + attributeName;
- RootElement root = (RootElement)valueHelper.getInitalInput(query);
- hasProposals = root != null && root.getChildren().length > 0;
+ query += nodeName + "@" + attributeName;
+ RootElement root = (RootElement) valueHelper.getInitalInput(query);
+ hasProposals = root != null && root.getChildren().length > 0;
}
-
+
private void checkButtonEnablement() {
- if(context == null) return;
- //valueHelper = (ValueHelper)context.get("valueHelper");
- //if(valueHelper == null) return;
- ValueHelper valueHelper = new ValueHelper();
- Button button = getButtonControl();
- if(button == null || button.isDisposed()) return;
- button.setVisible(hasProposals);
- handler.setEnabled(hasProposals);
+ if (context == null)
+ return;
+ // valueHelper = (ValueHelper)context.get("valueHelper");
+ // if(valueHelper == null) return;
+ ValueHelper valueHelper = new ValueHelper();
+ Button button = getButtonControl();
+ if (button == null || button.isDisposed())
+ return;
+ button.setVisible(hasProposals);
+ handler.setEnabled(hasProposals);
}
- protected Object openDialogBox(Control cellEditorWindow) {
- externalEditing = true;
- String attributeName = "" + context.getProperty("attributeName");
- String nodeName = "" + context.getProperty("nodeName");
- String query = "/";
- ValueHelper valueHelper = new ValueHelper();
- if(valueHelper != null && valueHelper.isFacetets() && nodeName.indexOf(":") < 0) {
- query += FaceletsHtmlContentAssistProcessor.faceletHtmlPrefixStart;
- }
- query += nodeName + "@" + attributeName;
- context.setProperty("query", query);
- context.setProperty("help", query);
- context.setProperty("title", "Edit " + WizardKeys.toDisplayName(attributeName));
- context.setProperty("subtitle", "<" + context.getProperty("nodeName") + ">");
+ protected Object openDialogBox(Control cellEditorWindow) {
+ externalEditing = true;
+ String attributeName = "" + context.getProperty("attributeName");
+ String nodeName = "" + context.getProperty("nodeName");
+ String query = "/";
+ ValueHelper valueHelper = new ValueHelper();
+ if (valueHelper != null && valueHelper.isFacetets()
+ && nodeName.indexOf(":") < 0) {
+ query += FaceletsHtmlContentAssistProcessor.faceletHtmlPrefixStart;
+ }
+ query += nodeName + "@" + attributeName;
+ context.setProperty("query", query);
+ context.setProperty("help", query);
+ context.setProperty("title", "Edit "
+ + WizardKeys.toDisplayName(attributeName));
+ context.setProperty("subtitle", "<" + context.getProperty("nodeName")
+ + ">");
- String value = (getValue() instanceof String)
- ? getValue().toString()
- : getValue() instanceof AttributeWrapper ? ((AttributeWrapper)getValue()).value
+ String value = (getValue() instanceof String) ? getValue().toString()
+ : getValue() instanceof AttributeWrapper ? ((AttributeWrapper) getValue()).value
: "";
-
- context.put("value", value);
- JSPTreeDialog dialog = new JSPTreeDialog();
- dialog.setObject(context);
- if(dialog.execute() != 0) {
- externalEditing = false;
- return null;
+
+ context.put("value", value);
+ if (attributeName.equals("style")) {
+ CSSDialog dialog = new CSSDialog(cellEditorWindow.getShell(), (value == null ? ""
+ : value));
+ if (dialog.open() == Window.OK) {
+ externalEditing = false;
+ return dialog.getNewStyle();
+
}
+ } else {
+
+ JSPTreeDialog dialog = new JSPTreeDialog();
+ dialog.setObject(context);
+ if (dialog.execute() != 0) {
externalEditing = false;
- value = context.getProperty("value");
- return value;
+ return null;
+ }
}
-
- public void stopEditing() {
- super.fireApplyEditorValue();
- }
-
- protected Text getTextField() {
- return text;
- }
+ externalEditing = false;
+ value = context.getProperty("value");
+ return value;
+ }
+
+ public void stopEditing() {
+ super.fireApplyEditorValue();
+ }
+
+ protected Text getTextField() {
+ return text;
+ }
}
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/CSSDialog.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/CSSDialog.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/CSSDialog.java 2008-07-16 15:19:39 UTC (rev 9155)
@@ -0,0 +1,426 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.jsp.outline.cssdialog;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.browser.Browser;
+import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
+import org.jboss.tools.jst.jsp.JspEditorPlugin;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.Constants;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.MessageUtil;
+import org.jboss.tools.jst.jsp.outline.cssdialog.parsers.BaseListener;
+import org.jboss.tools.jst.jsp.outline.cssdialog.parsers.CSSElementsParser;
+import org.jboss.tools.jst.jsp.outline.cssdialog.parsers.ColorParser;
+import org.jboss.tools.jst.jsp.outline.cssdialog.parsers.ColorParserListener;
+import org.jboss.tools.jst.jsp.outline.cssdialog.parsers.ComboParser;
+import org.jboss.tools.jst.jsp.outline.cssdialog.parsers.Parser;
+import org.jboss.tools.jst.jsp.outline.cssdialog.parsers.ParserListener;
+import org.jboss.tools.jst.jsp.outline.cssdialog.tabs.TabBackgroundControl;
+import org.jboss.tools.jst.jsp.outline.cssdialog.tabs.TabBoxesControl;
+import org.jboss.tools.jst.jsp.outline.cssdialog.tabs.TabPropertySheetControl;
+import org.jboss.tools.jst.jsp.outline.cssdialog.tabs.TabQuickEditControl;
+import org.jboss.tools.jst.jsp.outline.cssdialog.tabs.TabTextControl;
+import org.xml.sax.Attributes;
+
+/**
+ * Class for CSS editor dialog
+ *
+ * @author Dzmitry Sakovich (dsakovich(a)exadel.com)
+ */
+public class CSSDialog extends Dialog {
+
+ private static int MIN_HEIGHT_FOR_BROWSER = 60;
+
+ private static int TAB_TEXT_FONT_NUMBER = 0;
+ private static int TAB_QUICK_EDIT_NUMBER = 4;
+
+ private static int SIZE_NULL = 0;
+
+ private static int FIRST_SELECTION = 0;
+
+ private static String NODE_NAME_ELEMENTS = "elements";
+ private static String NODE_NAME_VALUE = "value";
+ private static String NODE_NAME_ELEMENT = "element";
+ private static String NODE_ATTRIBUTE_NAME = "name";
+
+ private Browser browser = null;
+
+ private String oldStyle;
+ private String newStyle;
+
+ private TabItem lastSelectedTab = null;
+
+ private TabTextControl tabTextControl;
+ private TabBackgroundControl tabBackgroundControl;
+ private TabBoxesControl tabBoxesControl;
+ private TabPropertySheetControl tabPropertySheetControl;
+ private TabQuickEditControl tabQuickEditControl;
+
+ private TabItem tabTextFont;
+ private TabItem tabBackground;
+ private TabItem tabBoxes;
+ private TabItem tabPropertySheet;
+ private TabItem tabQuickEdit;
+
+ private HashMap<String, ArrayList<String>> comboMap = new HashMap<String, ArrayList<String>>();
+ private HashMap<String, ArrayList<String>> elementsMap = new HashMap<String, ArrayList<String>>();
+ private HashMap<String, String> attributesMap = new HashMap<String, String>();
+
+ public CSSDialog(final Shell parentShell, String oldStyle) {
+ super(parentShell);
+ setShellStyle(getShellStyle() | SWT.RESIZE | SWT.MAX
+ | SWT.APPLICATION_MODAL);
+ this.oldStyle = oldStyle;
+
+ ComboParser comboParser = new ComboParser();
+ comboParser.setListener(new BaseListener(comboMap) {
+
+ private ArrayList<String> list = null;
+
+ public void startElement(String uri, String localName,
+ String nodeName, Attributes attrs) {
+
+ if (nodeName.trim().equalsIgnoreCase(NODE_NAME_ELEMENTS))
+ return;
+
+ if (!nodeName.trim().equalsIgnoreCase(NODE_NAME_VALUE)) {
+ String name = nodeName;
+ list = new ArrayList<String>();
+ map.put(name, list);
+ } else {
+ list.add(attrs.getValue(NODE_ATTRIBUTE_NAME));
+ }
+ }
+
+ });
+ comboParser.parse();
+
+ CSSElementsParser cssParser = new CSSElementsParser();
+ cssParser.setListener(new BaseListener(elementsMap) {
+
+ private ArrayList<String> list = null;
+
+ public void startElement(String uri, String localName,
+ String nodeName, Attributes attrs) {
+
+ if (nodeName.trim().equalsIgnoreCase(NODE_NAME_ELEMENTS))
+ return;
+
+ if (!nodeName.trim().equalsIgnoreCase(NODE_NAME_ELEMENT)) {
+ String name = nodeName;
+ list = new ArrayList<String>();
+ map.put(name, list);
+ } else {
+ list.add(attrs.getValue(NODE_ATTRIBUTE_NAME));
+ }
+ }
+
+ });
+ cssParser.parse();
+
+ ColorParserListener colorListener = new ColorParserListener();
+ ColorParser colorParser = new ColorParser();
+ colorParser.setListener(colorListener);
+ colorParser.parse();
+
+ }
+
+ /**
+ * Getter for newStyle attribute
+ *
+ * @return
+ */
+ public String getNewStyle() {
+ return newStyle;
+ }
+
+ /**
+ * Setter for newStyle attribute
+ *
+ * @param newStyle
+ */
+ public void setNewStyle(String newStyle) {
+ this.newStyle = newStyle;
+ }
+
+ /**
+ * Method for creating dialog area
+ *
+ * @param parent
+ */
+ protected Control createDialogArea(final Composite parent) {
+
+ ParserListener listener = new ParserListener(attributesMap);
+ Parser parser = new Parser(elementsMap);
+ parser.addListener(listener);
+ parser.parse(oldStyle);
+
+ final Composite composite = (Composite) super.createDialogArea(parent);
+
+ final GridData gridData = new GridData(GridData.FILL, GridData.FILL,
+ true, true);
+
+ composite.setLayoutData(gridData);
+ GridData gd = new GridData(GridData.FILL_BOTH
+ | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL);
+
+ final TabFolder tabFolder = new TabFolder(composite, SWT.NONE);
+ tabFolder.setLayoutData(gd);
+
+ // ------------------------Browser-----------------------------------
+
+ browser = new Browser(composite, SWT.BORDER);
+ GridData gridBrowser = new GridData(GridData.FILL_BOTH);
+ gridBrowser.minimumHeight = MIN_HEIGHT_FOR_BROWSER;
+ browser.setLayoutData(gridBrowser);
+ //browser.se
+ setStyleForPreview();
+ // ------------------------------------------------------------------
+
+ // Create each tab and set its text, tool tip text,
+ tabTextFont = new TabItem(tabFolder, SWT.NONE);
+ tabTextFont.setText(MessageUtil.getString("TEXT_FONT_TAB_NAME"));
+ tabTextFont.setToolTipText(MessageUtil.getString("TEXT_FONT_TAB_NAME"));
+ tabTextFont.setControl(createTabTextControl(tabFolder));
+ lastSelectedTab = tabTextFont;
+
+ tabBackground = new TabItem(tabFolder, SWT.NONE);
+ tabBackground.setText(MessageUtil.getString("BACKGROUND_TAB_NAME"));
+ tabBackground.setToolTipText(MessageUtil
+ .getString("BACKGROUND_TAB_NAME"));
+ tabBackground.setControl(createTabBackgroundControl(tabFolder));
+
+ tabBoxes = new TabItem(tabFolder, SWT.NONE);
+ tabBoxes.setText(MessageUtil.getString("BOXES_TAB_NAME"));
+ tabBoxes.setToolTipText(MessageUtil.getString("BOXES_TAB_NAME"));
+ tabBoxes.setControl(createTabBoxesControl(tabFolder));
+
+ tabPropertySheet = new TabItem(tabFolder, SWT.NONE);
+ tabPropertySheet.setText(MessageUtil
+ .getString("PROPERTY_SHEET_TAB_NAME"));
+ tabPropertySheet.setToolTipText(MessageUtil
+ .getString("PROPERTY_SHEET_TAB_NAME"));
+ tabPropertySheet.setControl(createTabPropertySheetControl(tabFolder));
+
+ tabFolder.setSelection(TAB_TEXT_FONT_NUMBER);
+ if (attributesMap.size() > SIZE_NULL) {
+ tabQuickEdit = new TabItem(tabFolder, SWT.NONE);
+ tabQuickEdit.setText(MessageUtil.getString("QUICK_EDIT_TAB-NAME"));
+ tabQuickEdit.setToolTipText(MessageUtil
+ .getString("QUICK_EDIT_TAB-NAME"));
+ tabQuickEdit.setControl(createTabQuickEditContol(tabFolder));
+ tabFolder.setSelection(TAB_QUICK_EDIT_NUMBER);
+ lastSelectedTab = tabQuickEdit;
+ }
+ tabFolder.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent se) {
+
+
+ if (tabFolder.getSelection()[FIRST_SELECTION] == tabQuickEdit) {
+ tabQuickEditControl.dispose();
+ tabQuickEdit
+ .setControl(createTabQuickEditContol(tabFolder));
+ lastSelectedTab = tabQuickEdit;
+ } else if (tabFolder.getSelection()[FIRST_SELECTION] == tabTextFont) {
+ tabTextControl.updateData(false);
+ lastSelectedTab = tabTextFont;
+ } else if (tabFolder.getSelection()[FIRST_SELECTION] == tabBackground) {
+ tabBackgroundControl.updateData(false);
+ lastSelectedTab = tabBackground;
+ } else if (tabFolder.getSelection()[FIRST_SELECTION] == tabBoxes) {
+ tabBoxesControl.updateData(false);
+ lastSelectedTab = tabBoxes;
+ } else if (tabFolder.getSelection()[FIRST_SELECTION] == tabPropertySheet) {
+ tabPropertySheetControl.updateData(false);
+ lastSelectedTab = tabPropertySheet;
+ }
+ }
+ });
+
+ return composite;
+ }
+
+ /**
+ * Method for setting title for dialog
+ *
+ * @param newShell
+ */
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ newShell.setText(MessageUtil.getString("CSS_DIALOG_TITLE"));
+ }
+
+ protected void okPressed() {
+
+ if (lastSelectedTab == tabTextFont) {
+ tabTextControl.updateData(true);
+ } else if (lastSelectedTab == tabBackground) {
+ tabBackgroundControl.updateData(true);
+ } else if (lastSelectedTab == tabBoxes) {
+ tabBoxesControl.updateData(true);
+ } else if (lastSelectedTab == tabPropertySheet) {
+ tabPropertySheetControl.updateData(true);
+ }
+ StringBuffer buf = new StringBuffer();
+ Set<Entry<String, String>> set = attributesMap.entrySet();
+ for (Map.Entry<String, String> me : set) {
+ buf.append(me.getKey() + Constants.COLON_STRING + me.getValue()
+ + Constants.SEMICOLON_STRING);
+ }
+ setNewStyle(buf.toString());
+ super.okPressed();
+ }
+
+ /**
+ * Method for creating text tab
+ *
+ * @param tabFolder
+ * @return composite
+ */
+ private Control createTabTextControl(TabFolder tabFolder) {
+
+ ScrolledComposite sc = new ScrolledComposite(tabFolder, SWT.H_SCROLL
+ | SWT.V_SCROLL);
+
+ sc.setExpandHorizontal(true);
+ sc.setExpandVertical(true);
+
+ tabTextControl = new TabTextControl(sc, comboMap, attributesMap, this);
+ sc.setContent(tabTextControl);
+
+ sc.setMinSize(tabTextControl.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+
+ return sc;
+ }
+
+ /**
+ * Method for creating background tab
+ *
+ * @param tabFolder
+ * @return composite
+ */
+ private Control createTabBackgroundControl(TabFolder tabFolder) {
+ ScrolledComposite sc = new ScrolledComposite(tabFolder, SWT.H_SCROLL
+ | SWT.V_SCROLL);
+
+ sc.setExpandHorizontal(true);
+ sc.setExpandVertical(true);
+
+ tabBackgroundControl = new TabBackgroundControl(sc, comboMap,
+ attributesMap, this);
+ sc.setContent(tabBackgroundControl);
+ sc.setMinSize(tabBackgroundControl
+ .computeSize(SWT.DEFAULT, SWT.DEFAULT));
+
+ return sc;
+ }
+
+ /**
+ * Method for creating boxes tab
+ *
+ * @param tabFolder
+ * @return composite
+ */
+ private Control createTabBoxesControl(TabFolder tabFolder) {
+
+ ScrolledComposite sc = new ScrolledComposite(tabFolder, SWT.H_SCROLL
+ | SWT.V_SCROLL);
+
+ sc.setExpandHorizontal(true);
+ sc.setExpandVertical(true);
+
+ tabBoxesControl = new TabBoxesControl(sc, comboMap, attributesMap, this);
+ sc.setContent(tabBoxesControl);
+ sc.setMinSize(tabBoxesControl.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+
+ return sc;
+ }
+
+ /**
+ *
+ * Method for creating property sheet tab
+ *
+ * @param tabFolder
+ * @return
+ */
+ private Control createTabPropertySheetControl(TabFolder tabFolder) {
+ tabPropertySheetControl = new TabPropertySheetControl(tabFolder,
+ elementsMap, comboMap, attributesMap, this);
+ return tabPropertySheetControl;
+ }
+
+ /**
+ *
+ * Method for creating quick edit tab
+ *
+ * @param tabFolder
+ * @return
+ */
+ private Control createTabQuickEditContol(TabFolder tabFolder) {
+
+ ScrolledComposite sc = new ScrolledComposite(tabFolder, SWT.H_SCROLL
+ | SWT.V_SCROLL);
+
+ sc.setExpandHorizontal(true);
+ sc.setExpandVertical(true);
+
+ tabQuickEditControl = new TabQuickEditControl(sc, comboMap,
+ attributesMap, this);
+ sc.setContent(tabQuickEditControl);
+
+ sc
+ .setMinSize(tabQuickEditControl.computeSize(SWT.DEFAULT,
+ SWT.DEFAULT));
+ return sc;
+ }
+
+ @Override
+ protected IDialogSettings getDialogBoundsSettings() {
+ return JspEditorPlugin.getDefault().getDialogSettings();
+ }
+
+ /**
+ *
+ * Set style for preview
+ */
+ public void setStyleForPreview() {
+
+ String styleForSpan = "";
+ String html = "";
+
+ Set<String> keySet = attributesMap.keySet();
+
+ for (String key : keySet)
+ styleForSpan += key + Constants.COLON_STRING
+ + attributesMap.get(key) + Constants.SEMICOLON_STRING;
+
+ html = Constants.OPEN_SPAN_TAG + styleForSpan
+ + Constants.TEXT_FOR_PREVIEW + Constants.CLOSE_SPAN_TAG;
+ browser.setText(html);
+ }
+}
\ No newline at end of file
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/FontFamilyDialog.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/FontFamilyDialog.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/FontFamilyDialog.java 2008-07-16 15:19:39 UTC (rev 9155)
@@ -0,0 +1,496 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.jsp.outline.cssdialog;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.DragSource;
+import org.eclipse.swt.dnd.DragSourceEvent;
+import org.eclipse.swt.dnd.DragSourceListener;
+import org.eclipse.swt.dnd.DropTarget;
+import org.eclipse.swt.dnd.DropTargetAdapter;
+import org.eclipse.swt.dnd.DropTargetEvent;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.List;
+import org.eclipse.swt.widgets.Shell;
+
+import org.jboss.tools.jst.jsp.JspEditorPlugin;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.Constants;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.MessageUtil;
+
+/**
+ * Class for choosing CCS font-family attribute
+ *
+ * @author dsakovich(a)exadel.com
+ */
+public class FontFamilyDialog extends Dialog implements SelectionListener {
+
+ /** Font family string */
+ private String fontFamily;
+
+ /** Existing font family */
+ private String existFontFamily;
+
+ private List fontFamilyList;
+ private List allFontFamilyList;
+
+ private Button rightButton;
+ private Button leftButton;
+
+ private static final String COMMA = ",";
+
+ private static final int HEIGHT = 300;
+
+ private static final int BUTTON_TOP_OFFSET = 20;
+ private static final int BUTTON_LEFT_OFFSET = 20;
+ private static final int BUTTON_RIGHT_OFFSET = -20;
+ private static final int BUTTON_RIGHT = 60;
+ private static final int RIGHT_BUTTON_TOP = 30;
+ private static final int LEFT_BUTTON_TOP = 40;
+
+ private static final int LIST_TOP_OFFSET = 10;
+ private static final int LIST_RIGHT_OFFSET = -10;
+ private static final int LIST_LEFT_OFFSET = 10;
+ private static final int LIST_BOTTOM_OFFSET = -10;
+ private static final int LIST_TOP = 5;
+ private static final int LIST_BOTTOM = 100;
+
+ private static final int ALL_FONTS_LIST_LEFT = 0;
+ private static final int ALL_FONTS_LIST_RIGHT = 40;
+ private static final int SELECTED_FONT_LIST_LEFT = 60;
+ private static final int SELECTED_FONT_LIST_RIGHT = 100;
+
+ /**
+ * Constructor
+ *
+ * @param parentShell
+ * parent shell
+ * @param existingFontFamily
+ * existing font family
+ */
+ public FontFamilyDialog(Shell parentShell, String existingFontFamily) {
+ super(parentShell);
+ this.existFontFamily = existingFontFamily;
+ }
+
+ /**
+ * Create Dialog area
+ *
+ * @param Composite
+ */
+ protected Control createDialogArea(Composite parent) {
+ final Composite composite = (Composite) super.createDialogArea(parent);
+
+ composite.setLayout(new FormLayout());
+
+ allFontFamilyList = new List(composite, SWT.MULTI | SWT.BORDER
+ | SWT.V_SCROLL);
+ FormData fd = new FormData();
+ fd.top = new FormAttachment(LIST_TOP, LIST_TOP_OFFSET);
+ fd.left = new FormAttachment(ALL_FONTS_LIST_LEFT, LIST_LEFT_OFFSET);
+ fd.bottom = new FormAttachment(LIST_BOTTOM, LIST_BOTTOM_OFFSET);
+ fd.right = new FormAttachment(ALL_FONTS_LIST_RIGHT, LIST_RIGHT_OFFSET);
+ fd.height = HEIGHT;
+ allFontFamilyList.setLayoutData(fd);
+
+ Set<String> s = new HashSet<String>();
+ FontData[] fds = composite.getDisplay().getFontList(null, false);
+ for (int i = 0; i < fds.length; ++i)
+ s.add(fds[i].getName());
+ fds = composite.getDisplay().getFontList(null, true);
+ for (int i = 0; i < fds.length; ++i)
+ s.add(fds[i].getName());
+ String[] existFonts = fontFamilyParser();
+ Arrays.sort(existFonts);
+
+ String[] answer = new String[s.size()];
+ s.toArray(answer);
+ Arrays.sort(answer);
+
+ for (int i = 0; i < answer.length; i++) {
+ allFontFamilyList.add(answer[i]);
+ }
+
+ rightButton = new Button(composite, SWT.PUSH);
+ fd = new FormData();
+ fd.top = new FormAttachment(RIGHT_BUTTON_TOP, BUTTON_TOP_OFFSET);
+ fd.left = new FormAttachment(allFontFamilyList, BUTTON_LEFT_OFFSET);
+ fd.right = new FormAttachment(BUTTON_RIGHT, BUTTON_RIGHT_OFFSET);
+ rightButton.setLayoutData(fd);
+ rightButton
+ .setToolTipText(MessageUtil.getString("ADD_FONT_FAMILY_TIP"));
+ ImageDescriptor rightDesc = JspEditorPlugin
+ .getImageDescriptor(Constants.IMAGE_RIGHT_FILE_LOCATION);
+ Image rightImage = rightDesc.createImage();
+ rightButton.setImage(rightImage);
+ rightButton.setEnabled(false);
+ rightButton.addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent e) {
+ Button button = (Button) e.getSource();
+ button.getImage().dispose();
+ }
+ });
+ leftButton = new Button(composite, SWT.PUSH);
+ fd = new FormData();
+ fd.top = new FormAttachment(LEFT_BUTTON_TOP, BUTTON_TOP_OFFSET);
+ fd.left = new FormAttachment(allFontFamilyList, BUTTON_LEFT_OFFSET);
+ fd.right = new FormAttachment(BUTTON_RIGHT, BUTTON_RIGHT_OFFSET);
+ leftButton.setLayoutData(fd);
+ leftButton.setToolTipText(MessageUtil
+ .getString("REMOVE_FONT_FAMILY_TIP"));
+ ImageDescriptor leftDesc = JspEditorPlugin
+ .getImageDescriptor(Constants.IMAGE_LEFT_FILE_LOCATION);
+ Image leftImage = leftDesc.createImage();
+ leftButton.setImage(leftImage);
+ leftButton.setEnabled(false);
+ leftButton.addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent e) {
+ Button button = (Button) e.getSource();
+ button.getImage().dispose();
+ }
+ });
+
+ fontFamilyList = new List(composite, SWT.SINGLE | SWT.BORDER
+ | SWT.V_SCROLL);
+ fd = new FormData();
+ fd.top = new FormAttachment(LIST_TOP, LIST_TOP_OFFSET);
+ fd.left = new FormAttachment(SELECTED_FONT_LIST_LEFT, LIST_LEFT_OFFSET);
+ fd.bottom = new FormAttachment(LIST_BOTTOM, LIST_BOTTOM_OFFSET);
+ fd.right = new FormAttachment(SELECTED_FONT_LIST_RIGHT,
+ LIST_RIGHT_OFFSET);
+ fd.height = HEIGHT;
+ fontFamilyList.setLayoutData(fd);
+ if (existFontFamily != null
+ && !existFontFamily.equals(Constants.EMPTY_STRING)) {
+ for (int i = 0; i < existFonts.length; i++) {
+ fontFamilyList.add(existFonts[i]);
+ }
+ }
+
+ /** Control listeners */
+ allFontFamilyList.addMouseListener(new MouseListener() {
+
+ public void mouseDoubleClick(MouseEvent e) {
+ int selectedItem = allFontFamilyList.getSelectionIndex();
+ addFont(fontFamilyList, allFontFamilyList.getItem(selectedItem));
+ allFontFamilyList.remove(selectedItem);
+ rightButton.setEnabled(false);
+ }
+
+ public void mouseDown(MouseEvent e) {
+ if (allFontFamilyList.getSelectionCount() > 0) {
+ fontFamilyList.deselectAll();
+ leftButton.setEnabled(false);
+ rightButton.setEnabled(true);
+ }
+ }
+
+ public void mouseUp(MouseEvent e) {
+ }
+ });
+
+ fontFamilyList.addMouseListener(new MouseListener() {
+
+ public void mouseDoubleClick(MouseEvent e) {
+ leftButton.setEnabled(false);
+ int selectedItem = fontFamilyList.getSelectionIndex();
+ fontFamilyList.deselectAll();
+ addFont(allFontFamilyList, fontFamilyList.getItem(selectedItem));
+ fontFamilyList.remove(selectedItem);
+ }
+
+ public void mouseDown(MouseEvent e) {
+ if (fontFamilyList.getSelectionCount() > 0) {
+ allFontFamilyList.deselectAll();
+ rightButton.setEnabled(false);
+ leftButton.setEnabled(true);
+ }
+ }
+
+ public void mouseUp(MouseEvent e) {
+ }
+
+ });
+
+ rightButton.addSelectionListener(this);
+
+ leftButton.addSelectionListener(this);
+
+ /** Add drag and drop */
+ Transfer[] types = new Transfer[] { TextTransfer.getInstance() };
+
+ final DragSource source = new DragSource(allFontFamilyList,
+ DND.DROP_MOVE);
+ source.setTransfer(types);
+ source.addDragListener(new DragSourceListener() {
+
+ public void dragFinished(DragSourceEvent event) {
+ if (event.detail == DND.DROP_MOVE) {
+ int selectedItem = allFontFamilyList.getSelectionIndex();
+ allFontFamilyList.remove(selectedItem);
+ }
+ }
+
+ public void dragSetData(DragSourceEvent event) {
+ int selectedItem = allFontFamilyList.getSelectionIndex();
+ event.data = allFontFamilyList.getItem(selectedItem);
+ }
+
+ public void dragStart(DragSourceEvent event) {
+ event.doit = (allFontFamilyList.getSelectionCount() != 0);
+ }
+
+ });
+
+ DropTarget target = new DropTarget(fontFamilyList, DND.DROP_MOVE);
+ target.setTransfer(types);
+ target.addDropListener(new DropTargetAdapter() {
+ public void drop(DropTargetEvent event) {
+ if (event.data == null) {
+ event.detail = DND.DROP_NONE;
+ return;
+ }
+ addFont(fontFamilyList, ((String) event.data));
+ rightButton.setEnabled(false);
+ }
+ });
+
+ final DragSource sourceBack = new DragSource(fontFamilyList,
+ DND.DROP_MOVE);
+ sourceBack.setTransfer(types);
+ sourceBack.addDragListener(new DragSourceListener() {
+
+ public void dragFinished(DragSourceEvent event) {
+ if (event.detail == DND.DROP_MOVE) {
+ int selectedItem = fontFamilyList.getSelectionIndex();
+ fontFamilyList.remove(selectedItem);
+ }
+ }
+
+ public void dragSetData(DragSourceEvent event) {
+ int selectedItem = fontFamilyList.getSelectionIndex();
+ event.data = fontFamilyList.getItem(selectedItem);
+ }
+
+ public void dragStart(DragSourceEvent event) {
+ event.doit = (fontFamilyList.getSelectionCount() != 0);
+ }
+
+ });
+
+ DropTarget targetBack = new DropTarget(allFontFamilyList, DND.DROP_MOVE);
+ targetBack.setTransfer(types);
+ targetBack.addDropListener(new DropTargetAdapter() {
+ public void drop(DropTargetEvent event) {
+ if (event.data == null) {
+ event.detail = DND.DROP_NONE;
+ return;
+ }
+ addFont(allFontFamilyList, ((String) event.data));
+ leftButton.setEnabled(false);
+ }
+ });
+
+ return composite;
+
+ }
+
+ /**
+ * Set title for dialog
+ */
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ newShell.setText(MessageUtil.getString("FONT_FAMILY_DIALOG_TITLE"));
+ }
+
+ protected void okPressed() {
+ String[] items = fontFamilyList.getItems();
+ StringBuffer buf = new StringBuffer();
+ for (int i = 0; i < items.length; i++) {
+ buf.append((i == 0 ? Constants.EMPTY_STRING : COMMA) + items[i]);
+ }
+ fontFamily = buf.toString();
+ super.okPressed();
+ }
+
+ /**
+ * Method for add to font to sorted list
+ *
+ * @param list
+ * @param font
+ */
+ private void addFont(List list, String font) {
+ Set<String> s = new HashSet<String>();
+ String[] items = list.getItems();
+ list.removeAll();
+ for (int i = 0; i < items.length; i++) {
+ s.add(items[i]);
+ }
+ s.add(font);
+ String[] answer = new String[s.size()];
+ s.toArray(answer);
+ Arrays.sort(answer);
+ for (int i = 0; i < answer.length; i++) {
+ list.add(answer[i]);
+ }
+ }
+
+ /**
+ * Getter for fontFamily attribute
+ *
+ * @return fontFamily
+ */
+ public String getFontFamily() {
+ return fontFamily;
+ }
+
+ /**
+ * Setter for fontFamily attribute
+ *
+ * @param fontFamily
+ */
+ public void setFontFamily(String fontFamily) {
+ this.fontFamily = fontFamily;
+ }
+
+ /**
+ * Method for parse font family string
+ *
+ * @param font
+ * family string
+ * @return list font family
+ */
+ private String[] fontFamilyParser() {
+ existFontFamily = existFontFamily.trim();
+ return existFontFamily.split(COMMA);
+ }
+
+ /**
+ * Selection listener
+ */
+ public void widgetDefaultSelected(SelectionEvent e) {
+ Object ob = e.getSource();
+ if (ob.equals(leftButton)) {
+ int[] selectedItems = fontFamilyList.getSelectionIndices();
+ String[] items = allFontFamilyList.getItems();
+ Set<String> s = new HashSet<String>();
+ for (int i = 0; i < items.length; i++) {
+ s.add(items[i]);
+ }
+ for (int i = 0; i < selectedItems.length; i++) {
+ s.add(fontFamilyList.getItem(selectedItems[i]));
+ }
+ allFontFamilyList.removeAll();
+ String[] answer = new String[s.size()];
+ s.toArray(answer);
+ Arrays.sort(answer);
+ for (int i = 0; i < answer.length; i++) {
+ allFontFamilyList.add(answer[i]);
+ }
+ fontFamilyList.remove(selectedItems);
+ leftButton.setEnabled(false);
+ } else if (ob.equals(rightButton)) {
+ int[] selectedItems = allFontFamilyList.getSelectionIndices();
+ String[] items = fontFamilyList.getItems();
+ Set<String> s = new HashSet<String>();
+ for (int i = 0; i < items.length; i++) {
+ s.add(items[i]);
+ }
+ for (int i = 0; i < selectedItems.length; i++) {
+ s.add(allFontFamilyList.getItem(selectedItems[i]));
+ }
+ fontFamilyList.removeAll();
+ String[] answer = new String[s.size()];
+ s.toArray(answer);
+ Arrays.sort(answer);
+ for (int i = 0; i < answer.length; i++) {
+ fontFamilyList.add(answer[i]);
+ }
+ allFontFamilyList.remove(selectedItems);
+ rightButton.setEnabled(false);
+ } else if (ob.equals(allFontFamilyList)) {
+ fontFamilyList.deselectAll();
+ leftButton.setEnabled(false);
+ rightButton.setEnabled(true);
+ } else if (ob.equals(fontFamilyList)) {
+ allFontFamilyList.deselectAll();
+ rightButton.setEnabled(false);
+ leftButton.setEnabled(true);
+ }
+ }
+
+ /**
+ * Selection listener
+ */
+ public void widgetSelected(SelectionEvent e) {
+ Object ob = e.getSource();
+ if (ob.equals(leftButton)) {
+ int[] selectedItems = fontFamilyList.getSelectionIndices();
+ String[] items = allFontFamilyList.getItems();
+ Set<String> s = new HashSet<String>();
+ for (int i = 0; i < items.length; i++) {
+ s.add(items[i]);
+ }
+ for (int i = 0; i < selectedItems.length; i++) {
+ s.add(fontFamilyList.getItem(selectedItems[i]));
+ }
+ allFontFamilyList.removeAll();
+ String[] answer = new String[s.size()];
+ s.toArray(answer);
+ Arrays.sort(answer);
+ for (int i = 0; i < answer.length; i++) {
+ allFontFamilyList.add(answer[i]);
+ }
+ fontFamilyList.remove(selectedItems);
+ leftButton.setEnabled(false);
+ } else if (ob.equals(rightButton)) {
+ int[] selectedItems = allFontFamilyList.getSelectionIndices();
+ String[] items = fontFamilyList.getItems();
+ Set<String> s = new HashSet<String>();
+ for (int i = 0; i < items.length; i++) {
+ s.add(items[i]);
+ }
+ for (int i = 0; i < selectedItems.length; i++) {
+ s.add(allFontFamilyList.getItem(selectedItems[i]));
+ }
+ fontFamilyList.removeAll();
+ String[] answer = new String[s.size()];
+ s.toArray(answer);
+ Arrays.sort(answer);
+ for (int i = 0; i < answer.length; i++) {
+ fontFamilyList.add(answer[i]);
+ }
+ allFontFamilyList.remove(selectedItems);
+ rightButton.setEnabled(false);
+ }
+ }
+}
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/ImageSelectionDialog.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/ImageSelectionDialog.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/ImageSelectionDialog.java 2008-07-16 15:19:39 UTC (rev 9155)
@@ -0,0 +1,719 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.jsp.outline.cssdialog;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Cursor;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
+import org.eclipse.ui.dialogs.ISelectionStatusValidator;
+import org.eclipse.ui.dialogs.SelectionStatusDialog;
+import org.eclipse.ui.internal.WorkbenchMessages;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.MessageUtil;
+
+/**
+ * Class for creating images selection dialog
+ *
+ * @author dsakovich(a)exadel.com
+ */
+@SuppressWarnings("restriction")
+public class ImageSelectionDialog extends SelectionStatusDialog {
+
+ private Combo filterCombo;
+
+ private Canvas canvas;
+
+ private IFile file;
+
+ private Text resolution;
+
+ private Color emptyColor;
+
+ private TreeViewer fViewer;
+
+ private ILabelProvider fLabelProvider;
+
+ private ITreeContentProvider fContentProvider;
+
+ private ISelectionStatusValidator fValidator = null;
+
+ private ViewerComparator fComparator;
+
+ private boolean fAllowMultiple = true;
+
+ private boolean fDoubleClickSelects = true;
+
+ private String fEmptyListMessage = WorkbenchMessages.ElementTreeSelectionDialog_nothing_available;
+
+ private IStatus fCurrStatus = new Status(IStatus.OK, PlatformUI.PLUGIN_ID,
+ IStatus.OK, "", null);
+
+ private List<ViewerFilter> fFilters;
+
+ private Object fInput;
+
+ private boolean fIsEmpty;
+
+ private int fWidth = 60;
+
+ private int fHeight = 18;
+
+ final static String[][] fileExtensions = {
+ { "jpeg", "jpg", "jpe", "jfif" }, { "gif" }, { "bmp" },
+ { "tif", "tiff" }, { "png" }, { "ico" } };
+
+ /**
+ * Constructs an instance of <code>ImageSelectionDialog</code>.
+ *
+ * @param parent
+ * The parent shell for the dialog
+ * @param labelProvider
+ * the label provider to render the entries
+ * @param contentProvider
+ * the content provider to evaluate the tree structure
+ */
+ public ImageSelectionDialog(Shell parent, ILabelProvider labelProvider,
+ ITreeContentProvider contentProvider) {
+ super(parent);
+
+ fLabelProvider = labelProvider;
+ fContentProvider = contentProvider;
+
+ setResult(new ArrayList<Object>(0));
+ setStatusLineAboveButtons(true);
+
+ int shellStyle = getShellStyle();
+ setShellStyle(shellStyle | SWT.MAX | SWT.RESIZE);
+ }
+
+ /**
+ * Sets the initial selection. Convenience method.
+ *
+ * @param selection
+ * the initial selection.
+ */
+ public void setInitialSelection(Object selection) {
+ setInitialSelections(new Object[] { selection });
+ }
+
+ /**
+ * Sets the message to be displayed if the list is empty.
+ *
+ * @param message
+ * the message to be displayed.
+ */
+ public void setEmptyListMessage(String message) {
+ fEmptyListMessage = message;
+ }
+
+ /**
+ * Specifies if multiple selection is allowed.
+ *
+ * @param allowMultiple
+ */
+ public void setAllowMultiple(boolean allowMultiple) {
+ fAllowMultiple = allowMultiple;
+ }
+
+ /**
+ * Specifies if default selected events (double click) are created.
+ *
+ * @param doubleClickSelects
+ */
+ public void setDoubleClickSelects(boolean doubleClickSelects) {
+ fDoubleClickSelects = doubleClickSelects;
+ }
+
+ /**
+ * Sets the sorter used by the tree viewer.
+ *
+ * @param sorter
+ * @deprecated as of 3.3, use
+ * {@link ElementTreeSelectionDialog#setComparator(ViewerComparator)}
+ * instead
+ */
+ public void setSorter(ViewerSorter sorter) {
+ fComparator = sorter;
+ }
+
+ /**
+ * Sets the comparator used by the tree viewer.
+ *
+ * @param comparator
+ * @since 3.3
+ */
+ public void setComparator(ViewerComparator comparator) {
+ fComparator = comparator;
+ }
+
+ /**
+ * Adds a filter to the tree viewer.
+ *
+ * @param filter
+ * a filter.
+ */
+ public void addFilter(String[] extention) {
+ if (fFilters == null) {
+ fFilters = new ArrayList<ViewerFilter>(4);
+ }
+
+ fFilters.add(new FileExtensionFilter(extention));
+ }
+
+ /**
+ * Sets an optional validator to check if the selection is valid. The
+ * validator is invoked whenever the selection changes.
+ *
+ * @param validator
+ * the validator to validate the selection.
+ */
+ public void setValidator(ISelectionStatusValidator validator) {
+ fValidator = validator;
+ }
+
+ /**
+ * Sets the tree input.
+ *
+ * @param input
+ * the tree input.
+ */
+ public void setInput(Object input) {
+ fInput = input;
+ }
+
+ /**
+ * Sets the size of the tree in unit of characters.
+ *
+ * @param width
+ * the width of the tree.
+ * @param height
+ * the height of the tree.
+ */
+ public void setSize(int width, int height) {
+ fWidth = width;
+ fHeight = height;
+ }
+
+ /**
+ * Validate the receiver and update the ok status.
+ *
+ */
+ protected void updateOKStatus() {
+ if (!fIsEmpty) {
+ if (fValidator != null) {
+ fCurrStatus = fValidator.validate(getResult());
+ updateStatus(fCurrStatus);
+ } else {
+ fCurrStatus = new Status(IStatus.OK, PlatformUI.PLUGIN_ID,
+ IStatus.OK, "", null);
+ }
+ } else {
+ fCurrStatus = new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID,
+ IStatus.ERROR, fEmptyListMessage, null);
+ }
+ updateStatus(fCurrStatus);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.window.Window#open()
+ */
+ public int open() {
+ fIsEmpty = evaluateIfTreeEmpty(fInput);
+ super.open();
+ return getReturnCode();
+ }
+
+ /**
+ * Handles cancel button pressed event.
+ */
+ protected void cancelPressed() {
+ setResult(null);
+ super.cancelPressed();
+ }
+
+ /*
+ * @see SelectionStatusDialog#computeResult()
+ */
+ protected void computeResult() {
+ setResult(((IStructuredSelection) fViewer.getSelection()).toList());
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.window.Window#create()
+ */
+ public void create() {
+ BusyIndicator.showWhile(null, new Runnable() {
+ public void run() {
+ access$superCreate();
+ fViewer.setSelection(new StructuredSelection(
+ getInitialElementSelections()), true);
+ updateOKStatus();
+ }
+ });
+ }
+
+ /*
+ * @see Dialog#createDialogArea(Composite)
+ */
+ protected Control createDialogArea(Composite parent) {
+
+ final Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
+ layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
+ layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
+ layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
+ composite.setLayout(layout);
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ super.applyDialogFont(composite);
+
+ Label messageLabel = createMessageArea(composite);
+ new Label(composite, SWT.NONE);
+ TreeViewer treeViewer = createTreeViewer(composite);
+
+ Composite comp = createPreview(composite);
+
+ GridData browserData = new GridData(GridData.FILL_BOTH);
+ browserData.widthHint = convertWidthInCharsToPixels(fWidth / 2);
+ browserData.heightHint = convertHeightInCharsToPixels(fHeight);
+ browserData.minimumWidth = convertWidthInCharsToPixels(fWidth / 2);
+ browserData.minimumHeight = convertHeightInCharsToPixels(fHeight);
+ comp.setLayoutData(browserData);
+
+ GridData data = new GridData(GridData.FILL_BOTH);
+ data.widthHint = convertWidthInCharsToPixels(fWidth);
+ data.heightHint = convertHeightInCharsToPixels(fHeight);
+
+ Tree treeWidget = treeViewer.getTree();
+ treeWidget.setLayoutData(data);
+ treeWidget.setFont(parent.getFont());
+
+ filterCombo = new Combo(composite, SWT.READ_ONLY | SWT.BORDER);
+ filterCombo.setLayoutData(new GridData(GridData.FILL, GridData.CENTER,
+ false, false));
+
+ filterCombo.add(MessageUtil.getString("ALL_FILES"));
+ filterCombo.add(MessageUtil.getString("ALL_IMAGE_FILES"));
+ for (int i = 0; i < fileExtensions.length; i++) {
+ String[] str = fileExtensions[i];
+ StringBuffer buf = new StringBuffer();
+ for (int j = 0; j < str.length; j++) {
+ buf.append("*." + str[j].toUpperCase() + "; ");
+ }
+ filterCombo.add(buf.toString());
+ }
+ filterCombo.select(0);
+ filterCombo.addSelectionListener(new SelectionListener() {
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ if (fViewer != null) {
+ ViewerFilter[] filters = fViewer.getFilters();
+ if (filters != null) {
+ for (int i = 0; i < filters.length; i++) {
+ fViewer.removeFilter(filters[i]);
+ }
+ }
+ if (filterCombo.getSelectionIndex() != 0)
+ if (filterCombo.getSelectionIndex() == 1) {
+ Set<String> s = new HashSet<String>();
+ for (int i = 0; i < fileExtensions.length; i++) {
+ String[] tmp = fileExtensions[i];
+ for (int j = 0; j < tmp.length; j++)
+ s.add(tmp[j]);
+ }
+ String[] allExtensions = new String[s.size()];
+ s.toArray(allExtensions);
+ fViewer.addFilter(new FileExtensionFilter(
+ allExtensions));
+
+ } else {
+ fViewer.addFilter(new FileExtensionFilter(
+ fileExtensions[filterCombo
+ .getSelectionIndex() - 2]));
+ }
+ fViewer.refresh();
+ if (fViewer.getTree().getItemCount() <= 0) {
+ fIsEmpty = true;
+ } else {
+ fIsEmpty = false;
+ }
+ if (fViewer.getTree().getSelectionCount() <= 0) {
+ file = null;
+ canvas.redraw();
+ }
+ updateOKStatus();
+
+ }
+ }
+ });
+
+ if (fIsEmpty) {
+ messageLabel.setEnabled(false);
+ treeWidget.setEnabled(false);
+ }
+ return composite;
+ }
+
+ /**
+ * Creates the tree viewer.
+ *
+ * @param parent
+ * the parent composite
+ * @return the tree viewer
+ */
+ protected TreeViewer createTreeViewer(Composite parent) {
+ int style = SWT.BORDER | (fAllowMultiple ? SWT.MULTI : SWT.SINGLE);
+
+ fViewer = new TreeViewer(new Tree(parent, style));
+ fViewer.setContentProvider(fContentProvider);
+ fViewer.setLabelProvider(fLabelProvider);
+ fViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ @SuppressWarnings("unchecked")
+ public void selectionChanged(SelectionChangedEvent event) {
+
+ access$setResult(((IStructuredSelection) event.getSelection())
+ .toList());
+ updateOKStatus();
+
+ }
+ });
+
+ fViewer.getTree().addSelectionListener(new SelectionListener() {
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ Object obj = getFirstResult();
+ if (obj instanceof IFile) {
+ file = (IFile) getFirstResult();
+ } else if (obj instanceof IFolder) {
+ file = null;
+ }
+ canvas.redraw();
+
+ }
+
+ });
+
+ fViewer.setComparator(fComparator);
+ if (fFilters != null) {
+ for (int i = 0; i != fFilters.size(); i++) {
+ fViewer.addFilter(fFilters.get(i));
+ }
+ }
+
+ if (fDoubleClickSelects) {
+ Tree tree = fViewer.getTree();
+ tree.addSelectionListener(new SelectionAdapter() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ updateOKStatus();
+ if (fCurrStatus.isOK()) {
+ access$superButtonPressed(IDialogConstants.OK_ID);
+ }
+ }
+ });
+ }
+ fViewer.addDoubleClickListener(new IDoubleClickListener() {
+ public void doubleClick(DoubleClickEvent event) {
+ updateOKStatus();
+
+ // If it is not OK or if double click does not
+ // select then expand
+ if (!(fDoubleClickSelects && fCurrStatus.isOK())) {
+ ISelection selection = event.getSelection();
+ if (selection instanceof IStructuredSelection) {
+ Object item = ((IStructuredSelection) selection)
+ .getFirstElement();
+ if (fViewer.getExpandedState(item)) {
+ fViewer.collapseToLevel(item, 1);
+ } else {
+ fViewer.expandToLevel(item, 1);
+ }
+ }
+ }
+ }
+ });
+
+ fViewer.setInput(fInput);
+
+ return fViewer;
+ }
+
+ /**
+ * Returns the tree viewer.
+ *
+ * @return the tree viewer
+ */
+ protected TreeViewer getTreeViewer() {
+ return fViewer;
+ }
+
+ /**
+ * Set the result using the super class implementation of buttonPressed.
+ *
+ * @param id
+ * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int)
+ */
+ protected void access$superButtonPressed(int id) {
+ super.buttonPressed(id);
+ }
+
+ /**
+ * Set the result using the super class implementation of setResult.
+ *
+ * @param result
+ * @see SelectionStatusDialog#setResult(int, Object)
+ */
+ protected void access$setResult(List<Object> result) {
+ super.setResult(result);
+ }
+
+ /**
+ * @see org.eclipse.jface.window.Window#handleShellCloseEvent()
+ */
+ protected void handleShellCloseEvent() {
+ super.handleShellCloseEvent();
+
+ // Handle the closing of the shell by selecting the close icon
+ if (getReturnCode() == CANCEL) {
+ setResult(null);
+ }
+ }
+
+ private void access$superCreate() {
+ super.create();
+ }
+
+ /**
+ * Create image preview control
+ *
+ * @param parent
+ * @return composite
+ */
+ private Composite createPreview(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ composite.setLayout(layout);
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ Label label = new Label(composite, SWT.NONE);
+ label.setLayoutData(new GridData(GridData.CENTER, GridData.CENTER,
+ false, false));
+ label.setText(MessageUtil.getString("IMAGE_PREVIEW"));
+ canvas = new Canvas(composite, SWT.BORDER);
+
+ GridData browserData = new GridData(GridData.FILL_BOTH);
+ browserData.widthHint = convertWidthInCharsToPixels((fWidth) / 2);
+ browserData.heightHint = convertHeightInCharsToPixels(fHeight);
+ canvas.setLayoutData(browserData);
+
+ resolution = new Text(composite, SWT.READ_ONLY | SWT.CENTER);
+ resolution.setLayoutData(new GridData(GridData.FILL, GridData.CENTER,
+ false, false));
+ resolution.setVisible(false);
+
+ emptyColor = canvas.getForeground();
+
+ canvas.addPaintListener(new PaintListener() {
+ public void paintControl(PaintEvent e) {
+ GC gc = new GC(canvas);
+ gc.setForeground(emptyColor);
+ gc.fillRectangle(1, 1, canvas.getSize().x - 2,
+ canvas.getSize().y - 2);
+ // resolution.setText("");
+ resolution.setVisible(false);
+ if (file != null) {
+ Cursor parentCursor = getShell().getCursor();
+ final Cursor waitCursor = new Cursor(getShell()
+ .getDisplay(), SWT.CURSOR_WAIT);
+ Point previewPoint = new Point(0, 0);
+ Point labelPoint = canvas.getSize();
+ InputStream stream;
+ try {
+ getShell().setCursor(waitCursor);
+ stream = new FileInputStream(file.getLocation()
+ .toOSString());
+ ImageData imageData = new ImageData(stream);
+ stream.close();
+ if (imageData != null) {
+ Image image = new Image(getShell().getDisplay(),
+ imageData);
+
+ // set image in center
+ Point imagePoint = new Point(
+ image.getBounds().width,
+ image.getBounds().height);
+
+ String imageInfo = imagePoint.x + " x "
+ + imagePoint.y + " px";
+ // change resolution if image anymore image label
+ if ((imagePoint.x > labelPoint.x)
+ || (imagePoint.y > labelPoint.y)) {
+ float ratioImage = (float) imagePoint.x
+ / (float) imagePoint.y;
+ if (((imagePoint.y > labelPoint.y) && (labelPoint.y
+ * ratioImage > labelPoint.x))
+ || ((imagePoint.x > labelPoint.x) && (labelPoint.x
+ / ratioImage < labelPoint.y))) {
+ imageData = imageData.scaledTo(
+ labelPoint.x - 10,
+ (int) (labelPoint.x / ratioImage));
+ } else {
+ imageData = imageData
+ .scaledTo(
+ (int) (labelPoint.y * ratioImage) - 10,
+ labelPoint.y);
+ }
+ image.dispose();
+ image = new Image(getShell().getDisplay(),
+ imageData);
+ imagePoint.x = image.getBounds().width;
+ imagePoint.y = image.getBounds().height;
+
+ }
+
+ previewPoint.x = labelPoint.x / 2 - imagePoint.x
+ / 2;
+ previewPoint.y = labelPoint.y / 2 - imagePoint.y
+ / 2;
+ gc.drawImage(image, previewPoint.x, previewPoint.y);
+ resolution.setVisible(true);
+ resolution.setText(imageInfo);
+ image.dispose();
+ gc.dispose();
+ }
+ } catch (Exception ev) {
+
+ } finally {
+ getShell().setCursor(parentCursor);
+ }
+ }
+ }
+ });
+ return composite;
+ }
+
+ private boolean evaluateIfTreeEmpty(Object input) {
+ Object[] elements = fContentProvider.getElements(input);
+ if (elements.length > 0) {
+ if (fFilters != null) {
+ for (int i = 0; i < fFilters.size(); i++) {
+ ViewerFilter curr = fFilters.get(i);
+ elements = curr.filter(fViewer, input, elements);
+ }
+ }
+ }
+ return elements.length == 0;
+ }
+
+ /**
+ * Class for creates filter by file extensions
+ *
+ * @author dsakovich
+ */
+ private class FileExtensionFilter extends ViewerFilter {
+
+ private String[] fTargetExtension;
+
+ public FileExtensionFilter(String[] targetExtension) {
+ fTargetExtension = targetExtension;
+ }
+
+ public boolean select(Viewer viewer, Object parent, Object element) {
+ if (element instanceof IFile) {
+ for (int i = 0; i < fTargetExtension.length; i++) {
+ if (((IFile) element).getName().toLowerCase().endsWith(
+ "." + fTargetExtension[i])) {
+ return true;
+ }
+ }
+ return false;
+ }
+ if (element instanceof IProject && ((IProject) element).isOpen())
+ return true;
+ if (element instanceof IContainer) { // i.e. IProject, IFolder
+ try {
+ IResource[] resources = ((IContainer) element).members();
+ for (int i = 0; i < resources.length; i++) {
+ if (select(viewer, parent, resources[i]))
+ return true;
+ }
+ } catch (CoreException e) {
+ // TODO Sakovich exception
+ }
+ }
+ return false;
+ }
+ }
+
+}
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/CSSConstants.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/CSSConstants.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/CSSConstants.java 2008-07-16 15:19:39 UTC (rev 9155)
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.jsp.outline.cssdialog.common;
+
+/**
+ * This class contains CSS constants
+ *
+ * @author dsakovich(a)exadel.com
+ *
+ */
+public class CSSConstants {
+
+ public static final String BACKGROUND_REPEAT = "background-repeat";
+ public static final String BACKGROUND_COLOR = "background-color";
+ public static final String BACKGROUND_IMAGE = "background-image";
+ public static final String BORDER_STYLE = "border-style";
+ public static final String BORDER_WIDTH = "border-width";
+ public static final String WIDTH = "width";
+ public static final String HEIGHT = "height";
+ public static final String BORDER_COLOR = "border-color";
+ public static final String MARGIN = "margin";
+ public static final String PADDING = "padding";
+ public static final String FONT_SIZE = "font-size";
+ public static final String FONT_STYLE = "font-style";
+ public static final String FONT_WEIGHT = "font-weight";
+ public static final String TEXT_DECORATION = "text-decoration";
+ public static final String TEXT_ALIGN = "text-align";
+ public static final String FONT_FAMILY = "font-family";
+ public static final String COLOR = "color";
+
+}
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/Constants.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/Constants.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/Constants.java 2008-07-16 15:19:39 UTC (rev 9155)
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.jsp.outline.cssdialog.common;
+
+import org.eclipse.swt.graphics.RGB;
+
+/**
+ *
+ * Class for constants
+ *
+ * @author Evgeny Zheleznyakov
+ *
+ */
+public class Constants {
+
+ public static final String extSizes[] = new String[] { "", "em", "ex",
+ "px", "in", "cm", "mm", "pt", "pc" };
+
+ public static final String elemFolder[] = new String[] {
+ "background-image", "list-style-image", "cursor", "cue-after",
+ "cue-before" };
+
+ public static final String extElem[] = new String[] {
+ "border-bottom-width", "border-left-width", "borer-right-width",
+ "border-top-width", "border-width", "bottom", "font-size",
+ "height", "left", "letter-spacing", "line-height", "margin",
+ "margin-bottom", "margin-left", "margin-right", "margin-top",
+ "margin-offset", "margin-bottom", "max-height", "max-width",
+ "min-height", "min-width", "outline-width", "padding",
+ "padding-bottom", "padding-left", "padding-right", "padding-top",
+ "right", "size", "text-indent", "top", "vertical-align", "width",
+ "word-spacing" };
+
+ public static final String NONE = "none";
+
+ public static final String IMAGE_COLOR_FILE_LOCATION = "images/cssdialog/color.gif";
+ public static final String IMAGE_FOLDER_FILE_LOCATION = "images/cssdialog/folder.gif";
+ public static final String IMAGE_FONT_FILE_LOCATION = "images/cssdialog/font.gif";
+ public static final String IMAGE_COLORLARGE_FILE_LOCATION = "images/cssdialog/color_large.gif";
+ public static final String IMAGE_FOLDERLARGE_FILE_LOCATION = "images/cssdialog/folder_large.gif";
+ public static final String IMAGE_FONTLARGE_FILE_LOCATION = "images/cssdialog/font_large.gif";
+ public static final String IMAGE_LEFT_FILE_LOCATION = "images/cssdialog/left.gif";
+ public static final String IMAGE_RIGHT_FILE_LOCATION = "images/cssdialog/right.gif";
+ public static final String IMAGE_SAMPLE_FILE_LOCATION = "images/cssdialog/sample.gif";
+
+ public static final int FIRST_COLUMN = 0;
+ public static final int SECOND_COLUMN = 1;
+
+ public static final String EMPTY_STRING = "";
+
+ public static final RGB RGB_BLACK = new RGB(0,0,0);
+ public static final RGB RGB_WHITE = new RGB(0xFF, 0xFF, 0xFF);
+
+ public static final int DONT_CONTAIN = -1;
+
+ public static String OPEN_SPAN_TAG = "<span style=\"width: 100%;";
+ public static String CLOSE_SPAN_TAG = "</span>";
+ public static String TEXT_FOR_PREVIEW = "\">Text for preview";
+
+ public static String COLON_STRING = ":";
+ public static String SEMICOLON_STRING = ";";
+}
\ No newline at end of file
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/ImageCombo.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/ImageCombo.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/ImageCombo.java 2008-07-16 15:19:39 UTC (rev 9155)
@@ -0,0 +1,1093 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.jsp.outline.cssdialog.common;
+
+import java.util.Arrays;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.SWTException;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.graphics.PaletteData;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.TypedListener;
+import org.eclipse.swt.widgets.Widget;
+
+/**
+ * The ImageCombo Combo-Widget class with images represents a selectable user
+ * interface object that combines a text field and a list and issues
+ * notification when an item is selected from the list.
+ *
+ * @author dsakovich(a)exadel.com
+ *
+ */
+public final class ImageCombo extends Composite {
+
+ private static final boolean gtk = "gtk".equals(SWT.getPlatform());
+ private boolean dontDrop = false;
+ private int visibleItemCount = 10;
+
+ private Text text;
+ private Table table;
+ private Shell popup;
+ private Button arrowButton;
+
+ private boolean hasFocus;
+
+ private Listener listener, filter;
+
+ private static final int X = 0;
+ private static final int Y = 0;
+ private static final int WIDTH = 20;
+ private static final int HEIGHT = 15;
+ private static final int DEPTH = 1;
+ private static final String SPACE = " ";
+ private static final int DEFAULT_SELECTION = -1;
+
+ /**
+ * Constructs a new instance of this class given its parent and a style
+ * value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in class
+ * <code>SWT</code> which is applicable to instances of this class, or
+ * must be built by <em>bitwise OR</em>'ing together (that is, using the
+ * <code>int</code> "|" operator) two or more of those <code>SWT</code>
+ * style constants. The class description lists the style constants that are
+ * applicable to the class. Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent
+ * a widget which will be the parent of the new instance
+ * (cannot be null)
+ * @param style
+ * the style of widget to construct
+ *
+ * @exception IllegalArgumentException
+ * <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException
+ * <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from
+ * the thread that created the parent</li>
+ * </ul>
+ *
+ * @see SWT#BORDER
+ * @see SWT#READ_ONLY
+ * @see SWT#FLAT
+ * @see Widget#getStyle()
+ */
+ public ImageCombo(Composite parent, int style) {
+ super(parent, style = checkStyle(style));
+ int textStyle = SWT.SINGLE;
+ if (gtk)
+ textStyle |= SWT.BORDER;
+ if ((style & SWT.READ_ONLY) != 0)
+ textStyle |= SWT.READ_ONLY;
+ if ((style & SWT.FLAT) != 0)
+ textStyle |= SWT.FLAT;
+ text = new Text(this, textStyle);
+ int arrowStyle = SWT.ARROW | SWT.DOWN;
+ if ((style & SWT.FLAT) != 0)
+ arrowStyle |= SWT.FLAT;
+ arrowButton = new Button(this, arrowStyle);
+ listener = new Listener() {
+ public void handleEvent(Event event) {
+ if (popup == event.widget) {
+ popupEvent(event);
+ return;
+ }
+ if (text == event.widget) {
+ textEvent(event);
+ return;
+ }
+ if (table == event.widget) {
+ listEvent(event);
+ return;
+ }
+ if (arrowButton == event.widget) {
+ arrowEvent(event);
+ return;
+ }
+ if (ImageCombo.this == event.widget) {
+ comboEvent(event);
+ return;
+ }
+ if (getShell() == event.widget) {
+ handleFocus(SWT.FocusOut);
+ }
+ }
+ };
+ filter = new Listener() {
+ public void handleEvent(Event event) {
+ Shell shell = ((Control) event.widget).getShell();
+ if (shell == ImageCombo.this.getShell()) {
+ handleFocus(SWT.FocusOut);
+ }
+ }
+ };
+
+ int[] comboEvents = { SWT.Dispose, SWT.Move, SWT.Resize };
+ for (int i = 0; i < comboEvents.length; i++)
+ this.addListener(comboEvents[i], listener);
+
+ int[] textEvents = { SWT.KeyDown, SWT.KeyUp, SWT.Modify, SWT.MouseDown,
+ SWT.MouseUp, SWT.Traverse, SWT.FocusIn };
+ for (int i = 0; i < textEvents.length; i++)
+ text.addListener(textEvents[i], listener);
+
+ int[] arrowEvents = { SWT.Selection, SWT.FocusIn };
+ for (int i = 0; i < arrowEvents.length; i++)
+ arrowButton.addListener(arrowEvents[i], listener);
+ createPopup(DEFAULT_SELECTION);
+ }
+
+ /**
+ *
+ * @param style
+ * @return
+ */
+ static int checkStyle(int style) {
+ int mask = gtk ? SWT.READ_ONLY | SWT.FLAT | SWT.LEFT_TO_RIGHT
+ | SWT.RIGHT_TO_LEFT : SWT.BORDER | SWT.READ_ONLY | SWT.FLAT
+ | SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT;
+ return style & mask;
+ }
+
+ /**
+ * Adds the argument to the end of the receiver's list.
+ *
+ * @param string
+ * the new item
+ *
+ * @param image
+ * image for the item
+ *
+ * @exception IllegalArgumentException
+ * <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException
+ * <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been
+ * disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from
+ * the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #add(String,int)
+ */
+ public void add(String string, Image image) {
+ checkWidget();
+ if (string == null)
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ TableItem newItem = new TableItem(this.table, SWT.NONE);
+
+ newItem.setText(string);
+ if (image != null)
+ newItem.setImage(image);
+ newItem.addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent e) {
+ TableItem item = (TableItem) e.getSource();
+ item.getImage().dispose();
+ }
+ });
+ }
+
+ /**
+ * Adds the argument to the receiver's list at the given zero-relative
+ * index.
+ * <p>
+ * Note: To add an item at the end of the list, use the result of calling
+ * <code>getItemCount()</code> as the index or use
+ * <code>add(String)</code>.
+ * </p>
+ *
+ * @param string
+ * the new item
+ *
+ * @param image
+ * image for the item
+ *
+ * @param index
+ * the index for the item
+ *
+ * @exception IllegalArgumentException
+ * <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * <li>ERROR_INVALID_RANGE - if the index is not between
+ * 0 and the number of elements in the list (inclusive)</li>
+ * </ul>
+ * @exception SWTException
+ * <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been
+ * disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from
+ * the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #add(String)
+ */
+ public void add(String string, Image image, int index) {
+ checkWidget();
+ if (string == null)
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ TableItem newItem = new TableItem(this.table, SWT.NONE, index);
+ if (image != null) {
+ newItem.setImage(image);
+ newItem.addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent e) {
+ TableItem item = (TableItem) e.getSource();
+ item.getImage().dispose();
+ }
+ });
+ }
+
+ }
+
+ /**
+ * Adds the argument to the end of the receiver's list.
+ *
+ * @param string
+ * the new item
+ * @param rgb
+ * RGB color image for the item
+ *
+ *
+ * @exception IllegalArgumentException
+ * <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException
+ * <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been
+ * disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from
+ * the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #add(String,int)
+ */
+ public void add(String string, RGB rgb) {
+ Color white = new Color(getDisplay(), Constants.RGB_WHITE);
+ Color black = new Color(getDisplay(), Constants.RGB_BLACK);
+ Color color = new Color(getDisplay(), rgb);
+
+ Image image = new Image(getDisplay(), WIDTH, HEIGHT);
+ GC gc = new GC(image);
+ gc.setBackground(color);
+ gc.fillRectangle(X, Y, WIDTH, HEIGHT);
+ gc.setBackground(black);
+ gc.drawRectangle(X, Y, WIDTH, HEIGHT);
+ gc.dispose();
+ ImageData imageData = image.getImageData();
+ image.dispose();
+ color.dispose();
+
+ PaletteData palette = new PaletteData(new RGB[] { Constants.RGB_BLACK,
+ Constants.RGB_WHITE, });
+ ImageData maskData = new ImageData(WIDTH, HEIGHT, DEPTH, palette);
+ Image mask = new Image(getDisplay(), maskData);
+ gc = new GC(mask);
+ gc.setBackground(black);
+ gc.fillRectangle(X, Y, WIDTH, HEIGHT);
+ gc.setBackground(white);
+ gc.fillRectangle(X, Y, WIDTH, HEIGHT);
+ gc.dispose();
+ maskData = mask.getImageData();
+ mask.dispose();
+
+ Image icon = new Image(getDisplay(), imageData, maskData);
+ color.dispose();
+ black.dispose();
+ white.dispose();
+ add(string, icon);
+ }
+
+ /**
+ * Adds the listener to the collection of listeners who will be notified
+ * when the receiver's text is modified, by sending it one of the messages
+ * defined in the <code>ModifyListener</code> interface.
+ *
+ * @param listener
+ * the listener which should be notified
+ *
+ * @exception IllegalArgumentException
+ * <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException
+ * <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been
+ * disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from
+ * the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ModifyListener
+ * @see #removeModifyListener
+ */
+ public void addModifyListener(ModifyListener listener) {
+ checkWidget();
+ if (listener == null)
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener(listener);
+ addListener(SWT.Modify, typedListener);
+ }
+
+ /**
+ * Adds the listener to the collection of listeners who will be notified
+ * when the receiver's selection changes, by sending it one of the messages
+ * defined in the <code>SelectionListener</code> interface.
+ * <p>
+ * <code>widgetSelected</code> is called when the combo's list selection
+ * changes. <code>widgetDefaultSelected</code> is typically called when
+ * ENTER is pressed the combo's text area.
+ * </p>
+ *
+ * @param listener
+ * the listener which should be notified
+ *
+ * @exception IllegalArgumentException
+ * <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException
+ * <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been
+ * disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from
+ * the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+ public void addSelectionListener(SelectionListener listener) {
+ checkWidget();
+ if (listener == null)
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener(listener);
+ addListener(SWT.Selection, typedListener);
+ addListener(SWT.DefaultSelection, typedListener);
+ }
+
+ /**
+ *
+ * @param event
+ */
+ void arrowEvent(Event event) {
+ switch (event.type) {
+ case SWT.FocusIn: {
+ if (gtk) {
+ setFocus();
+ return;
+ }
+ handleFocus(SWT.FocusIn);
+ break;
+ }
+ case SWT.Selection: {
+ if (gtk) {
+ if (!dontDrop) {
+ dropDown(!isDropped());
+ }
+ dontDrop = false;
+ } else {
+ dropDown(!isDropped());
+ }
+ break;
+ }
+ }
+ }
+
+ /**
+ *
+ * @param event
+ */
+ void comboEvent(Event event) {
+ switch (event.type) {
+ case SWT.Dispose:
+ if (popup != null && !popup.isDisposed()) {
+ table.removeListener(SWT.Dispose, listener);
+ popup.dispose();
+ }
+ Shell shell = getShell();
+ shell.removeListener(SWT.Deactivate, listener);
+ Display display = getDisplay();
+ display.removeFilter(SWT.FocusIn, filter);
+ popup = null;
+ text = null;
+ table = null;
+ arrowButton = null;
+ break;
+ case SWT.Move:
+ dropDown(false);
+ break;
+ case SWT.Resize:
+ internalLayout(false);
+ break;
+ }
+ }
+
+ /**
+ * Method for computing size for widget
+ *
+ * @param wHint
+ * width
+ * @param hHint
+ * height
+ * @return Point
+ */
+ public Point computeSize(int wHint, int hHint, boolean changed) {
+ checkWidget();
+ int width = 0, height = 0;
+ String[] items = getStringsFromTable();
+ int textWidth = 0;
+ GC gc = new GC(text);
+ int spacer = gc.stringExtent(SPACE).x;
+ for (int i = 0; i < items.length; i++) {
+ textWidth = Math.max(gc.stringExtent(items[i]).x, textWidth);
+ }
+ gc.dispose();
+ Point textSize = text.computeSize(SWT.DEFAULT, SWT.DEFAULT, changed);
+ Point arrowSize = arrowButton.computeSize(SWT.DEFAULT, SWT.DEFAULT,
+ changed);
+ Point listSize = table.computeSize(wHint, SWT.DEFAULT, changed);
+ int borderWidth = getBorderWidth();
+
+ height = Math.max(hHint, Math.max(textSize.y, arrowSize.y) + 2
+ * borderWidth);
+ width = Math.max(wHint, Math.max(textWidth + 2 * spacer + arrowSize.x
+ + 2 * borderWidth, listSize.x));
+ return new Point(width, height);
+ }
+
+ /**
+ * Method for creating popup table
+ *
+ * @param selectionIndex
+ */
+ void createPopup(int selectionIndex) {
+ // create shell and list
+ popup = new Shell(getShell(), SWT.NO_TRIM | SWT.ON_TOP);
+ int style = getStyle();
+ int listStyle = SWT.SINGLE | SWT.V_SCROLL;
+ if ((style & SWT.FLAT) != 0)
+ listStyle |= SWT.FLAT;
+ if ((style & SWT.RIGHT_TO_LEFT) != 0)
+ listStyle |= SWT.RIGHT_TO_LEFT;
+ if ((style & SWT.LEFT_TO_RIGHT) != 0)
+ listStyle |= SWT.LEFT_TO_RIGHT;
+ // create a table instead of a list.
+ table = new Table(popup, listStyle);
+ table.setToolTipText(MessageUtil
+ .getString("IMAGE_COMBO_TABLE_TOOL_TIP"));
+
+ int[] popupEvents = { SWT.Close, SWT.Paint, SWT.Deactivate };
+ for (int i = 0; i < popupEvents.length; i++)
+ popup.addListener(popupEvents[i], listener);
+ int[] listEvents = { SWT.Traverse, SWT.MouseDoubleClick, SWT.KeyDown,
+ SWT.KeyUp, SWT.FocusIn, SWT.Dispose };
+ for (int i = 0; i < listEvents.length; i++)
+ table.addListener(listEvents[i], listener);
+
+ if (selectionIndex != -1)
+ table.setSelection(selectionIndex);
+ }
+
+ /**
+ *
+ * @param drop
+ */
+ void dropDown(boolean drop) {
+ if (drop == isDropped())
+ return;
+ if (!drop) {
+ popup.setVisible(false);
+ if (!isDisposed() && arrowButton.isFocusControl()) {
+ text.setFocus();
+ }
+ return;
+ }
+
+ if (getShell() != popup.getParent()) {
+ int selectionIndex = table.getSelectionIndex();
+ table.removeListener(SWT.Dispose, listener);
+ popup.dispose();
+ popup = null;
+ table = null;
+ createPopup(selectionIndex);
+ }
+
+ Point size = getSize();
+ int itemCount = table.getItemCount();
+ itemCount = (itemCount == 0) ? visibleItemCount : Math.min(
+ visibleItemCount, itemCount);
+ int itemHeight = table.getItemHeight() * itemCount;
+ Point listSize = table.computeSize(SWT.DEFAULT, itemHeight, false);
+ table.setBounds(1, 1, Math.max(size.x - 2, listSize.x), listSize.y);
+
+ int index = table.getSelectionIndex();
+ if (index != -1)
+ table.setTopIndex(index);
+ Display display = getDisplay();
+ Rectangle listRect = table.getBounds();
+ Rectangle parentRect = display.map(getParent(), null, getBounds());
+ Point comboSize = getSize();
+ Rectangle displayRect = getMonitor().getClientArea();
+ int width = Math.max(comboSize.x, listRect.width + 2);
+ int height = listRect.height + 2;
+ int x = parentRect.x;
+ int y = parentRect.y + comboSize.y;
+ if (y + height > displayRect.y + displayRect.height)
+ y = parentRect.y - height;
+ popup.setBounds(x, y, width, height);
+ popup.setVisible(true);
+ table.setFocus();
+ }
+
+ /**
+ * Returns the number of items contained in the receiver's list.
+ *
+ * @return the number of items
+ *
+ * @exception SWTException
+ * <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been
+ * disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from
+ * the thread that created the receiver</li>
+ * </ul>
+ */
+ public int getItemCount() {
+ checkWidget();
+ return table.getItemCount();
+ }
+
+ String[] getStringsFromTable() {
+ String[] items = new String[this.table.getItems().length];
+ for (int i = 0, n = items.length; i < n; i++) {
+ items[i] = this.table.getItem(i).getText();
+ }
+ return items;
+ }
+
+ /**
+ * Returns the zero-relative index of the item which is currently selected
+ * in the receiver's list, or -1 if no item is selected.
+ *
+ * @return the index of the selected item
+ *
+ * @exception SWTException
+ * <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been
+ * disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from
+ * the thread that created the receiver</li>
+ * </ul>
+ */
+ public int getSelectionIndex() {
+ checkWidget();
+ return table.getSelectionIndex();
+ }
+
+ /**
+ * Method for getting widget style
+ */
+ public int getStyle() {
+ int style = super.getStyle();
+ style &= ~SWT.READ_ONLY;
+ if (!text.getEditable())
+ style |= SWT.READ_ONLY;
+ return style;
+ }
+
+ /**
+ * Returns a string containing a copy of the contents of the receiver's text
+ * field.
+ *
+ * @return the receiver's text
+ *
+ * @exception SWTException
+ * <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been
+ * disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from
+ * the thread that created the receiver</li>
+ * </ul>
+ */
+ public String getText() {
+ checkWidget();
+ return text.getText();
+ }
+
+ /**
+ *
+ * @param type
+ */
+ void handleFocus(int type) {
+ if (isDisposed())
+ return;
+ switch (type) {
+ case SWT.FocusIn: {
+ if (hasFocus)
+ return;
+ hasFocus = true;
+ Shell shell = getShell();
+ shell.removeListener(SWT.Deactivate, listener);
+ shell.addListener(SWT.Deactivate, listener);
+ Display display = getDisplay();
+ display.removeFilter(SWT.FocusIn, filter);
+ display.addFilter(SWT.FocusIn, filter);
+ Event e = new Event();
+ notifyListeners(SWT.FocusIn, e);
+ break;
+ }
+ case SWT.FocusOut: {
+ if (!hasFocus)
+ return;
+ Control focusControl = getDisplay().getFocusControl();
+ if (focusControl == arrowButton || focusControl == table
+ || focusControl == text)
+ return;
+ hasFocus = false;
+ Shell shell = getShell();
+ shell.removeListener(SWT.Deactivate, listener);
+ Display display = getDisplay();
+ display.removeFilter(SWT.FocusIn, filter);
+ Event e = new Event();
+ notifyListeners(SWT.FocusOut, e);
+ break;
+ }
+ }
+ }
+
+ /**
+ * Searches the receiver's list starting at the first item (index 0) until
+ * an item is found that is equal to the argument, and returns the index of
+ * that item. If no item is found, returns -1.
+ *
+ * @param string
+ * the search item
+ * @return the index of the item
+ *
+ * @exception IllegalArgumentException
+ * <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException
+ * <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been
+ * disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from
+ * the thread that created the receiver</li>
+ * </ul>
+ */
+ public int indexOf(String string) {
+ checkWidget();
+ if (string == null)
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ return Arrays.asList(getStringsFromTable()).indexOf(string);
+ }
+
+ /**
+ *
+ * @return
+ */
+ boolean isDropped() {
+ return popup.getVisible();
+ }
+
+ /**
+ *
+ * @param changed
+ */
+ void internalLayout(boolean changed) {
+ if (isDropped())
+ dropDown(false);
+ Rectangle rect = getClientArea();
+ int width = rect.width;
+ int height = rect.height;
+ Point arrowSize = arrowButton.computeSize(SWT.DEFAULT, height, changed);
+ text.setBounds(0, 0, width - arrowSize.x, height);
+ arrowButton.setBounds(width - arrowSize.x, 0, arrowSize.x, arrowSize.y);
+ }
+
+ /**
+ *
+ * @param event
+ */
+ void listEvent(Event event) {
+ switch (event.type) {
+ case SWT.Dispose:
+ if (getShell() != popup.getParent()) {
+ int selectionIndex = table.getSelectionIndex();
+ popup = null;
+ table = null;
+ createPopup(selectionIndex);
+ }
+ break;
+ case SWT.FocusIn: {
+ handleFocus(SWT.FocusIn);
+ break;
+ }
+ case SWT.MouseDoubleClick: {
+ int index = table.getSelectionIndex();
+ if (index == -1)
+ return;
+ text.setText(table.getItem(index).getText());
+ table.setSelection(index);
+ Event e = new Event();
+ e.time = event.time;
+ e.stateMask = event.stateMask;
+ e.doit = event.doit;
+ notifyListeners(SWT.Selection, e);
+ event.doit = e.doit;
+ dropDown(false);
+ break;
+ }
+ case SWT.Traverse: {
+ switch (event.detail) {
+ case SWT.TRAVERSE_RETURN:
+ case SWT.TRAVERSE_ESCAPE:
+ case SWT.TRAVERSE_ARROW_PREVIOUS:
+ case SWT.TRAVERSE_ARROW_NEXT:
+ event.doit = false;
+ break;
+ }
+ Event e = new Event();
+ e.time = event.time;
+ e.detail = event.detail;
+ e.doit = event.doit;
+ e.character = event.character;
+ e.keyCode = event.keyCode;
+ notifyListeners(SWT.Traverse, e);
+ event.doit = e.doit;
+ event.detail = e.detail;
+ break;
+ }
+ case SWT.KeyUp: {
+ Event e = new Event();
+ e.time = event.time;
+ e.character = event.character;
+ e.keyCode = event.keyCode;
+ e.stateMask = event.stateMask;
+ notifyListeners(SWT.KeyUp, e);
+ break;
+ }
+ case SWT.KeyDown: {
+ if (event.character == SWT.ESC) {
+ // Escape key cancels popup list
+ dropDown(false);
+ }
+ if ((event.stateMask & SWT.ALT) != 0
+ && (event.keyCode == SWT.ARROW_UP || event.keyCode == SWT.ARROW_DOWN)) {
+ dropDown(false);
+ }
+ if (event.character == SWT.CR) {
+ // Enter causes default selection
+ dropDown(false);
+ Event e = new Event();
+ e.time = event.time;
+ e.stateMask = event.stateMask;
+ notifyListeners(SWT.DefaultSelection, e);
+ }
+ if (isDisposed())
+ break;
+ Event e = new Event();
+ e.time = event.time;
+ e.character = event.character;
+ e.keyCode = event.keyCode;
+ e.stateMask = event.stateMask;
+ notifyListeners(SWT.KeyDown, e);
+ int index = table.getSelectionIndex();
+ if (index == -1)
+ return;
+ text.setText(table.getItem(index).getText());
+ table.setSelection(index);
+ break;
+ }
+ }
+ }
+
+ /**
+ *
+ * @param event
+ */
+ void popupEvent(Event event) {
+ switch (event.type) {
+ case SWT.Paint:
+ // draw black rectangle around list
+ Rectangle listRect = table.getBounds();
+ Color black = getDisplay().getSystemColor(SWT.COLOR_BLACK);
+ event.gc.setForeground(black);
+ event.gc.drawRectangle(X, Y, listRect.width + 1,
+ listRect.height + 1);
+ break;
+ case SWT.Close:
+ event.doit = false;
+ dropDown(false);
+ break;
+ case SWT.Deactivate:
+ // when the popup shell is deactivated by clicking the button,
+ // we receive two Deactivate events on Win32, whereas on GTK
+ // we first receive one Deactivation event from the shell and
+ // then a Selection event from the button.
+ // as a work-around, set a flag (dontDrop) if running GTK
+ if (gtk) {
+ Point loc = arrowButton.toControl(getDisplay()
+ .getCursorLocation());
+ Point size = arrowButton.getSize();
+ if ((loc.x >= 0) && (loc.y >= 0) && (loc.x < size.x)
+ && (loc.y < size.y)) {
+ dontDrop = true;
+ }
+ }
+ dropDown(false);
+ break;
+ }
+ }
+
+ /**
+ * Method for redrawing widget
+ */
+ public void redraw() {
+ super.redraw();
+ text.redraw();
+ arrowButton.redraw();
+ if (popup.isVisible())
+ table.redraw();
+ }
+
+ /**
+ * Selects the item at the given zero-relative index in the receiver's list.
+ * If the item at the index was already selected, it remains selected.
+ * Indices that are out of range are ignored.
+ *
+ * @param index
+ * the index of the item to select
+ *
+ * @exception SWTException
+ * <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been
+ * disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from
+ * the thread that created the receiver</li>
+ * </ul>
+ */
+ public void select(int index) {
+ checkWidget();
+ if (index == -1) {
+ table.deselectAll();
+ text.setText(Constants.EMPTY_STRING);
+ return;
+ }
+ if (0 <= index && index < table.getItemCount()) {
+ if (index != getSelectionIndex()) {
+ text.setText(table.getItem(index).getText());
+ text.selectAll();
+ table.select(index);
+ table.showSelection();
+ }
+ }
+ }
+
+ /**
+ * Method for setting focus in text widget
+ */
+ public boolean setFocus() {
+ checkWidget();
+ return text.setFocus();
+ }
+
+ /**
+ * Sets the contents of the receiver's text field to the given string.
+ * <p>
+ * Note: The text field in a <code>Combo</code> is typically only capable
+ * of displaying a single line of text. Thus, setting the text to a string
+ * containing line breaks or other special characters will probably cause it
+ * to display incorrectly.
+ * </p>
+ *
+ * @param string
+ * the new text
+ *
+ * @exception IllegalArgumentException
+ * <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException
+ * <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been
+ * disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from
+ * the thread that created the receiver</li>
+ * </ul>
+ */
+ public void setText(String string) {
+ checkWidget();
+ if (string == null)
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ int index = -1;
+ for (int i = 0, n = table.getItemCount(); i < n; i++) {
+ if (table.getItem(i).getText().equals(string)) {
+ index = i;
+ break;
+ }
+ }
+ if (index == -1) {
+ table.deselectAll();
+ text.setText(string);
+ return;
+ }
+ text.setText(string);
+ text.selectAll();
+ table.setSelection(index);
+ table.showSelection();
+ }
+
+ /**
+ *
+ * @param event
+ */
+ void textEvent(Event event) {
+ switch (event.type) {
+ case SWT.FocusIn: {
+ handleFocus(SWT.FocusIn);
+ break;
+ }
+ case SWT.KeyDown: {
+ if (event.character == SWT.CR) {
+ dropDown(false);
+ Event e = new Event();
+ e.time = event.time;
+ e.stateMask = event.stateMask;
+ notifyListeners(SWT.DefaultSelection, e);
+ }
+ if (isDisposed())
+ break;
+
+ if (event.keyCode == SWT.ARROW_UP
+ || event.keyCode == SWT.ARROW_DOWN) {
+ event.doit = false;
+ if ((event.stateMask & SWT.ALT) != 0) {
+ boolean dropped = isDropped();
+ text.selectAll();
+ if (!dropped)
+ setFocus();
+ dropDown(!dropped);
+ break;
+ }
+
+ int oldIndex = getSelectionIndex();
+ if (event.keyCode == SWT.ARROW_UP) {
+ select(Math.max(oldIndex - 1, 0));
+ } else {
+ select(Math.min(oldIndex + 1, getItemCount() - 1));
+ }
+ if (oldIndex != getSelectionIndex()) {
+ Event e = new Event();
+ e.time = event.time;
+ e.stateMask = event.stateMask;
+ notifyListeners(SWT.Selection, e);
+ }
+ if (isDisposed())
+ break;
+ }
+
+ Event e = new Event();
+ e.time = event.time;
+ e.character = event.character;
+ e.keyCode = event.keyCode;
+ e.stateMask = event.stateMask;
+ notifyListeners(SWT.KeyDown, e);
+ break;
+ }
+ case SWT.KeyUp: {
+ Event e = new Event();
+ e.time = event.time;
+ e.character = event.character;
+ e.keyCode = event.keyCode;
+ e.stateMask = event.stateMask;
+ notifyListeners(SWT.KeyUp, e);
+ break;
+ }
+ case SWT.Modify: {
+ table.deselectAll();
+ Event e = new Event();
+ e.time = event.time;
+ notifyListeners(SWT.Modify, e);
+ break;
+ }
+ case SWT.MouseDown: {
+ if (event.button != 1)
+ return;
+ if (text.getEditable())
+ return;
+ boolean dropped = isDropped();
+ text.selectAll();
+ if (!dropped)
+ setFocus();
+ dropDown(!dropped);
+ break;
+ }
+ case SWT.MouseUp: {
+ if (event.button != 1)
+ return;
+ if (text.getEditable())
+ return;
+ text.selectAll();
+ break;
+ }
+ case SWT.Traverse: {
+ switch (event.detail) {
+ case SWT.TRAVERSE_RETURN:
+ case SWT.TRAVERSE_ARROW_PREVIOUS:
+ case SWT.TRAVERSE_ARROW_NEXT:
+ event.doit = false;
+ break;
+ }
+
+ Event e = new Event();
+ e.time = event.time;
+ e.detail = event.detail;
+ e.doit = event.doit;
+ e.character = event.character;
+ e.keyCode = event.keyCode;
+ notifyListeners(SWT.Traverse, e);
+ event.doit = e.doit;
+ event.detail = e.detail;
+ break;
+ }
+ }
+ }
+
+}
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/MessageUtil.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/MessageUtil.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/MessageUtil.java 2008-07-16 15:19:39 UTC (rev 9155)
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.jsp.outline.cssdialog.common;
+
+import java.text.MessageFormat;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * Utility class which helps with managing messages.
+ *
+ * @author dsakovich(a)exadel.com
+ */
+public class MessageUtil {
+
+ private static final String RESOURCE_BUNDLE = "org.jboss.tools.jst.jsp.outline.cssdialog.common.messages";//$NON-NLS-1$
+
+ private static ResourceBundle fgResourceBundle = ResourceBundle
+ .getBundle(RESOURCE_BUNDLE);
+
+ private MessageUtil() {
+ }
+
+ /**
+ * Returns the formatted message for the given key in
+ *
+ * @param key
+ * the resource name
+ * @param args
+ * the message arguments
+ * @return the string
+ */
+ public static String format(String key, Object[] args) {
+ return MessageFormat.format(getString(key), args);
+ }
+
+ /**
+ * Returns the resource object with the given key
+ *
+ * @param key
+ * the resource name
+ * @return the string
+ */
+ public static String getString(String key) {
+ try {
+ return fgResourceBundle.getString(key);
+ } catch (MissingResourceException e) {
+ // TODO Sakovich
+ return key;
+ }
+ }
+}
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/Util.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/Util.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/Util.java 2008-07-16 15:19:39 UTC (rev 9155)
@@ -0,0 +1,326 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.jsp.outline.cssdialog.common;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import org.eclipse.swt.graphics.RGB;
+import org.jboss.tools.jst.jsp.outline.cssdialog.parsers.ColorParserListener;
+
+/**
+ *
+ * Utility class
+ *
+ * @author Evgeny Zheleznyakov
+ *
+ */
+public class Util {
+
+ private static String RGB = "rgb";
+
+ private static String NONE = "none";
+
+ private static String THIN = "thin";
+
+ private static String COMMA = ",";
+
+ private static int START_INDEX_RED = 1;
+ private static int END_INDEX_RED = 3;
+ private static int START_INDEX_GRENN = 3;
+ private static int END_INDEX_GREEN = 5;
+ private static int START_INDEX_BLUE = 5;
+ private static int END_INDEX_BLUE = 7;
+
+ private static int MAX_VALUE_RGB = 255;
+ private static int MIN_VALUE_RGB = 0;
+
+ private static int COUNT_COLORS = 3;
+
+ private static int RADIX = 16;
+
+ private static int COLOR_LENGTH = 7;
+
+ private static int START_COLOR_INDEX = 0;
+
+ private static char OPEN_BRACKET = '{';
+ private static char CLOSE_BRACKET = '}';
+
+ private static char SHARP = '#';
+ private static String SHARP_STRING = "#";
+
+ private static String ZERO_STR = "0";
+ private static int NORMAL_MIN_VALUE = 10;
+
+ /**
+ * Method for checking contain or not css attribute folder
+ *
+ * @param name
+ * Name css attribute
+ * @return true - contain, or else - dont contain
+ */
+ public static boolean containFolder(String name) {
+
+ for (int i = 0; i < Constants.elemFolder.length; i++)
+ if (Constants.elemFolder[i].equals(name))
+ return true;
+ return false;
+ }
+
+ /**
+ * Method for search css attribute in block elements (Aural, Boxes,....)
+ *
+ * @param name
+ * Name css attribute
+ * @param set
+ * Set of block elemnts
+ * @return true - find, or else - dont find
+ */
+ public static boolean searchOnBlock(String name, Set<String> set) {
+
+ for (String str1 : set)
+ if (str1.equals(name))
+ return true;
+
+ return false;
+ }
+
+ /**
+ * Method for search css attribute in combo elements (text-decoration,
+ * font-weight,....)
+ *
+ * @param name
+ * Name css attribute
+ * @param set
+ * Set of combo elemnts
+ * @return true - find, or else - dont find
+ */
+ public static boolean searchInCombo(String name, Set<String> set) {
+
+ for (String str1 : set)
+ if (str1.equals(name))
+ return true;
+
+ return false;
+ }
+
+ /**
+ * Method for search string into css attributes
+ *
+ * @param name
+ * Name
+ * @param elementMap
+ * Map of css attributes
+ * @return true - find, or else - dont find
+ */
+ public static boolean searchInElement(String name,
+ HashMap<String, ArrayList<String>> elementMap) {
+
+ Set<String> set = elementMap.keySet();
+
+ for (String str : set) {
+
+ ArrayList<String> list = elementMap.get(str);
+ for (String str1 : list)
+ if (str1.equals(name))
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Method for get RGB from string
+ *
+ * @param color
+ * Color string
+ * @return RGB color, or null, if color invalid
+ */
+ public static RGB getColor(String color) {
+
+ if (color.equals(Constants.EMPTY_STRING) || color.equals(NONE))
+ return null;
+
+ if (color.charAt(START_COLOR_INDEX) == SHARP
+ && color.length() == COLOR_LENGTH) {
+
+ String strR = color.substring(START_INDEX_RED, END_INDEX_RED);
+ String strG = color.substring(START_INDEX_GRENN, END_INDEX_GREEN);
+ String strB = color.substring(START_INDEX_BLUE, END_INDEX_BLUE);
+
+ try {
+ Integer.parseInt(strR, RADIX);
+ Integer.parseInt(strG, RADIX);
+ Integer.parseInt(strB, RADIX);
+ } catch (RuntimeException e) {
+ return null;
+ }
+ return convertColorHEX(color);
+ } else if (color.toLowerCase().indexOf(RGB) != Constants.DONT_CONTAIN) {
+
+ int start = color.indexOf(OPEN_BRACKET);
+ int end = color.indexOf(CLOSE_BRACKET);
+ String str = color.substring(start + 1, end);
+
+ StringTokenizer st = new StringTokenizer(str, COMMA);
+
+ int j = 0;
+ while (st.hasMoreTokens()) {
+ try {
+ int i = Integer.parseInt(st.nextToken().trim());
+ if (i < MIN_VALUE_RGB || i > MAX_VALUE_RGB)
+ return null;
+
+ } catch (NumberFormatException e) {
+ return null;
+ }
+ j++;
+ }
+
+ if (j == COUNT_COLORS)
+ return convertColorRGB(color);
+ } else {
+ HashMap<String, String> colorMap = ColorParserListener.getMap();
+
+ for (String key : colorMap.keySet())
+ if (colorMap.get(key).equalsIgnoreCase(color))
+ return convertColorHEX(key);
+ }
+
+ return null;
+ }
+
+ /**
+ * Method for convert string(123px) into two string (123 and px)
+ *
+ * @param str
+ * String for convert
+ * @return Array two strings, or null, if str uncorrect
+ */
+ public static String[] convertExtString(String str) {
+
+ if (str.equalsIgnoreCase(THIN))
+ return new String[] { THIN, Constants.EMPTY_STRING };
+
+ if (str == null)
+ return null;
+
+ if (str.trim().equals(Constants.EMPTY_STRING))
+ return new String[] { Constants.EMPTY_STRING,
+ Constants.EMPTY_STRING };
+
+ String newStr = str.toLowerCase().trim();
+
+ int index = -1;
+ for (int i = 1; i < Constants.extSizes.length; i++) {
+
+ index = newStr.indexOf(Constants.extSizes[i]);
+ if (index != -1)
+ break;
+ }
+
+ if (index == -1)
+ return new String[] { newStr, Constants.EMPTY_STRING };
+
+ String number = newStr.substring(0, index);
+ String ext = newStr.substring(index, index + 2);
+
+ return new String[] { number, ext };
+ }
+
+ /**
+ * Method for search css attribute into extElements
+ *
+ * @param name
+ * Name of css attribute
+ * @return true - find, or else - dont find
+ */
+ public static boolean searchInExtElement(String name) {
+
+ for (int i = 0; i < Constants.extElem.length; i++)
+ if (Constants.extElem[i].equals(name))
+ return true;
+ return false;
+ }
+
+ /**
+ * Method for getting RGB color from string color
+ *
+ * @param color
+ * String color
+ * @return RGB color
+ */
+ public static RGB convertColorRGB(String color) {
+
+ String newStr = color.trim().toLowerCase();
+
+ int rgb[] = new int[COUNT_COLORS];
+
+ int start = newStr.indexOf(OPEN_BRACKET);
+ int end = newStr.indexOf(CLOSE_BRACKET);
+ String str = newStr.substring(start + 1, end);
+
+ StringTokenizer st = new StringTokenizer(str, COMMA);
+ int i = 0;
+ while (st.hasMoreTokens())
+ rgb[i++] = Integer.parseInt(st.nextToken().trim());
+ return new RGB(rgb[0], rgb[1], rgb[2]);
+ }
+
+ /**
+ * Method for getting RGB color from hex string
+ *
+ * @param color
+ * String color
+ * @return RGB color
+ */
+ public static RGB convertColorHEX(String color) {
+
+ String newStr = color.trim().toLowerCase();
+
+ String strR = newStr.substring(START_INDEX_RED, END_INDEX_RED);
+ String strG = newStr.substring(START_INDEX_GRENN, END_INDEX_GREEN);
+ String strB = newStr.substring(START_INDEX_BLUE, END_INDEX_BLUE);
+
+ int red = Integer.parseInt(strR, RADIX);
+ int green = Integer.parseInt(strG, RADIX);
+ int blue = Integer.parseInt(strB, RADIX);
+
+ return new RGB(red, green, blue);
+ }
+
+ /**
+ * Method for convert RGB to String
+ *
+ * @param rgb
+ * RGB color
+ * @return String color
+ */
+ public static String createColorString(RGB rgb) {
+ String colorStr = SHARP_STRING
+ + (rgb.red < NORMAL_MIN_VALUE ? ZERO_STR
+ : Constants.EMPTY_STRING)
+ + Integer.toHexString(rgb.red)
+ + (rgb.green < NORMAL_MIN_VALUE ? ZERO_STR
+ : Constants.EMPTY_STRING)
+ + Integer.toHexString(rgb.green)
+ + Constants.EMPTY_STRING
+ + (rgb.blue < NORMAL_MIN_VALUE ? ZERO_STR
+ : Constants.EMPTY_STRING)
+ + Integer.toHexString(rgb.blue);
+ colorStr = colorStr.toUpperCase();
+ if (ColorParserListener.getMap().get(colorStr) != null)
+ return ColorParserListener.getMap().get(colorStr);
+ return colorStr;
+ }
+}
\ No newline at end of file
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/messages.properties
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/messages.properties (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/messages.properties 2008-07-16 15:19:39 UTC (rev 9155)
@@ -0,0 +1,42 @@
+CSS_DIALOG_TITLE=CSS Editor
+TEXT_FONT_TAB_NAME=Text/Font
+BOXES_TAB_NAME=Boxes
+BACKGROUND_TAB_NAME=Background
+PROPERTY_SHEET_TAB_NAME=Property Sheet
+QUICK_EDIT_TAB-NAME=Quick Edit
+BACKGROUND_COLOR=Background Color:
+BACKGROUND_COLOR_TIP=Choose background color
+COLOR_DIALOG_TITLE=Choose a Color
+BACKGROUND_IMAGE=Background Image:
+BACKGROUND_IMAGE_TIP=Choose background image
+IMAGE_DIALOG_TITLE=File Selection
+IMAGE_DIALOG_MESSAGE=Select image
+IMAGE_DIALOG_EMPTY_MESSAGE=Not find images in current Project
+BACKGROUND_REPEAT=Background Repeat:
+DIMENSION_TITLE=Dimension
+WIDTH=Width:
+HEIGHT=Height:
+BORDER_TITLE=Border
+BORDER_STYLE=Border Style:
+BORDER_COLOR=Border Color:
+BORDER_COLOR_TIP=Choose border color
+BORDER_WIDTH=Border Width:
+MARGIN_PADDING_TITLE=Margin/Padding
+MARGIN=Margin:
+PADDING=Padding:
+FONT_FAMILY=Font Family:
+FONT_FAMILY_TIP=Choose font family
+COLOR=Color:
+COLOR_TIP=Choose text color
+FONT_SIZE=Font Size:
+FONT_STYLE=Font Style:
+FONT_WEIGHT=Font Weight:
+TEXT_DECORATION=Text Decoration:
+TEXT_ALIGN=Text Align:
+ALL_FILES=All files
+ALL_IMAGE_FILES=All image files
+ADD_FONT_FAMILY_TIP=Add font family
+REMOVE_FONT_FAMILY_TIP=Remove font family
+FONT_FAMILY_DIALOG_TITLE=Choose font family
+IMAGE_PREVIEW=Image preview
+IMAGE_COMBO_TABLE_TOOL_TIP=Double click to select color
\ No newline at end of file
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/events/TabPropertySheetMouseAdapter.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/events/TabPropertySheetMouseAdapter.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/events/TabPropertySheetMouseAdapter.java 2008-07-16 15:19:39 UTC (rev 9155)
@@ -0,0 +1,467 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.jsp.outline.cssdialog.events;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.TreeEditor;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.ColorDialog;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.model.WorkbenchContentProvider;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+
+import org.jboss.tools.jst.jsp.JspEditorPlugin;
+import org.jboss.tools.jst.jsp.outline.cssdialog.CSSDialog;
+import org.jboss.tools.jst.jsp.outline.cssdialog.FontFamilyDialog;
+import org.jboss.tools.jst.jsp.outline.cssdialog.ImageSelectionDialog;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.CSSConstants;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.Constants;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.ImageCombo;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.MessageUtil;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.Util;
+import org.jboss.tools.jst.jsp.outline.cssdialog.parsers.ColorParserListener;
+import org.jboss.tools.jst.jsp.outline.cssdialog.tabs.TabPropertySheetControl;
+
+/**
+ *
+ * Listener for tree in tab property sheet
+ *
+ * @author Evgeny Zheleznyakov
+ *
+ */
+public class TabPropertySheetMouseAdapter extends MouseAdapter {
+
+ private Tree tree;
+
+ private TreeEditor editor;
+
+ private Combo combo = null;
+ private ImageCombo colorCombo = null;
+
+ private HashMap<String, ArrayList<String>> comboMap;
+ private HashMap<String, ArrayList<String>> elementsMap;
+
+ private static int GRID_NUM_COLUMNS = 2;
+ private static int GRID_MARGIN_HEIGHT = 0;
+ private static int GRID_MARGIN_WIDTH = 0;
+ private static int GRID_HORIZONTAL_SPASING = 0;
+
+ private CSSDialog cssDialog;
+
+ private TabPropertySheetControl tabPropertySheetControl;
+
+ public TabPropertySheetMouseAdapter(Tree tree,
+ HashMap<String, ArrayList<String>> elementsMap,
+ HashMap<String, ArrayList<String>> comboMap,
+ TabPropertySheetControl tabPropertySheetControl,
+ CSSDialog dialog) {
+
+ this.tabPropertySheetControl = tabPropertySheetControl;
+ this.cssDialog = dialog;
+ this.tree = tree;
+ this.comboMap = comboMap;
+ this.elementsMap = elementsMap;
+
+ editor = new TreeEditor(tree);
+ editor.horizontalAlignment = SWT.LEFT;
+ editor.grabHorizontal = true;
+ }
+
+ /**
+ * Invoke then mouse pressed
+ */
+ public void mouseDown(MouseEvent event) {
+
+ for (int i = 0; i < tree.getColumnCount(); i++)
+ tree.getColumn(i).pack();
+
+ Control old = editor.getEditor();
+ if (old != null)
+ old.dispose();
+
+ Point pt = new Point(event.x, event.y);
+
+ final TreeItem item = tree.getItem(pt);
+
+ if (item != null) {
+
+ if (Util.searchOnBlock(item.getText(Constants.FIRST_COLUMN).trim(),
+ elementsMap.keySet()))
+ return;
+
+ if (Util.searchInCombo(item.getText(Constants.FIRST_COLUMN).trim(),
+ comboMap.keySet()))
+ createCombo(item, Constants.SECOND_COLUMN);
+ else
+ createText(item, Constants.SECOND_COLUMN);
+ }
+ }
+
+ /**
+ * Method for create combo editor
+ *
+ * @param item
+ * Tree item for editing
+ * @param column
+ * Number of column for editing
+ */
+ private void createCombo(final TreeItem item, int column) {
+
+ final Composite panel = new Composite(tree, SWT.NONE);
+ GridLayout grid = new GridLayout();
+ grid.numColumns = GRID_NUM_COLUMNS;
+ grid.marginHeight = GRID_MARGIN_HEIGHT;
+ grid.marginWidth = GRID_MARGIN_WIDTH;
+ grid.horizontalSpacing = GRID_HORIZONTAL_SPASING;
+ panel.setLayout(grid);
+
+ Button btn = null;
+
+ boolean color = false;
+
+ // color element
+ if (item.getText(Constants.FIRST_COLUMN).trim().indexOf(
+ CSSConstants.COLOR) != Constants.DONT_CONTAIN) {
+ color = true;
+
+ // create combo for color
+ colorCombo = new ImageCombo(panel, SWT.BORDER);
+
+ HashMap<String, String> colorMap = ColorParserListener.getMap();
+
+ for (String key : colorMap.keySet()) {
+ RGB rgb = Util.getColor(key);
+ colorCombo.add(colorMap.get(key), rgb);
+ }
+
+ if (colorCombo.indexOf(item.getText(Constants.SECOND_COLUMN).trim()
+ .toLowerCase()) != Constants.DONT_CONTAIN)
+ colorCombo.select(colorCombo.indexOf(item.getText(
+ Constants.SECOND_COLUMN).trim().toLowerCase()));
+ else
+ colorCombo
+ .setText(item.getText(Constants.SECOND_COLUMN).trim());
+
+ colorCombo.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent event) {
+ item.setText(Constants.SECOND_COLUMN, colorCombo.getText());
+ panel.dispose();
+ tabPropertySheetControl.updateData(true);
+ cssDialog.setStyleForPreview();
+ }
+ });
+
+ colorCombo.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent event) {
+ item.setText(Constants.SECOND_COLUMN, colorCombo.getText());
+ tabPropertySheetControl.updateData(true);
+ cssDialog.setStyleForPreview();
+ }
+ });
+
+ // create color button
+ btn = new Button(panel, SWT.NONE);
+ ImageDescriptor imageDes = JspEditorPlugin
+ .getImageDescriptor(Constants.IMAGE_COLOR_FILE_LOCATION);
+ Image colorImage = imageDes.createImage();
+ btn.setImage(colorImage);
+ btn.addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent e) {
+ Button button = (Button) e.getSource();
+ button.getImage().dispose();
+ }
+ });
+ btn.setToolTipText(MessageUtil.getString("COLOR_DIALOG_TITLE"));
+
+ btn.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent event) {
+
+ RGB startRgb = Util.getColor(item.getText(
+ Constants.SECOND_COLUMN).toLowerCase().trim());
+
+ if (startRgb == null)
+ startRgb = Constants.RGB_BLACK;
+
+ ColorDialog colorDialog = new ColorDialog(tree.getShell());
+ colorDialog.setRGB(startRgb);
+ colorDialog.setText(MessageUtil
+ .getString("COLOR_DIALOG_TITLE"));
+ RGB rgb = colorDialog.open();
+ if (rgb != null) {
+
+ String str = Util.createColorString(rgb);
+
+ if (ColorParserListener.getMap().get(str) != null)
+ item.setText(Constants.SECOND_COLUMN,
+ ColorParserListener.getMap().get(str));
+ else
+ item.setText(Constants.SECOND_COLUMN, str);
+
+ tabPropertySheetControl.updateData(true);
+ cssDialog.setStyleForPreview();
+ }
+ panel.dispose();
+ }
+ });
+ } else if (Util.containFolder(item.getText(Constants.FIRST_COLUMN)
+ .trim())) {
+
+ combo = new Combo(panel, SWT.NONE);
+
+ // create chooser button
+ btn = new Button(panel, SWT.NONE);
+ ImageDescriptor imageDes = JspEditorPlugin
+ .getImageDescriptor(Constants.IMAGE_FOLDER_FILE_LOCATION);
+ Image chooserImage = imageDes.createImage();
+ btn.setImage(chooserImage);
+ btn.addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent e) {
+ Button button = (Button) e.getSource();
+ button.getImage().dispose();
+ }
+ });
+ btn.setToolTipText(MessageUtil.getString("IMAGE_DIALOG_MESSAGE"));
+
+ btn.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ IProject project = getCurrentProject();
+
+ ImageSelectionDialog dialog = new ImageSelectionDialog(tree
+ .getShell(), new WorkbenchLabelProvider(),
+ new WorkbenchContentProvider());
+ dialog
+ .setTitle(MessageUtil
+ .getString("IMAGE_DIALOG_TITLE"));
+ dialog.setMessage(MessageUtil
+ .getString("IMAGE_DIALOG_MESSAGE"));
+ dialog.setEmptyListMessage(MessageUtil
+ .getString("IMAGE_DIALOG_EMPTY_MESSAGE"));
+ dialog.setAllowMultiple(false);
+ dialog.setInput(project);
+ if (dialog.open() == ImageSelectionDialog.OK) {
+ IFile file = (IFile) dialog.getFirstResult();
+ String value = file.getFullPath().toString();
+ item.setText(Constants.SECOND_COLUMN, value);
+ panel.dispose();
+ tabPropertySheetControl.updateData(true);
+ cssDialog.setStyleForPreview();
+ }
+ }
+ });
+
+ } else {
+ combo = new Combo(panel, SWT.NONE);
+ }
+
+ // add items
+ if (!color) {
+ ArrayList<String> list = comboMap.get(item.getText(
+ Constants.FIRST_COLUMN).trim());
+
+ for (String str : list)
+ combo.add(str);
+
+ if (btn != null)
+ btn.setLayoutData(new GridData(GridData.END, GridData.CENTER,
+ false, false));
+
+ combo.setLayoutData(new GridData(GridData.FILL, GridData.CENTER,
+ true, false));
+
+ combo.setFocus();
+ if (combo.indexOf(item.getText(column)) == Constants.DONT_CONTAIN
+ && !item.getText(column).equals(Constants.EMPTY_STRING))
+ combo.setText(item.getText(column));
+ else
+ combo.select(combo.indexOf(item.getText(column)));
+
+ // Add a listener to set the selected item back into the
+ // cell
+ final int col = column;
+ combo.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ item.setText(col, combo.getText());
+ panel.dispose();
+ tabPropertySheetControl.updateData(true);
+ cssDialog.setStyleForPreview();
+ }
+ });
+
+ combo.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent event) {
+ item.setText(col, combo.getText());
+ tabPropertySheetControl.updateData(true);
+ cssDialog.setStyleForPreview();
+ }
+ });
+ } else {
+ colorCombo.setLayoutData(new GridData(GridData.FILL,
+ GridData.CENTER, true, false));
+
+ btn.setLayoutData(new GridData(GridData.END, GridData.CENTER,
+ false, false));
+
+ colorCombo.setFocus();
+ }
+
+ // Compute the width for the editor
+ // Also, compute the column width, so that the dropdown
+ // fits
+ editor.minimumWidth = panel.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
+ editor.minimumHeight = panel.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
+
+ tree.getColumn(column).setWidth(editor.minimumWidth);
+
+ // Set the focus on the dropdown and set into the editor
+ editor.setEditor(panel, item, column);
+ }
+
+ /**
+ * Method for create text editor
+ *
+ * @param item
+ * Tree item for editing
+ * @param column
+ * Number of column for editing
+ */
+ private void createText(final TreeItem item, int column) {
+
+ final Composite panel = new Composite(tree, SWT.NONE);
+ GridLayout grid = new GridLayout();
+ grid.numColumns = GRID_NUM_COLUMNS;
+ grid.marginHeight = GRID_MARGIN_HEIGHT;
+ grid.marginWidth = GRID_MARGIN_WIDTH;
+ grid.horizontalSpacing = GRID_HORIZONTAL_SPASING;
+ panel.setLayout(grid);
+
+ Button btn = null;
+
+ final Text text = new Text(panel, SWT.BORDER);
+
+ if (item.getText(Constants.FIRST_COLUMN).trim().equalsIgnoreCase(
+ CSSConstants.FONT_FAMILY)) {
+
+ btn = new Button(panel, SWT.NONE);
+ ImageDescriptor imageDes = JspEditorPlugin
+ .getImageDescriptor(Constants.IMAGE_FONT_FILE_LOCATION);
+ Image fontImage = imageDes.createImage();
+ btn.setImage(fontImage);
+ btn.addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent e) {
+ Button button = (Button) e.getSource();
+ button.getImage().dispose();
+ }
+ });
+ btn.setToolTipText(MessageUtil.getString("FONT_FAMILY_TIP"));
+
+ btn.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ FontFamilyDialog dialog = new FontFamilyDialog(tree
+ .getShell(), item.getText(Constants.SECOND_COLUMN));
+ if (dialog.open() == Window.OK) {
+ item.setText(Constants.SECOND_COLUMN, dialog
+ .getFontFamily());
+ panel.dispose();
+ tabPropertySheetControl.updateData(true);
+ cssDialog.setStyleForPreview();
+ }
+ }
+ });
+ }
+
+ if (btn != null)
+ btn.setLayoutData(new GridData(GridData.END, GridData.CENTER,
+ false, false));
+
+ text.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true,
+ false));
+
+ // Compute the width for the editor
+ // Also, compute the column width, so that the dropdown
+ // fits
+ editor.minimumWidth = panel.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
+ editor.minimumHeight = panel.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
+
+ tree.getColumn(column).setWidth(editor.minimumWidth);
+
+ // Set the focus on the dropdown and set into the editor
+ editor.setEditor(panel, item, column);
+
+ // Transfer any text from the cell to the Text control,
+ // set the color to match this row, select the text,
+ // and set focus to the control
+ text.setText(item.getText(column));
+ text.setFocus();
+
+ // Add a handler to transfer the text back to the cell
+ // any time it's modified
+ final int col = column;
+ text.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent event) {
+ // Set the text of the editor's control back
+ // into the cell
+ item.setText(col, text.getText());
+ tabPropertySheetControl.updateData(true);
+ cssDialog.setStyleForPreview();
+ }
+ });
+ }
+
+ /**
+ * Method for get current project
+ *
+ * @return IProject
+ */
+ public static IProject getCurrentProject() {
+ IEditorPart editor = JspEditorPlugin.getDefault().getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ IEditorInput input = editor.getEditorInput();
+ IFile file = null;
+ if (input instanceof IFileEditorInput) {
+ file = ((IFileEditorInput) input).getFile();
+ }
+ if (file == null)
+ return null;
+
+ IProject project = file.getProject();
+ return project;
+ }
+}
\ No newline at end of file
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/parsers/BaseListener.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/parsers/BaseListener.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/parsers/BaseListener.java 2008-07-16 15:19:39 UTC (rev 9155)
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.jsp.outline.cssdialog.parsers;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * Base listener
+ *
+ * @author Evgeny Zheleznyakov
+ *
+ */
+public class BaseListener extends DefaultHandler {
+
+ protected HashMap<String, ArrayList<String>> map;
+
+ /**
+ *
+ * Constructor for listener
+ *
+ * @param map
+ * Map for writing
+ */
+ public BaseListener(HashMap<String, ArrayList<String>> map) {
+ this.map = map;
+ }
+
+ /**
+ *
+ * Getter for map
+ *
+ * @return Map
+ */
+ public HashMap<String, ArrayList<String>> getMap() {
+ return map;
+ }
+}
\ No newline at end of file
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/parsers/CSSElementsParser.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/parsers/CSSElementsParser.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/parsers/CSSElementsParser.java 2008-07-16 15:19:39 UTC (rev 9155)
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.jsp.outline.cssdialog.parsers;
+
+import java.io.File;
+import java.io.IOException;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.jboss.tools.jst.jsp.JspEditorPlugin;
+import org.xml.sax.SAXException;
+
+public class CSSElementsParser {
+
+ private String FILE_NAME = "cssElements.xml";
+
+ private BaseListener listener;
+
+ private SAXParserFactory fact;
+
+ private SAXParser saxParser;
+
+ public CSSElementsParser() {
+
+ try {
+ fact = SAXParserFactory.newInstance();
+ saxParser = fact.newSAXParser();
+
+ } catch (ParserConfigurationException e) {
+ // TODO Evgeny Zheleznyakov remove all printStackTrace
+ e.printStackTrace();
+ } catch (SAXException e) {
+ // TODO Evgeny Zheleznyakov remove all printStackTrace
+ e.printStackTrace();
+ }
+ }
+
+ public void parse() {
+
+ String pluginPath = JspEditorPlugin.getPluginCSSDialogResourcePath();
+ IPath pluginFile = new Path(pluginPath);
+ String path = pluginFile.append(FILE_NAME).toFile().getAbsolutePath();
+ File file = new File(path);
+ if (!file.exists())
+ throw new RuntimeException();
+
+ try {
+ saxParser.parse(file, listener);
+ } catch (SAXException e) {
+ // TODO Evgeny Zheleznyakov remove all printStackTrace
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Evgeny Zheleznyakov remove all printStackTrace
+ e.printStackTrace();
+ }
+
+ }
+
+ public void setListener(BaseListener listener) {
+ this.listener = listener;
+ }
+}
\ No newline at end of file
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/parsers/ColorParser.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/parsers/ColorParser.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/parsers/ColorParser.java 2008-07-16 15:19:39 UTC (rev 9155)
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.jsp.outline.cssdialog.parsers;
+
+import java.io.File;
+import java.io.IOException;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.jboss.tools.jst.jsp.JspEditorPlugin;
+
+import org.xml.sax.SAXException;
+
+/**
+ *
+ * Parser for parse colors elements
+ *
+ * @author Evgeny Zheleznyakov
+ *
+ */
+public class ColorParser {
+
+ private String FILE_NAME = "colors.xml";
+
+ private ColorParserListener listener;
+
+ private SAXParserFactory fact;
+
+ private SAXParser saxParser;
+
+ /**
+ * Constructor for Color parser
+ */
+ public ColorParser() {
+
+ try {
+ fact = SAXParserFactory.newInstance();
+ saxParser = fact.newSAXParser();
+
+ } catch (ParserConfigurationException e) {
+ // TODO Evgeny Zheleznyakov remove all printStackTrace
+ e.printStackTrace();
+ } catch (SAXException e) {
+ // TODO Evgeny Zheleznyakov remove all printStackTrace
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Parse the content of the file specified as XML using the specified
+ */
+ public void parse() {
+
+ String pluginPath = JspEditorPlugin.getPluginCSSDialogResourcePath();
+ IPath pluginFile = new Path(pluginPath);
+ String path = pluginFile.append(FILE_NAME).toFile().getAbsolutePath();
+ File file = new File(path);
+ if (!file.exists())
+ throw new RuntimeException();
+
+ try {
+ saxParser.parse(file, listener);
+ } catch (SAXException e) {
+ // TODO Evgeny Zheleznyakov remove all printStackTrace
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Evgeny Zheleznyakov remove all printStackTrace
+ e.printStackTrace();
+ }
+
+ }
+
+ /**
+ * Method for set listener
+ *
+ * @param listener
+ * ColorParseListener
+ */
+ public void setListener(ColorParserListener listener) {
+ this.listener = listener;
+ }
+}
\ No newline at end of file
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/parsers/ColorParserListener.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/parsers/ColorParserListener.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/parsers/ColorParserListener.java 2008-07-16 15:19:39 UTC (rev 9155)
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.jsp.outline.cssdialog.parsers;
+
+import java.util.HashMap;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * Color parser listener
+ *
+ * @author ezheleznyakov
+ *
+ */
+public class ColorParserListener extends DefaultHandler {
+
+ private static String NODE_NAME_COLOR = "color";
+
+ private static String NODE_ATTRIBUTE_NAME = "name";
+
+ private static String NODE_ATTRIBUTE_VALUE = "value";
+
+ private static HashMap<String, String> map;
+
+ public ColorParserListener() {
+ map = new HashMap<String, String>();
+ }
+
+ public void startElement(String uri, String localName, String nodeName,
+ Attributes attrs) {
+
+ if (nodeName.trim().equalsIgnoreCase(NODE_NAME_COLOR)) {
+ map.put(attrs.getValue(NODE_ATTRIBUTE_NAME).trim().toUpperCase(),
+ attrs.getValue(NODE_ATTRIBUTE_VALUE).trim());
+ }
+ }
+
+ public static HashMap<String, String> getMap() {
+ return map;
+ }
+}
\ No newline at end of file
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/parsers/ComboParser.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/parsers/ComboParser.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/parsers/ComboParser.java 2008-07-16 15:19:39 UTC (rev 9155)
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.jsp.outline.cssdialog.parsers;
+
+import java.io.File;
+import java.io.IOException;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.jboss.tools.jst.jsp.JspEditorPlugin;
+import org.xml.sax.SAXException;
+
+/**
+ *
+ * @author ezheleznyakov
+ *
+ */
+public class ComboParser {
+
+ private String FILE_NAME = "cssElementsWithCombo.xml";
+
+ private BaseListener listener;
+
+ private SAXParser saxParser;
+
+ public ComboParser() {
+
+ try {
+ saxParser = SAXParserFactory.newInstance().newSAXParser();
+
+ } catch (ParserConfigurationException e) {
+ // TODO Evgeny Zheleznyakov remove all printStackTrace
+ e.printStackTrace();
+ } catch (SAXException e) {
+ // TODO Evgeny Zheleznyakov remove all printStackTrace
+ e.printStackTrace();
+ }
+ }
+
+ public void parse() {
+
+ String pluginPath = JspEditorPlugin.getPluginCSSDialogResourcePath();
+ IPath pluginFile = new Path(pluginPath);
+ String path = pluginFile.append(FILE_NAME).toFile().getAbsolutePath();
+ File file = new File(path);
+ if (!file.exists())
+ throw new RuntimeException();
+
+ try {
+ saxParser.parse(file, listener);
+ } catch (SAXException e) {
+ // TODO Evgeny Zheleznyakov remove all printStackTrace
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Evgeny Zheleznyakov remove all printStackTrace
+ e.printStackTrace();
+ }
+
+ }
+
+ public void setListener(BaseListener listener) {
+ this.listener = listener;
+ }
+}
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/parsers/IListener.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/parsers/IListener.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/parsers/IListener.java 2008-07-16 15:19:39 UTC (rev 9155)
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.jsp.outline.cssdialog.parsers;
+
+/**
+ *
+ * Interface for listenrs
+ *
+ * @author Evgeny Zheleznyakov
+ *
+ */
+public interface IListener {
+
+ /**
+ *
+ * Invoke when getting new pair name, value
+ *
+ * @param name
+ * Name css attribute
+ * @param value
+ * Value css attribute
+ */
+ public void nextElement(String name, String value);
+}
\ No newline at end of file
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/parsers/Parser.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/parsers/Parser.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/parsers/Parser.java 2008-07-16 15:19:39 UTC (rev 9155)
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.jsp.outline.cssdialog.parsers;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.StringTokenizer;
+
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.Constants;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.Util;
+
+/**
+ *
+ * Parser for input style string
+ *
+ * @author Evgeny Zheleznyakov
+ *
+ */
+public class Parser {
+
+ private static String SEPARATE_SYMBOLS = ":;";
+
+ private ArrayList<IListener> list;
+
+ private HashMap<String, ArrayList<String>> elementsMap;
+
+ public Parser(HashMap<String, ArrayList<String>> elementsMap) {
+ this.elementsMap = elementsMap;
+ list = new ArrayList<IListener>();
+ }
+
+ public void parse(String str) {
+
+ if (str == null)
+ return;
+ if (str.trim().equals(Constants.EMPTY_STRING))
+ return;
+
+ StringTokenizer st = new StringTokenizer(str, SEPARATE_SYMBOLS);
+
+ while (st.hasMoreTokens()) {
+ String name = null;
+ String value = null;
+
+ name = st.nextToken().trim().toLowerCase();
+ if (!Util.searchInElement(name, elementsMap))
+ continue;
+ if (st.hasMoreTokens())
+ value = st.nextToken().trim();
+ else
+ continue;
+
+ if (name.equals(Constants.EMPTY_STRING)
+ || value.equals(Constants.EMPTY_STRING))
+ continue;
+
+ for (IListener listener : list) {
+ listener.nextElement(name, value);
+ }
+ }
+ }
+
+ /**
+ *
+ * Add listener for parser
+ *
+ * @param listener
+ * Listener
+ */
+ public void addListener(IListener listener) {
+ list.add(listener);
+ }
+
+ /**
+ *
+ * Remove listener from parser
+ *
+ * @param listener
+ * Listener
+ */
+ public void removeListener(IListener listener) {
+ list.remove(listener);
+ }
+}
\ No newline at end of file
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/parsers/ParserListener.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/parsers/ParserListener.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/parsers/ParserListener.java 2008-07-16 15:19:39 UTC (rev 9155)
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.jsp.outline.cssdialog.parsers;
+
+import java.util.HashMap;
+
+/**
+ *
+ * ParserListener for input style string
+ *
+ * @author Evgeny Zheleznyakov
+ *
+ */
+public class ParserListener implements IListener {
+
+ private HashMap<String, String> map;
+
+ public ParserListener(HashMap<String, String> map) {
+ this.map = map;
+ }
+
+ public void nextElement(String name, String value) {
+ map.put(name, value);
+ }
+
+ public HashMap<String, String> getMap() {
+ return map;
+ }
+}
\ No newline at end of file
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabBackgroundControl.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabBackgroundControl.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabBackgroundControl.java 2008-07-16 15:19:39 UTC (rev 9155)
@@ -0,0 +1,305 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.jsp.outline.cssdialog.tabs;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.ColorDialog;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.model.WorkbenchContentProvider;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+import org.jboss.tools.jst.jsp.JspEditorPlugin;
+import org.jboss.tools.jst.jsp.outline.cssdialog.CSSDialog;
+import org.jboss.tools.jst.jsp.outline.cssdialog.ImageSelectionDialog;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.CSSConstants;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.Constants;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.ImageCombo;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.MessageUtil;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.Util;
+import org.jboss.tools.jst.jsp.outline.cssdialog.parsers.ColorParserListener;
+
+/**
+ * Class for creating control in Background tab
+ *
+ * @author dsakovich(a)exadel.com
+ *
+ */
+public class TabBackgroundControl extends Composite {
+
+ private ImageCombo colorCombo;
+
+ private Combo backgroundImageCombo;
+ private Combo backgroundRepeatCombo;
+
+ private HashMap<String, String> attributesMap;
+
+ private static final int numColumns = 3;
+
+ private CSSDialog cssDialog;
+
+ public TabBackgroundControl(final Composite composite,
+ HashMap<String, ArrayList<String>> comboMap,
+ final HashMap<String, String> attributesMap, CSSDialog dialog) {
+ super(composite, SWT.NONE);
+ this.attributesMap = attributesMap;
+ this.cssDialog = dialog;
+
+ final GridLayout gridLayout = new GridLayout();
+ gridLayout.numColumns = numColumns;
+ setLayout(gridLayout);
+
+ Label label = new Label(this, SWT.LEFT);
+ label.setLayoutData(new GridData(GridData.END, GridData.CENTER, false,
+ false));
+ label.setText(MessageUtil.getString("BACKGROUND_COLOR"));
+
+ colorCombo = new ImageCombo(this, SWT.BORDER);
+ colorCombo.setLayoutData(new GridData(GridData.FILL, GridData.CENTER,
+ true, false));
+ // ////////////////////////////////////////////////////////////////////////
+ Set<Entry<String, String>> set = ColorParserListener.getMap()
+ .entrySet();
+
+ for (Map.Entry<String, String> me : set) {
+ RGB rgb = Util.getColor(me.getKey());
+ colorCombo.add(me.getValue(), rgb);
+ }
+
+ colorCombo.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent event) {
+ String tmp = colorCombo.getText();
+ if (tmp != null) {
+ if (tmp.trim().length() > 0)
+ attributesMap.put(CSSConstants.BACKGROUND_COLOR, tmp);
+ else
+ attributesMap.remove(CSSConstants.BACKGROUND_COLOR);
+ }
+ cssDialog.setStyleForPreview();
+ }
+ });
+
+ Button button = new Button(this, SWT.PUSH);
+ button.setLayoutData(new GridData(GridData.END, GridData.CENTER, false,
+ false));
+ button.setToolTipText(MessageUtil.getString("BACKGROUND_COLOR_TIP"));
+ ImageDescriptor colorDesc = JspEditorPlugin
+ .getImageDescriptor(Constants.IMAGE_COLORLARGE_FILE_LOCATION);
+ Image im = colorDesc.createImage();
+ button.setImage(im);
+ button.addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent e) {
+ Button button = (Button) e.getSource();
+ button.getImage().dispose();
+ }
+ });
+ button.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ ColorDialog dlg = new ColorDialog(getShell());
+
+ dlg
+ .setRGB(Util.getColor((colorCombo.getText().trim())) == null ? new RGB(
+ 0, 0, 0)
+ : Util.getColor((colorCombo.getText().trim())));
+ dlg.setText(MessageUtil.getString("COLOR_DIALOG_TITLE"));
+ RGB rgb = dlg.open();
+ if (rgb != null) {
+ String colorStr = Util.createColorString(rgb);
+ colorCombo.setText(colorStr);
+ }
+ }
+ });
+
+ label = new Label(this, SWT.LEFT);
+ label.setLayoutData(new GridData(GridData.END, GridData.CENTER, false,
+ false));
+ label.setText(MessageUtil.getString("BACKGROUND_IMAGE"));
+
+ backgroundImageCombo = new Combo(this, SWT.BORDER);
+ final GridData backgroundImageGridData = new GridData(GridData.FILL,
+ GridData.CENTER, true, false);
+ backgroundImageCombo.setLayoutData(backgroundImageGridData);
+ backgroundImageCombo.add(Constants.NONE);
+
+ backgroundImageCombo.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent event) {
+ String tmp = backgroundImageCombo.getText();
+ if (tmp != null) {
+ if (tmp.trim().length() > 0)
+ attributesMap.put(CSSConstants.BACKGROUND_IMAGE, tmp);
+ else
+ attributesMap.remove(CSSConstants.BACKGROUND_IMAGE);
+ }
+ cssDialog.setStyleForPreview();
+ }
+ });
+
+ button = new Button(this, SWT.PUSH);
+ button.setLayoutData(new GridData(GridData.END, GridData.CENTER, false,
+ false));
+ button.setToolTipText(MessageUtil.getString("BACKGROUND_IMAGE"));
+ ImageDescriptor imageDesc = JspEditorPlugin
+ .getImageDescriptor(Constants.IMAGE_FOLDERLARGE_FILE_LOCATION);
+ Image image = imageDesc.createImage();
+ button.setImage(image);
+ button.addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent e) {
+ Button button = (Button) e.getSource();
+ button.getImage().dispose();
+ }
+ });
+ button.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ IProject project = getCurrentProject();
+ ImageSelectionDialog dialog = new ImageSelectionDialog(
+ getShell(), new WorkbenchLabelProvider(),
+ new WorkbenchContentProvider());
+ dialog.setTitle(MessageUtil.getString("IMAGE_DIALOG_TITLE"));
+ dialog
+ .setMessage(MessageUtil
+ .getString("IMAGE_DIALOG_MESSAGE"));
+ dialog.setEmptyListMessage(MessageUtil
+ .getString("IMAGE_DIALOG_EMPTY_MESSAGE"));
+ dialog.setAllowMultiple(false);
+ dialog.setInput(project);
+ if (dialog.open() == ImageSelectionDialog.OK) {
+ IFile file = (IFile) dialog.getFirstResult();
+ String value = file.getFullPath().toString();
+ backgroundImageCombo.add(value);
+ backgroundImageCombo.setText(value);
+ }
+ }
+ });
+
+ label = new Label(this, SWT.LEFT);
+ label.setLayoutData(new GridData(GridData.END, GridData.CENTER, false,
+ false));
+ label.setText(MessageUtil.getString("BACKGROUND_REPEAT"));
+
+ backgroundRepeatCombo = new Combo(this, SWT.BORDER);
+ backgroundRepeatCombo.setLayoutData(new GridData(GridData.FILL,
+ GridData.CENTER, false, false));
+
+ backgroundRepeatCombo.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent event) {
+ String tmp = backgroundRepeatCombo.getText();
+ if (tmp != null) {
+ if (tmp.trim().length() > 0)
+ attributesMap.put(CSSConstants.BACKGROUND_REPEAT, tmp);
+ else
+ attributesMap.remove(CSSConstants.BACKGROUND_REPEAT);
+ }
+ cssDialog.setStyleForPreview();
+ }
+ });
+
+ ArrayList<String> list = comboMap.get(CSSConstants.BACKGROUND_REPEAT);
+ for (String str : list)
+ backgroundRepeatCombo.add(str);
+
+ label = new Label(this, SWT.LEFT);
+ label.setLayoutData(new GridData(GridData.END, GridData.CENTER, false,
+ false));
+ label.setText(Constants.EMPTY_STRING);
+
+ }
+
+ /**
+ * Method for get current project
+ *
+ * @return IProject
+ */
+ public static IProject getCurrentProject() {
+ IEditorPart editor = JspEditorPlugin.getDefault().getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ IEditorInput input = editor.getEditorInput();
+ IFile file = null;
+ if (input instanceof IFileEditorInput) {
+ file = ((IFileEditorInput) input).getFile();
+ }
+ if (file == null)
+ return null;
+
+ IProject project = file.getProject();
+ return project;
+
+ }
+
+ /**
+ * Method for get data in controls (if param equal true ), or set data (if
+ * param equal false).
+ *
+ * @param param
+ */
+ public void updateData(boolean param) {
+ String tmp;
+
+ //TODO Evgeny Zheleznyakov remove block comment
+ /*if (param) {
+ tmp = colorCombo.getText();
+ if (tmp != null) {
+ if (tmp.trim().length() > 0)
+ attributesMap.put(CSSConstants.BACKGROUND_COLOR, tmp);
+ else
+ attributesMap.remove(CSSConstants.BACKGROUND_COLOR);
+ }
+ tmp = backgroundImageCombo.getText();
+ if (tmp != null) {
+ if (tmp.trim().length() > 0)
+ attributesMap.put(CSSConstants.BACKGROUND_IMAGE, tmp);
+ else
+ attributesMap.remove(CSSConstants.BACKGROUND_IMAGE);
+ }
+ tmp = backgroundRepeatCombo.getText();
+ if (tmp != null) {
+ if (tmp.trim().length() > 0)
+ attributesMap.put(CSSConstants.BACKGROUND_REPEAT, tmp);
+ else
+ attributesMap.remove(CSSConstants.BACKGROUND_REPEAT);
+ }
+ } else {*/
+ if ((tmp = attributesMap.get(CSSConstants.BACKGROUND_COLOR)) != null)
+ colorCombo.setText(tmp);
+ else
+ colorCombo.setText(Constants.EMPTY_STRING);
+ if ((tmp = attributesMap.get(CSSConstants.BACKGROUND_IMAGE)) != null)
+ backgroundImageCombo.setText(tmp);
+ else
+ backgroundImageCombo.setText(Constants.EMPTY_STRING);
+ if ((tmp = attributesMap.get(CSSConstants.BACKGROUND_REPEAT)) != null)
+ backgroundRepeatCombo.setText(tmp);
+ else
+ backgroundRepeatCombo.setText(Constants.EMPTY_STRING);
+ }
+}
\ No newline at end of file
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabBoxesControl.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabBoxesControl.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabBoxesControl.java 2008-07-16 15:19:39 UTC (rev 9155)
@@ -0,0 +1,680 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.jsp.outline.cssdialog.tabs;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.ColorDialog;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.jboss.tools.jst.jsp.JspEditorPlugin;
+import org.jboss.tools.jst.jsp.outline.cssdialog.CSSDialog;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.CSSConstants;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.Constants;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.ImageCombo;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.MessageUtil;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.Util;
+import org.jboss.tools.jst.jsp.outline.cssdialog.parsers.ColorParserListener;
+
+/**
+ * Class for creating control in Box tab
+ *
+ * @author dsakovich(a)exadel.com
+ *
+ */
+public class TabBoxesControl extends Composite {
+
+ private Combo extWidthCombo;
+ private Combo extHeightCombo;
+ private Combo borderWidthCombo;
+ private Combo extPaddingCombo;
+ private Combo extBorderWidthCombo;
+ private Combo borderStyleCombo;
+ private Combo extMarginCombo;
+
+ private ImageCombo borderColorCombo;
+
+ private Text widthText;
+ private Text heightText;
+ private Text marginText;
+ private Text paddingText;
+
+ private ArrayList<String> list;
+ private HashMap<String, String> attributesMap;
+
+ private static final int numColumns = 3;
+
+ private CSSDialog cssDialog;
+
+ /**
+ * Constructor for creating controls
+ *
+ * @param composite
+ */
+ public TabBoxesControl(final Composite composite,
+ final HashMap<String, ArrayList<String>> comboMap,
+ final HashMap<String, String> attributesMap, CSSDialog dialog) {
+ super(composite, SWT.NONE);
+ this.attributesMap = attributesMap;
+ this.cssDialog = dialog;
+
+ final GridLayout gridLayout = new GridLayout();
+ gridLayout.numColumns = numColumns;
+ setLayout(gridLayout);
+
+ Label label = new Label(this, SWT.NONE);
+ label.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER,
+ false, false, 3, 1));
+
+ label.setFont(JFaceResources.getFontRegistry().get(
+ JFaceResources.BANNER_FONT));
+ label.setText(MessageUtil.getString("DIMENSION_TITLE"));
+ label = new Label(this, SWT.LEFT);
+ label.setText(MessageUtil.getString("WIDTH"));
+ label.setLayoutData(new GridData(GridData.END, GridData.CENTER, false,
+ false));
+
+ widthText = new Text(this, SWT.BORDER | SWT.SINGLE);
+
+ widthText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent event) {
+
+ String tmp = widthText.getText();
+
+ if (tmp != null) {
+ if (tmp.trim().length() > 0) {
+ String extWidth = extWidthCombo.getText().trim();
+ if (extWidth != null)
+ attributesMap.put(CSSConstants.WIDTH, tmp
+ + extWidth);
+ else
+ attributesMap.put(CSSConstants.WIDTH, tmp);
+ } else
+ attributesMap.remove(CSSConstants.WIDTH);
+ } else
+ attributesMap.remove(CSSConstants.WIDTH);
+ cssDialog.setStyleForPreview();
+ }
+ });
+
+ widthText.setLayoutData(new GridData(GridData.FILL, GridData.CENTER,
+ true, false));
+
+ extWidthCombo = new Combo(this, SWT.BORDER | SWT.READ_ONLY);
+
+ extWidthCombo.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent event) {
+ String width = widthText.getText().trim();
+ if (width == null)
+ return;
+ if (width.equals(Constants.EMPTY_STRING))
+ return;
+
+ String tmp = extWidthCombo.getText();
+
+ if (tmp != null) {
+ attributesMap.put(CSSConstants.WIDTH, width + tmp);
+ cssDialog.setStyleForPreview();
+ }
+ }
+ });
+
+ extWidthCombo.setLayoutData(new GridData(GridData.FILL,
+ GridData.CENTER, false, false));
+ for (int i = 0; i < Constants.extSizes.length; i++) {
+ extWidthCombo.add(Constants.extSizes[i]);
+ }
+
+ label = new Label(this, SWT.LEFT);
+ label.setText(MessageUtil.getString("HEIGHT"));
+ label.setLayoutData(new GridData(GridData.END, GridData.CENTER, false,
+ false));
+
+ heightText = new Text(this, SWT.BORDER | SWT.SINGLE);
+
+ heightText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent event) {
+ String tmp = heightText.getText();
+
+ if (tmp != null) {
+ if (tmp.trim().length() > 0) {
+ String extHeight = extHeightCombo.getText().trim();
+ if (extHeight != null)
+ attributesMap.put(CSSConstants.HEIGHT, tmp
+ + extHeight);
+ else
+ attributesMap.put(CSSConstants.HEIGHT, tmp);
+ } else
+ attributesMap.remove(CSSConstants.HEIGHT);
+ } else
+ attributesMap.remove(CSSConstants.HEIGHT);
+ cssDialog.setStyleForPreview();
+ }
+ });
+
+ heightText.setLayoutData(new GridData(GridData.FILL, GridData.CENTER,
+ true, false));
+
+ extHeightCombo = new Combo(this, SWT.BORDER | SWT.READ_ONLY);
+
+ extHeightCombo.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent event) {
+ String height = heightText.getText().trim();
+ if (height == null)
+ return;
+ if (height.equals(Constants.EMPTY_STRING))
+ return;
+
+ String tmp = extHeightCombo.getText();
+
+ if (tmp != null) {
+ attributesMap.put(CSSConstants.HEIGHT, height + tmp);
+ cssDialog.setStyleForPreview();
+ }
+ }
+ });
+
+ extHeightCombo.setLayoutData(new GridData(GridData.FILL,
+ GridData.CENTER, false, false));
+ for (int i = 0; i < Constants.extSizes.length; i++) {
+ extHeightCombo.add(Constants.extSizes[i]);
+ }
+
+ label = new Label(this, SWT.NONE);
+ label.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER,
+ false, false, 3, 1));
+ label.setFont(JFaceResources.getFontRegistry().get(
+ JFaceResources.BANNER_FONT));
+ label.setText(MessageUtil.getString("BORDER_TITLE"));
+
+ label = new Label(this, SWT.LEFT);
+ label.setLayoutData(new GridData(GridData.END, GridData.CENTER, false,
+ false));
+ label.setText(MessageUtil.getString("BORDER_STYLE"));
+
+ borderStyleCombo = new Combo(this, SWT.BORDER);
+
+ borderStyleCombo.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent event) {
+ String tmp = borderStyleCombo.getText().trim();
+ if(tmp != null)
+ if(!tmp.equals(Constants.EMPTY_STRING)) {
+ attributesMap.put(CSSConstants.BORDER_STYLE, tmp);
+ cssDialog.setStyleForPreview();
+ return;
+ }
+ attributesMap.remove(CSSConstants.BORDER_STYLE);
+ cssDialog.setStyleForPreview();
+ }
+ });
+
+ borderStyleCombo.setLayoutData(new GridData(GridData.FILL,
+ GridData.CENTER, false, false));
+ list = comboMap.get(CSSConstants.BORDER_STYLE);
+ for (String str : list) {
+ borderStyleCombo.add(str);
+ }
+
+ label = new Label(this, SWT.LEFT);
+ label.setLayoutData(new GridData(GridData.END, GridData.CENTER, false,
+ false));
+ label.setText(Constants.EMPTY_STRING);
+
+ label = new Label(this, SWT.LEFT);
+ label.setLayoutData(new GridData(GridData.END, GridData.CENTER, false,
+ false));
+ label.setText(MessageUtil.getString("BORDER_COLOR"));
+
+ borderColorCombo = new ImageCombo(this, SWT.BORDER);
+
+ borderColorCombo.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent event) {
+ String tmp = borderColorCombo.getText().trim();
+ if(tmp != null)
+ if(!tmp.equals(Constants.EMPTY_STRING)) {
+ attributesMap.put(CSSConstants.BORDER_COLOR, tmp);
+ cssDialog.setStyleForPreview();
+ return;
+ }
+ attributesMap.remove(CSSConstants.BORDER_COLOR);
+ cssDialog.setStyleForPreview();
+ }
+ });
+
+ borderColorCombo.setLayoutData(new GridData(GridData.FILL,
+ GridData.CENTER, true, false));
+ Set<Entry<String, String>> set = ColorParserListener.getMap()
+ .entrySet();
+
+ for (Map.Entry<String, String> me : set) {
+ RGB rgb = Util.getColor(me.getKey());
+ borderColorCombo.add(me.getValue(), rgb);
+ }
+
+ final Button button = new Button(this, SWT.PUSH);
+ button.setLayoutData(new GridData(GridData.END, GridData.CENTER, false,
+ false));
+ button.setToolTipText(MessageUtil.getString("BORDER_COLOR_TIP"));
+ ImageDescriptor colorDesc = JspEditorPlugin
+ .getImageDescriptor(Constants.IMAGE_COLORLARGE_FILE_LOCATION);
+ Image im = colorDesc.createImage();
+ button.setImage(im);
+ button.addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent e) {
+ Button button = (Button) e.getSource();
+ button.getImage().dispose();
+ }
+ });
+ button.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ ColorDialog dlg = new ColorDialog(getShell());
+
+ dlg
+ .setRGB(Util.getColor((borderColorCombo.getText()
+ .trim())) == null ? Constants.RGB_BLACK : Util
+ .getColor((borderColorCombo.getText().trim())));
+ dlg.setText(MessageUtil.getString("COLOR_DIALOG_TITLE"));
+ RGB rgb = dlg.open();
+ if (rgb != null) {
+ String colorStr = Util.createColorString(rgb);
+ borderColorCombo.setText(colorStr);
+ }
+ }
+ });
+
+ label = new Label(this, SWT.LEFT);
+ label.setText(MessageUtil.getString("BORDER_WIDTH"));
+ label.setLayoutData(new GridData(GridData.END, GridData.CENTER, false,
+ false));
+
+ borderWidthCombo = new Combo(this, SWT.BORDER | SWT.SINGLE);
+
+ borderWidthCombo.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent e) {
+ String currentText = borderWidthCombo.getText();
+
+ list = comboMap.get(CSSConstants.BORDER_WIDTH);
+ for (String str : list) {
+ if (currentText.equals(str)) {
+ extBorderWidthCombo.select(0);
+ extBorderWidthCombo.setEnabled(false);
+ attributesMap.put(CSSConstants.BORDER_WIDTH,
+ currentText);
+ cssDialog.setStyleForPreview();
+ return;
+ }
+ }
+ extBorderWidthCombo.setEnabled(true);
+
+ String tmp = borderWidthCombo.getText();
+
+ if (tmp != null) {
+ if (tmp.trim().length() > 0) {
+ String extBorderWidth = extBorderWidthCombo.getText()
+ .trim();
+ if (extBorderWidth != null)
+ attributesMap.put(CSSConstants.BORDER_WIDTH, tmp
+ + extBorderWidth);
+ else
+ attributesMap.put(CSSConstants.BORDER_WIDTH, tmp);
+ } else
+ attributesMap.remove(CSSConstants.BORDER_WIDTH);
+ } else
+ attributesMap.remove(CSSConstants.BORDER_WIDTH);
+ cssDialog.setStyleForPreview();
+ }
+ });
+
+ borderWidthCombo.setLayoutData(new GridData(GridData.FILL,
+ GridData.CENTER, true, false));
+
+ list = comboMap.get(CSSConstants.BORDER_WIDTH);
+ for (String str : list) {
+ borderWidthCombo.add(str);
+ }
+
+ extBorderWidthCombo = new Combo(this, SWT.BORDER | SWT.READ_ONLY);
+
+ extBorderWidthCombo.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent event) {
+ String borderWidth = borderWidthCombo.getText().trim();
+ if (borderWidth == null)
+ return;
+ if (borderWidth.equals(Constants.EMPTY_STRING))
+ return;
+
+ String tmp = extBorderWidthCombo.getText();
+
+ if (tmp != null) {
+ attributesMap.put(CSSConstants.BORDER_WIDTH, borderWidth + tmp);
+ cssDialog.setStyleForPreview();
+ }
+ }
+ });
+
+ extBorderWidthCombo.setLayoutData(new GridData(GridData.FILL,
+ GridData.CENTER, false, false));
+ for (int i = 0; i < Constants.extSizes.length; i++) {
+ extBorderWidthCombo.add(Constants.extSizes[i]);
+ }
+
+ borderWidthCombo.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent e) {
+ String currentText = borderWidthCombo.getText();
+
+ list = comboMap.get(CSSConstants.BORDER_WIDTH);
+ for (String str : list) {
+ if (currentText.equals(str)) {
+ extBorderWidthCombo.select(0);
+ extBorderWidthCombo.setEnabled(false);
+ return;
+ }
+ extBorderWidthCombo.setEnabled(true);
+ }
+ }
+ });
+
+ label = new Label(this, SWT.NONE);
+ label.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER,
+ false, false, 3, 1));
+ label.setFont(JFaceResources.getFontRegistry().get(
+ JFaceResources.BANNER_FONT));
+ label.setText(MessageUtil.getString("MARGIN_PADDING_TITLE"));
+
+ label = new Label(this, SWT.LEFT);
+ label.setText(MessageUtil.getString("MARGIN"));
+ label.setLayoutData(new GridData(GridData.END, GridData.CENTER, false,
+ false));
+
+ marginText = new Text(this, SWT.BORDER | SWT.SINGLE);
+
+ marginText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent event) {
+
+ String tmp = marginText.getText();
+
+ if (tmp != null) {
+ if (tmp.trim().length() > 0) {
+ String extMargin = extMarginCombo.getText().trim();
+ if (extMargin != null)
+ attributesMap.put(CSSConstants.MARGIN, tmp
+ + extMargin);
+ else
+ attributesMap.put(CSSConstants.MARGIN, tmp);
+ } else
+ attributesMap.remove(CSSConstants.MARGIN);
+ } else
+ attributesMap.remove(CSSConstants.MARGIN);
+ cssDialog.setStyleForPreview();
+ }
+ });
+
+ marginText.setLayoutData(new GridData(GridData.FILL, GridData.CENTER,
+ true, false));
+
+ extMarginCombo = new Combo(this, SWT.BORDER | SWT.READ_ONLY);
+
+ extMarginCombo.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent event) {
+ String margin = marginText.getText().trim();
+ if (margin == null)
+ return;
+ if (margin.equals(Constants.EMPTY_STRING))
+ return;
+
+ String tmp = extMarginCombo.getText();
+
+ if (tmp != null) {
+ attributesMap.put(CSSConstants.MARGIN, margin + tmp);
+ cssDialog.setStyleForPreview();
+ }
+ }
+ });
+
+ extMarginCombo.setLayoutData(new GridData(GridData.FILL,
+ GridData.CENTER, false, false));
+ for (int i = 0; i < Constants.extSizes.length; i++) {
+ extMarginCombo.add(Constants.extSizes[i]);
+ }
+
+ label = new Label(this, SWT.LEFT);
+ label.setText(MessageUtil.getString("PADDING"));
+ label.setLayoutData(new GridData(GridData.END, GridData.CENTER, false,
+ false));
+
+ paddingText = new Text(this, SWT.BORDER | SWT.SINGLE);
+
+ paddingText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent event) {
+
+ String tmp = paddingText.getText();
+
+ if (tmp != null) {
+ if (tmp.trim().length() > 0) {
+ String extPadding = extPaddingCombo.getText().trim();
+ if (extPadding != null)
+ attributesMap.put(CSSConstants.PADDING, tmp
+ + extPadding);
+ else
+ attributesMap.put(CSSConstants.PADDING, tmp);
+ } else
+ attributesMap.remove(CSSConstants.PADDING);
+ } else
+ attributesMap.remove(CSSConstants.PADDING);
+ cssDialog.setStyleForPreview();
+ }
+ });
+
+ paddingText.setLayoutData(new GridData(GridData.FILL, GridData.CENTER,
+ true, false));
+
+ extPaddingCombo = new Combo(this, SWT.BORDER | SWT.READ_ONLY);
+
+ extPaddingCombo.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent event) {
+ String padding = paddingText.getText().trim();
+ if (padding == null)
+ return;
+ if (padding.equals(Constants.EMPTY_STRING))
+ return;
+
+ String tmp = extPaddingCombo.getText();
+
+ if (tmp != null) {
+ attributesMap.put(CSSConstants.PADDING, padding + tmp);
+ cssDialog.setStyleForPreview();
+ }
+ }
+ });
+
+ extPaddingCombo.setLayoutData(new GridData(GridData.FILL,
+ GridData.CENTER, false, false));
+ for (int i = 0; i < Constants.extSizes.length; i++) {
+ extPaddingCombo.add(Constants.extSizes[i]);
+ }
+ }
+
+ /**
+ * Method for get data in controls (if param equal true ), or set data (if
+ * param equal false).
+ *
+ * @param param
+ */
+ public void updateData(boolean param) {
+ String tmp;
+
+ //TODO Evgeny Zheleznyakov remove block comment
+ /*if (param) {
+ tmp = widthText.getText();
+ if (tmp != null) {
+ if (tmp.trim().length() > 0)
+ attributesMap
+ .put(
+ CSSConstants.WIDTH,
+ tmp
+ + (extWidthCombo.getText() == null ? Constants.EMPTY_STRING
+ : extWidthCombo.getText()));
+ else
+ attributesMap.remove(CSSConstants.WIDTH);
+ }
+ tmp = heightText.getText();
+ if (tmp != null) {
+ if (tmp.trim().length() > 0)
+ attributesMap
+ .put(
+ CSSConstants.HEIGHT,
+ tmp
+ + (extHeightCombo.getText() == null ? Constants.EMPTY_STRING
+ : extHeightCombo.getText()));
+ else
+ attributesMap.remove(CSSConstants.HEIGHT);
+ }
+ tmp = borderStyleCombo.getText();
+ if (tmp != null && tmp.trim().length() > 0) {
+ attributesMap.put(CSSConstants.BORDER_STYLE, tmp);
+ }
+ tmp = borderColorCombo.getText();
+ if (tmp != null && tmp.trim().length() > 0) {
+ attributesMap.put(CSSConstants.BORDER_COLOR, tmp);
+ }
+ tmp = borderWidthCombo.getText();
+ if (tmp != null) {
+ if (tmp.trim().length() > 0)
+ attributesMap
+ .put(
+ CSSConstants.BORDER_WIDTH,
+ tmp
+ + (extBorderWidthCombo.getText() == null ? Constants.EMPTY_STRING
+ : extBorderWidthCombo
+ .getText()));
+ else
+ attributesMap.remove(CSSConstants.BORDER_WIDTH);
+ }
+ tmp = marginText.getText();
+ if (tmp != null) {
+ if (tmp.trim().length() > 0)
+ attributesMap
+ .put(
+ CSSConstants.MARGIN,
+ tmp
+ + (extMarginCombo.getText() == null ? Constants.EMPTY_STRING
+ : extMarginCombo.getText()));
+ else
+ attributesMap.remove(CSSConstants.MARGIN);
+ }
+ tmp = paddingText.getText();
+ if (tmp != null) {
+ if (tmp.trim().length() > 0)
+ attributesMap
+ .put(
+ CSSConstants.PADDING,
+ tmp
+ + (extPaddingCombo.getText() == null ? Constants.EMPTY_STRING
+ : extPaddingCombo.getText()));
+ else
+ attributesMap.remove(CSSConstants.PADDING);
+ }
+ } else {*/
+ if ((tmp = attributesMap.get(CSSConstants.WIDTH)) != null) {
+ String[] str = Util.convertExtString(tmp);
+ widthText.setText(str[0]);
+ if (extWidthCombo.indexOf(str[1]) != -1) {
+ extWidthCombo.setText(str[1]);
+ extWidthCombo.select(extWidthCombo.indexOf(str[1]));
+ } else
+ extWidthCombo.select(0);
+ } else {
+ widthText.setText(Constants.EMPTY_STRING);
+ extWidthCombo.select(0);
+ }
+ if ((tmp = attributesMap.get(CSSConstants.HEIGHT)) != null) {
+ String[] str = Util.convertExtString(tmp);
+ heightText.setText(str[0]);
+ if (extHeightCombo.indexOf(str[1]) != -1) {
+ extHeightCombo.setText(str[1]);
+ extHeightCombo.select(extHeightCombo.indexOf(str[1]));
+ } else
+ extHeightCombo.select(0);
+ } else {
+ heightText.setText(Constants.EMPTY_STRING);
+ extHeightCombo.select(0);
+ }
+ if ((tmp = attributesMap.get(CSSConstants.BORDER_STYLE)) != null)
+ borderStyleCombo.setText(tmp);
+ else
+ borderStyleCombo.setText(Constants.EMPTY_STRING);
+ if ((tmp = attributesMap.get(CSSConstants.BORDER_COLOR)) != null)
+ borderColorCombo.setText(tmp);
+ else
+ borderColorCombo.setText(Constants.EMPTY_STRING);
+ if ((tmp = attributesMap.get(CSSConstants.BORDER_WIDTH)) != null) {
+ String[] str = Util.convertExtString(tmp);
+ borderWidthCombo.setText(str[0]);
+ if (extBorderWidthCombo.indexOf(str[1]) != -1) {
+ extBorderWidthCombo.setText(str[1]);
+ extBorderWidthCombo.select(extBorderWidthCombo
+ .indexOf(str[1]));
+ } else
+ extBorderWidthCombo.select(0);
+ } else {
+ borderWidthCombo.setText(Constants.EMPTY_STRING);
+ extBorderWidthCombo.select(0);
+ }
+ if ((tmp = attributesMap.get(CSSConstants.MARGIN)) != null) {
+ String[] str = Util.convertExtString(tmp);
+ marginText.setText(str[0]);
+ if (extMarginCombo.indexOf(str[1]) != -1) {
+ extMarginCombo.setText(str[1]);
+ extMarginCombo.select(extMarginCombo.indexOf(str[1]));
+ } else
+ extMarginCombo.select(0);
+ } else {
+ marginText.setText(Constants.EMPTY_STRING);
+ extMarginCombo.select(0);
+ }
+ if ((tmp = attributesMap.get(CSSConstants.PADDING)) != null) {
+ String[] str = Util.convertExtString(tmp);
+ paddingText.setText(str[0]);
+ if (extPaddingCombo.indexOf(str[1]) != -1) {
+ extPaddingCombo.setText(str[1]);
+ extPaddingCombo.select(extPaddingCombo.indexOf(str[1]));
+ } else
+ extPaddingCombo.select(0);
+ } else {
+ paddingText.setText(Constants.EMPTY_STRING);
+ extPaddingCombo.select(0);
+ }
+ }
+}
\ No newline at end of file
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabPropertySheetControl.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabPropertySheetControl.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabPropertySheetControl.java 2008-07-16 15:19:39 UTC (rev 9155)
@@ -0,0 +1,192 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.jsp.outline.cssdialog.tabs;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Set;
+
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
+import org.eclipse.swt.widgets.TreeItem;
+import org.jboss.tools.jst.jsp.outline.cssdialog.CSSDialog;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.Constants;
+import org.jboss.tools.jst.jsp.outline.cssdialog.events.TabPropertySheetMouseAdapter;
+
+/**
+ *
+ * Class for creating Property sheet tab
+ *
+ * @author Evgeny Zheleznyakov
+ *
+ */
+public class TabPropertySheetControl extends Composite {
+
+ private String columns[] = new String[] { "Attribute", "Value" };
+
+ private Tree tree;
+
+ private HashMap<String, String> attributesMap;
+
+ /**
+ * Constructor for creating controls
+ *
+ * @param composite
+ * The parent composite for tab
+ */
+ public TabPropertySheetControl(TabFolder tabFolder,
+ HashMap<String, ArrayList<String>> elementMap,
+ HashMap<String, ArrayList<String>> comboMap,
+ HashMap<String, String> attributesMap,
+ CSSDialog dialog) {
+ super(tabFolder, SWT.NONE);
+
+ this.attributesMap = attributesMap;
+
+ setLayout(new FillLayout());
+
+ tree = new Tree(this, SWT.NONE);
+ tree.setHeaderVisible(true);
+ tree.setLinesVisible(true);
+
+ // Create NUM columns
+ for (int i = 0; i < columns.length; i++) {
+ TreeColumn column = new TreeColumn(tree, SWT.LEFT | SWT.COLOR_BLACK);
+ column.setText(columns[i]);
+ }
+
+ Set<String> set = elementMap.keySet();
+
+ for (String str : set) {
+
+ TreeItem item = new TreeItem(tree, SWT.NONE);
+ item.setText(str);
+ item.setFont(Constants.FIRST_COLUMN, JFaceResources
+ .getFontRegistry().get(JFaceResources.TEXT_FONT));
+ ArrayList<String> list = elementMap.get(str);
+
+ for (String strList : list) {
+
+ TreeItem subItem = new TreeItem(item, SWT.NONE);
+ subItem.setText(Constants.FIRST_COLUMN, strList);
+ }
+ }
+ updateData(false);
+
+ tree.addMouseListener(new TabPropertySheetMouseAdapter(tree,
+ elementMap, comboMap, this, dialog));
+
+ for (int i = 0; i < tree.getColumnCount(); i++)
+ tree.getColumn(i).pack();
+ }
+
+ /**
+ * Method for get data in controls (if param equal true ), or set data (if
+ * param equal false).
+ *
+ * @param update
+ */
+ public void updateData(boolean update) {
+ if (update) {
+
+ for (int i = 0; i < tree.getItemCount(); i++) {
+ for (int j = 0; j < tree.getItem(i).getItemCount(); j++) {
+ if (tree.getItem(i).getItem(j).getText(
+ Constants.SECOND_COLUMN) == null) {
+ attributesMap.remove(tree.getItem(i).getItem(j)
+ .getText(Constants.FIRST_COLUMN));
+ } else if (tree.getItem(i).getItem(j).getText(
+ Constants.SECOND_COLUMN).trim().equals(
+ Constants.EMPTY_STRING)) {
+ attributesMap.remove(tree.getItem(i).getItem(j)
+ .getText(Constants.FIRST_COLUMN));
+ } else {
+ attributesMap.put(tree.getItem(i).getItem(j).getText(
+ Constants.FIRST_COLUMN), tree.getItem(i)
+ .getItem(j).getText(Constants.SECOND_COLUMN));
+ }
+ }
+ }
+ } else {
+
+ for (int i = 0; i < tree.getItemCount(); i++)
+ for (int j = 0; j < tree.getItem(i).getItemCount(); j++)
+ tree.getItem(i).getItem(j).setText(Constants.SECOND_COLUMN,
+ Constants.EMPTY_STRING);
+
+ Set<String> set = attributesMap.keySet();
+ for (String str : set) {
+
+ for (int i = 0; i < tree.getItemCount(); i++)
+ for (int j = 0; j < tree.getItem(i).getItemCount(); j++)
+ if (tree.getItem(i).getItem(j).getText(
+ Constants.FIRST_COLUMN).equals(str))
+ tree.getItem(i).getItem(j).setText(
+ Constants.SECOND_COLUMN,
+ attributesMap.get(str));
+ }
+ setExpanded();
+ }
+ }
+
+ /**
+ *
+ * Set expanded item for not empty css attributes
+ */
+ private void setExpanded() {
+
+ TreeItem item = null;
+
+ for (int i = 0; i < tree.getItemCount(); i++)
+ tree.getItem(i).setExpanded(false);
+
+ Set<String> set = attributesMap.keySet();
+
+ for (String attr : set)
+ if ((item = find(attr)) != null) {
+ item.setExpanded(true);
+ }
+
+ for (int i = 0; i < tree.getColumnCount(); i++)
+ tree.getColumn(i).pack();
+ }
+
+ /**
+ *
+ * Find tree item for expand
+ *
+ * @param attr
+ * Name of css attributes
+ * @return Tree item which will expand
+ */
+ private TreeItem find(String attr) {
+
+ TreeItem item = null;
+ TreeItem subItem = null;
+
+ for (int i = 0; i < tree.getItemCount(); i++) {
+
+ item = tree.getItem(i);
+ for (int j = 0; j < item.getItemCount(); j++) {
+
+ subItem = item.getItem(j);
+ if (subItem.getText().equals(attr))
+ return item;
+ }
+ }
+ return null;
+ }
+}
\ No newline at end of file
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabQuickEditControl.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabQuickEditControl.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabQuickEditControl.java 2008-07-16 15:19:39 UTC (rev 9155)
@@ -0,0 +1,608 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.jsp.outline.cssdialog.tabs;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.StringTokenizer;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.ColorDialog;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.model.WorkbenchContentProvider;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+import org.jboss.tools.jst.jsp.JspEditorPlugin;
+import org.jboss.tools.jst.jsp.outline.cssdialog.CSSDialog;
+import org.jboss.tools.jst.jsp.outline.cssdialog.FontFamilyDialog;
+import org.jboss.tools.jst.jsp.outline.cssdialog.ImageSelectionDialog;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.CSSConstants;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.Constants;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.ImageCombo;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.MessageUtil;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.Util;
+import org.jboss.tools.jst.jsp.outline.cssdialog.parsers.ColorParserListener;
+
+/**
+ *
+ * Class for creating control in Quick edit tab
+ *
+ * @author Evgeny Zheleznyakov
+ *
+ */
+public class TabQuickEditControl extends Composite {
+
+ private static String COLON_STRING = ":";
+ private static String SPACE_STRING = " ";
+
+ private static String DASH_STRING = "-";
+
+ private static int FIRST_INDEX = 0;
+ private static int SECOND_INDEX = 1;
+
+ private static int GRID_NUM_COLUMNS = 3;
+
+ private static int VALUE_NUMBER = 0;
+ private static int EXT_VALUE_NUMBER = 1;
+
+ private Label label = null;
+
+ private HashMap<String, ArrayList<String>> comboMap;
+ private HashMap<String, String> attributesMap;
+
+ private CSSDialog dialog;
+
+ /**
+ * Constructor for creating controls
+ *
+ * @param composite
+ * The parent composite for tab
+ */
+ public TabQuickEditControl(Composite sc,
+ HashMap<String, ArrayList<String>> comboMap,
+ HashMap<String, String> attributesMap, CSSDialog dialog) {
+ super(sc, SWT.NONE);
+
+ this.dialog = dialog;
+ this.attributesMap = attributesMap;
+ this.comboMap = comboMap;
+ GridLayout gridLayout = new GridLayout();
+ gridLayout.numColumns = GRID_NUM_COLUMNS;
+ setLayout(gridLayout);
+
+ ArrayList<String> listKeys = new ArrayList<String>();
+
+ for (String key : attributesMap.keySet())
+ listKeys.add(key);
+
+ Collections.sort(listKeys);
+
+ for (String key : listKeys) {
+
+ label = new Label(this, SWT.LEFT);
+ label.setText(format(key));
+ label.setLayoutData(new GridData(GridData.END, GridData.CENTER,
+ false, false));
+ if (Util.searchInCombo(key, comboMap.keySet()))
+ createCombo(this, key, attributesMap.get(key));
+ else
+ createText(this, key, attributesMap.get(key));
+ }
+ }
+
+ /**
+ * Method for creating combo controls
+ *
+ * @param composite
+ * The parent composite for tab
+ * @param name
+ * Name of css element
+ * @param value
+ * Value of css element
+ */
+ private void createCombo(final Composite composite, final String name,
+ final String value) {
+
+ Button btn = null;
+ //if css attribute with color combo
+ if (name.indexOf(CSSConstants.COLOR) != Constants.DONT_CONTAIN) {
+
+ final ImageCombo colorCombo = new ImageCombo(composite, SWT.BORDER);
+ colorCombo.setText(value);
+ colorCombo.setLayoutData(new GridData(GridData.FILL,
+ GridData.CENTER, true, false));
+
+ btn = new Button(composite, SWT.NONE);
+ btn.setLayoutData(new GridData(GridData.END, GridData.CENTER,
+ false, false));
+ ImageDescriptor imageDes = JspEditorPlugin
+ .getImageDescriptor(Constants.IMAGE_COLOR_FILE_LOCATION);
+ Image colorImage = imageDes.createImage();
+ btn.setImage(colorImage);
+ btn.setToolTipText(MessageUtil.getString("COLOR_DIALOG_TITLE"));
+ btn.addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent e) {
+ Button button = (Button) e.getSource();
+ button.getImage().dispose();
+ }
+ });
+ btn.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent event) {
+
+ RGB startRgb = Util.getColor((colorCombo.getText()
+ .toLowerCase().trim()));
+
+ if (startRgb == null)
+ startRgb = Constants.RGB_BLACK;
+
+ ColorDialog colorDialog = new ColorDialog(composite
+ .getShell());
+ colorDialog.setRGB(startRgb);
+ colorDialog.setText(MessageUtil
+ .getString("COLOR_DIALOG_TITLE"));
+ RGB rgb = colorDialog.open();
+ if (rgb != null) {
+
+ String str = Util.createColorString(rgb);
+
+ if (ColorParserListener.getMap().get(str) != null)
+ colorCombo.setText(ColorParserListener.getMap()
+ .get(str));
+ else
+ colorCombo.setText(str);
+ }
+ }
+ });
+
+ colorCombo.addModifyListener(new ModifyListener() {
+
+ String key = name;
+
+ public void modifyText(ModifyEvent event) {
+
+ if (!colorCombo.getText().trim().equals(
+ Constants.EMPTY_STRING))
+ attributesMap.put(key, colorCombo.getText().trim());
+ else
+ attributesMap.remove(key);
+
+ dialog.setStyleForPreview();
+ }
+ });
+
+ HashMap<String, String> colorMap = ColorParserListener.getMap();
+
+ for (String key : colorMap.keySet()) {
+ RGB rgb = Util.getColor(key);
+ colorCombo.add(colorMap.get(key), rgb);
+ }
+
+ if (btn == null) {
+ new Label(composite, SWT.NONE);
+ }
+
+ colorCombo.setText(value);
+
+ //if css attribute contain choose_folder button
+ } else if (Util.containFolder(name)) {
+ final Combo combo = new Combo(composite, SWT.NONE);
+ combo.setLayoutData(new GridData(GridData.FILL, GridData.CENTER,
+ true, false));
+ btn = new Button(composite, SWT.NONE);
+ btn.setLayoutData(new GridData(GridData.END, GridData.CENTER,
+ false, false));
+ ImageDescriptor imageDes = JspEditorPlugin
+ .getImageDescriptor(Constants.IMAGE_FOLDER_FILE_LOCATION);
+ Image chooserImage = imageDes.createImage();
+ btn.setImage(chooserImage);
+ btn.addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent e) {
+ Button button = (Button) e.getSource();
+ button.getImage().dispose();
+ }
+ });
+ btn.setToolTipText(MessageUtil.getString("COLOR_DIALOG_TITLE"));
+ ArrayList<String> list = comboMap.get(name);
+ for (String str : list)
+ combo.add(str);
+
+ btn.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ IProject project = getCurrentProject();
+ ImageSelectionDialog dialog = new ImageSelectionDialog(
+ composite.getShell(), new WorkbenchLabelProvider(),
+ new WorkbenchContentProvider());
+ dialog
+ .setTitle(MessageUtil
+ .getString("IMAGE_DIALOG_TITLE"));
+ dialog.setMessage(MessageUtil
+ .getString("IMAGE_DIALOG_MESSAGE"));
+ dialog.setEmptyListMessage(MessageUtil
+ .getString("IMAGE_DIALOG_EMPTY_MESSAGE"));
+ dialog.setAllowMultiple(false);
+ dialog.setInput(project);
+ if (dialog.open() == ImageSelectionDialog.OK) {
+ IFile file = (IFile) dialog.getFirstResult();
+ String value = file.getFullPath().toString();
+ combo.setText(value);
+ }
+ }
+ });
+
+ combo.setText(value);
+ combo.addModifyListener(new ModifyListener() {
+
+ String key = name;
+
+ public void modifyText(ModifyEvent event) {
+ if (!combo.getText().trim().equals(Constants.EMPTY_STRING))
+ attributesMap.put(key, combo.getText().trim());
+ else
+ attributesMap.remove(key);
+
+ dialog.setStyleForPreview();
+ }
+ });
+
+ } else {
+ final Combo combo = new Combo(composite, SWT.CENTER);
+ combo.setLayoutData(new GridData(GridData.FILL, GridData.CENTER,
+ true, false));
+
+ ArrayList<String> list = comboMap.get(name);
+ for (String str : list)
+ combo.add(str);
+
+ final Combo extCombo;
+ String values[] = null;
+ boolean ext = false;
+ if (Util.searchInExtElement(name)) {
+ ext = true;
+ values = Util.convertExtString(value);
+ extCombo = new Combo(composite, SWT.BORDER | SWT.READ_ONLY);
+ extCombo.setLayoutData(new GridData(GridData.END,
+ GridData.CENTER, false, false));
+ for (int i = 0; i < Constants.extSizes.length; i++)
+ extCombo.add(Constants.extSizes[i]);
+ extCombo.select(extCombo.indexOf(values[EXT_VALUE_NUMBER]));
+
+ //TODO Evgeny Zheleznyakov remove block comment
+ /*extCombo.addSelectionListener(new SelectionAdapter() {
+
+ String key = name;
+
+ public void widgetSelected(SelectionEvent event) {
+
+ if (!attributesMap.get(key).trim().equals(
+ Constants.EMPTY_STRING)) {
+ attributesMap.put(key, combo.getText()
+ + extCombo.getText());
+ dialog.setStyleForPreview();
+ }
+ }
+ });*/
+
+ extCombo.addModifyListener(new ModifyListener() {
+
+ String key = name;
+
+ public void modifyText(ModifyEvent event) {
+ String tmpCombo = combo.getText().trim();
+ if (tmpCombo == null)
+ return;
+ if (tmpCombo.equals(Constants.EMPTY_STRING))
+ return;
+
+ String tmpExt = extCombo.getText();
+
+ if (tmpExt != null) {
+ attributesMap.put(key, tmpCombo + tmpExt);
+ dialog.setStyleForPreview();
+ }
+ }
+ });
+
+ combo.addModifyListener(new ModifyListener() {
+
+ String key = name;
+
+ public void modifyText(ModifyEvent e) {
+
+ String currentText = combo.getText();
+
+ String[] items = combo.getItems();
+
+ for (int i = 0; i < items.length; i++) {
+ if (currentText.equalsIgnoreCase(items[i])) {
+ extCombo.select(VALUE_NUMBER);
+ extCombo.setEnabled(false);
+ attributesMap.put(key, currentText);
+ dialog.setStyleForPreview();
+ return;
+ }
+ }
+ extCombo.setEnabled(true);
+
+ String tmp = combo.getText().trim();
+ if (tmp != null) {
+ if (!tmp.equals(Constants.EMPTY_STRING)) {
+ String extTmp = extCombo.getText().trim();
+ if (extTmp != null)
+ attributesMap.put(key, tmp + extTmp);
+ else
+ attributesMap.put(key, tmp);
+
+ } else
+ attributesMap.remove(key);
+ } else
+ attributesMap.remove(key);
+ dialog.setStyleForPreview();
+ }
+ });
+
+ } else {
+ new Label(composite, SWT.NONE).setLayoutData(new GridData(
+ GridData.END, GridData.CENTER, false, false));
+ combo.addModifyListener(new ModifyListener() {
+
+ String key = name;
+
+ public void modifyText(ModifyEvent event) {
+
+ if (!combo.getText().trim().equals(
+ Constants.EMPTY_STRING))
+ attributesMap.put(key, combo.getText().trim());
+ else
+ attributesMap.remove(key);
+
+ dialog.setStyleForPreview();
+ }
+ });
+ }
+
+ if (ext)
+ combo.setText(values[VALUE_NUMBER]);
+ else
+ combo.setText(value);
+ }
+ }
+
+ /**
+ * Method for creating text controls
+ *
+ * @param composite
+ * The parent composite for tab
+ * @param name
+ * Name of css element
+ * @param value
+ * Value of css element
+ */
+ private void createText(final Composite composite, final String name,
+ final String value) {
+
+ Button btn = null;
+
+ final Text text = new Text(composite, SWT.BORDER);
+ text.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true,
+ false));
+
+ if (name.equalsIgnoreCase(CSSConstants.FONT_FAMILY)) {
+ btn = new Button(composite, SWT.NONE);
+ btn.setLayoutData(new GridData(GridData.END, GridData.CENTER,
+ false, false));
+ ImageDescriptor imageDes = JspEditorPlugin
+ .getImageDescriptor(Constants.IMAGE_FONT_FILE_LOCATION);
+ Image fontImage = imageDes.createImage();
+ btn.setImage(fontImage);
+ btn.setToolTipText(MessageUtil.getString("FONT_FAMILY_TIP"));
+ btn.addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent e) {
+ Button button = (Button) e.getSource();
+ button.getImage().dispose();
+ }
+ });
+ btn.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ FontFamilyDialog dialog = new FontFamilyDialog(composite
+ .getShell(), text.getText());
+ if (dialog.open() == Window.OK) {
+ text.setText(dialog.getFontFamily());
+ }
+ }
+ });
+
+ text.addModifyListener(new ModifyListener() {
+
+ String key = name;
+
+ public void modifyText(ModifyEvent event) {
+
+ if (!text.getText().trim().equals(Constants.EMPTY_STRING))
+ attributesMap.put(key, text.getText().trim());
+ else
+ attributesMap.remove(key);
+
+ dialog.setStyleForPreview();
+ }
+ });
+ }
+
+ final Combo extCombo;
+ String values[] = null;
+ boolean ext = false;
+ if (btn == null) {
+ if (Util.searchInExtElement(name)) {
+ values = Util.convertExtString(value);
+ ext = true;
+ extCombo = new Combo(composite, SWT.BORDER | SWT.READ_ONLY);
+ extCombo.setLayoutData(new GridData(GridData.END,
+ GridData.CENTER, false, false));
+ for (int i = 0; i < Constants.extSizes.length; i++)
+ extCombo.add(Constants.extSizes[i]);
+ extCombo.select(extCombo.indexOf(values[EXT_VALUE_NUMBER]));
+
+ //TODO Evgeny Zheleznyakov remove block comment
+ /*extCombo.addSelectionListener(new SelectionAdapter() {
+
+ String key = name;
+
+ public void widgetSelected(SelectionEvent event) {
+
+ if (!attributesMap.get(key).trim().equals(
+ Constants.EMPTY_STRING)) {
+ attributesMap.put(key, text.getText()
+ + extCombo.getText());
+ dialog.setStyleForPreview();
+ }
+ }
+ });*/
+
+ extCombo.addModifyListener(new ModifyListener() {
+
+ String key = name;
+
+ public void modifyText(ModifyEvent event) {
+ String tmpCombo = text.getText().trim();
+ if (tmpCombo == null)
+ return;
+ if (tmpCombo.equals(Constants.EMPTY_STRING))
+ return;
+
+ String tmpExt = extCombo.getText();
+
+ if (tmpExt != null) {
+ attributesMap.put(key, tmpCombo + tmpExt);
+ dialog.setStyleForPreview();
+ }
+ }
+ });
+
+ text.addModifyListener(new ModifyListener() {
+
+ String key = name;
+
+ public void modifyText(ModifyEvent e) {
+
+ String tmp = text.getText().trim();
+ if (tmp != null) {
+ if (!tmp.equals(Constants.EMPTY_STRING)) {
+ String extTmp = extCombo.getText().trim();
+ if (extTmp != null)
+ attributesMap.put(key, tmp + extTmp);
+ else
+ attributesMap.put(key, tmp);
+
+ } else
+ attributesMap.remove(key);
+ } else
+ attributesMap.remove(key);
+ dialog.setStyleForPreview();
+ }
+ });
+
+ } else {
+ new Label(composite, SWT.NONE).setLayoutData(new GridData(
+ GridData.END, GridData.CENTER, false, false));
+
+ text.addModifyListener(new ModifyListener() {
+
+ String key = name;
+
+ public void modifyText(ModifyEvent event) {
+
+ if (!text.getText().trim().equals(
+ Constants.EMPTY_STRING))
+ attributesMap.put(key, text.getText().trim());
+ else
+ attributesMap.remove(key);
+
+ dialog.setStyleForPreview();
+ }
+ });
+
+ }
+ }
+
+ if (ext)
+ text.setText(values[VALUE_NUMBER]);
+ else
+ text.setText(value);
+ }
+
+ /**
+ * Method for get current project
+ *
+ * @return IProject
+ */
+ public static IProject getCurrentProject() {
+ IEditorPart editor = JspEditorPlugin.getDefault().getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ IEditorInput input = editor.getEditorInput();
+ IFile file = null;
+ if (input instanceof IFileEditorInput) {
+ file = ((IFileEditorInput) input).getFile();
+ }
+ if (file == null)
+ return null;
+
+ IProject project = file.getProject();
+ return project;
+
+ }
+
+ /**
+ * Method for format css names (text-decoration : Text Decoration)
+ *
+ * @param str
+ * CSS name
+ * @return Format ss name
+ */
+ private String format(String str) {
+
+ StringTokenizer st = new StringTokenizer(str, DASH_STRING);
+ String finalStr = Constants.EMPTY_STRING;
+
+ while (st.hasMoreTokens()) {
+ StringBuffer sb = new StringBuffer(st.nextToken());
+ String upper = sb.substring(FIRST_INDEX, SECOND_INDEX)
+ .toUpperCase();
+ sb.replace(FIRST_INDEX, SECOND_INDEX, upper);
+ finalStr += sb;
+ if (st.hasMoreTokens())
+ finalStr += SPACE_STRING;
+ else
+ finalStr += COLON_STRING;
+ }
+ return finalStr;
+ }
+}
\ No newline at end of file
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabTextControl.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabTextControl.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabTextControl.java 2008-07-16 15:19:39 UTC (rev 9155)
@@ -0,0 +1,510 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.jsp.outline.cssdialog.tabs;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.ColorDialog;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.jboss.tools.jst.jsp.JspEditorPlugin;
+import org.jboss.tools.jst.jsp.outline.cssdialog.CSSDialog;
+import org.jboss.tools.jst.jsp.outline.cssdialog.FontFamilyDialog;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.CSSConstants;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.Constants;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.ImageCombo;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.MessageUtil;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.Util;
+import org.jboss.tools.jst.jsp.outline.cssdialog.parsers.ColorParserListener;
+
+/**
+ * Class for creating Text tab controls
+ *
+ * @author dsakovich(a)exadel.com
+ *
+ */
+public class TabTextControl extends Composite {
+
+ private Text fontFamilyText;
+
+ private ImageCombo colorCombo;
+ private Combo fontSizeCombo;
+ private Combo extFontSizeCombo;
+ private Combo fontStyleCombo;
+ private Combo fontWeigthCombo;
+ private Combo textDecorationCombo;
+ private Combo textAlignCombo;
+
+ private ArrayList<String> list;
+
+ private HashMap<String, String> attributesMap;
+
+ private static final int numColumns = 3;
+
+ private CSSDialog cssDialog;
+
+ /**
+ * Constructor for creating controls
+ *
+ * @param composite
+ */
+ public TabTextControl(final Composite composite,
+ final HashMap<String, ArrayList<String>> comboMap,
+ final HashMap<String, String> attributesMap, CSSDialog dialog) {
+ super(composite, SWT.NONE);
+ this.attributesMap = attributesMap;
+ this.cssDialog = dialog;
+
+ final GridLayout gridLayout = new GridLayout();
+ gridLayout.numColumns = numColumns;
+ setLayout(gridLayout);
+
+ Label label = new Label(this, SWT.LEFT);
+ label.setText(MessageUtil.getString("FONT_FAMILY"));
+ label.setLayoutData(new GridData(GridData.END, GridData.CENTER, false,
+ false));
+
+ fontFamilyText = new Text(this, SWT.BORDER | SWT.SINGLE);
+ fontFamilyText.setLayoutData(new GridData(GridData.FILL,
+ GridData.CENTER, true, false));
+
+ fontFamilyText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent event) {
+ String tmp = fontFamilyText.getText();
+ if (tmp != null) {
+ if (tmp.trim().length() > 0)
+ attributesMap.put(CSSConstants.FONT_FAMILY, tmp);
+ else
+ attributesMap.remove(CSSConstants.FONT_FAMILY);
+ }
+ cssDialog.setStyleForPreview();
+ }
+ });
+
+ Button button = new Button(this, SWT.PUSH);
+ button.setLayoutData(new GridData(GridData.END, GridData.CENTER, false,
+ false));
+ button.setToolTipText(MessageUtil.getString("FONT_FAMILY_TIP"));
+ ImageDescriptor fontDesc = JspEditorPlugin
+ .getImageDescriptor(Constants.IMAGE_FONTLARGE_FILE_LOCATION);
+ Image fontImage = fontDesc.createImage();
+ button.setImage(fontImage);
+ button.addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent e) {
+ Button button = (Button) e.getSource();
+ button.getImage().dispose();
+ }
+ });
+ button.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ FontFamilyDialog dialog = new FontFamilyDialog(getShell(),
+ fontFamilyText.getText());
+ if (dialog.open() == Window.OK) {
+ fontFamilyText.setText(dialog.getFontFamily());
+ }
+ }
+ });
+ label = new Label(this, SWT.LEFT);
+ label.setLayoutData(new GridData(GridData.END, GridData.CENTER, false,
+ false));
+ label.setText(MessageUtil.getString("COLOR"));
+
+ colorCombo = new ImageCombo(this, SWT.BORDER);
+ colorCombo.setLayoutData(new GridData(GridData.FILL, GridData.CENTER,
+ true, false));
+
+ colorCombo.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent event) {
+ String tmp = colorCombo.getText();
+ if (tmp != null) {
+ if (tmp.trim().length() > 0)
+ attributesMap.put(CSSConstants.COLOR, tmp);
+ else
+ attributesMap.remove(CSSConstants.COLOR);
+ }
+ cssDialog.setStyleForPreview();
+ }
+ });
+
+ // ////////////////////////////////////////////////////////////////////////
+ Set<Entry<String, String>> set = ColorParserListener.getMap()
+ .entrySet();
+
+ for (Map.Entry<String, String> me : set) {
+ RGB rgb = Util.getColor(me.getKey());
+ colorCombo.add(me.getValue(), rgb);
+ }
+ // ///////////////////////////////////////////////////////////////////////
+
+ button = new Button(this, SWT.PUSH);
+ button.setLayoutData(new GridData(GridData.END, GridData.CENTER, false,
+ false));
+ button.setToolTipText(MessageUtil.getString("COLOR_TIP"));
+ ImageDescriptor colorDesc = JspEditorPlugin
+ .getImageDescriptor(Constants.IMAGE_COLORLARGE_FILE_LOCATION);
+ Image im = colorDesc.createImage();
+ button.setImage(im);
+ button.addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent e) {
+ Button button = (Button) e.getSource();
+ button.getImage().dispose();
+ }
+ });
+ button.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ ColorDialog dlg = new ColorDialog(getShell());
+
+ dlg
+ .setRGB(Util.getColor((colorCombo.getText().trim())) == null ? Constants.RGB_BLACK
+ : Util.getColor((colorCombo.getText().trim())));
+ dlg.setText(MessageUtil.getString("COLOR_DIALOG_TITLE"));
+ RGB rgb = dlg.open();
+ if (rgb != null) {
+ String colorStr = Util.createColorString(rgb);
+ colorCombo.setText(colorStr);
+ }
+ }
+ });
+
+ label = new Label(this, SWT.LEFT);
+ label.setLayoutData(new GridData(GridData.END, GridData.CENTER, false,
+ false));
+ label.setText(MessageUtil.getString("FONT_SIZE"));
+
+ fontSizeCombo = new Combo(this, SWT.BORDER | SWT.SINGLE);
+
+ final GridData fontSizeGridData = new GridData(GridData.FILL,
+ GridData.CENTER, true, false);
+ fontSizeCombo.setLayoutData(fontSizeGridData);
+
+ list = comboMap.get(CSSConstants.FONT_SIZE);
+ for (String str : list) {
+ fontSizeCombo.add(str);
+ }
+
+ extFontSizeCombo = new Combo(this, SWT.BORDER | SWT.READ_ONLY);
+
+ extFontSizeCombo.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent event) {
+ String fontSize = fontSizeCombo.getText().trim();
+ if (fontSize == null)
+ return;
+ if (fontSize.equals(Constants.EMPTY_STRING))
+ return;
+
+ String tmp = extFontSizeCombo.getText();
+
+ if (tmp != null) {
+ attributesMap.put(CSSConstants.FONT_SIZE, fontSize + tmp);
+ cssDialog.setStyleForPreview();
+ }
+ }
+ });
+
+ extFontSizeCombo.setLayoutData(new GridData(GridData.FILL,
+ GridData.CENTER, false, false));
+ for (int i = 0; i < Constants.extSizes.length; i++) {
+ extFontSizeCombo.add(Constants.extSizes[i]);
+ }
+
+ fontSizeCombo.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent e) {
+ String currentText = fontSizeCombo.getText();
+
+ list = comboMap.get(CSSConstants.FONT_SIZE);
+ for (String str : list) {
+ if (currentText.equals(str)) {
+ extFontSizeCombo.select(0);
+ extFontSizeCombo.setEnabled(false);
+ attributesMap.put(CSSConstants.FONT_SIZE, currentText);
+ cssDialog.setStyleForPreview();
+ return;
+ }
+ }
+ extFontSizeCombo.setEnabled(true);
+
+ String tmp = fontSizeCombo.getText();
+
+ if (tmp != null) {
+ if (tmp.trim().length() > 0) {
+ String extFont = extFontSizeCombo.getText().trim();
+ if (extFont != null)
+ attributesMap.put(CSSConstants.FONT_SIZE, tmp
+ + extFont);
+ else
+ attributesMap.put(CSSConstants.FONT_SIZE, tmp);
+ } else
+ attributesMap.remove(CSSConstants.FONT_SIZE);
+ } else
+ attributesMap.remove(CSSConstants.FONT_SIZE);
+ cssDialog.setStyleForPreview();
+ }
+ });
+
+ label = new Label(this, SWT.LEFT);
+ label.setLayoutData(new GridData(GridData.END, GridData.CENTER, false,
+ false));
+ label.setText(MessageUtil.getString("FONT_STYLE"));
+
+ fontStyleCombo = new Combo(this, SWT.BORDER);
+
+ fontStyleCombo.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent event) {
+ String tmp = fontStyleCombo.getText();
+ if (tmp != null) {
+ if (tmp.trim().length() > 0)
+ attributesMap.put(CSSConstants.FONT_STYLE, tmp);
+ else
+ attributesMap.remove(CSSConstants.FONT_STYLE);
+ }
+ cssDialog.setStyleForPreview();
+ }
+ });
+
+ fontStyleCombo.setLayoutData(new GridData(GridData.FILL,
+ GridData.CENTER, false, false));
+
+ list = comboMap.get(CSSConstants.FONT_STYLE);
+ for (String str : list) {
+ fontStyleCombo.add(str);
+ }
+
+ label = new Label(this, SWT.LEFT);
+ label.setLayoutData(new GridData(GridData.END, GridData.CENTER, false,
+ false));
+ label.setText(Constants.EMPTY_STRING);
+
+ label = new Label(this, SWT.LEFT);
+ label.setLayoutData(new GridData(GridData.END, GridData.CENTER, false,
+ false));
+ label.setText(MessageUtil.getString("FONT_WEIGHT"));
+
+ fontWeigthCombo = new Combo(this, SWT.BORDER);
+
+ fontWeigthCombo.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent event) {
+ String tmp = fontWeigthCombo.getText();
+ if (tmp != null) {
+ if (tmp.trim().length() > 0)
+ attributesMap.put(CSSConstants.FONT_WEIGHT, tmp);
+ else
+ attributesMap.remove(CSSConstants.FONT_WEIGHT);
+ }
+ cssDialog.setStyleForPreview();
+ }
+ });
+
+ fontWeigthCombo.setLayoutData(new GridData(GridData.FILL,
+ GridData.CENTER, false, false));
+
+ list = comboMap.get(CSSConstants.FONT_WEIGHT);
+ for (String str : list) {
+ fontWeigthCombo.add(str);
+ }
+
+ label = new Label(this, SWT.LEFT);
+ label.setLayoutData(new GridData(GridData.END, GridData.CENTER, false,
+ false));
+ label.setText(Constants.EMPTY_STRING);
+
+ label = new Label(this, SWT.LEFT);
+ label.setLayoutData(new GridData(GridData.END, GridData.CENTER, false,
+ false));
+ label.setText(MessageUtil.getString("TEXT_DECORATION"));
+
+ textDecorationCombo = new Combo(this, SWT.BORDER);
+
+ textDecorationCombo.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent event) {
+ String tmp = textDecorationCombo.getText();
+ if (tmp != null) {
+ if (tmp.trim().length() > 0)
+ attributesMap.put(CSSConstants.TEXT_DECORATION, tmp);
+ else
+ attributesMap.remove(CSSConstants.TEXT_DECORATION);
+ }
+ cssDialog.setStyleForPreview();
+ }
+ });
+
+ textDecorationCombo.setLayoutData(new GridData(GridData.FILL,
+ GridData.CENTER, false, false));
+
+ list = comboMap.get(CSSConstants.TEXT_DECORATION);
+ for (String str : list) {
+ textDecorationCombo.add(str);
+ }
+
+ label = new Label(this, SWT.LEFT);
+ label.setLayoutData(new GridData(GridData.END, GridData.CENTER, false,
+ false));
+ label.setText(Constants.EMPTY_STRING);
+
+ label = new Label(this, SWT.LEFT);
+ label.setLayoutData(new GridData(GridData.END, GridData.CENTER, false,
+ false));
+ label.setText(MessageUtil.getString("TEXT_ALIGN"));
+
+ textAlignCombo = new Combo(this, SWT.BORDER);
+
+ textAlignCombo.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent event) {
+ String tmp = textAlignCombo.getText();
+ if (tmp != null) {
+ if (tmp.trim().length() > 0)
+ attributesMap.put(CSSConstants.TEXT_ALIGN, tmp);
+ else
+ attributesMap.remove(CSSConstants.TEXT_ALIGN);
+ }
+ cssDialog.setStyleForPreview();
+ }
+ });
+
+ textAlignCombo.setLayoutData(new GridData(GridData.FILL,
+ GridData.CENTER, false, false));
+
+ list = comboMap.get(CSSConstants.TEXT_ALIGN);
+ for (String str : list) {
+ textAlignCombo.add(str);
+ }
+
+ label = new Label(this, SWT.LEFT);
+ label.setLayoutData(new GridData(GridData.END, GridData.CENTER, false,
+ false));
+ label.setText(Constants.EMPTY_STRING);
+
+ }
+
+ /**
+ * Method for get data in controls (if param equal true ), or set data (if
+ * param equal false).
+ *
+ * @param param
+ */
+ public void updateData(boolean param) {
+ String tmp;
+ //TODO Evgeny Zheleznyakov remove block comment
+ /*if (param) {
+ tmp = fontFamilyText.getText();
+ if (tmp != null) {
+ if (tmp.trim().length() > 0)
+ attributesMap.put(CSSConstants.FONT_FAMILY, tmp);
+ else
+ attributesMap.remove(CSSConstants.FONT_FAMILY);
+ }
+ tmp = colorCombo.getText();
+ if (tmp != null) {
+ if (tmp.trim().length() > 0)
+ attributesMap.put(CSSConstants.COLOR, tmp);
+ else
+ attributesMap.remove(CSSConstants.COLOR);
+ }
+ tmp = fontSizeCombo.getText();
+ if (tmp != null) {
+ if (tmp.trim().length() > 0)
+ attributesMap
+ .put(
+ CSSConstants.FONT_SIZE,
+ tmp
+ + (extFontSizeCombo.getText() == null ? Constants.EMPTY_STRING
+ : extFontSizeCombo
+ .getText()));
+ else
+ attributesMap.remove(CSSConstants.FONT_SIZE);
+ }
+ tmp = textDecorationCombo.getText();
+ if (tmp != null) {
+ if (tmp.trim().length() > 0)
+ attributesMap.put(CSSConstants.TEXT_DECORATION, tmp);
+ else
+ attributesMap.remove(CSSConstants.TEXT_DECORATION);
+ }
+ tmp = fontStyleCombo.getText();
+ if (tmp != null) {
+ if (tmp.trim().length() > 0)
+ attributesMap.put(CSSConstants.FONT_STYLE, tmp);
+ else
+ attributesMap.remove(CSSConstants.FONT_STYLE);
+ }
+ tmp = fontWeigthCombo.getText();
+ if (tmp != null) {
+ if (tmp.trim().length() > 0)
+ attributesMap.put(CSSConstants.FONT_WEIGHT, tmp);
+ else
+ attributesMap.remove(CSSConstants.FONT_WEIGHT);
+ }
+ tmp = textAlignCombo.getText();
+ if (tmp != null) {
+ if (tmp.trim().length() > 0)
+ attributesMap.put(CSSConstants.TEXT_ALIGN, tmp);
+ else
+ attributesMap.remove(CSSConstants.TEXT_ALIGN);
+ }
+ } else {*/
+ if ((tmp = attributesMap.get(CSSConstants.FONT_FAMILY)) != null)
+ fontFamilyText.setText(tmp);
+ else
+ fontFamilyText.setText(Constants.EMPTY_STRING);
+ if ((tmp = attributesMap.get(CSSConstants.COLOR)) != null)
+ colorCombo.setText(tmp);
+ else
+ colorCombo.setText(Constants.EMPTY_STRING);
+ if ((tmp = attributesMap.get(CSSConstants.FONT_SIZE)) != null) {
+ String[] str = Util.convertExtString(tmp);
+ fontSizeCombo.setText(str[0]);
+ if (extFontSizeCombo.indexOf(str[1]) != -1) {
+ extFontSizeCombo.setText(str[1]);
+ extFontSizeCombo.select(extFontSizeCombo.indexOf(str[1]));
+ } else
+ extFontSizeCombo.select(0);
+ } else {
+ fontSizeCombo.setText(Constants.EMPTY_STRING);
+ extFontSizeCombo.select(0);
+ }
+ if ((tmp = attributesMap.get(CSSConstants.TEXT_DECORATION)) != null)
+ textDecorationCombo.setText(tmp);
+ else
+ textDecorationCombo.setText(Constants.EMPTY_STRING);
+ if ((tmp = attributesMap.get(CSSConstants.FONT_STYLE)) != null)
+ fontStyleCombo.setText(tmp);
+ else
+ fontStyleCombo.setText(Constants.EMPTY_STRING);
+ if ((tmp = attributesMap.get(CSSConstants.FONT_WEIGHT)) != null)
+ fontWeigthCombo.setText(tmp);
+ else
+ fontWeigthCombo.setText(Constants.EMPTY_STRING);
+ if ((tmp = attributesMap.get(CSSConstants.TEXT_ALIGN)) != null)
+ textAlignCombo.setText(tmp);
+ else
+ textAlignCombo.setText(Constants.EMPTY_STRING);
+ }
+}
\ No newline at end of file
16 years, 6 months
JBoss Tools SVN: r9154 - trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/test.
by jbosstools-commits@lists.jboss.org
Author: estherbin
Date: 2008-07-16 09:59:16 -0400 (Wed, 16 Jul 2008)
New Revision: 9154
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/test/ElPreferencesTestCase.java
Log:
Make simple el substitution for the https://jira.jboss.com:8443/jira/browse/JBIDE-2010
Modified: trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/test/ElPreferencesTestCase.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/test/ElPreferencesTestCase.java 2008-07-16 13:52:09 UTC (rev 9153)
+++ trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/test/ElPreferencesTestCase.java 2008-07-16 13:59:16 UTC (rev 9154)
@@ -78,8 +78,8 @@
int i = 0;
for (Entry<String, String> string : elValuesMap.entrySet()) {
- entries[i] = new ResourceReference(string.getValue(), ResourceReference.PROJECT_SCOPE);
- entries[i].setProperties(string.getKey());
+ entries[i] = new ResourceReference(string.getKey(), ResourceReference.PROJECT_SCOPE);
+ entries[i].setProperties(string.getValue());
i++;
setValues(entries);
16 years, 6 months
JBoss Tools SVN: r9153 - trunk/seam/plugins/org.jboss.tools.seam.core.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2008-07-16 09:52:09 -0400 (Wed, 16 Jul 2008)
New Revision: 9153
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/plugin.xml
Log:
https://jira.jboss.com/jira/browse/JBIDE-2523 Fixed
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/plugin.xml
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/plugin.xml 2008-07-16 13:46:01 UTC (rev 9152)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/plugin.xml 2008-07-16 13:52:09 UTC (rev 9153)
@@ -179,7 +179,7 @@
<facet id="jst.java" version="5.0" />
<facet id="jst.web" version="2.5"/>
<facet id="jst.jsf" version="1.2" />
- <facet id="jst.seam" version="2.0" />
+ <facet id="jst.seam" version="1.2" />
<description>
Configures a Dynamic Web application to use Seam v1.2
</description>
16 years, 6 months
JBoss Tools SVN: r9152 - in trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor: template and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: estherbin
Date: 2008-07-16 09:46:01 -0400 (Wed, 16 Jul 2008)
New Revision: 9152
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/IVpeTemplateAdvice.java
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpePreviewDomBuilder.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplate.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElService.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/IELService.java
Log:
Make simple el substitution for the https://jira.jboss.com:8443/jira/browse/JBIDE-2010
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpePreviewDomBuilder.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpePreviewDomBuilder.java 2008-07-16 13:45:45 UTC (rev 9151)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpePreviewDomBuilder.java 2008-07-16 13:46:01 UTC (rev 9152)
@@ -79,7 +79,13 @@
//FIX FOR JBIDE-1568, added by Max Areshkau
try {
- creationData = template.create(getPageContext(), sourceNode, getVisualDocument());
+ if (template.getClass().getName().contains("Rich") || template.getClass().getName().contains("Jsf")) {
+ final Element sourceNodeClone = (Element) ((Element) sourceNode).cloneNode(true);
+ template.beforeTemplateCreated(getPageContext(), sourceNodeClone, getVisualDocument());
+ creationData = template.create(getPageContext(), sourceNodeClone, getVisualDocument());
+ } else {
+ creationData = template.create(getPageContext(), sourceNode, getVisualDocument());
+ }
}catch (XPCOMException ex) {
VpePlugin.getPluginLog().logError(ex);
VpeTemplate defTemplate = templateManager.getDefTemplate();
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2008-07-16 13:45:45 UTC (rev 9151)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2008-07-16 13:46:01 UTC (rev 9152)
@@ -93,12 +93,12 @@
public class VpeVisualDomBuilder extends VpeDomBuilder {
- public static final String VPE_USER_TOGGLE_ID = "vpe-user-toggle-id"; //$NON-NLS-1$
- public static final String VPE_USER_TOGGLE_LOOKUP_PARENT = "vpe-user-toggle-lookup-parent"; //$NON-NLS-1$
+ public static final String VPE_USER_TOGGLE_ID = "vpe-user-toggle-id"; //$NON-NLS-1$
+ public static final String VPE_USER_TOGGLE_LOOKUP_PARENT = "vpe-user-toggle-lookup-parent"; //$NON-NLS-1$
- /** REGEX_EL */
+ /** REGEX_EL */
private static final Pattern REGEX_EL = Pattern.compile(
- "[\\$|\\#]\\{.*\\}", Pattern.MULTILINE + Pattern.DOTALL); //$NON-NLS-1$
+ "[\\$|\\#]\\{.*\\}", Pattern.MULTILINE + Pattern.DOTALL); //$NON-NLS-1$
private static final String PSEUDO_ELEMENT = "br"; //$NON-NLS-1$
private static final String PSEUDO_ELEMENT_ATTR = "vpe:pseudo-element"; //$NON-NLS-1$
@@ -111,7 +111,7 @@
private static final int DRAG_AREA_WIDTH = 10;
private static final int DRAG_AREA_HEIGHT = 10;
private static final String ATTR_DRAG_AVAILABLE_CLASS = "__drag__available_style"; //$NON-NLS-1$
- private static String DOTTED_BORDER = "border: 1px dotted #FF6600; padding: 5px;"; //$NON-NLS-1$
+ private static String DOTTED_BORDER = "border: 1px dotted #FF6600; padding: 5px;"; //$NON-NLS-1$
private MozillaEditor visualEditor;
private XulRunnerEditor xulRunnerEditor;
@@ -149,101 +149,101 @@
static private HashSet<String> unborderedSourceNodes = new HashSet<String>();
static {
- unborderedSourceNodes.add(HTML.TAG_HTML);
- unborderedSourceNodes.add(HTML.TAG_HEAD);
- unborderedSourceNodes.add(HTML.TAG_BODY);
+ unborderedSourceNodes.add(HTML.TAG_HTML);
+ unborderedSourceNodes.add(HTML.TAG_HEAD);
+ unborderedSourceNodes.add(HTML.TAG_BODY);
}
static private HashSet<String> unborderedVisualNodes = new HashSet<String>();
static {
- unborderedVisualNodes.add(HTML.TAG_TBODY);
- unborderedVisualNodes.add(HTML.TAG_THEAD);
- unborderedVisualNodes.add(HTML.TAG_TR);
- unborderedVisualNodes.add(HTML.TAG_TD);
- unborderedVisualNodes.add(HTML.TAG_COL);
- unborderedVisualNodes.add(HTML.TAG_COLS);
- unborderedVisualNodes.add(HTML.TAG_COLGROUP);
- unborderedVisualNodes.add(HTML.TAG_LI);
- unborderedVisualNodes.add(HTML.TAG_BR);
+ unborderedVisualNodes.add(HTML.TAG_TBODY);
+ unborderedVisualNodes.add(HTML.TAG_THEAD);
+ unborderedVisualNodes.add(HTML.TAG_TR);
+ unborderedVisualNodes.add(HTML.TAG_TD);
+ unborderedVisualNodes.add(HTML.TAG_COL);
+ unborderedVisualNodes.add(HTML.TAG_COLS);
+ unborderedVisualNodes.add(HTML.TAG_COLGROUP);
+ unborderedVisualNodes.add(HTML.TAG_LI);
+ unborderedVisualNodes.add(HTML.TAG_BR);
}
private VpeDnd dropper;
private Map<IFile, Document> includeDocuments = new HashMap<IFile, Document>();
public VpeVisualDomBuilder(VpeDomMapping domMapping,
- INodeAdapter sorceAdapter, VpeTemplateManager templateManager,
- MozillaEditor visualEditor, VpePageContext pageContext) {
- super(domMapping, sorceAdapter, templateManager);
- this.visualEditor = visualEditor;
- xulRunnerEditor = visualEditor.getXulRunnerEditor();
- this.visualDocument = visualEditor.getDomDocument();
-// this.visualContentArea = visualEditor.getContentArea();
- this.dnd = new VpeDnD();
- this.pageContext = pageContext;
-// this.headNode = visualEditor.getHeadNode();
- dropper = new VpeDnd();
- dropper.setDndData(false, true);
+ INodeAdapter sorceAdapter, VpeTemplateManager templateManager,
+ MozillaEditor visualEditor, VpePageContext pageContext) {
+ super(domMapping, sorceAdapter, templateManager);
+ this.visualEditor = visualEditor;
+ xulRunnerEditor = visualEditor.getXulRunnerEditor();
+ this.visualDocument = visualEditor.getDomDocument();
+// this.visualContentArea = visualEditor.getContentArea();
+ this.dnd = new VpeDnD();
+ this.pageContext = pageContext;
+// this.headNode = visualEditor.getHeadNode();
+ dropper = new VpeDnd();
+ dropper.setDndData(false, true);
- if (isFacelet()) {
- faceletFile = true;
- } else {
- faceletFile = false;
- }
+ if (isFacelet()) {
+ faceletFile = true;
+ } else {
+ faceletFile = false;
+ }
}
public void buildDom(Document sourceDocument) {
- VpeSourceDomBuilder sourceBuilder = pageContext.getSourceBuilder();
- IDocument document = sourceBuilder.getStructuredTextViewer()
- .getDocument();
- if (document == null)
- return;
- includeStack = new ArrayList();
- IEditorInput input = pageContext.getEditPart().getEditorInput();
- if (input instanceof IFileEditorInput) {
- IFile file = ((IFileEditorInput) input).getFile();
- if (file != null) {
- includeStack.add(new VpeIncludeInfo(null, file, pageContext
- .getSourceBuilder().getSourceDocument()));
- }
- }
- pageContext.refreshConnector();
- pageContext.installIncludeElements();
- if (isFacelet()) {
- Element root = FaceletUtil.getRootFaceletElement(sourceDocument);
- if (root != null) {
- addNode(root, null, getContentArea());
- }
- } else {
- addChildren(null, sourceDocument, getContentArea());
- }
- /*
- * Fixes http://jira.jboss.com/jira/browse/JBIDE-2126.
- * To provide appropriate context menu functionality
- * visual content area should be mapped in any case.
- */
- registerNodes(new VpeNodeMapping(sourceDocument, getContentArea()));
- }
+ VpeSourceDomBuilder sourceBuilder = pageContext.getSourceBuilder();
+ IDocument document = sourceBuilder.getStructuredTextViewer()
+ .getDocument();
+ if (document == null)
+ return;
+ includeStack = new ArrayList();
+ IEditorInput input = pageContext.getEditPart().getEditorInput();
+ if (input instanceof IFileEditorInput) {
+ IFile file = ((IFileEditorInput) input).getFile();
+ if (file != null) {
+ includeStack.add(new VpeIncludeInfo(null, file, pageContext
+ .getSourceBuilder().getSourceDocument()));
+ }
+ }
+ pageContext.refreshConnector();
+ pageContext.installIncludeElements();
+ if (isFacelet()) {
+ Element root = FaceletUtil.getRootFaceletElement(sourceDocument);
+ if (root != null) {
+ addNode(root, null, getContentArea());
+ }
+ } else {
+ addChildren(null, sourceDocument, getContentArea());
+ }
+ /*
+ * Fixes http://jira.jboss.com/jira/browse/JBIDE-2126.
+ * To provide appropriate context menu functionality
+ * visual content area should be mapped in any case.
+ */
+ registerNodes(new VpeNodeMapping(sourceDocument, getContentArea()));
+ }
public void rebuildDom(Document sourceDocument) {
- // clearIncludeDocuments();
- cleanHead();
- domMapping.clear(getContentArea());
- super.dispose();
+ // clearIncludeDocuments();
+ cleanHead();
+ domMapping.clear(getContentArea());
+ super.dispose();
- pageContext.clearAll();
- refreshExternalLinks();
- pageContext.getBundle().refreshRegisteredBundles();
+ pageContext.clearAll();
+ refreshExternalLinks();
+ pageContext.getBundle().refreshRegisteredBundles();
- nsIDOMNodeList children = getContentArea().getChildNodes();
- long len = children.getLength();
- for (long i = len - 1; i >= 0; i--) {
- getContentArea().removeChild(children.item(i));
- }
+ nsIDOMNodeList children = getContentArea().getChildNodes();
+ long len = children.getLength();
+ for (long i = len - 1; i >= 0; i--) {
+ getContentArea().removeChild(children.item(i));
+ }
- if (sourceDocument != null) {
- buildDom(sourceDocument);
- }
+ if (sourceDocument != null) {
+ buildDom(sourceDocument);
+ }
}
@@ -251,726 +251,753 @@
// private boolean borderVisible = true;
private boolean addNode(Node sourceNode, nsIDOMNode visualNextNode,
- nsIDOMNode visualContainer) {
-
- nsIDOMNode visualNewNode = createNode(sourceNode, visualContainer);
-
- // Fix for JBIDE-1097
- try {
- if (visualNewNode != null) {
- nsIDOMHTMLInputElement iDOMInputElement = (nsIDOMHTMLInputElement) visualNewNode
- .queryInterface(nsIDOMHTMLInputElement.NS_IDOMHTMLINPUTELEMENT_IID);
- iDOMInputElement.setReadOnly(true);
- }
- } catch (XPCOMException ex) {
- // just ignore this exception
- }
- if (visualNewNode != null) {
- if (visualNextNode == null) {
- visualContainer.appendChild(visualNewNode);
- } else {
- visualContainer.insertBefore(visualNewNode, visualNextNode);
- }
- return true;
- }
+ nsIDOMNode visualContainer) {
+
+ nsIDOMNode visualNewNode = createNode(sourceNode, visualContainer);
+
+ // Fix for JBIDE-1097
+ try {
+ if (visualNewNode != null) {
+ nsIDOMHTMLInputElement iDOMInputElement = (nsIDOMHTMLInputElement) visualNewNode
+ .queryInterface(nsIDOMHTMLInputElement.NS_IDOMHTMLINPUTELEMENT_IID);
+ iDOMInputElement.setReadOnly(true);
+ }
+ } catch (XPCOMException ex) {
+ // just ignore this exception
+ }
+ if (visualNewNode != null) {
+ if (visualNextNode == null) {
+ visualContainer.appendChild(visualNewNode);
+ } else {
+ visualContainer.insertBefore(visualNewNode, visualNextNode);
+ }
+ return true;
+ }
- return false;
+ return false;
}
private nsIDOMElement createBorder(Node sourceNode,
- nsIDOMElement visualNode, boolean block) {
- nsIDOMElement border = null;
- if (visualNode == null)
- return null;
- if (unborderedSourceNodes.contains(sourceNode.getNodeName()
- .toLowerCase()))
- return null;
- if (unborderedVisualNodes.contains(visualNode.getNodeName()
- .toLowerCase()))
- return null;
- if (HTML.TAG_IMG.equalsIgnoreCase(visualNode.getNodeName())) {
- String width = visualNode.getAttribute(ATRIBUTE_BORDER);
- if (width == null || ZERO_STRING.equalsIgnoreCase(width)
- || EMPTY_STRING.equalsIgnoreCase(width)) {
- String style = visualNode
- .getAttribute(VpeStyleUtil.ATTRIBUTE_STYLE);
- style = VpeStyleUtil.setParameterInStyle(style,
- ATRIBUTE_BORDER, DOTTED_BORDER_STYLE_FOR_IMG);
- visualNode.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE, style);
- }
- return null;
- }
- if (block) {
- if (YES_STRING.equals(VpePreference.USE_DETAIL_BORDER.getValue())) {
- border = visualDocument.createElement(HTML.TAG_TABLE);
- border.setAttribute(ATRIBUTE_CELLSPACING, ZERO_STRING);
- border.setAttribute(ATRIBUTE_CELLPADDING, ZERO_STRING);
+ nsIDOMElement visualNode, boolean block) {
+ nsIDOMElement border = null;
+ if (visualNode == null)
+ return null;
+ if (unborderedSourceNodes.contains(sourceNode.getNodeName()
+ .toLowerCase()))
+ return null;
+ if (unborderedVisualNodes.contains(visualNode.getNodeName()
+ .toLowerCase()))
+ return null;
+ if (HTML.TAG_IMG.equalsIgnoreCase(visualNode.getNodeName())) {
+ String width = visualNode.getAttribute(ATRIBUTE_BORDER);
+ if (width == null || ZERO_STRING.equalsIgnoreCase(width)
+ || EMPTY_STRING.equalsIgnoreCase(width)) {
+ String style = visualNode
+ .getAttribute(VpeStyleUtil.ATTRIBUTE_STYLE);
+ style = VpeStyleUtil.setParameterInStyle(style,
+ ATRIBUTE_BORDER, DOTTED_BORDER_STYLE_FOR_IMG);
+ visualNode.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE, style);
+ }
+ return null;
+ }
+ if (block) {
+ if (YES_STRING.equals(VpePreference.USE_DETAIL_BORDER.getValue())) {
+ border = visualDocument.createElement(HTML.TAG_TABLE);
+ border.setAttribute(ATRIBUTE_CELLSPACING, ZERO_STRING);
+ border.setAttribute(ATRIBUTE_CELLPADDING, ZERO_STRING);
- nsIDOMElement tr1 = visualDocument.createElement(HTML.TAG_TR);
- border.appendChild(tr1);
- nsIDOMElement td1 = visualDocument.createElement(HTML.TAG_TD);
- td1.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE,
- DOTTED_BORDER_STYLE_FOR_TD);
- nsIDOMText text = visualDocument.createTextNode(sourceNode
- .getNodeName());
- td1.appendChild(text);
- tr1.appendChild(td1);
- nsIDOMElement tr2 = visualDocument.createElement(HTML.TAG_TR);
- border.appendChild(tr2);
- nsIDOMElement td2 = visualDocument.createElement(HTML.TAG_TD);
- tr2.appendChild(td2);
- nsIDOMElement p = visualDocument.createElement(HTML.TAG_P);
- p.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE,
- DOTTED_BORDER_STYLE);
- td2.appendChild(p);
+ nsIDOMElement tr1 = visualDocument.createElement(HTML.TAG_TR);
+ border.appendChild(tr1);
+ nsIDOMElement td1 = visualDocument.createElement(HTML.TAG_TD);
+ td1.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE,
+ DOTTED_BORDER_STYLE_FOR_TD);
+ nsIDOMText text = visualDocument.createTextNode(sourceNode
+ .getNodeName());
+ td1.appendChild(text);
+ tr1.appendChild(td1);
+ nsIDOMElement tr2 = visualDocument.createElement(HTML.TAG_TR);
+ border.appendChild(tr2);
+ nsIDOMElement td2 = visualDocument.createElement(HTML.TAG_TD);
+ tr2.appendChild(td2);
+ nsIDOMElement p = visualDocument.createElement(HTML.TAG_P);
+ p.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE,
+ DOTTED_BORDER_STYLE);
+ td2.appendChild(p);
- p.appendChild(visualNode);
+ p.appendChild(visualNode);
- } else {
- border = visualDocument.createElement(HTML.TAG_TABLE);
- border.setAttribute(ATRIBUTE_CELLSPACING, ZERO_STRING);
- border.setAttribute(ATRIBUTE_CELLPADDING, ZERO_STRING);
+ } else {
+ border = visualDocument.createElement(HTML.TAG_TABLE);
+ border.setAttribute(ATRIBUTE_CELLSPACING, ZERO_STRING);
+ border.setAttribute(ATRIBUTE_CELLPADDING, ZERO_STRING);
- nsIDOMElement tr2 = visualDocument.createElement(HTML.TAG_TR);
- border.appendChild(tr2);
- nsIDOMElement td2 = visualDocument.createElement(HTML.TAG_TD);
- tr2.appendChild(td2);
- nsIDOMElement p = visualDocument.createElement(HTML.TAG_P);
- p.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE,
- DOTTED_BORDER_STYLE);
- td2.appendChild(p);
+ nsIDOMElement tr2 = visualDocument.createElement(HTML.TAG_TR);
+ border.appendChild(tr2);
+ nsIDOMElement td2 = visualDocument.createElement(HTML.TAG_TD);
+ tr2.appendChild(td2);
+ nsIDOMElement p = visualDocument.createElement(HTML.TAG_P);
+ p.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE,
+ DOTTED_BORDER_STYLE);
+ td2.appendChild(p);
- p.appendChild(visualNode);
- }
- } else {
- border = visualDocument.createElement(HTML.TAG_SPAN);
- border.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE,
- DOTTED_BORDER_STYLE);
- if (YES_STRING.equals(VpePreference.USE_DETAIL_BORDER.getValue())) {
- nsIDOMElement name = visualDocument
- .createElement(HTML.TAG_SPAN);
- name.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE,
- DOTTED_BORDER_STYLE_FOR_SPAN);
- nsIDOMText text = visualDocument.createTextNode(sourceNode
- .getNodeName());
- name.appendChild(text);
- border.appendChild(name);
- }
- border.appendChild(visualNode);
- }
- if (VpeStyleUtil.getAbsolute((Element) sourceNode) && border != null) {
- int top = VpeStyleUtil.getSizeFromStyle((Element) sourceNode,
- VpeStyleUtil.ATTRIBUTE_STYLE + VpeStyleUtil.DOT_STRING
- + VpeStyleUtil.PARAMETER_TOP);
- int left = VpeStyleUtil.getSizeFromStyle((Element) sourceNode,
- VpeStyleUtil.ATTRIBUTE_STYLE + VpeStyleUtil.DOT_STRING
- + VpeStyleUtil.PARAMETER_LEFT);
+ p.appendChild(visualNode);
+ }
+ } else {
+ border = visualDocument.createElement(HTML.TAG_SPAN);
+ border.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE,
+ DOTTED_BORDER_STYLE);
+ if (YES_STRING.equals(VpePreference.USE_DETAIL_BORDER.getValue())) {
+ nsIDOMElement name = visualDocument
+ .createElement(HTML.TAG_SPAN);
+ name.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE,
+ DOTTED_BORDER_STYLE_FOR_SPAN);
+ nsIDOMText text = visualDocument.createTextNode(sourceNode
+ .getNodeName());
+ name.appendChild(text);
+ border.appendChild(name);
+ }
+ border.appendChild(visualNode);
+ }
+ if (VpeStyleUtil.getAbsolute((Element) sourceNode) && border != null) {
+ int top = VpeStyleUtil.getSizeFromStyle((Element) sourceNode,
+ VpeStyleUtil.ATTRIBUTE_STYLE + VpeStyleUtil.DOT_STRING
+ + VpeStyleUtil.PARAMETER_TOP);
+ int left = VpeStyleUtil.getSizeFromStyle((Element) sourceNode,
+ VpeStyleUtil.ATTRIBUTE_STYLE + VpeStyleUtil.DOT_STRING
+ + VpeStyleUtil.PARAMETER_LEFT);
- String style = visualNode
- .getAttribute(VpeStyleUtil.ATTRIBUTE_STYLE);
- style = VpeStyleUtil.deleteFromString(style,
- VpeStyleUtil.PARAMETER_POSITION,
- VpeStyleUtil.SEMICOLON_STRING);
- style = VpeStyleUtil.deleteFromString(style,
- VpeStyleUtil.PARAMETER_TOP, VpeStyleUtil.SEMICOLON_STRING);
- style = VpeStyleUtil.deleteFromString(style,
- VpeStyleUtil.PARAMETER_LEFT, VpeStyleUtil.SEMICOLON_STRING);
- visualNode.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE, style);
+ String style = visualNode
+ .getAttribute(VpeStyleUtil.ATTRIBUTE_STYLE);
+ style = VpeStyleUtil.deleteFromString(style,
+ VpeStyleUtil.PARAMETER_POSITION,
+ VpeStyleUtil.SEMICOLON_STRING);
+ style = VpeStyleUtil.deleteFromString(style,
+ VpeStyleUtil.PARAMETER_TOP, VpeStyleUtil.SEMICOLON_STRING);
+ style = VpeStyleUtil.deleteFromString(style,
+ VpeStyleUtil.PARAMETER_LEFT, VpeStyleUtil.SEMICOLON_STRING);
+ visualNode.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE, style);
- style = border.getAttribute(VpeStyleUtil.ATTRIBUTE_STYLE);
- style = VpeStyleUtil.setAbsolute(style);
- if (top != -1)
- style = VpeStyleUtil.setSizeInStyle(style,
- VpeStyleUtil.PARAMETER_TOP, top);
- if (left != -1)
- style = VpeStyleUtil.setSizeInStyle(style,
- VpeStyleUtil.PARAMETER_LEFT, left);
- border.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE, style);
- }
- return border;
+ style = border.getAttribute(VpeStyleUtil.ATTRIBUTE_STYLE);
+ style = VpeStyleUtil.setAbsolute(style);
+ if (top != -1)
+ style = VpeStyleUtil.setSizeInStyle(style,
+ VpeStyleUtil.PARAMETER_TOP, top);
+ if (left != -1)
+ style = VpeStyleUtil.setSizeInStyle(style,
+ VpeStyleUtil.PARAMETER_LEFT, left);
+ border.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE, style);
}
+ return border;
+ }
protected nsIDOMNode createNode(Node sourceNode,
- nsIDOMNode visualOldContainer) {
- boolean registerFlag = isCurrentMainDocument();
-
- //reads and dispatch events
- //JBIDE-675, checks if editor was disposed or not
- if(getPageContext().getSourceBuilder()==null ||includeDocuments==null) {
-
- throw new VpeDisposeException();
+ nsIDOMNode visualOldContainer) {
+ boolean registerFlag = isCurrentMainDocument();
+
+ //reads and dispatch events
+ //JBIDE-675, checks if editor was disposed or not
+ if(getPageContext().getSourceBuilder()==null ||includeDocuments==null) {
+
+ throw new VpeDisposeException();
}
- getPageContext().processDisplayEvents();
-
- //check source node can be changed and link can be a null in this case
- //we shouldn't process this node
- if(sourceNode==null) {
- return null;
- }
-
-
- switch (sourceNode.getNodeType()) {
- case Node.ELEMENT_NODE:
- // Map<?, ?> xmlnsMap = createXmlns((Element) sourceNode);
- Set<Node> ifDependencySet = new HashSet<Node>();
- pageContext.setCurrentVisualNode(visualOldContainer);
- VpeTemplate template = templateManager.getTemplate(pageContext,
- (Element) sourceNode, ifDependencySet);
+ getPageContext().processDisplayEvents();
+
+ //check source node can be changed and link can be a null in this case
+ //we shouldn't process this node
+ if(sourceNode==null) {
+ return null;
+ }
+
+
+ switch (sourceNode.getNodeType()) {
+ case Node.ELEMENT_NODE:
+ // Map<?, ?> xmlnsMap = createXmlns((Element) sourceNode);
+ Set<Node> ifDependencySet = new HashSet<Node>();
+ pageContext.setCurrentVisualNode(visualOldContainer);
+ VpeTemplate template = templateManager.getTemplate(pageContext,
+ (Element) sourceNode, ifDependencySet);
- VpeCreationData creationData = null;
- // FIX FOR JBIDE-1568, added by Max Areshkau
- try {
-// if(getPageContext().isCreationDataExistInCash(sourceNode)) {
-
-// creationData = getPageContext().getVpeCreationDataFromCash(sourceNode).createHashCopy();
-// } else {
- creationData = template.create(getPageContext(), sourceNode,
- getVisualDocument());
-// if(creationData.getNode()!=null) {
-//
-// getPageContext().addCreationDataToCash(sourceNode, creationData.createHashCopy());
-//
-// }
-// }
- } catch (XPCOMException ex) {
- VpePlugin.getPluginLog().logError(ex);
- VpeTemplate defTemplate = templateManager.getDefTemplate();
- creationData = defTemplate.create(getPageContext(), sourceNode,
- getVisualDocument());
- }
-
- pageContext.setCurrentVisualNode(null);
- nsIDOMElement visualNewElement = null;
+ VpeCreationData creationData = null;
+ // FIX FOR JBIDE-1568, added by Max Areshkau
+ try {
+// if(getPageContext().isCreationDataExistInCash(sourceNode)) {
+
+// creationData = getPageContext().getVpeCreationDataFromCash(sourceNode).createHashCopy();
+// } else {
+
+// VpeCreationData
+// Map<String, String> oldAttributes = new HashMap<String, String>();
+// NamedNodeMap map = sourceNode.getAttributes();
+// for( int i = 0 ; i < map.getLength() ; i ++ ){
+// final Attr attr = (Attr) map.item(i);
+//
+// oldAttributes.put(attr.getName(),attr.getValue());
+// System.err.println(MessageFormat.format("name={0},value={1}", attr.getName(),attr.getValue()));
+//
+// }
- if(creationData.getNode()!=null) {
-
- visualNewElement = (nsIDOMElement) creationData
- .getNode().queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- }
-
- if ((visualNewElement != null) && template.hasImaginaryBorder()) {
+ if (template.getClass().getName().contains("Rich") || template.getClass().getName().contains("Jsf")) {
+ final Element sourceNodeClone = (Element) ((Element) sourceNode).cloneNode(true);
+ template.beforeTemplateCreated(getPageContext(), sourceNodeClone, getVisualDocument());
+ creationData = template.create(getPageContext(), sourceNodeClone, getVisualDocument());
+ }else{
+ creationData = template.create(getPageContext(), sourceNode, getVisualDocument());
+ }
+
+
+//
+// map = sourceNode.getAttributes();
+// for( int i = 0 ; i < map.getLength() ; i ++ ){
+// final Attr attr = (Attr) map.item(i);
+//
+// attr.setValue(oldAttributes.get(attr.getName()));
+// }
+
+// if(creationData.getNode()!=null) {
+//
+// getPageContext().addCreationDataToCash(sourceNode, creationData.createHashCopy());
+//
+// }
+// }
+ } catch (XPCOMException ex) {
+ VpePlugin.getPluginLog().logError(ex);
+ VpeTemplate defTemplate = templateManager.getDefTemplate();
+ creationData = defTemplate.create(getPageContext(), sourceNode,
+ getVisualDocument());
+ }
+
+ pageContext.setCurrentVisualNode(null);
+ nsIDOMElement visualNewElement = null;
- visualNewElement.setAttribute(HTML.ATTR_STYLE, visualNewElement
- .getAttribute(HTML.ATTR_STYLE)
- + VpeStyleUtil.SEMICOLON_STRING + DOTTED_BORDER);
+ if(creationData.getNode()!=null) {
+
+ visualNewElement = (nsIDOMElement) creationData
+ .getNode().queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+ }
+
+ if ((visualNewElement != null) && template.hasImaginaryBorder()) {
- }
-
- if (visualNewElement != null)
- correctVisualAttribute(visualNewElement);
-
+ visualNewElement.setAttribute(HTML.ATTR_STYLE, visualNewElement
+ .getAttribute(HTML.ATTR_STYLE)
+ + VpeStyleUtil.SEMICOLON_STRING + DOTTED_BORDER);
+ }
+
+ if (visualNewElement != null)
+ correctVisualAttribute(visualNewElement);
+
- nsIDOMElement border = null;
- setTooltip((Element) sourceNode, visualNewElement);
- if (YES_STRING.equals(VpePreference.SHOW_BORDER_FOR_ALL_TAGS
- .getValue())
- && visualNewElement != null) {
- boolean block = true;
- if (template.getTagDescription(null, null, null,
- visualNewElement, null).getDisplayType() == VpeTagDescription.DISPLAY_TYPE_INLINE) {
- block = false;
- }
- border = createBorder(sourceNode, visualNewElement, block);
- }
- if (!isCurrentMainDocument() && visualNewElement != null) {
- setReadOnlyElement(visualNewElement);
- }
- if (registerFlag) {
- VpeElementMapping elementMapping = new VpeElementMapping(
- (Element) sourceNode, visualNewElement, border,
- template, ifDependencySet, creationData.getData(),
- creationData.getElementData());
- // elementMapping.setXmlnsMap(xmlnsMap);
- registerNodes(elementMapping);
- }
- if (template.isChildren()) {
- List<?> childrenInfoList = creationData.getChildrenInfoList();
- if (childrenInfoList == null) {
- addChildren(template, sourceNode,
- visualNewElement != null ? visualNewElement
- : visualOldContainer);
- } else {
- addChildren(template, sourceNode, visualOldContainer,
- childrenInfoList);
- }
- }
- pageContext.setCurrentVisualNode(visualOldContainer);
- template.validate(pageContext, (Element) sourceNode,
- visualDocument, creationData);
- pageContext.setCurrentVisualNode(null);
- if (border != null)
- return border;
- else
- return visualNewElement;
- case Node.TEXT_NODE:
- return createTextNode(sourceNode, registerFlag);
- case Node.COMMENT_NODE:
- if (!YES_STRING.equals(VpePreference.SHOW_COMMENTS.getValue())) {
- return null;
- }
- nsIDOMElement visualNewComment = createComment(sourceNode);
- if (registerFlag) {
- registerNodes(new VpeNodeMapping(sourceNode, visualNewComment));
- }
- return visualNewComment;
- }
- return null;
+
+ nsIDOMElement border = null;
+ setTooltip((Element) sourceNode, visualNewElement);
+ if (YES_STRING.equals(VpePreference.SHOW_BORDER_FOR_ALL_TAGS
+ .getValue())
+ && visualNewElement != null) {
+ boolean block = true;
+ if (template.getTagDescription(null, null, null,
+ visualNewElement, null).getDisplayType() == VpeTagDescription.DISPLAY_TYPE_INLINE) {
+ block = false;
+ }
+ border = createBorder(sourceNode, visualNewElement, block);
+ }
+ if (!isCurrentMainDocument() && visualNewElement != null) {
+ setReadOnlyElement(visualNewElement);
+ }
+ if (registerFlag) {
+ VpeElementMapping elementMapping = new VpeElementMapping(
+ (Element) sourceNode, visualNewElement, border,
+ template, ifDependencySet, creationData.getData(),
+ creationData.getElementData());
+ // elementMapping.setXmlnsMap(xmlnsMap);
+ registerNodes(elementMapping);
+ }
+ if (template.isChildren()) {
+ List<?> childrenInfoList = creationData.getChildrenInfoList();
+ if (childrenInfoList == null) {
+ addChildren(template, sourceNode,
+ visualNewElement != null ? visualNewElement
+ : visualOldContainer);
+ } else {
+ addChildren(template, sourceNode, visualOldContainer,
+ childrenInfoList);
+ }
+ }
+ pageContext.setCurrentVisualNode(visualOldContainer);
+ template.validate(pageContext, (Element) sourceNode,
+ visualDocument, creationData);
+ pageContext.setCurrentVisualNode(null);
+ if (border != null)
+ return border;
+ else
+ return visualNewElement;
+ case Node.TEXT_NODE:
+ return createTextNode(sourceNode, registerFlag);
+ case Node.COMMENT_NODE:
+ if (!YES_STRING.equals(VpePreference.SHOW_COMMENTS.getValue())) {
+ return null;
+ }
+ nsIDOMElement visualNewComment = createComment(sourceNode);
+ if (registerFlag) {
+ registerNodes(new VpeNodeMapping(sourceNode, visualNewComment));
+ }
+ return visualNewComment;
}
+ return null;
+ }
private void correctVisualAttribute(nsIDOMElement element) {
- String styleValue = element.getAttribute(HTML.TAG_STYLE);
- String backgroundValue = element
- .getAttribute(VpeStyleUtil.PARAMETR_BACKGROND);
+ String styleValue = element.getAttribute(HTML.TAG_STYLE);
+ String backgroundValue = element
+ .getAttribute(VpeStyleUtil.PARAMETR_BACKGROND);
- if (styleValue != null) {
- styleValue = VpeStyleUtil.addFullPathIntoURLValue(styleValue,
- pageContext.getEditPart().getEditorInput());
- element.setAttribute(HTML.TAG_STYLE, styleValue);
- }
- if (backgroundValue != null) {
- backgroundValue = VpeStyleUtil
- .addFullPathIntoBackgroundValue(backgroundValue,
- pageContext.getEditPart().getEditorInput());
- element.setAttribute(VpeStyleUtil.PARAMETR_BACKGROND,
- backgroundValue);
- }
+ if (styleValue != null) {
+ styleValue = VpeStyleUtil.addFullPathIntoURLValue(styleValue,
+ pageContext.getEditPart().getEditorInput());
+ element.setAttribute(HTML.TAG_STYLE, styleValue);
}
+ if (backgroundValue != null) {
+ backgroundValue = VpeStyleUtil
+ .addFullPathIntoBackgroundValue(backgroundValue,
+ pageContext.getEditPart().getEditorInput());
+ element.setAttribute(VpeStyleUtil.PARAMETR_BACKGROND,
+ backgroundValue);
+ }
+ }
protected nsIDOMElement createComment(Node sourceNode) {
- nsIDOMElement div = visualDocument.createElement(HTML.TAG_DIV);
- div.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE, COMMENT_STYLE);
- String value = COMMENT_PREFIX + sourceNode.getNodeValue()
- + COMMENT_SUFFIX;
- nsIDOMText text = visualDocument.createTextNode(value);
- div.appendChild(text);
- return div;
+ nsIDOMElement div = visualDocument.createElement(HTML.TAG_DIV);
+ div.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE, COMMENT_STYLE);
+ String value = COMMENT_PREFIX + sourceNode.getNodeValue()
+ + COMMENT_SUFFIX;
+ nsIDOMText text = visualDocument.createTextNode(value);
+ div.appendChild(text);
+ return div;
}
protected void addChildren(VpeTemplate containerTemplate,
- Node sourceContainer, nsIDOMNode visualContainer) {
-
- /*
- * Fixes http://jira.jboss.com/jira/browse/JBIDE-1944
- * author: Denis Maliarevich
- * This method is called when template has no childrenInfoList.
- * In this case h:dataTable and h:panelGrid should display pseudo text
- */
- if (containerTemplate instanceof VpeHtmlTemplate) {
- int type = ((VpeHtmlTemplate) containerTemplate).getType();
- if ((VpeHtmlTemplate.TYPE_DATATABLE == type)
- || (VpeHtmlTemplate.TYPE_PANELGRID == type)) {
- setPseudoContent(containerTemplate, sourceContainer,
- visualContainer);
- return;
- }
- }
-
- NodeList sourceNodes = sourceContainer.getChildNodes();
- int len = sourceNodes.getLength();
- int childrenCount = 0;
- for (int i = 0; i < len; i++) {
- Node sourceNode = sourceNodes.item(i);
- if (addNode(sourceNode, null, visualContainer)) {
- if (Node.ELEMENT_NODE == sourceNode.getNodeType()) {
- }
- childrenCount++;
- }
- }
+ Node sourceContainer, nsIDOMNode visualContainer) {
+
+ /*
+ * Fixes http://jira.jboss.com/jira/browse/JBIDE-1944
+ * author: Denis Maliarevich
+ * This method is called when template has no childrenInfoList.
+ * In this case h:dataTable and h:panelGrid should display pseudo text
+ */
+ if (containerTemplate instanceof VpeHtmlTemplate) {
+ int type = ((VpeHtmlTemplate) containerTemplate).getType();
+ if ((VpeHtmlTemplate.TYPE_DATATABLE == type)
+ || (VpeHtmlTemplate.TYPE_PANELGRID == type)) {
+ setPseudoContent(containerTemplate, sourceContainer,
+ visualContainer);
+ return;
+ }
+ }
+
+ NodeList sourceNodes = sourceContainer.getChildNodes();
+ int len = sourceNodes.getLength();
+ int childrenCount = 0;
+ for (int i = 0; i < len; i++) {
+ Node sourceNode = sourceNodes.item(i);
+ if (addNode(sourceNode, null, visualContainer)) {
+ if (Node.ELEMENT_NODE == sourceNode.getNodeType()) {
+ }
+ childrenCount++;
+ }
+ }
- if (childrenCount == 0) {
- setPseudoContent(containerTemplate, sourceContainer,
- visualContainer);
- }
- }
+ if (childrenCount == 0) {
+ setPseudoContent(containerTemplate, sourceContainer,
+ visualContainer);
+ }
+ }
protected void addChildren(VpeTemplate containerTemplate,
- Node sourceContainer, nsIDOMNode visualOldContainer,
- List<?> childrenInfoList) {
- for (int i = 0; i < childrenInfoList.size(); i++) {
- VpeChildrenInfo info = (VpeChildrenInfo) childrenInfoList.get(i);
- nsIDOMNode visualParent = info.getVisualParent();
- if (visualParent == null)
- visualParent = visualOldContainer;
- List<?> sourceChildren = info.getSourceChildren();
- int childrenCount = 0;
- if (sourceChildren != null) {
- for (int j = 0; j < sourceChildren.size(); j++) {
- if (addNode((Node) sourceChildren.get(j), null,
- visualParent)) {
- childrenCount++;
- }
- }
- }
- if (childrenCount == 0 && childrenInfoList.size() == 0) {
- setPseudoContent(containerTemplate, sourceContainer,
- visualParent);
- }
- }
+ Node sourceContainer, nsIDOMNode visualOldContainer,
+ List<?> childrenInfoList) {
+ for (int i = 0; i < childrenInfoList.size(); i++) {
+ VpeChildrenInfo info = (VpeChildrenInfo) childrenInfoList.get(i);
+ nsIDOMNode visualParent = info.getVisualParent();
+ if (visualParent == null)
+ visualParent = visualOldContainer;
+ List<?> sourceChildren = info.getSourceChildren();
+ int childrenCount = 0;
+ if (sourceChildren != null) {
+ for (int j = 0; j < sourceChildren.size(); j++) {
+ if (addNode((Node) sourceChildren.get(j), null,
+ visualParent)) {
+ childrenCount++;
+ }
+ }
+ }
+ if (childrenCount == 0 && childrenInfoList.size() == 0) {
+ setPseudoContent(containerTemplate, sourceContainer,
+ visualParent);
+ }
}
+ }
// /////////////////////////////////////////////////////////////////////////
public nsIDOMNode addStyleNodeToHead(String styleText) {
- nsIDOMNode newStyle = visualDocument
- .createElement(VpeStyleUtil.ATTRIBUTE_STYLE);
+ nsIDOMNode newStyle = visualDocument
+ .createElement(VpeStyleUtil.ATTRIBUTE_STYLE);
- if (styleText != null) {
- nsIDOMText newText = visualDocument.createTextNode(styleText);
- newStyle.appendChild(newText);
- }
- getHeadNode().appendChild(newStyle);
- return newStyle;
+ if (styleText != null) {
+ nsIDOMText newText = visualDocument.createTextNode(styleText);
+ newStyle.appendChild(newText);
}
+ getHeadNode().appendChild(newStyle);
+ return newStyle;
+ }
public nsIDOMNode replaceStyleNodeToHead(nsIDOMNode oldStyleNode,
- String styleText) {
- nsIDOMElement newStyle = visualDocument
- .createElement(VpeStyleUtil.ATTRIBUTE_STYLE);
+ String styleText) {
+ nsIDOMElement newStyle = visualDocument
+ .createElement(VpeStyleUtil.ATTRIBUTE_STYLE);
- if (styleText != null) {
- nsIDOMNode newText = visualDocument.createTextNode(styleText);
- newStyle.appendChild(newText);
- }
+ if (styleText != null) {
+ nsIDOMNode newText = visualDocument.createTextNode(styleText);
+ newStyle.appendChild(newText);
+ }
- getHeadNode().replaceChild(newStyle, oldStyleNode);
- return newStyle;
+ getHeadNode().replaceChild(newStyle, oldStyleNode);
+ return newStyle;
}
public void removeStyleNodeFromHead(nsIDOMNode oldStyleNode) {
- getHeadNode().removeChild(oldStyleNode);
+ getHeadNode().removeChild(oldStyleNode);
}
void addExternalLinks() {
- IEditorInput input = pageContext.getEditPart().getEditorInput();
- IFile file = null;
- if (input instanceof IFileEditorInput) {
- file = ((IFileEditorInput) input).getFile();
- }
- ResourceReference[] l = null;
- if (file != null) {
- l = CSSReferenceList.getInstance().getAllResources(file);
- }
- if (l != null) {
- for (int i = 0; i < l.length; i++) {
- ResourceReference item = l[i];
- addLinkNodeToHead("file:///" + item.getLocation(), YES_STRING); //$NON-NLS-1$
- }
- }
+ IEditorInput input = pageContext.getEditPart().getEditorInput();
+ IFile file = null;
+ if (input instanceof IFileEditorInput) {
+ file = ((IFileEditorInput) input).getFile();
}
+ ResourceReference[] l = null;
+ if (file != null) {
+ l = CSSReferenceList.getInstance().getAllResources(file);
+ }
+ if (l != null) {
+ for (int i = 0; i < l.length; i++) {
+ ResourceReference item = l[i];
+ addLinkNodeToHead("file:///" + item.getLocation(), YES_STRING); //$NON-NLS-1$
+ }
+ }
+ }
void removeExternalLinks() {
- nsIDOMNodeList childs = getHeadNode().getChildNodes();
- long length = childs.getLength();
- for (long i = length - 1; i >= 0; i--) {
- nsIDOMNode node = childs.item(i);
- if (node.getNodeType() == nsIDOMNode.ELEMENT_NODE) {
- boolean isLink = false;
- boolean isStyle = false;
- if ((isLink = HTML.TAG_LINK
- .equalsIgnoreCase(node.getNodeName()))
- || (isStyle = HTML.TAG_STYLE.equalsIgnoreCase(node
- .getNodeName()))) {
- nsIDOMElement element = (nsIDOMElement) node
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- if ((isLink || (isStyle && ATTR_VPE_INLINE_LINK_VALUE
- .equalsIgnoreCase(element.getAttribute(ATTR_VPE))))
- && YES_STRING.equalsIgnoreCase(element
- .getAttribute(VpeTemplateManager.ATTR_LINK_EXT))) {
- getHeadNode().removeChild(node);
- }
- }
- }
- }
+ nsIDOMNodeList childs = getHeadNode().getChildNodes();
+ long length = childs.getLength();
+ for (long i = length - 1; i >= 0; i--) {
+ nsIDOMNode node = childs.item(i);
+ if (node.getNodeType() == nsIDOMNode.ELEMENT_NODE) {
+ boolean isLink = false;
+ boolean isStyle = false;
+ if ((isLink = HTML.TAG_LINK
+ .equalsIgnoreCase(node.getNodeName()))
+ || (isStyle = HTML.TAG_STYLE.equalsIgnoreCase(node
+ .getNodeName()))) {
+ nsIDOMElement element = (nsIDOMElement) node
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+ if ((isLink || (isStyle && ATTR_VPE_INLINE_LINK_VALUE
+ .equalsIgnoreCase(element.getAttribute(ATTR_VPE))))
+ && YES_STRING.equalsIgnoreCase(element
+ .getAttribute(VpeTemplateManager.ATTR_LINK_EXT))) {
+ getHeadNode().removeChild(node);
+ }
+ }
+ }
}
+ }
void refreshExternalLinks() {
- removeExternalLinks();
- addExternalLinks();
+ removeExternalLinks();
+ addExternalLinks();
}
// ==========================================================
void resetPseudoElement(nsIDOMNode visualNode) {
- if (visualNode != null) {
- nsIDOMNode visualParent = visualNode.getParentNode();
- if (visualParent != null) {
- PseudoInfo info = getPseudoInfo(visualParent);
- if (info.pseudoNode == null && !info.isElements) {
- addPseudoElementImpl(visualParent);
- } else if (info.pseudoNode != null && info.isElements) {
- visualParent.removeChild(info.pseudoNode);
- }
- }
- }
+ if (visualNode != null) {
+ nsIDOMNode visualParent = visualNode.getParentNode();
+ if (visualParent != null) {
+ PseudoInfo info = getPseudoInfo(visualParent);
+ if (info.pseudoNode == null && !info.isElements) {
+ addPseudoElementImpl(visualParent);
+ } else if (info.pseudoNode != null && info.isElements) {
+ visualParent.removeChild(info.pseudoNode);
+ }
+ }
}
+ }
private PseudoInfo getPseudoInfo(nsIDOMNode visualParent) {
- nsIDOMNode pseudoNode = null;
- boolean isElements = false;
+ nsIDOMNode pseudoNode = null;
+ boolean isElements = false;
- if (visualParent == null)
- return new PseudoInfo();
- nsIDOMNodeList visualNodes = visualParent.getChildNodes();
- if (visualNodes == null)
- return new PseudoInfo();
+ if (visualParent == null)
+ return new PseudoInfo();
+ nsIDOMNodeList visualNodes = visualParent.getChildNodes();
+ if (visualNodes == null)
+ return new PseudoInfo();
- long length = visualNodes.getLength();
- for (long i = 0; i < length; i++) {
- nsIDOMNode visualNode = visualNodes.item(i);
- if (pseudoNode == null && isPseudoElement(visualNode)) {
- pseudoNode = visualNode;
- } else if (!isEmptyText(visualNode)) {
- isElements = true;
- }
- if (pseudoNode != null && isElements) {
- break;
- }
- }
- return new PseudoInfo(pseudoNode, isElements);
+ long length = visualNodes.getLength();
+ for (long i = 0; i < length; i++) {
+ nsIDOMNode visualNode = visualNodes.item(i);
+ if (pseudoNode == null && isPseudoElement(visualNode)) {
+ pseudoNode = visualNode;
+ } else if (!isEmptyText(visualNode)) {
+ isElements = true;
+ }
+ if (pseudoNode != null && isElements) {
+ break;
+ }
}
+ return new PseudoInfo(pseudoNode, isElements);
+ }
static boolean isInitElement(nsIDOMNode visualNode) {
- if (visualNode == null) {
- return false;
- }
+ if (visualNode == null) {
+ return false;
+ }
- if (visualNode.getNodeType() != Node.ELEMENT_NODE) {
- return false;
- }
+ if (visualNode.getNodeType() != Node.ELEMENT_NODE) {
+ return false;
+ }
- if (YES_STRING.equalsIgnoreCase(((nsIDOMElement) visualNode)
- .getAttribute(INIT_ELEMENT_ATTR))) {
- return true;
- }
+ if (YES_STRING.equalsIgnoreCase(((nsIDOMElement) visualNode)
+ .getAttribute(INIT_ELEMENT_ATTR))) {
+ return true;
+ }
- return false;
+ return false;
}
static boolean isPseudoElement(nsIDOMNode visualNode) {
- if (visualNode == null) {
- return false;
- }
+ if (visualNode == null) {
+ return false;
+ }
- if (visualNode.getNodeType() != Node.ELEMENT_NODE) {
- return false;
- }
+ if (visualNode.getNodeType() != Node.ELEMENT_NODE) {
+ return false;
+ }
- if (YES_STRING.equalsIgnoreCase(((nsIDOMElement) visualNode
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID))
- .getAttribute(PSEUDO_ELEMENT_ATTR))) {
- return true;
- }
+ if (YES_STRING.equalsIgnoreCase(((nsIDOMElement) visualNode
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID))
+ .getAttribute(PSEUDO_ELEMENT_ATTR))) {
+ return true;
+ }
- return false;
+ return false;
}
private void setPseudoContent(VpeTemplate containerTemplate,
- Node sourceContainer, nsIDOMNode visualContainer) {
- if (containerTemplate != null) {
- containerTemplate.setPseudoContent(pageContext, sourceContainer,
- visualContainer, visualDocument);
- } else {
- VpeDefaultPseudoContentCreator.getInstance().setPseudoContent(
- pageContext, sourceContainer, visualContainer,
- visualDocument);
- }
+ Node sourceContainer, nsIDOMNode visualContainer) {
+ if (containerTemplate != null) {
+ containerTemplate.setPseudoContent(pageContext, sourceContainer,
+ visualContainer, visualDocument);
+ } else {
+ VpeDefaultPseudoContentCreator.getInstance().setPseudoContent(
+ pageContext, sourceContainer, visualContainer,
+ visualDocument);
+ }
- // if (isEmptyElement(visualContainer)) {
- // addPseudoElementImpl(visualContainer);
- // }
+ // if (isEmptyElement(visualContainer)) {
+ // addPseudoElementImpl(visualContainer);
+ // }
}
private void addPseudoElementImpl(nsIDOMNode visualParent) {
- if (!templateManager.isWithoutPseudoElementContainer(visualParent
- .getNodeName())) {
- if (VpeDebug.VISUAL_ADD_PSEUDO_ELEMENT) {
- System.out.println("-------------------- addPseudoElement: " //$NON-NLS-1$
- + visualParent.getNodeName());
- }
- nsIDOMElement visualPseudoElement = visualDocument
- .createElement(PSEUDO_ELEMENT);
- visualPseudoElement.setAttribute(PSEUDO_ELEMENT_ATTR, YES_STRING);
- visualParent.appendChild(visualPseudoElement);
- }
+ if (!templateManager.isWithoutPseudoElementContainer(visualParent
+ .getNodeName())) {
+ if (VpeDebug.VISUAL_ADD_PSEUDO_ELEMENT) {
+ System.out.println("-------------------- addPseudoElement: " //$NON-NLS-1$
+ + visualParent.getNodeName());
+ }
+ nsIDOMElement visualPseudoElement = visualDocument
+ .createElement(PSEUDO_ELEMENT);
+ visualPseudoElement.setAttribute(PSEUDO_ELEMENT_ATTR, YES_STRING);
+ visualParent.appendChild(visualPseudoElement);
}
+ }
public boolean isEmptyElement(nsIDOMNode visualParent) {
- nsIDOMNodeList visualNodes = visualParent.getChildNodes();
- long len = visualNodes.getLength();
+ nsIDOMNodeList visualNodes = visualParent.getChildNodes();
+ long len = visualNodes.getLength();
- if ((len == 0) || (len == 1 && isEmptyText(visualNodes.item(0)))) {
- return true;
- }
+ if ((len == 0) || (len == 1 && isEmptyText(visualNodes.item(0)))) {
+ return true;
+ }
- return false;
+ return false;
}
public boolean isEmptyDocument() {
- nsIDOMNodeList visualNodes = getContentArea().getChildNodes();
- long len = visualNodes.getLength();
- if ((len == 0)
- || (len == 1 && (isEmptyText(visualNodes.item(0)) || isPseudoElement(visualNodes
- .item(0))))) {
- return true;
- }
+ nsIDOMNodeList visualNodes = getContentArea().getChildNodes();
+ long len = visualNodes.getLength();
+ if ((len == 0)
+ || (len == 1 && (isEmptyText(visualNodes.item(0)) || isPseudoElement(visualNodes
+ .item(0))))) {
+ return true;
+ }
- return false;
+ return false;
}
private boolean isEmptyText(nsIDOMNode visualNode) {
- if (visualNode == null
- || (visualNode.getNodeType() != nsIDOMNode.TEXT_NODE)) {
- return false;
- }
+ if (visualNode == null
+ || (visualNode.getNodeType() != nsIDOMNode.TEXT_NODE)) {
+ return false;
+ }
- if (visualNode.getNodeValue().trim().length() == 0) {
- return true;
- }
+ if (visualNode.getNodeValue().trim().length() == 0) {
+ return true;
+ }
- return false;
+ return false;
}
// ==========================================================
public void updateNode(Node sourceNode) {
- if (sourceNode == null)
- return;
+ if (sourceNode == null)
+ return;
- switch (sourceNode.getNodeType()) {
- case Node.DOCUMENT_NODE:
- rebuildDom((Document) sourceNode);
- break;
- case Node.COMMENT_NODE:
- updateComment(sourceNode);
- break;
- default:
- updateElement(getNodeForUpdate(sourceNode));
- }
+ switch (sourceNode.getNodeType()) {
+ case Node.DOCUMENT_NODE:
+ rebuildDom((Document) sourceNode);
+ break;
+ case Node.COMMENT_NODE:
+ updateComment(sourceNode);
+ break;
+ default:
+ updateElement(getNodeForUpdate(sourceNode));
}
+ }
// TODO Ssergey Vasilyev make a common code for figuring out
// if it is need to update parent node or not
private Node getNodeForUpdate(Node sourceNode) {
- /* Changing of <tr> or <td> tags can affect whole the table */
- Node sourceTable = getParentTable(sourceNode, 2);
- if (sourceTable != null) {
- return sourceTable;
- }
+ /* Changing of <tr> or <td> tags can affect whole the table */
+ Node sourceTable = getParentTable(sourceNode, 2);
+ if (sourceTable != null) {
+ return sourceTable;
+ }
- /* Changing of an <option> tag can affect the parent select */
- Node sourceSelect = getParentSelect(sourceNode);
- if (sourceSelect != null) {
- return sourceSelect;
- }
+ /* Changing of an <option> tag can affect the parent select */
+ Node sourceSelect = getParentSelect(sourceNode);
+ if (sourceSelect != null) {
+ return sourceSelect;
+ }
- return sourceNode;
+ return sourceNode;
}
private void updateComment(Node sourceNode) {
- VpeNodeMapping mapping = domMapping.getNodeMapping(sourceNode);
- if (mapping != null
- && mapping.getType() == VpeNodeMapping.COMMENT_MAPPING) {
- nsIDOMNodeList visualNodes = mapping.getVisualNode()
- .getChildNodes();
+ VpeNodeMapping mapping = domMapping.getNodeMapping(sourceNode);
+ if (mapping != null
+ && mapping.getType() == VpeNodeMapping.COMMENT_MAPPING) {
+ nsIDOMNodeList visualNodes = mapping.getVisualNode()
+ .getChildNodes();
- if (visualNodes.getLength() > 0) {
- visualNodes.item(0).setNodeValue(sourceNode.getNodeValue());
- }
- }
+ if (visualNodes.getLength() > 0) {
+ visualNodes.item(0).setNodeValue(sourceNode.getNodeValue());
+ }
}
+ }
private void updateElement(Node sourceNode) {
- VpeElementMapping elementMapping = null;
- VpeNodeMapping nodeMapping = domMapping.getNodeMapping(sourceNode);
- if (nodeMapping instanceof VpeElementMapping) {
-
- elementMapping = (VpeElementMapping) nodeMapping;
- if (elementMapping != null && elementMapping.getTemplate() != null) {
- Node updateNode = elementMapping.getTemplate()
- .getNodeForUptate(pageContext,
- elementMapping.getSourceNode(),
- elementMapping.getVisualNode(),
- elementMapping.getData());
+ VpeElementMapping elementMapping = null;
+ VpeNodeMapping nodeMapping = domMapping.getNodeMapping(sourceNode);
+ if (nodeMapping instanceof VpeElementMapping) {
+
+ elementMapping = (VpeElementMapping) nodeMapping;
+ if (elementMapping != null && elementMapping.getTemplate() != null) {
+ Node updateNode = elementMapping.getTemplate()
+ .getNodeForUptate(pageContext,
+ elementMapping.getSourceNode(),
+ elementMapping.getVisualNode(),
+ elementMapping.getData());
- /*
- * special processing of "style" element
- *
- * for unification of updating nodes - or redevelop updating
- * mechanism (for example : transfer this function to template )
- * or redevelop template of "style" element
- */
- if (HTML.TAG_STYLE.equalsIgnoreCase(sourceNode.getNodeName())) {
- // refresh style node
- VpeStyleUtil.refreshStyleElement(this, elementMapping);
- return;
- }
- if (updateNode != null && updateNode != sourceNode) {
- updateNode(updateNode);
- return;
- }
- }
- }
-
+ /*
+ * special processing of "style" element
+ *
+ * for unification of updating nodes - or redevelop updating
+ * mechanism (for example : transfer this function to template )
+ * or redevelop template of "style" element
+ */
+ if (HTML.TAG_STYLE.equalsIgnoreCase(sourceNode.getNodeName())) {
+ // refresh style node
+ VpeStyleUtil.refreshStyleElement(this, elementMapping);
+ return;
+ }
+ if (updateNode != null && updateNode != sourceNode) {
+ updateNode(updateNode);
+ return;
+ }
+ }
+ }
- nsIDOMNode visualOldNode = domMapping.remove(sourceNode);
- getSourceNodes().remove(sourceNode);
-
- if (sourceNode instanceof INodeNotifier) {
- ((INodeNotifier) sourceNode).removeAdapter(getSorceAdapter());
- }
- if (visualOldNode != null) {
- if (elementMapping != null) {
- nsIDOMElement border = elementMapping.getBorder();
- if (border != null) {
- visualOldNode = border;
- }
- }
- nsIDOMNode visualContainer = visualOldNode.getParentNode();
- nsIDOMNode visualNextNode = visualOldNode.getNextSibling();
- if (visualContainer != null) {
- visualContainer.removeChild(visualOldNode);
- addNode(sourceNode, visualNextNode, visualContainer);
- }
- } else {
- // Max Areshkau Why we need update parent node when we update text
- // node?
- // lookd like we haven't need do it.
- if (sourceNode.getNodeType() == Node.TEXT_NODE) {
- updateNode(sourceNode.getParentNode());
- }
- }
+
+ nsIDOMNode visualOldNode = domMapping.remove(sourceNode);
+ getSourceNodes().remove(sourceNode);
+
+ if (sourceNode instanceof INodeNotifier) {
+ ((INodeNotifier) sourceNode).removeAdapter(getSorceAdapter());
}
+ if (visualOldNode != null) {
+ if (elementMapping != null) {
+ nsIDOMElement border = elementMapping.getBorder();
+ if (border != null) {
+ visualOldNode = border;
+ }
+ }
+ nsIDOMNode visualContainer = visualOldNode.getParentNode();
+ nsIDOMNode visualNextNode = visualOldNode.getNextSibling();
+ if (visualContainer != null) {
+ visualContainer.removeChild(visualOldNode);
+ addNode(sourceNode, visualNextNode, visualContainer);
+ }
+ } else {
+ // Max Areshkau Why we need update parent node when we update text
+ // node?
+ // lookd like we haven't need do it.
+ if (sourceNode.getNodeType() == Node.TEXT_NODE) {
+ updateNode(sourceNode.getParentNode());
+ }
+ }
+ }
public void removeNode(Node sourceNode) {
//remove from cash should be called first
getPageContext().removeNodeFromVpeCash(sourceNode);
- domMapping.remove(sourceNode);
- getSourceNodes().remove(sourceNode);
- if (sourceNode instanceof INodeNotifier) {
- ((INodeNotifier) sourceNode).removeAdapter(getSorceAdapter());
- }
+ domMapping.remove(sourceNode);
+ getSourceNodes().remove(sourceNode);
+ if (sourceNode instanceof INodeNotifier) {
+ ((INodeNotifier) sourceNode).removeAdapter(getSorceAdapter());
}
+ }
private Node getParentTable(Node sourceNode, int depth) {
- Node parentNode = sourceNode.getParentNode();
- for (int i = 0; parentNode != null && i < depth; parentNode = parentNode
- .getParentNode(), i++) {
- if (HTML.TAG_TABLE.equalsIgnoreCase(parentNode.getNodeName())) {
- return parentNode;
- }
- }
- return null;
+ Node parentNode = sourceNode.getParentNode();
+ for (int i = 0; parentNode != null && i < depth; parentNode = parentNode
+ .getParentNode(), i++) {
+ if (HTML.TAG_TABLE.equalsIgnoreCase(parentNode.getNodeName())) {
+ return parentNode;
+ }
}
+ return null;
+ }
private Node getParentSelect(Node sourceNode) {
- if (HTML.TAG_OPTION.equalsIgnoreCase(sourceNode.getNodeName())) {
- Node parentNode = sourceNode.getParentNode();
- if (HTML.TAG_SELECT.equalsIgnoreCase(parentNode.getNodeName())) {
- return parentNode;
- }
- }
- return null;
+ if (HTML.TAG_OPTION.equalsIgnoreCase(sourceNode.getNodeName())) {
+ Node parentNode = sourceNode.getParentNode();
+ if (HTML.TAG_SELECT.equalsIgnoreCase(parentNode.getNodeName())) {
+ return parentNode;
+ }
}
+ return null;
+ }
// public void setText(Node sourceText) {
// Node sourceParent = sourceText.getParentNode();
@@ -998,1121 +1025,1121 @@
// return;
// }
public boolean setText(Node sourceText) {
- Node sourceParent = sourceText.getParentNode();
- if (sourceParent != null && sourceParent.getLocalName() != null) {
- String sourceParentName = sourceParent.getLocalName();
- if (HTML.TAG_TEXTAREA.equalsIgnoreCase(sourceParentName)
- || HTML.TAG_OPTION.equalsIgnoreCase(sourceParentName) || HTML.TAG_STYLE.equalsIgnoreCase(sourceParentName)) {
- updateNode(sourceText.getParentNode());
- return true;
- }
- }
- nsIDOMNode visualText = domMapping.getVisualNode(sourceText);
- if (visualText != null) {
- String visualValue = TextUtil.visualText(sourceText.getNodeValue());
- visualText.setNodeValue(visualValue);
- } else {
- VpeNodeMapping nodeMapping = domMapping
- .getNodeMapping(sourceParent);
- if (nodeMapping != null
- && nodeMapping.getType() == VpeNodeMapping.ELEMENT_MAPPING) {
- VpeTemplate template = ((VpeElementMapping) nodeMapping)
- .getTemplate();
- if (template != null) {
- if (!template.containsText()) {
- return false;
- }
- }
- }
- updateNode(sourceText);
- return true;
- }
+ Node sourceParent = sourceText.getParentNode();
+ if (sourceParent != null && sourceParent.getLocalName() != null) {
+ String sourceParentName = sourceParent.getLocalName();
+ if (HTML.TAG_TEXTAREA.equalsIgnoreCase(sourceParentName)
+ || HTML.TAG_OPTION.equalsIgnoreCase(sourceParentName) || HTML.TAG_STYLE.equalsIgnoreCase(sourceParentName)) {
+ updateNode(sourceText.getParentNode());
+ return true;
+ }
+ }
+ nsIDOMNode visualText = domMapping.getVisualNode(sourceText);
+ if (visualText != null) {
+ String visualValue = TextUtil.visualText(sourceText.getNodeValue());
+ visualText.setNodeValue(visualValue);
+ } else {
+ VpeNodeMapping nodeMapping = domMapping
+ .getNodeMapping(sourceParent);
+ if (nodeMapping != null
+ && nodeMapping.getType() == VpeNodeMapping.ELEMENT_MAPPING) {
+ VpeTemplate template = ((VpeElementMapping) nodeMapping)
+ .getTemplate();
+ if (template != null) {
+ if (!template.containsText()) {
+ return false;
+ }
+ }
+ }
+ updateNode(sourceText);
+ return true;
+ }
- // }
- // updateNode(sourceText);
- return false;
+ // }
+ // updateNode(sourceText);
+ return false;
}
// }
public void setAttribute(Element sourceElement, String name, String value) {
- VpeElementMapping elementMapping = (VpeElementMapping) domMapping
- .getNodeMapping(sourceElement);
- if (elementMapping != null) {
- if (elementMapping.isIfDependencyFromAttribute(name)) {
- updateElement(sourceElement);
- } else {
- VpeTemplate template = elementMapping.getTemplate();
- if (elementMapping.getBorder() != null) {
- updateElement(sourceElement);
- } else if (template.isRecreateAtAttrChange(pageContext,
- sourceElement, visualDocument,
- (nsIDOMElement) elementMapping.getVisualNode(),
- elementMapping.getData(), name, value)) {
- updateElement(sourceElement);
- } else {
- nsIDOMElement visualElement = (nsIDOMElement) elementMapping
- .getVisualNode();
- if (visualElement != null) {
- String visualElementName = visualElement.getNodeName();
- if (HTML.TAG_SELECT.equalsIgnoreCase(visualElementName)) {
- updateElement(sourceElement);
- return;
- } else if (HTML.TAG_OPTION
- .equalsIgnoreCase(visualElementName)) {
- updateElement(sourceElement.getParentNode());
- return;
- } else if (HTML.TAG_INPUT
- .equalsIgnoreCase(visualElementName)) {
- updateElement(sourceElement);
- // Fixes JBIDE-1744 author dmaliarevich
- // unified h:dataTable border lookup
- // after attribute change and
- // after visual editor refresh
- } else if (HTML.TAG_TABLE
- .equalsIgnoreCase(visualElementName)) {
- updateElement(sourceElement);
- }
- // End of fix
- }
- // setXmlnsAttribute(elementMapping, name, value);
- template.setAttribute(pageContext, sourceElement,
- visualDocument, visualElement, elementMapping
- .getData(), name, value);
- resetTooltip(sourceElement, visualElement);
- }
- }
- }
+ VpeElementMapping elementMapping = (VpeElementMapping) domMapping
+ .getNodeMapping(sourceElement);
+ if (elementMapping != null) {
+ if (elementMapping.isIfDependencyFromAttribute(name)) {
+ updateElement(sourceElement);
+ } else {
+ VpeTemplate template = elementMapping.getTemplate();
+ if (elementMapping.getBorder() != null) {
+ updateElement(sourceElement);
+ } else if (template.isRecreateAtAttrChange(pageContext,
+ sourceElement, visualDocument,
+ (nsIDOMElement) elementMapping.getVisualNode(),
+ elementMapping.getData(), name, value)) {
+ updateElement(sourceElement);
+ } else {
+ nsIDOMElement visualElement = (nsIDOMElement) elementMapping
+ .getVisualNode();
+ if (visualElement != null) {
+ String visualElementName = visualElement.getNodeName();
+ if (HTML.TAG_SELECT.equalsIgnoreCase(visualElementName)) {
+ updateElement(sourceElement);
+ return;
+ } else if (HTML.TAG_OPTION
+ .equalsIgnoreCase(visualElementName)) {
+ updateElement(sourceElement.getParentNode());
+ return;
+ } else if (HTML.TAG_INPUT
+ .equalsIgnoreCase(visualElementName)) {
+ updateElement(sourceElement);
+ // Fixes JBIDE-1744 author dmaliarevich
+ // unified h:dataTable border lookup
+ // after attribute change and
+ // after visual editor refresh
+ } else if (HTML.TAG_TABLE
+ .equalsIgnoreCase(visualElementName)) {
+ updateElement(sourceElement);
+ }
+ // End of fix
+ }
+ // setXmlnsAttribute(elementMapping, name, value);
+ template.setAttribute(pageContext, sourceElement,
+ visualDocument, visualElement, elementMapping
+ .getData(), name, value);
+ resetTooltip(sourceElement, visualElement);
+ }
+ }
}
+ }
public void stopToggle(Node sourceNode) {
- if (!(sourceNode instanceof Element))
- return;
+ if (!(sourceNode instanceof Element))
+ return;
- Element sourceElement = (Element) sourceNode;
- VpeElementMapping elementMapping = (VpeElementMapping) domMapping
- .getNodeMapping(sourceElement);
- if (elementMapping != null) {
- VpeTemplate template = elementMapping.getTemplate();
+ Element sourceElement = (Element) sourceNode;
+ VpeElementMapping elementMapping = (VpeElementMapping) domMapping
+ .getNodeMapping(sourceElement);
+ if (elementMapping != null) {
+ VpeTemplate template = elementMapping.getTemplate();
- if (template instanceof VpeToggableTemplate) {
- ((VpeToggableTemplate) template).stopToggling(sourceElement);
- }
- }
+ if (template instanceof VpeToggableTemplate) {
+ ((VpeToggableTemplate) template).stopToggling(sourceElement);
+ }
}
+ }
public boolean doToggle(nsIDOMNode visualNode) {
- if (visualNode == null) {
- return false;
- }
- nsIDOMElement visualElement = null;
- try {
- visualElement = (nsIDOMElement) visualNode
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- } catch (XPCOMException exception) {
- visualElement = (nsIDOMElement) visualNode.getParentNode()
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- }
- if (visualElement == null) {
- return false;
- }
+ if (visualNode == null) {
+ return false;
+ }
+ nsIDOMElement visualElement = null;
+ try {
+ visualElement = (nsIDOMElement) visualNode
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+ } catch (XPCOMException exception) {
+ visualElement = (nsIDOMElement) visualNode.getParentNode()
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+ }
+ if (visualElement == null) {
+ return false;
+ }
- nsIDOMAttr toggleIdAttr = visualElement
- .getAttributeNode(VPE_USER_TOGGLE_ID);
- if (toggleIdAttr == null) {
- return false;
- }
- String toggleId = toggleIdAttr.getNodeValue();
+ nsIDOMAttr toggleIdAttr = visualElement
+ .getAttributeNode(VPE_USER_TOGGLE_ID);
+ if (toggleIdAttr == null) {
+ return false;
+ }
+ String toggleId = toggleIdAttr.getNodeValue();
- if (toggleId == null) {
- return false;
- }
+ if (toggleId == null) {
+ return false;
+ }
- boolean toggleLookup = false;
- nsIDOMAttr toggleLookupAttr = visualElement
- .getAttributeNode(VPE_USER_TOGGLE_LOOKUP_PARENT);
- if (toggleLookupAttr != null) {
- toggleLookup = "true".equals(toggleLookupAttr.getNodeValue());
- }
+ boolean toggleLookup = false;
+ nsIDOMAttr toggleLookupAttr = visualElement
+ .getAttributeNode(VPE_USER_TOGGLE_LOOKUP_PARENT);
+ if (toggleLookupAttr != null) {
+ toggleLookup = "true".equals(toggleLookupAttr.getNodeValue());
+ }
- nsIDOMElement selectedElem = getLastSelectedElement();
- // Fixes JBIDE-1823 author dmaliarevich
- if (null == selectedElem) {
- return false;
- }
- VpeElementMapping elementMapping = null;
- VpeNodeMapping nodeMapping = domMapping.getNodeMapping(selectedElem);
- if (nodeMapping instanceof VpeElementMapping) {
- elementMapping = (VpeElementMapping) nodeMapping;
- }
- // end of fix
- if (elementMapping == null) {
- // may be toggle with facet
- while (!selectedElem.getNodeName().equals(HTML.TAG_TABLE)) {
- selectedElem = (nsIDOMElement) selectedElem.getParentNode()
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- }
- // Fixes JBIDE-1823 author dmaliarevich
- nodeMapping = domMapping.getNodeMapping(selectedElem);
- if (nodeMapping instanceof VpeElementMapping) {
- elementMapping = (VpeElementMapping) nodeMapping;
- }
- // end of fix
- }
- Node sourceNode = (Node) domMapping.getSourceNode(selectedElem);
- if (sourceNode == null) {
- return false;
- }
+ nsIDOMElement selectedElem = getLastSelectedElement();
+ // Fixes JBIDE-1823 author dmaliarevich
+ if (null == selectedElem) {
+ return false;
+ }
+ VpeElementMapping elementMapping = null;
+ VpeNodeMapping nodeMapping = domMapping.getNodeMapping(selectedElem);
+ if (nodeMapping instanceof VpeElementMapping) {
+ elementMapping = (VpeElementMapping) nodeMapping;
+ }
+ // end of fix
+ if (elementMapping == null) {
+ // may be toggle with facet
+ while (!selectedElem.getNodeName().equals(HTML.TAG_TABLE)) {
+ selectedElem = (nsIDOMElement) selectedElem.getParentNode()
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+ }
+ // Fixes JBIDE-1823 author dmaliarevich
+ nodeMapping = domMapping.getNodeMapping(selectedElem);
+ if (nodeMapping instanceof VpeElementMapping) {
+ elementMapping = (VpeElementMapping) nodeMapping;
+ }
+ // end of fix
+ }
+ Node sourceNode = (Node) domMapping.getSourceNode(selectedElem);
+ if (sourceNode == null) {
+ return false;
+ }
- Element sourceElement = (Element) (sourceNode instanceof Element ? sourceNode
- : sourceNode.getParentNode());
+ Element sourceElement = (Element) (sourceNode instanceof Element ? sourceNode
+ : sourceNode.getParentNode());
- // Fixes JBIDE-1823 author dmaliarevich
- // Template is looked according to <code>selectedElem</code>
- // so <code>toggleLookupAttr</code> should be retrieved
- // from this element
- toggleLookupAttr = selectedElem
- .getAttributeNode(VPE_USER_TOGGLE_LOOKUP_PARENT);
- if (toggleLookupAttr != null) {
- toggleLookup = "true".equals(toggleLookupAttr.getNodeValue());
- }
- // end of fix
-
- if (elementMapping != null) {
- VpeTemplate template = elementMapping.getTemplate();
+ // Fixes JBIDE-1823 author dmaliarevich
+ // Template is looked according to <code>selectedElem</code>
+ // so <code>toggleLookupAttr</code> should be retrieved
+ // from this element
+ toggleLookupAttr = selectedElem
+ .getAttributeNode(VPE_USER_TOGGLE_LOOKUP_PARENT);
+ if (toggleLookupAttr != null) {
+ toggleLookup = "true".equals(toggleLookupAttr.getNodeValue());
+ }
+ // end of fix
+
+ if (elementMapping != null) {
+ VpeTemplate template = elementMapping.getTemplate();
- while (toggleLookup && sourceElement != null
- && !(template instanceof VpeToggableTemplate)) {
- sourceElement = (Element) sourceElement.getParentNode();
- if (sourceElement == null) {
- break;
- }
- // Fixes JBIDE-1823 author dmaliarevich
- nodeMapping = domMapping.getNodeMapping(sourceElement);
- if (nodeMapping instanceof VpeElementMapping) {
- elementMapping = (VpeElementMapping) nodeMapping;
- }
- // end of fix
- if (elementMapping == null) {
- continue;
- }
- template = elementMapping.getTemplate();
- }
+ while (toggleLookup && sourceElement != null
+ && !(template instanceof VpeToggableTemplate)) {
+ sourceElement = (Element) sourceElement.getParentNode();
+ if (sourceElement == null) {
+ break;
+ }
+ // Fixes JBIDE-1823 author dmaliarevich
+ nodeMapping = domMapping.getNodeMapping(sourceElement);
+ if (nodeMapping instanceof VpeElementMapping) {
+ elementMapping = (VpeElementMapping) nodeMapping;
+ }
+ // end of fix
+ if (elementMapping == null) {
+ continue;
+ }
+ template = elementMapping.getTemplate();
+ }
- if (template instanceof VpeToggableTemplate) {
- ((VpeToggableTemplate) template).toggle(this, sourceElement,
- toggleId);
- updateElement(sourceElement);
- return true;
- }
- }
- return false;
- }
+ if (template instanceof VpeToggableTemplate) {
+ ((VpeToggableTemplate) template).toggle(this, sourceElement,
+ toggleId);
+ updateElement(sourceElement);
+ return true;
+ }
+ }
+ return false;
+ }
public void removeAttribute(Element sourceElement, String name) {
- VpeElementMapping elementMapping = (VpeElementMapping) domMapping
- .getNodeMapping(sourceElement);
- if (elementMapping != null) {
- if (elementMapping.isIfDependencyFromAttribute(name)) {
- updateElement(sourceElement);
- } else {
- VpeTemplate template = elementMapping.getTemplate();
- if (template.isRecreateAtAttrChange(pageContext, sourceElement,
- visualDocument, (nsIDOMElement) elementMapping
- .getVisualNode(), elementMapping.getData(),
- name, null)) {
- updateElement(sourceElement);
- }
- // else {
- // removeXmlnsAttribute(elementMapping, name);
- // template.removeAttribute(pageContext, sourceElement,
- // visualDocument, (nsIDOMElement) elementMapping
- // .getVisualNode(), elementMapping.getData(),
- // name);
- // resetTooltip(sourceElement, (nsIDOMElement) elementMapping
- // .getVisualNode());
- // }
- }
- }
+ VpeElementMapping elementMapping = (VpeElementMapping) domMapping
+ .getNodeMapping(sourceElement);
+ if (elementMapping != null) {
+ if (elementMapping.isIfDependencyFromAttribute(name)) {
+ updateElement(sourceElement);
+ } else {
+ VpeTemplate template = elementMapping.getTemplate();
+ if (template.isRecreateAtAttrChange(pageContext, sourceElement,
+ visualDocument, (nsIDOMElement) elementMapping
+ .getVisualNode(), elementMapping.getData(),
+ name, null)) {
+ updateElement(sourceElement);
+ }
+ // else {
+ // removeXmlnsAttribute(elementMapping, name);
+ // template.removeAttribute(pageContext, sourceElement,
+ // visualDocument, (nsIDOMElement) elementMapping
+ // .getVisualNode(), elementMapping.getData(),
+ // name);
+ // resetTooltip(sourceElement, (nsIDOMElement) elementMapping
+ // .getVisualNode());
+ // }
+ }
}
+ }
public void refreshBundleValues(Element sourceElement) {
- VpeElementMapping elementMapping = (VpeElementMapping) domMapping
- .getNodeMapping(sourceElement);
- if (elementMapping != null) {
- VpeTemplate template = elementMapping.getTemplate();
- template.refreshBundleValues(pageContext, sourceElement,
- elementMapping.getData());
- }
+ VpeElementMapping elementMapping = (VpeElementMapping) domMapping
+ .getNodeMapping(sourceElement);
+ if (elementMapping != null) {
+ VpeTemplate template = elementMapping.getTemplate();
+ template.refreshBundleValues(pageContext, sourceElement,
+ elementMapping.getData());
}
+ }
boolean isContentArea(nsIDOMNode visualNode) {
- return getContentArea().equals(visualNode);
+ return getContentArea().equals(visualNode);
}
nsIDOMElement getContentArea() {
- return visualEditor.getContentArea();
+ return visualEditor.getContentArea();
}
public void setSelectionRectangle(/*nsIDOMElement*/ nsIDOMNode visualElement) {
- setSelectionRectangle(visualElement, true);
+ setSelectionRectangle(visualElement, true);
}
void setSelectionRectangle(/*nsIDOMElement*/ nsIDOMNode visualElement, boolean scroll) {
- int resizerConstrains = getResizerConstrains(visualElement);
- visualEditor.setSelectionRectangle(visualElement, resizerConstrains,
- scroll);
+ int resizerConstrains = getResizerConstrains(visualElement);
+ visualEditor.setSelectionRectangle(visualElement, resizerConstrains,
+ scroll);
}
public nsIDOMNode addLinkNodeToHead(String href_val, String ext_val) {
- nsIDOMElement newNode = createLinkNode(href_val,
- ATTR_REL_STYLESHEET_VALUE, ext_val);
+ nsIDOMElement newNode = createLinkNode(href_val,
+ ATTR_REL_STYLESHEET_VALUE, ext_val);
- //TODO Dzmitry Sakovich
- // Fix priority CSS classes JBIDE-1713
- nsIDOMNode firstNode = getHeadNode().getFirstChild();
- getHeadNode().insertBefore(newNode, firstNode);
- return newNode;
+ //TODO Dzmitry Sakovich
+ // Fix priority CSS classes JBIDE-1713
+ nsIDOMNode firstNode = getHeadNode().getFirstChild();
+ getHeadNode().insertBefore(newNode, firstNode);
+ return newNode;
}
public nsIDOMNode replaceLinkNodeToHead(nsIDOMNode oldNode,
- String href_val, String ext_val) {
- nsIDOMNode newNode = createLinkNode(href_val,
- ATTR_REL_STYLESHEET_VALUE, ext_val);
- getHeadNode().replaceChild(newNode, oldNode);
- return newNode;
+ String href_val, String ext_val) {
+ nsIDOMNode newNode = createLinkNode(href_val,
+ ATTR_REL_STYLESHEET_VALUE, ext_val);
+ getHeadNode().replaceChild(newNode, oldNode);
+ return newNode;
}
public nsIDOMNode replaceLinkNodeToHead(String href_val, String ext_val) {
- nsIDOMNode newNode = null;
- nsIDOMNode oldNode = getLinkNode(href_val, ext_val);
- if (oldNode == null) {
- newNode = addLinkNodeToHead(href_val, ext_val);
- }
- return newNode;
+ nsIDOMNode newNode = null;
+ nsIDOMNode oldNode = getLinkNode(href_val, ext_val);
+ if (oldNode == null) {
+ newNode = addLinkNodeToHead(href_val, ext_val);
}
+ return newNode;
+ }
public void removeLinkNodeFromHead(nsIDOMNode node) {
- getHeadNode().removeChild(node);
+ getHeadNode().removeChild(node);
}
private nsIDOMElement createLinkNode(String href_val, String rel_val,
- String ext_val) {
- nsIDOMElement linkNode = null;
- if ((ATTR_REL_STYLESHEET_VALUE.equalsIgnoreCase(rel_val))
- && href_val.startsWith("file:")) {
- /*
- * Because of the Mozilla caches the linked css files we replace tag
- * <link rel="styleseet" href="file://..."> with tag <style
- * vpe="ATTR_VPE_INLINE_LINK_VALUE">file content</style> It is
- * LinkReplacer
- */
- linkNode = visualDocument.createElement(HTML.TAG_STYLE);
- linkNode.setAttribute(ATTR_VPE, ATTR_VPE_INLINE_LINK_VALUE);
+ String ext_val) {
+ nsIDOMElement linkNode = null;
+ if ((ATTR_REL_STYLESHEET_VALUE.equalsIgnoreCase(rel_val))
+ && href_val.startsWith("file:")) {
+ /*
+ * Because of the Mozilla caches the linked css files we replace tag
+ * <link rel="styleseet" href="file://..."> with tag <style
+ * vpe="ATTR_VPE_INLINE_LINK_VALUE">file content</style> It is
+ * LinkReplacer
+ */
+ linkNode = visualDocument.createElement(HTML.TAG_STYLE);
+ linkNode.setAttribute(ATTR_VPE, ATTR_VPE_INLINE_LINK_VALUE);
- /* Copy links attributes into our <style> */
- linkNode.setAttribute(VpeTemplateManager.ATTR_LINK_HREF, href_val);
- linkNode.setAttribute(VpeTemplateManager.ATTR_LINK_EXT, ext_val);
- try {
- StringBuffer styleText = new StringBuffer(EMPTY_STRING);
- URL url = new URL((new Path(href_val)).toOSString());
- String fileName = url.getFile();
- BufferedReader in = new BufferedReader(new FileReader(
- (fileName)));
- String str = EMPTY_STRING;
- while ((str = in.readLine()) != null) {
- styleText.append(str);
- }
+ /* Copy links attributes into our <style> */
+ linkNode.setAttribute(VpeTemplateManager.ATTR_LINK_HREF, href_val);
+ linkNode.setAttribute(VpeTemplateManager.ATTR_LINK_EXT, ext_val);
+ try {
+ StringBuffer styleText = new StringBuffer(EMPTY_STRING);
+ URL url = new URL((new Path(href_val)).toOSString());
+ String fileName = url.getFile();
+ BufferedReader in = new BufferedReader(new FileReader(
+ (fileName)));
+ String str = EMPTY_STRING;
+ while ((str = in.readLine()) != null) {
+ styleText.append(str);
+ }
- String styleForParse = styleText.toString();
- styleForParse = VpeStyleUtil.addFullPathIntoURLValue(
- styleForParse, href_val);
+ String styleForParse = styleText.toString();
+ styleForParse = VpeStyleUtil.addFullPathIntoURLValue(
+ styleForParse, href_val);
- in.close();
- nsIDOMText textNode = visualDocument
- .createTextNode(styleForParse);
- linkNode.appendChild(textNode);
- return linkNode;
- } catch (FileNotFoundException fnfe) {
- /* File which was pointed by user is not exists. Do nothing. */
- } catch (IOException ioe) {
- VpePlugin.getPluginLog().logError(ioe.getMessage(), ioe);
- }
- }
+ in.close();
+ nsIDOMText textNode = visualDocument
+ .createTextNode(styleForParse);
+ linkNode.appendChild(textNode);
+ return linkNode;
+ } catch (FileNotFoundException fnfe) {
+ /* File which was pointed by user is not exists. Do nothing. */
+ } catch (IOException ioe) {
+ VpePlugin.getPluginLog().logError(ioe.getMessage(), ioe);
+ }
+ }
- linkNode = visualDocument.createElement(HTML.TAG_LINK);
- linkNode.setAttribute(VpeTemplateManager.ATTR_LINK_REL, rel_val);
- linkNode.setAttribute(VpeTemplateManager.ATTR_LINK_HREF, href_val);
- linkNode.setAttribute(VpeTemplateManager.ATTR_LINK_EXT, ext_val);
+ linkNode = visualDocument.createElement(HTML.TAG_LINK);
+ linkNode.setAttribute(VpeTemplateManager.ATTR_LINK_REL, rel_val);
+ linkNode.setAttribute(VpeTemplateManager.ATTR_LINK_HREF, href_val);
+ linkNode.setAttribute(VpeTemplateManager.ATTR_LINK_EXT, ext_val);
- return linkNode;
+ return linkNode;
}
private boolean isLinkReplacer(nsIDOMNode node) {
- return HTML.TAG_STYLE.equalsIgnoreCase(node.getNodeName())
- && ATTR_VPE_INLINE_LINK_VALUE
- .equalsIgnoreCase(((nsIDOMElement) node
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID))
- .getAttribute(ATTR_VPE));
+ return HTML.TAG_STYLE.equalsIgnoreCase(node.getNodeName())
+ && ATTR_VPE_INLINE_LINK_VALUE
+ .equalsIgnoreCase(((nsIDOMElement) node
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID))
+ .getAttribute(ATTR_VPE));
}
private nsIDOMNode getLinkNode(String href_val, String ext_val) {
- nsIDOMNodeList children = getHeadNode().getChildNodes();
- long len = children.getLength();
- for (long i = len - 1; i >= 0; i--) {
- nsIDOMNode node = children.item(i);
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- if (HTML.TAG_LINK.equalsIgnoreCase(node.getNodeName())
- || isLinkReplacer(node)) {
- nsIDOMElement element = (nsIDOMElement) node
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- if (ext_val.equalsIgnoreCase(element
- .getAttribute(VpeTemplateManager.ATTR_LINK_EXT))
- && href_val
- .equalsIgnoreCase(element
- .getAttribute(VpeTemplateManager.ATTR_LINK_HREF))) {
- return node;
- }
- }
- }
- }
- return null;
+ nsIDOMNodeList children = getHeadNode().getChildNodes();
+ long len = children.getLength();
+ for (long i = len - 1; i >= 0; i--) {
+ nsIDOMNode node = children.item(i);
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ if (HTML.TAG_LINK.equalsIgnoreCase(node.getNodeName())
+ || isLinkReplacer(node)) {
+ nsIDOMElement element = (nsIDOMElement) node
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+ if (ext_val.equalsIgnoreCase(element
+ .getAttribute(VpeTemplateManager.ATTR_LINK_EXT))
+ && href_val
+ .equalsIgnoreCase(element
+ .getAttribute(VpeTemplateManager.ATTR_LINK_HREF))) {
+ return node;
+ }
+ }
+ }
}
+ return null;
+ }
private void cleanHead() {
- nsIDOMNodeList children = getHeadNode().getChildNodes();
- long len = children.getLength();
- for (long i = len - 1; i >= 0; i--) {
- nsIDOMNode node = children.item(i);
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- if (isLinkReplacer(node)) {
- /*Added by Max Areshkau(Fix for JBIDE-1941)
- * Ext. attribute used for adding external styles
- * to editor. If was added external attribute, this
- * property is true.
- */
- if (!YES_STRING.equalsIgnoreCase(((nsIDOMElement) node
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID))
- .getAttribute(VpeTemplateManager.ATTR_LINK_EXT))) {
- // int linkAddress =
- // MozillaSupports.queryInterface(node,
- // nsIStyleSheetLinkingElement.NS_ISTYLESHEETLINKINGELEMENT_IID);
- // nsIStyleSheetLinkingElement linkingElement = new
- // nsIStyleSheetLinkingElement(linkAddress);
- // linkingElement.removeStyleSheet();
- node = getHeadNode().removeChild(node);
- }
- } else if (HTML.TAG_STYLE.equalsIgnoreCase(node.getNodeName())
- && (!YES_STRING
- .equalsIgnoreCase(((nsIDOMElement) node
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID))
- .getAttribute(ATTR_VPE)))) {
- node = getHeadNode().removeChild(node);
- }
- }
- }
+ nsIDOMNodeList children = getHeadNode().getChildNodes();
+ long len = children.getLength();
+ for (long i = len - 1; i >= 0; i--) {
+ nsIDOMNode node = children.item(i);
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ if (isLinkReplacer(node)) {
+ /*Added by Max Areshkau(Fix for JBIDE-1941)
+ * Ext. attribute used for adding external styles
+ * to editor. If was added external attribute, this
+ * property is true.
+ */
+ if (!YES_STRING.equalsIgnoreCase(((nsIDOMElement) node
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID))
+ .getAttribute(VpeTemplateManager.ATTR_LINK_EXT))) {
+ // int linkAddress =
+ // MozillaSupports.queryInterface(node,
+ // nsIStyleSheetLinkingElement.NS_ISTYLESHEETLINKINGELEMENT_IID);
+ // nsIStyleSheetLinkingElement linkingElement = new
+ // nsIStyleSheetLinkingElement(linkAddress);
+ // linkingElement.removeStyleSheet();
+ node = getHeadNode().removeChild(node);
+ }
+ } else if (HTML.TAG_STYLE.equalsIgnoreCase(node.getNodeName())
+ && (!YES_STRING
+ .equalsIgnoreCase(((nsIDOMElement) node
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID))
+ .getAttribute(ATTR_VPE)))) {
+ node = getHeadNode().removeChild(node);
+ }
+ }
}
+ }
private class PseudoInfo {
- private nsIDOMNode pseudoNode;
- private boolean isElements;
+ private nsIDOMNode pseudoNode;
+ private boolean isElements;
- private PseudoInfo() {
- this(null, false);
- }
+ private PseudoInfo() {
+ this(null, false);
+ }
- private PseudoInfo(nsIDOMNode pseudoNode, boolean isElements) {
- this.pseudoNode = pseudoNode;
- this.isElements = isElements;
- }
+ private PseudoInfo(nsIDOMNode pseudoNode, boolean isElements) {
+ this.pseudoNode = pseudoNode;
+ this.isElements = isElements;
}
+ }
void showDragCaret(nsIDOMNode node, int offset) {
- xulRunnerEditor.showDragCaret(node, offset);
+ xulRunnerEditor.showDragCaret(node, offset);
}
void hideDragCaret() {
- xulRunnerEditor.hideDragCaret();
+ xulRunnerEditor.hideDragCaret();
}
private int getResizerConstrains(nsIDOMNode visualNode) {
- VpeNodeMapping nodeMapping = domMapping.getNodeMapping(visualNode);
- if (nodeMapping != null
- && nodeMapping.getType() == VpeNodeMapping.ELEMENT_MAPPING) {
- return ((VpeElementMapping) nodeMapping).getTemplate()
- .getTagDescription(pageContext,
- (Element) nodeMapping.getSourceNode(),
- visualDocument,
- (nsIDOMElement) nodeMapping.getVisualNode(),
- ((VpeElementMapping) nodeMapping).getData())
- .getResizeConstrains();
- }
- return VpeTagDescription.RESIZE_CONSTRAINS_NONE;
+ VpeNodeMapping nodeMapping = domMapping.getNodeMapping(visualNode);
+ if (nodeMapping != null
+ && nodeMapping.getType() == VpeNodeMapping.ELEMENT_MAPPING) {
+ return ((VpeElementMapping) nodeMapping).getTemplate()
+ .getTagDescription(pageContext,
+ (Element) nodeMapping.getSourceNode(),
+ visualDocument,
+ (nsIDOMElement) nodeMapping.getVisualNode(),
+ ((VpeElementMapping) nodeMapping).getData())
+ .getResizeConstrains();
}
+ return VpeTagDescription.RESIZE_CONSTRAINS_NONE;
+ }
public void resize(nsIDOMElement element, int resizerConstrains, int top,
- int left, int width, int height) {
- VpeElementMapping elementMapping = (VpeElementMapping) domMapping
- .getNodeMapping(element);
- if (elementMapping != null) {
- elementMapping.getTemplate().resize(pageContext,
- (Element) elementMapping.getSourceNode(), visualDocument,
- element, elementMapping.getData(), resizerConstrains, top,
- left, width, height);
- }
+ int left, int width, int height) {
+ VpeElementMapping elementMapping = (VpeElementMapping) domMapping
+ .getNodeMapping(element);
+ if (elementMapping != null) {
+ elementMapping.getTemplate().resize(pageContext,
+ (Element) elementMapping.getSourceNode(), visualDocument,
+ element, elementMapping.getData(), resizerConstrains, top,
+ left, width, height);
}
+ }
static boolean isAnonElement(nsIDOMNode visualNode) {
- if (visualNode != null
- && visualNode.getNodeType() == nsIDOMNode.ELEMENT_NODE) {
- String attrValue = ((nsIDOMElement) visualNode
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID))
- .getAttribute(MOZ_ANONCLASS_ATTR);
+ if (visualNode != null
+ && visualNode.getNodeType() == nsIDOMNode.ELEMENT_NODE) {
+ String attrValue = ((nsIDOMElement) visualNode
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID))
+ .getAttribute(MOZ_ANONCLASS_ATTR);
- return attrValue != null && attrValue.length() > 0;
- }
+ return attrValue != null && attrValue.length() > 0;
+ }
- return false;
+ return false;
}
boolean canInnerDrag(nsIDOMElement visualDragElement) {
- VpeNodeMapping node = domMapping.getNodeMapping(visualDragElement);
- if (node instanceof VpeElementMapping) {
- VpeElementMapping elementMapping = (VpeElementMapping) node;
- if (elementMapping != null) {
- return elementMapping.getTemplate().canInnerDrag(pageContext,
- (Element) elementMapping.getSourceNode(),
- visualDocument, visualDragElement,
- elementMapping.getData());
- }
- }
- return false;
+ VpeNodeMapping node = domMapping.getNodeMapping(visualDragElement);
+ if (node instanceof VpeElementMapping) {
+ VpeElementMapping elementMapping = (VpeElementMapping) node;
+ if (elementMapping != null) {
+ return elementMapping.getTemplate().canInnerDrag(pageContext,
+ (Element) elementMapping.getSourceNode(),
+ visualDocument, visualDragElement,
+ elementMapping.getData());
+ }
}
+ return false;
+ }
VpeSourceInnerDropInfo getSourceInnerDropInfo(Node sourceDragNode,
- VpeVisualInnerDropInfo visualDropInfo, boolean checkParentTemplates) {
- nsIDOMNode visualDropContainer = visualDropInfo.getDropContainer();
- long visualDropOffset = visualDropInfo.getDropOffset();
- Node sourceDropContainer = null;
- int sourceDropOffset = 0;
+ VpeVisualInnerDropInfo visualDropInfo, boolean checkParentTemplates) {
+ nsIDOMNode visualDropContainer = visualDropInfo.getDropContainer();
+ long visualDropOffset = visualDropInfo.getDropOffset();
+ Node sourceDropContainer = null;
+ int sourceDropOffset = 0;
- switch (visualDropContainer.getNodeType()) {
- case nsIDOMNode.ELEMENT_NODE:
- nsIDOMNode visualOffsetNode = null;
- boolean afterFlag = false;
- long visualChildCount = VisualDomUtil
- .getChildCount(visualDropContainer);
- if (visualDropOffset < visualChildCount) {
- visualOffsetNode = VisualDomUtil.getChildNode(
- visualDropContainer, visualDropOffset);
- if (isPseudoElement(visualOffsetNode)
- || isAnonElement(visualOffsetNode)) {
- visualOffsetNode = getLastAppreciableVisualChild(visualDropContainer);
- afterFlag = true;
- }
- } else {
- visualOffsetNode = getLastAppreciableVisualChild(visualDropContainer);
- afterFlag = visualChildCount != 0;
- }
- if (visualOffsetNode != null) {
- Node sourceOffsetNode = domMapping
- .getSourceNode(visualOffsetNode);
- if (sourceOffsetNode != null) {
- sourceDropContainer = sourceOffsetNode.getParentNode();
- sourceDropOffset = ((NodeImpl) sourceOffsetNode).getIndex();
- if (afterFlag) {
- sourceDropOffset++;
- }
- }
- }
- if (sourceDropContainer == null) {
- sourceDropContainer = domMapping
- .getNearSourceNode(visualDropContainer);
- if (sourceDropContainer != null) {
- sourceDropOffset = sourceDropContainer.getChildNodes()
- .getLength();
- }
- }
- if (sourceDropContainer == null) {
- sourceDropContainer = domMapping
- .getNearSourceNode(getContentArea());
- sourceDropOffset = sourceDropContainer.getChildNodes()
- .getLength();
- }
- break;
- case nsIDOMNode.TEXT_NODE:
- VpeNodeMapping nodeMapping = domMapping
- .getNearNodeMapping(visualDropContainer);
- switch (nodeMapping.getType()) {
- case VpeNodeMapping.TEXT_MAPPING:
- sourceDropContainer = nodeMapping.getSourceNode();
- sourceDropOffset = TextUtil.sourceInnerPosition(
- sourceDropContainer.getNodeValue(), visualDropOffset);
- break;
- case VpeNodeMapping.ELEMENT_MAPPING:
- // it's attribute
- if (isTextEditable(visualDropContainer)) {
- String[] atributeNames = ((VpeElementMapping) nodeMapping)
- .getTemplate().getOutputAtributeNames();
- if (atributeNames != null && atributeNames.length > 0) {
- Element sourceElement = (Element) nodeMapping
- .getSourceNode();
- sourceDropContainer = sourceElement
- .getAttributeNode(atributeNames[0]);
- sourceDropOffset = TextUtil.sourceInnerPosition(
- sourceDropContainer.getNodeValue(),
- visualDropOffset);
- }
- }
- nodeMapping.getVisualNode();
- }
- break;
- }
- if (sourceDropContainer != null) {
- return getSourceInnerDropInfo(sourceDragNode, sourceDropContainer,
- sourceDropOffset, checkParentTemplates);
- } else {
- return new VpeSourceInnerDropInfo(null, 0, false);
- }
+ switch (visualDropContainer.getNodeType()) {
+ case nsIDOMNode.ELEMENT_NODE:
+ nsIDOMNode visualOffsetNode = null;
+ boolean afterFlag = false;
+ long visualChildCount = VisualDomUtil
+ .getChildCount(visualDropContainer);
+ if (visualDropOffset < visualChildCount) {
+ visualOffsetNode = VisualDomUtil.getChildNode(
+ visualDropContainer, visualDropOffset);
+ if (isPseudoElement(visualOffsetNode)
+ || isAnonElement(visualOffsetNode)) {
+ visualOffsetNode = getLastAppreciableVisualChild(visualDropContainer);
+ afterFlag = true;
+ }
+ } else {
+ visualOffsetNode = getLastAppreciableVisualChild(visualDropContainer);
+ afterFlag = visualChildCount != 0;
+ }
+ if (visualOffsetNode != null) {
+ Node sourceOffsetNode = domMapping
+ .getSourceNode(visualOffsetNode);
+ if (sourceOffsetNode != null) {
+ sourceDropContainer = sourceOffsetNode.getParentNode();
+ sourceDropOffset = ((NodeImpl) sourceOffsetNode).getIndex();
+ if (afterFlag) {
+ sourceDropOffset++;
+ }
+ }
+ }
+ if (sourceDropContainer == null) {
+ sourceDropContainer = domMapping
+ .getNearSourceNode(visualDropContainer);
+ if (sourceDropContainer != null) {
+ sourceDropOffset = sourceDropContainer.getChildNodes()
+ .getLength();
+ }
+ }
+ if (sourceDropContainer == null) {
+ sourceDropContainer = domMapping
+ .getNearSourceNode(getContentArea());
+ sourceDropOffset = sourceDropContainer.getChildNodes()
+ .getLength();
+ }
+ break;
+ case nsIDOMNode.TEXT_NODE:
+ VpeNodeMapping nodeMapping = domMapping
+ .getNearNodeMapping(visualDropContainer);
+ switch (nodeMapping.getType()) {
+ case VpeNodeMapping.TEXT_MAPPING:
+ sourceDropContainer = nodeMapping.getSourceNode();
+ sourceDropOffset = TextUtil.sourceInnerPosition(
+ sourceDropContainer.getNodeValue(), visualDropOffset);
+ break;
+ case VpeNodeMapping.ELEMENT_MAPPING:
+ // it's attribute
+ if (isTextEditable(visualDropContainer)) {
+ String[] atributeNames = ((VpeElementMapping) nodeMapping)
+ .getTemplate().getOutputAtributeNames();
+ if (atributeNames != null && atributeNames.length > 0) {
+ Element sourceElement = (Element) nodeMapping
+ .getSourceNode();
+ sourceDropContainer = sourceElement
+ .getAttributeNode(atributeNames[0]);
+ sourceDropOffset = TextUtil.sourceInnerPosition(
+ sourceDropContainer.getNodeValue(),
+ visualDropOffset);
+ }
+ }
+ nodeMapping.getVisualNode();
+ }
+ break;
}
+ if (sourceDropContainer != null) {
+ return getSourceInnerDropInfo(sourceDragNode, sourceDropContainer,
+ sourceDropOffset, checkParentTemplates);
+ } else {
+ return new VpeSourceInnerDropInfo(null, 0, false);
+ }
+ }
VpeSourceInnerDropInfo getSourceInnerDropInfo(Node dragNode,
- Node container, int offset, boolean checkParentsTemplates) {
- // Thread.dumpStack();
- boolean canDrop = false;
- switch (container.getNodeType()) {
- case Node.ELEMENT_NODE:
- VpeNodeMapping nodeMapping = domMapping.getNodeMapping(container);
- if (nodeMapping != null
- && nodeMapping.getType() == VpeNodeMapping.ELEMENT_MAPPING) {
- canDrop = ((VpeElementMapping) nodeMapping).getTemplate()
- .canInnerDrop(pageContext, container, dragNode);
- }
- if (!canDrop) {
- if (!checkParentsTemplates)
- return new VpeSourceInnerDropInfo(container, offset,
- canDrop);
- // offset = ((NodeImpl)container).getIndex();
- // container = container.getParentNode();
- // TODO Max Areshkau unclear logic , if we can drop on element
- // why we trying to drop
- // this on parent
- // return getSourceInnerDropInfo(dragNode, container, offset,
- // false);
- return new VpeSourceInnerDropInfo(container, offset, canDrop);
- }
- break;
- case Node.TEXT_NODE:
- case Node.DOCUMENT_NODE:
- canDrop = true;
- break;
- case Node.ATTRIBUTE_NODE:
- canDrop = true;
- break;
- }
- if (canDrop) {
- return new VpeSourceInnerDropInfo(container, offset, canDrop);
- } else {
- return new VpeSourceInnerDropInfo(null, 0, canDrop);
- }
+ Node container, int offset, boolean checkParentsTemplates) {
+ // Thread.dumpStack();
+ boolean canDrop = false;
+ switch (container.getNodeType()) {
+ case Node.ELEMENT_NODE:
+ VpeNodeMapping nodeMapping = domMapping.getNodeMapping(container);
+ if (nodeMapping != null
+ && nodeMapping.getType() == VpeNodeMapping.ELEMENT_MAPPING) {
+ canDrop = ((VpeElementMapping) nodeMapping).getTemplate()
+ .canInnerDrop(pageContext, container, dragNode);
+ }
+ if (!canDrop) {
+ if (!checkParentsTemplates)
+ return new VpeSourceInnerDropInfo(container, offset,
+ canDrop);
+ // offset = ((NodeImpl)container).getIndex();
+ // container = container.getParentNode();
+ // TODO Max Areshkau unclear logic , if we can drop on element
+ // why we trying to drop
+ // this on parent
+ // return getSourceInnerDropInfo(dragNode, container, offset,
+ // false);
+ return new VpeSourceInnerDropInfo(container, offset, canDrop);
+ }
+ break;
+ case Node.TEXT_NODE:
+ case Node.DOCUMENT_NODE:
+ canDrop = true;
+ break;
+ case Node.ATTRIBUTE_NODE:
+ canDrop = true;
+ break;
}
+ if (canDrop) {
+ return new VpeSourceInnerDropInfo(container, offset, canDrop);
+ } else {
+ return new VpeSourceInnerDropInfo(null, 0, canDrop);
+ }
+ }
public void innerDrop(Node dragNode, Node container, int offset) {
- VpeNodeMapping mapping = domMapping.getNearNodeMapping(container);
- if (mapping != null) {
- nsIDOMNode visualDropContainer = mapping.getVisualNode();
- switch (mapping.getType()) {
- case VpeNodeMapping.TEXT_MAPPING:
- break;
- case VpeNodeMapping.ELEMENT_MAPPING:
- nsIDOMNode visualParent = visualDropContainer.getParentNode();
- VpeNodeMapping oldMapping = mapping;
- mapping = domMapping.getNearNodeMapping(visualParent);
- if (mapping != null
- && mapping.getType() == VpeNodeMapping.ELEMENT_MAPPING) {
- ((VpeElementMapping) mapping).getTemplate()
- .innerDrop(
- pageContext,
- new VpeSourceInnerDragInfo(dragNode, 0, 0),
- new VpeSourceInnerDropInfo(container,
- offset, true));
- } else {
- ((VpeElementMapping) oldMapping).getTemplate()
- .innerDrop(
- pageContext,
- new VpeSourceInnerDragInfo(dragNode, 0, 0),
- new VpeSourceInnerDropInfo(container,
- offset, true));
- }
- }
+ VpeNodeMapping mapping = domMapping.getNearNodeMapping(container);
+ if (mapping != null) {
+ nsIDOMNode visualDropContainer = mapping.getVisualNode();
+ switch (mapping.getType()) {
+ case VpeNodeMapping.TEXT_MAPPING:
+ break;
+ case VpeNodeMapping.ELEMENT_MAPPING:
+ nsIDOMNode visualParent = visualDropContainer.getParentNode();
+ VpeNodeMapping oldMapping = mapping;
+ mapping = domMapping.getNearNodeMapping(visualParent);
+ if (mapping != null
+ && mapping.getType() == VpeNodeMapping.ELEMENT_MAPPING) {
+ ((VpeElementMapping) mapping).getTemplate()
+ .innerDrop(
+ pageContext,
+ new VpeSourceInnerDragInfo(dragNode, 0, 0),
+ new VpeSourceInnerDropInfo(container,
+ offset, true));
+ } else {
+ ((VpeElementMapping) oldMapping).getTemplate()
+ .innerDrop(
+ pageContext,
+ new VpeSourceInnerDragInfo(dragNode, 0, 0),
+ new VpeSourceInnerDropInfo(container,
+ offset, true));
+ }
+ }
- }
}
+ }
void innerDrop(VpeSourceInnerDragInfo dragInfo,
- VpeSourceInnerDropInfo dropInfo) {
- dropper.drop(pageContext, dragInfo, dropInfo);
+ VpeSourceInnerDropInfo dropInfo) {
+ dropper.drop(pageContext, dragInfo, dropInfo);
}
nsIDOMElement getNearDragElement(Element visualElement) {
- VpeElementMapping elementMapping = domMapping
- .getNearElementMapping(visualElement);
- while (elementMapping != null) {
- if (canInnerDrag(elementMapping.getVisualElement())) {
- return elementMapping.getVisualElement();
- }
- elementMapping = domMapping.getNearElementMapping(elementMapping
- .getVisualNode().getParentNode());
- }
- return null;
+ VpeElementMapping elementMapping = domMapping
+ .getNearElementMapping(visualElement);
+ while (elementMapping != null) {
+ if (canInnerDrag(elementMapping.getVisualElement())) {
+ return elementMapping.getVisualElement();
+ }
+ elementMapping = domMapping.getNearElementMapping(elementMapping
+ .getVisualNode().getParentNode());
}
+ return null;
+ }
nsIDOMElement getDragElement(nsIDOMElement visualElement) {
- VpeElementMapping elementMapping = domMapping
- .getNearElementMapping(visualElement);
- if (elementMapping != null
- && canInnerDrag(elementMapping.getVisualElement())) {
- return elementMapping.getVisualElement();
- }
- return null;
+ VpeElementMapping elementMapping = domMapping
+ .getNearElementMapping(visualElement);
+ if (elementMapping != null
+ && canInnerDrag(elementMapping.getVisualElement())) {
+ return elementMapping.getVisualElement();
}
+ return null;
+ }
public boolean isTextEditable(nsIDOMNode visualNode) {
- if (visualNode != null) {
- nsIDOMNode parent = visualNode.getParentNode();
- if (parent != null
- && parent.getNodeType() == nsIDOMNode.ELEMENT_NODE) {
- nsIDOMElement element = (nsIDOMElement) parent
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- nsIDOMAttr style = element.getAttributeNode("style");
- if (style != null) {
- String styleValue = style.getNodeValue();
- String[] items = styleValue.split(";");
- for (int i = 0; i < items.length; i++) {
- String[] item = items[i].split(":");
- if ("-moz-user-modify".equals(item[0].trim())
- && "read-only".equals(item[1].trim())) {
- return false;
- }
- }
- }
- nsIDOMAttr classAttr = element.getAttributeNode("class");
- if (classAttr != null) {
- String classValue = classAttr.getNodeValue().trim();
- if ("__any__tag__caption".equals(classValue)) {
- return false;
- }
- }
- }
- }
- return true;
- }
+ if (visualNode != null) {
+ nsIDOMNode parent = visualNode.getParentNode();
+ if (parent != null
+ && parent.getNodeType() == nsIDOMNode.ELEMENT_NODE) {
+ nsIDOMElement element = (nsIDOMElement) parent
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+ nsIDOMAttr style = element.getAttributeNode("style");
+ if (style != null) {
+ String styleValue = style.getNodeValue();
+ String[] items = styleValue.split(";");
+ for (int i = 0; i < items.length; i++) {
+ String[] item = items[i].split(":");
+ if ("-moz-user-modify".equals(item[0].trim())
+ && "read-only".equals(item[1].trim())) {
+ return false;
+ }
+ }
+ }
+ nsIDOMAttr classAttr = element.getAttributeNode("class");
+ if (classAttr != null) {
+ String classValue = classAttr.getNodeValue().trim();
+ if ("__any__tag__caption".equals(classValue)) {
+ return false;
+ }
+ }
+ }
+ }
+ return true;
+ }
VpeVisualInnerDropInfo getInnerDropInfo(Node sourceDropContainer,
- int sourceDropOffset) {
- nsIDOMNode visualDropContainer = null;
- long visualDropOffset = 0;
+ int sourceDropOffset) {
+ nsIDOMNode visualDropContainer = null;
+ long visualDropOffset = 0;
- switch (sourceDropContainer.getNodeType()) {
- case Node.TEXT_NODE:
- visualDropContainer = domMapping.getVisualNode(sourceDropContainer);
- visualDropOffset = TextUtil.visualInnerPosition(sourceDropContainer
- .getNodeValue(), sourceDropOffset);
- break;
- case Node.ELEMENT_NODE:
- case Node.DOCUMENT_NODE:
- NodeList sourceChildren = sourceDropContainer.getChildNodes();
- if (sourceDropOffset < sourceChildren.getLength()) {
- Node sourceChild = sourceChildren.item(sourceDropOffset);
- nsIDOMNode visualChild = domMapping.getVisualNode(sourceChild);
- if (visualChild != null) {
- visualDropContainer = visualChild.getParentNode();
+ switch (sourceDropContainer.getNodeType()) {
+ case Node.TEXT_NODE:
+ visualDropContainer = domMapping.getVisualNode(sourceDropContainer);
+ visualDropOffset = TextUtil.visualInnerPosition(sourceDropContainer
+ .getNodeValue(), sourceDropOffset);
+ break;
+ case Node.ELEMENT_NODE:
+ case Node.DOCUMENT_NODE:
+ NodeList sourceChildren = sourceDropContainer.getChildNodes();
+ if (sourceDropOffset < sourceChildren.getLength()) {
+ Node sourceChild = sourceChildren.item(sourceDropOffset);
+ nsIDOMNode visualChild = domMapping.getVisualNode(sourceChild);
+ if (visualChild != null) {
+ visualDropContainer = visualChild.getParentNode();
- visualDropOffset = VisualDomUtil.getOffset(visualChild);
- }
- }
- if (visualDropContainer == null) {
- visualDropContainer = domMapping
- .getNearVisualNode(sourceDropContainer);
- nsIDOMNode visualChild = getLastAppreciableVisualChild(visualDropContainer);
- if (visualChild != null) {
- visualDropOffset = VisualDomUtil.getOffset(visualChild) + 1;
- } else {
- visualDropOffset = 0;
- }
- }
- break;
- case Node.ATTRIBUTE_NODE:
- Element sourceElement = ((Attr) sourceDropContainer)
- .getOwnerElement();
- VpeElementMapping elementMapping = domMapping
- .getNearElementMapping(sourceElement);
- nsIDOMNode textNode = elementMapping.getTemplate()
- .getOutputTextNode(pageContext, sourceElement,
- elementMapping.getData());
- if (textNode != null) {
- visualDropContainer = textNode;
- visualDropOffset = TextUtil.visualInnerPosition(
- sourceDropContainer.getNodeValue(), sourceDropOffset);
- }
- break;
- }
- if (visualDropContainer == null) {
- return null;
- }
- return new VpeVisualInnerDropInfo(visualDropContainer,
- visualDropOffset, 0, 0);
+ visualDropOffset = VisualDomUtil.getOffset(visualChild);
+ }
+ }
+ if (visualDropContainer == null) {
+ visualDropContainer = domMapping
+ .getNearVisualNode(sourceDropContainer);
+ nsIDOMNode visualChild = getLastAppreciableVisualChild(visualDropContainer);
+ if (visualChild != null) {
+ visualDropOffset = VisualDomUtil.getOffset(visualChild) + 1;
+ } else {
+ visualDropOffset = 0;
+ }
+ }
+ break;
+ case Node.ATTRIBUTE_NODE:
+ Element sourceElement = ((Attr) sourceDropContainer)
+ .getOwnerElement();
+ VpeElementMapping elementMapping = domMapping
+ .getNearElementMapping(sourceElement);
+ nsIDOMNode textNode = elementMapping.getTemplate()
+ .getOutputTextNode(pageContext, sourceElement,
+ elementMapping.getData());
+ if (textNode != null) {
+ visualDropContainer = textNode;
+ visualDropOffset = TextUtil.visualInnerPosition(
+ sourceDropContainer.getNodeValue(), sourceDropOffset);
+ }
+ break;
}
+ if (visualDropContainer == null) {
+ return null;
+ }
+ return new VpeVisualInnerDropInfo(visualDropContainer,
+ visualDropOffset, 0, 0);
+ }
protected void setTooltip(Element sourceElement, nsIDOMElement visualElement) {
- if (visualElement != null && sourceElement != null
- && !((IDOMElement) sourceElement).isJSPTag()) {
- if (HTML.TAG_HTML.equalsIgnoreCase(sourceElement.getNodeName()))
- return;
- String titleValue = getTooltip(sourceElement);
+ if (visualElement != null && sourceElement != null
+ && !((IDOMElement) sourceElement).isJSPTag()) {
+ if (HTML.TAG_HTML.equalsIgnoreCase(sourceElement.getNodeName()))
+ return;
+ String titleValue = getTooltip(sourceElement);
- if (titleValue != null) {
- titleValue = titleValue.replaceAll("&", "&");
- titleValue = titleValue.replaceAll("<", "<");
- titleValue = titleValue.replaceAll(">", ">");
- }
+ if (titleValue != null) {
+ titleValue = titleValue.replaceAll("&", "&");
+ titleValue = titleValue.replaceAll("<", "<");
+ titleValue = titleValue.replaceAll(">", ">");
+ }
- if (titleValue != null) {
- // visualElement.setAttribute("title", titleValue);
- setTooltip(visualElement, titleValue);
- }
- }
+ if (titleValue != null) {
+ // visualElement.setAttribute("title", titleValue);
+ setTooltip(visualElement, titleValue);
+ }
}
+ }
protected void setTooltip(nsIDOMElement visualElement, String titleValue) {
- visualElement.setAttribute(HTML.ATTR_TITLE, titleValue);
- nsIDOMNodeList children = visualElement.getChildNodes();
- long len = children.getLength();
- for (long i = 0; i < len; i++) {
- nsIDOMNode child = children.item(i);
- if (child.getNodeType() == nsIDOMNode.ELEMENT_NODE) {
- setTooltip(((nsIDOMElement) child
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID)),
- titleValue);
- }
- }
+ visualElement.setAttribute(HTML.ATTR_TITLE, titleValue);
+ nsIDOMNodeList children = visualElement.getChildNodes();
+ long len = children.getLength();
+ for (long i = 0; i < len; i++) {
+ nsIDOMNode child = children.item(i);
+ if (child.getNodeType() == nsIDOMNode.ELEMENT_NODE) {
+ setTooltip(((nsIDOMElement) child
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID)),
+ titleValue);
+ }
}
+ }
private void resetTooltip(Element sourceElement, nsIDOMElement visualElement) {
- if (visualElement != null && sourceElement != null
- && !((ElementImpl) sourceElement).isJSPTag()) {
- if (HTML.TAG_HTML.equalsIgnoreCase(sourceElement.getNodeName()))
- return;
- String titleValue = getTooltip(sourceElement);
+ if (visualElement != null && sourceElement != null
+ && !((ElementImpl) sourceElement).isJSPTag()) {
+ if (HTML.TAG_HTML.equalsIgnoreCase(sourceElement.getNodeName()))
+ return;
+ String titleValue = getTooltip(sourceElement);
- if (titleValue != null) {
- titleValue = titleValue.replaceAll("&", "&"); //$NON-NLS-1$//$NON-NLS-2$
- titleValue = titleValue.replaceAll("<", "<"); //$NON-NLS-1$//$NON-NLS-2$
- titleValue = titleValue.replaceAll(">", ">"); //$NON-NLS-1$//$NON-NLS-2$
- }
+ if (titleValue != null) {
+ titleValue = titleValue.replaceAll("&", "&"); //$NON-NLS-1$//$NON-NLS-2$
+ titleValue = titleValue.replaceAll("<", "<"); //$NON-NLS-1$//$NON-NLS-2$
+ titleValue = titleValue.replaceAll(">", ">"); //$NON-NLS-1$//$NON-NLS-2$
+ }
- if (titleValue != null) {
- resetTooltip(visualElement, titleValue);
- }
- }
+ if (titleValue != null) {
+ resetTooltip(visualElement, titleValue);
+ }
}
+ }
private void resetTooltip(nsIDOMElement visualElement, String titleValue) {
- visualElement.setAttribute(HTML.ATTR_TITLE, titleValue);
- nsIDOMNodeList children = visualElement.getChildNodes();
- long len = children.getLength();
- for (long i = 0; i < len; i++) {
- nsIDOMNode child = children.item(i);
- if (child.getNodeType() == nsIDOMNode.ELEMENT_NODE) {
- if (domMapping.getNodeMapping(child) == null) {
- resetTooltip((nsIDOMElement) child
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID),
- titleValue);
- }
- }
- }
+ visualElement.setAttribute(HTML.ATTR_TITLE, titleValue);
+ nsIDOMNodeList children = visualElement.getChildNodes();
+ long len = children.getLength();
+ for (long i = 0; i < len; i++) {
+ nsIDOMNode child = children.item(i);
+ if (child.getNodeType() == nsIDOMNode.ELEMENT_NODE) {
+ if (domMapping.getNodeMapping(child) == null) {
+ resetTooltip((nsIDOMElement) child
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID),
+ titleValue);
+ }
+ }
}
+ }
private String getTooltip(Element sourceElement) {
- StringBuffer buffer = new StringBuffer();
- buffer.append(sourceElement.getNodeName());
- NamedNodeMap attrs = sourceElement.getAttributes();
- int len = attrs.getLength();
- for (int i = 0; i < len; i++) {
- if (i == 7) {
- return buffer.append("\n\t... ").toString(); //$NON-NLS-1$
- }
- int valueLength = attrs.item(i).getNodeValue().length();
- if (valueLength > 30) {
- StringBuffer temp = new StringBuffer();
- temp.append(attrs.item(i).getNodeValue().substring(0, 15)
- + " ... " //$NON-NLS-1$
- + attrs.item(i).getNodeValue().substring(
- valueLength - 15, valueLength));
- buffer.append("\n" + attrs.item(i).getNodeName() + ": " + temp); //$NON-NLS-1$ //$NON-NLS-2$
- } else
- buffer.append("\n" + attrs.item(i).getNodeName() + ": " //$NON-NLS-1$ //$NON-NLS-2$
- + attrs.item(i).getNodeValue());
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(sourceElement.getNodeName());
+ NamedNodeMap attrs = sourceElement.getAttributes();
+ int len = attrs.getLength();
+ for (int i = 0; i < len; i++) {
+ if (i == 7) {
+ return buffer.append("\n\t... ").toString(); //$NON-NLS-1$
+ }
+ int valueLength = attrs.item(i).getNodeValue().length();
+ if (valueLength > 30) {
+ StringBuffer temp = new StringBuffer();
+ temp.append(attrs.item(i).getNodeValue().substring(0, 15)
+ + " ... " //$NON-NLS-1$
+ + attrs.item(i).getNodeValue().substring(
+ valueLength - 15, valueLength));
+ buffer.append("\n" + attrs.item(i).getNodeName() + ": " + temp); //$NON-NLS-1$ //$NON-NLS-2$
+ } else
+ buffer.append("\n" + attrs.item(i).getNodeName() + ": " //$NON-NLS-1$ //$NON-NLS-2$
+ + attrs.item(i).getNodeValue());
- }
+ }
- return buffer.toString();
+ return buffer.toString();
}
Rectangle getNodeBounds(nsIDOMNode visualNode) {
- return XulRunnerVpeUtils.getElementBounds(visualNode);
+ return XulRunnerVpeUtils.getElementBounds(visualNode);
}
static boolean canInsertAfter(int x, int y, Rectangle rect) {
- if (y > (rect.y + rect.height) || x > (rect.x + rect.width)) {
- return true;
- }
- return y >= rect.x && x > (rect.x + rect.width / 2);
+ if (y > (rect.y + rect.height) || x > (rect.x + rect.width)) {
+ return true;
}
+ return y >= rect.x && x > (rect.x + rect.width / 2);
+ }
static nsIDOMNode getLastAppreciableVisualChild(nsIDOMNode visualParent) {
- nsIDOMNode visualLastChild = null;
- nsIDOMNodeList visualChildren = visualParent.getChildNodes();
- long len = visualChildren.getLength();
- for (long i = len - 1; i >= 0; i--) {
- nsIDOMNode visualChild = visualChildren.item(i);
- if (!isPseudoElement(visualChild) && !isAnonElement(visualChild)) {
- visualLastChild = visualChild;
- break;
- }
- }
- return visualLastChild;
+ nsIDOMNode visualLastChild = null;
+ nsIDOMNodeList visualChildren = visualParent.getChildNodes();
+ long len = visualChildren.getLength();
+ for (long i = len - 1; i >= 0; i--) {
+ nsIDOMNode visualChild = visualChildren.item(i);
+ if (!isPseudoElement(visualChild) && !isAnonElement(visualChild)) {
+ visualLastChild = visualChild;
+ break;
+ }
}
+ return visualLastChild;
+ }
void correctVisualDropPosition(VpeVisualInnerDropInfo newVisualDropInfo,
- VpeVisualInnerDropInfo oldVisualDropInfo) {
- nsIDOMNode newVisualDropContainer = newVisualDropInfo
- .getDropContainer();
- nsIDOMNode oldVisualDropContainer = oldVisualDropInfo
- .getDropContainer();
+ VpeVisualInnerDropInfo oldVisualDropInfo) {
+ nsIDOMNode newVisualDropContainer = newVisualDropInfo
+ .getDropContainer();
+ nsIDOMNode oldVisualDropContainer = oldVisualDropInfo
+ .getDropContainer();
- if (newVisualDropContainer.equals(oldVisualDropContainer)) {
- newVisualDropInfo.setDropOffset(oldVisualDropInfo.getDropOffset());
- return;
- }
+ if (newVisualDropContainer.equals(oldVisualDropContainer)) {
+ newVisualDropInfo.setDropOffset(oldVisualDropInfo.getDropOffset());
+ return;
+ }
- nsIDOMNode child = oldVisualDropContainer;
- while (child != null && child.getNodeType() != Node.DOCUMENT_NODE) {
- nsIDOMNode parent = child.getParentNode();
- if (newVisualDropContainer.equals(parent)) {
- long offset = VisualDomUtil.getOffset(child);
- Rectangle rect = getNodeBounds(child);
- if (canInsertAfter(oldVisualDropInfo.getMouseX(),
- oldVisualDropInfo.getMouseY(), rect)) {
- offset++;
- }
- newVisualDropInfo.setDropOffset(offset);
- }
- child = parent;
- }
+ nsIDOMNode child = oldVisualDropContainer;
+ while (child != null && child.getNodeType() != Node.DOCUMENT_NODE) {
+ nsIDOMNode parent = child.getParentNode();
+ if (newVisualDropContainer.equals(parent)) {
+ long offset = VisualDomUtil.getOffset(child);
+ Rectangle rect = getNodeBounds(child);
+ if (canInsertAfter(oldVisualDropInfo.getMouseX(),
+ oldVisualDropInfo.getMouseY(), rect)) {
+ offset++;
+ }
+ newVisualDropInfo.setDropOffset(offset);
+ }
+ child = parent;
}
+ }
public nsIDOMRange createDOMRange() {
- return xulRunnerEditor.createDOMRange();
+ return xulRunnerEditor.createDOMRange();
}
public nsIDOMRange createDOMRange(nsIDOMNode selectedNode) {
- nsIDOMRange range = createDOMRange();
- range.selectNode(selectedNode);
- return range;
+ nsIDOMRange range = createDOMRange();
+ range.selectNode(selectedNode);
+ return range;
}
public static boolean isIncludeElement(nsIDOMElement visualElement) {
- return YES_STRING.equalsIgnoreCase(visualElement
- .getAttribute(INCLUDE_ELEMENT_ATTR));
+ return YES_STRING.equalsIgnoreCase(visualElement
+ .getAttribute(INCLUDE_ELEMENT_ATTR));
}
public static void markIncludeElement(nsIDOMElement visualElement) {
- visualElement.setAttribute(INCLUDE_ELEMENT_ATTR, YES_STRING);
+ visualElement.setAttribute(INCLUDE_ELEMENT_ATTR, YES_STRING);
}
protected void setReadOnlyElement(nsIDOMElement node) {
- String style = node.getAttribute(VpeStyleUtil.ATTRIBUTE_STYLE);
- style = VpeStyleUtil.setParameterInStyle(style, "-moz-user-modify", //$NON-NLS-1$
- "read-only"); //$NON-NLS-1$
- node.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE, style);
+ String style = node.getAttribute(VpeStyleUtil.ATTRIBUTE_STYLE);
+ style = VpeStyleUtil.setParameterInStyle(style, "-moz-user-modify", //$NON-NLS-1$
+ "read-only"); //$NON-NLS-1$
+ node.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE, style);
}
void setMoveCursor(nsIDOMMouseEvent mouseEvent) {
- nsIDOMElement selectedElement = xulRunnerEditor
- .getLastSelectedElement();
- if (selectedElement != null && canInnerDrag(selectedElement)) {
- String styleClasses = selectedElement.getAttribute(HTML.ATTR_CLASS);
- if (inDragArea(getNodeBounds(selectedElement), VisualDomUtil
- .getMousePoint(mouseEvent))) {
- // change cursor
- if (styleClasses == null
- || !(styleClasses.contains(ATTR_DRAG_AVAILABLE_CLASS))) {
- // change cursor style to move
- styleClasses = ATTR_DRAG_AVAILABLE_CLASS + " " //$NON-NLS-1$
- + styleClasses;
- }
- } else {
- // change cursor style to normal
- if (styleClasses != null) {
+ nsIDOMElement selectedElement = xulRunnerEditor
+ .getLastSelectedElement();
+ if (selectedElement != null && canInnerDrag(selectedElement)) {
+ String styleClasses = selectedElement.getAttribute(HTML.ATTR_CLASS);
+ if (inDragArea(getNodeBounds(selectedElement), VisualDomUtil
+ .getMousePoint(mouseEvent))) {
+ // change cursor
+ if (styleClasses == null
+ || !(styleClasses.contains(ATTR_DRAG_AVAILABLE_CLASS))) {
+ // change cursor style to move
+ styleClasses = ATTR_DRAG_AVAILABLE_CLASS + " " //$NON-NLS-1$
+ + styleClasses;
+ }
+ } else {
+ // change cursor style to normal
+ if (styleClasses != null) {
- styleClasses = styleClasses.replaceAll(
- ATTR_DRAG_AVAILABLE_CLASS, ""); //$NON-NLS-1$
- }
- }
- selectedElement.setAttribute(HTML.ATTR_CLASS, styleClasses);
- }
+ styleClasses = styleClasses.replaceAll(
+ ATTR_DRAG_AVAILABLE_CLASS, ""); //$NON-NLS-1$
+ }
+ }
+ selectedElement.setAttribute(HTML.ATTR_CLASS, styleClasses);
}
+ }
private boolean inDragArea(Rectangle dragArea, Point mousePoint) {
- // TODO add drag and drop support
- return dragArea.contains(mousePoint)
- && mousePoint.x < (dragArea.x + DRAG_AREA_WIDTH)
- && mousePoint.y < (dragArea.y + DRAG_AREA_HEIGHT);
+ // TODO add drag and drop support
+ return dragArea.contains(mousePoint)
+ && mousePoint.x < (dragArea.x + DRAG_AREA_WIDTH)
+ && mousePoint.y < (dragArea.y + DRAG_AREA_HEIGHT);
}
nsIDOMElement getDragElement(nsIDOMMouseEvent mouseEvent) {
- nsIDOMElement selectedElement = xulRunnerEditor
- .getLastSelectedElement();
- if (selectedElement != null && canInnerDrag(selectedElement)) {
- if (inDragArea(getNodeBounds(selectedElement), VisualDomUtil
- .getMousePoint(mouseEvent))) {
- return selectedElement;
- }
- }
- return null;
+ nsIDOMElement selectedElement = xulRunnerEditor
+ .getLastSelectedElement();
+ if (selectedElement != null && canInnerDrag(selectedElement)) {
+ if (inDragArea(getNodeBounds(selectedElement), VisualDomUtil
+ .getMousePoint(mouseEvent))) {
+ return selectedElement;
+ }
}
+ return null;
+ }
VpeSourceInnerDragInfo getSourceInnerDragInfo(
- VpeVisualInnerDragInfo visualDragInfo) {
- nsIDOMNode visualNode = visualDragInfo.getNode();
- int offset = visualDragInfo.getOffset();
- int length = visualDragInfo.getLength();
+ VpeVisualInnerDragInfo visualDragInfo) {
+ nsIDOMNode visualNode = visualDragInfo.getNode();
+ int offset = visualDragInfo.getOffset();
+ int length = visualDragInfo.getLength();
- VpeNodeMapping nodeMapping = domMapping.getNearNodeMapping(visualNode);
- Node sourceNode = nodeMapping.getSourceNode();
+ VpeNodeMapping nodeMapping = domMapping.getNearNodeMapping(visualNode);
+ Node sourceNode = nodeMapping.getSourceNode();
- if (sourceNode != null) {
- switch (sourceNode.getNodeType()) {
- case Node.TEXT_NODE:
- int end = TextUtil.sourceInnerPosition(visualNode
- .getNodeValue(), offset + length);
- offset = TextUtil.sourceInnerPosition(
- visualNode.getNodeValue(), offset);
- length = end - offset;
- break;
- case Node.ELEMENT_NODE:
- if (visualNode.getNodeType() == Node.TEXT_NODE) {
- // it's attribute
- sourceNode = null;
- if (isTextEditable(visualNode)) {
- String[] atributeNames = ((VpeElementMapping) nodeMapping)
- .getTemplate().getOutputAtributeNames();
- if (atributeNames != null && atributeNames.length > 0) {
- Element sourceElement = (Element) nodeMapping
- .getSourceNode();
- sourceNode = sourceElement
- .getAttributeNode(atributeNames[0]);
- end = TextUtil.sourceInnerPosition(visualNode
- .getNodeValue(), offset + length);
- offset = TextUtil.sourceInnerPosition(visualNode
- .getNodeValue(), offset);
- length = end - offset;
- }
- }
- }
- break;
- }
- }
- return new VpeSourceInnerDragInfo(sourceNode, offset, length);
+ if (sourceNode != null) {
+ switch (sourceNode.getNodeType()) {
+ case Node.TEXT_NODE:
+ int end = TextUtil.sourceInnerPosition(visualNode
+ .getNodeValue(), offset + length);
+ offset = TextUtil.sourceInnerPosition(
+ visualNode.getNodeValue(), offset);
+ length = end - offset;
+ break;
+ case Node.ELEMENT_NODE:
+ if (visualNode.getNodeType() == Node.TEXT_NODE) {
+ // it's attribute
+ sourceNode = null;
+ if (isTextEditable(visualNode)) {
+ String[] atributeNames = ((VpeElementMapping) nodeMapping)
+ .getTemplate().getOutputAtributeNames();
+ if (atributeNames != null && atributeNames.length > 0) {
+ Element sourceElement = (Element) nodeMapping
+ .getSourceNode();
+ sourceNode = sourceElement
+ .getAttributeNode(atributeNames[0]);
+ end = TextUtil.sourceInnerPosition(visualNode
+ .getNodeValue(), offset + length);
+ offset = TextUtil.sourceInnerPosition(visualNode
+ .getNodeValue(), offset);
+ length = end - offset;
+ }
+ }
+ }
+ break;
+ }
}
+ return new VpeSourceInnerDragInfo(sourceNode, offset, length);
+ }
public nsIDOMText getOutputTextNode(Attr attr) {
- Element sourceElement = ((Attr) attr).getOwnerElement();
- VpeElementMapping elementMapping = domMapping
- .getNearElementMapping(sourceElement);
- if (elementMapping != null) {
+ Element sourceElement = ((Attr) attr).getOwnerElement();
+ VpeElementMapping elementMapping = domMapping
+ .getNearElementMapping(sourceElement);
+ if (elementMapping != null) {
- return elementMapping.getTemplate().getOutputTextNode(pageContext,
- sourceElement, elementMapping.getData());
- }
- return null;
+ return elementMapping.getTemplate().getOutputTextNode(pageContext,
+ sourceElement, elementMapping.getData());
+ }
+ return null;
}
nsIDOMElement getLastSelectedElement() {
- return xulRunnerEditor.getLastSelectedElement();
+ return xulRunnerEditor.getLastSelectedElement();
}
public void pushIncludeStack(VpeIncludeInfo includeInfo) {
- includeStack.add(includeInfo);
+ includeStack.add(includeInfo);
}
public VpeIncludeInfo popIncludeStack() {
- VpeIncludeInfo includeInfo = null;
- if (includeStack.size() > 0) {
- includeInfo = (VpeIncludeInfo) includeStack.remove(includeStack
- .size() - 1);
- }
- return includeInfo;
+ VpeIncludeInfo includeInfo = null;
+ if (includeStack.size() > 0) {
+ includeInfo = (VpeIncludeInfo) includeStack.remove(includeStack
+ .size() - 1);
}
+ return includeInfo;
+ }
public boolean isFileInIncludeStack(IFile file) {
- if (file == null)
- return false;
- for (int i = 0; i < includeStack.size(); i++) {
- if (file.equals(((VpeIncludeInfo) includeStack.get(i)).getFile())) {
- return true;
- }
- }
- return false;
+ if (file == null)
+ return false;
+ for (int i = 0; i < includeStack.size(); i++) {
+ if (file.equals(((VpeIncludeInfo) includeStack.get(i)).getFile())) {
+ return true;
+ }
}
+ return false;
+ }
protected boolean isCurrentMainDocument() {
- return includeStack.size() <= 1;
+ return includeStack.size() <= 1;
}
public int getCurrentMainIncludeOffset() {
- if (includeStack.size() <= 1)
- return -1;
- VpeIncludeInfo info = (VpeIncludeInfo) includeStack.get(1);
- return ((IndexedRegion) info.getElement()).getStartOffset();
+ if (includeStack.size() <= 1)
+ return -1;
+ VpeIncludeInfo info = (VpeIncludeInfo) includeStack.get(1);
+ return ((IndexedRegion) info.getElement()).getStartOffset();
}
public VpeIncludeInfo getCurrentIncludeInfo() {
- if (includeStack.size() <= 0)
- return null;
- return (VpeIncludeInfo) includeStack.get(includeStack.size() - 1);
+ if (includeStack.size() <= 0)
+ return null;
+ return (VpeIncludeInfo) includeStack.get(includeStack.size() - 1);
}
public VpeIncludeInfo getRootIncludeInfo() {
- if (includeStack.size() <= 1)
- return null;
- return (VpeIncludeInfo) includeStack.get(1);
+ if (includeStack.size() <= 1)
+ return null;
+ return (VpeIncludeInfo) includeStack.get(1);
}
public void dispose() {
- clearIncludeDocuments();
- includeDocuments = null;
- cleanHead();
- domMapping.clear(getContentArea());
- pageContext.dispose();
- super.dispose();
+ clearIncludeDocuments();
+ includeDocuments = null;
+ cleanHead();
+ domMapping.clear(getContentArea());
+ pageContext.dispose();
+ super.dispose();
}
private void clearIncludeDocuments() {
- Collection<Document> documents = includeDocuments.values();
- for (Iterator iterator = documents.iterator(); iterator.hasNext();) {
- Document document = (Document) iterator.next();
- VpeCreatorUtil.releaseDocumentFromRead(document);
- }
- includeDocuments.clear();
+ Collection<Document> documents = includeDocuments.values();
+ for (Iterator iterator = documents.iterator(); iterator.hasNext();) {
+ Document document = (Document) iterator.next();
+ VpeCreatorUtil.releaseDocumentFromRead(document);
}
+ includeDocuments.clear();
+ }
// protected Map createXmlns(Element sourceNode) {
// NamedNodeMap attrs = ((Element) sourceNode).getAttributes();
@@ -2173,7 +2200,7 @@
*/
public VpeDnD getDnd() {
- return dnd;
+ return dnd;
}
/**
@@ -2182,14 +2209,14 @@
*/
public void setDnd(VpeDnD dnd) {
- this.dnd = dnd;
+ this.dnd = dnd;
}
/**
* @return the pageContext
*/
protected VpePageContext getPageContext() {
- return pageContext;
+ return pageContext;
}
/**
@@ -2197,14 +2224,14 @@
* the pageContext to set
*/
protected void setPageContext(VpePageContext pageContext) {
- this.pageContext = pageContext;
+ this.pageContext = pageContext;
}
/**
* @return the visualDocument
*/
protected nsIDOMDocument getVisualDocument() {
- return visualDocument;
+ return visualDocument;
}
/**
@@ -2212,7 +2239,7 @@
* the visualDocument to set
*/
protected void setVisualDocument(nsIDOMDocument visualDocument) {
- this.visualDocument = visualDocument;
+ this.visualDocument = visualDocument;
}
/**
@@ -2221,32 +2248,32 @@
* @return this if file is facelet, otherwize false
*/
private boolean isFacelet() {
- boolean isFacelet = false;
+ boolean isFacelet = false;
- IEditorInput iEditorInput = pageContext.getEditPart().getEditorInput();
- if (iEditorInput instanceof IFileEditorInput) {
- IFileEditorInput iFileEditorInput = (IFileEditorInput) iEditorInput;
+ IEditorInput iEditorInput = pageContext.getEditPart().getEditorInput();
+ if (iEditorInput instanceof IFileEditorInput) {
+ IFileEditorInput iFileEditorInput = (IFileEditorInput) iEditorInput;
- IFile iFile = iFileEditorInput.getFile();
+ IFile iFile = iFileEditorInput.getFile();
- IProject project = iFile.getProject();
- IModelNature nature = EclipseResourceUtil.getModelNature(project);
- if (nature != null) {
- XModel model = nature.getModel();
- XModelObject webXML = WebAppHelper.getWebApp(model);
- XModelObject param = WebAppHelper.findWebAppContextParam(
- webXML, "javax.faces.DEFAULT_SUFFIX"); //$NON-NLS-1$
- if (param != null) {
- String value = param.getAttributeValue("param-value"); //$NON-NLS-1$
+ IProject project = iFile.getProject();
+ IModelNature nature = EclipseResourceUtil.getModelNature(project);
+ if (nature != null) {
+ XModel model = nature.getModel();
+ XModelObject webXML = WebAppHelper.getWebApp(model);
+ XModelObject param = WebAppHelper.findWebAppContextParam(
+ webXML, "javax.faces.DEFAULT_SUFFIX"); //$NON-NLS-1$
+ if (param != null) {
+ String value = param.getAttributeValue("param-value"); //$NON-NLS-1$
- if (value.length() != 0 && iFile.getName().endsWith(value)) {
- isFacelet = true;
- }
- }
- }
- }
+ if (value.length() != 0 && iFile.getName().endsWith(value)) {
+ isFacelet = true;
+ }
+ }
+ }
+ }
- return isFacelet;
+ return isFacelet;
}
/**
@@ -2258,55 +2285,55 @@
*/
protected nsIDOMNode createTextNode(Node sourceNode, boolean registerFlag) {
- String sourceText = sourceNode.getNodeValue();
+ String sourceText = sourceNode.getNodeValue();
- /*
- * Max Areshkau this code causes very slow work of visual editor
- * when we editing in big files txt nodes.For example exmployee.xhtml
- * from JBIDE1105
- *
- * Denis Maliarevich:
- * To fix JBIDE-2003 and JBIDE-2042
- * this code should be uncommented.
- */
- if (sourceText.trim().length() <= 0) {
- if (registerFlag) {
- registerNodes(new VpeNodeMapping(sourceNode, null));
- }
- return null;
- }
+ /*
+ * Max Areshkau this code causes very slow work of visual editor
+ * when we editing in big files txt nodes.For example exmployee.xhtml
+ * from JBIDE1105
+ *
+ * Denis Maliarevich:
+ * To fix JBIDE-2003 and JBIDE-2042
+ * this code should be uncommented.
+ */
+ if (sourceText.trim().length() <= 0) {
+ if (registerFlag) {
+ registerNodes(new VpeNodeMapping(sourceNode, null));
+ }
+ return null;
+ }
- if (faceletFile) {
- Matcher matcher_EL = REGEX_EL.matcher(sourceText);
- if (matcher_EL.find()) {
- BundleMap bundle = pageContext.getBundle();
- int offset = pageContext.getVisualBuilder()
- .getCurrentMainIncludeOffset();
- if (offset == -1)
- offset = ((IndexedRegion) sourceNode).getStartOffset();
- String jsfValue = bundle.getBundleValue(sourceText, offset);
- sourceText = jsfValue;
- }
- }
- String visualText = TextUtil.visualText(sourceText);
+ if (faceletFile) {
+ Matcher matcher_EL = REGEX_EL.matcher(sourceText);
+ if (matcher_EL.find()) {
+ BundleMap bundle = pageContext.getBundle();
+ int offset = pageContext.getVisualBuilder()
+ .getCurrentMainIncludeOffset();
+ if (offset == -1)
+ offset = ((IndexedRegion) sourceNode).getStartOffset();
+ String jsfValue = bundle.getBundleValue(sourceText, offset);
+ sourceText = jsfValue;
+ }
+ }
+ String visualText = TextUtil.visualText(sourceText);
- nsIDOMNode visualNewTextNode = visualDocument
- .createTextNode(visualText);
- nsIDOMElement element = visualDocument.createElement(HTML.TAG_SPAN);
- element.setAttribute(HTML.ATTR_STYLE, ""); //$NON-NLS-1$
- element.appendChild(visualNewTextNode);
- if (registerFlag) {
- registerNodes(new VpeNodeMapping(sourceNode, element));
- }
+ nsIDOMNode visualNewTextNode = visualDocument
+ .createTextNode(visualText);
+ nsIDOMElement element = visualDocument.createElement(HTML.TAG_SPAN);
+ element.setAttribute(HTML.ATTR_STYLE, ""); //$NON-NLS-1$
+ element.appendChild(visualNewTextNode);
+ if (registerFlag) {
+ registerNodes(new VpeNodeMapping(sourceNode, element));
+ }
- return element;
+ return element;
}
/**
* @return the xulRunnerEditor
*/
public XulRunnerEditor getXulRunnerEditor() {
- return xulRunnerEditor;
+ return xulRunnerEditor;
}
/**
@@ -2314,14 +2341,14 @@
* the xulRunnerEditor to set
*/
public void setXulRunnerEditor(XulRunnerEditor xulRunnerEditor) {
- this.xulRunnerEditor = xulRunnerEditor;
+ this.xulRunnerEditor = xulRunnerEditor;
}
public Map<IFile, Document> getIncludeDocuments() {
- return includeDocuments;
+ return includeDocuments;
}
public nsIDOMNode getHeadNode() {
- return visualEditor.getHeadNode();
- }
+ return visualEditor.getHeadNode();
+ }
}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java 2008-07-16 13:45:45 UTC (rev 9151)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java 2008-07-16 13:46:01 UTC (rev 9152)
@@ -14,6 +14,7 @@
import java.util.HashSet;
import java.util.List;
+import org.eclipse.core.resources.IFile;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.Region;
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
@@ -33,54 +34,91 @@
import org.jboss.tools.vpe.editor.template.dnd.VpeDnd;
import org.jboss.tools.vpe.editor.template.resize.VpeResizer;
import org.jboss.tools.vpe.editor.template.textformating.TextFormatingData;
+import org.jboss.tools.vpe.editor.util.ElService;
import org.jboss.tools.vpe.editor.util.NodesManagingUtil;
import org.jboss.tools.vpe.editor.util.SelectionUtil;
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
+import org.mozilla.interfaces.nsIDOMNamedNodeMap;
import org.mozilla.interfaces.nsIDOMNode;
import org.mozilla.interfaces.nsIDOMText;
+import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.Text;
+// TODO: Auto-generated Javadoc
/**
* Class which response for configuration template element from configuration
* file.
- *
*/
public abstract class VpeAbstractTemplate implements VpeTemplate {
- protected boolean caseSensitive;
+
+
+ /** The case sensitive. */
+ protected boolean caseSensitive;
+
+ /** The children. */
protected boolean children;
+
+ /** The modify. */
protected boolean modify;
+ /** The has imaginary border. */
protected boolean hasImaginaryBorder;
- /** a resizer instance */
+ /** a resizer instance. */
private VpeResizer resizer;
// TODO Max Areshkau add DnD support
+ /** The dragger. */
private VpeDnd dragger;
+
+ /** The text formating data. */
private TextFormatingData textFormatingData;
+
+ /** The pseudo content creator. */
private VpePseudoContentCreator pseudoContentCreator;
+ /** The Constant TAG_BREAKER. */
private static final String TAG_BREAKER = VpeTemplateManager.VPE_PREFIX
+ "breaker"; //$NON-NLS-1$
+
+ /** The Constant ATTR_BREAKER_TYPE. */
private static final String ATTR_BREAKER_TYPE = "type"; //$NON-NLS-1$
+
+ /** The Constant ATTR_BREAKER_TYPE_IGNORE. */
private static final String ATTR_BREAKER_TYPE_IGNORE = "ignore"; //$NON-NLS-1$
+
+ /** The Constant ATTR_BREAKER_TYPE_SELECTITEM. */
private static final String ATTR_BREAKER_TYPE_SELECTITEM = "selectItem"; //$NON-NLS-1$
+
+ /** The Constant BREAKER_TYPE_NONE. */
private static final int BREAKER_TYPE_NONE = 0;
+
+ /** The Constant BREAKER_TYPE_IGNORE. */
private static final int BREAKER_TYPE_IGNORE = 1;
+
+ /** The Constant BREAKER_TYPE_SELECTITEM. */
private static final int BREAKER_TYPE_SELECTITEM = 2;
+ /** The Constant TAG_PSEUDOCONTENT. */
private static final String TAG_PSEUDOCONTENT = VpeTemplateManager.VPE_PREFIX
+ "pseudoContent"; //$NON-NLS-1$
+
+ /** The Constant ATTR_PSEUDOCONTENT_DEFAULTTEXT. */
private static final String ATTR_PSEUDOCONTENT_DEFAULTTEXT = "defaultText"; //$NON-NLS-1$
+
+ /** The Constant ATTR_PSEUDOCONTENT_ATTRNAME. */
private static final String ATTR_PSEUDOCONTENT_ATTRNAME = "attrName"; //$NON-NLS-1$
+ /** The breaker type. */
private int breakerType = BREAKER_TYPE_NONE;
+ /** The inline tags. */
static private HashSet<String> inlineTags = new HashSet<String>();
static {
inlineTags.add("b"); //$NON-NLS-1$
@@ -98,6 +136,8 @@
inlineTags.add("button"); //$NON-NLS-1$
inlineTags.add("label"); //$NON-NLS-1$
}
+
+ /** The tag resize constrans. */
static private HashMap<String, Integer> tagResizeConstrans = new HashMap<String, Integer>();
static {
tagResizeConstrans
@@ -130,6 +170,7 @@
"a", Integer.valueOf(VpeTagDescription.RESIZE_CONSTRAINS_NONE)); //$NON-NLS-1$
}
+ /** The break with paragraph tags. */
static private HashSet<String> breakWithParagraphTags = new HashSet<String>();
static {
breakWithParagraphTags.add("b"); //$NON-NLS-1$
@@ -160,6 +201,8 @@
breakWithParagraphTags.add("u"); //$NON-NLS-1$
breakWithParagraphTags.add("var"); //$NON-NLS-1$
}
+
+ /** The break without paragraph tags. */
static private HashSet<String> breakWithoutParagraphTags = new HashSet<String>();
static {
breakWithoutParagraphTags.add("p"); //$NON-NLS-1$
@@ -178,13 +221,11 @@
}
/**
- * Initiates template after its creating
+ * Initiates template after its creating.
*
- * @param templateElement
- * <code>Element</code> with a name "vpe:template" from the
- * template file
- * @param caseSensitive
- * The case sensitive of an element of a source file
+ * @param caseSensitive The case sensitive of an element of a source file
+ * @param templateElement <code>Element</code> with a name "vpe:template" from the
+ * template file
*/
public void init(Element templateElement, boolean caseSensitive) {
this.caseSensitive = caseSensitive;
@@ -204,10 +245,25 @@
init(templateElement);
}
+ /**
+ * Init.
+ *
+ * @param templateElement the template element
+ */
protected void init(Element templateElement) {
initTemplateSections(templateElement, true, true, true, true, true);
}
+ /**
+ * Inits the template sections.
+ *
+ * @param templateElement the template element
+ * @param breakHandler the break handler
+ * @param textFormatingHandler the text formating handler
+ * @param pseudoContentHandler the pseudo content handler
+ * @param resizeHandler the resize handler
+ * @param dndHandler the dnd handler
+ */
protected void initTemplateSections(Element templateElement,
boolean resizeHandler, boolean dndHandler,
boolean textFormatingHandler, boolean breakHandler,
@@ -243,6 +299,11 @@
}
}
+ /**
+ * Inits the resize handler.
+ *
+ * @param templateSection the template section
+ */
private void initResizeHandler(Element templateSection) {
if (resizer == null) {
resizer = new VpeResizer();
@@ -250,6 +311,11 @@
}
}
+ /**
+ * Inits the dnd handler.
+ *
+ * @param templateSection the template section
+ */
private void initDndHandler(Element templateSection) {
if (getDragger() == null) {
@@ -258,12 +324,22 @@
}
}
+ /**
+ * Inits the text formating handler.
+ *
+ * @param templateSection the template section
+ */
private void initTextFormatingHandler(Element templateSection) {
if (textFormatingData == null) {
textFormatingData = new TextFormatingData(templateSection);
}
}
+ /**
+ * Inits the break handler.
+ *
+ * @param templateSection the template section
+ */
private void initBreakHandler(Element templateSection) {
if (breakerType == BREAKER_TYPE_NONE) {
String typeValue = templateSection.getAttribute(ATTR_BREAKER_TYPE);
@@ -278,6 +354,11 @@
}
}
+ /**
+ * Inits the pseudo content handler.
+ *
+ * @param templateSection the template section
+ */
private void initPseudoContentHandler(Element templateSection) {
if (pseudoContentCreator == null) {
if ("yes".equalsIgnoreCase(templateSection.getAttribute(ATTR_PSEUDOCONTENT_DEFAULTTEXT))) { //$NON-NLS-1$
@@ -314,6 +395,11 @@
}
}
+ /**
+ * Inits the template section.
+ *
+ * @param templateSection the template section
+ */
protected void initTemplateSection(Element templateSection) {
}
@@ -321,30 +407,40 @@
* Is invoked after construction of all child nodes of the current visual
* node.
*
- * @param pageContext
- * Contains the information on edited page.
- * @param sourceNode
- * The current node of the source tree.
- * @param visualDocument
- * The document of the visual tree.
- * @param data
- * Object <code>VpeCreationData</code>, built by a method
- * <code>create</code>
+ * @param visualDocument The document of the visual tree.
+ * @param sourceNode The current node of the source tree.
+ * @param data Object <code>VpeCreationData</code>, built by a method
+ * <code>create</code>
+ * @param pageContext Contains the information on edited page.
*/
public void validate(VpePageContext pageContext, Node sourceNode,
nsIDOMDocument visualDocument, VpeCreationData data) {
}
+ /** The f current region to format. */
IRegion fCurrentRegionToFormat = null;
+ /**
+ * Gets the region to format.
+ *
+ * @return the region to format
+ */
private IRegion getRegionToFormat() {
return fCurrentRegionToFormat;
}
+ /**
+ * Clear region to format.
+ */
private void clearRegionToFormat() {
fCurrentRegionToFormat = null;
}
+ /**
+ * Update region to format.
+ *
+ * @param node the node
+ */
private void updateRegionToFormat(Node node) {
if (node instanceof IndexedRegion) {
IndexedRegion region = (IndexedRegion) node;
@@ -368,6 +464,11 @@
}
}
+ /**
+ * Reformat callback.
+ *
+ * @param pageContext the page context
+ */
private void reformatCallback(VpePageContext pageContext) {
try {
StructuredTextEditor editor = pageContext.getEditPart()
@@ -387,24 +488,17 @@
}
/**
- * Processes keyboard input (without the pressed key Ctrl)
+ * Processes keyboard input (without the pressed key Ctrl).
*
- * @param pageContext
- * Contains the information on edited page.
- * @param sourceDocument
- * The document of the source tree.
- * @param sourceNode
- * The current node of the source tree.
- * @param visualNode
- * The current node of the visual tree.
- * @param data
- * The arbitrary data, built by a method <code>create</code>
- * @param charCode
- * Code of the pressed key
- * @param selection
- * The current selection
- * @param formatter
- * Interface for formatting the source text
+ * @param visualNode The current node of the visual tree.
+ * @param sourceNode The current node of the source tree.
+ * @param charCode Code of the pressed key
+ * @param data The arbitrary data, built by a method <code>create</code>
+ * @param pageContext Contains the information on edited page.
+ * @param sourceDocument The document of the source tree.
+ * @param selection The current selection
+ * @param formatter Interface for formatting the source text
+ *
* @return <code>true</code> if the key is processed
*/
public boolean nonctrlKeyPressHandler(VpePageContext pageContext,
@@ -424,6 +518,20 @@
}
}
+ /**
+ * Nonctrl key press handler impl.
+ *
+ * @param visualNode the visual node
+ * @param sourceNode the source node
+ * @param charCode the char code
+ * @param data the data
+ * @param pageContext the page context
+ * @param sourceDocument the source document
+ * @param selection the selection
+ * @param formatter the formatter
+ *
+ * @return true, if nonctrl key press handler impl
+ */
private boolean nonctrlKeyPressHandlerImpl(VpePageContext pageContext,
Document sourceDocument, Node sourceNode, nsIDOMNode visualNode,
Object data, long charCode, VpeSourceSelection selection,
@@ -695,6 +803,14 @@
return false;
}
+ /**
+ * Make new parent.
+ *
+ * @param clone the clone
+ * @param parent the parent
+ *
+ * @return the node
+ */
private Node makeNewParent(Node parent, boolean clone) {
Node newParent = null;
if (parent != null) {
@@ -711,6 +827,12 @@
return newParent;
}
+ /**
+ * Sets the cursor.
+ *
+ * @param node the node
+ * @param pageContext the page context
+ */
private void setCursor(VpePageContext pageContext, Node node) {
int nodeOffset = ((IndexedRegion) node).getStartOffset();
if (node.getNodeType() == Node.ELEMENT_NODE) {
@@ -724,16 +846,12 @@
}
/**
- * Is invoked before removal of the visiblis node from the tree
+ * Is invoked before removal of the visiblis node from the tree.
*
- * @param pageContext
- * Contains the information on edited page.
- * @param sourceNode
- * The current node of the source tree.
- * @param visualNode
- * The current node of the visual tree.
- * @param data
- * The arbitrary data, built by a method <code>create</code>
+ * @param visualNode The current node of the visual tree.
+ * @param sourceNode The current node of the source tree.
+ * @param data The arbitrary data, built by a method <code>create</code>
+ * @param pageContext Contains the information on edited page.
*/
public void beforeRemove(VpePageContext pageContext, Node sourceNode,
nsIDOMNode visualNode, Object data) {
@@ -743,16 +861,13 @@
* At a modification of the node of an source tree, the method update for
* this node is invoked. Template can indicate other node for update
*
- * @param pageContext
- * Contains the information on edited page.
- * @param sourceNode
- * The current node of the source tree.
- * @param visualNode
- * The current node of the visual tree.
- * @param data
- * The arbitrary data, built by a method <code>create</code>
+ * @param visualNode The current node of the visual tree.
+ * @param sourceNode The current node of the source tree.
+ * @param data The arbitrary data, built by a method <code>create</code>
+ * @param pageContext Contains the information on edited page.
+ *
* @return For this node of an source tree the method update is invoked. If
- * null, that is invoked update for current source node
+ * null, that is invoked update for current source node
*/
public Node getNodeForUptate(VpePageContext pageContext, Node sourceNode,
nsIDOMNode visualNode, Object data) {
@@ -760,36 +875,26 @@
}
/**
- * Is invoked at resize of an element visual tree
+ * Is invoked at resize of an element visual tree.
*
- * @param pageContext
- * Contains the information on edited page.
- * @param sourceElement
- * The current element of the source tree.
- * @param visualDocument
- * The document of the visual tree.
- * @param visualElement
- * The current element of the visual tree.
- * @param data
- * The arbitrary data, built by a method <code>create</code>
- * @param resizerConstrains
- * Code of resizer:<br>
- * top-left: 1<br>
- * top: 2<br>
- * top-right: 4<br>
- * left: 8<br>
- * right: 16<br>
- * bottomleft: 32<br>
- * bottom: 64<br>
- * bottom-right: 128<br>
- * @param top
- * Element top
- * @param left
- * Element left
- * @param width
- * Element width
- * @param height
- * Element height
+ * @param sourceElement The current element of the source tree.
+ * @param visualDocument The document of the visual tree.
+ * @param width Element width
+ * @param top Element top
+ * @param height Element height
+ * @param left Element left
+ * @param data The arbitrary data, built by a method <code>create</code>
+ * @param pageContext Contains the information on edited page.
+ * @param resizerConstrains Code of resizer:<br>
+ * top-left: 1<br>
+ * top: 2<br>
+ * top-right: 4<br>
+ * left: 8<br>
+ * right: 16<br>
+ * bottomleft: 32<br>
+ * bottom: 64<br>
+ * bottom-right: 128<br>
+ * @param visualElement The current element of the visual tree.
*/
public void resize(VpePageContext pageContext, Element sourceElement,
nsIDOMDocument visualDocument, nsIDOMElement visualElement,
@@ -803,18 +908,14 @@
}
/**
- * Checks a capability of drag of visual element
+ * Checks a capability of drag of visual element.
*
- * @param pageContext
- * Contains the information on edited page.
- * @param sourceElement
- * The current element of the source tree.
- * @param visualDocument
- * The document of the visual tree.
- * @param visualElement
- * The current element of the visual tree.
- * @param data
- * The arbitrary data, built by a method <code>create</code>
+ * @param sourceElement The current element of the source tree.
+ * @param visualDocument The document of the visual tree.
+ * @param data The arbitrary data, built by a method <code>create</code>
+ * @param pageContext Contains the information on edited page.
+ * @param visualElement The current element of the visual tree.
+ *
* @return <code>true</code> The element can be dragged
*/
public boolean canInnerDrag(VpePageContext pageContext,
@@ -830,14 +931,12 @@
}
/**
- * Checks a capability to drop an element in the container
+ * Checks a capability to drop an element in the container.
*
- * @param pageContext
- * Contains the information on edited page.
- * @param container
- * Element-Container
- * @param sourceDragNode
- * Node for drop
+ * @param container Element-Container
+ * @param sourceDragNode Node for drop
+ * @param pageContext Contains the information on edited page.
+ *
* @return <code>true</code> The node can be dropped
*/
public boolean canInnerDrop(VpePageContext pageContext, Node container,
@@ -852,14 +951,11 @@
}
/**
- * Is invoked at drop of an element visual tree
+ * Is invoked at drop of an element visual tree.
*
- * @param pageContext
- * Contains the information on edited page.
- * @param dragInfo
- * The information on the dragged element
- * @param dropInfo
- * The information on the drop container
+ * @param dropInfo The information on the drop container
+ * @param pageContext Contains the information on edited page.
+ * @param dragInfo The information on the dragged element
*/
public void innerDrop(VpePageContext pageContext,
VpeSourceInnerDragInfo dragInfo, VpeSourceInnerDropInfo dropInfo) {
@@ -869,6 +965,15 @@
// }
}
+ /**
+ * Delete from string.
+ *
+ * @param end the end
+ * @param data the data
+ * @param begin the begin
+ *
+ * @return the string
+ */
protected String deleteFromString(String data, String begin, String end) {
int startPosition = data.indexOf(begin);
@@ -887,24 +992,18 @@
/**
* Checks, whether it is necessary to re-create an element at change of
- * attribute
+ * attribute.
*
- * @param pageContext
- * Contains the information on edited page.
- * @param sourceElement
- * The current element of the source tree.
- * @param visualDocument
- * The document of the visual tree.
- * @param visualNode
- * The current node of the visual tree.
- * @param data
- * The arbitrary data, built by a method <code>create</code>
- * @param name
- * Atrribute name
- * @param value
- * Attribute value
+ * @param sourceElement The current element of the source tree.
+ * @param value Attribute value
+ * @param visualDocument The document of the visual tree.
+ * @param visualNode The current node of the visual tree.
+ * @param data The arbitrary data, built by a method <code>create</code>
+ * @param pageContext Contains the information on edited page.
+ * @param name Atrribute name
+ *
* @return <code>true</code> if it is required to re-create an element at a
- * modification of attribute, <code>false</code> otherwise.
+ * modification of attribute, <code>false</code> otherwise.
*/
public boolean isRecreateAtAttrChange(VpePageContext pageContext,
Element sourceElement, nsIDOMDocument visualDocument,
@@ -913,21 +1012,35 @@
}
/**
+ * Checks if is children.
+ *
* @return <code>true</code> if the element can have children
*/
public boolean isChildren() {
return children;
}
+ /**
+ * Checks if is modify.
+ *
+ * @return true, if is modify
+ */
public boolean isModify() {
return modify;
}
+ /**
+ * Sets the modify.
+ *
+ * @param modify the modify
+ */
public void setModify(boolean modify) {
this.modify = modify;
}
/**
+ * Checks if is case sensitive.
+ *
* @return <code>true</code> if the element is case sensitive
*/
public boolean isCaseSensitive() {
@@ -935,7 +1048,7 @@
}
/**
- * Returns the data for formatting an element of source tree
+ * Returns the data for formatting an element of source tree.
*
* @return <code>TextFormatingData</code>
*/
@@ -944,18 +1057,14 @@
}
/**
- * Returns <code>VpeTagDescription</code>
+ * Returns <code>VpeTagDescription</code>.
*
- * @param pageContext
- * Contains the information on edited page.
- * @param sourceElement
- * The current element of the source tree.
- * @param visualDocument
- * The document of the visual tree.
- * @param visualElement
- * The current element of the visual tree.
- * @param data
- * The arbitrary data, built by a method <code>create</code>
+ * @param sourceElement The current element of the source tree.
+ * @param visualDocument The document of the visual tree.
+ * @param data The arbitrary data, built by a method <code>create</code>
+ * @param pageContext Contains the information on edited page.
+ * @param visualElement The current element of the visual tree.
+ *
* @return <code>VpeTagDescription</code>
*/
public VpeTagDescription getTagDescription(VpePageContext pageContext,
@@ -978,20 +1087,13 @@
* Sets value of attribute of the current visual element. Is invoked at
* change of attribute of an source element.
*
- * @param pageContext
- * Contains the information on edited page.
- * @param sourceElement
- * The current element of the source tree.
- * @param visualDocument
- * The document of the visual tree.
- * @param visualNode
- * The current node of the visual tree.
- * @param data
- * The arbitrary data, built by a method <code>create</code>
- * @param name
- * Attribute name.
- * @param value
- * Attribute value.
+ * @param sourceElement The current element of the source tree.
+ * @param value Attribute value.
+ * @param visualDocument The document of the visual tree.
+ * @param visualNode The current node of the visual tree.
+ * @param data The arbitrary data, built by a method <code>create</code>
+ * @param pageContext Contains the information on edited page.
+ * @param name Attribute name.
*/
public void setAttribute(VpePageContext pageContext, Element sourceElement,
nsIDOMDocument visualDocument, nsIDOMNode visualNode, Object data,
@@ -1001,18 +1103,12 @@
/**
* Informs on remove of attribute of the current source element.
*
- * @param pageContext
- * Contains the information on edited page.
- * @param sourceElement
- * The current element of the source tree.
- * @param visualDocument
- * The document of the visual tree.
- * @param visualNode
- * The current node of the visual tree.
- * @param data
- * The arbitrary data, built by a method <code>create</code>
- * @param name
- * Attribute name.
+ * @param sourceElement The current element of the source tree.
+ * @param visualDocument The document of the visual tree.
+ * @param visualNode The current node of the visual tree.
+ * @param data The arbitrary data, built by a method <code>create</code>
+ * @param pageContext Contains the information on edited page.
+ * @param name Attribute name.
*/
public void removeAttribute(VpePageContext pageContext,
Element sourceElement, nsIDOMDocument visualDocument,
@@ -1021,7 +1117,7 @@
/**
* Returns a list of attributes of an element of the source tree, the values
- * which one are mapped in the visiblis editor
+ * which one are mapped in the visiblis editor.
*
* @return attrubute name array
*/
@@ -1032,14 +1128,12 @@
/**
* If the value of attribute of an element of an source tree is mapped by
* the way of text node of a visual treer, this method returns the text
- * node, otherwise - null
+ * node, otherwise - null.
*
- * @param pageContext
- * Contains the information on edited page.
- * @param sourceElement
- * The current element of the source tree.
- * @param data
- * The arbitrary data, built by a method <code>create</code>
+ * @param sourceElement The current element of the source tree.
+ * @param data The arbitrary data, built by a method <code>create</code>
+ * @param pageContext Contains the information on edited page.
+ *
* @return Text node or null
*/
public nsIDOMText getOutputTextNode(VpePageContext pageContext,
@@ -1048,14 +1142,21 @@
}
/**
+ * Checks if is output attributes.
+ *
+ * @return true, if is output attributes
+ *
* @deprecated
- * @return
*/
public boolean isOutputAttributes() {
return false;
}
/**
+ * Gets the type.
+ *
+ * @return the type
+ *
* @deprecated
*/
public int getType() {
@@ -1063,49 +1164,50 @@
}
/**
+ * Gets the any data.
+ *
+ * @return the any data
+ *
* @deprecated
- * @return
*/
public VpeAnyData getAnyData() {
return null;
}
/**
+ * Sets the source attribute selection.
+ *
+ * @param sourceElement The current element of the source tree.
+ * @param data the data
+ * @param length the length
+ * @param pageContext Contains the information on edited page.
+ * @param offset the offset
+ *
* @deprecated
- * @param pageContext
- * Contains the information on edited page.
- * @param sourceElement
- * The current element of the source tree.
- * @param offset
- * @param length
- * @param data
*/
public void setSourceAttributeSelection(VpePageContext pageContext,
Element sourceElement, int offset, int length, Object data) {
}
/**
+ * Sets the source attribute value.
+ *
+ * @param sourceElement The current element of the source tree.
+ * @param data The arbitrary data, built by a method <code>create</code>
+ * @param pageContext Contains the information on edited page.
+ *
* @deprecated
- * @param pageContext
- * Contains the information on edited page.
- * @param sourceElement
- * The current element of the source tree.
- * @param data
- * The arbitrary data, built by a method <code>create</code>
*/
public void setSourceAttributeValue(VpePageContext pageContext,
Element sourceElement, Object data) {
}
/**
- * Is invoked at a change of bundle values
+ * Is invoked at a change of bundle values.
*
- * @param pageContext
- * Contains the information on edited page.
- * @param sourceElement
- * The current element of the source tree.
- * @param data
- * The arbitrary data, built by a method <code>create</code>
+ * @param sourceElement The current element of the source tree.
+ * @param data The arbitrary data, built by a method <code>create</code>
+ * @param pageContext Contains the information on edited page.
*/
public void refreshBundleValues(VpePageContext pageContext,
Element sourceElement, Object data) {
@@ -1113,28 +1215,22 @@
/**
* Opens proprties editor for bundle value Is invoked at double mouse click
- * on visual element
+ * on visual element.
*
- * @param pageContext
- * Contains the information on edited page.
- * @param sourceElement
- * The current element of the source tree.
- * @param data
- * The arbitrary data, built by a method <code>create</code>
+ * @param sourceElement The current element of the source tree.
+ * @param data The arbitrary data, built by a method <code>create</code>
+ * @param pageContext Contains the information on edited page.
*/
public void openBundleEditors(VpePageContext pageContext,
Element sourceElement, Object data) {
}
/**
- * Opens editor of source file for include-element
+ * Opens editor of source file for include-element.
*
- * @param pageContext
- * Contains the information on edited page.
- * @param sourceElement
- * The current element of the source tree.
- * @param data
- * The arbitrary data, built by a method <code>create</code>
+ * @param sourceElement The current element of the source tree.
+ * @param data The arbitrary data, built by a method <code>create</code>
+ * @param pageContext Contains the information on edited page.
*/
public void openIncludeEditor(VpePageContext pageContext,
Element sourceElement, Object data) {
@@ -1142,16 +1238,12 @@
/**
* The unfilled element of an source tree can be mapped in the visiblis
- * editor with the default contents This method fills default contents
+ * editor with the default contents This method fills default contents.
*
- * @param pageContext
- * Contains the information on edited page.
- * @param sourceContainer
- * The current element of the source tree.
- * @param visualContainer
- * The current element of the visual tree.
- * @param visualDocument
- * The document of the visual tree.
+ * @param visualDocument The document of the visual tree.
+ * @param pageContext Contains the information on edited page.
+ * @param sourceContainer The current element of the source tree.
+ * @param visualContainer The current element of the visual tree.
*/
public void setPseudoContent(VpePageContext pageContext,
Node sourceContainer, nsIDOMNode visualContainer,
@@ -1166,15 +1258,27 @@
}
}
+ /**
+ * Contains text.
+ *
+ * @return true, if contains text
+ */
public boolean containsText() {
return true;
}
+ /**
+ * Checks for imaginary border.
+ *
+ * @return true, if has imaginary border
+ */
public boolean hasImaginaryBorder() {
return hasImaginaryBorder;
}
/**
+ * Gets the dragger.
+ *
* @return the dragger
*/
public VpeDnd getDragger() {
@@ -1183,8 +1287,9 @@
}
/**
- * @param dragger
- * the dragger to set
+ * Sets the dragger.
+ *
+ * @param dragger the dragger to set
*/
public void setDragger(VpeDnd dragger) {
this.dragger = dragger;
@@ -1199,6 +1304,15 @@
* org.jboss.tools.vpe.editor.mapping.VpeElementData,
* org.jboss.tools.vpe.editor.mapping.VpeDomMapping)
*/
+ /**
+ * Gets the node data.
+ *
+ * @param domMapping the dom mapping
+ * @param elementData the element data
+ * @param node the node
+ *
+ * @return the node data
+ */
public NodeData getNodeData(nsIDOMNode node, VpeElementData elementData,
VpeDomMapping domMapping) {
@@ -1227,6 +1341,16 @@
* (org.jboss.tools.vpe.editor.mapping.VpeElementMapping, int, int,
* org.jboss.tools.vpe.editor.mapping.VpeDomMapping)
*/
+ /**
+ * Gets the visual node by by source position.
+ *
+ * @param domMapping the dom mapping
+ * @param focusPosition the focus position
+ * @param anchorPosition the anchor position
+ * @param elementMapping the element mapping
+ *
+ * @return the visual node by by source position
+ */
public nsIDOMNode getVisualNodeByBySourcePosition(
VpeElementMapping elementMapping, int focusPosition,
int anchorPosition, VpeDomMapping domMapping) {
@@ -1248,6 +1372,14 @@
}
+ /**
+ * Find node by position.
+ *
+ * @param position the position
+ * @param elementData the element data
+ *
+ * @return the ns IDOM node
+ */
private nsIDOMNode findNodeByPosition(VpeElementData elementData,
int position) {
@@ -1280,6 +1412,15 @@
* org.mozilla.interfaces.nsIDOMNode,
* org.jboss.tools.vpe.editor.mapping.VpeElementMapping)
*/
+ /**
+ * Open bundle.
+ *
+ * @param visualNode the visual node
+ * @param pageContext the page context
+ * @param elementMapping the element mapping
+ *
+ * @return true, if open bundle
+ */
public boolean openBundle(VpePageContext pageContext,
nsIDOMNode visualNode, VpeElementMapping elementMapping) {
@@ -1300,4 +1441,54 @@
return false;
}
+
+
+ /**
+ * After template created.
+ *
+ * @param visualDocument the visual document
+ * @param sourceNode the source node
+ * @param pageContext the page context
+ */
+ public void afterTemplateCreated(VpePageContext pageContext, nsIDOMElement source, nsIDOMDocument visualDocument) {
+
+// final IFile file = pageContext.getVisualBuilder().getCurrentIncludeInfo().getFile();
+//
+// if ((file != null) && ElService.getInstance().isAvailable(file)) {
+// final nsIDOMNamedNodeMap nodeMap = source.getAttributes();
+// for (int i = 0; i < nodeMap.getLength(); i++) {
+// nsIDOMNode n = nodeMap.item(i);
+//
+// source.setAttribute(n.getNodeName(), ElService.getInstance().replaceEl(file, n.getNodeValue()));
+//
+// }
+//// if(source.getNodeName().equalsIgnoreCase("img")){
+//// source.setAttribute("src", ElService.getInstance().replaceEl(file, source.getAttribute("src")));
+//// }
+// if ((source.getChildNodes() != null) && source.getChildNodes().getLength() > 0) {
+// for (int j = 0; j < source.getChildNodes().getLength(); j++) {
+// if (source.getChildNodes().item(j).getNodeType() == nsIDOMNode.ELEMENT_NODE) {
+// afterTemplateCreated(pageContext, (nsIDOMElement) source.getChildNodes().item(j).queryInterface(
+// nsIDOMElement.NS_IDOMELEMENT_IID), visualDocument);
+// }
+// }
+// }
+// }
+//
+// System.err.println("Hello world4");
+ }
+
+ public void beforeTemplateCreated(VpePageContext pageContext, Node sourceNode, nsIDOMDocument domDocument) {
+ final IFile file = pageContext.getVisualBuilder().getCurrentIncludeInfo().getFile();
+
+ if ((file != null) && (sourceNode.getNodeType() == Node.ELEMENT_NODE) && ElService.getInstance().isAvailable(file)) {
+ final NamedNodeMap nodeMap = sourceNode.getAttributes();
+ for (int i = 0; i < nodeMap.getLength(); i++) {
+ final Attr n = (Attr)nodeMap.item(i);
+
+ n.setValue(ElService.getInstance().replaceEl(file, n.getValue()));
+
+ }
+ }
+ }
}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplate.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplate.java 2008-07-16 13:45:45 UTC (rev 9151)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplate.java 2008-07-16 13:46:01 UTC (rev 9152)
@@ -20,6 +20,7 @@
import org.jboss.tools.vpe.editor.mapping.VpeElementMapping;
import org.jboss.tools.vpe.editor.selection.VpeSourceSelection;
import org.jboss.tools.vpe.editor.template.textformating.TextFormatingData;
+import org.jboss.tools.vpe.editor.util.IVpeTemplateAdvice;
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
import org.mozilla.interfaces.nsIDOMNode;
@@ -28,8 +29,9 @@
import org.w3c.dom.Element;
import org.w3c.dom.Node;
-public interface VpeTemplate {
+public interface VpeTemplate extends IVpeTemplateAdvice {
+
/**
* Initiates template after its creating
*
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElService.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElService.java 2008-07-16 13:45:45 UTC (rev 9151)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElService.java 2008-07-16 13:46:01 UTC (rev 9152)
@@ -1,42 +1,72 @@
+
+
package org.jboss.tools.vpe.editor.util;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.Assert;
import org.jboss.tools.vpe.editor.css.ELReferenceList;
import org.jboss.tools.vpe.editor.css.ResourceReference;
+
/**
* The {@link IELService} implementation.
*
* @author Eugeny Stherbin
*/
public final class ElService implements IELService {
-
+
/** The Constant INSTANCE. */
private static final ElService INSTANCE = new ElService();
-
+
/**
+ * Checks if is available.
+ *
+ * @param resourceFile the resource file
+ *
+ * @return true, if is available
+ */
+ public boolean isAvailable(IFile resourceFile) {
+ boolean rst = false;
+ final ResourceReference[] references = ELReferenceList.getInstance().getAllResources(resourceFile);
+
+ if ((references != null) && (references.length > 0)) {
+ rst = true;
+ }
+ return rst;
+ }
+
+ /**
* Gets the singleton instance.
*
* @return the singleton instance
*/
- public static IELService getInstance(){
+ public static IELService getInstance() {
return INSTANCE;
}
/**
+ * Replace el.
*
+ * @param resourceFile the resource file
+ * @param resourceString the resource string
+ *
+ * @return the string
+ *
* @see IELService#getReplacedElValue(IFile, String)
*/
public String replaceEl(IFile resourceFile, String resourceString) {
- Assert.isNotNull(resourceString);
+ // Assert.isNotNull(resourceString);
+ if(resourceString == null){
+ return "";
+ }
Assert.isNotNull(resourceFile);
String rst = resourceString;
-
+
final ResourceReference[] references = ELReferenceList.getInstance().getAllResources(resourceFile);
-
- if((references!=null) && (references.length > 0)){
- rst = replace(resourceString,references);
+
+ if ((references != null) && (references.length > 0)) {
+ rst = replace(resourceString, references);
}
return rst;
}
@@ -53,14 +83,11 @@
String result = resourceString;
for (ResourceReference rf : references) {
- if (resourceString.contains(rf.getProperties())) {
- result = result.replace(rf.getProperties(), rf.getLocation());
+ if (resourceString.contains(rf.getLocation())) {
+ result = result.replace(rf.getLocation(),rf.getProperties());
}
}
return result;
}
-
-
-
-
+
}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/IELService.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/IELService.java 2008-07-16 13:45:45 UTC (rev 9151)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/IELService.java 2008-07-16 13:46:01 UTC (rev 9152)
@@ -6,10 +6,11 @@
import org.eclipse.core.resources.IFile;
+// TODO: Auto-generated Javadoc
/**
- * The service that substitute El values in vpe source editor.
- * For more details see issues
- * http://jira.jboss.com/jira/browse/JBIDE-2010
+ * The service that substitute El values in vpe source editor.
+ * For more details see issues
+ * http://jira.jboss.com/jira/browse/JBIDE-2010
* and
* http://jira.jboss.com/jira/browse/JBIDE-1410
*
@@ -18,13 +19,23 @@
public interface IELService {
/**
- * Return the {@link String} with substitued el values for given resource.
+ * Return the {@link String} with substitued el values for given resource.
*
- * @param resourceFile the resource file where resource
+ * @param resourceFile the resource file where resource
* @param resourceString the source string that will be substitute
*
* @return string where el values was substituted.
*/
String replaceEl(IFile resourceFile, String resourceString);
+
+
+ /**
+ * Checks if is available.
+ *
+ * @param resourceFile the resource file
+ *
+ * @return true, if is available
+ */
+ boolean isAvailable(IFile resourceFile);
}
Added: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/IVpeTemplateAdvice.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/IVpeTemplateAdvice.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/IVpeTemplateAdvice.java 2008-07-16 13:46:01 UTC (rev 9152)
@@ -0,0 +1,26 @@
+package org.jboss.tools.vpe.editor.util;
+
+import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.mozilla.interfaces.nsIDOMDocument;
+import org.mozilla.interfaces.nsIDOMElement;
+import org.w3c.dom.Node;
+
+/**
+ * The Interface IVpeTemplateAdvice.
+ */
+public interface IVpeTemplateAdvice {
+
+
+ /**
+ * After template created.
+ *
+ * @param visualDocument the visual document
+ * @param sourceNode the source node
+ * @param pageContext the page context
+ */
+ void afterTemplateCreated(VpePageContext pageContext, nsIDOMElement sourceNode,
+ nsIDOMDocument visualDocument);
+
+
+ void beforeTemplateCreated(VpePageContext pageContext,Node sourceNode,nsIDOMDocument domDocument);
+}
Property changes on: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/IVpeTemplateAdvice.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
16 years, 6 months
JBoss Tools SVN: r9151 - trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces.
by jbosstools-commits@lists.jboss.org
Author: estherbin
Date: 2008-07-16 09:45:45 -0400 (Wed, 16 Jul 2008)
New Revision: 9151
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/ComponentUtil.java
Log:
Make simple el substitution for the https://jira.jboss.com:8443/jira/browse/JBIDE-2010
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/ComponentUtil.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/ComponentUtil.java 2008-07-16 12:54:51 UTC (rev 9150)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/ComponentUtil.java 2008-07-16 13:45:45 UTC (rev 9151)
@@ -28,6 +28,8 @@
import org.jboss.tools.jsf.vpe.richfaces.template.util.RichFaces;
import org.jboss.tools.vpe.editor.bundle.BundleMap;
import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.css.ELReferenceList;
+import org.jboss.tools.vpe.editor.util.ElService;
import org.mozilla.interfaces.nsIDOMElement;
import org.mozilla.interfaces.nsIDOMNode;
import org.mozilla.interfaces.nsIDOMNodeList;
@@ -469,10 +471,11 @@
public static void setImgFromResources(VpePageContext pageContext, nsIDOMElement img, String fileImageName, String undefinedImgName) {
IEditorInput input = pageContext.getEditPart().getEditorInput();
IPath inputPath = getInputParentPath(input);
- File file = new File(inputPath.toOSString() + File.separator + fileImageName);
+ String path = ElService.getInstance().replaceEl(pageContext.getVisualBuilder().getCurrentIncludeInfo().getFile(), fileImageName);
+ File file = new File(inputPath.toOSString() + File.separator + path);
if (file.exists()) {
img.setAttribute(HtmlComponentUtil.HTML_ATR_SRC, HtmlComponentUtil.FILE_PROTOCOL + inputPath.toOSString() + File.separator
- + fileImageName);
+ + path);
} else {
img.setAttribute(HtmlComponentUtil.HTML_ATR_SRC, undefinedImgName);
}
16 years, 6 months
JBoss Tools SVN: r9149 - trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2008-07-15 17:15:54 -0400 (Tue, 15 Jul 2008)
New Revision: 9149
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/JBossServerStartupLaunchConfiguration.java
Log:
JBIDE-2479 - added core exceptions if the server is corrupt for some reason
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/JBossServerStartupLaunchConfiguration.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/JBossServerStartupLaunchConfiguration.java 2008-07-15 19:07:36 UTC (rev 9148)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/JBossServerStartupLaunchConfiguration.java 2008-07-15 21:15:54 UTC (rev 9149)
@@ -70,7 +70,13 @@
public static void forceDefaultsSet(ILaunchConfigurationWorkingCopy wc, IServer server) throws CoreException {
JBossServer jbs = findJBossServer(server.getId());
+ if( jbs == null )
+ throw new CoreException(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID, "Server " + server.getName() + " is not a proper JBoss Server"));
+
String serverHome = getServerHome(jbs);
+ if( serverHome == null )
+ throw new CoreException(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID, "Server " + server.getName() + " is corrupt and the server home is unable to be located."));
+
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, getDefaultArgs(jbs));
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, getDefaultVMArgs(jbs));
16 years, 6 months
JBoss Tools SVN: r9148 - in trunk/vpe/plugins/org.jboss.tools.vpe.docbook: META-INF and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2008-07-15 15:07:36 -0400 (Tue, 15 Jul 2008)
New Revision: 9148
Added:
trunk/vpe/plugins/org.jboss.tools.vpe.docbook/.classpath
trunk/vpe/plugins/org.jboss.tools.vpe.docbook/.project
trunk/vpe/plugins/org.jboss.tools.vpe.docbook/META-INF/
trunk/vpe/plugins/org.jboss.tools.vpe.docbook/META-INF/MANIFEST.MF
trunk/vpe/plugins/org.jboss.tools.vpe.docbook/build.properties
trunk/vpe/plugins/org.jboss.tools.vpe.docbook/plugin.xml
trunk/vpe/plugins/org.jboss.tools.vpe.docbook/templates/
trunk/vpe/plugins/org.jboss.tools.vpe.docbook/templates/docbook.xml
trunk/vpe/plugins/org.jboss.tools.vpe.docbook/templates/xinclude.xml
Log:
docbook example template for VPE
initial version
Added: trunk/vpe/plugins/org.jboss.tools.vpe.docbook/.classpath
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.docbook/.classpath (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.docbook/.classpath 2008-07-15 19:07:36 UTC (rev 9148)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Property changes on: trunk/vpe/plugins/org.jboss.tools.vpe.docbook/.classpath
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/vpe/plugins/org.jboss.tools.vpe.docbook/.project
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.docbook/.project (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.docbook/.project 2008-07-15 19:07:36 UTC (rev 9148)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.vpe.docbook</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Property changes on: trunk/vpe/plugins/org.jboss.tools.vpe.docbook/.project
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/vpe/plugins/org.jboss.tools.vpe.docbook/META-INF/MANIFEST.MF
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.docbook/META-INF/MANIFEST.MF (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.docbook/META-INF/MANIFEST.MF 2008-07-15 19:07:36 UTC (rev 9148)
@@ -0,0 +1,10 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Docbook Xml Visual Editor Plug-in
+Bundle-SymbolicName: org.jboss.tools.vpe.docbook;singleton:=true
+Bundle-Version: 1.0.0
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.jboss.tools.jst.jsp,
+ org.jboss.tools.vpe
+Eclipse-LazyStart: true
Property changes on: trunk/vpe/plugins/org.jboss.tools.vpe.docbook/META-INF/MANIFEST.MF
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/vpe/plugins/org.jboss.tools.vpe.docbook/build.properties
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.docbook/build.properties (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.docbook/build.properties 2008-07-15 19:07:36 UTC (rev 9148)
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
Property changes on: trunk/vpe/plugins/org.jboss.tools.vpe.docbook/build.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/vpe/plugins/org.jboss.tools.vpe.docbook/plugin.xml
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.docbook/plugin.xml (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.docbook/plugin.xml 2008-07-15 19:07:36 UTC (rev 9148)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension
+ point="org.jboss.tools.vpe.templates">
+ <templates
+ name="Web Deployment Descriptor"
+ path="templates/docbook.xml"></templates>
+ <templates
+ name="XInclude"
+ path="templates/xinclude.xml">
+ </templates>
+ </extension>
+
+</plugin>
Property changes on: trunk/vpe/plugins/org.jboss.tools.vpe.docbook/plugin.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/vpe/plugins/org.jboss.tools.vpe.docbook/templates/docbook.xml
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.docbook/templates/docbook.xml (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.docbook/templates/docbook.xml 2008-07-15 19:07:36 UTC (rev 9148)
@@ -0,0 +1,129 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<vpe:templates>
+ <!--vpe:template-taglib uri="-//OASIS//DTD DocBook XML V4.3CR3//EN"/-->
+
+ <vpe:tag name="chapter" case-sensitive="yes">
+ <vpe:template children="yes" modify="yes">
+ <div />
+ </vpe:template>
+ </vpe:tag>
+
+ <vpe:tag name="section" case-sensitive="yes">
+ <vpe:template children="yes" modify="yes">
+ <div />
+ </vpe:template>
+ </vpe:tag>
+
+ <vpe:tag name="sect1" case-sensitive="yes">
+ <vpe:template children="yes" modify="yes">
+ <div />
+ </vpe:template>
+ </vpe:tag>
+ <vpe:tag name="sect2" case-sensitive="yes">
+ <vpe:template children="yes" modify="yes">
+ <div />
+ </vpe:template>
+ </vpe:tag>
+ <vpe:tag name="title" case-sensitive="yes">
+ <vpe:template children="no" modify="yes">
+ <h1>
+ <vpe:value expr="{tagtext()}" />
+ </h1>
+ </vpe:template>
+ </vpe:tag>
+ <vpe:tag name="para" case-sensitive="yes">
+ <vpe:template children="yes" modify="yes">
+ <p />
+ </vpe:template>
+ </vpe:tag>
+ <vpe:tag name="itemizedlist" case-sensitive="yes">
+ <vpe:template children="yes" modify="yes">
+ <ul />
+ </vpe:template>
+ </vpe:tag>
+
+ <vpe:tag name="listitem" case-sensitive="yes">
+ <vpe:template children="yes" modify="yes">
+ <li />
+ </vpe:template>
+ </vpe:tag>
+
+ <vpe:tag name="ulink" case-sensitive="yes">
+ <vpe:template children="yes" modify="yes">
+ <a href="{@url}" />
+ </vpe:template>
+ </vpe:tag>
+
+ <vpe:tag name="programlisting" case-sensitive="yes">
+ <vpe:template children="yes" modify="yes">
+ <pre />
+ </vpe:template>
+ </vpe:tag>
+
+ <vpe:tag name="emphasis" case-sensitive="yes">
+ <vpe:template children="yes" modify="yes">
+ <em />
+ </vpe:template>
+ </vpe:tag>
+
+ <vpe:tag name="tgroup" case-sensitive="yes">
+ <vpe:template children="yes" modify="yes">
+ <table border="1px" />
+ </vpe:template>
+ </vpe:tag>
+
+ <vpe:tag name="row" case-sensitive="yes">
+ <vpe:template children="yes" modify="yes">
+ <tr />
+ </vpe:template>
+ </vpe:tag>
+
+ <vpe:tag name="entry" case-sensitive="yes">
+ <vpe:template children="yes" modify="yes">
+ <td />
+ </vpe:template>
+ </vpe:tag>
+
+ <vpe:tag name="property" case-sensitive="yes">
+ <vpe:template children="yes" modify="yes">
+ <i />
+ </vpe:template>
+ </vpe:tag>
+
+ <vpe:tag name="imagedata" case-sensitive="yes">
+ <vpe:template children="yes" modify="yes">
+ <img src="{src(@fileref)}" />
+ </vpe:template>
+ </vpe:tag>
+
+ <vpe:tag name="mediaobject" case-sensitive="yes">
+ <vpe:template children="yes" modify="yes">
+ <div />
+ </vpe:template>
+ </vpe:tag>
+ <vpe:tag name="imageobject" case-sensitive="yes">
+ <vpe:template children="yes" modify="yes">
+ <div />
+ </vpe:template>
+ </vpe:tag>
+ <vpe:tag name="figure" case-sensitive="yes">
+ <vpe:template children="yes" modify="yes">
+ <div />
+ </vpe:template>
+ </vpe:tag>
+ <vpe:tag name="orderedlist" case-sensitive="yes">
+ <vpe:template children="yes" modify="yes">
+ <ol />
+ </vpe:template>
+ </vpe:tag>
+ <vpe:tag case-sensitive="yes" name="chapterinfo">
+ <vpe:template children="yes" modify="yes">
+ <vpe:any display="none" icon="no" value="{name()}" />
+ </vpe:template>
+ </vpe:tag>
+ <vpe:tag case-sensitive="yes" name="note">
+ <vpe:template children="yes" modify="yes">
+ <vpe:any background-color="yellow" border="blue" icon="no" />
+ </vpe:template>
+ </vpe:tag>
+</vpe:templates>
\ No newline at end of file
Property changes on: trunk/vpe/plugins/org.jboss.tools.vpe.docbook/templates/docbook.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/vpe/plugins/org.jboss.tools.vpe.docbook/templates/xinclude.xml
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.docbook/templates/xinclude.xml (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.docbook/templates/xinclude.xml 2008-07-15 19:07:36 UTC (rev 9148)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<vpe:templates>
+ <vpe:template-taglib uri="http://www.w3.org/2001/XInclude" prefix="xi" />
+
+ <vpe:tag name="xi:include" case-sensitive="yes">
+ <vpe:template children="yes" file="{@href}" class="org.jboss.tools.vpe.editor.template.VpeIncludeTemplate"/>
+ </vpe:tag>
+</vpe:templates>
\ No newline at end of file
Property changes on: trunk/vpe/plugins/org.jboss.tools.vpe.docbook/templates/xinclude.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
16 years, 6 months
JBoss Tools SVN: r9146 - in trunk/vpe/plugins: org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: mareshkau
Date: 2008-07-15 13:41:08 -0400 (Tue, 15 Jul 2008)
New Revision: 9146
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/XPCOM.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/selection/VpeSelectionController.java
Log:
JBIDE-2505
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2008-07-15 13:51:27 UTC (rev 9145)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2008-07-15 17:41:08 UTC (rev 9146)
@@ -180,7 +180,6 @@
XulRunnerEditor xulRunnerEditor;
// TODO Sergey Vasilyev figure out with nsIPressShell
// private nsIPresShell presShell;
- // TODO Max Areshkau figure out with nsISelectionController
private VpeSelectionController visualSelectionController;
VpeDomMapping domMapping;
private VpeTemplateManager templateManager;
@@ -280,8 +279,8 @@
xulRunnerEditor = visualEditor.getXulRunnerEditor();
// TODO Sergey Vasilyev figure out with nsIPressShell
// presShell = browser.getPresShell();
- visualSelectionController = new VpeSelectionController(xulRunnerEditor
- .getSelection());
+
+ visualSelectionController = new VpeSelectionController(visualEditor.getEditor().getSelectionController());
selectionBuilder = new VpeSelectionBuilder(domMapping, sourceBuilder,
visualBuilder, visualSelectionController);
@@ -412,7 +411,8 @@
if (visualEditor != null) {
visualEditor.setEditorDomEventListener(null);
if (visualSelectionController != null) {
- // visualSelectionController.Release();
+
+// visualSelectionController.Release();
visualSelectionController = null;
}
// TODO Sergey Vasilyev figure out with Press Shell
@@ -3217,9 +3217,6 @@
} else {
visualBuilder.rebuildDom(null);
}
-
- visualSelectionController.setSelection(xulRunnerEditor.getSelection());
-
}
}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java 2008-07-15 13:51:27 UTC (rev 9145)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java 2008-07-15 17:41:08 UTC (rev 9146)
@@ -59,6 +59,7 @@
import org.jboss.tools.vpe.editor.util.DocTypeUtil;
import org.jboss.tools.vpe.editor.util.HTML;
import org.jboss.tools.vpe.messages.VpeUIMessages;
+import org.jboss.tools.vpe.xulrunner.XPCOM;
import org.jboss.tools.vpe.xulrunner.editor.XulRunnerEditor;
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
@@ -66,10 +67,15 @@
import org.mozilla.interfaces.nsIDOMNamedNodeMap;
import org.mozilla.interfaces.nsIDOMNode;
import org.mozilla.interfaces.nsIDOMNodeList;
+import org.mozilla.interfaces.nsIEditingSession;
+import org.mozilla.interfaces.nsIEditor;
+import org.mozilla.interfaces.nsIHTMLAbsPosEditor;
+import org.mozilla.interfaces.nsIHTMLInlineTableEditor;
+import org.mozilla.interfaces.nsIHTMLObjectResizer;
+import org.mozilla.interfaces.nsIPlaintextEditor;
public class MozillaEditor extends EditorPart implements IReusableEditor {
- protected static final String INIT_URL = /*"file://" +*/ (new File(VpePlugin.getDefault().getResourcePath("ve"), "init.html")).getAbsolutePath(); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-// private static final String INIT_URL = "chrome://vpe/content/init.html"; //$NON-NLS-1$
+ protected static final String INIT_URL = /*"file://" +*/ (new File(VpePlugin.getDefault().getResourcePath("ve"), "init.html")).getAbsolutePath(); //$NON-NLS-1$ //$NON-NLS-2$
private static final String CONTENT_AREA_ID = "__content__area__"; //$NON-NLS-1$
static String SELECT_BAR = "SELECT_LBAR"; //$NON-NLS-1$
@@ -90,6 +96,11 @@
private boolean loaded;
private boolean isRefreshPage = false;
private String doctype;
+ /**
+ * Used for manupalation of browser in design mode,
+ * for example enable or disable readOnlyMode
+ */
+ private nsIEditor editor;
public void doSave(IProgressMonitor monitor) {
}
@@ -120,7 +131,10 @@
formatControllerManager.setVpeController(controller);
controller.setToolbarFormatControllerManager(formatControllerManager);
}
-
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
+ */
public void createPartControl(final Composite parent) {
vpeToolBarManager = new VpeToolBarManager();
//Setting Layout for the parent Composite
@@ -258,6 +272,7 @@
public void completed(ProgressEvent event) {
loaded = true;
xulRunnerEditor.getBrowser().removeProgressListener(this);
+ //here we switchs xulrunner to design mode JBIDE-2505
}
});
@@ -316,7 +331,7 @@
});
link.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Label fill = new Label(cmpEd, SWT.WRAP);
- fill.setLayoutData(new GridData(GridData.FILL_BOTH));
+ fill.setLayoutData(new GridData(GridData.FILL_BOTH));
}
}
@@ -512,7 +527,7 @@
getContentAreaEventTarget().addEventListener(MozillaDomEventListener.DRAGOVEREVENT, getContentAreaEventListener(), false);
getContentAreaEventTarget().addEventListener(MozillaDomEventListener.DBLCLICK, getContentAreaEventListener(), false);
documentEventTarget = (nsIDOMEventTarget) getDomDocument().queryInterface(nsIDOMEventTarget.NS_IDOMEVENTTARGET_IID);
- documentEventTarget.addEventListener(MozillaDomEventListener.KEYPRESS, getContentAreaEventListener(), false);
+ documentEventTarget.addEventListener(MozillaDomEventListener.KEYPRESS, getContentAreaEventListener(), false);
} else {
//baseEventListener = new MozillaBaseEventListener();
}
@@ -670,8 +685,7 @@
}
/**
- *
- * @return
+ * @return Doctype for document
*/
public String getDoctype() {
return doctype;
@@ -684,4 +698,35 @@
public void setRefreshPage(boolean isRefreshPage) {
this.isRefreshPage = isRefreshPage;
}
+ /**
+ * Returns Editor for This Document
+ * @return
+ */
+ public nsIEditor getEditor() {
+
+ if(editor==null) {
+ //creating editing session
+ nsIEditingSession iEditingSession = (nsIEditingSession) getXulRunnerEditor().
+ getComponentManager().createInstanceByContractID(XPCOM.NS_EDITINGSESSION_CONTRACTID, null, nsIEditingSession.NS_IEDITINGSESSION_IID);
+ //make window editable
+ iEditingSession.makeWindowEditable(getXulRunnerEditor().getWebBrowser().getContentDOMWindow(), "html", true); //$NON-NLS-1$
+ //here we setup editor for window
+ iEditingSession.setupEditorOnWindow(getXulRunnerEditor().getWebBrowser().getContentDOMWindow());
+ //getting some editor to disable some actions
+ editor = iEditingSession.getEditorForWindow(getXulRunnerEditor().getWebBrowser().getContentDOMWindow());
+ editor.setFlags(nsIPlaintextEditor.eEditorReadonlyMask);
+ //here we hide nsIHTMLObjectResizers
+ nsIHTMLObjectResizer htmlObjectResizer = (nsIHTMLObjectResizer) editor.queryInterface(nsIHTMLObjectResizer.NS_IHTMLOBJECTRESIZER_IID);
+ //we disable abject resizers
+ htmlObjectResizer.hideResizers();
+ htmlObjectResizer.setObjectResizingEnabled(false);
+ //here we getting position editor and disable it's too
+ nsIHTMLAbsPosEditor htmlAbsPosEditor = (nsIHTMLAbsPosEditor) editor.queryInterface(nsIHTMLAbsPosEditor.NS_IHTMLABSPOSEDITOR_IID);
+ htmlAbsPosEditor.setAbsolutePositioningEnabled(false);
+ //here we getting inline table editor and disable it's too
+ nsIHTMLInlineTableEditor inlineTableEditor = (nsIHTMLInlineTableEditor) editor.queryInterface(nsIHTMLInlineTableEditor.NS_IHTMLINLINETABLEEDITOR_IID);
+ inlineTableEditor.setInlineTableEditingEnabled(false);
+ }
+ return editor;
+ }
}
\ No newline at end of file
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/selection/VpeSelectionController.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/selection/VpeSelectionController.java 2008-07-15 13:51:27 UTC (rev 9145)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/selection/VpeSelectionController.java 2008-07-15 17:41:08 UTC (rev 9146)
@@ -12,41 +12,61 @@
package org.jboss.tools.vpe.editor.selection;
import org.mozilla.interfaces.nsISelection;
+import org.mozilla.interfaces.nsISelectionController;
/**
+ * Class decorator for nsISelectionController
* @author Maxim Areshkau
- * Class which replace nsISelectionController functionality
*/
public class VpeSelectionController {
- private nsISelection selection;
+ private nsISelectionController selectionController;
/**
* @param selection
*/
- public VpeSelectionController(nsISelection selection) {
- this.selection = selection;
+ public VpeSelectionController(nsISelectionController selectionController) {
+
+ setSelectionController(selectionController);
}
/**
* type - not used in
* @return the selection
*/
- public nsISelection getSelection(long type) {
- return selection;
+ public nsISelection getSelection(short type) {
+
+ return getSelectionController().getSelection(type);
}
-
+
/**
- * @param selection the selection to set
+ * Sets caret enables or disabled
+ * @param value
*/
- public void setSelection(nsISelection selection) {
- this.selection = selection;
- }
-
- //method stub just because it is exist in nsISelectionController
public void setCaretEnabled(boolean value){
+
+ getSelectionController().setCaretEnabled(value);
}
- //method stub just because it is exist in nsISelectionController
+ /**
+ * Sets selection flags
+ * @param selectionFlags
+ */
public void setSelectionFlags(short selectionFlags){
+
+ getSelectionController().setSelectionFlags(selectionFlags);
}
+
+ /**
+ * @return the selectionController
+ */
+ private nsISelectionController getSelectionController() {
+ return selectionController;
+ }
+
+ /**
+ * @param selectionController the selectionController to set
+ */
+ private void setSelectionController(nsISelectionController selectionController) {
+ this.selectionController = selectionController;
+ }
}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/XPCOM.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/XPCOM.java 2008-07-15 13:51:27 UTC (rev 9145)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/XPCOM.java 2008-07-15 17:41:08 UTC (rev 9146)
@@ -28,7 +28,12 @@
public static final String NS_SUPPORTSARRAY_CONTRACTID = "@mozilla.org/supports-array;1"; //$NON-NLS-1$
public static final String IN_FLASHER_CONTRACTID = "@mozilla.org/inspector/flasher;1"; //$NON-NLS-1$
+ /**
+ * Editing Session Contract ID
+ * see http://www.xulplanet.com/references/xpcomref/ifaces/nsIEditingSession.html
+ */
+ public static final String NS_EDITINGSESSION_CONTRACTID="@mozilla.org/editor/editingsession;1"; //$NON-NLS-1$
- public static final String NS_IWEBBROWSER_CID = "F1EAC761-87E9-11d3-AF80-00A024FFC08C"; //$NON-NLS-1$
+ public static final String NS_IWEBBROWSER_CID = "F1EAC761-87E9-11d3-AF80-00A024FFC08C"; //$NON-NLS-1$
public static final String NS_IAPPSHELL_CID = "2d96b3df-c051-11d1-a827-0040959a28c9"; //$NON-NLS-1$
}
16 years, 6 months