public class ImportModel
extends info.textgrid._import.ImportSpec
Data model for the import / export wizard. This extends the basic ImportSpec with TextGridLab specific stuff.
You should use the load(Source)
method to load a spec. The model
maintains both a list of children (which are to
be displayed at root level) and entries
(which are somewhere in the model). Use the
appropriate child's
addFile method to add an entry to a child (and to this model).
Modifier and Type | Class and Description |
---|---|
static class |
ImportModel.LocalFileStatus
Value object describing the results from
checkLocalFiles(IProgressMonitor) |
static interface |
ImportModel.ModelListener |
Constructor and Description |
---|
ImportModel() |
Modifier and Type | Method and Description |
---|---|
protected ImportEntry |
addFile(File file,
boolean global,
IProgressMonitor monitor,
ISpecialImportEntrySupplier supplier)
Adds a file to import to the current list of files.
|
ImportEntry |
addFile(File file,
IProgressMonitor monitor) |
ImportEntry |
addFile(File file,
IProgressMonitor monitor,
ISpecialImportEntrySupplier supplier)
Adds a file to import to the current list of files.
|
void |
addListener(ImportModel.ModelListener listener) |
protected ImportEntry |
addObject(TGObjectReference objectReference,
boolean global,
File parentFile,
IProgressMonitor monitor)
Creates an entry for the given object and adds it to the model.
|
ImportEntry |
addObject(TGObjectReference object,
IProgressMonitor monitor) |
ImportModel.LocalFileStatus |
checkLocalFiles(IProgressMonitor monitor)
Checks whether all local files in this spec exist.
|
static Unmarshaller |
createUnmarshaller()
Creates a ready configured
Unmarshaller that will unmarshal
import specifications to lab-aware objects. |
IStatus |
doExport(IProgressMonitor monitor) |
IStatus |
doImport(TextGridProject project,
IProgressMonitor monitor) |
info.textgrid._import.ImportObject |
findEntry(com.google.common.base.Predicate<? super info.textgrid._import.ImportObject> predicate) |
List<RewriteSetup> |
getAvailableSetups() |
List<ImportEntry> |
getChildren() |
Set<File> |
getFiles() |
List<info.textgrid._import.ImportObject> |
getImportObject() |
Set<String> |
getReimportProjectIDs()
Returns a set of projects that are "reimport" projects, i.e.
|
IPath |
getRoot() |
TextGridProject |
getTargetProject() |
boolean |
importAsNewRevision()
Returns true if files may be imported as new revisions.
|
void |
initializeLoadedModelForImport(IProgressMonitor monitor) |
boolean |
isImportAsNewRevisions()
Returns
true if we try to create new revisions for
reimported objects. |
static ImportModel |
load(Source source) |
void |
remove(TreePath path) |
void |
removeListener(ImportModel.ModelListener listener) |
File |
resolve(File localFile)
Resolves the given file against the root, if applicable
|
protected void |
sanitize() |
void |
save(Result result) |
void |
setImportAsNewRevisions(boolean reImport)
If true, try to create new revisions
|
void |
setRoot(IPath root) |
void |
setTargetProject(TextGridProject project) |
public TextGridProject getTargetProject()
public List<ImportEntry> getChildren()
public static ImportModel load(Source source) throws JAXBException
JAXBException
public static Unmarshaller createUnmarshaller() throws DataBindingException
Unmarshaller
that will unmarshal
import specifications to lab-aware objects. Unmarshalling a complete
import specification will, e.g., return an ImportModel
object.DataBindingException
- with a wrapped JAXBException
if configuring the
unmarshaller goes wrong (which would probably be a bug)public void save(Result result)
public ImportEntry addFile(File file, IProgressMonitor monitor, ISpecialImportEntrySupplier supplier)
ImportObject
and a TextGridObject
and sets up metadata
according to a heuristic.file
- the file to addsupplier
- protected ImportEntry addFile(File file, boolean global, IProgressMonitor monitor, ISpecialImportEntrySupplier supplier)
ImportObject
and a TextGridObject
and sets up metadata
according to a heuristic.file
- the file to addglobal
- if true
, the file is added to the
list of direct children for this
model.monitor
- supplier
- a special entry supplier, or null
.public info.textgrid._import.ImportObject findEntry(com.google.common.base.Predicate<? super info.textgrid._import.ImportObject> predicate) throws NoSuchElementException
NoSuchElementException
public List<info.textgrid._import.ImportObject> getImportObject()
getImportObject
in class info.textgrid._import.ImportSpec
protected ImportEntry addObject(TGObjectReference objectReference, boolean global, File parentFile, IProgressMonitor monitor)
objectReference
- A reference to the TextGridObject
to be exported.global
- if true
, also add the object to the specific list
of children.parentFile
- if non-null
, the filename to export will be a
child of this filename.monitor
- TODOImportEntry
that has been added, or null
if no ImportEntry
has been added for some reason.public void setRoot(IPath root)
public void setTargetProject(TextGridProject project)
public IStatus doImport(TextGridProject project, IProgressMonitor monitor) throws IllegalStateException
IllegalStateException
public IStatus doExport(IProgressMonitor monitor)
public File resolve(File localFile)
localFile
- file to resolvepublic List<RewriteSetup> getAvailableSetups()
public IPath getRoot()
public void addListener(ImportModel.ModelListener listener)
public void removeListener(ImportModel.ModelListener listener)
public ImportEntry addObject(TGObjectReference object, IProgressMonitor monitor)
public void setImportAsNewRevisions(boolean reImport)
public boolean isImportAsNewRevisions()
true
if we try to create new revisions for
reimported objects. Note that we only create new revisions for entries
for which all criteria are
true.public void remove(TreePath path)
public ImportEntry addFile(File file, IProgressMonitor monitor)
protected void sanitize()
public void initializeLoadedModelForImport(IProgressMonitor monitor)
public boolean importAsNewRevision()
public Set<String> getReimportProjectIDs()
public ImportModel.LocalFileStatus checkLocalFiles(IProgressMonitor monitor)