提交 8a5aff50 编写于 作者: J jurgen

Folder list (replace of tabbed sheet)

Former-commit-id: b33247d2
上级 ee194769
......@@ -66,13 +66,13 @@ Export-Package: org.jkiss.dbeaver,
org.jkiss.dbeaver.ui.actions.datasource,
org.jkiss.dbeaver.ui.actions.navigator,
org.jkiss.dbeaver.ui.controls,
org.jkiss.dbeaver.ui.controls.folders,
org.jkiss.dbeaver.ui.controls.imageview,
org.jkiss.dbeaver.ui.controls.itemlist,
org.jkiss.dbeaver.ui.controls.lightgrid,
org.jkiss.dbeaver.ui.controls.querylog,
org.jkiss.dbeaver.ui.controls.resultset,
org.jkiss.dbeaver.ui.controls.spreadsheet,
org.jkiss.dbeaver.ui.controls.vtabs,
org.jkiss.dbeaver.ui.dialogs,
org.jkiss.dbeaver.ui.dialogs.connection,
org.jkiss.dbeaver.ui.dialogs.data,
......
......@@ -30,6 +30,12 @@
package org.jkiss.dbeaver.ui.controls.folders;
import org.eclipse.swt.SWT;
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;
......@@ -39,7 +45,40 @@ import org.eclipse.swt.widgets.Composite;
public class FolderComposite extends Composite {
private final FolderList folderList;
private final Composite pane;
private Composite curFolder;
public FolderComposite(Composite parent, int style) {
super(parent, style);
GridLayout gl = new GridLayout(2, false);
gl.horizontalSpacing = 0;
gl.verticalSpacing = 0;
gl.marginHeight = 0;
gl.marginWidth = 0;
setLayout(gl);
folderList = new FolderList(this);
folderList.setLayoutData(new GridData(GridData.FILL_BOTH));
pane = new Composite(this, SWT.NONE);
pane.setLayout(new FillLayout());
pane.setLayoutData(new GridData(GridData.FILL_BOTH));
folderList.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
switchFolder(folderList.getElementAt(folderList.getSelectionIndex()).getTabItem());
}
});
}
private void switchFolder(IFolderDescription folder) {
}
public void setFolders(IFolderDescription[] folders) {
folderList.setFolders(folders);
folderList.select(0);
}
}
/*******************************************************************************
* Copyright (c) 2001, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
* Mariot Chauvin <mariot.chauvin@obeo.fr> - bug 259553
* Amit Joglekar <joglekar@us.ibm.com> - Support for dynamic images (bug 385795)
*
* 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.controls.folders;
import org.eclipse.swt.graphics.Image;
/**
* Folders composite
*/
public abstract class FolderDescription implements IFolderDescription {
private String id;
private String text;
private Image image;
private String tooltip;
public FolderDescription(String id, String text, Image image, String tooltip) {
this.id = id;
this.text = text;
this.image = image;
this.tooltip = tooltip;
}
@Override
public String getId() {
return id;
}
@Override
public String getText() {
return text;
}
@Override
public Image getImage() {
return image;
}
@Override
public String getTooltip() {
return tooltip;
}
@Override
public boolean isIndented() {
return false;
}
}
......@@ -947,4 +947,12 @@ public class FolderList extends Composite {
}
});
}
public void addSelectionListener(SelectionListener listener) {
checkWidget ();
TypedListener typedListener = new TypedListener (listener);
addListener (SWT.Selection,typedListener);
addListener (SWT.DefaultSelection,typedListener);
}
}
......@@ -20,29 +20,45 @@ package org.jkiss.dbeaver.ext.test.ui;
import org.eclipse.jface.dialogs.TrayDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.jkiss.dbeaver.ui.DBIcon;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.ui.controls.folders.FolderList;
import org.jkiss.dbeaver.ui.controls.folders.FolderComposite;
import org.jkiss.dbeaver.ui.controls.folders.FolderDescription;
import org.jkiss.dbeaver.ui.controls.folders.IFolderDescription;
public class TestDialog extends TrayDialog {
private IFolderDescription[] tabs;
private FolderComposite folderComposite;
private final IFolderDescription[] tabs;
public TestDialog(Shell shell)
{
super(shell);
tabs = new IFolderDescription[3];
tabs[0] = new FolderDescriptionImpl("tab1", "Tab 1", DBIcon.TREE_TABLE.getImage());
tabs[1] = new FolderDescriptionImpl("tab2", "Tab with long-long name", DBIcon.TREE_COLUMNS.getImage());
tabs[2] = new FolderDescriptionImpl("tab3", "Example", DBIcon.PROJECT.getImage());
tabs[0] = new FolderDescription("tab1", "Tab 1", DBIcon.TREE_TABLE.getImage(), "Tooltip 1") {
@Override
public Composite createControl(Composite parent) {
return null;
}
};
tabs[1] = new FolderDescription("tab2", "Tab with long-long name", DBIcon.TREE_COLUMNS.getImage(), "Tooltip 2") {
@Override
public Composite createControl(Composite parent) {
return null;
}
};
tabs[2] = new FolderDescription("tab3", "Example", DBIcon.PROJECT.getImage(), "123123") {
@Override
public Composite createControl(Composite parent) {
return null;
}
};
}
@Override
......@@ -58,69 +74,14 @@ public class TestDialog extends TrayDialog {
GridData gd = new GridData(GridData.FILL_BOTH);
group.setLayoutData(gd);
Composite sheet = UIUtils.createPlaceholder(group, 2);
sheet.setLayoutData(new GridData(GridData.FILL_BOTH));
FolderList folderList = new FolderList(sheet);
folderComposite = new FolderComposite(group, SWT.BORDER);
gd = new GridData(GridData.FILL_BOTH);
gd.widthHint = 300;
gd.heightHint = 300;
gd.widthHint = 500;
folderList.setLayoutData(gd);
folderList.setFolders(tabs);
folderList.select(0);
Text pane = new Text(sheet, SWT.NONE);
pane.setLayoutData(new GridData(GridData.FILL_BOTH));
//pane.setLayout(new FillLayout());
folderComposite.setLayoutData(gd);
folderComposite.setFolders(tabs);
/*
Composite propsGroup = new Composite(group, SWT.NONE);
propsGroup.setLayout(new GridLayout(2, false));
gd = new GridData(GridData.FILL_HORIZONTAL);
propsGroup.setLayoutData(gd);
*/
return group;
}
private static class FolderDescriptionImpl implements IFolderDescription {
private String id;
private String text;
private Image image;
private FolderDescriptionImpl(String id, String text, Image image) {
this.id = id;
this.text = text;
this.image = image;
}
@Override
public Image getImage() {
return image;
}
@Override
public String getTooltip() {
return text + " information";
}
@Override
public String getId() {
return id;
}
@Override
public String getText() {
return text;
}
@Override
public boolean isIndented() {
return false;
}
@Override
public Composite createControl(Composite parent) {
return new Composite(parent, SWT.BORDER);
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册