Esempio n. 1
1
  public void bootOptionsReceived(BootEvent bootEvent) {
    log.info(" boot options received " + bootEvent.getNewSessionOptions());

    // reload setting, to ensure correct bootstraps
    ConfigureFactory.getInstance().reloadSettings();

    // If the options are not equal to the string 'null' then we have boot options
    if (!bootEvent.getNewSessionOptions().equals("null")) {
      // check if a session parameter is specified on the command line
      String[] args = new String[TN5250jConstants.NUM_PARMS];
      parseArgs(bootEvent.getNewSessionOptions(), args);

      if (isSpecified("-s", args)) {

        String sd = getParm("-s", args);
        if (sessions.containsKey(sd)) {
          parseArgs(sessions.getProperty(sd), args);
          final String[] args2 = args;
          final String sd2 = sd;
          SwingUtilities.invokeLater(() -> newSession(sd2, args2));
        }
      } else {

        if (args[0].startsWith("-")) {
          SwingUtilities.invokeLater(() -> startNewSession());
        } else {
          final String[] args2 = args;
          final String sd2 = args[0];
          SwingUtilities.invokeLater(() -> newSession(sd2, args2));
        }
      }
    } else {
      SwingUtilities.invokeLater(() -> startNewSession());
    }
  }
 @Override
 public void addNotifications(
     final NotificationChannel channel, Collection<NotificationItem> items) {
   channel.addNotifications(items);
   if (!channel.isVisible()) {
     boolean hasVisibleChannel = false;
     for (NotificationChannel ch : NotificationChannel.values()) {
       hasVisibleChannel |= ch.isVisible();
     }
     SwingUtilities.invokeLater(
         new Runnable() {
           @Override
           public void run() {
             channel.saveNormalColor();
             channel.getButton().setBackground(channel.getColor());
             showNotification(channel);
           }
         });
     if (!hasVisibleChannel) {
       SwingUtilities.invokeLater(
           new Runnable() {
             @Override
             public void run() {
               showNotification(channel);
             }
           });
     }
   }
 }
Esempio n. 3
0
    @Override
    public void update(Observable o, Object arg) {
      PingsClient client = (PingsClient) o;

      if (!client.getSourceGeoip().equals(client_geoip_info)) {
        client_geoip_info = client.getSourceGeoip();
        // FIXME: get ip from server
        SwingUtilities.invokeLater(
            new Runnable() {
              public void run() {
                updateClientInfoDisplay("", client_geoip_info);
              }
            });
        return;
      }

      GeoipInfo current_ping_geoip = client.getCurrentDestGeoip();
      InetAddress current_ping_adress = client.getCurrentPingDest();

      // If there are several PingsClient threads then this might still be
      // a
      if (current_ping_adress == null) return;

      // If there is a new ping add it to the counter and register an
      // effect for the globe
      if (gui_effect == null && last_address != current_ping_adress) {
        last_address = current_ping_adress;

        pings_counter++;
        SwingUtilities.invokeLater(
            new Runnable() {
              public void run() {
                updatePingsCounterDisplay();
              }
            });

        gui_effect = ping_globe.addPing(current_ping_geoip);
      }
      // Else if it's the last ping update it
      else if (gui_effect != null && last_address == current_ping_adress) {
        gui_effect.updatePingGUIValue(client.getCurrentPingResult());
        gui_effect = null;
      }
      // Else there are two case :
      // _ either the destination address is the same (and with the
      // current implementation there is no way to know it). This case has a
      // very low probability.
      // _ or we somehow missed the result of the previous ping, hence
      // we need to do some workaround for the old ping and declare a
      // new one.
      else {
        if (gui_effect != null) gui_effect.unknownError();
        String value = client.getCurrentPingResult();
        gui_effect = ping_globe.addPing(current_ping_geoip);
        if (!value.equals("")) {
          gui_effect.updatePingGUIValue(client.getCurrentPingResult());
          gui_effect = null;
        }
      }
    }
Esempio n. 4
0
 public static void main(String[] args) throws Exception {
   if (args != null && args.length == 4) {
     final String zipFile = args[0];
     final String findFile = args[1];
     final boolean regexp = Boolean.parseBoolean(args[2]);
     final boolean showUI = Boolean.parseBoolean(args[3]);
     // System.out.println(ipaFile);
     // System.out.println(findFile);
     // System.out.println(regexp);
     // System.out.println(showUI);
     if (showUI) {
       SwingUtilities.invokeLater(
           new Runnable() {
             public void run() {
               new AppMainFrame(zipFile, findFile, regexp).setVisible(true);
             }
           });
     } else {
       String info = FileUtil.getFileData(zipFile, findFile, regexp);
       // System.out.println(info);
     }
   } else {
     SwingUtilities.invokeLater(
         new Runnable() {
           public void run() {
             new AppMainFrame().setVisible(true);
           }
         });
   }
 }
Esempio n. 5
0
    @Override
    public void run() {
      SwingUtilities.invokeLater(
          new Runnable() {

            @Override
            public void run() {
              clusterStatusText.setText("Querying EC2, please wait...");
            }
          });
      EC2Agent agent = new EC2Agent();
      status = "Cluster status:\nUnknown";
      try {
        status = agent.describeRunningInstances();
        if (agent.getRunningInstances(true).size() == Settings.getSettings().getClusterSize()) {
          status += "\n\n" + agent.getClusterState();
        }
      } catch (Exception e) {
        e.printStackTrace(System.out);
      }
      SwingUtilities.invokeLater(
          new Runnable() {

            @Override
            public void run() {
              clusterStatusText.setText(status);
            }
          });
    }
 protected void doUpdateDescription(final Sector sector) {
   if (sector != null) {
     try {
       long size = retrievable.getEstimatedMissingDataSize(sector, 0, cache);
       final String formattedSize = BulkDownloadPanel.makeSizeDescription(size);
       SwingUtilities.invokeLater(
           new Runnable() {
             public void run() {
               descriptionLabel.setText(formattedSize);
             }
           });
     } catch (Exception e) {
       SwingUtilities.invokeLater(
           new Runnable() {
             public void run() {
               descriptionLabel.setText("-");
             }
           });
     }
   } else
     SwingUtilities.invokeLater(
         new Runnable() {
           public void run() {
             descriptionLabel.setText("-");
           }
         });
 }
Esempio n. 7
0
 /* Implementation of IPlaybackListener * */
 public void playbackFinished(final PlaybackResult result, boolean shutdown) {
   this.autShutdown = shutdown;
   displayView.endTest(result);
   if (ddTestRunner != null && ddTestRunner.hasNext() && !playbackStopped) {
     ddTestRunner.next();
     SwingUtilities.invokeLater(
         new Runnable() {
           public void run() {
             if (result.failureCount() == 0) {
               shouldClose = !reuseFixture;
               displayView.trackProgress();
               ignoreReuse = false;
             } else {
               ignoreReuse = true;
               shouldClose = false;
             }
             stopApplicationIfNecessary();
             runTest();
           }
         });
     return;
   }
   displayView.endTestRun();
   displayView.stopInserting();
   SwingUtilities.invokeLater(
       new Runnable() {
         public void run() {
           showResult(result);
         }
       });
   ddTestRunner = null;
 }
  private void showOperation(OperationItemId id, OperationInfo op) {

    final OperationItemId finalId = id;
    final OperationInfo finalInfo = op;
    // check if the panel was already added i.e. some input was being entered
    // check if that input is saved or not
    if (TableUtil.checkIfExists(rightPanel, addOperationPanel)) {
      checkNewOperationSave(addOperationPanel);
      SwingUtilities.invokeLater(
          new Runnable() {
            @Override
            public void run() {
              rightPanel.remove(addOperationPanel);
              rightPanel.add(displayDataPanel);
            }
          });

    } else if (TableUtil.checkIfExists(rightPanel, displayDataPanel)) {
      checkDisplayOperationSave(displayDataPanel);
    } else {
      rightPanel.add(displayDataPanel);
    }
    SwingUtilities.invokeLater(
        new Runnable() {
          @Override
          public void run() {
            displayDataPanel.populate(finalId, finalInfo);
            rightPanel.revalidate();
            rightPanel.repaint();
          }
        });
  }
Esempio n. 9
0
 /** Inits the dialog after it becomes visible. */
 @Override
 protected void initDialogAfterVisible() {
   final DrbdResourceInfo dri = getDrbdVolumeInfo().getDrbdResourceInfo();
   final boolean ch = dri.checkResourceFieldsChanged(null, PARAMS);
   final boolean cor = dri.checkResourceFieldsCorrect(null, PARAMS);
   if (cor) {
     enableComponents();
   } else {
     /* don't enable */
     enableComponents(new JComponent[] {buttonClass(nextButton())});
   }
   SwingUtilities.invokeLater(
       new Runnable() {
         public void run() {
           makeDefaultButton(buttonClass(nextButton()));
         }
       });
   if (Tools.getConfigData().getAutoOptionGlobal("autodrbd") != null) {
     SwingUtilities.invokeLater(
         new Runnable() {
           @Override
           public void run() {
             pressNextButton();
           }
         });
   }
 }
Esempio n. 10
0
  public static void main(String[] args) {

    // UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

    if (args.length == 1 && args[0].equals(TEST_FLAG)) {

      String[] filesToTest =
          new String[] {
            "examples/l22_cylsoma.swc",
            "examples/l22_sphersoma.swc",
            "examples/l22.swc",
            "examples/l22_small.swc",
            "examples/dCH-cobalt.CNG_small.swc",
            "examples/dCH-cobalt.CNG.swc"
          };

      for (String f : filesToTest) {
        String[] argsNew = new String[] {f, TEST_FLAG};
        SwingUtilities.invokeLater(new main(argsNew));
      }

    } else {
      SwingUtilities.invokeLater(new main(args));
    }
  }
    protected void preCache(List<Position> grid, Position centerPosition)
        throws InterruptedException {
      // Pre-cache the tiles that will be needed for the intersection calculations.
      double n = 0;
      final long start = System.currentTimeMillis();
      for (Position gridPos : grid) // for each grid point.
      {
        final double progress = 100 * (n++ / grid.size());
        terrain.cacheIntersectingTiles(centerPosition, gridPos);

        SwingUtilities.invokeLater(
            new Runnable() {
              public void run() {
                progressBar.setValue((int) progress);
                progressBar.setString(null);
              }
            });
      }

      SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {
              progressBar.setValue(100);
            }
          });

      long end = System.currentTimeMillis();
      System.out.printf(
          "Pre-caching time %d milliseconds, cache usage %f, tiles %d\n",
          end - start, terrain.getCacheUsage(), terrain.getNumCacheEntries());
    }
  private void selectPath(final CCTNode[] path, final int length) {
    if (length >= path.length) {
      final CCTNode node = (CCTNode) new TreePath(path).getLastPathComponent();

      // --- #208900 make sure the row is visible even if displaying a scrollbar
      fieldsListTable.selectNode(node, true);
      SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {
              fieldsListTable.selectNode(node, true);
            }
          });
      // ---
    } else {
      Object[] shortPath = new Object[length];
      System.arraycopy(path, 0, shortPath, 0, length);
      final TreePath p = new TreePath(shortPath);
      SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {
              selectPath(path, length + MAX_STEP);
            }
          });
    }
  }
  public void runGame() {
    SwingUtilities.invokeLater(a);
    try {
      sleep(delay);
    } catch (InterruptedException e) {
      System.out.println("interrupted.");
    }
    while (!world.endGame()) {
      // System.out.println("Game playing. Making move.");
      int action1 = -1;
      int action2 = -1;
      action1 = policy1.getBestAction(world.getState1());
      action2 = policy2.getBestAction(world.getState2());
      System.out.println("action2 " + action2);
      SwingUtilities.invokeLater(a);

      try {
        sleep(delay);
      } catch (InterruptedException e) {
        System.out.println("interrupted.");
      }
    }
    a.agentsScore += world.agent1Score;
    a.catScore += world.fail;

    // turn off gameOn flag if only single game
    if (single) gameOn = false;
  }
Esempio n. 14
0
  public void addNewPortController(final PortInfoView portcontroller) {

    // add the row to the table
    SwingUtilities.invokeLater(
        new Runnable() {
          public void run() {

            logger.debug("Adding portcontroller");

            if (boxControllers.getComponentCount() > 0) {
              boxControllers.remove(boxControllers.getComponentCount() - 1);
            }

            boxControllers.add(portcontroller);
            revalidate();
          }
        });

    SwingUtilities.invokeLater(
        new Runnable() {
          public void run() {

            boxControllers.add(Box.createVerticalGlue());
          }
        });
  }
Esempio n. 15
0
 /** prints error text in the answer pane, reenables buttons and adds retry button. */
 public final void printErrorAndRetry(String text, final String ans, final int exitCode) {
   if (ans != null) {
     text += "\n" + Tools.getString("Dialog.Dialog.PrintErrorAndRetry") + exitCode + "\n" + ans;
   }
   answerPaneSetTextError(text);
   addRetryButton();
   if (buttonClass(retryButton()) != null) {
     SwingUtilities.invokeLater(
         new Runnable() {
           @Override
           public void run() {
             buttonClass(retryButton()).requestFocus();
           }
         });
   }
   if (buttonClass(nextButton()) != null) {
     enableComponents(new JComponent[] {buttonClass(nextButton())});
     SwingUtilities.invokeLater(
         new Runnable() {
           @Override
           public void run() {
             buttonClass(nextButton()).setEnabled(false);
           }
         });
   }
 }
Esempio n. 16
0
  private void populatePortTable(List ports) {

    logger.debug("Filling port table");
    // get an array of ports
    final PortInfoController[] portcontrollers =
        (PortInfoController[]) ports.toArray(new PortInfoController[ports.size()]);

    // setup the panel
    boxControllers.removeAll();

    // add the ports to the data array
    for (int index = 0; index < portcontrollers.length; index++) {

      final int indexFinal = index;
      SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {

              boxControllers.add(portcontrollers[indexFinal].getView());
            }
          });
    }

    SwingUtilities.invokeLater(
        new Runnable() {
          public void run() {

            boxControllers.add(Box.createVerticalGlue());
          }
        });
  }
Esempio n. 17
0
  private void join(final String url) {
    SwingUtilities.invokeLater(
        new Runnable() {
          @Override
          public void run() {
            SOverlayUtils.startGameOverlay("Connecting to server...");
            SOverlayUtils.showOverlay();
          }
        });

    final ChatMessage result =
        NetConnectUtil.join(
            url, VSubmenuOnlineLobby.SINGLETON_INSTANCE, FNetOverlay.SINGLETON_INSTANCE);

    SwingUtilities.invokeLater(
        new Runnable() {
          @Override
          public void run() {
            SOverlayUtils.hideOverlay();
            FNetOverlay.SINGLETON_INSTANCE.show(result);
            if (CHomeUI.SINGLETON_INSTANCE.getCurrentDocID() == EDocID.HOME_NETWORK) {
              VSubmenuOnlineLobby.SINGLETON_INSTANCE.populate();
            }
          }
        });
  }
  private void setAllSlidersComp(final String[] data) {

    if (SwingUtilities.isEventDispatchThread()) {
      Main_frame.compressor_attack_slider.setValue(Integer.parseInt(data[8]));
    } else {
      SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {
              Main_frame.compressor_attack_slider.setValue(Integer.parseInt(data[8]));
            }
          });
    }

    if (SwingUtilities.isEventDispatchThread()) {
      Main_frame.compressor_decay_slider.setValue(Integer.parseInt(data[9]));
    } else {
      SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {
              Main_frame.compressor_decay_slider.setValue(Integer.parseInt(data[9]));
            }
          });
    }
    if (SwingUtilities.isEventDispatchThread()) {
      Main_frame.compressor_ratio_slider.setValue(Integer.parseInt(data[10]));
    } else {
      SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {
              Main_frame.compressor_ratio_slider.setValue(Integer.parseInt(data[10]));
            }
          });
    }

    if (SwingUtilities.isEventDispatchThread()) {
      Main_frame.compressor_threshold_slider.setValue(Integer.parseInt(data[11]));
    } else {
      SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {
              Main_frame.compressor_threshold_slider.setValue(Integer.parseInt(data[11]));
            }
          });
    }

    if (SwingUtilities.isEventDispatchThread()) {
      Main_frame.compressor_button.setSelected(Integer.parseInt(data[7]) == 1 ? true : false);
      Main_frame.compressor_button.setText(Integer.parseInt(data[7]) == 1 ? "ON" : "OFF");
    } else {
      SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {
              Main_frame.compressor_button.setSelected(
                  Integer.parseInt(data[7]) == 1 ? true : false);
              Main_frame.compressor_button.setText(Integer.parseInt(data[7]) == 1 ? "ON" : "OFF");
            }
          });
    }
  }
Esempio n. 19
0
  private void setApplicationAndMenuButtonIcon(final ResizableIcon icon) {
    if (System.getProperty("os.name").startsWith("Mac")) {
      class MacImages {
        Image icon16;

        Image icon128;

        public MacImages(Image icon16, Image icon128) {
          this.icon16 = icon16;
          this.icon128 = icon128;
        }
      }

      final Image image16 = getImage(icon, 16);
      final Image image128 = getImage(icon, 128);
      SwingUtilities.invokeLater(
          new Runnable() {
            @Override
            public void run() {
              if (image16 != null) {
                setLegacyIconImages(Arrays.asList(image16));
              }
              if (image128 != null) {
                try {
                  Class appClass = Class.forName("com.apple.eawt.Application");
                  if (appClass != null) {
                    Object appInstance = appClass.newInstance();
                    Method setDockImageMethod =
                        appClass.getDeclaredMethod("setDockIconImage", Image.class);
                    if (setDockImageMethod != null) {
                      setDockImageMethod.invoke(appInstance, image128);
                    }
                  }
                } catch (Throwable t) {
                  t.printStackTrace();
                  // give up
                }
              }
              setMainAppIcon(icon);
            }
          });
    } else {
      final List<Image> images = new ArrayList<Image>();
      Image icon16 = getImage(icon, 16);
      if (icon16 != null) images.add(icon16);
      Image icon32 = getImage(icon, 32);
      if (icon32 != null) images.add(icon32);
      Image icon64 = getImage(icon, 64);
      if (icon64 != null) images.add(icon64);
      SwingUtilities.invokeLater(
          new Runnable() {
            @Override
            public void run() {
              if (!images.isEmpty()) setLegacyIconImages(images);
              setMainAppIcon(icon);
            }
          });
    }
  }
Esempio n. 20
0
 private void evaluate_unrestricted_nothread(
     final String sql, final int maxDisplayedRowCount, boolean isUpdatable) {
   closeLastExecution();
   SwingUtilities.invokeLater(
       new Runnable() {
         @Override
         public void run() {
           startButton.setVisible(false);
           stopButton.setVisible(true);
           stopButton.setToolTipText("Query started on " + Utils.formatDateTimeTZ(new Date()));
         }
       });
   QueryExecutor queryExecutor;
   synchronized (STATEMENT_EXECUTOR_CREATOR_LOCK) {
     queryExecutor = queryExecutorCreator.createQueryExecutor(executionContextName);
     lastStatementExecutor = queryExecutor;
   }
   QueryExecution queryExecution;
   try {
     queryExecution =
         queryExecutor.execute(
             sql,
             isUsingMaxRowCount ? MAX_ROW_COUNT : Integer.MAX_VALUE,
             maxDisplayedRowCount,
             isUpdatable);
   } finally {
     SwingUtilities.invokeLater(
         new Runnable() {
           @Override
           public void run() {
             startButton.setVisible(true);
             stopButton.setVisible(false);
             stopButton.setToolTipText(null);
           }
         });
   }
   final QueryExecutionResult[] results = queryExecution.getResults();
   final long executionDuration = queryExecution.getExecutionDuration();
   SwingUtilities.invokeLater(
       new Runnable() {
         @Override
         public void run() {
           for (QueryExecutionResult result : results) {
             if (result instanceof QueryExecutionMessageResult) {
               QueryExecutionMessageResult messageResult = (QueryExecutionMessageResult) result;
               setMessage(addResultPane(), messageResult.getMessage(), messageResult.isError());
             } else if (result instanceof StatementExecutionResultSetResult) {
               addResultTable(sql, executionDuration, (StatementExecutionResultSetResult) result);
             } else {
               throw new IllegalStateException(
                   "Unknown result class: " + result.getClass().getName());
             }
           }
         }
       });
 }
Esempio n. 21
0
  private void startGame(final GameType gameType) {
    final DeckProxy humanDeck = VSubmenuWinston.SINGLETON_INSTANCE.getLstDecks().getSelectedItem();
    final int aiIndex = 0;

    if (humanDeck == null) {
      FOptionPane.showErrorDialog(
          "No deck selected for human.\n(You may need to build a new deck)", "No Deck");
      return;
    }

    if (FModel.getPreferences().getPrefBoolean(FPref.ENFORCE_DECK_LEGALITY)) {
      final String errorMessage =
          gameType.getDeckFormat().getDeckConformanceProblem(humanDeck.getDeck());
      if (null != errorMessage) {
        FOptionPane.showErrorDialog(
            "Your deck " + errorMessage + " Please edit or choose a different deck.",
            "Invalid Deck");
        return;
      }
    }

    SwingUtilities.invokeLater(
        new Runnable() {
          @Override
          public void run() {
            SOverlayUtils.startGameOverlay();
            SOverlayUtils.showOverlay();
          }
        });

    final DeckGroup opponentDecks = FModel.getDecks().getWinston().get(humanDeck.getName());
    final Deck aiDeck = opponentDecks.getAiDecks().get(aiIndex);
    if (aiDeck == null) {
      throw new IllegalStateException("Draft: Computer deck is null!");
    }

    final List<RegisteredPlayer> starter = new ArrayList<RegisteredPlayer>();
    final RegisteredPlayer human =
        new RegisteredPlayer(humanDeck.getDeck()).setPlayer(GamePlayerUtil.getGuiPlayer());
    starter.add(human);
    starter.add(new RegisteredPlayer(aiDeck).setPlayer(GamePlayerUtil.createAiPlayer()));

    final HostedMatch hostedMatch = GuiBase.getInterface().hostMatch();
    hostedMatch.startMatch(
        GameType.Winston, null, starter, human, GuiBase.getInterface().getNewGuiGame());

    SwingUtilities.invokeLater(
        new Runnable() {
          @Override
          public void run() {
            SOverlayUtils.hideOverlay();
          }
        });
  }
Esempio n. 22
0
 public void onShow(boolean showLeft) {
   if (showLeft)
     SwingUtilities.invokeLater(
         () -> MainFrame.instance.showMessage(C.i18n("ui.message.first_load")));
   if (cboLoginMode.getSelectedIndex() >= 0
       && cboLoginMode.getSelectedIndex() < cboLoginMode.getItemCount()) {
     IAuthenticator l = IAuthenticator.LOGINS.get(cboLoginMode.getSelectedIndex());
     if (!l.isHidePasswordBox() && !l.isLoggedIn())
       SwingUtilities.invokeLater(
           () -> MainFrame.instance.showMessage(C.i18n("ui.message.enter_password")));
   }
 }
Esempio n. 23
0
 public final void run(final Action aRunnableAction) {
   if (aRunnableAction instanceof Runnable) {
     SwingUtilities.invokeLater((Runnable) aRunnableAction);
   } else {
     SwingUtilities.invokeLater(
         new Runnable() {
           public final void run() {
             aRunnableAction.actionPerformed(null);
           }
         });
   }
 }
Esempio n. 24
0
  /** Inits the dialog. */
  @Override
  protected void initDialog() {
    /* align buttons to the right */
    final FlowLayout layout = new FlowLayout();
    layout.setAlignment(FlowLayout.RIGHT);

    if (buttonClass(cancelButton()) != null) {
      buttonClass(cancelButton()).getParent().setLayout(layout);
    }

    /* disable back button if there is no previous dialog */
    if (previousDialog == null && buttonClass(backButton()) != null) {
      SwingUtilities.invokeLater(
          new Runnable() {
            @Override
            public void run() {
              buttonClass(backButton()).setEnabled(false);
            }
          });
    }

    /* disable next and finish buttons */
    if (buttonClass(nextButton()) != null) {
      SwingUtilities.invokeLater(
          new Runnable() {
            @Override
            public void run() {
              buttonClass(nextButton()).setEnabled(false);
            }
          });
    }
    if (buttonClass(finishButton()) != null) {
      SwingUtilities.invokeLater(
          new Runnable() {
            @Override
            public void run() {
              buttonClass(finishButton()).setEnabled(false);
            }
          });
    }
    if (buttonClass(retryButton()) != null) {
      SwingUtilities.invokeLater(
          new Runnable() {
            @Override
            public void run() {
              buttonClass(retryButton()).setVisible(false);
              buttonClass(retryButton()).setBackgroundColor(Color.RED);
            }
          });
    }
    disableComponents();
  }
Esempio n. 25
0
    @Override
    public void run() {
      try {
        // initialize the statusbar
        status.removeAll();
        JProgressBar progress = new JProgressBar();
        progress.setMinimum(0);
        progress.setMaximum((int) f.length());
        status.add(progress);
        status.revalidate();

        // try to start reading
        Reader in = new FileReader(f);
        char[] buff = new char[4096];
        int nch;
        while ((nch = in.read(buff, 0, buff.length)) != -1) {
          doc.insertString(doc.getLength(), new String(buff, 0, nch), null);
          progress.setValue(progress.getValue() + nch);
        }
      } catch (IOException e) {
        final String msg = e.getMessage();
        SwingUtilities.invokeLater(
            new Runnable() {

              public void run() {
                JOptionPane.showMessageDialog(
                    getFrame(),
                    "Could not open file: " + msg,
                    "Error opening file",
                    JOptionPane.ERROR_MESSAGE);
              }
            });
      } catch (BadLocationException e) {
        System.err.println(e.getMessage());
      }
      doc.addUndoableEditListener(undoHandler);
      // we are done... get rid of progressbar
      status.removeAll();
      status.revalidate();

      resetUndoManager();

      if (elementTreePanel != null) {
        SwingUtilities.invokeLater(
            new Runnable() {

              public void run() {
                elementTreePanel.setEditor(getEditor());
              }
            });
      }
    }
Esempio n. 26
0
  /**
   * Takes a bit mask representing selected rows and causes it to become the Current Row Subset for
   * the given table. Usually this means creating a new Row Subset corresponding to that mask prior
   * to applying it. However, in the special case that the mask is identical to an existing subset,
   * that one will be used instead.
   *
   * @param tcModel topcat model
   * @param mask row selection mask
   * @param baseName name of the sending application
   */
  private void applyNewSubset(final TopcatModel tcModel, BitSet mask, String appName) {

    /* See if this is identical to an existing subset.  If so, don't
     * create a new one.  It's arguable whether this is the behaviour
     * that you want, but at least until we have some way to delete
     * subsets it's probably best to do it like this to cut down on
     * subset proliferation. */
    RowSubset matching = null;
    for (Iterator it = tcModel.getSubsets().iterator(); matching == null && it.hasNext(); ) {
      RowSubset rset = (RowSubset) it.next();
      int nrow = Tables.checkedLongToInt(tcModel.getDataModel().getRowCount());
      if (matches(mask, rset, nrow)) {
        matching = rset;
      }
    }

    /* If we've found an existing set with the same content,
     * apply that one. */
    if (matching != null) {
      final RowSubset rset = matching;
      SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {
              tcModel.applySubset(rset);
            }
          });
    }

    /* Otherwise make sure we have a unique name for the new subset. */
    else {
      int ipset = 0;
      for (Iterator it = tcModel.getSubsets().iterator(); it.hasNext(); ) {
        String setName = ((RowSubset) it.next()).getName();
        if (setName.matches(appName + "-[0-9]+")) {
          String digits = setName.substring(appName.length() + 1);
          ipset = Math.max(ipset, Integer.parseInt(digits));
        }
      }
      String setName = appName + '-' + (ipset + 1);

      /* Then construct, add and apply the new subset. */
      final RowSubset rset = new BitsRowSubset(setName, mask);
      SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {
              tcModel.addSubset(rset);
              tcModel.applySubset(rset);
            }
          });
    }
  }
Esempio n. 27
0
  public static void main(String[] args) {
    /* Use an appropriate Look and Feel */
    try {
      // UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
      UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
    } catch (UnsupportedLookAndFeelException ex) {
      ex.printStackTrace();
    } catch (IllegalAccessException ex) {
      ex.printStackTrace();
    } catch (InstantiationException ex) {
      ex.printStackTrace();
    } catch (ClassNotFoundException ex) {
      ex.printStackTrace();
    }
    /* Turn off metal's use of bold fonts */
    UIManager.put("swing.boldMetal", Boolean.FALSE);

    final GUI_QPDownloader frame = new GUI_QPDownloader("Thapar Question Paper Downloader");
    // Schedule a job for the event dispatch thread:
    // creating and showing this application's GUI.
    javax.swing.SwingUtilities.invokeLater(
        new Runnable() {
          public void run() {
            // Create and set up the window.
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

            frame.setJMenuBar((new MyJMenuBar(frame)).menuBar);

            // Display the window.
            // frame.pack();

            // Set up the content pane.
            frame.addLoadingMessage(frame.getContentPane());
            frame.pack();
            frame.setSize(new Dimension((int) (frame.getSize().getWidth()), 300));
            frame.setResizable(false);
            frame.setVisible(true);
            frame.update(frame.getGraphics());
          }
        });
    // Schedule a job for the event dispatch thread:
    // creating and showing this application's GUI.
    javax.swing.SwingUtilities.invokeLater(
        new Runnable() {
          public void run() {
            frame.addComponentsToPane(frame.getContentPane());
            frame.setResizable(true);
            frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
          }
        });
  }
Esempio n. 28
0
 public static void main(String[] args) throws Exception {
   SwingUtilities.invokeLater(
       new Runnable() {
         public void run() {
           ssp = new SubmitSwingProgram();
         }
       });
   TimeUnit.SECONDS.sleep(1);
   SwingUtilities.invokeLater(
       new Runnable() {
         public void run() {
           ssp.label.setText("Hey! This is Different!");
         }
       });
 }
  private void setAllSlidersDelay(final String[] data) {

    if (SwingUtilities.isEventDispatchThread()) {
      Main_frame.delay_time_slider.setValue(Integer.parseInt(data[13]));
    } else {
      SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {
              Main_frame.delay_time_slider.setValue(Integer.parseInt(data[13]));
            }
          });
    }

    if (SwingUtilities.isEventDispatchThread()) {
      Main_frame.delay_feedback_slider.setValue(Integer.parseInt(data[14]));
    } else {
      SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {
              Main_frame.delay_feedback_slider.setValue(Integer.parseInt(data[14]));
            }
          });
    }

    if (SwingUtilities.isEventDispatchThread()) {
      Main_frame.delay_mix_slider.setValue(Integer.parseInt(data[15]));
    } else {
      SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {
              Main_frame.delay_mix_slider.setValue(Integer.parseInt(data[15]));
            }
          });
    }

    if (SwingUtilities.isEventDispatchThread()) {
      Main_frame.delay_button.setSelected(Integer.parseInt(data[12]) == 1 ? true : false);
      Main_frame.delay_button.setText(Integer.parseInt(data[12]) == 1 ? "ON" : "OFF");
    } else {
      SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {
              Main_frame.delay_button.setSelected(Integer.parseInt(data[12]) == 1 ? true : false);
              Main_frame.delay_button.setText(Integer.parseInt(data[12]) == 1 ? "ON" : "OFF");
            }
          });
    }
  }
Esempio n. 30
0
  private void jButton2ActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton2ActionPerformed
    if (mpv5.ui.dialogs.Popup.Y_N_dialog(
        "Really delete all invoices, orders and offers from the database? This is irreversible!!! Contacts and Products will not be affected.",
        Messages.ARE_YOU_SURE)) {
      if (Popup.Y_N_dialog(Messages.ARE_YOU_SURE)) {
        Popup.notice(
            QueryHandler.instanceOf()
                .freeQuery("delete from items", MPSecurityManager.ADMINISTRATE, "Item reset done.")
                .getMessage());
        final String fmessage = "ITEM RESET: removed all invoices, orders and offers from database";
        final String fdbid = "items";
        final int fids = 0;
        final int fgids = 1;

        Runnable runnable =
            new Runnable() {

              @Override
              public void run() {
                QueryHandler.instanceOf()
                    .clone(Context.getHistory())
                    .insertHistoryItem(
                        fmessage,
                        mpv5.db.objects.User.getCurrentUser().__getCname(),
                        fdbid,
                        fids,
                        fgids);
              }
            };
        SwingUtilities.invokeLater(runnable);
      }
    }
  } // GEN-LAST:event_jButton2ActionPerformed