Author: DartPeng
Date: 2009-01-08 04:10:41 -0500 (Thu, 08 Jan 2009)
New Revision: 12926
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/SmooksTextEdtor.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksFormEditor.java
Log:
JBIDE-3429
change the graphical model and source page text when the page was changed
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/SmooksTextEdtor.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/SmooksTextEdtor.java 2009-01-08
08:58:58 UTC (rev 12925)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/SmooksTextEdtor.java 2009-01-08
09:10:41 UTC (rev 12926)
@@ -10,6 +10,8 @@
import org.eclipse.core.runtime.IProgressMonitor;
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;
@@ -36,6 +38,18 @@
private String errorMessage;
+ private boolean dirty = false;
+
+ public boolean isDirty() {
+ if (!dirty)
+ return false;
+ return super.isDirty();
+ }
+
+ public void setDirty(boolean dirty) {
+ this.dirty = dirty;
+ }
+
public String getErrorMessage() {
return errorMessage;
}
@@ -89,6 +103,7 @@
|| messageLabel == null || messageLabel.isDisposed()) {
return;
}
+ errorMessage = message;
if (message == null) {
GridData gd = new GridData();
if (flag) {
@@ -112,7 +127,6 @@
parent.layout();
}
} else {
- errorMessage = message;
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
errorComposite.setVisible(true);
messageLabel.setText(message);
@@ -194,6 +208,13 @@
textComposite.setLayoutData(gd);
textComposite.setLayout(new FillLayout());
super.createPartControl(textComposite);
+
+ getTextViewer().getTextWidget().addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ setDirty(true);
+ firePropertyChange(PROP_DIRTY);
+ }
+ });
}
public void endAnalyze(AnalyzeResult result) {
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksFormEditor.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksFormEditor.java 2009-01-08
08:58:58 UTC (rev 12925)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksFormEditor.java 2009-01-08
09:10:41 UTC (rev 12926)
@@ -19,7 +19,6 @@
import java.util.List;
import org.dom4j.Document;
-import org.dom4j.Element;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.SAXReader;
import org.dom4j.io.XMLWriter;
@@ -80,7 +79,7 @@
// private SmooksTextEdtor textEdtior = null;
private boolean forceDirty = false;
-// private boolean onlyShowTextEditor = false;
+ // private boolean onlyShowTextEditor = false;
private Throwable showTextEditorReason = null;
private boolean allowdActiveErrorSourcePage = true;
@@ -254,22 +253,24 @@
@Override
public void doSave(IProgressMonitor monitor) {
- int index = this.getCurrentPage();
- if (index == 2) {
- this.xmlTextEditor.doSave(monitor);
+ IEditorPart editor = this.getActiveEditor();
+ if (editor == null) {
+ this.graphicalPage.doSave(monitor);
fireEditorDirty(false);
} else {
-
- this.graphicalPage.doSave(monitor);
+ this.xmlTextEditor.doSave(monitor);
fireEditorDirty(false);
}
}
public void fireEditorDirty(boolean dirty) {
this.forceDirty = dirty;
- if (graphicalPage != null) {
+ if (graphicalPage != null && !dirty) {
graphicalPage.setDirty(false);
}
+ if (xmlTextEditor != null && !dirty) {
+ xmlTextEditor.setDirty(false);
+ }
this.firePropertyChange(PROP_DIRTY);
}
@@ -333,7 +334,7 @@
}
public void endAnalyze(AnalyzeResult result) {
- if (result.getError() != null && allowdActiveErrorSourcePage ) {
+ if (result.getError() != null && allowdActiveErrorSourcePage) {
this.setActivePage(2);
}
}
@@ -356,7 +357,7 @@
ByteArrayOutputStream tempStream = null;
XMLWriter writer = null;
try {
- if ((oldPageIndex == 0 || oldPageIndex == 1)&& newPageIndex == 2) {
+ if ((oldPageIndex == 0 || oldPageIndex == 1) && newPageIndex == 2) {
if (xmlTextEditor.getErrorMessage() == null) {
InputStream stream = graphicalPage
.generateSmooksContents(null);
Show replies by date