org.eclipse.swt.events.DisposeListener Java Examples
The following examples show how to use
org.eclipse.swt.events.DisposeListener.
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: CallbackDialog.java From neoscada with Eclipse Public License 1.0 | 6 votes |
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 #2
Source File: DataItemLabel.java From neoscada with Eclipse Public License 1.0 | 6 votes |
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 #3
Source File: FontUtils.java From BiglyBT with GNU General Public License v2.0 | 6 votes |
/** * 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 #4
Source File: ToolBarNavigator.java From neoscada with Eclipse Public License 1.0 | 6 votes |
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 #5
Source File: StyledTextXtextAdapter.java From statecharts with Eclipse Public License 1.0 | 6 votes |
private ControlDecoration createContentAssistDecoration(StyledText styledText) { final ControlDecoration result = new ControlDecoration(styledText, SWT.TOP | SWT.LEFT); result.setShowHover(true); result.setShowOnlyOnFocus(true); final Image image = ImageDescriptor .createFromFile(XtextStyledTextCellEditor.class, "images/content_assist_cue.gif").createImage(); result.setImage(image); result.setDescriptionText("Content Assist Available (CTRL + Space)"); result.setMarginWidth(2); styledText.addDisposeListener(new DisposeListener() { @Override public void widgetDisposed(DisposeEvent e) { if (getDecoration() != null) { getDecoration().dispose(); } if (image != null) { image.dispose(); } } }); return result; }
Example #6
Source File: DiskWindow.java From AppleCommander with GNU General Public License v2.0 | 6 votes |
/** * 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 #7
Source File: ChartManager.java From neoscada with Eclipse Public License 1.0 | 6 votes |
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 #8
Source File: SpecComparePage.java From n4js with Eclipse Public License 1.0 | 6 votes |
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 #9
Source File: VisibilityTester.java From neoscada with Eclipse Public License 1.0 | 6 votes |
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 #10
Source File: BlockedIpsWindow.java From BiglyBT with GNU General Public License v2.0 | 6 votes |
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 #11
Source File: ServersViewer.java From neoscada with Eclipse Public License 1.0 | 6 votes |
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 #12
Source File: CTreeComboViewer.java From nebula with Eclipse Public License 2.0 | 6 votes |
/** * @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 #13
Source File: MiniSelector.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
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: CodeRecommendationView.java From scava with Eclipse Public License 2.0 | 6 votes |
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 #15
Source File: ChangePathsFlatViewer.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
public ChangePathsFlatViewer(Composite parent, SVNHistoryPage page) { super(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI /* SWT.FULL_SELECTION */); GridData data = new GridData(GridData.FILL_BOTH); getControl().setLayoutData(data); getControl().addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { if (currentPathFont != null) { currentPathFont.dispose(); } } }); setLabelProvider(new ChangePathLabelProvider()); setContentProvider(new ChangePathsFlatContentProvider(page)); getTable().setHeaderVisible(false); getTable().setLinesVisible(false); }
Example #16
Source File: VerticalList.java From scava with Eclipse Public License 2.0 | 6 votes |
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 #17
Source File: SearchView.java From scava with Eclipse Public License 2.0 | 6 votes |
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 #18
Source File: Win7RendererSupport.java From nebula with Eclipse Public License 2.0 | 6 votes |
/** * @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 #19
Source File: TreeItemAccelerator.java From hop with Apache License 2.0 | 6 votes |
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 #20
Source File: ApiDocumentationView.java From scava with Eclipse Public License 2.0 | 6 votes |
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 #21
Source File: FontUtil.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
/** * 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 #22
Source File: VNative.java From nebula with Eclipse Public License 2.0 | 5 votes |
private VNative(VPanel panel, int style) { super(panel, style); disposeListener = new DisposeListener() { public void widgetDisposed(DisposeEvent e) { dispose(); } }; }
Example #23
Source File: GenericComposite.java From neoscada with Eclipse Public License 1.0 | 5 votes |
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: SWTScaleKnob.java From tuxguitar with GNU Lesser General Public License v2.1 | 5 votes |
private DisposeListener createItemDisposeListener(){ return new DisposeListener() { public void widgetDisposed(DisposeEvent e) { hideShell(); } }; }
Example #25
Source File: ImageLoader.java From BiglyBT with GNU General Public License v2.0 | 5 votes |
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 #26
Source File: ImageLoader.java From BiglyBT with GNU General Public License v2.0 | 5 votes |
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 #27
Source File: RenameInformationPopup.java From typescript.java with MIT License | 5 votes |
public void start() { fEditor.getSite().getWorkbenchWindow().getPartService().addPartListener(this); final ISourceViewer viewer= fEditor.getViewer(); final StyledText textWidget= viewer.getTextWidget(); textWidget.addControlListener(this); textWidget.addMouseListener(this); textWidget.addKeyListener(this); fEditor.getSite().getShell().addControlListener(this); viewer.addTextListener(this); viewer.addViewportListener(this); fPopup.addDisposeListener(new DisposeListener() { @Override public void widgetDisposed(DisposeEvent e) { fEditor.getSite().getWorkbenchWindow().getPartService().removePartListener(PopupVisibilityManager.this); if (! textWidget.isDisposed()) { textWidget.removeControlListener(PopupVisibilityManager.this); textWidget.removeMouseListener(PopupVisibilityManager.this); textWidget.removeKeyListener(PopupVisibilityManager.this); } fEditor.getSite().getShell().removeControlListener(PopupVisibilityManager.this); viewer.removeTextListener(PopupVisibilityManager.this); viewer.removeViewportListener(PopupVisibilityManager.this); // if (fMenuImage != null) { // fMenuImage.dispose(); // fMenuImage= null; // } if (fMenuManager != null) { fMenuManager.dispose(); fMenuManager= null; } fRenameLinkedMode.cancel(); } }); }
Example #28
Source File: BrowserWrapperSWT.java From BiglyBT with GNU General Public License v2.0 | 5 votes |
@Override public void addDisposeListener( DisposeListener l ) { browser.addDisposeListener( l ); }
Example #29
Source File: BrowserWrapperSWT.java From BiglyBT with GNU General Public License v2.0 | 5 votes |
@Override public void removeDisposeListener( DisposeListener l ) { browser.removeDisposeListener( l ); }
Example #30
Source File: Utils.java From BiglyBT with GNU General Public License v2.0 | 5 votes |
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 ); }