Changeset 806
- Timestamp:
- 10/21/10 09:42:58 (14 years ago)
- Location:
- VirtualCollectionRegistry/trunk/VirtualCollectionRegistry/src/main/java/eu/clarin/cmdi/virtualcollectionregistry/gui/wizard
- Files:
-
- 5 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
VirtualCollectionRegistry/trunk/VirtualCollectionRegistry/src/main/java/eu/clarin/cmdi/virtualcollectionregistry/gui/wizard/CreateVirtualCollectionWizard$ResourcesStep.html
r805 r806 7 7 <wicket:panel> 8 8 <!-- FIXME: use proper CSS, not table! --> 9 <!--10 9 <div style="display: none" wicket:id="editResourceDialog"></div> 11 10 <div style="display: none" wicket:id="deleteResourceDialog"></div> 11 <div style="display: none" wicket:id="addResourcesDialog"></div> 12 12 <table> 13 13 <tr style="vertical-align: top"> 14 <td> Creators</td>15 <td><table wicket:id=" creatorsTable"></table></td>14 <td>Resources</td> 15 <td><table wicket:id="resourcesTable"></table></td> 16 16 </tr> 17 17 <tr> 18 <td colspan="2"><a href="#" wicket:id="add">add creator</a></td> 18 <td colspan="2"> 19 <a href="#" wicket:id="add">add resource</a> 20 <a href="#" wicket:id="addMore">add more resource</a> 21 </td> 19 22 </tr> 20 23 </table> 21 -->22 24 </wicket:panel> 23 25 </body> -
VirtualCollectionRegistry/trunk/VirtualCollectionRegistry/src/main/java/eu/clarin/cmdi/virtualcollectionregistry/gui/wizard/CreateVirtualCollectionWizard.java
r805 r806 30 30 import eu.clarin.cmdi.virtualcollectionregistry.gui.pages.HomePage; 31 31 import eu.clarin.cmdi.virtualcollectionregistry.model.Creator; 32 import eu.clarin.cmdi.virtualcollectionregistry.model.Resource; 32 33 import eu.clarin.cmdi.virtualcollectionregistry.model.VirtualCollection; 34 import eu.clarin.cmdi.virtualcollectionregistry.model.Resource.Type; 33 35 34 36 @SuppressWarnings("serial") … … 121 123 public Iterator<? extends Creator> iterator( 122 124 int first, int count) { 123 return vc.getCreators().iterator(); 125 // XXX: hack 126 Iterator<Creator> i = 127 vc.getCreators().iterator(); 128 while (first-- > 0) { 129 i.next(); 130 } 131 return i; 124 132 } 125 133 … … 150 158 add(editCreatorDialog); 151 159 160 deleteCreatorDialog = 161 new DeleteCreatorDialog("deleteCreatorDialog", 162 creatorsTable); 163 add(deleteCreatorDialog); 164 152 165 add(new AjaxLink<Object>("add") { 153 166 @Override … … 157 170 } 158 171 }); 159 deleteCreatorDialog =160 new DeleteCreatorDialog("deleteCreatorDialog",161 creatorsTable);162 add(deleteCreatorDialog);163 172 } 164 173 … … 186 195 } // class CreateVirtualCollectionWizard.CreatorsStep 187 196 188 // private final class ResourcesStep extends WizardStep { 189 // public ResourcesStep() { 190 // super("Resources", "Yada yada yada ..."); 191 // } 192 // }// class CreateVirtualCollectionWizard.CreatorsStep 197 private final class ResourcesStep extends WizardStep { 198 private final class ActionsPanel extends Panel { 199 public ActionsPanel(String id, final IModel<Resource> model) { 200 super(id, model); 201 final AjaxLink<Resource> editLink = 202 new AjaxLink<Resource>("edit") { 203 @Override 204 public void onClick(AjaxRequestTarget target) { 205 final Resource resource = model.getObject(); 206 if (resource != null) { 207 editResourceDialog.setResource(resource); 208 editResourceDialog.show(target); 209 } 210 } 211 }; 212 add(editLink); 213 final AjaxLink<Resource> removeLink = 214 new AjaxLink<Resource>("remove") { 215 @Override 216 public void onClick(AjaxRequestTarget target) { 217 final Resource resource = model.getObject(); 218 if (resource != null) { 219 deleteResourceDialog.setResource(resource); 220 deleteResourceDialog.show(target); 221 } 222 } 223 }; 224 add(removeLink); 225 } 226 } // class CreateVirtualCollectionWizard.ResourcesStep.ActionsPanel 227 228 private final class DeleteResourceDialog extends ConfirmationDialog { 229 private final transient DataTable<Resource> resourcesTable; 230 private Resource resource; 231 232 public DeleteResourceDialog(String id, 233 DataTable<Resource> resourcesTable) { 234 super(id, new Model<String>("")); 235 this.resourcesTable = resourcesTable; 236 } 237 238 public void setResource(Resource resource) { 239 this.resource = resource; 240 setMessage(new StringResourceModel("resources.deleteconfirm", 241 new Model<Resource>(resource))); 242 } 243 244 @Override 245 public void onConfirm(AjaxRequestTarget target) { 246 if (resource != null) { 247 vc.getResources().remove(resource); 248 target.addComponent(resourcesTable); 249 } 250 } 251 252 @Override 253 public void onCancel(AjaxRequestTarget target) { 254 } 255 } // class CreateVirtualCollectionWizard.CreatorsStep.DeleteConfirmDialog 256 257 private final EditResourceDialog editResourceDialog; 258 private final DeleteResourceDialog deleteResourceDialog; 259 260 public ResourcesStep() { 261 super("Resources", "Yada yada yada ..."); 262 final DataTable<Resource> resourcesTable = 263 new AjaxFallbackDefaultDataTable<Resource>("resourcesTable", 264 createColumns(), 265 new SortableDataProvider<Resource>() { 266 @Override 267 public Iterator<? extends Resource> iterator( 268 int first, int count) { 269 // XXX: hack 270 Iterator<Resource> i = 271 vc.getResources().iterator(); 272 while (first-- > 0) { 273 i.next(); 274 } 275 return i; 276 } 277 278 @Override 279 public IModel<Resource> model(Resource resource) { 280 return new Model<Resource>(resource); 281 } 282 283 @Override 284 public int size() { 285 return vc.getResources().size(); 286 } 287 }, 288 8); 289 add(resourcesTable); 290 291 editResourceDialog = new EditResourceDialog("editResourceDialog") { 292 @Override 293 public void onSubmit(AjaxRequestTarget target, Resource resource) { 294 if (resource != null) { 295 if (!vc.getResources().contains(resource)) { 296 vc.getResources().add(resource); 297 } 298 target.addComponent(resourcesTable); 299 } 300 } 301 }; 302 add(editResourceDialog); 303 304 deleteResourceDialog = 305 new DeleteResourceDialog("deleteResourceDialog", 306 resourcesTable); 307 add(deleteResourceDialog); 308 309 final AddResourcesDialog addResourcesDialog = 310 new AddResourcesDialog("addResourcesDialog") { 311 @Override 312 public void onSubmit(AjaxRequestTarget target, 313 Resource[] resources) { 314 for (Resource resource : resources) { 315 if (!vc.getResources().contains(resource)) { 316 vc.getResources().add(resource); 317 } 318 } 319 target.addComponent(resourcesTable); 320 } 321 322 }; 323 add(addResourcesDialog); 324 325 add(new AjaxLink<Object>("add") { 326 @Override 327 public void onClick(AjaxRequestTarget target) { 328 editResourceDialog.setResource(new Resource()); 329 editResourceDialog.show(target); 330 } 331 }); 332 333 add(new AjaxLink<Object>("addMore") { 334 @Override 335 public void onClick(AjaxRequestTarget target) { 336 addResourcesDialog.show(target); 337 } 338 }); 339 } 340 341 @SuppressWarnings("unchecked") 342 private IColumn<Resource>[] createColumns() { 343 final IColumn<?>[] columns = new IColumn<?>[] { 344 new PropertyColumn<Resource>( 345 new Model<String>("Type"), "type"), 346 new PropertyColumn<Resource>( 347 new Model<String>("Reference"), "ref"), 348 new HeaderlessColumn<Resource>() { 349 @Override 350 public void populateItem( 351 Item<ICellPopulator<Resource>> cellItem, 352 String compontentId, 353 IModel<Resource> model) { 354 cellItem.add(new ActionsPanel(compontentId, model)); 355 } 356 } 357 }; 358 return (IColumn<Resource>[]) columns; 359 } 360 } // class CreateVirtualCollectionWizard.CreatorsStep 193 361 194 362 private final VirtualCollection vc = new VirtualCollection(); … … 196 364 public CreateVirtualCollectionWizard(String id) { 197 365 super(id); 366 vc.getResources().add(new Resource(Type.METADATA, "http://some/where1")); 367 vc.getResources().add(new Resource(Type.METADATA, "http://some/where2")); 368 vc.getResources().add(new Resource(Type.METADATA, "http://some/where3")); 369 vc.getResources().add(new Resource(Type.METADATA, "http://some/where4")); 198 370 setDefaultModel(new CompoundPropertyModel<VirtualCollection>(this)); 199 371 WizardModel model = new WizardModel(); 200 372 model.add(new GeneralStep()); 201 373 model.add(new CreatorsStep()); 202 //model.add(new ResourcesStep());374 model.add(new ResourcesStep()); 203 375 init(model); 204 376 } … … 215 387 System.err.println("Desc: " + vc.getDescription()); 216 388 for (Creator c : vc.getCreators()) { 217 System.err.println(c.getName() + ", " + c.getEMail()); 389 System.err.println("C: " + c.getName() + ", " + c.getEMail()); 390 } 391 for (Resource r : vc.getResources()) { 392 System.err.println("R: " + r.getType() + ", " + r.getRef()); 218 393 } 219 394 } -
VirtualCollectionRegistry/trunk/VirtualCollectionRegistry/src/main/java/eu/clarin/cmdi/virtualcollectionregistry/gui/wizard/CreateVirtualCollectionWizard.properties
r805 r806 1 1 Type.EXTENSIONAL: Extensional 2 2 Type.INTENSIONAL: Intensional 3 Type.METADATA: Metadata 4 Type.RESOURCE: Resource 3 5 creators.deleteconfirm: Do you really want to delete "${name}"? 6 resources.deleteconfirm: Do you really want to delete "${ref}"?
Note: See TracChangeset
for help on using the changeset viewer.