Exemplo n.º 1
0
 public org.eclipse.swt.widgets.Shell open(org.eclipse.swt.widgets.Display display) {
   createShell(display);
   createMenuBar();
   createStyledText();
   shell.setSize(500, 400);
   shell.open();
   return shell;
 }
Exemplo n.º 2
0
 private void setHoverLocation(
     org.eclipse.swt.widgets.Shell shell, org.eclipse.swt.graphics.Point position) {
   org.eclipse.swt.graphics.Rectangle displayBounds = shell.getDisplay().getBounds();
   org.eclipse.swt.graphics.Rectangle shellBounds = shell.getBounds();
   shellBounds.x = Math.max(Math.min(position.x, displayBounds.width - shellBounds.width), 0);
   shellBounds.y =
       Math.max(Math.min(position.y + 16, displayBounds.height - shellBounds.height), 0);
   shell.setBounds(shellBounds);
 }
Exemplo n.º 3
0
 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.examples.hoverhelp.HoverHelp()).open(display);
   while (shell != null && !shell.isDisposed()) {
     if (!display.readAndDispatch()) {
       display.sleep();
     }
   }
   display.dispose();
 }
Exemplo n.º 4
0
 public static void main(java.lang.String[] args) {
   org.eclipse.swt.widgets.Display display = new org.eclipse.swt.widgets.Display();
   org.eclipse.swt.examples.javaviewer.JavaViewer example =
       new org.eclipse.swt.examples.javaviewer.JavaViewer();
   org.eclipse.swt.widgets.Shell shell = example.open(display);
   while (!shell.isDisposed()) {
     if (!display.readAndDispatch()) {
       display.sleep();
     }
   }
   display.dispose();
 }
Exemplo n.º 5
0
 private static void setShellSize(
     org.eclipse.swt.widgets.Display display, org.eclipse.swt.widgets.Shell shell) {
   org.eclipse.swt.graphics.Rectangle bounds = display.getBounds();
   org.eclipse.swt.graphics.Point size = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT);
   if (size.x > bounds.width) {
     size.x = bounds.width * 9 / 10;
   }
   if (size.y > bounds.height) {
     size.y = bounds.height * 9 / 10;
   }
   shell.setSize(size);
 }
Exemplo n.º 6
0
 void createShell(org.eclipse.swt.widgets.Display display) {
   shell = new org.eclipse.swt.widgets.Shell(display);
   shell.setText(resources.getString("Window_title"));
   org.eclipse.swt.layout.GridLayout layout = new org.eclipse.swt.layout.GridLayout();
   layout.numColumns = 1;
   shell.setLayout(layout);
   shell.addShellListener(
       new org.eclipse.swt.events.ShellAdapter() {
         public void shellClosed(org.eclipse.swt.events.ShellEvent e) {
           lineStyler.disposeColors();
           text.removeLineStyleListener(lineStyler);
         }
       });
 }
Exemplo n.º 7
0
 void createMenuBar() {
   org.eclipse.swt.widgets.Menu bar = new org.eclipse.swt.widgets.Menu(shell, SWT.BAR);
   shell.setMenuBar(bar);
   org.eclipse.swt.widgets.MenuItem fileItem =
       new org.eclipse.swt.widgets.MenuItem(bar, SWT.CASCADE);
   fileItem.setText(resources.getString("File_menuitem"));
   fileItem.setMenu(createFileMenu());
 }
Exemplo n.º 8
0
 public org.eclipse.swt.widgets.Shell open(org.eclipse.swt.widgets.Display display) {
   java.lang.Class clazz = org.eclipse.swt.examples.hoverhelp.HoverHelp.class;
   try {
     if (images == null) {
       images = new org.eclipse.swt.graphics.Image[imageLocations.length];
       for (int i = 0; i < imageLocations.length; ++i) {
         java.io.InputStream stream = clazz.getResourceAsStream(imageLocations[i]);
         org.eclipse.swt.graphics.ImageData source =
             new org.eclipse.swt.graphics.ImageData(stream);
         org.eclipse.swt.graphics.ImageData mask = source.getTransparencyMask();
         images[i] = new org.eclipse.swt.graphics.Image(display, source, mask);
         try {
           stream.close();
         } catch (java.io.IOException e) {
           e.printStackTrace();
         }
       }
     }
   } catch (java.lang.Exception ex) {
     System.err.println(
         getResourceString(
             "error.CouldNotLoadResources", new java.lang.Object[] {ex.getMessage()}));
     return null;
   }
   org.eclipse.swt.widgets.Shell shell = new org.eclipse.swt.widgets.Shell();
   createPartControl(shell);
   shell.addDisposeListener(
       new org.eclipse.swt.events.DisposeListener() {
         public void widgetDisposed(org.eclipse.swt.events.DisposeEvent e) {
           if (images != null) {
             for (int i = 0; i < images.length; i++) {
               final org.eclipse.swt.graphics.Image image = images[i];
               if (image != null) {
                 image.dispose();
               }
             }
             images = null;
           }
         }
       });
   shell.pack();
   shell.open();
   return shell;
 }
Exemplo n.º 9
0
 public ToolTipHandler(org.eclipse.swt.widgets.Shell parent) {
   final org.eclipse.swt.widgets.Display display = parent.getDisplay();
   this.parentShell = parent;
   tipShell = new org.eclipse.swt.widgets.Shell(parent, SWT.ON_TOP | SWT.TOOL);
   org.eclipse.swt.layout.GridLayout gridLayout = new org.eclipse.swt.layout.GridLayout();
   gridLayout.numColumns = 2;
   gridLayout.marginWidth = 2;
   gridLayout.marginHeight = 2;
   tipShell.setLayout(gridLayout);
   tipShell.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
   tipLabelImage = new org.eclipse.swt.widgets.Label(tipShell, SWT.NONE);
   tipLabelImage.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND));
   tipLabelImage.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
   tipLabelImage.setLayoutData(
       new org.eclipse.swt.layout.GridData(
           GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER));
   tipLabelText = new org.eclipse.swt.widgets.Label(tipShell, SWT.NONE);
   tipLabelText.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND));
   tipLabelText.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
   tipLabelText.setLayoutData(
       new org.eclipse.swt.layout.GridData(
           (-(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER))));
 }
Exemplo n.º 10
0
 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.setText(getResourceString("window.title"));
   shell.setLayout(new org.eclipse.swt.layout.GridLayout());
   org.eclipse.swt.examples.paint.PaintExample instance =
       new org.eclipse.swt.examples.paint.PaintExample(shell);
   instance.createToolBar(shell);
   org.eclipse.swt.widgets.Composite composite =
       new org.eclipse.swt.widgets.Composite(shell, SWT.NONE);
   composite.setLayout(new org.eclipse.swt.layout.FillLayout());
   composite.setLayoutData(new org.eclipse.swt.layout.GridData(SWT.FILL, SWT.FILL, true, true));
   instance.createGUI(composite);
   instance.setDefaults();
   setShellSize(display, shell);
   shell.open();
   while (!shell.isDisposed()) {
     if (!display.readAndDispatch()) {
       display.sleep();
     }
   }
   instance.dispose();
 }
Exemplo n.º 11
0
 org.eclipse.swt.widgets.Menu createFileMenu() {
   org.eclipse.swt.widgets.Menu bar = shell.getMenuBar();
   org.eclipse.swt.widgets.Menu menu = new org.eclipse.swt.widgets.Menu(bar);
   org.eclipse.swt.widgets.MenuItem item;
   item = new org.eclipse.swt.widgets.MenuItem(menu, SWT.PUSH);
   item.setText(resources.getString("Open_menuitem"));
   item.setAccelerator(SWT.MOD1 + 'O');
   item.addSelectionListener(
       new org.eclipse.swt.events.SelectionAdapter() {
         public void widgetSelected(org.eclipse.swt.events.SelectionEvent event) {
           openFile();
         }
       });
   item = new org.eclipse.swt.widgets.MenuItem(menu, SWT.PUSH);
   item.setText(resources.getString("Exit_menuitem"));
   item.addSelectionListener(
       new org.eclipse.swt.events.SelectionAdapter() {
         public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
           menuFileExit();
         }
       });
   return menu;
 }
Exemplo n.º 12
0
 void menuFileExit() {
   shell.close();
 }