public static void main(String[] args) {

    //	if (args.length == 0) {
    //		System.out.println("Usage: java Main <program id>");
    //		return;
    //	}
    //
    //	String progID = args[0];

    String progID = "WMPlayer.OCX";
    //	String progID = "RealPlayX.OCX";

    Display display = new Display();
    Shell shell = new Shell(display);

    OleFrame frame = new OleFrame(shell, SWT.NONE);
    OleControlSite site = null;
    OleAutomation auto = null;
    try {
      site = new OleControlSite(frame, SWT.NONE, progID);
      auto = new OleAutomation(site);
    } catch (SWTException ex) {
      System.out.println("Unable to open type library for " + progID);
      display.dispose();
      return;
    }

    printTypeInfo(auto);

    auto.dispose();
    shell.dispose();
    display.dispose();
  }
  public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new GridLayout(2, true));

    final Browser browser;
    try {
      browser = new Browser(shell, SWT.NONE);
    } catch (SWTError e) {
      System.out.println("Could not instantiate Browser: " + e.getMessage());
      display.dispose();
      return;
    }
    GridData data = new GridData(GridData.FILL_BOTH);
    data.horizontalSpan = 2;
    browser.setLayoutData(data);

    Button headersButton = new Button(shell, SWT.PUSH);
    headersButton.setText("Send custom headers");
    data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    headersButton.setLayoutData(data);
    headersButton.addListener(
        SWT.Selection,
        event ->
            browser.setUrl(
                "http://www.ericgiguere.com/tools/http-header-viewer.html",
                null,
                new String[] {"User-agent: SWT Browser", "Custom-header: this is just a demo"}));
    Button postDataButton = new Button(shell, SWT.PUSH);
    postDataButton.setText("Send post data");
    data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    postDataButton.setLayoutData(data);
    postDataButton.addListener(
        SWT.Selection,
        event ->
            browser.setUrl(
                "https://bugs.eclipse.org/bugs/buglist.cgi",
                "emailassigned_to1=1&bug_severity=enhancement&bug_status=NEW&email1=platform-swt-inbox&emailtype1=substring",
                null));

    shell.setBounds(10, 10, 600, 600);
    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, SWT.DIALOG_TRIM | SWT.RESIZE);
    shell.setLayout(new FillLayout());

    SwtMetawidget metawidget = new SwtMetawidget(shell, SWT.NONE);
    metawidget.setMetawidgetLayout(
        new SeparatorLayoutDecorator(
            new SeparatorLayoutDecoratorConfig()
                .setLayout(
                    new TabFolderLayoutDecorator(
                        new TabFolderLayoutDecoratorConfig().setLayout(new GridLayout())))));
    metawidget.setToInspect(new Baz());

    shell.setVisible(true);
    shell.open();

    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }

    display.dispose();
  }
  public void dispose() {
    shell.dispose();
    if (trayItem != null) {
      trayItem.dispose();
      trayItem = null;
    }

    if (image != null) {
      image.dispose();
    }
    if (image2 != null) {
      image2.dispose();
    }
    try {
      if (!display.isDisposed()) {
        display.dispose();
      }
    } catch (Exception e) {
      // already disposed
    }
    // dispose AWT frames
    if (settingsFrame != null) {
      settingsFrame.dispose();
    }
    if (aboutFrame != null) {
      aboutFrame.dispose();
    }
    if (logBrokerMonitor != null) {
      logBrokerMonitor.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();
  }
Exemple #6
0
  public static void main(String[] args) {
    LoggerContext loggerContext = new LoggerContext();
    Display display = new Display();
    ResourceUtil.init(display);
    Shell shell = new Shell(display);
    final Tree tree = new Tree(shell, SWT.BORDER);
    Rectangle clientArea = shell.getClientArea();
    tree.setBounds(clientArea.x, clientArea.y, 200, 200);

    LoggerTree loggerTree = new LoggerTree(loggerContext, tree);
    tree.setMenu(TreeMenuBuilder.buildTreeMenu(loggerTree, null));
    loggerTree.update("com.foo.Bar");
    loggerTree.update("com.foo.Bar");

    loggerContext.getLogger("org.apache.struts").setLevel(Level.ERROR);

    loggerTree.update("org.apache.struts.BlahAction");

    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
  }
 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.setText("StyledText with underline and strike through");
   shell.setLayout(new FillLayout());
   StyledText text = new StyledText(shell, SWT.BORDER);
   text.setText("0123456789 ABCDEFGHIJKLM NOPQRSTUVWXYZ");
   // make 0123456789 appear underlined
   StyleRange style1 = new StyleRange();
   style1.start = 0;
   style1.length = 10;
   style1.underline = true;
   text.setStyleRange(style1);
   // make ABCDEFGHIJKLM have a strike through
   StyleRange style2 = new StyleRange();
   style2.start = 11;
   style2.length = 13;
   style2.strikeout = true;
   text.setStyleRange(style2);
   // make NOPQRSTUVWXYZ appear underlined and have a strike through
   StyleRange style3 = new StyleRange();
   style3.start = 25;
   style3.length = 13;
   style3.underline = true;
   style3.strikeout = true;
   text.setStyleRange(style3);
   shell.pack();
   shell.open();
   while (!shell.isDisposed()) {
     if (!display.readAndDispatch()) display.sleep();
   }
   display.dispose();
 }
Exemple #9
0
 @Override
 public void run() {
   // use my class for library loading
   try {
     Display display = Display.getDefault();
     final Shell splash = createSplash(display);
     final Shell content = new Shell(display);
     splash.open();
     display.asyncExec(
         new Runnable() {
           @Override
           public void run() {
             runContent(content);
             content.open();
             splash.close();
           }
         });
     while (!splash.isDisposed() || !content.isDisposed()) {
       if (!display.readAndDispatch()) display.sleep();
     }
     if (sandbox != null) sandbox.shutdown();
     display.dispose();
   } catch (Throwable e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   } finally {
     System.err.flush();
     System.out.flush();
     System.exit(0);
   }
 }
  /** @param args */
  public static void main(String[] args) throws Exception {
    // TODO Auto-generated method stub
    /* Before this is run, be sure to set up the launch configuration (Arguments->VM Arguments)
     * for the correct SWT library path in order to run with the SWT dlls.
     * The dlls are located in the SWT plugin jar.
     * For example, on Windows the Eclipse SWT 3.1 plugin jar is:
     *       installation_directory\plugins\org.eclipse.swt.win32_3.1.0.jar
     */
    Display display = Display.getDefault();
    ActiveHostsFileWindow thisClass = new ActiveHostsFileWindow();
    thisClass.createSShell();
    thisClass.sShell.open();

    /*
     * Loads active hosts file
     */
    File activeHostsFile = getActiveHostsFile();
    thisClass.highlightActiveHostsFile(activeHostsFile);
    thisClass.label.setText("Current hosts file (located at " + activeHostsFile.getPath() + ")");

    HostsFile hf = thisClass.loadHostsFile(activeHostsFile);

    System.out.println("Lines: " + hf.getHostsFileLines().size());

    HostsFileDAO hfDAO = new HostsFileSerializationDAO();
    hfDAO.save(hf);

    while (!thisClass.sShell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
  }
Exemple #11
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();
 }
  /** Debug only */
  private static void drawModel(final SWTArranger a) {
    final Display d = new Display();
    Shell s = new Shell(d);
    s.setSize(500, 500);

    s.setLayout(new FillLayout());

    Canvas canvas = new Canvas(s, SWT.NONE);
    canvas.setSize(500, 500);
    canvas.setLocation(20, 20);
    canvas.addPaintListener(
        new PaintListener() {

          @Override
          public void paintControl(PaintEvent e) {
            Color c = new Color(d, 0x00, 0x00, 0x00);
            GC gc = e.gc;
            gc.setBackground(c);
            for (Block r : a.blocks) {
              gc.fillRectangle(r.x, r.y, r.width, r.height);
            }
            c.dispose();
            gc.dispose();
          }
        });
    s.pack();
    s.open();

    while (!s.isDisposed()) {
      if (!d.readAndDispatch()) {
        d.sleep();
      }
    }
    d.dispose();
  }
 public Object run(Object args) throws Exception {
   this.setArguments((String[]) args);
   testableObject = PlatformUI.getTestableObject();
   testableObject.setTestHarness(this);
   Display display = PlatformUI.createDisplay();
   try {
     // delete generated JavaProjects in Eclipse Run Configuration Directory
     String[] cmdArray = new String[3];
     cmdArray[0] = "rm";
     cmdArray[1] = "-rf";
     cmdArray[2] = "/media/jefferson/Expansion Drive/runtime-ferramentaLPS.MainRunner";
     Runtime rt = Runtime.getRuntime();
     Process proc = rt.exec(cmdArray);
     System.out.println("SPL Refactoring Checker");
     PlatformUI.createAndRunWorkbench(display, new NullAdvisor());
     AppWindow refinementChecker = new AppWindow("Software Product Line Refinement Checker");
     refinementChecker.open();
     Shell shell = refinementChecker.getShell();
     while (!shell.isDisposed()) {
       if (!display.readAndDispatch()) display.sleep();
     }
     return EXIT_OK;
   } finally {
     display.dispose();
   }
 }
 @After
 public void tearDown() throws Exception {
   composite.dispose();
   if (createdDisplay) {
     display.dispose();
   }
 }
  public static void main(final String[] args) {
    Display display = new Display();
    shell = new Shell(display);
    shell.setText("StackOverflow");
    shell.setLayout(new GridLayout(1, false));

    // createToolbar();
    scform = new ScrolledForm(shell);
    scform.setLayout(new GridLayout(1, false));
    scform.getBody().setLayout(new GridLayout(1, false));
    scform.setExpandHorizontal(true);
    scform.setExpandVertical(true);

    SashForm form = new SashForm(scform.getBody(), SWT.VERTICAL);
    form.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    createTablePart(form);
    createMessagesPart(form);
    form.setWeights(new int[] {3, 1});

    shell.pack();
    shell.open();
    // shell.setSize(600, 450);
    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 RowLayout());
   Text text = new Text(shell, SWT.MULTI | SWT.BORDER);
   String modifier = SWT.MOD1 == SWT.CTRL ? "Ctrl" : "Command";
   text.setText("Hit " + modifier + "+Return\nto see\nthe default button\nrun");
   text.addTraverseListener(
       e -> {
         switch (e.detail) {
           case SWT.TRAVERSE_RETURN:
             if ((e.stateMask & SWT.MOD1) != 0) e.doit = true;
         }
       });
   Button button = new Button(shell, SWT.PUSH);
   button.pack();
   button.setText("OK");
   button.addSelectionListener(
       new SelectionAdapter() {
         @Override
         public void widgetSelected(SelectionEvent e) {
           System.out.println("OK selected");
         }
       });
   shell.setDefaultButton(button);
   shell.pack();
   shell.open();
   while (!shell.isDisposed()) {
     if (!display.readAndDispatch()) display.sleep();
   }
   display.dispose();
 }
Exemple #17
0
  public static void view(DrawModel d) {
    final Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());

    Composite composite = new Composite(shell, SWT.EMBEDDED | SWT.NO_BACKGROUND);
    Frame baseFrame = SWT_AWT.new_Frame(composite);

    baseFrame.setBounds(0, 0, 800, 600);

    Java3DViewer viewer = new Java3DViewer(baseFrame, d);
    baseFrame.add(viewer);

    shell.open();

    d.setFaceColor(Color.GREEN);
    d.circle(0.9);
    //		viewer.draw(d);

    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }

    baseFrame.dispose();
    shell.dispose();
    composite.dispose();
    display.dispose();
    System.exit(0);
  }
  public static void main(String[] args) {
    final Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setText("SWT and Swing DND Example");
    GridLayout layout = new GridLayout(1, false);
    shell.setLayout(layout);

    Text swtText = new Text(shell, SWT.BORDER);
    swtText.setText("SWT Text");
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    swtText.setLayoutData(data);
    setDragDrop(swtText);

    Composite comp = new Composite(shell, SWT.EMBEDDED);
    java.awt.Frame frame = SWT_AWT.new_Frame(comp);
    JTextField swingText = new JTextField(40);
    swingText.setText("Swing Text");
    swingText.setDragEnabled(true);
    frame.add(swingText);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = swingText.getPreferredSize().height;
    comp.setLayoutData(data);

    shell.setSize(400, 200);
    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();
  }
  /** @param args */
  public static void main(String[] args) {
    Display display = new Display();
    JFaceResources.getImageRegistry()
        .put(
            "IMG_1",
            ImageDescriptor.createFromURL(
                Snippet033CellEditorPerRowPre33.class
                    .getClassLoader()
                    .getResource("org/eclipse/jface/snippets/dialogs/cancel.png")));
    JFaceResources.getImageRegistry()
        .put(
            "IMG_2",
            ImageDescriptor.createFromURL(
                Snippet033CellEditorPerRowPre33.class
                    .getClassLoader()
                    .getResource("org/eclipse/jface/snippets/dialogs/filesave.png")));
    Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());
    new Snippet033CellEditorPerRowPre33(shell);
    shell.open();

    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }

    display.dispose();
  }
 public static void main(java.lang.String[] args) {
   org.eclipse.swt.widgets.Display display = new org.eclipse.swt.widgets.Display();
   org.eclipse.swt.widgets.Shell shell = new org.eclipse.swt.widgets.Shell(display);
   shell.setLayout(new org.eclipse.swt.layout.FillLayout());
   shell.setText(getResourceString("window.title"));
   java.io.InputStream stream =
       (org.eclipse.swt.examples.browserexample.BrowserExample.class)
           .getResourceAsStream(iconLocation);
   org.eclipse.swt.graphics.Image icon = new org.eclipse.swt.graphics.Image(display, stream);
   shell.setImage(icon);
   try {
     stream.close();
   } catch (java.io.IOException e) {
     e.printStackTrace();
   }
   org.eclipse.swt.examples.browserexample.BrowserExample app =
       new org.eclipse.swt.examples.browserexample.BrowserExample(shell, true);
   app.setShellDecoration(icon, true);
   shell.open();
   while (!shell.isDisposed()) {
     if (!display.readAndDispatch()) {
       display.sleep();
     }
   }
   icon.dispose();
   app.dispose();
   display.dispose();
 }
Exemple #22
0
  public Main(String args[]) {
    //   must be before display is created (on Macs at least)
    Display.setAppName("BrailleZephyr");

    Display display = Display.getDefault();

    //   needed to catch Quit (Command-Q) on Macs
    display.addListener(SWT.Close, new CloseHandler());

    shell = new Shell(display);
    shell.setLayout(new FillLayout());
    shell.setText("BrailleZephyr");
    shell.addShellListener(new ShellHandler());

    bzStyledText = new BZStyledText(shell);
    bzFile = new BZFile(bzStyledText);
    bzSettings = new BZSettings(bzStyledText);
    new BZMenu(bzStyledText, bzFile, bzSettings);

    //   assume any argument is a file to open
    if (args.length > 0) bzFile.openFile(args[0]);

    shell.open();
    while (!shell.isDisposed()) if (!display.readAndDispatch()) display.sleep();

    display.dispose();
  }
  /**
   * Launch the application
   *
   * @param args
   */
  public static void main(String args[]) {
    Display display = Display.getDefault();
    IETest shell = new IETest(display);
    shell.setMaximized(true);
    shell.setLayout(new FillLayout());
    Menu bar = new Menu(shell, SWT.BAR);
    shell.setMenuBar(bar);

    OleFrame frame = new OleFrame(shell, SWT.NONE);
    OleControlSite clientsite = null;
    OleAutomation browser = null;
    try {

      clientsite = new OleControlSite(frame, SWT.NONE, "Shell.Explorer");
      browser = new OleAutomation(clientsite);
      clientsite.doVerb(OLE.OLEIVERB_INPLACEACTIVATE);
      shell.open();
      int[] browserIDs = browser.getIDsOfNames(new String[] {"Navigate", "URL"});
      Variant[] address = new Variant[] {new Variant("http://blog.csdn.net/bovy")};
      browser.invoke(browserIDs[0], address, new int[] {browserIDs[1]});
    } catch (Exception ex) {
      System.out.println("Failed to create IE! " + ex.getMessage());
      return;
    }
    while (shell != null && !shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
    browser.dispose();
    display.dispose();
  }
  public static void main(final String[] args) {
    final Display display = Display.getDefault();
    final Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());

    final CompositeTable table = new CompositeTable(shell, SWT.NONE);
    new Header(table, SWT.NONE);
    new Row(table, SWT.NONE);
    table.setRunTime(true);

    final ICompositeTableRidget ridget =
        (ICompositeTableRidget) SwtRidgetFactory.createRidget(table);
    final WritableList input = new WritableList(PersonFactory.createPersonList(), Person.class);
    ridget.bindToModel(input, Person.class, RowRidget.class);
    ridget.updateFromModel();

    shell.setSize(400, 160);
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }

    display.dispose();
  }
Exemple #25
0
  public Object start(IApplicationContext context) {

    // create and register a backend server
    // TODO: this info should be saved, not hard coded.
    try {
      context.applicationRunning(); // only run one
      //			MonitorServerManager.getInstance().getServers().get("");
      MonitorServer server = new MonitorServer("admin", "", "admin");
      MonitorServerManager.getInstance().registerServer(server);
      if (!login(server)) return IApplication.EXIT_OK;
      //			MonitorServerManager.getInstance().getCurServer().connectAndLogin();
      //			server.connectAndLogin();

    } catch (RemoteException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (NotBoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    Display display = PlatformUI.createDisplay();
    try {
      int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor());

      if (returnCode == PlatformUI.RETURN_RESTART) {
        return IApplication.EXIT_RESTART;
      }
      return IApplication.EXIT_OK;
    } finally {
      display.dispose();
    }
  }
Exemple #26
0
  /*
   * (non-Javadoc)
   *
   * @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.
   * IApplicationContext)
   */
  @Override
  public Object start(IApplicationContext context) throws Exception {

    while (initApp() == false) {
      ConfigUtil config = ConfigUtil.getInstance();
      ConfigDialog configDialog = new ConfigDialog(shell, config);
      if (configDialog.open() == Window.CANCEL) {
        return EXIT_OK;
      }
    }

    // Setup login context
    String configName = Activator.getConfigurationName();
    URL configUrl = Activator.getContext().getBundle().getEntry(JAAS_CONFIG_FILE);
    loginContext = LoginContextFactory.createContext(configName, configUrl);

    Integer result = null;
    final Display display = PlatformUI.createDisplay();
    try {

      // Run app in secure context
      result = (Integer) Subject.doAs(loginContext.getSubject(), getRunAction(display));
    } finally {
      display.dispose();
      loginContext.logout();
    }
    // TBD handle javax.security.auth.login.LoginException

    if (result != null && PlatformUI.RETURN_RESTART == result.intValue()) return EXIT_RESTART;
    return EXIT_OK;
  }
  /** ********************* CONSTRUCTOR **************************** */
  public RyanairInspector2GUI() {

    bufferNavegadores = new Buffer(new CircularQueue(SIZE));
    for (Navegador n : navegadores) {
      bufferNavegadores.Put(n);
    }

    bufferVuelos = new Buffer(new CircularQueue(SIZE));
    System.out.println(rutaActual);
    System.out.println("-- Empieza lectura fichero --");
    vuelos = UtilsIO.leerFicheroDatosConsultaVuelos(rutaActual + nomFichConsultas);
    for (Vuelo v : vuelos) {
      bufferVuelos.Put(v);
      System.out.println(v.toString());
    }
    System.out.println("-- Termina lectura fichero --");

    /*__ CREAMOS UNA INSTANCIA PARA CAPTURAR UN VUELO */
    unvueloRyanair = new RyanairInspector2();

    creaContenidos();

    // Iniciamos la carga de la pagina
    iniciaCaptura(table);

    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
    // System.out.println("despues de dispose");

  }
Exemple #28
0
  public static void main(String[] args) {
    final Display d = new Display();
    final IStylingEngine styleingEngine = null;
    Realm.runWithDefault(
        SWTObservables.getRealm(d),
        new Runnable() {
          public void run() {
            Shell shell = new Shell(d);
            shell.setLayout(new FillLayout());
            MailView view = new MailView(shell, null);
            IFolder folder =
                ((IAccount)
                        new MailSessionFactoryImpl()
                            .openSession("", "john", "doe")
                            .getAccounts()
                            .get(0))
                    .getFolders()
                    .get(0);
            view.setMail(folder.getSession().getMails(folder, 0, 1).get(0));
            shell.open();

            while (!shell.isDisposed()) {
              if (!d.readAndDispatch()) {
                d.sleep();
              }
            }
          }
        });

    d.dispose();
  }
Exemple #29
0
  private void open() {

    display = Display.getDefault();

    shell = new Shell();

    shell.setSize(250, 170);

    // ---------创建窗口中的其他界面组件-------------

    shell.setLayout(new GridLayout());

    createMainComp(shell); // 创建主面板

    createStatusbar(shell); // 创建工具栏
    // -----------------END------------------------

    shell.layout();

    shell.open();

    while (!shell.isDisposed()) {

      if (!display.readAndDispatch()) display.sleep();
    }

    display.dispose();
  }
  public static void main(final String[] args) {
    final Display display = Display.getDefault();
    final Shell shell = new Shell(display);
    shell.setText(SnippetMasterDetailsRidget003.class.getSimpleName());
    shell.setLayout(new FillLayout());

    final PersonMasterDetails details = new PersonMasterDetails(shell, SWT.NONE);

    final IMasterDetailsRidget ridget =
        (IMasterDetailsRidget) SwtRidgetFactory.createRidget(details);
    ridget.setDelegate(new PersonDelegate());
    final WritableList input = new WritableList(PersonFactory.createPersonList(), Person.class);
    final String[] properties = {Person.PROPERTY_LASTNAME, Person.PROPERTY_FIRSTNAME};
    final String[] headers = {"Last Name", "First Name"}; // $NON-NLS-1$ //$NON-NLS-2$
    ridget.bindToModel(input, Person.class, properties, headers);
    ridget.updateFromModel();

    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }

    display.dispose();
  }