private ISelectionListener listener = new ISelectionListener() { @Override public void selectionChanged(IWorkbenchPart part, ISelection selection) { if(part instanceof WordOleEditor) { WordOleEditor editor = (WordOleEditor)part; String activeDocument = editor.getEditorInput().getName(); if(!backup.containsKey(activeDocument)) { System.out.println(activeDocument + " is new"); viewer.setInput(getInput()); } else { if(!editor.inputChanged()) { System.out.println(activeDocument + " is the same"); } else { System.out.println(activeDocument + " has changed!"); viewer.setInput(updateInput()); } } viewer.expandToLevel(AbstractTreeViewer.ALL_LEVELS); viewer.refresh(); } } };
... Variant activeDocument = null; OleAutomation auto = new OleAutomation(oleClientSite); int[] appId = auto.getIDsOfNames(new String[]{ "Application" }); if (appId != null) { Variant vApp = auto.getProperty(appId[0]); if (vApp != null) { OleAutomation application = vApp.getAutomation(); if(application!=null){ int[] activeId = getId(application, "ActiveDocument"); if(activeId != null){ activeDocument = application.getProperty(activeId[0]); } application.dispose(); } } } auto.dispose(); ...