Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 332961 | Differences between
and this patch

Collapse All | Expand All

(-)META-INF/MANIFEST.MF (-2 / +3 lines)
Lines 2-8 Link Here
2
Bundle-ManifestVersion: 2
2
Bundle-ManifestVersion: 2
3
Bundle-Name: %pluginName
3
Bundle-Name: %pluginName
4
Bundle-SymbolicName: org.eclipse.emf.edit.ui;singleton:=true
4
Bundle-SymbolicName: org.eclipse.emf.edit.ui;singleton:=true
5
Bundle-Version: 2.6.0.qualifier
5
Bundle-Version: 2.7.0.qualifier
6
Bundle-ClassPath: .
6
Bundle-ClassPath: .
7
Bundle-Activator: org.eclipse.emf.edit.ui.EMFEditUIPlugin$Implementation
7
Bundle-Activator: org.eclipse.emf.edit.ui.EMFEditUIPlugin$Implementation
8
Bundle-Vendor: %providerName
8
Bundle-Vendor: %providerName
Lines 21-26 Link Here
21
 org.eclipse.emf.edit;visibility:=reexport,
21
 org.eclipse.emf.edit;visibility:=reexport,
22
 org.eclipse.emf.common.ui;visibility:=reexport,
22
 org.eclipse.emf.common.ui;visibility:=reexport,
23
 org.eclipse.core.resources;resolution:=optional,
23
 org.eclipse.core.resources;resolution:=optional,
24
 org.eclipse.ui.ide;resolution:=optional
24
 org.eclipse.ui.ide;resolution:=optional,
25
 org.eclipse.jface.text;resolution:=optional
25
Eclipse-LazyStart: true
26
Eclipse-LazyStart: true
26
Bundle-ActivationPolicy: lazy
27
Bundle-ActivationPolicy: lazy
(-)build.properties (-1 / +3 lines)
Lines 6-12 Link Here
6
               .,\
6
               .,\
7
               icons/,\
7
               icons/,\
8
               plugin.properties,\
8
               plugin.properties,\
9
               META-INF/
9
               plugin.xml,\
10
               META-INF/,\
11
               schema/
10
src.includes = about.html
12
src.includes = about.html
11
source.. = src/
13
source.. = src/
12
output.. = bin/
14
output.. = bin/
(-)plugin.properties (-1 / +3 lines)
Lines 1-7 Link Here
1
# /**
1
# /**
2
#  * <copyright>
2
#  * <copyright>
3
#  *
3
#  *
4
#  * Copyright (c) 2002-2008 IBM Corporation and others.
4
#  * Copyright (c) 2002-2010 IBM Corporation and others.
5
#  * All rights reserved.   This program and the accompanying materials
5
#  * All rights reserved.   This program and the accompanying materials
6
#  * are made available under the terms of the Eclipse Public License v1.0
6
#  * are made available under the terms of the Eclipse Public License v1.0
7
#  * which accompanies this distribution, and is available at
7
#  * which accompanies this distribution, and is available at
Lines 89-91 Link Here
89
_UI_MultiLineInputDialog_message = &Enter a value:
89
_UI_MultiLineInputDialog_message = &Enter a value:
90
90
91
_UI_DiagnosisOfNObjects_message = Diagnosis of {0} objects
91
_UI_DiagnosisOfNObjects_message = Diagnosis of {0} objects
92
93
_UI_QueryDelegateTextViewerFactory_extensionpoint = Registered Query Delegate Text Viewer Factories
(-)plugin.xml (+5 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<?eclipse version="3.0"?>
3
<plugin>
4
   <extension-point id="queryDelegateTextViewerFactories" name="%_UI_QueryDelegateTextViewerFactory_extensionpoint" schema="schema/queryDelegateTextViewerFactories.exsd"/>
5
</plugin>
(-)schema/queryDelegateTextViewerFactories.exsd (+124 lines)
Added Link Here
1
<?xml version='1.0' encoding='UTF-8'?>
2
<!-- Schema file written by PDE -->
3
<schema targetNamespace="org.eclipse.emf.edit.ui" xmlns="http://www.w3.org/2001/XMLSchema">
4
<annotation>
5
      <appInfo>
6
         <meta.schema plugin="org.eclipse.emf.edit.ui" id="queryDelegateTextViewerFactories" name="Query Delegate Text Viewer Factory Registry"/>
7
      </appInfo>
8
      <documentation>
9
         This extension point is used to register factories for query delegate text viewers whose type is identified by a URI. The global EMF query delegate text viewer factory registry, &lt;samp&gt;QueryDelegateTextViewer.Factory.Registry.INSTANCE&lt;/samp&gt;, is used to record the registration.
10
      </documentation>
11
   </annotation>
12
13
   <element name="extension">
14
      <annotation>
15
         <appInfo>
16
            <meta.element />
17
         </appInfo>
18
      </annotation>
19
      <complexType>
20
         <sequence>
21
            <element ref="factory" minOccurs="1" maxOccurs="unbounded"/>
22
         </sequence>
23
         <attribute name="point" type="string" use="required">
24
            <annotation>
25
               <documentation>
26
                  A fully qualified identifier of the target extension point.
27
               </documentation>
28
            </annotation>
29
         </attribute>
30
         <attribute name="id" type="string">
31
            <annotation>
32
               <documentation>
33
                  An optional identifier of the extension instance.
34
               </documentation>
35
            </annotation>
36
         </attribute>
37
         <attribute name="name" type="string">
38
            <annotation>
39
               <documentation>
40
                  An optional name of the extension instance.
41
               </documentation>
42
            </annotation>
43
         </attribute>
44
      </complexType>
45
   </element>
46
47
   <element name="factory">
48
      <annotation>
49
         <appInfo>
50
            <meta.element labelAttribute="id"/>
51
         </appInfo>
52
      </annotation>
53
      <complexType>
54
         <attribute name="uri" type="string" use="required">
55
            <annotation>
56
               <documentation>
57
                  A URI identifying the type of query delegate text viewers that can be created by the factory.
58
               </documentation>
59
            </annotation>
60
         </attribute>
61
         <attribute name="class" type="string" use="required">
62
            <annotation>
63
               <documentation>
64
                  The fully qualified name of a Java class implementing &lt;samp&gt;org.eclipse.emf.edit.ui.util.QueryDelegateTextViewer.Factory&lt;/samp&gt;.
65
               </documentation>
66
               <appInfo>
67
                  <meta.attribute kind="java" basedOn="org.eclipse.emf.edit.ui.util.QueryDelegateTextViewer.Factory"/>
68
               </appInfo>
69
            </annotation>
70
         </attribute>
71
      </complexType>
72
   </element>
73
74
   <annotation>
75
      <appInfo>
76
         <meta.section type="since"/>
77
      </appInfo>
78
      <documentation>
79
         2.7.0
80
      </documentation>
81
   </annotation>
82
83
   <annotation>
84
      <appInfo>
85
         <meta.section type="examples"/>
86
      </appInfo>
87
      <documentation>
88
         Following is an example of how a query delegate text viewer factory can be registered: 
89
&lt;pre&gt;
90
  &lt;extension point=&quot;org.eclipse.emf.edit.ui.queryDelegateTextViewerFactories&quot; &gt;
91
    &lt;factory uri=&quot;http://www.eclipse.org/emf/2002/Ecore/OCL&quot; class=&quot;org.eclipse.ocl.examples.interpreter.delegate.OCLQueryDelegateTextViewerFactory&quot;/&gt; 
92
  &lt;/extension&gt;
93
&lt;/pre&gt;
94
      </documentation>
95
   </annotation>
96
97
   <annotation>
98
      <appInfo>
99
         <meta.section type="apiInfo"/>
100
      </appInfo>
101
      <documentation>
102
         The value of the class attribute must represent a class that implements &lt;samp&gt;org.eclipse.emf.edit.ui.util.QueryDelegateTextViewer.Factory&lt;/samp&gt; and has a no argument contructor.
103
&lt;p&gt;
104
A query delegate text viewer factory can be also registered from the source code with the &lt;samp&gt;QueryDelegateTextViewer.Factory.Registry.INSTANCE&lt;/samp&gt; as follows:
105
&lt;/p&gt;
106
&lt;pre&gt;
107
  QueryDelegateTextViewer.Factory.Registry.INSTANCE.put(&quot;http://www.eclipse.org/emf/2002/Ecore/OCL&quot;, new OCLQueryDelegateTextViewerFactory());
108
&lt;/pre&gt;
109
      </documentation>
110
   </annotation>
111
112
113
   <annotation>
114
      <appInfo>
115
         <meta.section type="copyright"/>
116
      </appInfo>
117
      <documentation>
118
         Copyright (c) 2010 Kenn Hussey and others.&lt;br&gt;
119
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 &lt;a 
120
href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
121
      </documentation>
122
   </annotation>
123
124
</schema>
(-)src/org/eclipse/emf/edit/ui/EMFEditUIPlugin.java (-5 / +92 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright> 
2
 * <copyright> 
3
 *
3
 *
4
 * Copyright (c) 2002-2006 IBM Corporation and others.
4
 * Copyright (c) 2002-2010 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 16-25 Link Here
16
 */
16
 */
17
package org.eclipse.emf.edit.ui;
17
package org.eclipse.emf.edit.ui;
18
18
19
19
import org.eclipse.core.runtime.IConfigurationElement;
20
import org.eclipse.core.runtime.Platform;
20
import org.eclipse.emf.common.EMFPlugin;
21
import org.eclipse.emf.common.EMFPlugin;
21
import org.eclipse.emf.common.ui.EclipseUIPlugin;
22
import org.eclipse.emf.common.ui.EclipseUIPlugin;
22
import org.eclipse.emf.common.util.ResourceLocator;
23
import org.eclipse.emf.common.util.ResourceLocator;
24
import org.eclipse.emf.ecore.plugin.RegistryReader;
25
import org.eclipse.emf.edit.ui.util.QueryDelegateTextViewer;
26
import org.osgi.framework.Bundle;
27
import org.osgi.framework.BundleContext;
23
28
24
29
25
/**
30
/**
Lines 34-40 Link Here
34
 * In this case, emf.edit.resources.jar must be on the CLASSPATH.
39
 * In this case, emf.edit.resources.jar must be on the CLASSPATH.
35
 * @see #INSTANCE
40
 * @see #INSTANCE
36
 */
41
 */
37
public final class EMFEditUIPlugin extends EMFPlugin 
42
public final class EMFEditUIPlugin extends EMFPlugin
38
{
43
{
39
  /**
44
  /**
40
   * The singleton instance of the plugin.
45
   * The singleton instance of the plugin.
Lines 46-57 Link Here
46
   */
51
   */
47
  private static Implementation plugin;
52
  private static Implementation plugin;
48
53
54
  public static final String QUERY_DELEGATE_TEXT_VIEWER_FACTORIES_PPID = "queryDelegateTextViewerFactories";
55
49
  /**
56
  /**
50
   * Creates the singleton instance.
57
   * Creates the singleton instance.
51
   */
58
   */
52
  private EMFEditUIPlugin()
59
  private EMFEditUIPlugin()
53
  {
60
  {
54
    super(new ResourceLocator[] {});
61
    super(new ResourceLocator []{});
55
  }
62
  }
56
63
57
  /*
64
  /*
Lines 75-81 Link Here
75
  /**
82
  /**
76
   * The actual implementation of the Eclipse <b>Plugin</b>.
83
   * The actual implementation of the Eclipse <b>Plugin</b>.
77
   */
84
   */
78
  public static class Implementation extends EclipseUIPlugin 
85
  public static class Implementation extends EclipseUIPlugin
79
  {
86
  {
80
    /**
87
    /**
81
     * Creates an instance.
88
     * Creates an instance.
Lines 88-92 Link Here
88
      //
95
      //
89
      plugin = this;
96
      plugin = this;
90
    }
97
    }
98
99
    /**
100
     * Starts up this plugin by reading some extensions and populating the relevant registries.
101
     * <p>
102
     * @throws Exception if there is a show stopping problem.
103
     */
104
    @Override
105
    public void start(BundleContext context) throws Exception
106
    {
107
      super.start(context);
108
109
      Bundle bundle = Platform.getBundle("org.eclipse.jface.text");
110
      if (bundle != null && (bundle.getState() & (Bundle.ACTIVE | Bundle.STARTING | Bundle.RESOLVED)) != 0)
111
      {
112
        new RegistryReader(
113
          Platform.getExtensionRegistry(),
114
          EMFEditUIPlugin.getPlugin().getBundle().getSymbolicName(),
115
          QUERY_DELEGATE_TEXT_VIEWER_FACTORIES_PPID)
116
          {
117
            @Override
118
            protected boolean readElement(IConfigurationElement element, boolean add)
119
            {
120
              if (element.getName().equals("factory"))
121
              {
122
                String uri = element.getAttribute("uri");
123
                if (uri == null)
124
                {
125
                  logMissingAttribute(element, "uri");
126
                }
127
                else if (element.getAttribute("class") == null)
128
                {
129
                  logMissingAttribute(element, "class");
130
                }
131
132
                class FactoryDescriptor extends PluginClassDescriptor implements QueryDelegateTextViewer.Factory.Descriptor
133
                {
134
                  protected QueryDelegateTextViewer.Factory factory;
135
136
                  public FactoryDescriptor(IConfigurationElement e, String attrName)
137
                  {
138
                    super(e, attrName);
139
                  }
140
141
                  public QueryDelegateTextViewer.Factory getFactory()
142
                  {
143
                    if (factory == null)
144
                    {
145
                      factory = (QueryDelegateTextViewer.Factory)createInstance();
146
                    }
147
                    return factory;
148
                  }
149
150
                  public IConfigurationElement getElement()
151
                  {
152
                    return element;
153
                  }
154
                }
155
156
                if (add)
157
                {
158
                  Object previous = QueryDelegateTextViewer.Factory.Registry.INSTANCE.put(uri, new FactoryDescriptor(element, "class"));
159
                  if (previous instanceof FactoryDescriptor)
160
                  {
161
                    FactoryDescriptor descriptor = (FactoryDescriptor)previous;
162
                    EMFEditUIPlugin.INSTANCE.log("Both '" + descriptor.getElement().getContributor().getName() + "' and '"
163
                      + element.getContributor().getName() + "' register a query delegate text viewer factory for '" + uri + "'");
164
                  }
165
                  return true;
166
                }
167
                else
168
                {
169
                  QueryDelegateTextViewer.Factory.Registry.INSTANCE.remove(uri);
170
                  return true;
171
                }
172
              }
173
              return false;
174
            }
175
          }.readRegistry();
176
      }
177
    }
91
  }
178
  }
92
}
179
}
(-)src/org/eclipse/emf/edit/ui/util/QueryDelegateTextViewer.java (+108 lines)
Added Link Here
1
/**
2
 * <copyright>
3
 *
4
 * Copyright (c) 2010 Kenn Hussey and others.
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Common Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/cpl-v10.html
9
 * 
10
 * Contributors: 
11
 *   Kenn Hussey - Initial API and implementation
12
 *
13
 * </copyright>
14
 *
15
 * $Id$
16
 */
17
package org.eclipse.emf.edit.ui.util;
18
19
import java.util.HashMap;
20
import java.util.Map;
21
22
import org.eclipse.emf.ecore.EClassifier;
23
import org.eclipse.jface.text.ITextViewer;
24
import org.eclipse.swt.widgets.Composite;
25
26
27
/**
28
 * An interface for text viewers of query delegate expressions.
29
 * 
30
 * @since 2.7
31
 */
32
public interface QueryDelegateTextViewer extends ITextViewer
33
{
34
  /**
35
   * A factory for creating query delegate source viewers.
36
   */
37
  interface Factory
38
  {
39
    /**
40
     * Creates a query delegate for the specified <tt>parent</tt>.
41
     * 
42
     * @param parent the parent container for the text viewer
43
     * @param styles the styles to apply to the text viewer
44
     * @return a query delegate text viewer
45
     */
46
    QueryDelegateTextViewer createTextViewer(Composite parent, int styles);
47
48
    /**
49
     * A <code>Factory</code> wrapper that is used by the {@link Factory.Registry}.
50
     */
51
    interface Descriptor
52
    {
53
      Factory getFactory();
54
    }
55
56
    /**
57
     * A registry of query delegate text viewer factories.
58
     */
59
    interface Registry extends Map<String, Object>
60
    {
61
      Registry INSTANCE = new Impl();
62
63
      Factory getFactory(String uri);
64
65
      class Impl extends HashMap<String, Object> implements Registry
66
      {
67
        private static final long serialVersionUID = 1L;
68
69
        @Override
70
        public Object get(Object key)
71
        {
72
          Object factory = super.get(key);
73
          if (factory instanceof Descriptor)
74
          {
75
            Descriptor factoryDescriptor = (Descriptor)factory;
76
            factory = factoryDescriptor.getFactory();
77
            put((String)key, factory);
78
            return factory;
79
          }
80
          else
81
          {
82
            return factory;
83
          }
84
        }
85
86
        public Factory getFactory(String uri)
87
        {
88
          return (Factory)get(uri);
89
        }
90
      }
91
    }
92
  }
93
94
  /**
95
   * Sets the context for the text viewer's query.
96
   * 
97
   * @param context the type of object against which the query will be executed
98
   */
99
  void setContext(EClassifier context);
100
101
  /**
102
   * Sets the parameters for the text viewer's query.
103
   * 
104
   * @param parameters a map of parameter names to types
105
   */
106
  void setParameters(Map<String, EClassifier> parameters);
107
108
}

Return to bug 332961