Javafx : Adding contents to the tabs based on chosen file - dynamic

I am trying to add dynamic contents to tabs. The scenario is when the user clicks on the open file menu, a tab should open displaying the contents of the chosen file. The scene is a border pane which has a pane and tab pane. The contents of respective files are displayed on the pane and should vary according the selected tab.
I appreciate any help to implement this scenario.

TabPane tabPane = new TabPane();
BorderPane mainPane = new BorderPane();
Tab tabB = new Tab();
tabB.setText("Tab B");
tabB.setContent(yourcontent);
tabPane.getTabs().add(tabB);
mainPane.setCenter(tabPane);
primaryStage.setScene(new Scene(mainpane, 400, 300, Color.WHITE););

Related

open a link in new tab in selenium

I am trying to open a link in new tab.
Trial1
Actions action = new Actions(Driver).KeyDown(Keys.Control).KeyDown(Keys.Shift).Click(FindElement(xxx).KeyUp(Keys.Control).KeyUp(Keys.Shift);
action.Build().Perform();
This code opens the link in new tab at the same time opens another blank window
Trial2 - right click the link and choose the first option "open link new tab"
action.ContextClick(FindElement(xxx).SendKeys(Keys.ArrowDown).SendKeys(Keys.Enter).Build().Perform();
This opens the link in new window instead of new tab
So what you need to do is first open a new tab using JS executor:
((JavascriptExecutor)driver).executeScript("window.open()");
or
((JavascriptExecutor)driver).executeScript("window.open('the new link here', '_blank')");
If you did not use the secon method continue with the following: switch to the new window and navigate to the link
driver.switchTo().window(here the window handle);
driver.get("here is the link");

MenuItem disabled after turning off the view

I set up a project with two view controllers connected to two xibs (MainMenu.xib and MasterVC.xib)
In my MasterVC I programatically add NSMenuItems with actions (located in MasterVC) to a menu, that is located in MainMenu.xib (and is connected to AppDelegate).
let menuItem = NSMenuItem()
menuItem.title = object.name!
menuItem.keyEquivalent = object.shortcut!
menuItem.representedObject = object
menuItem.action = "testSelector:"
appDel.menu.insertItem(menuItem, atIndex: 0)
func testSelector(sender: NSMenuItem) {
let object = (sender.representedObject as! MyNewObject)
print("Name of set:", object.name)
}
My added menu items work (are enabled) as long as I have window from MasterVC opened. As soon as I close it I can't click those menu items (they are disabled).
Is there a way to keep them enabled all the time?
You need to do two steps in your storyboard or XIB file (whichever contains the main menu):
1)
Use the Attribute Inspector after selecting the menu and then turn off "Auto Enable Items" checkbox:
]
2)
And for each menu item you want to have enabled, select that menu item and use the Attributes Inspector to make sure this checkbox is set to on:
]

Cannot open embedded hyperlink in PDF generated using PDFBox

I have used PDFBox version 2.0 to generated a PDF containing a clickable URL.
// Create a new annotation and make it invisible
PDAnnotationLink txtLink = new PDAnnotationLink();
txtLink.setInvisible(true);
// Add an action
PDActionURI action = new PDActionURI();
action.setURI(url);
txtLink.setAction(action);
// Create a new rectangle that will be the clickable area
PDRectangle position = new PDRectangle();
position.setLowerLeftX(currentXpos);
position.setLowerLeftY(currentYpos - rectangleHeight);
position.setUpperRightX(currentXpos + rectangleWidth);
position.setUpperRightY(currentYpos);
// Write the "Link" string in blue
contentStream.setNonStrokingColor(Color.blue);
contentStream.showText(elm.text());
contentStream.setNonStrokingColor(Color.black);
// Make the rectangle a clickable link and add it to the page
txtLink.setRectangle(position);
page.getAnnotations().add(txtLink);
When I click on the generated PDF in Chrome 45, the document is opened in the Chrome's PDF viewer. The link is clickable, no problem.
If I click on the generated PDF in Firefox (41.0.1) or IE 11, the document is loaded in the Adobe PDF viewer plugin and the link is not clickable. The mouse-over displays the correct URL, but nothing happens when I click the link.
Is this a security issue? Is there anything I can do in the PDFBox code to make the link clickable always?
I was able to hide the border by setting the width to 0:
// Create a new annotation and make it visible
PDAnnotationLink txtLink = new PDAnnotationLink();
txtLink.setInvisible(false);
// Set the border to zero to hide it
PDBorderStyleDictionary border = new PDBorderStyleDictionary();
border.setWidth(0);
txtLink.setBorderStyle(border);

Titanium - How to close View that is defined in another .js file

I have one window defined in a FirstView.js and a View defined in Settings.js.
I add the Settings View to the FirstView Window doing this:
var Settings = require('ui/common/Settings');
var Settings = new Settings();
self.add(Settings);
And now, when users press "back" button i need to remove the Settings View from main window.
I know that i could do this with self.remove(Settings) if both codes were in the same .js file.
But, in this case, how can i remove the Settings View from the main FirstView Window?
try to use Application level events.
in Settings.js and when you click on back button
Ti.App.fireEvent("backSetting");
and in FirstView.js
Ti.App.addEventListener("backSetting",function(e){
self.remove(Setting);
};
why not use a container for settings?
e.g:
var FirstView=Ti.UI.createWindow();
var contentSetting=Ti.UI.createView({
height:Ti.UI.SIZE //or Ti.UI.FILL,
width:Ti.UI.SIZE //or Ti.UI.FILL
});
FirstView.add(contentSetting);
var Settings = require('ui/common/Settings');
var Settings = new Settings();
contentSetting.add(Settings);
FirstView.addEventListener('android:back', function(e){
//remove view
$.contentSetting.removeAllChildren();
});

How to open dialog or popup when clicking on a cell in Dojo Dgrid

I want to open a dialog box when clicking on a cell.I am using dgrid/editor.
editor({field: "column1",label: "col1",editor: "text",editOn: "click"})
I am getting text box when using the above code.I want a dialog box.Please tell me how to get a dialog box.I am using OndemandGrid with JSONReststore to display the grid.
You don't need use editor to trigger a dialog, use click event on a cell is ok:
var grid = new declare([OnDemandGrid,Keyboard, Selection])({
store: Observable(new Memory({data: []}))
}, yourGridConatiner);
grid.on(".dgrid-content .dgrid-cell:click", function (evt) {
var cell = grid.cell(evt);
var data = cell.row.data;
/* your dialog creation at here, for example like below */
var dlg = new Dialog({
title: "Dialog",
className:"dialogclass",
content: dlgDiv //you need create this div using dojo.create or put-selector
});
dlg.show();
});
If you want show a pointer while mouse over that cell, you can style it at renderCell method with "cursor:pointer"
From the wiki:
editor - The type of component to use for editors in this column; either a string specifying a type of standard HTML input to create, or a Dijit widget constructor to instantiate.
You could provide (to editor) a button that pops up a dialog when clicked, but that would probably mean two clicks to edit a cell: one to focus or enter edit mode or otherwise get the button to appear and one to actually click the button.
You could also not bother with the editor plugin and attach a click event handler to the cell and pop up a dialog from there. You would have to manually save the changes back to your store if you went that route.
If I understand you right - you could try something like this:
function cellFormatter1(value) {
//output html-code to open your popup - ie. using value (of cell)
}
......
{field: "column1",label: "col1", formatter: cellFormatter1 }