Examples of Display


Examples of org.eclipse.swt.widgets.Display

    this.direction = direction;

    if (shell == null || shell.isDisposed())
      return;

    Display display = shell.getDisplay();
    display.syncExec(new Runnable() {
      public void run() {
        if (shell.isDisposed())
          return;

        switch (ShellSlider.this.direction) {
View Full Code Here

Examples of org.eclipse.swt.widgets.Display

     
        skin = (SWTSkin)JMuleUIManager.getJMuleUI().getSkin();
   
    }catch(Throwable t) {}
   
    Display display = SWTThread.getDisplay();
   
    final Shell shell1=new Shell(display,SWT.ON_TOP);
    shell=new Shell(shell1,SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
   
    shell.setText(_._("advancedsearchwindow.title"));
View Full Code Here

Examples of org.eclipse.swt.widgets.Display

    try {
        skin = (SWTSkin) JMuleUIManager.getJMuleUI().getSkin();
    }catch(Throwable t) {}
   
   
    Display display = SWTThread.getDisplay();
    final Shell shell1=new Shell(display,SWT.ON_TOP);
    shell=new Shell(shell1,SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.RESIZE);
   
    shell.setText(Localizer._("downloadinfowindow.title"));
    shell.setImage(SWTImageRepository.getImage("info.png"));
View Full Code Here

Examples of org.eclipse.swt.widgets.Display

  public void initUIComponents() {
    SWTSkin skin = null;
    try {
        skin = (SWTSkin)JMuleUIManager.getJMuleUI().getSkin();
    }catch(Throwable t) {}
    Display display = SWTThread.getDisplay();
    final Shell shell1=new Shell(display,SWT.ON_TOP);
    shell=new Shell(shell1,SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.RESIZE);
    shell.setText(Localizer._("uploadinfowindow.title"));
    shell.setImage(SWTImageRepository.getImage("info.png"));
       
View Full Code Here

Examples of org.eclipse.swt.widgets.Display

  public static Logger getLogger() {
    return logger;
  }
 
  public void initUIComponents() {
    final Display display = SWTThread.getDisplay();
    final MainWindow instance = this;
    display.asyncExec(new JMRunnable() {
            public void JMRun() {
   
              shell = new Shell(display);
             
        shell.setSize(800, 500);  
              Utils.centreWindow(shell);
             
              shell.setText(JMConstants.JMULE_FULL_NAME);
              shell.setImage(SWTImageRepository.getImage("jmule.png"));
             
              GridLayout gridLayout = new GridLayout(1,true);
              gridLayout.marginHeight = 2;
              gridLayout.marginWidth = 2;
              shell.setLayout(gridLayout);
              //Setup main_menu
              main_menu = new MainMenu(shell,instance);
              //Setup tool bar
              toolbar = new Toolbar(shell,_core,instance);
   
              window_content = new ScrolledComposite(shell,SWT.NONE);
              window_content.setExpandHorizontal(true);
              window_content.setExpandVertical(true);
              window_content.setLayout(new FillLayout());
              GridData gridData = new GridData(GridData.FILL_BOTH);
              window_content.setLayoutData(gridData);
   
              new Label(shell,SWT.SEPARATOR | SWT.HORIZONTAL).setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
             
              status_bar = new StatusBar(shell,_core);
             
              LogsTab logs_tab = new LogsTab(window_content);
              logger = logs_tab;
              tab_list.add(logs_tab);
              tab_list.add(new ServerListTab(window_content,_core));
              tab_list.add(new KadTab(window_content,_core));
              tab_list.add(new TransfersTab(window_content,_core));
              tab_list.add(new SearchTab(window_content,_core));
              tab_list.add(new SharedTab(window_content,_core));
              tab_list.add(new StatisticsTab(window_content));
   
              setTab(AbstractTab.JMULE_TABS.SERVERLIST);
             
              if (!SWTPreferences.getInstance().isStatusBarVisible())
              statusBarToogleVisibility();
             
            if (!SWTPreferences.getInstance().isToolBarVisible())
              toolbarToogleVisibility();

              shell.open ();

              if (SWTPreferences.getInstance().isConnectAtStartup()) {
                try {
            _core.getServerManager().connect();
          } catch (ServerManagerException e1) {
            e1.printStackTrace();
         
              }
             
              if (JMConstants.IS_NIGHTLY_BUILD)
                if (SWTPreferences.getInstance().isNightlyBuildWarning()){
                  NightlyBuildWarningWindow warning_window = new NightlyBuildWarningWindow(shell);
                  warning_window.getCoreComponents();
                  warning_window.initUIComponents();
              }
             
              // show log messages
              new JMThread(new JMRunnable() {
                public void JMRun() {
                  logger.fine(Localizer._("mainwindow.logtab.message_jmule_started",  JMConstants.JMULE_FULL_NAME));
                  logger.fine(Localizer._("mainwindow.logtab.message_servers_loaded", _core.getServerManager().getServersCount() + ""));
                  logger.fine(Localizer._("mainwindow.logtab.message_shared_loaded", _core.getSharingManager().getFileCount() + ""));
                  logger.fine(Localizer._("mainwindow.logtab.message_partial_loaded", _core.getDownloadManager().getDownloadCount() + ""));
                }}).start();
             
              _core.addEventListener(new JMuleCoreEventListener() {
          public void eventOccured(JMuleCoreEvent event, final EventDescriptor eventDescriptor) {
            if( event == JMuleCoreEvent.NOT_ENOUGH_SPACE ) {
              display.syncExec(new JMRunnable() {
                NotEnoughSpaceDownloadingFile nes = (NotEnoughSpaceDownloadingFile)eventDescriptor;
                public void JMRun() {
                  Utils.showErrorMessage(shell,
                      _._("mainwindow.not_enough_space_dialog.title"),
                      _._("mainwindow.not_enough_space_dialog.message",
View Full Code Here

Examples of org.eclipse.swt.widgets.Display

    }
    SWTSkin skin = null;
    try {
        skin = (SWTSkin)JMuleUIManager.getJMuleUI().getSkin();
    }catch(Throwable t) {}
    Display display = SWTThread.getDisplay();
    GridData grid_data;
   
    final Shell shell1=new Shell(display,SWT.ON_TOP);
    shell=new Shell(shell1,SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.RESIZE);
    if  (type == WindowType.DOWNLOAD) {
View Full Code Here

Examples of org.eclipse.swt.widgets.Display

    gc.drawRectangle(x, y, width, height);
  }
  static Shell shell;
  static GapListPainter gap_list_painter;
  public static void main(String... args) {
    Display display = Display.getCurrent();
    shell = new Shell(display);
    GapList gap_list = new GapList();
    gap_list.addGap(70, 90);
    gap_list.addGap(1, 20);
    gap_list.addGap(25, 40);
    gap_list_painter = new GapListPainter(gap_list,100);
    FillLayout layout = new FillLayout();
    layout.marginHeight = 10;
    layout.marginWidth  = 10;
    shell.setLayout(layout);
    final Canvas canvas = new Canvas(shell,SWT.NONE);
   
    canvas.addPaintListener(new PaintListener() {
      public void paintControl(PaintEvent arg0) {
        System.out.println(arg0.width+" : " + arg0.height);
        gap_list_painter.draw(arg0.gc, 0, 0, arg0.width, arg0.height);
      }
    });
   
    shell.setSize(500,100);
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch())
        display.sleep();
    }
    display.dispose();

   
   
  }
View Full Code Here

Examples of org.eclipse.swt.widgets.Display

    this.assumeInitiallyDown = _assumeInitiallyDown;
    cancelled = true;

    shell = new Shell(SWTThread.getDisplay(), SWT.DOUBLE_BUFFERED | SWT.ON_TOP);
    shell.setLayout(new FillLayout());
    final Display display = shell.getDisplay();

    composite = new Composite(shell, SWT.DOUBLE_BUFFERED);

    final Point firstMousePos = display.getCursorLocation();

    composite.addTraverseListener(new TraverseListener() {
      public void keyTraversed(TraverseEvent e) {
        if (e.detail == SWT.TRAVERSE_ESCAPE) {
          setCancelled(true);
          shell.dispose();
        } else if (e.detail == SWT.TRAVERSE_ARROW_NEXT) {
          setValue(value + 1);
        } else if (e.detail == SWT.TRAVERSE_ARROW_PREVIOUS) {
          setValue(value - 1);
        } else if (e.detail == SWT.TRAVERSE_PAGE_NEXT) {
          setValue(value + bigPageIncrement);
        } else if (e.detail == SWT.TRAVERSE_PAGE_PREVIOUS) {
          setValue(value - bigPageIncrement);
        } else if (e.detail == SWT.TRAVERSE_RETURN) {
          setCancelled(false);
          shell.dispose();
        }
      }
    });

    composite.addKeyListener(new KeyListener() {
      public void keyReleased(KeyEvent e) {
      }

      public void keyPressed(KeyEvent e) {
        if (e.keyCode == SWT.PAGE_DOWN && e.stateMask == 0) {
          setValue(value + pageIncrement);
        } else if (e.keyCode == SWT.PAGE_UP && e.stateMask == 0) {
          setValue(value - pageIncrement);
        } else if (e.keyCode == SWT.HOME) {
          setValue(minValue);
        } else if (e.keyCode == SWT.END) {
          if (maxValue != -1) {
            setValue(maxValue);
          }
        }
      }
    });

    composite.addMouseMoveListener(new MouseMoveListener() {
      public void mouseMove(MouseEvent e) {
        lastMoveHadMouseDown = false;
        boolean hasButtonDown = (e.stateMask & SWT.BUTTON_MASK) > 0
            || assumeInitiallyDown;
        if (hasButtonDown) {
          if (e.y > HEIGHT - SCALER_HEIGHT) {
            lastMoveHadMouseDown = true;
            setValue(getValueFromMousePos(e.x));
          }
          composite.redraw();
        } else {
          composite.redraw();
        }
      }
    });

    composite.addMouseTrackListener(new MouseTrackListener() {
      boolean mouseIsOut = false;

      private boolean exitCancelled = false;

      public void mouseHover(MouseEvent e) {
      }

      public void mouseExit(MouseEvent e) {
      if (!exitCancelled) {
            shell.dispose();
        } else {
        exitCancelled = false;
        }
     
      }

      public void mouseEnter(MouseEvent e) {
        if (mouseIsOut) {
          exitCancelled = true;
        }
        mouseIsOut = false;
      }
    });

    composite.addMouseListener(new MouseListener() {
      boolean bMouseDown = false;

      public void mouseUp(MouseEvent e) {
        if (assumeInitiallyDown) {
          assumeInitiallyDown = false;
        }
        if (MOUSE_ONLY_UP_EXITS) {
          if (lastMoveHadMouseDown) {
            Point mousePos = display.getCursorLocation();
            if (mousePos.equals(firstMousePos)) {
              lastMoveHadMouseDown = false;
              return;
            }
          }
          bMouseDown = true;
        }
        if (bMouseDown) {
          if (e.y > HEIGHT - SCALER_HEIGHT) {
            setValue(getValueFromMousePos(e.x));
            setCancelled(false);
            if (lastMoveHadMouseDown) {
              shell.dispose();
            }
          } else if (e.y > TEXT_HEIGHT) {
            int idx = (e.y - TEXT_HEIGHT) / OPTION_HEIGHT;
            Iterator iterator = mapOptions.keySet().iterator();
            long newValue;
            do {
              newValue = ((Long) iterator.next()).intValue();
              idx--;
            } while (idx >= 0);
            value = newValue; // ignore min/max
            setCancelled(false);
            setMenuChosen(true);
            shell.dispose();
          }
        }
      }

      public void mouseDown(MouseEvent e) {
        if (e.count > 1) {
          lastMoveHadMouseDown = true;
          return;
        }
        Point mousePos = display.getCursorLocation();
        if (e.y > HEIGHT - SCALER_HEIGHT) {
          bMouseDown = true;
          setValue(getValueFromMousePos(e.x));
        }
      }

      public void mouseDoubleClick(MouseEvent e) {
      }

    });

    composite.addPaintListener(new PaintListener() {
      public void paintControl(PaintEvent e) {
        int x = (int)(WIDTH_NO_PADDING * value / maxValue);
        if (x < 0) {
          x = 0;
        } else if (x > WIDTH_NO_PADDING) {
          x = WIDTH_NO_PADDING;
        }
        int startX = (int)(WIDTH_NO_PADDING * startValue / maxValue);
        if (startX < 0) {
          startX = 0;
        } else if (startX > WIDTH_NO_PADDING) {
          startX = WIDTH_NO_PADDING;
        }
        int baseLinePos = getBaselinePos();

        try {
          e.gc.setAdvanced(true);
          e.gc.setAntialias(SWT.ON);
        } catch (Exception ex) {
          // aw
        }

        e.gc.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
        // left
        e.gc.drawLine(PADDING_X0, baseLinePos - 6, PADDING_X0, baseLinePos + 6);
        // right
        e.gc.drawLine(PADDING_X0 + WIDTH_NO_PADDING, baseLinePos - 6,
            PADDING_X0 + WIDTH_NO_PADDING, baseLinePos + 6);
        // baseline
        e.gc.drawLine(PADDING_X0, baseLinePos, PADDING_X0 + WIDTH_NO_PADDING,
            baseLinePos);

        e.gc.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_FOREGROUND));
        e.gc.setBackground(display.getSystemColor(SWT.COLOR_WIDGET_FOREGROUND));
        // start value marker
        e.gc.drawLine(PADDING_X0 + startX, baseLinePos - 5,
            PADDING_X0 + startX, baseLinePos + 5);
        // current value marker
        e.gc.fillRoundRectangle(PADDING_X0 + x - 2, baseLinePos - 5, 5, 10, 10,
            10);

        // Current Value Text
        e.gc.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND));
        e.gc.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));

        e.gc.fillRectangle(0, 0, WIDTH, TEXT_HEIGHT);

        GCStringPrinter.printString(e.gc,title+"\n"+ _getStringValue(), new Rectangle(0,
            0, WIDTH, HEIGHT), true, false, SWT.CENTER | SWT.TOP | SWT.WRAP);

        e.gc.drawLine(0, TEXT_HEIGHT - 1, WIDTH, TEXT_HEIGHT - 1);

        // options list
        int y = TEXT_HEIGHT;
        Point mousePos = composite.toControl(display.getCursorLocation());
        for (Iterator iter = mapOptions.keySet().iterator(); iter.hasNext();) {
          long value = (Long) iter.next();
          String text = (String) mapOptions.get(value);

          Rectangle area = new Rectangle(0, y, WIDTH, OPTION_HEIGHT);
          Color bg;
          if (area.contains(mousePos)) {
            bg = display.getSystemColor(SWT.COLOR_LIST_SELECTION);
            e.gc.setBackground(bg);
            e.gc.setForeground(display.getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT));
            e.gc.fillRectangle(area);
          } else {
            bg = display.getSystemColor(SWT.COLOR_LIST_BACKGROUND);
            e.gc.setBackground(bg);
            e.gc.setForeground(display.getSystemColor(SWT.COLOR_LIST_FOREGROUND));
          }

          int ovalSize = OPTION_HEIGHT - 6;
          if (getValue() == value) {
            Color saveColor = e.gc.getBackground();
            e.gc.setBackground(e.gc.getForeground());
            e.gc.fillOval(4, y + 5, ovalSize - 3, ovalSize - 3);
            e.gc.setBackground(saveColor);
          }
          if (JMConstants.isLinux) {
            // Hack: on linux, drawing oval seems to draw a line from last pos
            // to start of oval.. drawing a point (anywhere) seems to clear the
            // path
            Color saveColor = e.gc.getForeground();
            e.gc.setForeground(bg);
            e.gc.drawPoint(2, y + 3);
            e.gc.setForeground(saveColor);
          }
          e.gc.drawOval(2, y + 3, ovalSize, ovalSize);

          GCStringPrinter.printString(e.gc, text, new Rectangle(OPTION_HEIGHT,
              y, WIDTH - OPTION_HEIGHT, OPTION_HEIGHT), true, false, SWT.LEFT);
          y += OPTION_HEIGHT;
        }

        // typed value
        if (sValue.length() > 0) {
          Point extent = e.gc.textExtent(sValue);
          if (extent.x > WIDTH - 10) {
            extent.x = WIDTH - 10;
          }
          Rectangle rect = new Rectangle(WIDTH - 8 - extent.x, 14,
              extent.x + 5, extent.y + 4 + 14 > TEXT_HEIGHT ? TEXT_HEIGHT - 15
                  : extent.y + 4);
          e.gc.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
          e.gc.fillRectangle(rect);

          try {
            e.gc.setAlpha(TYPED_TEXT_ALPHA);
          } catch (Exception ex) {
          }
          e.gc.setBackground(display.getSystemColor(SWT.COLOR_LIST_BACKGROUND));
          e.gc.setForeground(display.getSystemColor(SWT.COLOR_LIST_FOREGROUND));
          //e.gc.drawRectangle(rect);

          GCStringPrinter.printString(e.gc, sValue , new Rectangle(rect.x + 2,
              rect.y + 2, WIDTH - 5, OPTION_HEIGHT), true, false, SWT.LEFT
              | SWT.BOTTOM);
        }
      }
    });

    Point location = display.getCursorLocation();

    location.y -= getBaselinePos();
    int x = (int) (WIDTH_NO_PADDING * (value > maxValue ? 1 : (double) value
        / maxValue));
    location.x -= PADDING_X0 + x;

    Rectangle bounds = new Rectangle(location.x, location.y, WIDTH, HEIGHT);
    Monitor mouseMonitor = shell.getMonitor();
    Monitor[] monitors = display.getMonitors();
    for (int i = 0; i < monitors.length; i++) {
      Monitor monitor = monitors[i];
      if (monitor.getBounds().contains(location)) {
        mouseMonitor = monitor;
        break;
      }
    }
    Rectangle monitorBounds = mouseMonitor.getBounds();
    Rectangle intersection = monitorBounds.intersection(bounds);
    if (intersection.width != bounds.width) {
      bounds.x = monitorBounds.x + monitorBounds.width - WIDTH;
      bounds.width = WIDTH;
    }
    if (intersection.height != bounds.height) {
      bounds.y = monitorBounds.y + monitorBounds.height - HEIGHT;
      bounds.height = HEIGHT;
    }

    shell.setBounds(bounds);
    if (!bounds.contains(firstMousePos)) {
      // should never happen, which means it probably will, so handle it badly
      shell.setLocation(firstMousePos.x - (bounds.width / 2), firstMousePos.y
          - bounds.height + 2);
    }

    shell.open();
    // must be after, for OSX
    composite.setFocus();

    try {
      while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
          display.sleep();
        }
      }
    } catch (Throwable t) {
     
    }
View Full Code Here

Examples of org.eclipse.swt.widgets.Display

   
   
  }
 
  public static void main(String... args) {
    Display display = new Display ();
    Shell shell = new Shell (display);

    Composite c1 = new Composite(shell,SWT.BORDER);
    Composite c2 = new Composite(shell,SWT.BORDER);
   
    //createVerticalSash(10,50,shell,c1,c2);
    createHorizontalSash(10,50,shell,c1,c2);
   
    shell.open ();
    while (!shell.isDisposed ()) {
      if (!display.readAndDispatch ()) display.sleep ();
    }
    display.dispose ();

  }
View Full Code Here

Examples of org.eclipse.swt.widgets.Display

   
      display_created = false;
     
      display = Display.getCurrent();
      if ( display == null )
        display = new Display();
   
      display_created = true;
     
      synchronized(this) {
       
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.