summaryrefslogtreecommitdiff
path: root/src/plugins/snippets/src/com/motorola/studio/android/codesnippets
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/snippets/src/com/motorola/studio/android/codesnippets')
-rw-r--r--src/plugins/snippets/src/com/motorola/studio/android/codesnippets/AndroidPermissionInsertSnippet.java274
-rw-r--r--src/plugins/snippets/src/com/motorola/studio/android/codesnippets/AndroidSnippetsStartup.java338
-rw-r--r--src/plugins/snippets/src/com/motorola/studio/android/codesnippets/AndroidSnippetsTooltip.java147
-rw-r--r--src/plugins/snippets/src/com/motorola/studio/android/codesnippets/CodeSnippetsPlugin.java69
-rw-r--r--src/plugins/snippets/src/com/motorola/studio/android/codesnippets/SnippetsViewContributionItem.java227
-rw-r--r--src/plugins/snippets/src/com/motorola/studio/android/codesnippets/TooltipDisplayConfigContriutionItem.java164
-rw-r--r--src/plugins/snippets/src/com/motorola/studio/android/codesnippets/i18n/AndroidSnippetsNLS.java55
-rw-r--r--src/plugins/snippets/src/com/motorola/studio/android/codesnippets/i18n/androidSnippetsNLS.properties7
8 files changed, 1281 insertions, 0 deletions
diff --git a/src/plugins/snippets/src/com/motorola/studio/android/codesnippets/AndroidPermissionInsertSnippet.java b/src/plugins/snippets/src/com/motorola/studio/android/codesnippets/AndroidPermissionInsertSnippet.java
new file mode 100644
index 0000000..5743e16
--- /dev/null
+++ b/src/plugins/snippets/src/com/motorola/studio/android/codesnippets/AndroidPermissionInsertSnippet.java
@@ -0,0 +1,274 @@
+/*
+* Copyright (C) 2012 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package com.motorola.studio.android.codesnippets;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.dnd.DragSourceEvent;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.wst.common.snippets.core.ISnippetItem;
+import org.eclipse.wst.common.snippets.core.ISnippetsEntry;
+import org.eclipse.wst.common.snippets.internal.ui.SnippetsView;
+import org.eclipse.wst.common.snippets.ui.DefaultSnippetInsertion;
+
+import com.motorola.studio.android.codesnippets.i18n.AndroidSnippetsNLS;
+import com.motorola.studio.android.common.log.StudioLogger;
+import com.motorola.studio.android.common.log.UsageDataConstants;
+import com.motorola.studio.android.common.utilities.EclipseUtils;
+import com.motorola.studio.android.manifest.AndroidProjectManifestFile;
+import com.motorola.studio.android.model.manifest.AndroidManifestFile;
+import com.motorola.studio.android.model.manifest.dom.ManifestNode;
+import com.motorola.studio.android.model.manifest.dom.UsesPermissionNode;
+
+public class AndroidPermissionInsertSnippet extends DefaultSnippetInsertion
+{
+
+ @Override
+ protected void doInsert(IEditorPart editorPart, ITextEditor textEditor, IDocument document,
+ ITextSelection textSelection) throws BadLocationException
+ {
+ String replacement = getInsertString(editorPart.getEditorSite().getShell());
+ boolean permissionsAdded = addPermissionToManifest(editorPart, replacement);
+
+ // get the Snippets View
+ SnippetsView snippetsView =
+ (SnippetsView) EclipseUtils.getActiveView(AndroidSnippetsStartup.SNIPPETS_VIEW_ID);
+ // get the selected snippet
+ ISnippetsEntry snippetEntry = snippetsView.getSelectedEntry();
+ if (snippetEntry != null)
+ {
+ String snippetLabel = snippetEntry.getLabel();
+
+ if (CodeSnippetsPlugin.getDefault() != null)
+ {
+ StudioLogger
+ .collectUsageData(
+ UsageDataConstants.WHAT_CODESNIPPET,
+ UsageDataConstants.KIND_CODESNIPPET,
+ "Codesnippet '" + snippetLabel + "' used. Permission added: " + permissionsAdded, //$NON-NLS-1$
+ AndroidSnippetsStartup.SNIPPETS_VIEW_ID, CodeSnippetsPlugin
+ .getDefault().getBundle().getVersion().toString());
+ }
+ }
+
+ super.doInsert(editorPart, textEditor, document, textSelection);
+ }
+
+ /**
+ * If the snippetText contains comment to insert uses-permission, then
+ * it adds uses-permission to androidmanifest file
+ * @param editorPart editor
+ * @param snippetText text to drop
+ */
+ private boolean addPermissionToManifest(IEditorPart editorPart, String snippetText)
+ {
+ boolean needToAddPermission =
+ snippetText.contains("AndroidManifest.xml must have the following permission:"); //$NON-NLS-1$
+ boolean shouldAddToManifest = false;
+ if (needToAddPermission)
+ {
+
+ List<String> neededPermissions = getNeededPermissions(snippetText);
+ List<String> permissionsToBeAdded = new ArrayList<String>(neededPermissions.size());
+
+ IEditorInput input = editorPart.getEditorInput();
+ FileEditorInput fileEditorInput = null;
+ ManifestNode manifestNode = null;
+ if (input instanceof FileEditorInput)
+ {
+ fileEditorInput = (FileEditorInput) input;
+ IProject project;
+ IFile file = fileEditorInput.getFile();
+ project = file.getProject();
+ try
+ {
+ AndroidManifestFile androidManifestFile =
+ AndroidProjectManifestFile.getFromProject(project);
+ manifestNode = androidManifestFile.getManifestNode();
+ }
+ catch (Exception e)
+ {
+ // Do nothing, just ask for the permissions.
+ }
+ }
+
+ if (manifestNode != null)
+ {
+ for (String neededPermission : neededPermissions)
+ {
+ if (!permAlreadyExists(manifestNode, neededPermission))
+ {
+ permissionsToBeAdded.add(neededPermission);
+ }
+ }
+ }
+
+ if (!permissionsToBeAdded.isEmpty())
+ {
+
+ StringBuilder permMsgBuilder = new StringBuilder();
+ for (String neededPermission : permissionsToBeAdded)
+ {
+ permMsgBuilder
+ .append(AndroidSnippetsNLS.AndroidPermissionInsertSnippet_PermissionPrefix);
+ permMsgBuilder.append(neededPermission);
+ permMsgBuilder
+ .append(AndroidSnippetsNLS.AndroidPermissionInsertSnippet_PermissionSuffix);
+ }
+
+ //Ask user permission
+ shouldAddToManifest =
+ EclipseUtils
+ .showQuestionDialog(
+ AndroidSnippetsNLS.AndroidPermissionInsertSnippet_Msg_AddToManifest_Title,
+ NLS.bind(
+ AndroidSnippetsNLS.AndroidPermissionInsertSnippet_Msg_AddToManifest_Msg,
+ permMsgBuilder.toString()));
+
+ if (shouldAddToManifest)
+ {
+ AndroidManifestFile androidManifestFile = null;
+ manifestNode = null;
+ if (fileEditorInput != null)
+ {
+ addPermissionToManifest(permissionsToBeAdded, fileEditorInput,
+ androidManifestFile, manifestNode);
+ }
+
+ }
+ }
+ }
+ return shouldAddToManifest;
+ }
+
+ private List<String> getNeededPermissions(String snippetText)
+ {
+ //search each <uses-permission tag
+ StringTokenizer lineToken = new StringTokenizer(snippetText, "\n\r"); //$NON-NLS-1$
+ List<String> neededPermissions = new ArrayList<String>(lineToken.countTokens());
+ while (lineToken.hasMoreTokens())
+ {
+ String line = lineToken.nextToken();
+ if (line.contains("<uses-permission")) //$NON-NLS-1$
+ {
+ String permNameToAdd = null;
+ String androidNameStr = "android:name=\""; //$NON-NLS-1$
+ int beginIndex = line.indexOf(androidNameStr);
+ int endIndex = line.indexOf("\"/>"); //$NON-NLS-1$
+ if ((beginIndex > 0) && (endIndex > 0))
+ {
+ permNameToAdd = line.substring(beginIndex + androidNameStr.length(), endIndex);
+ neededPermissions.add(permNameToAdd);
+ }
+ else
+ {
+ //log malformed permission statement
+ StudioLogger
+ .error(AndroidPermissionInsertSnippet.class,
+ "Permission code snippet was not in the right format to enable insert of uses-permission on androidmanifest.xml" //$NON-NLS-1$
+ + snippetText);
+ }
+ }
+ }
+
+ return neededPermissions;
+ }
+
+ /**
+ * If the snippetText contains comment to insert uses-permission, then
+ * it asks user to add uses-permission to androidmanifest file
+ * @param snippetText text to drop
+ * @param input editor
+ * @param androidManifestFile file to update
+ * @param manifestNode node to update
+ */
+ private void addPermissionToManifest(List<String> neededPermissions, IEditorInput input,
+ AndroidManifestFile androidManifestFile, ManifestNode manifestNode)
+ {
+ IProject project;
+ IFile file = ((FileEditorInput) input).getFile();
+ project = file.getProject();
+ try
+ {
+ androidManifestFile = AndroidProjectManifestFile.getFromProject(project);
+ manifestNode = androidManifestFile.getManifestNode();
+
+ for (String neededPermission : neededPermissions)
+ {
+ if (!permAlreadyExists(manifestNode, neededPermission))
+ {
+ //append permission node
+ UsesPermissionNode usesPermissionNode =
+ new UsesPermissionNode(neededPermission);
+ manifestNode.addChild(usesPermissionNode);
+ }
+ }
+
+ AndroidProjectManifestFile.saveToProject(project, androidManifestFile, true);
+ }
+ catch (Exception e)
+ {
+ StudioLogger.error(AndroidPermissionInsertSnippet.class,
+ "Error adding snippet permissions to androidmanifest.xml.", e); //$NON-NLS-1$
+ }
+ }
+
+ private boolean permAlreadyExists(ManifestNode manifestNode, String neededPermission)
+ {
+ //Check if permissions does not exist yet
+ boolean permAlreadyExists = false;
+ List<UsesPermissionNode> permissionsNode = manifestNode.getUsesPermissionNodes();
+
+ if (permissionsNode != null)
+ {
+ for (UsesPermissionNode existentPermissionNode : permissionsNode)
+ {
+ String permName =
+ existentPermissionNode.getNodeProperties()
+ .get(UsesPermissionNode.PROP_NAME);
+ if ((permName != null) && permName.equals(neededPermission))
+ {
+ permAlreadyExists = true;
+ break;
+ }
+ }
+ }
+ return permAlreadyExists;
+ }
+
+ @Override
+ public void dragSetData(DragSourceEvent event, ISnippetItem item)
+ {
+ IEditorPart part =
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
+ .getActiveEditor();
+ addPermissionToManifest(part, item.getContentString());
+ super.dragSetData(event, item);
+ }
+}
diff --git a/src/plugins/snippets/src/com/motorola/studio/android/codesnippets/AndroidSnippetsStartup.java b/src/plugins/snippets/src/com/motorola/studio/android/codesnippets/AndroidSnippetsStartup.java
new file mode 100644
index 0000000..e555654
--- /dev/null
+++ b/src/plugins/snippets/src/com/motorola/studio/android/codesnippets/AndroidSnippetsStartup.java
@@ -0,0 +1,338 @@
+/*
+* Copyright (C) 2012 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package com.motorola.studio.android.codesnippets;
+
+import org.eclipse.gef.ui.palette.PaletteViewer;
+import org.eclipse.jface.action.ToolBarManager;
+import org.eclipse.swt.events.DragDetectEvent;
+import org.eclipse.swt.events.DragDetectListener;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.IPerspectiveDescriptor;
+import org.eclipse.ui.IPerspectiveListener;
+import org.eclipse.ui.IStartup;
+import org.eclipse.ui.IViewReference;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPartReference;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PerspectiveAdapter;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.wst.common.snippets.core.ISnippetItem;
+import org.eclipse.wst.common.snippets.core.ISnippetsEntry;
+import org.eclipse.wst.common.snippets.internal.ui.SnippetsView;
+
+import com.motorola.studio.android.common.utilities.EclipseUtils;
+
+/**
+ * This class register listeners in the Snippets View to monitor changes on its
+ * selection. This way, MOTODEV Studio for Android displays the snippet preview
+ * when appropriate
+ *
+ */
+@SuppressWarnings("restriction")
+public class AndroidSnippetsStartup implements IStartup
+{
+
+ public final static String SNIPPETS_VIEW_ID =
+ "org.eclipse.wst.common.snippets.internal.ui.SnippetsView";
+
+ private static SnippetsViewContributionItem searchContributionItem;
+
+ private static TooltipDisplayConfigContriutionItem tooltipDisplayConfigcontributionItem;
+
+ /*
+ * The tool tip being displayed
+ */
+ private AndroidSnippetsTooltip tooltip = null;
+
+ private static void addSearchBar(final SnippetsView view)
+ {
+ if (searchContributionItem == null)
+ {
+ ToolBarManager tbManager =
+ (ToolBarManager) view.getViewSite().getActionBars().getToolBarManager();
+
+ // the item which searches for words within snippets titles, descriptions and codes
+ searchContributionItem = new SnippetsViewContributionItem(view);
+
+ tbManager.add(searchContributionItem);
+ tbManager.update(true);
+ view.getViewSite().getActionBars().updateActionBars();
+ }
+
+ if (tooltipDisplayConfigcontributionItem == null)
+ {
+ ToolBarManager tbManager =
+ (ToolBarManager) view.getViewSite().getActionBars().getToolBarManager();
+
+ // the item which configures the display of the tool tip
+ tooltipDisplayConfigcontributionItem = new TooltipDisplayConfigContriutionItem();
+
+ tbManager.add(tooltipDisplayConfigcontributionItem);
+ tbManager.update(true);
+ view.getViewSite().getActionBars().updateActionBars();
+ }
+ }
+
+ /**
+ * Add a mouse listener to Snippets View
+ * Open the snippet preview tooltip when the user clicks on a
+ * snippet item.
+ * Close it when he clicks again in the same item
+ *
+ * @see org.eclipse.ui.IStartup#earlyStartup()
+ */
+ public void earlyStartup()
+ {
+
+ /*
+ * This is the listener responsible for monitoring mouse clicks
+ * on snippet items. When the user clicks on an item, it triggers
+ * the action to display the snippet preview
+ */
+ final MouseListener snippetsMouseListener = new MouseListener()
+ {
+ /**
+ * Do nothing
+ *
+ * @see org.eclipse.swt.events.MouseListener#mouseUp(org.eclipse.swt.events.MouseEvent)
+ */
+ public void mouseUp(MouseEvent e)
+ {
+ // nothing
+ }
+
+ /**
+ * Open/Toogle tooltip
+ *
+ * @see org.eclipse.swt.events.MouseListener#mouseDown(org.eclipse.swt.events.MouseEvent)
+ */
+ public void mouseDown(MouseEvent e)
+ {
+
+ // get the Snippets View
+ SnippetsView snippetsView =
+ (SnippetsView) EclipseUtils.getActiveView(SNIPPETS_VIEW_ID);
+
+ // get the selected snippet
+ ISnippetsEntry snippetEntry = snippetsView.getSelectedEntry();
+
+ // check the tooltip is already being displayed
+ // open it if it's not and its config allows so, close it otherwise
+ if ((snippetEntry instanceof ISnippetItem)
+ && ((tooltip == null) || (!tooltip.getItem().equals(snippetEntry)))
+ && tooltipDisplayConfigcontributionItem.isTooltipDisplayed())
+ {
+ Control snippetsControl = snippetsView.getViewer().getControl();
+ tooltip =
+ new AndroidSnippetsTooltip((ISnippetItem) snippetEntry, snippetsControl);
+ tooltip.setPopupDelay(250);
+ tooltip.show(new Point(snippetsControl.getBounds().width, 0));
+
+ }
+ else
+ {
+ if (tooltip != null)
+ {
+ tooltip.hide();
+ }
+ tooltip = null;
+ }
+ }
+
+ /**
+ * Hide tooltip
+ *
+ * @see org.eclipse.swt.events.MouseListener#mouseDoubleClick(org.eclipse.swt.events.MouseEvent)
+ */
+ public void mouseDoubleClick(MouseEvent e)
+ {
+ if (tooltip != null)
+ {
+ tooltip.hide();
+ }
+ tooltip = null;
+ }
+ };
+
+ /**
+ * this listener is called when the mouse is dragged. It simply
+ * hides the tool tip when this action occurs.
+ */
+ final DragDetectListener snippetsMouseDragListener = new DragDetectListener()
+ {
+
+ /**
+ * Hide the tool tip.
+ */
+ public void dragDetected(DragDetectEvent e)
+ {
+ // simply hide the tool tip
+ if (tooltip != null)
+ {
+ tooltip.hide();
+ }
+ }
+ };
+
+ /*
+ * This is the listener that is attached to the workspace and monitor
+ * perspectives activation, as well as changes in the views being displayed
+ * (for example: view opened/closed). It intends to attach the snippetsMouseListener
+ * listener declared above in the Snippets View being used by Eclipse
+ */
+ final IPerspectiveListener perspectiveListener = new PerspectiveAdapter()
+ {
+ // Set if it has already been executed
+ // If so, it doesn't need to be executed again
+ boolean executed = false;
+
+ /**
+ * This action is called when the user goes to another perspective (it's not called for the first perspective
+ * displayed when he opens Eclipse)
+ *
+ * @see org.eclipse.ui.PerspectiveAdapter#perspectiveActivated(org.eclipse.ui.IWorkbenchPage, org.eclipse.ui.IPerspectiveDescriptor)
+ */
+ @Override
+ public void perspectiveActivated(IWorkbenchPage page, IPerspectiveDescriptor perspective)
+ {
+ IViewReference[] viewReferences = page.getViewReferences();
+ for (IViewReference viewReference : viewReferences)
+ {
+ if (SNIPPETS_VIEW_ID.equals(viewReference.getId()))
+ {
+ SnippetsView snippetsView = (SnippetsView) viewReference.getView(true);
+ if (snippetsView != null)
+ {
+ addSearchBar(snippetsView);
+ PaletteViewer palleteViewer = snippetsView.getViewer();
+ if (palleteViewer != null)
+ {
+ Control control = palleteViewer.getControl();
+ if (control != null)
+ {
+ control.removeMouseListener(snippetsMouseListener); // remove mouse listener just to ensure we never have two listeners registered
+ control.removeDragDetectListener(snippetsMouseDragListener); // remove mouse draggable listener just to ensure we never have two listeners registered
+ control.addMouseListener(snippetsMouseListener);
+ control.addDragDetectListener(snippetsMouseDragListener);
+ executed = true;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * This is called when something in the perspective have changed.
+ * For example: when a view is opened or closed
+ *
+ * @see org.eclipse.ui.PerspectiveAdapter#perspectiveChanged(org.eclipse.ui.IWorkbenchPage, org.eclipse.ui.IPerspectiveDescriptor, org.eclipse.ui.IWorkbenchPartReference, java.lang.String)
+ */
+ @Override
+ public void perspectiveChanged(IWorkbenchPage page, IPerspectiveDescriptor perspective,
+ IWorkbenchPartReference partRef, String changeId)
+ {
+ // check if it's the Snippet View
+ if (SNIPPETS_VIEW_ID.equals(partRef.getId()))
+ {
+ // if it's the Snippet View and it's being OPENED
+ if (IWorkbenchPage.CHANGE_VIEW_SHOW.equals(changeId))
+ {
+ if (!executed)
+ {
+ SnippetsView snippetsView = (SnippetsView) partRef.getPart(false);
+ addSearchBar(snippetsView);
+ snippetsView.getViewer().getControl()
+ .removeMouseListener(snippetsMouseListener); // remove mouse listener just to ensure we never have two listeners registered
+ snippetsView.getViewer().getControl()
+ .removeDragDetectListener(snippetsMouseDragListener); // remove mouse draggable listener just to ensure we never have two liseteners registered
+ snippetsView.getViewer().getControl()
+ .addMouseListener(snippetsMouseListener);
+ snippetsView.getViewer().getControl()
+ .addDragDetectListener(snippetsMouseDragListener);
+ // it doesn't need to add the mouse listener to the Snippets View in further opportunities
+ executed = true;
+ }
+ }
+ // if it's the Snippet View and it's being CLOSED
+ else if (IWorkbenchPage.CHANGE_VIEW_HIDE.equals(changeId))
+ {
+ // it must add the mouse listener to the Snippets View again next time the view is opened
+ if (searchContributionItem != null)
+ {
+ searchContributionItem.clean();
+ searchContributionItem.getParent().remove(searchContributionItem);
+ }
+
+ if (tooltipDisplayConfigcontributionItem != null) {
+ tooltipDisplayConfigcontributionItem.getParent().remove(tooltipDisplayConfigcontributionItem);
+ }
+
+ searchContributionItem = null;
+ tooltipDisplayConfigcontributionItem = null;
+
+ executed = false;
+ }
+ }
+
+ }
+
+ };
+
+ /*
+ * Attach the perspectiveListener declared above into the active window
+ * Also try to add the snippetsMouseListener listener to the Snippet View,
+ * if it's already being displayed
+ */
+ PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable()
+ {
+
+ public void run()
+ {
+ /*
+ * Add mouse listener to Snippet View
+ */
+ final IWorkbenchWindow activeWindow =
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+
+ activeWindow.addPerspectiveListener(perspectiveListener);
+
+ IViewReference viewReference =
+ activeWindow.getActivePage().findViewReference(SNIPPETS_VIEW_ID);
+
+ if (viewReference != null)
+ {
+ final SnippetsView snippetsView = (SnippetsView) viewReference.getView(true);
+ if (snippetsView != null)
+ {
+ addSearchBar(snippetsView);
+ snippetsView.getViewer().getControl()
+ .addMouseListener(snippetsMouseListener);
+ snippetsView.getViewer().getControl()
+ .addDragDetectListener(snippetsMouseDragListener);
+ }
+
+ }
+
+ }
+
+ });
+
+ }
+} \ No newline at end of file
diff --git a/src/plugins/snippets/src/com/motorola/studio/android/codesnippets/AndroidSnippetsTooltip.java b/src/plugins/snippets/src/com/motorola/studio/android/codesnippets/AndroidSnippetsTooltip.java
new file mode 100644
index 0000000..a954ba8
--- /dev/null
+++ b/src/plugins/snippets/src/com/motorola/studio/android/codesnippets/AndroidSnippetsTooltip.java
@@ -0,0 +1,147 @@
+/*
+* Copyright (C) 2012 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package com.motorola.studio.android.codesnippets;
+
+import org.eclipse.jdt.internal.ui.JavaPlugin;
+import org.eclipse.jdt.internal.ui.javaeditor.JavaSourceViewer;
+import org.eclipse.jdt.ui.PreferenceConstants;
+import org.eclipse.jdt.ui.text.JavaSourceViewerConfiguration;
+import org.eclipse.jdt.ui.text.JavaTextTools;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.jface.window.ToolTip;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.events.ControlAdapter;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.wst.common.snippets.core.ISnippetItem;
+
+import com.motorola.studio.android.codesnippets.i18n.AndroidSnippetsNLS;
+
+/**
+ * Customized tooltip for snippets in Snippet View.
+ * It's intended to display the snippet preview
+ *
+ */
+@SuppressWarnings("restriction")
+public class AndroidSnippetsTooltip extends ToolTip
+{
+
+ /*
+ * The snippet item to be displayed in the tooltip
+ */
+ private final ISnippetItem item;
+
+ /**
+ * Constructor
+ *
+ * @param item the snippet item to be displayed
+ * @param control
+ */
+ public AndroidSnippetsTooltip(ISnippetItem item, Control control)
+ {
+ super(control, NO_RECREATE, true);
+ this.item = item;
+ }
+
+ /**
+ * Display the snippet preview by using a JAVA Source Viewer, which is
+ * used to highlight the code
+ *
+ * @see org.eclipse.jface.window.ToolTip#createToolTipContentArea(org.eclipse.swt.widgets.Event, org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected Composite createToolTipContentArea(Event event, Composite parent)
+ {
+ // the main composite
+ Composite mainComposite = new Composite(parent, SWT.NULL);
+ mainComposite.setLayout(new GridLayout(1, true));
+
+ /*
+ * snippet preview label
+ */
+ Label textElem = new Label(mainComposite, SWT.LEFT);
+ textElem.setText(AndroidSnippetsNLS.UI_Snippet_Preview);
+ textElem.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
+
+ /*
+ * JAVA source viewer
+ */
+ final ScrolledComposite scroll =
+ new ScrolledComposite(mainComposite, SWT.H_SCROLL | SWT.V_SCROLL);
+ scroll.setLayout(new FillLayout());
+ // create scroll layout which receives values to limit its area of display
+ GridData scrollLayoutData = new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1);
+ Rectangle visibleArea = parent.getDisplay().getActiveShell().getMonitor().getClientArea();
+ scrollLayoutData.heightHint = visibleArea.height / 3;
+ scrollLayoutData.widthHint = visibleArea.width / 3;
+ scroll.setLayoutData(scrollLayoutData);
+
+ final Composite javaSourceViewerComposite = new Composite(scroll, SWT.NULL);
+ javaSourceViewerComposite.setLayout(new FillLayout());
+
+ int styles = SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION;
+ Document document = new Document(item.getContentString());
+ IPreferenceStore store = JavaPlugin.getDefault().getCombinedPreferenceStore();
+ JavaTextTools javaTextTools = JavaPlugin.getDefault().getJavaTextTools();
+
+ SourceViewer javaSourceViewer =
+ new JavaSourceViewer(javaSourceViewerComposite, null, null, false, styles, store);
+ javaSourceViewer.configure(new JavaSourceViewerConfiguration(javaTextTools
+ .getColorManager(), store, null, null));
+ javaSourceViewer.getControl().setFont(
+ JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT));
+ javaTextTools.setupJavaDocumentPartitioner(document);
+ javaSourceViewer.setDocument(document);
+ javaSourceViewer.setEditable(false);
+
+ // set up scroll
+ scroll.setContent(javaSourceViewerComposite);
+ scroll.setExpandHorizontal(true);
+ scroll.setExpandVertical(true);
+ scroll.addControlListener(new ControlAdapter()
+ {
+ @Override
+ public void controlResized(ControlEvent e)
+ {
+ scroll.setMinSize(javaSourceViewerComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+ }
+ });
+
+ return mainComposite;
+ }
+
+ /**
+ * Get the snippet item being displayed
+ *
+ * @return the snippet item being displayed
+ */
+ public ISnippetItem getItem()
+ {
+ return item;
+ }
+
+}
diff --git a/src/plugins/snippets/src/com/motorola/studio/android/codesnippets/CodeSnippetsPlugin.java b/src/plugins/snippets/src/com/motorola/studio/android/codesnippets/CodeSnippetsPlugin.java
new file mode 100644
index 0000000..b3a0ab8
--- /dev/null
+++ b/src/plugins/snippets/src/com/motorola/studio/android/codesnippets/CodeSnippetsPlugin.java
@@ -0,0 +1,69 @@
+/*
+* Copyright (C) 2012 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package com.motorola.studio.android.codesnippets;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+import com.motorola.studio.android.common.log.StudioLogger;
+
+public class CodeSnippetsPlugin extends AbstractUIPlugin
+{
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "com.motorola.studio.android.codesnippets"; //$NON-NLS-1$
+
+ // The shared instance
+ private static CodeSnippetsPlugin plugin;
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void start(BundleContext context) throws Exception
+ {
+ StudioLogger.debug(CodeSnippetsPlugin.class,
+ "Starting MOTODEV Android Code Snippets Plugin...");
+
+ super.start(context);
+ plugin = this;
+
+ StudioLogger.debug(CodeSnippetsPlugin.class,
+ "MOTODEV Android Code Snippets Plugin started.");
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void stop(BundleContext context) throws Exception
+ {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static CodeSnippetsPlugin getDefault()
+ {
+ return plugin;
+ }
+}
diff --git a/src/plugins/snippets/src/com/motorola/studio/android/codesnippets/SnippetsViewContributionItem.java b/src/plugins/snippets/src/com/motorola/studio/android/codesnippets/SnippetsViewContributionItem.java
new file mode 100644
index 0000000..d869601
--- /dev/null
+++ b/src/plugins/snippets/src/com/motorola/studio/android/codesnippets/SnippetsViewContributionItem.java
@@ -0,0 +1,227 @@
+/*
+* Copyright (C) 2012 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package com.motorola.studio.android.codesnippets;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jface.action.ControlContribution;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.wst.common.snippets.internal.palette.SnippetPaletteDrawer;
+import org.eclipse.wst.common.snippets.internal.palette.SnippetPaletteItem;
+import org.eclipse.wst.common.snippets.internal.ui.SnippetsView;
+
+import com.motorola.studio.android.codesnippets.i18n.AndroidSnippetsNLS;
+
+@SuppressWarnings("restriction")
+public class SnippetsViewContributionItem extends ControlContribution
+{
+ private final SnippetsView view;
+
+ public SnippetsViewContributionItem(SnippetsView view)
+ {
+ super("com.motorola.studio.android.codesnippets.search");
+ this.view = view;
+ }
+
+ private Text text;
+
+ final String INITIAL_TEXT = AndroidSnippetsNLS.UI_Snippet_SearchLabel;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.action.ControlContribution#computeWidth(org.eclipse.swt.widgets.Control)
+ */
+ @Override
+ protected int computeWidth(Control control)
+ {
+ return text.computeSize(100, SWT.DEFAULT).x;
+ }
+
+ @Override
+ protected Control createControl(Composite parent)
+ {
+
+ text = new Text(parent, SWT.BORDER | SWT.SEARCH | SWT.ICON_SEARCH);
+
+ text.setToolTipText(INITIAL_TEXT);
+ text.setEnabled(true);
+ text.setEditable(true);
+ text.setMessage(INITIAL_TEXT);
+
+ resetView();
+
+ text.addListener(SWT.Modify, new Listener()
+ {
+ public void handleEvent(Event event)
+ {
+ String typed = text.getText().toLowerCase();
+
+ // variables for the first inner loop
+ Object rootChildObject = null;
+ SnippetPaletteDrawer snippetPaletteDrawer = null;
+ SnippetPaletteItem snippetPalletItem = null;
+
+ // variables for the second inner loop
+ List<?> snippetPalleteDrawerChildren = null;
+ Iterator<?> snippetPalleteDrawerIterator = null;
+ Integer foundItemsCount = null;
+ Integer lastIndex = null;
+ Object snippetPalletObject = null;
+
+ // get text and items to be sought in
+ List<?> rootChildren = view.getRoot().getChildren();
+ Iterator<?> rootChildremIterator = rootChildren.iterator();
+
+ /* Here the idea is to iterate through the snippets labels, text and codes,
+ * and find a match. In case there are results, a number of found items by category
+ * is displayed.
+ */
+ while (rootChildremIterator.hasNext())
+ {
+ rootChildObject = rootChildremIterator.next();
+ if (rootChildObject instanceof SnippetPaletteDrawer)
+ {
+ snippetPaletteDrawer = (SnippetPaletteDrawer) rootChildObject;
+ snippetPalleteDrawerChildren = snippetPaletteDrawer.getChildren();
+ snippetPalleteDrawerIterator = snippetPalleteDrawerChildren.iterator();
+ foundItemsCount = 0;
+ while (snippetPalleteDrawerIterator.hasNext())
+ {
+ snippetPalletObject = snippetPalleteDrawerIterator.next();
+ if (snippetPalletObject instanceof SnippetPaletteItem)
+ {
+ snippetPalletItem = (SnippetPaletteItem) snippetPalletObject;
+
+ // there must be a match for either the label, description or code of the snippet
+ if (snippetPalletItem.getLabel().toLowerCase().contains(typed)
+ || snippetPalletItem.getDescription().toLowerCase()
+ .contains(typed)
+ || snippetPalletItem.getContentString().toLowerCase()
+ .contains(typed))
+ {
+ snippetPalletItem.setVisible(true);
+ foundItemsCount++;
+ }
+ else
+ {
+ // since no match was found for the snippets, try to find for its category label
+ if (snippetPaletteDrawer.getLabel().toLowerCase()
+ .contains(typed))
+ {
+ snippetPalletItem.setVisible(true);
+ foundItemsCount++;
+ }
+ else
+ {
+ snippetPalletItem.setVisible(false);
+ }
+ }
+ }
+ }
+
+ // display the number of found items between parenthesis
+ lastIndex = snippetPaletteDrawer.getLabel().lastIndexOf(")");
+ if (lastIndex == -1)
+ {
+ snippetPaletteDrawer.setLabel(snippetPaletteDrawer.getLabel() + " ("
+ + foundItemsCount + ")");
+ }
+ else
+ {
+ snippetPaletteDrawer.setLabel(snippetPaletteDrawer.getLabel()
+ .replaceFirst("\\(\\d+\\)",
+ "(" + foundItemsCount.toString() + ")"));
+ }
+
+ /*
+ * In case no match is found, hide the pallete and all
+ * its children, otherwise display the number of items
+ * found between parenthesis.
+ */
+ if (foundItemsCount == 0)
+ {
+ snippetPaletteDrawer.setVisible(false);
+ snippetPaletteDrawer.setFilters(new String[]
+ {
+ "!"
+ });
+ }
+ else
+ {
+ // show the item
+ snippetPaletteDrawer.setVisible(true);
+ snippetPaletteDrawer.setFilters(new String[]
+ {
+ "*"
+ });
+ }
+ }
+ }
+ }
+
+ });
+
+ return text;
+ }
+
+ /**
+ * Set all items to be visible.
+ */
+ private void resetView()
+ {
+ // get text and items to be sought in
+ List<?> rootChildren = view.getRoot().getChildren();
+ Iterator<?> rootChildremIterator = rootChildren.iterator();
+
+ /*
+ * Here the idea is to iterate through the snippets labels, text and codes,
+ * and set everything to visible, since the view is saving the state.
+ */
+ while (rootChildremIterator.hasNext())
+ {
+ Object rootChildObject = rootChildremIterator.next();
+ if (rootChildObject instanceof SnippetPaletteDrawer)
+ {
+ SnippetPaletteDrawer snippetPaletteDrawer = (SnippetPaletteDrawer) rootChildObject;
+ List<?> snippetPalleteDrawerChildren = snippetPaletteDrawer.getChildren();
+ Iterator<?> snippetPalleteDrawerIterator = snippetPalleteDrawerChildren.iterator();
+ snippetPaletteDrawer.setVisible(true);
+ while (snippetPalleteDrawerIterator.hasNext())
+ {
+ Object snippetPalletObject = snippetPalleteDrawerIterator.next();
+ if (snippetPalletObject instanceof SnippetPaletteItem)
+ {
+ SnippetPaletteItem snippetPalletItem =
+ (SnippetPaletteItem) snippetPalletObject;
+ snippetPalletItem.setVisible(true);
+ }
+ }
+ }
+
+ }
+ }
+
+ public void clean()
+ {
+ text.setText("");
+ }
+}
diff --git a/src/plugins/snippets/src/com/motorola/studio/android/codesnippets/TooltipDisplayConfigContriutionItem.java b/src/plugins/snippets/src/com/motorola/studio/android/codesnippets/TooltipDisplayConfigContriutionItem.java
new file mode 100644
index 0000000..2a814c2
--- /dev/null
+++ b/src/plugins/snippets/src/com/motorola/studio/android/codesnippets/TooltipDisplayConfigContriutionItem.java
@@ -0,0 +1,164 @@
+/*
+* Copyright (C) 2012 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package com.motorola.studio.android.codesnippets;
+
+import org.eclipse.core.runtime.preferences.ConfigurationScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.jface.action.ControlContribution;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.RowLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.osgi.service.prefs.BackingStoreException;
+
+import com.motorola.studio.android.codesnippets.i18n.AndroidSnippetsNLS;
+import com.motorola.studio.android.common.log.StudioLogger;
+
+/**
+ * This {@link ControlContribution} adds the check box button which
+ * shows or hides the tooltip of the snippet.
+ *
+ * @see ControlContribution
+ * @see {@link AndroidSnippetsStartup}
+ *
+ */
+public class TooltipDisplayConfigContriutionItem extends ControlContribution
+{
+ /**
+ * Listener which updates the status of whether or not to display
+ * the tool tip.
+ *
+ * @see SelectionListener
+ *
+ */
+ private final class TooltipSelectionListener implements SelectionListener
+ {
+ /**
+ * Here the state of the tooltip display button is persisted in
+ * the {@link IDialogSettings}.
+ *
+ * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ public void widgetSelected(SelectionEvent e)
+ {
+ // action for when the check box is pressed.
+ performButtonSelection();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ public void widgetDefaultSelected(SelectionEvent e)
+ {
+ // do nothing
+ }
+ }
+
+ /**
+ * Check box {@link Button} which shows or hides the tooltip.
+ */
+ private Button showToolTipButton = null;
+
+ /**
+ * {@link IDialogSettings} field for whether or not the tooltip
+ * is to be displayed.
+ */
+ private static final String DIALOG_SETTINGS__IS_TOOLTIP_DISPLAYED = "IsTooltipDisplayed";
+
+ /**
+ * Constructor which initiates this {@link ControlContribution}.
+ */
+ public TooltipDisplayConfigContriutionItem()
+ {
+ super("com.motorola.studio.android.codesnippets.tooltipDisplayConfig"); //$NON-NLS-1$
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.action.ControlContribution#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected Control createControl(Composite parent)
+ {
+ // adjust layout in order to produce space to the left
+ Composite mainComposite = new Composite(parent, SWT.NONE);
+ RowLayout layout = new RowLayout(SWT.FILL);
+ layout.center = true;
+ layout.marginLeft = 10;
+ mainComposite.setLayout(layout);
+
+ // create the check box button
+ showToolTipButton = new Button(mainComposite, SWT.CHECK);
+ showToolTipButton
+ .setText(AndroidSnippetsNLS.TooltipDisplayConfigContriutionItem_ShowPreview);
+ showToolTipButton.addSelectionListener(new TooltipSelectionListener());
+
+ // set the selection persisted
+ IEclipsePreferences preferences = getEclipsePreferences();
+ boolean isTooltipDisplayed =
+ preferences.getBoolean(DIALOG_SETTINGS__IS_TOOLTIP_DISPLAYED, true);
+ showToolTipButton.setSelection(isTooltipDisplayed);
+ performButtonSelection();
+
+ return mainComposite;
+ }
+
+ /**
+ * Returns <code>true</code> in case the tool tip is to
+ * be displayed, or <code>false</code> should it be hidden.
+ *
+ * @return <code>true</code> in case the tool tip
+ * is to be displayed, <code>false</code> otherwise.
+ */
+ public boolean isTooltipDisplayed()
+ {
+ return showToolTipButton.getSelection();
+ }
+
+ /**
+ * Method called when the check box {@link Button} is called. It
+ * persists the check box selection state in the {@link IDialogSettings}.
+ */
+ private void performButtonSelection()
+ {
+ // persist whether or not to show the tooltip
+ IEclipsePreferences preferences = getEclipsePreferences();
+ preferences.putBoolean(DIALOG_SETTINGS__IS_TOOLTIP_DISPLAYED,
+ showToolTipButton.getSelection());
+ try
+ {
+ preferences.flush();
+ }
+ catch (BackingStoreException bse)
+ {
+ StudioLogger.error(TooltipDisplayConfigContriutionItem.class.toString(),
+ "Preferences for snippets could not be saved.", bse); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Get Eclipse´s preferences.
+ *
+ * @return Return Eclipse´s preferences.
+ */
+ private IEclipsePreferences getEclipsePreferences()
+ {
+ return ConfigurationScope.INSTANCE.getNode(AndroidSnippetsStartup.SNIPPETS_VIEW_ID);
+ }
+}
diff --git a/src/plugins/snippets/src/com/motorola/studio/android/codesnippets/i18n/AndroidSnippetsNLS.java b/src/plugins/snippets/src/com/motorola/studio/android/codesnippets/i18n/AndroidSnippetsNLS.java
new file mode 100644
index 0000000..07c77d8
--- /dev/null
+++ b/src/plugins/snippets/src/com/motorola/studio/android/codesnippets/i18n/AndroidSnippetsNLS.java
@@ -0,0 +1,55 @@
+/*
+* Copyright (C) 2012 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package com.motorola.studio.android.codesnippets.i18n;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * This class is the NLS component for Code Snippets plug-in
+ *
+ */
+public class AndroidSnippetsNLS extends NLS
+{
+ /**
+ * The bundle location.
+ * It refers to messages.properties file inside this package
+ */
+ private static final String BUNDLE_NAME =
+ "com.motorola.studio.android.codesnippets.i18n.androidSnippetsNLS";
+
+ static
+ {
+ NLS.initializeMessages(BUNDLE_NAME, AndroidSnippetsNLS.class);
+ }
+
+ public static String AndroidPermissionInsertSnippet_Msg_AddToManifest_Msg;
+
+ public static String AndroidPermissionInsertSnippet_Msg_AddToManifest_Title;
+
+ public static String AndroidPermissionInsertSnippet_PermissionPrefix;
+
+ public static String AndroidPermissionInsertSnippet_PermissionSuffix;
+
+ public static String TooltipDisplayConfigContriutionItem_ShowPreview;
+
+ /*
+ * UI strings area
+ */
+ public static String UI_Snippet_Preview;
+
+ public static String UI_Snippet_SearchLabel;
+
+}
diff --git a/src/plugins/snippets/src/com/motorola/studio/android/codesnippets/i18n/androidSnippetsNLS.properties b/src/plugins/snippets/src/com/motorola/studio/android/codesnippets/i18n/androidSnippetsNLS.properties
new file mode 100644
index 0000000..b66bfd4
--- /dev/null
+++ b/src/plugins/snippets/src/com/motorola/studio/android/codesnippets/i18n/androidSnippetsNLS.properties
@@ -0,0 +1,7 @@
+AndroidPermissionInsertSnippet_Msg_AddToManifest_Msg=This snippet requires specific permissions in order to work correctly.\nShould the following permissions be added to AndroidManifest.xml?\n{0}
+AndroidPermissionInsertSnippet_Msg_AddToManifest_Title=Snippet Required Permissions
+AndroidPermissionInsertSnippet_PermissionPrefix=-
+AndroidPermissionInsertSnippet_PermissionSuffix=\n
+TooltipDisplayConfigContriutionItem_ShowPreview=Show Preview
+UI_Snippet_Preview=Snippet Preview:
+UI_Snippet_SearchLabel=Search... \ No newline at end of file