Package com.eteks.sweethome3d.viewcontroller

Examples of com.eteks.sweethome3d.viewcontroller.HomeController$LanguageChangeListener


   * Binds <code>homeApplication</code> to Mac OS X application menu.
   */
  public static void bindToApplicationMenu(final SweetHome3D homeApplication) {
    Application macosxApplication = Application.getApplication();
    // Create a default controller for an empty home and disable unrelated actions
    final HomeController defaultController =
        homeApplication.createHomeFrameController(homeApplication.createHome()).getHomeController();
    final HomePane defaultHomeView = (HomePane)defaultController.getView();
    for (HomePane.ActionType action : HomePane.ActionType.values()) {
      switch (action) {
        case ABOUT :
        case NEW_HOME :
        case OPEN :
        case DELETE_RECENT_HOMES :
        case HELP :
          break;
        default :
          defaultHomeView.setEnabled(action, false);
      }
    }

    final JMenuBar defaultMenuBar = defaultHomeView.getJMenuBar();
    JFrame frame;
    try {
      if (UIManager.getLookAndFeel().getClass().getName().equals(UIManager.getSystemLookAndFeelClassName())) {
        macosxApplication.setDefaultMenuBar(defaultMenuBar);
        addWindowMenu(null, defaultMenuBar, homeApplication, true);
      }
      frame = null;
    } catch (NoSuchMethodError ex) {
      // Create default frame if setDefaultMenuBar isn't available
      frame = new JFrame();
      final JFrame defaultFrame = frame;
      EventQueue.invokeLater(new Runnable() {
        public void run() {
          // Create a default undecorated frame out of sight
          // and attach the application menu bar of empty view to it
          defaultFrame.setLocation(-10, 0);
          defaultFrame.setUndecorated(true);
          defaultFrame.setVisible(true);
          defaultFrame.setJMenuBar(defaultMenuBar);
          defaultFrame.setContentPane(defaultHomeView);
          addWindowMenu(defaultFrame, defaultMenuBar, homeApplication, true);
        }
      });
    }

    final JFrame defaultFrame = frame;
    // Add a listener to Mac OS X application that will call
    // controller methods of the active frame
    macosxApplication.addApplicationListener(new ApplicationAdapter() {     
      @Override
      public void handleQuit(ApplicationEvent ev) {
        handleAction(new Runnable() {
            public void run() {
              defaultController.exit();
            }
          });
        if (homeApplication.getHomes().isEmpty()) {
          System.exit(0);
        }
      }
     
      @Override
      public void handleAbout(ApplicationEvent ev) {
        handleAction(new Runnable() {
            public void run() {
              defaultController.about();
            }
          });
        ev.setHandled(true);
      }

      @Override
      public void handlePreferences(ApplicationEvent ev) {
        handleAction(new Runnable() {
            public void run() {
              defaultController.editPreferences();
            }
          });
      }
     
      private void handleAction(Runnable runnable) {
View Full Code Here


    this.viewFactory = new SwingViewFactory();
    this.preferences = new DefaultUserPreferences();
    this.preferences.setFurnitureCatalogViewedInTree(true);
    this.home = new Home();
    this.homeController =
        new HomeController(this.home, this.preferences, viewFactory);
    FurnitureCatalogController catalogController =
        homeController.getFurnitureCatalogController();
    this.catalogTree = (FurnitureCatalogTree)catalogController.getView();
    this.furnitureController =
        homeController.getFurnitureController();
View Full Code Here

        return null;
      }     
    };
    Home home = new Home();
    ViewFactory viewFactory = new SwingViewFactory();   
    final HomeController controller = new HomeController(home, preferences, viewFactory, contentManager);
    final JComponent homeView = (JComponent)controller.getView();

    // 1. Create a frame that displays a home view
    JFrame frame = new JFrame("Background Image Wizard Test");   
    frame.add(homeView);
    frame.pack();
View Full Code Here

  public void testHomeExportToOBJ() throws RecorderException {
    // 1. Create an empty home and a 3D controller
    ViewFactory viewFactory = new SwingViewFactory();
    UserPreferences preferences = new DefaultUserPreferences();
    Home home = new Home();
    HomeController homeController =
        new HomeController(home, preferences, viewFactory);
   
    // 2. Add to home a wall and a piece of furniture
    home.addWall(new Wall(0, 0, 0, 1000, 10));
    HomePieceOfFurniture piece = new HomePieceOfFurniture(
        preferences.getFurnitureCatalog().getCategory(0).getPieceOfFurniture(0));
    home.addPieceOfFurniture(piece);
    piece.setX(500);
    piece.setY(500);
    assertEquals("Incorrect wall count", 1, home.getWalls().size());
    assertEquals("Incorrect furniture count", 1, home.getFurniture().size());

    // 3. Export home to OBJ file
    File dir = new File("Tmp@#");
    dir.mkdir();
    File objFile = new File(dir, "Test.obj");
    File mtlFile = new File(dir, "Test.mtl");
    assertFalse(objFile + " exists", objFile.exists());
    assertFalse(mtlFile + " exists", mtlFile.exists());
   
    homeController.getView().exportToOBJ(objFile.toString());
    assertTrue(objFile + " wasn't created", objFile.exists());
    assertTrue(mtlFile + " wasn't created", mtlFile.exists());
   
    for (File file : dir.listFiles()) {
      if (!file.delete()) {
View Full Code Here

          public void write() throws RecorderException {
          }
        };
      ViewFactory viewFactory = new SwingViewFactory();
      FileContentManager contentManager = new FileContentManager(this.preferences);
      this.homeController = new HomeController(this.home, this.preferences, viewFactory, contentManager);
      setRootPane((JRootPane)this.homeController.getView());
      pack();
    }
View Full Code Here

   
    public void propertyChange(PropertyChangeEvent ev) {
      // If home pane was garbage collected, remove this listener from preferences
      HomePane homePane = this.homePane.get();
      JScrollPane planScrollPane = this.planScrollPane.get();
      HomeController controller = this.controller.get();
      if (homePane == null
          || planScrollPane == null
          || controller == null) {
        ((UserPreferences)ev.getSource()).removePropertyChangeListener(
            UserPreferences.Property.RULERS_VISIBLE, this);
View Full Code Here

      public String showSaveDialog(View parentView, String dialogTitle, ContentType contentType, String name) {
        return null;
      }     
    };
    Home home = new Home();
    final HomeController controller =
        new HomeController(home, preferences, viewFactory, contentManager);
    JComponent homeView = (JComponent)controller.getView();
    PlanComponent planComponent = (PlanComponent)TestUtilities.findComponent(
         homeView, PlanComponent.class);

    // 1. Create a frame that displays a home view
    JFrame frame = new JFrame("Imported Texture Wizard Test");   
View Full Code Here

      NoSuchFieldException, IllegalAccessException, InvocationTargetException {
    Locale.setDefault(Locale.FRANCE);
    UserPreferences preferences = new DefaultUserPreferences();
    Home home = new Home();
    home.getCompass().setVisible(false);
    final HomeController controller =
        new HomeController(home, preferences, new SwingViewFactory());
    JComponent homeView = (JComponent)controller.getView();
    PlanComponent planComponent = (PlanComponent)TestUtilities.findComponent(
        homeView, PlanComponent.class);
    HomeComponent3D component3D = (HomeComponent3D)TestUtilities.findComponent(
        homeView, HomeComponent3D.class);
View Full Code Here

   * Returns the home controller managed by this controller.
   */
  public HomeController getHomeController() {
    // Create sub controller lazily only once it's needed
    if (this.homeController == null) {
      this.homeController = new HomeController(
          this.home, this.application, this.viewFactory, this.contentManager, this.pluginManager);
    }
    return this.homeController;
  }
View Full Code Here

    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 WallController(home, preferences, viewFactory, contentManager, undoableEditSupport).getView();
      new RoomController(home, preferences, viewFactory, contentManager, undoableEditSupport).getView();
      new LabelController(home, preferences, viewFactory, undoableEditSupport).getView();
      new CompassController(home, preferences, viewFactory, undoableEditSupport).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 ThreadedTaskController(new Callable<Void>() {
          public Void call() throws Exception {
View Full Code Here

TOP

Related Classes of com.eteks.sweethome3d.viewcontroller.HomeController$LanguageChangeListener

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.