### Eclipse Workspace Patch 1.0
#P org.eclipse.wst.common.snippets
Index: META-INF/MANIFEST.MF
===================================================================
RCS file: /cvsroot/webtools/common/plugins/org.eclipse.wst.common.snippets/META-INF/MANIFEST.MF,v
retrieving revision 1.20
diff -u -r1.20 MANIFEST.MF
--- META-INF/MANIFEST.MF 26 Jan 2009 20:07:49 -0000 1.20
+++ META-INF/MANIFEST.MF 1 Sep 2009 21:50:26 -0000
@@ -25,6 +25,7 @@
org.eclipse.ui;bundle-version="[3.4.0,4.0.0)",
org.eclipse.jface.text;bundle-version="[3.4.0,4.0.0)",
org.eclipse.core.resources;bundle-version="[3.4.0,4.0.0)",
- org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)"
+ org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)",
+ org.eclipse.core.expressions;bundle-version="[3.4.0,4.0.0)"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.4
Index: src/org/eclipse/wst/common/snippets/internal/palette/ModelFactoryForUser.java
===================================================================
RCS file: /cvsroot/webtools/common/plugins/org.eclipse.wst.common.snippets/src/org/eclipse/wst/common/snippets/internal/palette/ModelFactoryForUser.java,v
retrieving revision 1.12
diff -u -r1.12 ModelFactoryForUser.java
--- src/org/eclipse/wst/common/snippets/internal/palette/ModelFactoryForUser.java 9 Dec 2008 18:15:46 -0000 1.12
+++ src/org/eclipse/wst/common/snippets/internal/palette/ModelFactoryForUser.java 1 Sep 2009 21:50:26 -0000
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * Copyright (c) 2004, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -219,11 +219,47 @@
return definitions;
}
-
+
public SnippetDefinitions loadCurrent() {
return load(getFilename());
}
+ public SnippetDefinitions load(InputStream in) {
+ SnippetDefinitions definitions = new SnippetDefinitions();
+ Document document = null;
+ try {
+ DocumentBuilder builder = CommonXML.getDocumentBuilder();
+ if (builder != null) {
+ document = builder.parse(new InputSource(in));
+ }
+ else {
+ Logger.log(Logger.ERROR, "Couldn't obtain a DocumentBuilder"); //$NON-NLS-1$
+ }
+ }
+ catch (FileNotFoundException e) {
+ // typical of new workspace, don't log it
+ document = null;
+ }
+ catch (IOException e) {
+ Logger.logException("Could not load user items", e); //$NON-NLS-1$
+ return definitions;
+ }
+ catch (SAXException e) {
+ Logger.logException("Could not load user items", e); //$NON-NLS-1$
+ return definitions;
+ }
+ if (document == null)
+ return definitions;
+ Element library = document.getDocumentElement();
+ if (library == null || !library.getNodeName().equals(SnippetsPlugin.NAMES.SNIPPETS))
+ return definitions;
+ loadDefinitions(definitions, library);
+
+ connectItemsAndCategories(definitions);
+
+ return definitions;
+ }
+
protected void loadDefinitions(SnippetDefinitions definitions, Node library) {
NodeList children = library.getChildNodes();
int length = children.getLength();
@@ -313,6 +349,7 @@
setProperty(item, SnippetsPlugin.NAMES.ID, element.getAttribute(SnippetsPlugin.NAMES.ID));
setProperty(item, SnippetsPlugin.NAMES.LABEL, element.getAttribute(SnippetsPlugin.NAMES.LABEL));
setProperty(item, SnippetsPlugin.NAMES.LARGEICON, element.getAttribute(SnippetsPlugin.NAMES.LARGEICON));
+ setProperty(item, SnippetsPlugin.NAMES.PROVIDER_ID, element.getAttribute(SnippetsPlugin.NAMES.PROVIDER_ID));
NodeList children = element.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Index: src/org/eclipse/wst/common/snippets/internal/palette/AbstractModelFactory.java
===================================================================
RCS file: /cvsroot/webtools/common/plugins/org.eclipse.wst.common.snippets/src/org/eclipse/wst/common/snippets/internal/palette/AbstractModelFactory.java,v
retrieving revision 1.7
diff -u -r1.7 AbstractModelFactory.java
--- src/org/eclipse/wst/common/snippets/internal/palette/AbstractModelFactory.java 10 Apr 2007 17:23:34 -0000 1.7
+++ src/org/eclipse/wst/common/snippets/internal/palette/AbstractModelFactory.java 1 Sep 2009 21:50:26 -0000
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * Copyright (c) 2004, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -20,6 +20,7 @@
import org.eclipse.wst.common.snippets.internal.Logger;
import org.eclipse.wst.common.snippets.internal.SnippetDefinitions;
import org.eclipse.wst.common.snippets.internal.SnippetsPlugin;
+import org.eclipse.wst.common.snippets.internal.util.SnippetProviderManager;
public abstract class AbstractModelFactory {
@@ -73,6 +74,7 @@
setProperties(item, source);
migrate50to51(item);
+
return item;
}
@@ -176,6 +178,8 @@
item.setContentString(propertyValue.toString());
else if (property.equals(SnippetsPlugin.NAMES.EDITORCLASSNAME))
item.setEditorClassName(propertyValue.toString());
+ else if (property.equals(SnippetsPlugin.NAMES.PROVIDER_ID))
+ item.setProvider(SnippetProviderManager.findProvider(propertyValue.toString()));
else
setEntryProperty(item, property, propertyValue);
}
Index: src/org/eclipse/wst/common/snippets/internal/palette/SnippetPaletteItem.java
===================================================================
RCS file: /cvsroot/webtools/common/plugins/org.eclipse.wst.common.snippets/src/org/eclipse/wst/common/snippets/internal/palette/SnippetPaletteItem.java,v
retrieving revision 1.4
diff -u -r1.4 SnippetPaletteItem.java
--- src/org/eclipse/wst/common/snippets/internal/palette/SnippetPaletteItem.java 10 Apr 2007 17:23:34 -0000 1.4
+++ src/org/eclipse/wst/common/snippets/internal/palette/SnippetPaletteItem.java 1 Sep 2009 21:50:26 -0000
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * Copyright (c) 2004, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -16,12 +16,15 @@
import java.util.Arrays;
import java.util.List;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.gef.palette.PaletteContainer;
import org.eclipse.gef.palette.PaletteTemplateEntry;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.wst.common.snippets.core.ISnippetCategory;
import org.eclipse.wst.common.snippets.core.ISnippetItem;
+import org.eclipse.wst.common.snippets.core.ISnippetProvider;
import org.eclipse.wst.common.snippets.core.ISnippetVariable;
+import org.eclipse.wst.common.snippets.internal.model.SnippetManager;
public class SnippetPaletteItem extends PaletteTemplateEntry implements ISnippetItem {
@@ -38,6 +41,7 @@
protected Object fSourceDescriptor;
protected Object fSourceType = SNIPPET_SOURCE_USER;
protected List fVariables;
+ private ISnippetProvider provider;
/**
* @param label
@@ -219,4 +223,17 @@
fVariables = new ArrayList(variables.length);
fVariables.addAll(Arrays.asList(variables));
}
+
+ public IPath getStorageLocation() {
+ return SnippetManager.getInstance().getStorageLocation(getId());
+ }
+
+
+ public ISnippetProvider getProvider() {
+ return provider;
+ }
+
+ public void setProvider(ISnippetProvider provider) {
+ this.provider = provider;
+ }
}
Index: src/org/eclipse/wst/common/snippets/internal/palette/SnippetCustomizerDialog.java
===================================================================
RCS file: /cvsroot/webtools/common/plugins/org.eclipse.wst.common.snippets/src/org/eclipse/wst/common/snippets/internal/palette/SnippetCustomizerDialog.java,v
retrieving revision 1.7
diff -u -r1.7 SnippetCustomizerDialog.java
--- src/org/eclipse/wst/common/snippets/internal/palette/SnippetCustomizerDialog.java 25 Feb 2009 21:18:54 -0000 1.7
+++ src/org/eclipse/wst/common/snippets/internal/palette/SnippetCustomizerDialog.java 1 Sep 2009 21:50:26 -0000
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * Copyright (c) 2004, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,12 +10,23 @@
*******************************************************************************/
package org.eclipse.wst.common.snippets.internal.palette;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.io.OutputStream;
+import java.util.Enumeration;
import java.util.List;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipException;
+import java.util.zip.ZipFile;
+import java.util.zip.ZipOutputStream;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.gef.palette.PaletteDrawer;
import org.eclipse.gef.palette.PaletteEntry;
import org.eclipse.gef.palette.PaletteRoot;
@@ -32,16 +43,24 @@
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
import org.eclipse.wst.common.snippets.core.ISnippetCategory;
+import org.eclipse.wst.common.snippets.core.ISnippetItem;
import org.eclipse.wst.common.snippets.internal.IHelpContextIds;
import org.eclipse.wst.common.snippets.internal.SnippetDefinitions;
import org.eclipse.wst.common.snippets.internal.SnippetsMessages;
+import org.eclipse.wst.common.snippets.internal.SnippetsPlugin;
import org.eclipse.wst.common.snippets.internal.SnippetsPluginImageHelper;
import org.eclipse.wst.common.snippets.internal.SnippetsPluginImages;
import org.eclipse.wst.common.snippets.internal.model.SnippetManager;
import org.eclipse.wst.common.snippets.internal.ui.SnippetsCustomizer;
+import org.osgi.framework.Bundle;
public class SnippetCustomizerDialog extends PaletteCustomizerDialog {
+ private static class EXPORT_IMPORT_STRATEGY {
+ static EXPORT_IMPORT_STRATEGY ARCHIVE = new EXPORT_IMPORT_STRATEGY();
+ static EXPORT_IMPORT_STRATEGY XML = new EXPORT_IMPORT_STRATEGY();
+ }
+
private class ExportAction extends PaletteCustomizationAction {
public ExportAction() {
setEnabled(false);
@@ -54,33 +73,92 @@
protected void handleExport() {
PaletteDrawer exportCategory = (PaletteDrawer) getSelectedPaletteEntry();
+ EXPORT_IMPORT_STRATEGY strategy = exportStrategy(exportCategory);
- final FileDialog fileDialog = new FileDialog(getShell(), SWT.SAVE);
- fileDialog.setText(SnippetsMessages.Export_Snippets);
- fileDialog.setFileName("snippets.xml"); //$NON-NLS-1$
- String[] filterExtensions = new String[2];
- filterExtensions[0] = "*.xml"; //$NON-NLS-1$
- filterExtensions[1] = "*.*"; //$NON-NLS-1$
- fileDialog.setFilterExtensions(filterExtensions);
- String filename = fileDialog.open();
+ if (EXPORT_IMPORT_STRATEGY.ARCHIVE == strategy){
+ exportArchive(exportCategory);
+ } else {
+ exportXML(exportCategory);
+ }
+ updateActions();
+ }
+
+ private EXPORT_IMPORT_STRATEGY exportStrategy(PaletteDrawer exportCategory) {
+ List children = exportCategory.getChildren();
+ for (int i = 0; i < children.size(); i++) {
+ ISnippetItem snippetItem = (ISnippetItem) children.get(i);
+ File folder = new File(SnippetManager.getInstance().getStorageLocation(snippetItem.getId()).toOSString());
+ if (folder.exists()){
+ return EXPORT_IMPORT_STRATEGY.ARCHIVE;
+ }
+ }
+ return EXPORT_IMPORT_STRATEGY.XML;
+ }
+
+ private void exportArchive(PaletteDrawer exportCategory) {
+ String filename = openFileDialog("*.zip");//$NON-NLS-1$
if (filename != null) {
- SnippetDefinitions definitions = ModelFactoryForUser.getInstance().load(filename);
- ISnippetCategory existingCategory = definitions.getCategory(exportCategory.getId());
+ ZipOutputStream outputStream = null;
+ try {
+ SnippetDefinitions definitions = getCategory(exportCategory, filename);
+ outputStream = new ZipOutputStream(new FileOutputStream(filename));
+ ZipEntry descriptorFile = new ZipEntry("snippets.xml");
+ outputStream.putNextEntry(descriptorFile);
+ new UserModelDumper().write(definitions, outputStream);
+ ISnippetCategory existingCategory = definitions.getCategory(exportCategory.getId());
+ ISnippetItem[] items = existingCategory.getItems();
+ for (int i = 0; i < items.length; i++) {
+ File folder = new File(SnippetManager.getInstance().getStorageLocation(items[i].getId()).toOSString());
+ if (folder.exists()){
+ addToZip(folder.getParentFile(), folder, outputStream);
+ }
+ }
+ }
+ catch (FileNotFoundException e) {
+ // should not have problem finding the output file
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ finally {
+ if (outputStream != null)
+ try {
+ outputStream.close();
+ }
+ catch (IOException e) {
+ // should not have problem closing the output file
+ e.printStackTrace();
+ }
+ }
+ }
+ }
- if (existingCategory == null)
- definitions.getCategories().add(exportCategory);
- else {
- String title = SnippetsMessages.SnippetCustomizerDialog_2; //$NON-NLS-1$
- String message = NLS.bind(SnippetsMessages.SnippetCustomizerDialog_4, new String[]{existingCategory.getLabel()});
- boolean answer = MessageDialog.openConfirm(getShell(), title, message);
- if (answer) {
- definitions.getCategories().remove(existingCategory);
- definitions.getCategories().add(exportCategory);
+ private void addToZip(File root, File folder, ZipOutputStream outputStream) throws IOException {
+ File[] listedFiles = folder.listFiles();
+ for (int i = 0; i < listedFiles.length; i++) {
+ if (listedFiles[i].isDirectory()){
+ addToZip(root, listedFiles[i], outputStream);
+ } else {
+ ZipEntry ze = new ZipEntry(listedFiles[i].getAbsolutePath().substring(root.getAbsolutePath().length()+1));
+ outputStream.putNextEntry(ze);
+ BufferedInputStream bis = new BufferedInputStream(new FileInputStream(listedFiles[i]), 1024);
+ byte[] data = new byte[1024];
+ int count;
+ while ((count = bis.read(data, 0, 1024)) != -1) {
+ outputStream.write(data, 0, count);
}
+ bis.close();
}
+ }
+ }
- OutputStream outputStream = null;
- try {
+ private void exportXML(PaletteDrawer exportCategory) {
+ String filename = openFileDialog("*.xml");//$NON-NLS-1$
+
+ OutputStream outputStream = null;
+ if (filename != null) {
+ try{
+ SnippetDefinitions definitions = getCategory(exportCategory, filename);
outputStream = new FileOutputStream(filename);
new UserModelDumper().write(definitions, outputStream);
}
@@ -93,14 +171,46 @@
try {
outputStream.close();
}
- catch (IOException e) {
- // should not have problem closing the output file
- e.printStackTrace();
- }
+ catch (IOException e) {
+ // should not have problem closing the output file
+ e.printStackTrace();
+ }
}
- updateActions();
}
+
+
+ }
+
+ private SnippetDefinitions getCategory(PaletteDrawer exportCategory,
+ String fileName) {
+ SnippetDefinitions definitions = ModelFactoryForUser.getInstance().load(fileName);
+ ISnippetCategory existingCategory = definitions.getCategory(exportCategory.getId());
+
+ if (existingCategory == null)
+ definitions.getCategories().add(exportCategory);
+ else {
+ String title = SnippetsMessages.SnippetCustomizerDialog_2; //$NON-NLS-1$
+ String message = NLS.bind(SnippetsMessages.SnippetCustomizerDialog_4, new String[]{existingCategory.getLabel()});
+ boolean answer = MessageDialog.openConfirm(getShell(), title, message);
+ if (answer) {
+ definitions.getCategories().remove(existingCategory);
+ definitions.getCategories().add(exportCategory);
+ }
+ }
+ return definitions;
+ }
+
+ private String openFileDialog(String extension) {
+ final FileDialog fileDialog = new FileDialog(getShell(), SWT.SAVE);
+ fileDialog.setText(SnippetsMessages.Export_Snippets);
+ fileDialog.setFileName("snippets"+ extension.substring(1)); //$NON-NLS-1$
+ String[] filterExtensions = new String[2];
+ filterExtensions[0] = extension;
+ filterExtensions[1] = "*.*"; //$NON-NLS-1$
+ fileDialog.setFilterExtensions(filterExtensions);
+ String filename = fileDialog.open();
+ return filename;
}
public void run() {
@@ -132,14 +242,38 @@
protected void handleImport() {
final FileDialog fileDialog = new FileDialog(getShell(), SWT.OPEN);
fileDialog.setText(SnippetsMessages.Import_Snippets);
- fileDialog.setFileName("snippets.xml"); //$NON-NLS-1$
+// fileDialog.setFileName("snippets.xml"); //$NON-NLS-1$
String[] filterExtensions = new String[2];
- filterExtensions[0] = "*.xml"; //$NON-NLS-1$
+ filterExtensions[0] = "*.xml; *.zip"; //$NON-NLS-1$
filterExtensions[1] = "*.*"; //$NON-NLS-1$
fileDialog.setFilterExtensions(filterExtensions);
String filename = fileDialog.open();
- if (filename != null) {
- SnippetDefinitions definitions = ModelFactoryForUser.getInstance().load(filename);
+ try {
+ if (filename.toLowerCase().endsWith(".zip")){
+ ZipFile zip = new ZipFile(new File(filename));
+ ZipEntry entry = zip.getEntry("snippets.xml");
+ loadMetadata(zip.getInputStream(entry));
+ Bundle bundle = Platform.getBundle(SnippetsPlugin.BUNDLE_ID);
+ unzip(zip, Platform.getStateLocation(bundle).toOSString());
+ } else {
+ loadMetadata(new FileInputStream(filename));
+ }
+
+
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (ZipException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ private void loadMetadata(InputStream fileInputStream) {
+ if (fileInputStream != null) {
+ SnippetDefinitions definitions = ModelFactoryForUser.getInstance().load(fileInputStream);
List importCategories = definitions.getCategories();
List currentCategories = SnippetManager.getInstance().getDefinitions().getCategories();
PaletteEntry lastImportEntry = null;
@@ -215,4 +349,42 @@
return super.open();
}
+
+ public static final void copyInputStream(InputStream in, OutputStream out)
+ throws IOException
+ {
+ byte[] buffer = new byte[1024];
+ int len;
+
+ while((len = in.read(buffer)) >= 0)
+ out.write(buffer, 0, len);
+
+ in.close();
+ out.close();
+ }
+
+ public void unzip(ZipFile zipFile, String path) throws FileNotFoundException, IOException {
+ Enumeration entries;
+ entries = zipFile.entries();
+
+ while(entries.hasMoreElements()) {
+ ZipEntry entry = (ZipEntry)entries.nextElement();
+ File file = new File(path + File.separator+ entry.getName());
+ if(entry.isDirectory()) {
+ file.mkdir();
+ continue;
+ }
+ if (!file.getParentFile().exists()){
+ file.getParentFile().mkdirs();
+ }
+ if (entry.getName().toLowerCase().equals("snippets.xml")){
+ continue;
+ }
+
+ copyInputStream(zipFile.getInputStream(entry), new BufferedOutputStream(new FileOutputStream(file)));
+ }
+
+ zipFile.close();
+ }
+
}
Index: src/org/eclipse/wst/common/snippets/internal/palette/ModelFactoryForPlugins.java
===================================================================
RCS file: /cvsroot/webtools/common/plugins/org.eclipse.wst.common.snippets/src/org/eclipse/wst/common/snippets/internal/palette/ModelFactoryForPlugins.java,v
retrieving revision 1.8
diff -u -r1.8 ModelFactoryForPlugins.java
--- src/org/eclipse/wst/common/snippets/internal/palette/ModelFactoryForPlugins.java 10 Apr 2007 17:23:34 -0000 1.8
+++ src/org/eclipse/wst/common/snippets/internal/palette/ModelFactoryForPlugins.java 1 Sep 2009 21:50:26 -0000
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * Copyright (c) 2004, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -169,6 +169,7 @@
setProperty(item, SnippetsPlugin.NAMES.ID, element.getAttribute(SnippetsPlugin.NAMES.ID));
setProperty(item, SnippetsPlugin.NAMES.LABEL, element.getAttribute(SnippetsPlugin.NAMES.LABEL));
setProperty(item, SnippetsPlugin.NAMES.LARGEICON, element.getAttribute(SnippetsPlugin.NAMES.LARGEICON));
+ setProperty(item, SnippetsPlugin.NAMES.PROVIDER_ID, element.getAttribute(SnippetsPlugin.NAMES.PROVIDER_ID));
IConfigurationElement[] children = element.getChildren();
for (int i = 0; i < children.length; i++) {
Index: src/org/eclipse/wst/common/snippets/internal/palette/UserModelDumper.java
===================================================================
RCS file: /cvsroot/webtools/common/plugins/org.eclipse.wst.common.snippets/src/org/eclipse/wst/common/snippets/internal/palette/UserModelDumper.java,v
retrieving revision 1.8
diff -u -r1.8 UserModelDumper.java
--- src/org/eclipse/wst/common/snippets/internal/palette/UserModelDumper.java 9 Dec 2008 18:15:46 -0000 1.8
+++ src/org/eclipse/wst/common/snippets/internal/palette/UserModelDumper.java 1 Sep 2009 21:50:26 -0000
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * Copyright (c) 2004, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -178,6 +178,8 @@
element.setAttribute(SnippetsPlugin.NAMES.CLASSNAME, ((SnippetPaletteItem) item).getClassName());
if (((SnippetPaletteItem) item).getEditorClassName() != null)
element.setAttribute(SnippetsPlugin.NAMES.EDITORCLASSNAME, ((SnippetPaletteItem) item).getEditorClassName());
+ if (((SnippetPaletteItem) item).getProvider() != null)
+ element.setAttribute(SnippetsPlugin.NAMES.PROVIDER_ID, ((SnippetPaletteItem) item).getProvider().getId());
element.appendChild(createContent(doc, item));
ISnippetVariable[] variables = item.getVariables();
for (int i = 0; i < variables.length; i++) {
@@ -279,13 +281,8 @@
Logger.log(Logger.ERROR, "could not save " + stream, e); //$NON-NLS-1$
}
finally {
- try {
- stream.close();
- document = null;
- }
- catch (IOException e) {
- // nothing to be done while closing
- }
+ // stream.close();
+ document = null;
}
}
Index: src/org/eclipse/wst/common/snippets/internal/ui/EntrySerializer.java
===================================================================
RCS file: /cvsroot/webtools/common/plugins/org.eclipse.wst.common.snippets/src/org/eclipse/wst/common/snippets/internal/ui/EntrySerializer.java,v
retrieving revision 1.5
diff -u -r1.5 EntrySerializer.java
--- src/org/eclipse/wst/common/snippets/internal/ui/EntrySerializer.java 10 Apr 2007 17:23:35 -0000 1.5
+++ src/org/eclipse/wst/common/snippets/internal/ui/EntrySerializer.java 1 Sep 2009 21:50:26 -0000
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * Copyright (c) 2004, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -116,6 +116,8 @@
element.setAttribute(SnippetsPlugin.NAMES.CLASSNAME, item.getClassName());
if (item.getEditorClassName() != null)
element.setAttribute(SnippetsPlugin.NAMES.EDITORCLASSNAME, item.getEditorClassName());
+ if (item.getProvider() != null)
+ element.setAttribute(SnippetsPlugin.NAMES.PROVIDER_ID, item.getProvider().getId());
if (item.getContentString() != null)
element.appendChild(createContent(doc, item));
ISnippetVariable[] variables = item.getVariables();
Index: src/org/eclipse/wst/common/snippets/internal/ui/EntryDeserializer.java
===================================================================
RCS file: /cvsroot/webtools/common/plugins/org.eclipse.wst.common.snippets/src/org/eclipse/wst/common/snippets/internal/ui/EntryDeserializer.java,v
retrieving revision 1.5
diff -u -r1.5 EntryDeserializer.java
--- src/org/eclipse/wst/common/snippets/internal/ui/EntryDeserializer.java 10 Apr 2007 17:23:35 -0000 1.5
+++ src/org/eclipse/wst/common/snippets/internal/ui/EntryDeserializer.java 1 Sep 2009 21:50:26 -0000
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * Copyright (c) 2004, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -22,6 +22,7 @@
import org.eclipse.wst.common.snippets.internal.palette.SnippetPaletteItem;
import org.eclipse.wst.common.snippets.internal.palette.SnippetVariable;
import org.eclipse.wst.common.snippets.internal.util.CommonXML;
+import org.eclipse.wst.common.snippets.internal.util.SnippetProviderManager;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -72,6 +73,7 @@
item.setCategoryName(element.getAttribute(SnippetsPlugin.NAMES.CATEGORY));
item.setClassName(element.getAttribute(SnippetsPlugin.NAMES.CLASSNAME));
item.setEditorClassName(element.getAttribute(SnippetsPlugin.NAMES.EDITORCLASSNAME));
+ item.setProvider(SnippetProviderManager.findProvider(element.getAttribute(SnippetsPlugin.NAMES.PROVIDER_ID)));
NodeList children = element.getChildNodes();
int length = children.getLength();
for (int i = 0; i < length; i++) {
Index: src/org/eclipse/wst/common/snippets/internal/ui/SnippetsCustomizer.java
===================================================================
RCS file: /cvsroot/webtools/common/plugins/org.eclipse.wst.common.snippets/src/org/eclipse/wst/common/snippets/internal/ui/SnippetsCustomizer.java,v
retrieving revision 1.4
diff -u -r1.4 SnippetsCustomizer.java
--- src/org/eclipse/wst/common/snippets/internal/ui/SnippetsCustomizer.java 10 Apr 2007 17:23:35 -0000 1.4
+++ src/org/eclipse/wst/common/snippets/internal/ui/SnippetsCustomizer.java 1 Sep 2009 21:50:26 -0000
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * Copyright (c) 2004, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,9 +10,11 @@
*******************************************************************************/
package org.eclipse.wst.common.snippets.internal.ui;
+import java.io.File;
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.gef.palette.PaletteContainer;
import org.eclipse.gef.palette.PaletteDrawer;
import org.eclipse.gef.palette.PaletteEntry;
@@ -31,8 +33,10 @@
public class SnippetsCustomizer extends PaletteCustomizer {
+
protected List activeEditors = new ArrayList();
protected List factories = null;
+ private List deletedIds = new ArrayList();
public SnippetsCustomizer() {
super();
@@ -117,6 +121,13 @@
Logger.logException(e);
}
}
+
+ for (int i = 0; i < deletedIds.size(); i++) {
+ IPath path = SnippetManager.getInstance().getStorageLocation(deletedIds.get(i).toString());
+ File folder = new File(path.toOSString());
+ deleteFolders(folder);
+ }
+ deletedIds.clear();
activeEditors = new ArrayList(0);
@@ -127,4 +138,25 @@
Logger.logException(e);
}
}
+
+ private void deleteFolders(File folder) {
+ if (!folder.exists()){
+ return;
+ }
+ File[] listFiles = folder.listFiles();
+ for (int i = 0; i < listFiles.length; i++) {
+ if (listFiles[i].isDirectory()){
+ deleteFolders(listFiles[i]);
+ } else {
+ listFiles[i].delete();
+ }
+ }
+ folder.delete();
+ }
+
+ public void performDelete(PaletteEntry entry) {
+ deletedIds.add(entry.getId());
+ super.performDelete(entry);
+ }
+
}
Index: src/org/eclipse/wst/common/snippets/internal/ui/SnippetTemplateEntryPage.java
===================================================================
RCS file: /cvsroot/webtools/common/plugins/org.eclipse.wst.common.snippets/src/org/eclipse/wst/common/snippets/internal/ui/SnippetTemplateEntryPage.java,v
retrieving revision 1.5
diff -u -r1.5 SnippetTemplateEntryPage.java
--- src/org/eclipse/wst/common/snippets/internal/ui/SnippetTemplateEntryPage.java 10 Apr 2007 17:23:35 -0000 1.5
+++ src/org/eclipse/wst/common/snippets/internal/ui/SnippetTemplateEntryPage.java 1 Sep 2009 21:50:26 -0000
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * Copyright (c) 2004, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -38,17 +38,21 @@
editor.addModifyListener(this);
editor.setItem((SnippetPaletteItem) entry);
editor.createContents((Composite) getControl());
- // it can't be known in advance since the editor is unknown as
- // well
+ /*
+ * Can't be known in advance since the editor content is unknown
+ */
((Composite) getControl()).setTabList(null);
}
}
protected ISnippetEditor getEditor(SnippetPaletteItem item) {
ISnippetEditor snippetEditor = null;
- if (item.getSourceType() != ISnippetsEntry.SNIPPET_SOURCE_PLUGINS) {
+ if (item.getSourceType() == ISnippetsEntry.SNIPPET_SOURCE_USER || item.getSourceType() == ISnippetsEntry.SNIPPET_SOURCE_WORKSPACE) {
snippetEditor = new VariableItemEditor();
}
+ else if (item.getProvider() != null) {
+ // TODO: let a provider provide its own editor?
+ }
return snippetEditor;
}
Index: src/org/eclipse/wst/common/snippets/internal/ui/SnippetsView.java
===================================================================
RCS file: /cvsroot/webtools/common/plugins/org.eclipse.wst.common.snippets/src/org/eclipse/wst/common/snippets/internal/ui/SnippetsView.java,v
retrieving revision 1.8
diff -u -r1.8 SnippetsView.java
--- src/org/eclipse/wst/common/snippets/internal/ui/SnippetsView.java 9 Dec 2008 06:00:26 -0000 1.8
+++ src/org/eclipse/wst/common/snippets/internal/ui/SnippetsView.java 1 Sep 2009 21:50:26 -0000
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * Copyright (c) 2004, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -83,7 +83,6 @@
import org.eclipse.wst.common.snippets.internal.palette.SnippetPaletteRoot;
import org.eclipse.wst.common.snippets.internal.util.UserDrawerSelector;
import org.eclipse.wst.common.snippets.internal.util.VisibilityUtil;
-import org.eclipse.wst.common.snippets.ui.DefaultSnippetInsertion;
import org.eclipse.wst.common.snippets.ui.ISnippetInsertion;
import org.osgi.framework.Bundle;
@@ -199,8 +198,11 @@
}
}
}
+
if (insertion == null) {
- insertion = new DefaultSnippetInsertion();
+ if (item.getProvider()!= null){
+ insertion = item.getProvider().getSnippetInsertion();
+ }
}
return insertion;
}
@@ -828,6 +830,8 @@
insertion.setItem(item);
insertion.setEditorPart(getSite().getPage().getActiveEditor());
supportedTypes = insertion.getTransfers();
+ } else {
+ supportedTypes = new Transfer[]{TextTransfer.getInstance()};
}
}
else {
Index: plugin.properties
===================================================================
RCS file: /cvsroot/webtools/common/plugins/org.eclipse.wst.common.snippets/plugin.properties,v
retrieving revision 1.4
diff -u -r1.4 plugin.properties
--- plugin.properties 10 Apr 2007 17:23:36 -0000 1.4
+++ plugin.properties 1 Sep 2009 21:50:26 -0000
@@ -13,3 +13,5 @@
Snippets.name=Snippets
Snippets_View_Contributions_Extension.name=Snippets View Contributions Extension
Add_to_Snippets.name=Add to Snippets...
+
+extension-point.name.0 = SnippetProvider
\ No newline at end of file
Index: plugin.xml
===================================================================
RCS file: /cvsroot/webtools/common/plugins/org.eclipse.wst.common.snippets/plugin.xml,v
retrieving revision 1.9
diff -u -r1.9 plugin.xml
--- plugin.xml 30 Apr 2007 19:32:42 -0000 1.9
+++ plugin.xml 1 Sep 2009 21:50:26 -0000
@@ -6,6 +6,11 @@
id="SnippetContributions"
name="%Snippets_View_Contributions_Extension.name"
schema="schema/SnippetContributions.exsd" />
+
+
+ * As an addded guard, the time is recorded and serialized in javaToNative
+ * to that navive to java can ensure that it's returns the value that was really to have been transferred.
+ */
+public class SnippetTransfer extends ByteArrayTransfer
+{
+ /**
+ * This is the register transfer type name.
+ */
+ protected static final String TYPE_NAME = "local-transfer-format";
+
+ /**
+ * This is the ID that is registered to the name.
+ */
+ protected static final int TYPE_ID = registerType(TYPE_NAME);
+
+ /**
+ * This is initialized and returned by {@link #getInstance}.
+ */
+ protected static SnippetTransfer instance;
+
+ /**
+ * This returns the one instance of this transfer agent.
+ */
+ public static SnippetTransfer getInstance()
+ {
+ if (instance == null)
+ {
+ instance = new SnippetTransfer();
+ }
+
+ return instance;
+ }
+
+ /**
+ * This records the time at which the transfer data was recorded.
+ */
+ protected long startTime;
+
+ /**
+ * This records the data being transferred.
+ */
+ protected Object object;
+
+ /**
+ * This creates an instance; typically you get one from {@link #getInstance}.
+ */
+ protected SnippetTransfer()
+ {
+ }
+
+ /**
+ * This returns the transfer ids that this agent supports.
+ */
+ protected int[] getTypeIds()
+ {
+ return new int[] { TYPE_ID };
+ }
+
+ /**
+ * This returns the transfer names that this agent supports.
+ */
+ public String[] getTypeNames()
+ {
+ return new String[] { TYPE_NAME };
+ }
+
+ /**
+ * This records the object and current time and encodes only the current time into the transfer data.
+ */
+ public void javaToNative(Object object, TransferData transferData)
+ {
+ startTime = System.currentTimeMillis();
+ this.object = object;
+ if (transferData != null)
+ {
+ super.javaToNative(String.valueOf(startTime).getBytes(), transferData);
+ }
+ }
+
+ /**
+ * This decodes the time of the transfer and returns the recorded the object if the recorded time and the decoded time match.
+ */
+ public Object nativeToJava(TransferData transferData)
+ {
+ long startTime = Long.valueOf(new String((byte[])super.nativeToJava(transferData))).longValue();
+ return
+ this.startTime == startTime ?
+ object :
+ null;
+ }
+}
Index: src/org/eclipse/wst/common/snippets/ui/TextSnippetProvider.java
===================================================================
RCS file: src/org/eclipse/wst/common/snippets/ui/TextSnippetProvider.java
diff -N src/org/eclipse/wst/common/snippets/ui/TextSnippetProvider.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/common/snippets/ui/TextSnippetProvider.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * Copyright (c) 2009 SAP AG and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * SAP AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.common.snippets.ui;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.gef.palette.PaletteEntry;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.wst.common.snippets.core.ISnippetProvider;
+import org.eclipse.wst.common.snippets.internal.AbstractSnippetProvider;
+import org.eclipse.wst.common.snippets.internal.Logger;
+import org.eclipse.wst.common.snippets.internal.palette.SnippetPaletteItem;
+import org.eclipse.wst.common.snippets.internal.util.StringUtils;
+
+public class TextSnippetProvider extends AbstractSnippetProvider implements ISnippetProvider {
+
+ public SnippetPaletteItem createSnippet(PaletteEntry drawer) throws CoreException {
+ SnippetPaletteItem item = super.createSnippet(drawer);
+ ITextSelection selection = getTextSelection();
+ try {
+ String selectedText = getDocument().get(selection.getOffset(), selection.getLength());
+ item.setDescription(StringUtils.firstLineOf(selectedText).trim() + "..."); //$NON-NLS-1$
+ item.setContentString(selectedText);
+ }
+ catch (BadLocationException e) {
+ Logger.logException(e);
+ }
+ return item;
+ }
+
+
+ protected ITextSelection getTextSelection() {
+ ITextEditor editor = getTextEditor();
+ if (editor != null) {
+ ISelection selection = editor.getSelectionProvider().getSelection();
+ if (selection instanceof ITextSelection) {
+ return (ITextSelection) selection;
+ }
+ }
+ return null;
+ }
+
+ protected ITextEditor getTextEditor() {
+ ITextEditor editor = null;
+ IWorkbenchPart activePart = fEditorPart;
+
+ if (activePart instanceof ITextEditor) {
+ editor = (ITextEditor) activePart;
+ }
+ if (editor == null) {
+ editor = (ITextEditor) activePart.getAdapter(ITextEditor.class);
+ }
+ return editor;
+ }
+
+ public boolean isActionEnabled(ISelection selection) {
+ boolean enable = false;
+ if (selection != null) {
+ if (selection instanceof ITextSelection) {
+ if (((ITextSelection) selection).getLength() > 0) {
+ enable = true;
+ }
+ }
+ else {
+ enable = !selection.isEmpty();
+ }
+ }
+ return enable;
+ }
+
+ public IDocument getDocument() {
+ return getTextEditor().getDocumentProvider().getDocument(fEditorPart.getEditorInput());
+ }
+
+ public IStatus saveAdditionalContent(IPath path) {
+ return Status.OK_STATUS;
+ }
+
+
+ public ISnippetInsertion getSnippetInsertion() {
+ return new DefaultSnippetInsertion();
+ }
+
+
+ public String getId() {
+ return TextSnippetProvider.class.getName();
+ }
+
+}
Index: src/org/eclipse/wst/common/snippets/internal/util/SnippetProviderManager.java
===================================================================
RCS file: src/org/eclipse/wst/common/snippets/internal/util/SnippetProviderManager.java
diff -N src/org/eclipse/wst/common/snippets/internal/util/SnippetProviderManager.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/common/snippets/internal/util/SnippetProviderManager.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (c) 2009 SAP AG and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * SAP AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.common.snippets.internal.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.wst.common.snippets.core.ISnippetProvider;
+import org.eclipse.wst.common.snippets.internal.SnippetContributor;
+import org.eclipse.wst.common.snippets.ui.TextSnippetProvider;
+
+
+public class SnippetProviderManager {
+
+ private static ISnippetProvider[] getProviders() {
+ IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(SnippetContributor.ID_EXTENSION_POINT_PROVIDER);
+ IExtension[] extensions = extensionPoint.getExtensions();
+ List providerList = new ArrayList();
+ for (int i = 0; i < extensions.length; i++) {
+ IConfigurationElement[] configurationElements = extensions[i].getConfigurationElements();
+ for (int j = 0; j < configurationElements.length; j++) {
+ SnippetContributor sc = new SnippetContributor(configurationElements[j]);
+ if (sc.getProvider() != null){
+ providerList.add(sc.getProvider());
+ }
+ }
+
+ }
+ return (ISnippetProvider[]) providerList.toArray(new ISnippetProvider[providerList.size()]);
+ }
+
+ public static ISnippetProvider findProvider(String id) {
+ Assert.isNotNull(id);
+ ISnippetProvider[] providers = getProviders();
+ for (int i = 0; i < providers.length; i++) {
+ if(id.equals(providers[i].getId()))
+ return providers[i];
+ }
+
+ return new TextSnippetProvider();
+ }
+
+ public static ISnippetProvider getApplicableProvider(IEditorPart targetEditor) {
+ SnippetContributor applicableContributor = null;
+ IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(SnippetContributor.ID_EXTENSION_POINT_PROVIDER);
+ if (extensionPoint != null) {
+ IExtension[] extensions = extensionPoint.getExtensions();
+ for (int i = 0; i < extensions.length; i++) {
+ IConfigurationElement[] configurationElements = extensions[i].getConfigurationElements();
+ for (int j = 0; j < configurationElements.length; j++) {
+ SnippetContributor sc = new SnippetContributor(configurationElements[j]);
+ if (sc.isApplicable(targetEditor)) {
+ if (applicableContributor == null || applicableContributor.getPriority() > sc.getPriority()) {
+ applicableContributor = sc;
+ }
+ }
+ }
+ }
+ }
+ if (applicableContributor == null){
+ return null;
+ }
+ ISnippetProvider provider = applicableContributor.getProvider();
+ // a null provider is an error condition
+ if (provider != null) {
+ provider.setEditor(targetEditor);
+ }
+ return provider;
+ }
+
+
+
+
+}
Index: src/org/eclipse/wst/common/snippets/core/ISnippetProvider.java
===================================================================
RCS file: src/org/eclipse/wst/common/snippets/core/ISnippetProvider.java
diff -N src/org/eclipse/wst/common/snippets/core/ISnippetProvider.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/common/snippets/core/ISnippetProvider.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,26 @@
+package org.eclipse.wst.common.snippets.core;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.gef.palette.PaletteEntry;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.wst.common.snippets.internal.palette.SnippetPaletteItem;
+import org.eclipse.wst.common.snippets.ui.ISnippetInsertion;
+
+public interface ISnippetProvider {
+
+ public SnippetPaletteItem createSnippet(PaletteEntry drawer) throws CoreException ;
+
+ public boolean isActionEnabled(ISelection selection);
+
+ public IStatus saveAdditionalContent(IPath path);
+
+ public ISnippetInsertion getSnippetInsertion();
+
+ public String getId();
+
+ public void setEditor(IEditorPart editor);
+
+}
#P org.eclipse.wst.common.snippets.tests
Index: META-INF/MANIFEST.MF
===================================================================
RCS file: /cvsroot/webtools/common/tests/org.eclipse.wst.common.snippets.tests/META-INF/MANIFEST.MF,v
retrieving revision 1.9
diff -u -r1.9 MANIFEST.MF
--- META-INF/MANIFEST.MF 1 Jun 2008 07:24:12 -0000 1.9
+++ META-INF/MANIFEST.MF 1 Sep 2009 21:50:27 -0000
@@ -17,6 +17,7 @@
org.eclipse.ui,
org.eclipse.wst.common.snippets,
org.eclipse.ui.ide,
- org.eclipse.ui.workbench.texteditor
+ org.eclipse.ui.workbench.texteditor,
+ org.eclipse.gef
Eclipse-LazyStart: true
Bundle-RequiredExecutionEnvironment: J2SE-1.4
Index: src/org/eclipse/wst/common/snippets/tests/AllTests.java
===================================================================
RCS file: /cvsroot/webtools/common/tests/org.eclipse.wst.common.snippets.tests/src/org/eclipse/wst/common/snippets/tests/AllTests.java,v
retrieving revision 1.1
diff -u -r1.1 AllTests.java
--- src/org/eclipse/wst/common/snippets/tests/AllTests.java 30 Nov 2005 11:36:42 -0000 1.1
+++ src/org/eclipse/wst/common/snippets/tests/AllTests.java 1 Sep 2009 21:50:27 -0000
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
+ * Copyright (c) 2005, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -15,6 +15,9 @@
import junit.framework.TestSuite;
import org.eclipse.wst.common.snippets.core.tests.SnippetCoreTests;
+import org.eclipse.wst.common.snippets.tests.providers.SnippetProviderExtensionTests;
+import org.eclipse.wst.common.snippets.tests.providers.TextProviderTests;
+import org.eclipse.wst.common.snippets.tests.scenarios.ObjectOrientedSnippetScenario;
import org.eclipse.wst.common.snippets.ui.tests.SnippetUITests;
@@ -27,6 +30,9 @@
public AllTests() {
super();
addTest(new TestSuite(SnippetCoreTests.class));
+ addTest(new TestSuite(SnippetProviderExtensionTests.class));
+ addTest(new TestSuite(TextProviderTests.class));
addTest(new TestSuite(SnippetUITests.class));
+ addTest(new TestSuite(ObjectOrientedSnippetScenario.class));
}
}
Index: src/org/eclipse/wst/common/snippets/tests/TestsPlugin.java
===================================================================
RCS file: /cvsroot/webtools/common/tests/org.eclipse.wst.common.snippets.tests/src/org/eclipse/wst/common/snippets/tests/TestsPlugin.java,v
retrieving revision 1.1
diff -u -r1.1 TestsPlugin.java
--- src/org/eclipse/wst/common/snippets/tests/TestsPlugin.java 30 Nov 2005 11:36:42 -0000 1.1
+++ src/org/eclipse/wst/common/snippets/tests/TestsPlugin.java 1 Sep 2009 21:50:27 -0000
@@ -9,6 +9,7 @@
*/
public class TestsPlugin extends AbstractUIPlugin {
+ public static final String PLUGIN_ID = "org.eclipse.wst.common.snippets.tests";
//The shared instance.
private static TestsPlugin plugin;
Index: plugin.xml
===================================================================
RCS file: /cvsroot/webtools/common/tests/org.eclipse.wst.common.snippets.tests/plugin.xml,v
retrieving revision 1.5
diff -u -r1.5 plugin.xml
--- plugin.xml 27 Feb 2006 09:18:56 -0000 1.5
+++ plugin.xml 1 Sep 2009 21:50:27 -0000
@@ -29,5 +29,33 @@
+