org.eclipse.swt.widgets.Shell#dispose ( )源码实例Demo

下面列出了org.eclipse.swt.widgets.Shell#dispose ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

/**
 * Internally compute completion proposals.
 *
 * @param cursorPosition
 *          the position of the cursor in the {@link IXtextDocument}
 * @param xtextDocument
 *          the {@link IXtextDocument}
 * @return a pair of {@link ICompletionProposal}[] and {@link BadLocationException}. If the tail argument is not {@code null}, an exception occurred in the UI
 *         thread.
 */
private Pair<ICompletionProposal[], BadLocationException> internalComputeCompletionProposals(final int cursorPosition, final IXtextDocument xtextDocument) {
  XtextSourceViewerConfiguration configuration = get(XtextSourceViewerConfiguration.class);
  Shell shell = new Shell();
  try {
    ISourceViewer sourceViewer = getSourceViewer(shell, xtextDocument, configuration);
    IContentAssistant contentAssistant = configuration.getContentAssistant(sourceViewer);
    String contentType = xtextDocument.getContentType(cursorPosition);
    IContentAssistProcessor processor = contentAssistant.getContentAssistProcessor(contentType);
    if (processor != null) {
      return Tuples.create(processor.computeCompletionProposals(sourceViewer, cursorPosition), null);
    }
    return Tuples.create(new ICompletionProposal[0], null);
  } catch (BadLocationException e) {
    return Tuples.create(new ICompletionProposal[0], e);
  } finally {
    shell.dispose();
  }
}
 
源代码2 项目: bonita-studio   文件: BonitaStudioApplication.java
protected void openErrorDialog(final Display display, final String javaVersion) {
    final Shell shell = new Shell(display);
    try {
        final Version version = Version.parseVersion(ProductVersion.CURRENT_VERSION);
        final String uriWithProductVersion = ONLINE_DOC_REQUIREMENTS + version.getMajor() + "."
                + version.getMinor();
        final URI uri = new URI(uriWithProductVersion);
        final MessageDialogWithLink messageDialog = new MessageDialogWithLink(shell,
                Messages.incompatibleJavaVersionTitle, null, String.format(
                        Messages.incompatibleJavaVersionMessage,
                        org.bonitasoft.studio.common.Messages.bonitaStudioModuleName, javaVersion,
                        "Java 1.8 and Java 11."),
                MessageDialog.ERROR,
                new String[] { IDialogConstants.OK_LABEL },
                0,
                uri);
        messageDialog.open();
    } catch (final URISyntaxException e) {
        BonitaStudioLog.error(e);
    } finally {
        shell.dispose();
    }
}
 
源代码3 项目: hop   文件: ControlSpaceKeyAdapter.java
private static final void applyChanges( Shell shell, List list, Control control, int position,
                                        IInsertText insertTextInterface ) {
  String selection =
    list.getSelection()[ 0 ].contains( Const.getDeprecatedPrefix() )
      ? list.getSelection()[ 0 ].replace( Const.getDeprecatedPrefix(), "" )
      : list.getSelection()[ 0 ];
  String extra = "${" + selection + "}";
  if ( insertTextInterface != null ) {
    insertTextInterface.insertText( extra, position );
  } else {
    if ( control.isDisposed() ) {
      return;
    }

    if ( list.getSelectionCount() <= 0 ) {
      return;
    }
    if ( control instanceof Text ) {
      ( (Text) control ).insert( extra );
    } else if ( control instanceof CCombo ) {
      CCombo combo = (CCombo) control;
      combo.setText( extra ); // We can't know the location of the cursor yet. All we can do is overwrite.
    } else if ( control instanceof StyledTextComp ) {
      ( (StyledTextComp) control ).insert( extra );
    } else if ( control instanceof StyledText ) {
      ( (StyledText) control ).insert( extra );
    }
  }
  if ( !shell.isDisposed() ) {
    shell.dispose();
  }
  if ( !control.isDisposed() ) {
    control.setData( Boolean.FALSE );
  }
}
 
源代码4 项目: birt   文件: TabbedPropertyTitle.java
/**
 * @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;
}
 
源代码5 项目: gef   文件: DotProposalProviderDelegator.java
private ICompletionProposal[] computeCompletionProposals(
		final IXtextDocument xtextDocument, int cursorPosition)
		throws BadLocationException {
	Shell shell = new Shell();
	try {
		return computeCompletionProposals(xtextDocument, cursorPosition,
				shell);
	} finally {
		shell.dispose();
	}
}
 
源代码6 项目: birt   文件: TabPageGeneratorTest.java
/**
 * Testcase for test createTabItems() method
 */
public void testCreateTabItems( )
{
	Shell shell = new Shell( );
	TabPageGenerator generator = new TabPageGenerator( );
	generator.createControl( shell, new ArrayList( ) );
	Control control = generator.getControl( );
	if(control instanceof CTabFolder)
	assertEquals( 0, ((CTabFolder)control).getItemCount( ) );
	shell.dispose( );
}
 
源代码7 项目: birt   文件: UIUtil.java
/**
 * Must run on UI thread
 * 
 * @return
 */
private static boolean test( )
{
	if ( !Constants.OS_WIN32.equalsIgnoreCase( Platform.getOS( ) )
			&& !Constants.OS_LINUX.equalsIgnoreCase( Platform.getOS( ) ) )
	{
		return false;
	}
	if ( !embeddedBrowserTested )
	{
		embeddedBrowserTested = true;
		Shell sh = new Shell( );
		try
		{
			new Browser( sh, SWT.NONE );
			embeddedBrowserAvailable = true;
		}
		catch ( SWTError se )
		{
			if ( se.code == SWT.ERROR_NO_HANDLES )
			{
				// Browser not implemented
				embeddedBrowserAvailable = false;
			}
		}
		catch ( Exception e )
		{
			// Browser not implemented
		}
		if ( sh != null && !sh.isDisposed( ) )
		{
			sh.dispose( );
		}
	}
	return embeddedBrowserAvailable;
}
 
源代码8 项目: goclipse   文件: AbstractWidgetTest.java
protected void runTestWithShell() {
	Shell shell = new Shell(Display.getDefault());
	try {

		doRunTest(shell);
	
	} finally {
		shell.dispose();
	}
}
 
public ContentAssistProcessorTestBuilder appendAndApplyProposal(String model, int position, String proposalString) throws Exception {
	IXtextDocument document = getDocument(getModel());
	Shell shell = new Shell();
	try {
		XtextSourceViewerConfiguration configuration = get(XtextSourceViewerConfiguration.class);
		ISourceViewer sourceViewer = getSourceViewer(shell, document, configuration);
		ICompletionProposal[] proposals = computeCompletionProposals(document, position, shell);
		ICompletionProposal proposal = findProposal(proposalString, proposals);
		return appendAndApplyProposal(proposal, sourceViewer, model, position);
	} finally {
		shell.dispose();
	}
}
 
public ContentAssistProcessorTestBuilder applyProposal(int position, String proposalString) throws Exception {
	IXtextDocument document = getDocument(getModel());
	Shell shell = new Shell();
	try {
		ICompletionProposal[] proposals = computeCompletionProposals(document, position, shell);
		ICompletionProposal proposal = findProposal(proposalString, proposals);
		return applyProposal(proposal, position, document);
	} finally {
		shell.dispose();
	}
}
 
protected ContentAssistProcessorTestBuilder applyProposal(ICompletionProposal proposal, int position, IXtextDocument document)
		throws Exception {
	Shell shell = new Shell();
	try {
		XtextSourceViewerConfiguration configuration = get(XtextSourceViewerConfiguration.class);
		ISourceViewer sourceViewer = getSourceViewer(shell, document, configuration);
		return appendAndApplyProposal(proposal, sourceViewer, model, position);
	} finally {
		shell.dispose();
	}
}
 
源代码12 项目: birt   文件: SubTotalProvider.java
public int[] columnWidths( )
{
	Shell shell = new Shell( );
	GC gc = new GC( shell );
	int height = gc.stringExtent( "" ).y;
	gc.dispose( );
	shell.dispose( );

	return new int[]{
			height + (int) ( ( ( (float) height ) / 12 ) * 8 ),
			210,
			120,
			120
	};
}
 
源代码13 项目: tmxeditor8   文件: ColumnStyleEditorDialog.java
@Override
protected void doFormClear(Shell shell) {
	this.newColumnCellStyle = null;
	shell.dispose();
}
 
protected void doFormCancel(Shell shell) {
	cancelPressed = true;
	shell.dispose();
}
 
protected void doFormClear(Shell shell) {
	shell.dispose();
}
 
@Override
protected void doFormClear(Shell shell) {
	this.newColumnCellStyle = null;
	shell.dispose();
}
 
源代码17 项目: birt   文件: ComboBoxColorCellEditor.java
protected Object openDialogBox( Control cellEditorWindow )
{
	Shell shell = new Shell( Display.getCurrent( ), SWT.SHELL_TRIM );
	shell.setLocation( cellEditorWindow.toDisplay( 0, 0 ).x
			+ cellEditorWindow.getBounds( ).width,
			cellEditorWindow.toDisplay( 0, 0 ).y
					- cellEditorWindow.getBounds( ).height );
	ColorDialog dialog = new ColorDialog( shell, SWT.APPLICATION_MODAL );
	RGB[] rgbs = ReportPlugin.getDefault( ).getCustomColorsPreference( );
	if ( rgbs != null )
	{
		dialog.setRGBs( rgbs );
	}
	Object value = getValue( );

	try
	{
		int color;

		if ( value instanceof String )
		{
			color = ColorUtil.parseColor( (String) value );
		}
		else
		{
			color = ( (Integer) value ).intValue( );
		}

		dialog.setRGB( DEUtil.getRGBValue( color ) );

	}
	catch ( Exception e )
	{
		// ignore.
	}

	value = dialog.open( );
	ReportPlugin.getDefault( )
			.setCustomColorsPreference( dialog.getRGBs( ) );
	if ( value != null && dialog.getRGB( ) != null )
	{
		deactivate( );
		return ColorUtil.format( ColorUtil.formRGB( dialog.getRGB( ).red,
				dialog.getRGB( ).green,
				dialog.getRGB( ).blue ), ColorUtil.HTML_FORMAT );
	}
	comboBox.setFocus( );
	shell.dispose( );
	return value;
}
 
源代码18 项目: tmxeditor8   文件: ColumnRenameDialog.java
@Override
protected void doFormOK(Shell shell) {
	renamedColumnLabel = columnLabelPanel.getNewValue();
	shell.dispose();
}
 
源代码19 项目: tmxeditor8   文件: AbstractStyleEditorDialog.java
protected void doFormClear(Shell shell) {
	shell.dispose();
}
 
public void close() {
	Shell shell = table.getShell();

	if (shell != null && !shell.isDisposed())
		shell.dispose();
}