@Override public Object generateCell(Table table, Object obj, Object colId) { // cast the params User user = (User) obj; String colName = colId.toString(); // create the button Button btn = new Button(); btn.addClickListener(new UserButtonClickListener(user.getUserId())); // update the caption if (FIELD_FULLNAME.equals(colName)) { btn.setCaption(user.getFullName()); } else if (FIELD_SCREENNAME.equals(colName)) { btn.setCaption(user.getScreenName()); } else if (FIELD_EMAILADDRESS.equals(colName)) { btn.setCaption(user.getEmailAddress()); } else { btn.setCaption(String.valueOf(user.getUserId())); } btn.setStyleName(Runo.BUTTON_LINK); return btn; }
/** * Instantiates a new SNMP collection table. * * @param dataCollectionConfigDao the OpenNMS data collection configuration DAO */ public SnmpCollectionTable(final DataCollectionConfigDao dataCollectionConfigDao) { this.dataCollectionConfigDao = dataCollectionConfigDao; container.setBeanIdProperty("name"); refreshSnmpCollections(); setContainerDataSource(container); setStyleName(Runo.TABLE_SMALL); setImmediate(true); setSelectable(true); setVisibleColumns(COLUMN_NAMES); setColumnHeaders(COLUMN_LABELS); setWidth("100%"); setHeight("250px"); addListener(new Property.ValueChangeListener() { @SuppressWarnings("unchecked") public void valueChange(Property.ValueChangeEvent event) { if (getValue() != null) { BeanItem<SnmpCollection> item = (BeanItem<SnmpCollection>) getContainerDataSource().getItem(getValue()); updateExternalSource(item); } } }); }
/** * Delete handler. */ private void deleteHandler() { final Object itemId = table.getValue(); if (itemId == null) { getApplication().getMainWindow().showNotification("Please select a RRA from the table."); } else { MessageBox mb = new MessageBox(getApplication().getMainWindow(), "Are you sure?", MessageBox.Icon.QUESTION, "Do you really want to remove the selected RRA?<br/>This action cannot be undone.", new MessageBox.ButtonConfig(MessageBox.ButtonType.YES, "Yes"), new MessageBox.ButtonConfig(MessageBox.ButtonType.NO, "No")); mb.addStyleName(Runo.WINDOW_DIALOG); mb.show(new EventListener() { public void buttonClicked(ButtonType buttonType) { if (buttonType == MessageBox.ButtonType.YES) { table.removeItem(itemId); } } }); } }
/** * Instantiates a new resource type table. * * @param group the OpenNMS Data Collection Group */ public ResourceTypeTable(final DatacollectionGroup group) { OnmsBeanContainer<ResourceType> container = new OnmsBeanContainer<ResourceType>(ResourceType.class); container.addAll(group.getResourceTypeCollection()); setContainerDataSource(container); setStyleName(Runo.TABLE_SMALL); setImmediate(true); setSelectable(true); setVisibleColumns(COLUMN_NAMES); setColumnHeaders(COLUMN_LABELS); setWidth("100%"); setHeight("250px"); addListener(new Property.ValueChangeListener() { @SuppressWarnings("unchecked") public void valueChange(Property.ValueChangeEvent event) { if (getValue() != null) { BeanItem<ResourceType> item = (BeanItem<ResourceType>) getContainerDataSource().getItem(getValue()); updateExternalSource(item); } } }); }
/** * Delete handler. */ private void deleteHandler() { final Object itemId = table.getValue(); if (itemId == null) { getApplication().getMainWindow().showNotification("Please select a MIB Object from the table."); } else { MessageBox mb = new MessageBox(getApplication().getMainWindow(), "Are you sure?", MessageBox.Icon.QUESTION, "Do you really want to remove the selected MIB Object?<br/>This action cannot be undone.", new MessageBox.ButtonConfig(MessageBox.ButtonType.YES, "Yes"), new MessageBox.ButtonConfig(MessageBox.ButtonType.NO, "No")); mb.addStyleName(Runo.WINDOW_DIALOG); mb.show(new EventListener() { public void buttonClicked(ButtonType buttonType) { if (buttonType == MessageBox.ButtonType.YES) { table.removeItem(itemId); } } }); } }
/** * Delete handler. */ private void deleteHandler() { final Object itemId = table.getValue(); if (itemId == null) { getApplication().getMainWindow().showNotification("Please select a Parameter from the table."); } else { MessageBox mb = new MessageBox(getApplication().getMainWindow(), "Are you sure?", MessageBox.Icon.QUESTION, "Do you really want to remove the selected parameter ?<br/>This action cannot be undone.", new MessageBox.ButtonConfig(MessageBox.ButtonType.YES, "Yes"), new MessageBox.ButtonConfig(MessageBox.ButtonType.NO, "No")); mb.addStyleName(Runo.WINDOW_DIALOG); mb.show(new EventListener() { public void buttonClicked(ButtonType buttonType) { if (buttonType == MessageBox.ButtonType.YES) { table.removeItem(itemId); } } }); } }
/** * Delete handler. */ private void deleteHandler() { final Object itemId = table.getValue(); if (itemId == null) { getApplication().getMainWindow().showNotification("Please select a Parameter from the table."); } else { MessageBox mb = new MessageBox(getApplication().getMainWindow(), "Are you sure?", MessageBox.Icon.QUESTION, "Do you really want to remove the selected Storage Strategy?<br/>This action cannot be undone.", new MessageBox.ButtonConfig(MessageBox.ButtonType.YES, "Yes"), new MessageBox.ButtonConfig(MessageBox.ButtonType.NO, "No")); mb.addStyleName(Runo.WINDOW_DIALOG); mb.show(new EventListener() { public void buttonClicked(ButtonType buttonType) { if (buttonType == MessageBox.ButtonType.YES) { table.removeItem(itemId); } } }); } }
/** * Delete handler. */ private void deleteHandler() { final Object itemId = table.getValue(); if (itemId == null) { getApplication().getMainWindow().showNotification("Please select a IncludeCollection from the table."); return; } MessageBox mb = new MessageBox(getApplication().getMainWindow(), "Are you sure?", MessageBox.Icon.QUESTION, "Do you really want to remove the selected Include Collection field<br/>This action cannot be undone.", new MessageBox.ButtonConfig(MessageBox.ButtonType.YES, "Yes"), new MessageBox.ButtonConfig(MessageBox.ButtonType.NO, "No")); mb.addStyleName(Runo.WINDOW_DIALOG); mb.show(new EventListener() { public void buttonClicked(ButtonType buttonType) { if (buttonType == MessageBox.ButtonType.YES) { table.removeItem(itemId); } } }); }
@Override public void init() { if (eventProxy == null) throw new RuntimeException("eventProxy cannot be null."); if (eventConfDao == null) throw new RuntimeException("eventConfDao cannot be null."); if (dataCollectionDao == null) throw new RuntimeException("dataCollectionDao cannot be null."); setTheme(Runo.THEME_NAME); final HorizontalSplitPanel mainPanel = new HorizontalSplitPanel(); final MibConsolePanel mibConsole = new MibConsolePanel(); final MibCompilerPanel mibPanel = new MibCompilerPanel(dataCollectionDao, eventConfDao, eventProxy, mibParser, mibConsole); mainPanel.setSizeFull(); mainPanel.setSplitPosition(25, Sizeable.UNITS_PERCENTAGE); mainPanel.addComponent(mibPanel); mainPanel.addComponent(mibConsole); final Window mainWindow = new Window("MIB Compiler Application", mainPanel); setMainWindow(mainWindow); }
/** * Instantiates a new MIB Console Panel. */ public MibConsolePanel() { super("MIB Console"); addStyleName(Runo.PANEL_LIGHT); clearButton = new Button("Clear Log"); clearButton.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { logContent.removeAllComponents(); } }); addComponent(clearButton); ((VerticalLayout) getContent()).setComponentAlignment(clearButton, Alignment.TOP_RIGHT); logContent = new VerticalLayout(); addComponent(logContent); setSizeFull(); }
@Override public void init() { if (dataCollectionDao == null) throw new RuntimeException("dataCollectionDao cannot be null."); setTheme(Runo.THEME_NAME); Logger logger = new SimpleLogger(); SnmpCollectionPanel scAdmin = new SnmpCollectionPanel(dataCollectionDao, logger); DataCollectionGroupAdminPanel dcgAdmin = new DataCollectionGroupAdminPanel(dataCollectionDao); TabSheet tabs = new TabSheet(); tabs.setStyleName(Runo.TABSHEET_SMALL); tabs.setSizeFull(); tabs.addTab(scAdmin); tabs.addTab(dcgAdmin); final Window mainWindow = new Window("SNMP Collection Administration", tabs); setMainWindow(mainWindow); }
/** * Delete handler. */ private void deleteHandler() { final Object itemId = table.getValue(); if (itemId == null) { getApplication().getMainWindow().showNotification("Please select a Mask Element from the table."); } else { MessageBox mb = new MessageBox(getApplication().getMainWindow(), "Are you sure?", MessageBox.Icon.QUESTION, "Do you really want to remove the selected Mask Element field ?<br/>This action cannot be undone.", new MessageBox.ButtonConfig(MessageBox.ButtonType.YES, "Yes"), new MessageBox.ButtonConfig(MessageBox.ButtonType.NO, "No")); mb.addStyleName(Runo.WINDOW_DIALOG); mb.show(new EventListener() { public void buttonClicked(ButtonType buttonType) { if (buttonType == MessageBox.ButtonType.YES) { table.removeItem(itemId); } } }); } }
/** * Process events. * * @param events the OpenNMS Events * @param logger the logger */ public void processEvents(final Events events, final Logger logger) { if (eventFile.exists()) { MessageBox mb = new MessageBox(getApplication().getMainWindow(), "Are you sure?", MessageBox.Icon.QUESTION, "Do you really want to override the existig file?<br/>All current information will be lost.", new MessageBox.ButtonConfig(MessageBox.ButtonType.YES, "Yes"), new MessageBox.ButtonConfig(MessageBox.ButtonType.NO, "No")); mb.addStyleName(Runo.WINDOW_DIALOG); mb.show(new EventListener() { public void buttonClicked(ButtonType buttonType) { if (buttonType == MessageBox.ButtonType.YES) { validateFile(eventFile, events, logger); } } }); } else { validateFile(eventFile, events, logger); } }
/** * Validate file. * * @param file the file * @param events the events * @param logger the logger */ private void validateFile(final File file, final Events events, final Logger logger) { int eventCount = 0; for (org.opennms.netmgt.xml.eventconf.Event e : events.getEventCollection()) { if (eventConfDao.findByUei(e.getUei()) != null) eventCount++; } if (eventCount == 0) { saveFile(file, events, logger); } else { MessageBox mb = new MessageBox(getApplication().getMainWindow(), "Are you sure?", MessageBox.Icon.QUESTION, eventCount + " of the new events are already on the configuration files. Do you really want to override those events ?", new MessageBox.ButtonConfig(MessageBox.ButtonType.YES, "Yes"), new MessageBox.ButtonConfig(MessageBox.ButtonType.NO, "No")); mb.addStyleName(Runo.WINDOW_DIALOG); mb.show(new EventListener() { public void buttonClicked(ButtonType buttonType) { if (buttonType == MessageBox.ButtonType.YES) { saveFile(file, events, logger); } } }); } }
/** * Instantiates a new event table. * * @param events the OpenNMS events */ public EventTable(final Events events) { container.addAll(events.getEventCollection()); setContainerDataSource(container); setStyleName(Runo.TABLE_SMALL); setImmediate(true); setSelectable(true); setVisibleColumns(COLUMN_NAMES); setColumnHeaders(COLUMN_LABELS); setWidth("100%"); setHeight("250px"); addListener(new Property.ValueChangeListener() { public void valueChange(Property.ValueChangeEvent event) { if (getValue() != null) { updateExternalSource(getEvent(getValue())); } } }); }
/** * Delete handler. */ private void deleteHandler() { final Object itemId = table.getValue(); if (itemId == null) { getApplication().getMainWindow().showNotification("Please select a Mask Varbind from the table."); } else { MessageBox mb = new MessageBox(getApplication().getMainWindow(), "Are you sure?", MessageBox.Icon.QUESTION, "Do you really want to remove the selected Mask Varbind field?<br/>This action cannot be undone.", new MessageBox.ButtonConfig(MessageBox.ButtonType.YES, "Yes"), new MessageBox.ButtonConfig(MessageBox.ButtonType.NO, "No")); mb.addStyleName(Runo.WINDOW_DIALOG); mb.show(new EventListener() { public void buttonClicked(ButtonType buttonType) { if (buttonType == MessageBox.ButtonType.YES) { table.removeItem(itemId); } } }); } }
/** * Instantiates a new events window. * * @param eventConfDao the OpenNMS Events Configuration DAO * @param eventProxy the OpenNMS Events Proxy * @param eventFile the events file * @param events the OpenNMS events object * @param logger the logger object * @throws Exception the exception */ public EventWindow(final EventConfDao eventConfDao, final EventProxy eventProxy, final File eventFile, final Events events, final Logger logger) throws Exception { super(eventFile.getAbsolutePath()); // Using fileName for as the window's name. setScrollable(true); setModal(false); setClosable(false); setDraggable(false); setResizable(false); addStyleName(Runo.WINDOW_DIALOG); setSizeFull(); setContent(new EventPanel(eventConfDao, eventProxy, eventFile, events, logger) { @Override public void cancel() { close(); } @Override public void success() { close(); } @Override public void failure() { close(); } }); }
/** * Delete handler. */ private void deleteHandler() { final Object itemId = table.getValue(); if (itemId == null) { getApplication().getMainWindow().showNotification("Please select a Varbind Decode from the table."); } else { MessageBox mb = new MessageBox(getApplication().getMainWindow(), "Are you sure?", MessageBox.Icon.QUESTION, "Do you really want to remove the selected Varbinds Decode field?<br/>This action cannot be undone.", new MessageBox.ButtonConfig(MessageBox.ButtonType.YES, "Yes"), new MessageBox.ButtonConfig(MessageBox.ButtonType.NO, "No")); mb.addStyleName(Runo.WINDOW_DIALOG); mb.show(new EventListener() { public void buttonClicked(ButtonType buttonType) { if (buttonType == MessageBox.ButtonType.YES) { table.removeItem(itemId); } } }); } }
private void initComponents() { // TODO Auto-generated method stub VerticalLayout contenedor = new VerticalLayout(); contenedor.setMargin(true); contenedor.setSpacing(true); contenedor.setSizeFull(); Label lblTitulo = new Label("Plan actual: " + this.certificado.getCodPlan() + " - " + this.certificado.getDescPlan()); lblTitulo.setStyleName(Runo.LABEL_H2); contenedor.addComponent(lblTitulo); listaSeleccionPlanesDisponibles.setCaption("Planes Disponibles"); listaSeleccionPlanesDisponibles.setMultiSelect(false); listaSeleccionPlanesDisponibles.setSizeFull(); listaSeleccionPlanesDisponibles.setImmediate(true); listaSeleccionPlanesDisponibles.setItemCaptionPropertyId("descripcion"); listaSeleccionPlanesDisponibles.setContainerDataSource(getPlanesDisponibles(this.certificado)); listaSeleccionPlanesDisponibles.setNullSelectionAllowed(false); listaSeleccionPlanesDisponibles.setRows(10); contenedor.addComponent(listaSeleccionPlanesDisponibles); contenedor.setComponentAlignment(listaSeleccionPlanesDisponibles, Alignment.TOP_CENTER); HorizontalLayout botonera = new HorizontalLayout(); botonera.setSpacing(true); botonera.addComponent(btnCancelar); botonera.addComponent(btnConfirmar); contenedor.addComponent(botonera); contenedor.setComponentAlignment(botonera, Alignment.TOP_CENTER); this.setContent(contenedor); }
/** * Instantiates a new data collection window. * * @param parser the MIB parser * @param dataCollectionConfigDao the OpenNMS Data Collection Configuration DAO * @param fileName the MIB's file name * @param dcGroup the OpenNMS data collection group * @param logger the logger object * @throws Exception the exception */ public DataCollectionWindow(final MibParser parser, final DataCollectionConfigDao dataCollectionConfigDao, final String fileName, final DatacollectionGroup dcGroup, final Logger logger) throws Exception { super(fileName); // Using fileName for as the window's name. setScrollable(true); setModal(false); setClosable(false); setDraggable(false); setResizable(false); addStyleName(Runo.WINDOW_DIALOG); setSizeFull(); setContent(new DataCollectionGroupPanel(dataCollectionConfigDao, dcGroup, logger) { @Override public void cancel() { close(); } @Override public void success() { MessageBox mb = new MessageBox(getApplication().getMainWindow(), "Graph Templates", MessageBox.Icon.QUESTION, "Do you want to generate the default graph templates?<br/>All the existing templates will be overriden.", new MessageBox.ButtonConfig(MessageBox.ButtonType.YES, "Yes"), new MessageBox.ButtonConfig(MessageBox.ButtonType.NO, "No")); mb.addStyleName(Runo.WINDOW_DIALOG); mb.show(new EventListener() { public void buttonClicked(ButtonType buttonType) { if (buttonType == MessageBox.ButtonType.YES) { generateGraphTemplates(parser, logger); } close(); } }); } @Override public void failure() { close(); } }); }
/** * Process data collection. * * @param dataCollectionConfigDao the OpenNMS data collection configuration DAO * @param logger the logger */ private void processDataCollection(final DataCollectionConfigDao dataCollectionConfigDao, final Logger logger) { final DatacollectionGroup dcGroup = getOnmsDataCollection(); final File configDir = new File(ConfigFileConstants.getHome(), "etc/datacollection/"); final File file = new File(configDir, dcGroup.getName().replaceAll(" ", "_") + ".xml"); if (file.exists()) { MessageBox mb = new MessageBox(getApplication().getMainWindow(), "Are you sure?", MessageBox.Icon.QUESTION, "Do you really want to override the existig file?<br/>All current information will be lost.", new MessageBox.ButtonConfig(MessageBox.ButtonType.YES, "Yes"), new MessageBox.ButtonConfig(MessageBox.ButtonType.NO, "No")); mb.addStyleName(Runo.WINDOW_DIALOG); mb.show(new EventListener() { public void buttonClicked(ButtonType buttonType) { if (buttonType == MessageBox.ButtonType.YES) { saveFile(file, dcGroup, logger); } } }); } else { if (dataCollectionConfigDao.getAvailableDataCollectionGroups().contains(dcGroup.getName())) { getApplication().getMainWindow().showNotification("There is a group with the same name, please pick another one."); } else { saveFile(file, dcGroup, logger); } } }
public void buttonClick(ClickEvent event) { Button source = event.getButton(); if (source == save) { commit(); setReadOnly(true); saveSnmpCollection(getSnmpCollection()); } if (source == cancel) { discard(); setReadOnly(true); } if (source == edit) { setReadOnly(false); } if (source == delete) { MessageBox mb = new MessageBox(getApplication().getMainWindow(), "Are you sure?", MessageBox.Icon.QUESTION, "Do you really want to remove the selected SNMP Collection?<br/>This action cannot be undone.", new MessageBox.ButtonConfig(MessageBox.ButtonType.YES, "Yes"), new MessageBox.ButtonConfig(MessageBox.ButtonType.NO, "No")); mb.addStyleName(Runo.WINDOW_DIALOG); mb.show(new EventListener() { public void buttonClicked(ButtonType buttonType) { if (buttonType == MessageBox.ButtonType.YES) { setVisible(false); deleteSnmpCollection(getSnmpCollection()); } } }); } }
public void buttonClick(ClickEvent event) { Button source = event.getButton(); if (source == save) { commit(); setReadOnly(true); saveResourceType(getResourceType()); } if (source == cancel) { discard(); setReadOnly(true); } if (source == edit) { setReadOnly(false); } if (source == delete) { // FIXME You cannot delete a resource type if it is being used on any group MessageBox mb = new MessageBox(getApplication().getMainWindow(), "Are you sure?", MessageBox.Icon.QUESTION, "Do you really want to remove the Resource Type " + getResourceType().getName() + "?<br/>This action cannot be undone.", new MessageBox.ButtonConfig(MessageBox.ButtonType.YES, "Yes"), new MessageBox.ButtonConfig(MessageBox.ButtonType.NO, "No")); mb.addStyleName(Runo.WINDOW_DIALOG); mb.show(new EventListener() { public void buttonClicked(ButtonType buttonType) { if (buttonType == MessageBox.ButtonType.YES) { setVisible(false); deleteResourceType(getResourceType()); } } }); } }
public void buttonClick(ClickEvent event) { Button source = event.getButton(); if (source == save) { if (isValid()) { commit(); setReadOnly(true); saveGroup(getGroup()); } else { getWindow().showNotification("There are errors on the MIB Groups", Notification.TYPE_WARNING_MESSAGE); } } if (source == cancel) { discard(); setReadOnly(true); } if (source == edit) { setReadOnly(false); } if (source == delete) { // FIXME You cannot delete a group if it is being used on any systemDef MessageBox mb = new MessageBox(getApplication().getMainWindow(), "Are you sure?", MessageBox.Icon.QUESTION, "Do you really want to remove the Group " + getGroup().getName() + "?<br/>This action cannot be undone.", new MessageBox.ButtonConfig(MessageBox.ButtonType.YES, "Yes"), new MessageBox.ButtonConfig(MessageBox.ButtonType.NO, "No")); mb.addStyleName(Runo.WINDOW_DIALOG); mb.show(new EventListener() { public void buttonClicked(ButtonType buttonType) { if (buttonType == MessageBox.ButtonType.YES) { setVisible(false); deleteGroup(getGroup()); } } }); } }
/** * Instantiates a new MIB object field. * * @param resourceTypes the available resource types */ public MibObjField(final List<String> resourceTypes) { table.setContainerDataSource(container); table.setStyleName(Runo.TABLE_SMALL); table.setVisibleColumns(new Object[]{"oid", "instance", "alias", "type"}); table.setColumnHeader("oid", "OID"); table.setColumnHeader("instance", "Instance"); table.setColumnHeader("alias", "Alias"); table.setColumnHeader("type", "Type"); table.setEditable(!isReadOnly()); table.setSelectable(true); table.setHeight("250px"); table.setWidth("100%"); table.setTableFieldFactory(new MibObjFieldFactory(resourceTypes)); add = new Button("Add", (Button.ClickListener) this); delete = new Button("Delete", (Button.ClickListener) this); toolbar.addComponent(add); toolbar.addComponent(delete); toolbar.setVisible(table.isEditable()); VerticalLayout layout = new VerticalLayout(); layout.addComponent(table); layout.addComponent(toolbar); layout.setComponentAlignment(toolbar, Alignment.MIDDLE_RIGHT); setWriteThrough(false); setValidationVisible(true); setCompositionRoot(layout); }
public void buttonClick(ClickEvent event) { Button source = event.getButton(); if (source == save) { commit(); setReadOnly(true); saveSystemDef(getSystemDef()); } if (source == cancel) { discard(); setReadOnly(true); } if (source == edit) { setReadOnly(false); } if (source == delete) { MessageBox mb = new MessageBox(getApplication().getMainWindow(), "Are you sure?", MessageBox.Icon.QUESTION, "Do you really want to remove the System Definition" + getSystemDef().getName() + "?<br/>This action cannot be undone.", new MessageBox.ButtonConfig(MessageBox.ButtonType.YES, "Yes"), new MessageBox.ButtonConfig(MessageBox.ButtonType.NO, "No")); mb.addStyleName(Runo.WINDOW_DIALOG); mb.show(new EventListener() { public void buttonClicked(ButtonType buttonType) { if (buttonType == MessageBox.ButtonType.YES) { setVisible(false); deleteSystemDef(getSystemDef()); } } }); } }
/** * Instantiates a new file editor window. * * @param file the file * @param logger the logger * @param readOnly true, if you want to display a read only window. */ public FileEditorWindow(final File file, final Logger logger, boolean readOnly) { this.file = file; this.logger = logger; setCaption((readOnly ? "View" : "Edit") + " MIB"); addStyleName(Runo.WINDOW_DIALOG); setModal(true); setClosable(false); setWidth("800px"); setHeight("540px"); editor = new TextArea(); editor.setPropertyDataSource(new TextFileProperty(file)); editor.setWriteThrough(false); editor.setImmediate(false); editor.setSizeFull(); editor.setRows(30); editor.setReadOnly(readOnly); cancel = new Button(readOnly ? "Close" : "Cancel"); cancel.setImmediate(false); cancel.addListener(this); save = new Button("Save"); save.setImmediate(false); save.addListener(this); HorizontalLayout toolbar = new HorizontalLayout(); toolbar.addComponent(cancel); if (!readOnly) toolbar.addComponent(save); addComponent(editor); addComponent(toolbar); ((VerticalLayout) getContent()).setExpandRatio(editor, 1.0f); ((VerticalLayout) getContent()).setComponentAlignment(toolbar, Alignment.BOTTOM_RIGHT); }
/** * Instantiates a new Event Generator window. * * @param defaultUei the default value for UEI base */ public EventUeiWindow(String defaultUei) { setCaption("Generate Events"); setModal(true); setWidth("400px"); setHeight("150px"); setResizable(false); setClosable(false); addStyleName(Runo.WINDOW_DIALOG); ueiBase = new TextField("UEI Base"); ueiBase.setNullSettingAllowed(false); ueiBase.setWriteThrough(false); ueiBase.setWidth("100%"); ueiBase.setRequired(true); ueiBase.setValue(defaultUei); ueiBase.setRequiredError("UEI Base cannot be null."); okButton = new Button("Continue"); okButton.addListener(this); cancelButton = new Button("Cancel"); cancelButton.addListener(this); HorizontalLayout toolbar = new HorizontalLayout(); toolbar.addComponent(okButton); toolbar.addComponent(cancelButton); addComponent(ueiBase); addComponent(toolbar); ((VerticalLayout) getContent()).setComponentAlignment(toolbar, Alignment.BOTTOM_RIGHT); }
/** * Instantiates a new Event Generator window. */ public PromptWindow(String caption, String fieldLabel) { setCaption(caption); setModal(true); setWidth("400px"); setHeight("150px"); setResizable(false); setClosable(false); addStyleName(Runo.WINDOW_DIALOG); fileName = new TextField(fieldLabel); fileName.setNullSettingAllowed(false); fileName.setWriteThrough(false); fileName.setWidth("100%"); fileName.setRequired(true); fileName.setRequiredError("This field cannot be null."); okButton = new Button("Continue"); okButton.addListener(this); cancelButton = new Button("Cancel"); cancelButton.addListener(this); HorizontalLayout toolbar = new HorizontalLayout(); toolbar.addComponent(okButton); toolbar.addComponent(cancelButton); addComponent(fileName); addComponent(toolbar); ((VerticalLayout) getContent()).setComponentAlignment(toolbar, Alignment.BOTTOM_RIGHT); }
public void buttonClick(ClickEvent event) { Button source = event.getButton(); if (source == save) { commit(); setReadOnly(true); saveEvent(getEvent()); } if (source == cancel) { discard(); setReadOnly(true); } if (source == edit) { setReadOnly(false); } if (source == delete) { MessageBox mb = new MessageBox(getApplication().getMainWindow(), "Are you sure?", MessageBox.Icon.QUESTION, "Do you really want to remove the event definition " + getEvent().getUei() + "?<br/>This action cannot be undone.", new MessageBox.ButtonConfig(MessageBox.ButtonType.YES, "Yes"), new MessageBox.ButtonConfig(MessageBox.ButtonType.NO, "No")); mb.addStyleName(Runo.WINDOW_DIALOG); mb.show(new EventListener() { public void buttonClicked(ButtonType buttonType) { if (buttonType == MessageBox.ButtonType.YES) { setVisible(false); deleteEvent(getEvent()); } } }); } }
public SuggestionComponent() { HorizontalLayout horizontalLayout = new HorizontalLayout(); horizontalLayout.setSpacing(true); horizontalLayout.setMargin(true); horizontalLayout.addComponent(iconLayout); iconLayout.setWidth("64px"); VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.setSpacing(true); horizontalLayout.addComponent(verticalLayout); Label titleLabel = new Label("<h1>" + CisConstants.uiSuggestionBox + "</h1>", Label.CONTENT_XML); Label descriptionLabel = new Label(CisConstants.uiSuggestionBoxDescription, Label.CONTENT_XML); Panel descriptionPanel = new Panel(); descriptionPanel.setWidth("500px"); descriptionPanel.addComponent(descriptionLabel); descriptionPanel.setStyleName(Runo.PANEL_LIGHT); verticalLayout.addComponent(titleLabel); verticalLayout.addComponent(descriptionPanel); verticalLayout.addComponent(textArea); HorizontalLayout buttonsLayout = new HorizontalLayout(); buttonsLayout.setSpacing(true); buttonsLayout.addComponent(clearButton); buttonsLayout.addComponent(sendButton); verticalLayout.addComponent(buttonsLayout); sendButton.addListener(this); clearButton.addListener(this); setCompositionRoot(horizontalLayout); }
/** * Instantiates a new group panel. * * @param dataCollectionConfigDao the OpenNMS Data Collection Configuration DAO * @param source the OpenNMS Data Collection Group object * @param logger the logger object */ public GroupPanel(final DataCollectionConfigDao dataCollectionConfigDao, final DatacollectionGroup source, final Logger logger) { addStyleName(Runo.PANEL_LIGHT); form = new GroupForm(dataCollectionConfigDao, source) { @Override public void saveGroup(Group group) { if (isNew) { table.addGroup(group); logger.info("MIB Group " + group.getName() + " has been created."); } else { logger.info("MIB Group " + group.getName() + " has been updated."); } table.refreshRowCache(); } @Override public void deleteGroup(Group group) { logger.info("MIB Group " + group.getName() + " has been updated."); Object itemId = table.getValue(); if (itemId != null) { table.select(null); table.removeItem(itemId); table.refreshRowCache(); } } }; table = new GroupTable(source) { @Override public void updateExternalSource(BeanItem<Group> item) { form.setItemDataSource(item, Arrays.asList(GroupForm.FORM_ITEMS)); form.setVisible(true); form.setReadOnly(true); setIsNew(false); } }; add = new Button("Add Group", new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { Group group = new Group(); group.setName("New Group"); group.setIfType("ignore"); table.updateExternalSource(new BeanItem<Group>(group)); form.setReadOnly(false); setIsNew(true); } }); setSpacing(true); setMargin(true); addComponent(table); addComponent(add); addComponent(form); setComponentAlignment(add, Alignment.MIDDLE_RIGHT); }
/** * Instantiates a new persist selector strategy field. */ public PersistSelectorStrategyField() { combo.setCaption("Class Name"); combo.addItem("org.opennms.netmgt.collectd.PersistAllSelectorStrategy"); // To avoid requires opennms-services combo.addItem("org.opennms.netmgt.collectd.PersistRegexSelectorStrategy"); // To avoid requires opennms-services combo.setNullSelectionAllowed(false); combo.setRequired(true); combo.setImmediate(true); combo.setNewItemsAllowed(true); combo.setNewItemHandler(new NewItemHandler() { public void addNewItem(String newItemCaption) { if (!combo.containsId(newItemCaption)) { combo.addItem(newItemCaption); combo.setValue(newItemCaption); } } }); table.setCaption("Parameters"); table.setContainerDataSource(container); table.setStyleName(Runo.TABLE_SMALL); table.setVisibleColumns(new Object[]{"key", "value"}); table.setColumnHeader("key", "Parameter Name"); table.setColumnHeader("value", "Parameter Value"); table.setColumnExpandRatio("value", 1); table.setEditable(!isReadOnly()); table.setSelectable(true); table.setHeight("125px"); table.setWidth("100%"); add = new Button("Add", (Button.ClickListener) this); delete = new Button("Delete", (Button.ClickListener) this); toolbar.addComponent(add); toolbar.addComponent(delete); toolbar.setVisible(table.isEditable()); VerticalLayout layout = new VerticalLayout(); layout.addComponent(combo); layout.addComponent(table); layout.addComponent(toolbar); layout.setComponentAlignment(toolbar, Alignment.MIDDLE_RIGHT); setCompositionRoot(layout); }
/** * Instantiates a new resource type panel. * * @param dataCollectionConfigDao the OpenNMS Data Collection Configuration DAO * @param source the OpenNMS Data Collection Group object * @param logger the logger object */ public ResourceTypePanel(final DataCollectionConfigDao dataCollectionConfigDao, final DatacollectionGroup source, final Logger logger) { addStyleName(Runo.PANEL_LIGHT); form = new ResourceTypeForm() { @Override public void saveResourceType(ResourceType resourceType) { if (isNew) { table.addResourceType(resourceType); logger.info("Resource type " + resourceType.getName() + " has been created."); } else { logger.info("Resource type " + resourceType.getName() + " has been updated."); } table.refreshRowCache(); } @Override public void deleteResourceType(ResourceType resourceType) { logger.info("Resource type " + resourceType.getName() + " has been removed."); Object itemId = table.getValue(); if (itemId != null) { table.select(null); table.removeItem(itemId); table.refreshRowCache(); } } }; table = new ResourceTypeTable(source) { @Override public void updateExternalSource(BeanItem<ResourceType> item) { form.setItemDataSource(item, Arrays.asList(ResourceTypeForm.FORM_ITEMS)); form.setVisible(true); form.setReadOnly(true); setIsNew(false); } }; add = new Button("Add Resource Type", new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { ResourceType rt = new ResourceType(); rt.setName("New Resource Type"); rt.setLabel("New Resource Type"); rt.setResourceLabel("{index}"); PersistenceSelectorStrategy persistence = new PersistenceSelectorStrategy(); persistence.setClazz("org.opennms.netmgt.collectd.PersistAllSelectorStrategy"); // To avoid requires opennms-services rt.setPersistenceSelectorStrategy(persistence); StorageStrategy storage = new StorageStrategy(); storage.setClazz(IndexStorageStrategy.class.getName()); rt.setStorageStrategy(storage); table.updateExternalSource(new BeanItem<ResourceType>(rt)); form.setReadOnly(false); setIsNew(true); } }); setSpacing(true); setMargin(true); addComponent(table); addComponent(add); addComponent(form); setComponentAlignment(add, Alignment.MIDDLE_RIGHT); }
/** * Instantiates a new storage strategy field. */ public StorageStrategyField() { combo.setCaption("Class Name"); combo.addItem(IndexStorageStrategy.class.getName()); combo.addItem(SiblingColumnStorageStrategy.class.getName()); combo.setNullSelectionAllowed(false); combo.setRequired(true); combo.setNewItemsAllowed(true); combo.setNewItemHandler(new NewItemHandler() { public void addNewItem(String newItemCaption) { if (!combo.containsId(newItemCaption)) { combo.addItem(newItemCaption); combo.setValue(newItemCaption); } } }); table.setCaption("Parameters"); table.setContainerDataSource(container); table.setStyleName(Runo.TABLE_SMALL); table.setVisibleColumns(new Object[]{"key", "value"}); table.setColumnHeader("key", "Parameter Name"); table.setColumnHeader("value", "Parameter Value"); table.setColumnExpandRatio("value", 1); table.setEditable(!isReadOnly()); table.setSelectable(true); table.setHeight("125px"); table.setWidth("100%"); add = new Button("Add", (Button.ClickListener) this); delete = new Button("Delete", (Button.ClickListener) this); toolbar.addComponent(add); toolbar.addComponent(delete); toolbar.setVisible(table.isEditable()); VerticalLayout layout = new VerticalLayout(); layout.addComponent(combo); layout.addComponent(table); layout.addComponent(toolbar); layout.setComponentAlignment(toolbar, Alignment.MIDDLE_RIGHT); setWriteThrough(false); setCompositionRoot(layout); }
/** * Instantiates a new include collection field. * * @param dataCollectionConfigDao the data collection configuration DAO */ public IncludeCollectionField(final DataCollectionConfigDao dataCollectionConfigDao) { table.setCaption("Includes List"); table.setContainerDataSource(container); table.setStyleName(Runo.TABLE_SMALL); table.setVisibleColumns(new Object[]{"type", "value"}); table.setColumnHeaders(new String[]{"Type", "Value"}); table.setSelectable(true); table.setImmediate(true); table.setHeight("125px"); table.setWidth("100%"); add = new Button("Add", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { final IncludeCollectionWrapper obj = new IncludeCollectionWrapper(); IncludeCollectionWindow w = new IncludeCollectionWindow(dataCollectionConfigDao, container, obj) { @Override public void fieldChanged() { table.select(container.addOnmsBean(obj)); } }; getApplication().getMainWindow().addWindow(w); } }); edit = new Button("Edit", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { final Object value = table.getValue(); if (value == null) { getApplication().getMainWindow().showNotification("Please select a IncludeCollection from the table."); return; } IncludeCollectionWindow w = new IncludeCollectionWindow(dataCollectionConfigDao, container, (IncludeCollectionWrapper) value) { @Override public void fieldChanged() { table.refreshRowCache(); } }; getApplication().getMainWindow().addWindow(w); } }); delete = new Button("Delete", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { deleteHandler(); } }); toolbar.addComponent(add); toolbar.addComponent(edit); toolbar.addComponent(delete); toolbar.setVisible(table.isEditable()); VerticalLayout layout = new VerticalLayout(); layout.addComponent(table); layout.addComponent(toolbar); layout.setComponentAlignment(toolbar, Alignment.MIDDLE_RIGHT); setWriteThrough(false); setCompositionRoot(layout); }
/** * Instantiates a new system definition panel. * * @param dataCollectionConfigDao the OpenNMS Data Collection Configuration DAO * @param source the OpenNMS Data Collection Group object * @param logger the logger object */ public SystemDefPanel(final DataCollectionConfigDao dataCollectionConfigDao, final DatacollectionGroup source, final Logger logger) { addStyleName(Runo.PANEL_LIGHT); form = new SystemDefForm(dataCollectionConfigDao, source) { @Override public void saveSystemDef(SystemDef systemDef) { if (isNew) { table.addSystemDef(systemDef); logger.info("System Definition " + systemDef.getName() + " has been added."); } else { logger.info("System Definition " + systemDef.getName() + " has been updated."); } table.refreshRowCache(); } @Override public void deleteSystemDef(SystemDef systemDef) { logger.info("System Definition " + systemDef.getName() + " has been removed."); Object itemId = table.getValue(); if (itemId != null) { table.select(null); table.removeItem(itemId); table.refreshRowCache(); } } }; table = new SystemDefTable(source) { @Override public void updateExternalSource(BeanItem<SystemDef> item) { form.setItemDataSource(item, Arrays.asList(SystemDefForm.FORM_ITEMS)); form.setVisible(true); form.setReadOnly(true); setIsNew(false); } }; add = new Button("Add System Definition", new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { SystemDef sysDef = new SystemDef(); sysDef.setName("New System Definition"); sysDef.setSysoidMask(".1.3.6.1.4.1."); sysDef.setCollect(new Collect()); table.updateExternalSource(new BeanItem<SystemDef>(sysDef)); form.setReadOnly(false); setIsNew(true); } }); setSpacing(true); setMargin(true); addComponent(table); addComponent(add); addComponent(form); setComponentAlignment(add, Alignment.MIDDLE_RIGHT); }
/** * Instantiates a new MIB tree panel. * * @param dataCollectionDao the OpenNMS Data Collection Configuration DAO * @param eventsDao the OpenNMS Events Configuration DAO * @param eventsProxy the OpenNMS Events Proxy * @param mibParser the MIB parser * @param logger the logger */ public MibCompilerPanel(final DataCollectionConfigDao dataCollectionDao, final EventConfDao eventsDao, final EventProxy eventsProxy, final MibParser mibParser, final Logger logger) { super("MIB Compiler"); if (dataCollectionDao == null) throw new RuntimeException("dataCollectionDao cannot be null."); if (eventsProxy == null) throw new RuntimeException("eventProxy cannot be null."); if (eventsDao == null) throw new RuntimeException("eventsDao cannot be null."); this.eventsDao = eventsDao; this.eventsProxy = eventsProxy; this.dataCollectionDao = dataCollectionDao; logger.info("Reading MIBs from " + MIBS_ROOT_DIR); // Make sure MIB directories exist if (!MIBS_COMPILED_DIR.exists()) { if (!MIBS_COMPILED_DIR.mkdirs()) { throw new RuntimeException("Unable to create directory for compiled MIBs (" + MIBS_COMPILED_DIR + ")"); } } if (!MIBS_PENDING_DIR.exists()) { if (!MIBS_PENDING_DIR.mkdirs()) { throw new RuntimeException("Unable to create directory for pending MIBs (" + MIBS_PENDING_DIR + ")"); } } // Parser Configuration this.mibParser = mibParser; mibParser.setMibDirectory(MIBS_COMPILED_DIR); // Initialize Toolbar MibUploadButton upload = new MibUploadButton(MIBS_PENDING_DIR, MIBS_COMPILED_DIR, logger) { public void uploadHandler(String filename) { addTreeItem(filename, PENDING); } }; addComponent(upload); // Initialize MIB Tree mibsTree = new Tree("MIB Tree"); initMibTree(logger); final Label label = new Label("<p>Use the right-click context menu over the MIB tree files, to display the compiler operations.</p>"); label.setContentMode(Label.CONTENT_XHTML); addComponent(label); addComponent(mibsTree); // Panel Setup setSizeFull(); addStyleName(Runo.PANEL_LIGHT); ((VerticalLayout) getContent()).setComponentAlignment(upload, Alignment.TOP_RIGHT); ((VerticalLayout) getContent()).setExpandRatio(mibsTree, 1); }
public void setTitulo(String titulo){ this.titulo.removeAllComponents(); Label lblTitulo = new Label(titulo); lblTitulo.setStyleName(Runo.LABEL_H1); this.titulo.addComponent(lblTitulo); }