JBoss Tools SVN: r15246 - trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2009-05-14 04:03:37 -0400 (Thu, 14 May 2009)
New Revision: 15246
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/RenameComponentProcessor.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-1077
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/RenameComponentProcessor.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/RenameComponentProcessor.java 2009-05-13 18:39:30 UTC (rev 15245)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/RenameComponentProcessor.java 2009-05-14 08:03:37 UTC (rev 15246)
@@ -429,7 +429,17 @@
}
}
+ private boolean isBadLocation(ISeamTextSourceReference location){
+ if(location.getStartPosition() == 0 && location.getLength() == 0)
+ return true;
+ else
+ return false;
+ }
+
private void changeXMLNode(ISeamTextSourceReference location, IFile file){
+ if(isBadLocation(location))
+ return;
+
String content = null;
try {
content = FileUtil.readStream(file.getContents());
@@ -456,6 +466,9 @@
}
private void changeAnnotation(ISeamTextSourceReference location, IFile file){
+ if(isBadLocation(location))
+ return;
+
String content = null;
try {
content = FileUtil.readStream(file.getContents());
15 years, 6 months
JBoss Tools SVN: r15245 - in trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe: editor/menu and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: yradtsevich
Date: 2009-05-13 14:39:30 -0400 (Wed, 13 May 2009)
New Revision: 15245
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/VpeMenuCreator.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/VpeMenuUtil.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/action/ComplexAction.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/action/EditAttributesAction.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/action/SelectThisTagAction.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/action/StripTagAction.java
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/menu/InsertContributionItem.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/MenuCreationHelper.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/SetupTemplateContributionItem.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/action/InsertAction2.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/VpeUIMessages.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/messages.properties
Log:
issue JBIDE-4226: Two different implementations of the VPE context menu
https://jira.jboss.org/jira/browse/JBIDE-4226
- the implementations have been merged and some actions have been rewritten
- some bugs have been fixed
- cut/add/paste items have been added to the menu of parent tag
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 2009-05-13 16:28:09 UTC (rev 15244)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2009-05-13 18:39:30 UTC (rev 15245)
@@ -16,12 +16,10 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.bindings.Binding;
@@ -110,7 +108,7 @@
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.mapping.VpeDomMapping;
import org.jboss.tools.vpe.editor.mapping.VpeNodeMapping;
-import org.jboss.tools.vpe.editor.menu.MenuCreationHelper;
+import org.jboss.tools.vpe.editor.menu.VpeMenuCreator;
import org.jboss.tools.vpe.editor.mozilla.EditorDomEventListener;
import org.jboss.tools.vpe.editor.mozilla.MozillaDropInfo;
import org.jboss.tools.vpe.editor.mozilla.MozillaEditor;
@@ -246,8 +244,7 @@
domMapping = new VpeDomMapping(pageContext);
sourceBuilder = new VpeSourceDomBuilder(domMapping, this,
VpeTemplateManager.getInstance(), sourceEditor, pageContext);
- visualBuilder = new VpeVisualDomBuilder(domMapping, this, visualEditor,
- pageContext);
+ visualBuilder = new VpeVisualDomBuilder(domMapping, this, visualEditor, pageContext);
pageContext.setSourceDomBuilder(sourceBuilder);
pageContext.setVisualDomBuilder(visualBuilder);
IDOMModel sourceModel = (IDOMModel) getModel();
@@ -272,8 +269,7 @@
}
IDOMDocument sourceDocument = sourceModel.getDocument();
- // FIXED FOR JBIDE-3799 by sdzmitrovich, moved calling of
- // this method to buid dom
+ // FIXED FOR JBIDE-3799 by sdzmitrovich, moved calling of this method to buid dom
// visualBuilder.refreshExternalLinks();
visualBuilder.buildDom(sourceDocument);
@@ -284,8 +280,7 @@
// presShell = browser.getPresShell();
//initialization visual selection controller
- visualSelectionController = new VpeSelectionController(
- visualEditor.getEditor().getSelectionController());
+ visualSelectionController = new VpeSelectionController(visualEditor.getEditor().getSelectionController());
selectionBuilder = new VpeSelectionBuilder(domMapping, sourceBuilder,
visualBuilder, visualSelectionController);
@@ -350,8 +345,7 @@
vpeUpdateDelayTime = 400;
// pageContext.fireTaglibsChanged();
- // yradtsevich: we have to refresh VPE selection on init
- // (fix of JBIDE-4037)
+ // yradtsevich: we have to refresh VPE selection on init (fix of JBIDE-4037)
sourceSelectionChanged(true);
}
@@ -373,8 +367,7 @@
}
if (optionsListener != null) {
- XModelObject optionsObject = ModelUtilities.getPreferenceModel()
- .getByPath(VpePreference.EDITOR_PATH);
+ XModelObject optionsObject = ModelUtilities.getPreferenceModel().getByPath(VpePreference.EDITOR_PATH);
optionsObject.getModel().removeModelTreeListener(optionsListener);
optionsListener.dispose();
optionsListener = null;
@@ -463,7 +456,7 @@
if (PlatformUI.isWorkbenchRunning())
display = PlatformUI.getWorkbench().getDisplay();
- if (display != null && Thread.currentThread() == display.getThread()) {
+ if (display != null && (Thread.currentThread() == display.getThread())) {
getChangeEvents().addLast(
new VpeEventBean(notifier, eventType, feature, oldValue,
newValue, pos));
@@ -471,22 +464,18 @@
uiJob = new UIJob(VpeUIMessages.VPE_UPDATE_JOB_TITLE) {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
- monitor.beginTask(VpeUIMessages.VPE_UPDATE_JOB_TITLE,
- 100);
+ monitor.beginTask(VpeUIMessages.VPE_UPDATE_JOB_TITLE, 100);
while (getChangeEvents().size() > 0) {
- monitor.worked(
- (int) (100 / getChangeEvents().size()));
- VpeEventBean eventBean = getChangeEvents()
- .getFirst();
+ monitor.worked((int) (100 / getChangeEvents().size()));
+ VpeEventBean eventBean = getChangeEvents().getFirst();
if (monitor.isCanceled()) {
- /* Yahor Radtsevich: the following line is
- * commented as the fix of JBIDE-3758:
- * VPE autorefresh is broken in some cases.
- * Now if the change events queue should be
- * cleared, the programmer have to do it
- * explicitly.
+ /*
+ * Yahor Radtsevich: the following line is commented
+ * as fix of JBIDE-3758: VPE autorefresh is broken in some cases.
+ * Now if the change events queue should be cleared, the user have to do it explicitly.
*/
// getChangeEvents().clear();
+
return Status.CANCEL_STATUS;
}
try {
@@ -501,7 +490,8 @@
// JBIDE-675 we will get this exception if user
// close editor,
// when update visual editor job is running, we
- // should ignore this exception
+ // shoud ignore this
+ // exception
break;
} catch (NullPointerException ex) {
if (switcher != null) {
@@ -517,22 +507,18 @@
}
// cause is to lock calls others events
if (switcher != null &&
- switcher.startActiveEditor(ActiveEditorSwitcher
- .ACTIVE_EDITOR_SOURCE))
+ switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE))
try {
sourceSelectionChanged();
/*
* https://jira.jboss.org/jira/browse/JBIDE-3619
- * VpeViewUpdateJob takes place after toolbar
- * selection have been updated.
+ * VpeViewUpdateJob takes place after toolbar selection have been updated.
* New nodes haven't been put into dom mapping
* thus toolbar becomes desabled.
- * Updating toolbar state here takes into
- * account updated vpe nodes.
+ * Updating toolbar state here takes into account updated vpe nodes.
*/
if (toolbarFormatControllerManager != null) {
- toolbarFormatControllerManager
- .selectionChanged();
+ toolbarFormatControllerManager.selectionChanged();
}
} finally {
switcher.stopActiveEditor();
@@ -563,12 +549,11 @@
job = new UIJob("NotifyChangedJob") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
- // we check if job was canceled and if is it true cancel the job
+ // we checks is job was canceled and if is it true we cancel job
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
} else {
- notifyChangedInUiThread(notifier, eventType, feature,
- oldValue, newValue, pos);
+ notifyChangedInUiThread(notifier, eventType, feature, oldValue, newValue, pos);
}
return Status.OK_STATUS;
}
@@ -580,14 +565,12 @@
public void notifyChangedInUiThread(INodeNotifier notifier, int eventType,
Object feature, Object oldValue, Object newValue, int pos) {
if (switcher == null ||
- !switcher.startActiveEditor(ActiveEditorSwitcher
- .ACTIVE_EDITOR_SOURCE)) {
+ !switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
return;
}
try {
if (VpeDebug.PRINT_SOURCE_MUTATION_EVENT) {
- printSourceEvent(notifier, eventType, feature,
- oldValue, newValue, pos);
+ printSourceEvent(notifier, eventType, feature, oldValue, newValue, pos);
}
if (visualBuilder == null) {
return;
@@ -606,28 +589,25 @@
if (!update)
visualBuilder.updateNode((Node) notifier);
} else if (type == Node.COMMENT_NODE) {
- if ("yes".equals( //$NON-NLS-1$
- VpePreference.SHOW_COMMENTS.getValue())) {
+ if ("yes".equals(VpePreference.SHOW_COMMENTS.getValue())) { //$NON-NLS-1$
visualBuilder.setSelectionRectangle(null);
visualBuilder.updateNode((Node) notifier);
}
} else if (feature != null
- && ((Node)feature).getNodeType()==Node.ATTRIBUTE_NODE) {
+ && ((Node) feature).getNodeType() == Node.ATTRIBUTE_NODE) {
if (newValue != null) {
String attrName = ((Attr) feature).getName();
if ((Attr) feature == lastRemovedAttr
&& !attrName.equals(lastRemovedAttrName)) {
lastRemovedAttr = null;
- visualBuilder.removeAttribute((Element) notifier,
- lastRemovedAttrName);
+ visualBuilder.removeAttribute((Element) notifier, lastRemovedAttrName);
}
visualBuilder.setAttribute((Element) notifier,
((Attr) feature).getName(), (String) newValue);
} else {
lastRemovedAttr = (Attr) feature;
lastRemovedAttrName = ((Attr) feature).getName();
- visualBuilder.removeAttribute((Element) notifier,
- lastRemovedAttrName);
+ visualBuilder.removeAttribute((Element) notifier, lastRemovedAttrName);
}
}
visualEditor.showResizer();
@@ -651,8 +631,7 @@
case INodeNotifier.CONTENT_CHANGED:
if (!sourceChangeFlag) {
if (feature != null
- && ((Node) feature).getNodeType()
- == Node.TEXT_NODE) {
+ && ((Node) feature).getNodeType() == Node.TEXT_NODE) {
// if
// (((Node)notifier).getNodeName().equalsIgnoreCase(
// "style"))
@@ -681,8 +660,7 @@
// INodeSelectionListener implementation
public void nodeSelectionChanged(NodeSelectionChangedEvent event) {
- if (!switcher.startActiveEditor(
- ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
+ if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
return;
}
try {
@@ -690,11 +668,8 @@
if (nodes != null && nodes.size() > 0) {
Node sourceNode = (Node) nodes.get(0);
if (VpeDebug.PRINT_SOURCE_SELECTION_EVENT) {
- System.out.println(">>>>>>>>>>>>>> " //$NON-NLS-1$
- + "nodeSelectionChanged " //$NON-NLS-1$
- + "sourceNode: " //$NON-NLS-1$
- + sourceNode.getNodeName()
- + " " + event.getCaretPosition()); //$NON-NLS-1$
+ System.out.println(">>>>>>>>>>>>>> nodeSelectionChanged sourceNode: " + //$NON-NLS-1$
+ sourceNode.getNodeName() + Constants.WHITE_SPACE + event.getCaretPosition());
}
if (event.getSource() instanceof IContentOutlinePage) {
sourceSelectionChanged();
@@ -708,15 +683,12 @@
// ITextSelectionListener implementation
// TODO Max Areshau looks like this method don't used
public void textSelectionChanged(TextSelectionChangedEvent event) {
- if (!switcher.startActiveEditor(
- ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
+ if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
return;
}
try {
if (VpeDebug.PRINT_SOURCE_SELECTION_EVENT) {
- System.out.println(">>>>>>>>>>>>>> " //$NON-NLS-1$
- + "textSelectionChanged " //$NON-NLS-1$
- + event.getSource());
+ System.out.println(">>>>>>>>>>>>>> textSelectionChanged " + event.getSource()); //$NON-NLS-1$
}
// if (event.getSource() instanceof StyledText) {
sourceSelectionChanged();
@@ -728,14 +700,12 @@
// SelectionListener implementation
public void widgetSelected(SelectionEvent event) {
- if (!switcher.startActiveEditor(
- ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
+ if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
return;
}
try {
if (VpeDebug.PRINT_SOURCE_SELECTION_EVENT) {
- System.out.println(">>>>>>>>>>>>>> " //$NON-NLS-1$
- + "widgetSelected"); //$NON-NLS-1$
+ System.out.println(">>>>>>>>>>>>>> widgetSelected"); //$NON-NLS-1$
}
if (event.getSource() instanceof StyledText) {
sourceSelectionChanged();
@@ -747,8 +717,7 @@
public void widgetDefaultSelected(SelectionEvent event) {
if (VpeDebug.PRINT_SOURCE_SELECTION_EVENT) {
- System.out.println(">>>>>>>>>>>>>> " //$NON-NLS-1$
- + "widgetDefaultSelected"); //$NON-NLS-1$
+ System.out.println(">>>>>>>>>>>>>> widgetDefaultSelected"); //$NON-NLS-1$
}
}
@@ -810,15 +779,9 @@
// if (VpeDebug.PRINT_SOURCE_SELECTION_EVENT) {
// System.out.println("sourceSelectionChanged"); //$NON-NLS-1$
// System.out
- // .println(" anchorNode: " //$NON-NLS-1$
- // + anchorNode.getNodeName()
- // + " anchorOffset: " //$NON-NLS-1$
- // + anchorOffset);
+ // .println(" anchorNode: " + anchorNode.getNodeName() + " anchorOffset: " + anchorOffset); //$NON-NLS-1$ //$NON-NLS-2$
// System.out
- // .println(" focusNode: " //$NON-NLS-1$
- // + focusNode.getNodeName()
- // + " focusOffset: " + focusOffset //$NON-NLS-1$
- // + " focusPosition: " + focusPosition); //$NON-NLS-1$
+ // .println(" focusNode: " + focusNode.getNodeName() + " focusOffset: " + focusOffset + " focusPosition: " + focusPosition); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
// }
// try {
// if (anchorNode.getNodeType() == Node.TEXT_NODE
@@ -856,8 +819,7 @@
}
public void sourceSelectionToVisualSelection(boolean showCaret) {
- if (!switcher.startActiveEditor(
- ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
+ if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
return;
}
try {
@@ -872,17 +834,15 @@
}
public void processPostModelEvent(ModelLifecycleEvent event) {
- if (!switcher.startActiveEditor(
- ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
+ if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
return;
}
try {
/*
* Added by Max Areshkau JBIDE-1457
- * ModelLifecycleEvent.MODEL_RELEASED is generated
- * when model in model calls methods releaseFromRead()
- * or releaseFromEdit(). When editor is open he has only
- * when href on model, so nothing can generated
+ * ModelLifecycleEvent.MODEL_RELEASED is generated when model in model
+ * calls methods releaseFromRead() or releaseFromEdit(). When editor
+ * is open he has only when href on model, so nothing can generated
* this event.When editor closes generation of this event depends
* from containing any service href on model or not. It's can be a
* reason of problems on reopen file.
@@ -891,12 +851,9 @@
*/
if (event.getType() == ModelLifecycleEvent.MODEL_RELEASED) {
if (VpeDebug.PRINT_SOURCE_MODEL_LIFECYCLE_EVENT) {
- System.out.println(">>> " //$NON-NLS-1$
- + "processPostModelEvent: " //$NON-NLS-1$
- + event.toString());
+ System.out.println(">>> processPostModelEvent: " + event.toString()); //$NON-NLS-1$
}
- // commented to fix org.mozilla.xpcom.XPCOMException: The
- // function "repaint" returned an error condition (0x8000ffff)
+ // commented to fix org.mozilla.xpcom.XPCOMException: The function "repaint" returned an error condition (0x8000ffff)
//visualBuilder.setSelectionRectangle(null);
IStructuredModel model = event.getModel();
model.removeModelLifecycleListener(this);
@@ -917,8 +874,7 @@
// EditorDomEventListener implementation
public void subtreeModified(nsIDOMMutationEvent mutationEvent) {
- if (!switcher.startActiveEditor(
- ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+ if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
return;
}
try {
@@ -931,8 +887,7 @@
}
public void nodeInserted(nsIDOMMutationEvent mutationEvent) {
- if (!switcher.startActiveEditor(
- ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+ if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
return;
}
try {
@@ -950,8 +905,7 @@
}
public void nodeRemoved(nsIDOMMutationEvent mutationEvent) {
- if (!switcher.startActiveEditor(
- ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+ if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
return;
}
try {
@@ -970,8 +924,7 @@
}
public void nodeRemovedFromDocument(nsIDOMMutationEvent mutationEvent) {
- if (!switcher.startActiveEditor(
- ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+ if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
return;
}
try {
@@ -984,8 +937,7 @@
}
public void nodeInsertedIntoDocument(nsIDOMMutationEvent mutationEvent) {
- if (!switcher.startActiveEditor(
- ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+ if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
return;
}
try {
@@ -998,8 +950,7 @@
}
public void attrModified(nsIDOMMutationEvent mutationEvent) {
- if (!switcher.startActiveEditor(
- ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+ if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
return;
}
try {
@@ -1012,8 +963,7 @@
}
public void characterDataModified(nsIDOMMutationEvent mutationEvent) {
- if (!switcher.startActiveEditor(
- ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+ if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
return;
}
try {
@@ -1028,13 +978,10 @@
}
}
- public void notifySelectionChanged(nsIDOMDocument doc,
- nsISelection selection, short reason) {
- if (switcher.startActiveEditor(
- ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+ public void notifySelectionChanged(nsIDOMDocument doc, nsISelection selection, short reason) {
+ if (switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
try {
- mouseUpSelectionReasonFlag
- = (reason & nsISelectionListener.MOUSEUP_REASON) > 0;
+ mouseUpSelectionReasonFlag = (reason & nsISelectionListener.MOUSEUP_REASON) > 0;
if (mouseUpSelectionReasonFlag
// commited by Dzmitrovich - experimental
// TODO check selection and if are appear errors then
@@ -1042,11 +989,9 @@
// || reason == nsISelectionListener.NO_REASON
|| reason == nsISelectionListener.KEYPRESS_REASON
|| reason == nsISelectionListener.SELECTALL_REASON
- || (reason&nsISelectionListener.MOUSEDOWN_REASON) > 0) {
+ || (reason & nsISelectionListener.MOUSEDOWN_REASON) > 0) {
if (VpeDebug.PRINT_VISUAL_SELECTION_EVENT) {
- System.out.println("<<< " //$NON-NLS-1$
- + "notifySelectionChanged: " //$NON-NLS-1$
- + reason);
+ System.out.println("<<< notifySelectionChanged: " + reason); //$NON-NLS-1$
}
nsIDOMNode node = SelectionUtil.getSelectedNode(selection);
/*
@@ -1067,8 +1012,7 @@
}
public void mouseDown(nsIDOMMouseEvent mouseEvent) {
- if (!switcher.startActiveEditor(
- ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+ if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
return;
}
try {
@@ -1085,22 +1029,22 @@
// .getDragElement(mouseEvent);
if (VpeDebug.PRINT_VISUAL_MOUSE_EVENT) {
nsIDOMNode visualNode = VisualDomUtil.getTargetNode(mouseEvent);
- System.out.println("<<< mouseDown targetNode: " //$NON-NLS-1$
- /* +visualNode.
- * getNodeName()
- * + " (" +
- * visualNode +
- * ") selectedElement: "
- * +(
- * visualDragElement
- * != null ?
- * visualDragElement
- * .
- * getNodeName()
- * + " (" +
- * visualDragElement
- * + ")" : null)
- */);
+ System.out.println("<<< mouseDown targetNode: " /* //$NON-NLS-1$
+ * +visualNode.
+ * getNodeName()
+ * + " (" +
+ * visualNode +
+ * ") selectedElement: "
+ * +(
+ * visualDragElement
+ * != null ?
+ * visualDragElement
+ * .
+ * getNodeName()
+ * + " (" +
+ * visualDragElement
+ * + ")" : null)
+ */);
}
//
// if (visualDragElement != null) {
@@ -1135,8 +1079,7 @@
}
public void mouseUp(nsIDOMMouseEvent mouseEvent) {
- if (!switcher.startActiveEditor(
- ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+ if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
return;
}
try {
@@ -1155,8 +1098,7 @@
}
public void mouseClick(nsIDOMMouseEvent mouseEvent) {
- if (!switcher.startActiveEditor(
- ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+ if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
return;
}
try {
@@ -1164,11 +1106,8 @@
if (visualNode != null) {
if (!mouseUpSelectionReasonFlag) {
if (VpeDebug.PRINT_VISUAL_MOUSE_EVENT) {
- System.out.println("<<< " //$NON-NLS-1$
- + "mouseClick visualNode: " //$NON-NLS-1$
- + visualNode.getNodeName()
- + " (" //$NON-NLS-1$
- + visualNode + ")"); //$NON-NLS-1$
+ System.out.println("<<< mouseClick visualNode: " + visualNode.getNodeName() + //$NON-NLS-1$
+ " (" + visualNode + ")"); //$NON-NLS-1$ //$NON-NLS-2$
}
if (visualBuilder.isContentArea(visualNode)) {
// selectionBuilder.setClickContentAreaSelection();
@@ -1177,8 +1116,7 @@
mouseUpSelectionReasonFlag = false;
}
- if (visualBuilder.doToggle(
- VisualDomUtil.getTargetNode(mouseEvent))) {
+ if (visualBuilder.doToggle(VisualDomUtil.getTargetNode(mouseEvent))) {
// selectionBuilder.setClickContentAreaSelection();
}
}
@@ -1188,8 +1126,7 @@
}
public void mouseDblClick(nsIDOMMouseEvent mouseEvent) {
- if (!switcher.startActiveEditor(
- ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+ if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
return;
}
try {
@@ -1199,11 +1136,8 @@
sourceBuilder.openIncludeEditor(visualNode);
}
if (VpeDebug.PRINT_VISUAL_MOUSE_EVENT) {
- System.out.println("<<< " //$NON-NLS-1$
- + "mouseDblClick visualNode: " //$NON-NLS-1$
- + visualNode.getNodeName()
- + " (" //$NON-NLS-1$
- + visualNode + ")"); //$NON-NLS-1$
+ System.out.println("<<< mouseDblClick visualNode: " + visualNode.getNodeName() + //$NON-NLS-1$
+ " (" + visualNode + ")"); //$NON-NLS-1$ //$NON-NLS-2$
}
}
} finally {
@@ -1212,8 +1146,7 @@
}
public void mouseMove(nsIDOMMouseEvent mouseEvent) {
- if (!switcher.startActiveEditor(
- ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+ if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
return;
}
try {
@@ -1233,15 +1166,11 @@
public void keyPress(nsIDOMKeyEvent keyEvent) {
if (VpeDebug.PRINT_VISUAL_KEY_EVENT) {
- System.out.println("<<< keyPress type: " //$NON-NLS-1$
- + keyEvent.getType()
- + " Ctrl: " + keyEvent.getCtrlKey()
- + " Shift: " + keyEvent.getShiftKey() //$NON-NLS-1$
- + " CharCode: " + keyEvent.getCharCode() //$NON-NLS-1$
- + " KeyCode: " + keyEvent.getKeyCode()); //$NON-NLS-1$
+ System.out.println("<<< keyPress type: " + keyEvent.getType() + //$NON-NLS-1$
+ " Ctrl: " + keyEvent.getCtrlKey() + " Shift: " + keyEvent.getShiftKey() + //$NON-NLS-1$ //$NON-NLS-2$
+ " CharCode: " + keyEvent.getCharCode() + " KeyCode: " + keyEvent.getKeyCode()); //$NON-NLS-1$ //$NON-NLS-2$
}
- if (!switcher.startActiveEditor(
- ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+ if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
switcher.stopActiveEditor();
return;
}
@@ -1287,19 +1216,14 @@
KeySequence sequenceBeforeKeyStroke = KeySequence.getInstance();
- Iterator<KeyStroke> iterator = possibleKeyStrokes.iterator();
- while (iterator.hasNext()) {
+ for (Iterator<KeyStroke> iterator = possibleKeyStrokes.iterator(); iterator.hasNext();) {
KeySequence sequenceAfterKeyStroke =
- KeySequence.getInstance(sequenceBeforeKeyStroke,
- iterator.next());
- if (iBindingService.isPerfectMatch(
- sequenceAfterKeyStroke)) {
- final Binding binding = iBindingService
- .getPerfectMatch(sequenceAfterKeyStroke);
+ KeySequence.getInstance(sequenceBeforeKeyStroke, iterator.next());
+ if (iBindingService.isPerfectMatch(sequenceAfterKeyStroke)) {
+ final Binding binding = iBindingService.getPerfectMatch(sequenceAfterKeyStroke);
if ((binding != null)
&& (binding.getParameterizedCommand() != null)
- && (binding.getParameterizedCommand()
- .getCommand() != null)) {
+ && (binding.getParameterizedCommand().getCommand() != null)) {
keyBindingPressed = true;
}
}
@@ -1326,8 +1250,8 @@
* JBIDE-2670
*/
keyEvent.preventDefault();
-// switcher.startActiveEditor(
-// ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL);
+// switcher
+// .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL);
// try {
/*
* Edward
@@ -1348,8 +1272,7 @@
public void elementResized(nsIDOMElement element, int constrains,
int top, int left, int width, int height) {
- if (!switcher.startActiveEditor(
- ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+ if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
return;
}
try {
@@ -1363,8 +1286,7 @@
public void dragGesture(nsIDOMEvent domEvent) {
nsIDOMMouseEvent mouseEvent =
- (nsIDOMMouseEvent) domEvent.queryInterface(
- nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
+ (nsIDOMMouseEvent) domEvent.queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
boolean canDragFlag = canInnerDrag(mouseEvent);
// start drag sessionvpe-element
if (canDragFlag) {
@@ -1383,23 +1305,20 @@
* @param node
* where this event are occur
*/
- public void onShowContextMenu(long contextFlags, nsIDOMEvent event,
- nsIDOMNode node) {
+ public void onShowContextMenu(long contextFlags, nsIDOMEvent event, nsIDOMNode node) {
//FIXED FOR JBIDE-3072 by sdzmitrovich
// nsIDOMNode visualNode = VisualDomUtil.getTargetNode(event);
// if (visualNode != null) {
Node selectedSourceNode = null;
- VpeNodeMapping nodeMapping = SelectionUtil
- .getNodeMappingBySourceSelection(sourceEditor, domMapping);
+ VpeNodeMapping nodeMapping = SelectionUtil.getNodeMappingBySourceSelection(sourceEditor, domMapping);
if (nodeMapping != null) {
selectedSourceNode = nodeMapping.getSourceNode();
}
MenuManager menuManager = new MenuManager("#popup"); //$NON-NLS-1$
- final Menu contextMenu = menuManager.createContextMenu(visualEditor
- .getControl());
+ final Menu contextMenu = menuManager.createContextMenu(visualEditor.getControl());
contextMenu.addMenuListener(new MenuListener() {
Menu menu = contextMenu;
public void menuHidden(MenuEvent e) {
@@ -1414,14 +1333,11 @@
});
// create context menu
- MenuCreationHelper menuCreationHelper =
- new MenuCreationHelper(domMapping, pageContext,
- sourceEditor, visualEditor);
- menuCreationHelper.createMenuForNode(selectedSourceNode,
- menuManager, true);
-
+// MenuCreationHelper menuCreationHelper =
+// new MenuCreationHelper(domMapping, pageContext, sourceEditor, visualEditor);
+// menuCreationHelper.createMenuForNode(selectedSourceNode, menuManager, true);
+ new VpeMenuCreator(menuManager, selectedSourceNode).createMenu();
contextMenu.setVisible(true);
-// }
}
// VpeTemplateListener implementation
@@ -1437,21 +1353,18 @@
if (uiJob != null && uiJob.getState() != Job.NONE) {
return;
}
- if (visualRefreshJob == null
- || visualRefreshJob.getState() == Job.NONE) {
+ if (visualRefreshJob == null || visualRefreshJob.getState() == Job.NONE) {
visualRefreshJob = new UIJob(VpeUIMessages.VPE_VISUAL_REFRESH_JOB) {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
- if (!switcher.startActiveEditor(
- ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
+ if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
return Status.CANCEL_STATUS;
}
try {
- monitor.beginTask(VpeUIMessages.VPE_VISUAL_REFRESH_JOB,
- IProgressMonitor.UNKNOWN);
+ monitor.beginTask(VpeUIMessages.VPE_VISUAL_REFRESH_JOB, IProgressMonitor.UNKNOWN);
visualRefreshImpl();
monitor.done();
setSynced(true);
@@ -1474,7 +1387,7 @@
return Status.OK_STATUS;
}
};
- visualRefreshJob.setRule(new VisualTreeChangingRule(this));
+
visualRefreshJob.setPriority(Job.SHORT);
visualRefreshJob.schedule();
}
@@ -1483,8 +1396,7 @@
void visualRefreshImpl() {
visualEditor.hideResizer();
- String currentDoctype = DocTypeUtil.getDoctype(
- visualEditor.getEditorInput());
+ String currentDoctype = DocTypeUtil.getDoctype(visualEditor.getEditorInput());
/*
* https://jira.jboss.org/jira/browse/JBIDE-3591
* Avoid using missing resource.
@@ -1519,38 +1431,30 @@
// for debug
private void printSourceEvent(INodeNotifier notifier, int eventType,
Object feature, Object oldValue, Object newValue, int pos) {
- System.out.println(">>> eventType: " //$NON-NLS-1$
- + INodeNotifier.EVENT_TYPE_STRINGS[eventType]
- + " pos: " + pos //$NON-NLS-1$
- + " notifier: " //$NON-NLS-1$
- + ((Node) notifier).getNodeName()
- + " hashCode: " + notifier.hashCode()); //$NON-NLS-1$
+ System.out.println(">>> eventType: " + INodeNotifier.EVENT_TYPE_STRINGS[eventType] + //$NON-NLS-1$
+ " pos: " + pos + " notifier: " + ((Node) notifier).getNodeName() + //$NON-NLS-1$ //$NON-NLS-2$
+ " hashCode: " + notifier.hashCode()); //$NON-NLS-1$
if (feature != null) {
if (feature instanceof Node) {
- System.out.println(" feature: " //$NON-NLS-1$
- + ((Node) feature).getNodeType()
- + Constants.WHITE_SPACE + ((Node) feature).getNodeName()
- + " hashCode: " + feature.hashCode()); //$NON-NLS-1$
+ System.out.println(" feature: " + ((Node) feature).getNodeType() + //$NON-NLS-1$
+ Constants.WHITE_SPACE + ((Node) feature).getNodeName() +
+ " hashCode: " + feature.hashCode()); //$NON-NLS-1$
} else {
System.out.println(" feature: " + feature); //$NON-NLS-1$
}
}
if (oldValue != null) {
if (oldValue instanceof Node) {
- System.out.println(" oldValue: " //$NON-NLS-1$
- + ((Node) oldValue).getNodeName()
- + " hashCode: " + oldValue.hashCode());//$NON-NLS-1$
+ System.out.println(" oldValue: " + ((Node) oldValue).getNodeName() + //$NON-NLS-1$
+ " hashCode: " + oldValue.hashCode()); //$NON-NLS-1$
} else {
- System.out.println(" oldValue: " + oldValue);//$NON-NLS-1$
+ System.out.println(" oldValue: " + oldValue); //$NON-NLS-1$
}
}
if (newValue != null) {
if (newValue instanceof Node) {
- System.out.println(" newValue: " //$NON-NLS-1$
- + ((Node) newValue).getNodeName()
- + " hashCode: " + newValue.hashCode() //$NON-NLS-1$
- + Constants.WHITE_SPACE
- + ((Node) newValue).getNodeType());
+ System.out.println(" newValue: " + ((Node) newValue).getNodeName() + //$NON-NLS-1$
+ " hashCode: " + newValue.hashCode() + Constants.WHITE_SPACE + ((Node) newValue).getNodeType()); //$NON-NLS-1$
} else {
System.out.println(" newValue: " + newValue); //$NON-NLS-1$
}
@@ -1563,22 +1467,17 @@
if (event instanceof nsIDOMMutationEvent) {
nsIDOMMutationEvent mutationEvent = (nsIDOMMutationEvent) event;
- System.out.print(" EventPhase: " //$NON-NLS-1$
- + mutationEvent.getEventPhase());
+ System.out.print(" EventPhase: " + mutationEvent.getEventPhase()); //$NON-NLS-1$
nsIDOMNode relatedNode = mutationEvent.getRelatedNode();
- System.out.print(" RelatedNode: " //$NON-NLS-1$
- + (relatedNode == null ? null : relatedNode.getNodeName()));
+ System.out.print(" RelatedNode: " + (relatedNode == null ? null : relatedNode.getNodeName())); //$NON-NLS-1$
nsIDOMNode targetNode = VisualDomUtil.getTargetNode(mutationEvent);
String name = targetNode != null ? targetNode.getNodeName() : null;
- System.out.print(" TargetNode: " + name //$NON-NLS-1$
- + " (" + targetNode + ")"); //$NON-NLS-1$ //$NON-NLS-2$
+ System.out.print(" TargetNode: " + name + " (" + targetNode + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- System.out.print(" PrevValue: " //$NON-NLS-1$
- + mutationEvent.getPrevValue().trim());
- System.out.print(" NewValue: " //$NON-NLS-1$
- + mutationEvent.getNewValue().trim());
+ System.out.print(" PrevValue: " + mutationEvent.getPrevValue().trim()); //$NON-NLS-1$
+ System.out.print(" NewValue: " + mutationEvent.getNewValue().trim()); //$NON-NLS-1$
}
System.out.println();
}
@@ -1602,8 +1501,7 @@
private boolean startActiveEditor(int newType) {
if (type == ACTIVE_EDITOR_NONE) {
if (newType == ACTIVE_EDITOR_SOURCE
- && editPart.getVisualMode()
- == VpeEditorPart.SOURCE_MODE) {
+ && editPart.getVisualMode() == VpeEditorPart.SOURCE_MODE) {
return false;
}
type = newType;
@@ -1620,8 +1518,7 @@
}
// void refreshBundleValues() {
-// if (!switcher.startActiveEditor(
-// ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
+// if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
// return;
// }
// try {
@@ -1646,8 +1543,7 @@
if (bundle != null) {
bundle.refresh();
if (pageContext != null) {
- if (!switcher.startActiveEditor(
- ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
+ if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
return;
}
try {
@@ -1682,18 +1578,12 @@
// if (attrs != null) {
// for (int i = 0; i < attrs.getLength(); i++) {
// if (attrs.item(i) instanceof AttrImpl) {
-// AttrImpl attr = (AttrImpl)attrs.item(i);
-// if (getSourceAttributeOffset(attr,
-// offset) != -1) {
-// String[] atributeNames
-// = elementMapping
-// .getTemplate()
-// .getOutputAtributeNames();
+// AttrImpl attr = (AttrImpl) attrs.item(i);
+// if (getSourceAttributeOffset(attr, offset) != -1) {
+// String[] atributeNames = elementMapping.getTemplate().getOutputAtributeNames();
// if (atributeNames != null
// && atributeNames.length > 0
-// && attr.getName()
-// .equalsIgnoreCase(
-// atributeNames[0])) {
+// && attr.getName().equalsIgnoreCase(atributeNames[0])) {
// return attr;
// }
// }
@@ -1845,12 +1735,10 @@
selection = new VpeSelection(offset, length);
}
- public void addSelectionChangedListener(
- ISelectionChangedListener listener) {
+ public void addSelectionChangedListener(ISelectionChangedListener listener) {
}
- public void removeSelectionChangedListener(
- ISelectionChangedListener listener) {
+ public void removeSelectionChangedListener(ISelectionChangedListener listener) {
}
public ISelection getSelection() {
@@ -1876,8 +1764,8 @@
if (length > 0) {
try {
- text = sourceEditor.getTextViewer().getDocument()
- .get(offset, length);
+ text = sourceEditor.getTextViewer().getDocument().get(
+ offset, length);
} catch (BadLocationException e) {
VpePlugin.getPluginLog().logError(e);
}
@@ -1889,8 +1777,8 @@
offset = region.getStartOffset();
length = region.getEndOffset() - offset;
try {
- text = sourceEditor.getTextViewer().getDocument()
- .get(offset, length);
+ text = sourceEditor.getTextViewer().getDocument().get(offset,
+ length);
} catch (BadLocationException ex) {
VpePlugin.reportProblem(ex);
}
@@ -1948,13 +1836,13 @@
public void dragEnter(nsIDOMEvent event) {
if (VpeDebug.PRINT_VISUAL_DRAGDROP_EVENT) {
- System.out.println("<<<<<<<<<<<<<<<<<<< DragEnter"); //$NON-NLS-1$
+ System.out.println("<<<<<<<<<<<<<<<<<<<< DragEnter"); //$NON-NLS-1$
}
}
public void dragExit(nsIDOMEvent event) {
if (VpeDebug.PRINT_VISUAL_DRAGDROP_EVENT) {
- System.out.println("<<<<<<<<<<<<<<<<<<< dragExit"); //$NON-NLS-1$
+ System.out.println("<<<<<<<<<<<<<<<<<<<< dragExit"); //$NON-NLS-1$
}
// TODO Sergey Vasilyev figure out with drag caret
// xulRunnerEditor.hideDragCaret();
@@ -1971,14 +1859,13 @@
}
try {
if (VpeDebug.PRINT_VISUAL_DRAGDROP_EVENT) {
- System.out.println("<<<<<<<<<<<<<<<<<<< dragOver");//$NON-NLS-1$
+ System.out.println("<<<<<<<<<<<<<<<<<<<< dragOver"); //$NON-NLS-1$
}
// browser.computeDropPosition(event);
boolean canDrop = !xulRunnerEditor.isMozillaDragFlavor();
if (canDrop) {
Clipboard clipboard = new Clipboard(Display.getCurrent());
- canDrop = clipboard.getContents(ModelTransfer.getInstance())
- != null;
+ canDrop = clipboard.getContents(ModelTransfer.getInstance()) != null;
}
if (canDrop) {
canDrop = VpeDndUtil
@@ -2027,9 +1914,8 @@
if (dragInfo != null) {
nsIDOMNode dragNode = dragInfo.getNode();
if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
- System.out.print(" dragNode: " //$NON-NLS-1$
- + dragNode.getNodeName()
- + "(" + dragNode + ")"); //$NON-NLS-1$ //$NON-NLS-2$
+ System.out
+ .print(" dragNode: " + dragNode.getNodeName() + "(" + dragNode + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
switch (dragNode.getNodeType()) {
case nsIDOMNode.ELEMENT_NODE:
@@ -2108,8 +1994,7 @@
+ "(" //$NON-NLS-1$
+ visualDropInfo.getDropContainer()
+ ") parent: " //$NON-NLS-1$
- + visualDropInfo.getDropContainer().getParentNode()
- .getNodeName()
+ + visualDropInfo.getDropContainer().getParentNode().getNodeName()
+ "(" //$NON-NLS-1$
+ visualDropInfo.getDropContainer().getParentNode()
+ ") offset: " //$NON-NLS-1$
@@ -2152,17 +2037,16 @@
.getInnerDropInfo(event);
if (visualDropInfo.getDropContainer() != null) {
if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
- System.out.print(" container: " //$NON-NLS-1$
- + visualDropInfo.getDropContainer().getNodeName()
- + "(" //$NON-NLS-1$
- + visualDropInfo.getDropContainer()
- + ")" //$NON-NLS-1$
- + " offset: " //$NON-NLS-1$
- + visualDropInfo.getDropOffset());
+ System.out
+ .print(" container: " + visualDropInfo.getDropContainer().getNodeName() + //$NON-NLS-1$
+ "(" + visualDropInfo.getDropContainer()
+ + ")" + //$NON-NLS-1$ //$NON-NLS-2$
+ " offset: "
+ + visualDropInfo.getDropOffset()); //$NON-NLS-1$
}
- VpeSourceInnerDragInfo sourceInnerDragInfo
- = visualBuilder.getSourceInnerDragInfo(innerDragInfo);
+ VpeSourceInnerDragInfo sourceInnerDragInfo = visualBuilder
+ .getSourceInnerDragInfo(innerDragInfo);
VpeSourceInnerDropInfo sourceDropInfo = visualBuilder
.getSourceInnerDropInfo(sourceInnerDragInfo.getNode(),
visualDropInfo, true);
@@ -2218,8 +2102,8 @@
dropWindow.flavor = flavor;
}
dropWindow.active = true;
- dropWindow.setEventPosition(mouseEvent.getScreenX(),
- mouseEvent.getScreenY());
+ dropWindow.setEventPosition(mouseEvent.getScreenX(), mouseEvent
+ .getScreenY());
dropWindow.setInitialTargetNode(sourceNode);
dropWindow.open();
mouseEvent.stopPropagation();
@@ -2244,9 +2128,7 @@
caretOffset = visualDropInfo.getDropOffset();
} else {
String tagname = getTagName(object);
- if (tagname.indexOf("taglib") >= 0) { //$NON-NLS-1$
- tagname = "taglib"; //$NON-NLS-1$
- }
+ if (tagname.indexOf("taglib") >= 0)tagname = "taglib"; //$NON-NLS-1$ //$NON-NLS-2$
Node sourceDragNode = ((Document) getModel().getAdapter(
Document.class)).createElement(tagname);
VpeVisualInnerDropInfo visualDropInfo = selectionBuilder
@@ -2257,8 +2139,8 @@
visualDropInfo, true);
canDrop = sourceDropInfo.canDrop();
if (canDrop) {
- VpeVisualInnerDropInfo newVisualDropInfo
- = visualBuilder.getInnerDropInfo(
+ VpeVisualInnerDropInfo newVisualDropInfo = visualBuilder
+ .getInnerDropInfo(
sourceDropInfo.getContainer(),
sourceDropInfo.getOffset());
if (newVisualDropInfo != null) {
@@ -2281,15 +2163,11 @@
}
if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
- System.out.println(" canDrop: " + canDrop //$NON-NLS-1$
- + (canDrop
- ? " container: " //$NON-NLS-1$
- + caretParent.getNodeName()
- + " offset: " //$NON-NLS-1$
- + caretOffset
- : "")); //$NON-NLS-1$
+ System.out
+ .println(" canDrop: " + canDrop + (canDrop ? " container: " + caretParent.getNodeName() + " offset: " + caretOffset : "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
return new MozillaDropInfo(canDrop, caretParent, caretOffset);
+
}
public VpeSourceInnerDropInfo canExternalDropMacro(XModelObject object,
@@ -2326,15 +2204,10 @@
String tagname = object.getAttributeValue("name"); //$NON-NLS-1$
XModelObject parent = object.getParent();
- String uri = (parent == null)
- ? "" //$NON-NLS-1$
- : parent.getAttributeValue(URIConstants.LIBRARY_URI);
- String defaultPrefix = (parent == null)
- ? "" //$NON-NLS-1$
- : parent.getAttributeValue(URIConstants.DEFAULT_PREFIX);
+ String uri = (parent == null) ? "" : parent.getAttributeValue(URIConstants.LIBRARY_URI); //$NON-NLS-1$
+ String defaultPrefix = (parent == null) ? "" : parent.getAttributeValue(URIConstants.DEFAULT_PREFIX); //$NON-NLS-1$
- String[] texts = new String[] {
- "<" + tagname + ">" }; //$NON-NLS-1$ //$NON-NLS-2$
+ String[] texts = new String[] { "<" + tagname + ">" }; //$NON-NLS-1$ //$NON-NLS-2$
PaletteInsertHelper.applyPrefix(texts, sourceEditor, tagname, uri,
defaultPrefix);
tagname = texts[0].substring(1, texts[0].length() - 1);
@@ -2342,15 +2215,12 @@
return tagname;
}
- public void externalDrop(nsIDOMMouseEvent mouseEvent, String flavor,
- String data) {
+ public void externalDrop(nsIDOMMouseEvent mouseEvent, String flavor, String data) {
onHideTooltip();
- VpeVisualInnerDropInfo visualDropInfo
- = selectionBuilder.getInnerDropInfo(mouseEvent);
- Point range = selectionBuilder.getSourceSelectionRangeAtVisualNode(
- visualDropInfo.getDropContainer(),
- (int) visualDropInfo.getDropOffset());
+ VpeVisualInnerDropInfo visualDropInfo = selectionBuilder.getInnerDropInfo(mouseEvent);
+ Point range = selectionBuilder.getSourceSelectionRangeAtVisualNode(visualDropInfo.getDropContainer(), (int) visualDropInfo
+ .getDropOffset());
VpeSourceInnerDropInfo sourceDropInfo = null;
// if (MODEL_FLAVOR.equals(flavor)) {
@@ -2361,8 +2231,7 @@
nsISupports aValue = DndUtil.getDnDValue(mouseEvent);
String aFlavor = ""; //$NON-NLS-1$
if (VpeDndUtil.isNsIFileInstance(aValue)) {
- nsIFile aFile
- = (nsIFile) aValue.queryInterface(nsIFile.NS_IFILE_IID);
+ nsIFile aFile = (nsIFile) aValue.queryInterface(nsIFile.NS_IFILE_IID);
if (aValue != null) {
data = aFile.getPath();
@@ -2370,15 +2239,11 @@
}
} else if (VpeDndUtil.isNsICStringInstance(aValue)) {
- nsISupportsCString aString
- = (nsISupportsCString) aValue.queryInterface(
- nsISupportsCString.NS_ISUPPORTSCSTRING_IID);
+ nsISupportsCString aString = (nsISupportsCString) aValue.queryInterface(nsISupportsCString.NS_ISUPPORTSCSTRING_IID);
data = aString.getData();
aFlavor = DndUtil.kHTMLMime;
} else if (VpeDndUtil.isNsIStringInstance(aValue)) {
- nsISupportsString aString
- = (nsISupportsString) aValue.queryInterface(
- nsISupportsString.NS_ISUPPORTSSTRING_IID);
+ nsISupportsString aString = (nsISupportsString) aValue.queryInterface(nsISupportsString.NS_ISUPPORTSSTRING_IID);
data = aString.getData();
aFlavor = DndUtil.kURLMime;
}
@@ -2394,9 +2259,7 @@
// }
// } else {
// String tagname = getTagName(object);
- // if (tagname.indexOf("taglib") >= 0) {//$NON-NLS-1$
- // tagname = "taglib";//$NON-NLS-1$
- // }
+ // if (tagname.indexOf("taglib") >= 0)tagname = "taglib"; //$NON-NLS-1$ //$NON-NLS-2$
// Node sourceDragNode = ((Document) getModel().getAdapter(
// Document.class)).createElement(tagname);
// if (visualDropInfo.getDropContainer() != null) {
@@ -2410,16 +2273,12 @@
if (visualDropInfo.getDropContainer() != null && data != null) {
if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
- System.out.println(" drop! container: " //$NON-NLS-1$
- + visualDropInfo.getDropContainer().getNodeName());
+ System.out.println(" drop! container: " + visualDropInfo.getDropContainer().getNodeName()); //$NON-NLS-1$
}
- externalDropAny(aFlavor, data, range, sourceDropInfo == null
- ? null
- : sourceDropInfo.getContainer());
+ externalDropAny(aFlavor, data, range, sourceDropInfo == null ? null : sourceDropInfo.getContainer());
DropContext dropContext = new DropContext();
- IDNDTextEditor textEditor = (IDNDTextEditor)
- VpeController.this.editPart.getSourceEditor();
+ IDNDTextEditor textEditor = (IDNDTextEditor) VpeController.this.editPart.getSourceEditor();
// TypedEvent tEvent = new TypedEvent(mouseEvent);
// tEvent.data = data;
@@ -2466,8 +2325,8 @@
*/
String[] attributeString = formatText.split("\n"); //$NON-NLS-1$
/**
- * buffer string containing the attribute and
- * the value in the different succeding string
+ * buffer string containing the attribute and the value in the different
+ * succeding string
*/
String[] buffer = attributeString[0].split(" "); //$NON-NLS-1$
@@ -2502,19 +2361,12 @@
buffer = attributeString[i].split(" ", 2); //$NON-NLS-1$
if (i == 1) {
tempAttr.append(buffer[0] + " "); //$NON-NLS-1$
- tempValue.append(
- (buffer.length >= 2
- ? buffer[1]
- : "") //$NON-NLS-1$
- + " "); //$NON-NLS-1$
+ tempValue
+ .append((buffer.length >= 2 ? buffer[1] : "") + " "); //$NON-NLS-1$ //$NON-NLS-2$
} else {
- tempAttr.append(
- "\n" + buffer[0] + " "); //$NON-NLS-1$ //$NON-NLS-2$
- tempValue.append(" \n" //$NON-NLS-1$
- + (buffer.length >= 2
- ? buffer[1]
- : "") //$NON-NLS-1$
- + " "); //$NON-NLS-1$
+ tempAttr.append("\n" + buffer[0] + " "); //$NON-NLS-1$ //$NON-NLS-2$
+ tempValue
+ .append(" \n" + (buffer.length >= 2 ? buffer[1] : "") + " "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
}
@@ -2562,8 +2414,8 @@
*/
Point point = display.getCursorLocation();
/*
- * Assuming cursor is 21x21 because this is
- * the size of the arrow cursor on Windows
+ * Assuming cursor is 21x21 because this is the size of the arrow cursor
+ * on Windows
*/
point.y += 21;
tip.setLocation(point);
@@ -2636,16 +2488,13 @@
toolbarFormatControllerManager.selectionChanged();
}
- if (!switcher.startActiveEditor(
- ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
+ if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
return;
}
try {
if (VpeDebug.PRINT_SOURCE_SELECTION_EVENT) {
- System.out.println(">>>>>>>>>>>>>> " //$NON-NLS-1$
- + "selectionChanged " //$NON-NLS-1$
- + event.getSource());
+ System.out.println(">>>>>>>>>>>>>> selectionChanged " + event.getSource()); //$NON-NLS-1$
}
sourceSelectionChanged();
} finally {
@@ -2654,8 +2503,7 @@
}
// nsIClipboardDragDropHooks implementation
- public void onPasteOrDrop(nsIDOMMouseEvent mouseEvent,
- String flavor, String data) {
+ public void onPasteOrDrop(nsIDOMMouseEvent mouseEvent, String flavor, String data) {
onHideTooltip();
VpeVisualInnerDropInfo visualDropInfo = selectionBuilder
@@ -2669,9 +2517,7 @@
.getModelBuffer().source();
String tagname = getTagName(object);
- if (tagname.indexOf("taglib") >= 0) { //$NON-NLS-1$
- tagname = "taglib"; //$NON-NLS-1$
- }
+ if (tagname.indexOf("taglib") >= 0)tagname = "taglib"; //$NON-NLS-1$ //$NON-NLS-2$
Node sourceDragNode = ((Document) getModel().getAdapter(Document.class))
.createElement(tagname);
if (visualDropInfo.getDropContainer() != null) {
@@ -2683,8 +2529,7 @@
if (visualDropInfo.getDropContainer() != null) {
if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
- System.out.println(" drop! container: " //$NON-NLS-1$
- + visualDropInfo.getDropContainer().getNodeName());
+ System.out.println(" drop! container: " + visualDropInfo.getDropContainer().getNodeName()); //$NON-NLS-1$
}
final String finalFlavor = flavor;
final String finalData = data;
@@ -2819,7 +2664,6 @@
return Status.OK_STATUS;
}
};
- reinitJob.setRule(new VisualTreeChangingRule(this));
reinitJob.schedule();
}
@@ -2840,12 +2684,11 @@
}
//reinits selection controller+ controller
visualEditor.reinitDesignMode();
- visualSelectionController = new VpeSelectionController(
- visualEditor.getEditor().getSelectionController());
+ visualSelectionController = new VpeSelectionController(visualEditor.getEditor().getSelectionController());
- selectionBuilder = new VpeSelectionBuilder(domMapping,
- sourceBuilder, visualBuilder, visualSelectionController);
-
+ selectionBuilder = new VpeSelectionBuilder(domMapping, sourceBuilder,
+ visualBuilder, visualSelectionController);
+
selectionManager = new SelectionManager(pageContext,
sourceEditor, visualSelectionController);
@@ -2908,40 +2751,5 @@
public ISelectionManager getSelectionManager() {
return selectionManager;
}
-
- /**
- * Jobs with the same instances of {@code VisualTreeChangingRule}
- * but different {@code vpeController} are
- * never run concurrently. Any resource-changing rule can
- * be nested inside this rule.
- *
- * @author yradtsevich
- */
- private static final class VisualTreeChangingRule
- implements ISchedulingRule {
- private VpeController vpeController;
- public VisualTreeChangingRule(VpeController vpeController) {
- this.vpeController = vpeController;
- }
- public boolean contains(ISchedulingRule rule) {
- if (this == rule) {
- return true;
- } else if (rule instanceof IResource) {
- /* can contain any resource-changing rule
- * (it is needed during preferences-saving operations) */
- return true;
- } else {
- return false;
- }
- }
- public boolean isConflicting(ISchedulingRule rule) {
- if (rule instanceof VisualTreeChangingRule
- && ((VisualTreeChangingRule) rule).vpeController
- == this.vpeController) {
- return true;
- } else {
- return false;
- }
- }
- }
+
}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/InsertContributionItem.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/InsertContributionItem.java 2009-05-13 16:28:09 UTC (rev 15244)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/InsertContributionItem.java 2009-05-13 18:39:30 UTC (rev 15245)
@@ -60,18 +60,18 @@
.getController().getPageContext();
}
- public InsertContributionItem(StructuredTextEditor sourceEditor,
- VpePageContext pageContext) {
- this.sourceEditor = sourceEditor;
- this.pageContext = pageContext;
- }
-
@Override
public void fill(Menu menu, int index) {
for (final InsertType insertItem : InsertType.values()) {
+ final MenuItem item;
+ if (index < 0) {
+ item = new MenuItem(menu, SWT.CASCADE);
+ } else {
+ item = new MenuItem(menu, SWT.CASCADE,
+ index + insertItem.ordinal());
+ }
+
final String itemName = insertItem.getMessage();
- final MenuItem item = new MenuItem(menu,
- SWT.CASCADE, index + insertItem.ordinal());
item.setText(itemName);
final Menu paletteManu = new Menu(menu);
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/MenuCreationHelper.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/MenuCreationHelper.java 2009-05-13 16:28:09 UTC (rev 15244)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/MenuCreationHelper.java 2009-05-13 18:39:30 UTC (rev 15245)
@@ -17,8 +17,6 @@
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.text.TextUtilities;
-import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
@@ -66,6 +64,7 @@
* This is helper class is used to create context menu for VPE.
*
* @author Igor Zhukov (izhukov(a)exadel.com)
+ * @deprecated use {@link VpeMenuCreator} instead
*/
public class MenuCreationHelper {
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/SetupTemplateContributionItem.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/SetupTemplateContributionItem.java 2009-05-13 16:28:09 UTC (rev 15244)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/SetupTemplateContributionItem.java 2009-05-13 18:39:30 UTC (rev 15245)
@@ -25,7 +25,6 @@
import org.jboss.tools.vpe.editor.mapping.VpeElementMapping;
import org.jboss.tools.vpe.editor.menu.action.SetupTemplateAction;
import org.jboss.tools.vpe.editor.template.VpeHtmlTemplate;
-import org.jboss.tools.vpe.editor.util.Constants;
import org.jboss.tools.vpe.messages.VpeUIMessages;
import org.w3c.dom.Element;
@@ -44,26 +43,15 @@
*/
public SetupTemplateContributionItem() {
super(new SetupTemplateAction());
- JSPMultiPageEditor editor = (JSPMultiPageEditor) PlatformUI
+ final JSPMultiPageEditor editor = (JSPMultiPageEditor) PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getActivePage()
.getActiveEditor();
this.sourceEditor = editor.getSourceEditor();
this.pageContext = ((VpeEditorPart) editor.getVisualEditor())
.getController().getPageContext();
- ((SetupTemplateAction) getAction()).setPageContext(pageContext);
+ getAction().setPageContext(pageContext);
}
- /**
- *
- */
- public SetupTemplateContributionItem(VpePageContext pageContext,
- StructuredTextEditor sourceEditor) {
- super(new SetupTemplateAction(pageContext));
- this.pageContext = pageContext;
- this.sourceEditor = sourceEditor;
-
- }
-
@Override
public void fill(Menu menu, int index) {
@@ -77,14 +65,14 @@
.getDomMapping().getNodeMapping(element);
if (elementMapping != null
&& elementMapping.getTemplate() != null
- && elementMapping.getTemplate().getType() == VpeHtmlTemplate.TYPE_ANY) {
+ && elementMapping.getTemplate().getType()
+ == VpeHtmlTemplate.TYPE_ANY) {
- ((SetupTemplateAction) getAction()).setText(NLS.bind(
+ getAction().setText(NLS.bind(
VpeUIMessages.SETUP_TEMPLATE_FOR_MENU,
element.getNodeName()));
- ((SetupTemplateAction) getAction()).setActionNode(element);
- ((SetupTemplateAction) getAction()).setData(elementMapping
- .getTemplate().getAnyData());
+ getAction().setActionNode(element);
+ getAction().setData(elementMapping.getTemplate().getAnyData());
MenuItem item = new MenuItem(menu, SWT.SEPARATOR, index );
super.fill(menu, index+1);
}
@@ -92,4 +80,8 @@
}
+ @Override
+ public SetupTemplateAction getAction() {
+ return (SetupTemplateAction) super.getAction();
+ }
}
Added: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/VpeMenuCreator.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/VpeMenuCreator.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/VpeMenuCreator.java 2009-05-13 18:39:30 UTC (rev 15245)
@@ -0,0 +1,282 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.editor.menu;
+
+import java.text.MessageFormat;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.texteditor.AbstractTextEditor;
+import org.eclipse.wst.sse.ui.StructuredTextEditor;
+import org.jboss.tools.vpe.VpeDebug;
+import org.jboss.tools.vpe.editor.mapping.VpeDomMapping;
+import org.jboss.tools.vpe.editor.mapping.VpeNodeMapping;
+import org.jboss.tools.vpe.editor.menu.action.EditAttributesAction;
+import org.jboss.tools.vpe.editor.menu.action.SelectThisTagAction;
+import org.jboss.tools.vpe.editor.menu.action.StripTagAction;
+import org.jboss.tools.vpe.editor.menu.action.ComplexAction;
+import org.jboss.tools.vpe.editor.mozilla.MozillaEditor;
+import org.jboss.tools.vpe.editor.util.SelectionUtil;
+import org.jboss.tools.vpe.messages.VpeUIMessages;
+import org.jboss.tools.vpe.xulrunner.browser.util.DOMTreeDumper;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * This class is used to create context menu for VPE.
+ *
+ * @author yradtsevich
+ * (based on the implementation of MenuCreationHelper)
+ */
+public class VpeMenuCreator {
+ private final MenuManager menuManager;
+ private final VpeMenuUtil vpeMenuUtil;
+ private final Node node;
+
+ public VpeMenuCreator(final MenuManager menuManager, final Node node) {
+ this.node = node;
+ this.menuManager = menuManager;
+ this.vpeMenuUtil = new VpeMenuUtil();
+ }
+
+ /**
+ * Inserts new menu items into {@link #menuManager}.
+ */
+ public void createMenu() {
+ createMenu(true);
+ }
+
+ /**
+ * Inserts new menu items into {@link #menuManager}.
+ *
+ * @param topLevelMenu if it is {@code true} then the menu will contain
+ * elements for the top level variant of the VPE menu, otherwise - elements
+ * for the sub menu variant.
+ *
+ * @see #addParentTagMenuItem(Element)
+ */
+ private void createMenu(boolean topLevelMenu) {
+ addIfEnabled(new EditAttributesAction(node));
+ menuManager.add(new SetupTemplateContributionItem());
+
+ if (!topLevelMenu) {
+ menuManager.add(new SelectThisTagAction(node));
+ }
+
+ final Node parent = node == null ? null : node.getParentNode();
+ if (parent != null && parent.getNodeType() == Node.ELEMENT_NODE) {
+ addParentTagMenuItem((Element) parent);
+ }
+ addSeparator();
+
+ menuManager.add(new InsertContributionItem());
+ addIfEnabled(new StripTagAction(node));
+ addSeparator();
+
+ if (topLevelMenu) {
+ addIfEnabled(new DumpSourceAction());
+ addIfEnabled(new DumpSelectedElementAction());
+ addIfEnabled(new DumpMappingAction());
+ addIfEnabled(new TestAction());
+ }
+ addSeparator();
+ addCutCopyPasteActions(topLevelMenu);
+ }
+
+ /**
+ * Creates the Cut, Copy and Paste actions.
+ */
+ private void addCutCopyPasteActions(boolean topLevelMenu) {
+ final IAction cutAction = getSourceEditorAction(ActionFactory.CUT);
+ final IAction copyAction = getSourceEditorAction(ActionFactory.COPY);
+ final IAction pasteAction = getSourceEditorAction(ActionFactory.PASTE);
+ if (topLevelMenu) {
+ if (node != null) {
+ menuManager.add(cutAction);
+ menuManager.add(copyAction);
+ }
+ menuManager.add(pasteAction);
+ } else {
+ final IAction selectAction = new SelectThisTagAction(node);
+ if (selectAction.isEnabled()) {
+ menuManager.add(new ComplexAction(cutAction.getText(),
+ selectAction, cutAction));
+ menuManager.add(new ComplexAction(copyAction.getText(),
+ selectAction, copyAction));
+ menuManager.add(new ComplexAction(pasteAction.getText(),
+ selectAction, pasteAction));
+ }
+ }
+ }
+
+ /**
+ * If the {@code action} is enabled, adds it to
+ * the {@link #menuManager}.
+ */
+ private void addIfEnabled(IAction action) {
+ if (action.isEnabled()) {
+ menuManager.add(action);
+ }
+ }
+
+ /**
+ * Adds a menu item for operations on {@code parent} element.
+ *
+ * @param parent the parent element
+ */
+ private void addParentTagMenuItem(final Element parent) {
+ final String itemName = MessageFormat.format(
+ VpeUIMessages.PARENT_TAG_MENU_ITEM, parent.getNodeName());
+
+ final MenuManager parentMenuManager = new MenuManager(itemName);
+ parentMenuManager.setParent(menuManager);
+ parentMenuManager.setRemoveAllWhenShown(true);
+ parentMenuManager.addMenuListener(new IMenuListener() {
+ public void menuAboutToShow(final IMenuManager manager) {
+ new VpeMenuCreator(parentMenuManager, parent).createMenu(false);
+ }
+ });
+
+ menuManager.add(parentMenuManager);
+ }
+
+ /**
+ * Adds a separator. If {@link #menuManager} is empty or the last
+ * item already is a separator, does nothing.
+ */
+ private void addSeparator() {
+ final int size = menuManager.getSize();
+ if (size > 0) {
+ final IContributionItem lastItem = menuManager.getItems()[size - 1];
+ if (!lastItem.isSeparator()) {
+ menuManager.add(new Separator());
+ }
+ }
+ }
+
+ /**
+ * Returns an action of the source editor.
+ *
+ * @param actionFactory instance of {@link ActionFactory}
+ * which identifies the action of the item.
+ */
+ private IAction getSourceEditorAction(final ActionFactory actionFactory) {
+ final AbstractTextEditor sourceEditor = vpeMenuUtil.getSourceEditor();
+ final IAction action = sourceEditor.getAction(actionFactory.getId());
+ return action;
+ }
+
+
+ /**
+ * Test action. For the debugging purposes only.
+ */
+ public class TestAction extends Action {
+ public TestAction() {
+ setText("Test Action"); //$NON-NLS-1$
+ }
+
+ public void run() {
+ // test code
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return VpeDebug.VISUAL_CONTEXTMENU_TEST;
+ }
+ }
+
+ /**
+ * Action to dump source of VPE.
+ * For debugging purposes only.
+ */
+ public class DumpSourceAction extends Action {
+ public DumpSourceAction() {
+ setText("Dump Source"); //$NON-NLS-1$
+ }
+
+ @Override
+ public void run() {
+ final MozillaEditor visualEditor
+ = vpeMenuUtil.getMozillaEditor();
+ DOMTreeDumper dumper = new DOMTreeDumper(
+ VpeDebug.VISUAL_DUMP_PRINT_HASH);
+ dumper.setIgnoredAttributes(
+ VpeDebug.VISUAL_DUMP_IGNORED_ATTRIBUTES);
+ dumper.dumpToStream(System.out, visualEditor.getDomDocument());
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return VpeDebug.VISUAL_CONTEXTMENU_DUMP_SOURCE;
+ }
+ }
+
+ /**
+ * Action to dump source of the selected VPE element.
+ * For debugging purposes only.
+ */
+ public class DumpSelectedElementAction extends Action {
+ public DumpSelectedElementAction() {
+ setText("Dump Selected Element"); //$NON-NLS-1$
+ }
+
+ @Override
+ public void run() {
+ final StructuredTextEditor sourceEditor
+ = vpeMenuUtil.getSourceEditor();
+ final VpeDomMapping domMapping
+ = vpeMenuUtil.getDomMapping();
+ final VpeNodeMapping nodeMapping
+ = SelectionUtil.getNodeMappingBySourceSelection(
+ sourceEditor, domMapping);
+ if (nodeMapping != null) {
+ DOMTreeDumper dumper = new DOMTreeDumper(
+ VpeDebug.VISUAL_DUMP_PRINT_HASH);
+ dumper.setIgnoredAttributes(
+ VpeDebug.VISUAL_DUMP_IGNORED_ATTRIBUTES);
+ dumper.dumpNode(nodeMapping.getVisualNode());
+ }
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return VpeDebug.VISUAL_CONTEXTMENU_DUMP_SELECTED_ELEMENT;
+ }
+ }
+
+ /**
+ * Action to print the {@link #domMapping}.
+ * For debugging purposes only.
+ */
+ public class DumpMappingAction extends Action {
+ public DumpMappingAction() {
+ setText("Dump Mapping"); //$NON-NLS-1$
+ }
+
+ @Override
+ public void run() {
+ final VpeDomMapping domMapping
+ = vpeMenuUtil.getDomMapping();
+ domMapping.printMapping();
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return VpeDebug.VISUAL_CONTEXTMENU_DUMP_MAPPING;
+ }
+ }
+}
Added: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/VpeMenuUtil.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/VpeMenuUtil.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/VpeMenuUtil.java 2009-05-13 18:39:30 UTC (rev 15245)
@@ -0,0 +1,130 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.editor.menu;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.wst.sse.ui.StructuredTextEditor;
+import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
+import org.jboss.tools.vpe.editor.VpeEditorPart;
+import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.mapping.VpeDomMapping;
+import org.jboss.tools.vpe.editor.mozilla.MozillaEditor;
+import org.w3c.dom.Node;
+
+/**
+ * An utility class that allows easily and quickly get
+ * some environment variables.
+ * <P>IMPORTANT: If an environment variable changes
+ * between the constructor call and the variable's getter call, the method
+ * could return an incorrect result. You must create a new instance to
+ * get correct result!
+ * </P>
+ *
+ * @author yradtsevich
+ */
+public class VpeMenuUtil {
+ private JSPMultiPageEditor editor;
+ private boolean editorInitialized = false;
+ private StructuredTextEditor sourceEditor;
+ private boolean sourceEditorInitialized = false;
+ private VpeDomMapping domMapping;
+ private boolean domMappingInitialized = false;
+ private VpePageContext pageContext;
+ private boolean pageContextInitialized = false;
+ private Node selectedNode;
+ private boolean selectedNodeInitialized = false;
+ private IStructuredSelection selection;
+ private boolean selectionInitialized = false;
+ private MozillaEditor mozillaEditor;
+ private boolean mozillaEditorInitialized = false;
+
+ /**
+ * Returns active {@code JSPMultiPageEditor}
+ */
+ public JSPMultiPageEditor getEditor() {
+ if (!editorInitialized) {
+ editor = (JSPMultiPageEditor) PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow()
+ .getActivePage().getActiveEditor();
+ editorInitialized = true;
+ }
+ return editor;
+ }
+ /**
+ * Returns active {@code StructuredTextEditor}
+ */
+ public StructuredTextEditor getSourceEditor() {
+ if (!sourceEditorInitialized) {
+ sourceEditor = getEditor().getSourceEditor();
+ sourceEditorInitialized = true;
+ }
+ return sourceEditor;
+ }
+ /**
+ * Returns active {@code StructuredTextEditor}
+ */
+ public VpeDomMapping getDomMapping() {
+ if (!domMappingInitialized) {
+ domMapping = getPageContext().getDomMapping();
+ domMappingInitialized = true;
+ }
+ return domMapping;
+ }
+ /**
+ * Returns {@code VpePageContext} of
+ * the active editor
+ */
+ public VpePageContext getPageContext() {
+ if (!pageContextInitialized) {
+ pageContext = ((VpeEditorPart) getEditor().getVisualEditor())
+ .getController().getPageContext();
+ pageContextInitialized = true;
+ }
+ return pageContext;
+ }
+ /**
+ * Returns active source selection
+ */
+ public IStructuredSelection getSelection() {
+ if (!selectionInitialized) {
+ selection = (IStructuredSelection) getSourceEditor()
+ .getSelectionProvider().getSelection();
+ selectionInitialized = true;
+ }
+ return selection;
+ }
+ /**
+ * Returns selected node.
+ */
+ public Node getSelectedNode() {
+ if (!selectedNodeInitialized) {
+ selection = getSelection();
+ if (selection != null
+ && selection.getFirstElement() instanceof Node) {
+ selectedNode = (Node) selection.getFirstElement();
+ }
+ selectedNodeInitialized = true;
+ }
+ return selectedNode;
+ }
+ /**
+ * Returns active {@code MozillaEditor}
+ */
+ public MozillaEditor getMozillaEditor() {
+ if (!mozillaEditorInitialized) {
+ mozillaEditor = ((VpeEditorPart) getEditor().getVisualEditor())
+ .getVisualEditor();
+ mozillaEditorInitialized = true;
+ }
+ return mozillaEditor;
+ }
+}
Added: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/action/ComplexAction.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/action/ComplexAction.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/action/ComplexAction.java 2009-05-13 18:39:30 UTC (rev 15245)
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.editor.menu.action;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+
+/**
+ * Allows to create an action which composed of multiple actions.
+ *
+ * @author yradtsevich
+ */
+public class ComplexAction extends Action {
+ private final IAction[] actions;
+
+ public ComplexAction(final String name, final IAction... actions) {
+ super(name);
+ this.actions = actions;
+ }
+
+ @Override
+ public void run() {
+ for (final IAction action : actions) {
+ action.run();
+ }
+ }
+}
\ No newline at end of file
Added: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/action/EditAttributesAction.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/action/EditAttributesAction.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/action/EditAttributesAction.java 2009-05-13 18:39:30 UTC (rev 15245)
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.editor.menu.action;
+
+import java.lang.reflect.InvocationTargetException;
+import java.text.MessageFormat;
+
+import org.eclipse.jface.action.Action;
+import org.jboss.tools.common.model.ui.objecteditor.ExtendedProperties;
+import org.jboss.tools.common.model.ui.objecteditor.ExtendedPropertiesWizard;
+import org.jboss.tools.common.model.util.ModelFeatureFactory;
+import org.jboss.tools.vpe.VpePlugin;
+import org.jboss.tools.vpe.editor.mapping.VpeDomMapping;
+import org.jboss.tools.vpe.editor.mapping.VpeElementMapping;
+import org.jboss.tools.vpe.editor.menu.VpeMenuUtil;
+import org.jboss.tools.vpe.messages.VpeUIMessages;
+import org.w3c.dom.Node;
+
+/**
+ * Action to edit attributes of the {@link #node}.
+ *
+ * @author yradtsevich
+ * (based on the implementation of MenuCreationHelper)
+ */
+public class EditAttributesAction extends Action {
+ final Node node;
+ final VpeMenuUtil menuUtil = new VpeMenuUtil();
+
+ public EditAttributesAction() {
+ this.node = menuUtil.getSelectedNode();
+ init();
+ }
+ public EditAttributesAction(final Node node) {
+ this.node = node;
+ init();
+ }
+
+ private void init() {
+ final String name = MessageFormat.format(
+ VpeUIMessages.ATTRIBUTES_MENU_ITEM,
+ node != null ? node.getNodeName() : "");
+ setText(name);
+ }
+
+ @Override
+ public void run() {
+ showProperties(node);
+ }
+
+ /**
+ * Indicates if editing of attributes of {@link #node}
+ * should be enabled.
+ */
+ @Override
+ public boolean isEnabled() {
+ final VpeDomMapping domMapping = menuUtil.getDomMapping();
+ if (node != null && node.getNodeType() == Node.ELEMENT_NODE) {
+ final VpeElementMapping elementMapping
+ = (VpeElementMapping) domMapping.getNodeMapping(node);
+ if (elementMapping != null
+ && elementMapping.getTemplate() != null) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Method is used to show properties of the node.
+ *
+ * @param node the Node object
+ */
+ private void showProperties(Node node) {
+ ExtendedProperties p = createExtendedProperties(node);
+ if (p != null) {
+ ExtendedPropertiesWizard.run(p);
+ }
+ }
+
+ /**
+ * Create extended properties list for the node.
+ *
+ * @param node the Node to be processed
+ * @return an extended properties
+ */
+ private ExtendedProperties createExtendedProperties(Node node) {
+ final Class<?> c = ModelFeatureFactory.getInstance().getFeatureClass(
+ "org.jboss.tools.jst.jsp.outline.VpeProperties"); //$NON-NLS-1$
+ try {
+ return (ExtendedProperties) c.getDeclaredConstructor(
+ new Class[] {Node.class}).newInstance(new Object[] {node});
+ } catch (IllegalArgumentException e) {
+ VpePlugin.getPluginLog().logError(e);
+ } catch (SecurityException e) {
+ VpePlugin.getPluginLog().logError(e);
+ } catch (InstantiationException e) {
+ VpePlugin.getPluginLog().logError(e);
+ } catch (IllegalAccessException e) {
+ VpePlugin.getPluginLog().logError(e);
+ } catch (InvocationTargetException e) {
+ VpePlugin.getPluginLog().logError(e);
+ } catch (NoSuchMethodException e) {
+ VpePlugin.getPluginLog().logError(e);
+ }
+ return null;
+ }
+}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/action/InsertAction2.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/action/InsertAction2.java 2009-05-13 16:28:09 UTC (rev 15244)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/action/InsertAction2.java 2009-05-13 18:39:30 UTC (rev 15245)
@@ -14,9 +14,6 @@
import org.eclipse.jface.action.Action;
import org.eclipse.jface.text.IUndoManager;
-import org.eclipse.jface.text.TextSelection;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.swt.graphics.Point;
import org.eclipse.wst.sse.ui.StructuredTextEditor;
Added: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/action/SelectThisTagAction.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/action/SelectThisTagAction.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/action/SelectThisTagAction.java 2009-05-13 18:39:30 UTC (rev 15245)
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.editor.menu.action;
+
+
+import org.eclipse.jface.action.Action;
+import org.jboss.tools.vpe.editor.menu.VpeMenuUtil;
+import org.jboss.tools.vpe.editor.util.NodesManagingUtil;
+import org.jboss.tools.vpe.messages.VpeUIMessages;
+import org.w3c.dom.Node;
+
+/**
+ * Action to select {@link #node}.
+ *
+ * @author yradtsevich
+ * (based on the implementation of MenuCreationHelper)
+ */
+public class SelectThisTagAction extends Action {
+ final Node node;
+ final VpeMenuUtil menuUtil = new VpeMenuUtil();
+
+ public SelectThisTagAction() {
+ this.node = menuUtil.getSelectedNode();
+ init();
+ }
+ public SelectThisTagAction(final Node node) {
+ this.node = node;
+ init();
+ }
+
+ private void init() {
+ setText(VpeUIMessages.SELECT_THIS_TAG_MENU_ITEM);
+ }
+
+ @Override
+ public void run() {
+ final int start = NodesManagingUtil.getStartOffsetNode(node);
+ final int end = NodesManagingUtil.getEndOffsetNode(node);
+ menuUtil.getSourceEditor().getTextViewer().setSelectedRange(
+ start, end - start);
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return node != null;
+ }
+}
Added: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/action/StripTagAction.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/action/StripTagAction.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/action/StripTagAction.java 2009-05-13 18:39:30 UTC (rev 15245)
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.editor.menu.action;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.text.IUndoManager;
+import org.eclipse.wst.sse.ui.StructuredTextEditor;
+import org.jboss.tools.vpe.editor.menu.VpeMenuUtil;
+import org.jboss.tools.vpe.messages.VpeUIMessages;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * Action to "strip tag" - replace the node by its children.
+ *
+ * @author yradtsevich
+ * (based on the implementation of MenuCreationHelper)
+ */
+public class StripTagAction extends Action {
+ final Node node;
+ final VpeMenuUtil menuUtil = new VpeMenuUtil();
+
+ public StripTagAction() {
+ this.node = menuUtil.getSelectedNode();
+ init();
+ }
+ public StripTagAction(final Node node) {
+ this.node = node;
+ init();
+ }
+
+ private void init() {
+ setText(VpeUIMessages.STRIP_TAG_MENU_ITEM);
+ }
+
+ @Override
+ public void run() {
+ final Node parent = node.getParentNode();
+ if (parent != null) {
+ final IUndoManager undoManager = menuUtil.getSourceEditor()
+ .getTextViewer().getUndoManager();
+ try {
+ undoManager.beginCompoundChange();
+ moveNodeChildrenInto(parent);
+ parent.removeChild(node);
+ } finally {
+ undoManager.endCompoundChange();
+ }
+ }
+ }
+
+ private void moveNodeChildrenInto(final Node parent) {
+ final NodeList children = node.getChildNodes();
+ final int childrenLength = children.getLength();
+ for (int i = 0; i < childrenLength; i++) {
+ final Node child = children.item(0);
+ node.removeChild(child);
+ parent.insertBefore(child, node);
+ }
+ }
+
+ @Override
+ public boolean isEnabled() {
+ if (node == null) {
+ return false;
+ }
+ if (node.getNodeType() != Node.ELEMENT_NODE) {
+ return false;
+ }
+
+ final NodeList children = node.getChildNodes();
+ final int childrenLength = children.getLength();
+ if (childrenLength <= 0) {
+ return false;
+ }
+ if (childrenLength == 1
+ && children.item(0).getNodeValue().trim().isEmpty()) {
+ return false;
+ }
+
+ return true;
+ }
+}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/VpeUIMessages.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/VpeUIMessages.java 2009-05-13 16:28:09 UTC (rev 15244)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/VpeUIMessages.java 2009-05-13 18:39:30 UTC (rev 15245)
@@ -13,13 +13,18 @@
import org.eclipse.osgi.util.NLS;
public class VpeUIMessages extends NLS {
- private static final String BUNDLE_NAME = "org.jboss.tools.vpe.messages.messages";//$NON-NLS-1$
+ private static final String BUNDLE_NAME
+ = "org.jboss.tools.vpe.messages.messages";//$NON-NLS-1$
static {
// load message values from bundle file
NLS.initializeMessages(BUNDLE_NAME, VpeUIMessages.class);
}
private VpeUIMessages(){}
+ public static String ATTRIBUTES_MENU_ITEM;
+ public static String SELECT_THIS_TAG_MENU_ITEM;
+ public static String STRIP_TAG_MENU_ITEM;
+ public static String PARENT_TAG_MENU_ITEM;
public static String NAMESPACE_NOT_DEFINED;
public static String PREFERENCES;
public static String REFRESH;
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/messages.properties
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/messages.properties 2009-05-13 16:28:09 UTC (rev 15244)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/messages/messages.properties 2009-05-13 18:39:30 UTC (rev 15245)
@@ -1,3 +1,7 @@
+ATTRIBUTES_MENU_ITEM=<{0}> Attributes
+SELECT_THIS_TAG_MENU_ITEM=Select This Tag
+STRIP_TAG_MENU_ITEM=Strip Tag
+PARENT_TAG_MENU_ITEM=Parent Tag ({0})
NAMESPACE_NOT_DEFINED=Namespace is not defined. Template could not be edited.
PREFERENCES=Preferences
REFRESH=Refresh
15 years, 6 months
JBoss Tools SVN: r15244 - trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2009-05-13 12:28:09 -0400 (Wed, 13 May 2009)
New Revision: 15244
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/AbstractExtendedXMLFileImpl.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4312
Modified: trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/AbstractExtendedXMLFileImpl.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/AbstractExtendedXMLFileImpl.java 2009-05-13 15:28:14 UTC (rev 15243)
+++ trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/AbstractExtendedXMLFileImpl.java 2009-05-13 16:28:09 UTC (rev 15244)
@@ -197,9 +197,15 @@
m.fireStructureChanged(this);
if(!isOverlapped) getResourceMarkers().update();
} else if(isMergingChanges()) {
+ String oldBody = get("correctBody");
+ boolean changed = body != null && !body.equals(oldBody);
set("correctBody", body);
set("actualBodyTimeStamp", "0");
+ long ots = getTimeStamp();
mergeAll(f, update);
+ if(changed && ots == getTimeStamp()) {
+ changeTimeStamp();
+ }
set("actualBodyTimeStamp", "" + getTimeStamp());
if(errors1) m.fireStructureChanged(this);
if(!isOverlapped) constraintChecker.check();
15 years, 6 months
JBoss Tools SVN: r15243 - trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template.
by jbosstools-commits@lists.jboss.org
Author: dmaliarevich
Date: 2009-05-13 11:28:14 -0400 (Wed, 13 May 2009)
New Revision: 15243
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDropDownMenuTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesMenuGroupTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesMenuItemTemplate.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-2497, attributes were moved to separate class.
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDropDownMenuTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDropDownMenuTemplate.java 2009-05-13 14:33:34 UTC (rev 15242)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDropDownMenuTemplate.java 2009-05-13 15:28:14 UTC (rev 15243)
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2007-2008 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
- *
- * Contributor:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ * Copyright (c) 2007-2008 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
package org.jboss.tools.jsf.vpe.richfaces.template;
import java.util.List;
@@ -18,69 +18,216 @@
import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate;
import org.jboss.tools.vpe.editor.template.VpeChildrenInfo;
import org.jboss.tools.vpe.editor.template.VpeCreationData;
+import org.jboss.tools.vpe.editor.util.Constants;
import org.jboss.tools.vpe.editor.util.HTML;
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
import org.mozilla.interfaces.nsIDOMText;
-import org.w3c.dom.Attr;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
public class RichFacesDropDownMenuTemplate extends VpeAbstractTemplate {
-
+
+ /*
+ * rich:dropDownMenu constants
+ */
+ private static final String COMPONENT_NAME = "dropDownMenu"; //$NON-NLS-1$
+ private static final String STYLE_PATH = "dropDownMenu/dropDownMenu.css"; //$NON-NLS-1$
+ private static final String CHILD_GROUP_NAME = ":menuGroup"; //$NON-NLS-1$
+ private static final String CHILD_ITEM_NAME = ":menuItem"; //$NON-NLS-1$
+ private static final String LABEL_FACET_NAME = "label"; //$NON-NLS-1$
+ private static final String DEFAULT_DDM_TITLE = "rich:dropDownMenu"; //$NON-NLS-1$
+
+ /*
+ * Constants for drop down mechanism.
+ */
+ private static final String MENU_TOP_ID = "vpe-ddm-menu-title-ul"; //$NON-NLS-1$
+ private static final String MENU_TOP_ITEM_ID = "vpe-ddm-menu-title-li"; //$NON-NLS-1$
+ private static final String MENU_CHILDREN_LIST_ID = "vpe-ddm-menu-children-ul"; //$NON-NLS-1$
+
+ /*
+ * rich:dropDownMenu css styles names
+ */
+ private static final String CSS_RICH_DDMENU_LABEL = "rich-ddmenu-label"; //$NON-NLS-1$
+ private static final String CSS_RICH_DDMENU_LABEL_UNSELECT = "rich-ddmenu-label-unselect"; //$NON-NLS-1$
+ private static final String CSS_RICH_DDMENU_LABEL_SELECT = "rich-ddmenu-label-select"; //$NON-NLS-1$
+ private static final String CSS_RICH_DDMENU_LABEL_DISABLED = "rich-ddmenu-label-disabled"; //$NON-NLS-1$
+ private static final String CSS_RICH_LABEL_TEXT_DECOR = "rich-label-text-decor"; //$NON-NLS-1$
+ private static final String CSS_RICH_MENU_LIST_BORDER = "rich-menu-list-border"; //$NON-NLS-1$
+ private static final String CSS_RICH_MENU_LIST_BG = "rich-menu-list-bg"; //$NON-NLS-1$
+ private static final String CSS_RICH_DDEMENU_LIST_DIV_STYLE = ""; //$NON-NLS-1$
+ private static final String CSS_RICH_DDEMENU_BORDER_DIV_STYLE = ""; //$NON-NLS-1$
+ private static final String CSS_MENU_TOP_DIV = "dr-menu-top-div"; //$NON-NLS-1$
+
+ public VpeCreationData create(VpePageContext pageContext, Node sourceNode, nsIDOMDocument visualDocument) {
+ VpeCreationData creationData = null;
+ Element sourceElement = (Element)sourceNode;
+
+ ComponentUtil.setCSSLink(pageContext, STYLE_PATH, COMPONENT_NAME);
+ final Attributes attrs = new Attributes(sourceElement);
+
/*
- * rich:dropDownMenu constants
+ * DropDownMenu component structure.
+ * In order of nesting.
*/
- private static final String COMPONENT_NAME = "dropDownMenu"; //$NON-NLS-1$
- private static final String STYLE_PATH = "dropDownMenu/dropDownMenu.css"; //$NON-NLS-1$
- private static final String CHILD_GROUP_NAME = ":menuGroup"; //$NON-NLS-1$
- private static final String CHILD_ITEM_NAME = ":menuItem"; //$NON-NLS-1$
- private static final String LABEL_FACET_NAME = "label"; //$NON-NLS-1$
- private static final String DEFAULT_DDM_TITLE = "ddm"; //$NON-NLS-1$
- private static final String EMPTY = ""; //$NON-NLS-1$
- private static final String SPACE = " "; //$NON-NLS-1$
+ nsIDOMElement ddmMainUL;
+ nsIDOMElement ddmMainLI;
+ nsIDOMElement ddmChildrenUL;
+ nsIDOMElement ddmLabelDiv;
+ nsIDOMElement ddmTextSpan;
+ nsIDOMText ddmLabelText;
+ nsIDOMElement ddmListDiv;
+ nsIDOMElement ddmListBorderDiv;
+ nsIDOMElement ddmListBgDiv;
/*
- * Constants for drop down mechanism.
+ * Creating visual elements
*/
- private static final String MENU_TOP_ID = "vpe-ddm-menu-title-ul"; //$NON-NLS-1$
- private static final String MENU_TOP_ITEM_ID = "vpe-ddm-menu-title-li"; //$NON-NLS-1$
- private static final String MENU_CHILDREN_LIST_ID = "vpe-ddm-menu-children-ul"; //$NON-NLS-1$
-
+ ddmMainUL = visualDocument.createElement(HTML.TAG_UL);
+ ddmMainLI = visualDocument.createElement(HTML.TAG_LI);
+ ddmChildrenUL = visualDocument.createElement(HTML.TAG_UL);
+ ddmLabelDiv = visualDocument.createElement(HTML.TAG_DIV);
+ ddmTextSpan = visualDocument.createElement(HTML.TAG_SPAN);
+ ddmLabelText = visualDocument.createTextNode(Constants.EMPTY);
+ ddmListDiv = visualDocument.createElement(HTML.TAG_DIV);
+ ddmListBorderDiv = visualDocument.createElement(HTML.TAG_DIV);
+ ddmListBgDiv = visualDocument.createElement(HTML.TAG_DIV);
+ creationData = new VpeCreationData(ddmMainUL);
+
/*
- * rich:dropDownMenu css styles names
+ * Nesting elements
*/
- private static final String CSS_RICH_DDMENU_LABEL = "rich-ddmenu-label"; //$NON-NLS-1$
- private static final String CSS_RICH_DDMENU_LABEL_UNSELECT = "rich-ddmenu-label-unselect"; //$NON-NLS-1$
- private static final String CSS_RICH_DDMENU_LABEL_SELECT = "rich-ddmenu-label-select"; //$NON-NLS-1$
- private static final String CSS_RICH_DDMENU_LABEL_DISABLED = "rich-ddmenu-label-disabled"; //$NON-NLS-1$
- private static final String CSS_RICH_LABEL_TEXT_DECOR = "rich-label-text-decor"; //$NON-NLS-1$
- private static final String CSS_RICH_MENU_LIST_BORDER = "rich-menu-list-border"; //$NON-NLS-1$
- private static final String CSS_RICH_MENU_LIST_BG = "rich-menu-list-bg"; //$NON-NLS-1$
- private static final String CSS_RICH_DDEMENU_LIST_DIV_STYLE = ""; //$NON-NLS-1$
- private static final String CSS_RICH_DDEMENU_BORDER_DIV_STYLE = ""; //$NON-NLS-1$
- private static final String CSS_MENU_TOP_DIV = "dr-menu-top-div"; //$NON-NLS-1$
+ ddmLabelDiv.appendChild(ddmTextSpan);
+// ddmTextSpan.appendChild(ddmLabelText);
+// ddmLabelDiv.appendChild(ddmListDiv);
+ ddmListDiv.appendChild(ddmListBorderDiv);
+ ddmListBorderDiv.appendChild(ddmListBgDiv);
+ ddmMainUL.appendChild(ddmMainLI);
+ ddmMainLI.appendChild(ddmLabelDiv);
/*
+ * Setting attributes for the drop-down mechanism
+ */
+ ddmMainUL.setAttribute(MENU_TOP_ID, Constants.EMPTY);
+ ddmMainLI.setAttribute(MENU_TOP_ITEM_ID, Constants.EMPTY);
+ ddmChildrenUL.setAttribute(MENU_CHILDREN_LIST_ID, Constants.EMPTY);
+
+ /*
+ * Setting css classes
+ */
+ String labelDivClass = Constants.EMPTY;
+ String listBorderDivClass = Constants.EMPTY;
+
+ labelDivClass += Constants.WHITE_SPACE + CSS_RICH_DDMENU_LABEL + Constants.WHITE_SPACE
+ + CSS_RICH_DDMENU_LABEL_UNSELECT;
+ listBorderDivClass += Constants.WHITE_SPACE + CSS_RICH_MENU_LIST_BORDER;
+
+ if (ComponentUtil.isNotBlank(attrs.getStyleClass())) {
+ labelDivClass += Constants.WHITE_SPACE + attrs.getStyleClass();
+ listBorderDivClass += Constants.WHITE_SPACE + attrs.getStyleClass();
+ }
+
+// ddmLabelDiv.setAttribute(HTML.ATTR_CLASS, labelDivClass);
+ ddmLabelDiv.setAttribute(HTML.ATTR_CLASS, CSS_MENU_TOP_DIV);
+ ddmMainLI.setAttribute(HTML.ATTR_CLASS, labelDivClass);
+ ddmTextSpan.setAttribute(HTML.ATTR_CLASS, CSS_RICH_LABEL_TEXT_DECOR);
+// ddmListBorderDiv.setAttribute(HTML.ATTR_CLASS, listBorderDivClass);
+// ddmListBgDiv.setAttribute(HTML.ATTR_CLASS, CSS_RICH_MENU_LIST_BG);
+ ddmChildrenUL.setAttribute(HTML.ATTR_CLASS, listBorderDivClass + Constants.WHITE_SPACE
+ + CSS_RICH_MENU_LIST_BG);
+ /*
+ * Setting css styles
+ */
+ String cssListDivStyle = Constants.EMPTY;
+ String cssListBorderDivStyle = Constants.EMPTY;
+ String cssLabelDivStyle = Constants.EMPTY;
+
+ cssListDivStyle += Constants.WHITE_SPACE + CSS_RICH_DDEMENU_LIST_DIV_STYLE;
+ cssListBorderDivStyle += Constants.WHITE_SPACE + CSS_RICH_DDEMENU_BORDER_DIV_STYLE;
+
+ if (ComponentUtil.isNotBlank(attrs.getStyle())) {
+ cssLabelDivStyle += Constants.WHITE_SPACE + attrs.getStyle();
+ }
+
+// ddmListDiv.setAttribute(HTML.ATTR_STYLE, cssListDivStyle);
+// ddmListBorderDiv.setAttribute(HTML.ATTR_STYLE, cssListBorderDivStyle);
+// ddmLabelDiv.setAttribute(HTML.ATTR_STYLE, cssLabelDivStyle);
+ ddmMainLI.setAttribute(HTML.ATTR_STYLE, cssListDivStyle + Constants.WHITE_SPACE
+ + cssListBorderDivStyle + Constants.WHITE_SPACE + cssLabelDivStyle);
+ ddmChildrenUL.setAttribute(HTML.ATTR_STYLE, cssListDivStyle + Constants.WHITE_SPACE
+ + cssListBorderDivStyle + Constants.WHITE_SPACE + cssLabelDivStyle);
+ /*
+ * Encoding label value
+ */
+ Element labelFacet = ComponentUtil.getFacet(sourceElement, LABEL_FACET_NAME);
+ if (null != labelFacet) {
+ VpeChildrenInfo childrenInfo = new VpeChildrenInfo(ddmTextSpan);
+ childrenInfo.addSourceChild(labelFacet);
+ creationData.addChildrenInfo(childrenInfo);
+ } else {
+ String labelValue = DEFAULT_DDM_TITLE;
+ if (ComponentUtil.isNotBlank(attrs.getValue())) {
+ labelValue = attrs.getValue();
+ }
+ ddmLabelText.setNodeValue(labelValue);
+ ddmTextSpan.appendChild(ddmLabelText);
+ }
+
+ /*
+ * Adding child nodes:
+ * <rich:menuGroup> and <rich:menuItem> only.
+ */
+ List<Node> children = ComponentUtil.getChildren(sourceElement);
+ boolean missingChildContainer = true;
+ for (Node child : children) {
+ if (child.getNodeType() == Node.ELEMENT_NODE
+ && (child.getNodeName().endsWith(CHILD_GROUP_NAME) || child
+ .getNodeName().endsWith(CHILD_ITEM_NAME))) {
+ if (missingChildContainer) {
+ /*
+ * Add children <ul> tag.
+ */
+ ddmMainLI.appendChild(ddmChildrenUL);
+ missingChildContainer = false;
+ }
+ VpeChildrenInfo childDivInfo = new VpeChildrenInfo(
+ ddmChildrenUL);
+ childDivInfo.addSourceChild(child);
+ creationData.addChildrenInfo(childDivInfo);
+ }
+ }
+
+ return creationData;
+ }
+
+ @Override
+ public boolean recreateAtAttrChange(VpePageContext pageContext,
+ Element sourceElement, nsIDOMDocument visualDocument,
+ nsIDOMElement visualNode, Object data, String name, String value) {
+ return true;
+ }
+
+ class Attributes {
+ /*
* rich:dropDownMenu attributes names
*/
- private static final String DIRECTION = "direction"; //$NON-NLS-1$
- private static final String HORIZONTAL_OFFCET = "horizontalOffset"; //$NON-NLS-1$
- private static final String JOINT_POINT = "jontPoint"; //$NON-NLS-1$
- private static final String POPUP_WIDTH = "popupWidth"; //$NON-NLS-1$
- private static final String VERTICAL_OFFSET = "verticalOffset"; //$NON-NLS-1$
-
+ private String DIRECTION = "direction"; //$NON-NLS-1$
+ private String HORIZONTAL_OFFCET = "horizontalOffset"; //$NON-NLS-1$
+ private String JOINT_POINT = "jontPoint"; //$NON-NLS-1$
+ private String POPUP_WIDTH = "popupWidth"; //$NON-NLS-1$
+ private String VERTICAL_OFFSET = "verticalOffset"; //$NON-NLS-1$
+
/*
* rich:menuGroup css styles and classes attributes names
*/
- private static final String DISABLED_ITEM_CLASS = "disabledItemClass"; //$NON-NLS-1$
- private static final String DISABLED_ITEM_STYLE = "disabledItemStyle"; //$NON-NLS-1$
- private static final String DISABLED_LABEL_CLASS = "disabledLabelClass"; //$NON-NLS-1$
- private static final String ITEM_CLASS = "itemClass"; //$NON-NLS-1$
- private static final String ITEM_STYLE = "itemStyle"; //$NON-NLS-1$
- private static final String SELECED_LABEL_CLASS = "selectedLabelClass"; //$NON-NLS-1$
- private static final String SELECT_ITEM_CLASS = "selectItemClass"; //$NON-NLS-1$
-
+ private String DISABLED_ITEM_CLASS = "disabledItemClass"; //$NON-NLS-1$
+ private String DISABLED_ITEM_STYLE = "disabledItemStyle"; //$NON-NLS-1$
+ private String DISABLED_LABEL_CLASS = "disabledLabelClass"; //$NON-NLS-1$
+ private String ITEM_CLASS = "itemClass"; //$NON-NLS-1$
+ private String ITEM_STYLE = "itemStyle"; //$NON-NLS-1$
+ private String SELECED_LABEL_CLASS = "selectedLabelClass"; //$NON-NLS-1$
+ private String SELECT_ITEM_CLASS = "selectItemClass"; //$NON-NLS-1$
+
/*
* rich:dropDownMenu attributes
*/
@@ -103,180 +250,47 @@
private String ddm_selectItemClass;
private String ddm_style;
private String ddm_styleClass;
+ private String ddm_value;
- public VpeCreationData create(VpePageContext pageContext, Node sourceNode, nsIDOMDocument visualDocument) {
- VpeCreationData creationData = null;
- Element sourceElement = (Element)sourceNode;
+ public Attributes(final Element sourceElement) {
+ if (null == sourceElement) {
+ return;
+ }
+
+ ddm_direction = sourceElement.getAttribute(DIRECTION);
+ ddm_disabled = sourceElement.getAttribute(HTML.ATTR_DISABLED);
+ ddm_horizontalOffset = sourceElement.getAttribute(HORIZONTAL_OFFCET);
+ ddm_jointPoint = sourceElement.getAttribute(JOINT_POINT);
+ ddm_popupWidth = sourceElement.getAttribute(POPUP_WIDTH);
+ ddm_verticalOffset = sourceElement.getAttribute(VERTICAL_OFFSET);
- ComponentUtil.setCSSLink(pageContext, STYLE_PATH, COMPONENT_NAME);
- readDropDownMenuAttributes(sourceElement);
-
- /*
- * DropDownMenu component structure.
- * In order of nesting.
- */
- nsIDOMElement ddmMainUL;
- nsIDOMElement ddmMainLI;
- nsIDOMElement ddmChildrenUL;
- nsIDOMElement ddmLabelDiv;
- nsIDOMElement ddmTextSpan;
- nsIDOMText ddmLabelText;
- nsIDOMElement ddmListDiv;
- nsIDOMElement ddmListBorderDiv;
- nsIDOMElement ddmListBgDiv;
-
- /*
- * Creating visual elements
- */
- ddmMainUL = visualDocument.createElement(HTML.TAG_UL);
- ddmMainLI = visualDocument.createElement(HTML.TAG_LI);
- ddmChildrenUL = visualDocument.createElement(HTML.TAG_UL);
- ddmLabelDiv = visualDocument.createElement(HTML.TAG_DIV);
- ddmTextSpan = visualDocument.createElement(HTML.TAG_SPAN);
- ddmLabelText = visualDocument.createTextNode(EMPTY);
- ddmListDiv = visualDocument.createElement(HTML.TAG_DIV);
- ddmListBorderDiv = visualDocument.createElement(HTML.TAG_DIV);
- ddmListBgDiv = visualDocument.createElement(HTML.TAG_DIV);
- creationData = new VpeCreationData(ddmMainUL);
-
- /*
- * Nesting elements
- */
- ddmLabelDiv.appendChild(ddmTextSpan);
-// ddmTextSpan.appendChild(ddmLabelText);
-// ddmLabelDiv.appendChild(ddmListDiv);
- ddmListDiv.appendChild(ddmListBorderDiv);
- ddmListBorderDiv.appendChild(ddmListBgDiv);
- ddmMainUL.appendChild(ddmMainLI);
- ddmMainLI.appendChild(ddmLabelDiv);
-
- /*
- * Setting attributes for the drop-down mechanism
- */
- ddmMainUL.setAttribute(MENU_TOP_ID, EMPTY);
- ddmMainLI.setAttribute(MENU_TOP_ITEM_ID, EMPTY);
- ddmChildrenUL.setAttribute(MENU_CHILDREN_LIST_ID, EMPTY);
-
- /*
- * Setting css classes
- */
- String labelDivClass = EMPTY;
- String listBorderDivClass = EMPTY;
+ ddm_disabledItemClass = sourceElement.getAttribute(DISABLED_ITEM_CLASS);
+ ddm_disabledItemStyle = sourceElement.getAttribute(DISABLED_ITEM_STYLE);
+ ddm_disabledLabelClass = sourceElement.getAttribute(DISABLED_LABEL_CLASS);
+ ddm_itemClass = sourceElement.getAttribute(ITEM_CLASS);
+ ddm_itemStyle = sourceElement.getAttribute(ITEM_STYLE);
+ ddm_selectedLabelClass = sourceElement.getAttribute(SELECED_LABEL_CLASS);
+ ddm_selectItemClass = sourceElement.getAttribute(SELECT_ITEM_CLASS);
+ ddm_style = sourceElement.getAttribute(HTML.ATTR_STYLE);
+ ddm_styleClass = sourceElement.getAttribute(RichFaces.ATTR_STYLE_CLASS);
+ ddm_value = sourceElement.getAttribute(HTML.ATTR_VALUE);
+ }
- labelDivClass += SPACE + CSS_RICH_DDMENU_LABEL + SPACE
- + CSS_RICH_DDMENU_LABEL_UNSELECT;
- listBorderDivClass += SPACE + CSS_RICH_MENU_LIST_BORDER;
-
- if (ComponentUtil.isNotBlank(ddm_styleClass)) {
- labelDivClass += SPACE + ddm_styleClass;
- listBorderDivClass += SPACE + ddm_styleClass;
- }
-
-// ddmLabelDiv.setAttribute(HTML.ATTR_CLASS, labelDivClass);
- ddmLabelDiv.setAttribute(HTML.ATTR_CLASS, CSS_MENU_TOP_DIV);
- ddmMainLI.setAttribute(HTML.ATTR_CLASS, labelDivClass);
- ddmTextSpan.setAttribute(HTML.ATTR_CLASS, CSS_RICH_LABEL_TEXT_DECOR);
-// ddmListBorderDiv.setAttribute(HTML.ATTR_CLASS, listBorderDivClass);
-// ddmListBgDiv.setAttribute(HTML.ATTR_CLASS, CSS_RICH_MENU_LIST_BG);
- ddmChildrenUL.setAttribute(HTML.ATTR_CLASS, listBorderDivClass + SPACE
- + CSS_RICH_MENU_LIST_BG);
- /*
- * Setting css styles
- */
- String cssListDivStyle = EMPTY;
- String cssListBorderDivStyle = EMPTY;
- String cssLabelDivStyle = EMPTY;
-
- cssListDivStyle += SPACE + CSS_RICH_DDEMENU_LIST_DIV_STYLE;
- cssListBorderDivStyle += SPACE + CSS_RICH_DDEMENU_BORDER_DIV_STYLE;
-
- if (ComponentUtil.isNotBlank(ddm_style)) {
- cssLabelDivStyle += SPACE + ddm_style;
- }
-
-// ddmListDiv.setAttribute(HTML.ATTR_STYLE, cssListDivStyle);
-// ddmListBorderDiv.setAttribute(HTML.ATTR_STYLE, cssListBorderDivStyle);
-// ddmLabelDiv.setAttribute(HTML.ATTR_STYLE, cssLabelDivStyle);
- ddmMainLI.setAttribute(HTML.ATTR_STYLE, cssListDivStyle + SPACE
- + cssListBorderDivStyle + SPACE + cssLabelDivStyle);
- ddmChildrenUL.setAttribute(HTML.ATTR_STYLE, cssListDivStyle + SPACE
- + cssListBorderDivStyle + SPACE + cssLabelDivStyle);
- /*
- * Encoding label value
- */
- Element labelFacet = ComponentUtil.getFacet(sourceElement, LABEL_FACET_NAME);
- if (null != labelFacet) {
- VpeChildrenInfo childrenInfo = new VpeChildrenInfo(ddmTextSpan);
- childrenInfo.addSourceChild(labelFacet);
- creationData.addChildrenInfo(childrenInfo);
- } else {
- Attr valueAttr = sourceElement.getAttributeNode(HTML.ATTR_VALUE);
- String labelValue = (valueAttr != null && valueAttr.getValue() != null)
- ? valueAttr.getValue()
- : DEFAULT_DDM_TITLE;
- ddmLabelText.setNodeValue(labelValue);
- ddmTextSpan.appendChild(ddmLabelText);
- }
+ public String getStyle() {
+ return ddm_style;
+ }
- /*
- * Adding child nodes:
- * <rich:menuGroup> and <rich:menuItem> only.
- */
- List<Node> children = ComponentUtil.getChildren(sourceElement);
- boolean missingChildContainer = true;
- for (Node child : children) {
- if (child.getNodeType() == Node.ELEMENT_NODE
- && (child.getNodeName().endsWith(CHILD_GROUP_NAME) || child
- .getNodeName().endsWith(CHILD_ITEM_NAME))) {
- if (missingChildContainer) {
- /*
- * Add children <ul> tag.
- */
- ddmMainLI.appendChild(ddmChildrenUL);
- missingChildContainer = false;
- }
- VpeChildrenInfo childDivInfo = new VpeChildrenInfo(
- ddmChildrenUL);
- childDivInfo.addSourceChild(child);
- creationData.addChildrenInfo(childDivInfo);
- }
- }
-
- return creationData;
+ public String getStyleClass() {
+ return ddm_styleClass;
}
-
- /**
- * Read attributes from the source element.
- *
- * @param sourceNode the source node
- */
- private void readDropDownMenuAttributes(Element sourceElement) {
- if (null == sourceElement) {
- return;
- }
-
- ddm_direction = sourceElement.getAttribute(DIRECTION);
- ddm_disabled = sourceElement.getAttribute(HTML.ATTR_DISABLED);
- ddm_horizontalOffset = sourceElement.getAttribute(HORIZONTAL_OFFCET);
- ddm_jointPoint = sourceElement.getAttribute(JOINT_POINT);
- ddm_popupWidth = sourceElement.getAttribute(POPUP_WIDTH);
- ddm_verticalOffset = sourceElement.getAttribute(VERTICAL_OFFSET);
- ddm_disabledItemClass = sourceElement.getAttribute(DISABLED_ITEM_CLASS);
- ddm_disabledItemStyle = sourceElement.getAttribute(DISABLED_ITEM_STYLE);
- ddm_disabledLabelClass = sourceElement.getAttribute(DISABLED_LABEL_CLASS);
- ddm_itemClass = sourceElement.getAttribute(ITEM_CLASS);
- ddm_itemStyle = sourceElement.getAttribute(ITEM_STYLE);
- ddm_selectedLabelClass = sourceElement.getAttribute(SELECED_LABEL_CLASS);
- ddm_selectItemClass = sourceElement.getAttribute(SELECT_ITEM_CLASS);
- ddm_style = sourceElement.getAttribute(HTML.ATTR_STYLE);
- ddm_styleClass = sourceElement.getAttribute(RichFaces.ATTR_STYLE_CLASS);
- }
-
- @Override
- public boolean recreateAtAttrChange(VpePageContext pageContext,
- Element sourceElement, nsIDOMDocument visualDocument,
- nsIDOMElement visualNode, Object data, String name, String value) {
- return true;
- }
+ public String getDisabled() {
+ return ddm_disabled;
+ }
+
+ public String getValue() {
+ return ddm_value;
+ }
+
+ }
}
\ No newline at end of file
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesMenuGroupTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesMenuGroupTemplate.java 2009-05-13 14:33:34 UTC (rev 15242)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesMenuGroupTemplate.java 2009-05-13 15:28:14 UTC (rev 15243)
@@ -18,12 +18,12 @@
import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate;
import org.jboss.tools.vpe.editor.template.VpeChildrenInfo;
import org.jboss.tools.vpe.editor.template.VpeCreationData;
+import org.jboss.tools.vpe.editor.util.Constants;
import org.jboss.tools.vpe.editor.util.HTML;
import org.jboss.tools.vpe.editor.util.VpeStyleUtil;
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
import org.mozilla.interfaces.nsIDOMText;
-import org.w3c.dom.Attr;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -42,8 +42,6 @@
private static final String CHILD_ITEM_NAME = ":menuItem"; //$NON-NLS-1$
private static final String ICON_FACET_NAME = "icon"; //$NON-NLS-1$
private static final String ICON_DISABLED_FACET_NAME = "iconDisabled"; //$NON-NLS-1$
- private static final String EMPTY = ""; //$NON-NLS-1$
- private static final String SPACE = " "; //$NON-NLS-1$
/*
* Constants for drop down mechanism.
@@ -72,61 +70,21 @@
private static final String CSS_RICH_LIST_BORDER_DIV_STYLE = ""; //$NON-NLS-1$
private static final String CSS_MENU_GROUP_TOP_DIV = "dr-menu-group-top-div"; //$NON-NLS-1$
- /*
- * rich:menuGroup attributes names
- */
- private static final String DIRECTION = "direction"; //$NON-NLS-1$
- private static final String ICON = "icon"; //$NON-NLS-1$
- private static final String ICON_DISABLED = "iconDisabled"; //$NON-NLS-1$
- private static final String ICON_FOLDER = "iconFolder"; //$NON-NLS-1$
- private static final String ICON_FOLDER_DISABLED = "iconFolderDisabled"; //$NON-NLS-1$
-
- /*
- * rich:menuGroup css styles and classes attributes names
- */
- private static final String ICON_CLASS = "iconClass"; //$NON-NLS-1$
- private static final String ICON_STYLE = "iconStyle"; //$NON-NLS-1$
- private static final String LABEL_CLASS = "labelClass"; //$NON-NLS-1$
- private static final String SELECT_CLASS = "selectClass"; //$NON-NLS-1$
- private static final String SELECT_STYLE = "selectStyle"; //$NON-NLS-1$
-
- /*
- * rich:menuGroup attributes
- */
- private String mg_direction;
- private String mg_disabled;
- private String mg_icon;
- private String mg_iconDisabled;
- private String mg_iconFolder;
- private String mg_iconFolderDisabled;
- private String mg_value;
-
- /*
- * rich:menuGroup css styles and classes attributes
- */
- private String mg_iconClass;
- private String mg_iconStyle;
- private String mg_labelClass;
- private String mg_selectClass;
- private String mg_selectStyle;
- private String mg_style;
- private String mg_styleClass;
-
public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
nsIDOMDocument visualDocument) {
VpeCreationData creationData = null;
Element sourceElement = (Element)sourceNode;
ComponentUtil.setCSSLink(pageContext, STYLE_PATH, COMPONENT_NAME);
- readMenuGroupAttributes(sourceElement);
+ final Attributes attrs = new Attributes(sourceElement);
/*
* MenuGroup component structure.
* In order of nesting.
*/
nsIDOMElement ddmMainUL;
- nsIDOMElement grMainLI;
- nsIDOMElement grChildrenUL;
- nsIDOMElement ddmChildrenLI;
+ nsIDOMElement grMainLI;
+ nsIDOMElement grChildrenUL;
+ nsIDOMElement ddmChildrenLI;
nsIDOMElement grTopDiv;
nsIDOMElement grImgSpan;
@@ -141,14 +99,14 @@
/*
* Creating visual elements
*/
- grMainLI = visualDocument.createElement(HTML.TAG_LI);
- grChildrenUL = visualDocument.createElement(HTML.TAG_UL);
+ grMainLI = visualDocument.createElement(HTML.TAG_LI);
+ grChildrenUL = visualDocument.createElement(HTML.TAG_UL);
grTopDiv = visualDocument.createElement(HTML.TAG_DIV);
grImgSpan = visualDocument.createElement(HTML.TAG_SPAN);
grImg = visualDocument.createElement(HTML.TAG_IMG);
grFolderImg = visualDocument.createElement(HTML.TAG_IMG);
grLabelSpan = visualDocument.createElement(HTML.TAG_SPAN);
- grLabelText = visualDocument.createTextNode(EMPTY);
+ grLabelText = visualDocument.createTextNode(Constants.EMPTY);
grFolderImgSpan = visualDocument.createElement(HTML.TAG_SPAN);
grListBorderDiv = visualDocument.createElement(HTML.TAG_DIV);
grListBgDiv = visualDocument.createElement(HTML.TAG_DIV);
@@ -168,31 +126,31 @@
/*
* Setting attributes for the drop-down mechanism
*/
- grMainLI.setAttribute(MENU_CHILD_ID, EMPTY);
- grChildrenUL.setAttribute(MENU_PARENT_ID, EMPTY);
+ grMainLI.setAttribute(MENU_CHILD_ID, Constants.EMPTY);
+ grChildrenUL.setAttribute(MENU_PARENT_ID, Constants.EMPTY);
/*
* Setting css classes
*/
- String topDivClass = EMPTY;
- String imgSpanClass = EMPTY;
- String labelSpanClass = EMPTY;
- String folderDivClass = EMPTY;
+ String topDivClass = Constants.EMPTY;
+ String imgSpanClass = Constants.EMPTY;
+ String labelSpanClass = Constants.EMPTY;
+ String folderDivClass = Constants.EMPTY;
- topDivClass += SPACE + CSS_RICH_MENU_GROUP;
- imgSpanClass += SPACE + CSS_RICH_MENU_ITEM_ICON_ENABLED;
- labelSpanClass += SPACE + CSS_RICH_MENU_ITEM_LABEL + SPACE + CSS_RICH_MENU_GROUP_LABEL;
- folderDivClass += SPACE + CSS_RICH_MENU_ITEM_FOLDER + SPACE + CSS_RICH_MENU_GROUP_FOLDER;
+ topDivClass += Constants.WHITE_SPACE + CSS_RICH_MENU_GROUP;
+ imgSpanClass += Constants.WHITE_SPACE + CSS_RICH_MENU_ITEM_ICON_ENABLED;
+ labelSpanClass += Constants.WHITE_SPACE + CSS_RICH_MENU_ITEM_LABEL + Constants.WHITE_SPACE + CSS_RICH_MENU_GROUP_LABEL;
+ folderDivClass += Constants.WHITE_SPACE + CSS_RICH_MENU_ITEM_FOLDER + Constants.WHITE_SPACE + CSS_RICH_MENU_GROUP_FOLDER;
- if (ComponentUtil.isNotBlank(mg_styleClass)) {
- topDivClass += SPACE + mg_styleClass;
+ if (ComponentUtil.isNotBlank(attrs.getStyleClass())) {
+ topDivClass += Constants.WHITE_SPACE + attrs.getStyleClass();
}
- if (ComponentUtil.isNotBlank(mg_iconClass)) {
- imgSpanClass += SPACE + mg_iconClass;
- folderDivClass += SPACE + mg_iconClass;
+ if (ComponentUtil.isNotBlank(attrs.getIconClass())) {
+ imgSpanClass += Constants.WHITE_SPACE + attrs.getIconClass();
+ folderDivClass += Constants.WHITE_SPACE + attrs.getIconClass();
}
- if (ComponentUtil.isNotBlank(mg_labelClass)) {
- labelSpanClass += SPACE + mg_labelClass;
+ if (ComponentUtil.isNotBlank(attrs.getLabelClass())) {
+ labelSpanClass += Constants.WHITE_SPACE + attrs.getLabelClass();
}
// grTopDiv.setAttribute(HTML.ATTR_CLASS, topDivClass);
@@ -204,29 +162,30 @@
// grListBorderDiv.setAttribute(HTML.ATTR_CLASS, CSS_RICH_MENU_LIST_BORDER);
// grListBgDiv.setAttribute(HTML.ATTR_CLASS, CSS_RICH_MENU_LIST_BG);
grChildrenUL.setAttribute(HTML.ATTR_CLASS, CSS_RICH_MENU_LIST_BORDER
- + SPACE + CSS_RICH_MENU_LIST_BG);
+ + Constants.WHITE_SPACE + CSS_RICH_MENU_LIST_BG);
/*
* Setting css styles
*/
- String topDivStyle = EMPTY;
+ String topDivStyle = Constants.EMPTY;
- if (ComponentUtil.isNotBlank(mg_style)) {
- topDivStyle += SPACE + mg_style;
+ if (ComponentUtil.isNotBlank(attrs.getStyle())) {
+ topDivStyle += Constants.WHITE_SPACE + attrs.getStyle();
}
grMainLI.setAttribute(HTML.ATTR_STYLE, topDivStyle);
grFolderImgSpan.setAttribute(HTML.ATTR_STYLE, CSS_RICH_LIST_FOLDER_DIV_STYLE);
// grListBorderDiv.setAttribute(HTML.ATTR_STYLE, CSS_RICH_LIST_BORDER_DIV_STYLE);
// grChildrenUL.setAttribute(HTML.ATTR_STYLE,
-// CSS_RICH_LIST_FOLDER_DIV_STYLE + SPACE
+// CSS_RICH_LIST_FOLDER_DIV_STYLE + Constants.WHITE_SPACE
// + CSS_RICH_LIST_BORDER_DIV_STYLE);
/*
* Encode label value
*/
- Attr valueAttr = sourceElement.getAttributeNode(HTML.ATTR_VALUE);
- String labelValue = valueAttr != null
- && valueAttr.getValue() != null ? valueAttr.getValue() : EMPTY;
+ String labelValue = Constants.EMPTY;
+ if (ComponentUtil.isNotBlank(attrs.getValue())) {
+ labelValue = attrs.getValue();
+ }
grLabelText.setNodeValue(labelValue);
/*
@@ -239,11 +198,11 @@
childInfo.addSourceChild(iconFacet);
creationData.addChildrenInfo(childInfo);
} else {
- if (ComponentUtil.isNotBlank(mg_icon)) {
+ if (ComponentUtil.isNotBlank(attrs.getIcon())) {
/*
* Add path to specified image
*/
- String imgFullPath = VpeStyleUtil.addFullPathToImgSrc(mg_icon, pageContext, true);
+ String imgFullPath = VpeStyleUtil.addFullPathToImgSrc(attrs.getIcon(), pageContext, true);
grImg.setAttribute(HTML.ATTR_SRC, imgFullPath);
} else {
/*
@@ -261,11 +220,11 @@
/*
* Add group folder icon
*/
- if (ComponentUtil.isNotBlank(mg_iconFolder)) {
+ if (ComponentUtil.isNotBlank(attrs.getIconFolder())) {
/*
* Add path to specified image
*/
- String imgFullPath = VpeStyleUtil.addFullPathToImgSrc(mg_iconFolder, pageContext, true);
+ String imgFullPath = VpeStyleUtil.addFullPathToImgSrc(attrs.getIconFolder(), pageContext, true);
grFolderImg.setAttribute(HTML.ATTR_SRC, imgFullPath);
} else {
/*
@@ -304,14 +263,58 @@
return creationData;
}
- /**
- * Read attributes from the source element.
- *
- * @param sourceNode the source node
- */
- private void readMenuGroupAttributes(Element sourceElement) {
+ @Override
+ public boolean recreateAtAttrChange(VpePageContext pageContext,
+ Element sourceElement, nsIDOMDocument visualDocument,
+ nsIDOMElement visualNode, Object data, String name, String value) {
+ return true;
+ }
+
+ class Attributes {
+
+ /*
+ * rich:menuGroup attributes names
+ */
+ private String DIRECTION = "direction"; //$NON-NLS-1$
+ private String ICON = "icon"; //$NON-NLS-1$
+ private String ICON_DISABLED = "iconDisabled"; //$NON-NLS-1$
+ private String ICON_FOLDER = "iconFolder"; //$NON-NLS-1$
+ private String ICON_FOLDER_DISABLED = "iconFolderDisabled"; //$NON-NLS-1$
+
+ /*
+ * rich:menuGroup css styles and classes attributes names
+ */
+ private String ICON_CLASS = "iconClass"; //$NON-NLS-1$
+ private String ICON_STYLE = "iconStyle"; //$NON-NLS-1$
+ private String LABEL_CLASS = "labelClass"; //$NON-NLS-1$
+ private String SELECT_CLASS = "selectClass"; //$NON-NLS-1$
+ private String SELECT_STYLE = "selectStyle"; //$NON-NLS-1$
+
+ /*
+ * rich:menuGroup attributes
+ */
+ private String mg_icon;
+ private String mg_iconFolder;
+ private String mg_direction;
+ private String mg_disabled;
+ private String mg_iconDisabled;
+ private String mg_iconFolderDisabled;
+ private String mg_value;
+
+ /*
+ * rich:menuGroup css styles and classes attributes
+ */
+ private String mg_iconClass;
+ private String mg_iconStyle;
+ private String mg_labelClass;
+ private String mg_selectClass;
+ private String mg_selectStyle;
+ private String mg_style;
+ private String mg_styleClass;
+
+ public Attributes(final Element sourceElement) {
if (null == sourceElement) {
- return;
+ return;
}
mg_direction = sourceElement.getAttribute(DIRECTION);
mg_disabled = sourceElement.getAttribute(HTML.ATTR_DISABLED);
@@ -328,13 +331,40 @@
mg_selectStyle = sourceElement.getAttribute(SELECT_STYLE);
mg_style = sourceElement.getAttribute(HTML.ATTR_STYLE);
mg_styleClass = sourceElement.getAttribute(RichFaces.ATTR_STYLE_CLASS);
+ }
+
+ public String getIconClass() {
+ return mg_iconClass;
+ }
+
+ public String getLabelClass() {
+ return mg_labelClass;
+ }
+
+ public String getStyle() {
+ return mg_style;
+ }
+
+ public String getStyleClass() {
+ return mg_styleClass;
+ }
+
+ public String getIcon() {
+ return mg_icon;
+ }
+
+ public String getIconFolder() {
+ return mg_iconFolder;
+ }
+
+ public String getIconStyle() {
+ return mg_iconStyle;
+ }
+
+ public String getValue() {
+ return mg_value;
+ }
+
}
-
- @Override
- public boolean recreateAtAttrChange(VpePageContext pageContext,
- Element sourceElement, nsIDOMDocument visualDocument,
- nsIDOMElement visualNode, Object data, String name, String value) {
- return true;
- }
-
+
}
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesMenuItemTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesMenuItemTemplate.java 2009-05-13 14:33:34 UTC (rev 15242)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesMenuItemTemplate.java 2009-05-13 15:28:14 UTC (rev 15243)
@@ -24,12 +24,10 @@
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
import org.mozilla.interfaces.nsIDOMText;
-import org.w3c.dom.Attr;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
public class RichFacesMenuItemTemplate extends VpeAbstractTemplate {
-
/*
* rich:menuItem constants
@@ -62,46 +60,12 @@
private static final String CSS_RICH_MENU_ITEM_ICON_SELECTED = "rich-menu-item-icon-selected"; //$NON-NLS-1$
private static final String CSS_MENU_ITEM_TOP_DIV = "dr-menu-item-top-div"; //$NON-NLS-1$
- /*
- * rich:menuItem attributes names
- */
- private static final String ICON = "icon"; //$NON-NLS-1$
-
- /*
- * rich:menuItem css styles and classes attributes names
- */
- private static final String ICON_CLASS = "iconClass"; //$NON-NLS-1$
- private static final String ICON_DISABLED = "iconDisabled"; //$NON-NLS-1$
- private static final String ICON_STYLE = "iconStyle"; //$NON-NLS-1$
- private static final String LABEL_CLASS = "labelClass"; //$NON-NLS-1$
- private static final String SELECT_STYLE = "selectStyle"; //$NON-NLS-1$
- private static final String SELECT_CLASS = "selectClass"; //$NON-NLS-1$
-
- /*
- * rich:menuItem attributes
- */
- private String mi_disabled;
- private String mi_icon;
- private String mi_value;
-
- /*
- * rich:menuItem css styles and classes attributes
- */
- private String mi_iconClass;
- private String mi_iconDisabled;
- private String mi_iconStyle;
- private String mi_labelClass;
- private String mi_selectClass;
- private String mi_selectStyle;
- private String mi_style;
- private String mi_styleClass;
-
public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
nsIDOMDocument visualDocument) {
VpeCreationData creationData = null;
Element sourceElement = (Element)sourceNode;
ComponentUtil.setCSSLink(pageContext, STYLE_PATH, COMPONENT_NAME);
- readMenuItemAttributes(sourceElement);
+ final Attributes attrs = new Attributes(sourceElement);
/*
* MenuItem component structure.
@@ -150,14 +114,14 @@
iconImgSpanClass += Constants.WHITE_SPACE + CSS_RICH_MENU_ITEM_ICON;
labelSpanClass += Constants.WHITE_SPACE + CSS_RICH_MENU_ITEM_LABEL;
- if (ComponentUtil.isNotBlank(mi_styleClass)) {
- topDivClass += Constants.WHITE_SPACE + mi_styleClass;
+ if (ComponentUtil.isNotBlank(attrs.getStyleClass())) {
+ topDivClass += Constants.WHITE_SPACE + attrs.getStyleClass();
}
- if (ComponentUtil.isNotBlank(mi_iconClass)) {
- iconImgSpanClass += Constants.WHITE_SPACE + mi_iconClass;
+ if (ComponentUtil.isNotBlank(attrs.getIconClass())) {
+ iconImgSpanClass += Constants.WHITE_SPACE + attrs.getIconClass();
}
- if (ComponentUtil.isNotBlank(mi_labelClass)) {
- labelSpanClass += Constants.WHITE_SPACE + mi_labelClass;
+ if (ComponentUtil.isNotBlank(attrs.getLabelClass())) {
+ labelSpanClass += Constants.WHITE_SPACE + attrs.getLabelClass();
}
// itemTopDiv.setAttribute(HTML.ATTR_CLASS, topDivClass);
@@ -172,8 +136,8 @@
*/
String topDivStyle = Constants.EMPTY;
- if (ComponentUtil.isNotBlank(mi_style)) {
- topDivStyle += Constants.WHITE_SPACE + mi_style;
+ if (ComponentUtil.isNotBlank(attrs.getStyle())) {
+ topDivStyle += Constants.WHITE_SPACE + attrs.getStyle();
}
// itemTopDiv.setAttribute(HTML.ATTR_STYLE, topDivStyle);
@@ -189,12 +153,11 @@
childInfo.addSourceChild(iconFacet);
creationData.addChildrenInfo(childInfo);
} else {
- String iconPath = sourceElement.getAttribute(ICON);
- if (ComponentUtil.isNotBlank(iconPath)) {
+ if (ComponentUtil.isNotBlank(attrs.getIcon())) {
/*
* Add path to specified image
*/
- String imgFullPath = VpeStyleUtil.addFullPathToImgSrc(iconPath, pageContext, true);
+ String imgFullPath = VpeStyleUtil.addFullPathToImgSrc(attrs.getIcon(), pageContext, true);
itemIconImg.setAttribute(HTML.ATTR_SRC, imgFullPath);
} else {
/*
@@ -211,10 +174,10 @@
/*
* Encode label and icon value
*/
- Attr valueAttr = sourceElement.getAttributeNode(HTML.ATTR_VALUE);
- String labelValue = (valueAttr != null && valueAttr.getValue() != null)
- ? valueAttr.getValue()
- : Constants.EMPTY;
+ String labelValue = Constants.EMPTY;
+ if (ComponentUtil.isNotBlank(attrs.getValue())) {
+ labelValue = attrs.getValue();
+ }
itemLabelText.setNodeValue(labelValue);
/*
@@ -229,21 +192,58 @@
return creationData;
}
+
+ @Override
+ public boolean recreateAtAttrChange(VpePageContext pageContext,
+ Element sourceElement, nsIDOMDocument visualDocument,
+ nsIDOMElement visualNode, Object data, String name, String value) {
+ return true;
+ }
-
- /**
- * Read attributes from the source element.
- *
- * @param sourceNode the source node
- */
- private void readMenuItemAttributes(Element sourceElement) {
+ class Attributes {
+
+ /*
+ * rich:menuItem attributes names
+ */
+ private String ICON = "icon"; //$NON-NLS-1$
+
+ /*
+ * rich:menuItem css styles and classes attributes names
+ */
+ private String ICON_CLASS = "iconClass"; //$NON-NLS-1$
+ private String ICON_DISABLED = "iconDisabled"; //$NON-NLS-1$
+ private String ICON_STYLE = "iconStyle"; //$NON-NLS-1$
+ private String LABEL_CLASS = "labelClass"; //$NON-NLS-1$
+ private String SELECT_STYLE = "selectStyle"; //$NON-NLS-1$
+ private String SELECT_CLASS = "selectClass"; //$NON-NLS-1$
+
+ /*
+ * rich:menuItem attributes
+ */
+ private String mi_disabled;
+ private String mi_icon;
+ private String mi_value;
+
+ /*
+ * rich:menuItem css styles and classes attributes
+ */
+ private String mi_iconClass;
+ private String mi_iconDisabled;
+ private String mi_iconStyle;
+ private String mi_labelClass;
+ private String mi_selectClass;
+ private String mi_selectStyle;
+ private String mi_style;
+ private String mi_styleClass;
+
+ public Attributes(final Element sourceElement) {
if (null == sourceElement) {
- return;
+ return;
}
mi_disabled = sourceElement.getAttribute(HTML.ATTR_DISABLED);
mi_icon = sourceElement.getAttribute(ICON);
mi_value = sourceElement.getAttribute(HTML.ATTR_VALUE);
-
+
mi_iconClass = sourceElement.getAttribute(ICON_CLASS);
mi_iconDisabled = sourceElement.getAttribute(ICON_DISABLED);
mi_iconStyle = sourceElement.getAttribute(ICON_STYLE);
@@ -252,13 +252,32 @@
mi_selectStyle = sourceElement.getAttribute(SELECT_STYLE);
mi_style = sourceElement.getAttribute(HTML.ATTR_STYLE);
mi_styleClass = sourceElement.getAttribute(RichFaces.ATTR_STYLE_CLASS);
- }
+ }
- @Override
- public boolean recreateAtAttrChange(VpePageContext pageContext,
- Element sourceElement, nsIDOMDocument visualDocument,
- nsIDOMElement visualNode, Object data, String name, String value) {
- return true;
+ public String getIconClass() {
+ return mi_iconClass;
+ }
+
+ public String getLabelClass() {
+ return mi_labelClass;
+ }
+
+ public String getStyle() {
+ return mi_style;
+ }
+
+ public String getStyleClass() {
+ return mi_styleClass;
+ }
+
+ public String getIcon() {
+ return mi_icon;
+ }
+
+ public String getValue() {
+ return mi_value;
+ }
+
}
}
15 years, 6 months
JBoss Tools SVN: r15242 - trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components.
by jbosstools-commits@lists.jboss.org
Author: yradtsevich
Date: 2009-05-13 10:33:34 -0400 (Wed, 13 May 2009)
New Revision: 15242
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/main.css
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/comboBox.xhtml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/comboBox.xhtml.xml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/inplaceInput.xhtml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/inplaceInput.xhtml.xml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/pickList.xhtml.xml
Log:
Patch from Yura Zhishko (yzhishko) is applied: some JUnit tests are fixed.
Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/comboBox.xhtml
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/comboBox.xhtml 2009-05-13 14:15:09 UTC (rev 15241)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/comboBox.xhtml 2009-05-13 14:33:34 UTC (rev 15242)
@@ -7,6 +7,7 @@
xmlns:rich="http://richfaces.org/rich">
<head>
+ <link rel="stylesheet" href="main.css" type="text/css"/>
</head>
<body>
<h1>comboBox</h1>
@@ -48,5 +49,25 @@
<f:selectItem itemValue="suggestion 5" />
</rich:comboBox>
+<rich:panel styleClass="btn" id="complexCombo">
+ <f:facet name="header">
+ <h:outputText value="Combo Box"/>
+ </f:facet>
+ <form>
+ <rich:comboBox defaultLabel="Enter some value" width="150">
+ <f:selectItem itemValue="item 1"/>
+ <f:selectItem itemValue="item 2"/>
+ <f:selectItem itemValue="item 3"/>
+ <f:selectItem itemValue="item 4"/>
+ <f:selectItem itemValue="item 5" />
+ <f:selectItem itemValue="item 6" escape="false"/>
+ <f:selectItem itemValue="item 7" itemDisabled="true"/>
+ <f:selectItem itemValue="item 8" itemDescription="some descriprion"/>
+ <f:selectItem itemValue="item 10"/>
+ <f:selectItem itemValue="item 11"/>
+ <f:selectItem itemValue="item 12"/>
+ </rich:comboBox>
+ </form>
+</rich:panel>
</body>
</html>
\ No newline at end of file
Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/comboBox.xhtml.xml
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/comboBox.xhtml.xml 2009-05-13 14:15:09 UTC (rev 15241)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/comboBox.xhtml.xml 2009-05-13 14:33:34 UTC (rev 15242)
@@ -34,7 +34,7 @@
<INPUT TYPE="text"
CLASS="rich-combobox-font-inactive rich-combobox-button-icon-inactive rich-combobox-button-inactive"
READONLY="true" VPE-USER-TOGGLE-ID="0" />
- <DIV CLASS="rich-combobox-strut rich-combobox-font" STYLE="width: 140px;">
+ <DIV CLASS="rich-combobox-strut rich-combobox-font" STYLE="width: 140px;">
Struts</DIV>
</DIV>
</DIV>
@@ -83,4 +83,41 @@
</DIV>
</DIV>
</test>
+ <test id="complexCombo">
+ <DIV CLASS="dr-pnl rich-panel btn">
+ <DIV CLASS="dr-pnl-h rich-panel-header"
+ STYLE="/background-image: url\(.*resources/common/background.gif\);/">
+ <SPAN CLASS="vpe-text">
+ Combo Box
+ </SPAN>
+ </DIV>
+ <DIV CLASS="dr-pnl-b rich-panel-body">
+ <FORM STYLE="-moz-user-modify: read-write;">
+ <DIV STYLE="width: 150px;">
+ <DIV STYLE="position: static; z-index: 0;">
+ <DIV CLASS="rich-combobox-font rich-combobox" STYLE="position: static; z-index: 0;">
+ <DIV CLASS="rich-combobox-font rich-combobox-shell" STYLE="width: 150px; z-index: 1;">
+ <INPUT TYPE="text"
+ CLASS="rich-combobox-font-disabled rich-combobox-input-inactive"
+ STYLE="width: 133px;" VALUE="Enter some value" />
+
+ <INPUT TYPE="text"
+ CLASS="rich-combobox-font-inactive rich-combobox-button-background rich-combobox-button-inactive"
+ READONLY="true" VPE-USER-TOGGLE-ID="0" STYLE="" />
+
+ <INPUT TYPE="text"
+ CLASS="rich-combobox-font-inactive rich-combobox-button-icon-inactive rich-combobox-button-inactive"
+ READONLY="true" VPE-USER-TOGGLE-ID="0" STYLE="" />
+
+ <DIV CLASS="rich-combobox-strut rich-combobox-font" STYLE="width: 140px;">
+ Struts
+ </DIV>
+ </DIV>
+ </DIV>
+ </DIV>
+ </DIV>
+ </FORM>
+ </DIV>
+ </DIV>
+ </test>
</tests>
\ No newline at end of file
Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/inplaceInput.xhtml
===================================================================
(Binary files differ)
Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/inplaceInput.xhtml.xml
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/inplaceInput.xhtml.xml 2009-05-13 14:15:09 UTC (rev 15241)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/inplaceInput.xhtml.xml 2009-05-13 14:33:34 UTC (rev 15242)
@@ -3,58 +3,83 @@
<SPAN VPE-USER-TOGGLE-ID="false" CLASS="rich-inplace rich-inplace-view"
STYLE="display: inline;"> click to enter your name</SPAN>
</test>
- <!-- test id="inplaceInputWithoutFacet">
- <SPAN VPE-USER-TOGGLE-ID="true" CLASS="rich-inplace rich-inplace-edit"
- STYLE="position: relative; display: inline;">
- <INPUT TYPE="text" VPE-USER-TOGGLE-ID="0" CLASS="rich-inplace-field" STYLE="top: 0px; width: 66px;"
- AUTOCOMPLETE="off" VALUE="Mama mila ram"/>
- <DIV CLASS="rich-inplace-input-controls-set" STYLE="position: absolute; top: 0px; left: 66px;">
- <DIV CLASS="rich-inplace-shadow">
- <TABLE CELLSPACING="0" CELLPADDING="0" BORDER="0">
- <TBODY>
- <TR>
- <TD CLASS="rich-inplace-shadow-tl">
- <IMG WIDTH="10" HEIGHT="1" BORDER="0" SRC="/.*resources/inplaceInput/spacer.gif/"/>
- </TD>
- <TD CLASS="rich-inplace-shadow-tr">
- <IMG WIDTH="1" HEIGHT="10" BORDER="0" SRC="/.*resources/resources/inplaceInput/spacer.gif/"/>
- </TD>
- </TR>
- <TR>
- <TD CLASS="rich-inplace-shadow-bl">
- <IMG WIDTH="1" HEIGHT="10" BORDER="0" SRC="/.*resources/inplaceInput/spacer.gif/"/>
- </TD>
- <TD CLASS="rich-inplace-shadow-br">
- <IMG WIDTH="10" HEIGHT="1" BORDER="0" SRC="/.*resources/inplaceInput/spacer.gif/"/>
- </TD>
- </TR>
- </TBODY>
- </TABLE>
- </DIV>
- <DIV STYLE="position: relative; height: 18px;">
- <INPUT TYPE="image" CLASS="rich-inplace-control"
- SRC="/.*resources/inplaceInput/applyButton.gif/" VPE-USER-TOGGLE-ID="0"/>
- <INPUT TYPE="image" CLASS="rich-inplace-control"
- SRC="/.*resources/inplaceInput/cancelButton.gif/" VPE-USER-TOGGLE-ID="0"/>
- </DIV>
- </DIV>
- </SPAN>
+ <!--
+ test id="inplaceInputWithoutFacet"> <SPAN VPE-USER-TOGGLE-ID="true"
+ CLASS="rich-inplace rich-inplace-edit" STYLE="position: relative;
+ display: inline;"> <INPUT TYPE="text" VPE-USER-TOGGLE-ID="0"
+ CLASS="rich-inplace-field" STYLE="top: 0px; width: 66px;"
+ AUTOCOMPLETE="off" VALUE="Mama mila ram"/> <DIV
+ CLASS="rich-inplace-input-controls-set" STYLE="position: absolute;
+ top: 0px; left: 66px;"> <DIV CLASS="rich-inplace-shadow"> <TABLE
+ CELLSPACING="0" CELLPADDING="0" BORDER="0"> <TBODY> <TR> <TD
+ CLASS="rich-inplace-shadow-tl"> <IMG WIDTH="10" HEIGHT="1" BORDER="0"
+ SRC="/.*resources/inplaceInput/spacer.gif/"/> </TD> <TD
+ CLASS="rich-inplace-shadow-tr"> <IMG WIDTH="1" HEIGHT="10" BORDER="0"
+ SRC="/.*resources/resources/inplaceInput/spacer.gif/"/> </TD> </TR>
+ <TR> <TD CLASS="rich-inplace-shadow-bl"> <IMG WIDTH="1" HEIGHT="10"
+ BORDER="0" SRC="/.*resources/inplaceInput/spacer.gif/"/> </TD> <TD
+ CLASS="rich-inplace-shadow-br"> <IMG WIDTH="10" HEIGHT="1" BORDER="0"
+ SRC="/.*resources/inplaceInput/spacer.gif/"/> </TD> </TR> </TBODY>
+ </TABLE> </DIV> <DIV STYLE="position: relative; height: 18px;"> <INPUT
+ TYPE="image" CLASS="rich-inplace-control"
+ SRC="/.*resources/inplaceInput/applyButton.gif/"
+ VPE-USER-TOGGLE-ID="0"/> <INPUT TYPE="image"
+ CLASS="rich-inplace-control"
+ SRC="/.*resources/inplaceInput/cancelButton.gif/"
+ VPE-USER-TOGGLE-ID="0"/> </DIV> </DIV> </SPAN> </test> <test
+ id="inplaceInputWithFacet"> <SPAN VPE-USER-TOGGLE-ID="true"
+ CLASS="rich-inplace rich-inplace-edit" STYLE="position: relative;
+ display: inline;"> <INPUT TYPE="text" VPE-USER-TOGGLE-ID="0"
+ CLASS="rich-inplace-field" STYLE="top: 0px; width: 66px;"
+ AUTOCOMPLETE="off" VALUE="Mama mila ramu"/> <DIV
+ CLASS="rich-inplace-input-controls-set" STYLE="position: absolute;
+ top: 18px; left: 0px;"> <DIV STYLE="position: relative; height:
+ 18px;"> <DIV> <SPAN TITLE="h:panelGroup" STYLE="-moz-user-modify:
+ read-write;" CLASS=""> <INPUT TYPE="button" VALUE="Save"
+ STYLE="-moz-user-modify: read-only;"/> <INPUT TYPE="button"
+ VALUE="Cancel" STYLE="-moz-user-modify: read-only;"/> </SPAN> </DIV>
+ </DIV> </DIV> </SPAN> </test
+ -->
+ <test id="inplaceInput1">
+ <DIV CLASS="dr-pnl rich-panel oddRow" STYLE="width: 240px;">
+ <DIV CLASS="dr-pnl-h rich-panel-header"
+ STYLE="/background-image: url\(.*resources/common/background.gif\);/">
+ <SPAN CLASS="vpe-text">
+ Person Info
+ </SPAN>
+ </DIV>
+ <DIV CLASS="dr-pnl-b rich-panel-body">
+ <TABLE BORDER="0" STYLE="-moz-user-modify: read-write;">
+ <TBODY>
+ <TR>
+ <TD>
+ <SPAN CLASS="vpe-text">
+ Name:
+ </SPAN>
+ </TD>
+ <TD>
+ <SPAN VPE-USER-TOGGLE-ID="false"
+ CLASS="rich-inplace rich-inplace-view btn" STYLE="display: inline;">
+ click to enter your NamE
+ </SPAN>
+ </TD>
+ </TR>
+ <TR>
+ <TD>
+ <SPAN CLASS="vpe-text">
+ Email:
+ </SPAN>
+ </TD>
+ <TD>
+ <SPAN VPE-USER-TOGGLE-ID="false"
+ CLASS="rich-inplace rich-inplace-view evenRow" STYLE="display: inline;">
+ click to enter your email
+ </SPAN>
+ </TD>
+ </TR>
+ </TBODY>
+ </TABLE>
+ </DIV>
+ </DIV>
</test>
- <test id="inplaceInputWithFacet">
- <SPAN VPE-USER-TOGGLE-ID="true" CLASS="rich-inplace rich-inplace-edit"
- STYLE="position: relative; display: inline;">
- <INPUT TYPE="text" VPE-USER-TOGGLE-ID="0" CLASS="rich-inplace-field" STYLE="top: 0px; width: 66px;"
- AUTOCOMPLETE="off" VALUE="Mama mila ramu"/>
- <DIV CLASS="rich-inplace-input-controls-set" STYLE="position: absolute; top: 18px; left: 0px;">
- <DIV STYLE="position: relative; height: 18px;">
- <DIV>
- <SPAN TITLE="h:panelGroup" STYLE="-moz-user-modify: read-write;" CLASS="">
- <INPUT TYPE="button" VALUE="Save" STYLE="-moz-user-modify: read-only;"/>
- <INPUT TYPE="button" VALUE="Cancel" STYLE="-moz-user-modify: read-only;"/>
- </SPAN>
- </DIV>
- </DIV>
- </DIV>
- </SPAN>
- </test-->
</tests>
\ No newline at end of file
Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/main.css
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/main.css (rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/main.css 2009-05-13 14:33:34 UTC (rev 15242)
@@ -0,0 +1,40 @@
+.evenRow {
+ text-align: center;
+ background-color: green;
+ font-style: italic;
+
+}
+
+.oddRow{
+ text-align: right;
+ background-color: blue;
+ font-style: oblique;
+
+}
+
+.btn {
+ text-align: center;
+ color: DodgerBlue;
+ font-size: x-large;
+ font-style: italic;
+ background-color: Turquoise;
+ border-style: ridge;
+ border-color: DarkViolet;
+ text-decoration: overline;
+ font-weight: bolder;
+ border-width: thick;
+}
+
+
+.btn {
+
+}
+
+.vpe-text {
+ color:red;
+}
+
+#editor {
+ background-color: red;
+
+}
\ No newline at end of file
Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/pickList.xhtml.xml
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/pickList.xhtml.xml 2009-05-13 14:15:09 UTC (rev 15241)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/pickList.xhtml.xml 2009-05-13 14:33:34 UTC (rev 15242)
@@ -33,7 +33,8 @@
CLASS="rich-list-picklist-button">
<DIV CLASS="rich-list-picklist-button-content">
<IMG WIDTH="15" HEIGHT="15"
- SRC="/.*resources/pickList/arrow_copy.gif/"/> Copy
+ SRC="/.*resources/pickList/arrow_remove.gif/" />
+ Remove
</DIV>
</DIV>
</DIV>
@@ -43,7 +44,8 @@
CLASS="rich-list-picklist-button">
<DIV CLASS="rich-list-picklist-button-content">
<IMG WIDTH="15" HEIGHT="15"
- SRC="/.*resources/pickList/arrow_remove.gif/"/> Remove
+ SRC="/.*resources/pickList/arrow_copy_all.gif/" />
+ Copy all
</DIV>
</DIV>
</DIV>
@@ -53,7 +55,8 @@
CLASS="rich-list-picklist-button">
<DIV CLASS="rich-list-picklist-button-content">
<IMG WIDTH="15" HEIGHT="15"
- SRC="/.*resources/pickList/arrow_remove_all.gif/"/> Remove All
+ SRC="/.*resources/pickList/arrow_copy.gif/" />
+ Copy
</DIV>
</DIV>
</DIV>
@@ -63,7 +66,8 @@
CLASS="rich-list-picklist-button">
<DIV CLASS="rich-list-picklist-button-content">
<IMG WIDTH="15" HEIGHT="15"
- SRC="/.*resources/pickList/arrow_copy_all.gif/"/> Copy all
+ SRC="/.*resources/pickList/arrow_remove_all.gif/" />
+ Remove All
</DIV>
</DIV>
</DIV>
@@ -75,12 +79,12 @@
CLASS="rich-picklist-body">
<TR>
<TD STYLE="border: 0px none ; padding: 0px;">
- <BR _MOZ_DIRTY="" TYPE="_moz"/>
+ <BR _MOZ_DIRTY="" TYPE="_moz" />
</TD>
</TR>
</TABLE>
</DIV>
- <BR _MOZ_DIRTY="" TYPE="_moz"/>
+ <BR _MOZ_DIRTY="" TYPE="_moz" />
</TD>
</TR>
</TBODY>
15 years, 6 months
JBoss Tools SVN: r15241 - trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2009-05-13 10:15:09 -0400 (Wed, 13 May 2009)
New Revision: 15241
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JSPDialogCellEditorContentAssistProcessor.java
Log:
JBIDE-4290
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JSPDialogCellEditorContentAssistProcessor.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JSPDialogCellEditorContentAssistProcessor.java 2009-05-13 11:34:09 UTC (rev 15240)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JSPDialogCellEditorContentAssistProcessor.java 2009-05-13 14:15:09 UTC (rev 15241)
@@ -25,17 +25,18 @@
import org.eclipse.swt.graphics.Image;
import org.eclipse.wst.xml.ui.internal.contentassist.XMLRelevanceConstants;
import org.eclipse.wst.xml.ui.internal.util.SharedXMLEditorPluginImageHelper;
+import org.jboss.tools.common.el.core.model.ELInstance;
+import org.jboss.tools.common.el.core.model.ELModel;
+import org.jboss.tools.common.el.core.model.ELUtil;
+import org.jboss.tools.common.el.core.parser.ELParser;
+import org.jboss.tools.common.el.core.parser.ELParserUtil;
import org.jboss.tools.common.kb.KbException;
import org.jboss.tools.common.kb.KbProposal;
import org.jboss.tools.common.kb.KbQuery;
import org.jboss.tools.common.kb.wtp.WtpKbConnector;
import org.jboss.tools.jst.jsp.JspEditorPlugin;
import org.jboss.tools.jst.jsp.outline.ValueHelper;
-import org.jboss.tools.jst.web.tld.TaglibData;
-import org.jboss.tools.jst.web.tld.VpeTaglibManager;
-import org.w3c.dom.Attr;
import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
public class JSPDialogCellEditorContentAssistProcessor extends JavaPackageCompletionProcessor implements ISubjectControlContentAssistProcessor {
@@ -84,6 +85,18 @@
matchString = currentValue.substring(0, offset);
strippedValue = currentValue;
+ String elProposalPrefix = "";
+
+ ELParser p = ELParserUtil.getJbossFactory().createParser();
+ ELModel model = p.parse(matchString);
+ ELInstance is = ELUtil.findInstance(model, matchString.length());
+
+ ELParser p1 = ELParserUtil.getJbossFactory().createParser();
+ ELModel model1 = p1.parse(currentValue);
+ ELInstance is1 = ELUtil.findInstance(model1, matchString.length());
+
+ int elStartPosition = is == null ? -1 : is.getStartPosition();
+
boolean faceletJsfTag = false;
String htmlQuery = null;
@@ -119,12 +132,26 @@
}
if(kbProposal.getStart() >= 0) {
- String replacementString = kbProposal.getReplacementString();
- int replacementBeginPosition = 0/*contentAssistRequest.getReplacementBeginPosition()*/ + kbProposal.getStart();
+ String replacementString = kbProposal.getReplacementString().substring(2,kbProposal.getReplacementString().length() - 1);
+ int replacementBeginPosition = /*contentAssistRequest.getReplacementBeginPosition() + */kbProposal.getStart();
int replacementLength = kbProposal.getEnd() - kbProposal.getStart();
int cursorPositionDelta = 0;
+
+ // Add an EL-starting quotation characters if needed
+ if (elStartPosition == -1) {
+ replacementString = elProposalPrefix + replacementString;
+ cursorPositionDelta += elProposalPrefix.length();
+ }
+
+ if(is1 == null || is1.getCloseInstanceToken() == null) {
+ replacementString += "}";
+ }
+
int cursorPosition = kbProposal.getPosition() + cursorPositionDelta;
-
+ String displayString = elProposalPrefix == null || elProposalPrefix.length() == 0 ?
+ kbProposal.getReplacementString().substring(2,kbProposal.getReplacementString().length() - 1) :
+ elProposalPrefix + kbProposal.getReplacementString().substring(2,kbProposal.getReplacementString().length() - 1) + "}" ;
+
Image image = kbProposal.hasImage() ?
kbProposal.getImage() :
SharedXMLEditorPluginImageHelper.getImage(SharedXMLEditorPluginImageHelper.IMG_OBJ_ATTRIBUTE);
15 years, 6 months
JBoss Tools SVN: r15240 - trunk/hibernatetools/plugins/org.hibernate.eclipse.console.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2009-05-13 07:34:09 -0400 (Wed, 13 May 2009)
New Revision: 15240
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/plugin.xml
Log:
https://jira.jboss.org/jira/browse/JBIDE-4274
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/plugin.xml
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/plugin.xml 2009-05-13 10:37:36 UTC (rev 15239)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/plugin.xml 2009-05-13 11:34:09 UTC (rev 15240)
@@ -666,9 +666,23 @@
id="org.hibernate.eclipse.launch.core.refactoring.RenameResourceParticipant"
name="Launch Configurations resource rename updates">
<enablement>
- <with variable="element">
- <instanceof value="org.eclipse.core.resources.IResource"/>
- </with>
+ <and>
+ <or>
+ <with variable="processorIdentifier">
+ <equals
+ value="org.eclipse.jdt.ui.renameJavaProjectProcessor">
+ </equals>
+ </with>
+ <with variable="processorIdentifier">
+ <equals
+ value="org.eclipse.ltk.core.refactoring.renameResourceProcessor">
+ </equals>
+ </with>
+ </or>
+ <with variable="element">
+ <instanceof value="org.eclipse.core.resources.IResource"/>
+ </with>
+ </and>
</enablement>
</renameParticipant>
<renameParticipant
@@ -822,4 +836,4 @@
</colorDefinition>
</extension>
-->
-</plugin>
+</plugin>
\ No newline at end of file
15 years, 6 months
JBoss Tools SVN: r15239 - in trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors: datasource and 5 other directories.
by jbosstools-commits@lists.jboss.org
Author: DartPeng
Date: 2009-05-13 06:37:36 -0400 (Wed, 13 May 2009)
New Revision: 15239
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/AttributeFieldEditPart.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/IPropertyUICreator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/PropertyUICreator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SelectorAttributes.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SelectoreSelectionDialog.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksStuffPropertyDetailPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/datasource/DirectUICreator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/freemarker/TemplateUICreator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/groovy/GroovyUICreator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/groovy/ScriptUICreator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/smooks/ParamTypeUICreator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xsl/TemplateUICreator.java
Log:
JBIDE-4298
write a method to group multiple attribute field editors.
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/AttributeFieldEditPart.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/AttributeFieldEditPart.java 2009-05-13 10:02:54 UTC (rev 15238)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/AttributeFieldEditPart.java 2009-05-13 10:37:36 UTC (rev 15239)
@@ -18,6 +18,8 @@
*/
public class AttributeFieldEditPart {
+ private Object attribute;
+
private IFieldMarker fieldMarker;
private Control contentControl;
@@ -49,4 +51,20 @@
public void setContentControl(Control contentControl) {
this.contentControl = contentControl;
}
+
+ /**
+ * @return the attribute
+ */
+ public Object getAttribute() {
+ return attribute;
+ }
+
+ /**
+ * @param attribute the attribute to set
+ */
+ public void setAttribute(Object attribute) {
+ this.attribute = attribute;
+ }
+
+
}
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/IPropertyUICreator.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/IPropertyUICreator.java 2009-05-13 10:02:54 UTC (rev 15238)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/IPropertyUICreator.java 2009-05-13 10:37:36 UTC (rev 15239)
@@ -10,6 +10,8 @@
******************************************************************************/
package org.jboss.tools.smooks.configuration.editors;
+import java.util.List;
+
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
@@ -26,7 +28,7 @@
IItemPropertyDescriptor propertyDescriptor, Object model, EAttribute feature,
SmooksMultiFormEditor formEditor);
- public void createExtendUI(AdapterFactoryEditingDomain editingdomain, FormToolkit toolkit,
+ public List<AttributeFieldEditPart> createExtendUI(AdapterFactoryEditingDomain editingdomain, FormToolkit toolkit,
Composite parent, Object model, SmooksMultiFormEditor formEditor);
public boolean ignoreProperty(EAttribute feature);
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/PropertyUICreator.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/PropertyUICreator.java 2009-05-13 10:02:54 UTC (rev 15238)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/PropertyUICreator.java 2009-05-13 10:37:36 UTC (rev 15239)
@@ -11,6 +11,7 @@
package org.jboss.tools.smooks.configuration.editors;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Iterator;
import java.util.List;
@@ -26,6 +27,7 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Combo;
@@ -33,6 +35,7 @@
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.forms.events.IHyperlinkListener;
import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Section;
import org.jboss.tools.smooks.configuration.editors.uitls.FieldMarkerWrapper;
import org.jboss.tools.smooks.configuration.editors.uitls.IFieldDialog;
import org.jboss.tools.smooks.configuration.editors.uitls.IModelProcsser;
@@ -65,8 +68,9 @@
* org.eclipse.emf.edit.provider.IItemPropertyDescriptor, java.lang.Object,
* org.eclipse.emf.ecore.EAttribute)
*/
- public AttributeFieldEditPart createPropertyUI(FormToolkit toolkit, Composite parent, IItemPropertyDescriptor propertyDescriptor, Object model,
- EAttribute feature, SmooksMultiFormEditor formEditor) {
+ public AttributeFieldEditPart createPropertyUI(FormToolkit toolkit, Composite parent,
+ IItemPropertyDescriptor propertyDescriptor, Object model, EAttribute feature,
+ SmooksMultiFormEditor formEditor) {
if (isBeanIDRefFieldFeature(feature)) {
return createBeanIDRefFieldEditor(toolkit, parent, propertyDescriptor, model, feature, formEditor);
}
@@ -79,9 +83,9 @@
if (isFileSelectionFeature(feature)) {
return createFileSelectionFieldEditor(toolkit, parent, propertyDescriptor, model, feature, formEditor);
}
- if(isConditionSelectionFeature(feature)){
+ if (isConditionSelectionFeature(feature)) {
return SmooksUIUtils.createConditionsChoiceFieldEditor(parent, toolkit, propertyDescriptor, model);
-// return parent;
+ // return parent;
}
if (feature == SmooksPackage.eINSTANCE.getAbstractReader_TargetProfile()) {
@@ -125,16 +129,18 @@
return SmooksUIUtils.getJavaProject(model);
}
- public void createExtendUI(AdapterFactoryEditingDomain editingdomain, FormToolkit toolkit, Composite parent, Object model,
- SmooksMultiFormEditor formEditor) {
+ public List<AttributeFieldEditPart> createExtendUI(AdapterFactoryEditingDomain editingdomain, FormToolkit toolkit,
+ Composite parent, Object model, SmooksMultiFormEditor formEditor) {
+ return Collections.emptyList();
}
protected boolean isFileSelectionFeature(EAttribute attribute) {
return false;
}
- public AttributeFieldEditPart createFileSelectionFieldEditor(FormToolkit toolkit, Composite parent, IItemPropertyDescriptor propertyDescriptor, Object model,
- EAttribute feature, SmooksMultiFormEditor formEditor) {
+ public AttributeFieldEditPart createFileSelectionFieldEditor(FormToolkit toolkit, Composite parent,
+ IItemPropertyDescriptor propertyDescriptor, Object model, EAttribute feature,
+ SmooksMultiFormEditor formEditor) {
IFieldDialog dialog = new IFieldDialog() {
public Object open(Shell shell) {
FileSelectionWizard wizard = new FileSelectionWizard();
@@ -160,16 +166,17 @@
}
};
- return SmooksUIUtils.createDialogFieldEditor(parent, toolkit, propertyDescriptor, "Browse", dialog, (EObject) model, true,
- getFileFiledEditorLinkListener());
+ return SmooksUIUtils.createDialogFieldEditor(parent, toolkit, propertyDescriptor, "Browse", dialog,
+ (EObject) model, true, getFileFiledEditorLinkListener());
}
protected boolean isSelectorFeature(EAttribute attribute) {
return false;
}
- public AttributeFieldEditPart createSelectorFieldEditor(FormToolkit toolkit, Composite parent, IItemPropertyDescriptor propertyDescriptor, Object model,
- EAttribute feature, SmooksMultiFormEditor formEditor) {
+ public AttributeFieldEditPart createSelectorFieldEditor(FormToolkit toolkit, Composite parent,
+ IItemPropertyDescriptor propertyDescriptor, Object model, EAttribute feature,
+ SmooksMultiFormEditor formEditor) {
SmooksGraphicsExtType ext = formEditor.getSmooksGraphicsExt();
if (ext != null) {
return SmooksUIUtils.createSelectorFieldEditor(toolkit, parent, propertyDescriptor, model, ext);
@@ -181,8 +188,9 @@
return false;
}
- public AttributeFieldEditPart createJavaTypeSearchEditor(FormToolkit toolkit, Composite parent, IItemPropertyDescriptor propertyDescriptor, Object model,
- EAttribute feature, SmooksMultiFormEditor formEditor) {
+ public AttributeFieldEditPart createJavaTypeSearchEditor(FormToolkit toolkit, Composite parent,
+ IItemPropertyDescriptor propertyDescriptor, Object model, EAttribute feature,
+ SmooksMultiFormEditor formEditor) {
if (model instanceof EObject)
return SmooksUIUtils.createJavaTypeSearchFieldEditor(parent, toolkit, propertyDescriptor, (EObject) model);
return null;
@@ -192,15 +200,17 @@
return false;
}
- public AttributeFieldEditPart createBeanIDRefFieldEditor(FormToolkit toolkit, Composite parent, IItemPropertyDescriptor propertyDescriptor, Object model,
- EAttribute feature, SmooksMultiFormEditor formEditor) {
+ public AttributeFieldEditPart createBeanIDRefFieldEditor(FormToolkit toolkit, Composite parent,
+ IItemPropertyDescriptor propertyDescriptor, Object model, EAttribute feature,
+ SmooksMultiFormEditor formEditor) {
if (model instanceof EObject) {
AttributeFieldEditPart editPart = new AttributeFieldEditPart();
SmooksResourceListType smooksResourceList = getSmooksResourceList((EObject) model);
if (smooksResourceList != null) {
- FieldMarkerWrapper wrapper = SmooksUIUtils.createFieldEditorLabel(null,parent, toolkit, propertyDescriptor, model, false);
+ FieldMarkerWrapper wrapper = SmooksUIUtils.createFieldEditorLabel(null, parent, toolkit,
+ propertyDescriptor, model, false);
editPart.setFieldMarker(wrapper.getMarker());
-
+
Composite tcom = toolkit.createComposite(parent);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
@@ -208,7 +218,7 @@
layout.marginRight = 0;
layout.horizontalSpacing = 0;
tcom.setLayout(layout);
-
+
FieldMarkerComposite notificationComposite = new FieldMarkerComposite(tcom, SWT.NONE);
GridData gd = new GridData();
gd.heightHint = 8;
@@ -217,13 +227,13 @@
gd.verticalAlignment = GridData.BEGINNING;
notificationComposite.setLayoutData(gd);
editPart.setFieldMarker(notificationComposite);
-
+
final Combo combo = new Combo(tcom, SWT.BORDER);
editPart.setContentControl(combo);
gd = new GridData(GridData.FILL_HORIZONTAL);
combo.setLayoutData(gd);
tcom.setLayoutData(gd);
-
+
Object editValue = SmooksUIUtils.getEditValue(propertyDescriptor, model);
if (editValue != null) {
combo.setText(editValue.toString());
@@ -284,4 +294,45 @@
return false;
}
+ protected List<AttributeFieldEditPart> createElementSelectionSection(String sectionTitle,
+ AdapterFactoryEditingDomain editingdomain, FormToolkit toolkit, Composite parent, Object model,
+ SmooksMultiFormEditor formEditor, IItemPropertyDescriptor createOnElementFeature,
+ IItemPropertyDescriptor createOnElementFeatureNS) {
+ Section section = toolkit.createSection(parent, Section.TITLE_BAR);
+ section.setText(sectionTitle);
+
+ FillLayout layout = new FillLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+
+ section.setLayout(layout);
+
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.heightHint = 100;
+ gd.horizontalSpan = 2;
+ section.setLayoutData(gd);
+
+ Composite container = toolkit.createComposite(section);
+
+ section.setClient(container);
+
+ GridLayout glayout = new GridLayout();
+ glayout.numColumns = 2;
+ container.setLayout(glayout);
+
+ AttributeFieldEditPart editPart1 = SmooksUIUtils.createSelectorFieldEditor("Name", toolkit, container,
+ createOnElementFeature, model, formEditor.getSmooksGraphicsExt());
+ editPart1.setAttribute(createOnElementFeature.getFeature(model));
+
+ AttributeFieldEditPart editPart2 = SmooksUIUtils.createStringFieldEditor("Namespace", container, editingdomain,
+ toolkit, createOnElementFeatureNS, model, false, false, false, 0, null, SmooksUIUtils.VALUE_TYPE_VALUE,
+ null);
+ editPart2.setAttribute(createOnElementFeatureNS.getFeature(model));
+
+ List<AttributeFieldEditPart> list = new ArrayList<AttributeFieldEditPart>();
+ list.add(editPart1);
+ list.add(editPart2);
+
+ return list;
+ }
}
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SelectorAttributes.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SelectorAttributes.java 2009-05-13 10:02:54 UTC (rev 15238)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SelectorAttributes.java 2009-05-13 10:37:36 UTC (rev 15239)
@@ -16,7 +16,7 @@
public static final String IGNORE_ROOT = "ignore_root";
public static final String INCLUDE_PARENT = "include_parent";
- private String selectorSperator = " ";
+ private String selectorSperator = "/";
private String selectorPolicy = SelectorAttributes.FULL_PATH;
public String getSelectorSperator() {
return selectorSperator;
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SelectoreSelectionDialog.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SelectoreSelectionDialog.java 2009-05-13 10:02:54 UTC (rev 15238)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SelectoreSelectionDialog.java 2009-05-13 10:37:36 UTC (rev 15239)
@@ -24,7 +24,6 @@
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.window.IShellProvider;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CCombo;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
@@ -32,6 +31,7 @@
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
@@ -95,11 +95,11 @@
Label label = new Label(composite,SWT.NONE);
label.setText("Sperator Char : ");
- final CCombo speratorCombo = new CCombo(composite,SWT.BORDER);
+ final Combo speratorCombo = new Combo(composite,SWT.BORDER|SWT.READ_ONLY);
speratorCombo.add(" ");
speratorCombo.add("/");
- speratorCombo.select(0);
- speratorCombo.setEditable(false);
+ speratorCombo.select(1);
+// speratorCombo.setEditable(false);
gd = new GridData(GridData.FILL_HORIZONTAL);
speratorCombo.setLayoutData(gd);
speratorCombo.addModifyListener(new ModifyListener(){
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksStuffPropertyDetailPage.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksStuffPropertyDetailPage.java 2009-05-13 10:02:54 UTC (rev 15238)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksStuffPropertyDetailPage.java 2009-05-13 10:37:36 UTC (rev 15239)
@@ -139,8 +139,17 @@
}
}
if (creator != null) {
- creator.createExtendUI((AdapterFactoryEditingDomain) formEditor.getEditingDomain(), formToolkit,
+ List<AttributeFieldEditPart> list = creator.createExtendUI((AdapterFactoryEditingDomain) formEditor.getEditingDomain(), formToolkit,
detailsComposite, getModel(), getFormEditor());
+ if(list != null){
+ for (Iterator<?> iterator = list.iterator(); iterator.hasNext();) {
+ AttributeFieldEditPart attributeFieldEditPart = (AttributeFieldEditPart) iterator.next();
+ Object attribute = attributeFieldEditPart.getAttribute();
+ if(attribute != null){
+ currentPropertyUIMap.put(attribute, attributeFieldEditPart);
+ }
+ }
+ }
}
formToolkit.paintBordersFor(detailsComposite);
detailsComposite.pack();
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/datasource/DirectUICreator.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/datasource/DirectUICreator.java 2009-05-13 10:02:54 UTC (rev 15238)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/datasource/DirectUICreator.java 2009-05-13 10:37:36 UTC (rev 15239)
@@ -10,8 +10,14 @@
******************************************************************************/
package org.jboss.tools.smooks.configuration.editors.datasource;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
+import org.eclipse.emf.edit.provider.IItemPropertySource;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.jboss.tools.smooks.configuration.editors.AttributeFieldEditPart;
@@ -33,8 +39,9 @@
* org.eclipse.emf.edit.provider.IItemPropertyDescriptor, java.lang.Object,
* org.eclipse.emf.ecore.EAttribute)
*/
- public AttributeFieldEditPart createPropertyUI(FormToolkit toolkit, Composite parent, IItemPropertyDescriptor propertyDescriptor, Object model,
- EAttribute feature, SmooksMultiFormEditor formEditor) {
+ public AttributeFieldEditPart createPropertyUI(FormToolkit toolkit, Composite parent,
+ IItemPropertyDescriptor propertyDescriptor, Object model, EAttribute feature,
+ SmooksMultiFormEditor formEditor) {
if (feature == DatasourcePackage.eINSTANCE.getDirect_AutoCommit()) {
}
if (feature == DatasourcePackage.eINSTANCE.getDirect_BindOnElementNS()) {
@@ -50,7 +57,59 @@
return super.createPropertyUI(toolkit, parent, propertyDescriptor, model, feature, formEditor);
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.jboss.tools.smooks.configuration.editors.PropertyUICreator#ignoreProperty
+ * (org.eclipse.emf.ecore.EAttribute)
+ */
@Override
+ public boolean ignoreProperty(EAttribute feature) {
+ if (feature == DatasourcePackage.eINSTANCE.getDirect_BindOnElementNS()) {
+ return true;
+ }
+ if (feature == DatasourcePackage.eINSTANCE.getDirect_BindOnElement()) {
+ return true;
+ }
+ return super.ignoreProperty(feature);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.jboss.tools.smooks.configuration.editors.PropertyUICreator#createExtendUI
+ * (org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain,
+ * org.eclipse.ui.forms.widgets.FormToolkit,
+ * org.eclipse.swt.widgets.Composite, java.lang.Object,
+ * org.jboss.tools.smooks.configuration.editors.SmooksMultiFormEditor)
+ */
+ @Override
+ public List<AttributeFieldEditPart> createExtendUI(AdapterFactoryEditingDomain editingdomain, FormToolkit toolkit,
+ Composite parent, Object model, SmooksMultiFormEditor formEditor) {
+ IItemPropertySource itemPropertySource = (IItemPropertySource) editingdomain.getAdapterFactory().adapt(model,
+ IItemPropertySource.class);
+ List<IItemPropertyDescriptor> propertyDes = itemPropertySource.getPropertyDescriptors(model);
+ IItemPropertyDescriptor createOnElementFeature = null;
+ IItemPropertyDescriptor createOnElementFeatureNS = null;
+ for (Iterator<?> iterator = propertyDes.iterator(); iterator.hasNext();) {
+ IItemPropertyDescriptor itemPropertyDescriptor = (IItemPropertyDescriptor) iterator.next();
+ if (itemPropertyDescriptor.getFeature(model) == DatasourcePackage.eINSTANCE.getDirect_BindOnElement()) {
+ createOnElementFeature = itemPropertyDescriptor;
+ }
+ if (itemPropertyDescriptor.getFeature(model) == DatasourcePackage.eINSTANCE.getDirect_BindOnElementNS()) {
+ createOnElementFeatureNS = itemPropertyDescriptor;
+ }
+ }
+ if(createOnElementFeature == null || createOnElementFeatureNS == null){
+ return Collections.emptyList();
+ }
+ return this.createElementSelectionSection("Binding On Element", editingdomain, toolkit, parent, model, formEditor,
+ createOnElementFeature, createOnElementFeatureNS);
+ }
+
+ @Override
public boolean isJavaTypeFeature(EAttribute attribute) {
if (attribute == DatasourcePackage.eINSTANCE.getDirect_Driver()) {
return true;
@@ -60,12 +119,11 @@
@Override
public boolean isSelectorFeature(EAttribute attribute) {
- if (attribute == DatasourcePackage.eINSTANCE.getDirect_BindOnElement()) {
- return true;
- }
+ // if (attribute ==
+ // DatasourcePackage.eINSTANCE.getDirect_BindOnElement()) {
+ // return true;
+ // }
return super.isSelectorFeature(attribute);
}
-
-
}
\ No newline at end of file
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/freemarker/TemplateUICreator.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/freemarker/TemplateUICreator.java 2009-05-13 10:02:54 UTC (rev 15238)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/freemarker/TemplateUICreator.java 2009-05-13 10:37:36 UTC (rev 15239)
@@ -10,6 +10,9 @@
******************************************************************************/
package org.jboss.tools.smooks.configuration.editors.freemarker;
+import java.util.Collections;
+import java.util.List;
+
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.xml.type.AnyType;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
@@ -48,7 +51,7 @@
}
@Override
- public void createExtendUI(AdapterFactoryEditingDomain editingdomain, FormToolkit toolkit, Composite parent, Object model,
+ public List<AttributeFieldEditPart> createExtendUI(AdapterFactoryEditingDomain editingdomain, FormToolkit toolkit, Composite parent, Object model,
SmooksMultiFormEditor formEditor) {
OpenEditorEditInnerContentsAction openCDATAEditorAction = new OpenEditorEditInnerContentsAction(editingdomain,(AnyType) model, SmooksUIUtils.VALUE_TYPE_CDATA, "flt");
OpenEditorEditInnerContentsAction openCommentEditorAction = new OpenEditorEditInnerContentsAction(editingdomain,(AnyType) model, SmooksUIUtils.VALUE_TYPE_COMMENT, "flt");
@@ -60,6 +63,8 @@
openCDATAEditorAction.setRelateText((Text)cdatatext.getContentControl());
openCommentEditorAction.setRelateText((Text)commenttext.getContentControl());
+
+ return Collections.emptyList();
}
@Override
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/groovy/GroovyUICreator.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/groovy/GroovyUICreator.java 2009-05-13 10:02:54 UTC (rev 15238)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/groovy/GroovyUICreator.java 2009-05-13 10:37:36 UTC (rev 15239)
@@ -10,6 +10,9 @@
******************************************************************************/
package org.jboss.tools.smooks.configuration.editors.groovy;
+import java.util.Collections;
+import java.util.List;
+
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
@@ -61,8 +64,9 @@
@Override
- public void createExtendUI(AdapterFactoryEditingDomain editingdomain, FormToolkit toolkit,
+ public List<AttributeFieldEditPart> createExtendUI(AdapterFactoryEditingDomain editingdomain, FormToolkit toolkit,
Composite parent, Object model, SmooksMultiFormEditor formEditor) {
+ return Collections.emptyList();
// SmooksUIUtils.createCommentFieldEditor("Script Contents",editingdomain, toolkit, parent, model);
}
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/groovy/ScriptUICreator.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/groovy/ScriptUICreator.java 2009-05-13 10:02:54 UTC (rev 15238)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/groovy/ScriptUICreator.java 2009-05-13 10:37:36 UTC (rev 15239)
@@ -10,6 +10,9 @@
******************************************************************************/
package org.jboss.tools.smooks.configuration.editors.groovy;
+import java.util.Collections;
+import java.util.List;
+
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.xml.type.AnyType;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
@@ -42,11 +45,12 @@
}
@Override
- public void createExtendUI(AdapterFactoryEditingDomain editingdomain, FormToolkit toolkit, Composite parent, Object model,
+ public List<AttributeFieldEditPart> createExtendUI(AdapterFactoryEditingDomain editingdomain, FormToolkit toolkit, Composite parent, Object model,
SmooksMultiFormEditor formEditor) {
OpenEditorEditInnerContentsAction action2 = new OpenEditorEditInnerContentsAction(editingdomain,(AnyType) model, SmooksUIUtils.VALUE_TYPE_COMMENT, "groovy");
AttributeFieldEditPart editPart = SmooksUIUtils.createCommentFieldEditor("Script Contents", editingdomain, toolkit, parent, model, action2);
action2.setRelateText((Text)editPart.getContentControl());
+ return Collections.emptyList();
}
@Override
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/smooks/ParamTypeUICreator.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/smooks/ParamTypeUICreator.java 2009-05-13 10:02:54 UTC (rev 15238)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/smooks/ParamTypeUICreator.java 2009-05-13 10:37:36 UTC (rev 15239)
@@ -10,6 +10,9 @@
******************************************************************************/
package org.jboss.tools.smooks.configuration.editors.smooks;
+import java.util.Collections;
+import java.util.List;
+
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
@@ -45,9 +48,11 @@
}
@Override
- public void createExtendUI(AdapterFactoryEditingDomain editingdomain, FormToolkit toolkit,
+ public List<AttributeFieldEditPart> createExtendUI(AdapterFactoryEditingDomain editingdomain, FormToolkit toolkit,
Composite parent, Object model, SmooksMultiFormEditor formEditor) {
SmooksUIUtils.createMixedTextFieldEditor("Text Value", editingdomain, toolkit, parent, model , false , 500,false,false,null,null);
SmooksUIUtils.createCDATAFieldEditor("CDATA Value", editingdomain, toolkit, parent, model,null);
+
+ return Collections.emptyList();
}
}
\ No newline at end of file
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java 2009-05-13 10:02:54 UTC (rev 15238)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java 2009-05-13 10:37:36 UTC (rev 15239)
@@ -151,10 +151,12 @@
String displayName = labelText;
if (itemPropertyDescriptor == null) {
} else {
- displayName = itemPropertyDescriptor.getDisplayName(model);
- EAttribute feature = (EAttribute) itemPropertyDescriptor.getFeature(model);
- if (feature.isRequired()) {
- displayName = displayName + "*";
+ if (displayName == null) {
+ displayName = itemPropertyDescriptor.getDisplayName(model);
+ EAttribute feature = (EAttribute) itemPropertyDescriptor.getFeature(model);
+ if (feature.isRequired()) {
+ displayName = displayName + "*";
+ }
}
}
Composite labelComposite = formToolKit.createComposite(parent);
@@ -344,7 +346,7 @@
label = itemPropertyDescriptor.getDisplayName(model);
EAttribute feature = (EAttribute) itemPropertyDescriptor.getFeature(model);
if (feature.isRequired()) {
- label = "*" + label;
+ label = label + "*";
}
}
if (multiText) {
@@ -573,7 +575,13 @@
public static AttributeFieldEditPart createSelectorFieldEditor(FormToolkit toolkit, Composite parent,
final IItemPropertyDescriptor propertyDescriptor, Object model, final SmooksGraphicsExtType extType) {
- return createDialogFieldEditor(parent, toolkit, propertyDescriptor, "Browse", new IFieldDialog() {
+ return createSelectorFieldEditor(null, toolkit, parent, propertyDescriptor, model, extType);
+ }
+
+ public static AttributeFieldEditPart createSelectorFieldEditor(String labelText, FormToolkit toolkit,
+ Composite parent, final IItemPropertyDescriptor propertyDescriptor, Object model,
+ final SmooksGraphicsExtType extType) {
+ return createDialogFieldEditor(labelText, parent, toolkit, propertyDescriptor, "Browse", new IFieldDialog() {
public Object open(Shell shell) {
SelectoreSelectionDialog dialog = new SelectoreSelectionDialog(shell, extType);
if (dialog.open() == Dialog.OK) {
@@ -989,11 +997,26 @@
return createDialogFieldEditor(parent, toolkit, propertyDescriptor, buttonName, dialog, model, false, null);
}
+ public static AttributeFieldEditPart createDialogFieldEditor(String label, Composite parent, FormToolkit toolkit,
+ final IItemPropertyDescriptor propertyDescriptor, String buttonName, IFieldDialog dialog,
+ final EObject model) {
+ return createDialogFieldEditor(label, parent, toolkit, propertyDescriptor, buttonName, dialog, model, false,
+ null);
+ }
+
public static AttributeFieldEditPart createDialogFieldEditor(Composite parent, FormToolkit toolkit,
final IItemPropertyDescriptor propertyDescriptor, String buttonName, IFieldDialog dialog,
final EObject model, boolean labelLink, IHyperlinkListener listener) {
+ return createDialogFieldEditor(null, parent, toolkit, propertyDescriptor, buttonName, dialog, model, labelLink,
+ listener);
+ }
+
+ public static AttributeFieldEditPart createDialogFieldEditor(String labelText, Composite parent,
+ FormToolkit toolkit, final IItemPropertyDescriptor propertyDescriptor, String buttonName,
+ IFieldDialog dialog, final EObject model, boolean labelLink, IHyperlinkListener listener) {
AttributeFieldEditPart editpart = new AttributeFieldEditPart();
- FieldMarkerWrapper wrapper = createFieldEditorLabel(parent, toolkit, propertyDescriptor, model, labelLink);
+ FieldMarkerWrapper wrapper = createFieldEditorLabel(labelText, parent, toolkit, propertyDescriptor, model,
+ labelLink);
editpart.setFieldMarker(wrapper.getMarker());
Control label = wrapper.getLabelControl();
if (label instanceof Hyperlink && listener != null) {
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xsl/TemplateUICreator.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xsl/TemplateUICreator.java 2009-05-13 10:02:54 UTC (rev 15238)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xsl/TemplateUICreator.java 2009-05-13 10:37:36 UTC (rev 15239)
@@ -10,6 +10,9 @@
******************************************************************************/
package org.jboss.tools.smooks.configuration.editors.xsl;
+import java.util.Collections;
+import java.util.List;
+
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.xml.type.AnyType;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
@@ -64,7 +67,7 @@
}
@Override
- public void createExtendUI(AdapterFactoryEditingDomain editingdomain, FormToolkit toolkit, Composite parent, Object model,
+ public List<AttributeFieldEditPart> createExtendUI(AdapterFactoryEditingDomain editingdomain, FormToolkit toolkit, Composite parent, Object model,
SmooksMultiFormEditor formEditor) {
OpenEditorEditInnerContentsAction openCdataEditorAction = new OpenEditorEditInnerContentsAction(editingdomain,(AnyType) model, SmooksUIUtils.VALUE_TYPE_CDATA, "xsl");
OpenEditorEditInnerContentsAction openCommentEditorAction = new OpenEditorEditInnerContentsAction(editingdomain,(AnyType) model, SmooksUIUtils.VALUE_TYPE_COMMENT, "xsl");
@@ -74,6 +77,8 @@
AttributeFieldEditPart text2 = SmooksUIUtils.createCommentFieldEditor("Template Contents (Comment)", editingdomain, toolkit, parent, model, openCommentEditorAction);
openCdataEditorAction.setRelateText((Text)text1.getContentControl());
openCommentEditorAction.setRelateText((Text)text2.getContentControl());
+
+ return Collections.emptyList();
}
}
\ No newline at end of file
15 years, 6 months
JBoss Tools SVN: r15238 - trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2009-05-13 06:02:54 -0400 (Wed, 13 May 2009)
New Revision: 15238
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/LaunchConfigurationResourceNameChange.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4277
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/LaunchConfigurationResourceNameChange.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/LaunchConfigurationResourceNameChange.java 2009-05-13 08:45:40 UTC (rev 15237)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/LaunchConfigurationResourceNameChange.java 2009-05-13 10:02:54 UTC (rev 15238)
@@ -18,8 +18,8 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.ltk.core.refactoring.Change;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
import org.hibernate.eclipse.console.HibernateConsoleMessages;
@@ -95,8 +95,7 @@
IPath newLaunchPath = fNewPath.append(relativePath.removeFirstSegments(matchSegment));
IFile file = root.getFileForLocation(rootLoacation.append(newLaunchPath));
if (file != null){
- fLaunchConfiguration = fLaunchConfiguration.getWorkingCopy();
- ((ILaunchConfigurationWorkingCopy) fLaunchConfiguration).setContainer(file.getParent());
+ fLaunchConfiguration = DebugPlugin.getDefault().getLaunchManager().getLaunchConfiguration(file);
}
}
}
15 years, 6 months
JBoss Tools SVN: r15237 - in trunk/smooks/plugins: org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/validate and 7 other directories.
by jbosstools-commits@lists.jboss.org
Author: DartPeng
Date: 2009-05-13 04:45:40 -0400 (Wed, 13 May 2009)
New Revision: 15237
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/command/
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/command/UnSetFeatureCommand.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/validate/ClassFieldEditorValidator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/validate/ISmooksModelValidateListener.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/validate/ISmooksValidator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/validate/SmooksModelValidator.java
Removed:
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/validate/ISmooksModelValidateListener.java
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/validate/SmooksModelValidator.java
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.core/META-INF/MANIFEST.MF
trunk/smooks/plugins/org.jboss.tools.smooks.ui/plugin.xml
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/actions/ValidateSmooksAction.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksConfigurationFormPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksMultiFormEditor.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksStuffPropertyDetailPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/validate/SmooksMarkerHelper.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/validate/ValidateResultLabelDecorator.java
Log:
JBIDE-4232
Change problem's type name and add new validator to validate class name of BindingsType
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.core/META-INF/MANIFEST.MF 2009-05-12 20:02:47 UTC (rev 15236)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.core/META-INF/MANIFEST.MF 2009-05-13 08:45:40 UTC (rev 15237)
@@ -76,7 +76,6 @@
org.jboss.tools.smooks.model.smooks.impl,
org.jboss.tools.smooks.model.smooks.provider,
org.jboss.tools.smooks.model.smooks.util,
- org.jboss.tools.smooks.model.validate,
org.jboss.tools.smooks.model.xsl,
org.jboss.tools.smooks.model.xsl.impl,
org.jboss.tools.smooks.model.xsl.provider,
Deleted: trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/validate/ISmooksModelValidateListener.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/validate/ISmooksModelValidateListener.java 2009-05-12 20:02:47 UTC (rev 15236)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/validate/ISmooksModelValidateListener.java 2009-05-13 08:45:40 UTC (rev 15237)
@@ -1,8 +0,0 @@
-package org.jboss.tools.smooks.model.validate;
-
-import org.eclipse.emf.common.util.Diagnostic;
-
-public interface ISmooksModelValidateListener {
- void validateStart();
- void validateEnd(Diagnostic diagnosticResult);
-}
Deleted: trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/validate/SmooksModelValidator.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/validate/SmooksModelValidator.java 2009-05-12 20:02:47 UTC (rev 15236)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/validate/SmooksModelValidator.java 2009-05-13 08:45:40 UTC (rev 15237)
@@ -1,179 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.smooks.model.validate;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.emf.common.notify.AdapterFactory;
-import org.eclipse.emf.common.util.Diagnostic;
-import org.eclipse.emf.common.util.DiagnosticChain;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.util.Diagnostician;
-import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.emf.edit.provider.IItemLabelProvider;
-import org.eclipse.swt.widgets.Display;
-
-/**
- * @author Dart (dpeng(a)redhat.com)
- * <p>
- * Apr 14, 2009
- */
-public class SmooksModelValidator {
-
- Collection<?> selectedObjects;
- EditingDomain domain;
- private boolean starting = false;
- private boolean waiting = false;
- private Object lock = new Object();
-
- private long watingTime = 300;
-
- private List<ISmooksModelValidateListener> listeners = new ArrayList<ISmooksModelValidateListener>();
-
- public SmooksModelValidator(Collection<?> selectedObjects, EditingDomain domain) {
- this.selectedObjects = selectedObjects;
- this.domain = domain;
- }
-
- public SmooksModelValidator() {
-
- }
-
- public void addValidateListener(ISmooksModelValidateListener l) {
- if (!listeners.contains(l))
- listeners.add(l);
- }
-
- public void removeValidateListener(ISmooksModelValidateListener l) {
- listeners.remove(l);
- }
-
- public Diagnostic validate(Collection<?> selectedObjects, EditingDomain editingDomain) {
- this.selectedObjects = selectedObjects;
- domain = editingDomain;
- return validate(new NullProgressMonitor());
- }
-
- public Diagnostic validate(final IProgressMonitor progressMonitor) {
- EObject eObject = (EObject) selectedObjects.iterator().next();
- int count = 0;
- for (Iterator<?> i = eObject.eAllContents(); i.hasNext(); i.next()) {
- ++count;
- }
-
- progressMonitor.beginTask("", count);
-
- final AdapterFactory adapterFactory = domain instanceof AdapterFactoryEditingDomain ? ((AdapterFactoryEditingDomain) domain)
- .getAdapterFactory()
- : null;
-
- Diagnostician diagnostician = new Diagnostician() {
- @Override
- public String getObjectLabel(EObject eObject) {
- if (adapterFactory != null && !eObject.eIsProxy()) {
- IItemLabelProvider itemLabelProvider = (IItemLabelProvider) adapterFactory.adapt(eObject,
- IItemLabelProvider.class);
- if (itemLabelProvider != null) {
- return itemLabelProvider.getText(eObject);
- }
- }
-
- return super.getObjectLabel(eObject);
- }
-
- @Override
- public boolean validate(EClass eClass, EObject eObject, DiagnosticChain diagnostics,
- Map<Object, Object> context) {
- progressMonitor.worked(1);
- return super.validate(eClass, eObject, diagnostics, context);
- }
- };
-
- progressMonitor.setTaskName("Validating...");
-
- return diagnostician.validate(eObject);
- }
-
- public void startValidate(final Collection<?> selectedObjects, final EditingDomain editingDomain) {
- if (starting) {
- synchronized (lock) {
- waiting = true;
- }
- return;
- }
- Thread thread = new Thread() {
- public void run() {
- synchronized (lock) {
- starting = true;
- waiting = true;
- }
- while (waiting) {
- try {
- waiting = false;
- Thread.sleep(watingTime);
- Thread.yield();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- try {
- for (Iterator<?> iterator = listeners.iterator(); iterator.hasNext();) {
- final ISmooksModelValidateListener l = (ISmooksModelValidateListener) iterator.next();
- Display.getDefault().syncExec(new Runnable() {
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Runnable#run()
- */
- public void run() {
- l.validateStart();
- }
-
- });
-
- }
-
- final Diagnostic d = validate(selectedObjects, editingDomain);
-
- for (Iterator<?> iterator = listeners.iterator(); iterator.hasNext();) {
- final ISmooksModelValidateListener l = (ISmooksModelValidateListener) iterator.next();
- Display.getDefault().syncExec(new Runnable() {
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Runnable#run()
- */
- public void run() {
- l.validateEnd(d);
- }
-
- });
- }
- } finally {
- waiting = false;
- starting = false;
- }
- }
- };
- thread.setName("Validate Smooks model");
- thread.start();
- }
-}
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/plugin.xml
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/plugin.xml 2009-05-12 20:02:47 UTC (rev 15236)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/plugin.xml 2009-05-13 08:45:40 UTC (rev 15237)
@@ -66,5 +66,19 @@
</enablement>
</decorator>
</extension>
+ <extension
+ id="problem"
+ name="Smooks Problem"
+ point="org.eclipse.core.resources.markers">
+ <persistent
+ value="true">
+ </persistent>
+ <super
+ type="org.eclipse.core.resources.problemmarker">
+ </super>
+ <attribute
+ name="uri">
+ </attribute>
+ </extension>
</plugin>
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/actions/ValidateSmooksAction.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/actions/ValidateSmooksAction.java 2009-05-12 20:02:47 UTC (rev 15236)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/actions/ValidateSmooksAction.java 2009-05-13 08:45:40 UTC (rev 15237)
@@ -11,6 +11,8 @@
package org.jboss.tools.smooks.configuration.actions;
import java.lang.reflect.InvocationTargetException;
+import java.util.Collections;
+import java.util.Iterator;
import java.util.List;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -31,7 +33,7 @@
import org.eclipse.ui.part.ISetSelectionTarget;
import org.jboss.tools.smooks.configuration.SmooksConfigurationActivator;
import org.jboss.tools.smooks.configuration.validate.SmooksMarkerHelper;
-import org.jboss.tools.smooks.model.validate.SmooksModelValidator;
+import org.jboss.tools.smooks.configuration.validate.SmooksModelValidator;
/**
* @author Dart (dpeng(a)redhat.com)
@@ -54,16 +56,24 @@
public void run(final IProgressMonitor progressMonitor) throws InvocationTargetException,
InterruptedException {
try {
- final Diagnostic diagnostic = validate(progressMonitor);
- shell.getDisplay().asyncExec(new Runnable() {
- public void run() {
- if (progressMonitor.isCanceled()) {
- handleDiagnostic(Diagnostic.CANCEL_INSTANCE);
- } else {
- handleDiagnostic(diagnostic);
+ List<Diagnostic> lists = validate(progressMonitor);
+ Resource resource = editingDomain.getResourceSet().getResources().get(0);
+ if (resource != null) {
+ markerHelper.deleteMarkers(resource);
+ }
+ for (Iterator<?> iterator = lists.iterator(); iterator.hasNext();) {
+ final Diagnostic diagnostic = (Diagnostic) iterator.next();
+ shell.getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ if (progressMonitor.isCanceled()) {
+ handleDiagnostic(Diagnostic.CANCEL_INSTANCE);
+ } else {
+ handleDiagnostic(diagnostic);
+ }
}
- }
- });
+ });
+ }
+
} finally {
progressMonitor.done();
}
@@ -85,67 +95,28 @@
}
protected void handleDiagnostic(Diagnostic diagnostic) {
- int severity = diagnostic.getSeverity();
- String title = null;
- String message = null;
-
- if (severity == Diagnostic.ERROR || severity == Diagnostic.WARNING) {
- title = "Error";
- message = "Validate Messages";
- } else {
- title = "Information";
- message = "Validate success";
- }
-
- int result = 0;
+
if (diagnostic.getSeverity() == Diagnostic.OK) {
-// MessageDialog.openInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), title,
-// message);
-// result = Window.CANCEL;
return;
} else {
- result = DiagnosticDialog.open(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), title,
- message, diagnostic);
}
if (markerHelper != null) {
- Resource resource = editingDomain.getResourceSet().getResources().get(0);
- if (resource != null) {
- markerHelper.deleteMarkers(resource);
- }
- if (result == Window.OK) {
- if (!diagnostic.getChildren().isEmpty()) {
- List<?> data = (diagnostic.getChildren().get(0)).getData();
- if (!data.isEmpty() && data.get(0) instanceof EObject) {
- Object part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
- .getActivePart();
- if (part instanceof ISetSelectionTarget) {
- ((ISetSelectionTarget) part).selectReveal(new StructuredSelection(data.get(0)));
- } else if (part instanceof IViewerProvider) {
- Viewer viewer = ((IViewerProvider) part).getViewer();
- if (viewer != null) {
- viewer.setSelection(new StructuredSelection(data.get(0)), true);
- }
- }
- }
+ if (resource != null) {
+ for (Diagnostic childDiagnostic : diagnostic.getChildren()) {
+ markerHelper.createMarkers(resource, childDiagnostic);
}
-
- if (resource != null) {
- for (Diagnostic childDiagnostic : diagnostic.getChildren()) {
- markerHelper.createMarkers(resource, childDiagnostic);
- }
- }
}
}
}
- protected Diagnostic validate(IProgressMonitor progressMonitor) {
+ protected List<Diagnostic> validate(IProgressMonitor progressMonitor) {
if (resource != null && editingDomain != null) {
validator = new SmooksModelValidator(resource.getContents(), editingDomain);
return validator.validate(progressMonitor);
}
- return Diagnostic.OK_INSTANCE;
+ return Collections.emptyList();
}
public Resource getResource() {
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/command/UnSetFeatureCommand.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/command/UnSetFeatureCommand.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/command/UnSetFeatureCommand.java 2009-05-13 08:45:40 UTC (rev 15237)
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.configuration.command;
+
+import org.eclipse.emf.common.command.AbstractCommand;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
+
+/**
+ * @author Dart (dpeng(a)redhat.com)
+ *
+ */
+public class UnSetFeatureCommand extends AbstractCommand implements Command {
+
+ private EObject model;
+
+ private EStructuralFeature attribute;
+
+ private Object oldValue;
+
+ public UnSetFeatureCommand(EObject model, EStructuralFeature attribute) {
+ super();
+ this.model = model;
+ this.attribute = attribute;
+ this.setLabel("UnSet attribute \"" + this.attribute.getName() + "\"");
+ }
+
+ public UnSetFeatureCommand(String label, String description) {
+ super(label, description);
+ }
+
+ public UnSetFeatureCommand(String label) {
+ super(label);
+ }
+
+ public UnSetFeatureCommand(IItemPropertyDescriptor pd, Object model) {
+ this((EObject) model, (EStructuralFeature) pd.getFeature(model));
+ }
+
+ public void execute() {
+ if (model != null && attribute != null) {
+ oldValue = model.eGet(attribute);
+ model.eUnset(attribute);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.emf.common.command.AbstractCommand#prepare()
+ */
+ @Override
+ protected boolean prepare() {
+ if (model != null && attribute != null)
+ return true;
+ return false;
+ }
+
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.emf.common.command.AbstractCommand#canUndo()
+ */
+ @Override
+ public boolean canUndo() {
+ return prepare() && (oldValue != null);
+ }
+
+ public void redo() {
+ execute();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.emf.common.command.AbstractCommand#undo()
+ */
+ @Override
+ public void undo() {
+ if (model != null && attribute != null) {
+ if (oldValue != null) {
+ model.eSet(attribute, oldValue);
+ }
+ }
+ }
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/command/UnSetFeatureCommand.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksConfigurationFormPage.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksConfigurationFormPage.java 2009-05-12 20:02:47 UTC (rev 15236)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksConfigurationFormPage.java 2009-05-13 08:45:40 UTC (rev 15237)
@@ -44,12 +44,12 @@
import org.jboss.tools.smooks.configuration.SmooksConfigurationActivator;
import org.jboss.tools.smooks.configuration.editors.wizard.IStructuredDataSelectionWizard;
import org.jboss.tools.smooks.configuration.editors.wizard.StructuredDataSelectionWizard;
+import org.jboss.tools.smooks.configuration.validate.ISmooksModelValidateListener;
import org.jboss.tools.smooks.model.graphics.ext.InputType;
import org.jboss.tools.smooks.model.graphics.ext.ParamType;
import org.jboss.tools.smooks.model.graphics.ext.SmooksGraphicsExtFactory;
import org.jboss.tools.smooks.model.graphics.ext.SmooksGraphicsExtType;
import org.jboss.tools.smooks.model.smooks.DocumentRoot;
-import org.jboss.tools.smooks.model.validate.ISmooksModelValidateListener;
import org.jboss.tools.smooks10.model.smooks.util.SmooksModelUtils;
/**
@@ -286,7 +286,7 @@
}
}
- public void validateEnd(Diagnostic diagnosticResult) {
+ public void validateEnd(List<Diagnostic> diagnosticResult) {
}
public void validateStart() {
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksMultiFormEditor.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksMultiFormEditor.java 2009-05-12 20:02:47 UTC (rev 15236)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksMultiFormEditor.java 2009-05-13 08:45:40 UTC (rev 15237)
@@ -61,6 +61,9 @@
import org.jboss.tools.smooks.configuration.SmooksConfigurationActivator;
import org.jboss.tools.smooks.configuration.SmooksConstants;
import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
+import org.jboss.tools.smooks.configuration.validate.ISmooksModelValidateListener;
+import org.jboss.tools.smooks.configuration.validate.SmooksMarkerHelper;
+import org.jboss.tools.smooks.configuration.validate.SmooksModelValidator;
import org.jboss.tools.smooks.configuration.wizards.SmooksConfigurationFileNewWizard;
import org.jboss.tools.smooks.model.calc.provider.CalcItemProviderAdapterFactory;
import org.jboss.tools.smooks.model.common.provider.CommonItemProviderAdapterFactory;
@@ -78,8 +81,6 @@
import org.jboss.tools.smooks.model.json.provider.JsonItemProviderAdapterFactory;
import org.jboss.tools.smooks.model.medi.provider.MEdiItemProviderAdapterFactory;
import org.jboss.tools.smooks.model.smooks.provider.SmooksItemProviderAdapterFactory;
-import org.jboss.tools.smooks.model.validate.ISmooksModelValidateListener;
-import org.jboss.tools.smooks.model.validate.SmooksModelValidator;
import org.jboss.tools.smooks.model.xsl.provider.XslItemProviderAdapterFactory;
import org.jboss.tools.smooks10.model.smooks.util.SmooksResourceFactoryImpl;
@@ -87,7 +88,7 @@
*
* @author Dart Peng (dpeng(a)redhat.com) Date Apr 1, 2009
*/
-public class SmooksMultiFormEditor extends FormEditor implements IEditingDomainProvider , ISmooksModelValidateListener{
+public class SmooksMultiFormEditor extends FormEditor implements IEditingDomainProvider, ISmooksModelValidateListener {
public static final String EDITOR_ID = "org.jboss.tools.smooks.configuration.editors.MultiPageEditor";
@@ -102,15 +103,17 @@
private PropertySheetPage propertySheetPage = null;
private SmooksGraphicsExtType smooksGraphicsExt = null;
-
+
private SmooksModelValidator validator = null;
private EObject smooksModel;
private boolean handleEMFModelChange;
-
- private Diagnostic diagnostic;
+ private SmooksMarkerHelper markerHelper = new SmooksMarkerHelper();
+
+ private List<Diagnostic> diagnosticList;
+
public SmooksMultiFormEditor() {
super();
initEditingDomain();
@@ -161,9 +164,9 @@
int length = oldEndIndex - startIndex + 1;
handleEMFModelChange = true;
document.replace(startIndex, length, replacement);
-
+
validator.startValidate(smooksModel.eResource().getContents(), editingDomain);
-
+
} catch (Exception exception) {
SmooksConfigurationActivator.getDefault().log(exception);
}
@@ -225,12 +228,12 @@
configurationPage.setSelectionToViewer(newList);
}
}
-
- public void addValidateListener(ISmooksModelValidateListener listener){
+
+ public void addValidateListener(ISmooksModelValidateListener listener) {
validator.addValidateListener(listener);
}
-
- public void removeValidateListener(ISmooksModelValidateListener listener){
+
+ public void removeValidateListener(ISmooksModelValidateListener listener) {
validator.removeValidateListener(listener);
}
@@ -331,7 +334,7 @@
SmooksConfigurationActivator.getDefault().log(e);
}
configurationPage.setSmooksModel(this.smooksModel);
-
+
validator.startValidate(smooksModel.eResource().getContents(), editingDomain);
}
@@ -398,11 +401,11 @@
}
editingDomain.getResourceSet().getResources().add(smooksResource);
super.init(site, input);
-
+
validator = new SmooksModelValidator();
addValidateListener(this);
- setDiagnostic(validator.validate(smooksModel.eResource().getContents(), editingDomain));
-
+ setDiagnosticList(validator.validate(smooksModel.eResource().getContents(), editingDomain));
+
// if success to open editor , check if there isn't ext file and create
// a new one
String extFileName = file.getName() + SmooksConstants.SMOOKS_GRAPHICSEXT_EXTENTION_NAME_WITHDOT;
@@ -462,15 +465,31 @@
/**
* @return the diagnostic
*/
- public Diagnostic getDiagnostic() {
- return diagnostic;
+ public List<Diagnostic> getDiagnosticList() {
+ return diagnosticList;
}
/**
- * @param diagnostic the diagnostic to set
+ * @param diagnosticList
+ * the diagnostic to set
*/
- public void setDiagnostic(Diagnostic diagnostic) {
- this.diagnostic = diagnostic;
+ public void setDiagnosticList(List<Diagnostic> d) {
+ this.diagnosticList = d;
+
+ if (markerHelper != null) {
+ Resource resource = editingDomain.getResourceSet().getResources().get(0);
+ if (resource != null) {
+ markerHelper.deleteMarkers(resource);
+ }
+ for (Iterator<?> iterator = d.iterator(); iterator.hasNext();) {
+ Diagnostic diagnostic = (Diagnostic) iterator.next();
+ if (resource != null && diagnostic.getSeverity() != Diagnostic.OK) {
+ for (Diagnostic childDiagnostic : diagnostic.getChildren()) {
+ markerHelper.createMarkers(resource, childDiagnostic);
+ }
+ }
+ }
+ }
}
/*
@@ -482,12 +501,12 @@
return false;
}
- public void validateEnd(Diagnostic diagnosticResult) {
- setDiagnostic(diagnosticResult);
+ public void validateEnd(List<Diagnostic> diagnosticResult) {
+ setDiagnosticList(diagnosticResult);
}
public void validateStart() {
-
+
}
}
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksStuffPropertyDetailPage.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksStuffPropertyDetailPage.java 2009-05-12 20:02:47 UTC (rev 15236)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksStuffPropertyDetailPage.java 2009-05-13 08:45:40 UTC (rev 15237)
@@ -45,8 +45,8 @@
import org.eclipse.ui.forms.widgets.Section;
import org.jboss.tools.smooks.configuration.editors.uitls.IModelProcsser;
import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
+import org.jboss.tools.smooks.configuration.validate.ISmooksModelValidateListener;
import org.jboss.tools.smooks.model.common.AbstractAnyType;
-import org.jboss.tools.smooks.model.validate.ISmooksModelValidateListener;
/**
*
@@ -146,20 +146,23 @@
detailsComposite.pack();
propertyMainComposite.layout();
- markPropertyUI(formEditor.getDiagnostic());
+ markPropertyUI(formEditor.getDiagnosticList());
} catch (Exception e) {
e.printStackTrace();
}
}
- protected void markPropertyUI(Diagnostic diagnostic) {
+ protected void markPropertyUI(List<Diagnostic> diagnosticList) {
for (Iterator<?> iterator = currentPropertyUIMap.values().iterator(); iterator.hasNext();) {
AttributeFieldEditPart editPart = (AttributeFieldEditPart) iterator.next();
if (editPart.getFieldMarker() != null) {
editPart.getFieldMarker().clean();
}
}
- markErrorWarningPropertyUI(diagnostic);
+ for (Iterator<?> iterator = diagnosticList.iterator(); iterator.hasNext();) {
+ Diagnostic diagnostic = (Diagnostic) iterator.next();
+ markErrorWarningPropertyUI(diagnostic);
+ }
}
protected void markErrorWarningPropertyUI(Diagnostic diagnostic) {
@@ -183,15 +186,20 @@
IFieldMarker marker = editPart.getFieldMarker();
if (marker == null)
return;
- marker.setMessage(diagnostic.getMessage());
+
if (diagnostic.getSeverity() == Diagnostic.ERROR) {
- if (marker.getMarkerType() != IFieldMarker.TYPE_ERROR)
+ if (marker.getMarkerType() != IFieldMarker.TYPE_ERROR) {
marker.setMarkerType(IFieldMarker.TYPE_ERROR);
+ marker.setMessage(diagnostic.getMessage());
+ }
}
-
if (diagnostic.getSeverity() == Diagnostic.WARNING) {
- if (marker.getMarkerType() != IFieldMarker.TYPE_WARINING)
+ // if there is error already , don't mark warning
+ if (marker.getMarkerType() != IFieldMarker.TYPE_WARINING
+ && marker.getMarkerType() != IFieldMarker.TYPE_ERROR) {
marker.setMarkerType(IFieldMarker.TYPE_WARINING);
+ marker.setMessage(diagnostic.getMessage());
+ }
}
}
}
@@ -469,7 +477,7 @@
this.isStale = isStale;
}
- public void validateEnd(Diagnostic diagnosticResult) {
+ public void validateEnd(List<Diagnostic> diagnosticResult) {
markPropertyUI(diagnosticResult);
}
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java 2009-05-12 20:02:47 UTC (rev 15236)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java 2009-05-13 08:45:40 UTC (rev 15237)
@@ -33,6 +33,7 @@
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
+import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
import org.eclipse.emf.edit.provider.ItemPropertyDescriptor.PropertyValueWrapper;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaElement;
@@ -78,6 +79,7 @@
import org.eclipse.ui.part.FileEditorInput;
import org.jboss.tools.smooks.configuration.SmooksConfigurationActivator;
import org.jboss.tools.smooks.configuration.actions.OpenEditorEditInnerContentsAction;
+import org.jboss.tools.smooks.configuration.command.UnSetFeatureCommand;
import org.jboss.tools.smooks.configuration.editors.AttributeFieldEditPart;
import org.jboss.tools.smooks.configuration.editors.ClassPathFileProcessor;
import org.jboss.tools.smooks.configuration.editors.CurrentProjecViewerFilter;
@@ -152,17 +154,17 @@
displayName = itemPropertyDescriptor.getDisplayName(model);
EAttribute feature = (EAttribute) itemPropertyDescriptor.getFeature(model);
if (feature.isRequired()) {
- displayName = displayName + "*";
+ displayName = displayName + "*";
}
}
Composite labelComposite = formToolKit.createComposite(parent);
-// GridLayout layout = new GridLayout();
-// layout.numColumns = 2;
-// layout.marginLeft = 0;
-// layout.marginRight = 0;
-// layout.horizontalSpacing = 0;
+ // GridLayout layout = new GridLayout();
+ // layout.numColumns = 2;
+ // layout.marginLeft = 0;
+ // layout.marginRight = 0;
+ // layout.horizontalSpacing = 0;
labelComposite.setLayout(new FillLayout());
-// GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ // GridData gd = new GridData(GridData.FILL_HORIZONTAL);
Control labelControl = null;
if (!isLink) {
@@ -173,19 +175,20 @@
Hyperlink link = formToolKit.createHyperlink(labelComposite, displayName + " :", SWT.NONE);
labelControl = link;
}
-// gd = new GridData();
-// labelControl.setLayoutData(gd);
+ // gd = new GridData();
+ // labelControl.setLayoutData(gd);
-// FieldMarkerComposite notificationComposite = new FieldMarkerComposite(labelComposite, SWT.NONE);
-// gd = new GridData();
-// gd.heightHint = 8;
-// gd.widthHint = 8;
-// gd.horizontalAlignment = GridData.BEGINNING;
-// gd.verticalAlignment = GridData.BEGINNING;
-// notificationComposite.setLayoutData(gd);
+ // FieldMarkerComposite notificationComposite = new
+ // FieldMarkerComposite(labelComposite, SWT.NONE);
+ // gd = new GridData();
+ // gd.heightHint = 8;
+ // gd.widthHint = 8;
+ // gd.horizontalAlignment = GridData.BEGINNING;
+ // gd.verticalAlignment = GridData.BEGINNING;
+ // notificationComposite.setLayoutData(gd);
wrapper.setLabelControl(labelControl);
-// wrapper.setMarker(notificationComposite);
+ // wrapper.setMarker(notificationComposite);
return wrapper;
}
@@ -436,7 +439,7 @@
layout.marginRight = 0;
layout.horizontalSpacing = 0;
tcom.setLayout(layout);
-
+
FieldMarkerComposite notificationComposite = new FieldMarkerComposite(tcom, SWT.NONE);
gd = new GridData();
gd.heightHint = 8;
@@ -445,16 +448,16 @@
gd.verticalAlignment = GridData.BEGINNING;
notificationComposite.setLayoutData(gd);
fieldEditPart.setFieldMarker(notificationComposite);
-
+
final Text valueText = toolkit.createText(tcom, "", textType);
gd = new GridData(GridData.FILL_HORIZONTAL);
if (multiText && height > 0) {
gd.heightHint = height;
}
valueText.setLayoutData(gd);
-
+
tcom.setLayoutData(gd);
-
+
toolkit.paintBordersFor(textContainer);
if (openFile) {
Button fileBrowseButton = toolkit.createButton(textContainer, "Browse", SWT.NONE);
@@ -480,7 +483,11 @@
});
}
- if (editValue != null) {
+ boolean valueIsSet = true;
+ if (model != null && model instanceof EObject && itemPropertyDescriptor != null) {
+ valueIsSet = ((EObject) model).eIsSet((EAttribute) itemPropertyDescriptor.getFeature(model));
+ }
+ if (editValue != null && valueIsSet) {
valueText.setText(editValue);
if (editValue.length() > 0 && section != null) {
section.setExpanded(true);
@@ -639,7 +646,7 @@
fillLayout.marginHeight = 0;
fillLayout.marginWidth = 0;
classTextComposite.setLayout(fillLayout);
-
+
Composite tcom = toolkit.createComposite(classTextComposite);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
@@ -647,7 +654,7 @@
layout.marginRight = 0;
layout.horizontalSpacing = 0;
tcom.setLayout(layout);
-
+
FieldMarkerComposite notificationComposite = new FieldMarkerComposite(tcom, SWT.NONE);
gd = new GridData();
gd.heightHint = 8;
@@ -656,10 +663,9 @@
gd.verticalAlignment = GridData.BEGINNING;
notificationComposite.setLayoutData(gd);
editpart.setFieldMarker(notificationComposite);
-
-
- final SearchComposite searchComposite = new SearchComposite(tcom, toolkit,
- "Search Class", dialog, SWT.NONE);
+
+ final SearchComposite searchComposite = new SearchComposite(tcom, toolkit, "Search Class", dialog,
+ SWT.NONE);
gd = new GridData(GridData.FILL_HORIZONTAL);
searchComposite.setLayoutData(gd);
Object editValue = getEditValue(propertyDescriptor, model);
@@ -886,7 +892,7 @@
if (readOnly) {
style = style | SWT.READ_ONLY;
}
-
+
Composite tcom = formToolkit.createComposite(parent);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
@@ -894,7 +900,7 @@
layout.marginRight = 0;
layout.horizontalSpacing = 0;
tcom.setLayout(layout);
-
+
FieldMarkerComposite notificationComposite = new FieldMarkerComposite(tcom, SWT.NONE);
GridData gd = new GridData();
gd.heightHint = 8;
@@ -903,13 +909,17 @@
gd.verticalAlignment = GridData.BEGINNING;
notificationComposite.setLayoutData(gd);
fieldEditPart.setFieldMarker(notificationComposite);
-
+
final Combo combo = new Combo(tcom, style);
+ boolean valueIsSet = false;
+ if (model instanceof EObject) {
+ valueIsSet = ((EObject) model).eIsSet((EAttribute) itemPropertyDescriptor.getFeature(model));
+ }
combo.add("");
if (items != null) {
for (int i = 0; i < items.length; i++) {
combo.add(items[i]);
- if (items[i].equals(editValue)) {
+ if (valueIsSet && items[i].equals(editValue)) {
currentSelect = i + 1;
}
}
@@ -917,25 +927,27 @@
gd = new GridData(GridData.FILL_HORIZONTAL);
tcom.setLayoutData(gd);
combo.setLayoutData(gd);
-
+
if (currentSelect != -1) {
combo.select(currentSelect);
}
final Object fm = model;
- final IItemPropertyDescriptor fipd = itemPropertyDescriptor;
+ final ItemPropertyDescriptor fipd = (ItemPropertyDescriptor) itemPropertyDescriptor;
final IModelProcsser fp = processer;
combo.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
String text = combo.getText();
if (text == null || text.length() == 0) {
- fipd.setPropertyValue(fm, null);
+ UnSetFeatureCommand command = new UnSetFeatureCommand(fipd, fm);
+ EditingDomain domain = fipd.getEditingDomain(fm);
+ domain.getCommandStack().execute(command);
return;
}
Object setValue = text;
if (fp != null) {
setValue = fp.wrapValue(text);
}
- if (setValue.equals(getEditValue(fipd, fm))) {
+ if (((EObject) fm).eIsSet((EAttribute) fipd.getFeature(fm)) && setValue.equals(getEditValue(fipd, fm))) {
return;
}
fipd.setPropertyValue(fm, setValue);
@@ -994,7 +1006,7 @@
fillLayout.marginHeight = 0;
fillLayout.marginWidth = 0;
classTextComposite.setLayout(fillLayout);
-
+
Composite tcom = toolkit.createComposite(classTextComposite);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
@@ -1002,7 +1014,7 @@
layout.marginRight = 0;
layout.horizontalSpacing = 0;
tcom.setLayout(layout);
-
+
FieldMarkerComposite notificationComposite = new FieldMarkerComposite(tcom, SWT.NONE);
gd = new GridData();
gd.heightHint = 8;
@@ -1011,12 +1023,11 @@
gd.verticalAlignment = GridData.BEGINNING;
notificationComposite.setLayoutData(gd);
editpart.setFieldMarker(notificationComposite);
-
- final SearchComposite searchComposite = new SearchComposite(tcom, toolkit, buttonName, dialog,
- SWT.NONE);
+
+ final SearchComposite searchComposite = new SearchComposite(tcom, toolkit, buttonName, dialog, SWT.NONE);
gd = new GridData(GridData.FILL_HORIZONTAL);
searchComposite.setLayoutData(gd);
-
+
Object editValue = getEditValue(propertyDescriptor, model);
if (editValue != null) {
searchComposite.getText().setText(editValue.toString());
@@ -1038,8 +1049,7 @@
}
}
});
-
-
+
toolkit.paintBordersFor(classTextComposite);
editpart.setContentControl(classTextComposite);
return editpart;
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/validate/ClassFieldEditorValidator.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/validate/ClassFieldEditorValidator.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/validate/ClassFieldEditorValidator.java 2009-05-13 08:45:40 UTC (rev 15237)
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.configuration.validate;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.emf.common.util.BasicDiagnostic;
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.jboss.tools.smooks.configuration.editors.uitls.ProjectClassLoader;
+import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
+import org.jboss.tools.smooks.model.javabean.BindingsType;
+import org.jboss.tools.smooks.model.javabean.JavabeanPackage;
+
+/**
+ * @author Dart (dpeng(a)redhat.com)
+ *
+ */
+public class ClassFieldEditorValidator implements ISmooksValidator {
+
+ private ProjectClassLoader classLoader;
+
+ /**
+ * @return the classLoader
+ */
+ public ProjectClassLoader getClassLoader(EObject obj) {
+ if (classLoader != null) {
+ return classLoader;
+ }
+ IResource resource = SmooksUIUtils.getResource(obj);
+ try {
+ classLoader = new ProjectClassLoader(JavaCore.create(resource.getProject()));
+ } catch (JavaModelException e) {
+ e.printStackTrace();
+ }
+ return classLoader;
+ }
+
+ public List<Diagnostic> validate(Collection<?> selectionObjects) {
+ List<Diagnostic> list = new ArrayList<Diagnostic>();
+ for (Iterator<?> iterator = selectionObjects.iterator(); iterator.hasNext();) {
+ Object object = (Object) iterator.next();
+ if (object instanceof BindingsType) {
+ BindingsType bindings = (BindingsType) object;
+ classLoader = getClassLoader(bindings);
+ String clazz = bindings.getClass_();
+ Class<?> clazz1 = null;
+ if (clazz != null && classLoader != null) {
+ try {
+ clazz1 = classLoader.loadClass(clazz);
+ } catch (ClassNotFoundException e) {
+ // ignore
+ }
+ }
+ String message = "Can't find class : \"" + clazz + "\"";
+ if (clazz1 == null) {
+ list.add(new BasicDiagnostic(Diagnostic.WARNING, "org.jboss.tools", 0, message, new Object[] {
+ bindings, JavabeanPackage.Literals.BINDINGS_TYPE__CLASS }));
+ }
+ }
+
+ if (object instanceof EObject) {
+ List<Diagnostic> dd = validate(((EObject) object).eContents());
+ if (dd != null) {
+ list.addAll(dd);
+ }
+ }
+ }
+ return list;
+ }
+
+ public List<Diagnostic> validate(Collection<?> selectedObjects, EditingDomain editingDomain) {
+ return validate(selectedObjects);
+ }
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/validate/ClassFieldEditorValidator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/validate/ISmooksModelValidateListener.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/validate/ISmooksModelValidateListener.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/validate/ISmooksModelValidateListener.java 2009-05-13 08:45:40 UTC (rev 15237)
@@ -0,0 +1,10 @@
+package org.jboss.tools.smooks.configuration.validate;
+
+import java.util.List;
+
+import org.eclipse.emf.common.util.Diagnostic;
+
+public interface ISmooksModelValidateListener {
+ void validateStart();
+ void validateEnd(List<Diagnostic> diagnosticResult);
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/validate/ISmooksModelValidateListener.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/validate/ISmooksValidator.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/validate/ISmooksValidator.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/validate/ISmooksValidator.java 2009-05-13 08:45:40 UTC (rev 15237)
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.configuration.validate;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.edit.domain.EditingDomain;
+
+/**
+ * @author Dart (dpeng(a)redhat.com)
+ *
+ */
+public interface ISmooksValidator {
+ public List<Diagnostic> validate(Collection<?> selectedObjects, EditingDomain editingDomain);
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/validate/ISmooksValidator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/validate/SmooksMarkerHelper.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/validate/SmooksMarkerHelper.java 2009-05-12 20:02:47 UTC (rev 15236)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/validate/SmooksMarkerHelper.java 2009-05-13 08:45:40 UTC (rev 15237)
@@ -31,13 +31,15 @@
*/
public class SmooksMarkerHelper extends EditUIMarkerHelper {
+ public static final String MARKER_ID = "org.jboss.tools.smooks.ui.problem";
+
public IRunnableWithProgress getWorkspaceModifyOperation(IRunnableWithProgress runnableWithProgress) {
return new WorkspaceModifyDelegatingOperation(runnableWithProgress);
}
@Override
protected String getMarkerID() {
- return EValidator.MARKER;
+ return MARKER_ID;
}
public void createMarkers(Resource resource, Diagnostic diagnostic) {
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/validate/SmooksModelValidator.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/validate/SmooksModelValidator.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/validate/SmooksModelValidator.java 2009-05-13 08:45:40 UTC (rev 15237)
@@ -0,0 +1,195 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.configuration.validate;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.common.util.BasicDiagnostic;
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.common.util.DiagnosticChain;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.Diagnostician;
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.edit.provider.IItemLabelProvider;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * @author Dart (dpeng(a)redhat.com)
+ * <p>
+ * Apr 14, 2009
+ */
+public class SmooksModelValidator implements ISmooksValidator{
+
+ Collection<?> selectedObjects;
+ EditingDomain domain;
+ private boolean starting = false;
+ private boolean waiting = false;
+ private Object lock = new Object();
+
+ private long watingTime = 300;
+
+ private List<ISmooksModelValidateListener> listeners = new ArrayList<ISmooksModelValidateListener>();
+
+ private List<ISmooksValidator> validatorList = new ArrayList<ISmooksValidator>();
+
+ public SmooksModelValidator(Collection<?> selectedObjects, EditingDomain domain) {
+ this();
+ this.selectedObjects = selectedObjects;
+ this.domain = domain;
+ }
+
+ public SmooksModelValidator() {
+ validatorList.add(new ClassFieldEditorValidator());
+ }
+
+ public void addValidateListener(ISmooksModelValidateListener l) {
+ if (!listeners.contains(l))
+ listeners.add(l);
+ }
+
+ public void removeValidateListener(ISmooksModelValidateListener l) {
+ listeners.remove(l);
+ }
+
+ public List<Diagnostic> validate(Collection<?> selectedObjects, EditingDomain editingDomain) {
+ this.selectedObjects = selectedObjects;
+ domain = editingDomain;
+ return validate(new NullProgressMonitor());
+ }
+
+ public List<Diagnostic> validate(final IProgressMonitor progressMonitor) {
+ EObject eObject = (EObject) selectedObjects.iterator().next();
+ int count = 0;
+ for (Iterator<?> i = eObject.eAllContents(); i.hasNext(); i.next()) {
+ ++count;
+ }
+
+ progressMonitor.beginTask("", count);
+
+ final AdapterFactory adapterFactory = domain instanceof AdapterFactoryEditingDomain ? ((AdapterFactoryEditingDomain) domain)
+ .getAdapterFactory()
+ : null;
+
+ Diagnostician diagnostician = new Diagnostician() {
+ @Override
+ public String getObjectLabel(EObject eObject) {
+ if (adapterFactory != null && !eObject.eIsProxy()) {
+ IItemLabelProvider itemLabelProvider = (IItemLabelProvider) adapterFactory.adapt(eObject,
+ IItemLabelProvider.class);
+ if (itemLabelProvider != null) {
+ return itemLabelProvider.getText(eObject);
+ }
+ }
+
+ return super.getObjectLabel(eObject);
+ }
+
+ @Override
+ public boolean validate(EClass eClass, EObject eObject, DiagnosticChain diagnostics,
+ Map<Object, Object> context) {
+ progressMonitor.worked(1);
+ return super.validate(eClass, eObject, diagnostics, context);
+ }
+ };
+
+ progressMonitor.setTaskName("Validating...");
+
+ Diagnostic diagnostic = diagnostician.validate(eObject);
+
+ List<Diagnostic> list = new ArrayList<Diagnostic>();
+ list.add(diagnostic);
+ for (Iterator<?> iterator = this.validatorList.iterator(); iterator.hasNext();) {
+ ISmooksValidator validator = (ISmooksValidator) iterator.next();
+ List<Diagnostic> d = validator.validate(selectedObjects, domain);
+ for (Iterator<?> iterator2 = d.iterator(); iterator2.hasNext();) {
+ Diagnostic diagnostic2 = (Diagnostic) iterator2.next();
+ ((BasicDiagnostic)diagnostic).add(diagnostic2);
+ }
+ }
+ return list;
+ }
+
+ public void startValidate(final Collection<?> selectedObjects, final EditingDomain editingDomain) {
+ if (starting) {
+ synchronized (lock) {
+ waiting = true;
+ }
+ return;
+ }
+ Thread thread = new Thread() {
+ public void run() {
+ synchronized (lock) {
+ starting = true;
+ waiting = true;
+ }
+ while (waiting) {
+ try {
+ waiting = false;
+ Thread.sleep(watingTime);
+ Thread.yield();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ try {
+ for (Iterator<?> iterator = listeners.iterator(); iterator.hasNext();) {
+ final ISmooksModelValidateListener l = (ISmooksModelValidateListener) iterator.next();
+ Display.getDefault().syncExec(new Runnable() {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Runnable#run()
+ */
+ public void run() {
+ l.validateStart();
+ }
+
+ });
+
+ }
+
+ final List<Diagnostic> d = validate(selectedObjects, editingDomain);
+
+ for (Iterator<?> iterator = listeners.iterator(); iterator.hasNext();) {
+ final ISmooksModelValidateListener l = (ISmooksModelValidateListener) iterator.next();
+ Display.getDefault().syncExec(new Runnable() {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Runnable#run()
+ */
+ public void run() {
+ l.validateEnd(d);
+ }
+
+ });
+ }
+ } finally {
+ waiting = false;
+ starting = false;
+ }
+ }
+ };
+ thread.setName("Validate Smooks model");
+ thread.start();
+ }
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/validate/SmooksModelValidator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/validate/ValidateResultLabelDecorator.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/validate/ValidateResultLabelDecorator.java 2009-05-12 20:02:47 UTC (rev 15236)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/validate/ValidateResultLabelDecorator.java 2009-05-13 08:45:40 UTC (rev 15237)
@@ -144,7 +144,8 @@
}
SmooksMultiFormEditor editor = (SmooksMultiFormEditor) window.getActivePage().findEditor(
new FileEditorInput((IFile) resource));
- int type = markErrorWarningPropertyUI(editor.getDiagnostic(), element);
+ int type = -1;
+// int type = markErrorWarningPropertyUI(editor.getDiagnosticList(), element);
decoration.addOverlay(null, IDecoration.BOTTOM_RIGHT);
if (type == Diagnostic.ERROR) {
decoration.addOverlay(SmooksConfigurationActivator.getDefault().getImageRegistry().getDescriptor(
15 years, 6 months