You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shale.apache.org by gv...@apache.org on 2007/07/23 19:51:18 UTC

svn commit: r558812 [4/4] - in /shale/sandbox/shale-eclipse-plugins: ./ plugins/ plugins/shale_clay_plugin_for_eclipse/ plugins/shale_clay_plugin_for_eclipse/META-INF/ plugins/shale_clay_plugin_for_eclipse/icons/ plugins/shale_clay_plugin_for_eclipse/l...

Added: shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/symbols/SymbolsMetadataList.java
URL: http://svn.apache.org/viewvc/shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/symbols/SymbolsMetadataList.java?view=auto&rev=558812
==============================================================================
--- shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/symbols/SymbolsMetadataList.java (added)
+++ shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/symbols/SymbolsMetadataList.java Mon Jul 23 10:51:09 2007
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package clay_plugin.symbols;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.apache.shale.clay.config.beans.ComponentBean;
+import org.apache.shale.clay.config.beans.SymbolBean;
+
+import clay_plugin.editor.ComponentEditedListener;
+
+public class SymbolsMetadataList {
+
+	private ComponentBean component;
+
+	private Set changeListeners = new HashSet();
+
+	private ComponentEditedListener listener = null;
+
+	public SymbolsMetadataList(ComponentEditedListener listener,
+			ComponentBean component) {
+		this.listener = listener;
+		this.component = component;
+	}
+
+	public void removeChangeListener(SymbolsMetadataViewer viewer) {
+		changeListeners.remove(viewer);
+	}
+
+	public void addChangeListener(SymbolsMetadataViewer viewer) {
+		changeListeners.add(viewer);
+	}
+
+	public void addSymbol() {
+		SymbolBean s = new SymbolBean();
+		s.setName(createSymbolName());
+		s.setValue("");
+		component.addSymbol(s);
+		Iterator iterator = changeListeners.iterator();
+		while (iterator.hasNext())
+			((SymbolsMetadataViewer) iterator.next()).addSymbol(s);
+
+		listener.componentEdited(component);
+	}
+
+	public void removeSymbol(SymbolBean symbol) {
+		component.getSymbols().remove(symbol.getName().toLowerCase());
+		Iterator iterator = changeListeners.iterator();
+		while (iterator.hasNext())
+			((SymbolsMetadataViewer) iterator.next()).removeSymbol(symbol);
+
+		listener.componentEdited(component);
+	}
+
+	public void updateSymbol(String oldName, SymbolBean symbol) {
+		if (oldName != null) {
+			component.getSymbols().remove(oldName.toLowerCase());
+		}
+
+		component.getSymbols().put(symbol.getName(), symbol);
+		Iterator iterator = changeListeners.iterator();
+		while (iterator.hasNext())
+			((SymbolsMetadataViewer) iterator.next()).updateSymbol(symbol);
+
+		listener.componentEdited(component);
+	}
+
+	protected String createSymbolName() {
+		StringBuffer symbolName = new StringBuffer();
+		symbolName.append("symbol");
+		int suffix = 1;
+		int start = symbolName.length();
+		symbolName.append(suffix);
+		while (component.getSymbols().containsKey(
+				symbolName.toString().toLowerCase())) {
+			symbolName = symbolName.delete(start, symbolName.length());
+			suffix++;
+			symbolName.append(suffix);
+
+		}
+		return symbolName.toString();
+	}
+
+}

Propchange: shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/symbols/SymbolsMetadataList.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/symbols/SymbolsMetadataViewer.java
URL: http://svn.apache.org/viewvc/shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/symbols/SymbolsMetadataViewer.java?view=auto&rev=558812
==============================================================================
--- shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/symbols/SymbolsMetadataViewer.java (added)
+++ shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/symbols/SymbolsMetadataViewer.java Mon Jul 23 10:51:09 2007
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package clay_plugin.symbols;
+
+import org.apache.shale.clay.config.beans.SymbolBean;
+
+public interface SymbolsMetadataViewer {
+
+	public void addSymbol(SymbolBean symbol);
+
+	public void removeSymbol(SymbolBean symbol);
+
+	public void updateSymbol(SymbolBean symbol);
+
+}

Propchange: shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/symbols/SymbolsMetadataViewer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/util/AbstractXMLVisitor.java
URL: http://svn.apache.org/viewvc/shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/util/AbstractXMLVisitor.java?view=auto&rev=558812
==============================================================================
--- shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/util/AbstractXMLVisitor.java (added)
+++ shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/util/AbstractXMLVisitor.java Mon Jul 23 10:51:09 2007
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package clay_plugin.util;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipException;
+import java.util.zip.ZipFile;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceVisitor;
+import org.eclipse.core.runtime.CoreException;
+
+public abstract class AbstractXMLVisitor implements IResourceVisitor {
+
+	public abstract boolean visit(IResource resource) throws CoreException;
+
+	public void visitJar(File resource) {
+
+		try {
+			ZipFile zipFile = new ZipFile(resource);
+
+			Enumeration entries = zipFile.entries();
+
+			while (entries.hasMoreElements()) {
+				ZipEntry entry = (ZipEntry) entries.nextElement();
+
+				if (entry.isDirectory()) {
+					continue;
+				}
+
+				if (entry.getName().endsWith(".xml")) {
+
+					URL jarEntryUrl = JarUtils.getJarEntryURL(resource, entry);
+
+					visitXML(resource, jarEntryUrl);
+				}
+
+			}
+
+		} catch (ZipException e) {
+			// TODO Auto-generated catch block
+			
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			
+		}
+
+	}
+
+	public void visitJar(IResource resource) {
+		visitJar(resource.getLocation().toFile());
+	}
+
+	public abstract void visitXML(File resource, URL url);
+
+	public abstract void visitXML(IResource resource, URL url);
+
+}

Propchange: shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/util/AbstractXMLVisitor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/util/ArrayUtils.java
URL: http://svn.apache.org/viewvc/shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/util/ArrayUtils.java?view=auto&rev=558812
==============================================================================
--- shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/util/ArrayUtils.java (added)
+++ shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/util/ArrayUtils.java Mon Jul 23 10:51:09 2007
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package clay_plugin.util;
+
+/**
+ * @author rwynn Utility methods for arrays
+ */
+public class ArrayUtils {
+
+	public static Object[] concat(Object[] a1, Object[] a2) {
+		Object[] result = new Object[a1.length + a2.length];
+		System.arraycopy(a1, 0, result, 0, a1.length);
+		System.arraycopy(a2, 0, result, a1.length, a2.length);
+		return result;
+	}
+
+	public static Object concat(Object[] a1, Object[] a2, Object[] a3) {
+		Object[] a2a3 = (Object[]) ArrayUtils.concat(a2, a3);
+		return ArrayUtils.concat(a1, a2a3);
+	}
+	
+	public static String[] concat(String[] a1, String[] a2) {
+		String[] result = new String[a1.length + a2.length];
+		System.arraycopy(a1, 0, result, 0, a1.length);
+		System.arraycopy(a2, 0, result, a1.length, a2.length);
+		return result;
+	}
+
+}

Propchange: shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/util/ArrayUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/util/ClayResourceDeltaVisitor.java
URL: http://svn.apache.org/viewvc/shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/util/ClayResourceDeltaVisitor.java?view=auto&rev=558812
==============================================================================
--- shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/util/ClayResourceDeltaVisitor.java (added)
+++ shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/util/ClayResourceDeltaVisitor.java Mon Jul 23 10:51:09 2007
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package clay_plugin.util;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.resources.IResourceDeltaVisitor;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.gef.ui.palette.PaletteViewer;
+
+import clay_plugin.editor.VisualEditorViewer;
+import clay_plugin.jobs.ClaySearchJob;
+import clay_plugin.jobs.EditorListener;
+
+public class ClayResourceDeltaVisitor implements IResourceDeltaVisitor {
+
+	private PaletteViewer paletteViewer;
+
+	private VisualEditorViewer viewer;
+
+	public ClayResourceDeltaVisitor(VisualEditorViewer viewer,
+			PaletteViewer paletteViewer) {
+		this.viewer = viewer;
+		this.paletteViewer = paletteViewer;
+	}
+
+	public boolean visit(IResourceDelta delta) throws CoreException {
+
+		IResource resource = delta.getResource();
+
+		if (resource instanceof IFile) {
+
+			if (!resource.isDerived()) {
+
+				if ("xml".equalsIgnoreCase(resource.getFileExtension())
+						|| "jar".equalsIgnoreCase(resource.getFileExtension())) {
+
+					ClaySearchJob job = new ClaySearchJob(
+							resource.getProject(), "Updating Clay Components");
+					job.addJobChangeListener(new EditorListener(viewer,
+							paletteViewer));
+					job.schedule();
+
+				}
+			}
+
+			return false;
+		}
+
+		else if (resource instanceof IProject) {
+			if (delta.getKind() == IResourceDelta.REMOVED) {
+
+				ClaySearchJob job = new ClaySearchJob(resource.getProject(),
+						"Updating Clay Components");
+				job.addJobChangeListener(new EditorListener(viewer,
+						paletteViewer));
+				job.schedule();
+
+				return false;
+
+			} else {
+				return true;
+			}
+
+		} else {
+			return true;
+		}
+	}
+
+}

Propchange: shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/util/ClayResourceDeltaVisitor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/util/ClayXMLResourceChangeListener.java
URL: http://svn.apache.org/viewvc/shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/util/ClayXMLResourceChangeListener.java?view=auto&rev=558812
==============================================================================
--- shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/util/ClayXMLResourceChangeListener.java (added)
+++ shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/util/ClayXMLResourceChangeListener.java Mon Jul 23 10:51:09 2007
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package clay_plugin.util;
+
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.gef.ui.palette.PaletteViewer;
+
+import clay_plugin.editor.VisualEditorViewer;
+
+public class ClayXMLResourceChangeListener implements IResourceChangeListener {
+
+	private PaletteViewer paletteViewer;
+	
+	private VisualEditorViewer viewer;
+
+	public ClayXMLResourceChangeListener(VisualEditorViewer viewer, PaletteViewer paletteViewer) {
+		this.viewer = viewer;
+		this.paletteViewer = paletteViewer;
+	}
+
+	public void resourceChanged(IResourceChangeEvent event) {
+
+		IResourceDelta delta = event.getDelta();
+
+		try {
+			delta.accept(new ClayResourceDeltaVisitor(viewer, paletteViewer));
+
+		} catch (CoreException e) {
+
+			
+		}
+
+	}
+
+}

Propchange: shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/util/ClayXMLResourceChangeListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/util/ClayXMLVisitor.java
URL: http://svn.apache.org/viewvc/shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/util/ClayXMLVisitor.java?view=auto&rev=558812
==============================================================================
--- shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/util/ClayXMLVisitor.java (added)
+++ shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/util/ClayXMLVisitor.java Mon Jul 23 10:51:09 2007
@@ -0,0 +1,153 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package clay_plugin.util;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.apache.shale.clay.config.ClayConfigParser;
+import org.apache.shale.clay.config.ClayXmlParser;
+import org.apache.shale.clay.config.beans.ComponentConfigBean;
+import org.apache.shale.clay.config.beans.ConfigBean;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.xml.sax.SAXException;
+
+import clay_plugin.ext.ComponentConfigBeanExt;
+import clay_plugin.model.ClayXMLModel;
+
+public class ClayXMLVisitor extends AbstractXMLVisitor {
+
+	private ClayXMLModel model;
+
+	private IProject project;
+
+	public ClayXMLVisitor(IProject project, ClayXMLModel model) {
+
+		this.model = model;
+
+		this.project = project;
+
+	}
+
+	public boolean visit(File resource) {
+
+		if (resource.isDirectory()) {
+			File[] children = resource.listFiles();
+			for (int j = 0; j < children.length; ++j) {
+				visit(children[j]);
+			}
+		}
+
+		if (resource.getName().endsWith(".jar")) {
+			visitJar(resource);
+
+		} else if (resource.getName().endsWith(".xml")) {
+
+			try {
+				visitXML(resource, resource.toURL());
+
+			} catch (MalformedURLException e) {
+
+			}
+		}
+
+		return false;
+
+	}
+
+	public void visitXML(File resource, URL url) {
+
+		try {
+			ClayConfigParser parser = getParser();
+
+			parser.loadConfigFile(url, null);
+
+			ComponentConfigBeanExt added = (ComponentConfigBeanExt) parser
+					.getConfig();
+
+			model.mergeConfig(project, added);
+
+		} catch (IOException e) {
+
+		} catch (SAXException e) {
+
+		}
+
+	}
+
+	public boolean visit(IResource resource) {
+
+		if (resource.getType() != IResource.FILE) {
+			return true;
+		}
+
+		String ext = resource.getFileExtension();
+
+		if ("jar".equalsIgnoreCase(ext)) {
+			visitJar(resource);
+
+		} else if ("xml".equalsIgnoreCase(ext)) {
+
+			try {
+				visitXML(resource, resource.getLocation().toFile().toURL());
+
+			} catch (MalformedURLException e) {
+
+			}
+		}
+
+		return false;
+
+	}
+
+	public void visitXML(IResource resource, URL url) {
+
+		try {
+			ClayConfigParser parser = getParser();
+
+			parser.loadConfigFile(url, null);
+
+			ComponentConfigBeanExt added = (ComponentConfigBeanExt) parser
+					.getConfig();
+
+			model.mergeConfig(resource, added);
+
+		} catch (IOException e) {
+
+		} catch (SAXException e) {
+
+		}
+
+	}
+
+	protected ClayConfigParser getParser() {
+		ClayConfigParser parser = new ClayXmlParser();
+		parser.setConfig(getConfigBean());
+		return parser;
+	}
+
+	protected ConfigBean getConfigBean() {
+		ComponentConfigBean configBean = new ComponentConfigBeanExt();
+		configBean.setDesigntime(true);
+		return configBean;
+	}
+
+}

Propchange: shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/util/ClayXMLVisitor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/util/CloneUtil.java
URL: http://svn.apache.org/viewvc/shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/util/CloneUtil.java?view=auto&rev=558812
==============================================================================
--- shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/util/CloneUtil.java (added)
+++ shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/util/CloneUtil.java Mon Jul 23 10:51:09 2007
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package clay_plugin.util;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+
+import org.eclipse.core.resources.ResourcesPlugin;
+
+public class CloneUtil {
+
+	public static Object clone(Serializable obj) {
+
+		ObjectOutputStream oos = null;
+		ObjectInputStream ois = null;
+		Object clone = null;
+
+		try {
+			File workspace = ResourcesPlugin.getWorkspace().getRoot()
+					.getLocation().toFile();
+
+			File temp = File.createTempFile("clone", "bin", workspace);
+
+			temp.deleteOnExit();
+
+			oos = new ObjectOutputStream(new FileOutputStream(temp));
+
+			oos.writeObject(obj);
+
+			oos.flush();
+
+			oos.close();
+
+			ois = new ObjectInputStream(new FileInputStream(temp));
+
+			clone = ois.readObject();
+
+			ois.close();
+			
+			temp.delete();
+
+		}
+
+		catch (Exception e) {
+
+			
+
+		} finally {
+
+			if (oos != null) {
+				try {
+					oos.close();
+				} catch (Exception e1) {
+				}
+			}
+
+			if (ois != null) {
+				try {
+					ois.close();
+				} catch (Exception e2) {
+				}
+			}
+
+		}
+		
+		return clone;
+
+	}
+}

Propchange: shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/util/CloneUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/util/FacesConfigVisitor.java
URL: http://svn.apache.org/viewvc/shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/util/FacesConfigVisitor.java?view=auto&rev=558812
==============================================================================
--- shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/util/FacesConfigVisitor.java (added)
+++ shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/util/FacesConfigVisitor.java Mon Jul 23 10:51:09 2007
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package clay_plugin.util;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.eclipse.core.resources.IResource;
+
+import clay_plugin.faces.FacesConfigModel;
+import clay_plugin.faces.FacesConfigParser;
+import clay_plugin.faces.ManagedBean;
+
+public class FacesConfigVisitor extends AbstractXMLVisitor {
+
+	protected FacesConfigModel model;
+
+	public FacesConfigVisitor(FacesConfigModel model) {
+		this.model = model;
+	}
+
+	public void visitXML(File resource, URL url) {
+		// TODO Auto-generated method stub
+
+	}
+
+	public boolean visit(IResource resource) {
+
+		if (resource.getType() != IResource.FILE) {
+			return true;
+		}
+
+		String ext = resource.getFileExtension();
+
+		if ("jar".equalsIgnoreCase(ext)) {
+			visitJar(resource);
+
+		} else if ("xml".equalsIgnoreCase(ext)) {
+
+			try {
+				visitXML(resource, resource.getLocation().toFile().toURL());
+
+			} catch (MalformedURLException e) {
+
+				
+			}
+		}
+
+		return false;
+
+	}
+
+	public void visitXML(IResource resource, URL url) {
+
+		try {
+			FacesConfigParser parser = getParser(url);
+
+			ManagedBean[] beans = parser.parse();
+
+			model.addManagedBeans(resource, beans);
+
+		} catch (Exception e) {
+
+			
+		}
+
+	}
+
+	protected FacesConfigParser getParser(URL url) {
+		return new FacesConfigParser(url);
+	}
+
+	public FacesConfigModel getModel() {
+		return model;
+	}
+	
+	
+
+}

Propchange: shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/util/FacesConfigVisitor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/util/JarUtils.java
URL: http://svn.apache.org/viewvc/shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/util/JarUtils.java?view=auto&rev=558812
==============================================================================
--- shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/util/JarUtils.java (added)
+++ shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/util/JarUtils.java Mon Jul 23 10:51:09 2007
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package clay_plugin.util;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.zip.ZipEntry;
+
+import org.eclipse.core.resources.IResource;
+
+public class JarUtils {
+
+	public static URL getJarEntryURL(IResource jar, ZipEntry entry) {
+
+		return getJarEntryURL(jar.getLocation().toFile(), entry);
+
+	}
+
+	public static URL getJarEntryURL(File jar, ZipEntry entry) {
+
+		try {
+			return new URL("jar:file:" + jar.getAbsolutePath() + "!/"
+					+ entry.getName());
+		} catch (MalformedURLException e) {
+
+			
+			return null;
+		}
+
+	}
+
+}

Propchange: shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/util/JarUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/util/PaletteDrawers.java
URL: http://svn.apache.org/viewvc/shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/util/PaletteDrawers.java?view=auto&rev=558812
==============================================================================
--- shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/util/PaletteDrawers.java (added)
+++ shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/util/PaletteDrawers.java Mon Jul 23 10:51:09 2007
@@ -0,0 +1,309 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package clay_plugin.util;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.shale.clay.config.beans.ComponentBean;
+import org.eclipse.gef.SharedImages;
+import org.eclipse.gef.palette.CreationToolEntry;
+import org.eclipse.gef.palette.PaletteDrawer;
+import org.eclipse.gef.palette.ToolEntry;
+
+import clay_plugin.ext.ComponentConfigBeanExt;
+
+public class PaletteDrawers {
+
+	private ComponentConfigBeanExt config;
+
+	private PaletteDrawer abstractDrawer;
+
+	private PaletteDrawer otherDrawer;
+
+	private PaletteDrawer shaleDrawer;
+
+	private PaletteDrawer inputDrawer;
+
+	private PaletteDrawer outputDrawer;
+
+	private PaletteDrawer dataDrawer;
+
+	private PaletteDrawer commandDrawer;
+
+	private PaletteDrawer validatorDrawer;
+
+	private PaletteDrawer converterDrawer;
+
+	private PaletteDrawer tomahawkDrawer;
+	
+	private PaletteDrawer ibmDrawer;
+	
+
+	private List drawerList;
+
+	public PaletteDrawers(ComponentConfigBeanExt config) {
+		this.config = config;
+	}
+
+	public List getDrawers() {
+
+		Iterator i = config.getSortedElements().iterator();
+		while (i.hasNext()) {
+
+			ComponentBean next = (ComponentBean) i.next();
+
+			ToolEntry entry = new CreationToolEntry(next.getJsfid(), next
+					.getDescription(), null,
+					SharedImages.DESC_SELECTION_TOOL_16,
+					SharedImages.DESC_SELECTION_TOOL_16);
+
+			String componentType = getComponentType(next);
+
+			if (detectValidator(next)) {
+				getValidatorDrawer().add(entry);
+			}
+
+			else if (detectConverter(next)) {
+				getConverterDrawer().add(entry);
+			}
+
+			else if (componentType == null) {
+				getOtherDrawer().add(entry);
+			}
+
+			else if ("override".equals(componentType)) {
+
+				getAbstractDrawer().add(entry);
+			}
+
+			else if (componentType.startsWith("org.apache.shale")) {
+				getShaleDrawer().add(entry);
+			}
+
+			else if (componentType.startsWith("javax.faces.HtmlInput")
+					|| componentType.startsWith("javax.faces.HtmlSelect")
+					|| componentType.equals("javax.faces.HtmlForm")
+					|| componentType.equals("javax.faces.Parameter")
+					|| componentType.startsWith("javax.faces.SelectItem")) {
+				getInputDrawer().add(entry);
+
+			}
+
+			else if (componentType.startsWith("javax.faces.HtmlOutput")
+					|| componentType.startsWith("javax.faces.HtmlMessage")) {
+				getOutputDrawer().add(entry);
+			}
+
+			else if (componentType.equals("javax.faces.HtmlDataTable")
+					|| componentType.equals("javax.faces.Column")) {
+				getDataDrawer().add(entry);
+			}
+
+			else if (componentType.startsWith("javax.faces.HtmlCommand")) {
+				getCommandDrawer().add(entry);
+			}
+
+			else if (detectTomahawk(next)) {
+				getTomahawkDrawer().add(entry);
+			}
+			
+			else if (detectIBM(next)) {
+				getIbmDrawer().add(entry);
+			}
+
+			else {
+				getOtherDrawer().add(entry);
+			}
+
+		}
+
+		Collections.sort(getDrawerList(), new Comparator() {
+
+			public int compare(Object o1, Object o2) {
+				PaletteDrawer pd1 = (PaletteDrawer) o1;
+				PaletteDrawer pd2 = (PaletteDrawer) o2;
+				return pd1.getLabel().compareTo(pd2.getLabel());
+			}
+
+		});
+
+		return getDrawerList();
+	}
+
+	protected PaletteDrawer getAbstractDrawer() {
+		if (abstractDrawer == null) {
+			abstractDrawer = new PaletteDrawer("Abstract");
+			abstractDrawer.setInitialState(PaletteDrawer.INITIAL_STATE_CLOSED);
+			getDrawerList().add(abstractDrawer);
+		}
+
+		return abstractDrawer;
+	}
+
+	public PaletteDrawer getOtherDrawer() {
+		if (otherDrawer == null) {
+			otherDrawer = new PaletteDrawer("Other");
+			otherDrawer.setInitialState(PaletteDrawer.INITIAL_STATE_CLOSED);
+			getDrawerList().add(otherDrawer);
+		}
+		return otherDrawer;
+	}
+
+	public PaletteDrawer getShaleDrawer() {
+		if (shaleDrawer == null) {
+			shaleDrawer = new PaletteDrawer("Shale");
+			shaleDrawer.setInitialState(PaletteDrawer.INITIAL_STATE_CLOSED);
+			getDrawerList().add(shaleDrawer);
+		}
+		return shaleDrawer;
+	}
+
+	public PaletteDrawer getInputDrawer() {
+		if (inputDrawer == null) {
+			inputDrawer = new PaletteDrawer("Input");
+			inputDrawer.setInitialState(PaletteDrawer.INITIAL_STATE_CLOSED);
+			getDrawerList().add(inputDrawer);
+		}
+		return inputDrawer;
+	}
+
+	public PaletteDrawer getOutputDrawer() {
+		if (outputDrawer == null) {
+			outputDrawer = new PaletteDrawer("Output");
+			outputDrawer.setInitialState(PaletteDrawer.INITIAL_STATE_CLOSED);
+			getDrawerList().add(outputDrawer);
+		}
+		return outputDrawer;
+	}
+
+	public PaletteDrawer getDataDrawer() {
+		if (dataDrawer == null) {
+			dataDrawer = new PaletteDrawer("Data");
+			dataDrawer.setInitialState(PaletteDrawer.INITIAL_STATE_CLOSED);
+			getDrawerList().add(dataDrawer);
+		}
+		return dataDrawer;
+	}
+
+	public PaletteDrawer getCommandDrawer() {
+		if (commandDrawer == null) {
+			commandDrawer = new PaletteDrawer("Command");
+			commandDrawer.setInitialState(PaletteDrawer.INITIAL_STATE_CLOSED);
+			getDrawerList().add(commandDrawer);
+		}
+		return commandDrawer;
+	}
+
+	public PaletteDrawer getConverterDrawer() {
+		if (converterDrawer == null) {
+			converterDrawer = new PaletteDrawer("Converter");
+			converterDrawer.setInitialState(PaletteDrawer.INITIAL_STATE_CLOSED);
+			getDrawerList().add(converterDrawer);
+		}
+		return converterDrawer;
+	}
+
+	public PaletteDrawer getValidatorDrawer() {
+		if (validatorDrawer == null) {
+			validatorDrawer = new PaletteDrawer("Validator");
+			validatorDrawer.setInitialState(PaletteDrawer.INITIAL_STATE_CLOSED);
+			getDrawerList().add(validatorDrawer);
+		}
+		return validatorDrawer;
+	}
+
+	public PaletteDrawer getTomahawkDrawer() {
+		if (tomahawkDrawer == null) {
+			tomahawkDrawer = new PaletteDrawer("Tomahawk");
+			tomahawkDrawer.setInitialState(PaletteDrawer.INITIAL_STATE_CLOSED);
+			getDrawerList().add(tomahawkDrawer);
+		}
+		return tomahawkDrawer;
+	}
+	
+	public PaletteDrawer getIbmDrawer() {
+		if (ibmDrawer == null) {
+			ibmDrawer = new PaletteDrawer("IBM");
+			ibmDrawer.setInitialState(PaletteDrawer.INITIAL_STATE_CLOSED);
+			getDrawerList().add(ibmDrawer);
+		}
+		return ibmDrawer;
+	}
+
+	protected List getDrawerList() {
+		if (drawerList == null) {
+			drawerList = new ArrayList();
+		}
+		return drawerList;
+	}
+
+	protected String getComponentType(ComponentBean in) {
+
+		if (in.getComponentType() != null) {
+			return in.getComponentType();
+		} else {
+			if (in.getExtends() != null) {
+				ComponentBean parent = config.getElement(in.getExtends());
+				if (parent != null) {
+					return getComponentType(parent);
+				}
+			}
+		}
+
+		return null;
+
+	}
+
+	protected boolean detectValidator(ComponentBean in) {
+		String[] flags = new String[] { "validate", "Validate", "validator",
+				"Validator" };
+		for (int i = 0; i < flags.length; ++i) {
+			if (in.getJsfid().indexOf(flags[i]) != -1) {
+				return true;
+			}
+		}
+		return false;
+
+	}
+
+	protected boolean detectConverter(ComponentBean in) {
+		String[] flags = new String[] { "convert", "Convert", "converter",
+				"Converter" };
+		for (int i = 0; i < flags.length; ++i) {
+			if (in.getJsfid().indexOf(flags[i]) != -1) {
+				return true;
+			}
+		}
+		return false;
+
+	}
+
+	protected boolean detectTomahawk(ComponentBean in) {
+		return in.getJsfid().startsWith("t:");
+	}
+
+	protected boolean detectIBM(ComponentBean in) {
+		return (in.getComponentType() != null && in.getComponentType()
+				.startsWith("com.ibm.faces"));
+	}
+
+}

Propchange: shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/util/PaletteDrawers.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/util/StringUtils.java
URL: http://svn.apache.org/viewvc/shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/util/StringUtils.java?view=auto&rev=558812
==============================================================================
--- shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/util/StringUtils.java (added)
+++ shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/util/StringUtils.java Mon Jul 23 10:51:09 2007
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package clay_plugin.util;
+
+public class StringUtils {
+
+	public static boolean empty(String in) {
+		return in == null || in.length() == 0;
+	}
+	
+}

Propchange: shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/util/StringUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/wizard/ClayConfigNewWizard.java
URL: http://svn.apache.org/viewvc/shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/wizard/ClayConfigNewWizard.java?view=auto&rev=558812
==============================================================================
--- shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/wizard/ClayConfigNewWizard.java (added)
+++ shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/wizard/ClayConfigNewWizard.java Mon Jul 23 10:51:09 2007
@@ -0,0 +1,157 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package clay_plugin.wizard;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.core.runtime.*;
+import org.eclipse.jface.operation.*;
+import java.lang.reflect.InvocationTargetException;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.core.resources.*;
+import org.eclipse.core.runtime.CoreException;
+import java.io.*;
+import org.eclipse.ui.*;
+import org.eclipse.ui.ide.IDE;
+
+
+public class ClayConfigNewWizard extends Wizard implements INewWizard {
+	private ClayConfigNewWizardPage page;
+
+	private ISelection selection;
+
+	/**
+	 * Constructor
+	 */
+	public ClayConfigNewWizard() {
+		super();
+		setNeedsProgressMonitor(true);
+	}
+
+	/**
+	 * Adding the page to the wizard.
+	 */
+
+	public void addPages() {
+		page = new ClayConfigNewWizardPage(selection);
+		addPage(page);
+	}
+
+	/**
+	 * This method is called when 'Finish' button is pressed in the wizard. We
+	 * will create an operation and run it using wizard as execution context.
+	 */
+	public boolean performFinish() {
+		final String containerName = page.getContainerName();
+		final String fileName = page.getFileName();
+		IRunnableWithProgress op = new IRunnableWithProgress() {
+			public void run(IProgressMonitor monitor)
+					throws InvocationTargetException {
+				try {
+					doFinish(containerName, fileName, monitor);
+				} catch (CoreException e) {
+					throw new InvocationTargetException(e);
+				} finally {
+					monitor.done();
+				}
+			}
+		};
+		try {
+			getContainer().run(true, false, op);
+		} catch (InterruptedException e) {
+			return false;
+		} catch (InvocationTargetException e) {
+			Throwable realException = e.getTargetException();
+			MessageDialog.openError(getShell(), "Error", realException
+					.getMessage());
+			return false;
+		}
+		return true;
+	}
+
+	/**
+	 * The worker method. It will find the container, create the file if missing
+	 * or just replace its contents, and open the editor on the newly created
+	 * file.
+	 */
+
+	private void doFinish(String containerName, String fileName,
+			IProgressMonitor monitor) throws CoreException {
+		// create a sample file
+		monitor.beginTask("Creating " + fileName, 2);
+		IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+		IResource resource = root.findMember(new Path(containerName));
+		if (!resource.exists() || !(resource instanceof IContainer)) {
+			throwCoreException("Container \"" + containerName
+					+ "\" does not exist.");
+		}
+		IContainer container = (IContainer) resource;
+		final IFile file = container.getFile(new Path(fileName));
+		try {
+			InputStream stream = openContentStream();
+			if (file.exists()) {
+				file.setContents(stream, true, true, monitor);
+			} else {
+				file.create(stream, true, monitor);
+			}
+			stream.close();
+		} catch (IOException e) {
+		}
+		monitor.worked(1);
+		monitor.setTaskName("Opening file for editing...");
+		getShell().getDisplay().asyncExec(new Runnable() {
+			public void run() {
+				IWorkbenchPage page = PlatformUI.getWorkbench()
+						.getActiveWorkbenchWindow().getActivePage();
+				try {
+					IDE.openEditor(page, file, "clay_plugin_3_2.editors.XMLEditor", true);
+				} catch (PartInitException e) {
+				}
+			}
+		});
+		monitor.worked(1);
+	}
+
+	/**
+	 * We will initialize file contents with a sample text.
+	 */
+
+	private InputStream openContentStream() {
+		String contents = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><view></view>";
+		return new ByteArrayInputStream(contents.getBytes());
+	}
+
+	private void throwCoreException(String message) throws CoreException {
+		IStatus status = new Status(IStatus.ERROR, "NewClayConfigDialog", IStatus.OK,
+				message, null);
+		throw new CoreException(status);
+	}
+
+	/**
+	 * We will accept the selection in the workbench to see if we can initialize
+	 * from it.
+	 * 
+	 * @see IWorkbenchWizard#init(IWorkbench, IStructuredSelection)
+	 */
+	public void init(IWorkbench workbench, IStructuredSelection selection) {
+		this.selection = selection;
+	}
+}
\ No newline at end of file

Propchange: shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/wizard/ClayConfigNewWizard.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/wizard/ClayConfigNewWizardPage.java
URL: http://svn.apache.org/viewvc/shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/wizard/ClayConfigNewWizardPage.java?view=auto&rev=558812
==============================================================================
--- shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/wizard/ClayConfigNewWizardPage.java (added)
+++ shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/wizard/ClayConfigNewWizardPage.java Mon Jul 23 10:51:09 2007
@@ -0,0 +1,196 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package clay_plugin.wizard;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.dialogs.ContainerSelectionDialog;
+
+public class ClayConfigNewWizardPage extends WizardPage {
+	private Text containerText;
+
+	private Text fileText;
+
+	private ISelection selection;
+
+	/**
+	 * Constructor
+	 * 
+	 * @param pageName
+	 */
+	public ClayConfigNewWizardPage(ISelection selection) {
+		super("wizardPage");
+		setTitle("Clay Config Editor File");
+		setDescription("This wizard creates a new clay config file with *.xml extension.");
+		this.selection = selection;
+	}
+
+	/**
+	 * @see IDialogPage#createControl(Composite)
+	 */
+	public void createControl(Composite parent) {
+		Composite container = new Composite(parent, SWT.NULL);
+		GridLayout layout = new GridLayout();
+		container.setLayout(layout);
+		layout.numColumns = 3;
+		layout.verticalSpacing = 9;
+		Label label = new Label(container, SWT.NULL);
+		label.setText("&Container:");
+
+		containerText = new Text(container, SWT.BORDER | SWT.SINGLE);
+		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+		containerText.setLayoutData(gd);
+		containerText.addModifyListener(new ModifyListener() {
+			public void modifyText(ModifyEvent e) {
+				dialogChanged();
+			}
+		});
+
+		Button button = new Button(container, SWT.PUSH);
+		button.setText("Browse...");
+		button.addSelectionListener(new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent e) {
+				handleBrowse();
+			}
+		});
+		label = new Label(container, SWT.NULL);
+		label.setText("&File name:");
+
+		fileText = new Text(container, SWT.BORDER | SWT.SINGLE);
+		gd = new GridData(GridData.FILL_HORIZONTAL);
+		fileText.setLayoutData(gd);
+		fileText.addModifyListener(new ModifyListener() {
+			public void modifyText(ModifyEvent e) {
+				dialogChanged();
+			}
+		});
+		initialize();
+		dialogChanged();
+		setControl(container);
+	}
+
+	/**
+	 * Tests if the current workbench selection is a suitable container to use.
+	 */
+
+	private void initialize() {
+		if (selection != null && selection.isEmpty() == false
+				&& selection instanceof IStructuredSelection) {
+			IStructuredSelection ssel = (IStructuredSelection) selection;
+			if (ssel.size() > 1)
+				return;
+			Object obj = ssel.getFirstElement();
+			if (obj instanceof IResource) {
+				IContainer container;
+				if (obj instanceof IContainer)
+					container = (IContainer) obj;
+				else
+					container = ((IResource) obj).getParent();
+				containerText.setText(container.getFullPath().toString());
+			}
+		}
+		fileText.setText("clay-config.xml");
+	}
+
+	/**
+	 * Uses the standard container selection dialog to choose the new value for
+	 * the container field.
+	 */
+
+	private void handleBrowse() {
+		ContainerSelectionDialog dialog = new ContainerSelectionDialog(
+				getShell(), ResourcesPlugin.getWorkspace().getRoot(), false,
+				"Select new file container");
+		if (dialog.open() == ContainerSelectionDialog.OK) {
+			Object[] result = dialog.getResult();
+			if (result.length == 1) {
+				containerText.setText(((Path) result[0]).toString());
+			}
+		}
+	}
+
+	/**
+	 * Ensures that both text fields are set.
+	 */
+
+	private void dialogChanged() {
+		IResource container = ResourcesPlugin.getWorkspace().getRoot()
+				.findMember(new Path(getContainerName()));
+		String fileName = getFileName();
+
+		if (getContainerName().length() == 0) {
+			updateStatus("File container must be specified");
+			return;
+		}
+		if (container == null
+				|| (container.getType() & (IResource.PROJECT | IResource.FOLDER)) == 0) {
+			updateStatus("File container must exist");
+			return;
+		}
+		if (!container.isAccessible()) {
+			updateStatus("Project must be writable");
+			return;
+		}
+		if (fileName.length() == 0) {
+			updateStatus("File name must be specified");
+			return;
+		}
+		if (fileName.replace('\\', '/').indexOf('/', 1) > 0) {
+			updateStatus("File name must be valid");
+			return;
+		}
+		int dotLoc = fileName.lastIndexOf('.');
+		if (dotLoc != -1) {
+			String ext = fileName.substring(dotLoc + 1);
+			if (ext.equalsIgnoreCase("xml") == false) {
+				updateStatus("File extension must be \"xml\"");
+				return;
+			}
+		}
+		updateStatus(null);
+	}
+
+	private void updateStatus(String message) {
+		setErrorMessage(message);
+		setPageComplete(message == null);
+	}
+
+	public String getContainerName() {
+		return containerText.getText();
+	}
+
+	public String getFileName() {
+		return fileText.getText();
+	}
+}
\ No newline at end of file

Propchange: shale/sandbox/shale-eclipse-plugins/plugins/shale_clay_plugin_for_eclipse/src/main/java/clay_plugin/wizard/ClayConfigNewWizardPage.java
------------------------------------------------------------------------------
    svn:eol-style = native