summaryrefslogtreecommitdiff
path: root/src/plugins/logger.collector/src/com/motorola/studio/android/logger/collector/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/logger.collector/src/com/motorola/studio/android/logger/collector/util')
-rw-r--r--src/plugins/logger.collector/src/com/motorola/studio/android/logger/collector/util/LogCollectorExtensionLoader.java76
-rw-r--r--src/plugins/logger.collector/src/com/motorola/studio/android/logger/collector/util/LoggerCollectorConstants.java52
-rw-r--r--src/plugins/logger.collector/src/com/motorola/studio/android/logger/collector/util/LoggerCollectorMessages.java123
-rw-r--r--src/plugins/logger.collector/src/com/motorola/studio/android/logger/collector/util/PlatformException.java51
-rw-r--r--src/plugins/logger.collector/src/com/motorola/studio/android/logger/collector/util/PlatformLogger.java201
-rw-r--r--src/plugins/logger.collector/src/com/motorola/studio/android/logger/collector/util/WidgetsFactory.java445
-rw-r--r--src/plugins/logger.collector/src/com/motorola/studio/android/logger/collector/util/WidgetsUtil.java392
-rw-r--r--src/plugins/logger.collector/src/com/motorola/studio/android/logger/collector/util/ZipUtil.java260
8 files changed, 1600 insertions, 0 deletions
diff --git a/src/plugins/logger.collector/src/com/motorola/studio/android/logger/collector/util/LogCollectorExtensionLoader.java b/src/plugins/logger.collector/src/com/motorola/studio/android/logger/collector/util/LogCollectorExtensionLoader.java
new file mode 100644
index 0000000..2bef177
--- /dev/null
+++ b/src/plugins/logger.collector/src/com/motorola/studio/android/logger/collector/util/LogCollectorExtensionLoader.java
@@ -0,0 +1,76 @@
+/*
+ * 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.logger.collector.util;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.Platform;
+
+import com.motorola.studio.android.logger.collector.core.ILogFile;
+
+/**
+ * This class is responsible to load the log collector contributor
+ * extension point and read all needed information
+ */
+public class LogCollectorExtensionLoader
+{
+ private static final String LOGGER_EXTENSION_POINT_ID =
+ "com.motorola.studio.android.logger.collector.log";
+
+ private static final String LOG_FILE_ELEMENT = "logContribution";
+
+ private static final String LOG_FILE_ATTRIBUTE = "logFileImpl";
+
+ public static ArrayList<ILogFile> getLogFiles()
+ {
+ ArrayList<ILogFile> logs = new ArrayList<ILogFile>();
+ IExtensionPoint point =
+ Platform.getExtensionRegistry().getExtensionPoint(LOGGER_EXTENSION_POINT_ID);
+ if (point != null)
+ {
+ IExtension[] extensions = point.getExtensions();
+
+ for (IExtension ext : extensions)
+ {
+ for (IConfigurationElement element : ext.getConfigurationElements())
+ {
+ if (element.getName().equals(LOG_FILE_ELEMENT))
+ {
+ try
+ {
+ Object o = element.createExecutableExtension(LOG_FILE_ATTRIBUTE);
+ if (o instanceof ILogFile)
+ {
+ logs.add((ILogFile) o);
+ }
+ }
+ catch (CoreException e)
+ {
+ //do nothing
+ }
+ }
+ }
+ }
+
+ }
+
+ return logs;
+ }
+}
diff --git a/src/plugins/logger.collector/src/com/motorola/studio/android/logger/collector/util/LoggerCollectorConstants.java b/src/plugins/logger.collector/src/com/motorola/studio/android/logger/collector/util/LoggerCollectorConstants.java
new file mode 100644
index 0000000..6415596
--- /dev/null
+++ b/src/plugins/logger.collector/src/com/motorola/studio/android/logger/collector/util/LoggerCollectorConstants.java
@@ -0,0 +1,52 @@
+/*
+ * 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.logger.collector.util;
+
+import java.io.File;
+
+import org.eclipse.core.runtime.Platform;
+
+/**
+ * Constant definitions for logger collector plug-in preferences
+ */
+public class LoggerCollectorConstants
+{
+
+ /**
+ * The constant contains a string representation of the regular expression
+ * to validate the file name format. The file name must follow the formats
+ * above: - Only alphanumeric characters and point must be supported
+ * ([A-Za-z0-9_.]). - The max length must be 60 characters;
+ */
+ public static final String FILE_NAME_REGEX = "[\\w.]{1,60}"; //$NON-NLS-1$
+
+ /**
+ * The plug-in ID
+ */
+ public static final String PLUGIN_ID = "com.motorolamobility.studio.android.logger.collector"; //$NON-NLS-1$
+
+ // The plugin path location
+ private static final String PLUGIN_LOCATION = File.separator + ".metadata" //$NON-NLS-1$
+ + File.separator + ".plugins" + File.separator //$NON-NLS-1$
+ + "com.motorolamobility.studio.android.logger"; //$NON-NLS-1$
+
+ // The absolute logger files path
+ public static final String LOG_PATH = Platform.getLocation() + PLUGIN_LOCATION;
+
+ public static final String PLATFORM_LOG_OUTPUT_FOLDER = "platform";
+
+ public static final String ZIP_FILE_EXTENSION = "zip";
+}
diff --git a/src/plugins/logger.collector/src/com/motorola/studio/android/logger/collector/util/LoggerCollectorMessages.java b/src/plugins/logger.collector/src/com/motorola/studio/android/logger/collector/util/LoggerCollectorMessages.java
new file mode 100644
index 0000000..9311858
--- /dev/null
+++ b/src/plugins/logger.collector/src/com/motorola/studio/android/logger/collector/util/LoggerCollectorMessages.java
@@ -0,0 +1,123 @@
+/*
+ * 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.logger.collector.util;
+
+import java.text.MessageFormat;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * Class to handle the messages. By default, all keys has the class name in its
+ * prefix, plus a sequential number.
+ */
+public class LoggerCollectorMessages
+{
+
+ /**
+ * The shared instance.
+ */
+ private static LoggerCollectorMessages instance = null;
+
+ /**
+ * Bundle to get messages from module (properties file).
+ */
+ private final ResourceBundle bundle;
+
+ /**
+ * Class used to get the message.
+ */
+ private Class<? extends Object> clazz;
+
+ /**
+ * Default constructor.
+ */
+ private LoggerCollectorMessages()
+ {
+ this.bundle = ResourceBundle.getBundle("loggerCollector"); //$NON-NLS-1$
+ }
+
+ /**
+ * Returns the single instance.
+ *
+ * @param clazz Class used to get the messages.
+ * @return The singleton instance.
+ */
+ public static synchronized LoggerCollectorMessages getInstance(Class<? extends Object> clazz)
+ {
+ if (instance == null)
+ {
+ instance = new LoggerCollectorMessages();
+ }
+ instance.clazz = clazz;
+ return instance;
+ }
+
+ /**
+ * Returns the single instance.
+ *
+ * @return The singleton instance.
+ */
+ public static synchronized LoggerCollectorMessages getInstance()
+ {
+ if (instance == null)
+ {
+ instance = new LoggerCollectorMessages();
+ }
+ instance.clazz = null;
+ return instance;
+ }
+
+ /**
+ * Returns the message of the given key.
+ *
+ * @param key The message key
+ * @return The message of the given key.
+ */
+ public String getString(String key)
+ {
+ try
+ {
+ return bundle
+ .getString(((this.clazz == null) ? "" : (this.clazz.getName() + ".")) + key); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ catch (MissingResourceException e)
+ {
+ return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ /**
+ * Returns the message of the given key.
+ *
+ * @param key The message key
+ * @param arguments Arguments to replace the pattern in the corresponding
+ * message of the key.
+ * @return The message of the given key.
+ */
+ public String getString(String key, Object... arguments)
+ {
+ try
+ {
+ String message =
+ bundle.getString(((this.clazz == null) ? "" : (this.clazz.getName() + ".")) + key); //$NON-NLS-1$ //$NON-NLS-2$
+ return MessageFormat.format(message, arguments);
+ }
+ catch (MissingResourceException e)
+ {
+ return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+}
diff --git a/src/plugins/logger.collector/src/com/motorola/studio/android/logger/collector/util/PlatformException.java b/src/plugins/logger.collector/src/com/motorola/studio/android/logger/collector/util/PlatformException.java
new file mode 100644
index 0000000..b30ccba
--- /dev/null
+++ b/src/plugins/logger.collector/src/com/motorola/studio/android/logger/collector/util/PlatformException.java
@@ -0,0 +1,51 @@
+/*
+ * 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.logger.collector.util;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+
+/**
+ * This class represents a basic platform exception that all Studios should
+ * extend and implement other functions. The error is logged when the status
+ * severity is <code>IStatus.CANCEL</code>.
+ *
+ * @see org.eclipse.core.runtime.CoreException
+ */
+
+public class PlatformException extends CoreException
+{
+
+ /**
+ * Universal version identifier for a Serializable object.
+ */
+ private static final long serialVersionUID = 5165818604668097411L;
+
+ /**
+ * Construct a platform exception with the given status.
+ *
+ * @param status The IStatus.
+ */
+ public PlatformException(final IStatus status)
+ {
+ super(status);
+ if (status.getSeverity() == IStatus.CANCEL)
+ {
+ PlatformLogger.getInstance(PlatformException.class).error(this.getMessage(), this);
+ }
+ }
+}
diff --git a/src/plugins/logger.collector/src/com/motorola/studio/android/logger/collector/util/PlatformLogger.java b/src/plugins/logger.collector/src/com/motorola/studio/android/logger/collector/util/PlatformLogger.java
new file mode 100644
index 0000000..efdac2b
--- /dev/null
+++ b/src/plugins/logger.collector/src/com/motorola/studio/android/logger/collector/util/PlatformLogger.java
@@ -0,0 +1,201 @@
+/*
+ * 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.logger.collector.util;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import com.motorola.studio.android.logger.Logger;
+
+/**
+ * Class with useful methods to log errors.
+ */
+public class PlatformLogger
+{
+
+ /**
+ * Logger for this class.
+ */
+ private final Logger logger;
+
+ /**
+ * Shared instances by Class
+ */
+ private static Map<Class<? extends Object>, PlatformLogger> instances =
+ new HashMap<Class<? extends Object>, PlatformLogger>();
+
+ /**
+ * Default constructor
+ *
+ * @param clazz Class to be logged.
+ */
+ private PlatformLogger(Class<? extends Object> clazz)
+ {
+ this.logger = Logger.getLogger(clazz.getName());
+ }
+
+ /**
+ * Returns an instance by a given class object.
+ *
+ * @param clazz The given class.
+ * @return an instance by a given class object.
+ */
+ public static synchronized PlatformLogger getInstance(Class<? extends Object> clazz)
+ {
+ PlatformLogger instance = instances.get(clazz);
+ if (instance == null)
+ {
+ instance = new PlatformLogger(clazz);
+ instances.put(clazz, instance);
+ }
+ return instance;
+ }
+
+ /**
+ * Log a message object with the DEBUG level.
+ *
+ * @param message The message to log.
+ */
+ public void debug(String message)
+ {
+ debug(message, null);
+ }
+
+ /**
+ * Log a message object with the DEBUG level.
+ *
+ * @param message The message to log.
+ * @param exception Exception whose stack will be logged.
+ */
+ public void debug(String message, Throwable exception)
+ {
+ if (null == exception)
+ {
+ logger.debug(message);
+ }
+ else
+ {
+ logger.debug(message, exception);
+ }
+ }
+
+ /**
+ * Log a message object with the WARN level.
+ *
+ * @param message The message to log.
+ */
+ public void warn(String message)
+ {
+ warn(message, null);
+ }
+
+ /**
+ * Log a message object with the WARN level.
+ *
+ * @param message The message to log.
+ * @param exception Exception whose stack will be logged.
+ */
+ public void warn(String message, Throwable exception)
+ {
+ if (null == exception)
+ {
+ logger.warn(message);
+ }
+ else
+ {
+ logger.warn(message, exception);
+ }
+ }
+
+ /**
+ * Log a message object with the FATAL level.
+ *
+ * @param message The message to log.
+ */
+ public void fatal(String message)
+ {
+ fatal(message, null);
+ }
+
+ /**
+ * Log a message object with the FATAL level.
+ *
+ * @param message The message to log.
+ * @param exception Exception whose stack will be logged.
+ */
+ public void fatal(String message, Throwable exception)
+ {
+ if (null == exception)
+ {
+ logger.fatal(message);
+ }
+ else
+ {
+ logger.fatal(message, exception);
+ }
+ }
+
+ /**
+ * Log a message object with the INFO level.
+ *
+ * @param message The message to log.
+ */
+ public void info(String message)
+ {
+ info(message, null);
+ }
+
+ /**
+ * Log a message object with the INFO level.
+ *
+ * @param message The message to log.
+ * @param exception Exception whose stack will be logged.
+ */
+ public void info(String message, Throwable exception)
+ {
+ if (null == exception)
+ {
+ logger.info(message);
+ }
+ else
+ {
+ logger.info(message, exception);
+ }
+ }
+
+ /**
+ * Log a message object with the ERROR level.
+ *
+ * @param message The message to log.
+ */
+ public void error(String message)
+ {
+ this.logger.error(message);
+ }
+
+ /**
+ * Log a message object with the ERROR level.
+ *
+ * @param message The message to log.
+ * @param exception Exception whose stack will be logged.
+ */
+ public void error(String message, Throwable exception)
+ {
+ this.logger.error(message, exception);
+ }
+
+}
diff --git a/src/plugins/logger.collector/src/com/motorola/studio/android/logger/collector/util/WidgetsFactory.java b/src/plugins/logger.collector/src/com/motorola/studio/android/logger/collector/util/WidgetsFactory.java
new file mode 100644
index 0000000..40c679c
--- /dev/null
+++ b/src/plugins/logger.collector/src/com/motorola/studio/android/logger/collector/util/WidgetsFactory.java
@@ -0,0 +1,445 @@
+/*
+ * 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.logger.collector.util;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.List;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.ToolBar;
+import org.eclipse.swt.widgets.ToolItem;
+import org.eclipse.swt.widgets.TreeItem;
+
+/**
+ * Class factory to create widgets.
+ */
+public class WidgetsFactory
+{
+
+ /**
+ * Create a new composite with two columns.
+ *
+ * @param parent The parent composite.
+ * @return A composite with two columns.
+ */
+ public static Composite createComposite(Composite parent)
+ {
+ Composite toReturn = new Composite(parent, SWT.NULL);
+ toReturn.setLayout(createGridLayout());
+ toReturn.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL));
+
+ return toReturn;
+ }
+
+ /**
+ * Create a new composite with the given column count.
+ *
+ * @param parent The parent composite.
+ * @param numColumns The column count for the new composite.
+ * @return A composite with the given column count.
+ */
+ public static Composite createComposite(Composite parent, int numColumns)
+ {
+ Composite toReturn = createComposite(parent);
+ ((GridLayout) toReturn.getLayout()).numColumns = numColumns;
+
+ return toReturn;
+ }
+
+ /**
+ * Creates a new line.
+ *
+ * @param parent The parent composite.
+ * @return A label with a line.
+ */
+ public static Label createLine(Composite parent)
+ {
+ Label toReturn = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL | SWT.BOLD);
+ GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
+ gridData.horizontalSpan = ((GridLayout) parent.getLayout()).numColumns;
+ toReturn.setLayoutData(gridData);
+
+ return toReturn;
+ }
+
+ /**
+ * Creates a new GridLayout with two columns.
+ *
+ * @return A new GridLayout with two columns.
+ */
+ public static GridLayout createGridLayout()
+ {
+ GridLayout toReturn = new GridLayout();
+ toReturn.numColumns = 2;
+ toReturn.makeColumnsEqualWidth = false;
+ toReturn.marginWidth = 0;
+ toReturn.marginHeight = 0;
+
+ return toReturn;
+ }
+
+ /**
+ * Creates a new GridLayout with the given number of columns.
+ *
+ * @return A new GridLayout with the given number of columns.
+ */
+ public static GridLayout createGridLayout(int numColumns)
+ {
+ GridLayout toReturn = new GridLayout();
+ toReturn.numColumns = numColumns;
+ toReturn.makeColumnsEqualWidth = false;
+ toReturn.marginWidth = 0;
+ toReturn.marginHeight = 0;
+
+ return toReturn;
+ }
+
+ /**
+ * Creates a new GridLayout with the given number of columns for the given
+ * composite.
+ *
+ * @return A new GridLayout with the given number of columns for the given
+ * composite.
+ */
+ public static GridLayout createGridLayout(int numColumns, Composite composite)
+ {
+ GridLayout toReturn = new GridLayout();
+ toReturn.numColumns = numColumns;
+ toReturn.makeColumnsEqualWidth = false;
+ toReturn.marginWidth = 0;
+ toReturn.marginHeight = 0;
+
+ composite.setLayout(toReturn);
+ return toReturn;
+ }
+
+ /**
+ * Creates a new label.
+ *
+ * @param parent The parent composite.
+ * @param text Text used in label.
+ * @return A new label
+ */
+ public static Label createLabel(Composite parent, String text)
+ {
+ return createLabel(parent, text, SWT.NONE);
+ }
+
+ /**
+ * Creates a new label.
+ *
+ * @param parent The parent composite.
+ * @param text Text used in label.
+ * @param style The style used in label.
+ * @return A new label
+ */
+ public static Label createLabel(Composite parent, String text, int style)
+ {
+ Label toReturn = new Label(parent, style);
+ if (text != null)
+ {
+ toReturn.setText(text);
+ }
+ toReturn.setFont(parent.getFont());
+
+ return toReturn;
+ }
+
+ /**
+ * Creates a new combo.
+ *
+ * @param parent The parent composite.
+ * @return The new combo
+ */
+ public static Combo createCombo(Composite parent)
+ {
+ Combo toReturn = new Combo(parent, SWT.READ_ONLY);
+ GridData data = new GridData(GridData.FILL_HORIZONTAL);
+ data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
+ data.horizontalSpan = 1;
+ toReturn.setLayoutData(data);
+
+ return toReturn;
+ }
+
+ /**
+ * Creates two labels used to show a read only value in screens.
+ *
+ * @param parent The parent composite.
+ * @param text The text used in both labels.
+ * @return The label that will show a read only value.
+ */
+ public static Label createValueLabel(Composite parent, String text)
+ {
+ createLabel(parent, text);
+
+ return createLabel(parent, null);
+ }
+
+ /**
+ * Creates a new button.
+ *
+ * @param parent The parent composite.
+ * @param text The text of the button.
+ * @return A new button
+ */
+ public static Button createButton(Composite parent, String text)
+ {
+ Button toReturn = new Button(parent, SWT.PUSH);
+ toReturn.setFont(parent.getFont());
+ toReturn.setText(text);
+ toReturn.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ return toReturn;
+ }
+
+ /**
+ * Creates a new table widget.
+ *
+ * @param parent The parent composite.
+ * @return The new table
+ */
+ public static Table createTable(Composite parent)
+ {
+ Table toReturn =
+ new Table(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION
+ | SWT.BORDER);
+ GridData data = new GridData(GridData.FILL_BOTH);
+ data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
+ data.heightHint = toReturn.getItemHeight();
+ data.horizontalSpan = 1;
+ toReturn.setLayoutData(data);
+
+ return toReturn;
+ }
+
+ /**
+ * Creates a new table widget.
+ *
+ * @param parent The parent composite.
+ * @return The new table
+ */
+ public static Table createTableMultiSelection(Composite parent)
+ {
+ Table toReturn =
+ new Table(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER
+ | SWT.MULTI);
+ GridData data = new GridData(GridData.FILL_BOTH);
+ data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
+ data.heightHint = toReturn.getItemHeight();
+ data.horizontalSpan = 1;
+ toReturn.setLayoutData(data);
+
+ return toReturn;
+ }
+
+ /**
+ * Creates a new table column.
+ *
+ * @param table The table of the column.
+ * @param text The column text.
+ * @return A new table column
+ */
+ public static TableColumn createTableColumn(Table table, String text)
+ {
+ TableColumn toReturn = new TableColumn(table, SWT.NONE);
+ toReturn.setText(text);
+
+ return toReturn;
+ }
+
+ /**
+ * Creates a new table item.
+ *
+ * @param table The table of the table item.
+ * @param image The image of the item.
+ * @param s The text of the item.
+ * @return The new table item.
+ */
+ public static TableItem createTableItem(Table table, Image image, String s)
+ {
+ TableItem toReturn = new TableItem(table, SWT.NONE);
+ toReturn.setText(s);
+ if (image != null)
+ {
+ toReturn.setImage(image);
+ }
+
+ return toReturn;
+ }
+
+ /**
+ * Creates a collection of table items.
+ *
+ * @param table The table of the table item.
+ * @param image The image of the item.
+ * @param s The text of the item.
+ * @return The new table item.
+ */
+ public static TableItem createTableItem(Table table, Image image, String... s)
+ {
+ TableItem toReturn = new TableItem(table, SWT.NONE);
+ toReturn.setText(s);
+ if (image != null)
+ {
+ toReturn.setImage(image);
+ }
+
+ return toReturn;
+ }
+
+ /**
+ * Creates a new text.
+ *
+ * @param parent The parent composite.
+ * @return The new text.
+ */
+ public static Text createText(Composite parent)
+ {
+ Text toReturn = new Text(parent, SWT.BORDER);
+ GridData data = new GridData(GridData.FILL_HORIZONTAL);
+ data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
+ toReturn.setLayoutData(data);
+
+ return toReturn;
+ }
+
+ /**
+ * Creates a new tree item. If the text parameter is null, it will appear is
+ * after the field parameter.
+ *
+ * @param itemParent The parent tree item
+ * @param image The image of the tree item.
+ * @param field The field.
+ * @param text The text of the tree item.
+ * @return The new tree item.
+ */
+ public static TreeItem createTreeItem(TreeItem itemParent, Image image, String field,
+ String text)
+ {
+ TreeItem toReturn = new TreeItem(itemParent, 0);
+ toReturn.setText((text == null) ? field : field + " (" + text + ")"); //$NON-NLS-1$ //$NON-NLS-2$
+ toReturn.setImage(image);
+ toReturn.setExpanded(true);
+
+ return toReturn;
+ }
+
+ /**
+ * Creates a new horizontal tool bar.
+ *
+ * @param parent The parent tool bar item.
+ * @return A new tool bar item.
+ */
+ public static ToolBar createHorizontalToolBar(Composite parent)
+ {
+ return new ToolBar(parent, SWT.HORIZONTAL);
+ }
+
+ /**
+ * Creates a new tool item like a push button
+ *
+ * @param toolBar The parent tool bar item.
+ * @return A new tool item.
+ */
+ public static ToolItem createPushToolItem(ToolBar toolBar)
+ {
+ return new ToolItem(toolBar, SWT.PUSH);
+ }
+
+ /**
+ * Creates a titled group.
+ *
+ * @param parent The parent composite
+ * @param title The desired title.
+ * @return The titled group
+ */
+ public static Group createTitledGroup(Composite parent, String title)
+ {
+ Group toReturn = new Group(parent, SWT.SHADOW_NONE);
+ toReturn.setText(title);
+ toReturn.setLayout(new GridLayout());
+ toReturn.setLayoutData(new GridData(GridData.FILL_BOTH));
+ return toReturn;
+ }
+
+ /**
+ * Creates a titled group with the given number of columns.
+ *
+ * @param parent The parent composite.
+ * @param title The group title.
+ * @param numColumns The number of columns.
+ * @return The created group.
+ */
+ public static Group createTitledGroup(Composite parent, String title, int numColumns)
+ {
+ Group toReturn = new Group(parent, SWT.SHADOW_NONE);
+ toReturn.setText(title);
+ GridLayout layout = createGridLayout(numColumns);
+ toReturn.setLayout(layout);
+ return toReturn;
+ }
+
+ /**
+ * Creates a group
+ *
+ * @param parent The parent composite
+ * @return The group
+ */
+ public static Group createGroup(Composite parent)
+ {
+ Group toReturn = new Group(parent, SWT.SHADOW_NONE);
+ return toReturn;
+ }
+
+ /**
+ * Creates a radio button
+ *
+ * @param parent The parent composite
+ * @param text The given text.
+ * @return The radio button
+ */
+ public static Button createRadioButton(Composite parent, String text)
+ {
+ Button toReturn = new Button(parent, SWT.RADIO);
+ toReturn.setText(text);
+ toReturn.setLayoutData(new GridData(GridData.FILL_BOTH));
+ return toReturn;
+ }
+
+ /**
+ * Creates a list.
+ *
+ * @param parent The parent composite.
+ * @return The list.
+ */
+ public static List createList(Composite parent)
+ {
+ return new List(parent, SWT.BORDER | SWT.SINGLE);
+ }
+
+}
diff --git a/src/plugins/logger.collector/src/com/motorola/studio/android/logger/collector/util/WidgetsUtil.java b/src/plugins/logger.collector/src/com/motorola/studio/android/logger/collector/util/WidgetsUtil.java
new file mode 100644
index 0000000..caa7f54
--- /dev/null
+++ b/src/plugins/logger.collector/src/com/motorola/studio/android/logger/collector/util/WidgetsUtil.java
@@ -0,0 +1,392 @@
+/*
+ * 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.logger.collector.util;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.preference.FileFieldEditor;
+import org.eclipse.jface.preference.PreferenceDialog;
+import org.eclipse.jface.preference.PreferenceManager;
+import org.eclipse.jface.preference.StringFieldEditor;
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Monitor;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Class with useful methods for widgets.
+ */
+public class WidgetsUtil
+{
+
+ /**
+ * This method test if a given String is null or empty.
+ *
+ * @param s The String
+ * @return <code>true</code> if the String is null or empty,
+ * <code>false</code> otherwise.
+ */
+ private static boolean isNullOrEmpty(String s)
+ {
+ return ((s != null) && s.trim().equals("")); //$NON-NLS-1$
+ }
+
+ /**
+ * The method verify if the file exist.
+ *
+ * @param fileName The full path for file.
+ * @return <code>true</code> if the file exist, <code>false</code>
+ * otherwise.
+ */
+ public static boolean fileExist(String fileName)
+ {
+ return !isNullOrEmpty(fileName) && new File(fileName).exists();
+ }
+
+ /**
+ * This method test if some StringFieldEditor value of the given collection
+ * is null or empty.
+ *
+ * @param editors
+ * @return <code>true</code> if some StringFieldEditor value is null or
+ * empty, <code>false</code> otherwise.
+ */
+ public static boolean isNullOrEmpty(StringFieldEditor... editors)
+ {
+ for (StringFieldEditor editor : editors)
+ {
+ if (isNullOrEmpty(editor))
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * This method test if a StringFieldEditor value is null or empty.
+ *
+ * @param editor The StringFieldEditor
+ * @return <code>true</code> if the StringFieldEditor value is null or
+ * empty, <code>false</code> otherwise.
+ */
+ public static boolean isNullOrEmpty(StringFieldEditor editor)
+ {
+ return ((editor != null) && isNullOrEmpty(editor.getStringValue()));
+ }
+
+ /**
+ * This method test if a StringFieldEditor value contains a invalid
+ * character.
+ *
+ * @param editor The StringFieldEditor
+ * @return <code>true</code> if the StringFieldEditor value contains invalid
+ * character, <code>false</code> otherwise.
+ */
+ public static boolean checkExistInvalidCharacter(StringFieldEditor editor, String invalidChars)
+ {
+ for (int i = 0; i < invalidChars.length(); i++)
+ {
+ String invalidChar = invalidChars.substring(i, i + 1);
+ if (editor.getStringValue().contains(invalidChar))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * This method test if a Text value is null or empty.
+ *
+ * @param text The Text
+ * @return <code>true</code> if the Text value is null or empty,
+ * <code>false</code> otherwise.
+ */
+ public static boolean isNullOrEmpty(Text text)
+ {
+ return ((text != null) && isNullOrEmpty(text.getText()));
+ }
+
+ /**
+ * This method test if a FileFieldEditor value is null or empty.
+ *
+ * @param editor The FileFieldEditor
+ * @return <code>true</code> if the FileFieldEditor value is null or empty,
+ * <code>false</code> otherwise.
+ */
+ public static boolean isEmpty(FileFieldEditor editor)
+ {
+ return isNullOrEmpty(editor.getStringValue());
+ }
+
+ /**
+ * This method test if a Combo value is null or empty.
+ *
+ * @param combo The Combo
+ * @return <code>true</code> if the Combo value is null or not selected,
+ * <code>false</code> otherwise.
+ */
+ public static boolean isNullOrDeselected(Combo combo)
+ {
+ return ((combo != null) && (combo.getSelectionIndex() == -1));
+ }
+
+ /**
+ * Returns the size of file.
+ *
+ * @param fileName The file name.
+ * @return The size of file.
+ */
+ public static long fileSize(String fileName)
+ {
+ return new File(fileName).length();
+ }
+
+ /**
+ * This method test if a Table has one or more lines.
+ *
+ * @param table The table
+ * @return <code>true</code> if the Table has one or more lines,
+ * <code>false</code> otherwise.
+ */
+ public static boolean isNullOrEmpty(Table table)
+ {
+ return table.getItemCount() > 0;
+ }
+
+ /**
+ * Executes a wizard.
+ *
+ * @param wizard The wizard.
+ * @return <code>true</code> if the Wizard dialog has constant OK,
+ * <code>false</code> otherwise .
+ */
+ public static boolean runWizard(IWizard wizard)
+ {
+ Shell activeShell = Display.getCurrent().getActiveShell();
+ WizardDialog dialog = new WizardDialog(activeShell, wizard);
+
+ try
+ {
+ dialog.create();
+ }
+ catch (Throwable e)
+ {
+ e.printStackTrace();
+ }
+ centerDialog(dialog);
+ return dialog.open() == WizardDialog.OK;
+ }
+
+ /**
+ * Opens the Eclipse preferences dialog and selects the page of the given
+ * id.
+ *
+ * @param shell The shell.
+ * @param selectedNode The preferences page to selec.
+ * @return <code>true</code> if the Wizard dialog has constant OK,
+ * <code>false</code> otherwise .
+ */
+ public static boolean runPreferencePage(Shell shell, String selectedNode)
+ {
+ PreferenceManager manager = PlatformUI.getWorkbench().getPreferenceManager();
+ PreferenceDialog dialog = new PreferenceDialog(shell, manager);
+ dialog.setSelectedNode(selectedNode);
+ WidgetsUtil.centerDialog(shell);
+ return dialog.open() == PreferenceDialog.OK;
+ }
+
+ /**
+ * Center the dialog.
+ *
+ * @param shell The shell.
+ */
+ public static void centerDialog(Shell shell)
+ {
+ Monitor primary = shell.getDisplay().getPrimaryMonitor();
+ Rectangle bounds = primary.getBounds();
+ Rectangle rect = shell.getBounds();
+ int x = bounds.x + (bounds.width - rect.width) / 2;
+ int y = bounds.y + (bounds.height - rect.height) / 2;
+ shell.setLocation(x, y);
+ }
+
+ /**
+ * Center the dialog.
+ *
+ * @param dialog The dialog.
+ */
+ public static void centerDialog(Dialog dialog)
+ {
+ centerDialog(dialog.getShell());
+ }
+
+ /**
+ * Check the leaf items of the given tree.
+ *
+ * @param tree The tree.
+ * @return A collection containing the leaf tree items.
+ */
+ public static List<TreeItem> getCheckedLeafItems(Tree tree)
+ {
+ List<TreeItem> toReturn = new ArrayList<TreeItem>();
+ selectCheckedLeafItems(tree.getItems(), toReturn);
+ return toReturn;
+ }
+
+ /**
+ * Returns a list of the leaf nodes that are checked.
+ *
+ * @param items The parent items.
+ * @param list A list of the leaf nodes that are checked.
+ */
+ private static void selectCheckedLeafItems(TreeItem[] items, List<TreeItem> list)
+ {
+ int len = items.length;
+ for (int i = 0; i < len; i++)
+ {
+ if (items[i].getItemCount() > 0)
+ {
+ selectCheckedLeafItems(items[i].getItems(), list);
+ }
+ else if (items[i].getChecked())
+ {
+ list.add(items[i]);
+ }
+ }
+ }
+
+ /**
+ * Expand all the given tree items.
+ *
+ * @param items The tree items.
+ */
+ public static void expandAll(TreeItem[] items)
+ {
+ for (int i = 0; i < items.length; i++)
+ {
+ if (items[i].getItems().length > 0)
+ {
+ items[i].setExpanded(true);
+ expandAll(items[i].getItems());
+ }
+ }
+ }
+
+ /**
+ * Returns the full path of a given tree item.
+ *
+ * @param item The tree item.
+ * @return The full path of a given tree item.
+ */
+ public static String getFullPathTreeItem(TreeItem item)
+ {
+ String toReturn = item.getText();
+ if (item != null)
+ {
+ if (item.getParentItem() != null)
+ {
+ toReturn = getFullPathTreeItem(item.getParentItem()) + "." + toReturn; //$NON-NLS-1$
+ }
+ }
+ return toReturn;
+ }
+
+ /**
+ * This method verifies if a given file can be read.
+ *
+ * @param fileName the full file path.
+ * @return <code>true</code> if read permission is granted,
+ * <code>false</code> otherwise.
+ */
+ public static boolean canRead(String fileName)
+ {
+ return !isNullOrEmpty(fileName) && new File(fileName).canRead();
+ }
+
+ /**
+ * This method verifies if a given file has the read and write permissions
+ * granted.
+ *
+ * @param fileName The file
+ * @return <code>true</code> if permissions are granted, <code>false</code>
+ * otherwise.
+ */
+ public static boolean canReadWrite(String fileName)
+ {
+ File file = new File(fileName);
+ return file.canRead() && file.canWrite();
+ }
+
+ /**
+ * This method simulates a refresh in a Composite object.
+ *
+ * @param composite A composite object.
+ */
+ public static void refreshComposite(Composite composite)
+ {
+ for (Composite parent = composite.getParent(); parent != null; parent = parent.getParent())
+ {
+ parent.layout();
+ }
+ }
+
+ /**
+ * Check the leaf items of the given table.
+ *
+ * @param table The table.
+ * @return A collection containing the leaf table items.
+ */
+ public static List<TableItem> getCheckedLeafItems(Table table)
+ {
+ List<TableItem> toReturn = new ArrayList<TableItem>();
+ selectCheckedLeafItems(table.getItems(), toReturn);
+ return toReturn;
+ }
+
+ /**
+ * Returns a list of the leaf nodes that are checked.
+ *
+ * @param items The parent items.
+ * @param list A list of the leaf nodes that are checked.
+ */
+ private static void selectCheckedLeafItems(TableItem[] items, List<TableItem> list)
+ {
+ int len = items.length;
+ for (int i = 0; i < len; i++)
+ {
+ if (items[i].getChecked())
+ {
+ list.add(items[i]);
+ }
+ }
+ }
+}
diff --git a/src/plugins/logger.collector/src/com/motorola/studio/android/logger/collector/util/ZipUtil.java b/src/plugins/logger.collector/src/com/motorola/studio/android/logger/collector/util/ZipUtil.java
new file mode 100644
index 0000000..f2c943c
--- /dev/null
+++ b/src/plugins/logger.collector/src/com/motorola/studio/android/logger/collector/util/ZipUtil.java
@@ -0,0 +1,260 @@
+/*
+ * 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.logger.collector.util;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.zip.CRC32;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+import java.util.zip.ZipOutputStream;
+
+/**
+ * Class with useful method to compact (zip) files and directories.
+ */
+public class ZipUtil
+{
+
+ /**
+ * The default buffer.
+ */
+ private static final int BUFFER = 2048;
+
+ /**
+ * The output file.
+ */
+ private File outputFile = null;
+
+ /**
+ * This file represents the current directory.
+ */
+ private File directory = null;
+
+ /**
+ * A ZipOutputStream object.
+ */
+ private ZipOutputStream zos = null;
+
+ /**
+ * The path of current directory.
+ */
+ private final String currentDirectory;
+
+ /**
+ * Class constructor.
+ *
+ * @param outputFile The output to create the zip file.
+ * @param directory The directory that will be compacted.
+ * @throws IOException
+ */
+ public ZipUtil(String outputFile, String directory) throws IOException
+ {
+ this(new File(outputFile), new File(directory));
+ }
+
+ /**
+ * Class constructor.
+ *
+ * @param outputFile The file where the zip file will be created.
+ * @param directory The directory that will be compacted.
+ * @throws IOException
+ */
+ public ZipUtil(File outputFile, File directory) throws IOException
+ {
+ this.outputFile = outputFile;
+ this.directory = directory;
+ this.currentDirectory = directory.getAbsolutePath();
+ }
+
+ /**
+ * Compact the content.
+ *
+ * @throws IOException
+ */
+ public final void zip() throws IOException
+ {
+ FileOutputStream fos = null;
+ try
+ {
+ fos = new FileOutputStream(outputFile);
+ zos = new ZipOutputStream(fos);
+ zipDir(directory);
+ zos.flush();
+ }
+ finally
+ {
+ try
+ {
+ zos.close();
+ fos.close();
+ }
+ catch (IOException io)
+ {
+ io.printStackTrace();
+ }
+ }
+ }
+
+ /**
+ * Compact directory the content.
+ *
+ * @param dir The directory
+ * @throws IOException
+ */
+ private final void zipDir(File dir) throws IOException
+ {
+ if (!dir.getPath().equals(currentDirectory))
+ {
+ String entryName = dir.getPath().substring(currentDirectory.length() + 1);
+ entryName = entryName.replace('\\', '/'); //$NON-NLS-1$ //$NON-NLS-2$
+ ZipEntry ze = new ZipEntry(entryName + "/"); //$NON-NLS-1$
+ if ((dir != null) && dir.exists())
+ {
+ ze.setTime(dir.lastModified());
+ }
+ else
+ {
+ ze.setTime(System.currentTimeMillis());
+ }
+ ze.setSize(0);
+ ze.setMethod(ZipEntry.STORED);
+ ze.setCrc(new CRC32().getValue());
+ zos.putNextEntry(ze);
+ }
+
+ if (dir.exists() && dir.isDirectory())
+ {
+ File[] fileList = dir.listFiles();
+ for (int i = 0; i < fileList.length; i++)
+ {
+ if (fileList[i].isDirectory())
+ {
+ zipDir(fileList[i]);
+ }
+ if (fileList[i].isFile())
+ {
+ zipFile(fileList[i]);
+ }
+ }
+ }
+ }
+
+ /**
+ * Compact the file content.
+ *
+ * @param file The file
+ * @throws IOException
+ */
+ private void zipFile(File file) throws IOException
+ {
+ if (!file.equals(this.outputFile))
+ {
+ BufferedInputStream bis = null;
+ try
+ {
+ bis = new BufferedInputStream(new FileInputStream(file), BUFFER);
+
+ String entryName = file.getPath().substring(currentDirectory.length() + 1);
+ entryName = entryName.replace('\\', '/'); //$NON-NLS-1$ //$NON-NLS-2$
+ ZipEntry fileEntry = new ZipEntry(entryName);
+ zos.putNextEntry(fileEntry);
+
+ byte[] data = new byte[BUFFER];
+ int byteCount;
+ while ((byteCount = bis.read(data, 0, BUFFER)) != -1)
+ {
+ zos.write(data, 0, byteCount);
+ }
+
+ }
+ finally
+ {
+ bis.close();
+ }
+ }
+ }
+
+ /**
+ * Unpacks a zip file to the target directory.
+ *
+ * @param zipFilePath The zip file.
+ * @param destDirPath The destination directory.
+ * @throws IOException
+ */
+ public static void unzip(String zipFilePath, String destDirPath) throws IOException
+ {
+ try
+ {
+ File zipFile = new File(zipFilePath);
+ File folder = new File(destDirPath);
+ ZipFile zip = new ZipFile(zipFile);
+ Enumeration<? extends ZipEntry> entries = zip.entries();
+ while (entries.hasMoreElements())
+ {
+ ZipEntry entry = entries.nextElement();
+ unzipEntry(zip, entry, folder);
+ }
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Error while trying to unzip jar file"); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Validate and write the stream of file.
+ *
+ * @param zipFile The zip file
+ * @param zipEntry The zip entry
+ * @param folder The folder
+ * @throws IOException
+ */
+ private static void unzipEntry(ZipFile zipFile, ZipEntry zipEntry, File folder)
+ throws IOException
+ {
+ if (zipEntry.isDirectory())
+ {
+ com.motorola.studio.android.common.utilities.FileUtil.mkdir(new File(folder, zipEntry
+ .getName()).getPath());
+ }
+ else
+ {
+ File outputFile = new File(folder, zipEntry.getName());
+ if (!outputFile.getParentFile().exists())
+ {
+ com.motorola.studio.android.common.utilities.FileUtil.mkdir(outputFile
+ .getParentFile().getPath());
+ }
+ BufferedInputStream is = new BufferedInputStream(zipFile.getInputStream(zipEntry));
+ BufferedOutputStream os = new BufferedOutputStream(new FileOutputStream(outputFile));
+ try
+ {
+ com.motorola.studio.android.common.utilities.FileUtil.copy(
+ new File(zipFile.getName()), outputFile);
+ }
+ finally
+ {
+ os.close();
+ is.close();
+ }
+ }
+ }
+}