Home » Eclipse Projects » Nebula » Gallery Item Selection
Gallery Item Selection [message #30393] |
Thu, 01 March 2007 01:33  |
Eclipse User |
|
|
|
Originally posted by: swetha.yahoo.co.in
Hi All,
I am using the Gallery Widget for displaying the list of
contents(folders and files) just like a Windows explorer kind of thing...
If I select a particular folder, the contents of that folder is getting
displayed ,the problem is it is not clearing the selection even after I
placed deselectAll() method;
Here is the code...for constructGallery on click of folder.
private void constructGallery(CustomerModel domain)
{
gallery.clearAll();
gallery.deselectAll();
i1 = new GalleryItem(gallery, SWT.NONE);
i1.setText(domain.toString());
if (domain.child != null)
{
for (int i = 0; i < domain.child.size(); i++)
{
GalleryItem i2 = new GalleryItem(i1, SWT.NONE);
// Your image here
i2.setImage(Util.getImageRegistry().get("galleryImage"));
i2.setText(domain.child.get(i).toString());
gallery.deselectAll();
}
}
gallery.deselectAll();
}
Thanks in advance,
Swetha
|
|
|
Re: Gallery Item Selection [message #30428 is a reply to message #30393] |
Thu, 01 March 2007 02:44   |
Eclipse User |
|
|
|
Hi Swetha,
This seems to be a bug. I took a quick look in the gallery code but I
couldn't find the reason why it is not clearing the selection.
Please try this and tell me if this fix the problem :
- add i1.deselectAll() and i2.deselectAll()
- add gallery.redraw() to force update
(this should be done automatically by the widget).
If it still doesn't work, please fill a bug report in bugzilla and
include a snippet if you can.
Thanks,
--
Nicolas
> Hi All,
>
> I am using the Gallery Widget for displaying the list of
> contents(folders and files) just like a Windows explorer kind of thing...
> If I select a particular folder, the contents of that folder is getting
> displayed ,the problem is it is not clearing the selection even after I
> placed deselectAll() method;
>
> Here is the code...for constructGallery on click of folder.
>
>
> private void constructGallery(CustomerModel domain)
> {
> gallery.clearAll();
> gallery.deselectAll();
> i1 = new GalleryItem(gallery, SWT.NONE);
> i1.setText(domain.toString());
> if (domain.child != null)
> {
> for (int i = 0; i < domain.child.size(); i++)
> {
> GalleryItem i2 = new GalleryItem(i1, SWT.NONE);
> // Your image here
> i2.setImage(Util.getImageRegistry().get("galleryImage"));
> i2.setText(domain.child.get(i).toString());
> gallery.deselectAll();
> }
> }
> gallery.deselectAll();
>
> }
>
>
> Thanks in advance,
> Swetha
>
>
>
>
>
|
|
| | | |
Re: Gallery Item Selection [message #30568 is a reply to message #30534] |
Thu, 01 March 2007 05:12   |
Eclipse User |
|
|
|
Hi,
Please double check you code, and add debug output to see if deselectAll
or constructGallery are really called.
deselectAll is working for me.
--
Nicolas
Swetha a écrit :
> Hi,
> Where CustomerModel is my domain object...
> GalleryView:
>
>
> import java.util.Iterator;
>
> import org.eclipse.jface.viewers.ISelection;
> import org.eclipse.jface.viewers.IStructuredSelection;
> import org.eclipse.jface.viewers.StructuredSelection;
> import org.eclipse.jface.viewers.TreeSelection;
> import org.eclipse.nebula.widgets.gallery.DefaultGalleryItemRendere r;
> import org.eclipse.nebula.widgets.gallery.Gallery;
> import org.eclipse.nebula.widgets.gallery.GalleryItem;
> import org.eclipse.nebula.widgets.gallery.NoGroupRenderer;
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.graphics.Point;
> import org.eclipse.swt.program.Program;
> import org.eclipse.swt.widgets.Composite;
> import org.eclipse.swt.widgets.Event;
> import org.eclipse.swt.widgets.Listener;
> import org.eclipse.swt.widgets.Table;
> import org.eclipse.swt.widgets.TableColumn;
> import org.eclipse.swt.widgets.TreeItem;
> import org.eclipse.ui.ISelectionListener;
> import org.eclipse.ui.IWorkbenchPart;
> import org.eclipse.ui.part.ViewPart;
>
>
>
> public class GalleryView extends ViewPart
> {
>
> int col;
> CustomerModel domain;
>
> NoGroupRenderer gr;
>
> DefaultGalleryItemRenderer ir;
>
> Gallery gallery;
>
> GalleryItem i1;
>
> int height;
>
> int width;
> String selectedItem;
>
> public void createPartControl(Composite parent)
> {
> gallery = new Gallery(parent, SWT.V_SCROLL);
> // Renderers
> // gr = new DefaultGalleryGroupRenderer();
> gr = new NoGroupRenderer();
> ir = new DefaultGalleryItemRenderer();
> height =
> Util.getImageRegistry().get("galleryImage").getBounds().height;
> width =
> Util.getImageRegistry().get("galleryImage").getBounds().width;
> gr.setItemSize(width * 3, height);
> gr.setMinMargin(3);
> gallery.setGroupRenderer(gr);
> gallery.setItemRenderer(ir);
> addListenerstoGallery();
>
> getSite().getPage().addSelectionListener(listener);
>
> }
>
>
> private void addListenerstoGallery()
> {
>
> gallery.addListener(SWT.MouseDoubleClick, new Listener()
> {
>
> // To handle like a windows explorer
>
> public void handleEvent(Event event)
> {
> // GalleryItem item = (GalleryItem) event.item;
> selectedItem = ((Gallery) (event.widget)).getItem(
> new Point(event.x, event.y)).getText();
> for (int i = 0; i < domain.child.size(); i++)
> {
> if (selectedItem.trim().equals(
> domain.child.get(i).toString()))
> {
> if (((CustomerModel) (domain.child.get(i))).child
> .size() > 0)
> {
> domain = ((CustomerModel) domain.child.get(i));
> constructGallery(domain);
> // System.out.println("domain---- "+domain);
> } else if
> (((CustomerModel)domain.child.get(i))).child
> .size() == 0)
> {
> Program.launch("c:/putty");
> constructGallery(domain);
>
> }
> }
> }
>
> }
>
> });
>
> }
>
>
>
> private void constructGallery(CustomerModel domain)
> {
> gallery.clearAll();
> // gallery.deselectAll();
> //gallery.redraw();
> i1 = new GalleryItem(gallery, SWT.NONE);
> i1.setText(domain.toString());
> if (domain.child != null)
> {
> for (int i = 0; i < domain.child.size(); i++)
> {
> GalleryItem i2 = new GalleryItem(i1, SWT.NONE);
> // Your image here
> i2.setImage(Util.getImageRegistry().get("galleryImage"));
> i2.setText(domain.child.get(i).toString());
> //i2.selectAll();
> //i2._deselectAll();
> //gallery._selectAll();
> gallery.deselectAll();
> gallery.redraw();
> }
> }
>
> gallery.deselectAll();
> gallery.redraw();
> }
>
>
>
> public void setFocus()
> {
>
> }
> }
>
>
|
|
| |
Re: Gallery Item Selection [message #30638 is a reply to message #30603] |
Thu, 01 March 2007 07:53   |
Eclipse User |
|
|
|
Hi,
Ok, I think I understand the problem :
Item selection is based on Windows explorer behavior. And in some cases,
an item becomes selected on mouseup event.
So when you double click on an item, the double click event is raised
first, and you replace the content of the gallery.
Then the mouse up event occurs and selects the item which is under the
mouse.
I'm going to fix this asap.
--
Nicolas
Swetha a écrit :
> Hi,
>
> Thanks for the reply... Both constructGallery(domain) and deselectAll()
> are getting called...Actually the logic of the required functionality is
> achieved thru this constructGallery method only...
>
> Everything is working fine.. except this selection...
> Let me say my problem once gain,
> Suppose there 10 folders which are arranged in 5 rows and 2 cols in
> gallery widget..
>
> If I double click on second row and first col folder(which contains
> again 8 child folders), will display the 8 folders in 4 rows and 2
> cols..here is the folder...As I selected the second row and first col
> folder, the folder which is in that place(2nd row 1st col) is showing as
> selected....which I don't want..
>
> Thanks,
> Swetha
>
|
|
| |
Re: Gallery Item Selection [message #30777 is a reply to message #30672] |
Sat, 03 March 2007 16:43  |
Eclipse User |
|
|
|
Hi,
This should be fixed now.
--
Nicolas
Swetha a écrit :
> Hi,
>
> Thanks .. Actually for my widget I don't need mouseUp event, for the
> time being I commented that mouseUp method and its working fine...
>
> Please let us know once it is fixed.
>
> Thanks a lot,
> Sujatha
>
|
|
|
Re: Gallery Item Selection [message #579307 is a reply to message #30393] |
Thu, 01 March 2007 02:44  |
Eclipse User |
|
|
|
Hi Swetha,
This seems to be a bug. I took a quick look in the gallery code but I
couldn't find the reason why it is not clearing the selection.
Please try this and tell me if this fix the problem :
- add i1.deselectAll() and i2.deselectAll()
- add gallery.redraw() to force update
(this should be done automatically by the widget).
If it still doesn't work, please fill a bug report in bugzilla and
include a snippet if you can.
Thanks,
--
Nicolas
> Hi All,
>
> I am using the Gallery Widget for displaying the list of
> contents(folders and files) just like a Windows explorer kind of thing...
> If I select a particular folder, the contents of that folder is getting
> displayed ,the problem is it is not clearing the selection even after I
> placed deselectAll() method;
>
> Here is the code...for constructGallery on click of folder.
>
>
> private void constructGallery(CustomerModel domain)
> {
> gallery.clearAll();
> gallery.deselectAll();
> i1 = new GalleryItem(gallery, SWT.NONE);
> i1.setText(domain.toString());
> if (domain.child != null)
> {
> for (int i = 0; i < domain.child.size(); i++)
> {
> GalleryItem i2 = new GalleryItem(i1, SWT.NONE);
> // Your image here
> i2.setImage(Util.getImageRegistry().get("galleryImage"));
> i2.setText(domain.child.get(i).toString());
> gallery.deselectAll();
> }
> }
> gallery.deselectAll();
>
> }
>
>
> Thanks in advance,
> Swetha
>
>
>
>
>
|
|
|
Re: Gallery Item Selection [message #579332 is a reply to message #30428] |
Thu, 01 March 2007 04:06  |
Eclipse User |
|
|
|
Hi,
I tried with that also...There is no deselectAll() method on Gallery
Item... deselectAll() is there on Gallery Object.Please give me an idea
how to solve this
Thanks,
Swetha
|
|
|
Re: Gallery Item Selection [message #579342 is a reply to message #30393] |
Thu, 01 March 2007 04:25  |
Eclipse User |
|
|
|
Hi,
Sorry, these are protected methods.
Could you send me a snippet showing the problem ?
Thanks
--
Nicolas
Swetha a écrit :
> Hi All,
>
> I am using the Gallery Widget for displaying the list of
> contents(folders and files) just like a Windows explorer kind of thing...
> If I select a particular folder, the contents of that folder is getting
> displayed ,the problem is it is not clearing the selection even after I
> placed deselectAll() method;
>
> Here is the code...for constructGallery on click of folder.
>
>
> private void constructGallery(CustomerModel domain)
> {
> gallery.clearAll();
> gallery.deselectAll();
> i1 = new GalleryItem(gallery, SWT.NONE);
> i1.setText(domain.toString());
> if (domain.child != null)
> {
> for (int i = 0; i < domain.child.size(); i++)
> {
> GalleryItem i2 = new GalleryItem(i1, SWT.NONE);
> // Your image here
> i2.setImage(Util.getImageRegistry().get("galleryImage"));
> i2.setText(domain.child.get(i).toString());
> gallery.deselectAll();
> }
> }
> gallery.deselectAll();
>
> }
>
>
> Thanks in advance,
> Swetha
>
>
>
>
>
|
|
|
Re: Gallery Item Selection [message #579369 is a reply to message #30499] |
Thu, 01 March 2007 04:45  |
Eclipse User |
|
|
|
Hi,
Where CustomerModel is my domain object...
GalleryView:
import java.util.Iterator;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TreeSelection;
import org.eclipse.nebula.widgets.gallery.DefaultGalleryItemRendere r;
import org.eclipse.nebula.widgets.gallery.Gallery;
import org.eclipse.nebula.widgets.gallery.GalleryItem;
import org.eclipse.nebula.widgets.gallery.NoGroupRenderer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.program.Program;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.part.ViewPart;
public class GalleryView extends ViewPart
{
int col;
CustomerModel domain;
NoGroupRenderer gr;
DefaultGalleryItemRenderer ir;
Gallery gallery;
GalleryItem i1;
int height;
int width;
String selectedItem;
public void createPartControl(Composite parent)
{
gallery = new Gallery(parent, SWT.V_SCROLL);
// Renderers
// gr = new DefaultGalleryGroupRenderer();
gr = new NoGroupRenderer();
ir = new DefaultGalleryItemRenderer();
height =
Util.getImageRegistry().get("galleryImage").getBounds().height;
width =
Util.getImageRegistry().get("galleryImage").getBounds().width;
gr.setItemSize(width * 3, height);
gr.setMinMargin(3);
gallery.setGroupRenderer(gr);
gallery.setItemRenderer(ir);
addListenerstoGallery();
getSite().getPage().addSelectionListener(listener);
}
private void addListenerstoGallery()
{
gallery.addListener(SWT.MouseDoubleClick, new Listener()
{
// To handle like a windows explorer
public void handleEvent(Event event)
{
// GalleryItem item = (GalleryItem) event.item;
selectedItem = ((Gallery) (event.widget)).getItem(
new Point(event.x, event.y)).getText();
for (int i = 0; i < domain.child.size(); i++)
{
if (selectedItem.trim().equals(
domain.child.get(i).toString()))
{
if (((CustomerModel) (domain.child.get(i))).child
.size() > 0)
{
domain = ((CustomerModel) domain.child.get(i));
constructGallery(domain);
// System.out.println("domain---- "+domain);
} else if
(((CustomerModel)domain.child.get(i))).child
.size() == 0)
{
Program.launch("c:/putty");
constructGallery(domain);
}
}
}
}
});
}
private void constructGallery(CustomerModel domain)
{
gallery.clearAll();
// gallery.deselectAll();
//gallery.redraw();
i1 = new GalleryItem(gallery, SWT.NONE);
i1.setText(domain.toString());
if (domain.child != null)
{
for (int i = 0; i < domain.child.size(); i++)
{
GalleryItem i2 = new GalleryItem(i1, SWT.NONE);
// Your image here
i2.setImage(Util.getImageRegistry().get("galleryImage"));
i2.setText(domain.child.get(i).toString());
//i2.selectAll();
//i2._deselectAll();
//gallery._selectAll();
gallery.deselectAll();
gallery.redraw();
}
}
gallery.deselectAll();
gallery.redraw();
}
public void setFocus()
{
}
}
|
|
|
Re: Gallery Item Selection [message #579389 is a reply to message #30534] |
Thu, 01 March 2007 05:12  |
Eclipse User |
|
|
|
Hi,
Please double check you code, and add debug output to see if deselectAll
or constructGallery are really called.
deselectAll is working for me.
--
Nicolas
Swetha a écrit :
> Hi,
> Where CustomerModel is my domain object...
> GalleryView:
>
>
> import java.util.Iterator;
>
> import org.eclipse.jface.viewers.ISelection;
> import org.eclipse.jface.viewers.IStructuredSelection;
> import org.eclipse.jface.viewers.StructuredSelection;
> import org.eclipse.jface.viewers.TreeSelection;
> import org.eclipse.nebula.widgets.gallery.DefaultGalleryItemRendere r;
> import org.eclipse.nebula.widgets.gallery.Gallery;
> import org.eclipse.nebula.widgets.gallery.GalleryItem;
> import org.eclipse.nebula.widgets.gallery.NoGroupRenderer;
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.graphics.Point;
> import org.eclipse.swt.program.Program;
> import org.eclipse.swt.widgets.Composite;
> import org.eclipse.swt.widgets.Event;
> import org.eclipse.swt.widgets.Listener;
> import org.eclipse.swt.widgets.Table;
> import org.eclipse.swt.widgets.TableColumn;
> import org.eclipse.swt.widgets.TreeItem;
> import org.eclipse.ui.ISelectionListener;
> import org.eclipse.ui.IWorkbenchPart;
> import org.eclipse.ui.part.ViewPart;
>
>
>
> public class GalleryView extends ViewPart
> {
>
> int col;
> CustomerModel domain;
>
> NoGroupRenderer gr;
>
> DefaultGalleryItemRenderer ir;
>
> Gallery gallery;
>
> GalleryItem i1;
>
> int height;
>
> int width;
> String selectedItem;
>
> public void createPartControl(Composite parent)
> {
> gallery = new Gallery(parent, SWT.V_SCROLL);
> // Renderers
> // gr = new DefaultGalleryGroupRenderer();
> gr = new NoGroupRenderer();
> ir = new DefaultGalleryItemRenderer();
> height =
> Util.getImageRegistry().get("galleryImage").getBounds().height;
> width =
> Util.getImageRegistry().get("galleryImage").getBounds().width;
> gr.setItemSize(width * 3, height);
> gr.setMinMargin(3);
> gallery.setGroupRenderer(gr);
> gallery.setItemRenderer(ir);
> addListenerstoGallery();
>
> getSite().getPage().addSelectionListener(listener);
>
> }
>
>
> private void addListenerstoGallery()
> {
>
> gallery.addListener(SWT.MouseDoubleClick, new Listener()
> {
>
> // To handle like a windows explorer
>
> public void handleEvent(Event event)
> {
> // GalleryItem item = (GalleryItem) event.item;
> selectedItem = ((Gallery) (event.widget)).getItem(
> new Point(event.x, event.y)).getText();
> for (int i = 0; i < domain.child.size(); i++)
> {
> if (selectedItem.trim().equals(
> domain.child.get(i).toString()))
> {
> if (((CustomerModel) (domain.child.get(i))).child
> .size() > 0)
> {
> domain = ((CustomerModel) domain.child.get(i));
> constructGallery(domain);
> // System.out.println("domain---- "+domain);
> } else if
> (((CustomerModel)domain.child.get(i))).child
> .size() == 0)
> {
> Program.launch("c:/putty");
> constructGallery(domain);
>
> }
> }
> }
>
> }
>
> });
>
> }
>
>
>
> private void constructGallery(CustomerModel domain)
> {
> gallery.clearAll();
> // gallery.deselectAll();
> //gallery.redraw();
> i1 = new GalleryItem(gallery, SWT.NONE);
> i1.setText(domain.toString());
> if (domain.child != null)
> {
> for (int i = 0; i < domain.child.size(); i++)
> {
> GalleryItem i2 = new GalleryItem(i1, SWT.NONE);
> // Your image here
> i2.setImage(Util.getImageRegistry().get("galleryImage"));
> i2.setText(domain.child.get(i).toString());
> //i2.selectAll();
> //i2._deselectAll();
> //gallery._selectAll();
> gallery.deselectAll();
> gallery.redraw();
> }
> }
>
> gallery.deselectAll();
> gallery.redraw();
> }
>
>
>
> public void setFocus()
> {
>
> }
> }
>
>
|
|
|
Re: Gallery Item Selection [message #579413 is a reply to message #30568] |
Thu, 01 March 2007 06:13  |
Eclipse User |
|
|
|
Hi,
Thanks for the reply... Both constructGallery(domain) and deselectAll()
are getting called...Actually the logic of the required functionality is
achieved thru this constructGallery method only...
Everything is working fine.. except this selection...
Let me say my problem once gain,
Suppose there 10 folders which are arranged in 5 rows and 2 cols in
gallery widget..
If I double click on second row and first col folder(which contains again
8 child folders), will display the 8 folders in 4 rows and 2 cols..here is
the folder...As I selected the second row and first col folder, the folder
which is in that place(2nd row 1st col) is showing as selected....which I
don't want..
Thanks,
Swetha
|
|
|
Re: Gallery Item Selection [message #579428 is a reply to message #30603] |
Thu, 01 March 2007 07:53  |
Eclipse User |
|
|
|
Hi,
Ok, I think I understand the problem :
Item selection is based on Windows explorer behavior. And in some cases,
an item becomes selected on mouseup event.
So when you double click on an item, the double click event is raised
first, and you replace the content of the gallery.
Then the mouse up event occurs and selects the item which is under the
mouse.
I'm going to fix this asap.
--
Nicolas
Swetha a écrit :
> Hi,
>
> Thanks for the reply... Both constructGallery(domain) and deselectAll()
> are getting called...Actually the logic of the required functionality is
> achieved thru this constructGallery method only...
>
> Everything is working fine.. except this selection...
> Let me say my problem once gain,
> Suppose there 10 folders which are arranged in 5 rows and 2 cols in
> gallery widget..
>
> If I double click on second row and first col folder(which contains
> again 8 child folders), will display the 8 folders in 4 rows and 2
> cols..here is the folder...As I selected the second row and first col
> folder, the folder which is in that place(2nd row 1st col) is showing as
> selected....which I don't want..
>
> Thanks,
> Swetha
>
|
|
|
Re: Gallery Item Selection [message #579448 is a reply to message #30638] |
Thu, 01 March 2007 08:03  |
Eclipse User |
|
|
|
Hi,
Thanks .. Actually for my widget I don't need mouseUp event, for the
time being I commented that mouseUp method and its working fine...
Please let us know once it is fixed.
Thanks a lot,
Sujatha
|
|
|
Re: Gallery Item Selection [message #579514 is a reply to message #30672] |
Sat, 03 March 2007 16:43  |
Eclipse User |
|
|
|
Hi,
This should be fixed now.
--
Nicolas
Swetha a écrit :
> Hi,
>
> Thanks .. Actually for my widget I don't need mouseUp event, for the
> time being I commented that mouseUp method and its working fine...
>
> Please let us know once it is fixed.
>
> Thanks a lot,
> Sujatha
>
|
|
|
Goto Forum:
Current Time: Fri Apr 25 20:12:09 EDT 2025
Powered by FUDForum. Page generated in 0.10024 seconds
|