use of org.eclipse.ui.internal.PartSite in project eclipse.platform.text by eclipse.
the class StatusEditorTest method doNotThrowOnActivationInStale.
/*
* https://bugs.eclipse.org/bugs/attachment.cgi?bugid=320672
*
* No exceptions are thrown when a status editor displaying an erroneous status is activated with a mouse click.
* @throws Exception
*/
@Test
public void doNotThrowOnActivationInStale() throws Exception {
IEditorPart editor1 = openNonExistentFile(page, new URI("file:/1.txt"));
openNonExistentFile(page, new URI("file:/2.txt"));
ILog log = Platform.getLog(Platform.getBundle("org.eclipse.e4.ui.workbench"));
List<String> logEvents = new ArrayList<>();
ILogListener listener = (status, plugin) -> logEvents.add(status.toString());
log.addLogListener(listener);
// Clicks are not equivalent to activation from API, so we need this
// hack to imitate tab clicks.
CTabFolder folder = (CTabFolder) (((PartSite) editor1.getSite()).getModel().getParent().getWidget());
try {
folder.setSelection(0);
processEvents();
folder.setSelection(1);
processEvents();
} finally {
log.removeLogListener(listener);
}
if (!logEvents.isEmpty()) {
Assert.assertEquals("Unexpected errors logged", "", logEvents.toString());
}
}
use of org.eclipse.ui.internal.PartSite in project dbeaver by serge-rider.
the class ObjectPropertiesEditor method createFoldersPanel.
private Composite createFoldersPanel(Composite parent, TabbedFolderInfo[] folders) {
// Properties
Composite foldersPlaceholder = UIUtils.createPlaceholder(parent, 1, 0);
foldersPlaceholder.setLayoutData(new GridData(GridData.FILL_BOTH));
boolean single = folders.length < 4;
if (single) {
for (TabbedFolderInfo fi : folders) {
if (!fi.isEmbeddable()) {
single = false;
}
}
}
folderComposite = new TabbedFolderComposite(foldersPlaceholder, SWT.LEFT | (single ? SWT.SINGLE : SWT.MULTI));
folderComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
// Load properties
{
String objectId = "PropertiesEditor." + getDatabaseObject().getClass().getName();
folderComposite.setFolders(objectId, folders);
}
// Collect section contributors
GlobalContributorManager contributorManager = GlobalContributorManager.getInstance();
for (TabbedFolderInfo folder : folders) {
ITabbedFolder page = folder.getContents();
if (page instanceof IDatabaseEditorContributorUser) {
IEditorActionBarContributor contributor = ((IDatabaseEditorContributorUser) page).getContributor(contributorManager);
if (contributor != null) {
contributorManager.addContributor(contributor, this);
pageContributors.put(page, contributor);
}
}
if (page instanceof ISaveablePart) {
nestedSaveable.add((ISaveablePart) page);
}
}
folderComposite.switchFolder(curFolderId);
folderComposite.addFolderListener(folderId1 -> {
if (CommonUtils.equalObjects(curFolderId, folderId1)) {
return;
}
IActionBars actionBars = getEditorSite().getActionBars();
MultiPageEditorPart mainEditor = ((MultiPageEditorSite) getSite()).getMultiPageEditor();
IWorkbenchPartSite mainEditorSite = mainEditor.getSite();
if (mainEditorSite instanceof PartSite) {
((PartSite) mainEditorSite).deactivateActionBars(true);
}
ITabbedFolder activeFolder = folderComposite.getActiveFolder();
if (activeFolder instanceof TabbedFolderPageEditor) {
IEditorActionBarContributor activeFolderContributor = pageContributors.get(activeFolder);
if (activeFolderContributor != null) {
// FIXME: do not add extra contributions as they will be there forever (never cleaned up)
// if (activeFolderContributor instanceof EditorActionBarContributor) {
// ((EditorActionBarContributor) activeFolderContributor).contributeToStatusLine(
// actionBars.getStatusLineManager());
// }
IEditorPart activeEditor = ((TabbedFolderPageEditor) activeFolder).getEditor();
activeFolderContributor.setActiveEditor(activeEditor);
}
} else if (activeFolder instanceof TabbedFolderPageNode) {
if (mainEditor instanceof EntityEditor) {
// Overwrite external contributor actions with EntityEditor actions
new EditorSearchActionsContributor().setActiveEditor(((EntityEditor) mainEditor).getActiveEditor());
}
}
actionBars.updateActionBars();
synchronized (folderListeners) {
curFolderId = folderId1;
for (ITabbedFolderListener listener : folderListeners) {
listener.folderSelected(folderId1);
}
}
});
return foldersPlaceholder;
}
Aggregations