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: PasswordPropertyEditor.java   Source Code and License 7 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 2
Project: gitplex-mit   File: NumericPropertyEditor.java   Source Code and License 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 3
Project: GeoCrawler   File: SeedPage.java   Source Code and License 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 4
Project: gitplex-mit   File: UserMultiChoiceEditor.java   Source Code and License 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 5
Project: gitplex-mit   File: UserSingleChoiceEditor.java   Source Code and License 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 6
Project: gitplex-mit   File: BooleanPropertyEditor.java   Source Code and License 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 7
Project: gitplex-mit   File: ReflectionBeanViewer.java   Source Code and License 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 8
Project: gitplex-mit   File: BranchMultiChoiceEditor.java   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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: Unicorn   File: DerivationTypeDropDownChoicePanel.java   Source Code and License 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 25
Project: engerek   File: AssignmentsUtil.java   Source Code and License 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 26
Project: engerek   File: PageInternals.java   Source Code and License 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 27
Project: Unicorn   File: SimpleSimulationPanel.java   Source Code and License 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 28
Project: engerek   File: CheckBoxHeaderColumn.java   Source Code and License 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 29
Project: Unicorn   File: BPMNMonitoringPanel.java   Source Code and License 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 30
Project: engerek   File: TextPopupPanel.java   Source Code and License 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 31
Project: engerek   File: SynchronizationStep.java   Source Code and License 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 32
Project: Unicorn   File: AttributeTreePanel.java   Source Code and License 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 33
Project: engerek   File: MappingEditorDialog.java   Source Code and License 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 34
Project: vlo-curation   File: BridgeOuterModelTest.java   Source Code and License 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 35
Project: engerek   File: PageResourceWizard.java   Source Code and License 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 36
Project: gitplex-mit   File: NullableBooleanPropertyEditor.java   Source Code and License 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 37
Project: gitplex-mit   File: ConcreteListPropertyViewer.java   Source Code and License 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 38
Project: gitplex-mit   File: ConcreteListPropertyEditor.java   Source Code and License 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 39
Project: gitplex-mit   File: ConfirmativePasswordPropertyEditor.java   Source Code and License 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 "";
		}
		
	}));
	
}
 
Example 40
Project: gitplex-mit   File: DatePropertyEditor.java   Source Code and License 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	DateTextFieldConfig config = new DateTextFieldConfig();
	config.autoClose(true);
	config.clearButton(true);
	config.withFormat(DateEditSupport.DATE_INPUT_FORMAT);
	input = new DateTextField("input", Model.of(getModelObject()), config);
	input.setType(getPropertyDescriptor().getPropertyClass());
	Method propertyGetter = getPropertyDescriptor().getPropertyGetter();
	if (propertyGetter.getAnnotation(OmitName.class) != null)
		input.add(AttributeModifier.replace("placeholder", EditableUtils.getName(propertyGetter)));
	
	add(input);

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

		@Override
		protected String load() {
			if (hasErrors(true))
				return " has-error";
			else
				return "";
		}
		
	}));
}
 
Example 41
Project: gitplex-mit   File: RevisionSelector.java   Source Code and License 5 votes vote down vote up
private void onSelectTab(AjaxRequestTarget target) {
	refs = findRefs();
	revField.setModel(Model.of(""));
	revInput = null;
	target.add(revField);
	newItemsView(target);
	String script = String.format("gitplex.server.revisionSelector.bindInputKeys('%s');", getMarkupId(true));
	target.appendJavaScript(script);
	target.focusComponent(revField);
}
 
Example 42
Project: gitplex-mit   File: BranchLink.java   Source Code and License 5 votes vote down vote up
@Override
public IModel<?> getBody() {
	String label;
	if (getPage() instanceof ProjectPage) {
		ProjectPage page = (ProjectPage) getPage();
		if (page.getProject().equals(projectAndBranch.getProject())) 
			label = projectAndBranch.getBranch();
		else 
			label = projectAndBranch.getFQN();
	} else {
		label = projectAndBranch.getFQN();
	}
	return Model.of(label);
}
 
Example 43
Project: gitplex-mit   File: AvatarLink.java   Source Code and License 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	setEnabled(!params.isEmpty());
	setEscapeModelStrings(false);
	
	if (tooltip != null)
		add(new TooltipBehavior(Model.of(tooltip), new TooltipConfig()));
	
	setOutputMarkupId(true);
}
 
Example 44
Project: gitplex-mit   File: ProjectSettingTab.java   Source Code and License 5 votes vote down vote up
public ProjectSettingTab(String title, String iconClass, 
		Class<? extends ProjectSettingPage> mainPageClass, 
		Class<? extends ProjectSettingPage> additionalPageClass1, 
		Class<? extends ProjectSettingPage> additionalPageClass2) {
	super(Model.of(title), mainPageClass, additionalPageClass1, additionalPageClass2);
	this.iconClass = iconClass;
}
 
Example 45
Project: gitplex-mit   File: ProjectSettingTab.java   Source Code and License 5 votes vote down vote up
public ProjectSettingTab(String title, String iconClass,  
		Class<? extends ProjectSettingPage> mainPageClass, 
		Class<? extends ProjectSettingPage> additionalPageClass1, 
		Class<? extends ProjectSettingPage> additionalPageClass2,
		Class<? extends ProjectSettingPage> additionalPageClass3) {
	super(Model.of(title), mainPageClass, additionalPageClass1, additionalPageClass2, additionalPageClass3);
	this.iconClass = iconClass;
}
 
Example 46
Project: gitplex-mit   File: ProjectSettingTab.java   Source Code and License 5 votes vote down vote up
public ProjectSettingTab(String title, String iconClass,  
		Class<? extends ProjectSettingPage> mainPageClass, 
		Class<? extends ProjectSettingPage> additionalPageClass1, 
		Class<? extends ProjectSettingPage> additionalPageClass2,
		Class<? extends ProjectSettingPage> additionalPageClass3,
		Class<? extends ProjectSettingPage> additionalPageClass4) {
	super(Model.of(title), mainPageClass, additionalPageClass1, additionalPageClass2, 
			additionalPageClass3, additionalPageClass4);
	this.iconClass = iconClass;
}
 
Example 47
Project: gitplex-mit   File: ProjectSettingTab.java   Source Code and License 5 votes vote down vote up
public ProjectSettingTab(String title, String iconClass,  
		Class<? extends ProjectSettingPage> mainPageClass, 
		Class<? extends ProjectSettingPage> additionalPageClass1, 
		Class<? extends ProjectSettingPage> additionalPageClass2,
		Class<? extends ProjectSettingPage> additionalPageClass3,
		Class<? extends ProjectSettingPage> additionalPageClass4, 
		Class<? extends ProjectSettingPage> additionalPageClass5) {
	super(Model.of(title), mainPageClass, additionalPageClass1, additionalPageClass2, 
			additionalPageClass3, additionalPageClass4, additionalPageClass5);
	this.iconClass = iconClass;
}
 
Example 48
Project: gitplex-mit   File: CommitOptionPanel.java   Source Code and License 5 votes vote down vote up
private void newChangedContainer(@Nullable AjaxRequestTarget target) {
	WebMarkupContainer changedContainer = new WebMarkupContainer("changed");
	changedContainer.setVisible(change != null);
	changedContainer.setOutputMarkupPlaceholderTag(true);
	if (change != null) {
		changedContainer.add(new BlobDiffPanel("changes", new AbstractReadOnlyModel<Project>() {

			@Override
			public Project getObject() {
				return context.getProject();
			}
			
		}, new Model<PullRequest>(null), change, DiffViewMode.UNIFIED, null, null));
	} else {
		changedContainer.add(new WebMarkupContainer("changes"));
	}
	if (target != null) {
		replace(changedContainer);
		target.add(changedContainer);
		if (change != null) {
			String script = String.format("$('#%s .commit-option input[type=submit]').val('Commit and overwrite');", 
					getMarkupId());
			target.appendJavaScript(script);
		}
	} else {
		add(changedContainer);		
	}
}
 
Example 49
Project: gitplex-mit   File: MarkdownBlobEditor.java   Source Code and License 5 votes vote down vote up
public MarkdownBlobEditor(String id, byte[] initialContent, boolean autoFocus) {
	super(id, Model.of(initialContent));
	this.autoFocus = autoFocus;

	Charset detectedCharset = ContentDetector.detectCharset(getModelObject());
	charset = (detectedCharset!=null?detectedCharset:Charset.defaultCharset()).name();
}
 
Example 50
Project: gitplex-mit   File: MarkdownBlobEditor.java   Source Code and License 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	add(input = new MarkdownEditor("input", Model.of(new String(getModelObject(), Charset.forName(charset))), 
			false) {

		@Override
		protected BlobReferenceSupport getBlobReferenceSupport() {
			return MarkdownBlobEditor.this.getBlobReferenceSupport();
		}

		@Override
		protected String getAutosaveKey() {
			return MarkdownBlobEditor.this.getAutosaveKey();
		}

		@Override
		protected String getBaseUrl() {
			return MarkdownBlobEditor.this.getBaseUrl();
		}
		
	});
	if (!autoFocus) {
		input.add(AttributeAppender.append("class", "no-autofocus"));
	}
	input.setOutputMarkupId(true);
}
 
Example 51
Project: gitplex-mit   File: MarkdownBlobViewPanel.java   Source Code and License 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	Blob blob = context.getProject().getBlob(context.getBlobIdent());
	add(new MarkdownViewer("markdown", Model.of(blob.getText().getContent()), null) {

		@Override
		protected String getBaseUrl() {
			ProjectBlobPage.State state = new ProjectBlobPage.State(context.getBlobIdent());
			return urlFor(ProjectBlobPage.class, ProjectBlobPage.paramsOf(context.getProject(), state)).toString();
		}
		
	});
}
 
Example 52
Project: gitplex-mit   File: SourceFormComponent.java   Source Code and License 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	String source = new String(getModelObject(), Charset.forName(charset));
	add(input = new TextArea<String>("input", Model.of(source)));
	setOutputMarkupId(true);
}
 
Example 53
Project: gitplex-mit   File: ProjectPage.java   Source Code and License 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	List<PageTab> tabs = new ArrayList<>();
	tabs.add(new ProjectTab(Model.of("Files"), "fa fa-fw fa-file-text-o", 0, ProjectBlobPage.class));
	tabs.add(new ProjectTab(Model.of("Commits"), "fa fa-fw fa-ext fa-commit", 0,
			ProjectCommitsPage.class, CommitDetailPage.class));
	tabs.add(new ProjectTab(Model.of("Branches"), "fa fa-fw fa-code-fork", 
			0, ProjectBranchesPage.class));
	tabs.add(new ProjectTab(Model.of("Tags"), "fa fa-fw fa-tag", 
			0, ProjectTagsPage.class));
	
	tabs.add(new ProjectTab(Model.of("Pull Requests"), "fa fa-fw fa-ext fa-branch-compare", 
			0, RequestListPage.class, NewRequestPage.class, RequestDetailPage.class));
	
	tabs.add(new ProjectTab(Model.of("Compare"), "fa fa-fw fa-ext fa-file-diff", 0, RevisionComparePage.class));
	
	if (SecurityUtils.canManage(getProject()))
		tabs.add(new ProjectTab(Model.of("Setting"), "fa fa-fw fa-cog", 0, GeneralSettingPage.class, ProjectSettingPage.class));
	
	WebMarkupContainer sidebar = new WebMarkupContainer("sidebar");
	add(sidebar);
	
	/*
	 * Add mini class here instead of project.js as we want the sidebar to 
	 * be minimized initially even if the page takes some time to load 
	 */
	WebRequest request = (WebRequest) RequestCycle.get().getRequest();
	Cookie cookie = request.getCookie("project.miniSidebar");
	if (cookie != null && "yes".equals(cookie.getValue()))
		sidebar.add(AttributeAppender.append("class", " mini"));
	
	sidebar.add(new Tabbable("projectTabs", tabs));
}
 
Example 54
Project: gitplex-mit   File: GroupTab.java   Source Code and License 5 votes vote down vote up
public GroupTab(String title, String iconClass, Class<? extends GroupPage> mainPageClass, 
		Class<? extends GroupPage> additionalPageClass1, 
		Class<? extends GroupPage> additionalPageClass2) {
	super(Model.of(title), mainPageClass, additionalPageClass1, additionalPageClass2);
	
	this.iconClass = iconClass;
}
 
Example 55
Project: gitplex-mit   File: GroupTab.java   Source Code and License 5 votes vote down vote up
public GroupTab(String title, String iconClass, Class<? extends GroupPage> mainPageClass, 
		Class<? extends GroupPage> additionalPageClass1, 
		Class<? extends GroupPage> additionalPageClass2, 
		Class<? extends GroupPage> additionalPageClass3) {
	super(Model.of(title), mainPageClass, additionalPageClass1, additionalPageClass2, additionalPageClass3);
	
	this.iconClass = iconClass;
}
 
Example 56
Project: gitplex-mit   File: UserTab.java   Source Code and License 5 votes vote down vote up
public UserTab(String title, String iconClass, Class<? extends UserPage> mainPageClass, 
		Class<? extends UserPage> additionalPageClass1, 
		Class<? extends UserPage> additionalPageClass2) {
	super(Model.of(title), mainPageClass, additionalPageClass1, additionalPageClass2);
	
	this.iconClass = iconClass;
}
 
Example 57
Project: gitplex-mit   File: UserTab.java   Source Code and License 5 votes vote down vote up
public UserTab(String title, String iconClass, Class<? extends UserPage> mainPageClass, 
		Class<? extends UserPage> additionalPageClass1, 
		Class<? extends UserPage> additionalPageClass2, 
		Class<? extends UserPage> additionalPageClass3) {
	super(Model.of(title), mainPageClass, additionalPageClass1, additionalPageClass2, additionalPageClass3);
	
	this.iconClass = iconClass;
}
 
Example 58
Project: openNaEF   File: LinkEditPage.java   Source Code and License 5 votes vote down vote up
private Link<Void> createLink(String id, PortDto port) {
    PageParameters param = NodeUtil.getNodeParameters(port);
    Link<Void> link = new BookmarkablePageLink<Void>(id, SimpleNodeDetailPage.class, param);
    link.setEnabled(port != null);
    link.add(new Label("nodeName", new Model<String>(NodeUtil.getNodeName(port))));
    return link;
}
 
Example 59
Project: openNaEF   File: HistoryUtil.java   Source Code and License 5 votes vote down vote up
public static ExternalLink createHistoryLink(NaefDto dto) {
    try {
        CoreConfiguration config = CoreConfiguration.getInstance();
        String url = config.getInventoryHistoryUrl() + (dto != null ? DtoUtil.getMvoId(dto).toString() : "");
        ExternalLink link = new ExternalLink("history", Model.of(url), Model.of("History"));
        link.setEnabled(dto != null);
        link.setVisible(dto != null);
        return link;
    } catch (Exception e) {
        throw ExceptionUtils.throwAsRuntime(e);
    }
}
 
Example 60
Project: openNaEF   File: HistoryUtil.java   Source Code and License 5 votes vote down vote up
public static ExternalLink createHistoryLink(NaefDto dto, String label) {
    try {
        CoreConfiguration config = CoreConfiguration.getInstance();
        String url = config.getInventoryHistoryUrl() + (dto != null ? DtoUtil.getMvoId(dto).toString() : "");
        ExternalLink link = new ExternalLink("history", Model.of(url), Model.of(label));
        link.setEnabled(dto != null);
        link.setVisible(dto != null);
        return link;
    } catch (Exception e) {
        throw ExceptionUtils.throwAsRuntime(e);
    }
}