use of org.apache.pivot.wtk.Sheet in project pivot by apache.
the class SheetTest method startup.
@SuppressWarnings("unused")
@Override
public void startup(final Display display, Map<String, String> properties) throws Exception {
Picture picture = (Picture) Image.load(getClass().getResource("IMG_0767_2.jpg"));
picture.resample(120);
BoxPane windowContent = new BoxPane();
PushButton button = new PushButton(picture);
button.getStyles().put(Style.toolbar, true);
windowContent.add(button);
frame = new Frame(windowContent);
frame.setPreferredSize(480, 360);
frame.getStyles().put(Style.padding, 0);
frame.open(display);
final TablePane tablePane = new TablePane();
tablePane.setPreferredSize(320, 240);
new TablePane.Column(tablePane, 1, true);
TablePane.Row row0 = new TablePane.Row(tablePane, 1, true);
TablePane.Row row1 = new TablePane.Row(tablePane, -1);
final Label sheetContent = new Label("Sheet Content");
sheetContent.getStyles().put(Style.wrapText, true);
sheetContent.getStyles().put(Style.horizontalAlignment, HorizontalAlignment.CENTER);
sheetContent.getStyles().put(Style.verticalAlignment, VerticalAlignment.CENTER);
row0.add(sheetContent);
Label promptBody = new Label("Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.");
promptBody.getStyles().put(Style.wrapText, true);
final Prompt prompt = new Prompt(MessageType.INFO, "Prompt", new ArrayList<>("OK"), promptBody);
prompt.setTitle("Prompt");
prompt.getStyles().put(Style.resizable, true);
prompt.getComponentMouseListeners().add(new ComponentMouseListener() {
@Override
public void mouseOver(Component component) {
System.out.println("Mouse Over");
}
@Override
public void mouseOut(Component component) {
System.out.println("Mouse out");
}
});
Label alertBody = new Label("Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.");
alertBody.getStyles().put(Style.wrapText, true);
final Alert alert = new Alert(MessageType.INFO, "Alert", new ArrayList<>("OK"), alertBody);
alert.setTitle("Alert");
BoxPane boxPane = new BoxPane();
row1.add(boxPane);
boxPane.getStyles().put(Style.horizontalAlignment, HorizontalAlignment.RIGHT);
final PushButton closeButton = new PushButton("Close");
closeButton.getStyles().put(Style.minimumAspectRatio, 3);
boxPane.add(closeButton);
sheet = new Sheet(tablePane);
closeButton.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button buttonArgument) {
buttonArgument.getWindow().close();
}
});
button.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button buttonArgument) {
prompt.open(frame);
Display displayLocal = DesktopApplicationContext.createDisplay(640, 480, 100, 100, true, true, false, buttonArgument.getDisplay().getHostWindow(), null);
Window window = new Window();
window.setTitle("New Secondary Window");
window.setMaximized(true);
window.setContent(new Label("I am a secondary window!"));
window.open(displayLocal);
}
});
sheet.getWindowStateListeners().add(new WindowStateListener() {
@Override
public void windowOpened(Window window) {
closeButton.requestFocus();
}
});
DesktopApplicationContext.sizeHostToFit(frame);
}
use of org.apache.pivot.wtk.Sheet in project pivot by apache.
the class Pivot862 method startup.
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
BXMLSerializer bxmlSerializer = new BXMLSerializer();
window = (Window) bxmlSerializer.readObject(getClass().getResource("pivot_862.bxml"));
bxmlSerializer.bind(this, Pivot862.class);
selectFolderButton.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
final FileBrowserSheet fileBrowserSheet = new FileBrowserSheet();
// to
fileBrowserSheet.setMode(FileBrowserSheet.Mode.SAVE_TO);
// be
// able
// to
// select
// a
// folder
fileBrowserSheet.open(window, new SheetCloseListener() {
@Override
public void sheetClosed(Sheet sheet) {
if (sheet.getResult()) {
File loadedFile = fileBrowserSheet.getSelectedFile();
try {
selectedFolder = loadedFile.getCanonicalPath();
System.out.println("Selected folder '" + selectedFolder + "'");
// multiple tests ...
System.out.println("Verify: Root folder (display from getName) was set to '" + fileBrowserSheet.getRootDirectory().getName() + "'");
System.out.println("Verify: Root folder (display from getCanonicalPath) was set to '" + fileBrowserSheet.getRootDirectory().getCanonicalPath() + "'");
System.out.println("Verify: Root folder (display from getCanonicalFile) was set to '" + fileBrowserSheet.getRootDirectory().getCanonicalFile() + "'");
openFileButton.setEnabled(true);
} catch (IOException e) {
e.printStackTrace();
openFileButton.setEnabled(false);
}
window.setTitle("Selected folder: " + selectedFolder);
}
}
});
}
});
openFileButton.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
System.out.println("Now opening a BrowserSheet starting from the previous selected folder: \"" + selectedFolder + "\"");
FileBrowserSheet fileBrowserSheet = // selectedFolder); // use this as a workaround ...
new FileBrowserSheet(// test to see
FileBrowserSheet.Mode.OPEN);
// the wrong
// behavior
// new FileBrowserSheet(); // test to see the wrong behavior
// ok, but
fileBrowserSheet.setRootFolder(selectedFolder);
// doesn't solve
// this issue
// ...
System.out.println("\nNote: the behavior here is right only when using the constructor with two parameters ..." + " but in this source it's used one of other constructors.\n");
try {
// multiple tests ...
System.out.println("Verify: Root folder (display from getName) was set to '" + fileBrowserSheet.getRootDirectory().getName() + "'");
System.out.println("Verify: Root folder (display from getCanonicalPath) was set to '" + fileBrowserSheet.getRootDirectory().getCanonicalPath() + "'");
System.out.println("Verify: Root folder (display from getCanonicalFile) was set to '" + fileBrowserSheet.getRootDirectory().getCanonicalFile() + "'");
} catch (IOException e) {
e.printStackTrace();
}
fileBrowserSheet.open(window, new SheetCloseListener() {
@Override
public void sheetClosed(Sheet sheet) {
// empty block
}
});
}
});
window.open(display);
}
use of org.apache.pivot.wtk.Sheet in project pivot by apache.
the class FileBrowserWithCharsetTest method startup.
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
BoxPane windowContent = new BoxPane();
windowContent.getStyles().put(Style.verticalAlignment, VerticalAlignment.CENTER);
final Checkbox showHiddenCheckbox = new Checkbox("Show hidden files");
windowContent.add(showHiddenCheckbox);
PushButton button = new PushButton("Open File Browser");
button.getStyles().put(Style.padding, "[2, 4, 2, 4]");
button.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button buttonArgument) {
final Window window = Window.getActiveWindow();
final FileBrowserWithCharsetTest fileBrowserSheet = new FileBrowserWithCharsetTest(FileBrowserSheet.Mode.OPEN);
fileBrowserSheet.getStyles().put(Style.showHiddenFiles, showHiddenCheckbox.isSelected());
fileBrowserSheet.open(window, new SheetCloseListener() {
@Override
public void sheetClosed(Sheet sheet) {
if (sheet.getResult()) {
Sequence<File> selectedFiles = fileBrowserSheet.getSelectedFiles();
ListView listView = new ListView();
listView.setListData(new ArrayList<>(selectedFiles));
listView.setSelectMode(ListView.SelectMode.NONE);
listView.getStyles().put(Style.backgroundColor, null);
Alert.alert(MessageType.INFO, "You selected (charset " + fileBrowserSheet.getCharsetName() + "):", listView, window);
} else {
Alert.alert(MessageType.INFO, "You didn't select anything.", window);
}
}
});
}
});
windowContent.add(button);
frame = new Frame(windowContent);
frame.setMaximized(true);
frame.open(display);
}
use of org.apache.pivot.wtk.Sheet in project pivot by apache.
the class VFSBrowserTest method startup.
@Override
public void startup(final Display display, final Map<String, String> properties) throws Exception {
BoxPane windowContent = new BoxPane();
windowContent.getStyles().put(Style.verticalAlignment, VerticalAlignment.CENTER);
final Checkbox showHiddenCheckbox = new Checkbox("Show hidden files");
windowContent.add(showHiddenCheckbox);
PushButton button = new PushButton("Open File Browser");
button.getStyles().put(Style.padding, "[2, 4, 2, 4]");
button.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(final Button buttonArgument) {
try {
final VFSBrowserSheet vfsBrowserSheet = new VFSBrowserSheet(VFSBrowserSheet.Mode.OPEN);
vfsBrowserSheet.getStyles().put(Style.showHiddenFiles, showHiddenCheckbox.isSelected());
vfsBrowserSheet.open(frame, new SheetCloseListener() {
@Override
public void sheetClosed(final Sheet sheet) {
if (sheet.getResult()) {
Sequence<FileObject> selectedFiles = vfsBrowserSheet.getSelectedFiles();
ListView listView = new ListView();
listView.setListData(new ArrayList<>(selectedFiles));
listView.setSelectMode(ListView.SelectMode.NONE);
listView.getStyles().put(Style.backgroundColor, null);
Alert.alert(MessageType.INFO, "You selected:", listView, frame);
} else {
Alert.alert(MessageType.INFO, "You didn't select anything.", frame);
}
}
});
} catch (FileSystemException fse) {
Alert.alert(MessageType.ERROR, String.format("File System Exception: %1$s", fse.getMessage()), frame);
}
}
});
windowContent.add(button);
frame = new Frame(windowContent);
frame.setMaximized(true);
frame.open(display);
}
use of org.apache.pivot.wtk.Sheet in project pivot by apache.
the class SheetExampleWindow method initialize.
@Override
public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
editGreetingButton.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
HashMap<String, Object> context = new HashMap<>();
store(context);
editGreetingSheet.load(context);
editGreetingSheet.open(SheetExampleWindow.this, new SheetCloseListener() {
@Override
public void sheetClosed(Sheet sheet) {
if (sheet.getResult()) {
HashMap<String, Object> contextLocal = new HashMap<>();
editGreetingSheet.store(contextLocal);
load(contextLocal);
}
}
});
}
});
}
Aggregations