[jbosstools-commits] JBoss Tools SVN: r43841 - in trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model: filesystems/impl and 4 other directories.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Wed Sep 19 13:41:44 EDT 2012
Author: scabanovich
Date: 2012-09-19 13:41:44 -0400 (Wed, 19 Sep 2012)
New Revision: 43841
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/XJob.java
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/AbstractXMLFileImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileAnyImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileXMLImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/SimpleFileImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/XModelImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/XModelObjectImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/loaders/impl/SimpleWebFileLoader.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/markers/XMarkerManager.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/plugin/ModelPlugin.java
Log:
JBIDE-12479
https://issues.jboss.org/browse/JBIDE-12479
XModel file objects should not keep references to long strings.
Modified: trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/XJob.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/XJob.java 2012-09-19 17:40:28 UTC (rev 43840)
+++ trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/XJob.java 2012-09-19 17:41:44 UTC (rev 43841)
@@ -49,6 +49,17 @@
waitForJob(false);
}
+ public static void shutdown() {
+ setSuspended(true);
+ synchronized (JOB) {
+ JOB.ids.clear();
+ JOB.list.clear();
+ }
+ if(JOB.isRunning()) {
+ JOB.cancel();
+ }
+ }
+
public static void waitForJob(boolean immediateOnly) throws InterruptedException {
Object[] o = {
XJob.FAMILY_XJOB, ResourcesPlugin.FAMILY_AUTO_REFRESH, ResourcesPlugin.FAMILY_AUTO_BUILD
@@ -173,6 +184,9 @@
synchronized (this) {
ids.remove(r.getId());
}
+ if(monitor.isCanceled()) {
+ break;
+ }
if (!isSuspended()) {
try {
r.run();
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 2012-09-19 17:40:28 UTC (rev 43840)
+++ trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/AbstractExtendedXMLFileImpl.java 2012-09-19 17:41:44 UTC (rev 43841)
@@ -56,7 +56,7 @@
public String get(String name) {
if(name.equals("_hasErrors_")) { //$NON-NLS-1$
- return super.get(XModelObjectConstants.ATTR_NAME_IS_INCORRECT);
+ return super.get(ATTR_NAME_IS_INCORRECT);
}
if (getParent() != null && ns.indexOf("." + name + ".") < 0) { //$NON-NLS-1$ //$NON-NLS-2$
if(loadAttributeSeparately(name)) return super.get(name);
@@ -193,8 +193,8 @@
public void set(String name, String value) {
super.set(name, value);
- if("incorrectBody".equals(name) && value.length() > 0) { //$NON-NLS-1$
- set(XModelObjectConstants.ATTR_NAME_IS_INCORRECT, XModelObjectConstants.YES);
+ if(ATTR_NAME_INCORRECT_BODY.equals(name) && value.length() > 0) { //$NON-NLS-1$
+ set(ATTR_NAME_IS_INCORRECT, YES);
// setErrors(value, hasDTD(), !hasDTD()); //never validate dtd
int resolution = EntityXMLRegistration.getInstance().resolve(getModelEntity());
if(EntityXMLRegistration.isSystemId(value)) resolution = EntityXMLRegistration.UNRESOLVED;
@@ -242,8 +242,8 @@
getChildren();
boolean fire = this.loaderError == null && f.loaderError != null;
this.loaderError = f.loaderError;
- super.set("incorrectBody", f.get("incorrectBody")); //$NON-NLS-1$ //$NON-NLS-2$
- super.set(XModelObjectConstants.ATTR_NAME_IS_INCORRECT, XModelObjectConstants.YES);
+ super.set(ATTR_NAME_INCORRECT_BODY, f.get(ATTR_NAME_INCORRECT_BODY));
+ super.set(ATTR_NAME_IS_INCORRECT, YES);
if(f.get("errors") != null) super.set("errors", f.get("errors")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
if(fire) changeTimeStamp();
@@ -253,9 +253,9 @@
m.fireStructureChanged(this);
if(!isOverlapped) getResourceMarkers().update();
} else if(isMergingChanges()) {
- String oldBody = get("correctBody"); //$NON-NLS-1$
+ String oldBody = get(ATTR_NAME_CORRECT_BODY);
boolean changed = body != null && !body.equals(oldBody);
- set("correctBody", body); //$NON-NLS-1$
+ set(ATTR_NAME_CORRECT_BODY, body);
set("actualBodyTimeStamp", "0"); //$NON-NLS-1$ //$NON-NLS-2$
long ots = getTimeStamp();
mergeAll(f, update);
@@ -311,7 +311,7 @@
setErrors(body, resolution == EntityXMLRegistration.DTD, resolution == EntityXMLRegistration.SCHEMA);
boolean errors2 = (get("errors") != null && get("errors").length() > 0); //$NON-NLS-1$ //$NON-NLS-2$
if(errors1 && errors2) {
- super.set("incorrectBody".intern(), body); //$NON-NLS-1$
+ super.set(ATTR_NAME_INCORRECT_BODY, body); //$NON-NLS-1$
if(fire) {
changeTimeStamp();
if(isActive()) ((XModelImpl)getModel()).fireNodeChanged(this, getPath());
@@ -321,11 +321,11 @@
AbstractExtendedXMLFileImpl f = (AbstractExtendedXMLFileImpl)getModel().createModelObject(getModelEntity().getName(), null);
f.setAttributeValue(XModelObjectConstants.ATTR_NAME, getAttributeValue(XModelObjectConstants.ATTR_NAME));
f.setAttributeValue(XModelObjectConstants.ATTR_NAME_EXTENSION, getAttributeValue(XModelObjectConstants.ATTR_NAME_EXTENSION));
+ f.setBodySource(new SFBodySource(body));
if(errors2) {
- f.set("incorrectBody", body); //$NON-NLS-1$
+ f.set(ATTR_NAME_INCORRECT_BODY, body); //$NON-NLS-1$
f.set("errors", super.get("errors")); //$NON-NLS-1$ //$NON-NLS-2$
}
- f.setBodySource(new SFBodySource(body));
return f;
}
@@ -333,8 +333,8 @@
if(fire) {
fireObjectChanged(XModelTreeEvent.BEFORE_MERGE);
}
- if(!XModelObjectConstants.YES.equals(update.get(XModelObjectConstants.ATTR_NAME_IS_INCORRECT))) {
- super.set("incorrectBody", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ if(!YES.equals(update.get(ATTR_NAME_IS_INCORRECT))) {
+ super.set(ATTR_NAME_INCORRECT_BODY, ""); //$NON-NLS-1$ //$NON-NLS-2$
super.set(XModelObjectConstants.ATTR_NAME_IS_INCORRECT,XModelObjectConstants.NO);
super.set("errors", ""); //$NON-NLS-1$ //$NON-NLS-2$
loaderError = null;
Modified: trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/AbstractXMLFileImpl.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/AbstractXMLFileImpl.java 2012-09-19 17:40:28 UTC (rev 43840)
+++ trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/AbstractXMLFileImpl.java 2012-09-19 17:41:44 UTC (rev 43841)
@@ -13,7 +13,6 @@
import java.text.MessageFormat;
import java.util.*;
import org.jboss.tools.common.model.markers.ResourceMarkers;
-import org.jboss.tools.common.model.XModelObjectConstants;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.filesystems.impl.RecognizedFileImpl;
import org.jboss.tools.common.model.util.FindObjectHelper;
@@ -33,7 +32,7 @@
public final static boolean turnOffDTDCheck = true;
public boolean isIncorrect() {
- return (XModelObjectConstants.YES.equals(get(XModelObjectConstants.ATTR_NAME_IS_INCORRECT)));
+ return (YES.equals(get(ATTR_NAME_IS_INCORRECT)));
}
public AbstractXMLFileImpl() {
@@ -97,16 +96,16 @@
}
String s = sb.toString();
if(s.equals(get("errors"))) return; //$NON-NLS-1$
- super.set("incorrectBody", body); //$NON-NLS-1$
+ super.set(ATTR_NAME_INCORRECT_BODY, (errors.length == 0 && loaderError == null) ? "" : body); //$NON-NLS-1$
set("errors", s); //$NON-NLS-1$
- setAttributeValue(XModelObjectConstants.ATTR_NAME_IS_INCORRECT, (errors.length == 0 && loaderError == null) ? XModelObjectConstants.NO : XModelObjectConstants.YES);
+ setAttributeValue(ATTR_NAME_IS_INCORRECT, (errors.length == 0 && loaderError == null) ? NO : YES);
if(!isOverlapped()) markers.update();
}
protected boolean isOverlapped() {
XModelObject p = getParent();
- while(p != null && !XModelObjectConstants.TRUE.equals(p.get("overlapped"))) p = p.getParent(); //$NON-NLS-1$
+ while(p != null && !TRUE.equals(p.get("overlapped"))) p = p.getParent(); //$NON-NLS-1$
return (p != null);
}
Modified: trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileAnyImpl.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileAnyImpl.java 2012-09-19 17:40:28 UTC (rev 43840)
+++ trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileAnyImpl.java 2012-09-19 17:41:44 UTC (rev 43841)
@@ -23,7 +23,7 @@
import org.jboss.tools.common.model.XJob.XRunnable;
import org.jboss.tools.common.model.filesystems.*;
-public class FileAnyImpl extends RegularObjectImpl {
+public class FileAnyImpl extends RegularObjectImpl implements XModelObjectConstants {
/**
* This is text editor that reads text from file than
* from model object. If some action modifies text
@@ -37,6 +37,14 @@
private static final long serialVersionUID = 5613864065417244573L;
private BodySource bodysource = null;
BodyListener listener;
+
+ /**
+ * Used only for temporarily loaded objects that are to be merged into existing object.
+ * If this property is set, get(name) for body attributes are redirected to it,
+ * and set(name, value) for body attributes are ignored.
+ */
+ private BodySource body = null;
+ private String tempBody = "";
int updateLock = 0;
@@ -79,7 +87,7 @@
}
private boolean isObjectEditable0() {
- if(XModelObjectConstants.TRUE.equals(get("overlapped")) && isActive()) return false; //$NON-NLS-1$
+ if(TRUE.equals(get("overlapped")) && isActive()) return false; //$NON-NLS-1$
XModelObject p = getParent();
if(p == null) return true;
if(p instanceof JarFolderImpl) return false;
@@ -88,15 +96,15 @@
}
public boolean isAttributeEditable(String name) {
- if(XModelObjectConstants.ATTR_NAME.equals(name) || XModelObjectConstants.ATTR_NAME_EXTENSION.equals(name)) return false;
- if(XModelObjectConstants.ATTR_NAME_BODY.equals(name)) {
+ if(ATTR_NAME.equals(name) || ATTR_NAME_EXTENSION.equals(name)) return false;
+ if(ATTR_NAME_BODY.equals(name)) {
return isObjectEditable0();
}
return super.isAttributeEditable(name);
}
public String getMainIconName() {
- if(XModelObjectConstants.TRUE.equals(get("overlapped")) && isActive()) { //$NON-NLS-1$
+ if(TRUE.equals(get("overlapped")) && isActive()) { //$NON-NLS-1$
String oin = get("overlappedSystem"); //$NON-NLS-1$
XModelObject o = (oin == null || oin.length() == 0) ? null : getModel().getByPath(oin);
if(o == null) {
@@ -123,7 +131,7 @@
}
public static String toFileName(XProperty p) {
- String n = p.get(XModelObjectConstants.XML_ATTR_NAME);
+ String n = p.get(XML_ATTR_NAME);
if(n == null) return null;
String s = p.get("EXTENSION"); //$NON-NLS-1$
return n + ((s == null || s.length() == 0) ? "" : "." + s); //$NON-NLS-1$ //$NON-NLS-2$
@@ -131,7 +139,10 @@
public void setBodySource(BodySource bodysource) {
this.bodysource = bodysource;
- super.set(XModelObjectConstants.ATTR_NAME_BODY, ""); //$NON-NLS-1$
+ if(bodysource instanceof SFBodySource) {
+ body = bodysource;
+ }
+ super.set(ATTR_NAME_BODY, ""); //$NON-NLS-1$
changeTimeStamp();
}
@@ -147,19 +158,33 @@
}
public String get(String name) {
- if(bodysource != null && XModelObjectConstants.ATTR_NAME_BODY.equals(name)) readBodySource();
+ if(body != null) {
+ if(ATTR_NAME_BODY.equals(name)) {
+ bodysource = null;
+ }
+ if(ATTR_NAME_BODY.equals(name)
+ || ATTR_NAME__BODY_.equals(name)
+ || ATTR_NAME_CORRECT_BODY.equals(name)
+ || ATTR_NAME_INCORRECT_BODY.equals(name)
+ ) {
+ return body.get();
+ }
+ } else if(ATTR_NAME__BODY_.equals(name)) {
+ return tempBody;
+ }
+ if(bodysource != null && ATTR_NAME_BODY.equals(name)) readBodySource();
return super.get(name);
}
private void readBodySource() {
String s = bodysource.get();
bodysource = null;
- if(s != null) super.set(XModelObjectConstants.ATTR_NAME_BODY, s);
+ if(s != null) super.set(ATTR_NAME_BODY, s);
}
public String setAttributeValue(String name, String value) {
-// if(XModelObjectConstants.ATTR_NAME_EXTENSION.equals(name) && isActive()) {
-// if(!value.equals(getAttributeValue(XModelObjectConstants.ATTR_NAME_EXTENSION))) {
+// if(ATTR_NAME_EXTENSION.equals(name) && isActive()) {
+// if(!value.equals(getAttributeValue(ATTR_NAME_EXTENSION))) {
// if(new ExtensionChange().execute(this, value) && getParent() == null) {
// return getAttributeValue(name);
// }
@@ -169,15 +194,28 @@
}
public String getAsText() {
- return getAttributeValue(XModelObjectConstants.ATTR_NAME_BODY);
+ if(body != null) {
+ return body.get();
+ }
+ return getAttributeValue(ATTR_NAME_BODY);
}
public void edit(String body) throws XModelException {
- getModel().changeObjectAttribute(this, XModelObjectConstants.ATTR_NAME_BODY, body);
+ getModel().changeObjectAttribute(this, ATTR_NAME_BODY, body);
}
public void set(String name, String value) {
- if((!XModelObjectConstants.XML_ATTR_NAME.equals(name) && !"EXTENSION".equals(name)) || !isActive() || !(getParent() instanceof FolderImpl)) { //$NON-NLS-1$
+ if(body != null) {
+ if(ATTR_NAME_BODY.equals(name)
+ || ATTR_NAME__BODY_.equals(name)
+ || ATTR_NAME_CORRECT_BODY.equals(name)
+ || ATTR_NAME_INCORRECT_BODY.equals(name)
+ ) {
+ //do nothing
+ }
+ } else if(ATTR_NAME__BODY_.equals(name)) {
+ tempBody = value;
+ } else if((!XML_ATTR_NAME.equals(name) && !"EXTENSION".equals(name)) || !isActive() || !(getParent() instanceof FolderImpl)) { //$NON-NLS-1$
super.set(name, value);
} else {
rename0(value, name);
@@ -185,11 +223,11 @@
}
public void fileRenamed(String name, String extension) {
- if(name != null && name.equals(super.get(XModelObjectConstants.XML_ATTR_NAME))
+ if(name != null && name.equals(super.get(XML_ATTR_NAME))
&& extension != null && extension.equals(super.get("EXTENSION"))) { //$NON-NLS-1$
return;
}
- super.set(XModelObjectConstants.XML_ATTR_NAME, name);
+ super.set(XML_ATTR_NAME, name);
super.set("EXTENSION", extension); //$NON-NLS-1$
safeChangeTimeStamp();
fireObjectChanged(null);
@@ -205,7 +243,7 @@
if(f2.exists() && !f.exists()) return;
if(!n2.equals(n1)) {
try {
- f.move(new Path(f.getParent().getFullPath() + XModelObjectConstants.SEPARATOR + toFileName(this)), true, null);
+ f.move(new Path(f.getParent().getFullPath() + SEPARATOR + toFileName(this)), true, null);
} catch (OperationCanceledException e) {
super.set(attr, n1);
} catch (CoreException e) {
@@ -267,7 +305,7 @@
}
protected void onAttributeValueEdit(String name, String oldValue, String newValue) throws XModelException {
- if(XModelObjectConstants.ATTR_NAME_BODY.equals(name) && listener != null) {
+ if(ATTR_NAME_BODY.equals(name) && listener != null) {
listener.bodyChanged(newValue);
}
}
Modified: trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileXMLImpl.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileXMLImpl.java 2012-09-19 17:40:28 UTC (rev 43840)
+++ trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileXMLImpl.java 2012-09-19 17:41:44 UTC (rev 43841)
@@ -10,7 +10,6 @@
******************************************************************************/
package org.jboss.tools.common.model.filesystems.impl;
-import org.jboss.tools.common.model.XModelObjectConstants;
import org.jboss.tools.common.model.filesystems.impl.AbstractXMLFileImpl;
public class FileXMLImpl extends AbstractXMLFileImpl {
@@ -29,17 +28,17 @@
public String get(String name) {
if(name.equals("_hasErrors_")) { //$NON-NLS-1$
- return super.get(XModelObjectConstants.ATTR_NAME_IS_INCORRECT);
+ return super.get(ATTR_NAME_IS_INCORRECT);
}
if(!markersReset && isActive()
&& !"NAME".equals(name) && !"EXTENSION".equals(name) && !"overlapped".equals(name)) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- updateMarkers(super.get(XModelObjectConstants.ATTR_NAME_BODY));
+ updateMarkers(super.get(ATTR_NAME_BODY));
}
return super.get(name);
}
public void set(String name, String value) {
- boolean isBody = XModelObjectConstants.ATTR_NAME_BODY.equals(name) || XModelObjectConstants.ATTR_NAME__BODY_.equals(name);
+ boolean isBody = ATTR_NAME_BODY.equals(name) || ATTR_NAME__BODY_.equals(name);
if(isActive() && isBody && !value.equals(get(name))) {
super.set(name, value);
updateMarkers(value);
Modified: trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/SimpleFileImpl.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/SimpleFileImpl.java 2012-09-19 17:40:28 UTC (rev 43840)
+++ trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/SimpleFileImpl.java 2012-09-19 17:41:44 UTC (rev 43841)
@@ -33,14 +33,14 @@
}
public String getBody() {
- if(isIncorrect()) return get("incorrectBody"); //$NON-NLS-1$
+ if(isIncorrect()) return get(ATTR_NAME_INCORRECT_BODY);
String abts = get("actualBodyTimeStamp"); //$NON-NLS-1$
if(abts != null && (abts.equals("0") || abts.equals("" + getTimeStamp()))) { //$NON-NLS-1$ //$NON-NLS-2$
- return get("correctBody"); //$NON-NLS-1$
+ return get(ATTR_NAME_CORRECT_BODY);
}
if(loader == null) loader = (SerializingLoader)XModelObjectLoaderUtil.getObjectLoader(this);
String body = loader.serializeObject(this);
- set("correctBody", body); //$NON-NLS-1$
+ set(ATTR_NAME_CORRECT_BODY, body);
set("actualBodyTimeStamp", "" + getTimeStamp()); //$NON-NLS-1$ //$NON-NLS-2$
return body;
}
Modified: trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/XModelImpl.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/XModelImpl.java 2012-09-19 17:40:28 UTC (rev 43840)
+++ trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/XModelImpl.java 2012-09-19 17:41:44 UTC (rev 43841)
@@ -70,7 +70,7 @@
private static XModelBufferImpl buffer = new XModelBufferImpl();
private XModelChangeManager changemanager = new XModelChangeManager();
private FileSystemPeer fileregistry = new FileSystemPeer();
- private PrintWriter out = new PrintWriter(System.out, true);
+ private static PrintWriter out = new PrintWriter(System.out, true);
private HashMap<String,XModelObject> extraroots = new HashMap<String,XModelObject>(2);
private String rootEntity = XModelObjectConstants.ROOT_OBJECT;
Modified: trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/XModelObjectImpl.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/XModelObjectImpl.java 2012-09-19 17:40:28 UTC (rev 43840)
+++ trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/XModelObjectImpl.java 2012-09-19 17:41:44 UTC (rev 43841)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.common.model.impl;
+import java.io.File;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
@@ -35,7 +36,9 @@
import org.jboss.tools.common.model.adapter.IModelObjectAdapter;
import org.jboss.tools.common.model.adapter.ModelObjectAdapterExtensionPoint;
import org.jboss.tools.common.model.icons.impl.XModelObjectIcon;
+import org.jboss.tools.common.model.plugin.ModelPlugin;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.common.util.FileUtil;
public class XModelObjectImpl implements XModelObject, Serializable, Cloneable {
private static final long serialVersionUID = 3860648580262144825L;
@@ -45,7 +48,6 @@
private XModelEntity entity = null;
private XModelObjectImpl parent = null;
protected XModelObjectImpl.SP properties = new SProperties();
-/// protected Hashtable properties = new Hashtable(10);
protected boolean modified = false;
protected long timeStamp = System.currentTimeMillis();
protected long lastModificationTimeStamp = 0;
@@ -643,6 +645,9 @@
}
class SProperties implements XModelObjectImpl.SP {
+ static final String SUFFIX = ".sp.txt";
+ static final String MOD_SUFFIX = ".mod.sp.txt";
+ static int modification = 0;
String[] list = null;
XModelEntity entity;
@@ -653,12 +658,44 @@
public String get(String name) {
int i = entity.getPropertyIndex(name, false);
- return (i < 0 || i >= list.length) ? null : list[i];
+ String value = (i < 0 || i >= list.length) ? null : list[i];
+ if(value != null && value.endsWith(SUFFIX)) {
+ File f = new File(value);
+ if(f.exists()) {
+ value = FileUtil.readFile(f);
+ } else {
+ ModelPlugin.getDefault().logError("Cannot read " + value);
+ return "";
+ }
+ }
+ return value;
}
public void put(String name, String value) {
int i = entity.getPropertyIndex(name, true);
ensureCapacity(i);
+ if(value != null && value.length() > 10000 && ModelPlugin.getDefault().getTempFolder() != null) {
+ long l = value.hashCode();
+ l = Math.abs((l << 32) + value.substring(100, value.length() - 100).hashCode());
+ File f = new File(ModelPlugin.getDefault().getTempFolder(), ModelPlugin.TEMP_FILE_PREFIX + l + SUFFIX);
+ String fileName = f.getAbsolutePath();
+ if(f.exists() && fileName.equals(list[i])) {
+ return;
+ }
+ if(!f.exists() || (list[i] != null && list[i].endsWith(MOD_SUFFIX))) {
+ if(list[i] != null && list[i].endsWith(SUFFIX)) {
+ if(!list[i].endsWith(MOD_SUFFIX)) {
+ String fn = list[i].substring(0, list[i].length() - SUFFIX.length()) + "." + (modification++) + MOD_SUFFIX;
+ list[i] = fn;
+ }
+ f = new File(list[i]);
+ fileName = list[i];
+ }
+ FileUtil.writeFile(f, value);
+ f.deleteOnExit();
+ }
+ value = fileName;
+ }
list[i] = value;
}
Modified: trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/loaders/impl/SimpleWebFileLoader.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/loaders/impl/SimpleWebFileLoader.java 2012-09-19 17:40:28 UTC (rev 43840)
+++ trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/loaders/impl/SimpleWebFileLoader.java 2012-09-19 17:41:44 UTC (rev 43841)
@@ -23,7 +23,7 @@
import org.jboss.tools.common.model.plugin.ModelPlugin;
import org.jboss.tools.common.model.util.*;
-public class SimpleWebFileLoader implements SerializingLoader {
+public class SimpleWebFileLoader implements SerializingLoader, XModelObjectConstants {
protected XModelObjectLoaderUtil util = createUtil();
public SimpleWebFileLoader() {
@@ -59,8 +59,8 @@
loadNamespace(element, object);
//// String postfix = (namespace == null) ? "" : ":" + namespace;
String postfix = ""; //$NON-NLS-1$
- element.setAttribute(XModelObjectConstants.XML_ATTR_NAME + postfix, object.getAttributeValue(XModelObjectConstants.ATTR_NAME));
- element.setAttribute("EXTENSION" + postfix, object.getAttributeValue(XModelObjectConstants.ATTR_NAME_EXTENSION)); //$NON-NLS-1$
+ element.setAttribute(XML_ATTR_NAME + postfix, object.getAttributeValue(ATTR_NAME));
+ element.setAttribute("EXTENSION" + postfix, object.getAttributeValue(ATTR_NAME_EXTENSION)); //$NON-NLS-1$
util.load(element, object);
String loadingError = util.getError();
@@ -72,8 +72,8 @@
((AbstractXMLFileImpl)object).setLoaderError(loadingError);
if(!((AbstractXMLFileImpl)object).isIncorrect() && loadingError != null) {
- object.setAttributeValue(XModelObjectConstants.ATTR_NAME_IS_INCORRECT, XModelObjectConstants.YES);
- object.setAttributeValue("incorrectBody", body); //$NON-NLS-1$
+ object.setAttributeValue(ATTR_NAME_IS_INCORRECT, YES);
+ object.setAttributeValue(ATTR_NAME_INCORRECT_BODY, body);
object.set("actualBodyTimeStamp", "" + object.getTimeStamp()); //$NON-NLS-1$ //$NON-NLS-2$
}
}
@@ -84,16 +84,16 @@
String[] errors =
XMLUtil.getXMLErrors(new StringReader(body), resolution == EntityXMLRegistration.DTD && isCheckingDTD(), resolution == EntityXMLRegistration.SCHEMA);
if(errors != null && errors.length > 0) {
- object.setAttributeValue(XModelObjectConstants.ATTR_NAME_IS_INCORRECT, XModelObjectConstants.YES);
- object.set("correctBody", ""); //$NON-NLS-1$ //$NON-NLS-2$
- object.setAttributeValue("incorrectBody", body); //$NON-NLS-1$
+ object.setAttributeValue(ATTR_NAME_IS_INCORRECT, YES);
+ object.set(ATTR_NAME_CORRECT_BODY, ""); //$NON-NLS-1$
+ object.setAttributeValue(ATTR_NAME_INCORRECT_BODY, body);
object.set("actualBodyTimeStamp", "-1"); //$NON-NLS-1$ //$NON-NLS-2$
// return;
} else {
- object.setAttributeValue(XModelObjectConstants.ATTR_NAME_IS_INCORRECT, XModelObjectConstants.NO);
- object.set("correctBody", body); //$NON-NLS-1$
+ object.setAttributeValue(ATTR_NAME_IS_INCORRECT, NO);
+ object.set(ATTR_NAME_CORRECT_BODY, body);
object.set("actualBodyTimeStamp", "0"); //$NON-NLS-1$ //$NON-NLS-2$
- object.setAttributeValue("incorrectBody", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ object.setAttributeValue(ATTR_NAME_INCORRECT_BODY, ""); //$NON-NLS-1$
}
return XMLUtil.getDocument(new StringReader(body));
}
@@ -157,11 +157,11 @@
public boolean save(XModelObject object) {
if (!object.isModified()) return true;
- if(XModelObjectConstants.YES.equals(object.get(XModelObjectConstants.ATTR_NAME_IS_INCORRECT))) {
- XModelObjectLoaderUtil.setTempBody(object, object.get("incorrectBody")); //$NON-NLS-1$
+ if(YES.equals(object.get(ATTR_NAME_IS_INCORRECT))) {
+ XModelObjectLoaderUtil.setTempBody(object, object.get(ATTR_NAME_INCORRECT_BODY));
return true;
}
- String main = object.get(XModelObjectConstants.ATTR_NAME_BODY);
+ String main = object.get(ATTR_NAME_BODY);
if(main == null) return false;
XModelObjectLoaderUtil.setTempBody(object, main);
return true;
Modified: trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/markers/XMarkerManager.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/markers/XMarkerManager.java 2012-09-19 17:40:28 UTC (rev 43840)
+++ trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/markers/XMarkerManager.java 2012-09-19 17:41:44 UTC (rev 43841)
@@ -15,6 +15,11 @@
import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.CoreException;
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.swt.widgets.Display;
+import org.eclipse.ui.progress.UIJob;
import org.jboss.tools.common.model.XJob;
import org.jboss.tools.common.model.XModelObject;
@@ -126,25 +131,31 @@
UpdateJob updateJob = new UpdateJob();
- class UpdateJob implements XRunnable {
+ class UpdateJob extends UIJob {// implements XRunnable {
Set<IFile> fs = new HashSet<IFile>();
boolean running = false;
+ UpdateJob() {
+ super(Display.getDefault(), "XMarkerManager");
+ }
+
public String getId() {
return "XMarkerManager"; //$NON-NLS-1$
}
- public void run() {
+// public void run() {
+ public IStatus runInUIThread(IProgressMonitor monitor) {
synchronized (this) {
running = true;
}
+// try {
+// Thread.sleep(100);
+// } catch (InterruptedException e) {
+// return Status.OK_STATUS;
+// }
try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
- return;
- }
- try {
IFile f = null;
- while((f = next()) != null) {
+ while((f = nextFile()) != null) {
+ System.out.println("Reloading " + f);
reload(f);
}
} finally {
@@ -152,9 +163,10 @@
running = false;
}
}
+ return Status.OK_STATUS;
}
- synchronized IFile next() {
+ synchronized IFile nextFile() {
if(fs.isEmpty()) {
return null;
}
@@ -169,7 +181,9 @@
}
fs.add(f);
if(!running) {
- XJob.addRunnable(updateJob);
+// XJob.addRunnable(updateJob);
+ running = true;
+ schedule(100);
}
}
}
Modified: trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/plugin/ModelPlugin.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/plugin/ModelPlugin.java 2012-09-19 17:40:28 UTC (rev 43840)
+++ trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/plugin/ModelPlugin.java 2012-09-19 17:41:44 UTC (rev 43841)
@@ -30,6 +30,7 @@
import org.eclipse.ui.IWorkbenchWindow;
import org.jboss.tools.common.log.BaseUIPlugin;
import org.jboss.tools.common.log.IPluginLog;
+import org.jboss.tools.common.model.XJob;
import org.jboss.tools.common.model.XModelConstants;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.osgi.framework.BundleContext;
@@ -39,14 +40,27 @@
private static ModelPlugin plugin;
private ResourceBundle resourceBundle;
private XModelSaveParticipant save = new XModelSaveParticipant();
+ public static final String TEMP_FILE_PREFIX = "efs_";
+ File tempFolder;
public ModelPlugin() {
plugin = this;
+ try {
+ File f = File.createTempFile(TEMP_FILE_PREFIX, ".x"); //$NON-NLS-1$ //$NON-NLS-2$
+ tempFolder = f.getParentFile();
+ f.deleteOnExit();
+ } catch (IOException e) {
+ getPluginLog().logError("ModelPlugin:requestForTempFolder:" + e.getMessage()); //$NON-NLS-1$
+ }
}
public static ModelPlugin getDefault() {
return plugin;
}
+
+ public File getTempFolder() {
+ return tempFolder;
+ }
public static boolean isDebugEnabled() {
return getDefault().isDebugging();
@@ -85,19 +99,16 @@
public void stop(BundleContext context) throws Exception {
super.stop(context);
cleanTempFiles();
+ XJob.shutdown();
}
private void cleanTempFiles() {
- try {
- File f = File.createTempFile("efs_", ".x"); //$NON-NLS-1$ //$NON-NLS-2$
- f = f.getParentFile();
- File[] fs = f.listFiles();
+ if(tempFolder != null && tempFolder.exists()) {
+ File[] fs = tempFolder.listFiles();
if(fs != null) for (int i = 0; i < fs.length; i++) {
String n = fs[i].getName();
if(n.startsWith("efs_")) fs[i].delete(); //$NON-NLS-1$
}
- } catch (IOException e) {
- getPluginLog().logError("ModelPlugin:cleanTempFiles:" + e.getMessage()); //$NON-NLS-1$
}
}
More information about the jbosstools-commits
mailing list