下面列出了org.eclipse.ui.IEditorPart#equals ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public void selectionChanged(final IWorkbenchPart part, final ISelection selection) {
if (selection instanceof StructuredSelection && !tableViewer.getTable().isDisposed()) {
final Object selectedEP = ((StructuredSelection) selection).getFirstElement();
if (selectedEP instanceof IGraphicalEditPart) {
final IEditorPart editorPart = getSite().getPage().getActiveEditor();
if (editorPart instanceof DiagramEditor && !editorPart.equals(tableViewer.getInput())) {
selectionProvider = editorPart.getEditorSite().getSelectionProvider();
tableViewer.setInput(editorPart);
exportAction.setReport(getReportFromEditor(editorPart));
linkAction.setEditor((DiagramEditor) editorPart);
} else if (editorPart != null && editorPart.equals(tableViewer.getInput())) {
tableViewer.refresh();
}
tableViewer.getTable().layout(true, true);
}
}
}
private String checkEditorAndGetId(IEditorPart editor) {
if (editor == null)
return null;
for (IEditorReference ref : activePage.getEditorReferences()) {
if (editor.equals(ref.getEditor(false))) {
return ref.getId();
}
}
return null;
}
/**
* Tells whether this is the active editor in the active page.
*
* @return <code>true</code> if this is the active editor in the active page
* @see IWorkbenchPage#getActiveEditor
*/
protected final boolean isActiveEditor() {
IWorkbenchWindow window= getSite().getWorkbenchWindow();
IWorkbenchPage page= window.getActivePage();
if (page == null)
return false;
IEditorPart activeEditor= page.getActiveEditor();
return activeEditor != null && activeEditor.equals(this);
}
@Override
public void selectionChanged(final IWorkbenchPart part, final ISelection selection) {
if (selection instanceof StructuredSelection
&& !tableViewer.getTable().isDisposed()) {
final Object selectedEP = ((StructuredSelection) selection)
.getFirstElement();
if (selectedEP instanceof IGraphicalEditPart) {
final IEditorPart editorPart = getSite().getPage().getActiveEditor();
if (editorPart != null) {
if (!editorPart.equals(tableViewer.getInput())) {
selectionProvider = editorPart.getEditorSite()
.getSelectionProvider();
tableViewer.setInput(editorPart);
} else {
tableViewer.refresh();
}
}
tableViewer.getTable().layout(true, true);
}
// change Validate Action
final IWorkbenchPage activePage = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getActivePage();
// tableViewer.setInput(activePage.getActiveEditor());
validateAction = new ValidationViewAction();
validateAction.setActivePage(activePage);
validateAction.setTableViewer(tableViewer);
tableViewer.refresh();
}
}