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();
  }
 protected void doSetUp() throws Exception {
   super.doSetUp();
   theShell = new Shell(Display.getCurrent(), SWT.NONE);
   theShell.setBounds(0, 0, 1024, 768);
   theShell.setVisible(true);
   img = UIPerformancePlugin.getImageDescriptor("icons/anything.gif").createImage();
   img2 = UIPerformancePlugin.getImageDescriptor("icons/view.gif").createImage();
 }
Example #3
0
 @Override
 public Object execute(ExecutionEvent event) throws ExecutionException {
   Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
   if (shell != null && !shell.isDisposed() && !shell.isVisible()) {
     shell.setVisible(true);
   }
   return null;
 }
  /** Test {@link SitarWindow#isValid()} when shell isn't visible. */
  @Test
  public void testShellIsValidFalse() {
    Shell shell = new Shell(display);
    shell.setText("ShellTitle");
    shell.setVisible(false);
    SitarWindow swtWindow = new SitarWindow(shell);

    assertEquals(swtWindow.isValid(), false);
  }
 private void createFeedback() {
   dragShell = new Shell(SWT.NO_TRIM | SWT.NO_BACKGROUND);
   dragShell.setAlpha(175);
   ToolBar dragTB = new ToolBar(dragShell, SWT.RIGHT);
   ToolItem newTI = new ToolItem(dragTB, SWT.RADIO);
   newTI.setText(dragItem.getText());
   newTI.setImage(dragItem.getImage());
   dragTB.pack();
   dragShell.pack();
   dragShell.setVisible(true);
 }
Example #6
0
  private void setShellVisible(final boolean isVisible) {

    if (isVisible) {

      // show tooltip

      _shell.setVisible(true);

      addDisplayFilterListener();

    } else {

      // hide tooltip

      beforeHideToolTip();

      _shell.setVisible(false);

      removeDisplayFilterListener();
    }
  }
Example #7
0
  public void onReparentShell(final Shell reparentedShell) {

    /*
     * reparenting a shells parent which is a shell do NOT work
     */

    if (_shell != null && _shell.isDisposed() == false && _shell.isVisible()) {
      _shell.setVisible(false);
    }

    // stop animation
    _isShellFadingIn = _isShellFadingOut = false;
  }
Example #8
0
  private void step3() {
    if (keyPair[0] == null) {
      MsgBox.warning(shell, "You have to load a server key pair.");
      return;
    }

    if (keyPair[1] == null) {
      MsgBox.warning(shell, "You have to load an admin key pair.");
      return;
    }

    builder.serverKeyPair = keyPair[0];
    builder.adminKeyPair = keyPair[1];

    File parent = builder.configFile.getAbsoluteFile().getParentFile();
    if (!parent.exists() && parent.mkdirs()) {
      shell.setVisible(false);
      MsgBox.error(shell, "Failed to create directory: " + parent.getAbsolutePath());
      shell.dispose();
      return;
    }

    ServerConfigManager cm = new ServerConfigManager(builder, null);
    try {
      cm.save();
    } catch (IOException ex) {
      shell.setVisible(false);
      MsgBox.error(shell, "Failed to save to file: " + ex.getMessage());
      shell.dispose();
      return;
    }

    shell.setVisible(false);
    MsgBox.info(shell, "Configuration was written successfuly.");

    shell.dispose();
  }
Example #9
0
  /* (non-Javadoc)
   * @see javax.microedition.lcdui.Displayable#handleShowEvent()
   */
  void eswtHandleShowCurrentEvent() {
    // If it alert is first displayable, default
    // displayable should be shown behind alert
    if (topShell.isVisible() == false && nextDisplayable == null) {
      topShell.setVisible(true);
    }
    super.eswtHandleShowCurrentEvent();
    topShell.addListener(SWT.Resize, resizeListener);

    // add key filter for scrollable text composite
    org.eclipse.swt.widgets.Display.getCurrent().addFilter(SWT.KeyDown, keyListener);
    org.eclipse.swt.widgets.Display.getCurrent().addFilter(SWT.Traverse, keyListener);
    org.eclipse.swt.widgets.Display.getCurrent().addFilter(SWT.MouseUp, keyListener);
    resetTimerTask(true);
  }
  /** The Hide button has been pressed. */
  public void hidePressed() {
    if (hideOnFinish) {
      final Shell activeShell = getShell();
      toast =
          new GenericInfoPopupDialog(
              PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
              infoTitle,
              infoMessage,
              new Runnable() {
                public void run() {
                  activeShell.setVisible(true);
                }
              });
      toast.open();
      activeShell.setVisible(false);

      activeShell.addListener(
          SWT.Show,
          new Listener() {
            public void handleEvent(Event event) {
              if (toast != null) {
                // Incase if the shell is opened through other source, close the toast
                toast.close();
              }
            }
          });

      activeShell.addShellListener(
          new ShellAdapter() {
            @Override
            public void shellClosed(ShellEvent e) {
              if (toast != null) {
                // In case the shell gets closed programatically, close the toast.
                toast.close();
              }
            }
          });
    }
  }
Example #11
0
  /**
   * Creates a new <code>Shell</code>. This Shell is the root for the SWT widgets that will be
   * embedded within the AWT canvas.
   *
   * @param display the display for the new Shell
   * @param parent the parent <code>java.awt.Canvas</code> of the new Shell
   * @return a <code>Shell</code> to be the parent of the embedded SWT widgets
   * @exception IllegalArgumentException
   *     <ul>
   *       <li>ERROR_NULL_ARGUMENT - if the display is null
   *       <li>ERROR_NULL_ARGUMENT - if the parent is null
   *       <li>ERROR_INVALID_ARGUMENT - if the parent's peer is not created
   *     </ul>
   *
   * @since 3.0
   */
  public static Shell new_Shell(final Display display, final Canvas parent) {
    if (display == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
    if (parent == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
    int /*long*/ handle = 0;

    try {
      loadLibrary();
      handle = getAWTHandle(parent);
    } catch (Throwable e) {
      SWT.error(SWT.ERROR_NOT_IMPLEMENTED, e);
    }
    if (handle == 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT, null, " [peer not created]");

    final Shell shell = Shell.cocoa_new(display, handle);
    final ComponentListener listener =
        new ComponentAdapter() {
          public void componentResized(ComponentEvent e) {
            display.asyncExec(
                new Runnable() {
                  public void run() {
                    if (shell.isDisposed()) return;
                    Dimension dim = parent.getSize();
                    shell.setSize(dim.width, dim.height);
                  }
                });
          }
        };
    parent.addComponentListener(listener);
    shell.addListener(
        SWT.Dispose,
        new Listener() {
          public void handleEvent(Event event) {
            parent.removeComponentListener(listener);
          }
        });
    shell.setVisible(true);
    return shell;
  }
Example #12
0
 public void setVisible(boolean visible) {
   shell.setVisible(visible);
 }
 public void show() {
   if (!splash.isDisposed()) splash.setVisible(true);
 }
 public void hide() {
   if (!splash.isDisposed()) splash.setVisible(false);
 }
Example #15
0
 public void setVisible(boolean visible) {
   if (visible) prepareForOpen();
   shell.setVisible(visible);
 }
Example #16
0
  // Private constructor means you can't open an OPIShell without adding
  // it to the cache.
  private OPIShell(Display display, IPath path, MacrosInput macrosInput) throws Exception {
    this.path = path;
    this.macrosInput = macrosInput;
    icon =
        OPIBuilderPlugin.imageDescriptorFromPlugin(
                OPIBuilderPlugin.PLUGIN_ID, "icons/OPIRunner.png")
            .createImage(display);

    shell = new Shell(display);
    shell.setImage(icon);
    displayModel = new DisplayModel(path);
    displayModel.setOpiRuntime(this);
    actionRegistry = new ActionRegistry();

    viewer = new GraphicalViewerImpl();
    viewer.createControl(shell);
    viewer.setEditPartFactory(new WidgetEditPartFactory(ExecutionMode.RUN_MODE));
    viewer.setRootEditPart(
        new ScalableFreeformRootEditPart() {
          @Override
          public DragTracker getDragTracker(Request req) {
            return new DragEditPartsTracker(this);
          }

          @Override
          public boolean isSelectable() {
            return false;
          }
        });

    EditDomain editDomain =
        new EditDomain() {
          @Override
          public void loadDefaultTool() {
            setActiveTool(new RuntimePatchedSelectionTool());
          }
        };
    editDomain.addViewer(viewer);

    displayModel = createDisplayModel();
    setTitle();

    shell.setLayout(new FillLayout());
    shell.addShellListener(
        new ShellListener() {
          private boolean firstRun = true;

          public void shellIconified(ShellEvent e) {}

          public void shellDeiconified(ShellEvent e) {}

          public void shellDeactivated(ShellEvent e) {}

          public void shellClosed(ShellEvent e) {
            // Remove this shell from the cache.
            openShells.remove(OPIShell.this);
            sendUpdateCommand();
          }

          public void shellActivated(ShellEvent e) {
            if (firstRun) {
              // Resize the shell after it's open, so we can take into account different window
              // borders.
              // Do this only the first time it's activated.
              resizeToContents();
              shell.setFocus();
              firstRun = false;
            }
          }
        });
    shell.addDisposeListener(
        new DisposeListener() {

          @Override
          public void widgetDisposed(DisposeEvent e) {
            if (!icon.isDisposed()) icon.dispose();
          }
        });
    /*
     * Don't open the Shell here, as it causes SWT to think the window is on top when it really isn't.
     * Wait until the window is open, then call shell.setFocus() in the activated listener.
     *
     * Make some attempt at sizing the shell, sometimes a shell is not given focus and the shellActivated
     * listener callback doesn't resize the window. It's better to have something a little too large as the
     * default. Related to Eclipse bug 96700.
     */
    shell.setSize(
        displayModel.getSize().width + WINDOW_BORDER_X,
        displayModel.getSize().height + WINDOW_BORDER_Y);
    shell.setVisible(true);
  }
Example #17
0
  /**
   * show one popup menu over the main window
   *
   * @param menu_entry actual entry which should be shown or disposed
   * @param move TRUE if the curser be moved over one entry, otherwise by clicking false
   */
  private void show(String menu_entry, boolean move) {
    Point abs;
    Group popup;
    Rectangle rect, popup_rect = new Rectangle(0, 0, 120, 100);
    TreeNodes node;
    RowLayout l;
    ArrayList<TreeNodes> nodes;
    ArrayList<Composite> comps;

    if (move && m_sMenu.equals("")) {
      return;
    }
    if (!m_sMenu.equals(menu_entry)) {
      if (m_popupShell != null) m_popupShell.dispose();
      popup = m_mRootEntrys.get(menu_entry);
      rect = popup.getBounds();
      m_popupShell = new Shell(m_oTopLevelShell, SWT.NO_TRIM);
      // popup_rect= m_popupShell.getClientArea();
      abs = LayoutLoader.getAbsoluteUseFieldPoint();
      popup_rect.x = m_oMenu.getBounds().x + abs.x + rect.x;
      popup_rect.y = abs.y + rect.y + rect.height;
      l = new RowLayout();
      l.type = SWT.VERTICAL;
      l.pack = false;
      l.marginBottom = 0;
      l.marginHeight = 0;
      l.marginLeft = 0;
      l.marginRight = 0;
      l.marginTop = 0;
      l.marginWidth = 0;
      l.spacing = 0;
      m_popupShell.setLayout(l);
      node = m_mRootNodes.get(menu_entry);
      nodes = node.getChilds();
      m_sMenu = menu_entry;
      if (nodes.size() == 0) {
        m_sMenu = "";
        return;
      }
      comps = new ArrayList<Composite>();
      for (TreeNodes subnode : nodes) {
        RowLayout layout = new RowLayout();
        Composite comp = new Group(m_popupShell, SWT.NONE);
        Label text = new Label(comp, SWT.NONE);
        HashMap<String, String> metablock = subnode.getMetaData();
        String popupspace = metablock.get("popupspace");
        final String entry;
        int space = 20;
        FontObject font = new FontObject();
        int popupsize = 0;
        boolean bold = false;
        boolean italic = false;
        String looks, ssize;
        MouseListener listener1, listener2;

        entry = m_sMenu + "/" + subnode.getName();
        ssize = metablock.get("popupfontsize");
        if (ssize != null) popupsize = Integer.parseInt(ssize);
        looks = metablock.get("popupstyle");
        if (looks != null) {
          String[] split;

          split = looks.split(",");
          for (int i = 0; i < split.length; ++i) {
            split[i] = split[i].trim().toLowerCase();
            if (split[i].equals("bold")) bold = true;
            else if (split[i].equals("italic")) italic = true;
          }
        }
        font.defineColor(popup, metablock.get("popupcolor"), colors.WIDGET, entry + " popup");
        font.defineColor(popup, metablock.get("popupfontcolor"), colors.TEXT, entry + " popup");
        font.defineFont(
            popup, metablock.get("popupfont"), popupsize, bold, italic, /*underline*/ false);
        text.setText(subnode.getTitle().trim());
        if (popupspace != null) space = Integer.parseInt(popupspace);
        layout.type = SWT.VERTICAL;
        layout.marginTop = space;
        layout.marginRight = space;
        layout.marginBottom = space;
        layout.marginLeft = space;
        comp.setLayout(layout);
        font.setDevice(comp);
        font.setDevice(text);
        font.dispose();
        comps.add(comp);
        text.addMouseListener(
            listener1 =
                new MouseAdapter() {
                  public void mouseDown(MouseEvent event) {
                    LayoutLoader loader;
                    Thread t = null;

                    if (HtmTags.lockDebug) {
                      t = Thread.currentThread();
                      System.out.println(t.getName() + " want to setActiveSideVisible of " + entry);
                    }
                    loader = LayoutLoader.instance();
                    loader.m_sAktFolder = entry;
                    synchronized (TreeNodes.m_DISPLAYLOCK) {
                      loader.setCurrentSideVisible(/*inform server by no body*/ true);
                    }
                    m_nPopup = m_popupShell.getBounds();
                    destroyPopupShell();
                    m_sMenu = "";
                  }
                });
        m_aPopupListeners.put(text, listener1);
        comp.addMouseListener(
            listener2 =
                new MouseAdapter() {
                  public void mouseDown(MouseEvent event) {
                    LayoutLoader loader;
                    Thread t = null;

                    if (HtmTags.lockDebug) {
                      t = Thread.currentThread();
                      System.out.println(t.getName() + " want to setActiveSideVisible of " + entry);
                    }
                    loader = LayoutLoader.instance();
                    loader.m_sAktFolder = entry;
                    synchronized (TreeNodes.m_DISPLAYLOCK) {
                      loader.setCurrentSideVisible(/*inform server by no body*/ true);
                    }
                    m_nPopup = m_popupShell.getBounds();
                    destroyPopupShell();
                    m_sMenu = "";
                  }
                });
        m_aPopupListeners.put(comp, listener2);
      }

      if (m_nPopup != null) popup_rect = m_nPopup;
      m_popupShell.setBounds(popup_rect);
      m_popupShell.setEnabled(false);
      m_popupShell.setVisible(false);
      m_popupShell.open();
      m_popupShell.pack();
      m_popupShell.setEnabled(true);
      m_popupShell.setVisible(true);

    } else if (!m_sMenu.equals("") && !move) { // actual popup is the same
      m_popupShell.dispose();
      m_sMenu = "";
    }
  }