提交 46b35f65 编写于 作者: J jurgen

Folder list

Former-commit-id: df23e2a5
上级 14dca69d
......@@ -103,7 +103,6 @@ Export-Package: org.jkiss.dbeaver,
org.jkiss.dbeaver.ui.editors.xml,
org.jkiss.dbeaver.ui.preferences,
org.jkiss.dbeaver.ui.properties,
org.jkiss.dbeaver.ui.properties.tabbed,
org.jkiss.dbeaver.ui.search,
org.jkiss.dbeaver.ui.search.data,
org.jkiss.dbeaver.ui.search.metadata,
......
......@@ -1879,12 +1879,6 @@
<factory id="org.jkiss.dbeaver.ui.editors.DatabaseEditorInputFactory" class="org.jkiss.dbeaver.ui.editors.DatabaseEditorInputFactory"/>
</extension>
<extension point="org.eclipse.ui.views.properties.tabbed.propertyContributor">
<propertyContributor contributorId="org.jkiss.dbeaver.core.propertyViewContributor" tabDescriptorProvider="org.jkiss.dbeaver.ui.editors.entity.properties.PropertyTabDescriptorProvider">
<propertyCategory category="core-properties"/>
</propertyContributor>
</extension>
<extension point="org.eclipse.ui.themes">
<themeElementCategory label="SQL Editor" id="org.jkiss.dbeaver.ui.presentation.sql">
<description>SQL Editor</description>
......
......@@ -54,7 +54,7 @@ public class EntityEditorDescriptor extends AbstractContextDescriptor
public static enum Type {
editor,
section
folder
}
private String id;
......
......@@ -34,7 +34,7 @@ import org.jkiss.dbeaver.ui.properties.DataSourcePropertyFilter;
import org.jkiss.dbeaver.ui.properties.ILazyPropertyLoadListener;
import org.jkiss.dbeaver.ui.properties.ObjectPropertyDescriptor;
import org.jkiss.dbeaver.ui.properties.PropertyCollector;
import org.jkiss.dbeaver.ui.properties.tabbed.PropertiesContributor;
import org.jkiss.dbeaver.ui.editors.entity.properties.PropertiesContributor;
import org.jkiss.utils.CommonUtils;
import java.util.*;
......
......@@ -16,13 +16,14 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.jkiss.dbeaver.ui.properties.tabbed;
package org.jkiss.dbeaver.ui.controls;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.views.properties.*;
import org.jkiss.dbeaver.runtime.RuntimeUtils;
import org.jkiss.dbeaver.ui.editors.entity.properties.PropertiesContributor;
import org.jkiss.dbeaver.ui.properties.ILazyPropertyLoadListener;
import org.jkiss.utils.ArrayUtils;
......
......@@ -35,10 +35,12 @@ import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.jkiss.dbeaver.ui.UIUtils;
import java.util.ArrayList;
import java.util.HashMap;
......@@ -54,7 +56,8 @@ public class FolderComposite extends Composite implements IFolderContainer {
private final FolderList folderList;
private final Composite pane;
private final Map<IFolderDescription, Control> contentsMap = new HashMap<IFolderDescription, Control>();
private final Map<IFolderDescription, Composite> contentsMap = new HashMap<IFolderDescription, Composite>();
private IFolder curFolder;
private Control curContent;
private List<IFolderListener> listeners = new ArrayList<IFolderListener>();
......@@ -68,7 +71,7 @@ public class FolderComposite extends Composite implements IFolderContainer {
setLayout(gl);
folderList = new FolderList(this);
folderList.setLayoutData(new GridData(GridData.FILL_BOTH));
folderList.setLayoutData(new GridData(GridData.FILL_VERTICAL));
pane = new Composite(this, SWT.NONE);
gl = new GridLayout(1, false);
gl.horizontalSpacing = 0;
......@@ -96,20 +99,26 @@ public class FolderComposite extends Composite implements IFolderContainer {
}
private void onFolderSwitch(IFolderDescription folder) {
Control newContent = contentsMap.get(folder);
Composite newContent = contentsMap.get(folder);
IFolder newFolder = folder.getContents();
if (newContent == null) {
folder.getContents().createControl(pane);
newContent = folder.getContents().getControl();
newContent = new Composite(pane, SWT.NONE);
newContent.setLayoutData(new GridData(GridData.FILL_BOTH));
newContent.setLayout(new FillLayout());
newFolder.createControl(newContent);
contentsMap.put(folder, newContent);
}
if (curContent != null) {
curContent.setVisible(false);
curFolder.aboutToBeHidden();
((GridData)curContent.getLayoutData()).exclude = true;
}
((GridData)newContent.getLayoutData()).exclude = false;
newFolder.aboutToBeShown();
newContent.setVisible(true);
curContent = newContent;
curFolder = newFolder;
pane.layout();
for (IFolderListener listener : listeners) {
......@@ -118,13 +127,21 @@ public class FolderComposite extends Composite implements IFolderContainer {
}
public void setFolders(IFolderDescription[] folders) {
boolean firstTime = folderList.getNumberOfElements() == 0;
folderList.setFolders(folders);
folderList.select(0);
if (firstTime) {
layout();
}
}
public IFolderDescription[] getFolders() {
return folderList.getElements();
}
@Override
public Object getActiveFolder() {
return folderList.getElementAt(folderList.getSelectionIndex()).getTabItem();
public IFolder getActiveFolder() {
return folderList.getElementAt(folderList.getSelectionIndex()).getTabItem().getContents();
}
@Override
......@@ -146,4 +163,5 @@ public class FolderComposite extends Composite implements IFolderContainer {
public void removeFolderListener(IFolderListener listener) {
listeners.remove(listener);
}
}
......@@ -42,9 +42,9 @@ public class FolderDescription implements IFolderDescription {
private String text;
private Image image;
private String tooltip;
private IPage contents;
private IFolder contents;
public FolderDescription(String id, String text, Image image, String tooltip, IPage contents) {
public FolderDescription(String id, String text, Image image, String tooltip, IFolder contents) {
this.id = id;
this.text = text;
this.image = image;
......@@ -78,7 +78,7 @@ public class FolderDescription implements IFolderDescription {
}
@Override
public IPage getContents() {
public IFolder getContents() {
return contents;
}
}
......@@ -39,6 +39,7 @@ import org.eclipse.swt.graphics.*;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.*;
import org.jkiss.dbeaver.core.DBeaverUI;
import org.jkiss.dbeaver.ui.UIUtils;
......@@ -523,6 +524,15 @@ public class FolderList extends Composite {
return null;
}
public IFolderDescription[] getElements() {
IFolderDescription[] tabs = new IFolderDescription[elements.length];
for (int i = 0; i < elements.length; i++) {
tabs[i] = elements[i].getTabItem();
}
return tabs;
}
/**
* Returns the zero-relative index of the item which is currently selected
* in the receiver, or -1 if no item is selected.
......@@ -574,7 +584,11 @@ public class FolderList extends Composite {
}
}
}
int maxTabWidth = getTabWidth(children[widestLabelIndex]);
Object layoutData = getLayoutData();
if (layoutData instanceof GridData) {
((GridData) layoutData).widthHint = maxTabWidth;
}
computeTopAndBottomTab();
}
......
......@@ -30,32 +30,27 @@
package org.jkiss.dbeaver.ui.controls.folders;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.part.Page;
/**
* Abstract folder page
*/
public abstract class FolderPage extends Page {
private Control control;
public abstract class FolderPage implements IFolder {
@Override
public void createControl(Composite parent) {
control = createPageControl(parent);
public void setFocus() {
}
@Override
public Control getControl() {
return control;
public void aboutToBeShown() {
}
@Override
public void setFocus() {
control.setFocus();
public void aboutToBeHidden() {
}
protected abstract Control createPageControl(Composite parent);
@Override
public void dispose() {
}
}
......@@ -16,41 +16,23 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.jkiss.dbeaver.ui.properties.tabbed;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.views.properties.tabbed.AbstractSectionDescriptor;
package org.jkiss.dbeaver.ui.controls.folders;
import org.eclipse.swt.widgets.Composite;
/**
* Section descriptor
* IFolder
*/
public abstract class SectionDescriptor extends AbstractSectionDescriptor {
private String id;
private String targetTab;
public interface IFolder
{
void createControl(Composite parent);
protected SectionDescriptor(String id, String targetTab)
{
this.id = id;
this.targetTab = targetTab;
}
void aboutToBeShown();
@Override
public String getId()
{
return id;
}
void aboutToBeHidden();
@Override
public String getTargetTab()
{
return targetTab;
}
void setFocus();
@Override
public boolean appliesTo(IWorkbenchPart part, ISelection selection)
{
return true;
}
}
void dispose();
}
\ No newline at end of file
......@@ -19,6 +19,8 @@
package org.jkiss.dbeaver.ui.controls.folders;
import org.eclipse.ui.part.IPage;
import org.eclipse.ui.views.properties.tabbed.ITabDescriptor;
import org.jkiss.code.Nullable;
/**
......@@ -26,8 +28,9 @@ import org.jkiss.code.Nullable;
*/
public interface IFolderContainer
{
@Nullable
Object getActiveFolder();
IFolder getActiveFolder();
void switchFolder(String folderId);
......
......@@ -64,6 +64,6 @@ public interface IFolderDescription {
/**
* Creates tab contents
*/
public IPage getContents();
public IFolder getContents();
}
......@@ -84,7 +84,6 @@ import org.jkiss.dbeaver.tools.transfer.IDataTransferProducer;
import org.jkiss.dbeaver.tools.transfer.database.DatabaseTransferProducer;
import org.jkiss.dbeaver.tools.transfer.wizard.DataTransferWizard;
import org.jkiss.dbeaver.ui.*;
import org.jkiss.dbeaver.ui.controls.CImageCombo;
import org.jkiss.dbeaver.ui.controls.lightgrid.GridCell;
import org.jkiss.dbeaver.ui.controls.lightgrid.GridPos;
import org.jkiss.dbeaver.ui.controls.lightgrid.IGridContentProvider;
......@@ -98,7 +97,7 @@ import org.jkiss.dbeaver.ui.dialogs.sql.ViewSQLDialog;
import org.jkiss.dbeaver.ui.dialogs.struct.EditConstraintDialog;
import org.jkiss.dbeaver.ui.preferences.PrefPageDatabaseGeneral;
import org.jkiss.dbeaver.ui.properties.PropertyCollector;
import org.jkiss.dbeaver.ui.properties.tabbed.PropertyPageStandard;
import org.jkiss.dbeaver.ui.controls.PropertyPageStandard;
import org.jkiss.dbeaver.utils.ContentUtils;
import org.jkiss.utils.CommonUtils;
......
......@@ -30,8 +30,6 @@ import org.jkiss.dbeaver.core.DBeaverUI;
import org.jkiss.dbeaver.core.Log;
import org.jkiss.dbeaver.ext.IDatabaseEditorInput;
import org.jkiss.dbeaver.ext.IPropertyChangeReflector;
import org.jkiss.dbeaver.ui.controls.folders.IFolderListener;
import org.jkiss.dbeaver.ui.controls.folders.IFolderContainer;
import org.jkiss.dbeaver.ext.ui.IProgressControlProvider;
import org.jkiss.dbeaver.ext.ui.IRefreshablePart;
import org.jkiss.dbeaver.model.DBPObject;
......@@ -59,6 +57,9 @@ import org.jkiss.dbeaver.ui.DBIcon;
import org.jkiss.dbeaver.ui.IHelpContextIds;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.ui.controls.ProgressPageControl;
import org.jkiss.dbeaver.ui.controls.folders.IFolder;
import org.jkiss.dbeaver.ui.controls.folders.IFolderContainer;
import org.jkiss.dbeaver.ui.controls.folders.IFolderListener;
import org.jkiss.dbeaver.ui.dialogs.ConfirmationDialog;
import org.jkiss.dbeaver.ui.dialogs.sql.ViewSQLDialog;
import org.jkiss.dbeaver.ui.editors.DatabaseEditorInput;
......@@ -581,7 +582,7 @@ public class EntityEditor extends MultiPageDatabaseEditor
@Nullable
@Override
public Object getActiveFolder()
public IFolder getActiveFolder()
{
if (getActiveEditor() instanceof IFolderContainer) {
((IFolderContainer)getActiveEditor()).getActiveFolder();
......
/*
* Copyright (C) 2010-2014 Serge Rieder
* serge@jkiss.org
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.jkiss.dbeaver.ui.editors.entity.properties;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.views.properties.tabbed.AbstractTabDescriptor;
import org.eclipse.ui.views.properties.tabbed.ISection;
import org.jkiss.dbeaver.core.DBeaverCore;
import org.jkiss.dbeaver.ext.IDatabaseEditor;
import org.jkiss.dbeaver.registry.editor.EntityEditorDescriptor;
import org.jkiss.dbeaver.ui.properties.tabbed.EditorWrapperSection;
import org.jkiss.dbeaver.ui.properties.tabbed.PropertiesContributor;
import org.jkiss.dbeaver.ui.properties.tabbed.SectionDescriptor;
import java.util.Collections;
/**
* EditorTabDescriptor
*/
class EditorTabDescriptor extends AbstractTabDescriptor {
private IDatabaseEditor mainEditor;
private EntityEditorDescriptor descriptor;
public EditorTabDescriptor(IDatabaseEditor part, EntityEditorDescriptor descriptor)
{
this.mainEditor = part;
this.descriptor = descriptor;
setSectionDescriptors(Collections.singletonList(
new SectionDescriptor(PropertiesContributor.SECTION_STANDARD, this.descriptor.getId()) {
@Override
public ISection getSectionClass()
{
return new EditorWrapperSection(
EditorTabDescriptor.this.mainEditor,
EditorTabDescriptor.this.descriptor);
}
}));
}
@Override
public String getCategory()
{
return PropertiesContributor.CATEGORY_STRUCT;
}
@Override
public String getId()
{
return descriptor.getId();
}
@Override
public String getLabel()
{
return descriptor.getName();
}
@Override
public Image getImage()
{
return descriptor.getIcon();
}
@Override
public boolean isIndented()
{
return !DBeaverCore.getInstance().getLocalSystem().isWindows();
}
}
......@@ -16,9 +16,8 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.jkiss.dbeaver.ui.properties.tabbed;
package org.jkiss.dbeaver.ui.editors.entity.properties;
import org.jkiss.dbeaver.core.Log;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.swt.events.DisposeEvent;
......@@ -28,8 +27,7 @@ import org.eclipse.ui.*;
import org.eclipse.ui.internal.services.INestable;
import org.eclipse.ui.part.MultiPageEditorPart;
import org.eclipse.ui.part.MultiPageEditorSite;
import org.eclipse.ui.views.properties.tabbed.AbstractPropertySection;
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
import org.jkiss.dbeaver.core.Log;
import org.jkiss.dbeaver.ext.IDatabaseEditor;
import org.jkiss.dbeaver.ext.IDatabaseEditorContributorManager;
import org.jkiss.dbeaver.ext.IDatabaseEditorContributorUser;
......@@ -38,23 +36,23 @@ import org.jkiss.dbeaver.ext.ui.IActiveWorkbenchPart;
import org.jkiss.dbeaver.ext.ui.IRefreshablePart;
import org.jkiss.dbeaver.registry.editor.EntityEditorDescriptor;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.ui.controls.folders.FolderPage;
import org.jkiss.dbeaver.ui.editors.SubEditorSite;
/**
* EditorWrapperSection
*/
public class EditorWrapperSection extends AbstractPropertySection implements IDatabaseEditorContributorUser, ISaveablePart, IRefreshablePart, IAdaptable {
public class FolderPageEditor extends FolderPage implements IDatabaseEditorContributorUser, ISaveablePart, IRefreshablePart, IAdaptable {
static final Log log = Log.getLog(EditorWrapperSection.class);
static final Log log = Log.getLog(FolderPageEditor.class);
private IDatabaseEditor mainEditor;
private EntityEditorDescriptor editorDescriptor;
private IEditorPart editor;
private IEditorActionBarContributor actionContributor;
private Composite parent;
private IEditorSite nestedEditorSite;
public EditorWrapperSection(IDatabaseEditor mainEditor, EntityEditorDescriptor editorDescriptor)
public FolderPageEditor(IDatabaseEditor mainEditor, EntityEditorDescriptor editorDescriptor)
{
this.mainEditor = mainEditor;
this.editorDescriptor = editorDescriptor;
......@@ -66,30 +64,7 @@ public class EditorWrapperSection extends AbstractPropertySection implements IDa
}
@Override
public void createControls(Composite parent, final TabbedPropertySheetPage tabbedPropertySheetPage)
{
super.createControls(parent, tabbedPropertySheetPage);
this.parent = parent;
}
@Override
public void dispose()
{
if (nestedEditorSite instanceof MultiPageEditorSite) {
((MultiPageEditorSite) nestedEditorSite).dispose();
nestedEditorSite = null;
}
super.dispose();
}
@Override
public boolean shouldUseExtraSpace()
{
return true;
}
private void createEditor()
{
public void createControl(Composite parent) {
editor = editorDescriptor.createEditor();
final IWorkbenchPartSite ownerSite = this.mainEditor.getSite();
......@@ -132,11 +107,18 @@ public class EditorWrapperSection extends AbstractPropertySection implements IDa
}
@Override
public void aboutToBeShown()
public void dispose()
{
if (editor == null) {
createEditor();
if (nestedEditorSite instanceof MultiPageEditorSite) {
((MultiPageEditorSite) nestedEditorSite).dispose();
nestedEditorSite = null;
}
super.dispose();
}
@Override
public void aboutToBeShown()
{
if (editor instanceof IActiveWorkbenchPart) {
((IActiveWorkbenchPart) editor).activatePart();
}
......
......@@ -18,14 +18,10 @@
*/
package org.jkiss.dbeaver.ui.editors.entity.properties;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.views.properties.tabbed.ISection;
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
import org.jkiss.dbeaver.ext.IDatabaseEditor;
import org.jkiss.dbeaver.ext.IDatabaseEditorInput;
import org.jkiss.dbeaver.ext.ui.*;
......@@ -35,25 +31,22 @@ import org.jkiss.dbeaver.model.navigator.DBNEvent;
import org.jkiss.dbeaver.model.navigator.DBNNode;
import org.jkiss.dbeaver.registry.tree.DBXTreeNode;
import org.jkiss.dbeaver.ui.controls.ProgressPageControl;
import org.jkiss.dbeaver.ui.controls.folders.FolderPage;
import org.jkiss.dbeaver.ui.controls.itemlist.ItemListControl;
/**
* EntityNodeEditor
*/
class NodeEditorSection implements ISection, ISearchContextProvider, IRefreshablePart, INavigatorModelView
class FolderPageNode extends FolderPage implements ISearchContextProvider, IRefreshablePart, INavigatorModelView
{
//static final Log log = Log.getLog(EntityNodeEditor.class);
private IDatabaseEditor editor;
private DBNNode node;
private DBXTreeNode metaNode;
private ItemListControl itemControl;
private boolean activated;
//private ISelectionProvider prevSelectionProvider;
private Composite parent;
NodeEditorSection(IDatabaseEditor editor, DBNNode node, DBXTreeNode metaNode)
FolderPageNode(IDatabaseEditor editor, DBNNode node, DBXTreeNode metaNode)
{
this.editor = editor;
this.node = node;
......@@ -72,30 +65,32 @@ class NodeEditorSection implements ISection, ISearchContextProvider, IRefreshabl
}
}
@Override
public void createControls(Composite parent, TabbedPropertySheetPage tabbedPropertySheetPage)
{
this.parent = parent;
}
public void setFocus()
{
itemControl.setFocus();
}
@Override
public void setInput(IWorkbenchPart part, ISelection selection)
{
this.editor = (IDatabaseEditor)part;
public void createControl(Composite parent) {
itemControl = new ItemListControl(parent, SWT.SHEET, editor.getSite(), node, metaNode);
//itemControl.getLayout().marginHeight = 0;
//itemControl.getLayout().marginWidth = 0;
ProgressPageControl progressControl = null;
if (editor instanceof IProgressControlProvider) {
progressControl = ((IProgressControlProvider)editor).getProgressControl();
}
if (progressControl != null) {
itemControl.substituteProgressPanel(progressControl);
} else {
itemControl.createProgressPanel();
}
parent.layout();
}
@Override
public void aboutToBeShown()
{
if (itemControl == null) {
createSectionControls();
}
//prevSelectionProvider = editor.getSite().getSelectionProvider();
// Update selection provider and selection
final ISelectionProvider selectionProvider = itemControl.getSelectionProvider();
editor.getSite().setSelectionProvider(selectionProvider);
......@@ -115,55 +110,6 @@ class NodeEditorSection implements ISection, ISearchContextProvider, IRefreshabl
if (itemControl != null) {
itemControl.activate(false);
}
/*
if (prevSelectionProvider != null) {
editor.getSite().setSelectionProvider(prevSelectionProvider);
}
*/
}
private void createSectionControls()
{
if (itemControl != null) {
return;
}
itemControl = new ItemListControl(parent, SWT.SHEET, editor.getSite(), node, metaNode);
//itemControl.getLayout().marginHeight = 0;
//itemControl.getLayout().marginWidth = 0;
ProgressPageControl progressControl = null;
if (editor instanceof IProgressControlProvider) {
progressControl = ((IProgressControlProvider)editor).getProgressControl();
}
if (progressControl != null) {
itemControl.substituteProgressPanel(progressControl);
} else {
itemControl.createProgressPanel();
}
//ISelectionProvider selectionProvider = itemControl.getSelectionProvider();
//editor.getSite().setSelectionProvider(itemControl.getSelectionProvider());
parent.layout();
}
@Override
public int getMinimumHeight()
{
return SWT.DEFAULT;
}
@Override
public boolean shouldUseExtraSpace()
{
return true;
}
@Override
public void refresh()
{
// Do nothing
// Property tab section is refreshed on every activation so just skip it
}
public IDatabaseEditorInput getEditorInput()
......@@ -213,10 +159,8 @@ class NodeEditorSection implements ISection, ISearchContextProvider, IRefreshabl
loadNewData = false;
}
}
if (!itemControl.isDisposed()) {
if (loadNewData) {
itemControl.loadData(false);
}
if (loadNewData && !itemControl.isDisposed()) {
itemControl.loadData(false);
}
}
......
......@@ -16,69 +16,59 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.jkiss.dbeaver.ui.properties.tabbed;
package org.jkiss.dbeaver.ui.editors.entity.properties;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.IFontProvider;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.progress.UIJob;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.eclipse.ui.views.properties.IPropertySource;
import org.eclipse.ui.views.properties.tabbed.AbstractPropertySection;
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
import org.jkiss.dbeaver.ext.IDatabaseEditorInput;
import org.jkiss.dbeaver.model.DBPEvent;
import org.jkiss.dbeaver.model.DBPEventListener;
import org.jkiss.dbeaver.model.DBUtils;
import org.jkiss.dbeaver.model.struct.DBSObject;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.ui.controls.folders.FolderPage;
import org.jkiss.dbeaver.ui.properties.ILazyPropertyLoadListener;
import org.jkiss.dbeaver.ui.properties.IPropertyDescriptorEx;
import org.jkiss.dbeaver.ui.properties.PropertyTreeViewer;
import org.jkiss.utils.CommonUtils;
/**
* StandardPropertiesSection
* FolderPageProperties
*/
public class StandardPropertiesSection extends AbstractPropertySection implements ILazyPropertyLoadListener, DBPEventListener {
public class FolderPageProperties extends FolderPage implements ILazyPropertyLoadListener, DBPEventListener {
protected IDatabaseEditorInput input;
protected PropertyTreeViewer propertyTree;
private IPropertySource curPropertySource;
private Font boldFont;
private UIJob refreshJob = null;
private IPropertySource curPropertySource;
public FolderPageProperties(IDatabaseEditorInput input) {
this.input = input;
}
@Override
public void createControls(Composite parent, final TabbedPropertySheetPage tabbedPropertySheetPage)
public void createControl(Composite parent)
{
super.createControls(parent, tabbedPropertySheetPage);
this.boldFont = UIUtils.makeBoldFont(parent.getFont());
propertyTree = new PropertyTreeViewer(parent, SWT.NONE);
propertyTree.setExtraLabelProvider(new PropertyLabelProvider());
PropertiesContributor.getInstance().addLazyListener(this);
}
@Override
public void setInput(IWorkbenchPart part, ISelection newSelection) {
if (!CommonUtils.equalObjects(getSelection(), newSelection)) {
super.setInput(part, newSelection);
if (!newSelection.isEmpty() && newSelection instanceof IStructuredSelection) {
Object element = ((IStructuredSelection) newSelection).getFirstElement();
if (element instanceof IPropertySource && element != curPropertySource) {
curPropertySource = (IPropertySource)element;
propertyTree.loadProperties(curPropertySource);
if (curPropertySource.getEditableValue() instanceof DBSObject) {
DBUtils.getRegistry((DBSObject) curPropertySource.getEditableValue()).addDataSourceListener(this);
}
}
}
curPropertySource = input.getPropertySource();
propertyTree.loadProperties(curPropertySource);
if (curPropertySource.getEditableValue() instanceof DBSObject) {
DBUtils.getRegistry((DBSObject) curPropertySource.getEditableValue()).addDataSourceListener(this);
}
}
......@@ -92,33 +82,6 @@ public class StandardPropertiesSection extends AbstractPropertySection implement
super.dispose();
}
@Override
public void refresh() {
//propertyTree.refresh();
}
@Override
public boolean shouldUseExtraSpace()
{
return true;
}
@Override
public void aboutToBeShown()
{
getPart().getSite().setSelectionProvider(propertyTree);
//propertyTree.setSelection(propertyTree.getSelection());
// if (editor instanceof IProgressControlProvider) {
// ((IProgressControlProvider)editor).getProgressControl().activate(true);
// }
}
@Override
public void aboutToBeHidden()
{
}
@Override
public void handlePropertyLoad(Object object, IPropertyDescriptor property, Object propertyValue, boolean completed)
{
......@@ -171,7 +134,7 @@ public class StandardPropertiesSection extends AbstractPropertySection implement
propertyTree.getControl().redraw();
}
synchronized (StandardPropertiesSection.this) {
synchronized (FolderPageProperties.this) {
refreshJob = null;
}
return Status.OK_STATUS;
......
......@@ -20,7 +20,6 @@ package org.jkiss.dbeaver.ui.editors.entity.properties;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
......@@ -33,31 +32,41 @@ import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Link;
import org.eclipse.ui.*;
import org.eclipse.ui.views.properties.tabbed.ISection;
import org.eclipse.ui.views.properties.tabbed.ITabDescriptor;
import org.eclipse.ui.views.properties.tabbed.ITabSelectionListener;
import org.eclipse.ui.views.properties.tabbed.TabContents;
import org.eclipse.ui.part.IPage;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.core.CoreMessages;
import org.jkiss.dbeaver.core.DBeaverCore;
import org.jkiss.dbeaver.core.DBeaverUI;
import org.jkiss.dbeaver.core.Log;
import org.jkiss.dbeaver.ext.IDatabaseEditor;
import org.jkiss.dbeaver.ext.IDatabaseEditorContributorUser;
import org.jkiss.dbeaver.ext.ui.IProgressControlProvider;
import org.jkiss.dbeaver.ext.ui.IRefreshableContainer;
import org.jkiss.dbeaver.ext.ui.IRefreshablePart;
import org.jkiss.dbeaver.ext.ui.ISearchContextProvider;
import org.jkiss.dbeaver.model.navigator.DBNDataSource;
import org.jkiss.dbeaver.model.navigator.DBNDatabaseFolder;
import org.jkiss.dbeaver.model.navigator.DBNDatabaseNode;
import org.jkiss.dbeaver.model.navigator.DBNNode;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.runtime.DBRRunnableWithProgress;
import org.jkiss.dbeaver.model.struct.DBSObject;
import org.jkiss.dbeaver.ui.ProxyPageSite;
import org.jkiss.dbeaver.registry.editor.EntityEditorDescriptor;
import org.jkiss.dbeaver.registry.tree.DBXTreeItem;
import org.jkiss.dbeaver.registry.tree.DBXTreeNode;
import org.jkiss.dbeaver.runtime.VoidProgressMonitor;
import org.jkiss.dbeaver.ui.DBIcon;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.ui.actions.navigator.NavigatorHandlerObjectOpen;
import org.jkiss.dbeaver.ui.controls.ObjectEditorPageControl;
import org.jkiss.dbeaver.ui.controls.ProgressPageControl;
import org.jkiss.dbeaver.ui.controls.folders.IFolderContainer;
import org.jkiss.dbeaver.ui.controls.folders.IFolderListener;
import org.jkiss.dbeaver.ui.controls.folders.*;
import org.jkiss.dbeaver.ui.editors.AbstractDatabaseObjectEditor;
import org.jkiss.dbeaver.ui.editors.entity.GlobalContributorManager;
import org.jkiss.utils.ArrayUtils;
import org.jkiss.utils.CommonUtils;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
......@@ -69,18 +78,16 @@ import java.util.Map;
public class ObjectPropertiesEditor extends AbstractDatabaseObjectEditor<DBSObject>
implements IRefreshablePart, IProgressControlProvider, IFolderContainer, ISearchContextProvider, IRefreshableContainer
{
//static final Log log = Log.getLog(ObjectPropertiesEditor.class);
static final Log log = Log.getLog(ObjectPropertiesEditor.class);
private PropertyPageTabbed properties;
private FolderComposite folderComposite;
private ObjectEditorPageControl pageControl;
private final List<IFolderListener> folderListeners = new ArrayList<IFolderListener>();
private String curFolderId;
private final List<IRefreshablePart> refreshClients = new ArrayList<IRefreshablePart>();
private final List<ISaveablePart> nestedSaveable = new ArrayList<ISaveablePart>();
private final Map<ISection, IEditorActionBarContributor> sectionContributors = new HashMap<ISection, IEditorActionBarContributor>();
//private Text nameText;
//private Text descriptionText;
private final Map<IFolder, IEditorActionBarContributor> pageContributors = new HashMap<IFolder, IEditorActionBarContributor>();
public ObjectPropertiesEditor()
{
......@@ -153,57 +160,55 @@ public class ObjectPropertiesEditor extends AbstractDatabaseObjectEditor<DBSObje
GridData gd = new GridData(GridData.FILL_BOTH);
gd.horizontalSpan = 2;
propsPlaceholder.setLayoutData(gd);
propsPlaceholder.setLayout(new FormLayout());
//final PropertyCollector propertyCollector = new PropertyCollector(itemObject);
//List<ObjectPropertyDescriptor> annoProps = ObjectPropertyDescriptor.extractAnnotations(itemObject);
GridLayout gl = new GridLayout(1, false);
gl.horizontalSpacing = 0;
gl.verticalSpacing = 0;
gl.marginHeight = 0;
gl.marginWidth = 0;
propsPlaceholder.setLayout(gl);
properties = new PropertyPageTabbed();
properties.init(new ProxyPageSite(getSite()));
properties.createControl(propsPlaceholder);
folderComposite = new FolderComposite(propsPlaceholder, SWT.BORDER);
folderComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
// Load properties
loadObjectProperties();
IFolderDescription[] folders = collectFolders(this);
folderComposite.setFolders(folders);
// Collect section contributors
GlobalContributorManager contributorManager = GlobalContributorManager.getInstance();
for (ITabDescriptor tab : properties.getActiveTabs()) {
final ISection[] tabSections = properties.getTabSections(tab);
if (!ArrayUtils.isEmpty(tabSections)) {
for (ISection section : tabSections) {
if (section instanceof IDatabaseEditorContributorUser) {
IEditorActionBarContributor contributor = ((IDatabaseEditorContributorUser) section).getContributor(contributorManager);
if (contributor != null) {
contributorManager.addContributor(contributor, this);
sectionContributors.put(section, contributor);
}
}
if (section instanceof ISaveablePart) {
nestedSaveable.add((ISaveablePart) section);
}
for (IFolderDescription folder : folderComposite.getFolders()) {
IFolder 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);
}
}
final String folderId = getEditorInput().getDefaultFolderId();
if (folderId != null) {
properties.setSelectedTab(folderId);
folderComposite.switchFolder(folderId);
}
properties.addTabSelectionListener(new ITabSelectionListener() {
folderComposite.addFolderListener(new IFolderListener() {
@Override
public void tabSelected(ITabDescriptor tabDescriptor)
{
if (CommonUtils.equalObjects(curFolderId, tabDescriptor.getId())) {
public void folderSelected(String folderId) {
if (CommonUtils.equalObjects(curFolderId, folderId)) {
return;
}
synchronized (folderListeners) {
curFolderId = tabDescriptor.getId();
curFolderId = folderId;
for (IFolderListener listener : folderListeners) {
listener.folderSelected(tabDescriptor.getId());
listener.folderSelected(folderId);
}
}
}
});
}
......@@ -213,75 +218,28 @@ public class ObjectPropertiesEditor extends AbstractDatabaseObjectEditor<DBSObje
//getSite().setSelectionProvider();
}
private void loadObjectProperties()
{
properties.selectionChanged(
this,
new StructuredSelection(
getEditorInput().getPropertySource()));
}
/*
private void createNamePanel(DBNNode node, Composite container)
{
// General options
Group infoGroup = UIUtils.createControlGroup(container, "General", 2, GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING, 0);
UIUtils.createControlLabel(infoGroup, "Name");
nameText = new Text(infoGroup, SWT.BORDER);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.widthHint = 200;
nameText.setLayoutData(gd);
nameText.setText(node.getNodeName());
nameText.setEditable(isNameEditable());
Label descriptionLabel = UIUtils.createControlLabel(infoGroup, "Description");
descriptionLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
descriptionText = new Text(infoGroup, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
gd = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
gd.widthHint = 200;
gd.heightHint = descriptionLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).y * 3;
descriptionText.setLayoutData(gd);
if (!CommonUtils.isEmpty(node.getNodeDescription())) {
descriptionText.setText(node.getNodeDescription());
}
descriptionText.setEditable(isDescriptionEditable());
}
*/
@Override
public void dispose()
{
// Remove contributors
GlobalContributorManager contributorManager = GlobalContributorManager.getInstance();
for (IEditorActionBarContributor contributor : sectionContributors.values()) {
for (IEditorActionBarContributor contributor : pageContributors.values()) {
contributorManager.removeContributor(contributor, this);
}
sectionContributors.clear();
pageContributors.clear();
//PropertiesContributor.getInstance().removeLazyListener(this);
if (properties != null) {
properties.dispose();
properties = null;
}
super.dispose();
}
@Override
public void setFocus()
{
properties.setFocus();
ITabDescriptor selectedTab = properties.getSelectedTab();
if (selectedTab != null) {
final ISection[] tabSections = properties.getTabSections(selectedTab);
if (!ArrayUtils.isEmpty(tabSections)) {
for (ISection section : tabSections) {
IEditorActionBarContributor contributor = sectionContributors.get(section);
if (contributor != null) {
section.aboutToBeShown();
}
}
}
folderComposite.setFocus();
IFolder selectedPage = folderComposite.getActiveFolder();
if (selectedPage != null) {
selectedPage.setFocus();
// IEditorActionBarContributor contributor = pageContributors.get(selectedPage);
}
}
......@@ -344,22 +302,6 @@ public class ObjectPropertiesEditor extends AbstractDatabaseObjectEditor<DBSObje
}
}
/*
public void handlePropertyLoad(final Object object, final Object propertyId, final Object propertyValue, final boolean completed)
{
if (completed && object == getTreeNode()) {
if ("description".equals(propertyId)) {
Display.getDefault().asyncExec(new Runnable() {
public void run()
{
descriptionText.setText(CommonUtils.toString(propertyValue));
}
});
}
}
}
*/
@Nullable
@Override
public ProgressPageControl getProgressControl()
......@@ -369,26 +311,15 @@ public class ObjectPropertiesEditor extends AbstractDatabaseObjectEditor<DBSObje
@Nullable
@Override
public Object getActiveFolder()
public IFolder getActiveFolder()
{
TabContents currentTab = properties.getCurrentTab();
if (currentTab != null) {
ISection[] sections = currentTab.getSections();
if (ArrayUtils.isEmpty(sections)) {
return null;
} else if (sections.length == 1) {
return sections[0];
} else {
return sections;
}
}
return null;
return folderComposite.getActiveFolder();
}
@Override
public void switchFolder(String folderId)
{
properties.setSelectedTab(folderId);
folderComposite.switchFolder(folderId);
}
@Override
......@@ -476,4 +407,146 @@ public class ObjectPropertiesEditor extends AbstractDatabaseObjectEditor<DBSObje
return result == null ? super.getAdapter(adapter) : result;
}
public IFolderDescription[] collectFolders(IWorkbenchPart part)
{
List<IFolderDescription> tabList = new ArrayList<IFolderDescription>();
makeStandardPropertiesTabs(tabList);
if (part instanceof IDatabaseEditor) {
makeDatabaseEditorTabs((IDatabaseEditor)part, tabList);
}
return tabList.toArray(new IFolderDescription[tabList.size()]);
}
private void makeStandardPropertiesTabs(List<IFolderDescription> tabList)
{
tabList.add(new FolderDescription(
//PropertiesContributor.CATEGORY_INFO,
PropertiesContributor.TAB_STANDARD,
CoreMessages.ui_properties_category_information,
DBIcon.TREE_INFO.getImage(),
null,
new FolderPageProperties(getEditorInput())));
}
private void makeDatabaseEditorTabs(IDatabaseEditor part, List<IFolderDescription> tabList)
{
final DBNDatabaseNode node = part.getEditorInput().getTreeNode();
final DBSObject object = node.getObject();
// Collect tabs from navigator tree model
final List<NavigatorTabInfo> tabs = new ArrayList<NavigatorTabInfo>();
DBRRunnableWithProgress tabsCollector = new DBRRunnableWithProgress() {
@Override
public void run(DBRProgressMonitor monitor)
{
tabs.addAll(collectNavigatorTabs(monitor, node));
}
};
try {
if (node.isLazyNode()) {
DBeaverUI.runInProgressService(tabsCollector);
} else {
tabsCollector.run(VoidProgressMonitor.INSTANCE);
}
} catch (InvocationTargetException e) {
log.error(e.getTargetException());
} catch (InterruptedException e) {
// just go further
}
for (NavigatorTabInfo tab : tabs) {
addNavigatorNodeTab(part, tabList, tab);
}
// Query for entity editors
List<EntityEditorDescriptor> editors = DBeaverCore.getInstance().getEditorsRegistry().getEntityEditors(object, null);
if (!CommonUtils.isEmpty(editors)) {
for (EntityEditorDescriptor descriptor : editors) {
if (descriptor.getType() == EntityEditorDescriptor.Type.folder) {
tabList.add(new FolderDescription(
//PropertiesContributor.CATEGORY_STRUCT,
descriptor.getId(),
descriptor.getName(),
descriptor.getIcon(),
descriptor.getDescription(),
new FolderPageEditor(this, descriptor)));
}
}
}
}
private void addNavigatorNodeTab(final IDatabaseEditor part, List<IFolderDescription> tabList, final NavigatorTabInfo tabInfo)
{
tabList.add(new FolderDescription(
//PropertiesContributor.CATEGORY_STRUCT,
tabInfo.getName(),
tabInfo.getName(),
tabInfo.node.getNodeIconDefault(),
null,
new FolderPageNode(part, tabInfo.node, tabInfo.meta)));
}
private static class NavigatorTabInfo {
final DBNDatabaseNode node;
final DBXTreeNode meta;
private NavigatorTabInfo(DBNDatabaseNode node)
{
this(node, null);
}
private NavigatorTabInfo(DBNDatabaseNode node, DBXTreeNode meta)
{
this.node = node;
this.meta = meta;
}
public String getName()
{
return meta == null ? node.getNodeName() : meta.getChildrenType(node.getObject().getDataSource());
}
}
private static List<NavigatorTabInfo> collectNavigatorTabs(DBRProgressMonitor monitor, DBNNode node)
{
List<NavigatorTabInfo> tabs = new ArrayList<NavigatorTabInfo>();
// Add all nested folders as tabs
if (node instanceof DBNDataSource && !((DBNDataSource)node).getDataSourceContainer().isConnected()) {
// Do not add children tabs
} else if (node != null) {
try {
List<? extends DBNNode> children = node.getChildren(monitor);
if (children != null) {
for (DBNNode child : children) {
if (child instanceof DBNDatabaseFolder) {
monitor.subTask(CoreMessages.ui_properties_task_add_folder + child.getNodeName() + "'"); //$NON-NLS-2$
tabs.add(new NavigatorTabInfo((DBNDatabaseFolder)child));
}
}
}
} catch (DBException e) {
log.error("Error initializing property tabs", e); //$NON-NLS-1$
}
// Add itself as tab (if it has child items)
if (node instanceof DBNDatabaseNode) {
DBNDatabaseNode databaseNode = (DBNDatabaseNode)node;
List<DBXTreeNode> subNodes = databaseNode.getMeta().getChildren(databaseNode);
if (subNodes != null) {
for (DBXTreeNode child : subNodes) {
if (child instanceof DBXTreeItem) {
try {
if (!((DBXTreeItem)child).isOptional() || databaseNode.hasChildren(monitor, child)) {
monitor.subTask(CoreMessages.ui_properties_task_add_node + node.getNodeName() + "'"); //$NON-NLS-2$
tabs.add(new NavigatorTabInfo((DBNDatabaseNode)node, child));
}
} catch (DBException e) {
log.debug("Can't add child items tab", e); //$NON-NLS-1$
}
}
}
}
}
}
return tabs;
}
}
\ No newline at end of file
......@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.jkiss.dbeaver.ui.properties.tabbed;
package org.jkiss.dbeaver.ui.editors.entity.properties;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.jkiss.dbeaver.core.CoreMessages;
......
/*
* Copyright (C) 2010-2014 Serge Rieder
* serge@jkiss.org
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.jkiss.dbeaver.ui.editors.entity.properties;
import org.eclipse.ui.views.properties.tabbed.*;
import java.util.HashMap;
import java.util.Map;
/**
* PropertyPageTabbed
*/
class PropertyPageTabbed extends TabbedPropertySheetPage {
private boolean allowContentScroll = false;
private Map<ITabDescriptor, TabContents> tabContentsMap = new HashMap<ITabDescriptor, TabContents>();
public PropertyPageTabbed()
{
this(true);
}
public PropertyPageTabbed(boolean showTitle)
{
super(DEFAULT_PROP_SHEET_CONTRIBUTOR, showTitle);
}
public boolean isAllowContentScroll()
{
return allowContentScroll;
}
public void setAllowContentScroll(boolean allowContentScroll)
{
this.allowContentScroll = allowContentScroll;
}
/**
* This is empty implementation of resizeScrolledComposite()
* to avoid scrolled composite scroll-bars
*/
@Override
public void resizeScrolledComposite()
{
if (allowContentScroll) {
super.resizeScrolledComposite();
}
}
public ISection[] getTabSections(ITabDescriptor tabDescriptor)
{
final TabContents tabContents = tabContentsMap.get(tabDescriptor);
return tabContents == null ? null : tabContents.getSections();
}
@Override
protected TabContents createTab(ITabDescriptor tabDescriptor)
{
final TabContents tabContents = super.createTab(tabDescriptor);
tabContentsMap.put(tabDescriptor, tabContents);
return tabContents;
}
@Override
protected void updateTabs(ITabDescriptor[] descriptors)
{
super.updateTabs(descriptors);
}
private static ITabbedPropertySheetPageContributor DEFAULT_PROP_SHEET_CONTRIBUTOR = new ITabbedPropertySheetPageContributor() {
@Override
public String getContributorId()
{
return PropertyTabDescriptorProvider.CONTRIBUTOR_ID;
}
};
}
/*
* Copyright (C) 2010-2014 Serge Rieder
* serge@jkiss.org
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.jkiss.dbeaver.ui.editors.entity.properties;
import org.jkiss.dbeaver.core.Log;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.views.properties.tabbed.ISection;
import org.eclipse.ui.views.properties.tabbed.ITabDescriptor;
import org.eclipse.ui.views.properties.tabbed.ITabDescriptorProvider;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.core.CoreMessages;
import org.jkiss.dbeaver.core.DBeaverCore;
import org.jkiss.dbeaver.core.DBeaverUI;
import org.jkiss.dbeaver.ext.IDatabaseEditor;
import org.jkiss.dbeaver.model.navigator.DBNDataSource;
import org.jkiss.dbeaver.model.navigator.DBNDatabaseFolder;
import org.jkiss.dbeaver.model.navigator.DBNDatabaseNode;
import org.jkiss.dbeaver.model.navigator.DBNNode;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.runtime.DBRRunnableWithProgress;
import org.jkiss.dbeaver.model.struct.DBSObject;
import org.jkiss.dbeaver.registry.editor.EntityEditorDescriptor;
import org.jkiss.dbeaver.registry.tree.DBXTreeItem;
import org.jkiss.dbeaver.registry.tree.DBXTreeNode;
import org.jkiss.dbeaver.runtime.VoidProgressMonitor;
import org.jkiss.dbeaver.ui.DBIcon;
import org.jkiss.dbeaver.ui.properties.tabbed.PropertiesContributor;
import org.jkiss.dbeaver.ui.properties.tabbed.PropertyTabDescriptor;
import org.jkiss.dbeaver.ui.properties.tabbed.SectionDescriptor;
import org.jkiss.dbeaver.ui.properties.tabbed.StandardPropertiesSection;
import org.jkiss.utils.CommonUtils;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
/**
* PropertyTabDescriptorProvider
*/
public class PropertyTabDescriptorProvider implements ITabDescriptorProvider {
static final Log log = Log.getLog(PropertyTabDescriptorProvider.class);
public static final String CONTRIBUTOR_ID = "org.jkiss.dbeaver.core.propertyViewContributor"; //$NON-NLS-1$
private ISelection curSelection;
private ITabDescriptor[] curTabs;
public PropertyTabDescriptorProvider()
{
}
@Override
public ITabDescriptor[] getTabDescriptors(IWorkbenchPart part, ISelection selection)
{
if (curTabs != null && CommonUtils.equalObjects(curSelection, selection)) {
return curTabs;
}
List<ITabDescriptor> tabList = new ArrayList<ITabDescriptor>();
makeStandardPropertiesTabs(tabList);
if (part instanceof IDatabaseEditor) {
makeDatabaseEditorTabs((IDatabaseEditor)part, tabList);
}
curTabs = tabList.toArray(new ITabDescriptor[tabList.size()]);
curSelection = selection;
return curTabs;
}
private void makeStandardPropertiesTabs(List<ITabDescriptor> tabList)
{
tabList.add(new PropertyTabDescriptor(
PropertiesContributor.CATEGORY_INFO,
PropertiesContributor.TAB_STANDARD,
CoreMessages.ui_properties_category_information,
DBIcon.TREE_INFO.getImage(),
new SectionDescriptor(PropertiesContributor.SECTION_STANDARD, PropertiesContributor.TAB_STANDARD) {
@Override
public ISection getSectionClass()
{
return new StandardPropertiesSection();
}
}));
}
private static class NavigatorTabInfo {
DBNDatabaseNode node;
DBXTreeNode meta;
private NavigatorTabInfo(DBNDatabaseNode node)
{
this.node = node;
}
private NavigatorTabInfo(DBNDatabaseNode node, DBXTreeNode meta)
{
this.node = node;
this.meta = meta;
}
public String getName()
{
return meta == null ? node.getNodeName() : meta.getChildrenType(node.getObject().getDataSource());
}
}
private void makeDatabaseEditorTabs(IDatabaseEditor part, List<ITabDescriptor> tabList)
{
final DBNDatabaseNode node = part.getEditorInput().getTreeNode();
final DBSObject object = node.getObject();
// Collect tabs from navigator tree model
final List<NavigatorTabInfo> tabs = new ArrayList<NavigatorTabInfo>();
DBRRunnableWithProgress tabsCollector = new DBRRunnableWithProgress() {
@Override
public void run(DBRProgressMonitor monitor)
{
tabs.addAll(collectNavigatorTabs(monitor, node));
}
};
try {
if (node.isLazyNode()) {
DBeaverUI.runInProgressService(tabsCollector);
} else {
tabsCollector.run(VoidProgressMonitor.INSTANCE);
}
} catch (InvocationTargetException e) {
log.error(e.getTargetException());
} catch (InterruptedException e) {
// just go further
}
for (NavigatorTabInfo tab : tabs) {
addNavigatorNodeTab(part, tabList, tab);
}
// Query for entity editors
List<EntityEditorDescriptor> editors = DBeaverCore.getInstance().getEditorsRegistry().getEntityEditors(object, null);
if (!CommonUtils.isEmpty(editors)) {
for (EntityEditorDescriptor descriptor : editors) {
if (descriptor.getType() == EntityEditorDescriptor.Type.section) {
tabList.add(new EditorTabDescriptor(part, descriptor));
}
}
}
}
private List<NavigatorTabInfo> collectNavigatorTabs(DBRProgressMonitor monitor, DBNNode node)
{
List<NavigatorTabInfo> tabs = new ArrayList<NavigatorTabInfo>();
// Add all nested folders as tabs
if (node instanceof DBNDataSource && !((DBNDataSource)node).getDataSourceContainer().isConnected()) {
// Do not add children tabs
} else if (node != null) {
try {
List<? extends DBNNode> children = node.getChildren(monitor);
if (children != null) {
for (DBNNode child : children) {
if (child instanceof DBNDatabaseFolder) {
monitor.subTask(CoreMessages.ui_properties_task_add_folder + child.getNodeName() + "'"); //$NON-NLS-2$
tabs.add(new NavigatorTabInfo((DBNDatabaseFolder)child));
}
}
}
} catch (DBException e) {
log.error("Error initializing property tabs", e); //$NON-NLS-1$
}
// Add itself as tab (if it has child items)
if (node instanceof DBNDatabaseNode) {
DBNDatabaseNode databaseNode = (DBNDatabaseNode)node;
List<DBXTreeNode> subNodes = databaseNode.getMeta().getChildren(databaseNode);
if (subNodes != null) {
for (DBXTreeNode child : subNodes) {
if (child instanceof DBXTreeItem) {
try {
if (!((DBXTreeItem)child).isOptional() || databaseNode.hasChildren(monitor, child)) {
monitor.subTask(CoreMessages.ui_properties_task_add_node + node.getNodeName() + "'"); //$NON-NLS-2$
tabs.add(new NavigatorTabInfo((DBNDatabaseNode)node, child));
}
} catch (DBException e) {
log.debug("Can't add child items tab", e); //$NON-NLS-1$
}
}
}
}
}
}
return tabs;
}
private void addNavigatorNodeTab(final IDatabaseEditor part, List<ITabDescriptor> tabList, final NavigatorTabInfo tabInfo)
{
tabList.add(new PropertyTabDescriptor(
PropertiesContributor.CATEGORY_STRUCT,
tabInfo.getName(),
tabInfo.getName(),
tabInfo.node.getNodeIconDefault(),
new SectionDescriptor(PropertiesContributor.SECTION_STANDARD, tabInfo.getName()) { //$NON-NLS-1$
@Override
public ISection getSectionClass()
{
return new NodeEditorSection(part, tabInfo.node, tabInfo.meta);
}
}));
}
}
......@@ -34,7 +34,7 @@ import org.jkiss.dbeaver.runtime.load.ILoadVisualizer;
import org.jkiss.dbeaver.runtime.load.LoadingUtils;
import org.jkiss.dbeaver.runtime.load.jobs.LoadingJob;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.ui.properties.tabbed.PropertiesContributor;
import org.jkiss.dbeaver.ui.editors.entity.properties.PropertiesContributor;
import org.jkiss.utils.ArrayUtils;
import java.lang.reflect.InvocationTargetException;
......
/*
* Copyright (C) 2010-2014 Serge Rieder
* serge@jkiss.org
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.jkiss.dbeaver.ui.properties.tabbed;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.views.properties.tabbed.AbstractTabDescriptor;
import org.eclipse.ui.views.properties.tabbed.ISectionDescriptor;
import org.jkiss.dbeaver.core.DBeaverCore;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* PropertyTabDescriptor
*/
public class PropertyTabDescriptor extends AbstractTabDescriptor {
private String category;
private String id;
private String label;
private Image image;
private String afterTab;
public PropertyTabDescriptor(
String category,
String id,
String label,
Image image,
ISectionDescriptor ... sectionDescriptors)
{
this.category = category;
this.id = id;
this.label = label;
this.image = image;
if (sectionDescriptors != null) {
List<ISectionDescriptor> sections = new ArrayList<ISectionDescriptor>(sectionDescriptors.length);
Collections.addAll(sections, sectionDescriptors);
setSectionDescriptors(sections);
}
}
@Override
public String getCategory()
{
return category;
}
@Override
public String getId()
{
return id;
}
@Override
public String getLabel()
{
return label;
}
@Override
public Image getImage()
{
return image;
}
@Override
public String getAfterTab()
{
if (afterTab != null) {
return afterTab;
}
return super.getAfterTab();
}
public void setAfterTab(String afterTab)
{
this.afterTab = afterTab;
}
@Override
/**
* Tabs are always intended because non-intended tabs looks ugly in some look-and-feel themes
* (because they use shadow color as background)
*/
public boolean isIndented()
{
return !DBeaverCore.getInstance().getLocalSystem().isWindows();//true;//PropertiesContributor.TAB_STANDARD.equals(id);
}
}
\ No newline at end of file
......@@ -25,7 +25,6 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.part.ViewPart;
import org.eclipse.ui.views.properties.IPropertySheetPage;
import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.DBeaverPreferences;
import org.jkiss.dbeaver.core.DBeaverCore;
import org.jkiss.dbeaver.ext.IDataSourceContainerProvider;
......@@ -39,7 +38,7 @@ import org.jkiss.dbeaver.ui.actions.datasource.DataSourceConnectHandler;
import org.jkiss.dbeaver.ui.actions.datasource.DataSourceDisconnectHandler;
import org.jkiss.dbeaver.ui.actions.navigator.NavigatorHandlerObjectOpen;
import org.jkiss.dbeaver.ui.editors.sql.handlers.OpenSQLEditorHandler;
import org.jkiss.dbeaver.ui.properties.tabbed.PropertyPageStandard;
import org.jkiss.dbeaver.ui.controls.PropertyPageStandard;
import org.jkiss.utils.CommonUtils;
public abstract class NavigatorViewBase extends ViewPart implements INavigatorModelView, IDataSourceContainerProvider
......
......@@ -439,7 +439,7 @@
icon="#sql_text"
position="additions_middle"
contributor="org.jkiss.dbeaver.ui.editors.sql.SQLEditorContributorNested"
type="section">
type="folder">
<objectType name="org.jkiss.dbeaver.ext.db2.model.DB2MaterializedQueryTable"/>
<objectType name="org.jkiss.dbeaver.ext.db2.model.DB2Routine"/>
<objectType name="org.jkiss.dbeaver.ext.db2.model.DB2Table"/>
......
......@@ -647,12 +647,12 @@
description="Table DDL"
position="additions_end"
icon="#sql_text"
type="section">
type="folder">
<objectType name="org.jkiss.dbeaver.ext.generic.model.GenericTable"/>
</editor>
<editor id="source.view" class="org.jkiss.dbeaver.ext.generic.edit.GenericSourceViewEditor"
label="%editor.source.name" description="%editor.source.name" icon="#sql_text" position="additions_middle"
contributor="org.jkiss.dbeaver.ui.editors.sql.SQLEditorContributorNested" type="section">
contributor="org.jkiss.dbeaver.ui.editors.sql.SQLEditorContributorNested" type="folder">
<objectType name="org.jkiss.dbeaver.ext.generic.model.GenericStoredCode"/>
</editor>
......
......@@ -201,12 +201,12 @@
<editor id="source.view" class="org.jkiss.dbeaver.ext.mssql.editors.MSSQLSourceViewEditor"
label="%editor.source.name" description="%editor.source.name" icon="#sql_text" position="additions_middle"
contributor="org.jkiss.dbeaver.ui.editors.sql.SQLEditorContributorNested" type="section">
contributor="org.jkiss.dbeaver.ui.editors.sql.SQLEditorContributorNested" type="folder">
<objectType name="org.jkiss.dbeaver.ext.mssql.model.MSSQLSourceObject"/>
</editor>
<editor id="source.ddl" class="org.jkiss.dbeaver.ext.mssql.editors.MSSQLDDLViewEditor"
label="DDL" description="DDL" icon="#sql_text" position="additions_middle"
contributor="org.jkiss.dbeaver.ui.editors.sql.SQLEditorContributorNested" type="section">
contributor="org.jkiss.dbeaver.ui.editors.sql.SQLEditorContributorNested" type="folder">
<objectType name="org.jkiss.dbeaver.ext.mssql.model.MSSQLTable"/>
</editor>
</extension>
......
......@@ -284,12 +284,12 @@
<editor id="source.view" class="org.jkiss.dbeaver.ext.mysql.editors.MySQLSourceViewEditor"
label="%editor.source.name" description="%editor.source.name" icon="#sql_text" position="additions_middle"
contributor="org.jkiss.dbeaver.ui.editors.sql.SQLEditorContributorNested" type="section">
contributor="org.jkiss.dbeaver.ui.editors.sql.SQLEditorContributorNested" type="folder">
<objectType name="org.jkiss.dbeaver.ext.mysql.model.MySQLSourceObject"/>
</editor>
<editor id="source.ddl" class="org.jkiss.dbeaver.ext.mysql.editors.MySQLDDLViewEditor"
label="DDL" description="DDL" icon="#sql_text" position="additions_middle"
contributor="org.jkiss.dbeaver.ui.editors.sql.SQLEditorContributorNested" type="section">
contributor="org.jkiss.dbeaver.ui.editors.sql.SQLEditorContributorNested" type="folder">
<objectType name="org.jkiss.dbeaver.ext.mysql.model.MySQLTable"/>
</editor>
<editor
......
......@@ -363,7 +363,7 @@
<extension point="org.jkiss.dbeaver.databaseEditor">
<editor id="source.declaration" class="org.jkiss.dbeaver.ext.oracle.editors.OracleSourceDeclarationEditor"
label="%editor.package.declaration.name" description="%editor.package.declaration.description" icon="#sql_text" position="additions_middle"
contributor="org.jkiss.dbeaver.ui.editors.sql.SQLEditorContributorNested" type="section">
contributor="org.jkiss.dbeaver.ui.editors.sql.SQLEditorContributorNested" type="folder">
<objectType name="org.jkiss.dbeaver.ext.oracle.model.OracleView"/>
<objectType name="org.jkiss.dbeaver.ext.oracle.model.OracleMaterializedView"/>
<objectType name="org.jkiss.dbeaver.ext.oracle.model.OracleProcedureStandalone"/>
......@@ -373,13 +373,13 @@
</editor>
<editor id="source.definition" class="org.jkiss.dbeaver.ext.oracle.editors.OracleSourceDefinitionEditor"
label="%editor.package.body.name" description="%editor.package.body.description" icon="#sql_text" position="additions_middle"
contributor="org.jkiss.dbeaver.ui.editors.sql.SQLEditorContributorNested" type="section">
contributor="org.jkiss.dbeaver.ui.editors.sql.SQLEditorContributorNested" type="folder">
<objectType name="org.jkiss.dbeaver.ext.oracle.model.OraclePackage"/>
<objectType name="org.jkiss.dbeaver.ext.oracle.model.OracleDataType" if="!object.predefined"/>
</editor>
<editor id="source.ddl" class="org.jkiss.dbeaver.ext.oracle.editors.OracleObjectDDLEditor"
label="DDL" description="DDL" icon="#sql_text" position="additions_middle"
contributor="org.jkiss.dbeaver.ui.editors.sql.SQLEditorContributorNested" type="section">
contributor="org.jkiss.dbeaver.ui.editors.sql.SQLEditorContributorNested" type="folder">
<objectType name="org.jkiss.dbeaver.ext.oracle.model.OracleTable"/>
</editor>
<manager
......
......@@ -40,22 +40,22 @@ public class TestDialog extends TrayDialog {
tabs = new IFolderDescription[3];
tabs[0] = new FolderDescription("tab1", "Tab 1", DBIcon.TREE_TABLE.getImage(), "Tooltip 1", new FolderPage() {
@Override
public Control createPageControl(Composite parent) {
return new Text(parent, SWT.NONE);
public void createControl(Composite parent) {
new Text(parent, SWT.NONE);
}
});
tabs[1] = new FolderDescription("tab2", "Tab with long-long name", DBIcon.TREE_COLUMNS.getImage(), "Tooltip 2", new FolderPage() {
@Override
public Control createPageControl(Composite parent) {
return new Label(parent, SWT.NONE);
public void createControl(Composite parent) {
new Label(parent, SWT.NONE);
}
});
tabs[2] = new FolderDescription("tab3", "Example", DBIcon.PROJECT.getImage(), "123123", new FolderPage() {
@Override
public Control createPageControl(Composite parent) {
return new Text(parent, SWT.V_SCROLL | SWT.H_SCROLL);
public void createControl(Composite parent) {
new Text(parent, SWT.V_SCROLL | SWT.H_SCROLL);
}
});
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册