diff options
Diffstat (limited to 'plugins/org.eclipse.emf.compare.ide/src/org/eclipse/emf/compare/ide')
5 files changed, 101 insertions, 39 deletions
diff --git a/plugins/org.eclipse.emf.compare.ide/src/org/eclipse/emf/compare/ide/internal/EMFCompareIDEMessages.java b/plugins/org.eclipse.emf.compare.ide/src/org/eclipse/emf/compare/ide/internal/EMFCompareIDEMessages.java new file mode 100644 index 000000000..aec4f9032 --- /dev/null +++ b/plugins/org.eclipse.emf.compare.ide/src/org/eclipse/emf/compare/ide/internal/EMFCompareIDEMessages.java @@ -0,0 +1,79 @@ +/******************************************************************************* + * Copyright (c) 2006, 2014 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.emf.compare.ide.internal; + +import java.text.MessageFormat; +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +/** + * Utility class to access externalized Strings for this bundle. + * + * @author <a href="mailto:laurent.goubet@obeo.fr">Laurent Goubet</a> + */ +public final class EMFCompareIDEMessages { + /** Fully qualified path to the properties file in which to seek the keys. */ + private static final String BUNDLE_NAME = "org.eclipse.emf.compare.ide.internal.ide_messages"; //$NON-NLS-1$ + + /** Contains the locale specific {@link String}s needed by this plug-in. */ + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); + + /** + * Utility classes don't need to (and shouldn't) be instantiated. + */ + private EMFCompareIDEMessages() { + // prevents instantiation + } + + /** + * Returns a specified {@link String} from the resource bundle. + * + * @param key + * Key of the String we seek. + * @return The String from the resource bundle associated with <code>key</code>. + */ + public static String getString(String key) { + // Pass through MessageFormat to be consistent in the handling of special chars such as the apostrophe + return MessageFormat.format(internalGetString(key), new Object[] {}); + } + + /** + * Returns a String from the resource bundle bound with the given arguments. + * + * @param key + * Key of the String we seek. + * @param arguments + * Arguments for the String formatting. + * @return formatted {@link String}. + * @see MessageFormat#format(String, Object[]) + */ + public static String getString(String key, Object... arguments) { + if (arguments == null) { + return getString(key); + } + return MessageFormat.format(internalGetString(key), arguments); + } + + /** + * This will return an unformatted String from the resource bundle. + * + * @param key + * Key of the String we seek. + * @return An unformatted String from the bundle. + */ + private static String internalGetString(String key) { + try { + return RESOURCE_BUNDLE.getString(key); + } catch (MissingResourceException e) { + return '!' + key + '!'; + } + } +} diff --git a/plugins/org.eclipse.emf.compare.ide/src/org/eclipse/emf/compare/ide/internal/ide_messages.properties b/plugins/org.eclipse.emf.compare.ide/src/org/eclipse/emf/compare/ide/internal/ide_messages.properties new file mode 100644 index 000000000..38559b4f0 --- /dev/null +++ b/plugins/org.eclipse.emf.compare.ide/src/org/eclipse/emf/compare/ide/internal/ide_messages.properties @@ -0,0 +1,12 @@ +################################################################################ +# Copyright (c) 2013 Obeo. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# Obeo - initial API and implementation +################################################################################ +## ! note ! double the apostrophes if you need one in the printed String +NotLoadingResourceSet.monitor.resolve = Create and resolve resource set
\ No newline at end of file diff --git a/plugins/org.eclipse.emf.compare.ide/src/org/eclipse/emf/compare/ide/internal/utils/NotLoadingResourceSet.java b/plugins/org.eclipse.emf.compare.ide/src/org/eclipse/emf/compare/ide/internal/utils/NotLoadingResourceSet.java index 63625d723..97ab0cedc 100644 --- a/plugins/org.eclipse.emf.compare.ide/src/org/eclipse/emf/compare/ide/internal/utils/NotLoadingResourceSet.java +++ b/plugins/org.eclipse.emf.compare.ide/src/org/eclipse/emf/compare/ide/internal/utils/NotLoadingResourceSet.java @@ -1,5 +1,5 @@ /*******************************************************************************
- * Copyright (c) 2012, 2013 Obeo.
+ * Copyright (c) 2012, 2014 Obeo.
* 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,6 +30,7 @@ import org.eclipse.core.runtime.SubMonitor; import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.common.util.WrappedException;
+import org.eclipse.emf.compare.ide.internal.EMFCompareIDEMessages;
import org.eclipse.emf.compare.ide.utils.StorageTraversal;
import org.eclipse.emf.compare.rcp.EMFCompareRCPPlugin;
import org.eclipse.emf.compare.rcp.policy.ILoadOnDemandPolicy;
@@ -59,7 +60,8 @@ public final class NotLoadingResourceSet extends ResourceSetImpl { * @return resource set to containing the resources described by the given traversals.
*/
public static NotLoadingResourceSet create(final StorageTraversal traversals, IProgressMonitor monitor) {
- SubMonitor progress = SubMonitor.convert(monitor, "Create and resolve resource set", 100);
+ SubMonitor progress = SubMonitor.convert(monitor, EMFCompareIDEMessages
+ .getString("NotLoadingResourceSet.monitor.resolve"), 100); //$NON-NLS-1$
final NotLoadingResourceSet resourceSet = new NotLoadingResourceSet();
resourceSet.setURIResourceMap(new HashMap<URI, Resource>(traversals.getStorages().size() << 1));
@@ -112,8 +114,6 @@ public final class NotLoadingResourceSet extends ResourceSetImpl { * The options to pass to {@link Resource#load(java.util.Map)}.
* @return The loaded EMF Resource if {@code file} was a model, {@code null} otherwise.
*/
- // Suppressing the warning until bug 376938 is fixed
- @SuppressWarnings("resource")
public Resource loadResource(IStorage storage, Map<?, ?> options) {
InputStream stream = null;
Resource resource = null;
diff --git a/plugins/org.eclipse.emf.compare.ide/src/org/eclipse/emf/compare/ide/utils/ResourceUtil.java b/plugins/org.eclipse.emf.compare.ide/src/org/eclipse/emf/compare/ide/utils/ResourceUtil.java index 5a80617d6..fb6d276b4 100644 --- a/plugins/org.eclipse.emf.compare.ide/src/org/eclipse/emf/compare/ide/utils/ResourceUtil.java +++ b/plugins/org.eclipse.emf.compare.ide/src/org/eclipse/emf/compare/ide/utils/ResourceUtil.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012 Obeo. + * Copyright (c) 2012, 2014 Obeo. * 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 @@ -200,6 +200,7 @@ public final class ResourceUtil { * @param file * The file for which we need an EMF URI. * @return The created URI. + * @since 4.0 */ public static URI createURIFor(IFile file) { // whether it exists or not (no longer), use platform:/resource @@ -277,37 +278,6 @@ public final class ResourceUtil { } /** - * This will return <code>true</code> if and only if the given IFile has the given <em>contentTypeId</em> - * configured (as returned by {@link IContentTypeManager#findContentTypesFor(InputStream, String) - * Platform.getContentTypeManager().findContentTypesFor(InputStream, String)}. - * - * @param resource - * The resource from which to test the content types. - * @param contentTypeId - * Fully qualified identifier of the content type this <em>resource</em> has to feature. - * @return <code>true</code> if the given {@link IFile} has the given content type. - * @deprecated use {@link #hasContentType(String, IContentType[])} instead. - */ - @Deprecated - public static boolean hasContentType(IFile resource, String contentTypeId) { - IContentTypeManager ctManager = Platform.getContentTypeManager(); - IContentType expected = ctManager.getContentType(contentTypeId); - if (expected == null) { - return false; - } - - final IContentType[] contentTypes = getContentTypes(resource); - - boolean hasContentType = false; - for (int i = 0; i < contentTypes.length && !hasContentType; i++) { - if (contentTypes[i].isKindOf(expected)) { - hasContentType = true; - } - } - return hasContentType; - } - - /** * This will return <code>true</code> if the given <em>contentTypeId</em> represents a content-type * contained in the given array. * @@ -316,7 +286,7 @@ public final class ResourceUtil { * @param contentTypes * The array of content-types to compare against. * @return <code>true</code> if the given array contains a content-type with this id. - * @since 3.1 + * @since 4.0 */ public static boolean hasContentType(String contentTypeId, IContentType[] contentTypes) { IContentTypeManager ctManager = Platform.getContentTypeManager(); @@ -340,7 +310,7 @@ public final class ResourceUtil { * @param file * The file we need the content types of. * @return All content types associated with the given file, an empty array if none. - * @since 3.1 + * @since 4.0 */ public static IContentType[] getContentTypes(IFile file) { IContentTypeManager ctManager = Platform.getContentTypeManager(); diff --git a/plugins/org.eclipse.emf.compare.ide/src/org/eclipse/emf/compare/ide/utils/StorageTraversal.java b/plugins/org.eclipse.emf.compare.ide/src/org/eclipse/emf/compare/ide/utils/StorageTraversal.java index af0240638..d73e057c0 100644 --- a/plugins/org.eclipse.emf.compare.ide/src/org/eclipse/emf/compare/ide/utils/StorageTraversal.java +++ b/plugins/org.eclipse.emf.compare.ide/src/org/eclipse/emf/compare/ide/utils/StorageTraversal.java @@ -1,5 +1,5 @@ /*******************************************************************************
- * Copyright (c) 2011, 2012 Obeo.
+ * Copyright (c) 2011, 2014 Obeo.
* 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
@@ -62,6 +62,7 @@ public class StorageTraversal implements IAdaptable { *
* @param storage
* The storage to be removed.
+ * @since 4.0
*/
public void removeStorage(IStorage storage) {
storages.remove(storage);
|