Java 类com.vaadin.ui.Window.CloseListener 实例源码

项目:incubator-openaz    文件:PDPManagement.java   
protected void movePDP(final PDP pdp, final PDPGroup currentGroup) {
    List<PDPGroup> currentGroups = this.container.getGroups();
    Set<PDPGroup> otherGroups = new HashSet<PDPGroup>(currentGroups);
    if (otherGroups.remove(currentGroup) == false) {
        logger.warn("Group list inconsistency - failed to move pdp to selected group");
        return;
    }
    final SelectPDPGroupWindow editor = new SelectPDPGroupWindow(otherGroups, "What was this?");
    editor.setCaption("Move PDP to group");
    editor.setModal(true);
    editor.addCloseListener(new CloseListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void windowClose(CloseEvent event) {
            if (editor.isSaved()) {
                self.container.movePDP((PDP) pdp, editor.selectedGroup());
            }
        }
    });
    editor.center();
    UI.getCurrent().addWindow(editor);
}
项目:incubator-openaz    文件:PIPManagement.java   
public static void editConfiguration(final EntityItem<PIPConfiguration> entity) {
    final PIPConfigurationEditorWindow editor = new PIPConfigurationEditorWindow(entity);
    if (entity.isPersistent()) {
        editor.setCaption("Edit PIP Configuration " + entity.getEntity().getName());
    } else {
        editor.setCaption("Create New PIP Configuration");
    }
    editor.setModal(true);
    editor.addCloseListener(new CloseListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void windowClose(CloseEvent event) {
            if (editor.isSaved()) {
                if (entity.isPersistent() == false) {
                    ((XacmlAdminUI)UI.getCurrent()).getPIPConfigurations().addEntity(entity.getEntity());
                }
                ((XacmlAdminUI)UI.getCurrent()).refreshPIPConfiguration();
            }
        }                   
    });
    editor.center();
    UI.getCurrent().addWindow(editor);
}
项目:openeos    文件:CachedApplicationFactoryDecorator.java   
@Override
public UIApplication<IUnoVaadinApplication> createApplication(final IUnoVaadinApplication application) {
    UIApplication<IUnoVaadinApplication> uiApplication = cacheMap.get(application);
    if (uiApplication == null) {
        uiApplication = delegate.createApplication(application);
        application.getMainWindow().addListener(new CloseListener() {

            private static final long serialVersionUID = 8932963545406877665L;

            @Override
            public void windowClose(CloseEvent e) {
                // TODO Check if this is called when the session expired
                cacheMap.remove(application);
            }

        });
        cacheMap.put(application, uiApplication);
    }
    return uiApplication;
}
项目:XACML    文件:PDPManagement.java   
protected void movePDP(final PDP pdp, final PDPGroup currentGroup) {
    List<PDPGroup> currentGroups = this.container.getGroups();
    Set<PDPGroup> otherGroups = new HashSet<PDPGroup>(currentGroups);
    if (otherGroups.remove(currentGroup) == false) {
        logger.warn("Group list inconsistency - failed to move pdp to selected group");
        return;
    }
    final SelectPDPGroupWindow editor = new SelectPDPGroupWindow(otherGroups, "What was this?");
    editor.setCaption("Move PDP to group");
    editor.setModal(true);
    editor.addCloseListener(new CloseListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void windowClose(CloseEvent event) {
            if (editor.isSaved()) {
                self.container.movePDP((PDP) pdp, editor.selectedGroup());
            }
        }
    });
    editor.center();
    UI.getCurrent().addWindow(editor);
}
项目:XACML    文件:PIPManagement.java   
public static void editConfiguration(final EntityItem<PIPConfiguration> entity) {
    final PIPConfigurationEditorWindow editor = new PIPConfigurationEditorWindow(entity);
    if (entity.isPersistent()) {
        editor.setCaption("Edit PIP Configuration " + entity.getEntity().getName());
    } else {
        editor.setCaption("Create New PIP Configuration");
    }
    editor.setModal(true);
    editor.addCloseListener(new CloseListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void windowClose(CloseEvent event) {
            if (editor.isSaved()) {
                if (entity.isPersistent() == false) {
                    ((XacmlAdminUI)UI.getCurrent()).getPIPConfigurations().addEntity(entity.getEntity());
                }
                ((XacmlAdminUI)UI.getCurrent()).refreshPIPConfiguration();
            }
        }                   
    });
    editor.center();
    UI.getCurrent().addWindow(editor);
}
项目:konekti    文件:BoxToolbar.java   
private void importFile() throws IllegalArgumentException, IllegalAccessException {
    final UploadViewForm uploadViewForm = new UploadViewForm(null, null);

    uploadViewForm.setWidth("300px");
    uploadViewForm.setHeight("-1px");
    uploadViewForm.addListener(new CloseListener() {                
        @Override
        public void windowClose(CloseEvent e) {
            byte[] file = uploadViewForm.getFile();

            if(listenerImportButton != null)
                listenerImportButton.importButtonClick(new ClickNavigationEvent(btnImport, file, e.getComponent()));


        }
    });

    getApplication().getMainWindow().addWindow(uploadViewForm);

}
项目:mideaas    文件:ShowLogButton.java   
private void openLogWindow() {
    Window w = new Window("Log");
    w.center();
    w.setWidth("80%");
    w.setHeight("80%");
    w.setContent(logView);
    logView.setSizeFull();
    UI.getCurrent().addWindow(w);
    setEnabled(false);
    w.addCloseListener(new CloseListener() {
        @Override
        public void windowClose(CloseEvent e) {
            ShowLogButton.this.setEnabled(true);
        }
    });
}
项目:jdal    文件:AddAction.java   
/**
 * {@inheritDoc}
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void buttonClick(ClickEvent event) {
    final TableComponent<?> table = getTable();
    VaadinView view = table.getEditorView();
    Object bean = BeanUtils.instantiate(table.getEntityClass());
    view.setModel(bean);
    ViewDialog dialog = table.getGuiFactory().newViewDialog(view);
    dialog.setModal(this.modal);
    dialog.addCloseListener(new CloseListener() {

        public void windowClose(CloseEvent e) {
            table.refresh();
        }
    });
    table.getUI().addWindow(dialog);
}
项目:incubator-openaz    文件:PIPResolverComponent.java   
public static void  editResolver(final EntityItem<PIPResolver> entity) {

    final PIPResolverEditorWindow window = new PIPResolverEditorWindow(entity);
    window.setModal(true);
    window.center();
    if (entity.isPersistent()) {
        window.setCaption("Edit Resolver");
    } else {
        window.setCaption("Create Resolver");
    }
    window.addCloseListener(new CloseListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void windowClose(CloseEvent e) {
            //
            // Did the user click "save"?
            //
            if (window.isSaved() == false) {
                return;
            }
            //
            // Adding a new entity?
            //
            if (entity.isPersistent() == false) {
                //
                // Yes - let's official add it
                //
                ((XacmlAdminUI)UI.getCurrent()).getPIPResolvers().addEntity(entity.getEntity());
                ((XacmlAdminUI)UI.getCurrent()).refreshPIPConfiguration();
            }
        }
    });
    UI.getCurrent().addWindow(window);
}
项目:incubator-openaz    文件:PolicyWorkspace.java   
protected void  renamePolicy(final File policy) {
    //
    // Run the rename window
    //
    final RenamePolicyFileWindow window = new RenamePolicyFileWindow(policy.getName());
    window.setCaption("Rename Policy");
    window.setModal(true);
    window.addCloseListener(new CloseListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void windowClose(CloseEvent event) {
            String newFilename = window.getNewFilename();
            if (newFilename == null) {
                //
                // User cancelled
                //
                return;
            }
            Path newPolicy = Paths.get(policy.getParent(), newFilename);
            if (Files.exists(newPolicy)) {
                Notification.show("Cannot rename to an existing file", Notification.Type.ERROR_MESSAGE);
                return;
            }
            try {
                if (policy.renameTo(newPolicy.toFile()) == false) {
                    throw new Exception("No known error, rename failed");
                }
                self.treeContainer.updateItem(newPolicy.getParent().toFile());
            } catch (Exception e) {
                Notification.show("Failed to rename file: " + e.getLocalizedMessage());
            }
        }
    });
    window.center();
    UI.getCurrent().addWindow(window);
}
项目:primecloud-controller    文件:TopBar.java   
public void showCloudEditWindow() {
    MyCloudManage window = new MyCloudManage();
    window.addListener(new CloseListener() {
        @Override
        public void windowClose(CloseEvent e) {
            sender.initialize();
            sender.refresh();
        }
    });
    getApplication().getMainWindow().addWindow(window);
}
项目:XACML    文件:PIPSQLResolverEditorWindow.java   
protected void editCSVAttribute(final Table table, final ResolverAttribute request) {
    assert(this.isCSV());
    //
    // Prompt for the column
    //
    final ColumnSelectionWindow window = new ColumnSelectionWindow((request != null ? request.getColumn() : 0));
    if (request == null) {
        window.setCaption("Input the CSV Column for the new attribute");
    } else {
        window.setCaption("Edit the CSV Column for the attribute");
    }
    window.setModal(true);
    window.center();
    window.addCloseListener(new CloseListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void windowClose(CloseEvent e) {
            //
            // Did the user save?
            //
            if (window.isSaved() == false) {
                return;
            }
            //
            // Save it if its not a new
            //
            if (request != null) {
                request.setColumn(window.getColumn());
            }
            //
            // Now we select the attribute, pass the column
            // in case this is a brand new attribute. Yeah its messy.
            //
            self.editResolverAttribute(table, request, window.getColumn());
        }
    });
    window.center();
    UI.getCurrent().addWindow(window);
}
项目:XACML    文件:PIPResolverComponent.java   
public static void  editResolver(final EntityItem<PIPResolver> entity) {

    final PIPResolverEditorWindow window = new PIPResolverEditorWindow(entity);
    window.setModal(true);
    window.center();
    if (entity.isPersistent()) {
        window.setCaption("Edit Resolver");
    } else {
        window.setCaption("Create Resolver");
    }
    window.addCloseListener(new CloseListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void windowClose(CloseEvent e) {
            //
            // Did the user click "save"?
            //
            if (window.isSaved() == false) {
                return;
            }
            //
            // Adding a new entity?
            //
            if (entity.isPersistent() == false) {
                //
                // Yes - let's official add it
                //
                ((XacmlAdminUI)UI.getCurrent()).getPIPResolvers().addEntity(entity.getEntity());
                ((XacmlAdminUI)UI.getCurrent()).refreshPIPConfiguration();
            }
        }
    });
    UI.getCurrent().addWindow(window);
}
项目:XACML    文件:PolicyWorkspace.java   
protected void  renamePolicy(final File policy) {
    //
    // Run the rename window
    //
    final RenamePolicyFileWindow window = new RenamePolicyFileWindow(policy.getName());
    window.setCaption("Rename Policy");
    window.setModal(true);
    window.addCloseListener(new CloseListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void windowClose(CloseEvent event) {
            String newFilename = window.getNewFilename();
            if (newFilename == null) {
                //
                // User cancelled
                //
                return;
            }
            Path newPolicy = Paths.get(policy.getParent(), newFilename);
            if (Files.exists(newPolicy)) {
                Notification.show("Cannot rename to an existing file", Notification.Type.ERROR_MESSAGE);
                return;
            }
            try {
                if (policy.renameTo(newPolicy.toFile()) == false) {
                    throw new Exception("No known error, rename failed");
                }
                self.treeContainer.updateItem(newPolicy.getParent().toFile());
            } catch (Exception e) {
                Notification.show("Failed to rename file: " + e.getLocalizedMessage());
            }
        }
    });
    window.center();
    UI.getCurrent().addWindow(window);
}
项目:holon-vaadin7    文件:NavigatorActuator.java   
/**
 * Build and configure the Window to use to display a View.
 * @param navigationState Navigation state
 * @param view View to display
 * @param viewName View name
 * @param viewConfiguration View configurator
 * @param windowConfigurator Optional Window configurator
 * @return Window to use to display the given View
 */
@SuppressWarnings("serial")
protected Window buildViewWindow(final String navigationState, final View view, final String viewName,
        final ViewConfiguration viewConfiguration, Consumer<ViewWindowConfigurator> windowConfigurator) {

    // window
    String caption = null;
    if (viewConfiguration != null) {
        caption = LocalizationContext.translate(viewConfiguration.getCaptionMessageCode(),
                viewConfiguration.getCaption(), true);
    }

    final DefaultViewWindow wnd = new DefaultViewWindow(caption, navigationState);

    wnd.setWidth(ViewWindowConfigurator.DEFAULT_WINDOW_WIDTH);
    wnd.setHeight(ViewWindowConfigurator.DEFAULT_WINDOW_WIDTH);

    wnd.setClosable(true);
    wnd.setResizable(true);
    wnd.setDraggable(true);

    wnd.addStyleName(ViewWindowConfigurator.DEFAULT_WINDOW_STYLE_NAME);

    final ViewWindowConfigurator configurator = new DefaultViewWindowConfigurator(wnd);

    // window configuration
    if (viewConfiguration != null) {
        viewConfiguration.accept(configurator);
    }

    // default
    if (defaultViewWindowConfigurator != null) {
        defaultViewWindowConfigurator.accept(configurator);
    }

    // provided
    if (windowConfigurator != null) {
        windowConfigurator.accept(configurator);
    }

    // force modal
    wnd.setModal(true);

    wnd.addCloseListener(new CloseListener() {

        @Override
        public void windowClose(CloseEvent e) {
            onViewWindowClose(navigationState, view, viewConfiguration, e.getWindow());
        }
    });

    return wnd;

}
项目:holon-vaadin7    文件:AbstractDialog.java   
@Override
public Registration addCloseListener(com.holonplatform.vaadin.components.Dialog.CloseListener listener) {
    ObjectUtils.argumentNotNull(listener, "CloseListener must be not null");
    closeListeners.add(listener);
    return () -> closeListeners.remove(listener);
}
项目:holon-vaadin7    文件:AbstractDialog.java   
/**
 * Fire registered close listeners
 * @param actionId Optional action id
 */
protected void fireCloseListeners(Object actionId) {
    for (com.holonplatform.vaadin.components.Dialog.CloseListener listener : closeListeners) {
        listener.dialogClosed(this, actionId);
    }
}
项目:holon-vaadin7    文件:AbstractDialog.java   
@Override
public B withCloseListener(com.holonplatform.vaadin.components.Dialog.CloseListener closeListener) {
    getInstance().addCloseListener(closeListener);
    return builder();
}
项目:holon-vaadin    文件:NavigatorActuator.java   
/**
 * Build and configure the Window to use to display a View.
 * @param navigationState Navigation state
 * @param view View to display
 * @param viewName View name
 * @param viewConfiguration View configurator
 * @param windowConfigurator Optional Window configurator
 * @return Window to use to display the given View
 */
@SuppressWarnings("serial")
protected Window buildViewWindow(final String navigationState, final View view, final String viewName,
        final ViewConfiguration viewConfiguration, Consumer<ViewWindowConfigurator> windowConfigurator) {

    // window
    String caption = null;
    if (viewConfiguration != null) {
        caption = LocalizationContext.translate(viewConfiguration.getCaptionMessageCode(),
                viewConfiguration.getCaption(), true);
    }

    final DefaultViewWindow wnd = new DefaultViewWindow(caption, navigationState);

    wnd.setWidth(ViewWindowConfigurator.DEFAULT_WINDOW_WIDTH);
    wnd.setHeight(ViewWindowConfigurator.DEFAULT_WINDOW_WIDTH);

    wnd.setClosable(true);
    wnd.setResizable(true);
    wnd.setDraggable(true);

    wnd.addStyleName(ViewWindowConfigurator.DEFAULT_WINDOW_STYLE_NAME);

    final ViewWindowConfigurator configurator = new DefaultViewWindowConfigurator(wnd);

    // window configuration
    if (viewConfiguration != null) {
        viewConfiguration.accept(configurator);
    }

    // default
    if (defaultViewWindowConfigurator != null) {
        defaultViewWindowConfigurator.accept(configurator);
    }

    // provided
    if (windowConfigurator != null) {
        windowConfigurator.accept(configurator);
    }

    // force modal
    wnd.setModal(true);

    wnd.addCloseListener(new CloseListener() {

        @Override
        public void windowClose(CloseEvent e) {
            onViewWindowClose(navigationState, view, viewConfiguration, e.getWindow());
        }
    });

    return wnd;

}
项目:holon-vaadin    文件:AbstractDialog.java   
@Override
public Registration addCloseListener(com.holonplatform.vaadin.components.Dialog.CloseListener listener) {
    ObjectUtils.argumentNotNull(listener, "CloseListener must be not null");
    closeListeners.add(listener);
    return () -> closeListeners.remove(listener);
}
项目:holon-vaadin    文件:AbstractDialog.java   
/**
 * Fire registered close listeners
 * @param actionId Optional action id
 */
protected void fireCloseListeners(Object actionId) {
    for (com.holonplatform.vaadin.components.Dialog.CloseListener listener : closeListeners) {
        listener.dialogClosed(this, actionId);
    }
}
项目:holon-vaadin    文件:AbstractDialog.java   
@Override
public B withCloseListener(com.holonplatform.vaadin.components.Dialog.CloseListener closeListener) {
    getInstance().addCloseListener(closeListener);
    return builder();
}
项目:incubator-openaz    文件:PIPParameterComponent.java   
protected void editParameter(final Object source) {
    //
    // Make a copy
    //
    final Object target = source != null ? source : this.config instanceof PIPConfiguration ? new PIPConfigParam() : new PIPResolverParam();
    final PIPParamEditorWindow window = new PIPParamEditorWindow(target);
    window.setModal(true);
    window.setCaption((source == null ? "Create New Parameter" : "Edit Parameter"));
    window.center();
    window.addCloseListener(new CloseListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void windowClose(CloseEvent e) {
            //
            // Did user save?
            //
            if (window.isSaved() == false) {
                return;
            }
            //
            // Yes - was it a brand new object?
            //
            if (source == null) {
                //
                // yes add it to the parent object
                //
                if (self.config instanceof PIPConfiguration) {
                    ((PIPConfiguration) self.config).addPipconfigParam((PIPConfigParam) target);
                } else {
                    ((PIPResolver) self.config).addPipresolverParam((PIPResolverParam) target);
                }
                //
                // add it to the table
                //
                Item item = self.tableParameters.addItem(target);
                if (item == null) {
                    logger.error("Failed to add parameter: " + target);
                } else {
                    self.tableParameters.select(target);
                }
            } else {
                //
                // Copy the parameters over
                //
                if (source instanceof PIPConfigParam) {
                    ((PIPConfigParam) source).setParamName(((PIPConfigParam) target).getParamName());
                    ((PIPConfigParam) source).setParamValue(((PIPConfigParam) target).getParamValue());
                } else {
                    ((PIPResolverParam) source).setParamName(((PIPResolverParam) target).getParamName());
                    ((PIPResolverParam) source).setParamValue(((PIPResolverParam) target).getParamValue());
                }
                //
                // Update the table
                //
                self.tableParameters.refreshRowCache();
            }
        }
    });
    UI.getCurrent().addWindow(window);
}
项目:incubator-openaz    文件:PolicyWorkspace.java   
protected void  importPolicy(final File domain) {
    //
    // Get the current domain
    //
    if (! domain.isDirectory()) {
        logger.error("Table must have a directory selected to import the file.");
        return;
    }
    //
    // Create the upload window
    //
    final PolicyUploadWindow upload = new PolicyUploadWindow(Paths.get(domain.toURI()));
    upload.setCaption("Import Xacml 3.0 Policy File");
    upload.setCloseShortcut(KeyCode.ESCAPE);
    upload.setModal(true);
    upload.addCloseListener(new CloseListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void windowClose(CloseEvent e) {
            //
            // Was it successful?
            //
            Path newFile = upload.getUploadedFile();
            if (newFile == null) {
                return;
            }
            //
            // Add it
            //
            self.addPolicyFileToTree(domain, newFile.toFile());
            //
            // Are we importing anything in the policy file?
            //
            boolean importAttributes = upload.importAttributes();
            boolean importObligations = upload.importObligations();
            boolean importAdvice = upload.importAdvice();
            if (importAttributes || importObligations || importAdvice) {
                //
                // Create our importer
                //
                XACMLPolicyImporter importer = new XACMLPolicyImporter();
                importer.setImportAttributes(importAttributes);
                importer.setImportObligations(importObligations);
                importer.setImportAdvice(importAdvice);     
                importer.setIgnoreStandardAttributes(upload.ignoreStandard());
                //
                // Yes load and scan the policy
                //
                new XACMLPolicyScanner(newFile, importer).scan();
            }
        }
    });
    upload.center();
    UI.getCurrent().addWindow(upload);
}
项目:incubator-openaz    文件:PolicyEditor.java   
protected void editPolicySet(final PolicySetType policy, final PolicySetType parent) {
    logger.info("editPolicySet: " + policy + " parent " + parent);
    //
    // Create a copy
    //
    final PolicySetType newPolicySet = (policy == null ? new PolicySetType() : XACMLObjectCopy.copy(policy));
    //
    // Create window
    //
    final PolicySetEditorWindow window = new PolicySetEditorWindow(newPolicySet);
    window.setCaption(policy == null ? "Create New Policy Set" : "Edit Policy Set");
    window.setModal(true);
    window.addCloseListener(new CloseListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void windowClose(CloseEvent e) {
            //
            // Did the user click save?
            //
            if (window.isSaved() == false) {
                if (logger.isDebugEnabled()) {
                    logger.debug("user did NOT save");
                }
                return;
            }
            //
            // Was it a new Policy Set?
            //
            if (policy == null) {
                logger.info("adding new policy set " + newPolicySet.getPolicySetId());
                //
                // Yes - new add it in
                //
                if (newPolicySet.getTarget() == null) {
                    newPolicySet.setTarget(new TargetType());
                }
                if (self.policyContainer.addItem(newPolicySet, parent) == null) {
                    logger.error("Failed to add new policy set");
                } else {
                    self.tree.setCollapsed(parent, false);
                    self.tree.setCollapsed(newPolicySet, false);
                    self.tree.select(newPolicySet);
                }
            } else {
                logger.info("updating new policy set " + newPolicySet.getPolicySetId());
                //
                // No - copy everything
                //
                policy.setDescription(newPolicySet.getDescription());
                policy.setVersion(newPolicySet.getVersion());
                policy.setPolicyCombiningAlgId(newPolicySet.getPolicyCombiningAlgId());
                //
                // Update
                //
                self.policyContainer.updateItem(policy);
            }
        }           
    });
    window.center();
    UI.getCurrent().addWindow(window);
}
项目:incubator-openaz    文件:PolicyEditor.java   
protected void editPolicy(final PolicyType policy, final PolicySetType parent) {
    //
    // Create a copy
    //
    final PolicyType newPolicy = (policy == null ? new PolicyType() : XACMLObjectCopy.copy(policy));
    //
    // Create window
    //
    final PolicyEditorWindow window = new PolicyEditorWindow(newPolicy);
    window.setCaption(policy == null ? "Create New Policy" : "Edit Policy");
    window.setModal(true);
    window.addCloseListener(new CloseListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void windowClose(CloseEvent e) {
            //
            // Did the user click save?
            //
            if (window.isSaved() == false) {
                return;
            }
            //
            // Was it a new Policy?
            //
            if (policy == null) {
                //
                // Yes - new add it in
                //
                if (newPolicy.getTarget() == null) {
                    newPolicy.setTarget(new TargetType());
                }
                if (self.policyContainer.addItem(newPolicy, parent) == null) {
                    logger.error("Failed to add policy");
                } else {
                    self.tree.setCollapsed(parent, false);
                    self.tree.setCollapsed(newPolicy, false);
                    self.tree.select(newPolicy);
                }
            } else {
                //
                // No - copy everything
                //
                policy.setDescription(newPolicy.getDescription());
                policy.setVersion(newPolicy.getVersion());
                policy.setRuleCombiningAlgId(newPolicy.getRuleCombiningAlgId());
                //
                // Update
                //
                self.policyContainer.updateItem(policy);
            }
        }           
    });
    window.center();
    UI.getCurrent().addWindow(window);
}
项目:incubator-openaz    文件:PolicyEditor.java   
protected void editRule(final RuleType rule, final PolicyType parent) {
    //
    // Create a copy
    //
    final RuleType newRule = (rule == null ? new RuleType() : XACMLObjectCopy.copy(rule));
    //
    // Create window
    //
    final RuleEditorWindow window = new RuleEditorWindow(newRule);
    window.setCaption(rule == null ? "Create New Rule" : "Edit Rule");
    window.setModal(true);
    window.addCloseListener(new CloseListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void windowClose(CloseEvent e) {
            //
            // Did the user click save?
            //
            if (window.isSaved() == false) {
                return;
            }
            //
            // Was this a new rule?
            //
            if (rule == null) {
                //
                // Yes a new rule
                //
                if (newRule.getTarget() == null) {
                    newRule.setTarget(new TargetType());
                }
                if (self.policyContainer.addItem(newRule, parent) == null) {
                    logger.error("Failed to add new rule");
                } else {
                    self.tree.setCollapsed(parent, false);
                    self.tree.setCollapsed(newRule, false);
                    self.tree.select(newRule);
                }
            } else {
                //
                // No - editing existing rule. Copy everything
                //
                rule.setEffect(newRule.getEffect());
                rule.setDescription(newRule.getDescription());
                self.policyContainer.updateItem(rule);
            }
        }
    });
    window.center();
    UI.getCurrent().addWindow(window);
}
项目:incubator-openaz    文件:PolicyEditor.java   
protected void editCondition(final ConditionType condition, final RuleType rule) {
    //
    // Make a copy of it first, in case the user manipulates it
    // and then decides to NOT save it
    //
    final ConditionType copyCondition = (condition == null ? new ConditionType() : XACMLObjectCopy.copy(condition));
    //
    // Create the window
    //
    final ExpressionBuilderComponent expression = new ExpressionBuilderComponent(copyCondition, 
                                        (copyCondition.getExpression() != null ? copyCondition.getExpression().getValue() : null), 
                                        null,
                                        self.policyContainer.getVariables());
    if (condition == null) {
        expression.setCaption("Create An Expression For The Condition");
    } else {
        expression.setCaption("Edit The Condition Expression");
    }
    expression.setModal(true);
    //
    // Add the close listener
    //
    expression.addCloseListener(new CloseListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void windowClose(CloseEvent e) {
            //
            // Did the user hit save?
            //
            if (expression.isSaved() == false) {
                return;
            }
            //
            // Were we creating something new?
            //
            if (condition == null) {
                //
                // Yes add the new one into the container
                //
                if (self.policyContainer.addItem(copyCondition, rule) == null) {
                    logger.error("Failed to add condition");
                } else {
                    self.tree.setCollapsed(rule, false);
                    self.tree.setCollapsed(copyCondition, false);
                    self.tree.select(copyCondition);
                }
            } else {
                //
                // We were editing an existing condition, so copy
                // over the new edited expression.
                //
                condition.setExpression(copyCondition.getExpression());
                //
                // Update the container
                //
                self.policyContainer.updateItem(condition);
            }
        }           
    });
    expression.center();
    UI.getCurrent().addWindow(expression);
}
项目:incubator-openaz    文件:PDPManagement.java   
protected void editPDP(final PDP pdp, final PDPGroup group) {
    final EditPDPWindow editor = new EditPDPWindow(pdp, this.container.getGroups());
    if (pdp == null) {
        editor.setCaption("Create New PDP");
    } else {
        editor.setCaption("Edit PDP " + pdp.getId());
    }
    editor.setModal(true);
    editor.addCloseListener(new CloseListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void windowClose(CloseEvent event) {
            if (editor.isSaved() == false) {
                return;
            }
            try {
                //
                // Adding a new PDP?
                //
                if (pdp == null) {
                    //
                    // Yes tell the container to add it
                    //
                    self.container.addNewPDP(editor.getPDPId(), group, editor.getPDPName(), editor.getPDPDescription());
                } else {
                    //
                    // No tell the container to update it
                    //
                    pdp.setName(editor.getPDPName());
                    pdp.setDescription(editor.getPDPDescription());
                    self.container.updatePDP(pdp);
                }
            } catch (Exception e) {
                String message = "Unable to create PDP.  Reason:\n" + e.getMessage();
                logger.error(message);
                AdminNotification.error(message);
            }
        }
    });
    editor.center();
    UI.getCurrent().addWindow(editor);
}
项目:incubator-openaz    文件:PDPManagement.java   
protected void editPDPGroup(final PDPGroup group) {
    //
    // copy the group
    //
    final StdPDPGroup copyGroup = (group == null ? null : new StdPDPGroup(group));
    //
    //
    //
    final EditPDPGroupWindow editor = new EditPDPGroupWindow(copyGroup, this.container.getGroups(), papEngine);
    if (group == null) {
        editor.setCaption("Create PDP Group");
    } else {
        editor.setCaption("Edit PDP Group " + ((PDPGroup) group).getName());
    }
    editor.setModal(true);
    editor.addCloseListener(new CloseListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void windowClose(CloseEvent event) {
            if (editor.isSaved() == false) {
                return;
            }
            if (group == null) {
                //
                // Creating a new group
                //
                try {
                    self.container.addNewGroup(editor.getGroupName(), editor.getGroupDescription());
                } catch (Exception e) {
                    String message = "Unable to create Group.  Reason:\n" + e.getMessage();
                    logger.error(message);
                    AdminNotification.error(message);
                }
            } else {
                //
                // Update group
                //
                self.container.updateGroup(editor.getUpdatedObject());
            }
        }
    });
    editor.center();
    UI.getCurrent().addWindow(editor);
}
项目:vexer    文件:StatSubmInfoFilterEditor.java   
private void showEditFilterPopup() {
    final Window popup = new Window();
    popup.setWidth("400px");
    popup.setHeight("400px");
    popup.center();
    popup.setModal(true);

    VerticalLayout cont = new VerticalLayout();
    cont.setMargin(true);
    cont.setSpacing(true);

    final FilterEditor<B> editCopy = theEditor.getCopy();

    cont.addComponent(editCopy.getFilterEditView());

    popup.setContent(cont);

    popup.addCloseListener(new CloseListener() {

        /**
         * 
         */
        private static final long serialVersionUID = 8568957374426173040L;

        @Override
        public void windowClose(CloseEvent e) {
            updateLayout();
        }

    });

    // edit's are committed only if OK-button is clicked and
    // editor's checkAndNotify returns true;
    // closing the popup with other methods effectively cancel
    // any edits done

    Button okButton = StandardUIFactory.getOKButton(localizer);

    okButton.addClickListener(new ClickListener() {

        /**
         * 
         */
        private static final long serialVersionUID = -6979725003624509202L;

        @Override
        public void buttonClick(ClickEvent event) {
            if (editCopy.checkAndNotify()) {
                UI.getCurrent().removeWindow(popup);
                updateBackingEditor(editCopy);
            }
        }

    });

    cont.addComponent(okButton);

    UI.getCurrent().addWindow(popup);
}
项目:XACML    文件:PIPParameterComponent.java   
protected void editParameter(final Object source) {
    //
    // Make a copy
    //
    final Object target = (source != null ? source : (this.config instanceof PIPConfiguration ? new PIPConfigParam() : new PIPResolverParam()));
    final PIPParamEditorWindow window = new PIPParamEditorWindow(target);
    window.setModal(true);
    window.setCaption((source == null ? "Create New Parameter" : "Edit Parameter"));
    window.center();
    window.addCloseListener(new CloseListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void windowClose(CloseEvent e) {
            //
            // Did user save?
            //
            if (window.isSaved() == false) {
                return;
            }
            //
            // Yes - was it a brand new object?
            //
            if (source == null) {
                //
                // yes add it to the parent object
                //
                if (self.config instanceof PIPConfiguration) {
                    ((PIPConfiguration) self.config).addPipconfigParam((PIPConfigParam) target);
                } else {
                    ((PIPResolver) self.config).addPipresolverParam((PIPResolverParam) target);
                }
                //
                // add it to the table
                //
                Item item = self.tableParameters.addItem(target);
                if (item == null) {
                    logger.error("Failed to add parameter: " + target);
                } else {
                    self.tableParameters.select(target);
                }
            } else {
                //
                // Copy the parameters over
                //
                if (source instanceof PIPConfigParam) {
                    ((PIPConfigParam) source).setParamName(((PIPConfigParam) target).getParamName());
                    ((PIPConfigParam) source).setParamValue(((PIPConfigParam) target).getParamValue());
                } else {
                    ((PIPResolverParam) source).setParamName(((PIPResolverParam) target).getParamName());
                    ((PIPResolverParam) source).setParamValue(((PIPResolverParam) target).getParamValue());
                }
                //
                // Update the table
                //
                self.tableParameters.refreshRowCache();
            }
        }
    });
    UI.getCurrent().addWindow(window);
}
项目:XACML    文件:PolicyWorkspace.java   
protected void  importPolicy(final File domain) {
    //
    // Get the current domain
    //
    if (! domain.isDirectory()) {
        logger.error("Table must have a directory selected to import the file.");
        return;
    }
    //
    // Create the upload window
    //
    final PolicyUploadWindow upload = new PolicyUploadWindow(Paths.get(domain.toURI()));
    upload.setCaption("Import Xacml 3.0 Policy File");
    upload.setCloseShortcut(KeyCode.ESCAPE);
    upload.setModal(true);
    upload.addCloseListener(new CloseListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void windowClose(CloseEvent e) {
            //
            // Was it successful?
            //
            Path newFile = upload.getUploadedFile();
            if (newFile == null) {
                return;
            }
            //
            // Add it
            //
            self.addPolicyFileToTree(domain, newFile.toFile());
            //
            // Are we importing anything in the policy file?
            //
            boolean importAttributes = upload.importAttributes();
            boolean importObligations = upload.importObligations();
            boolean importAdvice = upload.importAdvice();
            if (importAttributes || importObligations || importAdvice) {
                //
                // Create our importer
                //
                XACMLPolicyImporter importer = new XACMLPolicyImporter();
                importer.setImportAttributes(importAttributes);
                importer.setImportObligations(importObligations);
                importer.setImportAdvice(importAdvice);     
                importer.setIgnoreStandardAttributes(upload.ignoreStandard());
                //
                // Yes load and scan the policy
                //
                new XACMLPolicyScanner(newFile, importer).scan();
            }
        }
    });
    upload.center();
    UI.getCurrent().addWindow(upload);
}
项目:XACML    文件:PolicyEditor.java   
protected void editPolicySet(final PolicySetType policy, final PolicySetType parent) {
    logger.info("editPolicySet: " + policy + " parent " + parent);
    //
    // Create a copy
    //
    final PolicySetType newPolicySet = (policy == null ? new PolicySetType() : XACMLObjectCopy.copy(policy));
    //
    // Create window
    //
    final PolicySetEditorWindow window = new PolicySetEditorWindow(newPolicySet);
    window.setCaption(policy == null ? "Create New Policy Set" : "Edit Policy Set");
    window.setModal(true);
    window.addCloseListener(new CloseListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void windowClose(CloseEvent e) {
            //
            // Did the user click save?
            //
            if (window.isSaved() == false) {
                if (logger.isDebugEnabled()) {
                    logger.debug("user did NOT save");
                }
                return;
            }
            //
            // Was it a new Policy Set?
            //
            if (policy == null) {
                logger.info("adding new policy set " + newPolicySet.getPolicySetId());
                //
                // Yes - new add it in
                //
                if (newPolicySet.getTarget() == null) {
                    newPolicySet.setTarget(new TargetType());
                }
                if (self.policyContainer.addItem(newPolicySet, parent) == null) {
                    logger.error("Failed to add new policy set");
                } else {
                    self.tree.setCollapsed(parent, false);
                    self.tree.setCollapsed(newPolicySet, false);
                    self.tree.select(newPolicySet);
                }
            } else {
                logger.info("updating new policy set " + newPolicySet.getPolicySetId());
                //
                // No - copy everything
                //
                policy.setDescription(newPolicySet.getDescription());
                policy.setVersion(newPolicySet.getVersion());
                policy.setPolicyCombiningAlgId(newPolicySet.getPolicyCombiningAlgId());
                //
                // Update
                //
                self.policyContainer.updateItem(policy);
            }
        }           
    });
    window.center();
    UI.getCurrent().addWindow(window);
}
项目:XACML    文件:PolicyEditor.java   
protected void editPolicy(final PolicyType policy, final PolicySetType parent) {
    //
    // Create a copy
    //
    final PolicyType newPolicy = (policy == null ? new PolicyType() : XACMLObjectCopy.copy(policy));
    //
    // Create window
    //
    final PolicyEditorWindow window = new PolicyEditorWindow(newPolicy);
    window.setCaption(policy == null ? "Create New Policy" : "Edit Policy");
    window.setModal(true);
    window.addCloseListener(new CloseListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void windowClose(CloseEvent e) {
            //
            // Did the user click save?
            //
            if (window.isSaved() == false) {
                return;
            }
            //
            // Was it a new Policy?
            //
            if (policy == null) {
                //
                // Yes - new add it in
                //
                if (newPolicy.getTarget() == null) {
                    newPolicy.setTarget(new TargetType());
                }
                if (self.policyContainer.addItem(newPolicy, parent) == null) {
                    logger.error("Failed to add policy");
                } else {
                    self.tree.setCollapsed(parent, false);
                    self.tree.setCollapsed(newPolicy, false);
                    self.tree.select(newPolicy);
                }
            } else {
                //
                // No - copy everything
                //
                policy.setDescription(newPolicy.getDescription());
                policy.setVersion(newPolicy.getVersion());
                policy.setRuleCombiningAlgId(newPolicy.getRuleCombiningAlgId());
                //
                // Update
                //
                self.policyContainer.updateItem(policy);
            }
        }           
    });
    window.center();
    UI.getCurrent().addWindow(window);
}
项目:XACML    文件:PolicyEditor.java   
protected void editRule(final RuleType rule, final PolicyType parent) {
    //
    // Create a copy
    //
    final RuleType newRule = (rule == null ? new RuleType() : XACMLObjectCopy.copy(rule));
    //
    // Create window
    //
    final RuleEditorWindow window = new RuleEditorWindow(newRule);
    window.setCaption(rule == null ? "Create New Rule" : "Edit Rule");
    window.setModal(true);
    window.addCloseListener(new CloseListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void windowClose(CloseEvent e) {
            //
            // Did the user click save?
            //
            if (window.isSaved() == false) {
                return;
            }
            //
            // Was this a new rule?
            //
            if (rule == null) {
                //
                // Yes a new rule
                //
                if (newRule.getTarget() == null) {
                    newRule.setTarget(new TargetType());
                }
                if (self.policyContainer.addItem(newRule, parent) == null) {
                    logger.error("Failed to add new rule");
                } else {
                    self.tree.setCollapsed(parent, false);
                    self.tree.setCollapsed(newRule, false);
                    self.tree.select(newRule);
                }
            } else {
                //
                // No - editing existing rule. Copy everything
                //
                rule.setEffect(newRule.getEffect());
                rule.setDescription(newRule.getDescription());
                self.policyContainer.updateItem(rule);
            }
        }
    });
    window.center();
    UI.getCurrent().addWindow(window);
}
项目:XACML    文件:PolicyEditor.java   
protected void editCondition(final ConditionType condition, final RuleType rule) {
    //
    // Make a copy of it first, in case the user manipulates it
    // and then decides to NOT save it
    //
    final ConditionType copyCondition = (condition == null ? new ConditionType() : XACMLObjectCopy.copy(condition));
    //
    // Create the window
    //
    final ExpressionBuilderComponent expression = new ExpressionBuilderComponent(copyCondition, 
                                        (copyCondition.getExpression() != null ? copyCondition.getExpression().getValue() : null), 
                                        null,
                                        self.policyContainer.getVariables());
    if (condition == null) {
        expression.setCaption("Create An Expression For The Condition");
    } else {
        expression.setCaption("Edit The Condition Expression");
    }
    expression.setModal(true);
    //
    // Add the close listener
    //
    expression.addCloseListener(new CloseListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void windowClose(CloseEvent e) {
            //
            // Did the user hit save?
            //
            if (expression.isSaved() == false) {
                return;
            }
            //
            // Were we creating something new?
            //
            if (condition == null) {
                //
                // Yes add the new one into the container
                //
                if (self.policyContainer.addItem(copyCondition, rule) == null) {
                    logger.error("Failed to add condition");
                } else {
                    self.tree.setCollapsed(rule, false);
                    self.tree.setCollapsed(copyCondition, false);
                    self.tree.select(copyCondition);
                }
            } else {
                //
                // We were editing an existing condition, so copy
                // over the new edited expression.
                //
                condition.setExpression(copyCondition.getExpression());
                //
                // Update the container
                //
                self.policyContainer.updateItem(condition);
            }
        }           
    });
    expression.center();
    UI.getCurrent().addWindow(expression);
}
项目:XACML    文件:PDPManagement.java   
protected void editPDP(final PDP pdp, final PDPGroup group) {
    final EditPDPWindow editor = new EditPDPWindow(pdp, this.container.getGroups());
    if (pdp == null) {
        editor.setCaption("Create New PDP");
    } else {
        editor.setCaption("Edit PDP " + pdp.getId());
    }
    editor.setModal(true);
    editor.addCloseListener(new CloseListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void windowClose(CloseEvent event) {
            if (editor.isSaved() == false) {
                return;
            }
            try {
                //
                // Adding a new PDP?
                //
                if (pdp == null) {
                    //
                    // Yes tell the container to add it
                    //
                    self.container.addNewPDP(editor.getPDPId(), group, editor.getPDPName(), editor.getPDPDescription());
                } else {
                    //
                    // No tell the container to update it
                    //
                    pdp.setName(editor.getPDPName());
                    pdp.setDescription(editor.getPDPDescription());
                    self.container.updatePDP(pdp);
                }
            } catch (Exception e) {
                String message = "Unable to create PDP.  Reason:\n" + e.getMessage();
                logger.error(message);
                AdminNotification.error(message);
            }
        }
    });
    editor.center();
    UI.getCurrent().addWindow(editor);
}
项目:XACML    文件:PDPManagement.java   
protected void editPDPGroup(final PDPGroup group) {
    //
    // copy the group
    //
    final StdPDPGroup copyGroup = (group == null ? null : new StdPDPGroup(group));
    //
    //
    //
    final EditPDPGroupWindow editor = new EditPDPGroupWindow(copyGroup, this.container.getGroups(), papEngine);
    if (group == null) {
        editor.setCaption("Create PDP Group");
    } else {
        editor.setCaption("Edit PDP Group " + ((PDPGroup) group).getName());
    }
    editor.setModal(true);
    editor.addCloseListener(new CloseListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void windowClose(CloseEvent event) {
            if (editor.isSaved() == false) {
                return;
            }
            if (group == null) {
                //
                // Creating a new group
                //
                try {
                    self.container.addNewGroup(editor.getGroupName(), editor.getGroupDescription());
                } catch (Exception e) {
                    String message = "Unable to create Group.  Reason:\n" + e.getMessage();
                    logger.error(message);
                    AdminNotification.error(message);
                }
            } else {
                //
                // Update group
                //
                self.container.updateGroup(editor.getUpdatedObject());
            }
        }
    });
    editor.center();
    UI.getCurrent().addWindow(editor);
}
项目:vaadin-fluent-api    文件:FluentWindow.java   
/**
 * Adds a CloseListener to the window.
 *
 * For a window the CloseListener is fired when the user closes it (clicks
 * on the close button).
 *
 * For a browser level window the CloseListener is fired when the browser
 * level window is closed. Note that closing a browser level window does not
 * mean it will be destroyed. Also note that Opera does not send events like
 * all other browsers and therefore the close listener might not be called
 * if Opera is used.
 *
 * <p>
 * Since Vaadin 6.5, removing windows using {@link UI#removeWindow(Window)}
 * does fire the CloseListener.
 * </p>
 *
 * @param listener
 *            the CloseListener to add, not null
 * @return this for method chaining
 * @see Window#addCloseListener(CloseListener)
 */
@SuppressWarnings("unchecked")
public default THIS withCloseListener(CloseListener listener) {
    ((Window) this).addCloseListener(listener);
    return (THIS) this;
}