KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > omg > lifl > eclipse > plugin > utils > OSHelper


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2003 USTL - LIFL - GOAL
5 Contact: openccm-team@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Jerome Offroy.
23 Contributor(s): ______________________________________.
24
25 ====================================================================*/

26 /*
27  * Created on 27 juin 2003
28  *
29  */

30 package org.omg.lifl.eclipse.plugin.utils;
31
32 import java.io.IOException JavaDoc;
33
34 /**
35  * @author offroy
36  *
37  */

38 public class OSHelper {
39
40     public static boolean isWindowsOS() {
41         String JavaDoc os = System.getProperties().getProperty("os.name");
42         if (os.startsWith("Windows"))
43             return true;
44         else
45             return false;
46
47     }
48
49     public static boolean isLinuxOS() {
50         String JavaDoc os = System.getProperties().getProperty("os.name");
51         if (os.startsWith("Linux"))
52             return true;
53         else
54             return false;
55
56     }
57
58     public static boolean isOS(String JavaDoc OSName) {
59         String JavaDoc os = System.getProperties().getProperty("os.name");
60         if (os.startsWith("OSName"))
61             return true;
62         else
63             return false;
64
65     }
66
67     public static void launchProcess(String JavaDoc srciptCmd) throws IOException JavaDoc {
68         Process JavaDoc process;
69         process = Runtime.getRuntime().exec(srciptCmd);
70         
71         // TODO launch the bat file in an Eclipse view or get its output to
72
// OpenCCMConsole Eclipse view
73
/*
74         if (!OutputToConsole.init()) {
75             MessageBox infoBox =
76                 new MessageBox(
77                     PlatformUI
78                         .getWorkbench()
79                         .getActiveWorkbenchWindow()
80                         .getShell(),
81                     40);
82             infoBox.setMessage("The OpenCCM Console is not selected!");
83             infoBox.setText("CompilerAction.messageBoxTitle");
84             infoBox.open();
85             return;
86         }
87         
88         process = Runtime.getRuntime().exec(srciptCmd);
89         
90                     PrintStream outPrintStream = new PrintStream(process.getOutputStream());
91         StreamCatcher errorCatcher =
92             new StreamCatcher(
93                 process.getErrorStream(),
94                 outPrintStream,
95                 "ERROR");
96         StreamCatcher outputCatcher =
97             new StreamCatcher(
98                 process.getInputStream(),
99                 outPrintStream,
100                 "OUTPUT");
101         errorCatcher.start();
102         outputCatcher.start();
103         process.waitFor();
104         OutputToConsole.start();*/

105     }
106
107     public static String JavaDoc createWin32Shell() {
108         String JavaDoc shellTittle = " \"Shell\" ";
109         String JavaDoc cmdDirectory = WorkBenchHelper.getSelectedRessourceFullPath();
110         if (cmdDirectory == null)
111             cmdDirectory = ".";
112         String JavaDoc win32Shell = "cmd.exe /c start /D " + cmdDirectory + shellTittle;
113         return win32Shell;
114     }
115
116
117 }
118
Popular Tags