use of org.eclipse.ui.part.MultiPageEditorPart in project dbeaver by serge-rider.
the class TabbedFolderPageNode method createControl.
@Override
public void createControl(Composite parent) {
itemControl = new ItemListControl(parent, SWT.SHEET, mainEditor.getSite(), node, metaNode);
//itemControl.getLayout().marginHeight = 0;
//itemControl.getLayout().marginWidth = 0;
ProgressPageControl progressControl = null;
if (mainEditor instanceof IProgressControlProvider) {
progressControl = ((IProgressControlProvider) mainEditor).getProgressControl();
}
if (progressControl != null) {
itemControl.substituteProgressPanel(progressControl);
} else {
itemControl.createProgressPanel();
}
parent.layout();
// Activate items control on focus
itemControl.getItemsViewer().getControl().addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
// Update selection provider and selection
final ISelectionProvider selectionProvider = itemControl.getSelectionProvider();
if (mainEditor.getSite().getSelectionProvider() != selectionProvider) {
mainEditor.getSite().setSelectionProvider(selectionProvider);
selectionProvider.setSelection(selectionProvider.getSelection());
}
itemControl.activate(true);
// We need it to update search actions and other contributions provided by node editor
if (mainEditor.getSite() instanceof MultiPageEditorSite) {
MultiPageEditorPart multiPageEditor = ((MultiPageEditorSite) mainEditor.getSite()).getMultiPageEditor();
if (multiPageEditor.getSelectedPage() != mainEditor) {
multiPageEditor.setActiveEditor(mainEditor);
}
}
}
@Override
public void focusLost(FocusEvent e) {
itemControl.activate(false);
}
});
}
use of org.eclipse.ui.part.MultiPageEditorPart in project dbeaver by serge-rider.
the class ItemListControl method fillCustomActions.
@Override
protected void fillCustomActions(IContributionManager contributionManager) {
super.fillCustomActions(contributionManager);
final DBNNode rootNode = getRootNode();
if (rootNode instanceof DBNDatabaseFolder && ((DBNDatabaseFolder) rootNode).getItemsMeta() != null) {
contributionManager.add(new Action("Filter", DBeaverIcons.getImageDescriptor(UIIcon.FILTER)) {
@Override
public void run() {
NavigatorHandlerFilterConfig.configureFilters(getShell(), rootNode);
}
});
}
IWorkbenchSite workbenchSite = getWorkbenchSite();
if (workbenchSite != null) {
contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, IWorkbenchCommandConstants.FILE_REFRESH));
}
if (rootNode instanceof DBNDatabaseNode) {
contributionManager.add(new Separator());
contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, CoreCommands.CMD_OBJECT_OPEN));
contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, CoreCommands.CMD_OBJECT_CREATE));
contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, CoreCommands.CMD_OBJECT_DELETE));
}
if (rootNode instanceof DBNDatabaseNode && rootNode.isPersisted()) {
boolean hasReorder = false;
List<Class<?>> childrenTypes = ((DBNDatabaseNode) rootNode).getChildrenTypes(null);
for (Class<?> chilType : childrenTypes) {
if (EntityEditorsRegistry.getInstance().getObjectManager(chilType, DBEObjectReorderer.class) != null) {
hasReorder = true;
break;
}
}
if (hasReorder) {
contributionManager.add(new Separator());
contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, CoreCommands.CMD_OBJECT_MOVE_UP));
contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, CoreCommands.CMD_OBJECT_MOVE_DOWN));
}
}
if (workbenchSite instanceof MultiPageEditorSite) {
final MultiPageEditorPart editor = ((MultiPageEditorSite) workbenchSite).getMultiPageEditor();
if (editor instanceof EntityEditor) {
contributionManager.add(new Separator());
contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, IWorkbenchCommandConstants.FILE_SAVE, null, UIIcon.SAVE, null, true));
contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, IWorkbenchCommandConstants.FILE_REVERT, null, UIIcon.RESET, null, true));
}
}
}
use of org.eclipse.ui.part.MultiPageEditorPart in project dbeaver by serge-rider.
the class TabbedFolderPageEditor method createControl.
@Override
public void createControl(Composite parent) {
editor = editorDescriptor.createEditor();
final IWorkbenchPartSite ownerSite = this.mainEditor.getSite();
if (ownerSite instanceof MultiPageEditorSite) {
final MultiPageEditorPart ownerMultiPageEditor = ((MultiPageEditorSite) ownerSite).getMultiPageEditor();
nestedEditorSite = new TabbedFolderPageEditorSite(ownerMultiPageEditor, editor);
// We need it to tell owner editor about dirty state change
if (ownerMultiPageEditor instanceof IPropertyChangeReflector) {
editor.addPropertyListener(new IPropertyListener() {
@Override
public void propertyChanged(Object source, int propId) {
((IPropertyChangeReflector) ownerMultiPageEditor).handlePropertyChange(propId);
}
});
}
} else {
nestedEditorSite = new SubEditorSite(mainEditor.getEditorSite());
}
try {
editor.init(nestedEditorSite, editorDescriptor.getNestedEditorInput(mainEditor.getEditorInput()));
} catch (PartInitException e) {
UIUtils.showErrorDialog(parent.getShell(), "Create SQL viewer", null, e);
}
editor.createPartControl(parent);
if (editor instanceof ISingleControlEditor) {
// Use focus to active selection provider and contributed actions
Control editorControl = ((ISingleControlEditor) editor).getEditorControl();
assert editorControl != null;
editorControl.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
ISelectionProvider selectionProvider = editor.getSite().getSelectionProvider();
mainEditor.getSite().setSelectionProvider(selectionProvider);
if (actionContributor != null) {
actionContributor.setActiveEditor(editor);
}
activateNestedSite(true);
}
@Override
public void focusLost(FocusEvent e) {
activateNestedSite(false);
if (actionContributor != null) {
actionContributor.setActiveEditor(null);
}
}
});
}
parent.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
if (editor != null) {
editor.dispose();
editor = null;
}
}
});
}
Aggregations