Author: tfennelly
Date: 2009-11-30 18:20:03 -0500 (Mon, 30 Nov 2009)
New Revision: 18933
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/RuntimeMetadata.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/editor/AbstractSmooksFormEditor.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5323
Only open the Smooks Configuration if the editor can support the configurations therein
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/RuntimeMetadata.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/RuntimeMetadata.java 2009-11-30
22:22:22 UTC (rev 18932)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/RuntimeMetadata.java 2009-11-30
23:20:03 UTC (rev 18933)
@@ -135,7 +135,15 @@
reset();
if(smooksConfig != null) {
- configFile = new File(smooksConfig.getRawLocation().toOSString().trim());
+ setSmooksConfig(new File(smooksConfig.getRawLocation().toOSString().trim()));
+ }
+ }
+
+ public void setSmooksConfig(File file) {
+ reset();
+
+ if(file != null) {
+ configFile = file;
if(configFile.exists() && configFile.isFile()) {
ExecutionContext execContext = metadataExtractor.createExecutionContext();
Properties inputParams = new Properties();
@@ -172,7 +180,7 @@
}
}
}
-
+
private void reset() {
isSmooksConfig = false;
isValidSmooksConfig = false;
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/editor/AbstractSmooksFormEditor.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/editor/AbstractSmooksFormEditor.java 2009-11-30
22:22:22 UTC (rev 18932)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/editor/AbstractSmooksFormEditor.java 2009-11-30
23:20:03 UTC (rev 18933)
@@ -2,6 +2,7 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
+import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
@@ -59,6 +60,8 @@
import org.eclipse.ui.ide.FileStoreEditorInput;
import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.wst.sse.ui.StructuredTextEditor;
+import org.jboss.tools.smooks.configuration.RuntimeDependency;
+import org.jboss.tools.smooks.configuration.RuntimeMetadata;
import org.jboss.tools.smooks.configuration.SmooksConfigurationActivator;
import org.jboss.tools.smooks.configuration.SmooksConstants;
import org.jboss.tools.smooks.configuration.editors.SmooksXMLEditor;
@@ -610,21 +613,27 @@
String filePath = null;
String partName = "smooks editor";
IFile file = null;
+ RuntimeMetadata runtimeMetadata = new RuntimeMetadata();
+
if (input instanceof FileStoreEditorInput) {
try {
filePath = ((FileStoreEditorInput) input).getURI().toURL().getFile();
+ runtimeMetadata.setSmooksConfig(new File(filePath));
} catch (MalformedURLException e) {
throw new PartInitException("Transform URL to URL error.", e);
}
}
if (input instanceof IFileEditorInput) {
file = ((IFileEditorInput) input).getFile();
+ runtimeMetadata.setSmooksConfig(file);
filePath = file.getFullPath().toPortableString();
partName = file.getName();
}
if (filePath == null)
throw new PartInitException("Can't get the input file");
+
+ assertConfigSupported(runtimeMetadata);
Resource smooksResource = null;
@@ -658,6 +667,16 @@
judgeInputReader();
}
+ private void assertConfigSupported(RuntimeMetadata runtimeMetadata) throws
PartInitException {
+ List<RuntimeDependency> dependencies = runtimeMetadata.getDependencies();
+
+ for(RuntimeDependency dependency : dependencies) {
+ if(!dependency.isSupportedByEditor()) {
+ throw new PartInitException("\n\nSorry, this configuration is not yet supported
by the Smooks Editor because it contains configurations from the '" +
dependency.getNamespaceURI() + "' configuration namespace.\n\nPlease open this
configuration using the XML Editor.");
+ }
+ }
+ }
+
protected void judgeInputReader() {
SmooksResourceListType resourceList =
SmooksUIUtils.getSmooks11ResourceListType(smooksModel);
if (resourceList == null)