public String getCompleteProgramArguments(String os) {
   if (Platform.OS_WIN32.equals(os)) {
     return getCompleteArgs(getProgramArguments(L_ARGS_WIN32), fProgramArgs);
   } else if (Platform.OS_LINUX.equals(os)) {
     return getCompleteArgs(getProgramArguments(L_ARGS_LINUX), fProgramArgs);
   } else if (Platform.OS_MACOSX.equals(os)) {
     return getCompleteArgs(getProgramArguments(L_ARGS_MACOS), fProgramArgs);
   } else if (Platform.OS_SOLARIS.equals(os)) {
     return getCompleteArgs(getProgramArguments(L_ARGS_SOLAR), fProgramArgs);
   } else {
     return getProgramArguments(L_ARGS_ALL);
   }
 }
 public static void explore(String name) {
   File file = new File(name);
   String command = null;
   if (file.isFile()) {
     command = getExploreFileCommand();
   } else {
     command = getExploreCommand();
   }
   if (command != null) {
     if (Platform.getOS().equals(Platform.OS_WIN32)) {
       name = name.replace('/', '\\');
     }
     try {
       if (Platform.OS_LINUX.equals(Platform.getOS())
           || Platform.OS_MACOSX.equals(Platform.getOS())) {
         int len = exploreFolderCommandArray.length;
         String name2 = file.isFile() ? new Path(name).removeLastSegments(1).toString() : name;
         exploreFolderCommandArray[len - 1] = name2;
         Runtime.getRuntime().exec(exploreFolderCommandArray);
       } else if (Platform.getOS().equals(Platform.OS_WIN32)) {
         if (file.isDirectory()) {
           int len = exploreFolderCommandArray.length;
           exploreFolderCommandArray[len - 1] = "\"" + name + "\""; // $NON-NLS-1$ //$NON-NLS-2$
           Runtime.getRuntime().exec(exploreFolderCommandArray);
         } else {
           int len = exploreFileCommandArray.length;
           exploreFileCommandArray[len - 1] = "\"" + name + "\""; // $NON-NLS-1$ //$NON-NLS-2$
           Runtime.getRuntime().exec(exploreFileCommandArray);
         }
       } else {
         command = command.replace(ExploreUtils.PATH, name);
         if (JBossServerUIPlugin.getDefault().isDebugging()) {
           IStatus status =
               new Status(
                   IStatus.WARNING,
                   JBossServerUIPlugin.PLUGIN_ID,
                   "command=" + command,
                   null); //$NON-NLS-1$
           JBossServerUIPlugin.getDefault().getLog().log(status);
         }
         Runtime.getRuntime().exec(command);
       }
     } catch (IOException e) {
       JBossServerUIPlugin.log(e.getMessage(), e);
     }
   }
 }
  private static void setExploreCommands() {
    if (Platform.OS_MACOSX.equals(Platform.getOS())) {
      exploreFolderCommandArray =
          new String[] {
            "/usr/bin/open", "-a", "/System/Library/CoreServices/Finder.app", ""
          }; //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
      exploreFolderCommand = ""; // $NON-NLS-1$
    } else if (Platform.OS_WIN32.equals(Platform.getOS())) {
      exploreFolderCommandArray = new String[5];
      exploreFolderCommandArray[0] = "cmd"; // $NON-NLS-1$
      exploreFolderCommandArray[1] = "/C"; // $NON-NLS-1$
      exploreFolderCommandArray[2] = "start"; // $NON-NLS-1$
      exploreFolderCommandArray[3] = "explorer"; // $NON-NLS-1$

      exploreFileCommandArray = new String[6];
      exploreFileCommandArray[0] = "cmd"; // $NON-NLS-1$
      exploreFileCommandArray[1] = "/C"; // $NON-NLS-1$
      exploreFileCommandArray[2] = "start"; // $NON-NLS-1$
      exploreFileCommandArray[3] = "explorer"; // $NON-NLS-1$
      exploreFileCommandArray[4] = "/select,"; // $NON-NLS-1$

      exploreFolderCommand =
          "cmd /C start explorer \"" //$NON-NLS-1$
              + PATH
              + "\""; //$NON-NLS-1$
      exploreFileCommand =
          "cmd /C start explorer /select,\"" //$NON-NLS-1$
              + PATH
              + "\""; //$NON-NLS-1$
    } else if (Platform.OS_LINUX.equals(Platform.getOS())) {

      if (new File("/usr/bin/nautilus").exists()) { // $NON-NLS-1$
        exploreFolderCommandArray = new String[3];
        exploreFolderCommandArray[0] = "/usr/bin/nautilus"; // $NON-NLS-1$
        exploreFolderCommandArray[1] = "--no-desktop"; // $NON-NLS-1$
        exploreFolderCommand = ""; // $NON-NLS-1$
      } else if (new File("/usr/bin/konqueror").exists()) { // $NON-NLS-1$
        exploreFolderCommandArray = new String[2];
        exploreFolderCommandArray[0] = "/usr/bin/konqueror"; // $NON-NLS-1$
        exploreFolderCommand = ""; // $NON-NLS-1$
      }
      exploreFileCommand = exploreFolderCommand;
    }
  }
Beispiel #4
0
  private static OS create() {
    String os = Platform.getOS();
    String ws = Platform.getWS();
    String arch = Platform.getOSArch();

    if (Platform.OS_WIN32.equals(os)) {
      if (Platform.ARCH_X86_64.equals(arch)) {
        return new Win64(ws);
      }

      return new Win32(ws, arch);
    }

    if (Platform.OS_MACOSX.equals(os)) {
      return new Mac(ws, arch);
    }

    if (Platform.OS_LINUX.equals(os)) {
      return new Linux(ws, arch);
    }

    throw new IllegalStateException("Operating system not supported: " + os);
  }
Beispiel #5
0
 public static boolean isLinux() {
   return Platform.OS_LINUX.equals(Platform.getOS());
 }