diff options
author | Camille Letavernier | 2014-08-21 11:43:07 +0000 |
---|---|---|
committer | Camille Letavernier | 2014-08-21 13:50:25 +0000 |
commit | dbc038b44bcbb890ae256d15eb09eb285512f020 (patch) | |
tree | 757e736583eea3ae352ad9ac91a81df7e59b79ff /plugins/uml/org.eclipse.papyrus.uml.search.ui | |
parent | ea48a20561464c3cbb7895d430583669a9f82fcc (diff) | |
download | org.eclipse.papyrus-dbc038b44bcbb890ae256d15eb09eb285512f020.tar.gz org.eclipse.papyrus-dbc038b44bcbb890ae256d15eb09eb285512f020.tar.xz org.eclipse.papyrus-dbc038b44bcbb890ae256d15eb09eb285512f020.zip |
[Code style] Apply clean-up and formatter on Main plug-ins
Diffstat (limited to 'plugins/uml/org.eclipse.papyrus.uml.search.ui')
42 files changed, 1283 insertions, 1272 deletions
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/com/swtdesigner/ResourceManager.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/com/swtdesigner/ResourceManager.java index 8e97c09fdb9..f6a59eb533d 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/com/swtdesigner/ResourceManager.java +++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/com/swtdesigner/ResourceManager.java @@ -1,7 +1,7 @@ /***************************************************************************** * Copyright (c) 2013 CEA LIST. * - * + * * 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 @@ -34,37 +34,37 @@ import org.osgi.framework.Bundle; /** * Utility class for managing OS resources associated with SWT/JFace controls such as colors, fonts, images, * etc. - * + * * !!! IMPORTANT !!! Application code must explicitly invoke the <code>dispose()</code> method to release the * operating system resources managed by cached objects when those objects and OS resources are no longer * needed (e.g. on application shutdown) - * + * * This class may be freely distributed as part of any application or plugin. * <p> * Copyright (c) 2003 - 2007, Instantiations, Inc. <br> * All Rights Reserved - * + * * @author scheglov_ke * @author Dan Rubel */ public class ResourceManager extends SWTResourceManager { - //////////////////////////////////////////////////////////////////////////// + // ////////////////////////////////////////////////////////////////////////// // // Image // - //////////////////////////////////////////////////////////////////////////// + // ////////////////////////////////////////////////////////////////////////// /** The m_descriptor image map. */ private static Map<ImageDescriptor, Image> m_descriptorImageMap = new HashMap<ImageDescriptor, Image>(); /** * Returns an {@link ImageDescriptor} stored in the file at the specified path relative to the specified * class. - * + * * @param clazz - * the {@link Class} relative to which to find the image descriptor. + * the {@link Class} relative to which to find the image descriptor. * @param path - * the path to the image file. + * the path to the image file. * @return the {@link ImageDescriptor} stored in the file at the specified path. */ public static ImageDescriptor getImageDescriptor(Class<?> clazz, String path) { @@ -73,9 +73,9 @@ public class ResourceManager extends SWTResourceManager { /** * Returns an {@link ImageDescriptor} stored in the file at the specified path. - * + * * @param path - * the path to the image file. + * the path to the image file. * @return the {@link ImageDescriptor} stored in the file at the specified path. */ public static ImageDescriptor getImageDescriptor(String path) { @@ -88,17 +88,17 @@ public class ResourceManager extends SWTResourceManager { /** * Returns an {@link Image} based on the specified {@link ImageDescriptor}. - * + * * @param descriptor - * the {@link ImageDescriptor} for the {@link Image}. + * the {@link ImageDescriptor} for the {@link Image}. * @return the {@link Image} based on the specified {@link ImageDescriptor}. */ public static Image getImage(ImageDescriptor descriptor) { - if(descriptor == null) { + if (descriptor == null) { return null; } Image image = m_descriptorImageMap.get(descriptor); - if(image == null) { + if (image == null) { image = descriptor.createImage(); m_descriptorImageMap.put(descriptor, image); } @@ -113,11 +113,11 @@ public class ResourceManager extends SWTResourceManager { /** * Returns an {@link Image} composed of a base image decorated by another image. - * + * * @param baseImage - * the base {@link Image} that should be decorated. + * the base {@link Image} that should be decorated. * @param decorator - * the {@link Image} to decorate the base image. + * the {@link Image} to decorate the base image. * @return {@link Image} The resulting decorated image. */ public static Image decorateImage(Image baseImage, Image decorator) { @@ -126,32 +126,32 @@ public class ResourceManager extends SWTResourceManager { /** * Returns an {@link Image} composed of a base image decorated by another image. - * + * * @param baseImage - * the base {@link Image} that should be decorated. + * the base {@link Image} that should be decorated. * @param decorator - * the {@link Image} to decorate the base image. + * the {@link Image} to decorate the base image. * @param corner - * the corner to place decorator image. + * the corner to place decorator image. * @return the resulting decorated {@link Image}. */ public static Image decorateImage(final Image baseImage, final Image decorator, final int corner) { - if(corner <= 0 || corner >= LAST_CORNER_KEY) { + if (corner <= 0 || corner >= LAST_CORNER_KEY) { throw new IllegalArgumentException("Wrong decorate corner"); } Map<Image, Map<Image, Image>> cornerDecoratedImageMap = m_decoratedImageMap[corner]; - if(cornerDecoratedImageMap == null) { + if (cornerDecoratedImageMap == null) { cornerDecoratedImageMap = new HashMap<Image, Map<Image, Image>>(); m_decoratedImageMap[corner] = cornerDecoratedImageMap; } Map<Image, Image> decoratedMap = cornerDecoratedImageMap.get(baseImage); - if(decoratedMap == null) { + if (decoratedMap == null) { decoratedMap = new HashMap<Image, Image>(); cornerDecoratedImageMap.put(baseImage, decoratedMap); } // Image result = decoratedMap.get(decorator); - if(result == null) { + if (result == null) { final Rectangle bib = baseImage.getBounds(); final Rectangle dib = decorator.getBounds(); final Point baseImageSize = new Point(bib.width, bib.height); @@ -160,13 +160,13 @@ public class ResourceManager extends SWTResourceManager { @Override protected void drawCompositeImage(int width, int height) { drawImage(baseImage.getImageData(), 0, 0); - if(corner == TOP_LEFT) { + if (corner == TOP_LEFT) { drawImage(decorator.getImageData(), 0, 0); - } else if(corner == TOP_RIGHT) { + } else if (corner == TOP_RIGHT) { drawImage(decorator.getImageData(), bib.width - dib.width, 0); - } else if(corner == BOTTOM_LEFT) { + } else if (corner == BOTTOM_LEFT) { drawImage(decorator.getImageData(), 0, bib.height - dib.height); - } else if(corner == BOTTOM_RIGHT) { + } else if (corner == BOTTOM_RIGHT) { drawImage(decorator.getImageData(), bib.width - dib.width, bib.height - dib.height); } } @@ -190,17 +190,17 @@ public class ResourceManager extends SWTResourceManager { SWTResourceManager.disposeImages(); // dispose ImageDescriptor images { - for(Iterator<Image> I = m_descriptorImageMap.values().iterator(); I.hasNext();) { + for (Iterator<Image> I = m_descriptorImageMap.values().iterator(); I.hasNext();) { I.next().dispose(); } m_descriptorImageMap.clear(); } // dispose decorated images - for(int i = 0; i < m_decoratedImageMap.length; i++) { + for (int i = 0; i < m_decoratedImageMap.length; i++) { Map<Image, Map<Image, Image>> cornerDecoratedImageMap = m_decoratedImageMap[i]; - if(cornerDecoratedImageMap != null) { - for(Map<Image, Image> decoratedMap : cornerDecoratedImageMap.values()) { - for(Image image : decoratedMap.values()) { + if (cornerDecoratedImageMap != null) { + for (Map<Image, Image> decoratedMap : cornerDecoratedImageMap.values()) { + for (Image image : decoratedMap.values()) { image.dispose(); } decoratedMap.clear(); @@ -210,18 +210,18 @@ public class ResourceManager extends SWTResourceManager { } // dispose plugin images { - for(Iterator<Image> I = m_URLImageMap.values().iterator(); I.hasNext();) { + for (Iterator<Image> I = m_URLImageMap.values().iterator(); I.hasNext();) { I.next().dispose(); } m_URLImageMap.clear(); } } - //////////////////////////////////////////////////////////////////////////// + // ////////////////////////////////////////////////////////////////////////// // // Plugin images support // - //////////////////////////////////////////////////////////////////////////// + // ////////////////////////////////////////////////////////////////////////// /** * Maps URL to images. */ @@ -234,11 +234,11 @@ public class ResourceManager extends SWTResourceManager { /** * Gets the entry. - * + * * @param symbolicName - * the symbolic name + * the symbolic name * @param path - * the path + * the path * @return the entry */ URL getEntry(String symbolicName, String path); @@ -251,20 +251,20 @@ public class ResourceManager extends SWTResourceManager { /** * Returns an {@link Image} based on a plugin and file path. - * + * * @param plugin - * the plugin {@link Object} containing the image + * the plugin {@link Object} containing the image * @param name - * the path to the image within the plugin + * the path to the image within the plugin * @return the {@link Image} stored in the file at the specified path - * + * * @deprecated Use {@link #getPluginImage(String, String)} instead. */ @Deprecated public static Image getPluginImage(Object plugin, String name) { try { URL url = getPluginImageURL(plugin, name); - if(url != null) { + if (url != null) { return getPluginImageFromUrl(url); } } catch (Throwable e) { @@ -275,17 +275,17 @@ public class ResourceManager extends SWTResourceManager { /** * Returns an {@link Image} based on a {@link Bundle} and resource entry path. - * + * * @param symbolicName - * the symbolic name of the {@link Bundle}. + * the symbolic name of the {@link Bundle}. * @param path - * the path of the resource entry. + * the path of the resource entry. * @return the {@link Image} stored in the file at the specified path. */ public static Image getPluginImage(String symbolicName, String path) { try { URL url = getPluginImageURL(symbolicName, path); - if(url != null) { + if (url != null) { return getPluginImageFromUrl(url); } } catch (Throwable e) { @@ -296,9 +296,9 @@ public class ResourceManager extends SWTResourceManager { /** * Returns an {@link Image} based on given {@link URL}. - * + * * @param url - * the url + * the url * @return the plugin image from url */ private static Image getPluginImageFromUrl(URL url) { @@ -306,7 +306,7 @@ public class ResourceManager extends SWTResourceManager { try { String key = url.toExternalForm(); Image image = m_URLImageMap.get(key); - if(image == null) { + if (image == null) { InputStream stream = url.openStream(); try { image = getImage(stream); @@ -327,13 +327,13 @@ public class ResourceManager extends SWTResourceManager { /** * Returns an {@link ImageDescriptor} based on a plugin and file path. - * + * * @param plugin - * the plugin {@link Object} containing the image. + * the plugin {@link Object} containing the image. * @param name - * the path to th eimage within the plugin. + * the path to th eimage within the plugin. * @return the {@link ImageDescriptor} stored in the file at the specified path. - * + * * @deprecated Use {@link #getPluginImageDescriptor(String, String)} instead. */ @Deprecated @@ -353,17 +353,17 @@ public class ResourceManager extends SWTResourceManager { /** * Returns an {@link ImageDescriptor} based on a {@link Bundle} and resource entry path. - * + * * @param symbolicName - * the symbolic name of the {@link Bundle}. + * the symbolic name of the {@link Bundle}. * @param path - * the path of the resource entry. + * the path of the resource entry. * @return the {@link ImageDescriptor} based on a {@link Bundle} and resource entry path. */ public static ImageDescriptor getPluginImageDescriptor(String symbolicName, String path) { try { URL url = getPluginImageURL(symbolicName, path); - if(url != null) { + if (url != null) { return ImageDescriptor.createFromURL(url); } } catch (Throwable e) { @@ -374,23 +374,23 @@ public class ResourceManager extends SWTResourceManager { /** * Returns an {@link URL} based on a {@link Bundle} and resource entry path. - * + * * @param symbolicName - * the symbolic name + * the symbolic name * @param path - * the path + * the path * @return the plugin image url */ private static URL getPluginImageURL(String symbolicName, String path) { // try runtime plugins { Bundle bundle = Platform.getBundle(symbolicName); - if(bundle != null) { + if (bundle != null) { return bundle.getEntry(path); } } // try design time provider - if(m_designTimePluginResourceProvider != null) { + if (m_designTimePluginResourceProvider != null) { return m_designTimePluginResourceProvider.getEntry(symbolicName, path); } // no such resource @@ -399,32 +399,32 @@ public class ResourceManager extends SWTResourceManager { /** * Returns an {@link URL} based on a plugin and file path. - * + * * @param plugin - * the plugin {@link Object} containing the file path. + * the plugin {@link Object} containing the file path. * @param name - * the file path. + * the file path. * @return the {@link URL} representing the file at the specified path. * @throws Exception - * the exception + * the exception */ private static URL getPluginImageURL(Object plugin, String name) throws Exception { // try to work with 'plugin' as with OSGI BundleContext try { Class<?> BundleClass = Class.forName("org.osgi.framework.Bundle"); //$NON-NLS-1$ Class<?> BundleContextClass = Class.forName("org.osgi.framework.BundleContext"); //$NON-NLS-1$ - if(BundleContextClass.isAssignableFrom(plugin.getClass())) { + if (BundleContextClass.isAssignableFrom(plugin.getClass())) { Method getBundleMethod = BundleContextClass.getMethod("getBundle", new Class[0]); //$NON-NLS-1$ Object bundle = getBundleMethod.invoke(plugin, new Object[0]); // Class<?> PathClass = Class.forName("org.eclipse.core.runtime.Path"); //$NON-NLS-1$ - Constructor<?> pathConstructor = PathClass.getConstructor(new Class[]{ String.class }); - Object path = pathConstructor.newInstance(new Object[]{ name }); + Constructor<?> pathConstructor = PathClass.getConstructor(new Class[] { String.class }); + Object path = pathConstructor.newInstance(new Object[] { name }); // Class<?> IPathClass = Class.forName("org.eclipse.core.runtime.IPath"); //$NON-NLS-1$ Class<?> PlatformClass = Class.forName("org.eclipse.core.runtime.Platform"); //$NON-NLS-1$ - Method findMethod = PlatformClass.getMethod("find", new Class[]{ BundleClass, IPathClass }); //$NON-NLS-1$ - return (URL)findMethod.invoke(null, new Object[]{ bundle, path }); + Method findMethod = PlatformClass.getMethod("find", new Class[] { BundleClass, IPathClass }); //$NON-NLS-1$ + return (URL) findMethod.invoke(null, new Object[] { bundle, path }); } } catch (Throwable e) { // Ignore any exceptions @@ -432,25 +432,25 @@ public class ResourceManager extends SWTResourceManager { // else work with 'plugin' as with usual Eclipse plugin { Class<?> PluginClass = Class.forName("org.eclipse.core.runtime.Plugin"); //$NON-NLS-1$ - if(PluginClass.isAssignableFrom(plugin.getClass())) { + if (PluginClass.isAssignableFrom(plugin.getClass())) { // Class<?> PathClass = Class.forName("org.eclipse.core.runtime.Path"); //$NON-NLS-1$ - Constructor<?> pathConstructor = PathClass.getConstructor(new Class[]{ String.class }); - Object path = pathConstructor.newInstance(new Object[]{ name }); + Constructor<?> pathConstructor = PathClass.getConstructor(new Class[] { String.class }); + Object path = pathConstructor.newInstance(new Object[] { name }); // Class<?> IPathClass = Class.forName("org.eclipse.core.runtime.IPath"); //$NON-NLS-1$ - Method findMethod = PluginClass.getMethod("find", new Class[]{ IPathClass }); //$NON-NLS-1$ - return (URL)findMethod.invoke(plugin, new Object[]{ path }); + Method findMethod = PluginClass.getMethod("find", new Class[] { IPathClass }); //$NON-NLS-1$ + return (URL) findMethod.invoke(plugin, new Object[] { path }); } } return null; } - //////////////////////////////////////////////////////////////////////////// + // ////////////////////////////////////////////////////////////////////////// // // General // - //////////////////////////////////////////////////////////////////////////// + // ////////////////////////////////////////////////////////////////////////// /** * Dispose of cached objects and their underlying OS resources. This should only be called when the cached * objects are no longer needed (e.g. on application shutdown). diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/com/swtdesigner/SWTResourceManager.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/com/swtdesigner/SWTResourceManager.java index fef8f8ded2a..f465208a5bf 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/com/swtdesigner/SWTResourceManager.java +++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/com/swtdesigner/SWTResourceManager.java @@ -1,7 +1,7 @@ /***************************************************************************** * Copyright (c) 2013 CEA LIST. * - * + * * 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 @@ -34,32 +34,31 @@ import org.eclipse.swt.widgets.Display; /** * Utility class for managing OS resources associated with SWT controls such as colors, fonts, images, etc. * <p> - * !!! IMPORTANT !!! Application code must explicitly invoke the <code>dispose()</code> method to release the operating system resources managed by - * cached objects when those objects and OS resources are no longer needed (e.g. on application shutdown) + * !!! IMPORTANT !!! Application code must explicitly invoke the <code>dispose()</code> method to release the operating system resources managed by cached objects when those objects and OS resources are no longer needed (e.g. on application shutdown) * <p> * This class may be freely distributed as part of any application or plugin. * <p> * Copyright (c) 2003 - 2007, Instantiations, Inc. <br> * All Rights Reserved - * + * * @author scheglov_ke * @author Dan Rubel */ public class SWTResourceManager { - //////////////////////////////////////////////////////////////////////////// + // ////////////////////////////////////////////////////////////////////////// // // Color // - //////////////////////////////////////////////////////////////////////////// + // ////////////////////////////////////////////////////////////////////////// /** The m_color map. */ private static Map<RGB, Color> m_colorMap = new HashMap<RGB, Color>(); /** * Returns the system {@link Color} matching the specific ID. - * + * * @param systemColorID - * the ID value for the color + * the ID value for the color * @return the system {@link Color} matching the specific ID */ public static Color getColor(int systemColorID) { @@ -69,13 +68,13 @@ public class SWTResourceManager { /** * Returns a {@link Color} given its red, green and blue component values. - * + * * @param r - * the red component of the color + * the red component of the color * @param g - * the green component of the color + * the green component of the color * @param b - * the blue component of the color + * the blue component of the color * @return the {@link Color} matching the given red, green and blue component values */ public static Color getColor(int r, int g, int b) { @@ -84,14 +83,14 @@ public class SWTResourceManager { /** * Returns a {@link Color} given its RGB value. - * + * * @param rgb - * the {@link RGB} value of the color + * the {@link RGB} value of the color * @return the {@link Color} matching the RGB value */ public static Color getColor(RGB rgb) { Color color = m_colorMap.get(rgb); - if(color == null) { + if (color == null) { Display display = Display.getCurrent(); color = new Color(display, rgb); m_colorMap.put(rgb, color); @@ -103,17 +102,17 @@ public class SWTResourceManager { * Dispose of all the cached {@link Color}'s. */ public static void disposeColors() { - for(Color color : m_colorMap.values()) { + for (Color color : m_colorMap.values()) { color.dispose(); } m_colorMap.clear(); } - //////////////////////////////////////////////////////////////////////////// + // ////////////////////////////////////////////////////////////////////////// // // Image // - //////////////////////////////////////////////////////////////////////////// + // ////////////////////////////////////////////////////////////////////////// /** * Maps image paths to images. */ @@ -121,18 +120,18 @@ public class SWTResourceManager { /** * Returns an {@link Image} encoded by the specified {@link InputStream}. - * + * * @param stream - * the {@link InputStream} encoding the image data + * the {@link InputStream} encoding the image data * @return the {@link Image} encoded by the specified input stream * @throws IOException - * Signals that an I/O exception has occurred. + * Signals that an I/O exception has occurred. */ protected static Image getImage(InputStream stream) throws IOException { try { Display display = Display.getCurrent(); ImageData data = new ImageData(stream); - if(data.transparentPixel > 0) { + if (data.transparentPixel > 0) { return new Image(display, data, data.getTransparencyMask()); } return new Image(display, data); @@ -143,14 +142,14 @@ public class SWTResourceManager { /** * Returns an {@link Image} stored in the file at the specified path. - * + * * @param path - * the path to the image file + * the path to the image file * @return the {@link Image} stored in the file at the specified path */ public static Image getImage(String path) { Image image = m_imageMap.get(path); - if(image == null) { + if (image == null) { try { image = getImage(new FileInputStream(path)); m_imageMap.put(path, image); @@ -164,17 +163,17 @@ public class SWTResourceManager { /** * Returns an {@link Image} stored in the file at the specified path relative to the specified class. - * + * * @param clazz - * the {@link Class} relative to which to find the image + * the {@link Class} relative to which to find the image * @param path - * the path to the image file, if starts with <code>'/'</code> + * the path to the image file, if starts with <code>'/'</code> * @return the {@link Image} stored in the file at the specified path */ public static Image getImage(Class<?> clazz, String path) { String key = clazz.getName() + '|' + path; Image image = m_imageMap.get(key); - if(image == null) { + if (image == null) { try { image = getImage(clazz.getResourceAsStream(path)); m_imageMap.put(key, image); @@ -191,7 +190,7 @@ public class SWTResourceManager { /** * Gets the missing image. - * + * * @return the small {@link Image} that can be used as placeholder for missing image. */ private static Image getMissingImage() { @@ -238,11 +237,11 @@ public class SWTResourceManager { /** * Returns an {@link Image} composed of a base image decorated by another image. - * + * * @param baseImage - * the base {@link Image} that should be decorated + * the base {@link Image} that should be decorated * @param decorator - * the {@link Image} to decorate the base image + * the {@link Image} to decorate the base image * @return {@link Image} The resulting decorated image */ public static Image decorateImage(Image baseImage, Image decorator) { @@ -251,32 +250,32 @@ public class SWTResourceManager { /** * Returns an {@link Image} composed of a base image decorated by another image. - * + * * @param baseImage - * the base {@link Image} that should be decorated + * the base {@link Image} that should be decorated * @param decorator - * the {@link Image} to decorate the base image + * the {@link Image} to decorate the base image * @param corner - * the corner to place decorator image + * the corner to place decorator image * @return the resulting decorated {@link Image} */ public static Image decorateImage(final Image baseImage, final Image decorator, final int corner) { - if(corner <= 0 || corner >= LAST_CORNER_KEY) { + if (corner <= 0 || corner >= LAST_CORNER_KEY) { throw new IllegalArgumentException("Wrong decorate corner"); } Map<Image, Map<Image, Image>> cornerDecoratedImageMap = m_decoratedImageMap[corner]; - if(cornerDecoratedImageMap == null) { + if (cornerDecoratedImageMap == null) { cornerDecoratedImageMap = new HashMap<Image, Map<Image, Image>>(); m_decoratedImageMap[corner] = cornerDecoratedImageMap; } Map<Image, Image> decoratedMap = cornerDecoratedImageMap.get(baseImage); - if(decoratedMap == null) { + if (decoratedMap == null) { decoratedMap = new HashMap<Image, Image>(); cornerDecoratedImageMap.put(baseImage, decoratedMap); } // Image result = decoratedMap.get(decorator); - if(result == null) { + if (result == null) { Rectangle bib = baseImage.getBounds(); Rectangle dib = decorator.getBounds(); // @@ -284,13 +283,13 @@ public class SWTResourceManager { // GC gc = new GC(result); gc.drawImage(baseImage, 0, 0); - if(corner == TOP_LEFT) { + if (corner == TOP_LEFT) { gc.drawImage(decorator, 0, 0); - } else if(corner == TOP_RIGHT) { + } else if (corner == TOP_RIGHT) { gc.drawImage(decorator, bib.width - dib.width, 0); - } else if(corner == BOTTOM_LEFT) { + } else if (corner == BOTTOM_LEFT) { gc.drawImage(decorator, 0, bib.height - dib.height); - } else if(corner == BOTTOM_RIGHT) { + } else if (corner == BOTTOM_RIGHT) { gc.drawImage(decorator, bib.width - dib.width, bib.height - dib.height); } gc.dispose(); @@ -306,17 +305,17 @@ public class SWTResourceManager { public static void disposeImages() { // dispose loaded images { - for(Image image : m_imageMap.values()) { + for (Image image : m_imageMap.values()) { image.dispose(); } m_imageMap.clear(); } // dispose decorated images - for(int i = 0; i < m_decoratedImageMap.length; i++) { + for (int i = 0; i < m_decoratedImageMap.length; i++) { Map<Image, Map<Image, Image>> cornerDecoratedImageMap = m_decoratedImageMap[i]; - if(cornerDecoratedImageMap != null) { - for(Map<Image, Image> decoratedMap : cornerDecoratedImageMap.values()) { - for(Image image : decoratedMap.values()) { + if (cornerDecoratedImageMap != null) { + for (Map<Image, Image> decoratedMap : cornerDecoratedImageMap.values()) { + for (Image image : decoratedMap.values()) { image.dispose(); } decoratedMap.clear(); @@ -326,11 +325,11 @@ public class SWTResourceManager { } } - //////////////////////////////////////////////////////////////////////////// + // ////////////////////////////////////////////////////////////////////////// // // Font // - //////////////////////////////////////////////////////////////////////////// + // ////////////////////////////////////////////////////////////////////////// /** * Maps font names to fonts. */ @@ -343,13 +342,13 @@ public class SWTResourceManager { /** * Returns a {@link Font} based on its name, height and style. - * + * * @param name - * the name of the font + * the name of the font * @param height - * the height of the font + * the height of the font * @param style - * the style of the font + * the style of the font * @return {@link Font} The font matching the name, height and style */ public static Font getFont(String name, int height, int style) { @@ -359,34 +358,34 @@ public class SWTResourceManager { /** * Returns a {@link Font} based on its name, height and style. Windows-specific strikeout and underline * flags are also supported. - * + * * @param name - * the name of the font + * the name of the font * @param size - * the size of the font + * the size of the font * @param style - * the style of the font + * the style of the font * @param strikeout - * the strikeout flag (warning: Windows only) + * the strikeout flag (warning: Windows only) * @param underline - * the underline flag (warning: Windows only) + * the underline flag (warning: Windows only) * @return {@link Font} The font matching the name, height, style, strikeout and underline */ public static Font getFont(String name, int size, int style, boolean strikeout, boolean underline) { String fontName = name + '|' + size + '|' + style + '|' + strikeout + '|' + underline; Font font = m_fontMap.get(fontName); - if(font == null) { + if (font == null) { FontData fontData = new FontData(name, size, style); - if(strikeout || underline) { + if (strikeout || underline) { try { Class<?> logFontClass = Class.forName("org.eclipse.swt.internal.win32.LOGFONT"); //$NON-NLS-1$ Object logFont = FontData.class.getField("data").get(fontData); //$NON-NLS-1$ - if(logFont != null && logFontClass != null) { - if(strikeout) { - logFontClass.getField("lfStrikeOut").set(logFont, Byte.valueOf((byte)1)); //$NON-NLS-1$ + if (logFont != null && logFontClass != null) { + if (strikeout) { + logFontClass.getField("lfStrikeOut").set(logFont, Byte.valueOf((byte) 1)); //$NON-NLS-1$ } - if(underline) { - logFontClass.getField("lfUnderline").set(logFont, Byte.valueOf((byte)1)); //$NON-NLS-1$ + if (underline) { + logFontClass.getField("lfUnderline").set(logFont, Byte.valueOf((byte) 1)); //$NON-NLS-1$ } } } catch (Throwable e) { @@ -401,14 +400,14 @@ public class SWTResourceManager { /** * Returns a bold version of the given {@link Font}. - * + * * @param baseFont - * the {@link Font} for which a bold version is desired + * the {@link Font} for which a bold version is desired * @return the bold version of the given {@link Font} */ public static Font getBoldFont(Font baseFont) { Font font = m_fontToBoldFontMap.get(baseFont); - if(font == null) { + if (font == null) { FontData fontDatas[] = baseFont.getFontData(); FontData data = fontDatas[0]; font = new Font(Display.getCurrent(), data.getName(), data.getHeight(), SWT.BOLD); @@ -422,22 +421,22 @@ public class SWTResourceManager { */ public static void disposeFonts() { // clear fonts - for(Font font : m_fontMap.values()) { + for (Font font : m_fontMap.values()) { font.dispose(); } m_fontMap.clear(); // clear bold fonts - for(Font font : m_fontToBoldFontMap.values()) { + for (Font font : m_fontToBoldFontMap.values()) { font.dispose(); } m_fontToBoldFontMap.clear(); } - //////////////////////////////////////////////////////////////////////////// + // ////////////////////////////////////////////////////////////////////////// // // Cursor // - //////////////////////////////////////////////////////////////////////////// + // ////////////////////////////////////////////////////////////////////////// /** * Maps IDs to cursors. */ @@ -445,15 +444,15 @@ public class SWTResourceManager { /** * Returns the system cursor matching the specific ID. - * + * * @param id - * int The ID value for the cursor + * int The ID value for the cursor * @return Cursor The system cursor matching the specific ID */ public static Cursor getCursor(int id) { Integer key = Integer.valueOf(id); Cursor cursor = m_idToCursorMap.get(key); - if(cursor == null) { + if (cursor == null) { cursor = new Cursor(Display.getDefault(), id); m_idToCursorMap.put(key, cursor); } @@ -464,17 +463,17 @@ public class SWTResourceManager { * Dispose all of the cached cursors. */ public static void disposeCursors() { - for(Cursor cursor : m_idToCursorMap.values()) { + for (Cursor cursor : m_idToCursorMap.values()) { cursor.dispose(); } m_idToCursorMap.clear(); } - //////////////////////////////////////////////////////////////////////////// + // ////////////////////////////////////////////////////////////////////////// // // General // - //////////////////////////////////////////////////////////////////////////// + // ////////////////////////////////////////////////////////////////////////// /** * Dispose of cached objects and their underlying OS resources. This should only be called when the cached * objects are no longer needed (e.g. on application shutdown). diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/Activator.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/Activator.java index 78d2607ee2d..1afd9ed46d0 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/Activator.java +++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/Activator.java @@ -1,7 +1,7 @@ /*****************************************************************************
* Copyright (c) 2013 CEA LIST.
*
- *
+ *
* 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
@@ -46,7 +46,7 @@ public class Activator extends EssentialOCLActivator { */
/**
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
- *
+ *
* @param context
* @throws Exception
*/
@@ -65,7 +65,7 @@ public class Activator extends EssentialOCLActivator { */
/**
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
- *
+ *
* @param context
* @throws Exception
*/
@@ -78,7 +78,7 @@ public class Activator extends EssentialOCLActivator { /**
* Returns the shared instance.
- *
+ *
* @return the shared instance
*/
public static Activator getDefault() {
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/CheckBoxFilteredTree.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/CheckBoxFilteredTree.java index 67d8179fa10..aad40b5a9d0 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/CheckBoxFilteredTree.java +++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/CheckBoxFilteredTree.java @@ -1,7 +1,7 @@ /*****************************************************************************
* Copyright (c) 2013 CEA LIST.
*
- *
+ *
* 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,9 +20,9 @@ import org.eclipse.ui.dialogs.FilteredTree; import org.eclipse.ui.dialogs.PatternFilter;
/**
- *
+ *
* An custom FilteredTree that provides Checkboxes for items
- *
+ *
*/
public class CheckBoxFilteredTree extends FilteredTree {
@@ -32,9 +32,9 @@ public class CheckBoxFilteredTree extends FilteredTree { /**
* Override to create a CheckBoxTreeViewer instead
- *
+ *
* @see org.eclipse.ui.dialogs.FilteredTree#doCreateTreeViewer(org.eclipse.swt.widgets.Composite, int)
- *
+ *
* @param parent
* @param style
* @return
@@ -46,10 +46,10 @@ public class CheckBoxFilteredTree extends FilteredTree { /**
* Give an access to the viewer with appropriate typing
- *
+ *
* @return the CheckBoxTreeViewer
*/
public CheckboxTreeViewer getCheckboxTreeViewer() {
- return (CheckboxTreeViewer)getViewer();
+ return (CheckboxTreeViewer) getViewer();
}
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/Messages.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/Messages.java index 9a1cd027295..ccfbbfc83b8 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/Messages.java +++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/Messages.java @@ -1,7 +1,7 @@ /*****************************************************************************
* Copyright (c) 2013 CEA LIST.
*
- *
+ *
* 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
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/actions/FilterTypesAction.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/actions/FilterTypesAction.java index e4138149a75..5260842573f 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/actions/FilterTypesAction.java +++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/actions/FilterTypesAction.java @@ -1,7 +1,7 @@ /*****************************************************************************
* Copyright (c) 2013 CEA LIST.
*
- *
+ *
* 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,20 +22,20 @@ import org.eclipse.search.ui.text.AbstractTextSearchViewPage; import com.swtdesigner.ResourceManager;
/**
- *
+ *
* Action that opens a {@link org.eclipse.papyrus.uml.search.ui.dialogs.TypesFilterDialog} in order to filter search results
- *
+ *
*/
public class FilterTypesAction extends Action {
private AbstractTextSearchViewPage fPage;
/**
- *
+ *
* Constructor.
- *
+ *
* @param page
- * the result page whose results while be filtered
+ * the result page whose results while be filtered
*/
public FilterTypesAction(AbstractTextSearchViewPage page) {
fPage = page;
@@ -45,9 +45,9 @@ public class FilterTypesAction extends Action { }
/**
- *
+ *
* @see org.eclipse.jface.action.Action#run()
- *
+ *
*/
@Override
public void run() {
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/actions/ReplaceAction.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/actions/ReplaceAction.java index 47aa2a5c67e..143b35d193b 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/actions/ReplaceAction.java +++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/actions/ReplaceAction.java @@ -1,7 +1,7 @@ /*****************************************************************************
* Copyright (c) 2013 CEA LIST.
*
- *
+ *
* 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
@@ -28,7 +28,7 @@ public class ReplaceAction extends Action { /**
* Creates the replace action to be
- *
+ *
* @param shell
* the parent shell
* @param resultPage
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/adapter/PapyrusSearchAdapterFactory.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/adapter/PapyrusSearchAdapterFactory.java index d26efd0b20e..f64561dccaa 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/adapter/PapyrusSearchAdapterFactory.java +++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/adapter/PapyrusSearchAdapterFactory.java @@ -1,7 +1,7 @@ /*****************************************************************************
* Copyright (c) 2013 CEA LIST.
*
- *
+ *
* 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
@@ -18,24 +18,24 @@ import org.eclipse.search.ui.ISearchPageScoreComputer; /**
* Adapter factory for Papyrus Search
- *
+ *
* @author Camille
- *
+ *
*/
public class PapyrusSearchAdapterFactory implements IAdapterFactory {
public PapyrusSearchAdapterFactory() {
- //Nothing
+ // Nothing
}
public Object getAdapter(Object adaptableObject, Class adapterType) {
- if(adapterType == ISearchPageScoreComputer.class) {
+ if (adapterType == ISearchPageScoreComputer.class) {
return new PapyrusSearchPageScoreComputer();
}
return null;
}
public Class[] getAdapterList() {
- return new Class[]{ ISearchPageScoreComputer.class };
+ return new Class[] { ISearchPageScoreComputer.class };
}
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/adapter/PapyrusSearchPageScoreComputer.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/adapter/PapyrusSearchPageScoreComputer.java index 438141e0624..1206b25d0f4 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/adapter/PapyrusSearchPageScoreComputer.java +++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/adapter/PapyrusSearchPageScoreComputer.java @@ -1,7 +1,7 @@ /*****************************************************************************
* Copyright (c) 2013 CEA LIST.
*
- *
+ *
* 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
@@ -21,22 +21,22 @@ import org.eclipse.search.ui.ISearchPageScoreComputer; /**
* Computes the search page score for the Papyrus Search Page
- *
+ *
* @author Camille Letavernier
*/
public class PapyrusSearchPageScoreComputer implements ISearchPageScoreComputer {
public int computeScore(String pageId, Object input) {
- if("org.eclipse.papyrus.search.ui.pages.PapyrusSearchPage".equals(pageId)) { //$NON-NLS-1$
+ if ("org.eclipse.papyrus.search.ui.pages.PapyrusSearchPage".equals(pageId)) { //$NON-NLS-1$
EObject currentEObject = EMFHelper.getEObject(input);
- if(currentEObject != null) {
+ if (currentEObject != null) {
try {
ServicesRegistry registry = ServiceUtilsForEObject.getInstance().getServiceRegistry(currentEObject);
- if(registry != null) {
+ if (registry != null) {
return 99;
}
} catch (Exception ex) {
- //Nothing
+ // Nothing
}
}
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/dialogs/ReplaceDialog.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/dialogs/ReplaceDialog.java index 1904b7e52fc..e1cd83bf96d 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/dialogs/ReplaceDialog.java +++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/dialogs/ReplaceDialog.java @@ -1,7 +1,7 @@ /*****************************************************************************
* Copyright (c) 2013 CEA LIST.
*
- *
+ *
* 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
@@ -63,23 +63,23 @@ public class ReplaceDialog extends Dialog { Text replaceText;
/**
- *
+ *
* Constructor.
- *
+ *
* @param parentShell
- * the parent shell, or <code>null</code> to create a top-level
- * shell
+ * the parent shell, or <code>null</code> to create a top-level
+ * shell
* @param fSelection
* @param fResult
* @param page
- * the result page whose results while be filtered
+ * the result page whose results while be filtered
*/
public ReplaceDialog(Shell parentShell, PapyrusSearchResultPage fResultPage, Object[] selection) {
super(parentShell);
this.fResultPage = fResultPage;
this.fSelection = selection;
- this.fQuery = (org.eclipse.papyrus.uml.search.ui.query.AbstractPapyrusQuery)fResultPage.getInput().getQuery();
+ this.fQuery = (org.eclipse.papyrus.uml.search.ui.query.AbstractPapyrusQuery) fResultPage.getInput().getQuery();
}
@@ -126,13 +126,13 @@ public class ReplaceDialog extends Dialog { }
private String computeReplacementString(Pattern pattern, String originalText, String replacementText) throws PatternSyntaxException {
- if(pattern != null) {
+ if (pattern != null) {
try {
Matcher matcher = pattern.matcher(originalText);
StringBuffer sb = new StringBuffer();
matcher.reset();
- if(matcher.find()) {
+ if (matcher.find()) {
matcher.appendReplacement(sb, replacementText);
} else {
return null;
@@ -147,40 +147,40 @@ public class ReplaceDialog extends Dialog { }
private void change(AttributeMatch match) {
- if(match.getSource() instanceof EObject) {
+ if (match.getSource() instanceof EObject) {
- EObject target = (EObject)match.getSource();
+ EObject target = (EObject) match.getSource();
- if(match.getMetaAttribute() instanceof EAttribute) {
- Object value = target.eGet((EAttribute)match.getMetaAttribute());
- if(value != null) {
- if(value instanceof String) {
- String originalvalue = (String)value;
+ if (match.getMetaAttribute() instanceof EAttribute) {
+ Object value = target.eGet((EAttribute) match.getMetaAttribute());
+ if (value != null) {
+ if (value instanceof String) {
+ String originalvalue = (String) value;
Pattern pattern = PatternHelper.getInstance().createPattern(fQuery.getSearchQueryText(), fQuery.isCaseSensitive(), fQuery.isRegularExpression());
String newValue = computeReplacementString(pattern, originalvalue, replaceText.getText());
- target.eSet((EAttribute)match.getMetaAttribute(), newValue);
+ target.eSet((EAttribute) match.getMetaAttribute(), newValue);
}
}
- } else if(match.getMetaAttribute() instanceof Property) {
- Property source = (Property)match.getMetaAttribute();
+ } else if (match.getMetaAttribute() instanceof Property) {
+ Property source = (Property) match.getMetaAttribute();
Class containingClass = source.getClass_();
- if(containingClass instanceof Stereotype) {
- if(target instanceof Element) {
- Object tagValue = ((Element)target).getValue((Stereotype)containingClass, source.getName());
- if(tagValue instanceof String) {
+ if (containingClass instanceof Stereotype) {
+ if (target instanceof Element) {
+ Object tagValue = ((Element) target).getValue((Stereotype) containingClass, source.getName());
+ if (tagValue instanceof String) {
Object value = tagValue;
- if(value != null) {
- if(value instanceof String) {
- String originalvalue = (String)value;
+ if (value != null) {
+ if (value instanceof String) {
+ String originalvalue = (String) value;
Pattern pattern = PatternHelper.getInstance().createPattern(fQuery.getSearchQueryText(), fQuery.isCaseSensitive(), fQuery.isRegularExpression());
String newValue = computeReplacementString(pattern, originalvalue, replaceText.getText());
- ((Element)target).setValue((Stereotype)containingClass, source.getName(), newValue);
+ ((Element) target).setValue((Stereotype) containingClass, source.getName(), newValue);
}
}
@@ -200,29 +200,29 @@ public class ReplaceDialog extends Dialog { Set<AbstractResultEntry> toProcess = new HashSet<AbstractResultEntry>();
Set<ScopeEntry> toSave = new HashSet<ScopeEntry>();
- if(fSelection == null) {
+ if (fSelection == null) {
toProcess.addAll(MatchUtils.getMatches(fResultPage.getInput(), false));
} else {
- for(Object selected : Arrays.asList(fSelection)) {
- if(selected instanceof AbstractResultEntry) {
- toProcess.add((AbstractResultEntry)selected);
+ for (Object selected : Arrays.asList(fSelection)) {
+ if (selected instanceof AbstractResultEntry) {
+ toProcess.add((AbstractResultEntry) selected);
}
}
}
- for(AbstractResultEntry match : toProcess) {
+ for (AbstractResultEntry match : toProcess) {
- if(match instanceof AttributeMatch) {
- final AttributeMatch attributeMatch = (AttributeMatch)match;
+ if (match instanceof AttributeMatch) {
+ final AttributeMatch attributeMatch = (AttributeMatch) match;
EditingDomain editingDomain = AdapterFactoryEditingDomain.getEditingDomainFor(attributeMatch.getSource());
Object element = match.getElement();
- if(editingDomain != null) {
- if(editingDomain instanceof TransactionalEditingDomain) {
- editingDomain.getCommandStack().execute(new RecordingCommand((TransactionalEditingDomain)editingDomain) {
+ if (editingDomain != null) {
+ if (editingDomain instanceof TransactionalEditingDomain) {
+ editingDomain.getCommandStack().execute(new RecordingCommand((TransactionalEditingDomain) editingDomain) {
@Override
protected void doExecute() {
@@ -231,18 +231,18 @@ public class ReplaceDialog extends Dialog { });
}
} else {
- if(element instanceof ScopeEntry) {
+ if (element instanceof ScopeEntry) {
change(attributeMatch);
- toSave.add((ScopeEntry)element);
+ toSave.add((ScopeEntry) element);
}
}
}
}
- for(ScopeEntry scopeEntry : toSave) {
+ for (ScopeEntry scopeEntry : toSave) {
try {
scopeEntry.getModelSet().save(new NullProgressMonitor());
} catch (IOException e) {
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/dialogs/TypesFilterDialog.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/dialogs/TypesFilterDialog.java index d1976a25b73..2cb02337810 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/dialogs/TypesFilterDialog.java +++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/dialogs/TypesFilterDialog.java @@ -1,7 +1,7 @@ /*****************************************************************************
* Copyright (c) 2013 CEA LIST.
*
- *
+ *
* 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
@@ -36,9 +36,9 @@ import org.eclipse.ui.dialogs.PatternFilter; import com.swtdesigner.ResourceManager;
/**
- *
+ *
* A dialog that let user select the types of the elements that must be filtered
- *
+ *
*/
public class TypesFilterDialog extends Dialog {
@@ -49,14 +49,14 @@ public class TypesFilterDialog extends Dialog { private CheckboxTreeViewer filterTypesTreeViewer;
/**
- *
+ *
* Constructor.
- *
+ *
* @param parentShell
- * the parent shell, or <code>null</code> to create a top-level
- * shell
+ * the parent shell, or <code>null</code> to create a top-level
+ * shell
* @param page
- * the result page whose results while be filtered
+ * the result page whose results while be filtered
*/
public TypesFilterDialog(Shell parentShell, AbstractTextSearchViewPage page) {
super(parentShell);
@@ -85,7 +85,7 @@ public class TypesFilterDialog extends Dialog { parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 0, 0));
- filterTypesTreeViewer = (CheckboxTreeViewer)filterTypesTree.getViewer();
+ filterTypesTreeViewer = (CheckboxTreeViewer) filterTypesTree.getViewer();
filterTypesTreeViewer.setContentProvider(new FilterTypeContentProvider());
filterTypesTreeViewer.setLabelProvider(new FilterTypeLabelProvider());
@@ -104,9 +104,9 @@ public class TypesFilterDialog extends Dialog { MatchFilter[] filters = new MatchFilter[1];
filters[0] = typeFilter;
AbstractTextSearchResult input = fPage.getInput();
- if(input instanceof PapyrusSearchResult) {
+ if (input instanceof PapyrusSearchResult) {
input.setActiveMatchFilters(filters);
- ((PapyrusSearchResult)input).setPossibleMatchFilter(filters);
+ ((PapyrusSearchResult) input).setPossibleMatchFilter(filters);
}
super.okPressed();
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/filters/TypesMatchFilter.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/filters/TypesMatchFilter.java index 3d6236731a1..f5eddbde6e7 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/filters/TypesMatchFilter.java +++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/filters/TypesMatchFilter.java @@ -1,7 +1,7 @@ /*****************************************************************************
* Copyright (c) 2013 CEA LIST.
*
- *
+ *
* 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
@@ -23,20 +23,20 @@ import org.eclipse.search.ui.text.MatchFilter; import org.eclipse.uml2.uml.Element;
/**
- *
+ *
* A specific kind of filter that can filter UML based results
- *
+ *
*/
public class TypesMatchFilter extends MatchFilter {
private Object[] selectedTypes;
/**
- *
+ *
* Constructor.
- *
+ *
* @param types
- * the collection of types whose instance are NOT filtered
+ * the collection of types whose instance are NOT filtered
*/
public TypesMatchFilter(Object[] types) {
this.selectedTypes = types;
@@ -64,18 +64,18 @@ public class TypesMatchFilter extends MatchFilter { @Override
public boolean filters(Match match) {
- if(match instanceof AbstractResultEntry) {
+ if (match instanceof AbstractResultEntry) {
List<Object> selectedTypesList = Arrays.asList(selectedTypes);
- Object elementToValidate = ((AbstractResultEntry)match).elementToCheckFilterFor();
- - if(elementToValidate instanceof Element) {
+ Object elementToValidate = ((AbstractResultEntry) match).elementToCheckFilterFor();
+
+ if (elementToValidate instanceof Element) {
- if(selectedTypesList.contains(((Element)elementToValidate).eClass())) {
+ if (selectedTypesList.contains(((Element) elementToValidate).eClass())) {
return false;
}
- for(Object object : selectedTypesList) {
- if(((Element)elementToValidate).getAppliedStereotypes().contains(object)) {
+ for (Object object : selectedTypesList) {
+ if (((Element) elementToValidate).getAppliedStereotypes().contains(object)) {
return false;
}
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/handlers/SearchCommandHandler.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/handlers/SearchCommandHandler.java index d95764f3be8..d3a00af2985 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/handlers/SearchCommandHandler.java +++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/handlers/SearchCommandHandler.java @@ -1,7 +1,7 @@ /*****************************************************************************
* Copyright (c) 2013 CEA LIST.
*
- *
+ *
* 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
@@ -19,9 +19,9 @@ import org.eclipse.core.commands.ExecutionException; import org.eclipse.search.internal.ui.OpenSearchDialogAction;
/**
- *
+ *
* Handler for findAndReplace that opens the search dialog
- *
+ *
*/
public class SearchCommandHandler extends AbstractHandler {
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/manager/PapyrusSearchTextManager.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/manager/PapyrusSearchTextManager.java index de6b4f62df3..57fcd5fc467 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/manager/PapyrusSearchTextManager.java +++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/manager/PapyrusSearchTextManager.java @@ -1,7 +1,7 @@ /*****************************************************************************
* Copyright (c) 2013 CEA LIST.
*
- *
+ *
* 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
@@ -29,7 +29,7 @@ import org.eclipse.search.ui.ISearchQuery; import org.eclipse.swt.widgets.Display;
/**
- *Manage the search depending on user choices.
+ * Manage the search depending on user choices.
*
*/
public class PapyrusSearchTextManager {
@@ -50,7 +50,7 @@ public class PapyrusSearchTextManager { }
public ISearchQuery manageSimpleSearch(boolean searchAllStrings, Object[] umlMetaClassesArray) {
- if(fQueryText.isEmpty()) {
+ if (fQueryText.isEmpty()) {
MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.PapyrusSearchPage_29, Messages.PapyrusSearchPage_30);
return null;
} else {
@@ -64,14 +64,14 @@ public class PapyrusSearchTextManager { List<ParticipantTypeElement> participantsToEvaluate = getParticipantsToEvaluate(participantsList);
- if(participantsToEvaluate.size() == 0) {
+ if (participantsToEvaluate.size() == 0) {
MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.PapyrusSearchPage_31, Messages.PapyrusSearchPage_32);
return null;
} else {
- if(fQueryText.isEmpty()) {
- for(Object participantChecked : checkedElements) {
- if(participantChecked instanceof ParticipantTypeAttribute) {
+ if (fQueryText.isEmpty()) {
+ for (Object participantChecked : checkedElements) {
+ if (participantChecked instanceof ParticipantTypeAttribute) {
MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.PapyrusSearchPage_33, Messages.PapyrusSearchPage_34);
return null;
}
@@ -86,11 +86,11 @@ public class PapyrusSearchTextManager { private List<ParticipantTypeElement> getParticipantsToEvaluate(HashMap<ParticipantTypeElement, List<ParticipantTypeAttribute>> participantsList) {
List<ParticipantTypeElement> participantsToEvaluate = new ArrayList<ParticipantTypeElement>();
- for(ParticipantTypeElement element : participantsList.keySet()) {
- if(element.isChecked()) {
+ for (ParticipantTypeElement element : participantsList.keySet()) {
+ if (element.isChecked()) {
participantsToEvaluate.add(element);
- for(ParticipantTypeAttribute attributesToEvaluate : participantsList.get(element)) {
- if(attributesToEvaluate.isChecked()) {
+ for (ParticipantTypeAttribute attributesToEvaluate : participantsList.get(element)) {
+ if (attributesToEvaluate.isChecked()) {
participantsToEvaluate.add(attributesToEvaluate);
}
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/pages/PapyrusSearchPage.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/pages/PapyrusSearchPage.java index 9228396ace7..4d389f70ff9 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/pages/PapyrusSearchPage.java +++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/pages/PapyrusSearchPage.java @@ -1,7 +1,7 @@ /***************************************************************************** * Copyright (c) 2013, 2014 CEA LIST 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 @@ -61,6 +61,7 @@ import org.eclipse.ocl.examples.pivot.utilities.BaseResource; import org.eclipse.ocl.examples.pivot.utilities.PivotUtil; import org.eclipse.ocl.examples.xtext.base.utilities.CS2PivotResourceAdapter; import org.eclipse.ocl.examples.xtext.console.xtfo.EmbeddedXtextEditor; +import org.eclipse.ocl.examples.xtext.essentialocl.ui.internal.EssentialOCLActivator; import org.eclipse.ocl.examples.xtext.essentialocl.ui.model.BaseDocument; import org.eclipse.ocl.examples.xtext.essentialocl.utilities.EssentialOCLCSResource; import org.eclipse.ocl.examples.xtext.essentialocl.utilities.EssentialOCLPlugin; @@ -135,9 +136,9 @@ import org.eclipse.xtext.util.concurrent.IUnitOfWork; import com.google.inject.Injector; /** - * + * * Papyrus specific search page - * + * */ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IReplacePage, MetaModelManagerListener { @@ -201,8 +202,8 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla private Composite textQueryFieldsComposite; - private Button fBtnSearchForAllSelected;
-
+ private Button fBtnSearchForAllSelected; + @@ -257,7 +258,7 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla - Group grpSearchFor = new Group(textQueryComposite, SWT.NONE);
+ Group grpSearchFor = new Group(textQueryComposite, SWT.NONE); grpSearchFor.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); grpSearchFor.setLayout(new GridLayout(1, false)); grpSearchFor.setText(Messages.PapyrusSearchPage_8); @@ -277,15 +278,16 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla searchKind.select(SIMPLE_SEARCH); searchKind.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { - for(Control childControl : advancedSearchComposite.getChildren()) { + for (Control childControl : advancedSearchComposite.getChildren()) { childControl.dispose(); } - if(searchKind.getSelectionIndex() == ADVANCED_SEARCH) { - participantsList.clear();
- createResultList(); -
+ if (searchKind.getSelectionIndex() == ADVANCED_SEARCH) { + participantsList.clear(); + createResultList(); + createAdvancedSearch(); } else { simpleSearch(); @@ -295,7 +297,7 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla }); advancedSearchComposite = new Composite(groupComposite, SWT.NONE); - // gd_advancedSearchComposite.widthHint = 479; + // gd_advancedSearchComposite.widthHint = 479; advancedSearchComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); advancedSearchComposite.setLayout(new GridLayout(2, false)); @@ -311,14 +313,14 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla public void run(IProgressMonitor thePM) throws InterruptedException { - //UML metaclasses - for(EClassifier eClassifier : UMLPackage.eINSTANCE.getEClassifiers()) { - if(eClassifier instanceof EClass) { + // UML metaclasses + for (EClassifier eClassifier : UMLPackage.eINSTANCE.getEClassifiers()) { + if (eClassifier instanceof EClass) { ParticipantTypeElement parentElement = new ParticipantTypeElement(eClassifier); - if(parentElement.getElement() instanceof EClass) { + if (parentElement.getElement() instanceof EClass) { List<ParticipantTypeAttribute> attributeList = new ArrayList<ParticipantTypeAttribute>(); - for(EObject eAttribute : ((EClass)(parentElement).getElement()).getEAllAttributes()) { - ParticipantTypeAttribute attribute = new ParticipantTypeAttribute(eAttribute, ((ParticipantTypeElement)parentElement)); + for (EObject eAttribute : ((EClass) (parentElement).getElement()).getEAllAttributes()) { + ParticipantTypeAttribute attribute = new ParticipantTypeAttribute(eAttribute, (parentElement)); attributeList.add(attribute); @@ -329,16 +331,17 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla } - //Find available stereotypes + // Find available stereotypes availableStereotypes = StereotypeCollector.getInstance().computeAvailableStereotypes(container); - for(Stereotype stereotype : availableStereotypes) { + for (Stereotype stereotype : availableStereotypes) { ParticipantTypeElement parentElement = new ParticipantTypeElement(stereotype); List<ParticipantTypeAttribute> attributeList = new ArrayList<ParticipantTypeAttribute>(); - for(Property property : ((Stereotype)((ParticipantTypeElement)parentElement).getElement()).getAllAttributes()) { - if(!property.getName().startsWith("base_")) { //$NON-NLS-1$ - if(property.getType() instanceof Element) { - if(UMLUtil.isBoolean(property.getType()) || UMLUtil.isString(property.getType()) || UMLUtil.isInteger(property.getType()) || UMLUtil.isReal(property.getType()) || UMLUtil.isUnlimitedNatural(property.getType()) || property.getType() instanceof Enumeration) { - ParticipantTypeAttribute attribute = new ParticipantTypeAttribute(property, (ParticipantTypeElement)parentElement); + for (Property property : ((Stereotype) parentElement.getElement()).getAllAttributes()) { + if (!property.getName().startsWith("base_")) { //$NON-NLS-1$ + if (property.getType() instanceof Element) { + if (UMLUtil.isBoolean(property.getType()) || UMLUtil.isString(property.getType()) || UMLUtil.isInteger(property.getType()) || UMLUtil.isReal(property.getType()) || UMLUtil.isUnlimitedNatural(property.getType()) + || property.getType() instanceof Enumeration) { + ParticipantTypeAttribute attribute = new ParticipantTypeAttribute(property, parentElement); attributeList.add(attribute); } @@ -377,8 +380,8 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla chechboxTreeViewerGridData.heightHint = 150; participantTypesTree.setLayoutData(chechboxTreeViewerGridData); - participantTypesTreeViewer = (CheckboxTreeViewer)participantTypesTree.getViewer(); - participantTypesTreeViewer.setContentProvider(new ParticipantTypeContentProvider());
+ participantTypesTreeViewer = (CheckboxTreeViewer) participantTypesTree.getViewer(); + participantTypesTreeViewer.setContentProvider(new ParticipantTypeContentProvider()); participantTypesTreeViewer.setLabelProvider(new ParticipantTypeLabelProvider()); participantTypesTreeViewer.setSorter(new ViewerSorter()); participantTypesTreeViewer.setCheckStateProvider(new ICheckStateProvider() { @@ -388,9 +391,9 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla } public boolean isChecked(Object element) { - if(element instanceof ParticipantTypeElement) { + if (element instanceof ParticipantTypeElement) { - return ((ParticipantTypeElement)element).isChecked(); + return ((ParticipantTypeElement) element).isChecked(); } return false; @@ -408,27 +411,27 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla @Override public void mouseUp(MouseEvent e) { ISelection selection = participantTypesTreeViewer.getSelection(); - if(selection instanceof IStructuredSelection) { - Object selectedElement = ((IStructuredSelection)selection).getFirstElement(); + if (selection instanceof IStructuredSelection) { + Object selectedElement = ((IStructuredSelection) selection).getFirstElement(); - if(selectedElement instanceof ParticipantTypeElement) { + if (selectedElement instanceof ParticipantTypeElement) { List<ParticipantTypeAttribute> attributeParentList = new ArrayList<ParticipantTypeAttribute>(); - for(Object attribute : participantsList.get(selectedElement)) { - if(attribute instanceof ParticipantTypeAttribute) { - if(((ParticipantTypeAttribute)attribute).isChecked()) { - attributeParentList.add(((ParticipantTypeAttribute)attribute)); + for (Object attribute : participantsList.get(selectedElement)) { + if (attribute instanceof ParticipantTypeAttribute) { + if (((ParticipantTypeAttribute) attribute).isChecked()) { + attributeParentList.add(((ParticipantTypeAttribute) attribute)); } } } - if(((ParticipantTypeElement)selectedElement).getElement() instanceof EClass) { + if (((ParticipantTypeElement) selectedElement).getElement() instanceof EClass) { - selectAllSubUML((ParticipantTypeElement)selectedElement, attributeParentList); + selectAllSubUML((ParticipantTypeElement) selectedElement, attributeParentList); - } else if(((ParticipantTypeElement)selectedElement).getElement() instanceof Stereotype) { + } else if (((ParticipantTypeElement) selectedElement).getElement() instanceof Stereotype) { - selectAllSubSter((ParticipantTypeElement)selectedElement, attributeParentList); + selectAllSubSter((ParticipantTypeElement) selectedElement, attributeParentList); } } @@ -446,11 +449,11 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla @Override public void mouseUp(MouseEvent e) { - for(ParticipantTypeElement element : participantsList.keySet()) { - if(!element.isChecked()) { + for (ParticipantTypeElement element : participantsList.keySet()) { + if (!element.isChecked()) { element.setChecked(true); - for(ParticipantTypeAttribute attribute : participantsList.get(element)) { + for (ParticipantTypeAttribute attribute : participantsList.get(element)) { attribute.setChecked(true); } @@ -468,11 +471,11 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla @Override public void mouseUp(MouseEvent e) { - for(ParticipantTypeElement element : participantsList.keySet()) { - if(element.isChecked()) { + for (ParticipantTypeElement element : participantsList.keySet()) { + if (element.isChecked()) { element.setChecked(false); - for(ParticipantTypeAttribute attribute : participantsList.get(element)) { + for (ParticipantTypeAttribute attribute : participantsList.get(element)) { attribute.setChecked(false); @@ -491,8 +494,8 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla @Override public void mouseUp(MouseEvent e) { - participantsList.clear();
- createResultList();
+ participantsList.clear(); + createResultList(); createAdvancedSearch(); @@ -501,40 +504,40 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla participantTypesTreeViewer.setInput(participantsList); - // participantTypesTreeViewer.setAllChecked(true); - ((ICheckable)participantTypesTreeViewer).addCheckStateListener(new ICheckStateListener() { + // participantTypesTreeViewer.setAllChecked(true); + ((ICheckable) participantTypesTreeViewer).addCheckStateListener(new ICheckStateListener() { public void checkStateChanged(CheckStateChangedEvent event) { - if(event.getElement() instanceof ParticipantTypeElement) { + if (event.getElement() instanceof ParticipantTypeElement) { // If the item is checked . . . - if(event.getChecked()) { + if (event.getChecked()) { Object selectedElement = event.getElement(); - ((ParticipantTypeElement)selectedElement).setChecked(true); + ((ParticipantTypeElement) selectedElement).setChecked(true); participantTypesTreeViewer.refresh(selectedElement); - if(selectedElement instanceof ParticipantTypeAttribute) { - ParticipantTypeElement parent = ((ParticipantTypeAttribute)selectedElement).getParent(); - if(parent != null) { - // participantTypesTreeViewer.setChecked(parent, true); - ((ParticipantTypeElement)parent).setChecked(true); + if (selectedElement instanceof ParticipantTypeAttribute) { + ParticipantTypeElement parent = ((ParticipantTypeAttribute) selectedElement).getParent(); + if (parent != null) { + // participantTypesTreeViewer.setChecked(parent, true); + parent.setChecked(true); participantTypesTreeViewer.refresh(parent); } } } else { Object selectedElement = event.getElement(); - ((ParticipantTypeElement)selectedElement).setChecked(false); + ((ParticipantTypeElement) selectedElement).setChecked(false); participantTypesTreeViewer.refresh(selectedElement); - if(((ParticipantTypeElement)selectedElement).getElement() instanceof Stereotype || ((ParticipantTypeElement)selectedElement).getElement() instanceof EClassImpl) { - for(Object attribute : participantTypesTreeViewer.getCheckedElements()) { - if(attribute instanceof ParticipantTypeAttribute) { - if(((ParticipantTypeAttribute)attribute).getParent().equals(selectedElement)) { - // participantTypesTreeViewer.setChecked(attribute, false); - ((ParticipantTypeElement)attribute).setChecked(false); + if (((ParticipantTypeElement) selectedElement).getElement() instanceof Stereotype || ((ParticipantTypeElement) selectedElement).getElement() instanceof EClassImpl) { + for (Object attribute : participantTypesTreeViewer.getCheckedElements()) { + if (attribute instanceof ParticipantTypeAttribute) { + if (((ParticipantTypeAttribute) attribute).getParent().equals(selectedElement)) { + // participantTypesTreeViewer.setChecked(attribute, false); + ((ParticipantTypeElement) attribute).setChecked(false); participantTypesTreeViewer.refresh(attribute); } } @@ -546,79 +549,79 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla } }); -
- fBtnSearchForAllSelected = new Button(advancedSearchComposite, SWT.CHECK);
- fBtnSearchForAllSelected.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
- fBtnSearchForAllSelected.setText(Messages.PapyrusSearchPage_13);
+ + fBtnSearchForAllSelected = new Button(advancedSearchComposite, SWT.CHECK); + fBtnSearchForAllSelected.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); + fBtnSearchForAllSelected.setText(Messages.PapyrusSearchPage_13); } protected void selectAllSubSter(final ParticipantTypeElement elementParent, final List<ParticipantTypeAttribute> attributeParentList) { -
+ ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()); IRunnableWithProgress computeAvailableTypes = new IRunnableWithProgress() { public void run(IProgressMonitor thePM) throws InterruptedException { - for(Object element : participantsList.keySet()) { - if(element instanceof ParticipantTypeElement) { - checkAllSubSter((ParticipantTypeElement)element, elementParent, attributeParentList);
-
- }
- }
-
-
- }
-
- };
-
-
- try {
- dialog.run(true, true, computeAvailableTypes);
- } catch (InvocationTargetException e) {
- e.printStackTrace();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
-
-
- }
-
- protected void checkAllSubSter(ParticipantTypeElement element, ParticipantTypeElement elementParent, List<ParticipantTypeAttribute> attributeParentList) {
- if(((ParticipantTypeElement)element).getElement() instanceof Stereotype) { - List<Class> superTypes = ((Class)((ParticipantTypeElement)element).getElement()).getSuperClasses(); - - if(superTypes.contains(elementParent.getElement())) { - ((ParticipantTypeElement)element).setChecked(true); - - - //Proceed with attributes - for(ParticipantTypeAttribute attributeParent : attributeParentList) { - for(ParticipantTypeAttribute attributeToEvaluate : participantsList.get(element)) { - if(attributeParent.getElement() == attributeToEvaluate.getElement()) { - - attributeToEvaluate.setChecked(true); + for (Object element : participantsList.keySet()) { + if (element instanceof ParticipantTypeElement) { + checkAllSubSter((ParticipantTypeElement) element, elementParent, attributeParentList); + } + } + + + } + + }; + + + try { + dialog.run(true, true, computeAvailableTypes); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + + } + + protected void checkAllSubSter(ParticipantTypeElement element, ParticipantTypeElement elementParent, List<ParticipantTypeAttribute> attributeParentList) { + if (element.getElement() instanceof Stereotype) { + List<Class> superTypes = ((Class) element.getElement()).getSuperClasses(); + + if (superTypes.contains(elementParent.getElement())) { + element.setChecked(true); + + + // Proceed with attributes + for (ParticipantTypeAttribute attributeParent : attributeParentList) { + for (ParticipantTypeAttribute attributeToEvaluate : participantsList.get(element)) { + if (attributeParent.getElement() == attributeToEvaluate.getElement()) { + + attributeToEvaluate.setChecked(true); - } - } - } - } } + } + } + } + } + } + + protected void selectAllSubUML(final ParticipantTypeElement elementParent, final List<ParticipantTypeAttribute> attributeParentList) { + + ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()); + IRunnableWithProgress computeAvailableTypes = new IRunnableWithProgress() { - protected void selectAllSubUML(final ParticipantTypeElement elementParent, final List<ParticipantTypeAttribute> attributeParentList) {
-
- ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
- IRunnableWithProgress computeAvailableTypes = new IRunnableWithProgress() {
-
- public void run(IProgressMonitor thePM) throws InterruptedException {
- for(Object element : participantsList.keySet()) {
- if(element instanceof ParticipantTypeElement) {
- checkAllSubUML((ParticipantTypeElement)element, elementParent, attributeParentList);
+ public void run(IProgressMonitor thePM) throws InterruptedException { + for (Object element : participantsList.keySet()) { + if (element instanceof ParticipantTypeElement) { + checkAllSubUML((ParticipantTypeElement) element, elementParent, attributeParentList); + } + } } - }
- }
}; @@ -635,30 +638,30 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla } - protected void checkAllSubUML(ParticipantTypeElement element, ParticipantTypeElement elementParent, List<ParticipantTypeAttribute> attributeParentList) {
- if(((ParticipantTypeElement)element).getElement() instanceof EClass) { - List<EClass> superTypes = ((EClass)((ParticipantTypeElement)element).getElement()).getEAllSuperTypes(); - - if(superTypes.contains(elementParent.getElement())) { - // participantTypesTreeViewer.setChecked(element, true); - ((ParticipantTypeElement)element).setChecked(true); + protected void checkAllSubUML(ParticipantTypeElement element, ParticipantTypeElement elementParent, List<ParticipantTypeAttribute> attributeParentList) { + if (element.getElement() instanceof EClass) { + List<EClass> superTypes = ((EClass) element.getElement()).getEAllSuperTypes(); + if (superTypes.contains(elementParent.getElement())) { + // participantTypesTreeViewer.setChecked(element, true); + element.setChecked(true); - //Proceed with attributes - for(ParticipantTypeAttribute attributeParent : attributeParentList) { - for(ParticipantTypeAttribute attributeToEvaluate : participantsList.get(element)) { - if(attributeParent.getElement() == attributeToEvaluate.getElement()) { - attributeToEvaluate.setChecked(true); + // Proceed with attributes + for (ParticipantTypeAttribute attributeParent : attributeParentList) { + for (ParticipantTypeAttribute attributeToEvaluate : participantsList.get(element)) { + if (attributeParent.getElement() == attributeToEvaluate.getElement()) { + attributeToEvaluate.setChecked(true); - } - } - } - } } + } + } + } + } + } @@ -682,19 +685,19 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla } - public Object[] getMetaClassesList() {
- Set<EObject> umlMetaClasses= new HashSet<EObject>();
+ public Object[] getMetaClassesList() { + Set<EObject> umlMetaClasses = new HashSet<EObject>(); + + for (EClassifier eClassifier : UMLPackage.eINSTANCE.getEClassifiers()) { + if (eClassifier instanceof EClass) { + umlMetaClasses.add(eClassifier); + } + } + return umlMetaClasses.toArray(); + + } + - for(EClassifier eClassifier : UMLPackage.eINSTANCE.getEClassifiers()) {
- if(eClassifier instanceof EClass) {
- umlMetaClasses.add(eClassifier);
- }
- }
- return umlMetaClasses.toArray();
-
- }
-
-
protected void createOCLSearchQueryField(EObject root) { Composite client = queryComposite; @@ -720,10 +723,10 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla ScopeEntry currentScope = getCurrentScopeEntry(); - if(currentScope != null) { + if (currentScope != null) { try { - ((UmlModel)currentScope.getModelSet().getModel(UmlModel.MODEL_ID)).lookupRoot();
+ ((UmlModel) currentScope.getModelSet().getModel(UmlModel.MODEL_ID)).lookupRoot(); ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(Display.getCurrent().getActiveShell(), labelProvider, new OCLContextContentProvider()); dialog.setTitle(Messages.PapyrusSearchPage_19); @@ -733,12 +736,12 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla dialog.open(); Object selection = dialog.getFirstResult(); - if(selection instanceof EObject) { + if (selection instanceof EObject) { refreshSelection(selection); - if(contextObject instanceof NamedElement) { - oclContext.setText(((NamedElement)contextObject).getQualifiedName()); + if (contextObject instanceof NamedElement) { + oclContext.setText(((NamedElement) contextObject).getQualifiedName()); } else { oclContext.setText(labelProvider.getText(contextObject)); } @@ -754,16 +757,16 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla }); btnSelectContext.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1)); - Injector injector = Activator.getInstance().getInjector(EssentialOCLPlugin.LANGUAGE_ID); + Injector injector = EssentialOCLActivator.getInstance().getInjector(EssentialOCLPlugin.LANGUAGE_ID); Composite editorComposite = client; oclEditor = new EmbeddedXtextEditor(editorComposite, injector, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL); oclEditor.getViewer().getTextWidget().addVerifyKeyListener(new VerifyKeyListener() { public void verifyKey(VerifyEvent e) { - // System.out.println("verifyKey: " + e.keyCode);
- if(e.keyCode == SWT.KEYPAD_CR || e.keyCode == SWT.CR) { - if((e.stateMask & (SWT.CTRL | SWT.SHIFT)) == 0) { + // System.out.println("verifyKey: " + e.keyCode); + if (e.keyCode == SWT.KEYPAD_CR || e.keyCode == SWT.CR) { + if ((e.stateMask & (SWT.CTRL | SWT.SHIFT)) == 0) { e.doit = false; } } @@ -778,15 +781,15 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla } protected ScopeEntry getCurrentScopeEntry() { - if(container.getSelectedScope() == ISearchPageContainer.SELECTION_SCOPE) { + if (container.getSelectedScope() == ISearchPageContainer.SELECTION_SCOPE) { Collection<URI> scope = ScopeCollector.getInstance().computeSearchScope(container); // this is only used for OCL queries, which currently assume workspace-like availability of the model content Collection<ScopeEntry> scopeEntries = WorkspaceQueryProvider.createScopeEntries(scope); - if(scopeEntries.size() == 1) { + if (scopeEntries.size() == 1) { Object[] entries = scopeEntries.toArray(); - ScopeEntry selectedResource = (ScopeEntry)entries[0]; + ScopeEntry selectedResource = (ScopeEntry) entries[0]; return selectedResource; } @@ -817,30 +820,31 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla queryKind.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { - for(Control childControl : queryComposite.getChildren()) { + for (Control childControl : queryComposite.getChildren()) { childControl.dispose(); } - if(queryKind.getSelectionIndex() == TEXT_QUERY_KIND) { + if (queryKind.getSelectionIndex() == TEXT_QUERY_KIND) { createSimpleSearchQueryField(); } else { - if(container.getSelectedScope() == ISearchPageContainer.SELECTION_SCOPE) { + if (container.getSelectedScope() == ISearchPageContainer.SELECTION_SCOPE) { ScopeEntry currentScope = getCurrentScopeEntry(); - if(currentScope != null) { - if(currentScope.getModelSet() != null) { + if (currentScope != null) { + if (currentScope.getModelSet() != null) { try { - EObject root = ((UmlModel)currentScope.getModelSet().getModel(UmlModel.MODEL_ID)).lookupRoot(); + EObject root = ((UmlModel) currentScope.getModelSet().getModel(UmlModel.MODEL_ID)).lookupRoot(); createOCLSearchQueryField(root); - if(contextObject instanceof NamedElement) { - oclContext.setText(((NamedElement)contextObject).getQualifiedName()); + if (contextObject instanceof NamedElement) { + oclContext.setText(((NamedElement) contextObject).getQualifiedName()); } else { LabelProviderService labelProviderService = new LabelProviderServiceImpl(); ILabelProvider labelProvider = labelProviderService.getLabelProvider(); @@ -881,7 +885,7 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla } public boolean getSearchAllStringAttributes() { - if(btnSearchAllStringAttributes != null) { + if (btnSearchAllStringAttributes != null) { return btnSearchAllStringAttributes.getSelection(); } else { return false; @@ -890,7 +894,7 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla /** * Validate syntax of the regular expression of the search query text. - * + * * @return true, if successful */ private boolean validateRegex() { @@ -910,42 +914,42 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla } protected void refreshSelection(final Object selected) { - final BaseDocument editorDocument = (BaseDocument)oclEditor.getDocument(); + final BaseDocument editorDocument = (BaseDocument) oclEditor.getDocument(); editorDocument.modify(new IUnitOfWork<Object, XtextResource>() { public Value exec(XtextResource resource) throws Exception { Object selectedObject = selected; - if(selectedObject instanceof IOutlineNode) { - if(selectedObject instanceof EObjectNode) { - EObjectNode selectedObjectNode = (EObjectNode)selectedObject; - selectedObjectNode.getEObjectURI();
+ if (selectedObject instanceof IOutlineNode) { + if (selectedObject instanceof EObjectNode) { + EObjectNode selectedObjectNode = (EObjectNode) selectedObject; + selectedObjectNode.getEObjectURI(); contextObject = null; // FIXME // metaModelManager.loadResource(eObjectURI, // null, null); - } else if(selectedObject instanceof EStructuralFeatureNode) { + } else if (selectedObject instanceof EStructuralFeatureNode) { contextObject = null; } else { contextObject = null; } } else { - if(selectedObject instanceof IAdaptable) { - selectedObject = ((IAdaptable)selectedObject).getAdapter(EObject.class); + if (selectedObject instanceof IAdaptable) { + selectedObject = ((IAdaptable) selectedObject).getAdapter(EObject.class); } - if(selectedObject instanceof EObject) { - contextObject = (EObject)selectedObject; + if (selectedObject instanceof EObject) { + contextObject = (EObject) selectedObject; } else { contextObject = null; } } MetaModelManager metaModelManager = getMetaModelManager(contextObject); parserContext = new EObjectContext(metaModelManager, null, contextObject); - EssentialOCLCSResource csResource = (EssentialOCLCSResource)resource; - if(csResource != null) { - if(contextObject != null) { + EssentialOCLCSResource csResource = (EssentialOCLCSResource) resource; + if (csResource != null) { + if (contextObject != null) { CS2PivotResourceAdapter.getAdapter(csResource, metaModelManager); } ResourceSet resourceSet = oclEditor.getResourceSet(); - if(resourceSet != null) { + if (resourceSet != null) { MetaModelManagerResourceSetAdapter.getAdapter(resourceSet, metaModelManager); } csResource.setParserContext(parserContext); @@ -960,7 +964,7 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla private Collection<ScopeEntry> createScopeEntries(Collection<URI> scope) { Collection<ScopeEntry> results = new HashSet<ScopeEntry>(); - for(URI resource : scope) { + for (URI resource : scope) { ScopeEntry scopeEntry = new ScopeEntry(resource); @@ -970,15 +974,15 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla return results; } - + private List<ParticipantTypeElement> getParticipantsToEvaluate(HashMap<ParticipantTypeElement, List<ParticipantTypeAttribute>> participantsList) { List<ParticipantTypeElement> participantsToEvaluate = new ArrayList<ParticipantTypeElement>(); - for(ParticipantTypeElement element : participantsList.keySet()) { - if(element.isChecked()) { + for (ParticipantTypeElement element : participantsList.keySet()) { + if (element.isChecked()) { participantsToEvaluate.add(element); - for(ParticipantTypeAttribute attributesToEvaluate : participantsList.get(element)) { - if(attributesToEvaluate.isChecked()) { + for (ParticipantTypeAttribute attributesToEvaluate : participantsList.get(element)) { + if (attributesToEvaluate.isChecked()) { participantsToEvaluate.add(attributesToEvaluate); } } @@ -986,15 +990,15 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla } return participantsToEvaluate; } - + public boolean performAction() { - if(queryKind.getSelectionIndex() == TEXT_QUERY_KIND) { - if(validateRegex()) { + if (queryKind.getSelectionIndex() == TEXT_QUERY_KIND) { + if (validateRegex()) { Collection<URI> scope = ScopeCollector.getInstance().computeSearchScope(container); ISearchQuery query; - if(searchKind.getSelectionIndex() == SIMPLE_SEARCH) { - if(searchQueryText.getText().length() == 0) { + if (searchKind.getSelectionIndex() == SIMPLE_SEARCH) { + if (searchQueryText.getText().length() == 0) { MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.PapyrusSearchPage_29, Messages.PapyrusSearchPage_30); return false; } else { @@ -1005,24 +1009,24 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla List<ParticipantTypeElement> participantsToEvaluate = new ArrayList<ParticipantTypeElement>(); - for(ParticipantTypeElement element : this.participantsList.keySet()) { - if(element.isChecked()) { + for (ParticipantTypeElement element : this.participantsList.keySet()) { + if (element.isChecked()) { participantsToEvaluate.add(element); - for(ParticipantTypeAttribute attributesToEvaluate : participantsList.get(element)) { - if(attributesToEvaluate.isChecked()) { + for (ParticipantTypeAttribute attributesToEvaluate : participantsList.get(element)) { + if (attributesToEvaluate.isChecked()) { participantsToEvaluate.add(attributesToEvaluate); } } } } - if(participantsToEvaluate.size() == 0) { + if (participantsToEvaluate.size() == 0) { MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.PapyrusSearchPage_31, Messages.PapyrusSearchPage_32); return false; } else { - if(searchQueryText.getText().length() == 0) { - for(Object participantChecked : participantTypesTreeViewer.getCheckedElements()) { - if(participantChecked instanceof ParticipantTypeAttribute) { + if (searchQueryText.getText().length() == 0) { + for (Object participantChecked : participantTypesTreeViewer.getCheckedElements()) { + if (participantChecked instanceof ParticipantTypeAttribute) { MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.PapyrusSearchPage_33, Messages.PapyrusSearchPage_34); return false; } @@ -1035,7 +1039,7 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla } } - if(query.canRunInBackground()) { + if (query.canRunInBackground()) { NewSearchUI.runQueryInBackground(query); } @@ -1048,16 +1052,16 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla ScopeEntry scopeEntry = getCurrentScopeEntry(); - if(scopeEntry != null) { + if (scopeEntry != null) { try { PivotUtil.checkResourceErrors("", oclEditor.getResource()); //$NON-NLS-1$ - ExpressionInOCL expressionInOCL = parserContext.getExpression((BaseResource)oclEditor.getResource()); - ISearchQuery query = new PapyrusOCLQuery((BaseDocument)oclEditor.getDocument(), parserContext, getMetaModelManager(contextObject), modelManager, contextObject, scopeEntry); + ExpressionInOCL expressionInOCL = parserContext.getExpression((BaseResource) oclEditor.getResource()); + ISearchQuery query = new PapyrusOCLQuery((BaseDocument) oclEditor.getDocument(), parserContext, getMetaModelManager(contextObject), modelManager, contextObject, scopeEntry); - if(query.canRunInBackground()) { + if (query.canRunInBackground()) { NewSearchUI.runQueryInBackground(query); } } catch (ParserException e) { @@ -1079,89 +1083,89 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla } public boolean performReplace() { - if(queryKind.getSelectionIndex() == TEXT_QUERY_KIND) { - if(container.getSelectedScope() == ISearchPageContainer.SELECTION_SCOPE) {
- if(validateRegex()) { - if(searchQueryText.getText().length() == 0) { - MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.PapyrusSearchPage_36, Messages.PapyrusSearchPage_37); - return false; - } + if (queryKind.getSelectionIndex() == TEXT_QUERY_KIND) { + if (container.getSelectedScope() == ISearchPageContainer.SELECTION_SCOPE) { + if (validateRegex()) { + if (searchQueryText.getText().length() == 0) { + MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.PapyrusSearchPage_36, Messages.PapyrusSearchPage_37); + return false; + } - Collection<URI> scope = ScopeCollector.getInstance().computeSearchScope(container); + Collection<URI> scope = ScopeCollector.getInstance().computeSearchScope(container); - AbstractPapyrusQuery query; - if(searchKind.getSelectionIndex() == SIMPLE_SEARCH) { - QueryInfo info = new QueryInfo(searchQueryText.getText(), btnCaseSensitive.getSelection(), btnRegularExpression.getSelection(), btnSearchAllStringAttributes.getSelection(), scope); - query = CompositePapyrusQueryProvider.getInstance().createSimpleSearchQuery(info); - } else { - List<ParticipantTypeElement> participantsToEvaluate = new ArrayList<ParticipantTypeElement>(); - for(ParticipantTypeElement element : this.participantsList.keySet()) { - if(element.isChecked()) { - participantsToEvaluate.add(element); - if(participantsList.get(element).size() == 0) { - MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.PapyrusSearchPage_38, Messages.PapyrusSearchPage_39); - return false; + AbstractPapyrusQuery query; + if (searchKind.getSelectionIndex() == SIMPLE_SEARCH) { + QueryInfo info = new QueryInfo(searchQueryText.getText(), btnCaseSensitive.getSelection(), btnRegularExpression.getSelection(), btnSearchAllStringAttributes.getSelection(), scope); + query = CompositePapyrusQueryProvider.getInstance().createSimpleSearchQuery(info); + } else { + List<ParticipantTypeElement> participantsToEvaluate = new ArrayList<ParticipantTypeElement>(); + for (ParticipantTypeElement element : this.participantsList.keySet()) { + if (element.isChecked()) { + participantsToEvaluate.add(element); + if (participantsList.get(element).size() == 0) { + MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.PapyrusSearchPage_38, Messages.PapyrusSearchPage_39); + return false; - } else { - for(ParticipantTypeAttribute attributesToEvaluate : participantsList.get(element)) { - if(attributesToEvaluate.isChecked()) { - participantsToEvaluate.add(attributesToEvaluate); - boolean canDoReplace = false;
- if(attributesToEvaluate.getElement() instanceof EAttribute) {
- Object value = element.getElement().eGet((EAttribute)attributesToEvaluate.getElement()); - if(value instanceof String) {
- canDoReplace = true;
- }
- } else if(attributesToEvaluate.getElement() instanceof Property) {
- Property property = (Property)attributesToEvaluate.getElement();
- if(UMLUtil.isString(property.getType())) {
- canDoReplace = true;
- }
- }
- if(!canDoReplace) {
- MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.PapyrusSearchPage_40, Messages.PapyrusSearchPage_41); - return false; + } else { + for (ParticipantTypeAttribute attributesToEvaluate : participantsList.get(element)) { + if (attributesToEvaluate.isChecked()) { + participantsToEvaluate.add(attributesToEvaluate); + boolean canDoReplace = false; + if (attributesToEvaluate.getElement() instanceof EAttribute) { + Object value = element.getElement().eGet((EAttribute) attributesToEvaluate.getElement()); + if (value instanceof String) { + canDoReplace = true; + } + } else if (attributesToEvaluate.getElement() instanceof Property) { + Property property = (Property) attributesToEvaluate.getElement(); + if (UMLUtil.isString(property.getType())) { + canDoReplace = true; + } + } + if (!canDoReplace) { + MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.PapyrusSearchPage_40, Messages.PapyrusSearchPage_41); + return false; + } } } } } } - } - QueryInfo info = new QueryInfo(searchQueryText.getText(), btnCaseSensitive.getSelection(), btnRegularExpression.getSelection(), participantsToEvaluate, scope, fBtnSearchForAllSelected.getSelection()); - query = CompositePapyrusQueryProvider.getInstance().createAdvancedSearchQuery(info); + QueryInfo info = new QueryInfo(searchQueryText.getText(), btnCaseSensitive.getSelection(), btnRegularExpression.getSelection(), participantsToEvaluate, scope, fBtnSearchForAllSelected.getSelection()); + query = CompositePapyrusQueryProvider.getInstance().createAdvancedSearchQuery(info); - } + } - NewSearchUI.runQueryInForeground(container.getRunnableContext(), query); + NewSearchUI.runQueryInForeground(container.getRunnableContext(), query); - Display.getCurrent().syncExec(new Runnable() { + Display.getCurrent().syncExec(new Runnable() { - public void run() { - ISearchResultViewPart view = NewSearchUI.activateSearchResultView(); - if(view != null) { - ISearchResultPage page = view.getActivePage(); + public void run() { + ISearchResultViewPart view = NewSearchUI.activateSearchResultView(); + if (view != null) { + ISearchResultPage page = view.getActivePage(); - if(page instanceof PapyrusSearchResultPage) { - PapyrusSearchResultPage resultPage = (PapyrusSearchResultPage)page; - ReplaceAction replaceAction = new ReplaceAction(resultPage.getSite().getShell(), resultPage, null); - replaceAction.run(); + if (page instanceof PapyrusSearchResultPage) { + PapyrusSearchResultPage resultPage = (PapyrusSearchResultPage) page; + ReplaceAction replaceAction = new ReplaceAction(resultPage.getSite().getShell(), resultPage, null); + replaceAction.run(); + } } } - } - }); + }); - NewSearchUI.removeQuery(query);
- return true; + NewSearchUI.removeQuery(query); + return true; + } else { + MessageDialog.openError(Display.getCurrent().getActiveShell(), SEARCH_ISSUE, REGULAR_EXPRESSION_ILLFORMED); + return false; + } } else { - MessageDialog.openError(Display.getCurrent().getActiveShell(), SEARCH_ISSUE, REGULAR_EXPRESSION_ILLFORMED); + MessageDialog.openWarning(Display.getCurrent().getActiveShell(), Messages.PapyrusSearchPage_27, Messages.PapyrusSearchPage_28); return false; } } else { - MessageDialog.openWarning(Display.getCurrent().getActiveShell(), Messages.PapyrusSearchPage_27, Messages.PapyrusSearchPage_28);
- return false;
- }
- } else {
MessageDialog.openWarning(Display.getCurrent().getActiveShell(), Messages.PapyrusSearchPage_42, Messages.PapyrusSearchPage_43); return false; } @@ -1173,11 +1177,11 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla public MetaModelManager getMetaModelManager(EObject contextObject) { MetaModelManager metaModelManager = contextObject != null ? PivotUtil.findMetaModelManager(contextObject) : null; - if(metaModelManager != null) { + if (metaModelManager != null) { return metaModelManager; } MetaModelManager nullMetaModelManager2 = nullMetaModelManager; - if(nullMetaModelManager2 == null) { + if (nullMetaModelManager2 == null) { nullMetaModelManager2 = nullMetaModelManager = new MetaModelManager(); nullMetaModelManager2.addListener(this); } @@ -1192,38 +1196,40 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla protected void flushEvents() { IWorkbench workbench = PlatformUI.getWorkbench(); - while(workbench.getDisplay().readAndDispatch()); + while (workbench.getDisplay().readAndDispatch()) { + ; + } } public void reset() { - if(oclEditor != null) { + if (oclEditor != null) { IXtextDocument document = oclEditor.getDocument(); MetaModelManager metaModelManager = document.modify(new IUnitOfWork<MetaModelManager, XtextResource>() { // Cancel - // validation + // validation - public MetaModelManager exec(XtextResource state) throws Exception { - if(state == null) { - return null; - } - if(state instanceof BaseResource) { - ((BaseResource)state).setParserContext(null); - } - return PivotUtil.findMetaModelManager(state); - } - }); + public MetaModelManager exec(XtextResource state) throws Exception { + if (state == null) { + return null; + } + if (state instanceof BaseResource) { + ((BaseResource) state).setParserContext(null); + } + return PivotUtil.findMetaModelManager(state); + } + }); flushEvents(); // editor.close(false); flushEvents(); - if(metaModelManager != null) { + if (metaModelManager != null) { metaModelManager.dispose(); } } - if(modelManager != null) { + if (modelManager != null) { // modelManager.dispose(); modelManager = null; } - if(nullMetaModelManager != null) { + if (nullMetaModelManager != null) { nullMetaModelManager.dispose(); nullMetaModelManager = null; } diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/pages/PapyrusSearchResultPage.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/pages/PapyrusSearchResultPage.java index 68385a536be..6bca13e899d 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/pages/PapyrusSearchResultPage.java +++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/pages/PapyrusSearchResultPage.java @@ -1,7 +1,7 @@ /*****************************************************************************
* Copyright (c) 2013 CEA LIST.
*
- *
+ *
* 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
@@ -43,9 +43,9 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.ui.PartInitException;
/**
- *
+ *
* Papyrus specific search results page
- *
+ *
*/
public class PapyrusSearchResultPage extends AbstractTextSearchViewPage implements IResourceChangeListener {
@@ -71,12 +71,12 @@ public class PapyrusSearchResultPage extends AbstractTextSearchViewPage implemen Set<AbstractResultEntry> results = MatchUtils.getMatches(this.getInput(), true);
- if(element instanceof AbstractResultEntry) {
- AbstractResultEntry resultEntry = (AbstractResultEntry)element;
+ if (element instanceof AbstractResultEntry) {
+ AbstractResultEntry resultEntry = (AbstractResultEntry) element;
- if(results.contains(resultEntry)) {
+ if (results.contains(resultEntry)) {
- return new Match[]{ resultEntry };
+ return new Match[] { resultEntry };
}
return new Match[0];
@@ -88,11 +88,11 @@ public class PapyrusSearchResultPage extends AbstractTextSearchViewPage implemen @Override
public int getDisplayedMatchCount(Object element) {
- if(element instanceof AbstractResultEntry) {
- AbstractResultEntry resultEntry = (AbstractResultEntry)element;
+ if (element instanceof AbstractResultEntry) {
+ AbstractResultEntry resultEntry = (AbstractResultEntry) element;
Set<AbstractResultEntry> results = MatchUtils.getMatches(this.getInput(), true);
- if(results.contains(resultEntry)) {
+ if (results.contains(resultEntry)) {
return 1;
}
@@ -112,19 +112,19 @@ public class PapyrusSearchResultPage extends AbstractTextSearchViewPage implemen protected void handleOpen(OpenEvent event) {
ISelection selection = event.getSelection();
- if(!selection.isEmpty()) {
- if(selection instanceof IStructuredSelection) {
- Object firstElement = ((IStructuredSelection)selection).getFirstElement();
-
- if(firstElement instanceof AbstractResultEntry) {
- AbstractResultEntry resultEntry = (AbstractResultEntry)firstElement;
- ScopeEntry scopeEntry = (ScopeEntry)resultEntry.getElement();
- if(scopeEntry != null && scopeEntry.getServicesRegistry() != null) {
+ if (!selection.isEmpty()) {
+ if (selection instanceof IStructuredSelection) {
+ Object firstElement = ((IStructuredSelection) selection).getFirstElement();
+
+ if (firstElement instanceof AbstractResultEntry) {
+ AbstractResultEntry resultEntry = (AbstractResultEntry) firstElement;
+ ScopeEntry scopeEntry = (ScopeEntry) resultEntry.getElement();
+ if (scopeEntry != null && scopeEntry.getServicesRegistry() != null) {
try {
OpenElementService service = scopeEntry.getServicesRegistry().getService(OpenElementService.class);
resultEntry.openElement(service);
} catch (ServiceException e) {
- // Activator.log.error(Messages.PapyrusSearchResultPage_0 + resultEntry.elementToOpen(), e);
+ // Activator.log.error(Messages.PapyrusSearchResultPage_0 + resultEntry.elementToOpen(), e);
} catch (PartInitException e) {
Activator.log.error(Messages.PapyrusSearchResultPage_1, e);
}
@@ -136,12 +136,12 @@ public class PapyrusSearchResultPage extends AbstractTextSearchViewPage implemen }
- // super.handleOpen(event);
+ // super.handleOpen(event);
}
@Override
protected void elementsChanged(Object[] objects) {
- if(fContentProvider != null) {
+ if (fContentProvider != null) {
fContentProvider.elementsChanged(objects);
}
}
@@ -149,7 +149,7 @@ public class PapyrusSearchResultPage extends AbstractTextSearchViewPage implemen @Override
protected void evaluateChangedElements(Match[] matches, Set changedElements) {
- for(int i = 0; i < matches.length; i++) {
+ for (int i = 0; i < matches.length; i++) {
changedElements.add(matches[i]);
}
@@ -157,7 +157,7 @@ public class PapyrusSearchResultPage extends AbstractTextSearchViewPage implemen @Override
protected void clear() {
- if(fContentProvider != null) {
+ if (fContentProvider != null) {
fContentProvider.clear();
}
}
@@ -166,7 +166,7 @@ public class PapyrusSearchResultPage extends AbstractTextSearchViewPage implemen protected void configureTreeViewer(TreeViewer viewer) {
viewer.setContentProvider(new ResultContentProvider(this, viewer));
viewer.setLabelProvider(new ResultLabelProvider());
- fContentProvider = (ResultContentProvider)viewer.getContentProvider();
+ fContentProvider = (ResultContentProvider) viewer.getContentProvider();
}
@@ -177,16 +177,16 @@ public class PapyrusSearchResultPage extends AbstractTextSearchViewPage implemen public void resourceChanged(IResourceChangeEvent event) {
- if(event.getType() == IResourceChangeEvent.POST_CHANGE) {
+ if (event.getType() == IResourceChangeEvent.POST_CHANGE) {
- if(this.getInput() != null && this.getViewer().getInput() != null && this.getViewPart() != null) {
+ if (this.getInput() != null && this.getViewer().getInput() != null && this.getViewPart() != null) {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
- ((SearchView)getViewPart()).showSearchResult(getInput());
+ ((SearchView) getViewPart()).showSearchResult(getInput());
getViewer().refresh();
}
});
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/AttributeMatchLabelProvider.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/AttributeMatchLabelProvider.java index 2182ad93585..26ec1030361 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/AttributeMatchLabelProvider.java +++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/AttributeMatchLabelProvider.java @@ -1,7 +1,7 @@ /*****************************************************************************
* Copyright (c) 2013 CEA LIST.
*
- *
+ *
* 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
@@ -33,32 +33,32 @@ import org.eclipse.uml2.uml.Stereotype; public class AttributeMatchLabelProvider implements IFilteredLabelProvider {
public Image getImage(Object element) {
- if(element instanceof AttributeMatch) {
+ if (element instanceof AttributeMatch) {
LabelProviderService service = new LabelProviderServiceImpl();
try {
service.startService();
- return service.getLabelProvider().getImage(((AttributeMatch)element).getMetaAttribute());
+ return service.getLabelProvider().getImage(((AttributeMatch) element).getMetaAttribute());
} catch (ServiceException e) {
- Activator.log.warn(Messages.AttributeMatchLabelProvider_0 + ((AttributeMatch)element).getMetaAttribute());
+ Activator.log.warn(Messages.AttributeMatchLabelProvider_0 + ((AttributeMatch) element).getMetaAttribute());
}
}
return null;
}
private String printResult(String sectionThatMatch, String value, int offset, int lenght, String attributeName) {
- return "\"" + sectionThatMatch + "\"" + Messages.AttributeMatchLabelProvider_3 + "\"" + value + "\" [" + offset + "," + (offset + lenght) + "] (" + attributeName + Messages.AttributeMatchLabelProvider_8 + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
+ return "\"" + sectionThatMatch + "\"" + Messages.AttributeMatchLabelProvider_3 + "\"" + value + "\" [" + offset + "," + (offset + lenght) + "] (" + attributeName + Messages.AttributeMatchLabelProvider_8 + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
}
public String getText(Object element) {
- if(element instanceof AttributeMatch) {
- AttributeMatch attributeMatch = ((AttributeMatch)element);
- if((attributeMatch).getSource() instanceof EObject) {
- EObject target = (EObject)attributeMatch.getSource();
- if(attributeMatch.getMetaAttribute() instanceof EAttribute) {
- EAttribute source = (EAttribute)attributeMatch.getMetaAttribute();
- if(target.eGet(source) instanceof String) {
- String value = (String)target.eGet(source);
+ if (element instanceof AttributeMatch) {
+ AttributeMatch attributeMatch = ((AttributeMatch) element);
+ if ((attributeMatch).getSource() instanceof EObject) {
+ EObject target = (EObject) attributeMatch.getSource();
+ if (attributeMatch.getMetaAttribute() instanceof EAttribute) {
+ EAttribute source = (EAttribute) attributeMatch.getMetaAttribute();
+ if (target.eGet(source) instanceof String) {
+ String value = (String) target.eGet(source);
int end = attributeMatch.getOffset() + attributeMatch.getLength();
return printResult(value.substring(attributeMatch.getOffset(), end), value, attributeMatch.getOffset(), attributeMatch.getLength(), source.getName());
@@ -67,13 +67,13 @@ public class AttributeMatchLabelProvider implements IFilteredLabelProvider { int end = attributeMatch.getOffset() + attributeMatch.getLength();
return printResult(value.substring(attributeMatch.getOffset(), end), value, attributeMatch.getOffset(), attributeMatch.getLength(), source.getName());
}
- } else if(attributeMatch.getMetaAttribute() instanceof Property) {
+ } else if (attributeMatch.getMetaAttribute() instanceof Property) {
- Property source = (Property)attributeMatch.getMetaAttribute();
+ Property source = (Property) attributeMatch.getMetaAttribute();
Class containingClass = source.getClass_();
- if(containingClass instanceof Stereotype) {
- if(target instanceof Element) {
- String value = getStringValueOfProperty(((Element)target), (Stereotype)containingClass, (Property)attributeMatch.getMetaAttribute());
+ if (containingClass instanceof Stereotype) {
+ if (target instanceof Element) {
+ String value = getStringValueOfProperty(((Element) target), (Stereotype) containingClass, (Property) attributeMatch.getMetaAttribute());
return printResult(value.substring(attributeMatch.getOffset(), attributeMatch.getLength()), value, attributeMatch.getOffset(), attributeMatch.getLength(), source.getName());
}
@@ -104,7 +104,7 @@ public class AttributeMatchLabelProvider implements IFilteredLabelProvider { }
public boolean accept(Object element) {
- if(element instanceof AttributeMatch) {
+ if (element instanceof AttributeMatch) {
return true;
}
@@ -113,10 +113,10 @@ public class AttributeMatchLabelProvider implements IFilteredLabelProvider { private String getStringValueOfProperty(Element element, Stereotype stereotype, Property property) {
Object value = element.getValue(stereotype, property.getName());
- if(value instanceof String) {
- return (String)value;
- } else if(value instanceof EnumerationLiteral) {
- return ((EnumerationLiteral)value).getName();
+ if (value instanceof String) {
+ return (String) value;
+ } else if (value instanceof EnumerationLiteral) {
+ return ((EnumerationLiteral) value).getName();
} else {
return String.valueOf(value);
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/FilterTypeContentProvider.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/FilterTypeContentProvider.java index da32c4d3444..7d351c6fd12 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/FilterTypeContentProvider.java +++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/FilterTypeContentProvider.java @@ -1,7 +1,7 @@ /*****************************************************************************
* Copyright (c) 2013 CEA LIST.
*
- *
+ *
* 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
@@ -26,9 +26,9 @@ import org.eclipse.search.ui.text.AbstractTextSearchResult; import org.eclipse.uml2.uml.Element;
/**
- *
+ *
* Content provider used by the filter dialog to list available types in a search result
- *
+ *
*/
public class FilterTypeContentProvider implements ITreeContentProvider {
@@ -43,15 +43,15 @@ public class FilterTypeContentProvider implements ITreeContentProvider { public Object[] getElements(Object inputElement) {
Set<Object> results = new HashSet<Object>();
- if(inputElement instanceof AbstractTextSearchResult) {
- - Collection<AbstractResultEntry> matches = MatchUtils.getMatches((AbstractTextSearchResult)inputElement, Element.class, false);
+ if (inputElement instanceof AbstractTextSearchResult) {
+
+ Collection<AbstractResultEntry> matches = MatchUtils.getMatches((AbstractTextSearchResult) inputElement, Element.class, false);
+
+ for (AbstractResultEntry match : matches) {
- for(AbstractResultEntry match : matches) {
+ results.add(((EObject) match.elementToCheckFilterFor()).eClass());
+ results.addAll(((Element) match.elementToCheckFilterFor()).getAppliedStereotypes());
- results.add(((EObject)match.elementToCheckFilterFor()).eClass());
- results.addAll(((Element)match.elementToCheckFilterFor()).getAppliedStereotypes());
- }
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/FilterTypeLabelProvider.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/FilterTypeLabelProvider.java index 9a7536900b7..9ba1b206932 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/FilterTypeLabelProvider.java +++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/FilterTypeLabelProvider.java @@ -1,7 +1,7 @@ /*****************************************************************************
* Copyright (c) 2013 CEA LIST.
*
- *
+ *
* 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
@@ -26,18 +26,18 @@ import org.eclipse.uml2.uml.Stereotype; import com.swtdesigner.ResourceManager;
/**
- *
+ *
* Label provider used by the filter dialog to list available types in a search result
- *
+ *
*/
public class FilterTypeLabelProvider extends LabelProvider {
@Override
public Image getImage(Object object) {
- if(object instanceof ENamedElement) {
- String imagePath = "/icons/full/obj16/" + ((ENamedElement)object).getName() + ".gif"; //$NON-NLS-1$ //$NON-NLS-2$
+ if (object instanceof ENamedElement) {
+ String imagePath = "/icons/full/obj16/" + ((ENamedElement) object).getName() + ".gif"; //$NON-NLS-1$ //$NON-NLS-2$
return ResourceManager.getPluginImage("org.eclipse.uml2.uml.edit", imagePath); //$NON-NLS-1$
- } else if(object instanceof Stereotype) {
+ } else if (object instanceof Stereotype) {
LabelProviderService service = new LabelProviderServiceImpl();
try {
service.startService();
@@ -54,10 +54,10 @@ public class FilterTypeLabelProvider extends LabelProvider { @Override
public String getText(Object object) {
- if(object instanceof ENamedElement) {
- return ((ENamedElement)object).getName();
- } else if(object instanceof Stereotype) {
- return ((Stereotype)object).getName();
+ if (object instanceof ENamedElement) {
+ return ((ENamedElement) object).getName();
+ } else if (object instanceof Stereotype) {
+ return ((Stereotype) object).getName();
} else {
return ""; //$NON-NLS-1$
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/IResultContentProvider.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/IResultContentProvider.java index dc3988b87dc..dc9c05d04b6 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/IResultContentProvider.java +++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/IResultContentProvider.java @@ -1,7 +1,7 @@ /*****************************************************************************
* Copyright (c) 2013 CEA LIST.
*
- *
+ *
* 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,21 +22,21 @@ import org.eclipse.papyrus.views.search.results.AbstractResultEntry; import org.eclipse.search.ui.text.AbstractTextSearchResult;
/**
- *
+ *
* Interface of the ResultContentProvider extension point that contributors must implement
- *
+ *
*/
public interface IResultContentProvider {
/**
* Based on inputElement, add content to the resultHierarchy. Contributors must read the results to identify the elements they can process and add
* the corresponding content to the hierarchy
- *
+ *
* @param inputElement
- * the results
- *
+ * the results
+ *
* @param resultHierarchy
- * the hierarchy to contribute to
+ * the hierarchy to contribute to
*/
public void getHierarchy(AbstractTextSearchResult inputElement, Set<AbstractResultEntry> resultHierarchy);
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/OCLContextContentProvider.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/OCLContextContentProvider.java index d99707c59a9..cdd1670ed6e 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/OCLContextContentProvider.java +++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/OCLContextContentProvider.java @@ -24,8 +24,8 @@ public class OCLContextContentProvider implements ITreeContentProvider { public Object[] getElements(Object inputElement) {
ArrayList result = new ArrayList();
- if(inputElement instanceof ModelSet) {
- UmlModel root = (UmlModel)((ModelSet)inputElement).getModel(UmlModel.MODEL_ID);
+ if (inputElement instanceof ModelSet) {
+ UmlModel root = (UmlModel) ((ModelSet) inputElement).getModel(UmlModel.MODEL_ID);
try {
result.add(root.lookupRoot());
} catch (NotFoundException e) {
@@ -38,8 +38,8 @@ public class OCLContextContentProvider implements ITreeContentProvider { public Object[] getChildren(Object parentElement) {
ArrayList result = new ArrayList();
- if(parentElement instanceof EObject) {
- result.addAll(((EObject)parentElement).eContents());
+ if (parentElement instanceof EObject) {
+ result.addAll(((EObject) parentElement).eContents());
}
return result.toArray();
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ParticipantTypeAttribute.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ParticipantTypeAttribute.java index 05655a58040..e787c4948f2 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ParticipantTypeAttribute.java +++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ParticipantTypeAttribute.java @@ -22,6 +22,7 @@ public class ParticipantTypeAttribute extends ParticipantTypeElement { this.parent = parent;
}
+ @Override
public String getText() {
return super.getText();
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ParticipantTypeContentProvider.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ParticipantTypeContentProvider.java index 90747d62b36..04e5480df03 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ParticipantTypeContentProvider.java +++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ParticipantTypeContentProvider.java @@ -1,7 +1,7 @@ /*****************************************************************************
* Copyright (c) 2013 CEA LIST.
*
- *
+ *
* 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
@@ -17,14 +17,13 @@ import java.util.ArrayList; import java.util.HashMap;
import java.util.List;
-import org.eclipse.emf.ecore.EPackage;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
/**
- *
+ *
* A content provider for a ePackage
- *
+ *
*/
public class ParticipantTypeContentProvider implements ITreeContentProvider {
@@ -44,7 +43,7 @@ public class ParticipantTypeContentProvider implements ITreeContentProvider { }
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- participantsList = (HashMap<ParticipantTypeElement, List<ParticipantTypeAttribute>>)newInput;
+ participantsList = (HashMap<ParticipantTypeElement, List<ParticipantTypeAttribute>>) newInput;
}
public Object[] getElements(Object inputElement) {
@@ -52,17 +51,17 @@ public class ParticipantTypeContentProvider implements ITreeContentProvider { List<Object> result = new ArrayList<Object>();
- if(inputElement instanceof HashMap) {
- return ((HashMap)inputElement).keySet().toArray();
+ if (inputElement instanceof HashMap) {
+ return ((HashMap) inputElement).keySet().toArray();
}
-
+
return result.toArray();
}
public Object[] getChildren(Object parentElement) {
- if(parentElement instanceof ParticipantTypeElement) {
- if(!(parentElement instanceof ParticipantTypeAttribute)) {
+ if (parentElement instanceof ParticipantTypeElement) {
+ if (!(parentElement instanceof ParticipantTypeAttribute)) {
return participantsList.get(parentElement).toArray();
}
}
@@ -78,13 +77,14 @@ public class ParticipantTypeContentProvider implements ITreeContentProvider { }
public boolean hasChildren(Object element) {
- if(element instanceof ParticipantTypeAttribute) {
+ if (element instanceof ParticipantTypeAttribute) {
return false;
} else {
- if(getChildren(element).length > 0)
+ if (getChildren(element).length > 0) {
return true;
- else
+ } else {
return false;
+ }
}
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ParticipantTypeElement.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ParticipantTypeElement.java index d6068d6b28f..7243c76304a 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ParticipantTypeElement.java +++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ParticipantTypeElement.java @@ -42,10 +42,10 @@ public class ParticipantTypeElement { public String getText() {
- if(element instanceof NamedElement) {
- return ((NamedElement)element).getName();
- } else if(element instanceof ENamedElement) {
- return ((ENamedElement)element).getName();
+ if (element instanceof NamedElement) {
+ return ((NamedElement) element).getName();
+ } else if (element instanceof ENamedElement) {
+ return ((ENamedElement) element).getName();
}
return null;
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ParticipantTypeLabelProvider.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ParticipantTypeLabelProvider.java index e36ba6200f0..2fd841fdc6c 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ParticipantTypeLabelProvider.java +++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ParticipantTypeLabelProvider.java @@ -1,7 +1,7 @@ /*****************************************************************************
* Copyright (c) 2013 CEA LIST.
*
- *
+ *
* 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,23 +20,24 @@ import org.eclipse.swt.graphics.Image; import com.swtdesigner.ResourceManager;
public class ParticipantTypeLabelProvider extends LabelProvider {
- +
@Override
public Image getImage(Object object) {
- if(object instanceof ParticipantTypeElement)
- if(((ParticipantTypeElement)object).getElement() instanceof ENamedElement) {
- String imagePath = "/icons/full/obj16/" + ((ENamedElement)((ParticipantTypeElement)object).getElement()).getName() + ".gif"; //$NON-NLS-1$ //$NON-NLS-2$
+ if (object instanceof ParticipantTypeElement) {
+ if (((ParticipantTypeElement) object).getElement() instanceof ENamedElement) {
+ String imagePath = "/icons/full/obj16/" + ((ENamedElement) ((ParticipantTypeElement) object).getElement()).getName() + ".gif"; //$NON-NLS-1$ //$NON-NLS-2$
return ResourceManager.getPluginImage("org.eclipse.uml2.uml.edit", imagePath); //$NON-NLS-1$
}
+ }
return null;
}
- +
@Override
public String getText(Object object) {
- if(object instanceof ParticipantTypeElement) {
- return ((ParticipantTypeElement)object).getText();
+ if (object instanceof ParticipantTypeElement) {
+ return ((ParticipantTypeElement) object).getText();
}
return ""; //$NON-NLS-1$
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ResultContentProvider.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ResultContentProvider.java index 0f9e201e0dc..151a3ce4baf 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ResultContentProvider.java +++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ResultContentProvider.java @@ -1,7 +1,7 @@ /*****************************************************************************
* Copyright (c) 2013 CEA LIST 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
@@ -31,9 +31,9 @@ import org.eclipse.papyrus.views.search.utils.MatchUtils; import org.eclipse.search.ui.text.AbstractTextSearchResult;
/**
- *
+ *
* A content provider that generate the content through the results computed by resultContentProviders
- *
+ *
*/
public class ResultContentProvider implements ITreeContentProvider {
@@ -68,9 +68,9 @@ public class ResultContentProvider implements ITreeContentProvider { }
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- if(newInput != null) {
- if(newInput instanceof PapyrusSearchResult) {
- fResult = (AbstractTextSearchResult)newInput;
+ if (newInput != null) {
+ if (newInput instanceof PapyrusSearchResult) {
+ fResult = (AbstractTextSearchResult) newInput;
initialize();
}
} else {
@@ -84,7 +84,7 @@ public class ResultContentProvider implements ITreeContentProvider { public Object[] getElements(Object inputElement) {
Object[] children = getChildren(inputElement);
int elementLimit = getElementLimit();
- if(elementLimit != -1 && elementLimit < children.length) {
+ if (elementLimit != -1 && elementLimit < children.length) {
Object[] limitedChildren = new Object[elementLimit];
System.arraycopy(children, 0, limitedChildren, 0, elementLimit);
return limitedChildren;
@@ -110,7 +110,7 @@ public class ResultContentProvider implements ITreeContentProvider { Set<AbstractResultEntry> realMatches = MatchUtils.getMatches(fResult, true);
- for(AbstractResultEntry resultEntry : realMatches) {
+ for (AbstractResultEntry resultEntry : realMatches) {
insert(resultEntry, false);
}
@@ -120,21 +120,21 @@ public class ResultContentProvider implements ITreeContentProvider { Set<Object> children = fChildrenMap.get(parent);
- if(children == null) {
+ if (children == null) {
children = new HashSet<Object>();
fChildrenMap.put(parent, children);
}
boolean found = false;
- for(Object childInMap : children) {
- if(child instanceof AbstractResultEntry) {
- if(childInMap instanceof AbstractResultEntry) {
- if(((AbstractResultEntry)childInMap).equals((AbstractResultEntry)child)) {
+ for (Object childInMap : children) {
+ if (child instanceof AbstractResultEntry) {
+ if (childInMap instanceof AbstractResultEntry) {
+ if (((AbstractResultEntry) childInMap).equals(child)) {
- if((!(child instanceof ResultEntry)) && (childInMap instanceof ResultEntry)) {
+ if ((!(child instanceof ResultEntry)) && (childInMap instanceof ResultEntry)) {
- replaceResultEntryByRealResult((AbstractResultEntry)childInMap, (AbstractResultEntry)child);
+ replaceResultEntryByRealResult((AbstractResultEntry) childInMap, (AbstractResultEntry) child);
}
@@ -146,7 +146,7 @@ public class ResultContentProvider implements ITreeContentProvider { }
}
- if(!found) {
+ if (!found) {
children.add(child);
return true;
} else {
@@ -157,20 +157,20 @@ public class ResultContentProvider implements ITreeContentProvider { protected void replaceResultEntryByRealResult(AbstractResultEntry toReplace, AbstractResultEntry replacement) {
- //Must replace ResultEntry in the tree by RealMatch
- for(Object childInMap : fChildrenMap.get(toReplace)) {
- if(childInMap instanceof AbstractResultEntry) {
- ((AbstractResultEntry)childInMap).setParent(replacement);
+ // Must replace ResultEntry in the tree by RealMatch
+ for (Object childInMap : fChildrenMap.get(toReplace)) {
+ if (childInMap instanceof AbstractResultEntry) {
+ ((AbstractResultEntry) childInMap).setParent(replacement);
}
}
fChildrenMap.put(replacement, fChildrenMap.get(toReplace));
- ((AbstractResultEntry)replacement).setParent(toReplace.getParent());
+ replacement.setParent(toReplace.getParent());
fChildrenMap.remove(toReplace);
- for(Object key : fChildrenMap.keySet()) {
+ for (Object key : fChildrenMap.keySet()) {
- if(fChildrenMap.get(key).contains(toReplace)) {
+ if (fChildrenMap.get(key).contains(toReplace)) {
fChildrenMap.get(key).remove(toReplace);
fChildrenMap.get(key).add(replacement);
}
@@ -183,20 +183,20 @@ public class ResultContentProvider implements ITreeContentProvider { Object existingParent = null;
- //Try to find if it is already in the childrenMap
- for(Object key : fChildrenMap.keySet()) {
- //It may be the parent
- if(key instanceof AbstractResultEntry) {
- if(((AbstractResultEntry)key).equals(parent)) {
+ // Try to find if it is already in the childrenMap
+ for (Object key : fChildrenMap.keySet()) {
+ // It may be the parent
+ if (key instanceof AbstractResultEntry) {
+ if (((AbstractResultEntry) key).equals(parent)) {
existingParent = key;
break;
}
}
- //or one of the children
- for(Object childInMap : fChildrenMap.get(key)) {
- if(childInMap instanceof AbstractResultEntry) {
- if(((AbstractResultEntry)childInMap).equals(parent)) {
+ // or one of the children
+ for (Object childInMap : fChildrenMap.get(key)) {
+ if (childInMap instanceof AbstractResultEntry) {
+ if (((AbstractResultEntry) childInMap).equals(parent)) {
existingParent = childInMap;
break;
}
@@ -204,8 +204,8 @@ public class ResultContentProvider implements ITreeContentProvider { }
}
- if(existingParent != null) {
- ((AbstractResultEntry)child).setParent(existingParent);
+ if (existingParent != null) {
+ ((AbstractResultEntry) child).setParent(existingParent);
return existingParent;
} else {
return parent;
@@ -217,13 +217,13 @@ public class ResultContentProvider implements ITreeContentProvider { Object parent = getUpdateParent(child);
- while(parent != null) {
- if(insertChild(parent, child)) {
- if(refreshViewer) {
+ while (parent != null) {
+ if (insertChild(parent, child)) {
+ if (refreshViewer) {
fViewer.add(parent, child);
}
} else {
- if(refreshViewer) {
+ if (refreshViewer) {
fViewer.refresh(parent);
}
return;
@@ -232,8 +232,8 @@ public class ResultContentProvider implements ITreeContentProvider { parent = getUpdateParent(child);
}
- if(insertChild(fResult, child)) {
- if(refreshViewer) {
+ if (insertChild(fResult, child)) {
+ if (refreshViewer) {
fViewer.add(fResult, child);
}
}
@@ -242,14 +242,14 @@ public class ResultContentProvider implements ITreeContentProvider { protected boolean hasChild(Object parent, Object child) {
Set<Object> children = fChildrenMap.get(parent);
- if(children != null) {
- for(Object childInMap : children) {
- if(childInMap instanceof AbstractResultEntry) {
- if(child instanceof AbstractResultEntry) {
- if(((AbstractResultEntry)childInMap).equals((AbstractResultEntry)child)) {
+ if (children != null) {
+ for (Object childInMap : children) {
+ if (childInMap instanceof AbstractResultEntry) {
+ if (child instanceof AbstractResultEntry) {
+ if (((AbstractResultEntry) childInMap).equals(child)) {
- if((!(child instanceof ResultEntry)) && (childInMap instanceof ResultEntry)) {
- replaceResultEntryByRealResult((AbstractResultEntry)childInMap, (AbstractResultEntry)child);
+ if ((!(child instanceof ResultEntry)) && (childInMap instanceof ResultEntry)) {
+ replaceResultEntryByRealResult((AbstractResultEntry) childInMap, (AbstractResultEntry) child);
}
return true;
@@ -260,30 +260,30 @@ public class ResultContentProvider implements ITreeContentProvider { }
return false;
- // return children != null && children.contains(child);
+ // return children != null && children.contains(child);
}
protected void removeFromSiblings(Object element, Object parent) {
Set<Object> siblings = fChildrenMap.get(parent);
- if(siblings != null) {
+ if (siblings != null) {
siblings.remove(element);
}
}
public void remove(Object element, boolean refreshViewer) {
- if(hasChildren(element)) {
- if(refreshViewer) {
+ if (hasChildren(element)) {
+ if (refreshViewer) {
fViewer.refresh(element);
}
} else {
fChildrenMap.remove(element);
Object parent = getUpdateParent(element);
- if(parent != null) {
+ if (parent != null) {
removeFromSiblings(element, parent);
remove(parent, refreshViewer);
} else {
removeFromSiblings(element, fResult);
- if(refreshViewer) {
+ if (refreshViewer) {
fViewer.refresh();
}
}
@@ -293,33 +293,33 @@ public class ResultContentProvider implements ITreeContentProvider { /**
* Signal the objects that changed in the content
- *
+ *
* @param objects
- * objects that changed
+ * objects that changed
*/
public synchronized void elementsChanged(Object[] updatedElements) {
- for(int i = 0; i < updatedElements.length; i++) {
+ for (int i = 0; i < updatedElements.length; i++) {
- if(updatedElements[i] instanceof AbstractResultEntry) {
- AbstractResultEntry resultEntry = (AbstractResultEntry)updatedElements[i];
+ if (updatedElements[i] instanceof AbstractResultEntry) {
+ AbstractResultEntry resultEntry = (AbstractResultEntry) updatedElements[i];
Set<AbstractResultEntry> matches = MatchUtils.getMatches(fResult, true);
- if(matches.contains(updatedElements[i])) {
+ if (matches.contains(updatedElements[i])) {
Object parent = getUpdateParent(resultEntry);
- if(hasChild(parent, resultEntry)) {
- fViewer.update(new Object[]{ resultEntry, parent }, null);
+ if (hasChild(parent, resultEntry)) {
+ fViewer.update(new Object[] { resultEntry, parent }, null);
} else {
- insert(resultEntry, true); //or update
+ insert(resultEntry, true); // or update
}
} else {
remove(resultEntry, true);
}
} else {
- if(fResult.getMatchCount(updatedElements[i]) > 0) {
+ if (fResult.getMatchCount(updatedElements[i]) > 0) {
insert(updatedElements[i], true);
} else {
remove(updatedElements[i], true);
@@ -330,14 +330,15 @@ public class ResultContentProvider implements ITreeContentProvider { public Object[] getChildren(Object parentElement) {
Set<Object> children = fChildrenMap.get(parentElement);
- if(children == null)
+ if (children == null) {
return EMPTY_ARR;
+ }
return children.toArray();
}
public Object getParent(Object element) {
- if(element instanceof AbstractResultEntry) {
- AbstractResultEntry match = (AbstractResultEntry)element;
+ if (element instanceof AbstractResultEntry) {
+ AbstractResultEntry match = (AbstractResultEntry) element;
return match.getParent();
}
return null;
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ResultLabelProvider.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ResultLabelProvider.java index 1ceb4662045..5f8fac41acf 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ResultLabelProvider.java +++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ResultLabelProvider.java @@ -1,7 +1,7 @@ /*****************************************************************************
* Copyright (c) 2013 CEA LIST.
*
- *
+ *
* 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
@@ -30,8 +30,8 @@ public class ResultLabelProvider extends LabelProvider { @Override
public Image getImage(Object element) {
- if(element instanceof AbstractResultEntry) {
- return labelProviderService.getLabelProvider().getImage(((AbstractResultEntry)element).elementToDisplay());
+ if (element instanceof AbstractResultEntry) {
+ return labelProviderService.getLabelProvider().getImage(((AbstractResultEntry) element).elementToDisplay());
}
return null;
@@ -39,8 +39,8 @@ public class ResultLabelProvider extends LabelProvider { @Override
public String getText(Object element) {
- if(element instanceof AbstractResultEntry) {
- return labelProviderService.getLabelProvider().getText(((AbstractResultEntry)element).elementToDisplay());
+ if (element instanceof AbstractResultEntry) {
+ return labelProviderService.getLabelProvider().getText(((AbstractResultEntry) element).elementToDisplay());
}
return ""; //$NON-NLS-1$
}
@@ -51,7 +51,7 @@ public class ResultLabelProvider extends LabelProvider { try {
labelProviderService.disposeService();
} catch (ServiceException ex) {
- //Ignore
+ // Ignore
}
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/AbstractPapyrusQuery.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/AbstractPapyrusQuery.java index 394ea7110a4..915f99eeda9 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/AbstractPapyrusQuery.java +++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/AbstractPapyrusQuery.java @@ -1,7 +1,7 @@ /*****************************************************************************
* Copyright (c) 2013 CEA LIST 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,15 +22,15 @@ import org.eclipse.papyrus.uml.search.ui.results.PapyrusSearchResult; import org.eclipse.search.ui.ISearchQuery;
/**
- *
+ *
* Papyrus specific search query
- *
+ *
*/
public abstract class AbstractPapyrusQuery implements ISearchQuery {
/**
* Getter for the text query
- *
+ *
* @return the the query text
*/
public abstract String getSearchQueryText();
@@ -48,14 +48,14 @@ public abstract class AbstractPapyrusQuery implements ISearchQuery { //
// Nested types
//
-
+
public static final class Empty extends AbstractPapyrusQuery {
public static final Empty INSTANCE = new Empty();
-
+
private Empty() {
super();
}
-
+
public IStatus run(IProgressMonitor monitor) throws OperationCanceledException {
return Status.OK_STATUS;
}
@@ -80,6 +80,6 @@ public abstract class AbstractPapyrusQuery implements ISearchQuery { public String getSearchQueryText() {
return "";
}
-
+
}
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/CompositePapyrusQuery.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/CompositePapyrusQuery.java index a89feebb29f..d798a055d59 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/CompositePapyrusQuery.java +++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/CompositePapyrusQuery.java @@ -1,6 +1,6 @@ /***************************************************************************** * Copyright (c) 2013 CEA LIST 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 @@ -51,14 +51,14 @@ public class CompositePapyrusQuery extends AbstractPapyrusQuery { /** * Creates the most efficient composition of zero or more {@code queries}. - * + * * @param queries - * zero or more queries to delegate to - * + * zero or more queries to delegate to + * * @return a composition of the {@code queries} */ public static AbstractPapyrusQuery compose(Iterable<? extends AbstractPapyrusQuery> queries) { - switch(Iterables.size(queries)) { + switch (Iterables.size(queries)) { case 0: return AbstractPapyrusQuery.Empty.INSTANCE; case 1: @@ -80,8 +80,8 @@ public class CompositePapyrusQuery extends AbstractPapyrusQuery { public boolean canRerun() { boolean result = true; - for(AbstractPapyrusQuery next : queries) { - if(!next.canRerun()) { + for (AbstractPapyrusQuery next : queries) { + if (!next.canRerun()) { result = false; break; } @@ -93,8 +93,8 @@ public class CompositePapyrusQuery extends AbstractPapyrusQuery { public boolean canRunInBackground() { boolean result = true; - for(AbstractPapyrusQuery next : queries) { - if(!next.canRunInBackground()) { + for (AbstractPapyrusQuery next : queries) { + if (!next.canRunInBackground()) { result = false; break; } @@ -109,13 +109,13 @@ public class CompositePapyrusQuery extends AbstractPapyrusQuery { searchResult.clear(); SubMonitor sub = SubMonitor.convert(monitor, result.size()); - for(AbstractPapyrusQuery next : queries) { + for (AbstractPapyrusQuery next : queries) { IStatus status = next.run(sub.newChild(1)); - if(!status.isOK()) { + if (!status.isOK()) { result.add(status); } - searchResult.addSearchResult((AbstractTextSearchResult)next.getSearchResult()); + searchResult.addSearchResult((AbstractTextSearchResult) next.getSearchResult()); } return result.isEmpty() ? Status.OK_STATUS : (result.size() == 1) ? result.get(0) : new MultiStatus(Activator.PLUGIN_ID, 0, result.toArray(new IStatus[result.size()]), "Problems occurred in search.", null); @@ -138,7 +138,7 @@ public class CompositePapyrusQuery extends AbstractPapyrusQuery { } void clear() { - for(AbstractTextSearchResult next : searchResults.keySet()) { + for (AbstractTextSearchResult next : searchResults.keySet()) { next.removeListener(this); } searchResults.clear(); @@ -146,13 +146,13 @@ public class CompositePapyrusQuery extends AbstractPapyrusQuery { void addSearchResult(AbstractTextSearchResult searchResult) { Object[] elements = searchResult.getElements(); - for(int i = 0; i < elements.length; i++) { + for (int i = 0; i < elements.length; i++) { Match[] matches = searchResult.getMatches(elements[i]); searchResults.putAll(searchResult, Arrays.asList(matches)); addMatches(matches); // I need them, too } - if(!searchResults.containsKey(searchResult)) { + if (!searchResults.containsKey(searchResult)) { // we have to make sure that we remember this empty result! searchResults.putAll(searchResult, Collections.<Match> emptyList()); } @@ -161,13 +161,13 @@ public class CompositePapyrusQuery extends AbstractPapyrusQuery { } public void searchResultChanged(SearchResultEvent e) { - AbstractTextSearchResult source = (AbstractTextSearchResult)e.getSearchResult(); + AbstractTextSearchResult source = (AbstractTextSearchResult) e.getSearchResult(); - if(e instanceof RemoveAllEvent) { + if (e instanceof RemoveAllEvent) { removeAll(source); - } else if(e instanceof MatchEvent) { - MatchEvent event = (MatchEvent)e; - switch(event.getKind()) { + } else if (e instanceof MatchEvent) { + MatchEvent event = (MatchEvent) e; + switch (event.getKind()) { case MatchEvent.ADDED: add(source, event.getMatches()); break; diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/CompositePapyrusQueryProvider.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/CompositePapyrusQueryProvider.java index 7ba8dd5bbd3..98292218ae6 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/CompositePapyrusQueryProvider.java +++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/CompositePapyrusQueryProvider.java @@ -1,6 +1,6 @@ /***************************************************************************** * Copyright (c) 2013 CEA LIST 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 @@ -55,10 +55,10 @@ public class CompositePapyrusQueryProvider implements IPapyrusQueryProvider { Map<IPapyrusQueryProvider, Collection<URI>> partitions = partitionSearchScope(queryInfo.getScope()); List<AbstractPapyrusQuery> result = new java.util.ArrayList<AbstractPapyrusQuery>(partitions.size()); - for(Map.Entry<IPapyrusQueryProvider, Collection<URI>> next : partitions.entrySet()) { + for (Map.Entry<IPapyrusQueryProvider, Collection<URI>> next : partitions.entrySet()) { AbstractPapyrusQuery query = next.getKey().createSimpleSearchQuery(queryInfo.partition(next.getValue())); - if(query != null) { + if (query != null) { result.add(query); } } @@ -70,10 +70,10 @@ public class CompositePapyrusQueryProvider implements IPapyrusQueryProvider { Map<IPapyrusQueryProvider, Collection<URI>> partitions = partitionSearchScope(queryInfo.getScope()); List<AbstractPapyrusQuery> result = new java.util.ArrayList<AbstractPapyrusQuery>(partitions.size()); - for(Map.Entry<IPapyrusQueryProvider, Collection<URI>> next : partitions.entrySet()) { + for (Map.Entry<IPapyrusQueryProvider, Collection<URI>> next : partitions.entrySet()) { AbstractPapyrusQuery query = next.getKey().createAdvancedSearchQuery(queryInfo.partition(next.getValue())); - if(query != null) { + if (query != null) { result.add(query); } } @@ -84,9 +84,9 @@ public class CompositePapyrusQueryProvider implements IPapyrusQueryProvider { private AbstractPapyrusQuery composite(final List<? extends AbstractPapyrusQuery> queries) { AbstractPapyrusQuery result; - if(queries.isEmpty()) { + if (queries.isEmpty()) { result = AbstractPapyrusQuery.Empty.INSTANCE; - } else if(queries.size() == 1) { + } else if (queries.size() == 1) { result = queries.get(0); } else { result = new CompositePapyrusQuery(queries); @@ -99,12 +99,12 @@ public class CompositePapyrusQueryProvider implements IPapyrusQueryProvider { Map<IPapyrusQueryProvider, Collection<URI>> result = new java.util.HashMap<IPapyrusQueryProvider, Collection<URI>>(); Iterable<? extends IPapyrusQueryProvider> providers = getQueryProviders(); - for(URI next : scope) { - for(IPapyrusQueryProvider provider : providers) { - if(provider.canProvideFor(next)) { + for (URI next : scope) { + for (IPapyrusQueryProvider provider : providers) { + if (provider.canProvideFor(next)) { Collection<URI> myScope = result.get(provider); - if(myScope == null) { + if (myScope == null) { // preserve order but ensure uniqueness myScope = new java.util.LinkedHashSet<URI>(); result.put(provider, myScope); @@ -126,8 +126,8 @@ public class CompositePapyrusQueryProvider implements IPapyrusQueryProvider { final Iterable<? extends IPapyrusQueryProvider> getQueryProviders() { List<IPapyrusQueryProvider> result = new ArrayList<IPapyrusQueryProvider>(); - synchronized(queryProviders) { - for(IPapyrusQueryProvider next : queryProviders) { + synchronized (queryProviders) { + for (IPapyrusQueryProvider next : queryProviders) { result.add(next); } } @@ -162,7 +162,7 @@ public class CompositePapyrusQueryProvider implements IPapyrusQueryProvider { @Override public boolean equals(Object obj) { - return (obj instanceof PriorityQueryProvider) && ((PriorityQueryProvider)obj).delegate.equals(delegate); + return (obj instanceof PriorityQueryProvider) && ((PriorityQueryProvider) obj).delegate.equals(delegate); } // @@ -200,7 +200,7 @@ public class CompositePapyrusQueryProvider implements IPapyrusQueryProvider { } Iterable<? extends IPapyrusQueryProvider> load() { - synchronized(providers) { + synchronized (providers) { providers.clear(); readRegistry(); } @@ -212,13 +212,13 @@ public class CompositePapyrusQueryProvider implements IPapyrusQueryProvider { protected boolean readElement(IConfigurationElement element, boolean add) { boolean result = false; - if(TAG_PROVIDER.equals(element.getName())) { + if (TAG_PROVIDER.equals(element.getName())) { result = true; String className = element.getAttribute(ATTR_CLASS); - if((className == null) || (className.length() == 0)) { + if ((className == null) || (className.length() == 0)) { logMissingAttribute(element, ATTR_CLASS); - } else if(add) { + } else if (add) { addProvider(element, className); } else { removeProvider(element, className); @@ -232,16 +232,16 @@ public class CompositePapyrusQueryProvider implements IPapyrusQueryProvider { try { Object provider = element.createExecutableExtension(ATTR_CLASS); - if(!(provider instanceof IPapyrusQueryProvider)) { + if (!(provider instanceof IPapyrusQueryProvider)) { Activator.log.error("Query provider extension does not implement IPapyrusQueryProvider interface: " + className, null); //$NON-NLS-1$ } else { String priorityString = element.getAttribute(ATTR_PRIORITY); int priority = 0; try { - if((priorityString) != null && (priorityString.length() > 0)) { + if ((priorityString) != null && (priorityString.length() > 0)) { priority = Integer.parseInt(priorityString); - if(priority < 0) { + if (priority < 0) { Activator.log.warn("Negative priority in query provider " + className); //$NON-NLS-1$ priority = 0; } @@ -250,8 +250,8 @@ public class CompositePapyrusQueryProvider implements IPapyrusQueryProvider { Activator.log.warn("Not an integer priority in query provider " + className); //$NON-NLS-1$ } - synchronized(providers) { - providers.add(new PriorityQueryProvider((IPapyrusQueryProvider)provider, priority)); + synchronized (providers) { + providers.add(new PriorityQueryProvider((IPapyrusQueryProvider) provider, priority)); } } } catch (CoreException e) { @@ -260,9 +260,9 @@ public class CompositePapyrusQueryProvider implements IPapyrusQueryProvider { } private void removeProvider(IConfigurationElement element, String className) { - synchronized(providers) { - for(Iterator<PriorityQueryProvider> iter = providers.iterator(); iter.hasNext();) { - if(iter.next().delegate.getClass().getName().equals(className)) { + synchronized (providers) { + for (Iterator<PriorityQueryProvider> iter = providers.iterator(); iter.hasNext();) { + if (iter.next().delegate.getClass().getName().equals(className)) { iter.remove(); } } diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/IPapyrusQueryProvider.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/IPapyrusQueryProvider.java index 5a7d732a4d1..02f4d961842 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/IPapyrusQueryProvider.java +++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/IPapyrusQueryProvider.java @@ -1,6 +1,6 @@ /***************************************************************************** * Copyright (c) 2013 CEA LIST 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 @@ -26,13 +26,12 @@ public interface IPapyrusQueryProvider { /** * Asks whether this provider can query a resource (or resources) identified by the given {@code scope} URI. * This method is used to partition the overall search scope by query provider. - * + * * @param scope - * a URI identifying one or more model resources in the workspace or elsewhere - * - * @return whether I can provide a query on this scope. If I can, I had better be prepared to supply one - * {@linkplain #createSimpleSearchQuery(String, boolean, boolean, boolean, Collection) when asked} - * + * a URI identifying one or more model resources in the workspace or elsewhere + * + * @return whether I can provide a query on this scope. If I can, I had better be prepared to supply one {@linkplain #createSimpleSearchQuery(String, boolean, boolean, boolean, Collection) when asked} + * * @see #createSimpleSearchQuery(String, boolean, boolean, boolean, Collection) * @see #createAdvancedSearchQuery(String, boolean, boolean, Collection, Collection) */ @@ -40,24 +39,24 @@ public interface IPapyrusQueryProvider { /** * Creates a simple text-based search query. - * + * * @param queryInfo - * the query parameters - * + * the query parameters + * * @return the simple (for the user!) search query */ AbstractPapyrusQuery createSimpleSearchQuery(QueryInfo queryInfo); /** * Creates an advanced text-based search query. - * + * * @param queryInfo - * the query parameters - * + * the query parameters + * * @return the advanced (for the user!) search query */ AbstractPapyrusQuery createAdvancedSearchQuery(QueryInfo queryInfo); - + // // Nested types // diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/PapyrusAdvancedQuery.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/PapyrusAdvancedQuery.java index 32fcbbcd602..fac93c1302e 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/PapyrusAdvancedQuery.java +++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/PapyrusAdvancedQuery.java @@ -1,7 +1,7 @@ /*****************************************************************************
* Copyright (c) 2013 CEA LIST.
*
- *
+ *
* 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
@@ -58,16 +58,18 @@ import org.eclipse.uml2.uml.Stereotype; import org.eclipse.uml2.uml.util.UMLUtil;
/**
- *
+ *
* Papyrus specific search query
- *
+ *
*/
public class PapyrusAdvancedQuery extends AbstractPapyrusQuery {
+ @Override
public boolean isCaseSensitive() {
return isCaseSensitive;
}
+ @Override
public boolean isRegularExpression() {
return isRegularExpression;
}
@@ -117,28 +119,30 @@ public class PapyrusAdvancedQuery extends AbstractPapyrusQuery { participantsList = new HashMap<EObject, List<EAttribute>>();
stereotypeList = new HashMap<Stereotype, ArrayList<Property>>();
- for(Object participant : this.participantsChecked) {
- if(participant instanceof ParticipantTypeElement) {
- if(((ParticipantTypeElement)participant).getElement() instanceof ENamedElement) {
+ for (Object participant : this.participantsChecked) {
+ if (participant instanceof ParticipantTypeElement) {
+ if (((ParticipantTypeElement) participant).getElement() instanceof ENamedElement) {
List<EAttribute> attributesChecked = new ArrayList<EAttribute>();
- for(Object attributesFound : this.participantsChecked) {
- if(attributesFound instanceof ParticipantTypeAttribute) {
- if(((ParticipantTypeAttribute)attributesFound).getParent() == participant)
- attributesChecked.add((EAttribute)((ParticipantTypeAttribute)attributesFound).getElement());
+ for (Object attributesFound : this.participantsChecked) {
+ if (attributesFound instanceof ParticipantTypeAttribute) {
+ if (((ParticipantTypeAttribute) attributesFound).getParent() == participant) {
+ attributesChecked.add((EAttribute) ((ParticipantTypeAttribute) attributesFound).getElement());
+ }
}
}
- participantsList.put((EObject)((ParticipantTypeElement)participant).getElement(), attributesChecked);
+ participantsList.put(((ParticipantTypeElement) participant).getElement(), attributesChecked);
- } else if(((ParticipantTypeElement)participant).getElement() instanceof Stereotype) {
+ } else if (((ParticipantTypeElement) participant).getElement() instanceof Stereotype) {
ArrayList<Property> attributesChecked = new ArrayList<Property>();
- for(Object attributesFound : this.participantsChecked) {
- if(attributesFound instanceof ParticipantTypeAttribute) {
- if(((ParticipantTypeAttribute)attributesFound).getParent() == participant)
- attributesChecked.add((Property)((ParticipantTypeAttribute)attributesFound).getElement());
+ for (Object attributesFound : this.participantsChecked) {
+ if (attributesFound instanceof ParticipantTypeAttribute) {
+ if (((ParticipantTypeAttribute) attributesFound).getParent() == participant) {
+ attributesChecked.add((Property) ((ParticipantTypeAttribute) attributesFound).getElement());
+ }
}
}
- stereotypeList.put((Stereotype)((ParticipantTypeElement)participant).getElement(), attributesChecked);
+ stereotypeList.put((Stereotype) ((ParticipantTypeElement) participant).getElement(), attributesChecked);
}
}
}
@@ -150,21 +154,21 @@ public class PapyrusAdvancedQuery extends AbstractPapyrusQuery { results.removeAll();
fResults.clear();
- for(ScopeEntry scopeEntry : scopeEntries) {
+ for (ScopeEntry scopeEntry : scopeEntries) {
try {
- if(scopeEntry.getModelSet() != null) {
+ if (scopeEntry.getModelSet() != null) {
- UmlModel umlModel = (UmlModel)scopeEntry.getModelSet().getModelChecked(UmlModel.MODEL_ID);
+ UmlModel umlModel = (UmlModel) scopeEntry.getModelSet().getModelChecked(UmlModel.MODEL_ID);
EObject root = umlModel.lookupRoot();
Collection<EObject> participants = ParticipantValidator.getInstance().getParticipants(root, participantsList.keySet().toArray());
Collection<EObject> stereotypesParticipants = ParticipantValidator.getInstance().getParticipantsStereotype(root, stereotypeList.keySet().toArray());
- if(searchForAllSter) {
+ if (searchForAllSter) {
- if(participantsList.keySet().size() == 0) {
+ if (participantsList.keySet().size() == 0) {
stereotypesParticipants = getElementsWithAllSter(stereotypesParticipants);
evaluateStereotypes(stereotypesParticipants, scopeEntry);
} else {
@@ -192,19 +196,19 @@ public class PapyrusAdvancedQuery extends AbstractPapyrusQuery { private Collection<EObject> getElementsWithAllSter(Collection<EObject> initialParticipants) {
Collection<EObject> participantsToKeep = new ArrayList<EObject>();
- for(EObject participants : initialParticipants) {
- if(participants instanceof Element) {
+ for (EObject participants : initialParticipants) {
+ if (participants instanceof Element) {
int numberOfStereotypeToBeApplied = stereotypeList.size();
int numberOfStereotypeMatching = 0;
- if(numberOfStereotypeToBeApplied == ((Element)participants).getAppliedStereotypes().size()) {
- for(Stereotype stereotypeToBeApplied : stereotypeList.keySet()) {
- for(Stereotype stereotypeApplied : ((Element)participants).getAppliedStereotypes()) {
- if(EcoreUtil.equals(stereotypeToBeApplied, stereotypeApplied)) {
+ if (numberOfStereotypeToBeApplied == ((Element) participants).getAppliedStereotypes().size()) {
+ for (Stereotype stereotypeToBeApplied : stereotypeList.keySet()) {
+ for (Stereotype stereotypeApplied : ((Element) participants).getAppliedStereotypes()) {
+ if (EcoreUtil.equals(stereotypeToBeApplied, stereotypeApplied)) {
numberOfStereotypeMatching++;
}
}
}
- if(numberOfStereotypeMatching == numberOfStereotypeToBeApplied) {
+ if (numberOfStereotypeMatching == numberOfStereotypeToBeApplied) {
participantsToKeep.add(participants);
}
}
@@ -215,17 +219,17 @@ public class PapyrusAdvancedQuery extends AbstractPapyrusQuery { /**
* Evaluate if the value matches the pattern
- *
+ *
* @param value
- * the value to evaluate
+ * the value to evaluate
* @param attribute
- * the attribute has the value
+ * the attribute has the value
* @param pattern
- * the pattern that is searched
+ * the pattern that is searched
* @param participant
- * the element that contains the value
+ * the element that contains the value
* @param scopeEntry
- * the scopeEntry that contains the participant
+ * the scopeEntry that contains the participant
*/
protected void evaluateAndAddToResult(String value, Object attribute, Pattern pattern, Object participant, ScopeEntry scopeEntry, Stereotype stereotype) {
@@ -233,8 +237,8 @@ public class PapyrusAdvancedQuery extends AbstractPapyrusQuery { Matcher m = pattern.matcher(value);
- if(isRegularExpression) {
- if(m.matches()) {
+ if (isRegularExpression) {
+ if (m.matches()) {
int start = m.start();
int end = m.end();
ModelMatch match = new AttributeMatch(start, end, participant, scopeEntry, attribute, stereotype);
@@ -242,7 +246,7 @@ public class PapyrusAdvancedQuery extends AbstractPapyrusQuery { fResults.add(match);
}
} else {
- while(m.find()) {
+ while (m.find()) {
int start = m.start();
int end = m.end();
AttributeMatch match = new AttributeMatch(start, end, participant, scopeEntry, attribute, stereotype);
@@ -250,18 +254,18 @@ public class PapyrusAdvancedQuery extends AbstractPapyrusQuery { }
}
- // if(PatternHelper.getInstance().evaluate(m, isRegularExpression)) {
- // int start = m.start();
- // int end = m.end();
- // ModelMatch match = new AttributeMatch(start, end, participant, scopeEntry, attribute);
+ // if(PatternHelper.getInstance().evaluate(m, isRegularExpression)) {
+ // int start = m.start();
+ // int end = m.end();
+ // ModelMatch match = new AttributeMatch(start, end, participant, scopeEntry, attribute);
//
- // fResults.add(match);
- // }
+ // fResults.add(match);
+ // }
}
/**
* Try to find elements that match in the participants
- *
+ *
* @param participants
* @param scopeEntry
*/
@@ -269,23 +273,23 @@ public class PapyrusAdvancedQuery extends AbstractPapyrusQuery { protected void evaluate(Collection<EObject> participants, ScopeEntry scopeEntry) {
- for(EObject participant : participants) {
+ for (EObject participant : participants) {
- if(searchQueryText.equals("")) { //$NON-NLS-1$
+ if (searchQueryText.equals("")) { //$NON-NLS-1$
fResults.add(new ModelElementMatch(participant, scopeEntry));
} else {
String query = searchQueryText;
- if(searchQueryText.equals("")) { //$NON-NLS-1$
+ if (searchQueryText.equals("")) { //$NON-NLS-1$
query = ".*"; //$NON-NLS-1$
}
Pattern pattern = PatternHelper.getInstance().createPattern(query, isCaseSensitive, isRegularExpression);
- if(pattern != null) {
- if(participantsList.get(participant.eClass()).size() == 0) {
+ if (pattern != null) {
+ if (participantsList.get(participant.eClass()).size() == 0) {
attributesList = participant.eClass().getEAllAttributes();
@@ -297,12 +301,12 @@ public class PapyrusAdvancedQuery extends AbstractPapyrusQuery { }
- for(EAttribute attribute : attributesList) {
+ for (EAttribute attribute : attributesList) {
Object value = participant.eGet(attribute);
- if(value instanceof String) {
- String stringValue = (String)value;
+ if (value instanceof String) {
+ String stringValue = (String) value;
evaluateAndAddToResult(stringValue, attribute, pattern, participant, scopeEntry, null);
} else {
String stringValue = String.valueOf(value);
@@ -321,33 +325,33 @@ public class PapyrusAdvancedQuery extends AbstractPapyrusQuery { protected void evaluateStereotypes(Collection<EObject> participants, ScopeEntry scopeEntry) {
- for(EObject participant : participants) {
+ for (EObject participant : participants) {
- if(searchQueryText.equals("")) { //$NON-NLS-1$
+ if (searchQueryText.equals("")) { //$NON-NLS-1$
fResults.add(new ModelElementMatch(participant, scopeEntry));
} else {
String query = searchQueryText;
- if(searchQueryText.equals("")) { //$NON-NLS-1$
+ if (searchQueryText.equals("")) { //$NON-NLS-1$
query = ".*"; //$NON-NLS-1$
}
Pattern pattern = PatternHelper.getInstance().createPattern(query, isCaseSensitive, isRegularExpression);
- if(pattern != null) {
- EList<Stereotype> stereotypesApplied = ((Element)participant).getAppliedStereotypes();
- for(Stereotype stereotype : stereotypesApplied) {
- for(Stereotype stereotypeSelected : stereotypeList.keySet()) {
- if(EcoreUtil.equals(stereotype, stereotypeSelected)) {
- if(stereotypeList.get(stereotypeSelected).size() == 0) {
+ if (pattern != null) {
+ EList<Stereotype> stereotypesApplied = ((Element) participant).getAppliedStereotypes();
+ for (Stereotype stereotype : stereotypesApplied) {
+ for (Stereotype stereotypeSelected : stereotypeList.keySet()) {
+ if (EcoreUtil.equals(stereotype, stereotypeSelected)) {
+ if (stereotypeList.get(stereotypeSelected).size() == 0) {
propertyList = this.getStereotypesAttributes(stereotype);
- for(Property property : propertyList) {
+ for (Property property : propertyList) {
- Object value = ((Element)participant).getValue(stereotype, property.getName());
- if(value != null) {
- if(value instanceof String) {
- String stringValue = (String)value;
+ Object value = ((Element) participant).getValue(stereotype, property.getName());
+ if (value != null) {
+ if (value instanceof String) {
+ String stringValue = (String) value;
evaluateAndAddToResult(stringValue, property, pattern, participant, scopeEntry, stereotype);
} else {
String stringValue = String.valueOf(value);
@@ -357,13 +361,13 @@ public class PapyrusAdvancedQuery extends AbstractPapyrusQuery { }
} else {
propertyList = this.getStereotypesAttributes(stereotype);
- for(Property property : propertyList) {
- for(Property property2 : (stereotypeList.get(stereotypeSelected))) {
- if(EcoreUtil.equals(property, property2)) {
+ for (Property property : propertyList) {
+ for (Property property2 : (stereotypeList.get(stereotypeSelected))) {
+ if (EcoreUtil.equals(property, property2)) {
- String value = getStringValueOfProperty((Element)participant, stereotype, property);
+ String value = getStringValueOfProperty((Element) participant, stereotype, property);
- if(value != null) {
+ if (value != null) {
evaluateAndAddToResult(value, property, pattern, participant, scopeEntry, stereotype);
}
}
@@ -385,10 +389,10 @@ public class PapyrusAdvancedQuery extends AbstractPapyrusQuery { private String getStringValueOfProperty(Element element, Stereotype stereotype, Property property) {
Object value = element.getValue(stereotype, property.getName());
- if(value instanceof String) {
- return (String)value;
- } else if(value instanceof EnumerationLiteral) {
- return ((EnumerationLiteral)value).getName();
+ if (value instanceof String) {
+ return (String) value;
+ } else if (value instanceof EnumerationLiteral) {
+ return ((EnumerationLiteral) value).getName();
} else {
return String.valueOf(value);
}
@@ -396,14 +400,15 @@ public class PapyrusAdvancedQuery extends AbstractPapyrusQuery { public List<Property> getStereotypesAttributes(Object parentElement) {
List<Property> result = new ArrayList<Property>();
- if(parentElement instanceof Stereotype) {
+ if (parentElement instanceof Stereotype) {
- for(Property property : ((Stereotype)parentElement).getAllAttributes()) {
+ for (Property property : ((Stereotype) parentElement).getAllAttributes()) {
- if(!property.getName().startsWith("base_")) { //$NON-NLS-1$
- if(property.getType() instanceof Element) {
+ if (!property.getName().startsWith("base_")) { //$NON-NLS-1$
+ if (property.getType() instanceof Element) {
- if(UMLUtil.isBoolean(property.getType()) || UMLUtil.isString(property.getType()) || UMLUtil.isInteger(property.getType()) || UMLUtil.isReal(property.getType()) || UMLUtil.isUnlimitedNatural(property.getType()) || property.getType() instanceof Enumeration) {
+ if (UMLUtil.isBoolean(property.getType()) || UMLUtil.isString(property.getType()) || UMLUtil.isInteger(property.getType()) || UMLUtil.isReal(property.getType()) || UMLUtil.isUnlimitedNatural(property.getType())
+ || property.getType() instanceof Enumeration) {
result.add(property);
@@ -420,27 +425,27 @@ public class PapyrusAdvancedQuery extends AbstractPapyrusQuery { }
protected void findInDiagram(ScopeEntry scopeEntry) {
- //Now, find in diagram and others the elements we found
+ // Now, find in diagram and others the elements we found
ViewerSearchService viewerSearcherService = new ViewerSearchService();
try {
viewerSearcherService.startService();
- //Get sources elements that matched
+ // Get sources elements that matched
- for(AbstractResultEntry match : fResults) {
- if(match instanceof AttributeMatch) {
- sources.add(((AttributeMatch)match).getSource());
+ for (AbstractResultEntry match : fResults) {
+ if (match instanceof AttributeMatch) {
+ sources.add(((AttributeMatch) match).getSource());
} else {
sources.add(match.getSource());
}
}
- //Get viewer of these sources
+ // Get viewer of these sources
Map<Object, Map<Object, Object>> viewersMappings = viewerSearcherService.getViewers(sources, scopeEntry.getModelSet());
- //Add viewers to results
- for(Object containingModelSet : viewersMappings.keySet()) {
- for(Object view : viewersMappings.get(containingModelSet).keySet()) {
+ // Add viewers to results
+ for (Object containingModelSet : viewersMappings.keySet()) {
+ for (Object view : viewersMappings.get(containingModelSet).keySet()) {
Object semanticElement = viewersMappings.get(containingModelSet).get(view);
ViewerMatch viewMatch = new ViewerMatch(view, scopeEntry, semanticElement);
fResults.add(viewMatch);
@@ -465,7 +470,7 @@ public class PapyrusAdvancedQuery extends AbstractPapyrusQuery { }
public ISearchResult getSearchResult() {
- for(AbstractResultEntry match : fResults) {
+ for (AbstractResultEntry match : fResults) {
results.addMatch(match);
}
return results;
@@ -473,9 +478,10 @@ public class PapyrusAdvancedQuery extends AbstractPapyrusQuery { /**
* Getter for the text query
- *
+ *
* @return the the query text
*/
+ @Override
public String getSearchQueryText() {
return searchQueryText;
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/PapyrusOCLQuery.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/PapyrusOCLQuery.java index 54bdd408675..cb357cdbd1e 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/PapyrusOCLQuery.java +++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/PapyrusOCLQuery.java @@ -1,7 +1,7 @@ /*****************************************************************************
* Copyright (c) 2013, 2014 CEA LIST 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
@@ -65,9 +65,9 @@ import org.eclipse.xtext.resource.XtextResource; import org.eclipse.xtext.util.concurrent.IUnitOfWork;
/**
- *
+ *
* Papyrus specific search query
- *
+ *
*/
public class PapyrusOCLQuery extends AbstractPapyrusQuery {
@@ -105,7 +105,7 @@ public class PapyrusOCLQuery extends AbstractPapyrusQuery { protected boolean evaluate(final String expression) {
- if((expression == null) || (expression.trim().length() <= 0)) {
+ if ((expression == null) || (expression.trim().length() <= 0)) {
MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.PapyrusOCLQuery_0, Messages.PapyrusOCLQuery_1);
return false;
}
@@ -125,51 +125,51 @@ public class PapyrusOCLQuery extends AbstractPapyrusQuery { public Object exec(XtextResource state) throws Exception {
assert state != null;
IProgressService progressService = PlatformUI.getWorkbench().getProgressService();
- EvaluationRunnable runnable = new EvaluationRunnable((BaseResource)state, expression);
+ EvaluationRunnable runnable = new EvaluationRunnable((BaseResource) state, expression);
runnable.run(new NullProgressMonitor());
- // progressService.busyCursorWhile(runnable);
+ // progressService.busyCursorWhile(runnable);
return runnable.getValue();
}
});
} catch (Exception e) {
- // MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", e.getMessage());
+ // MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", e.getMessage());
}
- if(value instanceof InvalidValueException) {
- InvalidValueException exception = (InvalidValueException)value;
- // MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", exception.getMessage());
+ if (value instanceof InvalidValueException) {
+ InvalidValueException exception = (InvalidValueException) value;
+ // MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", exception.getMessage());
Throwable cause = exception.getCause();
- if((cause != null) && (cause != exception)) {
- // MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", cause.getMessage());
+ if ((cause != null) && (cause != exception)) {
+ // MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", cause.getMessage());
}
- } else if(value != null) {
+ } else if (value != null) {
CollectionValue collectionValue = ValuesUtil.isCollectionValue(value);
- if(collectionValue != null) {
- for(Object elementValue : collectionValue.iterable()) {
- if(elementValue instanceof EObject) {
+ if (collectionValue != null) {
+ for (Object elementValue : collectionValue.iterable()) {
+ if (elementValue instanceof EObject) {
ModelMatch match = new ModelElementMatch(elementValue, scopeEntry);
fResults.add(match);
}
- // System.err.println("Found : " + ValuesUtil.stringValueOf(elementValue));
+ // System.err.println("Found : " + ValuesUtil.stringValueOf(elementValue));
}
} else {
- if(value instanceof EObject) {
+ if (value instanceof EObject) {
ModelMatch match = new ModelElementMatch(value, scopeEntry);
fResults.add(match);
}
- // System.err.println("Found : " + ValuesUtil.stringValueOf(value));
+ // System.err.println("Found : " + ValuesUtil.stringValueOf(value));
}
} else {
- // MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", ValuesUtil.stringValueOf(value));
+ // MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", ValuesUtil.stringValueOf(value));
}
} catch (Exception e) {
result = false;
- if(e.getLocalizedMessage() == null) {
- // MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", e.getClass().getName());
+ if (e.getLocalizedMessage() == null) {
+ // MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", e.getClass().getName());
} else {
- // MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", e.getLocalizedMessage());
+ // MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", e.getLocalizedMessage());
}
}
@@ -207,7 +207,7 @@ public class PapyrusOCLQuery extends AbstractPapyrusQuery { value = new InvalidValueException(e, ConsoleMessages.Result_ParsingFailure);
return;
}
- if(expressionInOCL != null) {
+ if (expressionInOCL != null) {
// monitor.worked(2);
monitor.subTask(ConsoleMessages.Progress_Extent);
PivotEnvironmentFactory envFactory = new PivotEnvironmentFactory(null, metaModelManager);
@@ -224,17 +224,17 @@ public class PapyrusOCLQuery extends AbstractPapyrusQuery { try {
// metaModelManager.setMonitor(monitor);
CancelableEvaluationVisitor evaluationVisitor = new CancelableEvaluationVisitor(monitor, environment, evaluationEnvironment, modelManager2);
- // evaluationVisitor.setLogger(new DomainLogger() {
+ // evaluationVisitor.setLogger(new DomainLogger() {
//
- // public void append(final @NonNull String message) {
- // OCLConsolePage.this.getControl().getDisplay().asyncExec(new Runnable() {
+ // public void append(final @NonNull String message) {
+ // OCLConsolePage.this.getControl().getDisplay().asyncExec(new Runnable() {
//
- // public void run() {
- // OCLConsolePage.this.append(message, ColorManager.DEFAULT, false);
- // }
- // });
- // }
- // });
+ // public void run() {
+ // OCLConsolePage.this.append(message, ColorManager.DEFAULT, false);
+ // }
+ // });
+ // }
+ // });
value = evaluationVisitor.visitExpressionInOCL(expressionInOCL);
} catch (InvalidValueException e) {
value = e;
@@ -285,17 +285,17 @@ public class PapyrusOCLQuery extends AbstractPapyrusQuery { /**
* Evaluate if the value matches the pattern
- *
+ *
* @param value
- * the value to evaluate
+ * the value to evaluate
* @param attribute
- * the attribute has the value
+ * the attribute has the value
* @param pattern
- * the pattern that is searched
+ * the pattern that is searched
* @param participant
- * the element that contains the value
+ * the element that contains the value
* @param scopeEntry
- * the scopeEntry that contains the participant
+ * the scopeEntry that contains the participant
*/
protected void evaluateAndAddToResult(String value, Object attribute, Pattern pattern, Object participant, ScopeEntry scopeEntry) {
@@ -303,117 +303,117 @@ public class PapyrusOCLQuery extends AbstractPapyrusQuery { Matcher m = pattern.matcher(value);
- // if(isRegularExpression) {
- // if(m.matches()) {
- // int start = m.start();
- // int end = m.end();
- // ModelMatch match = new AttributeMatch(start, end, participant, scopeEntry, attribute);
+ // if(isRegularExpression) {
+ // if(m.matches()) {
+ // int start = m.start();
+ // int end = m.end();
+ // ModelMatch match = new AttributeMatch(start, end, participant, scopeEntry, attribute);
//
- // fResults.add(match);
- // }
- // } else {
- // while(m.find()) {
- // int start = m.start();
- // int end = m.end();
- // AttributeMatch match = new AttributeMatch(start, end, participant, scopeEntry, attribute);
- // fResults.add(match);
- // }
- // }
+ // fResults.add(match);
+ // }
+ // } else {
+ // while(m.find()) {
+ // int start = m.start();
+ // int end = m.end();
+ // AttributeMatch match = new AttributeMatch(start, end, participant, scopeEntry, attribute);
+ // fResults.add(match);
+ // }
+ // }
}
/**
* Try to find elements that match in the participants
- *
+ *
* @param participants
* @param scopeEntry
*/
protected void evaluate(Collection<EObject> participants, ScopeEntry scopeEntry) {
- // for(EObject participant : participants) {
+ // for(EObject participant : participants) {
//
- // String query = searchQueryText;
+ // String query = searchQueryText;
// if(searchQueryText.equals("")) { //$NON-NLS-1$
// query = ".*"; //$NON-NLS-1$
- // }
+ // }
//
- // Pattern pattern = PatternHelper.getInstance().createPattern(query, isCaseSensitive, isRegularExpression);
+ // Pattern pattern = PatternHelper.getInstance().createPattern(query, isCaseSensitive, isRegularExpression);
//
- // if(pattern != null) {
- // if(searchAllStringAttributes) {
+ // if(pattern != null) {
+ // if(searchAllStringAttributes) {
//
- // for(EAttribute attribute : participant.eClass().getEAllAttributes()) {
- // Object value = participant.eGet(attribute);
+ // for(EAttribute attribute : participant.eClass().getEAllAttributes()) {
+ // Object value = participant.eGet(attribute);
//
- // if(value instanceof String) {
- // String stringValue = (String)value;
- // evaluateAndAddToResult(stringValue, attribute, pattern, participant, scopeEntry);
- // }
- // }
+ // if(value instanceof String) {
+ // String stringValue = (String)value;
+ // evaluateAndAddToResult(stringValue, attribute, pattern, participant, scopeEntry);
+ // }
+ // }
//
- // } else {
- // if(participant instanceof NamedElement) {
- // String umlElementName = ((NamedElement)participant).getName();
+ // } else {
+ // if(participant instanceof NamedElement) {
+ // String umlElementName = ((NamedElement)participant).getName();
// umlElementName = umlElementName != null ? umlElementName : ""; //$NON-NLS-1$
//
- // evaluateAndAddToResult(umlElementName, UMLPackage.eINSTANCE.getNamedElement_Name(), pattern, participant, scopeEntry);
- // }
- // }
- // if(searchStereotypeAttributes) {
- // if(participant instanceof Element) {
- // EList<Stereotype> stereotypes = ((Element)participant).getAppliedStereotypes();
- // for(Stereotype stereotype : stereotypes) {
- // for(Property stereotypeProperty : stereotype.getAllAttributes()) {
- // if(!stereotypeProperty.getName().startsWith("base_")) {
- // Object value = ((Element)participant).getValue(stereotype, stereotypeProperty.getName());
- // if(value != null) {
+ // evaluateAndAddToResult(umlElementName, UMLPackage.eINSTANCE.getNamedElement_Name(), pattern, participant, scopeEntry);
+ // }
+ // }
+ // if(searchStereotypeAttributes) {
+ // if(participant instanceof Element) {
+ // EList<Stereotype> stereotypes = ((Element)participant).getAppliedStereotypes();
+ // for(Stereotype stereotype : stereotypes) {
+ // for(Property stereotypeProperty : stereotype.getAllAttributes()) {
+ // if(!stereotypeProperty.getName().startsWith("base_")) {
+ // Object value = ((Element)participant).getValue(stereotype, stereotypeProperty.getName());
+ // if(value != null) {
//
- // if(value instanceof String) {
- // String stringValue = (String)value;
- // evaluateAndAddToResult(stringValue, stereotypeProperty, pattern, participant, scopeEntry);
- // }
- // }
- // }
- // }
+ // if(value instanceof String) {
+ // String stringValue = (String)value;
+ // evaluateAndAddToResult(stringValue, stereotypeProperty, pattern, participant, scopeEntry);
+ // }
+ // }
+ // }
+ // }
//
- // }
- // }
- // }
+ // }
+ // }
+ // }
//
- // }
- // }
+ // }
+ // }
//
- // //Now, find in diagram and others the elements we found
- // ViewerSearchService viewerSearcherService = new ViewerSearchService();
- // try {
- // viewerSearcherService.startService();
+ // //Now, find in diagram and others the elements we found
+ // ViewerSearchService viewerSearcherService = new ViewerSearchService();
+ // try {
+ // viewerSearcherService.startService();
//
- // //Get sources elements that matched
- // Set<Object> sources = new HashSet<Object>();
- // for(AbstractResultEntry match : fResults) {
- // if(match instanceof AttributeMatch) {
- // sources.add(((AttributeMatch)match).getTarget());
- // } else {
- // sources.add(match.getSource());
- // }
- // }
+ // //Get sources elements that matched
+ // Set<Object> sources = new HashSet<Object>();
+ // for(AbstractResultEntry match : fResults) {
+ // if(match instanceof AttributeMatch) {
+ // sources.add(((AttributeMatch)match).getTarget());
+ // } else {
+ // sources.add(match.getSource());
+ // }
+ // }
//
- // //Get viewer of these sources
- // Map<Object, Map<Object, Object>> viewersMappings = viewerSearcherService.getViewers(sources, scopeEntry.getModelSet());
+ // //Get viewer of these sources
+ // Map<Object, Map<Object, Object>> viewersMappings = viewerSearcherService.getViewers(sources, scopeEntry.getModelSet());
//
- // //Add viewers to results
- // for(Object containingModelSet : viewersMappings.keySet()) {
- // for(Object view : viewersMappings.get(containingModelSet).keySet()) {
- // Object semanticElement = viewersMappings.get(containingModelSet).get(view);
- // ViewerMatch viewMatch = new ViewerMatch(view, scopeEntry, semanticElement);
- // fResults.add(viewMatch);
- // }
- // }
+ // //Add viewers to results
+ // for(Object containingModelSet : viewersMappings.keySet()) {
+ // for(Object view : viewersMappings.get(containingModelSet).keySet()) {
+ // Object semanticElement = viewersMappings.get(containingModelSet).get(view);
+ // ViewerMatch viewMatch = new ViewerMatch(view, scopeEntry, semanticElement);
+ // fResults.add(viewMatch);
+ // }
+ // }
//
- // } catch (ServiceException e) {
- // Activator.log.error(Messages.PapyrusQuery_5 + scopeEntry.getModelSet(), e);
- // }
+ // } catch (ServiceException e) {
+ // Activator.log.error(Messages.PapyrusQuery_5 + scopeEntry.getModelSet(), e);
+ // }
}
public String getLabel() {
@@ -429,7 +429,7 @@ public class PapyrusOCLQuery extends AbstractPapyrusQuery { }
public ISearchResult getSearchResult() {
- for(AbstractResultEntry match : fResults) {
+ for (AbstractResultEntry match : fResults) {
results.addMatch(match);
}
return results;
@@ -437,11 +437,12 @@ public class PapyrusOCLQuery extends AbstractPapyrusQuery { /**
* Getter for the text query
- *
+ *
* @return the the query text
*/
+ @Override
public String getSearchQueryText() {
- if(queryEditorDocument.get().length() > 25) {
+ if (queryEditorDocument.get().length() > 25) {
return queryEditorDocument.get().subSequence(0, 25) + "..."; //$NON-NLS-1$
} else {
return queryEditorDocument.get();
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/PapyrusQuery.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/PapyrusQuery.java index ec6dfd20d77..89ee62ffc21 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/PapyrusQuery.java +++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/PapyrusQuery.java @@ -1,7 +1,7 @@ /*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
+ * Copyright (c) 2013 CEA LIST.
+ *
*
- *
* 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
@@ -49,16 +49,18 @@ import org.eclipse.uml2.uml.Stereotype; import org.eclipse.uml2.uml.UMLPackage;
/**
- *
+ *
* Papyrus specific search query
- *
+ *
*/
public class PapyrusQuery extends AbstractPapyrusQuery {
+ @Override
public boolean isCaseSensitive() {
return isCaseSensitive;
}
+ @Override
public boolean isRegularExpression() {
return isRegularExpression;
}
@@ -97,12 +99,12 @@ public class PapyrusQuery extends AbstractPapyrusQuery { results.removeAll();
fResults.clear();
- for(ScopeEntry scopeEntry : scopeEntries) {
+ for (ScopeEntry scopeEntry : scopeEntries) {
try {
- if(scopeEntry.getModelSet() != null) {
+ if (scopeEntry.getModelSet() != null) {
- UmlModel umlModel = (UmlModel)scopeEntry.getModelSet().getModelChecked(UmlModel.MODEL_ID);
+ UmlModel umlModel = (UmlModel) scopeEntry.getModelSet().getModelChecked(UmlModel.MODEL_ID);
EObject root = umlModel.lookupRoot();
@@ -121,17 +123,17 @@ public class PapyrusQuery extends AbstractPapyrusQuery { /**
* Evaluate if the value matches the pattern
- *
+ *
* @param value
- * the value to evaluate
+ * the value to evaluate
* @param attribute
- * the attribute has the value
+ * the attribute has the value
* @param pattern
- * the pattern that is searched
+ * the pattern that is searched
* @param participant
- * the element that contains the value
+ * the element that contains the value
* @param scopeEntry
- * the scopeEntry that contains the participant
+ * the scopeEntry that contains the participant
*/
protected void evaluateAndAddToResult(String value, Object attribute, Pattern pattern, Object participant, ScopeEntry scopeEntry, Stereotype stereotype) {
@@ -139,8 +141,8 @@ public class PapyrusQuery extends AbstractPapyrusQuery { Matcher m = pattern.matcher(value);
- if(isRegularExpression) {
- if(m.matches()) {
+ if (isRegularExpression) {
+ if (m.matches()) {
int start = m.start();
int end = m.end();
ModelMatch match = new AttributeMatch(start, end, participant, scopeEntry, attribute, stereotype);
@@ -148,7 +150,7 @@ public class PapyrusQuery extends AbstractPapyrusQuery { fResults.add(match);
}
} else {
- while(m.find()) {
+ while (m.find()) {
int start = m.start();
int end = m.end();
AttributeMatch match = new AttributeMatch(start, end, participant, scopeEntry, attribute, stereotype);
@@ -156,53 +158,53 @@ public class PapyrusQuery extends AbstractPapyrusQuery { }
}
- // if(PatternHelper.getInstance().evaluate(m, isRegularExpression)) {
- // int start = m.start();
- // int end = m.end();
- // ModelMatch match = new AttributeMatch(start, end, participant, scopeEntry, attribute);
+ // if(PatternHelper.getInstance().evaluate(m, isRegularExpression)) {
+ // int start = m.start();
+ // int end = m.end();
+ // ModelMatch match = new AttributeMatch(start, end, participant, scopeEntry, attribute);
//
- // fResults.add(match);
- // }
+ // fResults.add(match);
+ // }
}
/**
* Try to find elements that match in the participants
- *
+ *
* @param participants
* @param scopeEntry
*/
protected void evaluate(Collection<EObject> participants, ScopeEntry scopeEntry) {
- for(EObject participant : participants) {
+ for (EObject participant : participants) {
String query = searchQueryText;
- if(searchQueryText.equals("")) { //$NON-NLS-1$
+ if (searchQueryText.equals("")) { //$NON-NLS-1$
query = ".*"; //$NON-NLS-1$
}
Pattern pattern = PatternHelper.getInstance().createPattern(query, isCaseSensitive, isRegularExpression);
- if(pattern != null) {
- if(searchAllStringAttributes) {
+ if (pattern != null) {
+ if (searchAllStringAttributes) {
- for(EAttribute attribute : participant.eClass().getEAllAttributes()) {
+ for (EAttribute attribute : participant.eClass().getEAllAttributes()) {
Object value = participant.eGet(attribute);
- if(value instanceof String) {
- String stringValue = (String)value;
+ if (value instanceof String) {
+ String stringValue = (String) value;
evaluateAndAddToResult(stringValue, attribute, pattern, participant, scopeEntry, null);
}
}
- if(participant instanceof Element) {
- EList<Stereotype> stereotypes = ((Element)participant).getAppliedStereotypes();
- for(Stereotype stereotype : stereotypes) {
- for(Property stereotypeProperty : stereotype.getAllAttributes()) {
- if(!stereotypeProperty.getName().startsWith("base_")) { //$NON-NLS-1$
- Object value = ((Element)participant).getValue(stereotype, stereotypeProperty.getName());
+ if (participant instanceof Element) {
+ EList<Stereotype> stereotypes = ((Element) participant).getAppliedStereotypes();
+ for (Stereotype stereotype : stereotypes) {
+ for (Property stereotypeProperty : stereotype.getAllAttributes()) {
+ if (!stereotypeProperty.getName().startsWith("base_")) { //$NON-NLS-1$
+ Object value = ((Element) participant).getValue(stereotype, stereotypeProperty.getName());
- if(value instanceof String) {
- String stringValue = (String)value;
+ if (value instanceof String) {
+ String stringValue = (String) value;
evaluateAndAddToResult(stringValue, stereotypeProperty, pattern, participant, scopeEntry, stereotype);
}
}
@@ -211,8 +213,8 @@ public class PapyrusQuery extends AbstractPapyrusQuery { }
} else {
- if(participant instanceof NamedElement) {
- String umlElementName = ((NamedElement)participant).getName();
+ if (participant instanceof NamedElement) {
+ String umlElementName = ((NamedElement) participant).getName();
umlElementName = umlElementName != null ? umlElementName : ""; //$NON-NLS-1$
evaluateAndAddToResult(umlElementName, UMLPackage.eINSTANCE.getNamedElement_Name(), pattern, participant, scopeEntry, null);
@@ -223,27 +225,27 @@ public class PapyrusQuery extends AbstractPapyrusQuery { }
}
- // Now, find in diagram and others the elements we found
+ // Now, find in diagram and others the elements we found
ViewerSearchService viewerSearcherService = new ViewerSearchService();
try {
viewerSearcherService.startService();
- //Get sources elements that matched
+ // Get sources elements that matched
Set<Object> sources = new HashSet<Object>();
- for(AbstractResultEntry match : fResults) {
- if(match instanceof AttributeMatch) {
- sources.add(((AttributeMatch)match).getSource());
+ for (AbstractResultEntry match : fResults) {
+ if (match instanceof AttributeMatch) {
+ sources.add(((AttributeMatch) match).getSource());
} else {
sources.add(match.getSource());
}
}
- //Get viewer of these sources
+ // Get viewer of these sources
Map<Object, Map<Object, Object>> viewersMappings = viewerSearcherService.getViewers(sources, scopeEntry.getModelSet());
- //Add viewers to results
- for(Object containingModelSet : viewersMappings.keySet()) {
- for(Object view : viewersMappings.get(containingModelSet).keySet()) {
+ // Add viewers to results
+ for (Object containingModelSet : viewersMappings.keySet()) {
+ for (Object view : viewersMappings.get(containingModelSet).keySet()) {
Object semanticElement = viewersMappings.get(containingModelSet).get(view);
ViewerMatch viewMatch = new ViewerMatch(view, scopeEntry, semanticElement);
fResults.add(viewMatch);
@@ -273,7 +275,7 @@ public class PapyrusQuery extends AbstractPapyrusQuery { }
public ISearchResult getSearchResult() {
- for(AbstractResultEntry match : fResults) {
+ for (AbstractResultEntry match : fResults) {
results.addMatch(match);
}
return results;
@@ -281,9 +283,10 @@ public class PapyrusQuery extends AbstractPapyrusQuery { /**
* Getter for the text query
- *
+ *
* @return the the query text
*/
+ @Override
public String getSearchQueryText() {
return searchQueryText;
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/QueryInfo.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/QueryInfo.java index 9f1d79c69d5..5e5c168038b 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/QueryInfo.java +++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/QueryInfo.java @@ -1,6 +1,6 @@ /***************************************************************************** * Copyright (c) 2013 CEA LIST 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 @@ -32,30 +32,30 @@ public class QueryInfo { private boolean searchAllStringAttributes; private Collection<? extends ParticipantTypeElement> participantTypes; - + private boolean searchForAllSter; private Collection<URI> scope; /** * Creates a query info for simple query. - * + * * @param queryText - * the user-supplied search query text + * the user-supplied search query text * @param caseSensitive - * whether the {@code queryText} is to be applied in case-sensitive fashion + * whether the {@code queryText} is to be applied in case-sensitive fashion * @param regularExpression - * whether the {@code queryText} is to be taken as a regular expression + * whether the {@code queryText} is to be taken as a regular expression * @param searchAllStringAttributes - * whether to search all string attributes of UML metaclasses ({@code true}), or just named element {@linkplain NamedElement#getName() - * names} ({@code false}) + * whether to search all string attributes of UML metaclasses ({@code true}), or just named element {@linkplain NamedElement#getName() + * names} ({@code false}) * @param scope - * the domain-specific search scope + * the domain-specific search scope */ public QueryInfo(String queryText, boolean caseSensitive, boolean regularExpression, boolean searchAllStringAttributes, Collection<URI> scope) { super(); - + this.queryText = queryText; this.caseSensitive = caseSensitive; this.regularExpression = regularExpression; @@ -66,21 +66,21 @@ public class QueryInfo { /** * Creates a query info for advanced query. - * + * * @param queryText - * the user-supplied search query text + * the user-supplied search query text * @param caseSensitive - * whether the {@code queryText} is to be applied in case-sensitive fashion + * whether the {@code queryText} is to be applied in case-sensitive fashion * @param regularExpression - * whether the {@code queryText} is to be taken as a regular expression + * whether the {@code queryText} is to be taken as a regular expression * @param participantTypes - * the participant types (identifying specific metaclasses and/or attributes) to include in the search + * the participant types (identifying specific metaclasses and/or attributes) to include in the search * @param searchForAllSter - * stereotype application must all applied or not + * stereotype application must all applied or not * @param scope - * the domain-specific search scope + * the domain-specific search scope */ - public QueryInfo(String queryText, boolean caseSensitive, boolean regularExpression, Collection<? extends ParticipantTypeElement> participantTypes, Collection<URI> scope,boolean searchForAllSter) { + public QueryInfo(String queryText, boolean caseSensitive, boolean regularExpression, Collection<? extends ParticipantTypeElement> participantTypes, Collection<URI> scope, boolean searchForAllSter) { super(); this.queryText = queryText; @@ -91,7 +91,7 @@ public class QueryInfo { this.scope = scope; this.searchForAllSter = searchForAllSter; } - + /** * Partition copy constructor. */ @@ -130,7 +130,7 @@ public class QueryInfo { public Collection<URI> getScope() { return scope; } - + public boolean isSearchForAllSter() { return searchForAllSter; } @@ -138,11 +138,12 @@ public class QueryInfo { /** * Creates a new instance encapsulating query parameters for the specified partition (strict subset) of my {@linkplain #getScope() scope}. - * - * @param scopePartition a partition of my scope - * + * + * @param scopePartition + * a partition of my scope + * * @return the partition query info - * + * * @see #getScope() */ public QueryInfo partition(Collection<URI> scopePartition) { diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/WorkspaceQueryProvider.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/WorkspaceQueryProvider.java index 5296eec748d..f7517b3be84 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/WorkspaceQueryProvider.java +++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/WorkspaceQueryProvider.java @@ -1,6 +1,6 @@ /***************************************************************************** * Copyright (c) 2013 CEA LIST 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 @@ -9,7 +9,7 @@ * Contributors: * CEA LIST - Initial API and implementation * Christian W. Damus (CEA LIST) - Extracted portions of the PapyrusSearchPage code. - * + * *****************************************************************************/ package org.eclipse.papyrus.uml.search.ui.query; @@ -51,15 +51,15 @@ public class WorkspaceQueryProvider implements IPapyrusQueryProvider { public AbstractPapyrusQuery createAdvancedSearchQuery(QueryInfo queryInfo) { Collection<ScopeEntry> scopeEntries = createScopeEntries(queryInfo.getScope()); - return new PapyrusAdvancedQuery(queryInfo.getQueryText(), queryInfo.isCaseSensitive(), queryInfo.isRegularExpression(), scopeEntries, queryInfo.getParticipantTypes().toArray(),queryInfo.isSearchForAllSter()); + return new PapyrusAdvancedQuery(queryInfo.getQueryText(), queryInfo.isCaseSensitive(), queryInfo.isRegularExpression(), scopeEntries, queryInfo.getParticipantTypes().toArray(), queryInfo.isSearchForAllSter()); } private void initMetaClasses() { // the UML metamodel doesn't change once we have scraped it - if(umlMetaClasses.isEmpty()) { - for(EClassifier eClassifier : UMLPackage.eINSTANCE.getEClassifiers()) { - if(eClassifier instanceof EClass) { + if (umlMetaClasses.isEmpty()) { + for (EClassifier eClassifier : UMLPackage.eINSTANCE.getEClassifiers()) { + if (eClassifier instanceof EClass) { umlMetaClasses.add(eClassifier); } } @@ -68,14 +68,14 @@ public class WorkspaceQueryProvider implements IPapyrusQueryProvider { /** * Create scopeEntries based on URIs. - * + * * @return the created scopeEntries */ public static Collection<ScopeEntry> createScopeEntries(Collection<URI> scope) { IServiceRegistryTracker tracker = createServiceRegistryTracker(); Collection<ScopeEntry> results = new HashSet<ScopeEntry>(); - for(URI uri : scope) { + for (URI uri : scope) { ScopeEntry scopeEntry = new ScopeEntry(uri, tracker); diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/results/PapyrusSearchResult.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/results/PapyrusSearchResult.java index 0afcb88d95d..51ca09f4050 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/results/PapyrusSearchResult.java +++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/results/PapyrusSearchResult.java @@ -1,7 +1,7 @@ /*****************************************************************************
* Copyright (c) 2013 CEA LIST 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
@@ -9,7 +9,7 @@ *
* Contributors:
* CEA LIST - Initial API and implementation
- * Christian W. Damus (CEA LIST) - Replace workspace IResource dependency with URI for CDO compatibility
+ * Christian W. Damus (CEA LIST) - Replace workspace IResource dependency with URI for CDO compatibility
*
*****************************************************************************/
package org.eclipse.papyrus.uml.search.ui.results;
@@ -48,7 +48,6 @@ import org.eclipse.search.ui.text.IFileMatchAdapter; import org.eclipse.search.ui.text.Match;
import org.eclipse.search.ui.text.MatchFilter;
import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.ide.ResourceUtil;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.EnumerationLiteral;
import org.eclipse.uml2.uml.Property;
@@ -111,10 +110,10 @@ public class PapyrusSearchResult extends AbstractTextSearchResult implements IEd Set<Match> results = new HashSet<Match>();
Set<AbstractResultEntry> allMatches = MatchUtils.getMatches(result, true);
- for(AbstractResultEntry modelMatch : allMatches) {
+ for (AbstractResultEntry modelMatch : allMatches) {
Object element = modelMatch.getElement();
- if(element instanceof ScopeEntry) {
- if(file.equals(getWorkspaceResource((ScopeEntry) element))) {
+ if (element instanceof ScopeEntry) {
+ if (file.equals(getWorkspaceResource((ScopeEntry) element))) {
results.add(modelMatch);
}
}
@@ -128,29 +127,29 @@ public class PapyrusSearchResult extends AbstractTextSearchResult implements IEd IResource result = null;
URI uri = scopeEntry.getResourceURI();
- if((uri != null) && uri.isPlatformResource()) {
+ if ((uri != null) && uri.isPlatformResource()) {
String path = uri.toPlatformString(true);
result = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
}
return result;
}
-
+
public IFile getFile(Object element) {
- if(element instanceof ScopeEntry) {
+ if (element instanceof ScopeEntry) {
IResource resource = getWorkspaceResource((ScopeEntry) element);
- if(resource instanceof IFile) {
- return (IFile)resource;
+ if (resource instanceof IFile) {
+ return (IFile) resource;
}
}
return null;
}
public boolean isShownInEditor(Match match, IEditorPart editor) {
- if(match instanceof AbstractResultEntry) {
+ if (match instanceof AbstractResultEntry) {
Object element = match.getElement();
- if(element instanceof ScopeEntry) {
- if(Objects.equal(EditorUtils.getResourceURI(editor), ((ScopeEntry) element).getResourceURI())) {
+ if (element instanceof ScopeEntry) {
+ if (Objects.equal(EditorUtils.getResourceURI(editor), ((ScopeEntry) element).getResourceURI())) {
return true;
}
}
@@ -165,91 +164,91 @@ public class PapyrusSearchResult extends AbstractTextSearchResult implements IEd Match[] matchList = super.getMatches(element);
Set<Match> matchToKeep = new HashSet<Match>();
List<Object> sourceList = new ArrayList<Object>();
- // Get matches which are still true
- for(Match match : matchList) {
- if(match instanceof AbstractResultEntry) {
- if(((AbstractResultEntry)match).getSource() != null) {
- if(match instanceof AttributeMatch) {
- Object attribute = ((AttributeMatch)match).getMetaAttribute();
+ // Get matches which are still true
+ for (Match match : matchList) {
+ if (match instanceof AbstractResultEntry) {
+ if (((AbstractResultEntry) match).getSource() != null) {
+ if (match instanceof AttributeMatch) {
+ Object attribute = ((AttributeMatch) match).getMetaAttribute();
String value = null;
- EObject target = (EObject)((AbstractResultEntry)match).getSource();
- if(attribute instanceof EAttribute) {
+ EObject target = (EObject) ((AbstractResultEntry) match).getSource();
+ if (attribute instanceof EAttribute) {
- value = String.valueOf(target.eGet((EStructuralFeature)attribute));
- } else if(attribute instanceof Property) {
+ value = String.valueOf(target.eGet((EStructuralFeature) attribute));
+ } else if (attribute instanceof Property) {
- value = getStringValueOfProperty((Element)((AbstractResultEntry)match).getSource(), ((AttributeMatch)match).getStereotype(), ((Property)attribute));
+ value = getStringValueOfProperty((Element) ((AbstractResultEntry) match).getSource(), ((AttributeMatch) match).getStereotype(), ((Property) attribute));
}
- if(value != null && !this.getQuery().isRegularExpression()) {
- if(value.length() >= match.getLength() - match.getOffset()) {
+ if (value != null && !this.getQuery().isRegularExpression()) {
+ if (value.length() >= match.getLength() - match.getOffset()) {
int end = match.getOffset() + match.getLength();
value = value.substring(match.getOffset(), end);
- if(this.searchQuery.isCaseSensitive()) {
- if(value.equals(this.searchQuery.getSearchQueryText())) {
- ((AbstractResultEntry)match).recursiveHierarchy((AbstractResultEntry)((AbstractResultEntry)match).getParent());
+ if (this.searchQuery.isCaseSensitive()) {
+ if (value.equals(this.searchQuery.getSearchQueryText())) {
+ ((AbstractResultEntry) match).recursiveHierarchy((AbstractResultEntry) ((AbstractResultEntry) match).getParent());
matchToKeep.add(match);
- sourceList.add(((AbstractResultEntry)match).getSource());
+ sourceList.add(((AbstractResultEntry) match).getSource());
}
} else {
- if(value.equalsIgnoreCase(this.searchQuery.getSearchQueryText())) {
+ if (value.equalsIgnoreCase(this.searchQuery.getSearchQueryText())) {
- ((AbstractResultEntry)match).recursiveHierarchy((AbstractResultEntry)((AbstractResultEntry)match).getParent());
+ ((AbstractResultEntry) match).recursiveHierarchy((AbstractResultEntry) ((AbstractResultEntry) match).getParent());
matchToKeep.add(match);
- sourceList.add(((AbstractResultEntry)match).getSource());
+ sourceList.add(((AbstractResultEntry) match).getSource());
}
}
}
- } else if(this.getQuery().isRegularExpression()) {
- if(this.getQuery().getSearchQueryText() != null) {
+ } else if (this.getQuery().isRegularExpression()) {
+ if (this.getQuery().getSearchQueryText() != null) {
Pattern pattern = PatternHelper.getInstance().createPattern(this.getQuery().getSearchQueryText(), false, true);
Matcher m = pattern.matcher(value);
- if(m.matches()) {
+ if (m.matches()) {
int start = m.start();
int end = m.end();
- if(start == match.getOffset() && end == match.getOffset() + match.getLength()) {
+ if (start == match.getOffset() && end == match.getOffset() + match.getLength()) {
matchToKeep.add(match);
- sourceList.add(((AbstractResultEntry)match).getSource());
+ sourceList.add(((AbstractResultEntry) match).getSource());
}
}
}
}
- } else if(match instanceof ModelElementMatch) {
- ((AbstractResultEntry)match).recursiveHierarchy((AbstractResultEntry)match);
+ } else if (match instanceof ModelElementMatch) {
+ ((AbstractResultEntry) match).recursiveHierarchy((AbstractResultEntry) match);
matchToKeep.add(match);
- sourceList.add(((AbstractResultEntry)match).getSource());
+ sourceList.add(((AbstractResultEntry) match).getSource());
}
}
}
}
// Now get Viewer
- for(Match match : matchList) {
- if(match instanceof ViewerMatch) {
- Object source = ((ViewerMatch)match).getSemanticElement();
- if(sourceList.contains(source)) {
+ for (Match match : matchList) {
+ if (match instanceof ViewerMatch) {
+ Object source = ((ViewerMatch) match).getSemanticElement();
+ if (sourceList.contains(source)) {
matchToKeep.add(match);
}
}
}
- return (Match[])matchToKeep.toArray(new Match[matchToKeep.size()]);
- // return ((PapyrusQuery)searchQuery).getfResults().toArray(new Match[matchToKeep.size()]);
+ return matchToKeep.toArray(new Match[matchToKeep.size()]);
+ // return ((PapyrusQuery)searchQuery).getfResults().toArray(new Match[matchToKeep.size()]);
//
}
public Match[] computeContainedMatches(AbstractTextSearchResult result, IEditorPart editor) {
Set<Object> results = new HashSet<Object>();
Set<AbstractResultEntry> allMatches = MatchUtils.getMatches(result, true);
- for(AbstractResultEntry modelMatch : allMatches) {
+ for (AbstractResultEntry modelMatch : allMatches) {
Object element = modelMatch.getElement();
- if(element instanceof ScopeEntry) {
- if(((ScopeEntry)element).getResourceURI().equals(EditorUtils.getResourceURI(editor))) {
+ if (element instanceof ScopeEntry) {
+ if (((ScopeEntry) element).getResourceURI().equals(EditorUtils.getResourceURI(editor))) {
results.add(modelMatch);
}
}
@@ -265,11 +264,12 @@ public class PapyrusSearchResult extends AbstractTextSearchResult implements IEd List<Object> elementList = Arrays.asList(this.getElements());
int count = 0;
- for(Object element : elementList) {
+ for (Object element : elementList) {
- for(Match match : this.getMatches(element)) {
- if(match instanceof ModelMatch || match instanceof ViewerMatch)
+ for (Match match : this.getMatches(element)) {
+ if (match instanceof ModelMatch || match instanceof ViewerMatch) {
count++;
+ }
}
}
@@ -278,10 +278,10 @@ public class PapyrusSearchResult extends AbstractTextSearchResult implements IEd private String getStringValueOfProperty(Element element, Stereotype stereotype, Property property) {
Object value = element.getValue(stereotype, property.getName());
- if(value instanceof String) {
- return (String)value;
- } else if(value instanceof EnumerationLiteral) {
- return ((EnumerationLiteral)value).getName();
+ if (value instanceof String) {
+ return (String) value;
+ } else if (value instanceof EnumerationLiteral) {
+ return ((EnumerationLiteral) value).getName();
} else {
return String.valueOf(value);
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/validator/IParticipantValidator.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/validator/IParticipantValidator.java index 30e58591747..d9df69ca7b9 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/validator/IParticipantValidator.java +++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/validator/IParticipantValidator.java @@ -1,7 +1,7 @@ /*****************************************************************************
* Copyright (c) 2013 CEA LIST.
*
- *
+ *
* 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
@@ -18,19 +18,19 @@ import java.util.Collection; import org.eclipse.emf.ecore.EObject;
/**
- *
+ *
* Interface to implement to have a specific content validator. It is used to select only the elements that will be used to find patterns.
- *
+ *
*/
public interface IParticipantValidator {
/**
* Return the elements that will participate (i.e. the participants) in the search query based on a list of types
- *
+ *
* @param root
- * all the children and itself will be check against the list of types
+ * all the children and itself will be check against the list of types
* @param participantsTypes
- * the types of the wanted participants
+ * the types of the wanted participants
* @return
* the elements that are of wanted types
*/
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/validator/ParticipantValidator.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/validator/ParticipantValidator.java index 38eb000b851..b3a4804e712 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/validator/ParticipantValidator.java +++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/validator/ParticipantValidator.java @@ -1,7 +1,7 @@ /*****************************************************************************
* Copyright (c) 2013 CEA LIST.
*
- *
+ *
* 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
@@ -26,9 +26,9 @@ import org.eclipse.uml2.uml.Element; import org.eclipse.uml2.uml.Stereotype;
/**
- *
+ *
* A generic implementation of participant validator that works on EMF basis
- *
+ *
*/
public class ParticipantValidator implements IParticipantValidator {
@@ -40,9 +40,9 @@ public class ParticipantValidator implements IParticipantValidator { public final static ParticipantValidator getInstance() {
- if(ParticipantValidator.instance == null) {
- synchronized(ParticipantValidator.class) {
- if(ParticipantValidator.instance == null) {
+ if (ParticipantValidator.instance == null) {
+ synchronized (ParticipantValidator.class) {
+ if (ParticipantValidator.instance == null) {
ParticipantValidator.instance = new ParticipantValidator();
}
}
@@ -59,12 +59,12 @@ public class ParticipantValidator implements IParticipantValidator { // ... and all its content
TreeIterator<EObject> it = root.eAllContents();
- while(it.hasNext()) {
- EObject modelElement = (EObject)it.next();
+ while (it.hasNext()) {
+ EObject modelElement = it.next();
- //Check that metaclass of this element is a supported metaclass
+ // Check that metaclass of this element is a supported metaclass
EClass e = modelElement.eClass();
- if(participantsTypesList.contains(modelElement.eClass())) {
+ if (participantsTypesList.contains(modelElement.eClass())) {
results.add(modelElement);
}
}
@@ -79,19 +79,19 @@ public class ParticipantValidator implements IParticipantValidator { List<EObject> results = new ArrayList<EObject>();
// Evaluate root...
- if(participantsTypesList.contains(root.eClass())) {
+ if (participantsTypesList.contains(root.eClass())) {
results.add(root);
}
// ... and all its content
TreeIterator<EObject> it = root.eAllContents();
- while(it.hasNext()) {
- EObject modelElement = (EObject)it.next();
- if(modelElement instanceof Element) {
- for(Stereotype appliedStereotype : ((Element)modelElement).getAppliedStereotypes()) {
- //Check that metaclass of this element is a supported metaclass
- for(Object stereotypeToGet : participantsTypesList) {
- if(EcoreUtil.equals(appliedStereotype, (EObject)stereotypeToGet)) {
+ while (it.hasNext()) {
+ EObject modelElement = it.next();
+ if (modelElement instanceof Element) {
+ for (Stereotype appliedStereotype : ((Element) modelElement).getAppliedStereotypes()) {
+ // Check that metaclass of this element is a supported metaclass
+ for (Object stereotypeToGet : participantsTypesList) {
+ if (EcoreUtil.equals(appliedStereotype, (EObject) stereotypeToGet)) {
results.add(modelElement);
}
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/stereotypecollector/IStereotypeCollector.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/stereotypecollector/IStereotypeCollector.java index 6f46977785b..7af4d371f1f 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/stereotypecollector/IStereotypeCollector.java +++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/stereotypecollector/IStereotypeCollector.java @@ -1,7 +1,7 @@ /*****************************************************************************
* Copyright (c) 2013 CEA LIST.
*
- *
+ *
* 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
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/stereotypecollector/StereotypeCollector.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/stereotypecollector/StereotypeCollector.java index ab63bc3a987..6989369b8f8 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/stereotypecollector/StereotypeCollector.java +++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/stereotypecollector/StereotypeCollector.java @@ -1,7 +1,7 @@ /*****************************************************************************
* Copyright (c) 2013 CEA LIST.
*
- *
+ *
* 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
@@ -30,8 +30,6 @@ import org.eclipse.emf.common.util.TreeIterator; import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
@@ -65,70 +63,65 @@ public class StereotypeCollector implements IStereotypeCollector { Set<URI> umlResources = new HashSet<URI>();
- if(container == null) {
+ if (container == null) {
umlResources.addAll(createWorkspaceScope());
} else {
- switch(container.getSelectedScope()) {
- case ISearchPageContainer.WORKSPACE_SCOPE:
- {
+ switch (container.getSelectedScope()) {
+ case ISearchPageContainer.WORKSPACE_SCOPE: {
umlResources.addAll(createWorkspaceScope());
break;
}
- case ISearchPageContainer.SELECTION_SCOPE:
- {
+ case ISearchPageContainer.SELECTION_SCOPE: {
ISelection selection = container.getSelection();
- if(!selection.isEmpty()) {
- if(selection instanceof IStructuredSelection) {
- umlResources.addAll(createSelectionScope((IStructuredSelection)selection));
+ if (!selection.isEmpty()) {
+ if (selection instanceof IStructuredSelection) {
+ umlResources.addAll(createSelectionScope((IStructuredSelection) selection));
} else {
- //Do a workspace search instead
+ // Do a workspace search instead
umlResources.addAll(createWorkspaceScope());
}
} else {
- //Do a workspace search instead
+ // Do a workspace search instead
umlResources.addAll(createWorkspaceScope());
}
break;
}
- case ISearchPageContainer.SELECTED_PROJECTS_SCOPE:
- {
+ case ISearchPageContainer.SELECTED_PROJECTS_SCOPE: {
String[] projects = container.getSelectedProjectNames();
umlResources.addAll(createProjectsScope(projects));
break;
}
- case ISearchPageContainer.WORKING_SET_SCOPE:
- {
+ case ISearchPageContainer.WORKING_SET_SCOPE: {
IWorkingSet[] workingSets = container.getSelectedWorkingSets();
umlResources.addAll(createWorkingSetsScope(workingSets));
break;
}
- default:
- {
+ default: {
break;
}
}
}
- for(URI uri : umlResources) {
+ for (URI uri : umlResources) {
ModelSet resourceSet = new ModelSet();
Resource resource = resourceSet.getResource(uri, true);
TreeIterator<EObject> UMLResourceContentIterator = resource.getAllContents();
- while(UMLResourceContentIterator.hasNext()) {
- EObject umlElement = (EObject)UMLResourceContentIterator.next();
+ while (UMLResourceContentIterator.hasNext()) {
+ EObject umlElement = UMLResourceContentIterator.next();
- if(umlElement instanceof ProfileApplication) {
+ if (umlElement instanceof ProfileApplication) {
boolean found = false;
- Profile profileToProcess = ((ProfileApplication)umlElement).getAppliedProfile();
- for(Profile alreadyAddedProfile : profiles) {
+ Profile profileToProcess = ((ProfileApplication) umlElement).getAppliedProfile();
+ for (Profile alreadyAddedProfile : profiles) {
- if(EcoreUtil.equals(alreadyAddedProfile, profileToProcess)) {
+ if (EcoreUtil.equals(alreadyAddedProfile, profileToProcess)) {
found = true;
}
}
- if(!found) {
+ if (!found) {
profiles.add(profileToProcess);
}
}
@@ -136,22 +129,22 @@ public class StereotypeCollector implements IStereotypeCollector { }
}
- for(Profile profile : profiles) {
+ for (Profile profile : profiles) {
TreeIterator<EObject> profileContentIterator = profile.eAllContents();
- while(profileContentIterator.hasNext()) {
- EObject profileContent = (EObject)profileContentIterator.next();
- if(profileContent instanceof Stereotype) {
+ while (profileContentIterator.hasNext()) {
+ EObject profileContent = profileContentIterator.next();
+ if (profileContent instanceof Stereotype) {
boolean found = false;
- Stereotype stereotypeToProcess = (Stereotype)profileContent;
- for(Stereotype alreadyAddedStereotype : preResult) {
+ Stereotype stereotypeToProcess = (Stereotype) profileContent;
+ for (Stereotype alreadyAddedStereotype : preResult) {
- if(EcoreUtil.equals(alreadyAddedStereotype, stereotypeToProcess)) {
+ if (EcoreUtil.equals(alreadyAddedStereotype, stereotypeToProcess)) {
found = true;
}
}
- if(!found) {
+ if (!found) {
preResult.add(stereotypeToProcess);
}
}
@@ -160,22 +153,22 @@ public class StereotypeCollector implements IStereotypeCollector { }
Set<Stereotype> result = new HashSet<Stereotype>();
- for(Stereotype stereo : preResult) {
+ for (Stereotype stereo : preResult) {
result.add(stereo);
- for(Classifier parent : stereo.getGenerals()) {
- if(parent instanceof Stereotype) {
- result.add((Stereotype)parent);
+ for (Classifier parent : stereo.getGenerals()) {
+ if (parent instanceof Stereotype) {
+ result.add((Stereotype) parent);
boolean found = false;
- Stereotype stereotypeToProcess = (Stereotype)parent;
- for(Stereotype alreadyAddedStereotype : result) {
+ Stereotype stereotypeToProcess = (Stereotype) parent;
+ for (Stereotype alreadyAddedStereotype : result) {
- if(EcoreUtil.equals(alreadyAddedStereotype, stereotypeToProcess)) {
+ if (EcoreUtil.equals(alreadyAddedStereotype, stereotypeToProcess)) {
found = true;
}
}
- if(!found) {
+ if (!found) {
result.add(stereotypeToProcess);
}
@@ -190,9 +183,9 @@ public class StereotypeCollector implements IStereotypeCollector { /**
* Create a scope when the container is ISearchPageContainer.SELECTION_SCOPE
- *
+ *
* @param selection
- * the selection of the container
+ * the selection of the container
* @return
* the scope
*/
@@ -200,33 +193,33 @@ public class StereotypeCollector implements IStereotypeCollector { List<URI> results = new ArrayList<URI>();
Iterator<?> it = selection.iterator();
- while(it.hasNext()) {
- Object object = (Object)it.next();
+ while (it.hasNext()) {
+ Object object = it.next();
- if(object instanceof IPapyrusFile) {
- IResource[] associatedResources = ((IPapyrusFile)object).getAssociatedResources();
- for(IResource iResource : associatedResources) {
+ if (object instanceof IPapyrusFile) {
+ IResource[] associatedResources = ((IPapyrusFile) object).getAssociatedResources();
+ for (IResource iResource : associatedResources) {
results.addAll(findUMLModels(iResource));
}
- } else if(object instanceof IResource) {
- results.addAll(findUMLModels((IResource)object));
+ } else if (object instanceof IResource) {
+ results.addAll(findUMLModels((IResource) object));
} else {
Object element = BusinessModelResolver.getInstance().getBusinessModel(object);
- if(element instanceof EObject) {
+ if (element instanceof EObject) {
// CDO resource *are* EObjects
- Resource eResource = (element instanceof Resource) ? (Resource) element : ((EObject)element).eResource();
- if(eResource != null) {
+ Resource eResource = (element instanceof Resource) ? (Resource) element : ((EObject) element).eResource();
+ if (eResource != null) {
results.add(eResource.getURI());
} else {
- //Do a workspace search instead
+ // Do a workspace search instead
results.addAll(createWorkspaceScope());
}
} else {
- //Do a workspace search instead
+ // Do a workspace search instead
results.addAll(createWorkspaceScope());
}
@@ -237,18 +230,18 @@ public class StereotypeCollector implements IStereotypeCollector { /**
* Create a scope when the container is ISearchPageContainer.SELECTED_PROJECTS_SCOPE
- *
+ *
* @param projects
- * the selected scope
+ * the selected scope
* @return
* the scope
*/
protected List<URI> createProjectsScope(String[] projects) {
List<URI> results = new ArrayList<URI>();
- for(String projectName : projects) {
+ for (String projectName : projects) {
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
- if(project.isOpen()) {
+ if (project.isOpen()) {
results.addAll(findUMLModels(project));
}
}
@@ -257,21 +250,21 @@ public class StereotypeCollector implements IStereotypeCollector { /**
* Create a scope when the container is ISearchPageContainer.WORKING_SET_SCOPE
- *
+ *
* @param workingSets
- * the selected workingSets
+ * the selected workingSets
* @return
* the scope
*/
protected List<URI> createWorkingSetsScope(IWorkingSet[] workingSets) {
List<URI> results = new ArrayList<URI>();
- if(workingSets != null && workingSets.length > 0) {
- for(IWorkingSet iWorkingSet : workingSets) {
- for(IAdaptable element : iWorkingSet.getElements()) {
+ if (workingSets != null && workingSets.length > 0) {
+ for (IWorkingSet iWorkingSet : workingSets) {
+ for (IAdaptable element : iWorkingSet.getElements()) {
Object resource = element.getAdapter(IResource.class);
- if(resource instanceof IResource) {
- results.addAll(findUMLModels((IResource)resource));
+ if (resource instanceof IResource) {
+ results.addAll(findUMLModels((IResource) resource));
}
}
}
@@ -282,9 +275,9 @@ public class StereotypeCollector implements IStereotypeCollector { /**
* Find all Papyrus models from a specific root
- *
+ *
* @param res
- * the root
+ * the root
* @return
* the found Papyrus models
*/
@@ -301,13 +294,13 @@ public class StereotypeCollector implements IStereotypeCollector { /**
* Create a scope when the container is ISearchPageContainer.WORKSPACE_SCOPE
- *
+ *
* @return
* the scope
*/
protected Collection<URI> createWorkspaceScope() {
- //Go through the workspace root
+ // Go through the workspace root
IResource root = ResourcesPlugin.getWorkspace().getRoot();
return findUMLModels(root);
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/stereotypecollector/UMLResourceVisitor.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/stereotypecollector/UMLResourceVisitor.java index 2c85c2ef447..061fb86c821 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/stereotypecollector/UMLResourceVisitor.java +++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/stereotypecollector/UMLResourceVisitor.java @@ -1,7 +1,7 @@ /*****************************************************************************
* Copyright (c) 2013 CEA LIST.
*
- *
+ *
* 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
@@ -24,9 +24,9 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.emf.common.util.URI;
/**
- *
+ *
* Implements a visitor that goes through a hierarchy of Iresource from a root and collect only those that can be processed for search
- *
+ *
*/
public class UMLResourceVisitor implements IResourceProxyVisitor {
@@ -38,13 +38,13 @@ public class UMLResourceVisitor implements IResourceProxyVisitor { }
public boolean visit(IResourceProxy proxy) throws CoreException {
- switch(proxy.getType()) {
+ switch (proxy.getType()) {
case IResource.FILE:
IResource resource = proxy.requestResource();
URI uri = URI.createPlatformResourceURI(resource.getFullPath().toString(), true);
- if("uml".equals(uri.fileExtension())) { //$NON-NLS-1$
+ if ("uml".equals(uri.fileExtension())) { //$NON-NLS-1$
participantURIs.add(uri);
}
|