* @throws PartInitException the part init exception
*/
@Override
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
if (!(input instanceof DAForJavaEditorInput)) {
throw new PartInitException("Invalid Input");
}
setSite(site);
setInput(input);
DAForJavaEditorInput eInput = (DAForJavaEditorInput) input;
AbstractSelectionHandler selectionHandler = SelectionHandlerFactory.getInstance().getSelectionHandler(eInput.getSelection());
setPartName(selectionHandler.getEditorTitle());
try {
// initialize db connection
IJavaProject selectedProject = selectionHandler.getSelectedProject();
String dbUrl = initDatabaseConfiguration(selectedProject.getProject());
IEvolizerSession session = EvolizerSessionHandler.getHandler().getCurrentSession(dbUrl);
SnapshotAnalyzer snapshotAnalyzer = new SnapshotAnalyzer(session);
fGraphPanel = new DAForJavaGraphPanel(new GraphLoader(snapshotAnalyzer));
fGraphPanel.initGraphPanel();
// site.getWorkbenchWindow().getActivePage().addPartListener(fPartListener);
initDragAndDrop();
// setPartName(selectionHandler.getEditorTitle());
List<AbstractFamixEntity> entities = selectionHandler.getSelectedEntities(snapshotAnalyzer);
if (entities.size() == 0) {
IProgressMonitor pm = Job.getJobManager().createProgressGroup();
pm.beginTask("Extracting and storing the FAMIX model for further use ...", 10);
List<IJavaElement> selection = new ArrayList<IJavaElement>();
selection.add(selectedProject);
FamixParserJob parseJob = new FamixParserJob(selection);
parseJob.setUser(true);
parseJob.setProgressGroup(pm, 5);
parseJob.schedule();
parseJob.join();
Job storeModelJob = new FamixStoreModelJob(dbUrl, parseJob.getFamixModel());
storeModelJob.setUser(true);
storeModelJob.setProgressGroup(pm, 5);
storeModelJob.schedule();
storeModelJob.join();
entities = selectionHandler.getSelectedEntities(snapshotAnalyzer);
}
AbstractGraphEditCommand command = new AddEntitiesCommand(entities, fGraphPanel.getGraphLoader(), fGraphPanel.getEdgeGrouper());
fGraphPanel.getCommandController().executeCommand(command);
openDependencyAnalyzerPerspective();
} catch (InterruptedException ie) {
throw new PartInitException(ie.getMessage(), ie);
} catch (EvolizerException ee) {
throw new PartInitException(ee.getMessage(), ee);
} catch (CoreException ce) {
throw new PartInitException(ce.getMessage(), ce);
}
}