Changeset 8918
- Timestamp:
- 10/04/08 17:21:19 (7 weeks ago)
- Location:
- trunk/java/org.semanticdesktop.nepomuk.comp.imapping
- Files:
-
- 1 added
- 12 modified
-
info.imapping.core/src/main/java/info/imapping/core/command/Commands.java (modified) (3 diffs)
-
info.imapping.core/src/main/java/info/imapping/core/command/impl/CreateTextItem.java (modified) (3 diffs)
-
info.imapping.core/src/main/java/info/imapping/core/command/impl/EraseItem.java (modified) (2 diffs)
-
info.imapping.core/src/main/java/info/imapping/core/command/impl/RemoveItem.java (added)
-
info.imapping.core/src/main/java/info/imapping/core/domain/IMapItem.java (modified) (1 diff)
-
info.imapping.core/src/main/java/info/imapping/core/domain/impl/MapItem.java (modified) (6 diffs)
-
info.imapping.core/src/main/java/info/imapping/core/domain/impl/MapItemFactory.java (modified) (1 diff)
-
info.imapping.core/src/main/java/info/imapping/core/domain/impl/MapItemRepository.java (modified) (2 diffs)
-
info.imapping.core/src/main/java/info/imapping/core/service/IMapService.java (modified) (1 diff)
-
info.imapping.core/src/main/java/info/imapping/core/service/impl/MapService.java (modified) (2 diffs)
-
info.imapping.core/src/test/java/info/imapping/core/command/CreateTextItemTest.java (modified) (3 diffs)
-
info.imapping.ui/src/main/java/info/imapping/piccolo/UIController.java (modified) (1 diff)
-
info.imapping.ui/src/main/java/info/imapping/piccolo/editor/WidgetEditor.java (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/java/org.semanticdesktop.nepomuk.comp.imapping/info.imapping.core/src/main/java/info/imapping/core/command/Commands.java
r8913 r8918 11 11 import info.imapping.core.command.impl.MoveItem; 12 12 import info.imapping.core.command.impl.EraseItem; 13 import info.imapping.core.command.impl.RemoveItem; 13 14 import info.imapping.core.command.impl.RemoveLink; 14 15 import info.imapping.core.command.impl.RenameLink; … … 40 41 public CreateTextItem createTextItem(final IMapItem parent, 41 42 final IPoint position, final IDimensions dimensions, 42 final String text, boolean named, IItem cdsItem , MapItem mapItem) {43 final String text, boolean named, IItem cdsItem) { 43 44 44 45 final CreateTextItem command = new CreateTextItem( 45 46 (IWritableMapItem) parent, position, dimensions, text, named, 46 itemFactory, cdsItem , mapItem);47 itemFactory, cdsItem); 47 48 manager.execute(command); 48 49 return command; … … 74 75 } 75 76 76 public EraseItem removeItem(MapItem mapItem, MapItemRepository myRepos) {77 public EraseItem eraseItem(MapItem mapItem, MapItemRepository myRepos) { 77 78 final EraseItem command = new EraseItem(mapItem, myRepos); 79 manager.execute(command); 80 return command; 81 } 82 83 public RemoveItem removeItem(MapItem mapItem, MapItemRepository myRepos) { 84 final RemoveItem command = new RemoveItem(mapItem, myRepos); 78 85 manager.execute(command); 79 86 return command; -
trunk/java/org.semanticdesktop.nepomuk.comp.imapping/info.imapping.core/src/main/java/info/imapping/core/command/impl/CreateTextItem.java
r8913 r8918 51 51 * @param named true if NameItem, else false 52 52 * @param give cds item if you want to init a mapitem 53 * @param give map item if you want a mirror54 53 * 55 54 */ 56 55 public CreateTextItem(IWritableMapItem parent, IPoint position, IDimensions dimensions, String text, 57 boolean named, MapItemFactory factory, IItem cdsItem , MapItem mapItem) {56 boolean named, MapItemFactory factory, IItem cdsItem) { 58 57 this.parent = parent; 59 58 this.position = position; … … 63 62 this.factory = factory; 64 63 this.existingCDS=cdsItem; 65 this.existingMap=mapItem;66 64 } 67 65 … … 75 73 //if we have CDS item, create MapItem for it 76 74 if (existingCDS!=null){ 77 createdItem = factory.createOrphanMapItem(existingCDS); 78 } 79 else if (existingMap!=null){ 80 75 createdItem = factory.createOrphanMapItem(existingCDS, parent); 81 76 } 82 77 else if (named) { -
trunk/java/org.semanticdesktop.nepomuk.comp.imapping/info.imapping.core/src/main/java/info/imapping/core/command/impl/EraseItem.java
r8913 r8918 8 8 9 9 /** 10 * Creates a text item as child of the given parent.10 * Erases an Item. 11 11 * 12 * @author Steffen Braun12 * @author Henning Sperr 13 13 * 14 14 */ … … 23 23 24 24 /** 25 * Removes an IMapping item from all parent bodies.26 * 25 * Erases an IMapping item from all parent bodies. 26 * and its CDSItem 27 27 * @param item 28 28 */ -
trunk/java/org.semanticdesktop.nepomuk.comp.imapping/info.imapping.core/src/main/java/info/imapping/core/domain/IMapItem.java
r8913 r8918 247 247 StoreImapItem getDelegate(); 248 248 249 IMapItem createMirror(String text); 250 249 251 } -
trunk/java/org.semanticdesktop.nepomuk.comp.imapping/info.imapping.core/src/main/java/info/imapping/core/domain/impl/MapItem.java
r8913 r8918 6 6 import info.imapping.core.command.impl.EraseItem; 7 7 import info.imapping.core.command.impl.EraseLink; 8 import info.imapping.core.command.impl.RemoveItem; 8 9 import info.imapping.core.command.impl.RemoveLink; 9 10 import info.imapping.core.command.impl.RenameLink; … … 33 34 import org.ontoware.rdfreactor.runtime.Base; 34 35 import org.semanticdesktop.swecr.model.IModel; 36 import org.semanticdesktop.swecr.model.INameItem; 35 37 import org.semanticdesktop.swecr.model.IRelation; 36 38 import org.semanticdesktop.swecr.model.IStatement; … … 340 342 setInnerHeight(dimensions.getInnerHeight()); 341 343 } 342 343 // TODO erase and remove item 344 344 345 /** {@inheritDoc} */ 345 346 public URI[] remove() { 346 throw _toBeImplemented(); 347 RemoveItem removeCommand = commands.removeItem(this,this.repository); 348 return null; 347 349 } 348 350 … … 350 352 public URI[] erase() { 351 353 352 EraseItem eraseCommand = commands. removeItem(this,this.repository);354 EraseItem eraseCommand = commands.eraseItem(this,this.repository); 353 355 354 356 return null; … … 400 402 IDimensions dimensions = new Dimensions(200, 150, 1.2); 401 403 CreateTextItem command = commands.createTextItem( 402 this, new Point.ImmutablePoint(0, 0), dimensions, text, named,null ,null);404 this, new Point.ImmutablePoint(0, 0), dimensions, text, named,null); 403 405 return command.getCreatedTextItem(); 404 406 } … … 488 490 } 489 491 492 public IMapItem createMirror(String text) { 493 IDimensions dimensions = new Dimensions(200, 150, 1.2); 494 //create the Command to init the Item 495 INameItem nameItem = store.getCDSModel().getNameItem(text); 496 CreateTextItem command = commands.createTextItem( 497 this, new Point.ImmutablePoint(0, 0), dimensions, "", true,nameItem); 498 //add to the items list 499 return (MapItem)command.getCreatedTextItem(); 500 } 501 490 502 } -
trunk/java/org.semanticdesktop.nepomuk.comp.imapping/info.imapping.core/src/main/java/info/imapping/core/domain/impl/MapItemFactory.java
r8913 r8918 92 92 /** 93 93 * Create MapItem for Orphan 94 * @param parent 94 95 * @param CDSItem 95 96 * @return MapItem 96 97 */ 97 public MapItem createOrphanMapItem(IItem cdsItem){ 98 return createMapItemForCDSItem(cdsItem); 98 public MapItem createOrphanMapItem(IItem cdsItem, IWritableMapItem parent){ 99 MapItem createdMapItem= createMapItemForCDSItem(cdsItem); 100 createdMapItem.setParent(parent); 101 return createdMapItem; 99 102 //(MapItem) itemRepository.getForURI(cdsItem.asJavaURI().toString()); 100 103 -
trunk/java/org.semanticdesktop.nepomuk.comp.imapping/info.imapping.core/src/main/java/info/imapping/core/domain/impl/MapItemRepository.java
r8913 r8918 123 123 store.removeCDSItem(mapItem.getCDSURI()); 124 124 } 125 public void removeMapItem(IWritableMapItem item) { 126 itemByURIMap.remove(item.getURI()); 127 itemByNameMap.remove(item.getText()); 128 } 125 129 126 130 public final MapItemFactory getItemFactory() { … … 151 155 return parentlessItems; 152 156 } 157 153 158 } -
trunk/java/org.semanticdesktop.nepomuk.comp.imapping/info.imapping.core/src/main/java/info/imapping/core/service/IMapService.java
r8913 r8918 101 101 Set<MapItem> createAndGetAllOrphans(); 102 102 103 boolean isAlreadyNamed(String text); 104 103 105 } -
trunk/java/org.semanticdesktop.nepomuk.comp.imapping/info.imapping.core/src/main/java/info/imapping/core/service/impl/MapService.java
r8913 r8918 171 171 //create the Command to init the Item 172 172 CreateTextItem command = commandManager.getCommands().createTextItem( 173 null, new Point.ImmutablePoint(0, 0), dimensions, "", true,actualCDSItem ,null);173 null, new Point.ImmutablePoint(0, 0), dimensions, "", true,actualCDSItem); 174 174 //add to the items list 175 175 OrphanItems.add((MapItem)command.getCreatedTextItem()); … … 190 190 } 191 191 192 public boolean isAlreadyNamed(String text) { 193 194 return getCDSModel().hasNameItem(text); 195 } 196 192 197 } -
trunk/java/org.semanticdesktop.nepomuk.comp.imapping/info.imapping.core/src/test/java/info/imapping/core/command/CreateTextItemTest.java
r8913 r8918 7 7 import info.imapping.core.domain.IPoint; 8 8 import info.imapping.core.domain.impl.Dimensions; 9 import info.imapping.core.domain.impl.MapItem; 9 10 import info.imapping.core.domain.impl.Point; 10 11 … … 29 30 position, 30 31 dimensions, 31 ISWC_2008, true,null ,null);32 ISWC_2008, true,null); 32 33 33 34 /* root has this item as single Detailitem */ … … 59 60 assertNotNull(cdsItem); 60 61 assertNotNull(cdsRoot); 62 63 } 64 public void testCreateMirrorItem() { 65 //create mirrorItems 66 IMapItem item1 = getRoot().createName("ABC"); 67 IMapItem item2 = getRoot().createMirror("ABC"); 68 //now we have 2 children 69 assertTrue(getRoot().getChildItems().length==2); 70 71 //same CDS Uri 72 assertEquals(item1.getCDSURI(),item2.getCDSURI()); 73 //but not same Item 74 assertFalse(item1.equals(item2)); 75 //and not same rdf 76 assertFalse(item1.getDelegate().equals(item2.getDelegate())); 77 //get uri of item 1!!! 78 org.ontoware.rdf2go.model.node.URI itemURI = new org.ontoware.rdf2go.model.node.impl.URIImpl(item1.getCDSURI().toString()); 79 //get cdsItem of item1 !!! 80 org.semanticdesktop.swecr.model.IItem cdsItem = store.getCDSModel().getItem(itemURI); 81 //cdsitem not null 82 assertNotNull(cdsItem); 83 84 //erase item 2 85 item2.erase(); 86 //now we have one child 87 assertTrue(getRoot().getChildItems().length==1); 88 //but if we get cdsItem of Item1 again 89 cdsItem = store.getCDSModel().getItem(itemURI); 90 //it is erased through item2 91 assertNull(cdsItem); 61 92 } 62 93 } -
trunk/java/org.semanticdesktop.nepomuk.comp.imapping/info.imapping.ui/src/main/java/info/imapping/piccolo/UIController.java
r8917 r8918 244 244 selectedWidget.removeAllChildren(); 245 245 parentWidget.removeChildWidget(selectedWidget); 246 selectedWidget.getMapItem(). erase();246 selectedWidget.getMapItem().remove(); 247 247 parentWidget.select(); 248 248 -
trunk/java/org.semanticdesktop.nepomuk.comp.imapping/info.imapping.ui/src/main/java/info/imapping/piccolo/editor/WidgetEditor.java
r8917 r8918 472 472 * exception. 473 473 */ 474 try { 475 if (editing) { 476 editItem(text); 474 475 if (editing) { 476 editItem(text); 477 } else { 478 IMapService mapService = widget.getController() 479 .getMapService(); 480 if (mapService.isAlreadyNamed(text)) { 481 String[] optionen = { "Cancel", 482 "Choose other Name", "Create TextItem", 483 "Create Mirror(do not delete)" }; 484 485 int n = JOptionPane 486 .showOptionDialog( 487 frame.getComponent(0), 488 "Item with this name already exists,\n create Textitem or Rename", // Fragetext 489 "Text or Rename", // Titel 490 JOptionPane.YES_NO_CANCEL_OPTION, 491 JOptionPane.QUESTION_MESSAGE, // Icon 492 null, optionen, optionen[0]); 493 if (n == 3) { 494 createMirrorItem(text); 495 } else if (n == 2) { 496 createTextItem(text); 497 log 498 .info("NameItem with a String " 499 + text 500 + " already existed, created new TextItem instead"); 501 } else if (n == 1) { 502 log 503 .info("NameItem with a String " 504 + text 505 + " already existed, chose renaming item"); 506 return; 507 } else { 508 this.closeEditor(); 509 this.editingFinished(); 510 return; 511 } 477 512 } else { 478 513 createNameItem(text); 479 514 } 480 } catch (Exception ex) {481 String[] optionen = {"Cancel", "Choose other Name","CreateTextItem"};482 483 int n = JOptionPane.showOptionDialog( null,484 "Item with this name already exists,\n create Textitem or Rename", // Fragetext485 "Text or Rename", // Titel486 JOptionPane.YES_NO_CANCEL_OPTION,487 JOptionPane.QUESTION_MESSAGE, // Icon488 null, optionen,optionen[0] );489 if(n==2){490 createTextItem(text);491 log492 .info("NameItem with a String "493 + text494 + " already existed, created new TextItem instead");495 }else if(n==1){496 log497 .info("NameItem with a String "498 + text499 + " already existed, chose renaming item");500 return;501 }502 else{503 this.closeEditor();504 this.editingFinished();505 return;506 }507 508 509 515 } 510 516 } … … 538 544 } 539 545 546 547 540 548 public void startEditing() { 541 549 setupHelplayer(); … … 607 615 createChildWidget(childItem); 608 616 } 609 617 618 private void createMirrorItem(String text) { 619 IMapItem childItem = mapItem.createMirror(text); 620 Point2D newWidgetPosition = widget.getChildContainer().globalToLocal( 621 mouseClickPosition); 622 childItem 623 .changePosition(new info.imapping.core.domain.impl.Point.ImmutablePoint( 624 newWidgetPosition.getX() - Widget.BASE_HEIGHT, 625 newWidgetPosition.getY() - Widget.BASE_HEIGHT)); 626 childItem.changeExpansionStatus(ExpansionStatus.collapsed); 627 createChildWidget(childItem); 628 629 } 610 630 private void createTextItem(final String text) { 611 631 IMapItem childItem = mapItem.createText(text);
