Home » Eclipse Projects » Nebula » Gallery Item Selection
Gallery Item Selection [message #30393] |
Thu, 01 March 2007 06: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 07:44 |
Nicolas Richeton Messages: 179 Registered: July 2009 |
Senior Member |
|
|
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 #30464 is a reply to message #30428] |
Thu, 01 March 2007 09:06 |
Eclipse User |
|
|
|
Originally posted by: swetha.yahoo.co.in
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 #30534 is a reply to message #30499] |
Thu, 01 March 2007 09:45 |
Eclipse User |
|
|
|
Originally posted by: swetha.yahoo.co.in
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 #30568 is a reply to message #30534] |
Thu, 01 March 2007 10:12 |
Nicolas Richeton Messages: 179 Registered: July 2009 |
Senior Member |
|
|
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 #30603 is a reply to message #30568] |
Thu, 01 March 2007 11:13 |
Eclipse User |
|
|
|
Originally posted by: swetha.atc.tcs.co.in
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 #30638 is a reply to message #30603] |
Thu, 01 March 2007 12:53 |
Nicolas Richeton Messages: 179 Registered: July 2009 |
Senior Member |
|
|
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 #30672 is a reply to message #30638] |
Thu, 01 March 2007 13:03 |
Eclipse User |
|
|
|
Originally posted by: swetha.yahoo.co.in
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 07:44 |
Nicolas Richeton Messages: 179 Registered: July 2009 |
Senior Member |
|
|
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 #579389 is a reply to message #30534] |
Thu, 01 March 2007 10:12 |
Nicolas Richeton Messages: 179 Registered: July 2009 |
Senior Member |
|
|
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 #579428 is a reply to message #30603] |
Thu, 01 March 2007 12:53 |
Nicolas Richeton Messages: 179 Registered: July 2009 |
Senior Member |
|
|
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
>
|
|
| | |
Goto Forum:
Current Time: Thu Sep 26 11:49:11 GMT 2024
Powered by FUDForum. Page generated in 0.05380 seconds
|