.................
@Override
protected void okPressed() {
if (text_name.getText().length() == 0)
MessageUtil.getWarningMessage(getShell(), "Please enter URL");
IProject project = getCurrentProject();
String project_path = project.getLocation().toOSString();
String url = text_name.getText().toString();
System.out.println(url);
String txt = url;
try {
FileOutputStream output = new FileOutputStream(project_path + "\\aa.bat");
String str = "pushd %~dp0\r\n" + "cd root\r\n" + "git init\r\n" + "git status\r\n"
+ "git add *\r\n" + "git commit -m \"d\"\r\n" + "git remote add origin " + txt + "\r\n"
+ "git push origin master";
byte[] by = str.getBytes();
output.write(by);
output.close();
} catch (Exception e) {
e.getStackTrace();
}
//Runtime rt = Runtime.getRuntime();
try {
String exeFile = project_path + "\\aa.bat";
Process p = Runtime.getRuntime().exec(exeFile);
//p = rt.exec(exeFile);
//p.waitFor();
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = null;
while ((line = br.readLine()) != null) {
System.out.println(line);
}
int waitFor = p.waitFor();
int result = p.exitValue();
}
catch (Exception e2) {
e2.printStackTrace();
}
super.okPressed();
}
.......
ok버튼 이벤트발생시 aa.bat이라는 배치파일을 만들어 실행시키는 구문이다. 메시지가 아무것도 입력되지 않았을 시 사용자에게 알려주고
사용자로부터 받은값을 이용하여 배치파일 url주소에 저장한다.
...으로 표시된 부분에는 swt를 이용한 ui구현이 되어있다.
'JAVA > JAVA(MEC)' 카테고리의 다른 글
filestream 2번이상사용시 주의 (0) | 2020.08.24 |
---|---|
rootcommit (0) | 2020.08.24 |
filewriter (0) | 2020.08.24 |
contextmenuitem 추가 - rcp eclipse (자세히) (0) | 2020.08.24 |
bat(배치파일) 예시 (0) | 2020.08.24 |