Refactor extension management and initialization of extension plug-ins
diff --git a/org.eclipse.babel.core/src/org/eclipse/babel/core/message/manager/RBManager.java b/org.eclipse.babel.core/src/org/eclipse/babel/core/message/manager/RBManager.java
index 4a25ccc..b9f4a46 100644
--- a/org.eclipse.babel.core/src/org/eclipse/babel/core/message/manager/RBManager.java
+++ b/org.eclipse.babel.core/src/org/eclipse/babel/core/message/manager/RBManager.java
@@ -67,8 +67,7 @@
private static final String TAPIJI_NATURE = "org.eclipse.babel.tapiji.tools.core.ui.nature";
- final static Logger logger = Logger.getLogger(RBManager.class
- .getSimpleName());
+ final static Logger logger = Logger.getLogger(RBManager.class.getName());
private static IRefactoringService refactorService;
diff --git a/org.eclipse.babel.editor/src/org/eclipse/babel/editor/builder/Builder.java b/org.eclipse.babel.editor/src/org/eclipse/babel/editor/builder/Builder.java
index eae906d..282b64e 100644
--- a/org.eclipse.babel.editor/src/org/eclipse/babel/editor/builder/Builder.java
+++ b/org.eclipse.babel.editor/src/org/eclipse/babel/editor/builder/Builder.java
@@ -10,13 +10,14 @@
******************************************************************************/
package org.eclipse.babel.editor.builder;
-//import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import org.eclipse.babel.core.message.IMessagesBundle;
import org.eclipse.babel.core.message.internal.MessagesBundle;
@@ -45,275 +46,282 @@
*/
public class Builder extends IncrementalProjectBuilder {
- public static final String BUILDER_ID = "org.eclipse.babel.editor.rbeBuilder"; //$NON-NLS-1$
+ private static final Logger LOGGER = Logger.getLogger(Builder.class.getName());
+
+ public static final String BUILDER_ID = "org.eclipse.babel.editor.rbeBuilder"; //$NON-NLS-1$
- private IValidationMarkerStrategy markerStrategy = new FileMarkerStrategy();
+ private IValidationMarkerStrategy markerStrategy = new FileMarkerStrategy();
- class SampleDeltaVisitor implements IResourceDeltaVisitor {
- /**
- * @see org.eclipse.core.resources.IResourceDeltaVisitor#visit(org.eclipse.core.resources.IResourceDelta)
- */
- public boolean visit(IResourceDelta delta) throws CoreException {
- IResource resource = delta.getResource();
- switch (delta.getKind()) {
- case IResourceDelta.ADDED:
- // handle added resource
- System.out.println("RBE DELTA added");
- checkBundleResource(resource);
- break;
- case IResourceDelta.REMOVED:
- System.out.println("RBE DELTA Removed"); //$NON-NLS-1$
- RBManager.getInstance(delta.getResource().getProject())
- .notifyResourceRemoved(delta.getResource());
- // handle removed resource
- break;
- case IResourceDelta.CHANGED:
- System.out.println("RBE DELTA changed");
- // handle changed resource
- checkBundleResource(resource);
- break;
- }
- // return true to continue visiting children.
- return true;
- }
- }
+ class SampleDeltaVisitor implements IResourceDeltaVisitor {
+ /**
+ * @see org.eclipse.core.resources.IResourceDeltaVisitor#visit(org.eclipse.core.resources.IResourceDelta)
+ */
+ public boolean visit(IResourceDelta delta) throws CoreException {
+ IResource resource = delta.getResource();
+
+ // export file ending (.properties) into a configuration constant
+ if (resource instanceof IFile && resource.getName().endsWith(".properties")) {
+ switch (delta.getKind()) {
+ case IResourceDelta.ADDED:
+ // handle added resource
+ LOGGER.log(Level.INFO, "RBE DELTA added");
+ checkBundleResource(resource);
+ break;
+ case IResourceDelta.REMOVED:
+ LOGGER.log(Level.INFO, "RBE DELTA removed");
+ RBManager.getInstance(delta.getResource().getProject())
+ .notifyResourceRemoved(delta.getResource());
+ // handle removed resource
+ break;
+ case IResourceDelta.CHANGED:
+ // handle changed resource
+ LOGGER.log(Level.INFO, "RBE DELTA changed");
+ checkBundleResource(resource);
+ break;
+ }
+ }
+
+ // return true to continue visiting children.
+ return true;
+ }
+ }
- class SampleResourceVisitor implements IResourceVisitor {
- public boolean visit(IResource resource) {
- checkBundleResource(resource);
- // return true to continue visiting children.
- return true;
- }
- }
+ class SampleResourceVisitor implements IResourceVisitor {
+ public boolean visit(IResource resource) {
+ checkBundleResource(resource);
+ // return true to continue visiting children.
+ return true;
+ }
+ }
- /**
- * list built during a single build of the properties files. Contains the
- * list of files that must be validated. The validation is done only at the
- * end of the visitor. This way the visitor can add extra files to be
- * visited. For example: if the default properties file is changed, it is a
- * good idea to rebuild all localized files in the same MessageBundleGroup
- * even if themselves were not changed.
- */
- private Set _resourcesToValidate;
+ /**
+ * list built during a single build of the properties files. Contains the
+ * list of files that must be validated. The validation is done only at the
+ * end of the visitor. This way the visitor can add extra files to be
+ * visited. For example: if the default properties file is changed, it is a
+ * good idea to rebuild all localized files in the same MessageBundleGroup
+ * even if themselves were not changed.
+ */
+ private Set _resourcesToValidate;
- /**
- * Index built during a single build.
- * <p>
- * The values of that map are message bundles. The key is a resource that
- * belongs to that message bundle.
- * </p>
- */
- private Map<IFile, MessagesBundleGroup> _alreadBuiltMessageBundle;
+ /**
+ * Index built during a single build.
+ * <p>
+ * The values of that map are message bundles. The key is a resource that
+ * belongs to that message bundle.
+ * </p>
+ */
+ private Map<IFile, MessagesBundleGroup> _alreadBuiltMessageBundle;
- // /** one indexer per project we open and close it at the beginning and the
- // end of each build. */
- // private Indexer _indexer = new Indexer();
+ // /** one indexer per project we open and close it at the beginning and the
+ // end of each build. */
+ // private Indexer _indexer = new Indexer();
- /**
- * @see org.eclipse.core.resources.IncrementalProjectBuilder#build(int,
- * java.util.Map, org.eclipse.core.runtime.IProgressMonitor)
- */
- protected IProject[] build(int kind, Map args, IProgressMonitor monitor)
- throws CoreException {
- try {
- _alreadBuiltMessageBundle = null;
- _resourcesToValidate = null;
- if (kind == FULL_BUILD) {
- fullBuild(monitor);
- } else {
- IResourceDelta delta = getDelta(getProject());
- if (delta == null) {
- fullBuild(monitor);
- } else {
- incrementalBuild(delta, monitor);
- }
- }
- } finally {
- try {
- finishBuild();
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- // must dispose the message bundles:
- if (_alreadBuiltMessageBundle != null) {
- for (MessagesBundleGroup msgGrp : _alreadBuiltMessageBundle
- .values()) {
- try {
- // msgGrp.dispose(); // TODO: [alst] do we need this
- // really?
- } catch (Throwable t) {
- // FIXME: remove this debugging:
- System.err
- .println("error disposing message-bundle-group "
- + msgGrp.getName());
- // disregard crashes: we are doing our best effort
- // to dispose things.
- }
- }
- _alreadBuiltMessageBundle = null;
- _resourcesToValidate = null;
- }
- // if (_indexer != null) {
- // try {
- // _indexer.close(true);
- // _indexer.clear();
- // } catch (CorruptIndexException e) {
- // e.printStackTrace();
- // } catch (IOException e) {
- // e.printStackTrace();
- // }
- // }
- }
- }
- return null;
- }
+ /**
+ * @see org.eclipse.core.resources.IncrementalProjectBuilder#build(int,
+ * java.util.Map, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ protected IProject[] build(int kind, Map args, IProgressMonitor monitor)
+ throws CoreException {
+ try {
+ _alreadBuiltMessageBundle = null;
+ _resourcesToValidate = null;
+ if (kind == FULL_BUILD) {
+ fullBuild(monitor);
+ } else {
+ IResourceDelta delta = getDelta(getProject());
+ if (delta == null) {
+ fullBuild(monitor);
+ } else {
+ incrementalBuild(delta, monitor);
+ }
+ }
+ } finally {
+ try {
+ finishBuild();
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ // must dispose the message bundles:
+ if (_alreadBuiltMessageBundle != null) {
+ for (MessagesBundleGroup msgGrp : _alreadBuiltMessageBundle
+ .values()) {
+ try {
+ // msgGrp.dispose(); // TODO: [alst] do we need this
+ // really?
+ } catch (Throwable t) {
+ // FIXME: remove this debugging:
+ System.err
+ .println("error disposing message-bundle-group "
+ + msgGrp.getName());
+ // disregard crashes: we are doing our best effort
+ // to dispose things.
+ }
+ }
+ _alreadBuiltMessageBundle = null;
+ _resourcesToValidate = null;
+ }
+ // if (_indexer != null) {
+ // try {
+ // _indexer.close(true);
+ // _indexer.clear();
+ // } catch (CorruptIndexException e) {
+ // e.printStackTrace();
+ // } catch (IOException e) {
+ // e.printStackTrace();
+ // }
+ // }
+ }
+ }
+ return null;
+ }
- /**
- * Collect the resource bundles to validate and index the corresponding
- * MessageBundleGroup(s).
- *
- * @param resource
- * The resource currently validated.
- */
- void checkBundleResource(IResource resource) {
- if (true)
- return; // TODO [alst]
- if (resource instanceof IFile
- && resource.getName().endsWith(".properties")) { //$NON-NLS-1$ //TODO have customized?
- IFile file = (IFile) resource;
- if (file.isDerived()) {
- return;
- }
- // System.err.println("Looking at " + file.getFullPath());
- deleteMarkers(file);
- MessagesBundleGroup msgBundleGrp = null;
- if (_alreadBuiltMessageBundle == null) {
- _alreadBuiltMessageBundle = new HashMap<IFile, MessagesBundleGroup>();
- _resourcesToValidate = new HashSet();
- } else {
- msgBundleGrp = _alreadBuiltMessageBundle.get(file);
- }
- if (msgBundleGrp == null) {
- msgBundleGrp = MessagesBundleGroupFactory.createBundleGroup(
- null, file);
- if (msgBundleGrp != null) {
- // index the files for which this MessagesBundleGroup
- // should be used for the validation.
- // cheaper than creating a group for each on of those
- // files.
- boolean validateEntireGroup = false;
- for (IMessagesBundle msgBundle : msgBundleGrp
- .getMessagesBundles()) {
- Object src = ((MessagesBundle) msgBundle).getResource()
- .getSource();
- // System.err.println(src + " -> " + msgBundleGrp);
- if (src instanceof IFile) {// when it is a read-only
- // thing we don't index it.
- _alreadBuiltMessageBundle.put((IFile) src,
- msgBundleGrp);
- if (!validateEntireGroup && src == resource) {
- if (((MessagesBundle) msgBundle).getLocale() == null
- || ((MessagesBundle) msgBundle)
- .getLocale().equals(
- UIUtils.ROOT_LOCALE)) {
- // ok the default properties have been
- // changed.
- // make sure that all resources in this
- // bundle group
- // are validated too:
- validateEntireGroup = true;
+ /**
+ * Collect the resource bundles to validate and index the corresponding
+ * MessageBundleGroup(s).
+ *
+ * @param resource
+ * The resource currently validated.
+ */
+ void checkBundleResource(IResource resource) {
+ if (true)
+ return; // TODO [alst]
+ if (resource instanceof IFile
+ && resource.getName().endsWith(".properties")) { //$NON-NLS-1$ //TODO have customized?
+ IFile file = (IFile) resource;
+ if (file.isDerived()) {
+ return;
+ }
+ // System.err.println("Looking at " + file.getFullPath());
+ deleteMarkers(file);
+ MessagesBundleGroup msgBundleGrp = null;
+ if (_alreadBuiltMessageBundle == null) {
+ _alreadBuiltMessageBundle = new HashMap<IFile, MessagesBundleGroup>();
+ _resourcesToValidate = new HashSet();
+ } else {
+ msgBundleGrp = _alreadBuiltMessageBundle.get(file);
+ }
+ if (msgBundleGrp == null) {
+ msgBundleGrp = MessagesBundleGroupFactory.createBundleGroup(
+ null, file);
+ if (msgBundleGrp != null) {
+ // index the files for which this MessagesBundleGroup
+ // should be used for the validation.
+ // cheaper than creating a group for each on of those
+ // files.
+ boolean validateEntireGroup = false;
+ for (IMessagesBundle msgBundle : msgBundleGrp
+ .getMessagesBundles()) {
+ Object src = ((MessagesBundle) msgBundle).getResource()
+ .getSource();
+ // System.err.println(src + " -> " + msgBundleGrp);
+ if (src instanceof IFile) {// when it is a read-only
+ // thing we don't index it.
+ _alreadBuiltMessageBundle.put((IFile) src,
+ msgBundleGrp);
+ if (!validateEntireGroup && src == resource) {
+ if (((MessagesBundle) msgBundle).getLocale() == null
+ || ((MessagesBundle) msgBundle)
+ .getLocale().equals(
+ UIUtils.ROOT_LOCALE)) {
+ // ok the default properties have been
+ // changed.
+ // make sure that all resources in this
+ // bundle group
+ // are validated too:
+ validateEntireGroup = true;
- // TODO: eventually something similar.
- // with foo_en.properties changed.
- // then foo_en_US.properties must be
- // revalidated
- // and foo_en_CA.properties as well.
+ // TODO: eventually something similar.
+ // with foo_en.properties changed.
+ // then foo_en_US.properties must be
+ // revalidated
+ // and foo_en_CA.properties as well.
- }
- }
- }
- }
- if (validateEntireGroup) {
- for (IMessagesBundle msgBundle : msgBundleGrp
- .getMessagesBundles()) {
- Object src = ((MessagesBundle) msgBundle)
- .getResource().getSource();
- _resourcesToValidate.add(src);
- }
- }
- }
- }
+ }
+ }
+ }
+ }
+ if (validateEntireGroup) {
+ for (IMessagesBundle msgBundle : msgBundleGrp
+ .getMessagesBundles()) {
+ Object src = ((MessagesBundle) msgBundle)
+ .getResource().getSource();
+ _resourcesToValidate.add(src);
+ }
+ }
+ }
+ }
- _resourcesToValidate.add(resource);
+ _resourcesToValidate.add(resource);
- }
- }
+ }
+ }
- /**
- * Validates the message bundles collected by the visitor. Makes sure we
- * validate only once each message bundle and build only once each
- * MessageBundleGroup it belongs to.
- */
- private void finishBuild() {
- if (_resourcesToValidate != null) {
- for (Iterator it = _resourcesToValidate.iterator(); it.hasNext();) {
- IFile resource = (IFile) it.next();
- MessagesBundleGroup msgBundleGrp = _alreadBuiltMessageBundle
- .get(resource);
+ /**
+ * Validates the message bundles collected by the visitor. Makes sure we
+ * validate only once each message bundle and build only once each
+ * MessageBundleGroup it belongs to.
+ */
+ private void finishBuild() {
+ if (_resourcesToValidate != null) {
+ for (Iterator it = _resourcesToValidate.iterator(); it.hasNext();) {
+ IFile resource = (IFile) it.next();
+ MessagesBundleGroup msgBundleGrp = _alreadBuiltMessageBundle
+ .get(resource);
- if (msgBundleGrp != null) {
- // when null it is probably because it was skipped from
- // the group because the locale was filtered.
- try {
- // System.out.println("Validate " + resource); //$NON-NLS-1$
- // TODO check if there is a matching
- // EclipsePropertiesEditorResource already open.
- // else, create MessagesBundle from
- // PropertiesIFileResource
- MessagesBundle messagesBundle = msgBundleGrp
- .getMessagesBundle(resource);
- if (messagesBundle != null) {
- Locale locale = messagesBundle.getLocale();
- MessagesBundleGroupValidator.validate(msgBundleGrp,
- locale, markerStrategy);
- }// , _indexer);
- } catch (Exception e) {
- e.printStackTrace();
- }
- } else {
- // System.out.println("Not validating " + resource); //$NON-NLS-1$
- }
- }
- }
- }
+ if (msgBundleGrp != null) {
+ // when null it is probably because it was skipped from
+ // the group because the locale was filtered.
+ try {
+ // System.out.println("Validate " + resource); //$NON-NLS-1$
+ // TODO check if there is a matching
+ // EclipsePropertiesEditorResource already open.
+ // else, create MessagesBundle from
+ // PropertiesIFileResource
+ MessagesBundle messagesBundle = msgBundleGrp
+ .getMessagesBundle(resource);
+ if (messagesBundle != null) {
+ Locale locale = messagesBundle.getLocale();
+ MessagesBundleGroupValidator.validate(msgBundleGrp,
+ locale, markerStrategy);
+ }// , _indexer);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ } else {
+ // System.out.println("Not validating " + resource); //$NON-NLS-1$
+ }
+ }
+ }
+ }
- private void deleteMarkers(IFile file) {
- try {
- // System.out.println("Builder: deleteMarkers"); //$NON-NLS-1$
- file.deleteMarkers(MessagesEditorPlugin.MARKER_TYPE, false,
- IResource.DEPTH_ZERO);
- } catch (CoreException ce) {
- }
- }
+ private void deleteMarkers(IFile file) {
+ try {
+ // System.out.println("Builder: deleteMarkers"); //$NON-NLS-1$
+ file.deleteMarkers(MessagesEditorPlugin.MARKER_TYPE, false,
+ IResource.DEPTH_ZERO);
+ } catch (CoreException ce) {
+ }
+ }
- protected void fullBuild(final IProgressMonitor monitor)
- throws CoreException {
- // System.out.println("Builder: fullBuild"); //$NON-NLS-1$
- getProject().accept(new SampleResourceVisitor());
- }
+ protected void fullBuild(final IProgressMonitor monitor)
+ throws CoreException {
+ // System.out.println("Builder: fullBuild"); //$NON-NLS-1$
+ getProject().accept(new SampleResourceVisitor());
+ }
- protected void incrementalBuild(IResourceDelta delta,
- IProgressMonitor monitor) throws CoreException {
- // System.out.println("Builder: incrementalBuild"); //$NON-NLS-1$
- delta.accept(new SampleDeltaVisitor());
- }
+ protected void incrementalBuild(IResourceDelta delta,
+ IProgressMonitor monitor) throws CoreException {
+ // System.out.println("Builder: incrementalBuild"); //$NON-NLS-1$
+ delta.accept(new SampleDeltaVisitor());
+ }
- protected void clean(IProgressMonitor monitor) throws CoreException {
- ResourcesPlugin
- .getWorkspace()
- .getRoot()
- .deleteMarkers(MessagesEditorPlugin.MARKER_TYPE, false,
- IResource.DEPTH_INFINITE);
- }
+ protected void clean(IProgressMonitor monitor) throws CoreException {
+ ResourcesPlugin
+ .getWorkspace()
+ .getRoot()
+ .deleteMarkers(MessagesEditorPlugin.MARKER_TYPE, false,
+ IResource.DEPTH_INFINITE);
+ }
}
diff --git a/org.eclipse.babel.editor/src/org/eclipse/babel/editor/builder/ToggleNatureAction.java b/org.eclipse.babel.editor/src/org/eclipse/babel/editor/builder/ToggleNatureAction.java
index a8be8b6..4294914 100644
--- a/org.eclipse.babel.editor/src/org/eclipse/babel/editor/builder/ToggleNatureAction.java
+++ b/org.eclipse.babel.editor/src/org/eclipse/babel/editor/builder/ToggleNatureAction.java
@@ -10,6 +10,9 @@
******************************************************************************/
package org.eclipse.babel.editor.builder;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
import org.eclipse.babel.core.util.BabelUtils;
import org.eclipse.babel.editor.util.UIUtils;
import org.eclipse.core.resources.IProject;
@@ -24,6 +27,8 @@
import org.eclipse.ui.IWorkbenchPart;
public class ToggleNatureAction implements IObjectActionDelegate {
+
+ private static final Logger LOGGER = Logger.getLogger(ToggleNatureAction.class.getName());
/**
* Method call during the start up of the plugin or during a change of the
@@ -145,7 +150,7 @@
String[] newNatures = new String[natures.length + 1];
System.arraycopy(natures, 0, newNatures, 0, natures.length);
newNatures[natures.length] = Nature.NATURE_ID;
- System.out.println("New natures: "
+ LOGGER.log(Level.INFO, "New natures: "
+ BabelUtils.join(newNatures, ", "));
description.setNatureIds(newNatures);
project.setDescription(description, null);
diff --git a/org.eclipse.babel.editor/src/org/eclipse/babel/editor/tree/internal/KeyTreeContributor.java b/org.eclipse.babel.editor/src/org/eclipse/babel/editor/tree/internal/KeyTreeContributor.java
index 93a3f26..00b38ba 100644
--- a/org.eclipse.babel.editor/src/org/eclipse/babel/editor/tree/internal/KeyTreeContributor.java
+++ b/org.eclipse.babel.editor/src/org/eclipse/babel/editor/tree/internal/KeyTreeContributor.java
@@ -13,6 +13,8 @@
import java.lang.reflect.Constructor;
import java.util.Observable;
import java.util.Observer;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import org.eclipse.babel.core.message.tree.IKeyTreeNode;
import org.eclipse.babel.core.message.tree.TreeType;
@@ -20,6 +22,7 @@
import org.eclipse.babel.core.message.tree.internal.IKeyTreeModelListener;
import org.eclipse.babel.core.message.tree.internal.KeyTreeNode;
import org.eclipse.babel.editor.IMessagesEditorChangeListener;
+import org.eclipse.babel.editor.builder.Builder;
import org.eclipse.babel.editor.internal.AbstractMessagesEditor;
import org.eclipse.babel.editor.internal.MessagesEditorChangeAdapter;
import org.eclipse.babel.editor.internal.MessagesEditorMarkers;
@@ -60,6 +63,8 @@
*
*/
public class KeyTreeContributor implements IKeyTreeContributor {
+
+ private static final Logger LOGGER = Logger.getLogger(KeyTreeContributor.class.getName());
private AbstractMessagesEditor editor;
private AbstractKeyTreeModel treeModel;
@@ -310,7 +315,7 @@
if (selection != null && selection.getFirstElement() != null) {
KeyTreeNode node = (KeyTreeNode) selection
.getFirstElement();
- System.out.println("viewer key/hash:"
+ LOGGER.log(Level.INFO, "viewer key/hash:"
+ node.getMessageKey() + "/" + node.hashCode());
editor.setSelectedKey(node.getMessageKey());
} else {
diff --git a/org.eclipse.babel.editor/src/org/eclipse/pde/nls/internal/ui/model/ResourceBundle.java b/org.eclipse.babel.editor/src/org/eclipse/pde/nls/internal/ui/model/ResourceBundle.java
index c576dda..c6ac209 100644
--- a/org.eclipse.babel.editor/src/org/eclipse/pde/nls/internal/ui/model/ResourceBundle.java
+++ b/org.eclipse.babel.editor/src/org/eclipse/pde/nls/internal/ui/model/ResourceBundle.java
@@ -104,7 +104,7 @@
if (resource instanceof IFile) {
if (debug) {
- System.out.println("Loading " + resource + "...");
+ System.out.println("Loading " + resource + "...");
}
IFile file = (IFile) resource;
InputStream inputStream = file.getContents();
diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/ResourceBundleManager.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/ResourceBundleManager.java
index 0b4e2fc..6507902 100644
--- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/ResourceBundleManager.java
+++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/ResourceBundleManager.java
@@ -219,7 +219,7 @@
if (bundleName.equals("org.example.com")) {
Logger.logInfo("adding bundle with id: " + bundleName);
}
-
+
resources.put(bundleName, res);
allBundles.put(bundleName, new HashSet<IResource>(res));
bundleNames.put(bundleName, getResourceBundleName(resource));
@@ -449,7 +449,7 @@
bundleName, res.getProject()));
}
}
-
+
return rbRemoved;
}
@@ -483,7 +483,7 @@
rbRemoved |= excludeSingleResource(resource);
monitor.worked(1);
}
-
+
if (rbRemoved) {
try {
res.getProject().build(
@@ -526,7 +526,9 @@
// check if the changed resource is a resource
// bundle
if (org.eclipse.babel.tapiji.tools.core.ui.utils.RBFileUtils
- .isResourceBundleFile(resource) && !changedResourceBundles.contains(resource)) {
+ .isResourceBundleFile(resource)
+ && !changedResourceBundles
+ .contains(resource)) {
changedResourceBundles.add(resource);
}
changedResources.add(resource);
@@ -562,14 +564,18 @@
for (IResource rbResource : changedResourceBundles) {
String bundleName = getResourceBundleId(rbResource);
- //fullBuildRequired &= !resources.containsKey(bundleName);
+
+ // TODO check if fullbuild needs only be triggered if a complete
+ // bundle was excluded
+ // fullBuildRequired &= !resources.containsKey(bundleName);
this.addBundleResource(rbResource);
Logger.logInfo("Including resource bundle '"
+ rbResource.getFullPath().toOSString() + "'");
-
- RBManager.getInstance(rbResource.getProject()).addBundleResource(rbResource);
+ RBManager.getInstance(rbResource.getProject())
+ .addBundleResource(rbResource);
+
fireResourceBundleChangedEvent(getResourceBundleId(rbResource),
new ResourceBundleChangedEvent(
ResourceBundleChangedEvent.INCLUDED,
@@ -584,6 +590,20 @@
} catch (CoreException e) {
Logger.logError(e);
}
+ } else {
+ // trigger incremental build of included resources
+ for (IResource changedResource : changedResources) {
+ try {
+ Logger.logInfo(String.format(
+ "trigger rebuild for resource: %s",
+ changedResource));
+ changedResource.touch(monitor);
+ } catch (CoreException e) {
+ Logger.logError(String.format(
+ "error during rebuild of resource: %s",
+ changedResource), e);
+ }
+ }
}
fireResourceExclusionEvent(new ResourceExclusionEvent(
diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/analyzer/ResourceFinder.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/analyzer/ResourceFinder.java
index 0f73345..4677027 100644
--- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/analyzer/ResourceFinder.java
+++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/analyzer/ResourceFinder.java
@@ -34,6 +34,8 @@
@Override
public boolean visit(IResource resource) throws CoreException {
+ Logger.logInfo(String.format("resource finder is visiting resource %s", resource));
+
if (I18nBuilder.isResourceAuditable(resource, supportedExtensions)) {
Logger.logInfo("Audit necessary for resource '"
+ resource.getFullPath().toOSString() + "'");
diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/builder/ExtensionManager.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/builder/ExtensionManager.java
index 59f277b..6eed916 100644
--- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/builder/ExtensionManager.java
+++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/builder/ExtensionManager.java
@@ -26,55 +26,71 @@
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.util.IPropertyChangeListener;
-public class ExtensionManager {
+public final class ExtensionManager {
- // list of registered extension plug-ins
- private static List<I18nAuditor> extensions = null;
+ // list of registered extension plug-ins
+ private List<I18nAuditor> extensions = null;
- // change listener for builder property change events
- private static IPropertyChangeListener propertyChangeListener = null;
+ // change listener for builder property change events
+ private IPropertyChangeListener propertyChangeListener = null;
- // file-endings supported by the registered extension plug-ins
- private static Set<String> supportedFileEndings = new HashSet<String>();
+ // file-endings supported by the registered extension plug-ins
+ private Set<String> supportedFileEndings = new HashSet<String>();
+
+ // singleton instance
+ private static ExtensionManager INSTANCE = null;
+
+ private ExtensionManager() {
+ initExtensionManager();
+ }
+
+ public static ExtensionManager getExtensionManager() {
+ if (INSTANCE == null) {
+ INSTANCE = new ExtensionManager();
+ }
+
+ return INSTANCE;
+ }
- public static List<I18nAuditor> getRegisteredI18nAuditors() {
- if (extensions == null) {
- extensions = new ArrayList<I18nAuditor>();
+ private void initExtensionManager() {
+ extensions = new ArrayList<I18nAuditor>();
- // init default auditors
- extensions.add(new RBAuditor());
+ // init default auditors
+ extensions.add(new RBAuditor());
- // lookup registered auditor extensions
- IConfigurationElement[] config = Platform
- .getExtensionRegistry()
- .getConfigurationElementsFor(Activator.BUILDER_EXTENSION_ID);
+ // lookup registered auditor extensions
+ IConfigurationElement[] config = Platform
+ .getExtensionRegistry()
+ .getConfigurationElementsFor(Activator.BUILDER_EXTENSION_ID);
- try {
- for (IConfigurationElement e : config) {
- addExtensionPlugIn((I18nAuditor) e
- .createExecutableExtension("class"));
- }
- } catch (CoreException ex) {
- Logger.logError(ex);
- }
- }
+ try {
+ for (IConfigurationElement e : config) {
+ addExtensionPlugIn((I18nAuditor) e
+ .createExecutableExtension("class"));
+ }
+ } catch (CoreException ex) {
+ Logger.logError(ex);
+ }
+ }
+
+ public List<I18nAuditor> getRegisteredI18nAuditors() {
+
+ // init builder property change listener
+ if (propertyChangeListener == null) {
+ propertyChangeListener = new BuilderPropertyChangeListener();
+ TapiJIPreferences.addPropertyChangeListener(propertyChangeListener);
+ }
- // init builder property change listener
- if (propertyChangeListener == null) {
- propertyChangeListener = new BuilderPropertyChangeListener();
- TapiJIPreferences.addPropertyChangeListener(propertyChangeListener);
- }
+ return extensions;
+ }
- return extensions;
- }
+ public Set<String> getSupportedFileEndings() {
+ return supportedFileEndings;
+ }
- public static Set<String> getSupportedFileEndings() {
- return supportedFileEndings;
- }
-
- private static void addExtensionPlugIn(I18nAuditor extension) {
- I18nAuditor a = extension;
- extensions.add(a);
- supportedFileEndings.addAll(Arrays.asList(a.getFileEndings()));
- }
+ private void addExtensionPlugIn(I18nAuditor extension) {
+ I18nAuditor a = extension;
+ extensions.add(a);
+ supportedFileEndings.addAll(Arrays.asList(a.getFileEndings()));
+ }
}
diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/builder/I18nBuilder.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/builder/I18nBuilder.java
index ae2b951..9124c82 100644
--- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/builder/I18nBuilder.java
+++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/builder/I18nBuilder.java
@@ -44,428 +44,447 @@
public class I18nBuilder extends IncrementalProjectBuilder {
- public static final String BUILDER_ID = ResourceBundleManager.BUILDER_ID;
+ public static final String BUILDER_ID = ResourceBundleManager.BUILDER_ID;
+
+ private static final ExtensionManager extensionManager = ExtensionManager.getExtensionManager();
- public static I18nAuditor getI18nAuditorByContext(String contextId)
- throws NoSuchResourceAuditorException {
- for (I18nAuditor auditor : ExtensionManager.getRegisteredI18nAuditors()) {
- if (auditor.getContextId().equals(contextId)) {
- return auditor;
- }
- }
- throw new NoSuchResourceAuditorException();
- }
+ public static I18nAuditor getI18nAuditorByContext(String contextId)
+ throws NoSuchResourceAuditorException {
+ for (I18nAuditor auditor : extensionManager.getRegisteredI18nAuditors()) {
+ if (auditor.getContextId().equals(contextId)) {
+ return auditor;
+ }
+ }
+ throw new NoSuchResourceAuditorException();
+ }
- public static boolean isResourceAuditable(IResource resource,
- Set<String> supportedExtensions) {
- for (String ext : supportedExtensions) {
- if (resource.getType() == IResource.FILE && !resource.isDerived()
- && resource.getFileExtension() != null
- && (resource.getFileExtension().equalsIgnoreCase(ext))) {
- return true;
- }
- }
- return false;
- }
+ public static boolean isResourceAuditable(IResource resource,
+ Set<String> supportedExtensions) {
+ for (String ext : supportedExtensions) {
+ if (resource.getType() == IResource.FILE && !resource.isDerived()
+ && resource.getFileExtension() != null
+ && (resource.getFileExtension().equalsIgnoreCase(ext))) {
+ return true;
+ }
+ }
+ return false;
+ }
- @Override
- protected IProject[] build(final int kind, Map args,
- IProgressMonitor monitor) throws CoreException {
+ @Override
+ protected IProject[] build(final int kind, Map args,
+ IProgressMonitor monitor) throws CoreException {
- ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
- @Override
- public void run(IProgressMonitor monitor) throws CoreException {
- if (kind == FULL_BUILD) {
- fullBuild(monitor);
- } else {
- // only perform audit if the resource delta is not empty
- IResourceDelta resDelta = getDelta(getProject());
+ ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
+ @Override
+ public void run(IProgressMonitor monitor) throws CoreException {
+ if (kind == FULL_BUILD) {
+ Logger.logInfo("full project build was triggered");
+ fullBuild(monitor);
+ } else {
+ Logger.logInfo("incremental project build was triggered for: ");
+ // only perform audit if the resource delta is not empty
+ IResourceDelta resDelta = getDelta(getProject());
- if (resDelta == null) {
- return;
- }
+ if (resDelta == null) {
+ Logger.logInfo(" (empty resource delta)");
+ return;
+ }
- if (resDelta.getAffectedChildren() == null) {
- return;
- }
+ if (resDelta.getAffectedChildren() == null) {
+ Logger.logInfo(" (empty resource delta)");
+ return;
+ }
- incrementalBuild(monitor, resDelta);
- }
- }
- }, monitor);
+ incrementalBuild(monitor, resDelta);
+ }
+ }
+ }, monitor);
- return null;
- }
+ return null;
+ }
- private void incrementalBuild(IProgressMonitor monitor,
- IResourceDelta resDelta) throws CoreException {
- try {
- // inspect resource delta
- ResourceFinder csrav = new ResourceFinder(
- ExtensionManager.getSupportedFileEndings());
- resDelta.accept(csrav);
- auditResources(csrav.getResources(), monitor, getProject());
- } catch (CoreException e) {
- Logger.logError(e);
- }
- }
+ private void incrementalBuild(IProgressMonitor monitor,
+ IResourceDelta resDelta) throws CoreException {
+ try {
+ for (final IResourceDelta changedResource : resDelta
+ .getAffectedChildren()) {
+ Logger.logInfo(String.format(" - %s",
+ changedResource.getResource()));
+ }
- public void buildResource(IResource resource, IProgressMonitor monitor) {
- if (isResourceAuditable(resource,
- ExtensionManager.getSupportedFileEndings())) {
- List<IResource> resources = new ArrayList<IResource>();
- resources.add(resource);
- // TODO: create instance of progressmonitor and hand it over to
- // auditResources
- try {
- auditResources(resources, monitor, resource.getProject());
- } catch (Exception e) {
- Logger.logError(e);
- }
- }
- }
+ // inspect resource delta
+ Logger.logInfo(String
+ .format("looking for resources with the following file endings: %s",
+ extensionManager.getSupportedFileEndings()));
+ ResourceFinder csrav = new ResourceFinder(
+ extensionManager.getSupportedFileEndings());
+ resDelta.accept(csrav);
- public void buildProject(IProgressMonitor monitor, IProject proj) {
- try {
- ResourceFinder csrav = new ResourceFinder(
- ExtensionManager.getSupportedFileEndings());
- proj.accept(csrav);
- auditResources(csrav.getResources(), monitor, proj);
- } catch (CoreException e) {
- Logger.logError(e);
- }
- }
+ Logger.logInfo(String.format(
+ "Audit triggered for derived resources: %s",
+ csrav.getResources()));
+ auditResources(csrav.getResources(), monitor, getProject());
+ } catch (CoreException e) {
+ Logger.logError(e);
+ }
+ }
- private void fullBuild(IProgressMonitor monitor) {
- buildProject(monitor, getProject());
- }
+ public void buildResource(IResource resource, IProgressMonitor monitor) {
+ if (isResourceAuditable(resource,
+ extensionManager.getSupportedFileEndings())) {
+ List<IResource> resources = new ArrayList<IResource>();
+ resources.add(resource);
+ // TODO: create instance of progressmonitor and hand it over to
+ // auditResources
+ try {
+ auditResources(resources, monitor, resource.getProject());
+ } catch (Exception e) {
+ Logger.logError(e);
+ }
+ }
+ }
- private void auditResources(List<IResource> resources,
- IProgressMonitor monitor, IProject project) {
- IConfiguration configuration = ConfigurationManager.getInstance()
- .getConfiguration();
+ public void buildProject(IProgressMonitor monitor, IProject proj) {
+ try {
+ ResourceFinder csrav = new ResourceFinder(
+ extensionManager.getSupportedFileEndings());
+ proj.accept(csrav);
+ auditResources(csrav.getResources(), monitor, proj);
+ } catch (CoreException e) {
+ Logger.logError(e);
+ }
+ }
- int work = resources.size();
- if (monitor == null) {
- monitor = new NullProgressMonitor();
- }
+ private void fullBuild(IProgressMonitor monitor) {
+ buildProject(monitor, getProject());
+ }
- monitor.beginTask(
- "Audit resource file for Internationalization problems", work);
-
- for (I18nAuditor ra : ExtensionManager.getRegisteredI18nAuditors()) {
- if (ra instanceof I18nResourceAuditor) {
- ((I18nResourceAuditor)ra).reset();
- }
- }
+ private void auditResources(List<IResource> resources,
+ IProgressMonitor monitor, IProject project) {
+ IConfiguration configuration = ConfigurationManager.getInstance()
+ .getConfiguration();
- for (IResource resource : resources) {
- monitor.subTask("'" + resource.getFullPath().toOSString() + "'");
- if (monitor.isCanceled()) {
- throw new OperationCanceledException();
- }
+ int work = resources.size();
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
- if (!EditorUtils.deleteAuditMarkersForResource(resource)) {
- continue;
- }
+ monitor.beginTask(
+ "Audit resource file for Internationalization problems", work);
- if (ResourceBundleManager.isResourceExcluded(resource)) {
- continue;
- }
+ for (I18nAuditor ra : extensionManager.getRegisteredI18nAuditors()) {
+ if (ra instanceof I18nResourceAuditor) {
+ ((I18nResourceAuditor) ra).reset();
+ }
+ }
- if (!resource.exists()) {
- continue;
- }
+ for (IResource resource : resources) {
+ monitor.subTask("'" + resource.getFullPath().toOSString() + "'");
+ if (monitor.isCanceled()) {
+ throw new OperationCanceledException();
+ }
- for (I18nAuditor ra : ExtensionManager.getRegisteredI18nAuditors()) {
- if (ra instanceof I18nResourceAuditor
- && !(configuration.getAuditResource())) {
- continue;
- }
- if (ra instanceof I18nRBAuditor
- && !(configuration.getAuditRb())) {
- continue;
- }
+ if (!EditorUtils.deleteAuditMarkersForResource(resource)) {
+ continue;
+ }
- try {
- if (monitor.isCanceled()) {
- monitor.done();
- break;
- }
+ if (ResourceBundleManager.isResourceExcluded(resource)) {
+ continue;
+ }
- if (ra.isResourceOfType(resource)) {
- ra.audit(resource);
- }
- } catch (Exception e) {
- Logger.logError(
- "Error during auditing '" + resource.getFullPath()
- + "'", e);
- }
- }
+ if (!resource.exists()) {
+ continue;
+ }
- if (monitor != null) {
- monitor.worked(1);
- }
- }
+ for (I18nAuditor ra : extensionManager.getRegisteredI18nAuditors()) {
+ if (ra instanceof I18nResourceAuditor
+ && !(configuration.getAuditResource())) {
+ continue;
+ }
+ if (ra instanceof I18nRBAuditor
+ && !(configuration.getAuditRb())) {
+ continue;
+ }
- for (I18nAuditor a : ExtensionManager.getRegisteredI18nAuditors()) {
- if (a instanceof I18nResourceAuditor) {
- handleI18NAuditorMarkers((I18nResourceAuditor) a);
- }
- if (a instanceof I18nRBAuditor) {
- handleI18NAuditorMarkers((I18nRBAuditor) a);
- ((I18nRBAuditor) a).resetProblems();
- }
- }
+ try {
+ if (monitor.isCanceled()) {
+ monitor.done();
+ break;
+ }
- monitor.done();
- }
+ if (ra.isResourceOfType(resource)) {
+ ra.audit(resource);
+ }
+ } catch (Exception e) {
+ Logger.logError(
+ "Error during auditing '" + resource.getFullPath()
+ + "'", e);
+ }
+ }
- private void handleI18NAuditorMarkers(I18nResourceAuditor ra) {
- try {
- for (ILocation problem : ra.getConstantStringLiterals()) {
- EditorUtils
- .reportToMarker(
- org.eclipse.babel.tapiji.tools.core.util.EditorUtils
- .getFormattedMessage(
- org.eclipse.babel.tapiji.tools.core.util.EditorUtils.MESSAGE_NON_LOCALIZED_LITERAL,
- new String[] { problem
- .getLiteral() }),
- problem,
- MarkerConstants.CAUSE_CONSTANT_LITERAL, "",
- (ILocation) problem.getData(), ra
- .getContextId());
- }
+ if (monitor != null) {
+ monitor.worked(1);
+ }
+ }
- // Report all broken Resource-Bundle references
- for (ILocation brokenLiteral : ra.getBrokenResourceReferences()) {
- EditorUtils
- .reportToMarker(
- org.eclipse.babel.tapiji.tools.core.util.EditorUtils
- .getFormattedMessage(
- org.eclipse.babel.tapiji.tools.core.util.EditorUtils.MESSAGE_BROKEN_RESOURCE_REFERENCE,
- new String[] {
- brokenLiteral
- .getLiteral(),
- ((ILocation) brokenLiteral
- .getData())
- .getLiteral() }),
- brokenLiteral,
- MarkerConstants.CAUSE_BROKEN_REFERENCE,
- brokenLiteral.getLiteral(),
- (ILocation) brokenLiteral.getData(), ra
- .getContextId());
- }
+ for (I18nAuditor a : extensionManager.getRegisteredI18nAuditors()) {
+ if (a instanceof I18nResourceAuditor) {
+ handleI18NAuditorMarkers((I18nResourceAuditor) a);
+ }
+ if (a instanceof I18nRBAuditor) {
+ handleI18NAuditorMarkers((I18nRBAuditor) a);
+ ((I18nRBAuditor) a).resetProblems();
+ }
+ }
- // Report all broken definitions to Resource-Bundle
- // references
- for (ILocation brokenLiteral : ra.getBrokenBundleReferences()) {
- EditorUtils
- .reportToMarker(
- org.eclipse.babel.tapiji.tools.core.util.EditorUtils
- .getFormattedMessage(
- org.eclipse.babel.tapiji.tools.core.util.EditorUtils.MESSAGE_BROKEN_RESOURCE_BUNDLE_REFERENCE,
- new String[] { brokenLiteral
- .getLiteral() }),
- brokenLiteral,
- MarkerConstants.CAUSE_BROKEN_RB_REFERENCE,
- brokenLiteral.getLiteral(),
- (ILocation) brokenLiteral.getData(), ra
- .getContextId());
- }
- } catch (Exception e) {
- Logger.logError(
- "Exception during reporting of Internationalization errors",
- e);
- }
- }
+ monitor.done();
+ }
- private void handleI18NAuditorMarkers(I18nRBAuditor ra) {
- IConfiguration configuration = ConfigurationManager.getInstance()
- .getConfiguration();
- try {
- // Report all unspecified keys
- if (configuration.getAuditMissingValue()) {
- for (ILocation problem : ra.getUnspecifiedKeyReferences()) {
- EditorUtils
- .reportToRBMarker(
- org.eclipse.babel.tapiji.tools.core.util.EditorUtils
- .getFormattedMessage(
- org.eclipse.babel.tapiji.tools.core.util.EditorUtils.MESSAGE_UNSPECIFIED_KEYS,
- new String[] {
- problem.getLiteral(),
- problem.getFile()
- .getName() }),
- problem,
- MarkerConstants.CAUSE_UNSPEZIFIED_KEY,
- problem.getLiteral(), "",
- (ILocation) problem.getData(), ra
- .getContextId());
- }
- }
+ private void handleI18NAuditorMarkers(I18nResourceAuditor ra) {
+ try {
+ for (ILocation problem : ra.getConstantStringLiterals()) {
+ EditorUtils
+ .reportToMarker(
+ org.eclipse.babel.tapiji.tools.core.util.EditorUtils
+ .getFormattedMessage(
+ org.eclipse.babel.tapiji.tools.core.util.EditorUtils.MESSAGE_NON_LOCALIZED_LITERAL,
+ new String[] { problem
+ .getLiteral() }),
+ problem,
+ MarkerConstants.CAUSE_CONSTANT_LITERAL, "",
+ (ILocation) problem.getData(), ra
+ .getContextId());
+ }
- // Report all same values
- if (configuration.getAuditSameValue()) {
- Map<ILocation, ILocation> sameValues = ra
- .getSameValuesReferences();
- for (ILocation problem : sameValues.keySet()) {
- EditorUtils
- .reportToRBMarker(
- org.eclipse.babel.tapiji.tools.core.util.EditorUtils
- .getFormattedMessage(
- org.eclipse.babel.tapiji.tools.core.util.EditorUtils.MESSAGE_SAME_VALUE,
- new String[] {
- problem.getFile()
- .getName(),
- sameValues
- .get(problem)
- .getFile()
- .getName(),
- problem.getLiteral() }),
- problem,
- MarkerConstants.CAUSE_SAME_VALUE,
- problem.getLiteral(),
- sameValues.get(problem).getFile().getName(),
- (ILocation) problem.getData(), ra
- .getContextId());
- }
- }
- // Report all missing languages
- if (configuration.getAuditMissingLanguage()) {
- for (ILocation problem : ra.getMissingLanguageReferences()) {
- EditorUtils
- .reportToRBMarker(
- org.eclipse.babel.tapiji.tools.core.util.EditorUtils
- .getFormattedMessage(
- org.eclipse.babel.tapiji.tools.core.util.EditorUtils.MESSAGE_MISSING_LANGUAGE,
- new String[] {
- RBFileUtils
- .getCorrespondingResourceBundleId(problem
- .getFile()),
- problem.getLiteral() }),
- problem,
- MarkerConstants.CAUSE_MISSING_LANGUAGE,
- problem.getLiteral(), "",
- (ILocation) problem.getData(), ra
- .getContextId());
- }
- }
- } catch (Exception e) {
- Logger.logError(
- "Exception during reporting of Internationalization errors",
- e);
- }
- }
+ // Report all broken Resource-Bundle references
+ for (ILocation brokenLiteral : ra.getBrokenResourceReferences()) {
+ EditorUtils
+ .reportToMarker(
+ org.eclipse.babel.tapiji.tools.core.util.EditorUtils
+ .getFormattedMessage(
+ org.eclipse.babel.tapiji.tools.core.util.EditorUtils.MESSAGE_BROKEN_RESOURCE_REFERENCE,
+ new String[] {
+ brokenLiteral
+ .getLiteral(),
+ ((ILocation) brokenLiteral
+ .getData())
+ .getLiteral() }),
+ brokenLiteral,
+ MarkerConstants.CAUSE_BROKEN_REFERENCE,
+ brokenLiteral.getLiteral(),
+ (ILocation) brokenLiteral.getData(), ra
+ .getContextId());
+ }
- @SuppressWarnings("unused")
- private void setProgress(IProgressMonitor monitor, int progress)
- throws InterruptedException {
- monitor.worked(progress);
+ // Report all broken definitions to Resource-Bundle
+ // references
+ for (ILocation brokenLiteral : ra.getBrokenBundleReferences()) {
+ EditorUtils
+ .reportToMarker(
+ org.eclipse.babel.tapiji.tools.core.util.EditorUtils
+ .getFormattedMessage(
+ org.eclipse.babel.tapiji.tools.core.util.EditorUtils.MESSAGE_BROKEN_RESOURCE_BUNDLE_REFERENCE,
+ new String[] { brokenLiteral
+ .getLiteral() }),
+ brokenLiteral,
+ MarkerConstants.CAUSE_BROKEN_RB_REFERENCE,
+ brokenLiteral.getLiteral(),
+ (ILocation) brokenLiteral.getData(), ra
+ .getContextId());
+ }
+ } catch (Exception e) {
+ Logger.logError(
+ "Exception during reporting of Internationalization errors",
+ e);
+ }
+ }
- if (monitor.isCanceled()) {
- throw new OperationCanceledException();
- }
+ private void handleI18NAuditorMarkers(I18nRBAuditor ra) {
+ IConfiguration configuration = ConfigurationManager.getInstance()
+ .getConfiguration();
+ try {
+ // Report all unspecified keys
+ if (configuration.getAuditMissingValue()) {
+ for (ILocation problem : ra.getUnspecifiedKeyReferences()) {
+ EditorUtils
+ .reportToRBMarker(
+ org.eclipse.babel.tapiji.tools.core.util.EditorUtils
+ .getFormattedMessage(
+ org.eclipse.babel.tapiji.tools.core.util.EditorUtils.MESSAGE_UNSPECIFIED_KEYS,
+ new String[] {
+ problem.getLiteral(),
+ problem.getFile()
+ .getName() }),
+ problem,
+ MarkerConstants.CAUSE_UNSPEZIFIED_KEY,
+ problem.getLiteral(), "",
+ (ILocation) problem.getData(), ra
+ .getContextId());
+ }
+ }
- if (isInterrupted()) {
- throw new InterruptedException();
- }
- }
+ // Report all same values
+ if (configuration.getAuditSameValue()) {
+ Map<ILocation, ILocation> sameValues = ra
+ .getSameValuesReferences();
+ for (ILocation problem : sameValues.keySet()) {
+ EditorUtils
+ .reportToRBMarker(
+ org.eclipse.babel.tapiji.tools.core.util.EditorUtils
+ .getFormattedMessage(
+ org.eclipse.babel.tapiji.tools.core.util.EditorUtils.MESSAGE_SAME_VALUE,
+ new String[] {
+ problem.getFile()
+ .getName(),
+ sameValues
+ .get(problem)
+ .getFile()
+ .getName(),
+ problem.getLiteral() }),
+ problem,
+ MarkerConstants.CAUSE_SAME_VALUE,
+ problem.getLiteral(),
+ sameValues.get(problem).getFile().getName(),
+ (ILocation) problem.getData(), ra
+ .getContextId());
+ }
+ }
+ // Report all missing languages
+ if (configuration.getAuditMissingLanguage()) {
+ for (ILocation problem : ra.getMissingLanguageReferences()) {
+ EditorUtils
+ .reportToRBMarker(
+ org.eclipse.babel.tapiji.tools.core.util.EditorUtils
+ .getFormattedMessage(
+ org.eclipse.babel.tapiji.tools.core.util.EditorUtils.MESSAGE_MISSING_LANGUAGE,
+ new String[] {
+ RBFileUtils
+ .getCorrespondingResourceBundleId(problem
+ .getFile()),
+ problem.getLiteral() }),
+ problem,
+ MarkerConstants.CAUSE_MISSING_LANGUAGE,
+ problem.getLiteral(), "",
+ (ILocation) problem.getData(), ra
+ .getContextId());
+ }
+ }
+ } catch (Exception e) {
+ Logger.logError(
+ "Exception during reporting of Internationalization errors",
+ e);
+ }
+ }
- @Override
- protected void clean(IProgressMonitor monitor) throws CoreException {
- // TODO Auto-generated method stub
- super.clean(monitor);
- }
+ @SuppressWarnings("unused")
+ private void setProgress(IProgressMonitor monitor, int progress)
+ throws InterruptedException {
+ monitor.worked(progress);
- public static void addBuilderToProject(IProject project) {
- Logger.logInfo("Internationalization-Builder registered for '"
- + project.getName() + "'");
+ if (monitor.isCanceled()) {
+ throw new OperationCanceledException();
+ }
- // Only for open projects
- if (!project.isOpen()) {
- return;
- }
+ if (isInterrupted()) {
+ throw new InterruptedException();
+ }
+ }
- IProjectDescription description = null;
- try {
- description = project.getDescription();
- } catch (CoreException e) {
- Logger.logError(e);
- return;
- }
+ @Override
+ protected void clean(IProgressMonitor monitor) throws CoreException {
+ // TODO Auto-generated method stub
+ super.clean(monitor);
+ }
- // Check if the builder is already associated to the specified project
- ICommand[] commands = description.getBuildSpec();
- for (ICommand command : commands) {
- if (command.getBuilderName().equals(BUILDER_ID)) {
- return;
- }
- }
+ public static void addBuilderToProject(IProject project) {
+ Logger.logInfo("Internationalization-Builder registered for '"
+ + project.getName() + "'");
- // Associate the builder with the project
- ICommand builderCmd = description.newCommand();
- builderCmd.setBuilderName(BUILDER_ID);
- List<ICommand> newCommands = new ArrayList<ICommand>();
- newCommands.addAll(Arrays.asList(commands));
- newCommands.add(builderCmd);
- description.setBuildSpec(newCommands.toArray(new ICommand[newCommands
- .size()]));
+ // Only for open projects
+ if (!project.isOpen()) {
+ return;
+ }
- try {
- project.setDescription(description, null);
- } catch (CoreException e) {
- Logger.logError(e);
- }
- }
+ IProjectDescription description = null;
+ try {
+ description = project.getDescription();
+ } catch (CoreException e) {
+ Logger.logError(e);
+ return;
+ }
- public static void removeBuilderFromProject(IProject project) {
- // Only for open projects
- if (!project.isOpen()) {
- return;
- }
+ // Check if the builder is already associated to the specified project
+ ICommand[] commands = description.getBuildSpec();
+ for (ICommand command : commands) {
+ if (command.getBuilderName().equals(BUILDER_ID)) {
+ return;
+ }
+ }
- try {
- project.deleteMarkers(EditorUtils.MARKER_ID, false,
- IResource.DEPTH_INFINITE);
- project.deleteMarkers(EditorUtils.RB_MARKER_ID, false,
- IResource.DEPTH_INFINITE);
- } catch (CoreException e1) {
- Logger.logError(e1);
- }
+ // Associate the builder with the project
+ ICommand builderCmd = description.newCommand();
+ builderCmd.setBuilderName(BUILDER_ID);
+ List<ICommand> newCommands = new ArrayList<ICommand>();
+ newCommands.addAll(Arrays.asList(commands));
+ newCommands.add(builderCmd);
+ description.setBuildSpec(newCommands.toArray(new ICommand[newCommands
+ .size()]));
- IProjectDescription description = null;
- try {
- description = project.getDescription();
- } catch (CoreException e) {
- Logger.logError(e);
- return;
- }
+ try {
+ project.setDescription(description, null);
+ } catch (CoreException e) {
+ Logger.logError(e);
+ }
+ }
- // remove builder from project
- int idx = -1;
- ICommand[] commands = description.getBuildSpec();
- for (int i = 0; i < commands.length; i++) {
- if (commands[i].getBuilderName().equals(BUILDER_ID)) {
- idx = i;
- break;
- }
- }
- if (idx == -1) {
- return;
- }
+ public static void removeBuilderFromProject(IProject project) {
+ // Only for open projects
+ if (!project.isOpen()) {
+ return;
+ }
- List<ICommand> newCommands = new ArrayList<ICommand>();
- newCommands.addAll(Arrays.asList(commands));
- newCommands.remove(idx);
- description.setBuildSpec(newCommands.toArray(new ICommand[newCommands
- .size()]));
+ try {
+ project.deleteMarkers(EditorUtils.MARKER_ID, false,
+ IResource.DEPTH_INFINITE);
+ project.deleteMarkers(EditorUtils.RB_MARKER_ID, false,
+ IResource.DEPTH_INFINITE);
+ } catch (CoreException e1) {
+ Logger.logError(e1);
+ }
- try {
- project.setDescription(description, null);
- } catch (CoreException e) {
- Logger.logError(e);
- }
+ IProjectDescription description = null;
+ try {
+ description = project.getDescription();
+ } catch (CoreException e) {
+ Logger.logError(e);
+ return;
+ }
- }
+ // remove builder from project
+ int idx = -1;
+ ICommand[] commands = description.getBuildSpec();
+ for (int i = 0; i < commands.length; i++) {
+ if (commands[i].getBuilderName().equals(BUILDER_ID)) {
+ idx = i;
+ break;
+ }
+ }
+ if (idx == -1) {
+ return;
+ }
+
+ List<ICommand> newCommands = new ArrayList<ICommand>();
+ newCommands.addAll(Arrays.asList(commands));
+ newCommands.remove(idx);
+ description.setBuildSpec(newCommands.toArray(new ICommand[newCommands
+ .size()]));
+
+ try {
+ project.setDescription(description, null);
+ } catch (CoreException e) {
+ Logger.logError(e);
+ }
+
+ }
}
diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/menus/InternationalizationMenu.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/menus/InternationalizationMenu.java
index bc69e95..adb6336 100644
--- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/menus/InternationalizationMenu.java
+++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/menus/InternationalizationMenu.java
@@ -295,8 +295,6 @@
final Class<? extends IAdaptable> type,
final ISelection selection) {
if (selection instanceof IStructuredSelection) {
- System.out.println(((IStructuredSelection) selection)
- .getFirstElement().getClass());
return type.isAssignableFrom(((IStructuredSelection) selection)
.getFirstElement().getClass());
}