public abstract class AbstractExampleInstallerWizard
extends Wizard
This abstract example installer wizard simply copies or unzips a number of files and directories into the workspace, creating the projects to hold them. This wizard can be added as a new wizard to the new wizards dialog through the org.eclipse.ui.newWizards extension point.
Clients should subclass this class and override the getProjectDescriptors()
method to provide the location and name of the project content that should be added to the
workspace. Note that any projects that are already in the workspace will not be
overwritten because the user could have made changes to them that would be lost.
It is highly recommended when registering subclasses to the new wizards extension point that the wizard declaration should have canFinishEarly = true. Any label and icon can be freely given to the wizard to suit the needs of the client.
Modifier and Type | Class and Description |
---|---|
static class |
AbstractExampleInstallerWizard.FileToOpen |
static class |
AbstractExampleInstallerWizard.ProjectDescriptor |
class |
AbstractExampleInstallerWizard.ProjectPage |
Modifier and Type | Field and Description |
---|---|
protected static IOverwriteQuery |
OVERWRITE_ALL_QUERY |
protected AbstractExampleInstallerWizard.ProjectPage |
projectPage |
protected IStructuredSelection |
structuredSelection |
protected IWorkbench |
workbench |
Constructor and Description |
---|
AbstractExampleInstallerWizard() |
Modifier and Type | Method and Description |
---|---|
void |
addPages() |
protected ImportOperation |
createDirectoryImportOperation(AbstractExampleInstallerWizard.ProjectDescriptor projectDescriptor)
Deprecated.
Use
installProjectFromDirectory(org.eclipse.emf.common.ui.wizard.AbstractExampleInstallerWizard.ProjectDescriptor, IProgressMonitor) , which also actually creates the project and performs the import. |
protected ImportOperation |
createFileImportOperation(AbstractExampleInstallerWizard.ProjectDescriptor projectDescriptor)
Deprecated.
Use
installProjectFromFile(org.eclipse.emf.common.ui.wizard.AbstractExampleInstallerWizard.ProjectDescriptor, IProgressMonitor) , which also actually creates the project and performs the import. |
protected ImportOperation |
createImportOperation(AbstractExampleInstallerWizard.ProjectDescriptor projectDescriptor)
Deprecated.
Use
installProject(ProjectDescriptor, IProgressMonitor) , which also actually creates the project and performs the import. |
protected void |
createProject(AbstractExampleInstallerWizard.ProjectDescriptor projectDescriptor,
IProgressMonitor monitor) |
protected java.util.zip.ZipFile |
createZipFile(java.io.File file)
Returns a
ZipFile for reading from the given file, if it is in fact a zip file; null otherwise. |
protected ImportOperation |
createZipImportOperation(AbstractExampleInstallerWizard.ProjectDescriptor projectDescriptor,
java.io.File file)
Deprecated.
Use
installProjectFromFile(org.eclipse.emf.common.ui.wizard.AbstractExampleInstallerWizard.ProjectDescriptor, IProgressMonitor) , which handles zip files directly, and also actually creates the project and performs the import. |
protected Diagnostic |
deleteExistingProjects(IProgressMonitor monitor) |
void |
dispose() |
protected abstract java.util.List<AbstractExampleInstallerWizard.FileToOpen> |
getFilesToOpen() |
protected abstract java.util.List<AbstractExampleInstallerWizard.ProjectDescriptor> |
getProjectDescriptors()
Returns the project descriptors to be used by this wizard.
|
protected IStructuredSelection |
getSelection() |
protected IWorkbench |
getWorkbench() |
void |
init(IWorkbench workbench,
IStructuredSelection selection) |
protected void |
installExample(IProgressMonitor progressMonitor)
Installs the projects described by
getProjectDescriptors() . |
protected void |
installProject(AbstractExampleInstallerWizard.ProjectDescriptor projectDescriptor,
ImportOperation importOperation,
IProgressMonitor progressMonitor)
Creates the project described by the given
projectDescriptor and imports its contents using the given importOperation . |
protected void |
installProject(AbstractExampleInstallerWizard.ProjectDescriptor projectDescriptor,
IProgressMonitor progressMonitor)
Installs the project described by the given
projectDescriptor . |
protected void |
installProjectFromDirectory(AbstractExampleInstallerWizard.ProjectDescriptor projectDescriptor,
IProgressMonitor progressMonitor)
Installs the project described by the given
projectDescriptor from a directory. |
protected void |
installProjectFromFile(AbstractExampleInstallerWizard.ProjectDescriptor projectDescriptor,
IProgressMonitor progressMonitor)
Installs the project described by the given
projectDescriptor from a file. |
protected boolean |
isZipFile(java.io.File file)
Deprecated.
Use
createZipFile(java.io.File) , which doesn't require creating another ZipFile . |
protected void |
openEditor(IFile file,
java.lang.String editorID) |
protected void |
openErrorDialog(java.lang.String message,
java.lang.Throwable throwable) |
protected void |
openFiles(IProgressMonitor progressMonitor) |
boolean |
performFinish() |
protected static final IOverwriteQuery OVERWRITE_ALL_QUERY
protected IWorkbench workbench
protected IStructuredSelection structuredSelection
protected AbstractExampleInstallerWizard.ProjectPage projectPage
public void init(IWorkbench workbench, IStructuredSelection selection)
protected abstract java.util.List<AbstractExampleInstallerWizard.ProjectDescriptor> getProjectDescriptors()
protected abstract java.util.List<AbstractExampleInstallerWizard.FileToOpen> getFilesToOpen()
public void dispose()
public void addPages()
public boolean performFinish()
protected Diagnostic deleteExistingProjects(IProgressMonitor monitor)
protected void installExample(IProgressMonitor progressMonitor) throws java.lang.Exception
getProjectDescriptors()
.
In EMF 2.4, this worked by obtaining an ImportOperation
for each descriptor from createImportOperation(org.eclipse.emf.common.ui.wizard.AbstractExampleInstallerWizard.ProjectDescriptor)
, and then creating the project and running the operation.
Beginning in EMF 2.5, createImportOperation(org.eclipse.emf.common.ui.wizard.AbstractExampleInstallerWizard.ProjectDescriptor)
returns null by default, and installProject(ProjectDescriptor, IProgressMonitor)
is called to create the project, create the operation, and run it.
This allows the same code that creates the operation to do any cleanup required after executing it. This change was needed to stop extending ImportOperation
, which was an API violation.
Note that existing overrides of createImportOperation(org.eclipse.emf.common.ui.wizard.AbstractExampleInstallerWizard.ProjectDescriptor)
and the methods it calls are still supported; however, it is recommended to switch over to the new design.
java.lang.Exception
protected void openFiles(IProgressMonitor progressMonitor)
protected void openErrorDialog(java.lang.String message, java.lang.Throwable throwable)
protected void installProject(AbstractExampleInstallerWizard.ProjectDescriptor projectDescriptor, ImportOperation importOperation, IProgressMonitor progressMonitor) throws java.lang.Exception
projectDescriptor
and imports its contents using the given importOperation
.java.lang.Exception
protected void createProject(AbstractExampleInstallerWizard.ProjectDescriptor projectDescriptor, IProgressMonitor monitor) throws CoreException
CoreException
protected void installProject(AbstractExampleInstallerWizard.ProjectDescriptor projectDescriptor, IProgressMonitor progressMonitor) throws java.lang.Exception
projectDescriptor
.
This implementation simply looks at the form of its content URI and delegates to installProjectFromDirectory(org.eclipse.emf.common.ui.wizard.AbstractExampleInstallerWizard.ProjectDescriptor, IProgressMonitor)
or installProjectFromFile(org.eclipse.emf.common.ui.wizard.AbstractExampleInstallerWizard.ProjectDescriptor, IProgressMonitor)
, as appropriate.java.lang.Exception
@Deprecated protected ImportOperation createImportOperation(AbstractExampleInstallerWizard.ProjectDescriptor projectDescriptor) throws java.lang.Exception
installProject(ProjectDescriptor, IProgressMonitor)
, which also actually creates the project and performs the import.ImportOperation
for installing a project.
This implementation now merely returns null (or throws an exception for unsupported content forms).java.lang.Exception
protected void installProjectFromDirectory(AbstractExampleInstallerWizard.ProjectDescriptor projectDescriptor, IProgressMonitor progressMonitor) throws java.lang.Exception
projectDescriptor
from a directory.
This implementation should handle the directory scenario completely, but will throw an exception if the specified directory is not found or readable.java.lang.Exception
@Deprecated protected ImportOperation createDirectoryImportOperation(AbstractExampleInstallerWizard.ProjectDescriptor projectDescriptor) throws java.lang.Exception
installProjectFromDirectory(org.eclipse.emf.common.ui.wizard.AbstractExampleInstallerWizard.ProjectDescriptor, IProgressMonitor)
, which also actually creates the project and performs the import.ImportOperation
for installing a project from a directory.
This implementation now merely returns null.java.lang.Exception
protected void installProjectFromFile(AbstractExampleInstallerWizard.ProjectDescriptor projectDescriptor, IProgressMonitor progressMonitor) throws java.lang.Exception
projectDescriptor
from a file.
This implementation only handles zip files, throwing an exception otherwise. It may be overridden to handle other cases.java.lang.Exception
@Deprecated protected ImportOperation createFileImportOperation(AbstractExampleInstallerWizard.ProjectDescriptor projectDescriptor) throws java.lang.Exception
installProjectFromFile(org.eclipse.emf.common.ui.wizard.AbstractExampleInstallerWizard.ProjectDescriptor, IProgressMonitor)
, which also actually creates the project and performs the import.ImportOperation
for installing a project from a file.
This implementation now merely returns null (or throws an exception for unsupported files).java.lang.Exception
protected java.util.zip.ZipFile createZipFile(java.io.File file)
ZipFile
for reading from the given file, if it is in fact a zip file; null otherwise.
The client is responsible for closing the zip file if it is non-null.@Deprecated protected boolean isZipFile(java.io.File file)
File
represents a zip file.@Deprecated protected ImportOperation createZipImportOperation(AbstractExampleInstallerWizard.ProjectDescriptor projectDescriptor, java.io.File file) throws java.lang.Exception
installProjectFromFile(org.eclipse.emf.common.ui.wizard.AbstractExampleInstallerWizard.ProjectDescriptor, IProgressMonitor)
, which handles zip files directly, and also actually creates the project and performs the import.ImportOperation
for installing a project from a zip file.
This implementation now merely returns null.java.lang.Exception
protected IWorkbench getWorkbench()
protected IStructuredSelection getSelection()
protected void openEditor(IFile file, java.lang.String editorID) throws PartInitException
PartInitException