Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoritrimble2010-12-17 17:23:23 -0500
committeritrimble2010-12-17 17:23:23 -0500
commit3fa1aa0efc2a4a58e8154d22954a6a1e38624f38 (patch)
tree7d6c092da182fb2e054880b92f7ae7a09be981e8
parent11cce1aede47278533c9c6c0561ea8a6b09a2bf4 (diff)
downloadwebtools.jsf-3fa1aa0efc2a4a58e8154d22954a6a1e38624f38.tar.gz
webtools.jsf-3fa1aa0efc2a4a58e8154d22954a6a1e38624f38.tar.xz
webtools.jsf-3fa1aa0efc2a4a58e8154d22954a6a1e38624f38.zip
Bug 330412 - [WPE] Drag 'n' Drop of tag from palette doesn't notify team system of edit
Bug 330413 - [WPE] Modifying tag attribute using property sheet doesn't notify team system of edit
-rw-r--r--jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/commands/CreateItemCommand.java2
-rw-r--r--jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/commands/DesignerCommand.java20
-rw-r--r--jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/commands/PaletteDropInsertCommand.java2
-rw-r--r--jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/commands/SourceViewerCommand.java20
-rw-r--r--jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/commands/single/ChangeAttributeCommand.java2
-rw-r--r--jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/editors/DesignerStructuredTextEditorJSP.java102
6 files changed, 101 insertions, 47 deletions
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/commands/CreateItemCommand.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/commands/CreateItemCommand.java
index 6b521e498..e19bb0a09 100644
--- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/commands/CreateItemCommand.java
+++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/commands/CreateItemCommand.java
@@ -63,8 +63,6 @@ public class CreateItemCommand extends DesignerCommand implements ICustomizableC
getModel(), this._position, this._customizationData);
if (element != null)
{
- //Bug 330412 - [WPE] Drag 'n' Drop of tag from palette doesn't notify team system of edit
- notifyTeamFrameworkOfEdit();
formatNode(element);
}
this._ele = element;
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/commands/DesignerCommand.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/commands/DesignerCommand.java
index 8ff76d7da..10d6c60ac 100644
--- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/commands/DesignerCommand.java
+++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/commands/DesignerCommand.java
@@ -11,9 +11,6 @@
*******************************************************************************/
package org.eclipse.jst.pagedesigner.commands;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.runtime.IStatus;
import org.eclipse.draw2d.IFigure;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.GraphicalEditPart;
@@ -31,7 +28,6 @@ import org.eclipse.jst.pagedesigner.dom.EditValidateUtil;
import org.eclipse.jst.pagedesigner.dom.IDOMPosition;
import org.eclipse.jst.pagedesigner.parts.ElementEditPart;
import org.eclipse.jst.pagedesigner.utils.SelectionHelper;
-import org.eclipse.jst.pagedesigner.utils.StructuredModelUtil;
import org.eclipse.jst.pagedesigner.viewer.DesignPosition;
import org.eclipse.jst.pagedesigner.viewer.DesignRange;
import org.eclipse.jst.pagedesigner.viewer.IHTMLGraphicalViewer;
@@ -336,22 +332,6 @@ public abstract class DesignerCommand extends Command {
}
/**
- * Notifies the team framework of an edit to the model's underlying file.
- */
- public void notifyTeamFrameworkOfEdit() {
- IFile file = StructuredModelUtil.getFileFor(_model);
- if (file != null) {
- IWorkspace workspace = file.getWorkspace();
- if (workspace != null) {
- IStatus status = workspace.validateEdit(new IFile[]{file}, null);
- if (!status.isOK()) {
- _log.info(status.getMessage());
- }
- }
- }
- }
-
- /**
* Re-executes the Command. This method should only be called after
* <code>undo()</code> has been called.
*/
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/commands/PaletteDropInsertCommand.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/commands/PaletteDropInsertCommand.java
index 41fe7f104..7438282d0 100644
--- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/commands/PaletteDropInsertCommand.java
+++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/commands/PaletteDropInsertCommand.java
@@ -97,8 +97,6 @@ public class PaletteDropInsertCommand extends SourceViewerCommand implements ICu
_creationProvider, getModel()
, position, getCustomizationData());
if (element != null) {
- //Bug 330412 - [WPE] Drag 'n' Drop of tag from palette doesn't notify team system of edit
- notifyTeamFrameworkOfEdit();
formatNode(element);
}
this._element = element;
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/commands/SourceViewerCommand.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/commands/SourceViewerCommand.java
index b1a504fa4..2974929f0 100644
--- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/commands/SourceViewerCommand.java
+++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/commands/SourceViewerCommand.java
@@ -11,16 +11,12 @@
*******************************************************************************/
package org.eclipse.jst.pagedesigner.commands;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IStatus;
import org.eclipse.gef.commands.Command;
import org.eclipse.jface.text.TextSelection;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jst.jsf.common.ui.internal.logging.Logger;
import org.eclipse.jst.pagedesigner.PDPlugin;
-import org.eclipse.jst.pagedesigner.utils.StructuredModelUtil;
import org.eclipse.wst.html.core.internal.format.HTMLFormatProcessorImpl;
import org.eclipse.wst.sse.ui.StructuredTextEditor;
import org.eclipse.wst.sse.ui.internal.provisional.extensions.ISourceEditingTextTools;
@@ -103,22 +99,6 @@ public abstract class SourceViewerCommand extends Command {
}
/**
- * Notifies the team framework of an edit to the model's underlying file.
- */
- public void notifyTeamFrameworkOfEdit() {
- IFile file = StructuredModelUtil.getFileFor(getModel());
- if (file != null) {
- IWorkspace workspace = file.getWorkspace();
- if (workspace != null) {
- IStatus status = workspace.validateEdit(new IFile[]{file}, null);
- if (!status.isOK()) {
- _log.info(status.getMessage());
- }
- }
- }
- }
-
- /**
* @return the dom model
*/
protected IDOMModel getModel() {
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/commands/single/ChangeAttributeCommand.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/commands/single/ChangeAttributeCommand.java
index 6244e1219..223f4ec59 100644
--- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/commands/single/ChangeAttributeCommand.java
+++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/commands/single/ChangeAttributeCommand.java
@@ -87,8 +87,6 @@ public class ChangeAttributeCommand extends SingleNodeCommand {
if (!isEmptyString(value) || _keepEmptyAttribute) {
_element.setAttribute(name, value);
}
- //Bug 330413 - [WPE] Modifying tag attribute using property sheet doesn't notify team system of edit
- notifyTeamFrameworkOfEdit();
}
private boolean isSameValue(String value1, String value2) {
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/editors/DesignerStructuredTextEditorJSP.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/editors/DesignerStructuredTextEditorJSP.java
index 6596d8d17..369fd4eea 100644
--- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/editors/DesignerStructuredTextEditorJSP.java
+++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/editors/DesignerStructuredTextEditorJSP.java
@@ -11,12 +11,21 @@
*******************************************************************************/
package org.eclipse.jst.pagedesigner.editors;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jst.pagedesigner.dnd.internal.DesignerSourceDropTargetListener;
+import org.eclipse.jst.pagedesigner.utils.StructuredModelUtil;
import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.DropTarget;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.ui.texteditor.ITextEditorDropTargetListener;
+import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IModelStateListener;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
import org.eclipse.wst.sse.ui.StructuredTextEditor;
/**
@@ -26,6 +35,8 @@ public class DesignerStructuredTextEditorJSP extends StructuredTextEditor
{
private ITextEditorDropTargetListener _dropTargetListener;
private DropTarget _dropTarget;
+ private IStructuredModel _structuredModel;
+ private IModelStateListener _modelStateListener;
@Override
protected void initializeDrop(final ITextViewer viewer)
@@ -62,6 +73,15 @@ public class DesignerStructuredTextEditorJSP extends StructuredTextEditor
return super.getAdapter(required);
}
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.sse.ui.StructuredTextEditor#doSetInput(org.eclipse.ui.IEditorInput)
+ */
+ @Override
+ protected void doSetInput(IEditorInput input) throws CoreException {
+ super.doSetInput(input);
+ addModelStateListener();
+ }
+
@Override
public void dispose()
{
@@ -74,7 +94,87 @@ public class DesignerStructuredTextEditorJSP extends StructuredTextEditor
_dropTarget.dispose();
_dropTarget = null;
}
-
+ removeModelStateListener();
+ if (_structuredModel != null) {
+ _structuredModel.releaseFromRead();
+ _structuredModel = null;
+ }
super.dispose();
}
+
+ private IStructuredModel getStructuredModel() {
+ IStructuredModel model = null;
+ if (_structuredModel != null) {
+ model = _structuredModel;
+ } else {
+ IDocumentProvider provider = getDocumentProvider();
+ if (provider != null) {
+ IDocument document = provider.getDocument(getEditorInput());
+ _structuredModel = StructuredModelManager.getModelManager().getExistingModelForRead(document);
+ model = _structuredModel;
+ }
+ }
+ return model;
+ }
+
+ private void addModelStateListener() {
+ IStructuredModel model = getStructuredModel();
+ if (model != null) {
+ if (_modelStateListener == null) {
+ _modelStateListener = new ModelStateListener();
+ } else {
+ model.removeModelStateListener(_modelStateListener);
+ }
+ model.addModelStateListener(_modelStateListener);
+ }
+ }
+
+ private void removeModelStateListener() {
+ IStructuredModel model = getStructuredModel();
+ if (model != null) {
+ if (_modelStateListener != null) {
+ model.removeModelStateListener(_modelStateListener);
+ _modelStateListener = null;
+ }
+ }
+ }
+
+ private class ModelStateListener implements IModelStateListener {
+
+ public void modelAboutToBeChanged(IStructuredModel model) {
+ //do nothing
+ }
+
+ public void modelChanged(IStructuredModel model) {
+ //do nothing
+ }
+
+ public void modelDirtyStateChanged(IStructuredModel model, boolean isDirty) {
+ //Bug 330412 - [WPE] Drag 'n' Drop of tag from palette doesn't notify team system of edit
+ //Bug 330413 - [WPE] Modifying tag attribute using property sheet doesn't notify team system of edit
+ if (isDirty) {
+ IFile file = StructuredModelUtil.getFileFor(model);
+ if (file != null) {
+ file.getWorkspace().validateEdit(new IFile[]{file}, null);
+ }
+ }
+ }
+
+ public void modelResourceDeleted(IStructuredModel model) {
+ //do nothing
+ }
+
+ public void modelResourceMoved(IStructuredModel oldModel, IStructuredModel newModel) {
+ //do nothing
+ }
+
+ public void modelAboutToBeReinitialized(IStructuredModel structuredModel) {
+ //do nothing
+ }
+
+ public void modelReinitialized(IStructuredModel structuredModel) {
+ //do nothing
+ }
+ }
+
}

Back to the top