Home » Eclipse Projects » Standard Widget Toolkit (SWT) » TableTree
TableTree [message #459613] |
Fri, 12 August 2005 14:14  |
Eclipse User |
|
|
|
I am trying to work with the TableTree control. There is the viewer
abstraction that provides content and label support for Tables and Trees,
but I cannot find anything that provides the same level of abstraction for
the TableTree control. I have tried to apply the TableViewer to the
TableTree's table control -> new TableViewer(tableTree.getTable()), but it
doesn't work. Is there such an abstraction, or do I need to create my own
(or interface directly to the TableTree control)?
--
Mark M. Ingerman
Creative Software Solutions, Inc.
Architect, OO-Designer, Developer, Mentor
mark.ingerman@cs2.com
617-630-2895
www.cs2.com
|
|
| |
Re: TableTree [message #459615 is a reply to message #459614] |
Fri, 12 August 2005 16:03   |
Eclipse User |
|
|
|
Okay. does this mean that the tree can support the tree and table functions
now? Can I then use the TreeViewer too? What version of SWT/JFace did the
table functions get incorporated into the Tree, or am I missing something?
--
Mark M. Ingerman
Creative Software Solutions, Inc.
Architect, OO-Designer, Developer, Mentor
mark.ingerman@cs2.com
617-630-2895
www.cs2.com
"Sunil Kamath" <sunil_kamath@nohotspammail.com> wrote in message
news:ddir65$s3k$1@news.eclipse.org...
>
> "Mark M. Ingerman" <online@cs2.com> wrote in message
> news:ddiov5$pre$1@news.eclipse.org...
>>I am trying to work with the TableTree control. There is the viewer
>>abstraction that provides content and label support for Tables and Trees,
>>but I cannot find anything that provides the same level of abstraction for
>>the TableTree control. I have tried to apply the TableViewer to the
>>TableTree's table control -> new TableViewer(tableTree.getTable()), but it
>>doesn't work. Is there such an abstraction, or do I need to create my own
>>(or interface directly to the TableTree control)?
>>
> TableTree has been deprecated in 3.1- you can use Tree directly.
> But if you insist, you can use org.eclipse.jface.viewers.TableTreeViewer.
> ---
> Sunil
>
|
|
|
Re: TableTree [message #459616 is a reply to message #459613] |
Fri, 12 August 2005 16:40   |
Eclipse User |
|
|
|
Sunil is right. TableTree should not be used any longer.
Below is the code for using a regular tree with columns:
import java.util.ArrayList;
import java.util.List;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeColumn;
public class TreeWithColumnsDriver {
public static void main(String[] args) {
// My computer
FileDirectory myComputer = new FileDirectory("My computer");
// C Drive
FileDirectory cDrive = new FileDirectory("C Drive");
FileDirectory file1 = new FileDirectory("Test1.txt", "John", "2 KB");
FileDirectory file2 = new FileDirectory("Testing2.html", "John", "5 KB");
FileDirectory file3 = new FileDirectory("Rest3.doc", "Marty", "10 KB");
FileDirectory file4 = new FileDirectory("Really big name.html", "Bob",
"100 KB");
cDrive.addChild(file1);
cDrive.addChild(file2);
cDrive.addChild(file3);
cDrive.addChild(file4);
myComputer.addChild(cDrive);
// D Drive
FileDirectory dDrive = new FileDirectory("D Drive");
FileDirectory downloads = new FileDirectory("Downloads");
dDrive.addChild(downloads);
FileDirectory filed1 = new FileDirectory("Whatever.txt", "John", "2 KB");
FileDirectory filed2 = new FileDirectory("Blogger.html", "John", "5 KB");
FileDirectory filed3 = new FileDirectory("something else.mp3", "Jack", "10
MB");
FileDirectory filed4 = new FileDirectory("Reality.txt", "Bryan", "100
KB");
downloads.addChild(filed1);
downloads.addChild(filed2);
downloads.addChild(filed3);
downloads.addChild(filed4);
myComputer.addChild(dDrive);
List filesDirs = new ArrayList();
filesDirs.add(myComputer);
showTree(filesDirs);
}
private static void showTree(List myComputer) {
// Create outside shell
Display display = new Display ();
Shell shell = new Shell(display);
shell.setText("Tree with columns sample");
shell.setLayout(new GridLayout());
shell.setSize(400, 400);
// Create treeViewer and the tree that goes inside the shell
TreeViewer fileTreeViewer = new TreeViewer(shell, SWT.FULL_SELECTION);
// Build the actual tree
Tree tree = fileTreeViewer.getTree();
tree.setHeaderVisible(true);
tree.setLinesVisible(false);
TreeColumn col1 = new TreeColumn(tree, SWT.LEFT);
col1.setText("Name");
col1.setWidth(200);
TreeColumn col2 = new TreeColumn(tree, SWT.LEFT);
col2.setText("Created By");
col2.setWidth(100);
TreeColumn col3 = new TreeColumn(tree, SWT.RIGHT);
col3.setText("File Size");
col3.setWidth(100);
tree.setLayoutData(new GridData(GridData.FILL_BOTH));
// Create content provider
fileTreeViewer.setContentProvider(new ITreeContentProvider() {
public Object[] getElements(Object inputElement) { // original input
List filesDirs = (List)inputElement;
return filesDirs.toArray();
}
public boolean hasChildren(Object element) {
FileDirectory fileDir = (FileDirectory)element;
return !fileDir.getChildren().isEmpty();
}
public Object[] getChildren(Object parentElement) { // all other children
FileDirectory fileDir = (FileDirectory)parentElement;
return fileDir.getChildren().toArray();
}
public Object getParent(Object element) {
return null;
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
{
}
public void dispose() {
}
});
fileTreeViewer.setLabelProvider(new ITableLabelProvider() {
public String getColumnText(Object element, int columnIndex) {
FileDirectory fileDir = (FileDirectory) element;
String colText = null;
switch (columnIndex) {
case 0:
colText = fileDir.getName();
break;
case 1:
colText = fileDir.getCreatedBy();
break;
case 2:
colText = fileDir.getSizeInBytes();
break;
default:
break;
}
return (colText != null) ? colText : "";
}
public void removeListener(ILabelProviderListener listener) {
}
public boolean isLabelProperty(Object element, String property) {
return false;
}
public void dispose() {
}
public void addListener(ILabelProviderListener listener) {
}
public Image getColumnImage(Object element, int columnIndex) {
return null;
}
});
fileTreeViewer.setInput(myComputer);
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
}
class FileDirectory {
private String name;
private String createdBy;
private String sizeInBytes;
private List children = new ArrayList();
public FileDirectory(String name, String createdBy, String sizeInBytes) {
this.name = name;
this.createdBy = createdBy;
this.sizeInBytes = sizeInBytes;
}
public FileDirectory(String name) {
this.name = name;
}
public void addChild(FileDirectory child) {
children.add(child);
}
public List getChildren() {
return children;
}
public void setChildren(List children) {
this.children = children;
}
public String getCreatedBy() {
return createdBy;
}
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSizeInBytes() {
return sizeInBytes;
}
public void setSizeInBytes(String sizeInBytes) {
this.sizeInBytes = sizeInBytes;
}
}
--
HTH,
- Kalman (http://www.zikal.com/)
"Mark M. Ingerman" <online@cs2.com> wrote in message
news:ddiov5$pre$1@news.eclipse.org...
>I am trying to work with the TableTree control. There is the viewer
>abstraction that provides content and label support for Tables and Trees,
>but I cannot find anything that provides the same level of abstraction for
>the TableTree control. I have tried to apply the TableViewer to the
>TableTree's table control -> new TableViewer(tableTree.getTable()), but it
>doesn't work. Is there such an abstraction, or do I need to create my own
>(or interface directly to the TableTree control)?
>
> --
> Mark M. Ingerman
> Creative Software Solutions, Inc.
> Architect, OO-Designer, Developer, Mentor
> mark.ingerman@cs2.com
> 617-630-2895
> www.cs2.com
>
|
|
|
Re: TableTree [message #459617 is a reply to message #459615] |
Fri, 12 August 2005 16:41   |
Eclipse User |
|
|
|
Version 3.1
--
HTH,
- Kalman (http://www.zikal.com/)
"Mark M. Ingerman" <online@cs2.com> wrote in message
news:ddiva4$il$1@news.eclipse.org...
> Okay. does this mean that the tree can support the tree and table
> functions now? Can I then use the TreeViewer too? What version of
> SWT/JFace did the table functions get incorporated into the Tree, or am I
> missing something?
>
> --
> Mark M. Ingerman
> Creative Software Solutions, Inc.
> Architect, OO-Designer, Developer, Mentor
> mark.ingerman@cs2.com
> 617-630-2895
> www.cs2.com
> "Sunil Kamath" <sunil_kamath@nohotspammail.com> wrote in message
> news:ddir65$s3k$1@news.eclipse.org...
>>
>> "Mark M. Ingerman" <online@cs2.com> wrote in message
>> news:ddiov5$pre$1@news.eclipse.org...
>>>I am trying to work with the TableTree control. There is the viewer
>>>abstraction that provides content and label support for Tables and Trees,
>>>but I cannot find anything that provides the same level of abstraction
>>>for the TableTree control. I have tried to apply the TableViewer to the
>>>TableTree's table control -> new TableViewer(tableTree.getTable()), but
>>>it doesn't work. Is there such an abstraction, or do I need to create my
>>>own (or interface directly to the TableTree control)?
>>>
>> TableTree has been deprecated in 3.1- you can use Tree directly.
>> But if you insist, you can use org.eclipse.jface.viewers.TableTreeViewer.
>> ---
>> Sunil
>>
>
>
|
|
|
Re: TableTree [message #459618 is a reply to message #459616] |
Fri, 12 August 2005 18:02   |
Eclipse User |
|
|
|
Thank you for your input. I downloaded Eclipse 3.1. Installed it. Created
a project to test this. Added the necessary required libraries, but I
cannot run it due to the UnsatisfiedLinkError: no swt-win32-3138 in
java.library.path error:
I tried to:
1) add the -Djava.library.path= statement in the runtime VM arguments
2) changed my system path to point to the directory with the DLL
3) copied the DLL into my system and system32 folders, but nothing works
Did something else change in the new version of eclispe that prevents me
from setting this variable?
--
Mark M. Ingerman
Creative Software Solutions, Inc.
Architect, OO-Designer, Developer, Mentor
mark.ingerman@cs2.com
617-630-2895
www.cs2.com
"Kalman" <kalman@zikal.com> wrote in message
news:ddj0t5$29m$1@news.eclipse.org...
> Sunil is right. TableTree should not be used any longer.
>
> Below is the code for using a regular tree with columns:
>
> import java.util.ArrayList;
> import java.util.List;
>
> import org.eclipse.jface.viewers.ILabelProviderListener;
> import org.eclipse.jface.viewers.ITableLabelProvider;
> import org.eclipse.jface.viewers.ITreeContentProvider;
> import org.eclipse.jface.viewers.TreeViewer;
> import org.eclipse.jface.viewers.Viewer;
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.graphics.Image;
> import org.eclipse.swt.layout.GridData;
> import org.eclipse.swt.layout.GridLayout;
> import org.eclipse.swt.widgets.Display;
> import org.eclipse.swt.widgets.Shell;
> import org.eclipse.swt.widgets.Tree;
> import org.eclipse.swt.widgets.TreeColumn;
>
> public class TreeWithColumnsDriver {
> public static void main(String[] args) {
> // My computer
> FileDirectory myComputer = new FileDirectory("My computer");
>
> // C Drive
> FileDirectory cDrive = new FileDirectory("C Drive");
> FileDirectory file1 = new FileDirectory("Test1.txt", "John", "2 KB");
> FileDirectory file2 = new FileDirectory("Testing2.html", "John", "5 KB");
> FileDirectory file3 = new FileDirectory("Rest3.doc", "Marty", "10 KB");
> FileDirectory file4 = new FileDirectory("Really big name.html", "Bob",
> "100 KB");
> cDrive.addChild(file1);
> cDrive.addChild(file2);
> cDrive.addChild(file3);
> cDrive.addChild(file4);
> myComputer.addChild(cDrive);
>
> // D Drive
> FileDirectory dDrive = new FileDirectory("D Drive");
> FileDirectory downloads = new FileDirectory("Downloads");
> dDrive.addChild(downloads);
> FileDirectory filed1 = new FileDirectory("Whatever.txt", "John", "2 KB");
> FileDirectory filed2 = new FileDirectory("Blogger.html", "John", "5 KB");
> FileDirectory filed3 = new FileDirectory("something else.mp3", "Jack",
> "10 MB");
> FileDirectory filed4 = new FileDirectory("Reality.txt", "Bryan", "100
> KB");
> downloads.addChild(filed1);
> downloads.addChild(filed2);
> downloads.addChild(filed3);
> downloads.addChild(filed4);
> myComputer.addChild(dDrive);
>
> List filesDirs = new ArrayList();
> filesDirs.add(myComputer);
> showTree(filesDirs);
> }
>
> private static void showTree(List myComputer) {
> // Create outside shell
> Display display = new Display ();
> Shell shell = new Shell(display);
> shell.setText("Tree with columns sample");
> shell.setLayout(new GridLayout());
> shell.setSize(400, 400);
>
> // Create treeViewer and the tree that goes inside the shell
> TreeViewer fileTreeViewer = new TreeViewer(shell, SWT.FULL_SELECTION);
>
> // Build the actual tree
> Tree tree = fileTreeViewer.getTree();
> tree.setHeaderVisible(true);
> tree.setLinesVisible(false);
>
> TreeColumn col1 = new TreeColumn(tree, SWT.LEFT);
> col1.setText("Name");
> col1.setWidth(200);
> TreeColumn col2 = new TreeColumn(tree, SWT.LEFT);
> col2.setText("Created By");
> col2.setWidth(100);
> TreeColumn col3 = new TreeColumn(tree, SWT.RIGHT);
> col3.setText("File Size");
> col3.setWidth(100);
>
> tree.setLayoutData(new GridData(GridData.FILL_BOTH));
>
> // Create content provider
> fileTreeViewer.setContentProvider(new ITreeContentProvider() {
> public Object[] getElements(Object inputElement) { // original input
> List filesDirs = (List)inputElement;
> return filesDirs.toArray();
> }
> public boolean hasChildren(Object element) {
> FileDirectory fileDir = (FileDirectory)element;
> return !fileDir.getChildren().isEmpty();
> }
> public Object[] getChildren(Object parentElement) { // all other
> children
> FileDirectory fileDir = (FileDirectory)parentElement;
> return fileDir.getChildren().toArray();
> }
> public Object getParent(Object element) {
> return null;
> }
> public void inputChanged(Viewer viewer, Object oldInput, Object
> newInput) {
> }
> public void dispose() {
> }
> });
>
> fileTreeViewer.setLabelProvider(new ITableLabelProvider() {
> public String getColumnText(Object element, int columnIndex) {
> FileDirectory fileDir = (FileDirectory) element;
>
> String colText = null;
> switch (columnIndex) {
> case 0:
> colText = fileDir.getName();
> break;
> case 1:
> colText = fileDir.getCreatedBy();
> break;
> case 2:
> colText = fileDir.getSizeInBytes();
> break;
>
> default:
> break;
> }
>
> return (colText != null) ? colText : "";
> }
>
> public void removeListener(ILabelProviderListener listener) {
> }
> public boolean isLabelProperty(Object element, String property) {
> return false;
> }
> public void dispose() {
> }
> public void addListener(ILabelProviderListener listener) {
> }
> public Image getColumnImage(Object element, int columnIndex) {
> return null;
> }
> });
>
> fileTreeViewer.setInput(myComputer);
>
> shell.open ();
> while (!shell.isDisposed ()) {
> if (!display.readAndDispatch ()) display.sleep ();
> }
> display.dispose ();
> }
> }
>
> class FileDirectory {
> private String name;
> private String createdBy;
> private String sizeInBytes;
>
> private List children = new ArrayList();
>
> public FileDirectory(String name, String createdBy, String sizeInBytes) {
> this.name = name;
> this.createdBy = createdBy;
> this.sizeInBytes = sizeInBytes;
> }
>
> public FileDirectory(String name) {
> this.name = name;
> }
>
> public void addChild(FileDirectory child) {
> children.add(child);
> }
>
> public List getChildren() {
> return children;
> }
>
> public void setChildren(List children) {
> this.children = children;
> }
>
> public String getCreatedBy() {
> return createdBy;
> }
>
> public void setCreatedBy(String createdBy) {
> this.createdBy = createdBy;
> }
>
> public String getName() {
> return name;
> }
>
> public void setName(String name) {
> this.name = name;
> }
>
> public String getSizeInBytes() {
> return sizeInBytes;
> }
>
> public void setSizeInBytes(String sizeInBytes) {
> this.sizeInBytes = sizeInBytes;
> }
> }
>
>
> --
> HTH,
> - Kalman (http://www.zikal.com/)
>
>
> "Mark M. Ingerman" <online@cs2.com> wrote in message
> news:ddiov5$pre$1@news.eclipse.org...
>>I am trying to work with the TableTree control. There is the viewer
>>abstraction that provides content and label support for Tables and Trees,
>>but I cannot find anything that provides the same level of abstraction for
>>the TableTree control. I have tried to apply the TableViewer to the
>>TableTree's table control -> new TableViewer(tableTree.getTable()), but it
>>doesn't work. Is there such an abstraction, or do I need to create my own
>>(or interface directly to the TableTree control)?
>>
>> --
>> Mark M. Ingerman
>> Creative Software Solutions, Inc.
>> Architect, OO-Designer, Developer, Mentor
>> mark.ingerman@cs2.com
>> 617-630-2895
>> www.cs2.com
>>
>
>
|
|
|
Re: TableTree [message #459619 is a reply to message #459618] |
Fri, 12 August 2005 18:39  |
Eclipse User |
|
|
|
Mark M. Ingerman wrote:
> Thank you for your input. I downloaded Eclipse 3.1. Installed it. Created
> a project to test this. Added the necessary required libraries, but I
> cannot run it due to the UnsatisfiedLinkError: no swt-win32-3138 in
> java.library.path error:
Try "Run As > SWT Application". This will always work.
If I had to guess, I bet you're point at the wrong DLLs. Did you
just add the SWT .jar file as a library dependency in your project? In
Eclipse 3.1, the SWT plug-in does some special Eclipse stuff, and so the
DLLs are extracted from the .jar file at runtime by the Eclipse plug-in
infrastructure.
The recommended way to use SWT in your app is to download the
standalone SWT .zip file and import it using the "External Plug-ins"
import wizard. This will put all the DLLs in a project in your
workspace in a sane way, and you can use "Run As > Java Application" and
it will "just work" without you having to add anything to your library path.
-Billy
|
|
|
Goto Forum:
Current Time: Thu Jul 03 17:33:54 EDT 2025
Powered by FUDForum. Page generated in 0.04525 seconds
|