org.eclipse.swt.events.DisposeEvent Java Examples

The following examples show how to use org.eclipse.swt.events.DisposeEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VerticalList.java    From scava with Eclipse Public License 2.0 6 votes vote down vote up
public void add(Composite composite) {
	composite.setParent(this);
	composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	
	composite.addDisposeListener(new DisposeListener() {
		
		@Override
		public void widgetDisposed(DisposeEvent e) {
			if( composite.getParent() == VerticalList.this ) {
				remove(composite);
			}
		}
	});
	
	notifyParentScrolledComposite();
}
 
Example #2
Source File: FontUtils.java    From BiglyBT with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Change the height of the installed <code>Font</code> and takes care of disposing
 * the new font when the control is disposed
 * @param control
 * @param height
 * @param style one or both of SWT.BOLD, SWT.ITALIC, or SWT.NORMAL
 */
public static void setFontHeight(Control control, int height, int style) {
	FontData[] fDatas = control.getFont().getFontData();
	for (FontData fData : fDatas) {
		fData.height = height;
		fData.setStyle(style);
	}
	final Font newFont = new Font(control.getDisplay(), fDatas);
	control.setFont(newFont);
	control.addDisposeListener(new DisposeListener() {

		@Override
		public void widgetDisposed(DisposeEvent e) {
			if (!newFont.isDisposed()) {
				newFont.dispose();
			}
		}
	});
}
 
Example #3
Source File: DiskWindow.java    From AppleCommander with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Setup the Disk window and display (open) it.
 */
public void open() {
	shell = new Shell(parentShell, SWT.SHELL_TRIM);
	shell.setLayout(new FillLayout());
	shell.setImage(imageManager.get(ImageManager.ICON_DISK));
	setStandardWindowTitle();
	shell.addDisposeListener(new DisposeListener() {
			public void widgetDisposed(DisposeEvent event) {
				dispose(event);
			}
		});
		
	CTabFolder tabFolder = new CTabFolder(shell, SWT.BOTTOM);
	new DiskExplorerTab(tabFolder, disks, imageManager, this);
	diskMapTabs = new DiskMapTab[disks.length];
	for (int i=0; i<disks.length; i++) {
		if (disks[i].supportsDiskMap()) {
			diskMapTabs[i] = new DiskMapTab(tabFolder, disks[i]);
		}
	}
	diskInfoTab = new DiskInfoTab(tabFolder, disks);
	tabFolder.setSelection(tabFolder.getItems()[0]);
	
	
	shell.open();
}
 
Example #4
Source File: Win7RendererSupport.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * @param agrid
 *
 */
private Win7RendererSupport(Grid agrid) {
	this.grid = agrid;
	this.palette = new Win7PaletteProvider();
	grid.addDisposeListener(new DisposeListener() {
		public void widgetDisposed(DisposeEvent e) {
			grid.removeDisposeListener(this);
			if (palette != null) {
				palette.dispose();
			}
			headerRenderer = null;
			emptyHeaderRenderer = null;
			groupHeaderRenderer = null;
		}
	});
}
 
Example #5
Source File: TreeItemAccelerator.java    From hop with Apache License 2.0 6 votes vote down vote up
public static final void addDoubleClick( final TreeItem treeItem, final IDoubleClick doubleClick ) {
  final String[] path1 = ConstUi.getTreeStrings( treeItem );
  final Tree tree = treeItem.getParent();

  if ( doubleClick != null ) {
    final SelectionAdapter selectionAdapter = new SelectionAdapter() {
      public void widgetDefaultSelected( SelectionEvent selectionEvent ) {
        TreeItem[] items = tree.getSelection();
        for ( int i = 0; i < items.length; i++ ) {
          String[] path2 = ConstUi.getTreeStrings( items[ i ] );
          if ( equalPaths( path1, path2 ) ) {
            doubleClick.action( treeItem );
          }
        }
      }
    };
    tree.addSelectionListener( selectionAdapter );

    // Clean up when we do a refresh too.
    treeItem.addDisposeListener( new DisposeListener() {
      public void widgetDisposed( DisposeEvent disposeEvent ) {
        tree.removeSelectionListener( selectionAdapter );
      }
    } );
  }
}
 
Example #6
Source File: CodeRecommendationView.java    From scava with Eclipse Public License 2.0 6 votes vote down vote up
public void showPreview(CodeRecommendationPreviewView view) {
	view.getComposite().setParent(previewComposite);

	StackLayout layout = (StackLayout) previewComposite.getLayout();
	layout.topControl = view.getComposite();

	view.getComposite().addDisposeListener(new DisposeListener() {

		@Override
		public void widgetDisposed(DisposeEvent e) {
			layout.topControl = lblSelectAPattern;
		}
	});

	Display.getDefault().syncExec(() -> {
		previewComposite.pack();
		previewComposite.requestLayout();
	});
}
 
Example #7
Source File: ServersViewer.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
public ServersViewer ( final Composite parent )
{
    parent.setLayout ( new FillLayout () );
    this.viewer = new TreeViewer ( parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL );

    this.contentProvider = new ObservableSetTreeContentProvider ( new ObservableFactoryImpl (), null );
    this.viewer.setContentProvider ( this.contentProvider );
    this.labelProvider = new ServerLabelProvider ( this.contentProvider.getKnownElements () );
    this.viewer.setLabelProvider ( this.labelProvider );

    this.viewer.setInput ( HivesPlugin.getDefault ().getServerManager () );
    this.viewer.getControl ().addDisposeListener ( new DisposeListener () {

        @Override
        public void widgetDisposed ( final DisposeEvent e )
        {
            handleDispose ();
        }
    } );

    ColumnViewerToolTipSupport.enableFor ( this.viewer );
}
 
Example #8
Source File: BlockedIpsWindow.java    From BiglyBT with GNU General Public License v2.0 6 votes vote down vote up
public static void
show(
		Core _core,
Display 		display,
String 			ipsBlocked,
String 			ipsBanned)
{
    if(instance == null || instance.isDisposed())
    {
        instance = create(_core, display, ipsBlocked, ipsBanned);
        instance.addDisposeListener(new DisposeListener() {
            @Override
            public void widgetDisposed(DisposeEvent event) {
                instance = null;
            }
        });
    }
    else
    {
        instance.open();
    }
}
 
Example #9
Source File: CallbackDialog.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
private Composite createComposite ( final Composite wrapper )
{
    this.dbc = new DataBindingContext ( DisplayRealm.getRealm ( wrapper.getDisplay () ) );

    wrapper.addDisposeListener ( new DisposeListener () {

        @Override
        public void widgetDisposed ( final DisposeEvent e )
        {
            CallbackDialog.this.dbc.dispose ();
        }
    } );

    final Composite composite = new Composite ( wrapper, SWT.NONE );
    composite.setLayout ( new GridLayout ( 2, false ) );

    for ( final CallbackWidgetFactory factory : this.factories )
    {
        factory.createGridWidgets ( this.dbc, composite );
    }

    return composite;
}
 
Example #10
Source File: VisibilityTester.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
private void checkCreateDialog ()
{
    if ( this.dialog != null )
    {
        return;
    }

    this.dialog = new Shell ();
    this.dialog.setText ( "Visibility Tester" );
    this.dialog.open ();
    this.dialog.setLayout ( new GridLayout ( 1, false ) );
    this.dialog.addDisposeListener ( new DisposeListener () {

        @Override
        public void widgetDisposed ( final DisposeEvent e )
        {
            VisibilityTester.this.dialog = null;
        }
    } );
}
 
Example #11
Source File: SearchView.java    From scava with Eclipse Public License 2.0 6 votes vote down vote up
public void addSearchTab(String title, ITab<?> view) {
	CTabItem tab = new CTabItem(searchTabs, SWT.NONE);
	tab.setText(title);

	Composite composite = view.getComposite();
	composite.setParent(searchTabs);

	tab.setControl(composite);

	searchTabs.setSelection(tab);

	// this part is a bit hacky, but there is no other way to notify the view about
	// the dispose
	tab.addDisposeListener(new DisposeListener() {
		public void widgetDisposed(DisposeEvent e) {
			view.closed();
		}
	});
}
 
Example #12
Source File: DataItemLabel.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
public DataItemLabel ( final Composite composite, final String connectionId, final String itemId )
{
    this.label = new CLabel ( composite, SWT.NONE );
    this.dataItem = new DataItemObservableValue ( Activator.getDefault ().getBundle ().getBundleContext (), connectionId, itemId );
    this.label.addDisposeListener ( new DisposeListener () {

        @Override
        public void widgetDisposed ( final DisposeEvent e )
        {
            handleDispose ();
        }
    } );
    this.model = PojoObservables.observeDetailValue ( this.dataItem, "value", Variant.class ); //$NON-NLS-1$
    this.dbc = new DataBindingContext ();

    bind ();
}
 
Example #13
Source File: MiniSelector.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
private void create(Composite parent) {
  displayExecutor = DisplayExecutor.create(parent.getDisplay());
  comboViewer = new ComboViewer(parent, SWT.READ_ONLY | SWT.DROP_DOWN);
  comboViewer.setComparator(new ViewerComparator());
  comboViewer.setLabelProvider(new LabelProvider() {
    @Override
    public String getText(Object element) {
      if (element instanceof GcpProject) {
        GcpProject project = (GcpProject) element;
        return project.getName() + " (" + project.getId() + ")";
      }
      return super.getText(element);
    }
  });
  comboViewer.setContentProvider(ArrayContentProvider.getInstance());
  comboViewer.setInput(EMPTY_PROJECTS);
  parent.addDisposeListener(new DisposeListener() {
    @Override
    public void widgetDisposed(DisposeEvent event) {
      cancelFetch();
    }
  });

  fetch();
}
 
Example #14
Source File: FontUtil.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
/**
 * Converts the font of the control by adding a single style bit, unless the font already have
 * that style.
 * <p>
 * If the font is converted, it will attach a {@link DisposeListener}
 * to the <code>control</code> to dispose the font when it's not needed anymore.
 * <p>
 * <em>If converting fonts is a frequent operation, this method will create
 * several {@link DisposeListener}s that can lead to high resource allocation</em>
 *
 * @param control whose font will be changed
 * @param style e.g. SWT.BOLD or SWT.ITALIC
 */
public static void convertFont(Control control, int style) {
  for (FontData fontData : control.getFont().getFontData()) {
    if (hasStyle(fontData, style)) {
      return;
    }
  }
  FontDescriptor fontDescriptor = FontDescriptor.createFrom(control.getFont()).setStyle(style);
  final Font newFont = fontDescriptor.createFont(control.getDisplay());
  control.setFont(newFont);
  control.addDisposeListener(new DisposeListener() {
    @Override
    public void widgetDisposed(DisposeEvent event) {
      newFont.dispose();
    }
  });
}
 
Example #15
Source File: ToolBarNavigator.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
public ToolBarNavigator ( final Composite parent, final int style, final ViewManager viewManager )
{
    this.viewManager = viewManager;
    this.toolbar = new ToolBar ( parent, style );
    this.resourceManager = new LocalResourceManager ( JFaceResources.getResources ( parent.getDisplay () ) );

    this.toolbar.addDisposeListener ( new DisposeListener () {

        @Override
        public void widgetDisposed ( final DisposeEvent e )
        {
            handleDispose ();
        }
    } );

    viewManager.addViewManagerListener ( this );
}
 
Example #16
Source File: CTreeComboViewer.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
/** 
 * @see org.eclipse.jface.viewers.StructuredViewer#mapElement(java.lang.Object, org.eclipse.swt.widgets.Widget)
 */
protected void mapElement(Object element, final Widget item) {
	super.mapElement(element, item);
	// make sure to unmap elements if the tree is virtual
	if ((getTree().getStyle() & SWT.VIRTUAL) != 0) {
		// only add a dispose listener if item hasn't already on assigned
		// because it is reused
		if (item.getData(VIRTUAL_DISPOSE_KEY) == null) {
			item.setData(VIRTUAL_DISPOSE_KEY, Boolean.TRUE);
			item.addDisposeListener(new DisposeListener() {
				public void widgetDisposed(DisposeEvent e) {
					if (!treeIsDisposed) {
						Object data = item.getData();
						if (usingElementMap() && data != null) {
							unmapElement(data, item);
						}
					}
				}
			});
		}
	}
}
 
Example #17
Source File: VTracker.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
public void widgetDisposed(DisposeEvent e) {
	VTracker tracker = instance();
	if(tracker.panels != null && tracker.panels.containsKey(e.widget)) {
		tracker.panels.remove(e.widget);
		if(tracker.panels.isEmpty()) {
			Display.getDefault().removeFilter(SWT.FocusIn, tracker.filter);
			Display.getDefault().removeFilter(SWT.MouseMove, tracker.filter);
			Display.getDefault().removeFilter(SWT.MouseDown, tracker.filter);
			Display.getDefault().removeFilter(SWT.MouseUp, tracker.filter);
			Display.getDefault().removeFilter(SWT.Traverse, tracker.filter);
			tracker.listening = false;
			if(activeControl != null) {
				Control control = activeControl.getControl();
				if(control != null && !control.isDisposed()) {
					control.dispose();
				}
			}
			tracker.panels = null;
		}
	}
}
 
Example #18
Source File: ChartViewerPane.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
public void createControl ( final Composite parent )
{
    this.wrapper = new Composite ( parent, SWT.NONE );
    this.wrapper.setLayout ( GridLayoutFactory.slimStack () );

    final Composite extensionSpace = new Composite ( this.wrapper, SWT.NONE );
    extensionSpace.setLayoutData ( new GridData ( SWT.FILL, SWT.FILL, true, false ) );
    extensionSpace.setLayout ( new RowLayout ( SWT.HORIZONTAL ) );
    this.chartArea = new ChartArea ( this.wrapper, SWT.NONE );
    this.chartArea.setLayoutData ( new GridData ( SWT.FILL, SWT.FILL, true, true ) );
    this.viewer = new ChartViewer ( this.chartArea.getDisplay (), this.chartArea.getChartRenderer (), this.configuration, new CompositeExtensionSpace ( extensionSpace ), null );

    parent.addDisposeListener ( new DisposeListener () {

        @Override
        public void widgetDisposed ( final DisposeEvent e )
        {
            handleDispose ();
        }
    } );
}
 
Example #19
Source File: ApiDocumentationView.java    From scava with Eclipse Public License 2.0 6 votes vote down vote up
public void showResult(ApiDocumentationResultView view) {
	Composite composite = view.getComposite();

	resultsVerticalList.add(composite);

	StackLayout layout = (StackLayout) getComposite().getLayout();
	layout.topControl = resultsScrolledComposite;

	view.getComposite().addDisposeListener(new DisposeListener() {

		@Override
		public void widgetDisposed(DisposeEvent e) {
			if (resultsVerticalList.getChildren().length == 0)
				layout.topControl = defaultMessageComposite;
		}
	});
}
 
Example #20
Source File: SpecComparePage.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
private Control createPreviewer(Composite parent) {
	final CompareConfiguration compareConfiguration = new CompareConfiguration();
	compareConfiguration.setLeftLabel("Original " + docTypeName);
	compareConfiguration.setLeftEditable(false);
	compareConfiguration.setRightLabel("Updated " + docTypeName);
	compareConfiguration.setRightEditable(false);
	compareConfiguration.setProperty(CompareConfiguration.IGNORE_WHITESPACE, Boolean.FALSE);
	compareConfiguration.setProperty(PREFIX_SUFFIX_PROPERTY, fPrefixSuffix);

	fViewer = new TextMergeViewer(parent, SWT.NONE, compareConfiguration);
	// add initial input in order to avoid problems when disposing the viewer later:
	fViewer.setInput(new DiffNode(new TargetElementFromString(""), new TargetElementFromString("")));

	Control control = fViewer.getControl();
	control.addDisposeListener(new DisposeListener() {
		@Override
		public void widgetDisposed(DisposeEvent e) {
			compareConfiguration.dispose();
		}
	});
	return control;
}
 
Example #21
Source File: ChartManager.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
public ChartManager ( final Composite parent, final int style )
{
    super ( parent, style );

    setLayout ( makeLayout () );

    // title row

    this.title = new Label ( this, SWT.NONE );
    this.title.setLayoutData ( new GridData ( GridData.CENTER, GridData.FILL, true, false, 1, 1 ) );

    // row 2

    this.chartArea = new ChartArea ( this, SWT.NONE );
    this.chartArea.setLayoutData ( makeMainLayoutData () );

    addDisposeListener ( new DisposeListener () {

        @Override
        public void widgetDisposed ( final DisposeEvent e )
        {
            onDispose ();
        }
    } );
}
 
Example #22
Source File: SwtAppleCommander.java    From AppleCommander with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Dispose of all shared resources.
 */
protected void dispose(DisposeEvent event) {
	imageCanvas.dispose();
	toolBar.dispose();
	imageManager.dispose();
       if (System.getProperty("os.name").startsWith("Mac OS X")) {
   		System.exit(0);
       }
}
 
Example #23
Source File: GenericComposite.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
public GenericComposite ( final Composite parent, final int style, final Collection<Registration> registrations, final Map<String, String> properties )
{
    super ( parent, style );

    this.callbackHandler = new DisplayCallbackHandler ( parent.getShell (), "Operation", "Confirmation required" );

    this.registrationManager = new RegistrationManager ( Activator.getDefault ().getBundle ().getBundleContext () );
    this.registrationManager.addListener ( this );

    this.summaryProvider = new RegistrationManagerSummaryProvider ( this.registrationManager );

    if ( registrations != null )
    {
        for ( final Registration reg : registrations )
        {
            final DataItemDescriptor descriptor = DataItemDescriptor.create ( DetailComponentImpl.resolve ( reg.getDescriptor (), properties ) );
            this.registrationManager.registerItem ( reg.getKey (), descriptor.getItemId (), descriptor.getConnectionInformation (), reg.isAggregateState (), true );
        }
    }

    addDisposeListener ( new DisposeListener () {

        @Override
        public void widgetDisposed ( final DisposeEvent e )
        {
            handleDispose ();
        }
    } );
}
 
Example #24
Source File: FileViewerWindow.java    From AppleCommander with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Dispose of all shared resources.
 */
protected void dispose(DisposeEvent event) {
	courier.dispose();
	black.dispose();
	blue.dispose();
	green.dispose();
	if (nativeFilterAdapter != null) nativeFilterAdapter.dispose();
	hexFilterAdapter.dispose();
	rawDumpFilterAdapter.dispose();
	System.gc();
}
 
Example #25
Source File: Utils.java    From BiglyBT with GNU General Public License v2.0 5 votes vote down vote up
public static Sash
createSash(
	Composite	form,
	int			SASH_WIDTH,
	int			style )
{
    final Sash sash = new Sash(form, style );
    Image image = new Image(sash.getDisplay(), 9, SASH_WIDTH);
    ImageData imageData = image.getImageData();
    int[] row = new int[imageData.width];
    for (int i = 0; i < row.length; i++) {
    	if (imageData.depth == 16) {
    		row[i] = (i % 3) != 0 ? 0x7BDEF7BD : 0xDEF7BDEB;
    	} else {
    		row[i] = (i % 3) != 0 ? 0xE0E0E0 : 0x808080;
    		if (imageData.depth == 32) {
    			row[i] = (row[i] & 255) + (row[i] << 8);
    		}
    	}
		}
    for (int y = 1; y < imageData.height - 1; y++) {
    	imageData.setPixels(0, y, row.length, row, 0);
    }
    Arrays.fill(row, imageData.depth == 16 ? 0x7BDEF7BD : 0xE0E0E0E0);
  	imageData.setPixels(0, 0, row.length, row, 0);
  	imageData.setPixels(0, imageData.height - 1, row.length, row, 0);
    image.dispose();
    image = new Image(sash.getDisplay(), imageData);
    sash.setBackgroundImage(image);
    sash.addDisposeListener(new DisposeListener() {
			@Override
			public void widgetDisposed(DisposeEvent e) {
				sash.getBackgroundImage().dispose();
			}
		});

    return( sash );
}
 
Example #26
Source File: ImageLoader.java    From BiglyBT with GNU General Public License v2.0 5 votes vote down vote up
public Image setButtonImage(Button btn, final String key) {
	Image bg = getImage(key);
	btn.setImage(bg);
	btn.addDisposeListener(new DisposeListener() {
		@Override
		public void widgetDisposed(DisposeEvent e) {
			releaseImage(key);
		}
	});

	return( bg );
}
 
Example #27
Source File: BreadcrumbBar.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
public BreadcrumbBar ( final Composite parent, final int style )
{
    this.composite = new Composite ( parent, SWT.NONE );
    this.composite.addDisposeListener ( new DisposeListener () {

        @Override
        public void widgetDisposed ( final DisposeEvent e )
        {
            handleDispose ();
        }
    } );
    this.horizontal = ( style & SWT.HORIZONTAL ) != 0;

    final GridLayout layout = new GridLayout ( 1, false );
    layout.marginHeight = layout.marginWidth = 0;
    layout.horizontalSpacing = layout.verticalSpacing = 0;

    if ( this.horizontal )
    {
        layout.marginWidth = 5;
        layout.horizontalSpacing = 5;
    }
    else
    {
        layout.marginHeight = 5;
        layout.verticalSpacing = 5;
    }

    this.composite.setLayout ( layout );
}
 
Example #28
Source File: ImageLoader.java    From BiglyBT with GNU General Public License v2.0 5 votes vote down vote up
public void setBackgroundImage(Control control, final String key) {
	Image bg = getImage(key);
	control.setBackgroundImage(bg);
	control.addDisposeListener(new DisposeListener() {
		@Override
		public void widgetDisposed(DisposeEvent e) {
			releaseImage(key);
		}
	});
}
 
Example #29
Source File: DataItemHeaderLabel.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
public DataItemHeaderLabel ( final Composite parent )
{
    super ( parent, SWT.NONE );
    setLayout ( new RowLayout ( SWT.HORIZONTAL ) );

    this.headerIcon = new Label ( this, SWT.NONE );
    this.headerLabel = new Label ( this, SWT.NONE );
    this.headerLabel.setText ( Messages.DataItemHeaderLabel_EmptyDataItem );

    this.headerValueLabel = new Label ( this, SWT.NONE );

    this.blinker = new StyleBlinker () {

        @Override
        public void update ( final CurrentStyle style )
        {
            handleStyleUpdate ( style );
        }
    };

    this.styler = new StateStyler ( this.blinker );

    addDisposeListener ( new DisposeListener () {

        @Override
        public void widgetDisposed ( final DisposeEvent e )
        {
            handleDispose ();
        }
    } );

    handleUpdateData ( null );
}
 
Example #30
Source File: VNative.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
private VNative(VPanel panel, int style) {
	super(panel, style);
	disposeListener = new DisposeListener() {
		public void widgetDisposed(DisposeEvent e) {
			dispose();
		}
	};
}