diff options
Diffstat (limited to 'eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/actions')
6 files changed, 0 insertions, 468 deletions
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 deleted file mode 100644 index 4d3870b86..000000000 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/actions/ExportAction.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Eclipse Public License, Version 1.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.eclipse.org/org/documents/epl-v10.php - * - * 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.android.ide.eclipse.adt.internal.wizards.actions; - -import com.android.ide.eclipse.adt.internal.lint.EclipseLintRunner; -import com.android.ide.eclipse.adt.internal.project.ExportHelper; -import com.android.ide.eclipse.adt.internal.sdk.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) - */ - @Override - public void setActivePart(IAction action, IWorkbenchPart targetPart) { - mShell = targetPart.getSite().getShell(); - } - - @Override - public void run(IAction action) { - if (mSelection instanceof IStructuredSelection) { - IStructuredSelection selection = (IStructuredSelection)mSelection; - // 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) { - if (!EclipseLintRunner.runLintOnExport(mShell, project)) { - return; - } - - ProjectState state = Sdk.getProjectState(project); - if (state.isLibrary()) { - MessageDialog.openError(mShell, "Android Export", - "Android library projects cannot be exported."); - } else { - ExportHelper.exportUnsignedReleaseApk(project); - } - } - } - } - } - - @Override - public void selectionChanged(IAction action, ISelection 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 deleted file mode 100644 index 673d9569f..000000000 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/actions/ExportWizardAction.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Eclipse Public License, Version 1.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.eclipse.org/org/documents/epl-v10.php - * - * 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.android.ide.eclipse.adt.internal.wizards.actions; - -import com.android.ide.eclipse.adt.internal.lint.EclipseLintRunner; -import com.android.ide.eclipse.adt.internal.sdk.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; -import org.eclipse.ui.IObjectActionDelegate; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPart; - -public class ExportWizardAction implements IObjectActionDelegate { - - private ISelection mSelection; - private IWorkbench mWorkbench; - - /** - * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart) - */ - @Override - public void setActivePart(IAction action, IWorkbenchPart targetPart) { - mWorkbench = targetPart.getSite().getWorkbenchWindow().getWorkbench(); - } - - @Override - public void run(IAction action) { - if (mSelection instanceof IStructuredSelection) { - IStructuredSelection selection = (IStructuredSelection)mSelection; - - // 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) { - if (!EclipseLintRunner.runLintOnExport( - mWorkbench.getActiveWorkbenchWindow().getShell(), project)) { - return; - } - - 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(); - } - } - } - } - } - - @Override - public void selectionChanged(IAction action, ISelection selection) { - mSelection = selection; - } -} diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/actions/NewProjectAction.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/actions/NewProjectAction.java deleted file mode 100644 index 38f4768b1..000000000 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/actions/NewProjectAction.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Eclipse Public License, Version 1.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.eclipse.org/org/documents/epl-v10.php - * - * 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.android.ide.eclipse.adt.internal.wizards.actions; - -import com.android.ide.eclipse.adt.internal.wizards.templates.NewProjectWizard; - -import org.eclipse.jface.action.IAction; -import org.eclipse.ui.IWorkbenchWizard; - -/** - * Delegate for the toolbar action "Android Project". - * It displays the Android New Project wizard to create a new Android Project (not a test project). - * - * @see NewTestProjectAction - */ -public class NewProjectAction extends OpenWizardAction { - - @Override - protected IWorkbenchWizard instanciateWizard(IAction action) { - return new NewProjectWizard(); - } -} diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/actions/NewTestProjectAction.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/actions/NewTestProjectAction.java deleted file mode 100755 index c8e45ef1a..000000000 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/actions/NewTestProjectAction.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Eclipse Public License, Version 1.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.eclipse.org/org/documents/epl-v10.php - * - * 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.android.ide.eclipse.adt.internal.wizards.actions; - -import com.android.ide.eclipse.adt.internal.wizards.newproject.NewTestProjectWizard; - -import org.eclipse.jface.action.IAction; -import org.eclipse.ui.IWorkbenchWizard; - -/** - * Delegate for the toolbar action "Android Test Project". - * It displays the Android New Project wizard to create a new Test Project. - */ -public class NewTestProjectAction extends OpenWizardAction { - - @Override - protected IWorkbenchWizard instanciateWizard(IAction action) { - return new NewTestProjectWizard(); - } -} diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/actions/NewXmlFileAction.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/actions/NewXmlFileAction.java deleted file mode 100644 index ba349c30a..000000000 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/actions/NewXmlFileAction.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Eclipse Public License, Version 1.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.eclipse.org/org/documents/epl-v10.php - * - * 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.android.ide.eclipse.adt.internal.wizards.actions; - -import com.android.ide.eclipse.adt.internal.wizards.newxmlfile.NewXmlFileWizard; - -import org.eclipse.jface.action.IAction; -import org.eclipse.ui.IWorkbenchWizard; - -/** - * Delegate for the toolbar action "Android Project" or for the - * project > Android Project context menu. - * - * It displays the Android New XML file wizard. - */ -public class NewXmlFileAction extends OpenWizardAction { - - @Override - protected IWorkbenchWizard instanciateWizard(IAction action) { - return new NewXmlFileWizard(); - } -} diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/actions/OpenWizardAction.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/actions/OpenWizardAction.java deleted file mode 100644 index a3e6135e5..000000000 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/actions/OpenWizardAction.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Eclipse Public License, Version 1.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.eclipse.org/org/documents/epl-v10.php - * - * 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.android.ide.eclipse.adt.internal.wizards.actions; - -import com.android.ide.eclipse.adt.internal.ui.IUpdateWizardDialog; -import com.android.ide.eclipse.adt.internal.ui.WizardDialogEx; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IObjectActionDelegate; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.IWorkbenchWindowActionDelegate; -import org.eclipse.ui.IWorkbenchWizard; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.internal.IWorkbenchHelpContextIds; -import org.eclipse.ui.internal.LegacyResourceSupport; -import org.eclipse.ui.internal.actions.NewWizardShortcutAction; -import org.eclipse.ui.internal.util.Util; - -/** - * An abstract action that displays one of our wizards. - * Derived classes must provide the actual wizard to display. - */ -/*package*/ abstract class OpenWizardAction - implements IWorkbenchWindowActionDelegate, IObjectActionDelegate { - - /** - * The wizard dialog width, extracted from {@link NewWizardShortcutAction} - */ - private static final int SIZING_WIZARD_WIDTH = 500; - - /** - * The wizard dialog height, extracted from {@link NewWizardShortcutAction} - */ - private static final int SIZING_WIZARD_HEIGHT = 500; - - /** The wizard that was created by {@link #run(IAction)}. */ - private IWorkbenchWizard mWizard; - /** The result from the dialog */ - private int mDialogResult; - - private ISelection mSelection; - private IWorkbench mWorkbench; - - /** Returns the wizard that was created by {@link #run(IAction)}. */ - public IWorkbenchWizard getWizard() { - return mWizard; - } - - /** Returns the result from {@link Dialog#open()}, available after - * the completion of {@link #run(IAction)}. */ - public int getDialogResult() { - return mDialogResult; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose() - */ - @Override - public void dispose() { - // pass - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow) - */ - @Override - public void init(IWorkbenchWindow window) { - // pass - } - - /** - * Opens and display the Android New Project Wizard. - * <p/> - * Most of this implementation is extracted from {@link NewWizardShortcutAction#run()}. - * - * @param action The action that got us here. Can be null when used internally. - * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) - */ - @Override - public void run(IAction action) { - - // get the workbench and the current window - IWorkbench workbench = mWorkbench != null ? mWorkbench : PlatformUI.getWorkbench(); - IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); - - // This code from NewWizardShortcutAction#run() gets the current window selection - // and converts it to a workbench structured selection for the wizard, if possible. - ISelection selection = mSelection; - if (selection == null) { - selection = window.getSelectionService().getSelection(); - } - - IStructuredSelection selectionToPass = StructuredSelection.EMPTY; - if (selection instanceof IStructuredSelection) { - selectionToPass = (IStructuredSelection) selection; - } else { - // Build the selection from the IFile of the editor - IWorkbenchPart part = window.getPartService().getActivePart(); - if (part instanceof IEditorPart) { - IEditorInput input = ((IEditorPart) part).getEditorInput(); - Class<?> fileClass = LegacyResourceSupport.getFileClass(); - if (input != null && fileClass != null) { - Object file = Util.getAdapter(input, fileClass); - if (file != null) { - selectionToPass = new StructuredSelection(file); - } - } - } - } - - // Create the wizard and initialize it with the selection - mWizard = instanciateWizard(action); - mWizard.init(workbench, selectionToPass); - - // It's not visible yet until a dialog is created and opened - Shell parent = window.getShell(); - WizardDialogEx dialog = new WizardDialogEx(parent, mWizard); - dialog.create(); - - if (mWizard instanceof IUpdateWizardDialog) { - ((IUpdateWizardDialog) mWizard).updateWizardDialog(dialog); - } - - // This code comes straight from NewWizardShortcutAction#run() - Point defaultSize = dialog.getShell().getSize(); - dialog.getShell().setSize( - Math.max(SIZING_WIZARD_WIDTH, defaultSize.x), - Math.max(SIZING_WIZARD_HEIGHT, defaultSize.y)); - window.getWorkbench().getHelpSystem().setHelp(dialog.getShell(), - IWorkbenchHelpContextIds.NEW_WIZARD_SHORTCUT); - - mDialogResult = dialog.open(); - } - - /** - * Called by {@link #run(IAction)} to instantiate the actual wizard. - * - * @param action The action parameter from {@link #run(IAction)}. - * This can be null. - * @return A new wizard instance. Must not be null. - */ - protected abstract IWorkbenchWizard instanciateWizard(IAction action); - - /* (non-Javadoc) - * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) - */ - @Override - public void selectionChanged(IAction action, ISelection selection) { - mSelection = selection; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart) - */ - @Override - public void setActivePart(IAction action, IWorkbenchPart targetPart) { - mWorkbench = targetPart.getSite().getWorkbenchWindow().getWorkbench(); - } -} |