Drag & Drop of Items

SWT Designer allows you to create the views, editors, perspectives, pref pages, composites, etc. that comprise Eclipse SWT & RCP applications and plug-ins.

Moderators: Konstantin.Scheglov, gnebling, Alexander.Mitin, jwren, Eric Clayberg

Drag & Drop of Items

Postby illvoid » Fri Sep 03, 2010 5:12 pm

Hi,

I have an own control which paints a grid, the control is derived from Canvas-class. This widget can be used in SWT-designer without problems. The widgets displays columns, a column is derived from Item. The problem: A column cannot be dragged onto my inctance of the grid in the designer just like a TableColumn for example. It has the following constructors:

Code: Select all
   public MyGridColumn(MyGrid grid, int style) {
      super(myGrid, style);
      setIndex(grid.getColumnsCount());
   }

   public MyGridColumn(MyGrid grid, int style, int index) {
      super(myGrid, style, index);      
                setIndex(index);
   }


But I just can't get the drag n drop featur for that columns. It works for widgets like the SWT-table or for the Nebula-grid. What do I have to implement to get this working for a control that is owner-drawn?

Thanks and bye,
Illvoid
illvoid
 
Posts: 11
Joined: Fri Sep 03, 2010 5:05 pm

Re: Drag & Drop of Items

Postby illvoid » Fri Sep 03, 2010 5:25 pm

Could it be that this drag n drop of columns in SWT-designer only works for Nebula-Grid and SWT-Table/Tree because it is implemented in the SWT-designer?

Bye and kind regards

Illvoid
illvoid
 
Posts: 11
Joined: Fri Sep 03, 2010 5:05 pm

Re: Drag & Drop of Items

Postby illvoid » Sat Sep 04, 2010 12:42 am

What I want to know is: Is the drag'n drop of Columns in SWT-Designer (like TreeCOlumn, TableColumn...) a built-functionality in SWT-designer for these classes or can I achieve the same functionality with my own Grid (MyGrid derived from Canvas) and MyGridColumn (derived from Item) too?

Thanks
Matthias
illvoid
 
Posts: 11
Joined: Fri Sep 03, 2010 5:05 pm

Re: Drag & Drop of Items

Postby Eric Clayberg » Sat Sep 04, 2010 5:55 am

This is definitely built-in behavior as it goes well beyond anything supported in the standard JavaBean spec.

You should start be reviewing the product docs and reading the New Component Tutorial and Customization API.

In its *wbp-component.xml file, SWT Table widgets are described as "flow containers" that accept TableColumns.

See the attached description file for Table.

Table.wbp-component.xml
(3.23 KiB) Downloaded 18 times

Also, please be aware that if you post a question late on a Friday night, it might not get answered until sometime over the weekend or even the following Monday.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

Re: Drag & Drop of Items

Postby illvoid » Sat Sep 04, 2010 8:32 am

Hello Eric,

thanks a lot for your answer. I read the documents but I am not quite sure how to do what I want, I try to explain:

When I add my grid to the SWT-designer this works really good, now I want to add MyColumn-class as visible column to my grid via Drop'n Drop. Is there a way to achieve this by adding *wbp-component.xml-file like for Table-widget? Do I have to add this xml-file and anotations to my libary and the SWT-designer will parse this?

Thank you and kind regards,

Matthias
illvoid
 
Posts: 11
Joined: Fri Sep 03, 2010 5:05 pm

Re: Drag & Drop of Items

Postby illvoid » Sat Sep 04, 2010 9:20 am

I tried to add this xml-file as MyGrid.xml to a folder names wbp-meta in my project (plugin) where I use my grid:

<?xml version="1.0" encoding="UTF-8"?>
<component xmlns="http://www.instantiations.com/D2/WBPComponent">

<description></description>
<!-- CREATION -->
<creation>
</creation>
<!-- CONSTRUCTORS -->
<constructors>
<constructor>
</constructor>
</constructors>
<!-- METHODS -->
<methods>

</methods>

<!-- PARAMETERS -->
<parameters>
<parameter name="layout.has">false</parameter>
<parameter name="gridLayout.grabHorizontal">true</parameter>
<parameter name="gridLayout.grabVertical">true</parameter>

<!-- flow container: MyColumn -->
<parameter name="flowContainer.1">true</parameter>
<parameter name="flowContainer.1.horizontal">true</parameter>
<parameter name="flowContainer.1.component">com.mynamespace.MyGridColumn</parameter>

</parameters>
</component>

But this has no effect.

Matthias
illvoid
 
Posts: 11
Joined: Fri Sep 03, 2010 5:05 pm

Re: Drag & Drop of Items - solved

Postby illvoid » Sat Sep 04, 2010 9:36 am

Hi Eric,

thanks again, here is file which I added to my grid-project:

<?xml version="1.0" encoding="UTF-8"?>
<component xmlns="http://www.instantiations.com/D2/WBPComponent">

<description>My description...</description>

<!-- PARAMETERS -->
<parameters>
<parameter name="layout.has">false</parameter>
<parameter name="gridLayout.grabHorizontal">true</parameter>
<parameter name="gridLayout.grabVertical">true</parameter>

<!-- flow container: TreeListColumn -->
<parameter name="flowContainer.1">true</parameter>
<parameter name="flowContainer.1.horizontal">true</parameter>
<parameter name="flowContainer.1.component">com.mynamespace.MyColumn</parameter>

</parameters>
</component>

Thanks for your help!

Matthias
illvoid
 
Posts: 11
Joined: Fri Sep 03, 2010 5:05 pm

Re: Drag & Drop of Items

Postby Eric Clayberg » Sat Sep 04, 2010 10:46 am

The file name should be MyGrid.wbp-component.xml and it should be located either in the same directory as your components or in a exactly parallel directory within a /wbp-meta directory in your project.

If you plan to package a custom jar, putting in the same directory as the component itself might be easiest.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

Re: Drag & Drop of Items

Postby illvoid » Sat Sep 04, 2010 12:35 pm

Thanks Eric, I did so and it works like a charm. Another question I have:

I want to achieve 3 things:

1. Select a column in the designer when added to the grid

2. Resize the selected column in the designer

3. Display images for my components in the palette. Could you help me with these issues.

Thanks a lot,

Matthias
illvoid
 
Posts: 11
Joined: Fri Sep 03, 2010 5:05 pm

Re: Drag & Drop of Items

Postby Eric Clayberg » Sat Sep 04, 2010 1:17 pm

illvoid wrote:1. Select a column in the designer when added to the grid
2. Resize the selected column in the designer

Doing this graphically in the design view is handled by special support code in SWT Designer itself. We don't have a published, public API for that (yet).

For a custom component, you can only select and reorder custom columns in the component tree view. Resizing would have to be done via the properties view.

illvoid wrote:3. Display images for my components in the palette. Could you help me with these issues.

All you you need is a .gif or .png image file with the same name as your component class (e.g., MyGrid.png).

Put that file in the same directory as your component or in the parallel /wbp-meta directory.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

Re: Drag & Drop of Items

Postby illvoid » Sun Sep 05, 2010 11:09 am

Hello Eric,

thank you, this works great. I have 2 more questions that I am not able to solve:

1. How can I define a category and some components for the palette as XML-file in my product (plugin)?
I tried to add a file names Mygrid.wbp-palette.xml and add it to a folder named wbp-meta. The file has this content:

Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<palette>
    <category id="id_mygrid_24434" name="MyGrid" description="MyGrid description..." open="true">
        <component class="com.mynamespace.MyGrid"/>
    </category>
</palette>

When I open the designer, the categroy is not added.

2. I have an advances property in MyGrid which I want to be visible as normal property. So I added this to the component.xml file:
<properties-normal names="myproperty"/>

But the property is only visible when I display the advanced-properties.

Thanks and kind regards,
Matthias
illvoid
 
Posts: 11
Joined: Fri Sep 03, 2010 5:05 pm

Re: Drag & Drop of Items

Postby Eric Clayberg » Mon Sep 06, 2010 5:40 pm

1. The palette should be defined in a file named {toolkitID}.wbp-palette.xml. In the case of RCP, it should be in a file named com.instantiations.designer.rcp.wbp-palette.xml.

2. A property remains "advanced" if it is a non-standard "object" property. Only standard property types are considered "normal".
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

Re: Drag & Drop of Items

Postby illvoid » Wed Sep 08, 2010 6:21 am

This works great, thank you.
illvoid
 
Posts: 11
Joined: Fri Sep 03, 2010 5:05 pm

Re: Drag & Drop of Items

Postby Eric Clayberg » Wed Sep 08, 2010 6:41 am

Glad that worked for you.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA


Return to SWT Designer

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest

cron