public static void main(String[] args) {
   final Display display = new Display();
   final Shell shell = new Shell(display);
   shell.setLayout(new FillLayout());
   final StyledText styledText = new StyledText(shell, SWT.WRAP | SWT.BORDER);
   styledText.setText(text);
   FontData data = display.getSystemFont().getFontData()[0];
   Font font = new Font(display, data.getName(), 16, SWT.BOLD);
   styledText.setFont(font);
   styledText.setForeground(display.getSystemColor(SWT.COLOR_BLUE));
   styledText.addListener(
       SWT.Resize,
       new Listener() {
         public void handleEvent(Event event) {
           Rectangle rect = styledText.getClientArea();
           Image newImage = new Image(display, 1, Math.max(1, rect.height));
           GC gc = new GC(newImage);
           gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
           gc.setBackground(display.getSystemColor(SWT.COLOR_YELLOW));
           gc.fillGradientRectangle(rect.x, rect.y, 1, rect.height, true);
           gc.dispose();
           styledText.setBackgroundImage(newImage);
           if (oldImage != null) oldImage.dispose();
           oldImage = newImage;
         }
       });
   shell.setSize(700, 400);
   shell.open();
   while (!shell.isDisposed()) {
     if (!display.readAndDispatch()) display.sleep();
   }
   if (oldImage != null) oldImage.dispose();
   font.dispose();
   display.dispose();
 }
  public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new RowLayout());

    DateTime calendar = new DateTime(shell, SWT.CALENDAR);
    calendar.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            System.out.println("calendar date changed");
          }
        });

    DateTime time = new DateTime(shell, SWT.TIME);
    time.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            System.out.println("time changed");
          }
        });

    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
  }
  public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new GridLayout());
    final ScrolledComposite sc =
        new ScrolledComposite(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    sc.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    Composite c = new Composite(sc, SWT.NONE);
    c.setLayout(new GridLayout(10, true));
    for (int i = 0; i < 300; i++) {
      Button b = new Button(c, SWT.PUSH);
      b.setText("Button " + i);
    }
    sc.setContent(c);
    sc.setExpandHorizontal(true);
    sc.setExpandVertical(true);
    sc.setMinSize(c.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    sc.setShowFocusedControl(true);

    shell.setSize(300, 500);
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
  }
  private boolean findEntry() {
    Cursor waitCursor = shell.getDisplay().getSystemCursor(SWT.CURSOR_WAIT);
    shell.setCursor(waitCursor);

    boolean matchCase = searchDialog.getMatchCase();
    boolean matchWord = searchDialog.getMatchWord();
    String searchString = searchDialog.getSearchString();
    int column = searchDialog.getSelectedSearchArea();

    searchString = matchCase ? searchString : searchString.toLowerCase();

    boolean found = false;
    if (searchDialog.getSearchDown()) {
      for (int i = table.getSelectionIndex() + 1; i < table.getItemCount(); i++) {
        if (found = findMatch(searchString, table.getItem(i), column, matchWord, matchCase)) {
          table.setSelection(i);
          break;
        }
      }
    } else {
      for (int i = table.getSelectionIndex() - 1; i > -1; i--) {
        if (found = findMatch(searchString, table.getItem(i), column, matchWord, matchCase)) {
          table.setSelection(i);
          break;
        }
      }
    }

    shell.setCursor(null);

    return found;
  }
  public void readData(final Widget widget) {
    //    HttpServletRequest request = ContextProvider.getRequest();
    //    String parameter = request.getParameter( "JSON" );
    //    if( parameter != null ) {
    //      System.out.println( "#### BEGIN ####");
    //      System.out.println( parameter );
    //      System.out.println( "#### END ####");
    //    }

    Shell shell = (Shell) widget;
    // [if] Preserve the menu bounds before setting the new shell bounds.
    preserveMenuBounds(shell);
    // Important: Order matters, readMode() before readBounds()

    readBounds(shell);
    if (WidgetLCAUtil.wasEventSent(shell, JSConst.EVENT_SHELL_CLOSED)) {
      shell.close();
    }
    processActiveShell(shell);
    processActivate(shell);
    ControlLCAUtil.processMouseEvents(shell);
    ControlLCAUtil.processKeyEvents(shell);
    ControlLCAUtil.processMenuDetect(shell);
    WidgetLCAUtil.processHelp(shell);
  }
Beispiel #6
0
 public static void main(String[] args) {
   Display display = new Display();
   Shell shell = new Shell(display);
   shell.setLayout(new RowLayout());
   Combo combo = new Combo(shell, SWT.NONE);
   combo.setItems(new String[] {"A-1", "B-1", "C-1"});
   Text text = new Text(shell, SWT.SINGLE | SWT.BORDER);
   text.setText("some text");
   combo.addListener(
       SWT.DefaultSelection,
       new Listener() {
         public void handleEvent(Event e) {
           System.out.println(e.widget + " - Default Selection");
         }
       });
   text.addListener(
       SWT.DefaultSelection,
       new Listener() {
         public void handleEvent(Event e) {
           System.out.println(e.widget + " - Default Selection");
         }
       });
   shell.pack();
   shell.open();
   while (!shell.isDisposed()) {
     if (!display.readAndDispatch()) display.sleep();
   }
   display.dispose();
 }
Beispiel #7
0
  private void runSession() {
    while (true) {
      shell = arseGUI.open(display);
      initializeARSE();
      while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) display.sleep();
      }

      if (gameMasterMode) {
        gameMasterSession = new GameMasterSession(display);
        gameMasterSession.open();

        gameMasterMode = false;
      } else if (playerMode) {
        playerLoginGUI = new PlayerLoginGUI();
        playerSession = new PlayerSession(display);
        shell = playerLoginGUI.open(display);
        initializePlayerLoginGUI();
        while (!shell.isDisposed()) {
          if (!display.readAndDispatch()) display.sleep();
        }

        if (playerSession.loggedIn()) {
          playerSession.open();
        }
        playerMode = false;
      } else break;
    }
  }
Beispiel #8
0
  // create a wsman Shell instance; @see https://msdn.microsoft.com/en-us/library/cc251739.aspx
  public String openShell() {
    final boolean noprofile = false; // @TODO@ make param
    final int codepage = 437; // @TODO@ make param

    String messageId = UUID.randomUUID().toString();
    HashMap<String, String> options = new HashMap<>();
    options.put("WINRS_NOPROFILE", noprofile ? "TRUE" : "FALSE");
    options.put("WINRS_CODEPAGE", String.valueOf(codepage));

    prepareRequest(URI_ACTION_CREATE, null, messageId, options);

    // add SOAP body
    Shell shell = new Shell();
    shell.getOutputStreams().add("stdout stderr");
    shell.getInputStreams().add("stdin");
    //        shell.setEnvironment();
    //        shell.setIdleTimeout();
    //        shell.setWorkingDirectory();

    // ws call
    CreateResponseType response = wsmanService.create(shell);

    Shell sh = (Shell) response.getAny();
    return sh.getShellId(); // @TODO@ get shellId (from response)
  }
Beispiel #9
0
  /**
   * This will return an ArrayList of the class Mount. The class mount contains the following
   * property's: device mountPoint type flags
   *
   * <p>These will provide you with any information you need to work with the mount points.
   *
   * @return <code>ArrayList<Mount></code> an ArrayList of the class Mount.
   * @throws Exception if we cannot return the mount points.
   */
  protected static ArrayList<Mount> getMounts() throws Exception {

    final String tempFile = "/data/local/RootToolsMounts";

    // copy /proc/mounts to tempfile. Directly reading it does not work on 4.3
    Shell shell = Shell.startRootShell();
    Toolbox tb = new Toolbox(shell);
    tb.copyFile("/proc/mounts", tempFile, false, false);
    tb.setFilePermissions(tempFile, "777");
    shell.close();

    LineNumberReader lnr = null;
    lnr = new LineNumberReader(new FileReader(tempFile));
    String line;
    ArrayList<Mount> mounts = new ArrayList<Mount>();
    while ((line = lnr.readLine()) != null) {

      Log.d(RootCommands.TAG, line);

      String[] fields = line.split(" ");
      mounts.add(
          new Mount(
              new File(fields[0]), // device
              new File(fields[1]), // mountPoint
              fields[2], // fstype
              fields[3] // flags
              ));
    }
    lnr.close();

    return mounts;
  }
Beispiel #10
0
  public void positionWindow(boolean resetToDefault) {
    String mapWindow;

    mapShellBounds = mapShell.getBounds();
    mapWindow = prefs.get(RadarConsts.PREF_KEY_MAP_WINDOW, "");

    if (mapWindow.equals("") || resetToDefault) {
      Rectangle dispBounds, tableBounds;

      dispBounds = ((Display.getCurrent()).getPrimaryMonitor()).getClientArea();
      tableBounds = display.getShells()[1].getBounds();

      mapShellBounds.width = dispBounds.width - tableBounds.width;
      mapShellBounds.height = dispBounds.height;
      mapShellBounds.x = dispBounds.x + tableBounds.width;
      mapShellBounds.y = dispBounds.y;
    } else {
      String[] tokens = mapWindow.split(",");

      mapShellBounds =
          new Rectangle(
              new Integer(tokens[0]), // X value
              new Integer(tokens[1]), // Y value
              new Integer(tokens[2]), // Width
              new Integer(tokens[3]) // Height
              );
    }
    mapShell.setBounds(mapShellBounds);
  }
Beispiel #11
0
  public void paintReticle(final TableItem item) {
    if (cursor != null) {
      mapShell.removePaintListener(cursor);
    }
    cursor =
        new PaintListener() {
          public void paintControl(PaintEvent pe) {
            int x = 0, y = 0;
            float xF = 0.0F, yF = 0.0F;

            Entity entity = dp.entityList.get(new Integer(item.getText(0)));

            xF = RadarConsts.WINDOW_BUFFER + dp.maxX - entity.posXAxis;
            yF = entity.posYAxis - (dp.minY - RadarConsts.WINDOW_BUFFER);

            x = (int) (xF * boundsXScale);
            y = (int) (yF * boundsYScale);

            pe.gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE));

            pe.gc.drawRectangle(
                x - (RadarConsts.POINT_RADIUS * 2),
                y - (RadarConsts.POINT_RADIUS * 2),
                (RadarConsts.POINT_RADIUS * 4) - 1,
                (RadarConsts.POINT_RADIUS * 4));

            pe.gc.drawLine(
                x - (RadarConsts.POINT_RADIUS * 3), y, x + (RadarConsts.POINT_RADIUS * 3) - 1, y);
            pe.gc.drawLine(
                x, y - (RadarConsts.POINT_RADIUS * 3), x, y + (RadarConsts.POINT_RADIUS * 3) - 1);
          }
        };
    mapShell.addPaintListener(cursor);
    mapShell.redraw();
  }
Beispiel #12
0
 public static void main(String[] args) {
   Display display = new Display();
   Shell shell = new Shell(display);
   shell.setText("Hi there, SWT!"); // Title bar
   shell.open();
   while (!shell.isDisposed()) if (!display.readAndDispatch()) display.sleep();
   display.dispose();
 }
Beispiel #13
0
  private void pullWhatsNew(Composite cWhatsNew) {
    labelLoading = new Label(cWhatsNew, SWT.CENTER);
    labelLoading.setText(MessageText.getString("installPluginsWizard.details.loading"));
    shell.layout(true, true);
    shell.update();

    getWhatsNew(1);
  }
Beispiel #14
0
  public View(Controller controller) {
    this.controller = controller;
    display = new Display();
    shell = new Shell(display);
    shell.setText("Gallant Animation Viewer");

    shell.setLayout(new GridLayout());
  }
Beispiel #15
0
 public static void main(String[] args) {
   Display display = new Display();
   Shell shell = new Shell(display);
   shell.open();
   while (!shell.isDisposed()) {
     if (!display.readAndDispatch()) display.sleep();
   }
   display.dispose();
 }
Beispiel #16
0
 private static String getMode(final Shell shell) {
   String result = null;
   if (shell.getMinimized()) {
     result = "minimized";
   } else if (shell.getMaximized() || shell.getFullScreen()) {
     result = "maximized";
   }
   return result;
 }
Beispiel #17
0
  public void clearMap(boolean performRedraw) {
    Listener[] painters;

    painters = mapShell.getListeners(SWT.Paint);

    for (int i = 0; i < painters.length; i++) mapShell.removeListener(SWT.Paint, painters[i]);

    if (performRedraw) mapShell.redraw();
  }
 public static void main(String[] args) {
   Display display = new Display();
   AddressBook application = new AddressBook();
   Shell shell = application.open(display);
   while (!shell.isDisposed()) {
     if (!display.readAndDispatch()) display.sleep();
   }
   display.dispose();
 }
Beispiel #19
0
 public static void runInUI(@Nullable Shell shell, @NotNull Runnable runnable) {
   final Display display =
       shell == null || shell.isDisposed() ? Display.getDefault() : shell.getDisplay();
   if (display.getThread() != Thread.currentThread()) {
     display.syncExec(runnable);
   } else {
     runnable.run();
   }
 }
Beispiel #20
0
 @Override
 protected String getValue(Shell shell) {
   Interpreter interpreter = shell.getInterpreter();
   if (interpreter == null) {
     return shell.getEnvironment().getValue(INTERPRETER.name);
   } else {
     return interpreter.getName();
   }
 }
Beispiel #21
0
 private static void cd(final String dir) throws IOException {
   File newUserDir = new File(dir);
   if (!newUserDir.isAbsolute()) {
     newUserDir = new File(Shell.getUserDir().getAbsoluteFile().toPath().resolve(dir).toString());
   }
   if (!newUserDir.isDirectory()) {
     throw new IOException(dir + " directory doesn't exist");
   }
   Shell.setUserDir(newUserDir);
 }
Beispiel #22
0
  /** Initialize all ui elements, and then display the window */
  public void Initialize() {
    initMenu();
    initToolbar();
    initCanvas();
    shell.open();

    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
  }
Beispiel #23
0
 public void execute(String cmd) {
   // System.out.println("exec '" + cmd + "'");
   scroll.append(cmd);
   if (!cmd.endsWith("\n")) scroll.append("\n");
   shell.processSource(shell.getContext(), cmd.trim());
   Object console = app.find(myUi, "console");
   app.requestFocus(console);
   app.setInteger(console, "start", scroll.length());
   app.setInteger(console, "end", scroll.length());
 }
Beispiel #24
0
  public void testQuoteWorkingDirectoryAndExecutable_WDPathWithSingleQuotes_BackslashFileSep() {
    Shell sh = newShell();

    sh.setWorkingDirectory("\\usr\\local\\'something else'");
    sh.setExecutable("chmod");

    String executable = StringUtils.join(sh.getShellCommandLine(new String[] {}).iterator(), " ");

    assertEquals("/bin/sh -c cd \"\\usr\\local\\\'something else\'\" && chmod", executable);
  }
Beispiel #25
0
  public void testQuoteWorkingDirectoryAndExecutable() {
    Shell sh = newShell();

    sh.setWorkingDirectory("/usr/local/bin");
    sh.setExecutable("chmod");

    String executable = StringUtils.join(sh.getShellCommandLine(new String[] {}).iterator(), " ");

    assertEquals("/bin/sh -c cd /usr/local/bin && chmod", executable);
  }
  public Shell open(Display display) {
    shell = new Shell(display);
    shell.setLayout(new FillLayout());
    shell.addShellListener(
        new ShellAdapter() {
          @Override
          public void shellClosed(ShellEvent e) {
            e.doit = closeAddressBook();
          }
        });

    createMenuBar();

    searchDialog = new SearchDialog(shell);
    searchDialog.setSearchAreaNames(columnNames);
    searchDialog.setSearchAreaLabel(resAddressBook.getString("Column"));
    searchDialog.addFindListener(
        new FindListener() {
          public boolean find() {
            return findEntry();
          }
        });

    table = new Table(shell, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION);
    table.setHeaderVisible(true);
    table.setMenu(createPopUpMenu());
    table.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetDefaultSelected(SelectionEvent e) {
            TableItem[] items = table.getSelection();
            if (items.length > 0) editEntry(items[0]);
          }
        });
    for (int i = 0; i < columnNames.length; i++) {
      TableColumn column = new TableColumn(table, SWT.NONE);
      column.setText(columnNames[i]);
      column.setWidth(150);
      final int columnIndex = i;
      column.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              sort(columnIndex);
            }
          });
    }

    newAddressBook();

    shell.setSize(table.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, 300);
    shell.open();
    return shell;
  }
Beispiel #27
0
 /** Open the window. */
 public void open() {
   Display display = Display.getDefault();
   createContents();
   shlUCEditor.open();
   shlUCEditor.layout();
   while (!shlUCEditor.isDisposed()) {
     if (!display.readAndDispatch()) {
       display.sleep();
     }
   }
 }
Beispiel #28
0
 private static void writeOpen(final Shell shell) throws IOException {
   // TODO [rst] workaround: qx window should be opened only once.
   Boolean defValue = Boolean.FALSE;
   Boolean actValue = Boolean.valueOf(shell.getVisible());
   if (WidgetLCAUtil.hasChanged(shell, Props.VISIBLE, actValue, defValue) && shell.getVisible()) {
     //      JSWriter writer = JSWriter.getWriterFor( shell );
     //      writer.call( "open", null );
     IWidgetSynchronizer synchronizer = WidgetSynchronizerFactory.getSynchronizerForWidget(shell);
     synchronizer.call("open");
   }
 }
 @Override
 public void setToolTipText(String string) {
   checkWidget();
   super.setToolTipText(string);
   Shell shell = _getShell();
   ToolItem[] items = getItems();
   for (int i = 0; i < items.length; i++) {
     String newString = string != null ? null : items[i].toolTipText;
     shell.setToolTipText(items[i].handle, newString);
   }
 }
Beispiel #30
0
  /** Create contents of the window. */
  protected void createContents() {
    shlUCEditor = new Shell();
    shlUCEditor.setSize(722, 530);
    shlUCEditor.setText("µC Editor");
    shlUCEditor.setLayout(new GridLayout(1, false));

    Label lblAddElements = new Label(shlUCEditor, SWT.CENTER);
    lblAddElements.setFont(SWTResourceManager.getFont("Lucida Grande", 20, SWT.NORMAL));
    lblAddElements.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1));
    lblAddElements.setText("Microcontroller Editor");

    table = new Table(shlUCEditor, SWT.BORDER | SWT.FULL_SELECTION);
    table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    table.setHeaderVisible(true);
    table.setLinesVisible(true);

    TableColumn tblclmnType = new TableColumn(table, SWT.CENTER);
    tblclmnType.setWidth(123);
    tblclmnType.setText("Type");
    // Set not editable
    //		tblclmnType.setData(new UCEditorColumnData(false));

    TableColumn tblclmnName = new TableColumn(table, SWT.CENTER);
    tblclmnName.setWidth(193);
    tblclmnName.setText("Name");

    TableColumn tblclmnId = new TableColumn(table, SWT.CENTER);
    tblclmnId.setWidth(184);
    tblclmnId.setText("Port");

    // Allow the table to be edited
    //		table.addListener(SWT.MouseDoubleClick, new ElementsDoubleClickListener(this, table));

    Label label = new Label(shlUCEditor, SWT.SEPARATOR | SWT.HORIZONTAL);
    label.setAlignment(SWT.CENTER);
    label.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1));

    Label lblDoubleClickTo = new Label(shlUCEditor, SWT.NONE);
    lblDoubleClickTo.setText("Double click a microcontroller to make changes. ");

    Composite composite = new Composite(shlUCEditor, SWT.NONE);
    composite.setLayout(new GridLayout(1, false));

    Button btnNewButton = new Button(composite, SWT.NONE);
    btnNewButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent arg0) {
            addController();
          }
        });
    btnNewButton.setBounds(0, 0, 94, 28);
    btnNewButton.setText("Add Local Arduino");
  }