Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » Jface TreeView File list drag and drop
Jface TreeView File list drag and drop [message #1695614] Mon, 18 May 2015 06:47 Go to next message
Lalit Solanki is currently offline Lalit SolankiFriend
Messages: 146
Registered: April 2015
Senior Member
Hi friend,
I am created one application and using jface treeview and fill file to treeview and now i am trying drag and drop file my code :-

private TreeViewer tree = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);

tree.setContentProvider(new ViewContentProvider());
tree.setLabelProvider(new ViewLabelProvider());
tree.setInput(File.listRoots());



class ViewContentProvider implements ITreeContentProvider {
public void inputChanged(Viewer v, Object oldInput, Object newInput) {
}

@Override
public void dispose() {
}

@Override
public Object[] getElements(Object inputElement) {
return (File[]) inputElement;
}

@Override
public Object[] getChildren(Object parentElement) {
File file = (File) parentElement;
return file.listFiles();
}

@Override
public Object getParent(Object element) {
File file = (File) element;
return file.getParentFile();
}

@Override
public boolean hasChildren(Object element) {
File file = (File) element;
if (file.isDirectory()) {
return true;
}
return false;
}
}

class ViewLabelProvider extends StyledCellLabelProvider {
@Override
public void update(ViewerCell cell) {
Object element = cell.getElement();
StyledString text = new StyledString();
File file = (File) element;
if (file.isDirectory()) {
text.append(getFileName(file));
cell.setImage(mainimage);
String[] files = file.list();
if (files != null) {
text.append(" (" + files.length + ") ",StyledString.QUALIFIER_STYLER);
}
} else {
text.append(getFileName(file));
}
cell.setText(text.toString());
cell.setStyleRanges(text.getStyleRanges());
super.update(cell);

}

private String getFileName(File file) {
String name = file.getName();
return name.isEmpty() ? file.getPath() : name;
}
}
/*********************************************/

I am trying file drag and drop so please help me ...


Lalit
Re: Jface TreeView File list drag and drop [message #1695646 is a reply to message #1695614] Mon, 18 May 2015 11:40 Go to previous messageGo to next message
Lalit Solanki is currently offline Lalit SolankiFriend
Messages: 146
Registered: April 2015
Senior Member
Hello friend,
please any idea above my post then please help me .....


Lalit
Re: Jface TreeView File list drag and drop [message #1695964 is a reply to message #1695646] Wed, 20 May 2015 15:26 Go to previous messageGo to next message
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 788
Registered: January 2012
Senior Member

Take a look at the Lars Vogel's tutorials.

Brian.


Eclipse Platform committer. Ask me about Eclipse support, training, and consulting.
Re: Jface TreeView File list drag and drop [message #1696036 is a reply to message #1695964] Thu, 21 May 2015 10:16 Go to previous message
Lalit Solanki is currently offline Lalit SolankiFriend
Messages: 146
Registered: April 2015
Senior Member
Thank you Brian de Alwis sir.............

Lalit
Previous Topic:Custom PatternFilter in TreeViewer
Next Topic:[DataBinding] Model and UI Independence for Collections
Goto Forum:
  


Current Time: Mon Nov 19 21:36:16 GMT 2018

Powered by FUDForum. Page generated in 0.06178 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top