@Test
 public void test_setParentLorg_eclipse_swt_widgets_Composite() {
   if (control.isReparentable()) {
     Shell originalParent = new Shell();
     Shell newParent = new Shell();
     Button b = new Button(originalParent, SWT.PUSH);
     b.setParent(newParent);
     originalParent.dispose();
     assertTrue(!b.isDisposed());
     newParent.dispose();
   }
 }
  public void fireFileObjectDoubleClicked(FileObject selectedItem) {
    if (fileDialogMode != VFS_DIALOG_SAVEAS) {
      // let's try drilling into the file as a new vfs root first

      String scheme = null;
      if (selectedItem.getName().getExtension().contains("jar")) {
        scheme = "jar:";
      } else if (selectedItem.getName().getExtension().contains("zip")) {
        scheme = "zip:";
      } else if (selectedItem.getName().getExtension().contains("gz")) {
        scheme = "gz:";
      } else if (selectedItem.getName().getExtension().contains("war")) {
        scheme = "war:";
      } else if (selectedItem.getName().getExtension().contains("ear")) {
        scheme = "ear:";
      } else if (selectedItem.getName().getExtension().contains("sar")) {
        scheme = "sar:";
      } else if (selectedItem.getName().getExtension().contains("tar")) {
        scheme = "tar:";
      } else if (selectedItem.getName().getExtension().contains("tbz2")) {
        scheme = "tbz2:";
      } else if (selectedItem.getName().getExtension().contains("tgz")) {
        scheme = "tgz:";
      } else if (selectedItem.getName().getExtension().contains("bz2")) {
        scheme = "bz2:";
      }

      if (scheme != null) {
        try {
          FileObject jarFileObject =
              selectedItem
                  .getFileSystem()
                  .getFileSystemManager()
                  .resolveFile(scheme + selectedItem.getName().getURI());
          vfsBrowser.resetVfsRoot(jarFileObject);
          updateParentFileCombo(jarFileObject);
          vfsBrowser.fileSystemTree.forceFocus();
        } catch (FileSystemException e) {
          e.printStackTrace();
          okPressed = true;
          hideCustomPanelChildren();
          dialog.dispose();
        }
      } else {
        okPressed = true;
        hideCustomPanelChildren();
        dialog.dispose();
      }

    } else {
      // anything?
    }
  }
示例#3
0
 @Override
 protected void tearDown() throws Exception {
   node.deactivate(null);
   removeExtension("sub.module.view.test");
   shell.dispose();
   super.tearDown();
 }
 private void disposeOfCurrentTipShell() {
   if (tipShell != null) {
     tipShell.dispose();
     tipShell = null;
   }
   tipWidget = null;
 }
  public static void main(String[] args) {

    //	if (args.length == 0) {
    //		System.out.println("Usage: java Main <program id>");
    //		return;
    //	}
    //
    //	String progID = args[0];

    String progID = "WMPlayer.OCX";
    //	String progID = "RealPlayX.OCX";

    Display display = new Display();
    Shell shell = new Shell(display);

    OleFrame frame = new OleFrame(shell, SWT.NONE);
    OleControlSite site = null;
    OleAutomation auto = null;
    try {
      site = new OleControlSite(frame, SWT.NONE, progID);
      auto = new OleAutomation(site);
    } catch (SWTException ex) {
      System.out.println("Unable to open type library for " + progID);
      display.dispose();
      return;
    }

    printTypeInfo(auto);

    auto.dispose();
    shell.dispose();
    display.dispose();
  }
 public void dispose() {
   props.setScreen(new WindowProperty(shell));
   bounds = shell.getBounds();
   hscroll = wFields.getHorizontalBar().getSelection();
   vscroll = wFields.getVerticalBar().getSelection();
   shell.dispose();
 }
示例#7
0
  /** destroy exist menu pop-up shell when open */
  public void destroyPopupShell() {
    if (m_popupShell == null) return;
    // Alexander Kolli 01/02/2014
    // do not need to remove mouse listeners
    // when I dispose the widget
    /*		DisplayAdapter.syncExec(new Runnable() {

    	public void run()
    	{
    		for(Control key : m_aPopupListeners.keySet())
    		{
    			MouseListener listener;

    			listener= m_aPopupListeners.get(key);
    			if(listener != null)
    			{
    				key.removeMouseListener(listener);
    				m_aPopupListeners.remove(key);
    			}
    		}
    	}
    });*/
    m_aPopupListeners.clear();
    m_popupShell.dispose();
    m_sMenu = "";
    m_popupShell = null;
  }
示例#8
0
  private void clickQuit() {

    // TODO disconnect and so on if relevant

    // TODO confirmation
    shell.dispose();
  }
示例#9
0
  public void run(String trace) throws JDOMException, IOException, JniException {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Flightbox");
    shell.setSize(800, 800);
    shell.setLayout(new FillLayout(SWT.VERTICAL));

    IntervalView widget = new IntervalView(shell, SWT.NONE);
    VersionizedStack<String> stack = new VersionizedStack<String>();
    int i;
    int max = 1000;
    for (i = 0; i < max; i++) {
      long disp = i * 100;
      stack.push("FOO", 10L + disp);
      stack.push("BAR", 20L + disp);
      stack.pop(30L + disp);
      stack.pop(40L + disp);
    }

    widget.setStack(stack);

    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }

    shell.dispose();
  }
示例#10
0
  public static void view(DrawModel d) {
    final Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());

    Composite composite = new Composite(shell, SWT.EMBEDDED | SWT.NO_BACKGROUND);
    Frame baseFrame = SWT_AWT.new_Frame(composite);

    baseFrame.setBounds(0, 0, 800, 600);

    Java3DViewer viewer = new Java3DViewer(baseFrame, d);
    baseFrame.add(viewer);

    shell.open();

    d.setFaceColor(Color.GREEN);
    d.circle(0.9);
    //		viewer.draw(d);

    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }

    baseFrame.dispose();
    shell.dispose();
    composite.dispose();
    display.dispose();
    System.exit(0);
  }
  public void dispose() {
    shell.dispose();
    if (trayItem != null) {
      trayItem.dispose();
      trayItem = null;
    }

    if (image != null) {
      image.dispose();
    }
    if (image2 != null) {
      image2.dispose();
    }
    try {
      if (!display.isDisposed()) {
        display.dispose();
      }
    } catch (Exception e) {
      // already disposed
    }
    // dispose AWT frames
    if (settingsFrame != null) {
      settingsFrame.dispose();
    }
    if (aboutFrame != null) {
      aboutFrame.dispose();
    }
    if (logBrokerMonitor != null) {
      logBrokerMonitor.dispose();
    }
  }
 protected void doTearDown() throws Exception {
   theShell.dispose();
   theShell = null;
   //		img.dispose();
   //		img2.dispose();
   super.doTearDown();
 }
示例#13
0
 public void shutDownDisplay() {
   Shell[] childrenShells = this.getShell().getShells();
   for (Shell child : childrenShells) {
     child.dispose();
   }
   this.chartDisplayStrategy.shutDownDisplay();
 }
  @Override
  protected String browse(final Presentation context) {
    final Property property = property();

    final Shell parent = ((FormComponentPresentation) context).shell();
    final Rectangle bounds = parent.getBounds();

    // There is no means to compute the size of the color dialog. In the following
    // computations, measurements of the dialog on Windows 7 are used. Will need to
    // generalize in the future.

    final int x = bounds.x + bounds.width / 2 - 120;
    final int y = bounds.y + bounds.height / 2 - 170;

    final Shell shell = new Shell(parent);

    try {
      shell.setBounds(x, y, 0, 0);

      final ColorDialog dialog = new ColorDialog(shell);

      dialog.setText(property.definition().getLabel(false, CapitalizationType.TITLE_STYLE, false));
      dialog.setRGB(convert((Color) ((Value<?>) property).content()));

      final RGB pickedColor = dialog.open();

      if (pickedColor != null) {
        return convert(pickedColor).toString();
      }
    } finally {
      shell.dispose();
    }

    return null;
  }
示例#15
0
 /** @return the height of the title. */
 public int getHeight() {
   Shell shell = new Shell();
   GC gc = new GC(shell);
   gc.setFont(getFont());
   Point point = gc.textExtent(BLANK);
   point.x++;
   int textOrImageHeight = Math.max(point.x, 16);
   gc.dispose();
   shell.dispose();
   return textOrImageHeight + 8;
 }
示例#16
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();
  }
  public void okPressed() {
    if (fileDialogMode == VFS_DIALOG_SAVEAS && "".equals(fileNameText.getText())) { // $NON-NLS-1$
      // do nothing, user did not enter a file name for saving
      MessageBox messageDialog = new MessageBox(dialog, SWT.OK);
      messageDialog.setText(Messages.getString("VfsFileChooserDialog.error")); // $NON-NLS-1$
      messageDialog.setMessage(
          Messages.getString("VfsFileChooserDialog.noFilenameEntered")); // $NON-NLS-1$
      messageDialog.open();
      return;
    }

    if (fileDialogMode == VFS_DIALOG_SAVEAS) {
      try {
        FileObject toBeSavedFile =
            vfsBrowser.getSelectedFileObject().resolveFile(fileNameText.getText());
        if (toBeSavedFile.exists()) {
          MessageBox messageDialog = new MessageBox(dialog, SWT.YES | SWT.NO);
          messageDialog.setText(
              Messages.getString("VfsFileChooserDialog.fileExists")); // $NON-NLS-1$
          messageDialog.setMessage(
              Messages.getString("VfsFileChooserDialog.fileExistsOverwrite")); // $NON-NLS-1$
          int flag = messageDialog.open();
          if (flag == SWT.NO) {
            return;
          }
        }
      } catch (FileSystemException e) {
        e.printStackTrace();
      }
    }
    if (fileDialogMode == VFS_DIALOG_SAVEAS) {
      enteredFileName = fileNameText.getText();
    }

    try {
      if (fileDialogMode == VFS_DIALOG_OPEN_FILE
          && vfsBrowser.getSelectedFileObject().getType().equals(FileType.FOLDER)) {
        // try to open this node, it is a directory
        vfsBrowser.selectTreeItemByFileObject(vfsBrowser.getSelectedFileObject(), true);
        return;
      }
    } catch (FileSystemException e) {
    }

    okPressed = true;
    hideCustomPanelChildren();
    dialog.dispose();
  }
        @Override
        public void widgetSelected(SelectionEvent e) {
          exitApplicationWhenWindowCloses = false;

          int selectedHostIndexInTable = hostTable.getSelectionIndex();
          try {
            app.openRemoteTerminalWindow(app.hostManager.get(selectedHostIndexInTable));
          } catch (Exception ex) {
            MessageBox dialog = new MessageBox(connectToHostShell, SWT.ICON_ERROR | SWT.OK);
            dialog.setText("My info");
            dialog.setMessage("Failed to connect because " + ex.toString());
          }

          connectToHostShell.close();
          connectToHostShell.dispose();
        }
示例#19
0
  private void onDispose(final Event event) {

    if (_shell == null || _shell.isDisposed()) {
      return;
    }

    // hide tooltip definitively

    removeOwnerShellListener();
    removeDisplayFilterListener();

    // deactivate auto close timer
    _display.timerExec(-1, _ttAutoCloseTimer);

    _shell.dispose();
  }
  /** Create the TableViewer */
  private void okSelected() {
    ArrayList<ArtifactModel> artifactList =
        relationTableViewer.getArtifactList().getArtifactModel();

    for (int i = 0; i < artifactList.size(); i++) {
      ArtifactModel model = artifactList.get(i);

      if (model.isAdd()) {
        Artifact artifact = model.getArtifact();
        descriptor = model.getDescriptor();
        if (artifact == null) {
          if (descriptor != null) {
            try {
              artifact = ArtifactTypeManager.addArtifact(descriptor, branch);
              artifact.setName(model.getName());
              artifact.setSoleAttributeValue(
                  CoreAttributeTypes.ContentUrl, urls.get(names.indexOf(model.getName())));
              artifact.persist(getClass().getSimpleName());
            } catch (Exception ex) {
              OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex);
            }
          }
        } else {
          artifact = model.getArtifact();
        }

        if (artifact != null) {
          try {
            relationGroup.getArtifact().addRelation(relationGroup, artifact);
          } catch (OseeCoreException ex) {
            OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex);
          }
        }
      }
    }
    if (persistOnOk) {
      try {
        relationGroup.getArtifact().persist(getClass().getSimpleName());
      } catch (OseeCoreException ex) {
        OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex);
      }
    }
    shell.dispose();
    viewer.refresh();
  }
  public void testWizardDispose() {
    wizard.setThrowExceptionOnDispose(true);

    final boolean logged[] = new boolean[1];
    Policy.setLog(
        new ILogger() {
          @Override
          public void log(IStatus status) {
            logged[0] = true;
          }
        });
    Shell shell = dialog.getShell();
    dialog.close();

    assertTrue(logged[0]);

    shell.dispose();
  }
  /*
   * main method for testing only
   */
  public static void main(String[] args) {
    Shell myShell = new Shell(Display.getCurrent(), SWT.CLOSE | SWT.RESIZE);
    myShell.setLayout(new FormLayout());

    GroupPanel gp = new GroupPanelForTemporalEventAnchor(myShell, SWT.None);
    gp.setLayoutData(FormDataMaker.makeFullFormData());

    myShell.setSize(550, 200);

    myShell.open();
    while (!myShell.isDisposed()) {
      if (!Display.getCurrent().readAndDispatch()) Display.getCurrent().sleep();
    }
    if (!myShell.isDisposed()) {
      myShell.close();
      myShell.dispose();
    }
  }
示例#23
0
 public boolean edit(IParameters params, boolean readOnly, IContext context) {
   boolean bRes = false;
   try {
     this.projectDir = context.getString("projDir");
     help = (IHelp) context.getObject("help");
     this.params = (Parameters) params;
     shell =
         new Shell(
             (Shell) context.getObject("shell"),
             SWT.CLOSE | SWT.TITLE | SWT.RESIZE | SWT.APPLICATION_MODAL);
     create((Shell) context.getObject("shell"), readOnly);
     return showDialog();
   } catch (Exception e) {
     Dialogs.showError(shell, e.getLocalizedMessage(), null);
     bRes = false;
   } finally {
     // Dispose of the shell, but not of the display
     if (shell != null) shell.dispose();
   }
   return bRes;
 }
示例#24
0
    protected void close(boolean ok) {
      if (ok) {

        if (username == null) {

          username = "";
        }

        if (password == null) {

          password = "";
        }

      } else {

        username = null;
        password = null;
      }

      shell.dispose();
      sem.release();
    }
示例#25
0
  protected void close(boolean ok, boolean check_on_startup) {
    if (check_on_startup
        != COConfigurationManager.getBooleanParameter("config.interface.checkassoc")) {

      COConfigurationManager.setParameter("config.interface.checkassoc", check_on_startup);

      COConfigurationManager.save();
    }

    if (ok) {

      try {
        platform.registerApplication();

      } catch (PlatformManagerException e) {

        Debug.printStackTrace(e);
      }
    }

    shell.dispose();
  }
示例#26
0
  protected void buttonPressed() {
    userId = userText.getText();
    password = passwordText.getText();

    if (userId.trim().equals("")) {
      setMessage(ERROR_TIPS_EMPTYUSERNAME, userText);
      return;
    }

    if (invalidCharInUserId(userId)) {
      setMessage(ERROR_TIPS_INVALIDUSERNAME + INVALID_CHARS, userText);
      return;
    }
    if (password.trim().equals("")) {
      setMessage(ERROR_TIPS_EMPTYPSW, passwordText);
      return;
    }

    String loginMessage = UserSessionContext.getSession().login(userId, password);
    if (loginMessage == null) {
      if (isSavedUserId()) {
        try {
          RWT.getSettingStore().setAttribute(COOKIE_UI_USERID, userId);
        } catch (IOException e) {
        }
      }
      if (isSavedUserPassword()) {
        try {
          RWT.getSettingStore().setAttribute(COOKIE_UI_PASSWORD, password);
        } catch (IOException e) {
        }
      }
      // ͨ¹ýÁËÑéÖ¤
      shell.dispose();
    } else {
      setMessage(loginMessage, passwordText);
    }
  }
  /*
   * Report the specified execution exception to the log and to the user.
   */
  private void reportException(Exception e, IAdaptable uiInfo) {
    Throwable nestedException = StatusUtil.getCause(e);
    Throwable exception = (nestedException == null) ? e : nestedException;
    String title = WorkbenchMessages.Error;
    String message = WorkbenchMessages.WorkbenchWindow_exceptionMessage;
    String exceptionMessage = exception.getMessage();
    if (exceptionMessage == null) {
      exceptionMessage = message;
    }
    IStatus status =
        new Status(IStatus.ERROR, WorkbenchPlugin.PI_WORKBENCH, 0, exceptionMessage, exception);
    WorkbenchPlugin.log(message, status);

    boolean createdShell = false;
    Shell shell = getShell(uiInfo);
    if (shell == null) {
      createdShell = true;
      shell = new Shell();
    }
    ErrorDialog.openError(shell, title, message, status);
    if (createdShell) {
      shell.dispose();
    }
  }
  private boolean addFields() {
    // int middle = props.getMiddlePct();
    int margin = Const.MARGIN;

    if (wlFields == null) {
      wlFields = new Label(shell, SWT.LEFT);
      wlFields.setText(message);
      props.setLook(wlFields);
      fdlFields = new FormData();
      fdlFields.left = new FormAttachment(0, 0);
      fdlFields.right = new FormAttachment(100, 0);
      fdlFields.top = new FormAttachment(0, margin);
      wlFields.setLayoutData(fdlFields);
    } else {
      wFields.dispose();
    }

    if (dynamic && rowMeta == null) {
      rowMeta = new RowMeta();
      rowMeta.addValueMeta(new ValueMeta("<waiting for rows>", ValueMetaInterface.TYPE_STRING));
      waitingForRows = true;
    }
    if (!dynamic) {
      // Mmm, if we don't get any rows in the buffer: show a dialog box.
      if (buffer == null || buffer.size() == 0) {
        ShowMessageDialog dialog =
            new ShowMessageDialog(
                shell,
                SWT.OK | SWT.ICON_WARNING,
                BaseMessages.getString(PKG, "PreviewRowsDialog.NoRows.Text"),
                BaseMessages.getString(PKG, "PreviewRowsDialog.NoRows.Message"));
        dialog.open();
        shell.dispose();
        return true;
      }
    }

    // ColumnInfo[] colinf = new ColumnInfo[rowMeta==null ? 0 : rowMeta.size()];
    ColumnInfo[] colinf = new ColumnInfo[rowMeta.size()];
    for (int i = 0; i < rowMeta.size(); i++) {
      ValueMetaInterface v = rowMeta.getValueMeta(i);
      colinf[i] = new ColumnInfo(v.getName(), ColumnInfo.COLUMN_TYPE_TEXT, v.isNumeric());
      colinf[i].setToolTip(v.toStringMeta());
      colinf[i].setValueMeta(v);
    }

    wFields =
        new TableView(
            variables, shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, colinf, 0, null, props);

    fdFields = new FormData();
    fdFields.left = new FormAttachment(0, 0);
    fdFields.top = new FormAttachment(wlFields, margin);
    fdFields.right = new FormAttachment(100, 0);
    fdFields.bottom = new FormAttachment(100, -50);
    wFields.setLayoutData(fdFields);

    if (dynamic) {
      shell.layout(true, true);
    }

    return false;
  }
 public void dispose() {
   props.setScreen(new WindowProperty(shell));
   shell.dispose();
 }
 private void cancelSelected() {
   cancelled = true;
   shell.dispose();
 }