/** * Implemented as specified by the {@link Importer} interface. * * @see Importer#setImportedFile(ImportableFile, Object, int) */ public void setImportedFile(ImportableFile f, Object result, int index) { if (model.getState() == DISCARDED) return; ImporterUIElement element = view.getUIElement(index); if (element != null) { element.setImportedFile(f, result); if (element.isDone()) { model.importCompleted(element.getID()); view.onImportEnded(element); if (markToclose) { view.setVisible(false); fireStateChange(); return; } element = view.getElementToStartImportFor(); if (element != null) { importData(element); } } fireStateChange(); } if (!hasOnGoingImport() && chooser.reloadHierarchies()) { // reload the hierarchies. Class rootType = ProjectData.class; if (chooser != null && chooser.getType() == Importer.SCREEN_TYPE) rootType = ScreenData.class; model.fireContainerLoading(rootType, true, false, -1); fireStateChange(); } }
/** * Implemented as specified by the {@link Importer} interface. * * @see Importer#removeImportElement(Object) */ public void removeImportElement(Object object) { if (model.getState() == DISCARDED || object == null) return; ImporterUIElement element = view.removeImportElement(object); if (element != null) { element.cancelLoading(); model.cancel(element.getID()); fireStateChange(); } }
/** * Imports the data for the specified import view. * * @param element The import view. */ private void importData(ImporterUIElement element) { if (element == null) return; view.setSelectedPane(element, true); model.fireImportData(element.getData(), element.getID()); if (!model.isMaster()) { EventBus bus = ImporterAgent.getRegistry().getEventBus(); bus.post(new ImportStatusEvent(true, element.getExistingContainers())); fireStateChange(); } }
/** * Implemented as specified by the {@link Importer} interface. * * @see Importer#cancelImport() */ public void cancelImport() { if (model.getState() != DISCARDED) { ImporterUIElement element = view.getSelectedPane(); if (element != null && !element.isDone() && !element.isLastImport()) { MessageBox box = new MessageBox(view, CANCEL_TITLE, CANCEL_SELECTED_TEXT); if (box.centerMsgBox() == MessageBox.NO_OPTION) return; element.cancelLoading(); model.cancel(element.getID()); } } }
/** * Implemented as specified by the {@link Importer} interface. * * @see Importer#hasOnGoingImport() */ public boolean hasOnGoingImport() { if (model.getState() != DISCARDED) { Collection<ImporterUIElement> list = view.getImportElements(); if (list == null || list.size() == 0) return false; Iterator<ImporterUIElement> i = list.iterator(); ImporterUIElement element; while (i.hasNext()) { element = i.next(); if (!element.isDone()) return true; } } return false; }
/** * Implemented as specified by the {@link Importer} interface. * * @see Importer#retryImport() */ public void retryImport() { if (model.getState() == DISCARDED) return; ImporterUIElement element = view.getSelectedPane(); if (element == null) return; List<FileImportComponent> l = element.getFilesToReimport(); if (l == null || l.size() == 0) return; Iterator<FileImportComponent> i = l.iterator(); FileImportComponent fc; ImportableObject object = element.getData(); List<File> files = new ArrayList<File>(); while (i.hasNext()) { fc = i.next(); fc.setReimported(true); files.add(fc.getFile()); } object.reImport(files); importData(object); }
/** * Implemented as specified by the {@link Importer} interface. * * @see Importer#setContainers(Collection, boolean, int, long) */ public void setContainers( Collection result, boolean refreshImport, boolean changeGroup, int type, long userID) { switch (model.getState()) { case DISCARDED: return; } if (chooser == null) return; Set nodes = TreeViewerTranslator.transformHierarchy(result); chooser.reset(nodes, type, model.getGroupId(), userID); if (refreshImport) { Collection<ImporterUIElement> l = view.getImportElements(); Iterator<ImporterUIElement> i = l.iterator(); ImporterUIElement element; while (i.hasNext()) { element = i.next(); if (!element.isDone()) { element.resetContainers(result); } } } }
/** * Implemented as specified by the {@link Importer} interface. * * @see Importer#cancelAllImports() */ public void cancelAllImports() { if (model.getState() != DISCARDED) { Collection<ImporterUIElement> list = view.getImportElements(); List<ImporterUIElement> toImport = new ArrayList<ImporterUIElement>(); if (list == null || list.size() == 0) return; Iterator<ImporterUIElement> i = list.iterator(); ImporterUIElement element; while (i.hasNext()) { element = i.next(); if (!element.isDone() && !element.isLastImport()) toImport.add(element); } if (toImport.size() > 0) { MessageBox box = new MessageBox(view, CANCEL_TITLE, CANCEL_TEXT); if (box.centerMsgBox() == MessageBox.NO_OPTION) return; i = toImport.iterator(); while (i.hasNext()) { element = i.next(); element.cancelLoading(); // if (!element.hasStarted()) model.cancel(element.getID()); } } } }
/** * Implemented as specified by the {@link Importer} interface. * * @see Importer#close() */ public void close() { if (model.isMaster()) { EventBus bus = ImporterAgent.getRegistry().getEventBus(); bus.post(new ExitApplication()); return; } Collection<ImporterUIElement> list = view.getImportElements(); List<ImporterUIElement> toImport = new ArrayList<ImporterUIElement>(); if (list == null || list.size() == 0) { view.setVisible(false); return; } Iterator<ImporterUIElement> i = list.iterator(); ImporterUIElement element; ImporterUIElement started = null; while (i.hasNext()) { element = i.next(); if (element.hasStarted()) started = element; if (!element.isDone()) toImport.add(element); } if (toImport.size() > 0) { MessageBox box = new MessageBox( view, CANCEL_TITLE, CANCEL_TEXT + "\n" + "If Yes, the window will close when the on-going " + "import is completed."); if (box.centerMsgBox() == MessageBox.NO_OPTION) return; markToclose = true; i = toImport.iterator(); while (i.hasNext()) { element = i.next(); element.cancelLoading(); // if (!element.hasStarted()) model.cancel(element.getID()); } if (started != null && started.isDone()) { markToclose = false; } } else markToclose = false; if (!markToclose) view.setVisible(false); }
/** * Implemented as specified by the {@link Importer} interface. * * @see Importer#isLastImport() */ public boolean isLastImport() { ImporterUIElement element = view.getSelectedPane(); if (element == null) return false; return element.isLastImport(); }