Пример #1
1
  protected void initExtensions(ClassLoader extensionClassLoader) {
    /* We break the general rule that you shouldn't catch Throwable, because we don't want extensions to crash SoapUI. */
    try {
      String extDir = System.getProperty("soapui.ext.listeners");
      addExternalListeners(
          FilenameUtils.normalize(
              extDir != null
                  ? extDir
                  : root == null ? "listeners" : root + File.separatorChar + "listeners"),
          extensionClassLoader);
    } catch (Throwable e) {
      SoapUI.logError(e, "Couldn't load external listeners");
    }

    try {
      String factoriesDir = System.getProperty("soapui.ext.factories");
      addExternalFactories(
          FilenameUtils.normalize(
              factoriesDir != null
                  ? factoriesDir
                  : root == null ? "factories" : root + File.separatorChar + "factories"),
          extensionClassLoader);
    } catch (Throwable e) {
      SoapUI.logError(e, "Couldn't load external factories");
    }
  }
 private MouseOrTabletOperation(
     String name,
     String description,
     WorldPainterView view,
     int delay,
     boolean oneshot,
     String statisticsKey,
     String iconName) {
   super(
       name,
       description,
       (iconName != null) ? iconName : name.toLowerCase().replaceAll("\\s", ""));
   setView(view);
   this.delay = delay;
   this.oneShot = oneshot;
   this.statisticsKey = statisticsKey;
   statisticsKeyUndo = statisticsKey + ".undo";
   legacy =
       (SystemUtils.isMac() && System.getProperty("os.version").startsWith("10.4."))
           || "true"
               .equalsIgnoreCase(
                   System.getProperty("org.pepsoft.worldpainter.disableTabletSupport"));
   if (legacy) {
     logger.warn("Tablet support disabled for operation " + name);
   }
 }
 /** Panel avec le titre de l'élément, et les boutons d'aide et d'attributs de l'élément */
 private JPanel getPanelTitre() {
   final JButton baide = new JButton(new ActionAide(refNoeud));
   baide.setFont(baide.getFont().deriveFont((float) 9));
   if (System.getProperty("os.name").startsWith("Mac OS")) {
     baide.setText("?");
     if ("10.5".compareTo(System.getProperty("os.version")) <= 0)
       baide.putClientProperty("JButton.buttonType", "help");
     else baide.putClientProperty("JButton.buttonType", "toolbar");
   } else {
     baide.setIcon(new ImageIcon(ImageKeeper.loadImage("images/aide.png")));
     baide.setMargin(new Insets(0, 0, 0, 0));
     baide.setBorderPainted(false);
     baide.setContentAreaFilled(false);
   }
   String documentation = getDocumentation();
   if (documentation != null) baide.setToolTipText(documentation);
   final JPanel panelTitre = new JPanel();
   panelTitre.add(baide);
   final JLabel labelTitre = new JLabel(getTitre());
   Color couleurTitre;
   if (affParent != null) {
     if (obligatoire()) couleurTitre = couleurObligatoire;
     else couleurTitre = couleurFacultatif;
   } else couleurTitre = panelEnfants.getForeground();
   labelTitre.setForeground(couleurTitre);
   panelTitre.add(labelTitre);
   panelTitre.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
   final JPanel panelNord = new JPanel(new FlowLayout(FlowLayout.LEADING, 0, 0));
   panelNord.add(panelTitre);
   return (panelNord);
 }
  @Override
  public void actionPerformed(ActionEvent AE) {
    if (AE.getSource() == CheckAll) {
      boolean Selection = CheckAll.isSelected();
      if (Selection) CheckAll.setText("Uncheck all");
      else CheckAll.setText("Check all");
      for (int i = 0; i < NumberOfCourses; i++) My[i].CourseCheckBox.setSelected(Selection);
    }

    if (AE.getSource() == DocButton)
      if (TempControll.ConnectionManagerObject.createConnection()) {

        new File(System.getProperty("user.home") + "/TermResultCalculator/StudentDocs/").mkdirs();
        if (gatherDataForDocument()) {
          if (TempControll.StudentPdfObject.createPDF(
              this.Roll, this.Session, this.Selected, this.Taken, this.Completed, this.GPA))
            JOptionPane.showMessageDialog(
                RPS,
                "Report created successfully at "
                    + System.getProperty("user.home")
                    + "/TermResultCalculator/StudentDocs/",
                "Success",
                JOptionPane.INFORMATION_MESSAGE);
          else
            JOptionPane.showMessageDialog(
                RPS, "Error while creating report.", "Error", JOptionPane.ERROR_MESSAGE);
        } else
          JOptionPane.showMessageDialog(
              RPS,
              "At least one course has to be selected.",
              "Error : No Selection",
              JOptionPane.ERROR_MESSAGE);
      }
  }
Пример #5
0
    // Creates a new thread, runs the program in that thread, and reports any errors as needed.
    private void run(String clazz) {
      try {
        // Makes sure the JVM resets if it's already running.
        if (JVMrunning) kill();

        // Some String constants for java path and OS-specific separators.
        String separator = System.getProperty("file.separator");
        String path = System.getProperty("java.home") + separator + "bin" + separator + "java";

        // Tries to run compiled code.
        ProcessBuilder builder = new ProcessBuilder(path, clazz);

        // Should be good now! Everything past this is on you. Don't mess it up.
        println(
            "Build succeeded on " + java.util.Calendar.getInstance().getTime().toString(), progErr);
        println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", progErr);

        JVM = builder.start();

        // Note that as of right now, there is no support for input. Only output.
        Reader errorReader = new InputStreamReader(JVM.getErrorStream());
        Reader outReader = new InputStreamReader(JVM.getInputStream());
        // Writer inReader = new OutputStreamWriter(JVM.getOutputStream());

        redirectErr = redirectIOStream(errorReader, err);
        redirectOut = redirectIOStream(outReader, out);
        // redirectIn = redirectIOStream(null, inReader);
      } catch (Exception e) {
        // This catches any other errors we might get.
        println("Some error thrown", progErr);
        logError(e.toString());
        displayLog();
        return;
      }
    }
Пример #6
0
  /** Checks if the program can run under the JDK it was started with. */
  private static boolean checkJdkVersion() {
    if (!"true".equals(System.getProperty("idea.no.jre.check"))) {
      try {
        // try to find a class from tools.jar
        Class.forName("com.sun.jdi.Field");
      } catch (ClassNotFoundException e) {
        showError(
            "Error",
            "'tools.jar' is not in "
                + ApplicationNamesInfo.getInstance().getProductName()
                + " classpath.\n"
                + "Please ensure JAVA_HOME points to JDK rather than JRE.");
        return false;
      }
    }

    if (!"true".equals(System.getProperty("idea.no.jdk.check"))) {
      final String version = System.getProperty("java.version");
      if (!SystemInfo.isJavaVersionAtLeast("1.6")) {
        showError(
            "Java Version Mismatch",
            "The JDK version is "
                + version
                + ".\n"
                + ApplicationNamesInfo.getInstance().getProductName()
                + " requires JDK 1.6 or higher.");
        return false;
      }
    }

    return true;
  }
    /* (non-Javadoc)
     * @see org.jdesktop.swingworker.SwingWorker#doInBackground()
     */
    @Override
    protected Void doInBackground() throws Exception {

      if (errorInfo != null) {
        Throwable t = errorInfo.getErrorException();
        String osMessage =
            "An error occurred on "
                + System.getProperty("os.name")
                + " version "
                + System.getProperty("os.version");
        StringBuffer message = new StringBuffer();
        message.append("System Info : ").append(osMessage).append(NEW_LINE_CHAR);
        message.append("Message : ").append(t.toString()).append(NEW_LINE_CHAR);
        message.append("Level : ").append(errorInfo.getErrorLevel()).append(NEW_LINE_CHAR);
        message.append("Stack Trace : ").append(NEW_LINE_CHAR);
        message.append(stackTraceToString(t));

        // copy error message to system clipboard
        StringSelection stringSelection = new StringSelection(message.toString());
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        clipboard.setContents(stringSelection, null);

        // open errorReportingURL
        OpenBrowserAction openBrowserAction = new OpenBrowserAction(errorReportingURL);
        openBrowserAction.actionPerformed(null);
      }

      return null;
    }
Пример #8
0
 @Override
 public void load() {
   for (AnimationComboListener listener : comboListeners) {
     listener.load();
   }
   otherCombo.setSelectedIndex(
       MCPatcherUtils.getBoolean(MCPatcherUtils.HD_TEXTURES, "customOther", true) ? 1 : 0);
   boolean is64bit = false;
   try {
     String datamodel =
         System.getProperty("sun.arch.data.model"); // sun-specific, but gets the arch of the jvm
     String arch =
         System.getProperty(
             "os.arch"); // generic, but gets the arch of the os, not the jvm (may be a 32-bit jvm
                         // on a 64-bit os)
     if (datamodel != null) {
       is64bit = (Integer.parseInt(datamodel) >= 64);
     } else if (arch != null) {
       is64bit = arch.contains("64");
     } else {
       is64bit = false;
     }
   } catch (Throwable e) {
   }
   textureCacheCheckBox.setSelected(
       MCPatcherUtils.getBoolean(MCPatcherUtils.HD_TEXTURES, "useTextureCache", is64bit));
   shrinkGLMemoryCheckBox.setSelected(
       MCPatcherUtils.getBoolean(MCPatcherUtils.HD_TEXTURES, "reclaimGLMemory", false));
   autoRefreshTexturesCheckBox.setSelected(
       MCPatcherUtils.getBoolean(MCPatcherUtils.HD_TEXTURES, "autoRefreshTextures", false));
 }
 /**
  * Renvoit le JPanel de gauche, avec le titre du champ. Utilisé dans le cas où il n'y a pas
  * d'enfants.
  */
 private JPanel getPanelGauche() {
   panelGauche = new JPanel(new FlowLayout(FlowLayout.LEFT));
   final JButton baide = new JButton(new ActionAide(refNoeud));
   baide.setFont(baide.getFont().deriveFont((float) 9));
   if (System.getProperty("os.name").startsWith("Mac OS")) {
     baide.setText("?");
     if ("10.5".compareTo(System.getProperty("os.version")) <= 0)
       baide.putClientProperty("JButton.buttonType", "help");
     else baide.putClientProperty("JButton.buttonType", "toolbar");
   } else {
     baide.setIcon(new ImageIcon(ImageKeeper.loadImage("images/aide.png")));
     baide.setMargin(new Insets(0, 0, 0, 0));
     baide.setBorderPainted(false);
     baide.setContentAreaFilled(false);
   }
   String documentation = getDocumentation();
   if (documentation != null) baide.setToolTipText(documentation);
   if (documentation == null && attribut) baide.setEnabled(false);
   panelGauche.add(baide);
   labelTitre = new JLabel(getTitre());
   if (affParent != null) {
     if (obligatoire()) labelTitre.setForeground(couleurObligatoire);
     else labelTitre.setForeground(couleurFacultatif);
   }
   panelGauche.add(labelTitre);
   return (panelGauche);
 }
Пример #10
0
  /**
   * Returns JPicEdt's install directory w/o trailing "/", provided the command line looks like :
   *
   * <p><code>java -classpath other-class-paths:jpicedt-install-dir/lib/jpicedt.jar jpicedt.JPicEdt
   * </code> (where <code>/</code> may be replaced by the actual respective separator for files on
   * the underlying platform).
   *
   * <p>For Windows platform, the install directory is tried to be detected 1st with the MSWindows
   * file-separator (<code>\</code>), and if this does not work, a subsequent trial is made with
   * <code>/</code>.
   *
   * <p>That is, the old way (java -jar jpicedt.jar) won't work. However, classpath can contain
   * relative pathname (then user.dir get prepended).
   *
   * <p>Code snippet was adapted from jEdit/JEdit.java (http://www.jedit.org).
   *
   * @return the value of the "user.dir" Java property if "lib/jpicedt.jar" wasn't found in the
   *     command line.
   */
  public static String getJPicEdtHome() {

    String classpath = System.getProperty("java.class.path"); // e.g.
    // "/usr/lib/java/jre/lib/rt.jar:/home/me/jpicedt/1.3.2/lib/jpicedt.jar"
    // File.separator = "/" on Unix, "\\" on Windows,...
    String fileSeparator = File.separator;
    int index;
    // File.pathSeparator = ":" on Unix/MacOS-X platforms, ";" on Windows
    // search ":" backward starting from
    // "/usr/lib/java/jre/lib/rt.jar:/home/me/jpicedt/1.3.2/^lib/jpicedt.jar"

    String homeDir = null;
    int trials = 2;
    do {
      index = classpath.toLowerCase().indexOf("lib" + fileSeparator + "jpicedt.jar");
      int start = classpath.lastIndexOf(File.pathSeparator, index);
      if (start == -1)
        start =
            0; // File.pathSeparator not found => lib/jpicedt.jar probably at beginning of classpath
      else start += File.pathSeparator.length(); // e.g. ":^/home..."

      if (index >= start) {
        homeDir = classpath.substring(start, index);
        if (homeDir.endsWith(fileSeparator)) homeDir = homeDir.substring(0, homeDir.length() - 1);
      }
      switch (trials) {
        case 2:
          if (File.pathSeparator.equals(";") && homeDir == null) {
            // MS-Windows case, this must work both with / and \
            trials = 1;
            fileSeparator = "/";
          } else trials = 0;
          break;
        case 1:
          if (homeDir != null && !fileSeparator.equals(File.separator)) {
            homeDir.replace(fileSeparator, File.separator);
          }
          trials = 0;
          break;

        default:
          trials = 0;
          break;
      }
    } while (trials != 0);

    if (homeDir != null) {
      if (homeDir.equals("")) homeDir = System.getProperty("user.dir");
      else if (!new File(homeDir).isAbsolute())
        homeDir = System.getProperty("user.dir") + File.separator + homeDir;
    } else {
      homeDir = System.getProperty("user.dir");
      if (homeDir.endsWith(
          "lib")) // this is the case if jpicedt run as "java -jar jpicedt.jar" from inside lib/ dir
      homeDir = homeDir.substring(0, homeDir.lastIndexOf("lib"));
    }

    // System.out.println("JPicEdt's home = " + homeDir);
    return homeDir;
  }
Пример #11
0
  /**
   * Make sure we have a theme set. Try to read a default value from the 'theme' property or use the
   * fallback.
   */
  public static void initialize() {

    if (ShadeConfig.theme.isSet()) return;

    MyTheme theme = null;
    if (System.getProperty("theme") == null) theme = FALLBACK;
    else {
      try {
        theme = valueOf(System.getProperty("theme").trim().toUpperCase(java.util.Locale.ENGLISH));
      } catch (IllegalArgumentException ignored) {
        /* No theme by the name given in the property 'theme'. */
      }

      if (theme == null) {
        Color customColor = null;
        try {
          customColor = Color.decode(System.getProperty("theme").trim());
        } catch (NumberFormatException e) {
          if (System.getProperty("theme").trim().length() > 0)
            Logger.get(MyTheme.class)
                .err(e, "err.invalidDefaultTheme", System.getProperty("theme").trim());
        }

        if (customColor != null) {
          MyTheme.CUSTOM.getLookAndFeel().setBase(customColor);
          theme = CUSTOM;
        } else theme = FALLBACK;
      }
    }

    ShadeConfig.theme.set(theme.getLookAndFeel());
  }
Пример #12
0
 static {
   // SoyLatte doesn't properly support document modal dialogs yet.
   isDocumentModalitySupported =
       !System.getProperty("os.name").equals("Darwin")
           && System.getProperty("java.version").compareTo("1.6") >= 0;
   isNativeSheetSupported =
       QuaquaManager.isOSX() && System.getProperty("java.version").compareTo("1.6") >= 0;
 }
  public static File getAppData() {
    String userHomeDir = System.getProperty("user.home", ".");
    String osType = System.getProperty("os.name").toLowerCase(Locale.ENGLISH);

    if (osType.contains("win") && System.getenv("APPDATA") != null) {
      return new File(new File(System.getenv("APPDATA")), ".minecraft");
    } else if (osType.contains("mac")) {
      return new File(new File(userHomeDir, "Library"), "Application Support");
    } else {
      return new File(new File(userHomeDir), ".minecraft");
    }
  }
Пример #14
0
 private String generateExceptionReport() {
   StringBuilder builder = new StringBuilder("Spoutcraft Launcher Error Report:\n");
   builder.append("( Please submit this report to http://spout.in/issues )\n");
   builder.append("    Launcher Build: ").append(Settings.getLauncherBuild()).append("\n");
   builder
       .append("----------------------------------------------------------------------")
       .append("\n");
   builder.append("Stack Trace:").append("\n");
   builder.append("    Exception: ").append(cause.getClass().getSimpleName()).append("\n");
   builder.append("    Message: ").append(cause.getMessage()).append("\n");
   logTrace(builder, cause);
   builder
       .append("----------------------------------------------------------------------")
       .append("\n");
   builder.append("System Information:\n");
   builder.append("    Operating System: ").append(System.getProperty("os.name")).append("\n");
   builder
       .append("    Operating System Version: ")
       .append(System.getProperty("os.version"))
       .append("\n");
   builder
       .append("    Operating System Architecture: ")
       .append(System.getProperty("os.arch"))
       .append("\n");
   builder
       .append("    Java version: ")
       .append(System.getProperty("java.version"))
       .append(" ")
       .append(System.getProperty("sun.arch.data.model", "32"))
       .append(" bit")
       .append("\n");
   builder
       .append("    Total Memory: ")
       .append(Runtime.getRuntime().totalMemory() / 1024L / 1024L)
       .append(" MB\n");
   builder
       .append("    Max Memory: ")
       .append(Runtime.getRuntime().maxMemory() / 1024L / 1024L)
       .append(" MB\n");
   builder
       .append("    Memory Free: ")
       .append(Runtime.getRuntime().freeMemory() / 1024L / 1024L)
       .append(" MB\n");
   builder
       .append("    CPU Cores: ")
       .append(Runtime.getRuntime().availableProcessors())
       .append("\n");
   return builder.toString();
 }
Пример #15
0
  /**
   * This method initializes jTextArea
   *
   * @return javax.swing.JTextArea
   */
  private JTextArea getJTextArea() {
    if (installDirTextArea == null) {

      String path;

      path = System.getProperty("user.home");

      installDirTextArea = new JTextArea();
      installDirTextArea.setEditable(false);
      installDirTextArea.setText(System.getProperty("user.home"));

      installDirTextArea.setBounds(new Rectangle(13, 49, 206, 21));
    }
    return installDirTextArea;
  }
Пример #16
0
  private void updateLinuxServiceInstaller() {
    try {
      File dir = new File(directory, "CTP");
      if (suppressFirstPathElement) dir = dir.getParentFile();
      Properties props = new Properties();
      String ctpHome = dir.getAbsolutePath();
      cp.appendln(Color.black, "...CTP_HOME: " + ctpHome);
      ctpHome = ctpHome.replaceAll("\\\\", "\\\\\\\\");
      props.put("CTP_HOME", ctpHome);
      File javaHome = new File(System.getProperty("java.home"));
      String javaBin = (new File(javaHome, "bin")).getAbsolutePath();
      cp.appendln(Color.black, "...JAVA_BIN: " + javaBin);
      javaBin = javaBin.replaceAll("\\\\", "\\\\\\\\");
      props.put("JAVA_BIN", javaBin);

      File linux = new File(dir, "linux");
      File install = new File(linux, "ctpService-ubuntu.sh");
      cp.appendln(Color.black, "Linux service installer:");
      cp.appendln(Color.black, "...file: " + install.getAbsolutePath());
      String bat = getFileText(install);
      bat = replace(bat, props); // do the substitutions
      bat = bat.replace("\r", "");
      setFileText(install, bat);

      // If this is an ISN installation, put the script in the correct place.
      String osName = System.getProperty("os.name").toLowerCase();
      if (programName.equals("ISN") && !osName.contains("windows")) {
        install = new File(linux, "ctpService-red.sh");
        cp.appendln(Color.black, "ISN service installer:");
        cp.appendln(Color.black, "...file: " + install.getAbsolutePath());
        bat = getFileText(install);
        bat = replace(bat, props); // do the substitutions
        bat = bat.replace("\r", "");
        File initDir = new File("/etc/init.d");
        File initFile = new File(initDir, "ctpService");
        if (initDir.exists()) {
          setOwnership(initDir, "edge", "edge");
          setFileText(initFile, bat);
          initFile.setReadable(true, false); // everybody can read //Java 1.6
          initFile.setWritable(true); // only the owner can write //Java 1.6
          initFile.setExecutable(true, false); // everybody can execute //Java 1.6
        }
      }
    } catch (Exception ex) {
      ex.printStackTrace();
      System.err.println("Unable to update the Linux service ctpService.sh file");
    }
  }
Пример #17
0
  void enableLionFS() {
    try {
      String version = System.getProperty("os.version");
      String[] tokens = version.split("\\.");
      int major = Integer.parseInt(tokens[0]), minor = 0;
      if (tokens.length > 1) minor = Integer.parseInt(tokens[1]);
      if (major < 10 || (major == 10 && minor < 7))
        throw new Exception("Operating system version is " + version);

      Class fsuClass = Class.forName("com.apple.eawt.FullScreenUtilities");
      Class argClasses[] = new Class[] {Window.class, Boolean.TYPE};
      Method setWindowCanFullScreen = fsuClass.getMethod("setWindowCanFullScreen", argClasses);
      setWindowCanFullScreen.invoke(fsuClass, this, true);

      Class fsListenerClass = Class.forName("com.apple.eawt.FullScreenListener");
      InvocationHandler fsHandler = new MyInvocationHandler(cc);
      Object proxy =
          Proxy.newProxyInstance(
              fsListenerClass.getClassLoader(), new Class[] {fsListenerClass}, fsHandler);
      argClasses = new Class[] {Window.class, fsListenerClass};
      Method addFullScreenListenerTo = fsuClass.getMethod("addFullScreenListenerTo", argClasses);
      addFullScreenListenerTo.invoke(fsuClass, this, proxy);

      canDoLionFS = true;
    } catch (Exception e) {
      vlog.debug("Could not enable OS X 10.7+ full-screen mode:");
      vlog.debug("  " + e.toString());
    }
  }
  /** Constructor */
  public PrideInspectorContext() {
    // instantiate data access monitor
    this.dataAccessMonitor = new DataAccessMonitor();

    // data content pane cache
    this.dataContentPaneCache =
        Collections.synchronizedMap(new HashMap<DataAccessController, JComponent>());

    // data summary pane cache
    this.dataSummaryPaneCache =
        Collections.synchronizedMap(new HashMap<DataAccessController, JComponent>());

    // action map
    this.sharedActionCache =
        Collections.synchronizedMap(
            new HashMap<DataAccessController, Map<Class<? extends PrideAction>, PrideAction>>());

    // summary report tracker
    this.summaryReportTracker =
        Collections.synchronizedMap(new HashMap<DataAccessController, ListModel>());

    // by default the data source browser is invisible
    this.leftControlPaneVisible = false;

    // set the default path for opening/saving files
    this.setOpenFilePath(System.getProperty("user.dir"));
  }
Пример #19
0
  public String getSelectedPath(String item) {
    String path = "", fileSep = System.getProperty("file.separator");

    /*
            try
            {
                path = converter.getDefaultTemplateFilePath().getParent() + fileSep;
            }
            catch (FileNotFoundException e)
            {
    	    final String caption = ResourceHandler.getMessage("notemplate_dialog.caption");
    	    final String info = ResourceHandler.getMessage("notemplate_dialog.info0")
    				+ PluginConverter.getDefaultTemplateFileName()
    				+ ResourceHandler.getMessage("notemplate_dialog.info1");

    	    JOptionPane.showMessageDialog(this, info, caption, JOptionPane.ERROR_MESSAGE);

                System.exit(0);
            }
    */
    if (item.equals(DEFAULT_STR)) return path + DEFAULT_PATH;
    else if (item.equals(EXTEND_STR)) return path + EXTEND_PATH;
    else if (item.equals(IE_STR)) return path + IE_PATH;
    else if (item.equals(NS_STR)) return path + NS_PATH;
    else return item;
  }
Пример #20
0
  /** Construct a FileTree */
  public FilePanel(JPanel panel, final IDEWindow ideWindow) {

    pane = panel;
    setLayout(new BorderLayout());
    // Make a tree list with all the nodes, and make it a JTree
    JTree tree = new JTree(addNodes(null, new File(System.getProperty("user.dir"))));

    // Add a listener
    tree.addTreeSelectionListener(
        new TreeSelectionListener() {
          public void valueChanged(TreeSelectionEvent e) {

            DefaultMutableTreeNode node =
                (DefaultMutableTreeNode) e.getPath().getLastPathComponent();

            File file = null;

            if (node.isLeaf()) {
              file = new File(node.getParent() + "/" + node);
              ToolbarFunctions.open(file, ideWindow);
            }
          }
        });

    setSize(panel.getPreferredSize());
    // Lastly, put the JTree into a JScrollPane.
    JScrollPane scrollpane = new JScrollPane();
    scrollpane.getViewport().add(tree);

    add(BorderLayout.CENTER, scrollpane);
  }
Пример #21
0
  public APCircleWindow() {
    super("AP Circles");
    setDefaultCloseOperation(EXIT_ON_CLOSE);

    String startDirectoryName = System.getProperty("user.dir");
    startDirectory = new File(startDirectoryName);
    // this for convenience, as the program normally starts in graph/display
    //		startDirectory = startDirectory.getParentFile();

    gw = this;

    generalXML = new GeneralXML(graph);

    gp = new APCirclePanel(this);
    getContentPane().add(gp);

    graph = gp.getGraph();

    initView();
    initExperiment();
    initUtility();
    initLayout();
    initMenu();

    setSize(width, height);

    Dimension frameDim = Toolkit.getDefaultToolkit().getScreenSize();
    int posX = (frameDim.width - getSize().width) / 2;
    int posY = (frameDim.height - getSize().height) / 2;
    setLocation(posX, posY);

    setVisible(true);

    gp.requestFocus();
  }
Пример #22
0
 /** Return the platform standard tmp dir, or null if none is standardly defined. */
 public static File getOSTmpDir() {
   // Note : default tmp dir can be obtained through :
   // System.getProperty("java.io.tmp")
   String tmp = System.getProperty("java.io.tmp");
   if (tmp == null) return null;
   else return new File(tmp);
 }
Пример #23
0
 private byte[] loadClassData(String className) throws IOException {
   Playground.println("Loading class " + className + ".class", warning);
   File f = new File(System.getProperty("user.dir") + "/" + className + ".class");
   byte[] b = new byte[(int) f.length()];
   new FileInputStream(f).read(b);
   return b;
 }
Пример #24
0
  /**
   * Class constructor alloowing specification of the heading text.
   *
   * @param properties the Properties object containing the initial values of the extensions list
   *     and the path to be displayed. This object is updated tin response to root changes,
   *     extension changes, and file selections. If any property is missing, a suitable one is
   *     supplied by default.
   * @param heading the text to appear in the heading of the JPanel.
   * @param background the background color or null if the default is to be used.
   */
  public SourcePanel(ApplicationProperties properties, String heading, Color background) {
    super();
    this.properties = properties;
    if (background == null) this.background = Color.getHSBColor(0.58f, 0.17f, 0.95f);
    else this.background = background;

    // Make the file filter
    filter = new GeneralFileFilter();
    String extensions = properties.getProperty("extensions");
    if (extensions != null) filter.setExtensions(extensions);
    else {
      filter.addExtension(".dcm");
      properties.setProperty("extensions", filter.getExtensionString());
    }

    // Get the starting directory path from the properties.
    // If it is missing, start in the directory containing the program.
    String currentDirectoryPath = properties.getProperty("directory");
    if (currentDirectoryPath == null) currentDirectoryPath = System.getProperty("user.dir");

    // Create the UI components
    this.setLayout(new BorderLayout());
    directoryPane = new DirectoryPane(filter, currentDirectoryPath);
    directoryPane.addFileListener(this);
    headerPanel = new HeaderPanel(heading);
    footerPanel = new FooterPanel();
    this.add(headerPanel, BorderLayout.NORTH);
    this.add(directoryPane, BorderLayout.CENTER);
    this.add(footerPanel, BorderLayout.SOUTH);
  }
Пример #25
0
  @NotNull
  @Override
  public Collection<String> suggestHomePaths() {
    if (!SystemInfo.isWindows) return Collections.singletonList(suggestHomePath());

    String property = System.getProperty("java.home");
    if (property == null) return Collections.emptyList();

    File javaHome = new File(property).getParentFile(); // actually java.home points to to jre home
    if (javaHome == null || !javaHome.isDirectory() || javaHome.getParentFile() == null) {
      return Collections.emptyList();
    }
    ArrayList<String> result = new ArrayList<>();
    File javasFolder = javaHome.getParentFile();
    scanFolder(javasFolder, result);
    File parentFile = javasFolder.getParentFile();
    File root = parentFile != null ? parentFile.getParentFile() : null;
    String name = parentFile != null ? parentFile.getName() : "";
    if (name.contains("Program Files") && root != null) {
      String x86Suffix = " (x86)";
      boolean x86 = name.endsWith(x86Suffix) && name.length() > x86Suffix.length();
      File anotherJavasFolder;
      if (x86) {
        anotherJavasFolder = new File(root, name.substring(0, name.length() - x86Suffix.length()));
      } else {
        anotherJavasFolder = new File(root, name + x86Suffix);
      }
      if (anotherJavasFolder.isDirectory()) {
        scanFolder(new File(anotherJavasFolder, javasFolder.getName()), result);
      }
    }
    return result;
  }
  public boolean avrdude(Collection params) throws RunnerException {
    List commandDownloader = new ArrayList();
    commandDownloader.add("avrdude");

    // Point avrdude at its config file since it's in a non-standard location.
    if (Base.isMacOS()) {
      commandDownloader.add("-C" + "hardware/tools/avr/etc/avrdude.conf");
    } else if (Base.isWindows()) {
      String userdir = System.getProperty("user.dir") + File.separator;
      commandDownloader.add("-C" + userdir + "hardware/tools/avr/etc/avrdude.conf");
    } else {
      // ???: is it better to have Linux users install avrdude themselves, in
      // a way that it can find its own configuration file?
      commandDownloader.add("-C" + "hardware/tools/avrdude.conf");
    }

    if (Preferences.getBoolean("upload.verbose")) {
      commandDownloader.add("-v");
      commandDownloader.add("-v");
      commandDownloader.add("-v");
      commandDownloader.add("-v");
    } else {
      commandDownloader.add("-q");
      commandDownloader.add("-q");
    }
    // XXX: quick hack to chop the "atmega" off of "atmega8" and "atmega168",
    // then shove an "m" at the beginning.  won't work for attiny's, etc.
    commandDownloader.add(
        "-pm" + Preferences.get("boards." + Preferences.get("board") + ".build.mcu").substring(6));
    commandDownloader.addAll(params);

    return executeUploadCommand(commandDownloader);
  }
  @NotNull
  private static String findMainClass(VirtualFile gradleHome, VirtualFile script, Project project) {
    final String userDefined = System.getProperty("gradle.launcher.class");
    if (StringUtil.isNotEmpty(userDefined)) {
      return userDefined;
    }

    VirtualFile launcher = gradleHome.findFileByRelativePath("bin/gradle");
    if (launcher == null) {
      launcher = gradleHome.findFileByRelativePath("bin/gradle.bat");
    }
    if (launcher != null) {
      try {
        final String text = StringUtil.convertLineSeparators(VfsUtilCore.loadText(launcher));
        final Matcher matcher = MAIN_CLASS_NAME_PATTERN.matcher(text);
        if (matcher.find()) {
          String candidate = matcher.group(1);
          if (StringUtil.isNotEmpty(candidate)) {
            return candidate;
          }
        }
      } catch (IOException ignored) {
      }
    }

    final PsiFile grFile = PsiManager.getInstance(project).findFile(script);
    if (grFile != null
        && JavaPsiFacade.getInstance(project)
                .findClass("org.gradle.BootstrapMain", grFile.getResolveScope())
            != null) {
      return "org.gradle.BootstrapMain";
    }

    return "org.gradle.launcher.GradleMain";
  }
Пример #28
0
  /**
   * The following code is a trick! By default Swing uses lightweight and "medium" weight popups to
   * show JPopupMenu. The code below force the creation of real heavyweight menus - this increases
   * speed of popups and allows to get rid of some drawing artifacts.
   */
  private static void fixPopupWeight() {
    int popupWeight = OurPopupFactory.WEIGHT_MEDIUM;
    String property = System.getProperty("idea.popup.weight");
    if (property != null) property = property.toLowerCase(Locale.ENGLISH).trim();
    if (SystemInfo.isMacOSLeopard) {
      // force heavy weight popups under Leopard, otherwise they don't have shadow or any kind of
      // border.
      popupWeight = OurPopupFactory.WEIGHT_HEAVY;
    } else if (property == null) {
      // use defaults if popup weight isn't specified
      if (SystemInfo.isWindows) {
        popupWeight = OurPopupFactory.WEIGHT_HEAVY;
      }
    } else {
      if ("light".equals(property)) {
        popupWeight = OurPopupFactory.WEIGHT_LIGHT;
      } else if ("medium".equals(property)) {
        popupWeight = OurPopupFactory.WEIGHT_MEDIUM;
      } else if ("heavy".equals(property)) {
        popupWeight = OurPopupFactory.WEIGHT_HEAVY;
      } else {
        LOG.error("Illegal value of property \"idea.popup.weight\": " + property);
      }
    }

    PopupFactory factory = PopupFactory.getSharedInstance();
    if (!(factory instanceof OurPopupFactory)) {
      factory = new OurPopupFactory(factory);
      PopupFactory.setSharedInstance(factory);
    }
    PopupUtil.setPopupType(factory, popupWeight);
  }
Пример #29
0
 public void initGame() {
   String cfgname = null;
   if (isApplet()) {
     cfgname = getParameter("configfile");
   } else {
     JFileChooser chooser = new JFileChooser();
     chooser.setCurrentDirectory(new File(System.getProperty("user.dir")));
     chooser.setDialogTitle("Choose a config file");
     int returnVal = chooser.showOpenDialog(this);
     if (returnVal == JFileChooser.APPROVE_OPTION) {
       cfgname = chooser.getSelectedFile().getAbsolutePath();
     } else {
       System.exit(0);
     }
     // XXX read this as resource!
     // cfgname = "mygeneratedgame.appconfig";
   }
   gamecfg = new AppConfig("Game parameters", this, cfgname);
   gamecfg.loadFromFile();
   gamecfg.defineFields("gp_", "", "", "");
   gamecfg.saveToObject();
   initMotionPars();
   // unpause and copy settingswhen config window is closed
   gamecfg.setListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           start();
           requestGameFocus();
           initMotionPars();
         }
       });
   defineMedia("simplegeneratedgame.tbl");
   setFrameRate(35, 1);
 }
Пример #30
0
  /**
   * @return the clipboard content as a String (DataFlavor.stringFlavor) Code snippet adapted from
   *     jEdit (Registers.java), http://www.jedit.org. Returns null if clipboard is empty.
   */
  public static String getClipboardStringContent(Clipboard clipboard) {
    // Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
    try {
      String selection =
          (String) (clipboard.getContents(null).getTransferData(DataFlavor.stringFlavor));
      if (selection == null) return null;

      boolean trailingEOL =
          (selection.endsWith("\n") || selection.endsWith(System.getProperty("line.separator")));

      // Some Java versions return the clipboard contents using the native line separator,
      // so have to convert it here , see jEdit's "registers.java"
      BufferedReader in = new BufferedReader(new StringReader(selection));
      StringBuffer buf = new StringBuffer();
      String line;
      while ((line = in.readLine()) != null) {
        buf.append(line);
        buf.append('\n');
      }
      // remove trailing \n
      if (!trailingEOL) buf.setLength(buf.length() - 1);
      return buf.toString();
    } catch (Exception e) {
      e.printStackTrace();
      return null;
    }
  }