Java Code Examples for org.apache.wicket.markup.repeater.RepeatingView#add()

The following examples show how to use org.apache.wicket.markup.repeater.RepeatingView#add() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GanttChartEditTreeTablePanel.java    From projectforge-webapp with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void initializeColumnHeads()
{
  int col = 0;
  colHeadRepeater = new RepeatingView("cols");
  treeTableHead.add(colHeadRepeater);
  colHeadRepeater.add(createColHead("task"));
  colHeadRepeater.add(createEmtpyColumnHead(16)); // Column for edit icon.
  colHeadRepeater.add(SingleImagePanel
      .createTooltipImage(colHeadRepeater.newChildId(), WebConstants.IMAGE_EYE, getString("gantt.tooltip.isVisible"))
      .add(AttributeModifier.replace("style", "width: 16px;")).setRenderBodyOnly(false));
  addColumnHead(col++, "title");
  addColumnHead(col++, "gantt.startDate");
  addColumnHead(col++, "gantt.duration");
  addColumnHead(col++, "gantt.endDate");
  addColumnHead(col++, "task.progress");
  addColumnHead(col++, "gantt.predecessor");
  addColumnHead(col++, "gantt.predecessorOffset");
  addColumnHead(col++, "gantt.relationType.short");
  addColumnHead(col++, "gantt.objectType.short");
}
 
Example 2
Source File: AbstractSecuredPage.java    From projectforge-webapp with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("serial")
private void addBreadCrumbs(final RepeatingView breadcrumbItems, final AbstractSecuredPage page)
{
  final WebPage returnTo = page.getReturnToPage();
  if (returnTo != null && returnTo instanceof AbstractSecuredPage) {
    addBreadCrumbs(breadcrumbItems, (AbstractSecuredPage) returnTo);
  }
  final WebMarkupContainer li = new WebMarkupContainer(breadcrumbItems.newChildId());
  breadcrumbItems.add(li);
  final Link<Void> pageLink = new Link<Void>("link") {

    @Override
    public void onClick()
    {
      setResponsePage(page);
    }
  };
  li.add(pageLink);
  pageLink.add(new Label("label", page.getTitle()));
}
 
Example 3
Source File: IssueActivitiesPanel.java    From onedev with MIT License 6 votes vote down vote up
@Override
protected void onBeforeRender() {
	activitiesView = new RepeatingView("activities");
	addOrReplace(activitiesView);
	Issue issue = getIssue();

	for (IssueActivity activity: getActivities()) {
		if (issue.isVisitedAfter(activity.getDate())) {
			activitiesView.add(newActivityRow(activitiesView.newChildId(), activity));
		} else {
			Component row = newActivityRow(activitiesView.newChildId(), activity);
			row.add(AttributeAppender.append("class", "new"));
			activitiesView.add(row);
		}
	}		
	
	super.onBeforeRender();
}
 
Example 4
Source File: AccessEditTablePanel.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
private void addAccessRow(final RepeatingView rowRepeater, final AccessEntryDO accessEntry)
{
  final WebMarkupContainer row = new WebMarkupContainer(rowRepeater.newChildId());
  rowRepeater.add(row);
  row.add(new Label("area", getString(accessEntry.getAccessType().getI18nKey())));
  final ButtonGroupPanel groupPanel = new ButtonGroupPanel("checkboxes").setToggleButtons();
  row.add(groupPanel);
  groupPanel.addButton(new CheckBoxButton(groupPanel.newChildId(), new PropertyModel<Boolean>(accessEntry, "accessSelect"), getString("access.type.select")));
  groupPanel.addButton(new CheckBoxButton(groupPanel.newChildId(), new PropertyModel<Boolean>(accessEntry, "accessInsert"), getString("access.type.insert")));
  groupPanel.addButton(new CheckBoxButton(groupPanel.newChildId(), new PropertyModel<Boolean>(accessEntry, "accessUpdate"), getString("access.type.update")));
  groupPanel.addButton(new CheckBoxButton(groupPanel.newChildId(), new PropertyModel<Boolean>(accessEntry, "accessDelete"), getString("access.type.delete")));
}
 
Example 5
Source File: TeamCalImportStoragePanel.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @see org.projectforge.web.core.importstorage.AbstractImportStoragePanel#addHeadColumns(org.apache.wicket.markup.repeater.RepeatingView)
 */
@Override
protected void addHeadColumns(final RepeatingView headColRepeater)
{
  headColRepeater.add(new Label(headColRepeater.newChildId(), getString("plugins.teamcal.event.subject")));
  headColRepeater.add(new Label(headColRepeater.newChildId(), getString("plugins.teamcal.event.location")));
  headColRepeater.add(new Label(headColRepeater.newChildId(), getString("plugins.teamcal.event.allDay")));
  headColRepeater.add(new Label(headColRepeater.newChildId(), getString("plugins.teamcal.event.beginDate")));
  headColRepeater.add(new Label(headColRepeater.newChildId(), getString("plugins.teamcal.event.endDate")));
  headColRepeater.add(new Label(headColRepeater.newChildId(), getString("plugins.teamcal.event.note")));
  headColRepeater.add(new Label(headColRepeater.newChildId(), getString("plugins.teamcal.event.recurrence")));
  headColRepeater.add(new Label(headColRepeater.newChildId(), getString("plugins.teamcal.event.recurrence.until")));
}
 
Example 6
Source File: AbstractImportStoragePanel.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
protected Component addCell(final RepeatingView cellRepeater, final Component comp, final String style)
{
  final WebMarkupContainer cell = new WebMarkupContainer(cellRepeater.newChildId());
  cellRepeater.add(cell);
  cell.add(comp);
  if (style != null) {
    comp.add(AttributeModifier.replace("style", style));
  }
  return comp;
}
 
Example 7
Source File: SetupImportForm.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
@Override
@SuppressWarnings("serial")
protected void init()
{
  add(createFeedbackPanel());
  final GridBuilder gridBuilder = newGridBuilder(this, "flowform");
  gridBuilder.newFormHeading(getString("import"));
  {
    // Upload dump file
    final FieldsetPanel fs = gridBuilder.newFieldset(getString("administration.setup.dumpFile"));
    fileUploadField = new FileUploadField(FileUploadPanel.WICKET_ID);
    fs.add(new FileUploadPanel(fs.newChildId(), fileUploadField));
  }
  final RepeatingView actionButtons = new RepeatingView("buttons");
  add(actionButtons);
  {
    final Button importButton = new Button(SingleButtonPanel.WICKET_ID, new Model<String>("import")) {
      @Override
      public final void onSubmit()
      {
        parentPage.upload();
      }
    };
    final SingleButtonPanel importButtonPanel = new SingleButtonPanel(actionButtons.newChildId(), importButton, getString("import"),
        SingleButtonPanel.DEFAULT_SUBMIT);
    actionButtons.add(importButtonPanel);
  }
}
 
Example 8
Source File: MenuConfigContent.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
public MenuConfigContent(final String id, final Menu menu)
{
  super(id);
  final RepeatingView mainMenuRepeater = new RepeatingView("mainMenuItem");
  add(mainMenuRepeater);
  if (menu == null) {
    mainMenuRepeater.setVisible(false);
    log.error("Oups, menu is null. Configuration of favorite menu not possible.");
    return;
  }
  int counter = 0;
  if (menu.getMenuEntries() == null) {
    // Should only occur in maintenance mode!
    return;
  }
  for (final MenuEntry mainMenuEntry : menu.getMenuEntries()) {
    if (mainMenuEntry.hasSubMenuEntries() == false) {
      continue;
    }
    final WebMarkupContainer mainMenuContainer = new WebMarkupContainer(mainMenuRepeater.newChildId());
    mainMenuRepeater.add(mainMenuContainer);
    if (counter++ % 5 == 0) {
      mainMenuContainer.add(AttributeModifier.append("class", "mm_clear"));
    }
    mainMenuContainer.add(new Label("label", new ResourceModel(mainMenuEntry.getI18nKey())));
    final RepeatingView subMenuRepeater = new RepeatingView("menuItem");
    mainMenuContainer.add(subMenuRepeater);
    for (final MenuEntry subMenuEntry : mainMenuEntry.getSubMenuEntries()) {
      final WebMarkupContainer subMenuContainer = new WebMarkupContainer(subMenuRepeater.newChildId());
      subMenuRepeater.add(subMenuContainer);
      final AbstractLink link = NavAbstractPanel.getMenuEntryLink(subMenuEntry, false);
      if (link != null) {
        subMenuContainer.add(link);
      } else {
        subMenuContainer.setVisible(false);
      }
    }
  }
}
 
Example 9
Source File: AbstractImportStoragePanel.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
protected void addActionLink(final RepeatingView actionLinkRepeater, final AbstractLink link, final String labelText, final String tooltip)
{
  final WebMarkupContainer actionLinkContainer = new WebMarkupContainer(actionLinkRepeater.newChildId());
  actionLinkRepeater.add(actionLinkContainer);
  final Label label = new Label("label", labelText);
  if (tooltip != null) {
    WicketUtils.addTooltip(label, tooltip);
  }
  actionLinkContainer.add(link.add(label));
}
 
Example 10
Source File: FieldListViewPanel.java    From onedev with MIT License 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	RepeatingView fieldsView = new RepeatingView("fields");
	for (FieldSupply field: fields) {
		WebMarkupContainer container = new WebMarkupContainer(fieldsView.newChildId());
		container.add(new Label("name", field.getName()));
		
		if (field.getValueProvider() instanceof SpecifiedValue) {
			if (field.isSecret())
				container.add(new Label("valueProvider", SpecifiedValue.SECRET_DISPLAY_NAME));
			else
				container.add(new Label("valueProvider", SpecifiedValue.DISPLAY_NAME));
			List<String> value = field.getValueProvider().getValue();
			if (value.size() == 0) 
				container.add(new Label("value", "<i>Empty</i>").setEscapeModelStrings(false));
			else if (value.size() == 1)
				container.add(new Label("value", value.iterator().next()));
			else 
				container.add(new Label("value", value.toString()));
		} else if (field.getValueProvider() instanceof ScriptingValue) {
			if (field.isSecret())
				container.add(new Label("valueProvider", ScriptingValue.SECRET_DISPLAY_NAME));
			else
				container.add(new Label("valueProvider", ScriptingValue.DISPLAY_NAME));
			container.add(PropertyContext.view("value", field.getValueProvider(), "scriptName"));
		} else {
			container.add(new WebMarkupContainer("value"));
		}
		fieldsView.add(container);
	}
	add(fieldsView);
}
 
Example 11
Source File: BeanListPropertyEditor.java    From onedev with MIT License 5 votes vote down vote up
private WebMarkupContainer addRow(Serializable element) {
	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", "property-" + 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);
			markFormDirty(target);
			target.appendJavaScript($(row).chain("remove").get());
			rows.remove(row);
			target.add(noElements);
			onPropertyUpdating(target);
		}

	}.setDefaultFormProcessing(false));
	
	return row;
}
 
Example 12
Source File: StateStatsBar.java    From onedev with MIT License 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();

	int totalCount = getModelObject().values().stream().collect(Collectors.summingInt(it->it));
	if (totalCount != 0) {
		RepeatingView statesView = new RepeatingView("states");
		for (StateSpec state: OneDev.getInstance(SettingManager.class).getIssueSetting().getStateSpecs()) {
			Integer count = getModelObject().get(state.getName());
			if (count != null) { 
				Link<Void> link = newStateLink(statesView.newChildId(), state.getName());
				link.add(AttributeAppender.append("title", count + " " + state.getName().toLowerCase() + " issues"));
				link.add(AttributeAppender.append("data-percent", count*1.0/totalCount));
				link.add(AttributeAppender.append("style", "background-color: " + state.getColor()));
				statesView.add(link);
			}
		}
		add(statesView);
	} else {
		add(new Label("states", "&nbsp;") {

			@Override
			protected void onComponentTag(ComponentTag tag) {
				super.onComponentTag(tag);
				tag.setName("span");
			}
			
		}.setEscapeModelStrings(false));
		add(AttributeAppender.append("title", "No issues in milestone"));
	}
	
	setOutputMarkupId(true);
}
 
Example 13
Source File: SimpleUserListPanel.java    From onedev with MIT License 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();

	RepeatingView usersView = new RepeatingView("users");
	for (User user:  getUsers()) {
		WebMarkupContainer container = new WebMarkupContainer(usersView.newChildId());
		container.add(new UserAvatar("avatar", user));
		container.add(new Label("name", user.getDisplayName()));
		usersView.add(container);
	}
	add(usersView);
}
 
Example 14
Source File: CommitListPanel.java    From onedev with MIT License 5 votes vote down vote up
private RepeatingView newCommitsView() {
	RepeatingView commitsView = new RepeatingView("commits");
	commitsView.setOutputMarkupId(true);
	
	int commitIndex = 0;
	List<RevCommit> commits = commitsModel.getObject().current;
	for (int i=0; i<commits.size(); i++) {
		Component item = newCommitItem(commitsView.newChildId(), i);
		if (commits.get(i) != null)
			addCommitClass(item, commitIndex++);
		commitsView.add(item);
	}
	getProject().cacheCommitStatus(getBuildManager().queryStatus(getProject(), getCommitIdsToQueryStatus()));
	return commitsView;
}
 
Example 15
Source File: ProjectEditCost2TypeTablePanel.java    From projectforge-webapp with GNU General Public License v3.0 4 votes vote down vote up
public void init(final List<Kost2Art> kost2Arts)
{
  final Iterator<Kost2Art> it = kost2Arts.iterator();
  final RepeatingView kost2artRowsRepeater = new RepeatingView("kost2artRows");
  add(kost2artRowsRepeater);
  while (it.hasNext() == true) {
    final WebMarkupContainer rowItem = new WebMarkupContainer(kost2artRowsRepeater.newChildId());
    kost2artRowsRepeater.add(rowItem);
    final RepeatingView kost2artColsRepeater = new RepeatingView("kost2artCols");
    rowItem.add(kost2artColsRepeater);
    for (int i = 0; i < 2 && it.hasNext() == true; i++) {
      final WebMarkupContainer colItem = new WebMarkupContainer(kost2artColsRepeater.newChildId());
      kost2artColsRepeater.add(colItem);
      final Kost2Art kost2Art = it.next();
      String style = null;
      if (kost2Art.isExistsAlready() == true) {
        if (kost2Art.isProjektStandard() == true) {
          style = "color: green;";
        }
      } else {
        if (kost2Art.isProjektStandard() == true) {
          style = "color: red;";
        }
      }
      final CheckBox checkBox = new CheckBox("kost2artSelect", new PropertyModel<Boolean>(kost2Art, "selected"));
      colItem.add(checkBox);
      final IconPanel image = new IconPanel("acceptImage", IconType.ACCEPT);
      image.setTooltip(new ResourceModel("fibu.projekt.edit.kost2DoesAlreadyExists"));
      colItem.add(image);
      if (kost2Art.isExistsAlready() == true) {
        checkBox.setVisible(false);
      } else {
        image.setVisibilityAllowed(false);
      }
      final Label kost2artNummerLabel = new Label("kost2artNummer", StringHelper.format2DigitNumber(kost2Art.getId()));
      colItem.add(kost2artNummerLabel);
      final Label kost2artNameLabel = new Label("kost2artName", kost2Art.isFakturiert() == true ? kost2Art.getName() : kost2Art.getName()
          + " (nf)");
      colItem.add(kost2artNameLabel);
      if (style != null) {
        kost2artNummerLabel.add(AttributeModifier.replace("style", style));
        kost2artNameLabel.add(AttributeModifier.replace("style", style));
      }
    }
  }
}
 
Example 16
Source File: ParamListEditPanel.java    From onedev with MIT License 4 votes vote down vote up
private Component newParamsView(Class<?> paramBeanClass) {
	RepeatingView paramsView = new RepeatingView("params");
	paramsView.setDefaultModel(Model.of(paramBeanClass.getName()));
	BeanDescriptor beanDescriptor = new BeanDescriptor(paramBeanClass);
	for (List<PropertyDescriptor> groupProperties: beanDescriptor.getProperties().values()) {
		for (PropertyDescriptor property: groupProperties) {
			WebMarkupContainer container = new WebMarkupContainer(paramsView.newChildId());
			container.add(new Label("name", property.getDisplayName()));

			ParamSupply param = params.get(property.getDisplayName());
			if (param != null) {
				container.add(newValuesEditor("values", property, param.getValuesProvider()));
				container.setDefaultModel(Model.of(param.getValuesProvider().getClass()));
			} else {
				container.add(newValuesEditor("values", property, newSpecifiedValuesProvider(property)));
				container.setDefaultModel(Model.of(SpecifiedValues.class));
			}

			String required;
			if (property.isPropertyRequired() 
					&& property.getPropertyClass() != boolean.class
					&& property.getPropertyClass() != Boolean.class) {
				required = "*";
			} else {
				required = "&nbsp;";
			}
			
			container.add(new Label("required", required).setEscapeModelStrings(false));
			
			boolean isSecret = property.getPropertyGetter().getAnnotation(Password.class) != null;

			List<String> choices = new ArrayList<>();
			if (isSecret) {
				choices.add(SpecifiedValues.SECRET_DISPLAY_NAME);
				choices.add(ScriptingValues.SECRET_DISPLAY_NAME);
				choices.add(Ignore.DISPLAY_NAME);
			} else {
				choices.add(SpecifiedValues.DISPLAY_NAME);
				choices.add(ScriptingValues.DISPLAY_NAME);
				choices.add(Ignore.DISPLAY_NAME);
			}
			DropDownChoice<String> valuesProviderChoice = new DropDownChoice<String>("valuesProvider", new IModel<String>() {
				
				@Override
				public void detach() {
				}

				@Override
				public String getObject() {
					Class<?> valuesProviderClass = (Class<?>) container.getDefaultModelObject();
					if (valuesProviderClass == SpecifiedValues.class)
						return isSecret?SpecifiedValues.SECRET_DISPLAY_NAME:SpecifiedValues.DISPLAY_NAME;
					else if (valuesProviderClass == ScriptingValues.class)
						return isSecret?ScriptingValues.SECRET_DISPLAY_NAME:ScriptingValues.DISPLAY_NAME;
					else
						return Ignore.DISPLAY_NAME;
				}

				@Override
				public void setObject(String object) {
					ValuesProvider valuesProvider;
					if (object.equals(SpecifiedValues.DISPLAY_NAME) || object.equals(SpecifiedValues.SECRET_DISPLAY_NAME))  
						valuesProvider = newSpecifiedValuesProvider(property);
					else if (object.equals(ScriptingValues.DISPLAY_NAME) || object.equals(ScriptingValues.SECRET_DISPLAY_NAME))
						valuesProvider = new ScriptingValues();
					else
						valuesProvider = new Ignore();
					container.replace(newValuesEditor("values", property, valuesProvider));
					container.setDefaultModelObject(valuesProvider.getClass());
				}
									
			}, choices);
			
			valuesProviderChoice.setNullValid(false);
			
			valuesProviderChoice.add(new AjaxFormComponentUpdatingBehavior("change"){

				@Override
				protected void onUpdate(AjaxRequestTarget target) {
					onPropertyUpdating(target);
					target.add(container);
				}
				
			});
			container.add(valuesProviderChoice);
			container.add(new Label("description", property.getDescription()).setEscapeModelStrings(false));
			container.add(new FencedFeedbackPanel("feedback", container));
			container.setOutputMarkupId(true);
			paramsView.add(container);
		}
	}
	
	return paramsView;
}
 
Example 17
Source File: AssociationTransformPage.java    From ontopia with Apache License 2.0 4 votes vote down vote up
private void createPanel() {
  Form<Object> form = new Form<Object>("form");
  add(form);
  AssociationType associationType = getAssociationType();

  // get used role type combinations
  Collection<List<RoleType>> roleCombos = associationType.getUsedRoleTypeCombinations();

  // then remove the combination that is valid according to declaration
  List<RoleType> declaredRoleTypes = associationType.getDeclaredRoleTypes();
  Collections.sort(declaredRoleTypes, new Comparator<RoleType>() {
    @Override
    public int compare(RoleType rt1, RoleType rt2) {
      return ObjectIdComparator.INSTANCE.compare(rt1.getTopicIF(), rt2.getTopicIF());
    }      
  });
  roleCombos.remove(declaredRoleTypes);
  
  RepeatingView rview = new RepeatingView("combos");    
  Iterator<List<RoleType>> citer = roleCombos.iterator();
  while (citer.hasNext()) {
    List<RoleType> roleTypes = citer.next();
    if (roleTypes.size() != declaredRoleTypes.size()) {
      citer.remove();
      continue;
    }
    rview.add(new AssociationTransformerPanel(rview.newChildId(), associationType, roleTypes));
  }
  form.add(rview);
  
  Label message = new Label("message", new ResourceModel("transform.association.instances.none"));
  message.setVisible(roleCombos.isEmpty());
  form.add(message);
  
  Button button = new Button("button", new ResourceModel("button.ok"));
  button.setVisible(roleCombos.isEmpty());
  button.add(new AjaxFormComponentUpdatingBehavior("onclick") {
    @Override
    protected void onUpdate(AjaxRequestTarget target) {
      Topic t = getAssociationType();
      Map<String,String> pageParametersMap = new HashMap<String,String>();
      pageParametersMap.put("topicMapId", t.getTopicMap().getId());
      pageParametersMap.put("topicId", t.getId());
      pageParametersMap.put("ontology", "true");
      setResponsePage(InstancePage.class, new PageParameters(pageParametersMap));
    }          
  });
  form.add(button);    
}
 
Example 18
Source File: ViewsFunctionBoxPanel.java    From ontopia with Apache License 2.0 4 votes vote down vote up
public ViewsFunctionBoxPanel(String id, TopicModel<Topic> topicModel, TopicTypeModel topicTypeModel, FieldsViewModel fieldsViewModel) {
  super(id);
  add(new Label("title", new ResourceModel("views.list.header")));

  Topic topic = topicModel.getTopic();
  TopicMap tm = topic.getTopicMap();
  TopicType topicType = topicTypeModel.getTopicType();
  FieldsView fieldsView = fieldsViewModel.getFieldsView();
  
  Collection<FieldsView> views = topicType.getFieldViews(fieldsView);
  if (views.isEmpty())
    setVisible(false);
  
  FieldsView currentView = fieldsViewModel.getFieldsView();
  FieldsView defaultView = FieldsView.getDefaultFieldsView(topicType.getTopicMap());
  if (currentView == null)
    currentView = defaultView;
  
  RepeatingView rv = new RepeatingView("rows");
  add(rv);
  
  for (FieldsView view : views) {
    WebMarkupContainer parent =  new WebMarkupContainer(rv.newChildId());
    rv.add(parent);
    
    
    Map<String,String> pageParametersMap = new HashMap<String,String>();
    pageParametersMap.put("topicMapId", tm.getId());
    pageParametersMap.put("topicId", topic.getId());
    pageParametersMap.put("topicTypeId", topicType.getId());
    if (!Objects.equals(view, defaultView))
      pageParametersMap.put("viewId", view.getId());
    if (topic.isOntologyTopic())
      pageParametersMap.put("ontology", "true");
    
    String viewName = view.getName();
    OntopolyBookmarkablePageLink link =
      new OntopolyBookmarkablePageLink("link", InstancePage.class, new PageParameters(pageParametersMap), viewName);
    link.setEnabled(!Objects.equals(currentView, view));
    
    parent.add(link);
  }
}
 
Example 19
Source File: TopicTypesFunctionBoxPanel.java    From ontopia with Apache License 2.0 4 votes vote down vote up
public TopicTypesFunctionBoxPanel(String id, TopicModel<Topic> topicModel, TopicTypeModel topicTypeModel, FieldsViewModel fieldsViewModel) {
  super(id);
  add(new Label("title", new ResourceModel("topictypes.list.header")));

  List<TopicType> types = topicModel.getTopic().getTopicTypes();
  if (types.isEmpty())
    setVisible(false);
  
  TopicType currentTopicType = topicTypeModel.getTopicType();
  FieldsView currentView = fieldsViewModel.getFieldsView();
  
  RepeatingView rv = new RepeatingView("rows");
  add(rv);
  
  Iterator<TopicType> iter =  types.iterator();
  while (iter.hasNext()) {
    TopicType topicType = iter.next();      
    boolean isCurrentTopicType = Objects.equals(currentTopicType, topicType);
    
    WebMarkupContainer parent =  new WebMarkupContainer(rv.newChildId());
    rv.add(parent);
    
    Topic topic = topicModel.getTopic();
    TopicMap tm = topic.getTopicMap();
    
    Map<String,String> pageParametersMap = new HashMap<String,String>();
    pageParametersMap.put("topicMapId", tm.getId());
    pageParametersMap.put("topicId", topic.getId());
    pageParametersMap.put("topicTypeId", topicType.getId());
    
    if (currentView != null && isCurrentTopicType)
      pageParametersMap.put("viewId", currentView.getId());
    
    String linkText = topicType.getName();
    OntopolyBookmarkablePageLink link =
      new OntopolyBookmarkablePageLink("link", InstancePage.class, new PageParameters(pageParametersMap), linkText);
    link.setEnabled(!isCurrentTopicType);
    
    parent.add(link);
  }
}
 
Example 20
Source File: FieldListEditPanel.java    From onedev with MIT License 4 votes vote down vote up
private Component newFieldsView(Class<?> fieldBeanClass) {
	RepeatingView fieldsView = new RepeatingView("fields");
	fieldsView.setDefaultModel(Model.of(fieldBeanClass.getName()));
	BeanDescriptor beanDescriptor = new BeanDescriptor(fieldBeanClass);
	for (List<PropertyDescriptor> groupProperties: beanDescriptor.getProperties().values()) {
		for (PropertyDescriptor property: groupProperties) {
			if (getFieldSpecs().containsKey(property.getDisplayName())) {
				WebMarkupContainer container = new WebMarkupContainer(fieldsView.newChildId());
				FieldSupply field = fields.get(property.getDisplayName());
				if (field != null) {
					container.add(newValueEditor("value", property, field.getValueProvider()));
					container.setDefaultModel(Model.of(field.getValueProvider().getClass()));
				} else {
					container.add(newValueEditor("value", property, newSpecifiedValueProvider(property)));
					container.setDefaultModel(Model.of(SpecifiedValue.class));
				}
				
				container.add(new Label("name", property.getDisplayName()));

				String required;
				if (property.isPropertyRequired() 
						&& property.getPropertyClass() != boolean.class
						&& property.getPropertyClass() != Boolean.class) {
					required = "*";
				} else {
					required = "&nbsp;";
				}
				
				container.add(new Label("required", required).setEscapeModelStrings(false));
				
				boolean isSecret = property.getPropertyGetter().getAnnotation(Password.class) != null;

				List<String> choices = new ArrayList<>();
				if (isSecret) {
					choices.add(SpecifiedValue.SECRET_DISPLAY_NAME);
					choices.add(ScriptingValue.SECRET_DISPLAY_NAME);
					choices.add(Ignore.DISPLAY_NAME);
				} else {
					choices.add(SpecifiedValue.DISPLAY_NAME);
					choices.add(ScriptingValue.DISPLAY_NAME);
					choices.add(Ignore.DISPLAY_NAME);
				}
				DropDownChoice<String> valueProviderChoice = new DropDownChoice<String>("valueProvider", new IModel<String>() {
					
					@Override
					public void detach() {
					}

					@Override
					public String getObject() {
						Class<?> valueProviderClass = (Class<?>) container.getDefaultModelObject();
						if (valueProviderClass == SpecifiedValue.class)
							return isSecret?SpecifiedValue.SECRET_DISPLAY_NAME:SpecifiedValue.DISPLAY_NAME;
						else if (valueProviderClass == ScriptingValue.class)
							return isSecret?ScriptingValue.SECRET_DISPLAY_NAME:ScriptingValue.DISPLAY_NAME;
						else
							return Ignore.DISPLAY_NAME;
					}

					@Override
					public void setObject(String object) {
						ValueProvider valueProvider;
						if (object.equals(SpecifiedValue.DISPLAY_NAME) || object.equals(SpecifiedValue.SECRET_DISPLAY_NAME))  
							valueProvider = newSpecifiedValueProvider(property);
						else if (object.equals(ScriptingValue.DISPLAY_NAME) || object.equals(ScriptingValue.SECRET_DISPLAY_NAME))
							valueProvider = new ScriptingValue();
						else
							valueProvider = new Ignore();
						container.replace(newValueEditor("value", property, valueProvider));
						container.setDefaultModelObject(valueProvider.getClass());
					}
					
				}, choices);
				
				valueProviderChoice.setNullValid(false);
				
				valueProviderChoice.add(new AjaxFormComponentUpdatingBehavior("change"){

					@Override
					protected void onUpdate(AjaxRequestTarget target) {
						onPropertyUpdating(target);
						target.add(container);
					}
					
				});
				container.add(valueProviderChoice);
				
				container.add(new Label("description", property.getDescription()).setEscapeModelStrings(false));
				container.add(new FencedFeedbackPanel("feedback", container));
				container.setOutputMarkupId(true);
				fieldsView.add(container);
			}
		}
	}
	
	return fieldsView;
}