aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@android.com>2010-03-30 11:18:18 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-03-30 11:18:18 -0700
commitcc9db245bd07b361db1a86a0a6bae969a25b80df (patch)
tree101b892af8d809b57e861cf0689b192ddab2801a
parentaa79d9a808a5da7a59a15bb3f78b7412f34015aa (diff)
parent7a3e56acaa9b3c3d4be46edde30d6dbbd69fe9b5 (diff)
downloadsdk-cc9db245bd07b361db1a86a0a6bae969a25b80df.zip
sdk-cc9db245bd07b361db1a86a0a6bae969a25b80df.tar.gz
sdk-cc9db245bd07b361db1a86a0a6bae969a25b80df.tar.bz2
Merge "Disable export for library projects." into tools-r6
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/pages/OverviewExportPart.java98
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/actions/ExportAction.java16
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/actions/ExportWizardAction.java42
3 files changed, 111 insertions, 45 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/pages/OverviewExportPart.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/pages/OverviewExportPart.java
index ec947c5..4c75a86 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/pages/OverviewExportPart.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/pages/OverviewExportPart.java
@@ -19,6 +19,8 @@ package com.android.ide.eclipse.adt.internal.editors.manifest.pages;
import com.android.ide.eclipse.adt.internal.editors.manifest.ManifestEditor;
import com.android.ide.eclipse.adt.internal.editors.ui.SectionHelper.ManifestSectionPart;
import com.android.ide.eclipse.adt.internal.project.ExportHelper;
+import com.android.ide.eclipse.adt.internal.project.ProjectState;
+import com.android.ide.eclipse.adt.internal.sdk.Sdk;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
@@ -43,45 +45,69 @@ final class OverviewExportPart extends ManifestSectionPart {
mOverviewPage = overviewPage;
Section section = getSection();
section.setText("Exporting");
- section.setDescription("To export the application for distribution, you have the following options:");
- Composite table = createTableLayout(toolkit, 2 /* numColumns */);
-
- StringBuffer buf = new StringBuffer();
- buf.append("<form><li><a href=\"wizard\">"); //$NON-NLS-1$
- buf.append("Use the Export Wizard");
- buf.append("</a>"); //$NON-NLS-1$
- buf.append(" to export and sign an APK");
- buf.append("</li>"); //$NON-NLS-1$
- buf.append("<li><a href=\"manual\">"); //$NON-NLS-1$
- buf.append("Export an unsigned APK");
- buf.append("</a>"); //$NON-NLS-1$
- buf.append(" and sign it manually");
- buf.append("</li></form>"); //$NON-NLS-1$
+ final IProject project = getProject();
+ boolean isLibrary = false;
+ if (project != null) {
+ ProjectState state = Sdk.getProjectState(project);
+ if (state != null) {
+ isLibrary = state.isLibrary();
+ }
+ }
+
+ if (isLibrary) {
+ section.setDescription("Library project cannot be exported.");
+ Composite table = createTableLayout(toolkit, 2 /* numColumns */);
+ createFormText(table, toolkit, true, "<form></form>", false /* setupLayoutData */);
+ } else {
+ section.setDescription("To export the application for distribution, you have the following options:");
+
+ Composite table = createTableLayout(toolkit, 2 /* numColumns */);
+
+ StringBuffer buf = new StringBuffer();
+ buf.append("<form><li><a href=\"wizard\">"); //$NON-NLS-1$
+ buf.append("Use the Export Wizard");
+ buf.append("</a>"); //$NON-NLS-1$
+ buf.append(" to export and sign an APK");
+ buf.append("</li>"); //$NON-NLS-1$
+ buf.append("<li><a href=\"manual\">"); //$NON-NLS-1$
+ buf.append("Export an unsigned APK");
+ buf.append("</a>"); //$NON-NLS-1$
+ buf.append(" and sign it manually");
+ buf.append("</li></form>"); //$NON-NLS-1$
- FormText text = createFormText(table, toolkit, true, buf.toString(),
- false /* setupLayoutData */);
- text.addHyperlinkListener(new HyperlinkAdapter() {
- @Override
- public void linkActivated(HyperlinkEvent e) {
- // get the project from the editor
- IEditorInput input = mOverviewPage.mEditor.getEditorInput();
- if (input instanceof FileEditorInput) {
- FileEditorInput fileInput = (FileEditorInput)input;
- IFile file = fileInput.getFile();
- IProject project = file.getProject();
-
- if ("manual".equals(e.data)) { //$NON-NLS-1$
- // now we can export an unsigned apk for the project.
- ExportHelper.exportProject(project);
- } else {
- // call the export wizard
- ExportHelper.startExportWizard(project);
+ FormText text = createFormText(table, toolkit, true, buf.toString(),
+ false /* setupLayoutData */);
+ text.addHyperlinkListener(new HyperlinkAdapter() {
+ @Override
+ public void linkActivated(HyperlinkEvent e) {
+ if (project != null) {
+ if ("manual".equals(e.data)) { //$NON-NLS-1$
+ // now we can export an unsigned apk for the project.
+ ExportHelper.exportProject(project);
+ } else {
+ // call the export wizard
+ ExportHelper.startExportWizard(project);
+ }
}
}
- }
- });
-
+ });
+ }
+
layoutChanged();
- }
+ }
+
+ /**
+ * Returns the project of the edited file.
+ */
+ private IProject getProject() {
+ IEditorInput input = mOverviewPage.mEditor.getEditorInput();
+ if (input instanceof FileEditorInput) {
+ FileEditorInput fileInput = (FileEditorInput)input;
+ IFile file = fileInput.getFile();
+ return file.getProject();
+ }
+
+ return null;
+ }
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/actions/ExportAction.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/actions/ExportAction.java
index 9093470..c331680 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/actions/ExportAction.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/actions/ExportAction.java
@@ -17,23 +17,29 @@
package com.android.ide.eclipse.adt.internal.wizards.actions;
import com.android.ide.eclipse.adt.internal.project.ExportHelper;
+import com.android.ide.eclipse.adt.internal.project.ProjectState;
+import com.android.ide.eclipse.adt.internal.sdk.Sdk;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;
public class ExportAction implements IObjectActionDelegate {
private ISelection mSelection;
+ private Shell mShell;
/**
* @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
*/
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ mShell = targetPart.getSite().getShell();
}
public void run(IAction action) {
@@ -53,13 +59,19 @@ public class ExportAction implements IObjectActionDelegate {
// and finally do the action
if (project != null) {
- ExportHelper.exportProject(project);
+ ProjectState state = Sdk.getProjectState(project);
+ if (state.isLibrary()) {
+ MessageDialog.openError(mShell, "Android Export",
+ "Android library projects cannot be exported.");
+ } else {
+ ExportHelper.exportProject(project);
+ }
}
}
}
}
public void selectionChanged(IAction action, ISelection selection) {
- this.mSelection = selection;
+ mSelection = selection;
}
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/actions/ExportWizardAction.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/actions/ExportWizardAction.java
index 8165f97..cfdab0f 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/actions/ExportWizardAction.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/actions/ExportWizardAction.java
@@ -16,9 +16,14 @@
package com.android.ide.eclipse.adt.internal.wizards.actions;
+import com.android.ide.eclipse.adt.internal.project.ProjectState;
+import com.android.ide.eclipse.adt.internal.sdk.Sdk;
import com.android.ide.eclipse.adt.internal.wizards.export.ExportWizard;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.WizardDialog;
@@ -42,16 +47,39 @@ public class ExportWizardAction implements IObjectActionDelegate {
if (mSelection instanceof IStructuredSelection) {
IStructuredSelection selection = (IStructuredSelection)mSelection;
- // call the export wizard on the current selection.
- ExportWizard wizard = new ExportWizard();
- wizard.init(mWorkbench, selection);
- WizardDialog dialog = new WizardDialog(mWorkbench.getDisplay().getActiveShell(),
- wizard);
- dialog.open();
+ // get the unique selected item.
+ if (selection.size() == 1) {
+ Object element = selection.getFirstElement();
+
+ // get the project object from it.
+ IProject project = null;
+ if (element instanceof IProject) {
+ project = (IProject) element;
+ } else if (element instanceof IAdaptable) {
+ project = (IProject) ((IAdaptable) element).getAdapter(IProject.class);
+ }
+
+ // and finally do the action
+ if (project != null) {
+ ProjectState state = Sdk.getProjectState(project);
+ if (state.isLibrary()) {
+ MessageDialog.openError(mWorkbench.getDisplay().getActiveShell(),
+ "Android Export",
+ "Android library projects cannot be exported.");
+ } else {
+ // call the export wizard on the current selection.
+ ExportWizard wizard = new ExportWizard();
+ wizard.init(mWorkbench, selection);
+ WizardDialog dialog = new WizardDialog(
+ mWorkbench.getDisplay().getActiveShell(), wizard);
+ dialog.open();
+ }
+ }
+ }
}
}
public void selectionChanged(IAction action, ISelection selection) {
- this.mSelection = selection;
+ mSelection = selection;
}
}