Esempio n. 1
0
 public static void invokeAndWait(Runnable runnable) {
   if (SwingUtilities.isEventDispatchThread()) {
     runnable.run();
   } else {
     try {
       SwingUtilities.invokeAndWait(runnable);
     } catch (InvocationTargetException | InterruptedException e) {
       e.printStackTrace();
     }
   }
 }
 @Override
 public boolean performFinish() {
   AsposeMavenProjectSupport asposeMavenProjectSupport =
       new AsposeMavenProjectSupport(
           wizardPage.getProjectName(),
           wizardPage.getLocationURI(),
           wizardPage.getPackageName(),
           wizardPage.isDownloadExamplesChecked(),
           wizardPage.getVersion(),
           wizardPage.getGroupId());
   try {
     new ProgressMonitorDialog(this.getShell()).run(true, false, asposeMavenProjectSupport);
   } catch (InvocationTargetException | InterruptedException e) {
     e.printStackTrace();
   }
   return true;
 }
    @Override
    protected List<AppsListItem> doInBackground(Void... params) {
      mCacheSize = 0;

      final List<ApplicationInfo> packages =
          getPackageManager().getInstalledApplications(PackageManager.GET_META_DATA);

      publishProgress(0, packages.size());

      final CountDownLatch countDownLatch = new CountDownLatch(packages.size());

      final List<AppsListItem> apps = new ArrayList<>();

      try {
        for (ApplicationInfo pkg : packages) {
          mGetPackageSizeInfoMethod.invoke(
              getPackageManager(),
              pkg.packageName,
              new IPackageStatsObserver.Stub() {

                @Override
                public void onGetStatsCompleted(PackageStats pStats, boolean succeeded)
                    throws RemoteException {
                  synchronized (apps) {
                    publishProgress(++mAppCount, packages.size());

                    mCacheSize += addPackage(apps, pStats, succeeded);
                  }

                  synchronized (countDownLatch) {
                    countDownLatch.countDown();
                  }
                }
              });
        }

        countDownLatch.await();
      } catch (InvocationTargetException | InterruptedException | IllegalAccessException e) {
        e.printStackTrace();
      }

      return new ArrayList<>(apps);
    }
Esempio n. 4
0
  public void run() {
    System.out.print("Your name is :");
    try {
      synchronized (Main.gigi) {
        Main.gigi.wait();
      }

    } catch (InterruptedException e1) {
      // TODO Auto-generated catch block

    }

    hero.setName(GUI.getStdin());
    hero.setGold(300);
    System.out.println(hero.getName());
    // SimplePlayer music = new SimplePlayer();
    int mapLevel = 1;
    m = new Map(9, mapLevel);
    try {
      EventQueue.invokeAndWait(
          new Runnable() {
            public void run() {
              try {
                mapGUI = new MapGUI(m, hero);
              } catch (Exception e) {
                e.printStackTrace();
              }
            }
          });
    } catch (InvocationTargetException | InterruptedException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    }

    while (hero.getCurrentHitPoints() > 0) {
      mapGUI.update();
      mapGUI.repaint();

      // System.out
      //	.println("You are at :  X " + hero.getVerticalLocation() + "  Y  " +
      // hero.getHorizontalLocation());
      try {
        m.movePlayer(hero);
        if (m.getRoom(hero.getVerticalLocation(), hero.getHorizontalLocation())
            instanceof EmptyRoom) {
          System.out.println("This room is empty as f**k.");
        }
        if (m.getRoom(hero.getVerticalLocation(), hero.getHorizontalLocation())
            instanceof MonsterRoom) {
          MonsterRoom temp =
              (MonsterRoom) (m.getRoom(hero.getVerticalLocation(), hero.getHorizontalLocation()));
          if (temp.getMonster().isAlive() == false) {
            System.out.println("Monster is dead.");
          } else {
            Battle b = new Battle(hero, temp.getMonster());
            System.out.println("Current Gold : " + hero.getGold());
          }
        }
        if (m.getRoom(hero.getVerticalLocation(), hero.getHorizontalLocation())
            instanceof BossRoom) {
          BossRoom temp =
              (BossRoom) (m.getRoom(hero.getVerticalLocation(), hero.getHorizontalLocation()));
          Battle b = new Battle(hero, temp.getMonster());
          if (!temp.getMonster().isAlive()) {

            System.out.println("Current Gold : " + hero.getGold());
            System.out.println(
                temp.getMonster().getName() + " is dead,you delve deeper into the dungeon.");
            mapLevel++;
            m = new Map(9, mapLevel);
            mapGUI.hide();
            mapGUI = new MapGUI(m, hero);
            hero.setCurrentHitPoints(hero.getMaxHitPoints());
          }
        }
        if (m.getRoom(hero.getVerticalLocation(), hero.getHorizontalLocation())
            instanceof CityRoom) {
          Trader t = new Trader();
          Trade trade = new Trade(hero, t);
        }
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
    // SQL.recordHighScore(hero.getName(), hero.getGold());
    System.out.println("YOU LOST!");
    // SQL.getHighScores();
  }