Java 类javax.swing.undo.UndoableEditSupport 实例源码

项目:SweetHome3D    文件:BackgroundImageWizardController.java   
public BackgroundImageWizardController(Home home, UserPreferences preferences, ViewFactory viewFactory,
        ContentManager contentManager, UndoableEditSupport undoSupport)
{
    super(preferences, viewFactory);
    this.home = home;
    this.preferences = preferences;
    this.viewFactory = viewFactory;
    this.contentManager = contentManager;
    this.undoSupport = undoSupport;
    this.propertyChangeSupport = new PropertyChangeSupport(this);
    setTitle(preferences.getLocalizedString(BackgroundImageWizardController.class, "wizard.title"));
    setResizable(true);
    // Initialize states
    this.imageChoiceStepState = new ImageChoiceStepState();
    this.imageScaleStepState = new ImageScaleStepState();
    this.imageOriginStepState = new ImageOriginStepState();
    setStepState(this.imageChoiceStepState);
}
项目:SweetHome3D    文件:LabelController.java   
/**
 * Creates the controller of label creation with undo support.
 */
public LabelController(Home home, float x, float y, UserPreferences preferences, ViewFactory viewFactory,
        UndoableEditSupport undoSupport)
{
    this.home = home;
    this.x = x;
    this.y = y;
    this.preferences = preferences;
    this.viewFactory = viewFactory;
    this.undoSupport = undoSupport;
    this.propertyChangeSupport = new PropertyChangeSupport(this);
    this.fontName = preferences.getDefaultFontName();
    this.fontNameSet = true;
    this.fontSize = preferences.getDefaultTextStyle(Label.class).getFontSize();
    this.pitchEnabled = Boolean.FALSE;
    this.elevation = 0f;
}
项目:SweetHome3D    文件:HomeController.java   
/**
 * Deletes items and post a cut operation to undo support.
 */
public void cut(List<? extends Selectable> items)
{
    // Start a compound edit that deletes items and changes presentation name
    UndoableEditSupport undoSupport = getUndoableEditSupport();
    undoSupport.beginUpdate();
    getPlanController().deleteItems(items);
    // Add a undoable edit to change presentation name
    undoSupport.postEdit(new AbstractUndoableEdit()
    {
        @Override
        public String getPresentationName()
        {
            return preferences.getLocalizedString(HomeController.class, "undoCutName");
        }
    });
    // End compound edit
    undoSupport.endUpdate();
}
项目:SweetHome3D    文件:HomeController.java   
/**
 * Paste the furniture in clipboard to the selected group in home.
 * @since 5.0
 */
public void pasteToGroup()
{
    // Start a compound edit that adds furniture
    UndoableEditSupport undoSupport = getUndoableEditSupport();
    undoSupport.beginUpdate();
    List<HomePieceOfFurniture> addedFurniture = Home.getFurnitureSubList(getView().getClipboardItems());
    adjustFurnitureSizeAndElevation(addedFurniture, true);
    getFurnitureController().addFurnitureToGroup(addedFurniture,
            (HomeFurnitureGroup) this.home.getSelectedItems().get(0));
    undoSupport.postEdit(new AbstractUndoableEdit()
    {
        @Override
        public String getPresentationName()
        {
            return preferences.getLocalizedString(HomeController.class, "undoPasteToGroupName");
        }
    });

    // End compound edit
    undoSupport.endUpdate();
}
项目:SweetHome3D    文件:ImportedFurnitureWizardController.java   
/**
 * Creates a controller that edits <code>piece</code> values.
 */
private ImportedFurnitureWizardController(Home home, CatalogPieceOfFurniture piece, String modelName,
        UserPreferences preferences, FurnitureController furnitureController, ViewFactory viewFactory,
        ContentManager contentManager, UndoableEditSupport undoSupport)
{
    super(preferences, viewFactory);
    this.home = home;
    this.piece = piece;
    this.modelName = modelName;
    this.preferences = preferences;
    this.furnitureController = furnitureController;
    this.viewFactory = viewFactory;
    this.undoSupport = undoSupport;
    this.contentManager = contentManager;
    this.propertyChangeSupport = new PropertyChangeSupport(this);
    setTitle(this.preferences.getLocalizedString(ImportedFurnitureWizardController.class,
            piece == null ? "importFurnitureWizard.title" : "modifyFurnitureWizard.title"));
    // Initialize states
    this.furnitureModelStepState = new FurnitureModelStepState();
    this.furnitureOrientationStepState = new FurnitureOrientationStepState();
    this.furnitureAttributesStepState = new FurnitureAttributesStepState();
    this.furnitureIconStepState = new FurnitureIconStepState();
    setStepState(this.furnitureModelStepState);
}
项目:SweetHome3D    文件:HomeController3D.java   
/**
 * Creates the controller of home 3D view.
 * @param home the home edited by this controller and its view
 */
public HomeController3D(final Home home, UserPreferences preferences, ViewFactory viewFactory,
        ContentManager contentManager, UndoableEditSupport undoSupport)
{
    this.home = home;
    this.preferences = preferences;
    this.viewFactory = viewFactory;
    this.contentManager = contentManager;
    this.undoSupport = undoSupport;
    // Initialize states
    this.topCameraState = new TopCameraState(preferences);
    this.observerCameraState = new ObserverCameraState();
    // Set default state 
    setCameraState(home.getCamera() == home.getTopCamera() ? this.topCameraState : this.observerCameraState);
    addModelListeners(home);
}
项目:incubator-netbeans    文件:XDMModel.java   
/**
 * @param ms requires an instance of org.netbeans.editor.BaseDocument to be
 * available in the lookup;
 */
public XDMModel(ModelSource ms) {
    source = ms;
    // assert getSwingDocument() != null; // It can be null, for example if the file is deleted. 
    ues = new UndoableEditSupport(this);
    pcs = new PropertyChangeSupport(this);
    parser = new XMLSyntaxParser();
    setStatus(Status.UNPARSED);

    //establish a default element identification mechanism
    //domain models should override this by invoking "setElementIdentity"
    ElementIdentity eID = createElementIdentity();
    setElementIdentity(eID);
}
项目:SweetHome3D    文件:WallController.java   
/**
 * Creates the controller of wall view with undo support.
 */
public WallController(final Home home, UserPreferences preferences, ViewFactory viewFactory,
        ContentManager contentManager, UndoableEditSupport undoSupport)
{
    this.home = home;
    this.preferences = preferences;
    this.viewFactory = viewFactory;
    this.contentManager = contentManager;
    this.undoSupport = undoSupport;
    this.propertyChangeSupport = new PropertyChangeSupport(this);

    updateProperties();
}
项目:SweetHome3D    文件:LabelController.java   
/**
 * Creates the controller of label modifications with undo support.
 */
public LabelController(Home home, UserPreferences preferences, ViewFactory viewFactory,
        UndoableEditSupport undoSupport)
{
    this.home = home;
    this.x = null;
    this.y = null;
    this.preferences = preferences;
    this.viewFactory = viewFactory;
    this.undoSupport = undoSupport;
    this.propertyChangeSupport = new PropertyChangeSupport(this);

    updateProperties();
}
项目:SweetHome3D    文件:HomeFurnitureController.java   
/**
 * Creates the controller of home furniture view with undo support.
 */
public HomeFurnitureController(Home home, UserPreferences preferences, ViewFactory viewFactory,
        ContentManager contentManager, UndoableEditSupport undoSupport)
{
    this.home = home;
    this.preferences = preferences;
    this.viewFactory = viewFactory;
    this.contentManager = contentManager;
    this.undoSupport = undoSupport;
    this.propertyChangeSupport = new PropertyChangeSupport(this);

    updateProperties();
}
项目:SweetHome3D    文件:FurnitureController.java   
/**
 * Creates the controller of home furniture view with undo support.
 */
public FurnitureController(final Home home, UserPreferences preferences, ViewFactory viewFactory,
        ContentManager contentManager, UndoableEditSupport undoSupport)
{
    this.home = home;
    this.preferences = preferences;
    this.viewFactory = viewFactory;
    this.undoSupport = undoSupport;
    this.contentManager = contentManager;

    addModelListeners();
}
项目:SweetHome3D    文件:HomeController.java   
/**
 * Adds items to home.
 */
private void addPastedItems(final List<? extends Selectable> items, float dx, float dy,
        final boolean isDropInPlanView, final String presentationNameKey)
{
    if (items.size() > 1 || (items.size() == 1 && !(items.get(0) instanceof Compass)))
    {
        // Always use selection mode after a drop or a paste operation
        getPlanController().setMode(PlanController.Mode.SELECTION);
        // Start a compound edit that adds walls, furniture, rooms, dimension lines, polylines and labels to home
        UndoableEditSupport undoSupport = getUndoableEditSupport();
        undoSupport.beginUpdate();
        List<HomePieceOfFurniture> addedFurniture = Home.getFurnitureSubList(items);
        adjustFurnitureSizeAndElevation(addedFurniture, dx == 0 && dy == 0);
        getPlanController().moveItems(items, dx, dy);
        if (isDropInPlanView && this.preferences.isMagnetismEnabled() && items.size() == 1
                && addedFurniture.size() == 1)
        {
            // Adjust piece when it's dropped in plan view  
            getPlanController().adjustMagnetizedPieceOfFurniture((HomePieceOfFurniture) items.get(0), dx, dy);
        }
        getPlanController().addItems(items);
        undoSupport.postEdit(new AbstractUndoableEdit()
        {
            @Override
            public String getPresentationName()
            {
                return preferences.getLocalizedString(HomeController.class, presentationNameKey);
            }
        });

        // End compound edit
        undoSupport.endUpdate();
    }
}
项目:SweetHome3D    文件:Home3DAttributesController.java   
/**
 * Creates the controller of 3D view with undo support.
 */
public Home3DAttributesController(Home home, UserPreferences preferences, ViewFactory viewFactory,
        ContentManager contentManager, UndoableEditSupport undoSupport)
{
    this.home = home;
    this.preferences = preferences;
    this.viewFactory = viewFactory;
    this.contentManager = contentManager;
    this.undoSupport = undoSupport;
    this.propertyChangeSupport = new PropertyChangeSupport(this);

    updateProperties();
}
项目:SweetHome3D    文件:ImportedFurnitureWizardController.java   
/**
 * Creates a controller that edits a new imported home piece of furniture.
 */
public ImportedFurnitureWizardController(Home home, UserPreferences preferences,
        FurnitureController furnitureController, ViewFactory viewFactory, ContentManager contentManager,
        UndoableEditSupport undoSupport)
{
    this(home, null, null, preferences, furnitureController, viewFactory, contentManager, undoSupport);
}
项目:SweetHome3D    文件:ImportedFurnitureWizardController.java   
/**
 * Creates a controller that edits a new imported home piece of furniture
 * with a given <code>modelName</code>.
 */
public ImportedFurnitureWizardController(Home home, String modelName, UserPreferences preferences,
        FurnitureController furnitureController, ViewFactory viewFactory, ContentManager contentManager,
        UndoableEditSupport undoSupport)
{
    this(home, null, modelName, preferences, furnitureController, viewFactory, contentManager, undoSupport);
}
项目:SweetHome3D    文件:LevelController.java   
/**
 * Creates the controller of home levels view with undo support.
 */
public LevelController(Home home, UserPreferences preferences, ViewFactory viewFactory,
        UndoableEditSupport undoSupport)
{
    this.home = home;
    this.preferences = preferences;
    this.viewFactory = viewFactory;
    this.undoSupport = undoSupport;
    this.propertyChangeSupport = new PropertyChangeSupport(this);

    updateProperties();
}
项目:SweetHome3D    文件:RoomController.java   
/**
 * Creates the controller of room view with undo support.  
 */
public RoomController(final Home home, UserPreferences preferences, ViewFactory viewFactory,
        ContentManager contentManager, UndoableEditSupport undoSupport)
{
    this.home = home;
    this.preferences = preferences;
    this.viewFactory = viewFactory;
    this.contentManager = contentManager;
    this.undoSupport = undoSupport;
    this.propertyChangeSupport = new PropertyChangeSupport(this);

    updateProperties();
}
项目:SweetHome3D    文件:PolylineController.java   
/**
 * Creates the controller of polyline view with undo support.
 */
public PolylineController(final Home home, UserPreferences preferences, ViewFactory viewFactory,
        ContentManager contentManager, UndoableEditSupport undoSupport)
{
    this.home = home;
    this.preferences = preferences;
    this.viewFactory = viewFactory;
    this.undoSupport = undoSupport;
    this.propertyChangeSupport = new PropertyChangeSupport(this);

    updateProperties();
}
项目:SweetHome3D    文件:CompassController.java   
public CompassController(Home home, UserPreferences preferences, ViewFactory viewFactory,
        UndoableEditSupport undoSupport)
{
    this.home = home;
    this.preferences = preferences;
    this.viewFactory = viewFactory;
    this.undoSupport = undoSupport;
    this.propertyChangeSupport = new PropertyChangeSupport(this);

    updateProperties();
}
项目:SweetHome3D    文件:PageSetupController.java   
/**
 * Creates the controller of page setup with undo support.
 */
public PageSetupController(Home home, UserPreferences preferences, ViewFactory viewFactory,
        UndoableEditSupport undoSupport)
{
    this.home = home;
    this.preferences = preferences;
    this.viewFactory = viewFactory;
    this.undoSupport = undoSupport;
    this.propertyChangeSupport = new PropertyChangeSupport(this);

    setPrint(home.getPrint());
}
项目:UbikSim    文件:PlanControllerInspector.java   
public PlanControllerInspector(GUIState guiState, Home home,
        UserPreferences preferences, ViewFactory viewFactory,
        ContentManager contentManager, UndoableEditSupport undoSupport) {
    super(home, preferences, viewFactory, contentManager, undoSupport);
    this.guiState = guiState;
    this.home = home;
    this.preferences = preferences;
    this.viewFactory = viewFactory;
    this.contentManager = contentManager;
    this.undoSupport = undoSupport;
}
项目:osp    文件:JarTreeDialog.java   
/**
 * Constructor.
 *
 * @param owner the owner frame
 * @param root the root directory
 */
public JarTreeDialog(Frame owner, File root) {
  super(owner, true);
  rootFile = root;
  createGUI();
  // set up the undo system
  undoManager = new UndoManager();
  undoSupport = new UndoableEditSupport();
  undoSupport.addUndoableEditListener(undoManager);
  CheckTreeSelectionModel checkModel = checkManager.getSelectionModel();
  checkModel.addPropertyChangeListener(new PropertyChangeListener() {
    public void propertyChange(PropertyChangeEvent e) {
      if(ignoreEvents) {
        return;
      }
      TreePath[] prev = (TreePath[]) e.getOldValue();
      TreePath[] curr = (TreePath[]) e.getNewValue();
      TreePath path = jarTree.getSelectionPath();
      int row = jarTree.getRowForPath(path);
      SelectionEdit edit = new SelectionEdit(prev, prevRow, curr, row);
      undoSupport.postEdit(edit);
      prevRow = row;
      refresh();
    }

  });
  refresh();
  // center on screen
  Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
  int x = (dim.width-getBounds().width)/2;
  int y = (dim.height-getBounds().height)/2;
  setLocation(x, y);
}
项目:UaicNlpToolkit    文件:SelectNodesCommand.java   
public void register(UndoableEditSupport undoSupport) {
    if (prevSelection.equals(nextSelection))
        return;
    undoSupport.postEdit(this);
}
项目:SweetHome3D    文件:Plugin.java   
/**
 * Sets the undoable edit support that records undoable modifications made on a home. 
 */
final void setUndoableEditSupport(UndoableEditSupport undoableEditSupport)
{
    this.undoableEditSupport = undoableEditSupport;
}
项目:SweetHome3D    文件:Plugin.java   
/**
 * Returns the undoable edit support that records undoable modifications made on a home. 
 */
public final UndoableEditSupport getUndoableEditSupport()
{
    return this.undoableEditSupport;
}
项目:SweetHome3D    文件:PluginManager.java   
/**
 * Returns an unmodifiable list of plug-in instances initialized with the 
 * given parameters.
 */
public List<Plugin> getPlugins(final HomeApplication application, final Home home, UserPreferences preferences,
        UndoableEditSupport undoSupport)
{
    return getPlugins(application, home, preferences, null, undoSupport);
}
项目:SweetHome3D    文件:HomeFurnitureController.java   
/**
 * Creates the controller of home furniture view with undo support.
 */
public HomeFurnitureController(Home home, UserPreferences preferences, ViewFactory viewFactory,
        UndoableEditSupport undoSupport)
{
    this(home, preferences, viewFactory, null, undoSupport);
}
项目:SweetHome3D    文件:HomeController.java   
private HomeController(final Home home, final UserPreferences preferences, ViewFactory viewFactory,
        ContentManager contentManager, HomeApplication application)
{
    this.home = home;
    this.preferences = preferences;
    this.viewFactory = viewFactory;
    this.contentManager = contentManager;
    this.application = application;
    this.undoSupport = new UndoableEditSupport()
    {
        @Override
        protected void _postEdit(UndoableEdit edit)
        {
            // Ignore not significant compound edit
            if (!(edit instanceof CompoundEdit) || edit.isSignificant())
            {
                super._postEdit(edit);
            }
        }
    };
    this.undoManager = new UndoManager();
    this.undoSupport.addUndoableEditListener(this.undoManager);

    // Update recent homes list
    if (home.getName() != null)
    {
        List<String> recentHomes = new ArrayList<String>(this.preferences.getRecentHomes());
        recentHomes.remove(home.getName());
        recentHomes.add(0, home.getName());
        updateUserPreferencesRecentHomes(recentHomes);

        // If home version is more recent than current version
        if (home.getVersion() > Home.CURRENT_VERSION)
        {
            // Warn the user that view will display a home created with a more recent version 
            getView().invokeLater(new Runnable()
            {
                public void run()
                {
                    String message = preferences.getLocalizedString(HomeController.class, "moreRecentVersionHome",
                            home.getName());
                    getView().showMessage(message);
                }
            });
        }
    }
}
项目:SweetHome3D    文件:HomeController.java   
/**
 * Returns the undoable edit support managed by this controller.
 */
protected final UndoableEditSupport getUndoableEditSupport()
{
    return this.undoSupport;
}
项目:SweetHome3D    文件:HomeController.java   
/**
 * Adds imported models to home, moves them of (dx, dy) 
 * and post a drop operation to undo support.
 */
public void dropFiles(final List<String> importableModels, float dx, float dy)
{
    // Always use selection mode after a drop operation
    getPlanController().setMode(PlanController.Mode.SELECTION);
    // Add to home a listener to track imported furniture 
    final List<HomePieceOfFurniture> importedFurniture = new ArrayList<HomePieceOfFurniture>(
            importableModels.size());
    CollectionListener<HomePieceOfFurniture> addedFurnitureListener = new CollectionListener<HomePieceOfFurniture>()
    {
        public void collectionChanged(CollectionEvent<HomePieceOfFurniture> ev)
        {
            importedFurniture.add(ev.getItem());
        }
    };
    this.home.addFurnitureListener(addedFurnitureListener);

    // Start a compound edit that adds furniture to home
    UndoableEditSupport undoSupport = getUndoableEditSupport();
    undoSupport.beginUpdate();
    // Import furniture
    for (String model : importableModels)
    {
        getFurnitureController().importFurniture(model);
    }
    this.home.removeFurnitureListener(addedFurnitureListener);

    if (importedFurniture.size() > 0)
    {
        getPlanController().moveItems(importedFurniture, dx, dy);
        this.home.setSelectedItems(importedFurniture);

        // Add a undoable edit that will select the imported furniture at redo
        undoSupport.postEdit(new AbstractUndoableEdit()
        {
            @Override
            public void redo() throws CannotRedoException
            {
                super.redo();
                home.setSelectedItems(importedFurniture);
            }

            @Override
            public String getPresentationName()
            {
                return preferences.getLocalizedString(HomeController.class, "undoDropName");
            }
        });
    }

    // End compound edit
    undoSupport.endUpdate();
}
项目:SweetHome3D    文件:PlanController.java   
/**
 * Creates the controller of plan view. 
 * @param home        the home plan edited by this controller and its view
 * @param preferences the preferences of the application
 * @param viewFactory a factory able to create the plan view managed by this controller
 * @param contentManager a content manager used to import furniture
 * @param undoSupport undo support to post changes on plan by this controller
 */
public PlanController(Home home, UserPreferences preferences, ViewFactory viewFactory,
        ContentManager contentManager, UndoableEditSupport undoSupport)
{
    super(home, preferences, viewFactory, contentManager, undoSupport);
    this.home = home;
    this.preferences = preferences;
    this.viewFactory = viewFactory;
    this.contentManager = contentManager;
    this.undoSupport = undoSupport;
    this.propertyChangeSupport = new PropertyChangeSupport(this);
    this.furnitureSidesCache = new Hashtable<HomePieceOfFurniture, Area>();
    // Initialize states
    this.selectionState = new SelectionState();
    this.selectionMoveState = new SelectionMoveState();
    this.rectangleSelectionState = new RectangleSelectionState();
    this.panningState = new PanningState();
    this.dragAndDropState = new DragAndDropState();
    this.wallCreationState = new WallCreationState();
    this.wallDrawingState = new WallDrawingState();
    this.wallResizeState = new WallResizeState();
    this.pieceOfFurnitureRotationState = new PieceOfFurnitureRotationState();
    this.pieceOfFurnitureElevationState = new PieceOfFurnitureElevationState();
    this.pieceOfFurnitureHeightState = new PieceOfFurnitureHeightState();
    this.pieceOfFurnitureResizeState = new PieceOfFurnitureResizeState();
    this.lightPowerModificationState = new LightPowerModificationState();
    this.pieceOfFurnitureNameOffsetState = new PieceOfFurnitureNameOffsetState();
    this.pieceOfFurnitureNameRotationState = new PieceOfFurnitureNameRotationState();
    this.cameraYawRotationState = new CameraYawRotationState();
    this.cameraPitchRotationState = new CameraPitchRotationState();
    this.cameraElevationState = new CameraElevationState();
    this.dimensionLineCreationState = new DimensionLineCreationState();
    this.dimensionLineDrawingState = new DimensionLineDrawingState();
    this.dimensionLineResizeState = new DimensionLineResizeState();
    this.dimensionLineOffsetState = new DimensionLineOffsetState();
    this.roomCreationState = new RoomCreationState();
    this.roomDrawingState = new RoomDrawingState();
    this.roomResizeState = new RoomResizeState();
    this.roomAreaOffsetState = new RoomAreaOffsetState();
    this.roomAreaRotationState = new RoomAreaRotationState();
    this.roomNameOffsetState = new RoomNameOffsetState();
    this.roomNameRotationState = new RoomNameRotationState();
    this.polylineCreationState = new PolylineCreationState();
    this.polylineDrawingState = new PolylineDrawingState();
    this.polylineResizeState = new PolylineResizeState();
    this.labelCreationState = new LabelCreationState();
    this.labelRotationState = new LabelRotationState();
    this.labelElevationState = new LabelElevationState();
    this.compassRotationState = new CompassRotationState();
    this.compassResizeState = new CompassResizeState();
    // Set default state to selectionState
    setState(this.selectionState);

    addModelListeners();

    // Restore previous scale if it exists
    Number scale = home.getNumericProperty(SCALE_VISUAL_PROPERTY);
    if (scale != null)
    {
        setScale(scale.floatValue());
    }
}
项目:SweetHome3D    文件:RoomTest.java   
/**
 * Tests automatic split of walls surrounding rooms.
 */
public void testRoomWallsSplit() {
  Home home = new Home();
  UserPreferences preferences = new DefaultUserPreferences();
  UndoableEditSupport undoSupport = new UndoableEditSupport();
  UndoManager undoManager = new UndoManager();
  undoSupport.addUndoableEditListener(undoManager);

  // 1. Create a home drawing walls as follows 
  // --------------------
  // |        |         |
  // |   0    |    1    |
  // |--------|         |
  // |        |         |
  // |        |         |
  // |        |        /
  // -----------------/
  Wall [] walls = {new Wall(0, 0, 1000, 0, 20, 250), 
                   new Wall(1000, 0, 1000, 800, 20, 250), 
                   new Wall(1000, 800, 800, 1000, 20, 250), 
                   new Wall(800, 1000, 0, 1000, 20, 250), 
                   new Wall(0, 1000, 0, 0, 20, 250),
                   new Wall(500, 0, 500, 1000, 10, 250),
                   new Wall(0, 400, 500, 400, 10, 250)};
  // Join the first 4 walls
  for (int i = 0; i < 4; i++) {
    walls [i].setWallAtStart(walls [(i + 3) % 4]);
    walls [i].setWallAtEnd(walls [(i + 1) % 4]);
  }
  for (Wall wall : walls) {
    home.addWall(wall);
  }

  // 2. Create automatically 2 rooms by simulating double clicks
  PlanController planController = new PlanController(home, preferences, new SwingViewFactory(), null, undoSupport);
  planController.setMode(PlanController.Mode.ROOM_CREATION);
  planController.pressMouse(50, 50, 1, false, false);
  planController.pressMouse(50, 50, 2, false, false);
  assertEquals("Room wasn't created", 1, home.getRooms().size());
  assertRoomCoordinates(home.getRooms().get(0), 
      new float [][] {{495.0f, 10.0f}, {495.0f, 395.0f}, {10.0f, 395.0f}, {10.0f, 10.0f}});
  planController.pressMouse(700, 700, 1, false, false);
  planController.pressMouse(700, 700, 2, false, false);
  Room room = home.getRooms().get(1);
  assertRoomCoordinates(room, 
      new float [][] {{990.0f, 10.0f}, {990.0f, 795.8579f}, {795.8579f, 990.0f}, {505.0f, 990.0f}, {505.0f, 10.0f}});
  assertTrue("Second room isn't selected", home.getSelectedItems().contains(room));

  // 3. Split walls automatically
  RoomController roomController = new RoomController(home, preferences, new SwingViewFactory(), null, undoSupport);
  assertTrue("Walls around second room have to be splitted", roomController.isSplitSurroundingWallsNeeded());
  roomController.setSplitSurroundingWalls(true);
  roomController.modifyRooms();
  // Check two walls were split
  assertEquals("No wall was split", walls.length + 2, home.getWalls().size());
  undoManager.undo();
  assertEquals("Incorrect wall count", walls.length, home.getWalls().size());

  home.setSelectedItems(Arrays.asList(new Selectable [] {home.getRooms().get(0), walls [0]}));
  roomController = new RoomController(home, preferences, new SwingViewFactory(), null, undoSupport);
  roomController.setSplitSurroundingWalls(true);
  roomController.modifyRooms();
  // Check 3 walls were split
  assertEquals("No wall was split", walls.length + 3, home.getWalls().size());
  // Check selection contains 1 more item
  assertEquals("Selection doesn't contain split walls", 3, home.getSelectedItems().size());
  undoManager.undo();
  assertEquals("Selection wasn't restored", 2, home.getSelectedItems().size());
  undoManager.redo();
  assertEquals("No wall was split", walls.length + 3, home.getWalls().size());
  assertEquals("Selection doesn't contain split walls", 3, home.getSelectedItems().size());

  roomController = new RoomController(home, preferences, new SwingViewFactory(), null, undoSupport);
  assertFalse("Walls around first room don't need to be splitted", roomController.isSplitSurroundingWallsNeeded());
}
项目:SweetHome3D    文件:UserPreferencesPanelTest.java   
/**
 * Tests language changes on the GUI. 
 */
public void testLanguageChange() {
  Locale defaultLocale = Locale.getDefault();
  Locale.setDefault(Locale.US);
  UserPreferences preferences = new DefaultUserPreferences() {
    @Override
    public void write() throws RecorderException {
      // Ignore write requests
    }
  };

  Home home = new Home();
  Content imageContent = new URLContent(UserPreferencesPanelTest.class.getResource("resources/test.png"));
  home.setBackgroundImage(new BackgroundImage(imageContent, 1, 0, 1, 0, 1, 0, 0));

  SwingViewFactory viewFactory = new SwingViewFactory();
  FileContentManager contentManager = new FileContentManager(preferences);
  UndoableEditSupport undoableEditSupport = new UndoableEditSupport();

  for (String language : preferences.getSupportedLanguages()) {
    preferences.setLanguage(language);
    // Instantiate all views available in Sweet Home 3D 
    HomeController homeController = new HomeController(home, preferences, viewFactory, contentManager);
    homeController.getView();
    preferences.setFurnitureCatalogViewedInTree(false);
    new FurnitureCatalogController(preferences.getFurnitureCatalog(), preferences, viewFactory, contentManager).getView();
    preferences.setFurnitureCatalogViewedInTree(true);
    new FurnitureCatalogController(preferences.getFurnitureCatalog(), preferences, viewFactory, contentManager).getView();
    new FurnitureController(home, preferences, viewFactory).getView();
    new PlanController(home, preferences, viewFactory, contentManager, undoableEditSupport).getView();
    new HomeController3D(home, preferences, viewFactory, contentManager, undoableEditSupport).getView();

    new PageSetupController(home, preferences, viewFactory, undoableEditSupport).getView();
    new PrintPreviewController(home, preferences, homeController, viewFactory).getView();
    new UserPreferencesController(preferences, viewFactory, contentManager).getView();
    new HomeFurnitureController(home, preferences, viewFactory, contentManager, undoableEditSupport).getView();
    new LevelController(home, preferences, viewFactory, undoableEditSupport).getView();
    new WallController(home, preferences, viewFactory, contentManager, undoableEditSupport).getView();
    new RoomController(home, preferences, viewFactory, contentManager, undoableEditSupport).getView();
    new PolylineController(home, preferences, viewFactory, contentManager, undoableEditSupport).getView();
    new LabelController(home, preferences, viewFactory, undoableEditSupport).getView();
    new CompassController(home, preferences, viewFactory, undoableEditSupport).getView();
    new ObserverCameraController(home, preferences, viewFactory).getView();
    new Home3DAttributesController(home, preferences, viewFactory, contentManager, undoableEditSupport).getView();
    new PhotoController(home, preferences, homeController.getHomeController3D().getView(), viewFactory, contentManager).getView();
    new VideoController(home, preferences, viewFactory, contentManager).getView();

    new TextureChoiceController("", preferences, viewFactory, contentManager).getView();
    new ModelMaterialsController("", preferences, viewFactory, contentManager).getView();
    new ThreadedTaskController(new Callable<Void>() { 
        public Void call() throws Exception {
          return null;
        }
      }, "", null, preferences, viewFactory).getView();

    new BackgroundImageWizardController(home, preferences, viewFactory, contentManager, undoableEditSupport).getView();
    new ImportedFurnitureWizardController(preferences, viewFactory, contentManager).getView();
    new ImportedTextureWizardController(preferences, viewFactory, contentManager).getView();

    new HelpController(preferences, viewFactory).getView();
    Locale.setDefault(defaultLocale);
  }
}
项目:mytechia_commons    文件:UndoableModelAction.java   
public UndoableModelAction(String name, 
        UndoableEditSupport undoSupport, ChangesManager changesManager)
{
    super(name, changesManager);
    this.undoSupport = undoSupport;
}