List of usage examples for com.vaadin.ui Alignment TOP_RIGHT
Alignment TOP_RIGHT
To view the source code for com.vaadin.ui Alignment TOP_RIGHT.
Click Source Link
From source file:org.opennms.netmgt.vaadin.core.StringInputDialogWindow.java
License:Open Source License
/** * Constructor responsible for creating new instances of this class * * @param caption the window's title//from w w w .ja v a 2 s . c om * @param fieldName the title of the input field */ public StringInputDialogWindow(String caption, String fieldName) { super(caption); /** * set window properties */ setModal(true); setClosable(false); setResizable(false); /** * create the main layout */ VerticalLayout verticalLayout = new VerticalLayout(); /** * add the input field */ m_inputField = new TextField(fieldName); m_inputField.setValue(""); m_inputField.focus(); m_inputField.selectAll(); m_inputField.setImmediate(true); /** * create nested FormLayout instance */ FormLayout formLayout = new FormLayout(); formLayout.setSizeUndefined(); formLayout.setMargin(true); formLayout.addComponent(m_inputField); /** * add the buttons in a horizontal layout */ HorizontalLayout horizontalLayout = new HorizontalLayout(); horizontalLayout.setMargin(true); horizontalLayout.setSpacing(true); horizontalLayout.setWidth("100%"); /** * create cancel button */ m_cancelButton = new Button("Cancel"); m_cancelButton.setClickShortcut(ShortcutAction.KeyCode.ESCAPE, null); m_cancelButton.addClickListener(this); horizontalLayout.addComponent(m_cancelButton); horizontalLayout.setExpandRatio(m_cancelButton, 1); horizontalLayout.setComponentAlignment(m_cancelButton, Alignment.TOP_RIGHT); /** * create ok button */ m_okButton = new Button("OK"); m_okButton.setClickShortcut(ShortcutAction.KeyCode.ENTER, null); m_okButton.addClickListener(this); horizontalLayout.addComponent(m_okButton); formLayout.addComponent(horizontalLayout); verticalLayout.addComponent(formLayout); /** * the close listener */ addCloseListener(this); /** * set the content */ setContent(verticalLayout); }
From source file:org.openthinclient.web.pkgmngr.ui.view.PackageDetailsWindow.java
public PackageDetailsWindow(PackageDetailsPresenter.View target, Component viewComponent) { this.target = target; final VerticalLayout contents = new VerticalLayout(); contents.setMargin(true);//from w w w.j a va 2 s. com contents.addComponent(viewComponent); contents.setExpandRatio(viewComponent, 1); contents.setSizeFull(); final HorizontalLayout footer = new HorizontalLayout(); footer.addStyleNames(ValoTheme.WINDOW_BOTTOM_TOOLBAR); actionBar = new CssLayout(); footer.addComponent(actionBar); footer.setWidth("100%"); footer.setExpandRatio(actionBar, 1); footer.setComponentAlignment(actionBar, Alignment.TOP_RIGHT); final Button closeButton = new Button(); closeButton.addStyleNames(ValoTheme.BUTTON_QUIET); closeButton.setIcon(VaadinIcons.CLOSE); closeButton.setCaption("Close"); closeButton.addClickListener(e -> hide()); footer.addComponent(closeButton); contents.addComponent(footer); setContent(contents); }
From source file:org.processbase.ui.portlet.chart.ChartConfigurationPanel.java
License:Open Source License
public ChartConfigurationPanel() { super(4, 7);/*from w w w. ja v a2 s .c om*/ setWidth("100%"); chartType = new NativeSelect("Chart Type"); chartType.addItem("BarChart"); chartType.addItem("ColumnChart"); chartType.addItem("PieChart"); chartType.addItem("LineChart"); chartType.addItem("AreaChart"); chartType.setWidth("100px"); refreshInterval = new TextField(ChartPortlet.getCurrent().messages.getString("refreshInterval")); refreshInterval.setMaxLength(3); refreshInterval.setRequired(true); refreshInterval .addValidator(new IntegerValidator(ChartPortlet.getCurrent().messages.getString("refreshInterval") + " " + ChartPortlet.getCurrent().messages.getString("IntegerValidatorError"))); refreshInterval.setValue(new Integer("10")); title = new TextField(ChartPortlet.getCurrent().messages.getString("title")); title.setWidth("100%"); title.setRequired(true); legend = new NativeSelect(ChartPortlet.getCurrent().messages.getString("legend")); legend.setWidth("100%"); legend.addItem("bottom"); legend.addItem("top"); legend.addItem("left"); legend.addItem("right"); titleX = new TextField(ChartPortlet.getCurrent().messages.getString("titleX")); titleX.setWidth("100%"); titleX.setRequired(true); titleY = new TextField(ChartPortlet.getCurrent().messages.getString("titleY")); titleY.setWidth("100%"); titleY.setRequired(true); height = new TextField(ChartPortlet.getCurrent().messages.getString("height")); height.setWidth("70px"); // height.addValidator(new IntegerValidator(ChartPortlet.getCurrent().messages.getString("height") + " " + ChartPortlet.getCurrent().messages.getString("IntegerValidatorError"))); height.setRequired(true); width = new TextField(ChartPortlet.getCurrent().messages.getString("width")); width.setWidth("70px"); // width.addValidator(new IntegerValidator(ChartPortlet.getCurrent().messages.getString("width") + " " + ChartPortlet.getCurrent().messages.getString("IntegerValidatorError"))); width.setRequired(true); min = new TextField(ChartPortlet.getCurrent().messages.getString("min")); min.setWidth("70px"); min.addValidator(new IntegerValidator(ChartPortlet.getCurrent().messages.getString("min") + " " + ChartPortlet.getCurrent().messages.getString("IntegerValidatorError"))); max = new TextField(ChartPortlet.getCurrent().messages.getString("max")); max.setWidth("70px"); max.addValidator(new IntegerValidator(ChartPortlet.getCurrent().messages.getString("max") + " " + ChartPortlet.getCurrent().messages.getString("IntegerValidatorError"))); sqlText = new TextArea(ChartPortlet.getCurrent().messages.getString("sqlText")); sqlText.setWidth("100%"); sqlText.setRequired(true); sqlText.setRows(7); isStacked = new CheckBox("Stacked"); btnSave = new Button(ChartPortlet.getCurrent().messages.getString("btnSave"), this); btnTestSQL = new Button(ChartPortlet.getCurrent().messages.getString("btnTestSQL"), this); btnView = new Button(ChartPortlet.getCurrent().messages.getString("btnView"), this); buttons.addComponent(btnSave); buttons.addComponent(btnTestSQL); buttons.addComponent(btnView); addComponent(chartType, 0, 0, 1, 0); addComponent(isStacked, 3, 0); addComponent(title, 0, 1, 1, 1); addComponent(legend, 2, 1); addComponent(refreshInterval, 3, 1); addComponent(titleX, 0, 2, 1, 2); addComponent(titleY, 2, 2, 3, 2); addComponent(height, 0, 3); addComponent(width, 1, 3); addComponent(max, 2, 3); addComponent(min, 3, 3); addComponent(sqlText, 0, 4, 3, 4); addComponent(buttons, 0, 6, 3, 6); setComponentAlignment(btnSave, Alignment.TOP_RIGHT); setMargin(true); setSpacing(true); try { portletPreferences = ChartPortlet.portletPreferences.get(); for (String key : portletPreferences.getMap().keySet()) { String[] value = portletPreferences.getMap().get(key); if (key.equals("refreshInterval") && value.length > 0) { refreshInterval.setValue(value[0]); } else if (key.equals("sqlText") && value.length > 0) { sqlText.setValue(value[0]); } else if (key.equals("chartType") && value.length > 0) { chartType.setValue(value[0]); } else if (key.equals("title") && value.length > 0) { title.setValue(value[0]); } else if (key.equals("legend") && value.length > 0) { legend.setValue(value[0]); } else if (key.equals("height") && value.length > 0) { height.setValue(value[0]); } else if (key.equals("width") && value.length > 0) { width.setValue(value[0]); } else if (key.equals("min") && value.length > 0) { min.setValue(value[0]); } else if (key.equals("max") && value.length > 0) { max.setValue(value[0]); } else if (key.equals("titleX") && value.length > 0) { titleX.setValue(value[0]); } else if (key.equals("titleY") && value.length > 0) { titleY.setValue(value[0]); } else if (key.equals("isStacked") && value.length > 0) { isStacked.setValue(Boolean.parseBoolean(value[0])); } else if (key.equals("legend") && value.length > 0) { legend.setValue(value[0]); } } } catch (Exception ex) { ex.printStackTrace(); } }
From source file:org.rapidpm.jumpstart.vaadin.ui.basics.RapidTopPanel.java
License:Apache License
@PostConstruct private void createIconsLayout() { iconsLayout.setWidth("100%"); iconsLayout.setMargin(new MarginInfo(false, false, false, false)); if (propertyService.hasKey("app.logo")) { final String resourceName = propertyService.resolve("app.logo"); final Image iconLeft = new Image(null, new ClassResource(resourceName)); final Image iconRight = new Image(null, new ClassResource(resourceName)); iconsLayout.addComponent(iconLeft); iconsLayout.setComponentAlignment(iconLeft, Alignment.TOP_LEFT); if (propertyService.hasKey("app.version")) { final Label versionLabel = new Label(propertyService.resolve("app.version")); versionLabel.setSizeUndefined(); iconsLayout.addComponent(versionLabel); iconsLayout.setComponentAlignment(versionLabel, Alignment.MIDDLE_CENTER); iconsLayout.setExpandRatio(versionLabel, 1.0f); }//from w w w . jav a 2s. co m iconsLayout.addComponent(iconRight); iconsLayout.setComponentAlignment(iconRight, Alignment.TOP_RIGHT); } }
From source file:org.robot.gtf.gui.GTFApplication.java
License:Apache License
private void buildAboutWindow() { // Create the window... aboutWindow = new Window("About"); aboutWindow.setModal(true);// w w w. jav a 2 s. c o m aboutWindow.setResizable(false); aboutWindow.setWidth(350, Window.UNITS_PIXELS); aboutWindow.setHeight(180, Window.UNITS_PIXELS); // Configure the window layout; by default a VerticalLayout VerticalLayout layout = (VerticalLayout) aboutWindow.getContent(); layout.setMargin(true); layout.setSpacing(true); // Add some content; a label and a close-button Label message = new Label(TextResources.getAboutText()); message.setContentMode(Label.CONTENT_XHTML); aboutWindow.addComponent(message); Button close = new Button("Close", new Button.ClickListener() { public void buttonClick(ClickEvent event) { (aboutWindow.getParent()).removeWindow(aboutWindow); } }); // The components added to the window are actually added to the window's // layout; you can use either. Alignments are set using the layout layout.addComponent(close); layout.setComponentAlignment(close, Alignment.TOP_RIGHT); }
From source file:org.s23m.cell.editor.semanticdomain.ui.components.EdgeCreationForm.java
License:Mozilla Public License
private void init() { setReadOnly(true);//from w w w .ja v a2s. co m setImmediate(true); setWriteThrough(false); setInvalidCommitted(false); // set up form data binding edgeData = new EdgeData(sourceInstance); final BeanItem<EdgeData> item = new BeanItem<EdgeData>(edgeData); setFormFieldFactory(new FormFieldFactory() { public Field createField(final Item item, final Object propertyId, final Component uiContext) { final String pid = (String) propertyId; if (EdgeData.getDisplayedInstances().contains(pid)) { @SuppressWarnings("unchecked") final Set edge = (Set) item.getItemProperty(propertyId).getValue(); //see if this set has any associated instances if (EdgeData.getInstancesWithAssociatedList().contains(pid)) { //Returns a field that shows a list of options final BeanItemContainer<SetData> listContainer = new BeanItemContainer<SetData>( SetData.class); final List<SetData> assocList = EdgeData.getAssociatedListOf(pid); listContainer.addAll(assocList); final ListField listField = new ListField( DefaultFieldFactory.createCaptionByPropertyId(pid), "Select...", listContainer); return listField; } else { //Returns a field that shows the name of a set if (EdgeData.META_ELEMENT.equals(pid)) { final BeanItemContainer<SetData> listContainer = new BeanItemContainer<SetData>( SetData.class); final List<SetData> assocList = edgeData .getAllValidEdgeFlavoredInstances(targetInstance); listContainer.addAll(assocList); final ListField listField = new ListField( DefaultFieldFactory.createCaptionByPropertyId(pid), "Select...", listContainer); metaField = listField; enableOrDisableMetaField(assocList); return listField; } else if (EdgeData.TARGET_INSTANCE.equals(pid)) { //target field final BeanItemContainer<SetData> listContainer = new BeanItemContainer<SetData>( SetData.class); final List<SetData> assocList = edgeData.getAllVisibleVertices(); listContainer.addAll(assocList); final ListField listField = new ListField( DefaultFieldFactory.createCaptionByPropertyId(pid), "Select...", listContainer); targetField = listField; return listField; } else { return new SetField(DefaultFieldFactory.createCaptionByPropertyId(pid), new SetData(edge), true, true); } } } else { final TextField f = new TextField(DefaultFieldFactory.createCaptionByPropertyId(pid)); f.setReadOnly(true); return f; } } }); setItemDataSource(item); setVisibleItemProperties(EdgeData.getDisplayedInstances()); targetField.addEventListener(this); final HorizontalLayout buttonBarLayout = new HorizontalLayout(); buttonBarLayout.setSpacing(true); buttonBarLayout.setHeight(BUTTON_BAR_HEIGHT); getFooter().addComponent(buttonBarLayout); final Button okBtn = new Button("OK", new Button.ClickListener() { public void buttonClick(final ClickEvent event) { try { commit(); processFormData(edgeData); } catch (final Throwable th) { } } private void processFormData(final EdgeData edgeData) { final Set edgeIdentity = lookupSet(EdgeData.EDGE_IDENTITY_INSTANCE); final Set edgeSet = Instantiation.arrow(lookupSet(EdgeData.META_ELEMENT), edgeIdentity, lookupSet(EdgeData.FIRST_SEMANTIC_IDENTITY), lookupSet(EdgeData.SOURCE_INSTANCE), lookupSet(EdgeData.FIRST_MIN_CARDINALITY), lookupSet(EdgeData.FIRST_MAX_CARDINALITY), lookupSet(EdgeData.FIRST_IS_NAVIGABLE), lookupSet(EdgeData.FIRST_IS_CONTAINER), lookupSet(EdgeData.SECOND_SEMANTIC_IDENTITY), lookupSet(EdgeData.TARGET_INSTANCE), lookupSet(EdgeData.SECOND_MIN_CARDINALITY), lookupSet(EdgeData.SECOND_MAX_CARDINALITY), lookupSet(EdgeData.SECOND_IS_NAVIGABLE), lookupSet(EdgeData.SECOND_IS_CONTAINER)); if (edgeSet.identity().name().equals(edgeIdentity.identity().name())) { // propertyChangeSupport.firePropertyChange( // EditorEvents.CHANGESET_MODIFIED.getEventName(), // null, null); ((org.s23m.cell.editor.semanticdomain.Editor) getApplication()).updateContainmentTree(); containerLayout.getParent().closeTab(containerLayout); } containerLayout.getParent().getMainApplication().getMainWindow().showNotification("Edge created"); } }); final Button closeBtn = new Button("Cancel", new Button.ClickListener() { public void buttonClick(final ClickEvent event) { discard(); containerLayout.getParent().closeTab(containerLayout); } }); buttonBarLayout.addComponent(okBtn); buttonBarLayout.addComponent(closeBtn); buttonBarLayout.setComponentAlignment(closeBtn, Alignment.TOP_RIGHT); }
From source file:org.s23m.cell.editor.semanticdomain.ui.components.layout.AdminFormLayout.java
License:Mozilla Public License
private void init() { setMargin(true);//w w w .j av a2 s.c o m final String lblMsg = STATUS_MSG_SERVER_INACTIVE;//RepositoryClientServer.getInstance().isRepositoryServerRunning() ? STATUS_MSG_SERVER_ACTIVE : STATUS_MSG_SERVER_INACTIVE; final Label lblStatus = new Label(lblMsg); addComponent(lblStatus); final HorizontalLayout buttonBarLayout = new HorizontalLayout(); buttonBarLayout.setSpacing(true); buttonBarLayout.setHeight(BUTTON_BAR_HEIGHT); final HorizontalLayout checkinBarLayout = new HorizontalLayout(); checkinBarLayout.setSpacing(true); checkinBarLayout.setHeight(BUTTON_BAR_HEIGHT); final Button okBtn = new Button("Start Repository Client", new Button.ClickListener() { public void buttonClick(final ClickEvent event) { try { if (!RepositoryClientServer.getInstance().isRepositoryServerRunning()) { RepositoryClientServer.getInstance().start(); lblStatus.setValue(STATUS_MSG_SERVER_ACTIVE); } } catch (final Throwable th) { lblStatus.setValue(th); } } }); final Button stopBtn = new Button("Stop Repository Client", new Button.ClickListener() { public void buttonClick(final ClickEvent event) { try { if (RepositoryClientServer.getInstance().isRepositoryServerRunning()) { RepositoryClientServer.getInstance().stop(); lblStatus.setValue(STATUS_MSG_SERVER_INACTIVE); } } catch (final Throwable th) { lblStatus.setValue(th); } } }); buttonBarLayout.addComponent(okBtn); buttonBarLayout.addComponent(stopBtn); buttonBarLayout.setComponentAlignment(stopBtn, Alignment.TOP_RIGHT); final Button checkInButton = new Button("Do initial check-in", new Button.ClickListener() { public void buttonClick(final ClickEvent event) { try { S23MKernel.completeCellKernelInitialization(); CellPlatform.instantiateFeature(); //org.s23m.cell.test.artifactinstantiation.Test.main(null); final ArtefactContainer container = ObjectFactoryHolder.getInstance().createArtefactContainer(); container.setContentType(SerializationType.IN_MEMORY_PERSISTENCE.name()); client.put(container); lblStatus.setValue("Initial check-in done."); } catch (final Throwable th) { lblStatus.setValue(th); } } }); checkInButton.setEnabled(true); checkinBarLayout.addComponent(checkInButton); addComponent(buttonBarLayout); addComponent(checkinBarLayout); }
From source file:org.s23m.cell.editor.semanticdomain.ui.components.layout.LinkCreationFormLayout.java
License:Mozilla Public License
public void initLayout() { setCaption(action.getCaption());/* www.j av a 2s.co m*/ // main window layout setWidth(FULL_SIZE); setMargin(true); setSpacing(true); final Form inputForm = new Form(); inputForm.setReadOnly(true); inputForm.setWidth(INPUT_FORM_WIDTH); addComponent(inputForm); inputForm.setImmediate(true); inputForm.setWriteThrough(false); // set up form data binding final LinkData linkData = new LinkData(fromInstance); linkData.setToInstance(S23MKernel.coreGraphs.vertex); //default target instance final BeanItem<LinkData> item = new BeanItem<LinkData>(linkData); inputForm.setItemDataSource(item); inputForm.setVisibleItemProperties(LinkData.getDisplayedInstances()); final HorizontalLayout buttonBarLayout = new HorizontalLayout(); buttonBarLayout.setSpacing(true); buttonBarLayout.setHeight(BUTTON_BAR_HEIGHT); inputForm.getFooter().addComponent(buttonBarLayout); for (final String key : LinkData.getDisplayedInstances()) { inputForm.getField(key).setWidth(FIELD_WIDTH); } // drop handler final DragAndDropWrapper targetWrapper = new DragAndDropWrapper(inputForm); targetWrapper.setWidth(FULL_SIZE); targetWrapper.setHeight(FULL_SIZE); targetWrapper.setDropHandler(new DropHandler() { public void drop(final DragAndDropEvent event) { final DataBoundTransferable t = (DataBoundTransferable) event.getTransferable(); final TreeNode node = (TreeNode) t.getData("itemId"); inputForm.getItemDataSource().getItemProperty(LinkData.TO_INSTANCE).setValue(node.getSet()); inputForm.getField(LinkData.TARGET).requestRepaint(); } public AcceptCriterion getAcceptCriterion() { return AcceptAll.get(); } }); addComponent(targetWrapper); //parent.getMainApplication().getContainmentTreePanel().setEditMode(true); //add all visible instances from the fromInstance //parent.getMainApplication().getContainmentTreePanel().getScopeMap() // .putAll(addAllVisibleInstanceUUIDs(fromInstance)); //changeSupport.firePropertyChange(EditorEvents.CHANGESET_MODIFIED.getEventName(), null, null); //((org.s23m.cell.editor.semanticdomain.Editor)getApplication()).updateContainmentTree(); final Button okBtn = new Button("OK", new Button.ClickListener() { public void buttonClick(final ClickEvent event) { // create a new link instance final Set metaInstance = (action.equals(TreeActionHandler.ACTION_CREATE_VISIBILITY)) ? S23MKernel.coreGraphs.visibility : S23MKernel.coreGraphs.superSetReference; if (action.equals(TreeActionHandler.ACTION_CREATE_VISIBILITY) || action.equals(TreeActionHandler.ACTION_CREATE_SSR)) { final Set src = (Set) inputForm.getItemDataSource().getItemProperty(LinkData.FROM_INSTANCE) .getValue(); final Set trgt = (Set) inputForm.getItemDataSource().getItemProperty(LinkData.TO_INSTANCE) .getValue(); if (src != null && trgt != null) { final Set v = Instantiation.arrow(metaInstance, src, trgt); String msg = ""; if (!v.identity().isEqualTo( S23MSemanticDomains.semanticErr_TargetIsNotWithinVisibility.identity())) { inputForm.commit(); msg = "Successfully created a new link"; parent.getMainApplication().getMainWindow().showNotification(msg); ((org.s23m.cell.editor.semanticdomain.Editor) getApplication()).updateContainmentTree(); parent.closeTab(LinkCreationFormLayout.this); } else { msg = "Failed creating a visibility link: " + v.identity().name(); parent.getMainApplication().getMainWindow().showNotification("Error", v.identity().name(), Notification.TYPE_ERROR_MESSAGE); } //parent.getMainApplication().getConsole().setValue( // parent.getMainApplication().getConsole().getValue() + msg // + "\n"); } } //parent.getMainApplication().getContainmentTreePanel().setEditMode(false); //parent.getMainApplication().getContainmentTreePanel().getScopeMap().clear(); //changeSupport.firePropertyChange(EditorEvents.CHANGESET_MODIFIED.getEventName(), null, null); } }); final Button closeBtn = new Button("Cancel", new Button.ClickListener() { public void buttonClick(final ClickEvent event) { inputForm.discard(); parent.getMainApplication().getContainmentTreePanel().setEditMode(false); parent.getMainApplication().getContainmentTreePanel().getScopeMap().clear(); ((org.s23m.cell.editor.semanticdomain.Editor) getApplication()).updateContainmentTree(); //changeSupport.firePropertyChange(EditorEvents.CHANGESET_MODIFIED.getEventName(), null, null); //changeSupport.removePropertyChangeListener(EditorController.getInstance()); parent.closeTab(LinkCreationFormLayout.this); } }); buttonBarLayout.addComponent(okBtn); buttonBarLayout.addComponent(closeBtn); buttonBarLayout.setComponentAlignment(closeBtn, Alignment.TOP_RIGHT); }
From source file:org.s23m.cell.editor.semanticdomain.ui.components.layout.SemanticInstanceCreationFormLayout.java
License:Mozilla Public License
private void initLayout() { setCaption(action.getCaption());//from w w w . j a va 2s. com setWidth(FULL_SIZE); setMargin(true); setSpacing(true); final Form inputForm = new Form(); inputForm.setReadOnly(true); inputForm.setWidth(INPUT_FORM_WIDTH); addComponent(inputForm); inputForm.setImmediate(true); inputForm.setWriteThrough(false); inputForm.setFormFieldFactory(new FormFieldFactory() { public Field createField(final Item item, final Object propertyId, final Component uiContext) { final String textLabel = DefaultFieldFactory.createCaptionByPropertyId(propertyId); final TextField f = new TextField(textLabel); if (propertyId.toString().equals(SemanticInstanceData.REFERENCED_SEMANTIC_IDENTITY_NAME)) { f.setRequiredError(textLabel + " is a mandatory field."); f.setRequired(true); } if (action.equals(TreeActionHandler.ACTION_ADD_SEMANTIC_DOMAIN)) { if (propertyId.toString().equals(SemanticInstanceData.NAME)) { f.setRequiredError(textLabel + " is a mandatory field."); f.setRequired(true); } } return f; } }); //set up form data binding final SemanticInstanceData formData = new SemanticInstanceData("", "", containerInstnace); final BeanItem<SemanticInstanceData> item = new BeanItem<SemanticInstanceData>(formData); inputForm.setItemDataSource(item); if (action.equals(TreeActionHandler.ACTION_ADD_SEMANTIC_ROLE)) { inputForm.setVisibleItemProperties(SemanticInstanceData.getDisplayedInstancesForSemanticRole()); } else { inputForm.setVisibleItemProperties(SemanticInstanceData.getDisplayedInstances()); } // drop handler final DragAndDropWrapper targetWrapper = new DragAndDropWrapper(inputForm); targetWrapper.setWidth(INPUT_FORM_WIDTH); targetWrapper.setHeight(INPUT_FORM_WIDTH); targetWrapper.setDropHandler(new DropHandler() { public void drop(final DragAndDropEvent event) { final DataBoundTransferable t = (DataBoundTransferable) event.getTransferable(); final TreeNode node = (TreeNode) t.getData("itemId"); inputForm.getItemDataSource().getItemProperty(SemanticInstanceData.REFERENCED_SEMANTIC_IDENTITY) .setValue(node.getSet()); inputForm.getField(SemanticInstanceData.REFERENCED_SEMANTIC_IDENTITY_NAME).requestRepaint(); } public AcceptCriterion getAcceptCriterion() { return AcceptAll.get(); } }); addComponent(targetWrapper); final HorizontalLayout buttonBarLayout = new HorizontalLayout(); buttonBarLayout.setSpacing(true); buttonBarLayout.setHeight(BUTTON_BAR_HEIGHT); inputForm.getFooter().addComponent(buttonBarLayout); final Button okBtn = new Button("OK", new Button.ClickListener() { public void buttonClick(final ClickEvent event) { try { if (action.equals(TreeActionHandler.ACTION_ADD_SEMANTIC_IDENTITY)) { inputForm.commit(); if (isAnonymousData(formData)) { Instantiation.addAnonymousDisjunctSemanticIdentitySet(formData.getSemanticDomain()); } else { Instantiation.addDisjunctSemanticIdentitySet(formData.getName(), formData.getPluralName(), formData.getSemanticDomain()); } closeOperation("New semantic identity is created"); } else if (action.equals(TreeActionHandler.ACTION_ADD_SEMANTIC_DOMAIN)) { inputForm.commit(); if (!isAnonymousData(formData)) { Instantiation.addSemanticDomain(formData.getName(), formData.getPluralName(), formData.getSemanticDomain()); closeOperation("New semantic domain is created"); } } else if (action.equals(TreeActionHandler.ACTION_ADD_SEMANTIC_ROLE)) { inputForm.commit(); if (formData.getReferencedSemanticIdentity() != null) { F_Transaction.commitChangedSets(); log.info("Changeset size " + org.s23m.cell.api.Query.changedSets().size()); if (isAnonymousData(formData)) { final Set r = Instantiation.addAnonymousSemanticRole(formData.getSemanticDomain(), formData.getReferencedSemanticIdentity()); log.info("AnonymousSemanticRole " + r.identity().uniqueRepresentationReference() + " created."); } else { final Set r = Instantiation.addSemanticRole(formData.getName(), formData.getPluralName(), formData.getSemanticDomain(), formData.getReferencedSemanticIdentity()); log.info("Semantic role " + r.identity().name() + " created."); } log.info("Changeset size after creation " + org.s23m.cell.api.Query.changedSets().size()); closeOperation("New semantic role is created"); } else { parentTab.getMainApplication().getMainWindow().showNotification( "Missing referenced semantic identity", Window.Notification.TYPE_ERROR_MESSAGE); } } } catch (final EmptyValueException th) { } } private void closeOperation(final String message) { parentTab.getMainApplication().getMainWindow().showNotification(message); ((Editor) getApplication()).updateContainmentTree(); //changeSupport.firePropertyChange(EditorEvents.CHANGESET_MODIFIED.getEventName(), null, null); //changeSupport.removePropertyChangeListener(EditorController.getInstance()); parentTab.closeTab(SemanticInstanceCreationFormLayout.this); } }); final Button cancelBtn = new Button("Cancel", new Button.ClickListener() { public void buttonClick(final ClickEvent event) { inputForm.discard(); ((org.s23m.cell.editor.semanticdomain.Editor) getApplication()).updateContainmentTree(); //changeSupport.firePropertyChange(EditorEvents.CHANGESET_MODIFIED.getEventName(), null, null); changeSupport.removePropertyChangeListener(EditorController.getInstance()); parentTab.closeTab(SemanticInstanceCreationFormLayout.this); } }); buttonBarLayout.addComponent(okBtn); buttonBarLayout.addComponent(cancelBtn); buttonBarLayout.setComponentAlignment(cancelBtn, Alignment.TOP_RIGHT); }
From source file:org.s23m.cell.editor.semanticdomain.ui.components.layout.VertexCreationFormLayout.java
License:Mozilla Public License
private void createInputForm() { setCaption(action.getCaption());/* ww w . j ava2 s .c o m*/ setWidth(WINDOW_WIDTH); setMargin(true); setSpacing(true); final Form inputForm = new Form(); inputForm.setWidth(INPUT_FORM_WIDTH); addComponent(inputForm); inputForm.setImmediate(true); inputForm.setWriteThrough(false); final InstantiationData instData = new InstantiationData(metaInstance, containerInstance.identity().name(), false, "", ""); final BeanItem<InstantiationData> instItem = new BeanItem<InstantiationData>(instData); inputForm.setItemDataSource(instItem); inputForm.setVisibleItemProperties(InstantiationData.getDisplayOrder()); // drop handler final DragAndDropWrapper targetWrapper = new DragAndDropWrapper(inputForm); targetWrapper.setWidth(WINDOW_WIDTH); targetWrapper.setHeight("100%"); targetWrapper.setDropHandler(new DropHandler() { public void drop(final DragAndDropEvent event) { final DataBoundTransferable t = (DataBoundTransferable) event.getTransferable(); final TreeNode node = (TreeNode) t.getData("itemId"); if (SetType.isSemanticDomainNode(node.getSet())) { instData.setIdentity(node.getSet()); inputForm.getField(InstantiationData.NAME).requestRepaint(); inputForm.getField(InstantiationData.PLURAL_NAME).requestRepaint(); inputForm.setComponentError(null); } else { inputForm.getItemDataSource().getItemProperty(InstantiationData.METAINSTANCE) .setValue(node.getSet()); inputForm.getField(InstantiationData.METAINSTANCE_NAME).requestRepaint(); } } public AcceptCriterion getAcceptCriterion() { return AcceptAll.get(); } }); addComponent(targetWrapper); final HorizontalLayout okbar = new HorizontalLayout(); okbar.setSpacing(true); okbar.setHeight(BUTTON_BAR_HEIGHT); inputForm.getFooter().addComponent(okbar); for (final String key : InstantiationData.getDisplayOrder()) { inputForm.getField(key).setWidth(FIELD_WIDTH); } final Button okBtn = new Button(OK_BUTTON_TEXT, new Button.ClickListener() { public void buttonClick(final ClickEvent event) { //create a new instance inputForm.commit(); if (!checkForEmptyInstances(instData)) { Set s = null; String msgCaption = ""; if (action.equals(TreeActionHandler.ACTION_ADD)) { msgCaption = INSTANCE_ADDITION_MSG; if (instData.isAbstract()) { ; s = containerInstance.addAbstract(instData.getMetaInstance(), instData.getIdentity()); } else { s = containerInstance.addConcrete(instData.getMetaInstance(), instData.getIdentity()); } } else if (action.equals(TreeActionHandler.ACTION_INSTANTIATE)) { msgCaption = INSTANCE_INSTANTIATION_MSG; if (instData.isAbstract()) { s = Instantiation.instantiateAbstract(metaInstance, instData.getIdentity()); } else { s = Instantiation.instantiateConcrete(metaInstance, instData.getIdentity()); } } if (s != null && s.identity().name().equals(instData.getName())) { parent.getMainApplication().getMainWindow().showNotification(msgCaption); ((org.s23m.cell.editor.semanticdomain.Editor) getApplication()).updateContainmentTree(); //changeSupport.firePropertyChange(EditorEvents.CHANGESET_MODIFIED.getEventName(), null, null); //changeSupport.removePropertyChangeListener(EditorController.getInstance()); parent.closeTab(VertexCreationFormLayout.this); } else { parent.getMainApplication().getMainWindow().showNotification("Error", s.identity().name(), Notification.TYPE_ERROR_MESSAGE); } } } private boolean checkForEmptyInstances(final InstantiationData instData) { boolean gotEmptyValue = false; if (instData.getMetaInstance() == null) { inputForm.setComponentError(new UserError( DefaultFieldFactory.createCaptionByPropertyId(InstantiationData.METAINSTANCE) + " is missing.")); gotEmptyValue = true; } if (instData.getIdentity() == null) { inputForm.setComponentError( new UserError(DefaultFieldFactory.createCaptionByPropertyId(InstantiationData.IDENTITY) + " is missing.")); gotEmptyValue = true; } return gotEmptyValue; } }); final Button closeBtn = new Button(CANCEL_BUTTON_TEXT, new Button.ClickListener() { public void buttonClick(final ClickEvent event) { inputForm.discard(); ((org.s23m.cell.editor.semanticdomain.Editor) getApplication()).updateContainmentTree(); //changeSupport.firePropertyChange(EditorEvents.CHANGESET_MODIFIED.getEventName(), null, null); changeSupport.removePropertyChangeListener(EditorController.getInstance()); parent.closeTab(VertexCreationFormLayout.this); } }); okbar.addComponent(okBtn); okbar.addComponent(closeBtn); okbar.setComponentAlignment(closeBtn, Alignment.TOP_RIGHT); }