Package com.eteks.sweethome3d.viewcontroller

Examples of com.eteks.sweethome3d.viewcontroller.ThreadedTaskController$ExceptionHandler


                    preferences.getLocalizedString(EditorController.class, "invalidFile"));
              }
            }
          }
        };
    new ThreadedTaskController(saveTask,
        this.preferences.getLocalizedString(EditorController.class, "openMessage"), exceptionHandler,
        this.preferences, this.viewFactory).executeTask(getView());
  }
View Full Code Here


                    preferences.getLocalizedString(EditorController.class, "saveError"));
              }
            }
          }
        };
    new ThreadedTaskController(saveTask,
        this.preferences.getLocalizedString(EditorController.class, "saveMessage"), exceptionHandler,
        this.preferences, this.viewFactory).executeTask(getView());
  }
View Full Code Here

          throw new UnsupportedOperationException();
        }
      };

   String importFurnitureMessage = preferences.getLocalizedString(ImportFurnitureController.class, "importFurnitureMessage");
   this.threadedTaskController = new ThreadedTaskController(importFurnitureTask, importFurnitureMessage, exceptionHandler,
       preferences, threadedTaskViewFactory);
  }
View Full Code Here

        };
    KeyboardFocusManager.getCurrentKeyboardFocusManager().
        addPropertyChangeListener("activeWindow", activeWindowListener);
    // Check that a simple short task is correctly executed with no exception
    // and doesn't create any visible dialog at screen
    new ThreadedTaskController(shortTask, "Message", noExceptionHandler, preferences, viewFactory).executeTask(null);
    shortTaskLatch.await(1000, TimeUnit.MILLISECONDS);
    assertEquals("Simple task wasn't executed", 0, shortTaskLatch.getCount());
    KeyboardFocusManager.getCurrentKeyboardFocusManager().
        removePropertyChangeListener("activeWindow", activeWindowListener);
   
    // 2. Create a longer task
    final CountDownLatch longTaskLatch = new CountDownLatch(2);
    Callable<Void> longTask = new Callable<Void>() {
        public Void call() throws Exception {
          Thread.sleep(1000);
          longTaskLatch.countDown();
          return null;
        }
      };
    // Add a listener that counts down latch once a waiting dialog is displayed
    activeWindowListener = new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent ev) {
            longTaskLatch.countDown();
          }
        };
    KeyboardFocusManager.getCurrentKeyboardFocusManager().
        addPropertyChangeListener("activeWindow", activeWindowListener);
    // Check that a long task creates a visible dialog at screen
    new ThreadedTaskController(longTask, "Message", noExceptionHandler, preferences, viewFactory).executeTask(null);
    longTaskLatch.await(1500, TimeUnit.MILLISECONDS);
    assertEquals("Long task wasn't executed with a waiting dialog", 0, longTaskLatch.getCount());
    KeyboardFocusManager.getCurrentKeyboardFocusManager().
        removePropertyChangeListener("activeWindow", activeWindowListener);
   
    // 3. Create a long task that we will cancel 
    final CountDownLatch cancelledTaskLatch = new CountDownLatch(1);
    Callable<Void> cancelledTask = new Callable<Void>() {
        public Void call() throws Exception {
          try {
            Thread.sleep(1000);
          } catch (InterruptedException ex) {
            cancelledTaskLatch.countDown();
          }
          return null;
        }
      };
    // Add a listener that closes the waiting dialog
    activeWindowListener = new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent ev) {
            final Window activeWindow = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();
            if (activeWindow != null) {
              try {
                ((JButton)TestUtilities.findComponent(activeWindow, JButton.class)).doClick();
              } catch (ComponentSearchException ex) {
                fail("No button in waiting dialog");
              }
            }
          }
        };
    KeyboardFocusManager.getCurrentKeyboardFocusManager().
        addPropertyChangeListener("activeWindow", activeWindowListener);
    // Check that a long task creates a visible dialog at screen
    new ThreadedTaskController(cancelledTask, "Message", noExceptionHandler, preferences, viewFactory).executeTask(null);
    cancelledTaskLatch.await(1500, TimeUnit.MILLISECONDS);
    assertEquals("Task wasn't cancelled", 0, cancelledTaskLatch.getCount());
    KeyboardFocusManager.getCurrentKeyboardFocusManager().
        removePropertyChangeListener("activeWindow", activeWindowListener);

    // 4. Create a task that fails 
    final CountDownLatch failingTaskLatch = new CountDownLatch(2);
    Callable<Void> failingTask = new Callable<Void>() {
        public Void call() throws Exception {
          failingTaskLatch.countDown();
          throw new Exception();
        }
      };
    // Create an exception handler that counts down latch when it's called
    ThreadedTaskController.ExceptionHandler exceptionHandler =
        new ThreadedTaskController.ExceptionHandler() {
          public void handleException(Exception ex) {
            failingTaskLatch.countDown();
          }
        };
    // Check that a long task creates a visible dialog at screen
    new ThreadedTaskController(failingTask, "Message", exceptionHandler, preferences, viewFactory).executeTask(null);
    failingTaskLatch.await(1000, TimeUnit.MILLISECONDS);
    assertEquals("Exception in task wasn't handled", 0, failingTaskLatch.getCount());
  }
View Full Code Here

      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 {
            return null;
          }
        }, "", null, preferences, viewFactory).getView();
     
View Full Code Here

                  ex.printStackTrace();
                }
              }
            }
          };
      new ThreadedTaskController(openTask,
          preferences.getLocalizedString(ViewerHelper.class, "openMessage"), exceptionHandler,
          null, viewFactory).executeTask(null);
    } catch (MalformedURLException ex) {
      showError(applet.getRootPane(),
          preferences.getLocalizedString(ViewerHelper.class, "openError", homeUrlParameter));
View Full Code Here

                  ex.printStackTrace();
                }
              }
            }
          };
      new ThreadedTaskController(exportToObjTask,
          this.application.getUserPreferences().getLocalizedString(HomeAppletController.class, "exportToSH3DMessage"), exceptionHandler,
          this.application.getUserPreferences(), viewFactory).executeTask(getView());
    }
  }
View Full Code Here

TOP

Related Classes of com.eteks.sweethome3d.viewcontroller.ThreadedTaskController$ExceptionHandler

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.