[289256] JSPTranslator should wrap JSP expressions with parentheses
[289659] Misbehaviour of Disabling "Automatically publish when starting servers"
[289638] StructuredTextEditor validates file buffer changes to documents
diff --git a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/JSPTranslator.java b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/JSPTranslator.java
index cd9bdee..1ae3f32 100644
--- a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/JSPTranslator.java
+++ b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/JSPTranslator.java
@@ -130,7 +130,7 @@
private String fSessionVariableDeclaration = "javax.servlet.http.HttpSession session = null;" + ENDL; //$NON-NLS-1$
private String fFooter = "}}"; //$NON-NLS-1$
private String fException = "Throwable exception = null;"; //$NON-NLS-1$
- public static final String EXPRESSION_PREFIX = "out.print(\"\"+"; //$NON-NLS-1$
+ public static final String EXPRESSION_PREFIX = "out.print("; //$NON-NLS-1$
public static final String EXPRESSION_SUFFIX = ");"; //$NON-NLS-1$
private String fSuperclass = "javax.servlet.http.HttpServlet"; //$NON-NLS-1$
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextEditor.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextEditor.java
index 9c5a865..fca4bd0 100644
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextEditor.java
+++ b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextEditor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
+ * Copyright (c) 2001, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -42,9 +42,7 @@
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.DefaultInformationControl;
-import org.eclipse.jface.text.DocumentEvent;
import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentListener;
import org.eclipse.jface.text.IInformationControl;
import org.eclipse.jface.text.IInformationControlCreator;
import org.eclipse.jface.text.IRegion;
@@ -200,66 +198,6 @@
public class StructuredTextEditor extends TextEditor {
-
- // ISSUE: This use case is not clear to me.
- // Is this listner and dance with dirty state for non-editor driven
- // updates?
- class InternalDocumentListener implements IDocumentListener {
- // This is for the IDocumentListener interface
- public void documentAboutToBeChanged(DocumentEvent event) {
- fDirtyBeforeDocumentEvent = isDirty();
- }
-
- // This is for the IDocumentListener interface
- public void documentChanged(DocumentEvent event) {
- if (isEditorInputReadOnly()) {
- // stop listening to document event
- // caused by the undo after validateEdit
- final int offset = event.getOffset() + event.getLength();
- final IStructuredModel internalModel = getInternalModel();
- fCurrentRunnable = new Runnable() {
- public void run() {
- if (!fEditorDisposed) {
- boolean status = validateEditorInputState();
- if (!status) {
- if (internalModel != null) {
- internalModel.getUndoManager().undo();
- getSourceViewer().setSelectedRange(offset, 0);
- if (!fDirtyBeforeDocumentEvent) {
- // reset dirty state if
- // model not dirty before
- // document event
- internalModel.setDirtyState(false);
- }
- }
- }
- }
- fCurrentRunnable = null;
- }
- };
- /*
- * We need to ensure that this is run via 'asyncExec' since
- * these notifications can come from a non-ui thread.
- *
- * The non-ui thread call would occur when creating a new file
- * under ClearCase (or other library) control. The creation of
- * the new file would trigger a validateEdit call, on another
- * thread, that would prompt the user to add the new file to
- * version control.
- */
- Display display = getDisplay();
- if (display != null) {
- if (Thread.currentThread() != display.getThread())
- // future_TODO: there's probably a better
- // way than relying on asycnExec
- display.asyncExec(fCurrentRunnable);
- else
- fCurrentRunnable.run();
- }
- }
- }
- }
-
private class InternalModelStateListener implements IModelStateListener {
public void modelAboutToBeChanged(IStructuredModel model) {
if (getTextViewer() != null) {
@@ -1297,7 +1235,6 @@
private DropTarget fDropTarget;
boolean fEditorDisposed = false;
private IEditorPart fEditorPart;
- private IDocumentListener fInternalDocumentListener;
private InternalModelStateListener fInternalModelStateListener;
private MouseTracker fMouseTracker;
private IContentOutlinePage fOutlinePage;
@@ -2004,9 +1941,6 @@
// but makes a memory leak
// less severe.
if (fStructuredModel != null) {
- if (fStructuredModel.getStructuredDocument() != null) {
- fStructuredModel.getStructuredDocument().removeDocumentListener(getInternalDocumentListener());
- }
fStructuredModel.removeModelStateListener(getInternalModelStateListener());
}
@@ -2015,7 +1949,6 @@
if (getDocumentProvider() != null) {
IDocument doc = getDocumentProvider().getDocument(getEditorInput());
if (doc != null) {
- doc.removeDocumentListener(getInternalDocumentListener());
if (doc instanceof IExecutionDelegatable) {
((IExecutionDelegatable) doc).setExecutionDelegate(null);
}
@@ -2393,13 +2326,6 @@
return fEditorPart;
}
- private IDocumentListener getInternalDocumentListener() {
- if (fInternalDocumentListener == null) {
- fInternalDocumentListener = new InternalDocumentListener();
- }
- return fInternalDocumentListener;
- }
-
IStructuredModel getInternalModel() {
return fStructuredModel;
}
@@ -2946,16 +2872,10 @@
private void setModel(IStructuredModel newModel) {
Assert.isNotNull(getDocumentProvider(), "document provider can not be null when setting model"); //$NON-NLS-1$
if (fStructuredModel != null) {
- if (fStructuredModel.getStructuredDocument() != null) {
- fStructuredModel.getStructuredDocument().removeDocumentListener(getInternalDocumentListener());
- }
fStructuredModel.removeModelStateListener(getInternalModelStateListener());
}
fStructuredModel = newModel;
if (fStructuredModel != null) {
- if (fStructuredModel.getStructuredDocument() != null) {
- fStructuredModel.getStructuredDocument().addDocumentListener(getInternalDocumentListener());
- }
fStructuredModel.addModelStateListener(getInternalModelStateListener());
}
// update() should be called whenever the model is
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/extension/DropActionProxy.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/extension/DropActionProxy.java
index 0eebf4e..6637ec5 100644
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/extension/DropActionProxy.java
+++ b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/extension/DropActionProxy.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
+ * Copyright (c) 2001, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -22,6 +22,8 @@
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.text.IDocument;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.ui.texteditor.ITextEditorExtension2;
import org.eclipse.wst.sse.core.StructuredModelManager;
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
import org.eclipse.wst.sse.core.internal.undo.IStructuredTextUndoManager;
@@ -122,17 +124,8 @@
editor = (IExtendedSimpleEditor) args[1];
}
beginRecording();
- if ((editor != null) && !(obj instanceof ISelfValidateEditAction)) {
-
- // TODO: cleanup validateEdit
- // just leaving this check and following code here for transition.
- // I assume we'll remove all need for 'validateEdit'
- // or move to platform editor's validateState
-
-// IStatus status = editor.validateEdit(getDisplay().getActiveShell());
-// if (!status.isOK()) {
-// return null;
-// }
+ if ((args[1] instanceof ITextEditor) && !(obj instanceof ISelfValidateEditAction) && !isEditable((ITextEditor) args[1])) {
+ return Boolean.FALSE;
}
}
result = m.invoke(obj, args);
@@ -147,4 +140,10 @@
}
return result;
}
+
+ private boolean isEditable(ITextEditor editor) {
+ if (editor instanceof ITextEditorExtension2)
+ return ((ITextEditorExtension2) editor).validateEditorInputState();
+ return editor.isEditable();
+ }
}
diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/TreeContentHelper.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/TreeContentHelper.java
index 3db3af2..5a670d6 100644
--- a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/TreeContentHelper.java
+++ b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/TreeContentHelper.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
+ * Copyright (c) 2004, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -17,8 +17,13 @@
import java.util.List;
import java.util.Vector;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Path;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
import org.eclipse.wst.xml.core.internal.contentmodel.util.DOMWriter;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
@@ -258,10 +263,25 @@
return result;
}
+ private boolean validateEdit(IStructuredModel model, Shell context) {
+ if (model != null && model.getBaseLocation() != null) {
+ IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(model.getBaseLocation()));
+ if (!file.isAccessible())
+ return true;
+ return ResourcesPlugin.getWorkspace().validateEdit(new IFile[] {file}, context).isOK();
+ }
+ return false;
+ }
+
+ public void setNodeValue(Node node, String value) {
+ setNodeValue(node, value, null);
+ }
/**
*
*/
- public void setNodeValue(Node node, String value) {
+ public void setNodeValue(Node node, String value, Shell context) {
+ if (node instanceof IDOMNode && !validateEdit(((IDOMNode) node).getModel(), context))
+ return;
int nodeType = node.getNodeType();
try {
switch (nodeType) {
diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTreeExtension.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTreeExtension.java
index 2775fae..a4fb68a 100644
--- a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTreeExtension.java
+++ b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTreeExtension.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2004 IBM Corporation and others. All rights reserved. This
+ * Copyright (c) 2004, 2009 IBM Corporation and others. All rights reserved. This
* program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and
* is available at http://www.eclipse.org/legal/epl-v10.html
@@ -154,7 +154,7 @@
String oldValue = treeContentHelper.getNodeValue((Node) item.getData());
String newValue = value.toString();
if (newValue != null && !newValue.equals(oldValue)) {
- treeContentHelper.setNodeValue((Node) item.getData(), value.toString());
+ treeContentHelper.setNodeValue((Node) item.getData(), value.toString(), (control != null) ? control.getShell() : null);
}
// enableNodeSelectionListener(true);
}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/AbstractNodeActionManager.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/AbstractNodeActionManager.java
index 10bb371..c7b2efb 100644
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/AbstractNodeActionManager.java
+++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/AbstractNodeActionManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
+ * Copyright (c) 2001, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -157,13 +157,16 @@
public void run() {
- beginNodeAction(this);
- if (cmnode != null) {
- addNodeForCMNode();
- } else {
- addNodeForNodeType();
+ if (validateEdit(getModel(), getWorkbenchWindowShell())) {
+ beginNodeAction(this);
+ if (cmnode != null) {
+ addNodeForCMNode();
+ }
+ else {
+ addNodeForNodeType();
+ }
+ endNodeAction(this);
}
- endNodeAction(this);
}
}
@@ -190,26 +193,28 @@
}
public void run() {
- beginNodeAction(this);
-
- for (Iterator i = list.iterator(); i.hasNext();) {
- Node node = (Node) i.next();
- if (node.getNodeType() == Node.ATTRIBUTE_NODE) {
- Attr attr = (Attr) node;
- attr.getOwnerElement().removeAttributeNode(attr);
- } else {
- Node parent = node.getParentNode();
- if (parent != null) {
- Node previousSibling = node.getPreviousSibling();
- if (previousSibling != null && isWhitespaceTextNode(previousSibling)) {
- parent.removeChild(previousSibling);
+ if (validateEdit(getModel(), getWorkbenchWindowShell())) {
+ beginNodeAction(this);
+
+ for (Iterator i = list.iterator(); i.hasNext();) {
+ Node node = (Node) i.next();
+ if (node.getNodeType() == Node.ATTRIBUTE_NODE) {
+ Attr attr = (Attr) node;
+ attr.getOwnerElement().removeAttributeNode(attr);
+ } else {
+ Node parent = node.getParentNode();
+ if (parent != null) {
+ Node previousSibling = node.getPreviousSibling();
+ if (previousSibling != null && isWhitespaceTextNode(previousSibling)) {
+ parent.removeChild(previousSibling);
+ }
+ parent.removeChild(node);
}
- parent.removeChild(node);
}
}
+
+ endNodeAction(this);
}
-
- endNodeAction(this);
}
}
@@ -328,38 +333,40 @@
}
public void run() {
- beginNodeAction(this);
-
- Document document = parent.getNodeType() == Node.DOCUMENT_NODE ? (Document) parent : parent.getOwnerDocument();
- Node newChildNode = null;
- boolean format = true;
- switch (nodeType) {
- case Node.COMMENT_NODE : {
- newChildNode = document.createComment(XMLUIMessages._UI_COMMENT_VALUE); //$NON-NLS-1$
- break;
+ if (validateEdit(getModel(), getWorkbenchWindowShell())) {
+ beginNodeAction(this);
+
+ Document document = parent.getNodeType() == Node.DOCUMENT_NODE ? (Document) parent : parent.getOwnerDocument();
+ Node newChildNode = null;
+ boolean format = true;
+ switch (nodeType) {
+ case Node.COMMENT_NODE : {
+ newChildNode = document.createComment(XMLUIMessages._UI_COMMENT_VALUE); //$NON-NLS-1$
+ break;
+ }
+ case Node.PROCESSING_INSTRUCTION_NODE : {
+ newChildNode = document.createProcessingInstruction(XMLUIMessages._UI_PI_TARGET_VALUE, XMLUIMessages._UI_PI_DATA_VALUE); //$NON-NLS-1$ //$NON-NLS-2$
+ break;
+ }
+ case Node.CDATA_SECTION_NODE : {
+ newChildNode = document.createCDATASection(""); //$NON-NLS-1$
+ break;
+ }
+ case Node.TEXT_NODE : {
+ format = false;
+ newChildNode = document.createTextNode(parent.getNodeName());
+ break;
+ }
}
- case Node.PROCESSING_INSTRUCTION_NODE : {
- newChildNode = document.createProcessingInstruction(XMLUIMessages._UI_PI_TARGET_VALUE, XMLUIMessages._UI_PI_DATA_VALUE); //$NON-NLS-1$ //$NON-NLS-2$
- break;
+
+ if (newChildNode != null) {
+ List list = new Vector(1);
+ list.add(newChildNode);
+ insertNodesAtIndex(parent, list, index, format);
}
- case Node.CDATA_SECTION_NODE : {
- newChildNode = document.createCDATASection(""); //$NON-NLS-1$
- break;
- }
- case Node.TEXT_NODE : {
- format = false;
- newChildNode = document.createTextNode(parent.getNodeName());
- break;
- }
+
+ endNodeAction(this);
}
-
- if (newChildNode != null) {
- List list = new Vector(1);
- list.add(newChildNode);
- insertNodesAtIndex(parent, list, index, format);
- }
-
- endNodeAction(this);
}
}
@@ -392,13 +399,15 @@
}
public void run() {
- beginNodeAction(this);
-
- if (parent != null && cmnode != null) {
- remove(parent, startIndex, endIndex);
- insert(parent, cmnode, startIndex);
+ if (validateEdit(getModel(), getWorkbenchWindowShell())) {
+ beginNodeAction(this);
+
+ if (parent != null && cmnode != null) {
+ remove(parent, startIndex, endIndex);
+ insert(parent, cmnode, startIndex);
+ }
+ endNodeAction(this);
}
- endNodeAction(this);
}
}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditAttributeAction.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditAttributeAction.java
index 5e3a984..329b988 100644
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditAttributeAction.java
+++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditAttributeAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
+ * Copyright (c) 2001, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -56,25 +56,27 @@
}
public void run() {
- manager.beginNodeAction(this);
Shell shell = XMLUIPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow().getShell();
- EditAttributeDialog dialog = new EditAttributeDialog(shell, ownerElement, attr);
- dialog.create();
- dialog.getShell().setText(title);
- dialog.setBlockOnOpen(true);
- dialog.open();
-
- if (dialog.getReturnCode() == Window.OK) {
- if (attr != null) {
- ownerElement.removeAttributeNode(attr);
+ if (validateEdit(manager.getModel(), shell)) {
+ manager.beginNodeAction(this);
+ EditAttributeDialog dialog = new EditAttributeDialog(shell, ownerElement, attr);
+ dialog.create();
+ dialog.getShell().setText(title);
+ dialog.setBlockOnOpen(true);
+ dialog.open();
+
+ if (dialog.getReturnCode() == Window.OK) {
+ if (attr != null) {
+ ownerElement.removeAttributeNode(attr);
+ }
+ Document document = ownerElement.getOwnerDocument();
+ Attr newAttribute = document.createAttribute(dialog.getAttributeName());
+ newAttribute.setValue(dialog.getAttributeValue());
+ ownerElement.setAttributeNode(newAttribute);
+ manager.setViewerSelection(newAttribute);
}
- Document document = ownerElement.getOwnerDocument();
- Attr newAttribute = document.createAttribute(dialog.getAttributeName());
- newAttribute.setValue(dialog.getAttributeValue());
- ownerElement.setAttributeNode(newAttribute);
- manager.setViewerSelection(newAttribute);
+ manager.endNodeAction(this);
}
- manager.endNodeAction(this);
}
}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditDoctypeAction.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditDoctypeAction.java
index 0a7c2bf..f6690e1 100644
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditDoctypeAction.java
+++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditDoctypeAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
+ * Copyright (c) 2001, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,7 +13,6 @@
package org.eclipse.wst.xml.ui.internal.actions;
import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.action.Action;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
@@ -33,7 +32,7 @@
/**
* EditDoctypeAction
*/
-public class EditDoctypeAction extends Action {
+public class EditDoctypeAction extends NodeAction {
protected DocumentType doctype;
protected Document document;
protected IStructuredModel model;
@@ -119,23 +118,26 @@
}
public void run() {
- model.beginRecording(this, getUndoDescription());
- //Shell shell =
- // XMLCommonUIPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow().getShell();
Shell shell = getDisplay().getActiveShell();
- EditDoctypeDialog dialog = showEditDoctypeDialog(shell);
-
- if (dialog.getReturnCode() == Window.OK) {
- if (doctype != null) {
- updateDoctype(dialog, doctype);
- } else if (document != null) {
- DocumentType doctype = createDoctype(dialog, document);
+ if (validateEdit(model, shell)) {
+ model.beginRecording(this, getUndoDescription());
+ //Shell shell =
+ // XMLCommonUIPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow().getShell();
+
+ EditDoctypeDialog dialog = showEditDoctypeDialog(shell);
+
+ if (dialog.getReturnCode() == Window.OK) {
if (doctype != null) {
- insertDoctype(doctype, document);
+ updateDoctype(dialog, doctype);
+ } else if (document != null) {
+ DocumentType doctype = createDoctype(dialog, document);
+ if (doctype != null) {
+ insertDoctype(doctype, document);
+ }
}
}
+ model.endRecording(this);
}
- model.endRecording(this);
}
protected EditDoctypeDialog showEditDoctypeDialog(Shell shell) {
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditElementAction.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditElementAction.java
index 9084fa9..546c094 100644
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditElementAction.java
+++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditElementAction.java
@@ -69,38 +69,40 @@
}
public void run() {
- manager.beginNodeAction(this);
Shell shell = XMLUIPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow().getShell();
- EditElementDialog dialog = new EditElementDialog(shell, element);
- dialog.create();
- dialog.getShell().setText(title);
- dialog.setBlockOnOpen(true);
- dialog.open();
-
- if (dialog.getReturnCode() == Window.OK) {
- Document document = parent.getNodeType() == Node.DOCUMENT_NODE ? (Document) parent : parent.getOwnerDocument();
- if (element != null) {
- // here we need to do a rename... which seems to be quite hard
- // to do :-(
- if (element instanceof IDOMElement) {
- IDOMElement elementImpl = (IDOMElement) element;
- IDOMModel model = elementImpl.getModel();
- String oldName = elementImpl.getNodeName();
- String newName = dialog.getElementName();
- setStructuredDocumentRegionElementName(model, elementImpl.getStartStructuredDocumentRegion(), oldName, newName);
- setStructuredDocumentRegionElementName(model, elementImpl.getEndStructuredDocumentRegion(), oldName, newName);
+ if (validateEdit(manager.getModel(), shell)) {
+ manager.beginNodeAction(this);
+ EditElementDialog dialog = new EditElementDialog(shell, element);
+ dialog.create();
+ dialog.getShell().setText(title);
+ dialog.setBlockOnOpen(true);
+ dialog.open();
+
+ if (dialog.getReturnCode() == Window.OK) {
+ Document document = parent.getNodeType() == Node.DOCUMENT_NODE ? (Document) parent : parent.getOwnerDocument();
+ if (element != null) {
+ // here we need to do a rename... which seems to be quite hard
+ // to do :-(
+ if (element instanceof IDOMElement) {
+ IDOMElement elementImpl = (IDOMElement) element;
+ IDOMModel model = elementImpl.getModel();
+ String oldName = elementImpl.getNodeName();
+ String newName = dialog.getElementName();
+ setStructuredDocumentRegionElementName(model, elementImpl.getStartStructuredDocumentRegion(), oldName, newName);
+ setStructuredDocumentRegionElementName(model, elementImpl.getEndStructuredDocumentRegion(), oldName, newName);
+ }
+ } else {
+ Element newElement = document.createElement(dialog.getElementName());
+ NodeList nodeList = parent.getChildNodes();
+ int nodeListLength = nodeList.getLength();
+ Node refChild = insertionIndex < nodeListLength && insertionIndex >= 0 ? nodeList.item(insertionIndex) : null;
+ parent.insertBefore(newElement, refChild);
+ manager.reformat(newElement, false);
+ manager.setViewerSelection(newElement);
}
- } else {
- Element newElement = document.createElement(dialog.getElementName());
- NodeList nodeList = parent.getChildNodes();
- int nodeListLength = nodeList.getLength();
- Node refChild = insertionIndex < nodeListLength && insertionIndex >= 0 ? nodeList.item(insertionIndex) : null;
- parent.insertBefore(newElement, refChild);
- manager.reformat(newElement, false);
- manager.setViewerSelection(newElement);
}
+ manager.endNodeAction(this);
}
- manager.endNodeAction(this);
}
protected void setStructuredDocumentRegionElementName(IDOMModel model, IStructuredDocumentRegion flatNode, String oldName, String newName) {
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditProcessingInstructionAction.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditProcessingInstructionAction.java
index cf1cc1d..8e34e2d 100644
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditProcessingInstructionAction.java
+++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditProcessingInstructionAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
+ * Copyright (c) 2001, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -58,37 +58,39 @@
}
public void run() {
- manager.beginNodeAction(this);
Shell shell = XMLUIPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow().getShell();
-
- EditProcessingInstructionDialog dialog = null;
- if (pi != null) {
- dialog = new EditProcessingInstructionDialog(shell, pi);
- } else {
- dialog = new EditProcessingInstructionDialog(shell, XMLUIMessages._UI_PI_TARGET_VALUE, XMLUIMessages._UI_PI_DATA_VALUE); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- dialog.create();
- dialog.getShell().setText(title);
- dialog.setBlockOnOpen(true);
- dialog.open();
-
- if (dialog.getReturnCode() == Window.OK) {
+ if (validateEdit(manager.getModel(), shell)) {
+ manager.beginNodeAction(this);
+
+ EditProcessingInstructionDialog dialog = null;
if (pi != null) {
- childRef = pi;
+ dialog = new EditProcessingInstructionDialog(shell, pi);
+ } else {
+ dialog = new EditProcessingInstructionDialog(shell, XMLUIMessages._UI_PI_TARGET_VALUE, XMLUIMessages._UI_PI_DATA_VALUE); //$NON-NLS-1$ //$NON-NLS-2$
}
-
- Document document = parent.getNodeType() == Node.DOCUMENT_NODE ? (Document) parent : parent.getOwnerDocument();
- Node newNode = document.createProcessingInstruction(dialog.getTarget(), dialog.getData());
- parent.insertBefore(newNode, childRef);
-
- if (pi != null) {
- parent.removeChild(pi);
+
+ dialog.create();
+ dialog.getShell().setText(title);
+ dialog.setBlockOnOpen(true);
+ dialog.open();
+
+ if (dialog.getReturnCode() == Window.OK) {
+ if (pi != null) {
+ childRef = pi;
+ }
+
+ Document document = parent.getNodeType() == Node.DOCUMENT_NODE ? (Document) parent : parent.getOwnerDocument();
+ Node newNode = document.createProcessingInstruction(dialog.getTarget(), dialog.getData());
+ parent.insertBefore(newNode, childRef);
+
+ if (pi != null) {
+ parent.removeChild(pi);
+ }
+
+ manager.reformat(newNode, false);
+ manager.setViewerSelection(newNode);
}
-
- manager.reformat(newNode, false);
- manager.setViewerSelection(newNode);
+ manager.endNodeAction(this);
}
- manager.endNodeAction(this);
}
}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditSchemaInfoAction.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditSchemaInfoAction.java
index 391931b..f879f96 100644
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditSchemaInfoAction.java
+++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditSchemaInfoAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
+ * Copyright (c) 2001, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -113,52 +113,54 @@
}
public void run() {
- manager.beginNodeAction(this);
-
- // todo... change constructor to take an element
- Element element = getElement(node);
- if (element != null) {
- Shell shell = XMLUIPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow().getShell();
- EditSchemaInfoDialog dialog = new EditSchemaInfoDialog(shell, new Path(resourceLocation));
-
- List namespaceInfoList = namespaceInfoManager.getNamespaceInfoList(element);
- List oldNamespaceInfoList = NamespaceInfo.cloneNamespaceInfoList(namespaceInfoList);
-
- // here we store a copy of the old info for each NamespaceInfo
- // this info will be used in createPrefixMapping() to figure out
- // how to update the document
- // in response to these changes
- for (Iterator i = namespaceInfoList.iterator(); i.hasNext();) {
- NamespaceInfo info = (NamespaceInfo) i.next();
- NamespaceInfo oldCopy = new NamespaceInfo(info);
- info.setProperty("oldCopy", oldCopy); //$NON-NLS-1$
- }
-
- dialog.setNamespaceInfoList(namespaceInfoList);
- dialog.create();
- //dialog.getShell().setSize(500, 300);
- dialog.getShell().setText(XMLUIMessages._UI_MENU_EDIT_SCHEMA_INFORMATION_TITLE); //$NON-NLS-1$
- dialog.setBlockOnOpen(true);
- dialog.open();
-
- if (dialog.getReturnCode() == Window.OK) {
- List newInfoList = dialog.getNamespaceInfoList();
- namespaceInfoManager.removeNamespaceInfo(element);
- namespaceInfoManager.addNamespaceInfo(element, newInfoList, true);
-
- // see if we need to rename any prefixes
- Map prefixMapping = createPrefixMapping(oldNamespaceInfoList, namespaceInfoList);
- if (prefixMapping.size() > 0) {
- try {
- manager.getModel().aboutToChangeModel();
- ReplacePrefixAction replacePrefixAction = new ReplacePrefixAction(manager, element, prefixMapping);
- replacePrefixAction.run();
- } finally {
- manager.getModel().changedModel();
+ Shell shell = XMLUIPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow().getShell();
+ if (validateEdit(manager.getModel(), shell)) {
+ manager.beginNodeAction(this);
+
+ // todo... change constructor to take an element
+ Element element = getElement(node);
+ if (element != null) {
+ EditSchemaInfoDialog dialog = new EditSchemaInfoDialog(shell, new Path(resourceLocation));
+
+ List namespaceInfoList = namespaceInfoManager.getNamespaceInfoList(element);
+ List oldNamespaceInfoList = NamespaceInfo.cloneNamespaceInfoList(namespaceInfoList);
+
+ // here we store a copy of the old info for each NamespaceInfo
+ // this info will be used in createPrefixMapping() to figure out
+ // how to update the document
+ // in response to these changes
+ for (Iterator i = namespaceInfoList.iterator(); i.hasNext();) {
+ NamespaceInfo info = (NamespaceInfo) i.next();
+ NamespaceInfo oldCopy = new NamespaceInfo(info);
+ info.setProperty("oldCopy", oldCopy); //$NON-NLS-1$
+ }
+
+ dialog.setNamespaceInfoList(namespaceInfoList);
+ dialog.create();
+ //dialog.getShell().setSize(500, 300);
+ dialog.getShell().setText(XMLUIMessages._UI_MENU_EDIT_SCHEMA_INFORMATION_TITLE); //$NON-NLS-1$
+ dialog.setBlockOnOpen(true);
+ dialog.open();
+
+ if (dialog.getReturnCode() == Window.OK) {
+ List newInfoList = dialog.getNamespaceInfoList();
+ namespaceInfoManager.removeNamespaceInfo(element);
+ namespaceInfoManager.addNamespaceInfo(element, newInfoList, true);
+
+ // see if we need to rename any prefixes
+ Map prefixMapping = createPrefixMapping(oldNamespaceInfoList, namespaceInfoList);
+ if (prefixMapping.size() > 0) {
+ try {
+ manager.getModel().aboutToChangeModel();
+ ReplacePrefixAction replacePrefixAction = new ReplacePrefixAction(manager, element, prefixMapping);
+ replacePrefixAction.run();
+ } finally {
+ manager.getModel().changedModel();
+ }
}
}
}
+ manager.endNodeAction(this);
}
- manager.endNodeAction(this);
}
}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/NodeAction.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/NodeAction.java
index 64c4728..5fb319e 100644
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/NodeAction.java
+++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/NodeAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
+ * Copyright (c) 2001, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -14,7 +14,12 @@
package org.eclipse.wst.xml.ui.internal.actions;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Path;
import org.eclipse.jface.action.Action;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
public abstract class NodeAction extends Action {
@@ -22,5 +27,24 @@
return null;
}
+ /**
+ * Checks that the resource backing the model is writeable utilizing <code>validateEdit</code>
+ * on a given <tt>IWorkspace</tt>.
+ *
+ * @param model the model to be checked
+ * @param context the shell context for which <code>validateEdit</code> will be run
+ * @return boolean result of checking <code>validateEdit</code>. If the resource is unwriteable, <code>status.isOK()</code>
+ * will return true; otherwise, false.
+ */
+ protected final boolean validateEdit(IStructuredModel model, Shell context) {
+ if (model != null && model.getBaseLocation() != null) {
+ IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(model.getBaseLocation()));
+ if (!file.isAccessible())
+ return true;
+ return ResourcesPlugin.getWorkspace().validateEdit(new IFile[] {file}, context).isOK();
+ }
+ return false; //$NON-NLS-1$
+ }
+
public abstract String getUndoDescription();
}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/ReplacePrefixAction.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/ReplacePrefixAction.java
index 46430e9..8256036 100644
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/ReplacePrefixAction.java
+++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/ReplacePrefixAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
+ * Copyright (c) 2001, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -18,7 +18,9 @@
import java.util.Vector;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.wst.xml.core.internal.contentmodel.util.DOMVisitor;
+import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
import org.w3c.dom.Attr;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -65,14 +67,17 @@
}
public void run() {
- NodeCollectingDOMVisitor visitor = new NodeCollectingDOMVisitor();
- visitor.visitNode(element);
- for (Iterator i = visitor.list.iterator(); i.hasNext();) {
- Node node = (Node) i.next();
- String key = node.getPrefix() != null ? node.getPrefix() : ""; //$NON-NLS-1$
- String newPrefix = (String) prefixMapping.get(key);
- if (newPrefix != null) {
- node.setPrefix(newPrefix);
+ Shell shell = XMLUIPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow().getShell();
+ if (validateEdit(manager.getModel(), shell)) {
+ NodeCollectingDOMVisitor visitor = new NodeCollectingDOMVisitor();
+ visitor.visitNode(element);
+ for (Iterator i = visitor.list.iterator(); i.hasNext();) {
+ Node node = (Node) i.next();
+ String key = node.getPrefix() != null ? node.getPrefix() : ""; //$NON-NLS-1$
+ String newPrefix = (String) prefixMapping.get(key);
+ if (newPrefix != null) {
+ node.setPrefix(newPrefix);
+ }
}
}
}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dnd/DragNodeCommand.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dnd/DragNodeCommand.java
index e24391f..4b911cc 100644
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dnd/DragNodeCommand.java
+++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dnd/DragNodeCommand.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
+ * Copyright (c) 2001, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -19,9 +19,13 @@
import java.util.List;
import java.util.Vector;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Path;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.wst.common.ui.internal.dnd.DefaultDragAndDropCommand;
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
@@ -143,6 +147,8 @@
boolean result = true;
if (target instanceof Node) {
Node targetNode = (Node) target;
+ if (!testOnly && fTreeViewer != null && !validateEdit(getStructuredModel(targetNode), fTreeViewer.getControl().getShell()))
+ return false;
Node parentNode = getParentForDropPosition(targetNode);
Node refChild = getRefChild(targetNode);
@@ -177,6 +183,24 @@
return result;
}
+ /**
+ * Checks that the resource backing the model is writeable utilizing <code>validateEdit</code>
+ * on a given <tt>IWorkspace</tt>.
+ *
+ * @param model the model to be checked
+ * @param context the shell context for which <code>validateEdit</code> will be run
+ * @return boolean result of checking <code>validateEdit</code>. If the resource is unwriteable, <code>status.isOK()</code>
+ * will return true; otherwise, false.
+ */
+ private boolean validateEdit(IStructuredModel model, Shell context) {
+ if (model != null && model.getBaseLocation() != null) {
+ IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(model.getBaseLocation()));
+ if (!file.isAccessible())
+ return true;
+ return ResourcesPlugin.getWorkspace().validateEdit(new IFile[] {file}, context).isOK();
+ }
+ return false; //$NON-NLS-1$
+ }
public int getFeedback() {
int result = DND.FEEDBACK_SELECT;
diff --git a/features/org.eclipse.wst.xml_ui.feature.patch/buildnotes_org.eclipse.wst.xml_ui.feature.patch.html b/features/org.eclipse.wst.xml_ui.feature.patch/buildnotes_org.eclipse.wst.xml_ui.feature.patch.html
index 5440307..b900f99 100644
--- a/features/org.eclipse.wst.xml_ui.feature.patch/buildnotes_org.eclipse.wst.xml_ui.feature.patch.html
+++ b/features/org.eclipse.wst.xml_ui.feature.patch/buildnotes_org.eclipse.wst.xml_ui.feature.patch.html
@@ -19,4 +19,5 @@
<p>Bug <a href='https://bugs.eclipse.org/bugs/show_bug.cgi?id=234905'>234905</a>. Backport fix for bug 158409 to 1.5.5 patches</p>
<p>Bug <a href='https://bugs.eclipse.org/bugs/show_bug.cgi?id=247887'>247887</a>. No Toggle Breakpoint action in vertical ruler for tag files</p>
<p>Bug <a href='https://bugs.eclipse.org/bugs/show_bug.cgi?id=111411'>111411</a>. G2X:Lost "PublicID", "SystemID" after installing Language Pack</p>
+<p>Bug <a href='https://bugs.eclipse.org/bugs/show_bug.cgi?id=289638'>289638</a>. StructuredTextEditor validates file buffer changes to documents</p>
</body></html>
\ No newline at end of file
diff --git a/features/org.eclipse.wst.xml_ui.feature.patch/feature.properties b/features/org.eclipse.wst.xml_ui.feature.patch/feature.properties
index f7e8006..37924f0 100644
--- a/features/org.eclipse.wst.xml_ui.feature.patch/feature.properties
+++ b/features/org.eclipse.wst.xml_ui.feature.patch/feature.properties
@@ -36,6 +36,7 @@
Bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=234905 Backport fix for bug 158409 to 1.5.5 patches\n\
Bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=247887 No Toggle Breakpoint action in vertical ruler for tag files\n\
Bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=111411 G2X:Lost "PublicID", "SystemID" after installing Language Pack\n\
+Bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=289638 StructuredTextEditor validates file buffer changes to documents\n\
\n\
# "copyright" property - text of the "Feature Update Copyright"
copyright=\