Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndre Weinand2003-03-24 15:38:57 +0000
committerAndre Weinand2003-03-24 15:38:57 +0000
commit8f49559469b644c3f26c8331b96fa805ff34ff7d (patch)
tree1677dba15f54347d728855d64b2d33e9f11f3fae
parentaea06383149db74eb28e030bf6dac5bb0c6ae11f (diff)
downloadeclipse.platform.team-8f49559469b644c3f26c8331b96fa805ff34ff7d.tar.gz
eclipse.platform.team-8f49559469b644c3f26c8331b96fa805ff34ff7d.tar.xz
eclipse.platform.team-8f49559469b644c3f26c8331b96fa805ff34ff7d.zip
initial checkin
-rw-r--r--examples/org.eclipse.compare.examples/.cvsignore2
-rw-r--r--examples/org.eclipse.compare.examples/.project25
-rw-r--r--examples/org.eclipse.compare.examples/about.html30
-rw-r--r--examples/org.eclipse.compare.examples/build.properties19
-rw-r--r--examples/org.eclipse.compare.examples/doc-html/hglegal.htm14
-rw-r--r--examples/org.eclipse.compare.examples/doc-html/hglegal2002.htm13
-rw-r--r--examples/org.eclipse.compare.examples/doc-html/ngibmcpy.gifbin0 -> 814 bytes
-rw-r--r--examples/org.eclipse.compare.examples/doc-html/ngibmcpy2002.gifbin0 -> 1045 bytes
-rw-r--r--examples/org.eclipse.compare.examples/doc-html/ui_structurecreator_ex.html43
-rw-r--r--examples/org.eclipse.compare.examples/plugin.properties15
-rw-r--r--examples/org.eclipse.compare.examples/plugin.xml44
-rw-r--r--examples/org.eclipse.compare.examples/src/org/eclipse/compare/examples/structurecreator/CompareExampleMessages.properties16
-rw-r--r--examples/org.eclipse.compare.examples/src/org/eclipse/compare/examples/structurecreator/KeyValuePairStructureCreator.java155
-rw-r--r--examples/org.eclipse.compare.examples/src/org/eclipse/compare/examples/structurecreator/TextMergeViewerCreator.java31
-rw-r--r--examples/org.eclipse.compare.examples/src/org/eclipse/compare/examples/structurecreator/Util.java66
15 files changed, 473 insertions, 0 deletions
diff --git a/examples/org.eclipse.compare.examples/.cvsignore b/examples/org.eclipse.compare.examples/.cvsignore
new file mode 100644
index 000000000..73cceacad
--- /dev/null
+++ b/examples/org.eclipse.compare.examples/.cvsignore
@@ -0,0 +1,2 @@
+bin
+.classpath
diff --git a/examples/org.eclipse.compare.examples/.project b/examples/org.eclipse.compare.examples/.project
new file mode 100644
index 000000000..1fe5dffd9
--- /dev/null
+++ b/examples/org.eclipse.compare.examples/.project
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.compare.examples</name>
+ <comment></comment>
+ <projects>
+ <project>org.eclipse.compare</project>
+ <project>org.eclipse.core.resources</project>
+ <project>org.eclipse.core.runtime</project>
+ <project>org.eclipse.jface</project>
+ <project>org.eclipse.jface.text</project>
+ <project>org.eclipse.swt</project>
+ <project>org.eclipse.ui</project>
+ <project>org.eclipse.ui.workbench</project>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/examples/org.eclipse.compare.examples/about.html b/examples/org.eclipse.compare.examples/about.html
new file mode 100644
index 000000000..9db411aab
--- /dev/null
+++ b/examples/org.eclipse.compare.examples/about.html
@@ -0,0 +1,30 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+<html>
+<head>
+<title>About</title>
+<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>20th June, 2002</p>
+<h3>License</h3>
+<p>Eclipse.org makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the
+Common Public License Version 1.0 (&quot;CPL&quot;). A copy of the CPL is available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a>.
+For purposes of the CPL, &quot;Program&quot; will mean the Content.</p>
+
+<h3>Contributions</h3>
+
+<p>If this Content is licensed to you under the terms and conditions of the CPL, any Contributions, as defined in the CPL, uploaded, submitted, or otherwise
+made available to Eclipse.org, members of Eclipse.org and/or the host of Eclipse.org web site, by you that relate to such
+Content are provided under the terms and conditions of the CPL and can be made available to others under the terms of the CPL.</p>
+
+<p>If this Content is licensed to you under license terms and conditions other than the CPL (&quot;Other License&quot;), any modifications, enhancements and/or
+other code and/or documentation (&quot;Modifications&quot;) uploaded, submitted, or otherwise made available to Eclipse.org, members of Eclipse.org and/or the
+host of Eclipse.org, by you that relate to such Content are provided under terms and conditions of the Other License and can be made available
+to others under the terms of the Other License. In addition, with regard to Modifications for which you are the copyright holder, you are also
+providing the Modifications under the terms and conditions of the CPL and such Modifications can be made available to others under the terms of
+the CPL.</p>
+
+</body>
+</html> \ No newline at end of file
diff --git a/examples/org.eclipse.compare.examples/build.properties b/examples/org.eclipse.compare.examples/build.properties
new file mode 100644
index 000000000..937a64cef
--- /dev/null
+++ b/examples/org.eclipse.compare.examples/build.properties
@@ -0,0 +1,19 @@
+###############################################################################
+# Copyright (c) 2000, 2003 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Common Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/cpl-v10.html
+#
+# Contributors:
+# IBM Corporation - initial API and implementation
+###############################################################################
+source.compareexamples.jar = src/
+
+bin.includes = doc-html/,\
+ about.html,\
+ plugin.properties,\
+ plugin.xml,\
+ compareexamples.jar
+
+src.includes = about.html
diff --git a/examples/org.eclipse.compare.examples/doc-html/hglegal.htm b/examples/org.eclipse.compare.examples/doc-html/hglegal.htm
new file mode 100644
index 000000000..c59811321
--- /dev/null
+++ b/examples/org.eclipse.compare.examples/doc-html/hglegal.htm
@@ -0,0 +1,14 @@
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.73 [en] (Win98; U) [Netscape]">
+ <title>Legal Notices</title>
+</head>
+<body>
+
+<h3>
+<a NAME="Notices"></a>Notices</h3>
+(c) Copyright IBM Corp. 2000, 2001. All Rights Reserved.
+</body>
+</html>
diff --git a/examples/org.eclipse.compare.examples/doc-html/hglegal2002.htm b/examples/org.eclipse.compare.examples/doc-html/hglegal2002.htm
new file mode 100644
index 000000000..3c8646735
--- /dev/null
+++ b/examples/org.eclipse.compare.examples/doc-html/hglegal2002.htm
@@ -0,0 +1,13 @@
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <title>Legal Notices</title>
+</head>
+<body>
+
+<h3>
+<a NAME="Notices"></a>Notices</h3>
+(c) Copyright IBM Corp. and others 2000, 2002. All Rights Reserved.
+</body>
+</html>
diff --git a/examples/org.eclipse.compare.examples/doc-html/ngibmcpy.gif b/examples/org.eclipse.compare.examples/doc-html/ngibmcpy.gif
new file mode 100644
index 000000000..360f8e998
--- /dev/null
+++ b/examples/org.eclipse.compare.examples/doc-html/ngibmcpy.gif
Binary files differ
diff --git a/examples/org.eclipse.compare.examples/doc-html/ngibmcpy2002.gif b/examples/org.eclipse.compare.examples/doc-html/ngibmcpy2002.gif
new file mode 100644
index 000000000..61cef4852
--- /dev/null
+++ b/examples/org.eclipse.compare.examples/doc-html/ngibmcpy2002.gif
Binary files differ
diff --git a/examples/org.eclipse.compare.examples/doc-html/ui_structurecreator_ex.html b/examples/org.eclipse.compare.examples/doc-html/ui_structurecreator_ex.html
new file mode 100644
index 000000000..702f3e006
--- /dev/null
+++ b/examples/org.eclipse.compare.examples/doc-html/ui_structurecreator_ex.html
@@ -0,0 +1,43 @@
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <title>Structural Compare for Key/Value Pairs</title>
+</head>
+<body>
+
+<h2>Compare Example - Structural Compare for Key/Value Pairs</h2>
+
+<p>
+The Structural Compare Example demonstrates how to register an custom structure creator
+for a file exe
+for
+
+The Java Editor example demonstrates the standard features available for custom text editors.
+It also shows howÊto register an editor for a file extension (in this case .jav) and how to
+define a custom Document provider for use by that editor.
+This example is only for demonstration purposes. Java editing support is provided by theÊEclipse Java Tooling.
+
+
+The File Viewer example shows how a simple application can be implemented using SWT.
+This application provides the ability to navigate files and folders and manipulate them via Drag and Drop.
+It includes the use of alternate threads for long actions and demonstrates the use of the Tree,
+Table, Toolbar and Program.
+</p>
+
+<h3>Running the example</h3>
+<p>
+Follow the <a href="swt_manual_setup.html">Manual Setup</a>
+instructions to install and run the example from your workspace.
+</p>
+<p>
+The "Main" class is <code>org.eclipse.swt.examples.fileviewer.FileViewer</code>.
+</p>
+<p>
+This example can also be run using the <a href="swt_launcher_ex.html">Example Launcher</a>.
+Select the File Viewer item from the Standalone category and click Run.
+</p>
+
+<p><a href="hglegal2002.htm"><img SRC="ngibmcpy2002.gif" ALT="Copyright IBM Corporation and others 2000, 2002. All Rights Reserved." BORDER=0 height=14 width=324></a></p>
+</body>
+</html>
diff --git a/examples/org.eclipse.compare.examples/plugin.properties b/examples/org.eclipse.compare.examples/plugin.properties
new file mode 100644
index 000000000..cbc537819
--- /dev/null
+++ b/examples/org.eclipse.compare.examples/plugin.properties
@@ -0,0 +1,15 @@
+###############################################################################
+# Copyright (c) 2000, 2003 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Common Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/cpl-v10.html
+#
+# Contributors:
+# IBM Corporation - initial API and implementation
+###############################################################################
+#
+# Resource strings for Compare Examples plugin.xml file
+#
+pluginName=Compare Example
+providerName = Eclipse.org
diff --git a/examples/org.eclipse.compare.examples/plugin.xml b/examples/org.eclipse.compare.examples/plugin.xml
new file mode 100644
index 000000000..970875eda
--- /dev/null
+++ b/examples/org.eclipse.compare.examples/plugin.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- File written by PDE 1.0 -->
+<plugin
+ id="org.eclipse.compare.examples"
+ name="%pluginName"
+ version="2.1.0"
+ provider-name="%providerName">
+
+<!-- Required plugins -->
+
+<requires>
+ <import plugin="org.eclipse.ui"/>
+ <import plugin="org.eclipse.core.resources"/>
+ <import plugin="org.eclipse.compare"/>
+</requires>
+
+<!-- Runtime -->
+
+<runtime>
+ <library name="compareexamples.jar">
+ <export name="*"/>
+ </library>
+</runtime>
+
+<!-- Extension points -->
+
+<!-- Extensions -->
+<extension
+ point="org.eclipse.compare.contentMergeViewers">
+ <viewer
+ extensions="kv"
+ class="org.eclipse.compare.examples.structurecreator.TextMergeViewerCreator">
+ </viewer>
+</extension>
+
+<extension
+ point="org.eclipse.compare.structureCreators">
+ <structureCreator
+ extensions="kv"
+ class="org.eclipse.compare.examples.structurecreator.KeyValuePairStructureCreator">
+ </structureCreator>
+</extension>
+
+</plugin>
diff --git a/examples/org.eclipse.compare.examples/src/org/eclipse/compare/examples/structurecreator/CompareExampleMessages.properties b/examples/org.eclipse.compare.examples/src/org/eclipse/compare/examples/structurecreator/CompareExampleMessages.properties
new file mode 100644
index 000000000..3ebe0141c
--- /dev/null
+++ b/examples/org.eclipse.compare.examples/src/org/eclipse/compare/examples/structurecreator/CompareExampleMessages.properties
@@ -0,0 +1,16 @@
+###############################################################################
+# Copyright (c) 2000, 2003 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Common Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/cpl-v10.html
+#
+# Contributors:
+# IBM Corporation - initial API and implementation
+###############################################################################
+#
+# Resource strings
+#
+KeyValuePairStructureCreator.title= Key/Value Pair Compare
+KeyValuePairStructureCreator.CoreException.message= CoreException
+KeyValuePairStructureCreator.BadLocationException.message= BadLocationException
diff --git a/examples/org.eclipse.compare.examples/src/org/eclipse/compare/examples/structurecreator/KeyValuePairStructureCreator.java b/examples/org.eclipse.compare.examples/src/org/eclipse/compare/examples/structurecreator/KeyValuePairStructureCreator.java
new file mode 100644
index 000000000..657b5d28b
--- /dev/null
+++ b/examples/org.eclipse.compare.examples/src/org/eclipse/compare/examples/structurecreator/KeyValuePairStructureCreator.java
@@ -0,0 +1,155 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.compare.examples.structurecreator;
+
+import org.eclipse.swt.graphics.*;
+
+import org.eclipse.jface.text.*;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Status;
+
+import org.eclipse.compare.*;
+import org.eclipse.compare.structuremergeviewer.*;
+
+
+/**
+ * This structure creator parses input containing key/value pairs
+ * and returns the pairs as a tree of <code>IStructureComparator</code>s.
+ * Each key/value pair must be on a separate line and keys are separated
+ * from values by a '='.
+ * <p>
+ * Example:
+ * <pre>
+ * foo=bar
+ * name=joe
+ * </pre>
+ */
+public class KeyValuePairStructureCreator implements IStructureCreator {
+
+ static class KeyValueNode extends DocumentRangeNode implements ITypedElement {
+
+ String fValue;
+
+ public KeyValueNode(String id, String value, IDocument doc, int start, int length) {
+ super(0, id, doc, start, length);
+ fValue= value;
+ }
+
+ String getValue() {
+ return fValue;
+ }
+
+ /**
+ * @see ITypedElement#getName
+ */
+ public String getName() {
+ return this.getId();
+ }
+
+ /**
+ * Every key/value pair is of type "txt" so that the builtin TextMergeViewer is used automatically.
+ * @see ITypedElement#getType
+ */
+ public String getType() {
+ return "txt"; //$NON-NLS-1$
+ }
+
+ /**
+ * @see ITypedElement#getImage
+ */
+ public Image getImage() {
+ return CompareUI.getImage(getType());
+ }
+ };
+
+
+ public KeyValuePairStructureCreator() {
+ }
+
+ /**
+ * This title will be shown in the title bar of the structure compare pane.
+ */
+ public String getName() {
+ return Util.getString("KeyValuePairStructureCreator.title"); //$NON-NLS-1$
+ }
+
+ /**
+ * Returns a node.
+ */
+ public IStructureComparator getStructure(Object input) {
+
+ if (!(input instanceof IStreamContentAccessor))
+ return null;
+
+ IStreamContentAccessor sca= (IStreamContentAccessor) input;
+
+ try {
+ String contents= Util.readString(sca.getContents());
+ if (contents == null)
+ contents= ""; //$NON-NLS-1$
+ Document doc= new Document(contents);
+
+ KeyValueNode root= new KeyValueNode("root", "", doc, 0, doc.getLength()); //$NON-NLS-1$ //$NON-NLS-2$
+
+ for (int i= 0; i < doc.getNumberOfLines(); i++) {
+
+ IRegion r= doc.getLineInformation(i);
+ String s= doc.get(r.getOffset(), r.getLength());
+ int start= r.getOffset();
+
+ String key= ""; //$NON-NLS-1$
+ String value= ""; //$NON-NLS-1$
+ int pos= s.indexOf('=');
+ if (pos >= 0) {
+ key= s.substring(0, pos);
+ value= s.substring(pos+1);
+ } else {
+ key= s;
+ }
+ if (key.length() > 0)
+ root.addChild(new KeyValueNode(key, value, doc, start, s.length()));
+ }
+ return root;
+ } catch (CoreException ex) {
+ String message= Util.getString("KeyValuePairStructureCreator.CoreException.message"); //$NON-NLS-1$
+ CompareUI.getPlugin().getLog().log(new Status(Status.ERROR, CompareUI.PLUGIN_ID, 0, message, ex));
+ } catch (BadLocationException ex) {
+ String message= Util.getString("KeyValuePairStructureCreator.BadLocationException.message"); //$NON-NLS-1$
+ CompareUI.getPlugin().getLog().log(new Status(Status.ERROR, CompareUI.PLUGIN_ID, 0, message, ex));
+ }
+
+ return null;
+ }
+
+ public void save(IStructureComparator structure, Object input) {
+ if (input instanceof IEditableContent && structure instanceof KeyValueNode) {
+ IDocument doc= ((KeyValueNode)structure).getDocument();
+ IEditableContent bca= (IEditableContent) input;
+ String c= doc.get();
+ bca.setContent(c.getBytes());
+ }
+ }
+
+ public String getContents(Object node, boolean ignoreWhitespace) {
+ if (node instanceof KeyValueNode) {
+ String s= ((KeyValueNode)node).getValue();
+ if (ignoreWhitespace)
+ s= s.trim();
+ return s;
+ }
+ return null;
+ }
+
+ public IStructureComparator locate(Object path, Object source) {
+ return null;
+ }
+}
diff --git a/examples/org.eclipse.compare.examples/src/org/eclipse/compare/examples/structurecreator/TextMergeViewerCreator.java b/examples/org.eclipse.compare.examples/src/org/eclipse/compare/examples/structurecreator/TextMergeViewerCreator.java
new file mode 100644
index 000000000..2565e4544
--- /dev/null
+++ b/examples/org.eclipse.compare.examples/src/org/eclipse/compare/examples/structurecreator/TextMergeViewerCreator.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.compare.examples.structurecreator;
+
+import org.eclipse.swt.widgets.Composite;
+
+import org.eclipse.jface.viewers.Viewer;
+
+import org.eclipse.compare.*;
+import org.eclipse.compare.contentmergeviewer.TextMergeViewer;
+
+/**
+ * A factory object for the <code>TextMergeViewer</code>.
+ * This indirection is necessary because only objects with a default
+ * constructor can be created via an extension point
+ * (this precludes Viewers).
+ */
+public class TextMergeViewerCreator implements IViewerCreator {
+
+ public Viewer createViewer(Composite parent, CompareConfiguration mp) {
+ return new TextMergeViewer(parent, mp);
+ }
+}
diff --git a/examples/org.eclipse.compare.examples/src/org/eclipse/compare/examples/structurecreator/Util.java b/examples/org.eclipse.compare.examples/src/org/eclipse/compare/examples/structurecreator/Util.java
new file mode 100644
index 000000000..04ae99f8a
--- /dev/null
+++ b/examples/org.eclipse.compare.examples/src/org/eclipse/compare/examples/structurecreator/Util.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.compare.examples.structurecreator;
+
+import java.io.*;
+import java.util.*;
+
+import org.eclipse.core.resources.ResourcesPlugin;
+
+
+public class Util {
+
+ private static final String RESOURCE_BUNDLE= "org.eclipse.compare.examples.structurecreator.CompareExampleMessages"; //$NON-NLS-1$
+
+ private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
+
+ public static String getString(String key) {
+ try {
+ return fgResourceBundle.getString(key);
+ } catch (MissingResourceException e) {
+ return "!" + key + "!"; //$NON-NLS-2$ //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Reads the contents of the given input stream into a string.
+ * The function assumes that the input stream uses the platform's default encoding
+ * (<code>ResourcesPlugin.getEncoding()</code>).
+ * Returns null if an error occurred.
+ */
+ static String readString(InputStream is) {
+ if (is == null)
+ return null;
+ BufferedReader reader= null;
+ try {
+ StringBuffer buffer= new StringBuffer();
+ char[] part= new char[2048];
+ int read= 0;
+ reader= new BufferedReader(new InputStreamReader(is, ResourcesPlugin.getEncoding()));
+
+ while ((read= reader.read(part)) != -1)
+ buffer.append(part, 0, read);
+
+ return buffer.toString();
+
+ } catch (IOException ex) {
+ } finally {
+ if (reader != null) {
+ try {
+ reader.close();
+ } catch (IOException ex) {
+ // we don't log IOException when closing a file
+ }
+ }
+ }
+ return null;
+ }
+}

Back to the top