Esempio n. 1
0
  public VncViewer(String[] argv) {
    applet = false;

    // Override defaults with command-line options
    for (int i = 0; i < argv.length; i++) {
      if (argv[i].equalsIgnoreCase("-log")) {
        if (++i >= argv.length) usage();
        System.err.println("Log setting: " + argv[i]);
        LogWriter.setLogParams(argv[i]);
        continue;
      }

      if (Configuration.setParam(argv[i])) continue;

      if (argv[i].charAt(0) == '-') {
        if (i + 1 < argv.length) {
          if (Configuration.setParam(argv[i].substring(1), argv[i + 1])) {
            i++;
            continue;
          }
        }
        usage();
      }

      if (vncServerName.getValue() != null) usage();
      vncServerName.setParam(argv[i]);
    }
  }
  public static void main(String[] args) {
    // zoom to San Francisco downtown
    Configuration.setValue(AVKey.INITIAL_ALTITUDE, 34e3);
    Configuration.setValue(AVKey.INITIAL_LATITUDE, 37.9521d);
    Configuration.setValue(AVKey.INITIAL_LONGITUDE, -119.7761d);

    // Adjust configuration values before instantiation
    ApplicationTemplate.start("World Wind Terrain Intersections", AppFrame.class);
  }
Esempio n. 3
0
 public void save() {
   Configuration config = Configuration.getInstance();
   Properties props = config.props;
   props.setProperty("mx", maxMemory.tf.getText().trim());
   props.setProperty("ms", initMemory.tf.getText().trim());
   props.setProperty("ss", stackSize.tf.getText().trim());
   props.setProperty("ext", extDirs.tf.getText().trim());
   props.setProperty("clr", (clearLogs.cb.isSelected() ? "yes" : "no"));
   props.setProperty("ssl", (debugSSL.cb.isSelected() ? "yes" : "no"));
   props.setProperty("mon", (javaMonitor.cb.isSelected() ? "yes" : "no"));
   config.save();
 }
  public JungGraphObserver(String name) {
    this.name = name;
    this.hyphadataPid = Configuration.getPid(PAR_HYPHADATA_PROTO);
    this.hyphalinkPid = Configuration.getPid(PAR_HYPHALINK_PROTO);
    this.mycocastPid = Configuration.getPid(PAR_MYCOCAST_PROTO);
    this.period = Configuration.getInt(name + "." + PAR_PERIOD);

    this.walkDelay = Configuration.getInt(name + "." + PAR_WALK_DELAY);
    mainThread = Thread.currentThread();
    this.changeListeners = new HashSet<ChangeListener>();

    visualizer = null;

    // HyphaData.addHyphaDataListener(this);
    // HyphaLink.addHyphaLinkListener(this);
  }
 public CfgInfo(Configuration cfg, final String title) {
   this.cfg = cfg;
   this.title = title;
   bundledInjections.addAll(cfg.getDefaultInjections());
   originalInjections =
       new ArrayList<BaseInjection>(
           ContainerUtil.concat(
               InjectorUtils.getActiveInjectionSupportIds(),
               new Function<String, Collection<? extends BaseInjection>>() {
                 public Collection<? extends BaseInjection> fun(final String s) {
                   List<BaseInjection> injections =
                       CfgInfo.this.cfg instanceof Configuration.Prj
                           ? ((Configuration.Prj) CfgInfo.this.cfg).getOwnInjections(s)
                           : CfgInfo.this.cfg.getInjections(s);
                   return ContainerUtil.findAll(
                       injections,
                       new Condition<BaseInjection>() {
                         public boolean value(final BaseInjection injection) {
                           String id = injection.getInjectedLanguageId();
                           return InjectedLanguage.findLanguageById(id) != null
                               || ReferenceInjector.findById(id) != null;
                         }
                       });
                 }
               }));
   sortInjections(originalInjections);
   reset();
 }
Esempio n. 6
0
 public ConfigurationDialog(Frame owner, boolean insideOOo, Configuration config) {
   this.owner = owner;
   this.insideOOo = insideOOo;
   this.original = config;
   this.config = original.copy(original);
   messages = JLanguageTool.getMessageBundle();
 }
Esempio n. 7
0
 public void start() {
   vlog.debug("start called");
   if (version == null || build == null) {
     ClassLoader cl = this.getClass().getClassLoader();
     InputStream stream = cl.getResourceAsStream("com/tigervnc/vncviewer/timestamp");
     try {
       Manifest manifest = new Manifest(stream);
       Attributes attributes = manifest.getMainAttributes();
       version = attributes.getValue("Version");
       build = attributes.getValue("Build");
     } catch (java.io.IOException e) {
     }
   }
   nViewers++;
   if (firstApplet) {
     alwaysShowServerDialog.setParam(true);
     Configuration.readAppletParams(this);
     String host = getCodeBase().getHost();
     if (vncServerName.getValue() == null && vncServerPort.getValue() != 0) {
       int port = vncServerPort.getValue();
       vncServerName.setParam(
           host + ((port >= 5900 && port <= 5999) ? (":" + (port - 5900)) : ("::" + port)));
     }
   }
   thread = new Thread(this);
   thread.start();
 }
  public void loadConfiguration(Configuration configuration) {
    imagesList.clear();

    String directory = configuration.getDirectory();
    int maxSize = ImageHolder.coerceInteger(configuration.getMaxSize());
    if (directory != null && !directory.isEmpty()) {
      File dir = new File(directory);
      File[] files =
          dir.listFiles(
              new FilenameFilter() {
                @Override
                public boolean accept(File dir, String name) {
                  String lowerName = name.toLowerCase();
                  return lowerName.endsWith(".jpg")
                      || lowerName.endsWith(".png")
                      || lowerName.endsWith(".gif");
                }
              });

      if (files != null && files.length > 0) {
        imagesList.ensureCapacity(files.length);
        for (File file : files) {
          if (file.isFile()) {
            imagesList.add(new ImageHolder(file, maxSize));
          }
        }
        imagesList.trimToSize();
      }
    }

    boolean useTimer = configuration.isUseTimer();
    if (useTimer) {
      if (timer.isRunning()) {
        timer.restart();
      } else {
        timer.start();
      }
    } else {
      if (timer.isRunning()) {
        timer.stop();
      }
    }

    for (Editor editor : editorsList) {
      loadImage(editor);
    }
  }
 public void apply() {
   final List<BaseInjection> injectionList = getInjectionList(injectionInfos);
   cfg.replaceInjections(injectionList, originalInjections, true);
   originalInjections.clear();
   originalInjections.addAll(injectionList);
   sortInjections(originalInjections);
   FileContentUtil.reparseOpenedFiles();
 }
Esempio n. 10
0
 @Override
 public void actionPerformed(ActionEvent e) {
   if (e.getSource() == okButton) {
     if (original != null) {
       original.restoreState(config);
     }
     dialog.setVisible(false);
   } else if (e.getSource() == cancelButton) {
     dialog.setVisible(false);
   }
 }
Esempio n. 11
0
  private boolean getState(Rule rule) {
    boolean ret = true;

    if (config.getDisabledRuleIds().contains(rule.getId())) {
      ret = false;
    }
    if (config.getDisabledCategoryNames().contains(rule.getCategory().getName())) {
      ret = false;
    }
    if (rule.isDefaultOff() && !config.getEnabledRuleIds().contains(rule.getId())) {
      ret = false;
    }

    if (rule.isDefaultOff()
        && rule.getCategory().isDefaultOff()
        && config.getEnabledRuleIds().contains(rule.getId())) {
      config.getDisabledCategoryNames().remove(rule.getCategory().getName());
    }
    return ret;
  }
  private void addTemplate(SearchDialogFactory searchDialogFactory) {
    SearchDialog dialog = createDialog(searchDialogFactory);
    dialog.show();
    if (!dialog.isOK()) return;
    Configuration configuration = dialog.getConfiguration();

    if (configuration.getName() == null
        || configuration.getName().equals(SearchDialog.USER_DEFINED)) {
      String name = dialog.showSaveTemplateAsDialog();

      if (name != null) {
        name =
            ConfigurationManager.findAppropriateName(myConfigurations, name, dialog.getProject());
      }
      if (name == null) return;
      configuration.setName(name);
    }
    myConfigurations.add(configuration);

    configurationsChanged(dialog.getSearchContext());
  }
Esempio n. 13
0
 private void run() {
   int port = Util.getInt(serverPort.tf.getText().trim(), config.port);
   if (port != config.port) {
     try {
       Element server = Util.getFirstNamedChild(config.configXML, "Server");
       server.setAttribute("port", Integer.toString(port));
       config.saveXML();
       config.port = port;
     } catch (Exception unable) {
     }
     serverPort.tf.setText(Integer.toString(config.port));
   }
   save();
   if (!running) {
     runner = Util.startup();
     Util.wait(500);
     running = runner.isAlive();
     if (running) {
       monitor = new Monitor(runner);
       monitor.start();
     }
   }
   setStatus();
 }
Esempio n. 14
0
  private DefaultMutableTreeNode createTree(List<Rule> rules) {
    DefaultMutableTreeNode root = new DefaultMutableTreeNode("Rules");
    String lastRule = null;
    TreeMap<String, DefaultMutableTreeNode> parents = new TreeMap<>();
    for (final Rule rule : rules) {
      if (!parents.containsKey(rule.getCategory().getName())) {

        boolean enabled = true;
        if (config.getDisabledCategoryNames() != null
            && config.getDisabledCategoryNames().contains(rule.getCategory().getName())) {
          enabled = false;
        }
        DefaultMutableTreeNode categoryNode = new CategoryNode(rule.getCategory(), enabled);
        root.add(categoryNode);
        parents.put(rule.getCategory().getName(), categoryNode);
      }
      if (!rule.getId().equals(lastRule)) {
        RuleNode ruleNode = new RuleNode(rule, getState(rule));
        parents.get(rule.getCategory().getName()).add(ruleNode);
      }
      lastRule = rule.getId();
    }
    return root;
  }
Esempio n. 15
0
 public void actionPerformed(ActionEvent event) {
   if (event.getSource().equals(launchBrowser)) {
     Configuration config = Configuration.getInstance();
     String ip = Util.getIPAddress();
     String protocol = "http" + (config.ssl ? "s" : "");
     String url = protocol + "://" + ip + ":" + config.port;
     Util.openURL(url);
   } else if (event.getSource().equals(stop)) {
     Util.shutdown();
     running = Util.isRunning();
     setStatus();
   } else if (event.getSource().equals(start)) {
     clearLogsDir();
     run();
     launchBrowser.requestFocusInWindow();
   }
 }
Esempio n. 16
0
  public void start(String appConfigurationLocation, Dimension appSize) throws Exception {
    this.appTitle = Configuration.getStringValue(Constants.APPLICATION_DISPLAY_NAME);
    this.appSize = appSize;

    this.unitsFormat = new WWOUnitsFormat();
    this.unitsFormat.setShowUTM(true);
    this.unitsFormat.setShowWGS84(true);

    this.appConfigurationLocation = appConfigurationLocation;
    final AppConfiguration appConfig = new AppConfiguration();
    appConfig.initialize(this);

    appConfig.configure(this.appConfigurationLocation);

    SwingUtilities.invokeLater(
        new Runnable() {
          public void run() {
            redraw();
          }
        });
  }
Esempio n. 17
0
 public static void usage() {
   String usage =
       ("\nusage: vncviewer [options/parameters] "
           + "[host:displayNum] [options/parameters]\n"
           + "       vncviewer [options/parameters] -listen [port] "
           + "[options/parameters]\n"
           + "\n"
           + "Options:\n"
           + "  -log <level>    configure logging level\n"
           + "\n"
           + "Parameters can be turned on with -<param> or off with "
           + "-<param>=0\n"
           + "Parameters which take a value can be specified as "
           + "-<param> <value>\n"
           + "Other valid forms are <param>=<value> -<param>=<value> "
           + "--<param>=<value>\n"
           + "Parameter names are case-insensitive.  The parameters "
           + "are:\n\n"
           + Configuration.listParams());
   System.err.print(usage);
   System.exit(1);
 }
  public void setValuesFromConfig(Configuration configuration) {
    // replaceCriteriaEdit.putUserData(SubstitutionShortInfoHandler.CURRENT_CONFIGURATION_KEY,
    // configuration);

    if (configuration instanceof ReplaceConfiguration) {
      final ReplaceConfiguration config = (ReplaceConfiguration) configuration;
      final ReplaceOptions options = config.getOptions();
      super.setValuesFromConfig(config);

      UIUtil.setContent(
          replaceCriteriaEdit,
          config.getOptions().getReplacement(),
          0,
          replaceCriteriaEdit.getDocument().getTextLength(),
          searchContext.getProject());

      shortenFQN.setSelected(options.isToShortenFQN());
      formatAccordingToStyle.setSelected(options.isToReformatAccordingToStyle());
      useStaticImport.setSelected(options.isToUseStaticImport());

      ReplaceOptions newReplaceOptions = ((ReplaceConfiguration) model.getConfig()).getOptions();
      newReplaceOptions.clearVariableDefinitions();

      for (ReplacementVariableDefinition def : options.getReplacementVariableDefinitions()) {
        newReplaceOptions.addVariableDefinition((ReplacementVariableDefinition) def.clone());
      }
    } else {
      super.setValuesFromConfig(configuration);

      UIUtil.setContent(
          replaceCriteriaEdit,
          configuration.getMatchOptions().getSearchPattern(),
          0,
          replaceCriteriaEdit.getDocument().getTextLength(),
          searchContext.getProject());
    }
  }
Esempio n. 19
0
 @Deprecated
 public void setRunServer(boolean serverMode) {
   config.setRunServer(serverMode);
 }
Esempio n. 20
0
    protected void saveToFile() {
      if (this.fileChooser == null) {
        this.fileChooser = new JFileChooser();
        this.fileChooser.setCurrentDirectory(new File(Configuration.getUserHomeDirectory()));
      }

      this.fileChooser.setDialogTitle("Choose Directory to Place Airspaces");
      this.fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
      this.fileChooser.setMultiSelectionEnabled(false);
      int status = this.fileChooser.showSaveDialog(null);
      if (status != JFileChooser.APPROVE_OPTION) return;

      final File dir = this.fileChooser.getSelectedFile();
      if (dir == null) return;

      if (!dir.exists()) {
        //noinspection ResultOfMethodCallIgnored
        dir.mkdirs();
      }

      final Iterable<AirspaceEntry> entries = this.getModel().getEntries();

      Thread t =
          new Thread(
              new Runnable() {
                public void run() {
                  try {
                    java.text.DecimalFormat f = new java.text.DecimalFormat("####");
                    f.setMinimumIntegerDigits(4);
                    int counter = 0;

                    for (AirspaceEntry entry : entries) {
                      Airspace a = entry.getAirspace();
                      AirspaceAttributes currentAttribs = a.getAttributes();
                      a.setAttributes(entry.getAttributes());

                      String xmlString = a.getRestorableState();
                      if (xmlString != null) {
                        try {
                          PrintWriter of =
                              new PrintWriter(
                                  new File(
                                      dir,
                                      a.getClass().getName()
                                          + "-"
                                          + entry.getName()
                                          + "-"
                                          + f.format(counter++)
                                          + ".xml"));
                          of.write(xmlString);
                          of.flush();
                          of.close();
                        } catch (Exception e) {
                          e.printStackTrace();
                        }
                      }

                      a.setAttributes(currentAttribs);
                    }
                  } finally {
                    SwingUtilities.invokeLater(
                        new Runnable() {
                          public void run() {
                            setEnabled(true);
                            getApp().setCursor(null);
                            getApp().getWwd().redraw();
                          }
                        });
                  }
                }
              });
      this.setEnabled(false);
      getApp().setCursor(new Cursor(Cursor.WAIT_CURSOR));
      t.start();
    }
Esempio n. 21
0
    protected void openFromFile() {
      if (this.fileChooser == null) {
        this.fileChooser = new JFileChooser();
        this.fileChooser.setCurrentDirectory(new File(Configuration.getUserHomeDirectory()));
      }

      this.fileChooser.setDialogTitle("Choose Airspace File Directory");
      this.fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
      this.fileChooser.setMultiSelectionEnabled(false);
      int status = this.fileChooser.showOpenDialog(null);
      if (status != JFileChooser.APPROVE_OPTION) return;

      final File dir = this.fileChooser.getSelectedFile();
      if (dir == null) return;

      Thread t =
          new Thread(
              new Runnable() {
                public void run() {
                  final ArrayList<Airspace> airspaces = new ArrayList<Airspace>();
                  try {
                    File[] files =
                        dir.listFiles(
                            new FilenameFilter() {
                              public boolean accept(File dir, String name) {
                                return name.startsWith("gov.nasa.worldwind.render.airspaces")
                                    && name.endsWith(".xml");
                              }
                            });

                    for (File file : files) {
                      String[] name = file.getName().split("-");
                      try {
                        Class c = Class.forName(name[0]);
                        Airspace airspace = (Airspace) c.newInstance();
                        BufferedReader input = new BufferedReader(new FileReader(file));
                        String s = input.readLine();
                        airspace.restoreState(s);
                        airspaces.add(airspace);

                        if (name.length >= 2) {
                          airspace.setValue(AVKey.DISPLAY_NAME, name[1]);
                        }
                      } catch (Exception e) {
                        e.printStackTrace();
                      }
                    }
                  } finally {
                    SwingUtilities.invokeLater(
                        new Runnable() {
                          public void run() {
                            setAirspaces(airspaces);
                            setEnabled(true);
                            getApp().setCursor(null);
                            getApp().getWwd().redraw();
                          }
                        });
                  }
                }
              });
      this.setEnabled(false);
      getApp().setCursor(new Cursor(Cursor.WAIT_CURSOR));
      t.start();
    }
Esempio n. 22
0
 @Deprecated
 public void setDisabledCategories(Set<String> categoryNames) {
   config.setDisabledCategoryNames(categoryNames);
 }
Esempio n. 23
0
 @Deprecated
 public int getServerPort() {
   return config.getServerPort();
 }
Esempio n. 24
0
 @Deprecated
 public void setServerPort(int serverPort) {
   config.setServerPort(serverPort);
 }
Esempio n. 25
0
 @Deprecated
 public boolean getRunServer() {
   return config.getRunServer();
 }
Esempio n. 26
0
 @Deprecated
 public boolean getUseGUIConfig() {
   return config.getUseGUIConfig();
 }
Esempio n. 27
0
 @Deprecated
 public Set<String> getDisabledCategoryNames() {
   return config.getDisabledCategoryNames();
 }
Esempio n. 28
0
 @Deprecated
 public void setMotherTongue(Language motherTongue) {
   config.setMotherTongue(motherTongue);
 }
Esempio n. 29
0
 @Deprecated
 public Language getMotherTongue() {
   return config.getMotherTongue();
 }
Esempio n. 30
0
 @Deprecated
 public void setUseGUIConfig(boolean useGUIConfig) {
   config.setUseGUIConfig(useGUIConfig);
 }