오른쪽마우스 클릭시 menutextitem 구현과 클릭이벤트발생시 rootdialog 호출
.........................
public void fill(Menu menu, int index) {
// Here you could get selection and decide what to do
// You can also simply return if you do not want to show a menu
// create the menu item
MenuItem menuItem = new MenuItem(menu, SWT.CHECK, index);
menuItem.setText("ROOT COMMIT");
menuItem.setImage(Activator.getImage(IIconConstants.GENERATECODES));
menuItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
RootDialog rootDialog = new RootDialog(Display.getCurrent().getActiveShell(),0);
int open = rootDialog.open();
rootDialog.close();
@Override
public void run() {
Display display = new Display();
Shell shell = new Shell(display);
Button btn1 = new Button(shell, SWT.PUSH);
shell.setBounds(1100, 200, 700, 500);
btn1.setText("확인");
btn1.setBounds(310, 400, 50, 30);
// 창 이름.setResizable(false);
Text helloText = new Text(shell, SWT.LEFT);
helloText.setBounds(185, 200, 440, 20);
btn1.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
String url = helloText.getText().toString();
System.out.println(url);
String txt = url;
try {
OutputStream output = new FileOutputStream(project_path + "\\gggg.bat");
String str = "pushd %~dp0\r\n" + "cd ..\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);
} catch (Exception e) {
e.getStackTrace();
}
String filename = "C:\\Users\\psh0749\\Desktop\\aa";
try {
File file = new File(filename);
file.mkdirs();
FileWriter fw = new FileWriter(file, true);
fw.write(txt);
fw.flush();
fw.close();
} catch (Exception e) {
e.printStackTrace();
}
shell.close();
}
});
Label label = new Label(shell, SWT.CENTER);
label.setText("please input git url : ");
label.setBounds(50, 200, 150, 150);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
});
...........................
}
'JAVA > JAVA(MEC)' 카테고리의 다른 글
git 자격증명 credential 정리 (0) | 2020.09.04 |
---|---|
filestream 2번이상사용시 주의 (0) | 2020.08.24 |
root dialog ok버튼 클릭시 (0) | 2020.08.24 |
filewriter (0) | 2020.08.24 |
contextmenuitem 추가 - rcp eclipse (자세히) (0) | 2020.08.24 |