hi Maneesh,
Sorry for that, i got some code. Can you help me to resolve the position issue which i am phasing now.
initially i get a window with two division, in which i drag text from one division to another. I am using SWT package,
in the second window when i click any dropped text, it should automatically open third division to edit that selected text and a button to finish the update task.
Right now i am able to do the all the task but when i select a item to edit, the screen is not updating, i have to re size the screen to see the button and editable text.
Can you help me to resolve this issue.
here is the code
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package
test;
import javax.swing.JTextField;
import org.eclipse.swt.SWT;
import org.eclipse.swt.dnd.*;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.TreeAdapter;
import org.eclipse.swt.events.TreeEvent;
import org.eclipse.swt.events.TreeListener;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
public class doitforme
{
public int count=0;
TreeItem item4;
Shell shell;
Display display ;
Text displaytext;
public doitforme()
{
// item4=new TreeItem();
}
public void getthatworkdone()
{
display = new Display();
shell = new Shell(display);
shell.setLayout(new FillLayout());
shell.setText("Drag and Drop");
final Tree tree = new Tree(shell, SWT.BORDER);
TreeItem item1 = new TreeItem(tree, SWT.NONE);
item1.setText("Hello 1");
TreeItem item2 = new TreeItem(tree, SWT.NONE);
item2.setText("Hello 2");
TreeItem item3 = new TreeItem(tree, SWT.NONE);
item3.setText("Hello 3");
TreeItem item5 = new TreeItem(tree, SWT.NONE);
item5.setText("Hello 4");
DragSource ds = new DragSource(tree, DND.DROP_MOVE);
ds.setTransfer(new Transfer[] { TextTransfer.getInstance() });
ds.addDragListener(new DragSourceAdapter() {
public void dragSetData(DragSourceEvent event) {
event.data = tree.getSelection()[0].getText();
}
});
// final Text text = new Text(shell, SWT.BORDER);
final Tree tree1 = new Tree(shell, SWT.BORDER);
DropTarget dt = new DropTarget(tree1, DND.DROP_MOVE);
dt.setTransfer(new Transfer[] { TextTransfer.getInstance() });
dt.addDropListener(new DropTargetAdapter(){
public void drop(DropTargetEvent event) {
item4 = new TreeItem(tree1, SWT.NONE);
item4.setText((
String)event.data);
System.out.println("here to refresh the screen");
shell.redraw();
System.out.println("ok droped one item");
tree1.addTreeListener(new TreeListener() {
public void treeExpanded(TreeEvent e) {
System.out.println("expanded: " + ((TreeItem)e.item).getText()); }
public void treeCollapsed(TreeEvent e) {
System.out.println("collapsed: " + ((TreeItem)e.item).getText());
}
});
tree1.addSelectionListener(new SelectionAdapter(){
public void widgetSelected( final SelectionEvent e) {
System.out.println("selected: " +
((TreeItem)e.item).getText());
if(count==0)
{
count=1;
System.out.println("here to refresh the on mouse click");
shell.redraw();
display.readAndDispatch();
displaytext = new Text(shell, SWT.BORDER);
displaytext.setText(((TreeItem)e.item).getText());
final Text abcd = displaytext;
final Button okButton = new Button(shell, SWT.ABORT);
// Button newone =new Button(shell.getParent(),SWT.CLIP_SIBLINGS);
okButton.setSize(100, 100);
Listener listener = new Listener() {
public void handleEvent(Event event) {
((TreeItem)e.item).setText(displaytext.getText());
// ((TreeItem)e.item).setText("abcd");
System.out.println("go this ayararer");
displaytext.dispose();
okButton.dispose();
count=0;
// display.readAndDispatch();
okButton.dispose();
}
};
okButton.addListener(SWT.Selection, listener);
}
}
});
} }
);
shell.setSize(1000, 500);
shell.open();
while (!shell.isDisposed())
{
if (!display.readAndDispatch())
{
display.sleep();
}
}
display.dispose();
}
}
Thanks in advance!