You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by prophe <au...@cargosoft.ru> on 2011/09/02 14:31:33 UTC

Custom TableViewFilter

My task is create a filter in tableView. I have created a topic where I've
described requirements to this filter
http://apache-pivot-users.399431.n3.nabble.com/Filter-in-TableView-td3215369.html
And first of all, I thank all people that reply my. But now I try to write
my custom teableView filter, that I'll can use in every tableView. I take as
example Ruler component.

 
http://svn.apache.org/repos/asf/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/navigation/Ruler.java
 
http://svn.apache.org/repos/asf/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/navigation/RulerListener.java
 
http://svn.apache.org/repos/asf/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/navigation/RulerSkin.java

I've written simple GridViewFilter class that extend
org.apache.pivot.wtk.Component:

public class GridViewFilter extends Component{
	
	private TableView tableView;
	
	public GridViewFilter() {
		this(null);
	}

	public GridViewFilter(TableView tableView) {
		setTableView(tableView);
		setSkin(new GridViewFilterSkin());
	}
	
	public void setTableView(TableView tableView){
		this.tableView = tableView;
	}
	
	public TableView getTableView(){
		return tableView;
	}
}

And GridViewFilterSkin

public class GridViewFilterSkin extends ComponentSkin {
    @Override
    public void install(Component component) {
        super.install(component);
    }

    @Override
    public void layout() {
        // No-op
    }

    @Override
    public int getPreferredHeight(int width) {
		return 0;
    }

    @Override
    public int getPreferredWidth(int height) {

		return 20;
    }

    @Override
    public void paint(Graphics2D graphics) {
    	System.out.println("paint");
        int width = getWidth();
        int height = getHeight();

        graphics.setColor(new Color(0xFF, 0xFF, 0xE0));
        graphics.fillRect(0, 0, width, height);

        graphics.setColor(Color.BLACK);
        graphics.drawRect(0, 0, width - 1, height - 1);
    }
}

And write a bxml file:

<Window title="Table Views" maximized="true"
	xmlns:bxml="http://pivot.apache.org/bxml"
xmlns:collections="org.apache.pivot.collections"
	xmlns="org.apache.pivot.wtk" xmlns:content="org.apache.pivot.wtk.content"
	xmlns:grid="com.cargosoft.tutorials.wtk.grid">
	<StackPane>
		<TablePane styles="{verticalSpacing:4}">
			<columns>
				<TablePane.Column width="1*" />
			</columns>
			<TablePane.Row height="1*">
				<Border styles="{color:7}">
					<ScrollPane>
						<TableView bxml:id="tableView">
							<columns>
								<TableView.Column name="nation" width="180"
									headerData="Nation" />
								<TableView.Column name="gold" width="60"
									headerData="Gold" />
								<TableView.Column name="silver" width="60"
									headerData="Silver" />
								<TableView.Column name="bronze" width="60"
									headerData="Bronze" />
								<TableView.Column name="total" width="60"
									headerData="Total" />
							</columns>

							
							<collections:HashMap nation="China" gold="51"
								silver="21" bronze="28" total="100" />
							<collections:HashMap nation="United States"
								gold="36" silver="38" bronze="36" total="110" />
							<collections:HashMap nation="Russia" gold="23"
								silver="21" bronze="28" total="72" />
							<collections:HashMap nation="Great Britain"
								gold="19" silver="13" bronze="15" total="47" />
							<collections:HashMap nation="Germany" gold="16"
								silver="10" bronze="15" total="41" />
							<collections:HashMap nation="Australia" gold="14"
								silver="15" bronze="17" total="46" />
							<collections:HashMap nation="South Korea"
								gold="13" silver="10" bronze="8" total="31" />
							<collections:HashMap nation="Japan" gold="9"
								silver="6" bronze="11" total="26" />
							<collections:HashMap nation="Italy" gold="8"
								silver="10" bronze="10" total="28" />
							<collections:HashMap nation="France" gold="7"
								silver="16" bronze="17" total="40" />
						</TableView>

						<columnHeader>
							<TableViewHeader tableView="$tableView" />
								<TableViewHeader tableView="$tableView" />
						</columnHeader>
					</ScrollPane>
				</Border>
			</TablePane.Row>
			<TablePane.Row height="-1">
				<BoxPane styles="{spacing:0, fill:true}">
					<PushButton bxml:id="add" styles="{toolbar:true}"
						buttonData="add" />
					<grid:GridViewFilter tableView="$tableView" />
				</BoxPane>
			</TablePane.Row>
		</TablePane>
	</StackPane>
</Window>

My custom component looks like small yellow rectangle.

http://apache-pivot-users.399431.n3.nabble.com/file/n3304078/ScreenClip.png 

But when I remove PushButton from my code my custom component doesn't
render?
............................................
				<BoxPane styles="{spacing:0, fill:true}">
					<grid:GridViewFilter tableView="$tableView" />
				</BoxPane>
............................................................

http://apache-pivot-users.399431.n3.nabble.com/file/n3304078/5.png 







-----
Thank you!
--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Custom-TableViewFilter-tp3304078p3304078.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: Custom TableViewFilter

Posted by prophe <au...@cargosoft.ru>.
And when I comment this line all work's fine

//	filterBounds = gridViewFilter.getVisibleArea(filterBounds);

Is it line of code impotent?

-----
Thank you!
--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Custom-TableViewFilter-tp3304078p3322557.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: Custom TableViewFilter

Posted by prophe <au...@cargosoft.ru>.
My filter editor must look like an in cell editor (when I click on a cell -
only one editor for this cell is shown). In future I want to have a
different kind of filters. But now I try to write a custom input text
filter. It must have an appearance like on this picture:

http://apache-pivot-users.399431.n3.nabble.com/file/n3322554/table.jpg 

But I have this: 

http://apache-pivot-users.399431.n3.nabble.com/file/n3322554/teable2..png 

As you can see there is a free space between my editor an header of table
view... How can I remove this and make my filter editor looking like on the
first page?

My custom editor is GridViewFilterEditor.class... As example I user
TableViewRowEditor.class.

My code is:

public class GridViewFilterEditor extends Window implements
		GridViewFilter.FilterEditor {

	private int columnIndex = -1;

	private CardPane cardPane = new CardPane();
	private TablePane tablePane = new TablePane();
	private TablePane.Row editorRow = new TablePane.Row();

	private static final int IMAGE_CARD_INDEX = 0;


	public GridViewFilterEditor() {
		setContent(cardPane);

		cardPane.add(tablePane);
		cardPane.getCardPaneListeners().add(new CardPaneListener.Adapter() {

			@Override
			public void selectedIndexChanged(CardPane cardPane,
					int previousSelectedIndex) {
				if (previousSelectedIndex == IMAGE_CARD_INDEX) {
					editorRow.get(columnIndex).requestFocus();
				} else {
					endEdit(false);
				}
			}
		});

		tablePane.getStyles().put("horizontalSpacing", 1);
		tablePane.getRows().add(editorRow);
	}

	@Override
	public void beginEdit(GridViewFilter gridViewFilter, int columnIndex) {
		// Open the editor
		System.out.println("begin edit. Column index " + columnIndex);

		this.columnIndex = columnIndex;

		TableView tableView = gridViewFilter.getTableView();
		GridViewFilter.Filter filter =
gridViewFilter.getFilters().get(columnIndex);

		// Add/create the editor components
		TablePane.ColumnSequence tablePaneColumns = tablePane.getColumns();

		// Add a new column to the table pane to match the table view column
		TablePane.Column tablePaneColumn = new TablePane.Column();

		tablePaneColumn.setWidth(tableView.getColumnBounds(columnIndex).width);
		tablePaneColumns.add(tablePaneColumn);

		String columnName = filter.getColumnName();

		// Default to a read-only text input editor
		TextInput editorTextInput = new TextInput();
		editorTextInput.setTextKey(columnName);
		editorTextInput.setEnabled(true);
		editorTextInput.setTextBindType(BindType.LOAD);
		editorTextInput.setText(filter.getFilterData());

		// Add the editor component to the table pane
		editorRow.add(editorTextInput);

		// Get the row bounds
		Bounds filterBounds = gridViewFilter.getFilterBounds(columnIndex);

		// Scroll to make the row as visible as possible
		gridViewFilter.scrollAreaToVisible(filterBounds.x, filterBounds.y,
				filterBounds.width, filterBounds.height);

		// Constrain the bounds by what is visible through viewport ancestors
		filterBounds = gridViewFilter.getVisibleArea(filterBounds);
		Point location = gridViewFilter.mapPointToAncestor(
				tableView.getDisplay(), filterBounds.x, filterBounds.y);

		// Set size and location and match scroll left
		setPreferredWidth(filterBounds.width);
		setLocation(location.x, location.y
				+ (filterBounds.height - getPreferredHeight(-1)) / 2);
		
		// Open the editor
		open(tableView.getWindow());
	}

	@Override
	public void endEdit(boolean result) {
		// TODO Auto-generated method stub

	}

	@Override
	public boolean isEditing() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public void open(Display display, Window owner) {
		super.open(display, owner);
		// display.getContainerMouseListeners().add(displayMouseHandler);
	}

	@Override
	public void close() {
		Display display = getDisplay();
		// display.getContainerMouseListeners().remove(displayMouseHandler);
		super.close();
	}

}

When I try to do this

		System.out.println(filterBounds.x+" "+ filterBounds.y+" "+ 
				filterBounds.width+" "+  filterBounds.height);

		// Constrain the bounds by what is visible through viewport ancestors
		filterBounds = gridViewFilter.getVisibleArea(filterBounds);
		
		
		System.out.println(filterBounds.x+" "+ filterBounds.y+" "+ 
				filterBounds.width+" "+  filterBounds.height);

In console I see  

0 0 180 21
0 21 180 0

May be this line make this free space filterBounds =
gridViewFilter.getVisibleArea(filterBounds);?
And how to resolve this problem?

All my code  http://perdunov.net/pivotforum.rar here 




-----
Thank you!
--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Custom-TableViewFilter-tp3304078p3322554.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: Custom TableViewFilter

Posted by prophe <au...@cargosoft.ru>.
Oh, yes it resolve my problem... Before line
filterRenderer.paint(rendererGraphics); I've added
filterRenderer.setSize(columnWidth, height);

Thank you!

-----
Thank you!
--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Custom-TableViewFilter-tp3304078p3319660.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: Custom TableViewFilter

Posted by Greg Brown <gk...@verizon.net>.
It doesn't look like you are calling setSize() on your renderer anywhere. You'll probably want to do this. You'll probably also want to make sure that your renderer overrides setSize() to call validate(). See the renderers in org.apache.pivot.wtk.content for an example.

On Sep 8, 2011, at 8:40 AM, prophe wrote:

> I have another error while creating custom filter. I try to write my own skin
> and filter renderer for table filter. As example of code I use
> TerraTableViewSkin.class, TableViewCellRenderer.class and TableView.class. I
> need to render default text in my filter when it isn't applied... like this:
> http://apache-pivot-users.399431.n3.nabble.com/file/n3319533/te.png 
> 
> But I have an error in my custom class GridViewFilterSkin.class in this
> lines:
> 
> 		// render filter data
> 		for (int columnIndex = 0, columnCount = columns.getLength(); columnIndex <
> columnCount; columnIndex++) {
> 			TableView.Column column = columns.get(columnIndex);
> 			Object rowData = tableData.get(0);
> 			
> 			for (int filterIndex = 0, filterCount = filters.getLength(); filterIndex
> < filterCount; filterIndex++) {
> 				Filter filter = filters.get(filterIndex);
> 				if (filter.getColumnName().equals(column.getName())) {
> 					_filter = filter;
> 					break;
> 				}
> 			}
> 			
> 			GridViewFilter.FilterRenderer filterRenderer =
> _filter.getFilterRenderer();
> 			
> 			int columnWidth = columnWidths.get(columnIndex);
> 			
> 			Graphics2D rendererGraphics = (Graphics2D) graphics.create(columnX,
> 					0, columnWidth, height);
> 			
> 			filterRenderer.render(_filter, columnIndex, tableView);
> 			
> 			filterRenderer.paint(rendererGraphics);
> 
> 			rendererGraphics.dispose();
> 
> 			columnX += columnWidth + 1;
> 		}
> 
> in method paint(Graphics2D graphics) in line
> filterRenderer.paint(rendererGraphics); and my error is:
> 
> Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
> 	at org.apache.pivot.wtk.skin.LabelSkin.paint(LabelSkin.java:295)
> 	at org.apache.pivot.wtk.Component.paint(Component.java:2060)
> 	at com.custom.skin.GridViewFilterSkin.paint(GridViewFilterSkin.java:192)
> 	at org.apache.pivot.wtk.Component.paint(Component.java:2060)
> 	at org.apache.pivot.wtk.Container.paint(Container.java:410)
> 	at org.apache.pivot.wtk.Container.paint(Container.java:410)
> 	at org.apache.pivot.wtk.Container.paint(Container.java:410)
> 	at org.apache.pivot.wtk.Container.paint(Container.java:410)
> 	at org.apache.pivot.wtk.Container.paint(Container.java:410)
> 	at org.apache.pivot.wtk.Container.paint(Container.java:410)
> 	at
> org.apache.pivot.wtk.ApplicationContext$DisplayHost.paintDisplay(ApplicationContext.java:564)
> 	at
> org.apache.pivot.wtk.ApplicationContext$DisplayHost.paintVolatileBuffered(ApplicationContext.java:530)
> 	at
> org.apache.pivot.wtk.ApplicationContext$DisplayHost.paint(ApplicationContext.java:434)
> 	at java.awt.GraphicsCallback$PaintCallback.run(Unknown Source)
> 	at sun.awt.SunGraphicsCallback.runOneComponent(Unknown Source)
> 	at sun.awt.SunGraphicsCallback.runComponents(Unknown Source)
> 	at java.awt.Container.paint(Unknown Source)
> 	at java.awt.Window.paint(Unknown Source)
> 	at sun.awt.RepaintArea.paintComponent(Unknown Source)
> 	at sun.awt.RepaintArea.paint(Unknown Source)
> 	at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
> 	at sun.awt.windows.WWindowPeer.handleEvent(Unknown Source)
> 	at java.awt.Component.dispatchEventImpl(Unknown Source)
> 	at java.awt.Container.dispatchEventImpl(Unknown Source)
> 	at java.awt.Window.dispatchEventImpl(Unknown Source)
> 	at java.awt.Component.dispatchEvent(Unknown Source)
> 	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
> 	at java.awt.EventQueue.access$000(Unknown Source)
> 	at java.awt.EventQueue$1.run(Unknown Source)
> 	at java.awt.EventQueue$1.run(Unknown Source)
> 	at java.security.AccessController.doPrivileged(Native Method)
> 	at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown
> Source)
> 	at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown
> Source)
> 	at java.awt.EventQueue$2.run(Unknown Source)
> 	at java.awt.EventQueue$2.run(Unknown Source)
> 	at java.security.AccessController.doPrivileged(Native Method)
> 	at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown
> Source)
> 	at java.awt.EventQueue.dispatchEvent(Unknown Source)
> 	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
> 	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
> 	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
> 	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
> 	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
> 	at java.awt.EventDispatchThread.run(Unknown Source)
> 
> All my code to test you can find  http://perdunov.net/pivotforum.rar here 
> 
> if you comment line filterRenderer.paint(rendererGraphics); - you can see
> my table rendered.
> 
> -----
> Thank you!
> --
> View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Custom-TableViewFilter-tp3304078p3319533.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.


Re: Custom TableViewFilter

Posted by prophe <au...@cargosoft.ru>.
I have another error while creating custom filter. I try to write my own skin
and filter renderer for table filter. As example of code I use
TerraTableViewSkin.class, TableViewCellRenderer.class and TableView.class. I
need to render default text in my filter when it isn't applied... like this:
http://apache-pivot-users.399431.n3.nabble.com/file/n3319533/te.png 

But I have an error in my custom class GridViewFilterSkin.class in this
lines:

		// render filter data
		for (int columnIndex = 0, columnCount = columns.getLength(); columnIndex <
columnCount; columnIndex++) {
			TableView.Column column = columns.get(columnIndex);
			Object rowData = tableData.get(0);
			
			for (int filterIndex = 0, filterCount = filters.getLength(); filterIndex
< filterCount; filterIndex++) {
				Filter filter = filters.get(filterIndex);
				if (filter.getColumnName().equals(column.getName())) {
					_filter = filter;
					break;
				}
			}
			
			GridViewFilter.FilterRenderer filterRenderer =
_filter.getFilterRenderer();
			
			int columnWidth = columnWidths.get(columnIndex);
			
			Graphics2D rendererGraphics = (Graphics2D) graphics.create(columnX,
					0, columnWidth, height);
			
			filterRenderer.render(_filter, columnIndex, tableView);
			
			filterRenderer.paint(rendererGraphics);

			rendererGraphics.dispose();

			columnX += columnWidth + 1;
		}

in method paint(Graphics2D graphics) in line
filterRenderer.paint(rendererGraphics); and my error is:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
	at org.apache.pivot.wtk.skin.LabelSkin.paint(LabelSkin.java:295)
	at org.apache.pivot.wtk.Component.paint(Component.java:2060)
	at com.custom.skin.GridViewFilterSkin.paint(GridViewFilterSkin.java:192)
	at org.apache.pivot.wtk.Component.paint(Component.java:2060)
	at org.apache.pivot.wtk.Container.paint(Container.java:410)
	at org.apache.pivot.wtk.Container.paint(Container.java:410)
	at org.apache.pivot.wtk.Container.paint(Container.java:410)
	at org.apache.pivot.wtk.Container.paint(Container.java:410)
	at org.apache.pivot.wtk.Container.paint(Container.java:410)
	at org.apache.pivot.wtk.Container.paint(Container.java:410)
	at
org.apache.pivot.wtk.ApplicationContext$DisplayHost.paintDisplay(ApplicationContext.java:564)
	at
org.apache.pivot.wtk.ApplicationContext$DisplayHost.paintVolatileBuffered(ApplicationContext.java:530)
	at
org.apache.pivot.wtk.ApplicationContext$DisplayHost.paint(ApplicationContext.java:434)
	at java.awt.GraphicsCallback$PaintCallback.run(Unknown Source)
	at sun.awt.SunGraphicsCallback.runOneComponent(Unknown Source)
	at sun.awt.SunGraphicsCallback.runComponents(Unknown Source)
	at java.awt.Container.paint(Unknown Source)
	at java.awt.Window.paint(Unknown Source)
	at sun.awt.RepaintArea.paintComponent(Unknown Source)
	at sun.awt.RepaintArea.paint(Unknown Source)
	at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
	at sun.awt.windows.WWindowPeer.handleEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Window.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
	at java.awt.EventQueue.access$000(Unknown Source)
	at java.awt.EventQueue$1.run(Unknown Source)
	at java.awt.EventQueue$1.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown
Source)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown
Source)
	at java.awt.EventQueue$2.run(Unknown Source)
	at java.awt.EventQueue$2.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown
Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)

All my code to test you can find  http://perdunov.net/pivotforum.rar here 

 if you comment line filterRenderer.paint(rendererGraphics); - you can see
my table rendered.

-----
Thank you!
--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Custom-TableViewFilter-tp3304078p3319533.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: Custom TableViewFilter

Posted by prophe <au...@cargosoft.ru>.
Oh, thank you! It was so simple=))) And now my task - to do filter looking
like table row but having all functionality of filter. All my problems and
questions I'll post here!

-----
Thank you!
--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Custom-TableViewFilter-tp3304078p3316455.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: Custom TableViewFilter

Posted by Chris Bartlett <cb...@gmail.com>.
It is due to the preferred height.

Change your NotWork.bxml file from this
<filter:GridViewFilter/>
to this
<filter:GridViewFilter preferredHeight="20"/>
and you will see the GridViewFilter

Change the start of your
com.custom.skin.GridViewFilterSkin.paint(Graphics2D) method to show
the width and height that are used when painting
    @Override
    public void paint(Graphics2D graphics) {
        int width = getWidth();
        int height = getHeight();
        System.out.println(String.format("paint [%d,%d]", width, height));
        ...
    }

You will see that it has a height of 0, so you will not see anything
painted to the screen.

Have a look at the source for TerraTableViewHeaderSkin and how it sets
its preferredWidth & preferredHeight
http://svn.apache.org/repos/asf/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTableViewHeaderSkin.java


I have attached a modified version of your BXML file to show that the
GridViewFilter will be shown when it has been given a non-zero height.
 (Look in the <columnHeader> element)

Chris

On 7 September 2011 17:50, Chris Bartlett <cb...@gmail.com> wrote:
> OK, I will have a look and get back to you.
>
> On 7 September 2011 17:42, prophe <au...@cargosoft.ru> wrote:
>> Ok, thank you for your reply.
>>
>> I use pivot eclipse plugin. In archive you'll find code of my custom
>> component ant 2 bxml with working and not working example. I run my
>> application with this two bxml files like a pivot script.
>>
>> Here is my code:
>>
>> http://perdunov.net/pivotforum.rar my code
>>
>> -----
>> Thank you!
>> --
>> View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Custom-TableViewFilter-tp3304078p3316281.html
>> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
>>
>

Re: Custom TableViewFilter

Posted by Chris Bartlett <cb...@gmail.com>.
OK, I will have a look and get back to you.

On 7 September 2011 17:42, prophe <au...@cargosoft.ru> wrote:
> Ok, thank you for your reply.
>
> I use pivot eclipse plugin. In archive you'll find code of my custom
> component ant 2 bxml with working and not working example. I run my
> application with this two bxml files like a pivot script.
>
> Here is my code:
>
> http://perdunov.net/pivotforum.rar my code
>
> -----
> Thank you!
> --
> View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Custom-TableViewFilter-tp3304078p3316281.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
>

Re: Custom TableViewFilter

Posted by prophe <au...@cargosoft.ru>.
Ok, thank you for your reply. 

I use pivot eclipse plugin. In archive you'll find code of my custom
component ant 2 bxml with working and not working example. I run my
application with this two bxml files like a pivot script.

Here is my code:

http://perdunov.net/pivotforum.rar my code 

-----
Thank you!
--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Custom-TableViewFilter-tp3304078p3316281.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: Custom TableViewFilter

Posted by Chris Bartlett <cb...@gmail.com>.
As Greg mentioned, it would be much easier for us to look into if you
put all of your code into a zip file and attach it.  Then we can
download and run it locally to see what is going on.

Please keep the example code simple, and just include your custom
component and the things required to show the problem.


Are you sure that the GridViewFilter has a height that is > 0?
In your first email you have this method which returns a preferred height of 0
   @Override
   public int getPreferredHeight(int width) {
               return 0;
   }

Place an extra debugging statement to show the actual size of the
GridViewFilter when it is painted.
  @Override
   public void paint(Graphics2D graphics) {
       System.out.println("paint");
       int width = getWidth();
       int height = getHeight();
       ...
       <print the width and height here>
    }


On 7 September 2011 16:52, prophe <au...@cargosoft.ru> wrote:
> Ok, I've tried this code:
>
> <Window title="Table Views" maximized="true"
>        xmlns:bxml="http://pivot.apache.org/bxml"
> xmlns:collections="org.apache.pivot.collections"
>        xmlns="org.apache.pivot.wtk" xmlns:content="org.apache.pivot.wtk.content"
>        xmlns:grid="com.cargosoft.tutorials.wtk.grid">
>        <StackPane>
>                <BoxPane styles="{spacing:0, fill:true}">
>                        <grid:GridViewFilter />
>                </BoxPane>
>        </StackPane>
> </Window>
>
> and I see my custom component rendered
>
> http://apache-pivot-users.399431.n3.nabble.com/file/n3316194/t.png
>
> But I want to display this custom component in the header of table, but I
> can't... It doesn't display... I want to display my component something like
> this (look inside columnHeader tag):
>
> <Window title="Table Views" maximized="true"
>        xmlns:bxml="http://pivot.apache.org/bxml"
> xmlns:collections="org.apache.pivot.collections"
>        xmlns="org.apache.pivot.wtk" xmlns:content="org.apache.pivot.wtk.content"
>        xmlns:grid="com.cargosoft.tutorials.wtk.grid">
>        <StackPane>
>                <Border styles="{color:7}">
>                        <ScrollPane>
>                                <TableView bxml:id="tableView">
>                                        <columns>
>                                                <TableView.Column name="nation" width="180"
>                                                        headerData="Nation" />
>                                                <TableView.Column name="gold" width="60"
>                                                        headerData="Gold" />
>                                                <TableView.Column name="silver" width="60"
>                                                        headerData="Silver" />
>                                                <TableView.Column name="bronze" width="60"
>                                                        headerData="Bronze" />
>                                                <TableView.Column name="total" width="60"
>                                                        headerData="Total" />
>                                        </columns>
>
>
>                                        <collections:HashMap nation="China" gold="51"
>                                                silver="21" bronze="28" total="100" />
>                                        <collections:HashMap nation="United States"
>                                                gold="36" silver="38" bronze="36" total="110" />
>
>                                </TableView>
>
>                                <columnHeader>
>                                        <BoxPane orientation="vertical" styles="{fill:true}">
>                                                <TableViewHeader tableView="$tableView" />
>                                                <grid:GridViewFilter />
>                                        </BoxPane>
>                                </columnHeader>
>                        </ScrollPane>
>                </Border>
>        </StackPane>
>
> But I see only this (and no my custom component in the header):
>
> http://apache-pivot-users.399431.n3.nabble.com/file/n3316194/te.png
>
> Why pivot doesn't render my custom component? Code off component you can
> find above at the first message...
>
> -----
> Thank you!
> --
> View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Custom-TableViewFilter-tp3304078p3316194.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
>

Re: Custom TableViewFilter

Posted by prophe <au...@cargosoft.ru>.
Ok, I've tried this code:

<Window title="Table Views" maximized="true"
	xmlns:bxml="http://pivot.apache.org/bxml"
xmlns:collections="org.apache.pivot.collections"
	xmlns="org.apache.pivot.wtk" xmlns:content="org.apache.pivot.wtk.content"
	xmlns:grid="com.cargosoft.tutorials.wtk.grid">
	<StackPane>
		<BoxPane styles="{spacing:0, fill:true}">
			<grid:GridViewFilter />
		</BoxPane>
	</StackPane>
</Window>

and I see my custom component rendered

http://apache-pivot-users.399431.n3.nabble.com/file/n3316194/t.png 

But I want to display this custom component in the header of table, but I
can't... It doesn't display... I want to display my component something like
this (look inside columnHeader tag):

<Window title="Table Views" maximized="true"
	xmlns:bxml="http://pivot.apache.org/bxml"
xmlns:collections="org.apache.pivot.collections"
	xmlns="org.apache.pivot.wtk" xmlns:content="org.apache.pivot.wtk.content"
	xmlns:grid="com.cargosoft.tutorials.wtk.grid">
	<StackPane>
		<Border styles="{color:7}">
			<ScrollPane>
				<TableView bxml:id="tableView">
					<columns>
						<TableView.Column name="nation" width="180"
							headerData="Nation" />
						<TableView.Column name="gold" width="60"
							headerData="Gold" />
						<TableView.Column name="silver" width="60"
							headerData="Silver" />
						<TableView.Column name="bronze" width="60"
							headerData="Bronze" />
						<TableView.Column name="total" width="60"
							headerData="Total" />
					</columns>

					
					<collections:HashMap nation="China" gold="51"
						silver="21" bronze="28" total="100" />
					<collections:HashMap nation="United States"
						gold="36" silver="38" bronze="36" total="110" />
						
				</TableView>

				<columnHeader>
					<BoxPane orientation="vertical" styles="{fill:true}">
						<TableViewHeader tableView="$tableView" />
						<grid:GridViewFilter />
					</BoxPane>
				</columnHeader>
			</ScrollPane>
		</Border>
	</StackPane>

But I see only this (and no my custom component in the header):

http://apache-pivot-users.399431.n3.nabble.com/file/n3316194/te.png 

Why pivot doesn't render my custom component? Code off component you can
find above at the first message...

-----
Thank you!
--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Custom-TableViewFilter-tp3304078p3316194.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: Custom TableViewFilter

Posted by Greg Brown <gk...@verizon.net>.
Can you provide a smaller, self-contained test app that demonstrates the problem? Please include your custom component if you can.

On Sep 5, 2011, at 4:06 AM, prophe wrote:

> Anybody know what is the problem?
> 
> -----
> Thank you!
> --
> View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Custom-TableViewFilter-tp3304078p3310242.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.


Re: Custom TableViewFilter

Posted by prophe <au...@cargosoft.ru>.
Anybody know what is the problem?

-----
Thank you!
--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Custom-TableViewFilter-tp3304078p3310242.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.