Tabris UI Controls Demo Indication error on IPad and IPhone - eclipse-rap

I'm validating the Tabris framework at the moment and stumbled about a few indication errors when I tried the UI Control Code Snippets.
I added the VisualGuideDemo.java to my HelloWorld-Project and added a table to the display with the createTable function. In my browser it is displaying the expected output with 3 columns and 128 rows. When I test the application on an IPad mini or the IPhone Simulator ...
only the first Column is displayed,
it is not possible to scroll through the whole list (i can scroll about 60 items down, then the list "jumps" back)
and the width of the table does not adjust to the fullwidth of the screen.
See attached Screenshots
I also tried to add a TabFolder which uses the full width of the screen. I used the 'createTabFolder' method:
private void createTabFolder() {
final Shell shell = new Shell( display, SWT.NONE );
shell.setLayout( new FillLayout() );
final TabFolder tabFolder = new TabFolder( shell, SWT.NONE );
final TabItem tab0 = new TabItem( tabFolder, SWT.NONE );
tab0.setText( "Tab0" );
final TabItem tab1 = new TabItem( tabFolder, SWT.NONE );
tab1.setText( "Tab1" );
final TabItem tab2 = new TabItem( tabFolder, SWT.NONE );
tab2.setText( "Tab2" );
//shell.setSize( 300, 100 );
shell.open();
}
I uncommented the setSize function, but the TabFolder does not adjust to the full width of the screen (not in browser or on iOS device).
I'm new to SWT, RAP/Tabris so I am wondering if I miss something basic.
EDIT:
I guess several columns in one table are not supported in the mobile clients, but maybe it would be a nice feature to add the missing columns to the end of the list, seperated by listdividers. Is my assumption correct?

I found the solution to the width problem, I just had to call shell.setMaximized(true);

Related

How to draw timelines in a tree table

I am writing an analyzer to visually see where my application is spending time. The interface that I am trying to achieve (see below) is something similar to a tree table with
lines or boxes to denote response time.
be a collapsible tree like graph
the ability to display metrics in the table columns (e.g., start time, cost, etc)
the ability to display the labels or description and metrics on the left and lines on the right
I create the following diagram (see below) in R -- unfortunately, although the graph production is automated, the approach is not interactive. I was wondering if you could suggest a better way -- maybe a tree table. I looked at many Swing, JavaFx tree table examples. I have not seen an example that has lines (time lines) in a tree table.
Any suggestions would be greatly appreciated. Thanks in advance.
You can show any node in a TreeTableCell using the grahic property in javaFX. This includes Rectangles.
This is a simple example of showing bars in a column using Rectangles:
// Arrays in TreeItems contain {startValue, endValue} (both positive)
TreeItem<int[]> root = new TreeItem<>(new int[]{0, 10});
root.getChildren().addAll(new TreeItem<>(new int[]{0, 5}), new TreeItem<>(new int[]{5, 10}));
TreeTableView<int[]> ttv = new TreeTableView<>(root);
// Column displaying bars based on data of TreeItem. Do not use this as
// the first column, otherwise the alignment be off depending on the
// distance to the root.
TreeTableColumn<int[], int[]> column = new TreeTableColumn<>();
column.setCellValueFactory(c -> c.getValue().valueProperty());
final double BAR_SIZE = 20;
column.setCellFactory((t) -> new TreeTableCell<int[], int[]>() {
// the bar
private final Rectangle rectangle = new Rectangle(0, 10);
{
setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
// bar invisible by default
rectangle.setVisible(false);
setGraphic(rectangle);
}
#Override
protected void updateItem(int[] item, boolean empty) {
super.updateItem(item, empty);
if (!empty && item != null) {
// resize and display bar, it item is present
rectangle.setWidth((item[1] - item[0]) * BAR_SIZE);
rectangle.setTranslateX(item[0] * BAR_SIZE);
rectangle.setVisible(true);
} else {
// no item -> hide bar
rectangle.setVisible(false);
}
}
});
// add a columns new column
// add a additional empty column at the start to prevent bars being
// aligned based on distance to the root
ttv.getColumns().addAll(new TreeTableColumn<>(), column);
Things you need to do
use a data type different to int[]; the cell value factory and TreeTableCell needs to be adjusted accordingly; an example of a more complex model can be found e.g. in the oracle tutorial: https://docs.oracle.com/javase/8/javafx/user-interface-tutorial/tree-table-view.htm
Choose better colors; These colors could e.g. be stored in a Map and created if a new one is needed.
add additional colums

Why is it impossible to move a chrome (webkit) browser full screen window programmatically?

I made a program in Delphi to move windows to another screen/monitor reserving the state, size (if possible) and center the window on the screen if not fullscreen. Especially for borderless windows this is very useful because the easy window hotkeys of Windows do not work properly.
The function is a part of a software suite. I have tested this with fullscreen YouTube videos and works perfectly with mozilla, IE but not with Chrome and Opera (webkit), the window won't move.
Two questions:
What's the reason the window won't move?
Can I move it with a trick or is trying to a waste of time?
EDIT:
Found out that the chrome window doesn't respond to any message send to this window, for example, restoring, minimize and maximize the window doesn't do anything (tried also other things). Maybe there is something in the code of chrome that avoids it. Maybe someone can confirm this?
Some code (using Windows API func moveWindow() ):
var
AHandle : Hwnd;
brCurrent : TBounds; // TBounds = TRect + width and height
iCurrDispNum : LongInt;
iNextDispNum : LongInt;
brNext : TBounds;
begin
........
AHandle:=getForeGroundWindow();
brCurrent:=getWindowBoundsRect( AHandle );
iCurrDispNum:=getDisplayNumFromBoundsRect( brCurrent );
iNextDispNum:=getNextDisplayNum( iCurrDispNum )
brNext:=getBoundsRectOnDisplay( iNextDispNum, brCurrent.width, brCurrent.height, alNone, TRUE );
.......
// Finally, move the window with WINAPI function, this does not work for chrome and opera fullscreen window, all other window work ok.
moveWindow( AHandle, brNext.left, brNext.top, brNext.width, brNext.height, TRUE );
// Find out if window is moved to other screen
if( getDisplayNumFromBoundsRect( getWindowBoundsRect( AHandle )) <> iNextDispNum ) then
begin
// Error, window not moved
end;
You can try it yourself with this piece of code:
Put a TTimer on a form and paste code below. What does it do? It checks if the foreground window is a chrome window and moves the window 20px to the left. When you maximize a YouTube video in chrome, the window won't move but moveWindow returns TRUE. Relying on the result of moveWindow is useless. NOTICE: This is just a quick example, not a brilliant piece of code.
function getWindowClassName( AHandle : hWnd ) : string;
begin
SetLength( Result, MAX_PATH );
SetLength( Result, getClassName( AHandle, PChar( Result ), length(Result)));
end;
// Code in a TTimer proc
procedure TForm1.Timer1Timer(Sender: TObject);
var
h : Hwnd;
r : TRect;
begin
h:=getForeGroundWindow();
writeln( getClassName( h ) );
if( h > 0 ) and ( getClassName( h ) = 'Chrome_WidgetWin_1' ) and ( getWindowRect( h, r )) then
begin
inc( r.left, 20 );
writeln( moveWindow( h, r.left, r.top, r.right-r.left+20, r.bottom-r.top, TRUE ) );
end;
end;
PS: You need to turn on "Generate Console Application" at the Project Options to avoid writeln I/O errors.
////////////////////
The properties of the chrome fullscreen window obtained with MS SPY doesn't show something weird is going on:

Masked images not displaying in AS3

I am trying to mask an image on another so that I only view the specific portion of the unmasked image through the masked one. My problem is that I cannot see anything on the screen.. no Image, no effect at all
cardMask = new Image(Root.assets.getTexture("card_mask"));
cardMask.y = Constants.STAGE_HEIGHT*0.40;
cardMask.x = Constants.STAGE_WIDTH *0.48;
trace("it's add mask");
cardLight = new Image(Root.assets.getTexture("card_light_mask"));
cardLight.y = Constants.STAGE_HEIGHT*0.46;
cardLight.x = Constants.STAGE_WIDTH *0.48;
cardLight.mask=cardMask;
maskedDisplayObject = new PixelMaskDisplayObject(-1,false);
maskedDisplayObject.addChild(cardLight);
maskedDisplayObject.x=cardLight.x;
maskedDisplayObject.y=cardLight.y;
maskedDisplayObject.mask=cardMask;
maskedDisplayObject.blendMode = BlendMode.SCREEN;
addChild(maskedDisplayObject);
First, for masking an object the mask object should also be added to the display list. Your code does not add cardMask to display list anywhere. Second, if your maskedDisplayObject should be visible at all times, the mask should be assigned not to it, but to some other object which displayed part you desire to control. And third, it is also possible that this.stage is null, therefore the entire tree (this -> maskedDisplayObject -> cardLight) is plain not rendered. You need to check all three of these conditions to get something displayed.
Also, if you desire cardLight as an object to move independently of maskedDisplayObject, you should add it to this instead, and check that it's displayed on top of maskedDisplayObject (call addChild(cardLight) after addChild(maskedDisplayObject)).
This all totals to this code:
trace("Stage is null:", (this.stage==null)); // if this outputs true, you're out of display
cardMask = new Image(Root.assets.getTexture("card_mask"));
cardMask.y = Constants.STAGE_HEIGHT*0.40;
cardMask.x = Constants.STAGE_WIDTH *0.48; // mask creation unaltered
trace("it's add mask");
cardLight = new Image(Root.assets.getTexture("card_light_mask"));
cardLight.y = Constants.STAGE_HEIGHT*0.46;
cardLight.x = Constants.STAGE_WIDTH *0.48;
cardLight.mask=cardMask; // this is right
maskedDisplayObject = new PixelMaskDisplayObject(-1,false);
// maskedDisplayObject.addChild(cardLight); this is moved to main part of display list
maskedDisplayObject.x=cardLight.x;
maskedDisplayObject.y=cardLight.y;
// maskedDisplayObject.mask=cardMask; NO masking of this, you're only masking cardLight
cardLight.blendMode = BlendMode.SCREEN; // display mode is also changed
addChild(maskedDisplayObject);
addChild(cardLight);

slider zoom with selenium webDriver

I have a problem with my slider when i drag and drop it with selenium webDriver
I have no zoom and the value before and after drag and drop is the same !!
below my code
my html code
<input type="range" class="zoom-range" id="myrange" name="rmouse" min="0.25" max="2.00" step="0.01" value="1"/>
<div id="blocToZoom">
....
</div>
my selenium code:
WebElement slider = this.driver.findElement(By.id("myrange"));
System.out.println("The value of slider before dragDrop: "+slider.getAttribute("value"));
Actions move = new Actions(driver);
Action action = move.dragAndDropBy(slider, 30, 0).build();
action.perform();
System.out.println("The value of slider after dragDrop: "+slider.getAttribute("value"));
the result is the same
The value of slider before dragDrop: 1
The value of slider after dragDrop: 1
That mean the drag and drop dont work
so can someone give me solution of this problem.
i also try using this code but i have same problem
final WebElement slider = this.driver.findElement(By.id("myrange"));
System.out.println(slider.getAttribute("value"));
final Actions move = new Actions(this.driver);
final int Width = slider.getSize().getWidth();
final int Height = slider.getSize().getHeight();
final int MyX = (Width * 95) / 100;// spot to click is at 95% of the width
final int MyY = 1;// anywhere above Height/2 works
final Action actionDrag = move.dragAndDropBy(slider, MyX, MyY).build();
actionDrag.perform();
System.out.println(slider.getAttribute("value"));
PS: it works when i use Selenium 2.41.0 with firefox 30.0.1
but now i use Selenium 2.43.0 with firefox 32.0.1
maybe is that the problem !?
Thanks
i don't think a successful drag should result in changing the value. I will suggest you to change dimension (30,0) to some bigger range. Currently value shows that you are trying to drag slider on X axis,not Y axis. Plez check this as well which Axis you wish to change

Show "no rows found" inside a JTable row if not found entry while filtering

i have a JTable with row filter.
once fitered if i didn't get any row then i have to show a string like "Nothing found to display " inside table as first row.
please do needful.
Thanks ,
Narasimha
I needed to solve this exact problem today and wasn't able to find a good answer online. In the end I came up with my own solution, which I think may be exactly what you want. I don't know if this is too late for your project, but perhaps it can help others:
JTable.paintComponent(Graphics g) will not be called unless the table has a height that is greater than 0. This causes a problem for empty tables, so we expand the JTable height if needed so that it will always be at least the size of the JViewport that is it's parent.
JTable tableName = new JTable() {
public boolean getScrollableTracksViewportHeight() {
if(getParent() instanceof JViewport)
return(((JViewport)getParent()).getHeight() > getPreferredSize().height);
return super.getScrollableTracksViewportHeight();
}
protected void paintComponent(Graphics g) {
super.paintComponent(g);
if(getRowCount() == 0) {
Graphics2D g2d = (Graphics2D) g;
g2d.setColor(Color.BLACK);
g2d.drawString("Nothing found to display.",10,20);
}
}
}
containerName.add(new JScrollPane(tableName));
To show a line of text in the multicolumn table can be quite difficult, the span AFAIK is not supported.
One possibility would be to hide all data columns (to show them later you have to memorize them somewhere) and show one column for the message.
An easier way would be to create a JPanel with CardLayout, add 2 cards - one containing table and one containing your empty data warning. If the filter returns empty result, show the card with empty warning, in other case - show the table.
If the filter has excluded all rows, the result returned by getViewRowCount() will be zero. You can update the GUI accordingly; setToolTipText() is handy if screen space is lacking.
Here's an example:
TableModel model = ...
JTable table = new JTable(model);
TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(model);
table.setRowSorter(sorter);
JScrollPane pane = new JScrollPane(table);
JLabel label = new JLabel("");
...
String s = "Rows: " + sorter.getViewRowCount()
pane.setToolTipText(s);
label.setText(s);