package com.es.app.main;
import com.vaadin.annotations.AutoGenerated;
import com.vaadin.server.ExternalResource;
import com.vaadin.ui.AbsoluteLayout;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.Link;
import com.vaadin.ui.MenuBar;
import com.vaadin.ui.MenuBar.Command;
import com.vaadin.ui.MenuBar.MenuItem;
public class MainWindow extends CustomComponent {
/*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
/**
*
*/
private static final long serialVersionUID = -3719726765762505221L;
@AutoGenerated
private AbsoluteLayout mainLayout;
@AutoGenerated
private MenuBar menubar;
/**
* The constructor should first build the main layout, set the composition
* root and then do any custom initialization.
*
* The constructor will not be automatically regenerated by the visual
* editor.
*/
public MainWindow() {
buildMainLayout();
setCompositionRoot(mainLayout);
genControls();
// TODO add user code here
}
private Command menuCommand = new Command() {
/**
*
*/
private static final long serialVersionUID = 3499652963445434590L;
@SuppressWarnings("deprecation")
public void menuSelected(MenuItem selectedItem) {
getUI().showNotification("Action " + selectedItem.getText());
}
};
private void genControls() {
menubar.addItem("nuevo", null);
// Save reference to individual items so we can add sub-menu items to
// them
final MenuBar.MenuItem file = menubar.addItem("File", null);
final MenuBar.MenuItem newItem = file.addItem("New", null);
file.addItem("Open file...", menuCommand);
file.addSeparator();
newItem.addItem("File", menuCommand);
newItem.addItem("Folder", menuCommand);
newItem.addItem("Project...", menuCommand);
file.addItem("Close", menuCommand);
file.addItem("Close All", menuCommand);
file.addSeparator();
file.addItem("Save", menuCommand);
file.addItem("Save As...", menuCommand);
file.addItem("Save All", menuCommand);
final MenuBar.MenuItem edit = menubar.addItem("Edit", null);
edit.addItem("Undo", menuCommand);
edit.addItem("Redo", menuCommand).setEnabled(false);
edit.addSeparator();
edit.addItem("Cut", menuCommand);
edit.addItem("Copy", menuCommand);
edit.addItem("Paste", menuCommand);
edit.addSeparator();
final MenuBar.MenuItem find = edit.addItem("Find/Replace", menuCommand);
Link sample = new Link("Google search", new ExternalResource(
"http://www.google.com"));
sample.setDescription("Visit google.com");
// Actions can be added inline as well, of course
find.addItem("Google Search", new Command() {
/**
*
*/
private static final long serialVersionUID = 4723307629344582943L;
@SuppressWarnings("static-access")
public void menuSelected(MenuItem selectedItem) {
getUI().getCurrent().getPage()
.open("www.google.com.ec","");
}
});
find.addSeparator();
find.addItem("Find/Replace...", menuCommand);
find.addItem("Find Next", menuCommand);
find.addItem("Find Previous", menuCommand);
final MenuBar.MenuItem view = menubar.addItem("View", null);
view.addItem("Show/Hide Status Bar", menuCommand);
view.addItem("Customize Toolbar...", menuCommand);
view.addSeparator();
view.addItem("Actual Size", menuCommand);
view.addItem("Zoom In", menuCommand);
view.addItem("Zoom Out", menuCommand);
}
@AutoGenerated
private AbsoluteLayout buildMainLayout() {
// common part: create layout
mainLayout = new AbsoluteLayout();
mainLayout.setImmediate(false);
mainLayout.setWidth("100%");
mainLayout.setHeight("100%");
// top-level component properties
setWidth("100.0%");
setHeight("100.0%");
// menuBar_1
menubar = new MenuBar();
menubar.setImmediate(false);
menubar.setWidth("100.0%");
menubar.setHeight("-1px");
mainLayout.addComponent(menubar, "top:0.0px;left:0.0px;");
return mainLayout;
}
}