use of org.eclipse.ui.IEditorReference in project tdq-studio-se by Talend.
the class CorePlugin method itemIsOpening.
/**
* check the item's editor is opening or not.
*
* @param item
* @param closeEditor close the editor if it is opening
* @return
*/
public boolean itemIsOpening(Item item, boolean closeEditor) {
boolean opening = false;
IWorkbenchPage activePage = CorePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
IEditorReference[] editorReferences = activePage.getEditorReferences();
IEditorInput editorInput = null;
Property property = item.getProperty();
for (IEditorReference reference : editorReferences) {
try {
editorInput = reference.getEditorInput();
if (editorInput instanceof FileEditorInput) {
FileEditorInput fileInput = (FileEditorInput) editorInput;
if (property.eResource() != null) {
IPath itemPath = PropertyHelper.getItemPath(property);
if (itemPath != null && itemPath.equals(fileInput.getFile().getFullPath())) {
opening = true;
if (closeEditor) {
activePage.closeEditor(reference.getEditor(false), false);
}
break;
}
}
} else if (editorInput instanceof AbstractItemEditorInput) {
AbstractItemEditorInput input = (AbstractItemEditorInput) editorInput;
Item it = input.getItem();
if (it != null && property != null && it.getProperty().getId().equals(property.getId())) {
opening = true;
if (closeEditor) {
activePage.closeEditor(reference.getEditor(false), false);
}
break;
}
}
} catch (PartInitException e) {
log.error(e);
continue;
}
}
return opening;
}
use of org.eclipse.ui.IEditorReference in project tdq-studio-se by Talend.
the class CorePlugin method getCurrentOpenAnalysisEditor.
public List<AnalysisEditor> getCurrentOpenAnalysisEditor() {
IWorkbenchPage activePage = CorePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
IEditorReference[] editorReferences = activePage.getEditorReferences();
List<AnalysisEditor> result = new ArrayList<AnalysisEditor>();
for (IEditorReference iEditorReference : editorReferences) {
IEditorPart editor = iEditorReference.getEditor(false);
if (editor instanceof AnalysisEditor) {
result.add((AnalysisEditor) editor);
}
}
return result;
}
use of org.eclipse.ui.IEditorReference in project tdq-studio-se by Talend.
the class CorePlugin method refreshOpenedEditor.
/**
* refresh the related connection which is opened in DQ side.
*
* @param item
*/
public void refreshOpenedEditor(Item item) {
if (item == null) {
return;
}
IWorkbenchPage activePage = CorePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
IEditorReference[] editorReferences = activePage.getEditorReferences();
Property property = item.getProperty();
for (IEditorReference reference : editorReferences) {
try {
IEditorInput input = reference.getEditorInput();
if (input instanceof AbstractItemEditorInput) {
AbstractItemEditorInput itemInput = (AbstractItemEditorInput) input;
Item it = itemInput.getItem();
if (it != null && property != null && it.getProperty().getId().equals(property.getId())) {
// make sure the item in editorInput is latest.
if (!item.equals(it)) {
itemInput.setRepNode(RepositoryNodeHelper.recursiveFind(property));
}
CommonFormEditor editor = (CommonFormEditor) reference.getEditor(false);
editor.refreshEditor();
break;
}
}
} catch (PartInitException e) {
log.error(e);
continue;
}
}
}
use of org.eclipse.ui.IEditorReference in project titan.EclipsePlug-ins by eclipse.
the class AstRunnerJava method init.
public void init(IWorkbenchWindow window) {
fileNames = new ArrayList<String>();
files = new ArrayList<IFile>();
AstRunnerJava.window = window;
try {
FileOutputStream fos = new FileOutputStream(props.getProperty("log.path"));
fos.write("open file".getBytes());
IWorkbenchPage p = window.getActivePage();
if (p != null) {
IEditorPart e = p.getActiveEditor();
if (e != null) {
IEditorInput i = e.getEditorInput();
if (i instanceof IFileEditorInput) {
fos.write(((IFileEditorInput) i).getFile().getLocation().toOSString().getBytes());
}
}
}
fos.write("\n".getBytes());
for (IWorkbenchPage page : window.getPages()) {
for (IEditorReference editor : page.getEditorReferences()) {
IEditorInput input = editor.getEditorInput();
if (input instanceof IFileEditorInput) {
fos.write(((IFileEditorInput) input).getFile().getLocation().toOSString().getBytes());
}
}
}
fos.flush();
fos.close();
} catch (PartInitException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
use of org.eclipse.ui.IEditorReference in project epp.mpc by eclipse.
the class AbstractMarketplaceWizardBotTest method marketplaceBrowser.
protected SWTBotBrowser marketplaceBrowser() {
SWTWorkbenchBot wbBot = new SWTWorkbenchBot();
Matcher<IEditorReference> marketplaceBrowserMatch = allOf(WidgetMatcherFactory.<IEditorReference>withPartId("org.eclipse.ui.browser.editor"), WidgetMatcherFactory.<IEditorReference>withTitle(containsString("Marketplace")));
SWTBotEditor browserEditor = wbBot.editor(marketplaceBrowserMatch);
SWTBotBrowser browser = browserEditor.bot().browser();
return browser;
}
Aggregations