Package org.eclipse.swt.widgets

Examples of org.eclipse.swt.widgets.Shell


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

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

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

    /* 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


  private NewsCounter countAll() {
    final NewsCounter newsCounter = new NewsCounter();
    final long start = System.currentTimeMillis();
    final Collection<IFeed> feeds = DynamicDAO.loadAll(IFeed.class);

    final ProgressMonitorDialog dialog = new NewsServiceProgressMonitorDialog(new Shell(Display.getDefault(), SWT.NONE));
    dialog.setOpenOnRun(false);

    /* Runnable will open the Dialog after SHOW_PROGRESS_THRESHOLD ms */
    IRunnableWithProgress runnable = new IRunnableWithProgress() {
      private boolean fDialogOpened;
View Full Code Here

  private MouseTrackListener fMouseTrackListner;
  private IPreferenceScope fGlobalScope;
  private int fVisibleNewsCount;

  NotificationPopup(int visibleNewsCount) {
    super(new Shell(PlatformUI.getWorkbench().getDisplay()), PopupDialog.INFOPOPUP_SHELLSTYLE | SWT.ON_TOP, false, false, false, false, null, null);
    fResources = new LocalResourceManager(JFaceResources.getResources());
    fMapFeedToBookmark = new HashMap<FeedLinkReference, IBookMark>();
    fBoldTextFont = OwlUI.getThemeFont(OwlUI.NOTIFICATION_POPUP_FONT_ID, SWT.BOLD);
    fGlobalScope = Owl.getPreferenceService().getGlobalScope();
    fVisibleNewsCount = (visibleNewsCount > MAX_NEWS) ? MAX_NEWS : visibleNewsCount;
View Full Code Here

    }

    /* Otherwise open Feedview and select the News */
    IWorkbenchPage page = OwlUI.getPage();
    if (page != null) {
      Shell shell = page.getWorkbenchWindow().getShell();

      /* Restore from Tray or Minimization if required */
      ApplicationWorkbenchWindowAdvisor advisor = ApplicationWorkbenchAdvisor.fgPrimaryApplicationWorkbenchWindowAdvisor;
      if (advisor != null && advisor.isMinimizedToTray())
        advisor.restoreFromTray(shell);
      else if (shell.getMinimized()) {
        shell.setMinimized(false);
        shell.forceActive();
      }

      /* First try if the Bookmark is already visible */
      IEditorReference editorRef = EditorUtils.findEditor(page.getEditorReferences(), bookmark);
      if (editorRef != null) {
View Full Code Here

  }

  private void startCore() {

    /* Dialog to show progress */
    final ProgressMonitorDialog dialog = new ProgressMonitorDialog(new Shell(Display.getDefault())) {
      @Override
      protected Point getInitialLocation(Point initialSize) {
        Rectangle displayBounds = getParentShell().getDisplay().getPrimaryMonitor().getBounds();
        Point shellSize = getInitialSize();
        int x = displayBounds.x + (displayBounds.width - shellSize.x) >> 1;
View Full Code Here

        }
      }
    };

    /* Progress Dialog */
    Shell shell = fShell;
    if (shell == null)
      shell = OwlUI.getActiveShell();

    ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell) {
      @Override
      protected void initializeBounds() {
        super.initializeBounds();

        /* Size */
        Shell shell = getShell();
        int width = convertHorizontalDLUsToPixels(OwlUI.MIN_DIALOG_WIDTH_DLU);
        shell.setSize(width, shell.getSize().y);

        /* New Location */
        Rectangle containerBounds = shell.getParent().getBounds();
        int x = Math.max(0, containerBounds.x + (containerBounds.width - width) / 2);
        shell.setLocation(x, shell.getLocation().y);
      }
    };

    /* Open and Run */
    try {
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

   * minimized.
   *
   * @param page the workbench page the application is running in.
   */
  public static void restoreWindow(IWorkbenchPage page) {
    Shell applicationShell = page.getWorkbenchWindow().getShell();
    restoreWindow(applicationShell);
  }
View Full Code Here

  /**
   * Switch between full-screen and normal screen.
   */
  public static void toggleFullScreen() {
    Shell shell = OwlUI.getActiveShell();
    if (shell != null) {
      shell.setFullScreen(!shell.getFullScreen());

      /* Shell got restored */
      if (!shell.getFullScreen()) {
        ApplicationWorkbenchWindowAdvisor configurer = ApplicationWorkbenchAdvisor.fgPrimaryApplicationWorkbenchWindowAdvisor;
        configurer.setStatusVisible(Owl.getPreferenceService().getGlobalScope().getBoolean(DefaultPreferences.SHOW_STATUS), false);

        shell.layout(); //Need to layout to avoid screen cheese
      }

      /* Shell got fullscreen */
      else {
        ApplicationWorkbenchWindowAdvisor configurer = ApplicationWorkbenchAdvisor.fgPrimaryApplicationWorkbenchWindowAdvisor;
View Full Code Here

    }

    private class UpdateJobChangeListener extends JobChangeAdapter {
      @Override
      public void done(final IJobChangeEvent event) {
        final Shell validShell = getValidShell();

        if (event.getJob() == fJob) {
          Job.getJobManager().removeJobChangeListener(this);
          Job.getJobManager().cancel(fJob);
          if (fJob.getStatus() == Status.CANCEL_STATUS)
            return;

          if (fJob.getStatus() != Status.OK_STATUS)
            getValidShell().getDisplay().syncExec(new Runnable() {
              public void run() {
                org.eclipse.update.internal.ui.UpdateUI.log(fJob.getStatus(), true);
              }
            });

          validShell.getDisplay().asyncExec(new Runnable() {
            public void run() {
              validShell.getDisplay().beep();
              BusyIndicator.showWhile(validShell.getDisplay(), new Runnable() {
                public void run() {
                  openInstallWizard2();
                }
              });
            }
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.