case "welcome": log.debug("sending welcome + prompt"); ws.send(event("print", shell.getWelcome())); ws.send(event("prompt", shell.getPrompt())); break; case "execute": Integer width = (Integer) event.get("width"); Integer height = (Integer) event.get("height"); process.set(shell.createProcess(command)); SimpleProcessContext context = new SimpleProcessContext(r -> { Try.run(() -> { ws.send(event("prompt", shell.getPrompt())); ws.send(event("end")); }).onFailure(x -> log.error("error found while sending output", x)); case "complete": String prefix = (String) event.get("prefix"); CompletionMatch completion = shell.complete(prefix); Completion completions = completion.getValue(); Delimiter delimiter = completion.getDelimiter(); sp.cancel(); shell.close(); });
import org.eclipse.swt.*; import org.eclipse.swt.widgets.*; public class SWTFileOpenSnippet { public static void main (String [] args) { Display display = new Display (); Shell shell = new Shell (display); // Don't show the shell. //shell.open (); FileDialog dialog = new FileDialog (shell, SWT.OPEN | SWT.MULTI); String [] filterNames = new String [] {"All Files (*)"}; String [] filterExtensions = new String [] {"*"}; String filterPath = "c:\\"; dialog.setFilterNames (filterNames); dialog.setFilterExtensions (filterExtensions); dialog.setFilterPath (filterPath); dialog.open(); System.out.println ("Selected files: "); String[] selectedFileNames = dialog.getFileNames(); for(String fileName : selectedFileNames) { System.out.println(" " + fileName); } shell.close(); while (!shell.isDisposed ()) { if (!display.readAndDispatch ()) display.sleep (); } display.dispose (); } }
static void install(final Env env, final Config conf) { String path = conf.getString("crash.httpshell.path"); Router router = env.router(); router.get(path + "/{cmd:.*}", router.promise("direct", (req, deferred) -> { MediaType type = req.accepts(MediaType.json) .map(it -> MediaType.json) .orElse(MediaType.html); PluginContext ctx = req.require(PluginContext.class); ShellFactory shellFactory = ctx.getPlugin(ShellFactory.class); Shell shell = shellFactory.create(null); String cmd = req.param("cmd").value().replaceAll("/", " "); ShellProcess process = shell.createProcess(cmd); ShellProcessContext spc = new SimpleProcessContext( result -> deferred.resolve(result.type(type))); process.execute(spc); })); }
public String getPrompt() { return shell.getPrompt(); }
public String getWelcome() { return shell.getWelcome(); }
public CompletionMatch complete(String prefix) { return shell.complete(prefix); }
Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); shell.setBounds(100, 100, 200, 70); Button button = new Button(shell, SWT.NONE); button.setText("Go"); public void handleEvent(Event arg0) { Shell screenShell = new Shell(display, SWT.NO_TRIM | SWT.ON_TOP); screenShell.setMaximized(true); screenShell.setBackground(display.getSystemColor(SWT.COLOR_GRAY)); screenShell.setAlpha(120); screenShell.addListener(SWT.MouseDown, new Listener() { @Override public void handleEvent(Event event) { screenShell.close(); }}); screenShell.open(); Display.getCurrent().timerExec(10, new Runnable(){ @Override public void run() { if (!screenShell.isDisposed()) { int x = MouseInfo.getPointerInfo().getLocation().x; int y = MouseInfo.getPointerInfo().getLocation().y; shell.open(); while (!shell.isDisposed ()) { if (!display.readAndDispatch ()) display.sleep ();
shell.setLayout(new GridLayout()); shell.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); shell.setSize(200, 100); shell.setText("Parent Shell"); shell.open (); while (!shell.isDisposed ()) { if (!display.readAndDispatch ()) display.sleep (); dialog.setLayout(new GridLayout()); dialog.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); dialog.setSize(200, 100); dialog.setText("Child Shell"); okButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { dialog.close(); dialog.addShellListener(new ShellListener() { public void shellIconified(ShellEvent e) { dialog.setDefaultButton (okButton); dialog.open ();
shell.setLayout(new GridLayout(1, false)); popup.setLayout(new FillLayout()); public void handleEvent(Event event) if(popup != null && !popup.isDisposed()) popup.close(); shell.pack(); shell.open(); popup.pack(); popup.open(); popup.setLocation(button.toDisplay(button.getBounds().width, 1)); while (!shell.isDisposed())
dialog.setText("Enter deadline date (NONE for none)"); myPoint.x +=80; // myPoint.x +=30; myPoint.y +=320; // myPoint.y +=350; dialog.setLocation(myPoint); dialog.setSize(270, 220); dialog.setLayout (null); dialog.close (); dialog.open (); while (!dialog.isDisposed()) { if (!display.readAndDispatch()) { display.sleep();
shell.setLayout(new GridLayout(1, true)); shell.setLayoutData(gridData); shell.setText("Side By Side"); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); shell.setLayoutData(gridData); area.setLayoutData(gridData); pdfButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { shell.close(); plotButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { shell.close();
b.setSize(bsize); b.setLocation(0, 0); s.setSize(bsize); s.open(); Image image = new Image(shell.getDisplay(), bsize.x, bsize.y); gc.copyArea(image, 0, 0); gc.dispose(); s.close();
shell.setLayout(new GridLayout(1, true)); GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true); shell.setLayoutData(gridData); public void completed(ProgressEvent event) { System.out.println(browser.getText()); shell.close(); image.dispose(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep();
Log.d("AUTO", str3); shell.add( new SimpleCommand( "chmod 777 /data/data/com.whatsapp/databases/msgstore.db")) .waitForFinish(); shell.add(new SimpleCommand(str1)).waitForFinish(); shell.add(new SimpleCommand(str2)).waitForFinish(); shell.add(new SimpleCommand(str3)).waitForFinish(); shell.close(); } catch (Exception e) { e.printStackTrace();
@Override protected void tearDown() throws Exception { if (shell != null) { shell.close(); shell = null; groovyShell = null; } }
private BaseProcessContext(Shell shell, String line) { this(shell.createProcess(line)); }
void writePromptFlush() { String prompt = shell.getPrompt(); try { StringBuilder sb = new StringBuilder("\r\n"); String p = prompt == null ? "% " : prompt; sb.append(p); CharSequence buffer = term.getBuffer(); if (buffer != null) { sb.append(buffer); } term.append(sb); term.flush(); } catch (IOException e) { // Todo : improve that e.printStackTrace(); } }