Package org.eclipse.swt.widgets

Examples of org.eclipse.swt.widgets.Shell


  /*
   * @see org.eclipse.ui.application.WorkbenchWindowAdvisor#postWindowOpen()
   */
  @Override
  public void postWindowOpen() {
    final Shell shell = getWindowConfigurer().getWindow().getShell();

    /* Toolbar & Status Visibility */
    IPreferenceScope preferences = Owl.getPreferenceService().getGlobalScope();
    if (!preferences.getBoolean(DefaultPreferences.SHOW_TOOLBAR))
      setToolBarVisible(false);
    if (!preferences.getBoolean(DefaultPreferences.SHOW_STATUS))
      setStatusVisible(false);

    /* Use PNG on Windows and Linux */
    if (Application.IS_WINDOWS || Application.IS_LINUX) {
      Image[] shellImg = new Image[3];
      shellImg[0] = OwlUI.getImage(shell, "icons/product/16x16.png");
      shellImg[1] = OwlUI.getImage(shell, "icons/product/24x24.png");
      shellImg[2] = OwlUI.getImage(shell, "icons/product/32x32.png");
      shell.setImages(shellImg);
    }

    /* System Tray */
    SafeRunner.run(new LoggingSafeRunnable() {
      public void run() throws Exception {
        boolean trayEnabled = false;

        /* Hook TrayItem if supported on OS and 1st Window */
        if (fPreferences.getBoolean(DefaultPreferences.TRAY_ON_MINIMIZE) || fPreferences.getBoolean(DefaultPreferences.TRAY_ON_CLOSE) || fPreferences.getBoolean(DefaultPreferences.TRAY_ON_START))
          trayEnabled = enableTray();

        /* Win only: Allow Scroll over Cursor-Control */
        if (Application.IS_WINDOWS)
          hookFocuslessScrolling(shell.getDisplay());

        /* Register Listeners */
        registerListeners();

        /* Move to Tray if set */
 
View Full Code Here


    /* Only enable for Primary Window */
    IWorkbenchWindow primaryWindow = OwlUI.getPrimaryWindow();
    if (primaryWindow == null || !primaryWindow.equals(getWindowConfigurer().getWindow()))
      return false;

    final Shell shell = primaryWindow.getShell();
    final Tray tray = shell.getDisplay().getSystemTray();

    /* Tray not support on the OS */
    if (tray == null)
      return false;

    /* Create Item in Tray */
    fTrayItem = new TrayItem(tray, SWT.NONE);
    fTrayItem.setToolTipText("RSSOwl");
    fTrayEnabled = true;

    if (Application.IS_WINDOWS)
      fTrayItem.setVisible(false);

    /* Apply Image */
    fTrayItem.setImage(OwlUI.getImage(fResources, OwlUI.TRAY_OWL));

    /* Minimize to Tray on Shell Iconify if set */
    fTrayShellListener = new ShellAdapter() {

      @Override
      public void shellIconified(ShellEvent e) {
        if (!fBlockIconifyEvent && (fMinimizeFromClose || fPreferences.getBoolean(DefaultPreferences.TRAY_ON_MINIMIZE)))
          moveToTray(shell);
      }
    };
    shell.addShellListener(fTrayShellListener);

    /* Show Menu on Selection */
    fTrayItem.addListener(SWT.MenuDetect, new Listener() {
      public void handleEvent(Event event) {
        MenuManager trayMenu = new MenuManager();

        /* Restore */
        trayMenu.add(new ContributionItem() {
          @Override
          public void fill(Menu menu, int index) {
            MenuItem restoreItem = new MenuItem(menu, SWT.PUSH);
            restoreItem.setText("Restore");
            restoreItem.addSelectionListener(new SelectionAdapter() {
              @Override
              public void widgetSelected(SelectionEvent e) {
                restoreFromTray(shell);
              }
            });
            menu.setDefaultItem(restoreItem);
          }
        });

        /* Separator */
        trayMenu.add(new Separator());

        /* Other Items */
        fActionBarAdvisor.fillTrayItem(trayMenu);

        Menu menu = trayMenu.createContextMenu(shell);
        menu.setVisible(true);
      }
    });

    /* Handle DefaultSelection */
    fTrayItem.addListener(SWT.DefaultSelection, new Listener() {
      public void handleEvent(Event event) {

        /* Restore from Tray */
        if (!shell.isVisible())
          restoreFromTray(shell);

        /* Move to Tray */
        else if (!Application.IS_WINDOWS)
          moveToTray(shell);
      }
    });

    /* Indicate new News in Tray */
    fNewsListener = new NewsAdapter() {

      @Override
      public void entitiesAdded(Set<NewsEvent> events) {
        JobRunner.runInUIThread(fTrayItem, new Runnable() {
          public void run() {

            /* Update Icon only when Tray is visible and not yet teasing */
            if (!fTrayItem.getVisible() || fTrayTeasing || shell.getVisible())
              return;

            fTrayTeasing = true;
            fTrayItem.setImage(OwlUI.getImage(fResources, OwlUI.TRAY_OWL_TEASING));
          }
View Full Code Here

   */
  @Override
  protected void initializeBounds() {
    super.initializeBounds();

    Shell shell = getShell();

    /* Minimum Size */
    int minWidth = convertHorizontalDLUsToPixels(OwlUI.MIN_DIALOG_WIDTH_DLU);
    int minHeight = shell.computeSize(minWidth, SWT.DEFAULT).y;

    /* Required Size */
    Point requiredSize = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT);

    shell.setSize(Math.max(minWidth, requiredSize.x), Math.max(minHeight, requiredSize.y));
    LayoutUtils.positionShell(shell, true);
  }
View Full Code Here

   */
  @Override
  protected void initializeBounds() {
    super.initializeBounds();

    Shell shell = getShell();

    /* Minimum Size */
    int minWidth = convertHorizontalDLUsToPixels(OwlUI.MIN_DIALOG_WIDTH_DLU);
    int minHeight = shell.computeSize(minWidth, SWT.DEFAULT).y;

    /* Required Size */
    Point requiredSize = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT);

    shell.setSize(Math.max(minWidth, requiredSize.x), Math.max(minHeight, requiredSize.y));
    LayoutUtils.positionShell(shell, false);
  }
View Full Code Here

    Control cursorControl = Display.getDefault().getCursorControl();
    if (cursorControl == null)
      return null;

    /* Return Window that belongs to Cursor-Shell */
    Shell cursorShell = cursorControl.getShell();
    IWorkbenchWindow windows[] = PlatformUI.getWorkbench().getWorkbenchWindows();
    for (IWorkbenchWindow workbenchWindow : windows) {
      if (workbenchWindow.getShell().equals(cursorShell))
        return workbenchWindow;
    }
View Full Code Here

    return null;
  }

  /* Focus the Application */
  private void restoreApplication() {
    final Shell shell = OwlUI.getPrimaryShell();
    if (shell != null) {
      JobRunner.runInUIThread(shell, new Runnable() {
        public void run() {

          /* Restore from Tray */
          ApplicationWorkbenchWindowAdvisor advisor = fWorkbenchAdvisor.getPrimaryWorkbenchWindowAdvisor();
          if (advisor != null && advisor.isMinimizedToTray()) {
            advisor.restoreFromTray(shell);
          }

          /* Force Active and De-Iconify */
          else {
            shell.forceActive();
            shell.setMinimized(false);
          }
        }
      });
    }
  }
View Full Code Here

  /* Handle the supplied Link */
  private void handleLinkSupplied(final String link) {

    /* Need a Shell */
    final Shell shell = OwlUI.getPrimaryShell();
    if (shell == null)
      return;

    /* Check for existing BookMark */
    final IBookMark existingBookMark = getBookMark(link);
View Full Code Here

   */
  @Override
  protected void initializeBounds() {
    super.initializeBounds();

    Shell shell = getShell();

    /* Minimum Size */
    int minWidth = convertHorizontalDLUsToPixels(OwlUI.MIN_DIALOG_WIDTH_DLU);
    int minHeight = shell.computeSize(minWidth, SWT.DEFAULT).y;

    /* Required Size */
    Point requiredSize = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT);

    /* Bug in SWT: The preferred width of the state condition is wrong */
    if (Application.IS_LINUX && displaysSavedSearch())
      requiredSize.x = requiredSize.x + 100;

    shell.setSize(Math.max(minWidth, requiredSize.x), Math.max(minHeight, requiredSize.y));
    LayoutUtils.positionShell(shell, true);
  }
View Full Code Here

      return Status.OK_STATUS;
    }
  };

  NotificationPopup(int visibleItemCount, Mode mode) {
    super(new Shell(PlatformUI.getWorkbench().getDisplay()), SWT.NO_TRIM | SWT.ON_TOP, mode != Mode.INCOMING_AUTOMATIC, false, false, false, false, null, null);
    fMode = mode;
    fResources = new LocalResourceManager(JFaceResources.getResources());
    fBoldTextFont = OwlUI.getThemeFont(OwlUI.NOTIFICATION_POPUP_FONT_ID, SWT.BOLD);
    fNormalTextFont = OwlUI.getThemeFont(OwlUI.NOTIFICATION_POPUP_FONT_ID, SWT.NORMAL);
    fGlobalScope = Owl.getPreferenceService().getGlobalScope();
View Full Code Here

      super(""); //$NON-NLS-1$
      setSystem(true);
    }

    private boolean proceed(IProgressMonitor monitor) {
      Shell shell = getShell();
      if (monitor.isCanceled() || shell == null || shell.isDisposed() || shell.getDisplay().isDisposed() || Controller.getDefault().isShuttingDown())
        return false;

      return true;
    }
View Full Code Here

TOP

Related Classes of org.eclipse.swt.widgets.Shell

Copyright © 2018 www.massapicom. 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.