Java Code Examples for org.apache.wicket.model.Model

The following are top voted examples for showing how to use org.apache.wicket.model.Model. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: gitplex-mit   File: NumericPropertyEditor.java   View source code 7 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	input = new TextField<Number>("input", Model.of(getModelObject()));
	input.setType(getPropertyDescriptor().getPropertyClass());
	add(input);

	add(new AttributeAppender("class", new LoadableDetachableModel<String>() {

		@Override
		protected String load() {
			if (hasErrors(true))
				return " has-error";
			else
				return "";
		}
		
	}));
}
 
Example 2
Project: GeoCrawler   File: SeedPage.java   View source code 7 votes vote down vote up
private void addUrlForm() {
  urlForm = new Form<SeedUrl>("urlForm", CompoundPropertyModel.of(Model
      .of(new SeedUrl())));
  urlForm.setOutputMarkupId(true);
  urlForm.add(new TextField<String>("url"));
  urlForm.add(new AjaxSubmitLink("addUrl", urlForm) {
    @Override
    protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
      addSeedUrl();
      urlForm.setModelObject(new SeedUrl());
      target.add(urlForm);
      target.add(seedUrlsTable);
    }
  });
  add(urlForm);
}
 
Example 3
Project: gitplex-mit   File: UserMultiChoiceEditor.java   View source code 6 votes vote down vote up
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
protected void onInitialize() {
	super.onInitialize();
	
   	List<UserFacade> users = new ArrayList<>();
	if (getModelObject() != null) {
		UserManager userManager = GitPlex.getInstance(UserManager.class);
		for (String userName: getModelObject()) {
			User user = userManager.findByName(userName);
			if (user != null)
				users.add(user.getFacade());
		}
	} 
	
	input = new UserMultiChoice("input", new Model((Serializable)users), new UserChoiceProvider(type));
       input.setConvertEmptyInputStringToNull(true);
       
       add(input);
}
 
Example 4
Project: gitplex-mit   File: UserSingleChoiceEditor.java   View source code 6 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();

	User user;
	if (getModelObject() != null)
		user = GitPlex.getInstance(UserManager.class).findByName(getModelObject());
	else
		user = null;
	
	UserFacade facade = user!=null?user.getFacade():null;
   	input = new UserSingleChoice("input", Model.of(facade), new UserChoiceProvider(type));
       input.setConvertEmptyInputStringToNull(true);
       
       // add this to control allowClear flag of select2
   	input.setRequired(propertyDescriptor.isPropertyRequired());
       
       add(input);
}
 
Example 5
Project: gitplex-mit   File: BooleanPropertyEditor.java   View source code 6 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	add(input = new CheckBox("input", Model.of(getModelObject())));

	add(new AttributeAppender("class", new LoadableDetachableModel<String>() {

		@Override
		protected String load() {
			if (hasErrors(true))
				return " has-error";
			else
				return "";
		}
		
	}));
	
}
 
Example 6
Project: gitplex-mit   File: ReflectionBeanViewer.java   View source code 6 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	add(new ListView<PropertyContext<Serializable>>("properties", propertyContexts) {

		@Override
		protected void populateItem(ListItem<PropertyContext<Serializable>> item) {
			PropertyContext<Serializable> propertyContext = item.getModelObject();
			Method propertyGetter = propertyContext.getPropertyGetter();
			Label nameLabel = new Label("name", EditableUtils.getName(propertyGetter));
			item.add(nameLabel);
			OmitName omitName = propertyGetter.getAnnotation(OmitName.class);

			if (omitName != null && omitName.value() != OmitName.Place.EDITOR) {
				nameLabel.setVisible(false);
				item.add(AttributeAppender.append("class", "name-omitted"));
			}

			Serializable bean = (Serializable) ReflectionBeanViewer.this.getDefaultModelObject();
			Serializable propertyValue = (Serializable) propertyContext.getPropertyValue(bean);
			item.add(propertyContext.renderForView("value", Model.of(propertyValue)));
		}

	});
}
 
Example 7
Project: gitplex-mit   File: PasswordPropertyEditor.java   View source code 6 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	input = new PasswordTextField("input", Model.of(getModelObject()));
	input.setRequired(false);
	input.setResetPassword(false);
	add(input);

	String autocomplete = EditableUtils.getAutocomplete(getPropertyDescriptor().getPropertyGetter());
	if (autocomplete != null)
		input.add(AttributeAppender.append("autocomplete", autocomplete));
	
	add(new AttributeAppender("class", new LoadableDetachableModel<String>() {

		@Override
		protected String load() {
			if (hasErrors(true))
				return " has-error";
			else
				return "";
		}
		
	}));
}
 
Example 8
Project: gitplex-mit   File: BranchMultiChoiceEditor.java   View source code 6 votes vote down vote up
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
protected void onInitialize() {
	super.onInitialize();
	
   	BranchChoiceProvider branchProvider = new BranchChoiceProvider(new LoadableDetachableModel<Project>() {

		@Override
		protected Project load() {
			ProjectPage page = (ProjectPage) getPage();
			return page.getProject();
		}
   		
   	});

   	ArrayList<String> projectAndBranches = new ArrayList<>();
	if (getModelObject() != null) 
		projectAndBranches.addAll(getModelObject());
	
	input = new BranchMultiChoice("input", new Model(projectAndBranches), branchProvider);
       
       add(input);
}
 
Example 9
Project: gitplex-mit   File: VerificationMultiChoiceEditor.java   View source code 6 votes vote down vote up
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
protected void onInitialize() {
	super.onInitialize();
	
   	List<String> verifications = new ArrayList<>();
	if (getModelObject() != null) {
		verifications.addAll(getModelObject());
	} 
	
	input = new VerificationMultiChoice("input", new Model((Serializable) verifications), 
			new VerificationChoiceProvider());
       input.setConvertEmptyInputStringToNull(true);
       
       add(input);
}
 
Example 10
Project: gitplex-mit   File: GroupMultiChoiceEditor.java   View source code 6 votes vote down vote up
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
protected void onInitialize() {
	super.onInitialize();
	
   	List<GroupFacade> groups = new ArrayList<>();
	if (getModelObject() != null) {
		GroupManager groupManager = GitPlex.getInstance(GroupManager.class);
		for (String groupName: getModelObject()) {
			Group group = groupManager.find(groupName);
			if (group != null)
				groups.add(group.getFacade());
		}
	} 
	
	input = new GroupMultiChoice("input", new Model((Serializable)groups), new GroupChoiceProvider());
       input.setConvertEmptyInputStringToNull(true);
       
       add(input);
}
 
Example 11
Project: gitplex-mit   File: GroupSingleChoiceEditor.java   View source code 6 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();

	Group group;
	if (getModelObject() != null)
		group = GitPlex.getInstance(GroupManager.class).find(getModelObject());
	else
		group = null;
	
	GroupFacade facade = group!=null?group.getFacade():null;
   	input = new GroupSingleChoice("input", Model.of(facade), new GroupChoiceProvider());
       input.setConvertEmptyInputStringToNull(true);

       // add this to control allowClear flag of select2
   	input.setRequired(propertyDescriptor.isPropertyRequired());
       
       add(input);
}
 
Example 12
Project: gitplex-mit   File: RevisionPicker.java   View source code 6 votes vote down vote up
@Override
public IModel<?> getBody() {
	String iconClass;
	ProjectAndRevision repoAndRevision = new ProjectAndRevision(projectModel.getObject(), revision);
	String label = repoAndRevision.getBranch();
	if (label != null) {
		iconClass = "fa fa-code-fork";
	} else {
		label = repoAndRevision.getTag();
		if (label != null) {
			iconClass = "fa fa-tag";
		} else {
			label = revision;
			if (GitUtils.isHash(label))
				label = GitUtils.abbreviateSHA(label);
			iconClass = "fa fa-ext fa-commit";
		}
	} 
	
	return Model.of(String.format("<i class='%s'></i> <span>%s</span> <i class='fa fa-caret-down'></i>", iconClass, label));
}
 
Example 13
Project: gitplex-mit   File: SourceViewPanel.java   View source code 6 votes vote down vote up
@Override
public WebMarkupContainer newAdditionalActions(String id) {
	WebMarkupContainer actions = new Fragment(id, "actionsFrag", this);
	if (!symbols.isEmpty()) {
		actions.add(new CheckBox("outline", Model.of(isOutlineVisibleInitially())).add(new OnChangeAjaxBehavior() {

			@Override
			protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
				super.updateAjaxAttributes(attributes);
				attributes.setMethod(Method.POST);
			}

			@Override
			protected void onUpdate(AjaxRequestTarget target) {
				toggleOutline(target);
			}
			
		}));
	} else {
		actions.add(new WebMarkupContainer("outline").setVisible(false));
	}
	return actions;
}
 
Example 14
Project: gitplex-mit   File: ProjectListPage.java   View source code 6 votes vote down vote up
@Override
protected List<ComponentRenderer> getBreadcrumbs() {
	List<ComponentRenderer> breadcrumbs = super.getBreadcrumbs();
	
	breadcrumbs.add(new ComponentRenderer() {

		@Override
		public Component render(String componentId) {
			return new ViewStateAwarePageLink<Void>(componentId, ProjectListPage.class) {

				@Override
				public IModel<?> getBody() {
					return Model.of("Projects");
				}
				
			};
		}
		
	});

	return breadcrumbs;
}
 
Example 15
Project: gitplex-mit   File: AdministrationPage.java   View source code 6 votes vote down vote up
@Override
protected List<ComponentRenderer> getBreadcrumbs() {
	List<ComponentRenderer> breadcrumbs = super.getBreadcrumbs();
	
	breadcrumbs.add(new ComponentRenderer() {

		@Override
		public Component render(String componentId) {
			return new ViewStateAwarePageLink<Void>(componentId, SystemSettingPage.class) {

				@Override
				public IModel<?> getBody() {
					return Model.of("Administration");
				}
				
			};
		}
		
	});
	
	return breadcrumbs;
}
 
Example 16
Project: gitplex-mit   File: GroupListPage.java   View source code 6 votes vote down vote up
@Override
protected List<ComponentRenderer> getBreadcrumbs() {
	List<ComponentRenderer> breadcrumbs = super.getBreadcrumbs();
	
	breadcrumbs.add(new ComponentRenderer() {

		@Override
		public Component render(String componentId) {
			return new ViewStateAwarePageLink<Void>(componentId, GroupListPage.class) {

				@Override
				public IModel<?> getBody() {
					return Model.of("Groups");
				}
				
			};
		}
		
	});

	return breadcrumbs;
}
 
Example 17
Project: gitplex-mit   File: UserListPage.java   View source code 6 votes vote down vote up
@Override
protected List<ComponentRenderer> getBreadcrumbs() {
	List<ComponentRenderer> breadcrumbs = super.getBreadcrumbs();
	
	breadcrumbs.add(new ComponentRenderer() {

		@Override
		public Component render(String componentId) {
			return new ViewStateAwarePageLink<Void>(componentId, UserListPage.class) {

				@Override
				public IModel<?> getBody() {
					return Model.of("Users");
				}
				
			};
		}
		
	});

	return breadcrumbs;
}
 
Example 18
Project: gitplex-mit   File: LayoutPage.java   View source code 6 votes vote down vote up
protected List<ComponentRenderer> getBreadcrumbs() {
	List<ComponentRenderer> breadcrumbs = new ArrayList<>();
	
	breadcrumbs.add(new ComponentRenderer() {
		
		@Override
		public Component render(String componentId) {
			return new ViewStateAwarePageLink<Void>(componentId, DashboardPage.class) {

				@Override
				public IModel<?> getBody() {
					return Model.of("Home");
				}
				
			};
		}
	});
	
	return breadcrumbs;
}
 
Example 19
Project: openNaEF   File: LocationViewPage.java   View source code 6 votes vote down vote up
private void createHeader() {
    ExternalLink topLink = UrlUtil.getTopLink("top");
    add(topLink);
    Link<Void> reloadLink = new BookmarkablePageLink<Void>("refresh",
            LocationViewPage.class, LocationUtil.getParameters(current));
    add(reloadLink);

    Label categoryLabel = new Label("category", Model.of(LocationRenderer.getLocationType(current)));
    add(categoryLabel);

    String buildingCode = LocationRenderer.getBuildingCode(current);
    if (buildingCode != null) {
        buildingCode = "Building Code: " + buildingCode;
    }
    Label addressLabel = new Label("buildingCode", Model.of(buildingCode));
    add(addressLabel);

    String popName = LocationRenderer.getPopName(current);
    if (popName != null) {
        popName = "POP Name: " + popName;
    }
    Label popNameLabel = new Label("popName", Model.of(popName));
    add(popNameLabel);
}
 
Example 20
Project: Unicorn   File: Export.java   View source code 6 votes vote down vote up
@SuppressWarnings({"rawtypes", "unchecked"})
private void addEventTable() {
	this.columns = new ArrayList<IColumn<EapEvent, String>>();
	this.columns.add(new PropertyColumn<EapEvent, String>(Model.of("ID"), "ID"));
	this.columns.add(new PropertyColumn<EapEvent, String>(Model.of("Timestamp"), "timestamp"));
	this.columns.add(new PropertyColumn<EapEvent, String>(Model.of("EventType"), "eventType"));
	this.columns.add(new PropertyColumn<EapEvent, String>(Model.of("Values"), "values"));
	this.columns.add(new PropertyColumn<EapEvent, String>(Model.of("Process Instances"), "processInstances"));

	this.columns.add(new AbstractColumn<EapEvent, String>(new Model("Select")) {
		private static final long serialVersionUID = 1L;

		@Override
		public void populateItem(final Item cellItem, final String componentId, final IModel rowModel) {
			final int entryId = ((EapEvent) rowModel.getObject()).getID();
			cellItem.add(new SelectEntryPanel(componentId, entryId, Export.this.eventProvider));
		}
	});

	this.dataTable = new DefaultDataTable<EapEvent, String>("events", this.columns, this.eventProvider, 20);
	this.dataTable.setOutputMarkupId(true);
	this.add(this.dataTable);
}
 
Example 21
Project: engerek   File: LoggingConfigPanel.java   View source code 6 votes vote down vote up
private IModel<LoggingComponentType> createFilterModel(final IModel<FilterConfiguration> model) {
    return new Model<LoggingComponentType>() {

        @Override
        public LoggingComponentType getObject() {
            String name = model.getObject().getName();
            if (StringUtils.isEmpty(name)) {
                return null;
            }
            return LoggingComponentType.fromValue(name);
        }

        @Override
        public void setObject(LoggingComponentType object) {
            model.getObject().setName(object.name());
        }
    };
}
 
Example 22
Project: MBaaS   File: RoleBrowsePage.java   View source code 6 votes vote down vote up
@Override
protected void doInitialize(Border layout) {
    add(layout);

    RoleProvider provider = new RoleProvider();
    provider.selectField("roleId", String.class);

    FilterForm<Map<String, String>> filterForm = new FilterForm<>("filter-form", provider);
    layout.add(filterForm);

    List<IColumn<Map<String, Object>, String>> columns = new ArrayList<>();
    columns.add(new TextFilterColumn(provider, ItemClass.String, Model.of("name"), "name", this::modelValue));
    columns.add(new TextFilterColumn(provider, ItemClass.String, Model.of("description"), "description", this::modelValue));
    columns.add(new TextFilterColumn(provider, ItemClass.Boolean, Model.of("system"), "system", this::modelValue));
    columns.add(new ActionFilterColumn(Model.of("action"), this::actions, this::clickable, this::itemCss, this::itemClick));

    DataTable<Map<String, Object>, String> dataTable = new DefaultDataTable<>("table", columns, provider, 20);
    dataTable.addTopToolbar(new FilterToolbar(dataTable, filterForm));
    filterForm.add(dataTable);

    BookmarkablePageLink<Void> refreshLink = new BookmarkablePageLink<>("refreshLink", RoleBrowsePage.class);
    layout.add(refreshLink);

    BookmarkablePageLink<Void> createLink = new BookmarkablePageLink<>("createLink", RoleCreatePage.class);
    layout.add(createLink);
}
 
Example 23
Project: MBaaS   File: SectionBrowsePage.java   View source code 6 votes vote down vote up
@Override
protected void doInitialize(Border layout) {
    add(layout);

    SectionProvider provider = new SectionProvider();
    provider.selectField("sectionId", String.class);

    FilterForm<Map<String, String>> filterForm = new FilterForm<>("filter-form", provider);
    layout.add(filterForm);

    List<IColumn<Map<String, Object>, String>> columns = new ArrayList<>();
    columns.add(new TextFilterColumn(provider, ItemClass.String, Model.of("title"), "title", this::modelValue));
    columns.add(new TextFilterColumn(provider, ItemClass.Boolean, Model.of("system"), "system", this::modelValue));
    columns.add(new ActionFilterColumn(Model.of("action"), this::actions, this::clickable, this::itemCss, this::itemClick));

    DataTable<Map<String, Object>, String> dataTable = new DefaultDataTable<>("table", columns, provider, 20);
    dataTable.addTopToolbar(new FilterToolbar(dataTable, filterForm));
    filterForm.add(dataTable);

    BookmarkablePageLink<Void> refreshLink = new BookmarkablePageLink<>("refreshLink", SectionBrowsePage.class);
    layout.add(refreshLink);

    BookmarkablePageLink<Void> createLink = new BookmarkablePageLink<>("createLink", SectionCreatePage.class);
    layout.add(createLink);
}
 
Example 24
Project: wicket-stream-download-example   File: HomePageTmpFile.java   View source code 6 votes vote down vote up
public HomePageTmpFile(final PageParameters parameters) throws IOException {
	super(parameters);
	setVersioned(false);

	add(new DownloadLink("download", new LoadableDetachableModel<File>(){

		@Override
		protected File load() {
			Path p;
			try {
				p = Files.createTempFile("google", "html");
				Files.copy(WicketApplication.getInMemoryStream(), p, StandardCopyOption.REPLACE_EXISTING);
				return p.toFile();
			} catch (IOException e) {
				return null;
			}
			
		}
		
	}, Model.of("google.html")).setDeleteAfterDownload(true));
	
}
 
Example 25
Project: Unicorn   File: DerivationTypeDropDownChoicePanel.java   View source code 6 votes vote down vote up
public DerivationTypeDropDownChoicePanel(final String id, final int entryId, final SimulationTreeTableProvider<Object> simulationTreeTableProvider) {
	super(id);
	final Form<Void> layoutForm = new Form<Void>("layoutForm");

	final DropDownChoice<DerivationType> derivationTypeDropDownChoice = new DropDownChoice<DerivationType>("derivationTypeDropDownChoice", Model.of(simulationTreeTableProvider.getDerivationTypeForEntry(entryId)), this.derivationTypes);
	derivationTypeDropDownChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") {

		private static final long serialVersionUID = 1L;

		@Override
		protected void onUpdate(final AjaxRequestTarget target) {
			simulationTreeTableProvider.setDerivationTypeForEntry(derivationTypeDropDownChoice.getModelObject(), entryId);

			if (DerivationTypeDropDownChoicePanel.this.treeTable != null) {
				target.add(DerivationTypeDropDownChoicePanel.this.treeTable);
			} else {
				target.add(DerivationTypeDropDownChoicePanel.this.getPage());
			}
		}
	});

	derivationTypeDropDownChoice.setEnabled(true);
	layoutForm.add(derivationTypeDropDownChoice);
	this.add(layoutForm);
}
 
Example 26
Project: engerek   File: AssignmentsUtil.java   View source code 6 votes vote down vote up
public static IModel<Date> createDateModel(final IModel<XMLGregorianCalendar> model) {
    return new Model<Date>() {

        @Override
        public Date getObject() {
            XMLGregorianCalendar calendar = model.getObject();
            if (calendar == null) {
                return null;
            }
            return MiscUtil.asDate(calendar);
        }

        @Override
        public void setObject(Date object) {
            if (object == null) {
                model.setObject(null);
            } else {
                model.setObject(MiscUtil.asXMLGregorianCalendar(object));
            }
        }
    };
}
 
Example 27
Project: engerek   File: PageInternals.java   View source code 6 votes vote down vote up
public PageInternals() {
     model = new LoadableModel<XMLGregorianCalendar>() {
private static final long serialVersionUID = 1L;

@Override
         protected XMLGregorianCalendar load() {
             return clock.currentTimeXMLGregorianCalendar();
         }
     };

     internalsModel = new Model<>(new InternalsConfigDto());
     tracesMap = new HashMap<>();
     for (InternalOperationClasses op: InternalOperationClasses.values()) {
     	tracesMap.put(op, InternalMonitor.isTrace(op));
     }

     initLayout();
 }
 
Example 28
Project: Unicorn   File: SimpleSimulationPanel.java   View source code 6 votes vote down vote up
private void addProcessSelect(final Form<Void> layoutForm) {
	this.processSelect = new DropDownChoice<String>("processSelect", new Model<String>(), this.processNameList);
	this.processSelect.setOutputMarkupId(true);
	this.processSelect.add(new AjaxFormComponentUpdatingBehavior("onchange") {

		private static final long serialVersionUID = 1L;

		@Override
		protected void onUpdate(final AjaxRequestTarget target) {
			final String processValue = SimpleSimulationPanel.this.processSelect.getValue();
			if (processValue != null && !processValue.isEmpty()) {
				final List<CorrelationProcess> processList = CorrelationProcess.findByName(SimpleSimulationPanel.this.processSelect.getChoices().get(Integer.parseInt(SimpleSimulationPanel.this.processSelect.getValue())));
				if (processList.size() > 0) {
					SimpleSimulationPanel.this.selectedProcess = processList.get(0);

					SimpleSimulationPanel.this.createEventTypeList(SimpleSimulationPanel.this.selectedProcess);
					target.add(SimpleSimulationPanel.this.eventTypeSelect);
				}
			}
			SimpleSimulationPanel.this.treeTableProvider.setCorrelationAttributes(SimpleSimulationPanel.this.selectedProcess.getCorrelationAttributes());
		}
	});

	layoutForm.add(this.processSelect);
}
 
Example 29
Project: engerek   File: CheckBoxHeaderColumn.java   View source code 6 votes vote down vote up
@Override
public Component getHeader(final String componentId) {
    final IModel<Boolean> model = new Model<Boolean>(false);
    CheckBoxPanel panel = new CheckBoxPanel(componentId, model, getEnabled()) {

        @Override
        public void onUpdate(AjaxRequestTarget target) {
        	DataTable table = findParent(DataTable.class);
            boolean selected = model.getObject() != null ? model.getObject() : false;

            onUpdateHeader(target, selected, table);
        }
    };
    panel.setOutputMarkupId(true);
    panel.add(new VisibleEnableBehaviour() {
    	
    	@Override
    	public boolean isVisible() {
    		return CheckBoxHeaderColumn.this.isCheckboxVisible();
    	}
    	
    });

    return panel;
}
 
Example 30
Project: Unicorn   File: BPMNMonitoringPanel.java   View source code 6 votes vote down vote up
private void addProcessSelect(final Form<Void> layoutForm) {
	this.processNameList = new ArrayList<String>();
	for (final CorrelationProcess process : CorrelationProcess.findAll()) {
		this.processNameList.add(process.getName());
	}

	this.processSelect = new DropDownChoice<String>("processSelect", new Model<String>(), this.processNameList);
	this.processSelect.setOutputMarkupId(true);
	this.processSelect.add(new AjaxFormComponentUpdatingBehavior("onchange") {

		private static final long serialVersionUID = 1L;

		@Override
		protected void onUpdate(final AjaxRequestTarget target) {
			BPMNMonitoringPanel.this.process = CorrelationProcess.findByName(BPMNMonitoringPanel.this.processSelect.getChoices().get(Integer.parseInt(BPMNMonitoringPanel.this.processSelect.getValue()))).get(0);
			BPMNMonitoringPanel.this.createProcessInstanceMonitoringProvider();
			target.add(BPMNMonitoringPanel.this.dataTable);
		}

	});

	layoutForm.add(this.processSelect);
}
 
Example 31
Project: engerek   File: TextPopupPanel.java   View source code 6 votes vote down vote up
private void initLayout() {
    final TextField input = initTextField();

    input.add(new AjaxFormComponentUpdatingBehavior("blur") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            //nothing to do, just update model data
        }
    });
    input.add(new Behavior() {

        @Override
        public void bind(Component component) {
            super.bind(component);

            component.add(AttributeModifier.replace("onkeydown",
                    Model.of("if(event.keyCode == 13) {event.preventDefault();}")));
        }
    });
    input.setOutputMarkupId(true);
    add(input);
}
 
Example 32
Project: engerek   File: SynchronizationStep.java   View source code 6 votes vote down vote up
private void reactionEditPerformed(AjaxRequestTarget target, SynchronizationReactionType reaction){
WebMarkupContainer newContainer = new SynchronizationReactionEditor(ID_THIRD_ROW_CONTAINER, new Model<>(reaction), this, parentPage);
getThirdRowContainer().replaceWith(newContainer);

for (SynchronizationActionType action : reaction.getAction()) {
	if (action.getRef() != null) {
		warn(getString("SynchronizationStep.message.unsupportedActionFormat"));
		break;
	}
}

resetSelections(target);
syncDtoModel.getObject().setSelectedReaction(reaction);

      target.add(getThirdRowContainer(), get(ID_OBJECT_SYNC_EDITOR), getPageBase().getFeedbackPanel());
  }
 
Example 33
Project: Unicorn   File: AttributeTreePanel.java   View source code 6 votes vote down vote up
private List<IColumn<TypeTreeNode, String>> createColumns() {
	final List<IColumn<TypeTreeNode, String>> columns = new ArrayList<IColumn<TypeTreeNode, String>>();

	columns.add(new PropertyColumn<TypeTreeNode, String>(Model.of("ID"), "ID"));
	columns.add(new TreeColumn<TypeTreeNode, String>(Model.of("Attributes")));

	columns.add(new AbstractColumn<TypeTreeNode, String>(new Model("Select")) {
		@Override
		public void populateItem(final Item cellItem, final String componentId, final IModel rowModel) {
			final TypeTreeNode attribute = ((TypeTreeNode) rowModel.getObject());
			cellItem.add(new AttributeSelectionPanel(componentId, attribute, AttributeTreePanel.this.attributeIdentifiersAndExpressions, AttributeTreePanel.this.attributeIdentifiersWithExternalKnowledge, AttributeTreePanel.this.advancedRuleEditorPanel.getPatternBuilderPanel()));

		}
	});

	return columns;
}
 
Example 34
Project: engerek   File: MappingEditorDialog.java   View source code 6 votes vote down vote up
public void updateModel(AjaxRequestTarget target, MappingType mapping, boolean isTargetRequired) {
	this.isTargetRequired = isTargetRequired;
	model.setObject(new MappingTypeDto(mapping, getPageBase().getPrismContext()));

	if (inputModel != null) {
		inputModel.setObject(mapping);
	} else {
		inputModel = new Model<>(mapping);
	}

	target.add(getContent());

	if (initialized) {
		((WebMarkupContainer) get(getContentId())).removeAll();
		initialized = false;
	}
}
 
Example 35
Project: vlo-curation   File: BridgeOuterModelTest.java   View source code 6 votes vote down vote up
/**
 * Test of setObject method, of class BridgeOuterModel.
 */
@Test
public void testSetObject() {
    IModel<String> inner = Model.of("inner value");
    IModel<Boolean> state = Model.of(false);

    BridgeOuterModel instance = new BridgeOuterModel(inner, state, "initial outer");

    // set while bridge closed
    instance.setObject("new outer");
    assertEquals("inner value", inner.getObject());

    // open bridge
    state.setObject(true);
    // this does not change the inner value until a value is set on the outer
    assertEquals("inner value", inner.getObject());
    // set a new value
    instance.setObject("new outer/inner");
    // should have been transferred to the inner
    assertEquals("new outer/inner", inner.getObject());
}
 
Example 36
Project: engerek   File: PageResourceWizard.java   View source code 6 votes vote down vote up
private void initLayout() {
      WizardModel wizardModel = new ResourceWizardModel(this);
if (!configurationOnly) {
	wizardModel.add(new NameStep(modelRaw, this));
}
      wizardModel.add(new ConfigurationStep(modelNoFetch, this));
if (!configurationOnly) {
	wizardModel.add(new SchemaStep(modelFull, this));
	wizardModel.add(new SchemaHandlingStep(modelFull, this));
	wizardModel.add(new SynchronizationStep(modelFull, this));
	wizardModel.add(new CapabilityStep(modelFull, this));
}

      Wizard wizard = new Wizard(ID_WIZARD, new Model<>(wizardModel), issuesModel);
      wizard.setOutputMarkupId(true);
      add(wizard);
  }
 
Example 37
Project: gitplex-mit   File: NullableBooleanPropertyEditor.java   View source code 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();

	String stringValue;
	if (getModelObject() != null) {
		if (getModelObject())
			stringValue = "yes";
		else
			stringValue = "no";
	} else {
		stringValue = null;
	}
	input = new DropDownChoice<String>("input", Model.of(stringValue), Lists.newArrayList("yes", "no"));
	
	input.setNullValid(true);
	
	add(input);

	add(new AttributeAppender("class", new LoadableDetachableModel<String>() {

		@Override
		protected String load() {
			if (hasErrors(true))
				return " has-error";
			else
				return "";
		}
		
	}));
}
 
Example 38
Project: gitplex-mit   File: ConcreteListPropertyViewer.java   View source code 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	add(new ListView<PropertyContext<Serializable>>("headers", elementPropertyContexts) {

		@Override
		protected void populateItem(ListItem<PropertyContext<Serializable>> item) {
			item.add(new Label("header", EditableUtils.getName(item.getModelObject().getPropertyGetter())));
		}
		
	});
	add(new ListView<Serializable>("rows", elements) {

		@Override
		protected void populateItem(final ListItem<Serializable> rowItem) {
			rowItem.add(new ListView<PropertyContext<Serializable>>("columns", elementPropertyContexts) {

				@Override
				protected void populateItem(ListItem<PropertyContext<Serializable>> columnItem) {
					PropertyContext<Serializable> propertyContext = columnItem.getModelObject(); 
					Serializable elementPropertyValue = (Serializable) propertyContext.getPropertyValue(rowItem.getModelObject());
					columnItem.add(propertyContext.renderForView("cell", Model.of(elementPropertyValue)));
				}
				
			});
		}
		
	});
	WebMarkupContainer noElements = new WebMarkupContainer("noElements");
	noElements.setVisible(elements.isEmpty());
	noElements.add(AttributeModifier.append("colspan", elementPropertyContexts.size()));
	add(noElements);
}
 
Example 39
Project: gitplex-mit   File: ConcreteListPropertyEditor.java   View source code 5 votes vote down vote up
private WebMarkupContainer addRow(final RepeatingView rows, Serializable element) {
	final WebMarkupContainer row = new WebMarkupContainer(rows.newChildId());
	row.setOutputMarkupId(true);
	rows.add(row);
	
	RepeatingView columns = new RepeatingView("properties");
	row.add(columns);
	
	for (PropertyContext<Serializable> propertyContext: propertyContexts) {
		WebMarkupContainer column = new WebMarkupContainer(columns.newChildId());
		column.add(AttributeAppender.append("class", " " + propertyContext.getPropertyName()));
		columns.add(column);
		
		Serializable propertyValue = (Serializable) propertyContext.getPropertyValue(element);
		PropertyEditor<?> propertyEditor = propertyContext.renderForEdit("propertyEditor", Model.of(propertyValue));
		column.add(propertyEditor);
		column.add(new FencedFeedbackPanel("feedback", propertyEditor));
	}
	
	row.add(new AjaxButton("deleteElement") {

		@Override
		protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
			super.onSubmit(target, form);
			
			target.appendJavaScript($(row).chain("remove").get());
			rows.remove(row);

			if (rows.size() == 0) {
				WebMarkupContainer table = (WebMarkupContainer) ConcreteListPropertyEditor.this.get("listEditor");
				target.add(table.get("noElementsRow"));
			}
			send(ConcreteListPropertyEditor.this, Broadcast.BUBBLE, new EditorChanged(target));								
		}

	}.setDefaultFormProcessing(false));
	
	return row;
}
 
Example 40
Project: gitplex-mit   File: ConfirmativePasswordPropertyEditor.java   View source code 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	input = new PasswordTextField("input", Model.of(getModelObject()));
	input.setResetPassword(true);
	input.setRequired(false);
	add(input);
	
	inputAgain = new PasswordTextField("inputAgain", Model.of(getModelObject()));
	inputAgain.setResetPassword(true);
	inputAgain.setRequired(false);
	add(inputAgain);
	
	String autocomplete = EditableUtils.getAutocomplete(getPropertyDescriptor().getPropertyGetter());
	if (autocomplete != null) {
		input.add(AttributeAppender.append("autocomplete", autocomplete));
		inputAgain.add(AttributeAppender.append("autocomplete", autocomplete));
	}
	
	add(new AttributeAppender("class", new LoadableDetachableModel<String>() {

		@Override
		protected String load() {
			if (hasErrors(true))
				return " has-error";
			else
				return "";
		}
		
	}));
	
}