Java Code Examples for org.eclipse.swt.widgets.Control#isDisposed()
The following examples show how to use
org.eclipse.swt.widgets.Control#isDisposed() .
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: PackageExplorerContentProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
protected final void executeRunnables(final Collection<Runnable> runnables) { // now post all collected runnables Control ctrl= fViewer.getControl(); if (ctrl != null && !ctrl.isDisposed()) { final boolean hasPendingUpdates; synchronized (this) { hasPendingUpdates= fPendingUpdates != null && !fPendingUpdates.isEmpty(); } //Are we in the UIThread? If so spin it until we are done if (!hasPendingUpdates && ctrl.getDisplay().getThread() == Thread.currentThread() && !fViewer.isBusy()) { runUpdates(runnables); } else { synchronized (this) { if (fPendingUpdates == null) { fPendingUpdates= runnables; } else { fPendingUpdates.addAll(runnables); } } postAsyncUpdate(ctrl.getDisplay()); } } }
Example 2
Source File: DataDefinitionTextManager.java From birt with Eclipse Public License 1.0 | 6 votes |
public void updateQuery( Control control ) { if ( textCollection.containsKey( control ) ) { IQueryExpressionManager queryManager = textCollection.get( control ); queryManager.updateQuery( ChartUIUtil.getText( control ) ); adjustScaleData( queryManager.getQuery( ) ); // control may be disposed when updating query if ( control.isDisposed( ) ) { control = findText( queryManager.getQuery( ) ); } // Bind color to this data definition if ( control != null ) { updateControlBackground( control, queryManager.getQuery( ) .getDefinition( ) ); } } }
Example 3
Source File: FilterUpdater.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public void resourceChanged(IResourceChangeEvent event) { if (fViewer.getInput() == null) { return; } IResourceDelta delta= event.getDelta(); if (delta == null) return; IResourceDelta[] projDeltas = delta.getAffectedChildren(IResourceDelta.CHANGED); for (int i= 0; i < projDeltas.length; i++) { IResourceDelta pDelta= projDeltas[i]; if ((pDelta.getFlags() & IResourceDelta.DESCRIPTION) != 0) { IProject project= (IProject) pDelta.getResource(); if (needsRefiltering(project)) { final Control ctrl= fViewer.getControl(); if (ctrl != null && !ctrl.isDisposed()) { // async is needed due to bug 33783 ctrl.getDisplay().asyncExec(new Runnable() { public void run() { if (!ctrl.isDisposed()) fViewer.refresh(false); } }); } return; // one refresh is good enough } } } }
Example 4
Source File: OperationGroupViewer.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
public void setInput(Object input) { final Control control = getControl(); if (control == null || control.isDisposed()) { throw new IllegalStateException( "Need an underlying widget to be able to set the input." + //$NON-NLS-1$ "(Has the widget been disposed?)"); //$NON-NLS-1$ } this.input = input; if (input instanceof IObservableList) { final IObservableList observableList = (IObservableList) input; observableList.removeListChangeListener(operationListlistener); observableList.addListChangeListener(operationListlistener); } }
Example 5
Source File: SwtUtils.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
public static Boolean setEnabled(Control control, boolean isEnabled) { if (control.isDisposed()) return null; boolean isEnabledBefore = control.getEnabled(); if (isEnabledBefore != isEnabled) { control.setEnabled(isEnabled); } return isEnabledBefore; }
Example 6
Source File: PythonBaseModelProvider.java From Pydev with Eclipse Public License 1.0 | 5 votes |
/** * Process the resource delta. * * @param delta */ protected void processDelta(IResourceDelta delta) { Control ctrl = viewer.getControl(); if (ctrl == null || ctrl.isDisposed()) { return; } final Collection<Runnable> runnables = new ArrayList<Runnable>(); processDelta(delta, runnables); processRunnables(runnables); }
Example 7
Source File: BillingProposalView.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
private void updateViewer(){ Control control = viewer.getControl(); if (control != null && !control.isDisposed()) { control.getDisplay().asyncExec(new Runnable() { @Override public void run(){ if (!control.isDisposed() && control.isVisible()) { viewer.refresh(item, true); } } }); } }
Example 8
Source File: PWWidget.java From nebula with Eclipse Public License 2.0 | 5 votes |
/** * Enable or disable the widget, depending on the associated enabler */ public boolean enableOrDisable() { if (this.enabler == null) { return true; } final boolean enabled = this.enabler.isEnabled(); for (final Control c : this.controls) { if (!c.isDisposed()) { c.setEnabled(enabled); } } return enabled; }
Example 9
Source File: CustomMatchConditionDialog.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
/** * 销毁除了“过滤器列表控件”之外的其它控件 */ private void disposeChild() { for (Control ctl : this.getChildren()) { if (!"filterName".equals(ctl.getData()) && ctl != null && !ctl.isDisposed()) { ctl.dispose(); } } }
Example 10
Source File: CellEditorTextViewer.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
/** * Dispose this viewer SWT control ; */ public void dispose() { Control control = getControl(); if (control != null && !control.isDisposed()) { control.dispose(); } }
Example 11
Source File: DragDropUtils.java From BiglyBT with GNU General Public License v2.0 | 5 votes |
private static void createDropTarget(Composite composite, DropTargetListener dropTargetListener) { Transfer[] transferList = new Transfer[] { FixedHTMLTransfer.getInstance(), FixedURLTransfer.getInstance(), FileTransfer.getInstance(), TextTransfer.getInstance() }; final DropTarget dropTarget = new DropTarget(composite, DND.DROP_DEFAULT | DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK | DND.DROP_TARGET_MOVE); dropTarget.setTransfer(transferList); dropTarget.addDropListener(dropTargetListener); // Note: DropTarget will dipose when the parent it's on diposes // On Windows, dropping on children moves up to parent // On OSX, each child needs it's own drop. if (Constants.isWindows) { return; } Control[] children = composite.getChildren(); for (Control control : children) { if (control.isDisposed()) { continue; } if (control instanceof Composite) { createDropTarget((Composite) control, dropTargetListener); } else { DropTarget dropTarget2 = new DropTarget(control, DND.DROP_DEFAULT | DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK | DND.DROP_TARGET_MOVE); dropTarget2.setTransfer(transferList); dropTarget2.addDropListener(dropTargetListener); } } }
Example 12
Source File: TimeGraphViewer.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
/** * Callback for the show legend action */ public void showLegend() { Control tgControl = getControl(); if (tgControl == null || tgControl.isDisposed()) { return; } ITimeGraphLegendProvider legendProvider = fLegendProvider; if (legendProvider == null) { TimeGraphLegend.open(tgControl.getShell(), getTimeGraphProvider()); } else { legendProvider.showLegend(tgControl.getShell(), getTimeGraphProvider()); } }
Example 13
Source File: CustomMatchConditionDialog.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
/** * 销毁除了“过滤器列表控件”之外的其它控件 */ private void disposeChild() { for (Control ctl : this.getChildren()) { if (!"filterName".equals(ctl.getData()) && ctl != null && !ctl.isDisposed()) { ctl.dispose(); } } }
Example 14
Source File: MedicationTableViewerItem.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
private void updateViewer(){ if (viewer != null) { Control control = viewer.getControl(); if (control != null && !control.isDisposed()) { viewer.getControl().getDisplay().asyncExec(new Runnable() { @Override public void run(){ if (!control.isDisposed() && control.isVisible()) { viewer.update(item, null); } } }); } } }
Example 15
Source File: LibraryExplorerTreeViewPage.java From birt with Eclipse Public License 1.0 | 4 votes |
protected boolean isDisposed( ) { Control ctrl = getControl( ); return ( ctrl == null || ctrl.isDisposed( ) ); }
Example 16
Source File: CompletionProposalPopup.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
/** * Completes the common prefix of all proposals directly in the code. If no common prefix can be found, the proposal * popup is shown. * * @return an error message if completion failed. * @since 3.0 */ public String incrementalComplete() { if (Helper.okToUse(fProposalShell) && fFilteredProposals != null) { completeCommonPrefix(); } else { final Control control = fContentAssistSubjectControlAdapter.getControl(); if (fKeyListener == null) { fKeyListener = new ProposalSelectionListener(); } if (!Helper.okToUse(fProposalShell) && !control.isDisposed()) { fContentAssistSubjectControlAdapter.addKeyListener(fKeyListener); } BusyIndicator.showWhile(control.getDisplay(), new Runnable() { public void run() { fInvocationOffset = fContentAssistSubjectControlAdapter.getSelectedRange().x; fFilterOffset = fInvocationOffset; fFilteredProposals = computeProposals(fInvocationOffset, false); int count = (fFilteredProposals == null) ? 0: fFilteredProposals.length; if (count == 0) { // IM turned off for the moment, as it's annoying more than helpful to beep. // control.getDisplay().beep(); hide(); } else if ((count == 1)&& (canAutoInsert(fFilteredProposals[0]))) { insertProposal(fFilteredProposals[0],'\0', 0, fInvocationOffset); } else if (completeCommonPrefix()) { hide(); } else { fComputedProposals = fFilteredProposals; createPopup(fComputedProposals); } } }); } return getErrorMessage(); }
Example 17
Source File: CommonOutlinePage.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
private boolean isDisposed() { Control control = getControl(); return control == null || control.isDisposed(); }
Example 18
Source File: ClipboardCopy.java From BiglyBT with GNU General Public License v2.0 | 4 votes |
public static void addCopyToClipMenu( final Control control, final copyToClipProvider provider ) { MouseAdapter ml = (MouseAdapter)control.getData( MOUSE_LISTENER_KEY ); if ( ml != null ){ control.removeMouseListener( ml ); } ml = new MouseAdapter() { @Override public void mouseDown( MouseEvent e ) { if ( control.isDisposed()){ return; } final String text = provider.getText(); if ( control.getMenu() != null || text == null || text.length() == 0 ){ return; } if (!(e.button == 3 || (e.button == 1 && e.stateMask == SWT.CONTROL))){ return; } final Menu menu = new Menu(control.getShell(),SWT.POP_UP); MenuItem item = new MenuItem( menu,SWT.NONE ); item.setData( MENU_ITEM_KEY, "" ); String msg_text_id; if ( provider instanceof copyToClipProvider2 ){ msg_text_id = ((copyToClipProvider2)provider).getMenuResource(); }else{ msg_text_id = "label.copy.to.clipboard"; } item.setText( MessageText.getString( msg_text_id )); item.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent arg0) { new Clipboard(control.getDisplay()).setContents(new Object[] {text}, new Transfer[] {TextTransfer.getInstance()}); } }); control.setMenu( menu ); menu.addMenuListener( new MenuAdapter() { @Override public void menuHidden( MenuEvent arg0 ) { if ( control.getMenu() == menu ){ control.setMenu( null ); } } }); menu.setVisible( true ); } }; control.setData( MOUSE_LISTENER_KEY, ml ); control.addMouseListener( ml ); }
Example 19
Source File: CustomFilterDialog.java From tmxeditor8 with GNU General Public License v2.0 | 4 votes |
/** * 编辑 */ private void edit() { String[] filters = customFilterList.getSelection(); if (filters.length > 0) { if (isChange()) { if (!MessageDialog.openConfirm(getShell(), "", Messages.getString("dialog.CustomFilterDialog.msg1"))) { return; } } String key = filters[0]; filterNameTxt.setText(key); String link = XLFHandler.getCustomFilterAdditionMap().get(key); if (link.indexOf("and") != -1) { andBtn.setSelection(true); orBtn.setSelection(false); } else { andBtn.setSelection(false); orBtn.setSelection(true); } for (Control ctl : conditionList) { if (!ctl.isDisposed()) { ctl.dispose(); } } conditionList.clear(); ArrayList<String[]> tmpList = XLFHandler.getCustomFilterIndexMap().get(key); for (String[] tempIndex : tmpList) { String filterIndex = tempIndex[0]; DynaComposite dyna = new DynaComposite(dynaComp, SWT.NONE); dyna.getFilterName().select(Integer.parseInt(filterIndex)); dyna.getFilterName().notifyListeners(SWT.Selection, null); if ("0".equals(filterIndex) || "1".equals(filterIndex)) { // 关键字、批注 dyna.getConditions().select(Integer.parseInt(tempIndex[1])); dyna.getValue().setText(tempIndex[2].replace("0x0020", " ")); dyna.getValue().setForeground(black); } else if ("2".equals(filterIndex)) { // 属性 dyna.getPropName().setText(tempIndex[1]); dyna.getPropValue().setText(tempIndex[2]); dyna.getPropName().setForeground(black); dyna.getPropValue().setForeground(black); } } scroll.setMinSize(dynaComp.computeSize(SWT.DEFAULT, SWT.DEFAULT)); dynaComp.layout(); } else { MessageDialog.openInformation(getShell(), "", Messages.getString("dialog.CustomFilterDialog.msg4")); } }
Example 20
Source File: CustomMatchConditionDialog.java From tmxeditor8 with GNU General Public License v2.0 | 4 votes |
/** * 编辑 */ private void edit() { String[] filters = customFilterList.getSelection(); if (filters.length > 0) { if (isChange()) { if (!MessageDialog.openConfirm(getShell(), "", "不保存当前内容吗?")) { return; } } String key = filters[0]; filterNameTxt.setText(key); String[] tempArray = XLFHandler.getCustomMatchFilterAdditionMap().get(key).get(0); if (tempArray[0].indexOf("and") != -1) { andBtn.setSelection(true); orBtn.setSelection(false); } else { andBtn.setSelection(false); orBtn.setSelection(true); } int check = Integer.parseInt(tempArray[1]); if (btnIsTagged != null) { if ((check & btnIsTaggedCheck) != 0) { btnIsTagged.setSelection(true); } else { btnIsTagged.setSelection(false); } } if (btnQT != null) { if ((check & btnQTCheck) != 0) { btnQT.setSelection(true); } else { btnQT.setSelection(false); } } if (btnPT != null) { if ((check & btnPTCheck) != 0) { btnPT.setSelection(true); } else { btnPT.setSelection(false); } } if (btnIsRemoveFromSrc != null) { if ((check & btnIsRemoveFromSrcCheck) != 0) { btnIsRemoveFromSrc.setSelection(true); } else { btnIsRemoveFromSrc.setSelection(false); } } for (Control ctl : conditionList) { if (!ctl.isDisposed()) { ctl.dispose(); } } conditionList.clear(); ArrayList<String[]> tmpList = XLFHandler.getCustomMatchFilterIndexMap().get(key); for (String[] tempIndex : tmpList) { String filterIndex = tempIndex[0]; DynaComposite dyna = new DynaComposite(dynaComp, SWT.NONE); dyna.getFilterName().select(Integer.parseInt(filterIndex)); dyna.getFilterName().notifyListeners(SWT.Selection, null); if ("0".equals(filterIndex)) { // 匹配率 dyna.getConditions().select(Integer.parseInt(tempIndex[1])); dyna.getValue().setText(tempIndex[2]); } else if ("1".equals(filterIndex)) { // 关键字 dyna.getConditions().select(Integer.parseInt(tempIndex[1])); dyna.getValue().setText(tempIndex[2]); } else if ("2".equals(filterIndex)) { // 来源 dyna.getValue().setText(tempIndex[1]); } dyna.getValue().setForeground(black); } scroll.setMinSize(dynaComp.computeSize(SWT.DEFAULT, SWT.DEFAULT)); dynaComp.layout(); } else { MessageDialog.openInformation(getShell(), "", "请选择一个自定义过滤器。"); } }