本文整理汇总了Java中org.eclipse.jface.util.SafeRunnable类的典型用法代码示例。如果您正苦于以下问题:Java SafeRunnable类的具体用法?Java SafeRunnable怎么用?Java SafeRunnable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SafeRunnable类属于org.eclipse.jface.util包,在下文中一共展示了SafeRunnable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dispose
import org.eclipse.jface.util.SafeRunnable; //导入依赖的package包/类
public void dispose ()
{
checkWidget ();
if ( this.disposed )
{
return;
}
this.disposed = true;
for ( final DisposeListener listener : this.disposeListeners )
{
SafeRunnable.getRunner ().run ( new SafeRunnable () {
@Override
public void run () throws Exception
{
listener.onDispose ();
};
} );
}
this.resourceManager.dispose ();
}
示例2: processTick
import org.eclipse.jface.util.SafeRunnable; //导入依赖的package包/类
private void processTick ()
{
this.scheduled = false;
this.globalCounter++;
for ( final BlinkCallback tc : this.callbacks )
{
SafeRunner.run ( new SafeRunnable () {
@Override
public void run () throws Exception
{
tc.toggle ( DisplayBlinkServiceImpl.this.globalCounter );
}
} );
}
schedule ();
}
示例3: fireValueChanged
import org.eclipse.jface.util.SafeRunnable; //导入依赖的package包/类
@Override
protected void fireValueChanged ( final String property, final Object oldValue, final Object newValue )
{
if ( VALUE.equals ( property ) )
{
if ( this.callback != null )
{
SafeRunner.run ( new SafeRunnable () {
@Override
public void run () throws Exception
{
ComboFieldEditor2.this.callback.valueChange ( newValue );
}
} );
}
}
super.fireValueChanged ( property, oldValue, newValue );
}
示例4: fireChange
import org.eclipse.jface.util.SafeRunnable; //导入依赖的package包/类
/**
* Fire visibility change
* <p>
* The change will only be fired if the state really changed.
* </p>
*
* @param state
* the new state
*/
protected void fireChange ( final boolean state )
{
if ( this.state == state )
{
return;
}
this.state = state;
for ( final Listener listener : this.listeners )
{
SafeRunner.run ( new SafeRunnable () {
@Override
public void run () throws Exception
{
listener.visibilityChanged ( state );
}
} );
}
}
示例5: restoreCodeFoldingStateFromFile
import org.eclipse.jface.util.SafeRunnable; //导入依赖的package包/类
/**
* <p>
* Restores the code folding state from a XML file in the state location.
* </p>
*
* @param uriString the key to determine the file to load the state from
*/
public void restoreCodeFoldingStateFromFile(String uriString) {
final File stateFile = getCodeFoldingStateFile(uriString);
if (stateFile == null || !stateFile.exists()) {
calculatePositions();
return;
}
SafeRunner.run(new SafeRunnable("Unable to read code folding state. The state will be reset.") {
public void run() throws Exception {
FileInputStream input = new FileInputStream(stateFile);
BufferedReader reader = new BufferedReader(new InputStreamReader(input, "utf-8"));
IMemento memento = XMLMemento.createReadRoot(reader);
reader.close();
String sourceText = sourceViewer.getDocument().get();
if (memento.getString(VERIFY_KEY).equals(makeMD5(sourceText))) {
restoreCodeFolding(memento);
} else {
calculatePositions();
}
}
});
}
示例6: setSelection
import org.eclipse.jface.util.SafeRunnable; //导入依赖的package包/类
@Override
public void setSelection(ISelection selection) {
theSelection = selection;
final SelectionChangedEvent e = new SelectionChangedEvent(this, selection);
Object[] listenersArray = listeners.toArray();
for (int i = 0; i < listenersArray.length; i++) {
final ISelectionChangedListener l = (ISelectionChangedListener) listenersArray[i];
SafeRunner.run(new SafeRunnable() {
@Override
public void run() {
l.selectionChanged(e);
}
});
}
}
示例7: firePropertyChangeEvent
import org.eclipse.jface.util.SafeRunnable; //导入依赖的package包/类
public void firePropertyChangeEvent(String name, Object oldValue,
Object newValue) {
// important: create intermediate array to protect against listeners
// being added/removed during the notification
final Object[] list = getListeners();
if (list.length == 0) {
return;
}
final PropertyChangeEvent event = new PropertyChangeEvent(this, name,
oldValue, newValue);
for (int i = 0; i < list.length; i++) {
final IPropertyChangeListener listener = (IPropertyChangeListener) list[i];
SafeRunner.run(new SafeRunnable(JFaceResources
.getString("PreferenceStore.changeError")) { //$NON-NLS-1$
public void run() {
listener.propertyChange(event);
}
});
}
}
示例8: firePropertyChangeEvent
import org.eclipse.jface.util.SafeRunnable; //导入依赖的package包/类
@Override
public void firePropertyChangeEvent(String name, Object oldValue,
Object newValue) {
// important: create intermediate array to protect against listeners
// being added/removed during the notification
final Object[] list = getListeners();
if (list.length == 0) {
return;
}
final PropertyChangeEvent event = new PropertyChangeEvent(this, name,
oldValue, newValue);
for (int i = 0; i < list.length; i++) {
final IPropertyChangeListener listener = (IPropertyChangeListener) list[i];
SafeRunner.run(new SafeRunnable(JFaceResources
.getString("PreferenceStore.changeError")) { //$NON-NLS-1$
@Override
public void run() {
listener.propertyChange(event);
}
});
}
}
示例9: addIncludedFeatures
import org.eclipse.jface.util.SafeRunnable; //导入依赖的package包/类
public static void addIncludedFeatures(final IFeatureModel parentModel,
final Collection<IFeatureModel> featureModelsToInclude) {
SafeRunnable.run(new SafeRunnable() {
@Override
public void run() throws Exception {
IFeature feature = parentModel.getFeature();
Collection<IFeatureChild> includes = new TreeSet<IFeatureChild>(IDENTIFIABLE_COMPARATOR);
includes.addAll(Arrays.asList(feature.getIncludedFeatures()));
feature.removeIncludedFeatures(feature.getIncludedFeatures());
for (IFeatureModel featureModelToInclude : featureModelsToInclude) {
includes.add(createInclude(parentModel, featureModelToInclude));
}
feature.addIncludedFeatures(includes.toArray(new IFeatureChild[includes.size()]));
((IEditableModel) parentModel).save();
}
});
}
示例10: addIncludedPlugins
import org.eclipse.jface.util.SafeRunnable; //导入依赖的package包/类
public static void addIncludedPlugins(final IFeatureModel parentModel,
final Collection<IPluginModelBase> pluginModelsToInclude) {
SafeRunnable.run(new SafeRunnable() {
@Override
public void run() throws Exception {
IFeature feature = parentModel.getFeature();
Collection<IFeaturePlugin> includes = new TreeSet<IFeaturePlugin>(IDENTIFIABLE_COMPARATOR);
includes.addAll(Arrays.asList(feature.getPlugins()));
feature.removePlugins(feature.getPlugins());
for (IPluginModelBase pluginModelToInclude : pluginModelsToInclude) {
includes.add(createInclude(parentModel, pluginModelToInclude));
}
feature.addPlugins(includes.toArray(new IFeaturePlugin[includes.size()]));
((IEditableModel) parentModel).save();
}
});
}
示例11: addProductFeatures
import org.eclipse.jface.util.SafeRunnable; //导入依赖的package包/类
public static void addProductFeatures(final IProductModel productModel,
final Collection<IFeatureModel> featureModelsToInclude) {
SafeRunnable.run(new SafeRunnable() {
@Override
public void run() throws Exception {
IProduct product = productModel.getProduct();
Collection<IProductFeature> includes = new TreeSet<IProductFeature>(PRODUCT_FEATURE_COMPARATOR);
includes.addAll(Arrays.asList(product.getFeatures()));
product.removeFeatures(product.getFeatures());
for (IFeatureModel featureModelToInclude : featureModelsToInclude) {
includes.add(createInclude(productModel, featureModelToInclude));
}
product.addFeatures(includes.toArray(new IProductFeature[includes.size()]));
((IEditableModel) productModel).save();
}
});
}
示例12: removeProductFeatures
import org.eclipse.jface.util.SafeRunnable; //导入依赖的package包/类
public static void removeProductFeatures(final IProductModel productModel,
final Collection<IProductFeature> featuresToRemove) {
SafeRunnable.run(new SafeRunnable() {
@Override
public void run() throws Exception {
IProduct product = productModel.getProduct();
Collection<String> featureIdsToRemove = new HashSet<String>();
for (IProductFeature featureToRemove : featuresToRemove) {
featureIdsToRemove.add(featureToRemove.getId());
}
Collection<IProductFeature> removals = new ArrayList<IProductFeature>();
for (IProductFeature feature : product.getFeatures()) {
if (featureIdsToRemove.contains(feature.getId())) {
removals.add(feature);
}
}
product.removeFeatures(removals.toArray(new IProductFeature[removals.size()]));
((IEditableModel) productModel).save();
}
});
}
示例13: firePropertyChangeEvent
import org.eclipse.jface.util.SafeRunnable; //导入依赖的package包/类
@Override
public void firePropertyChangeEvent(String name, Object oldValue, Object newValue) {
final Object[] finalListeners = getListeners();
// Do we need to fire an event.
if (finalListeners.length > 0 && (oldValue == null || !oldValue.equals(newValue))) {
final PropertyChangeEvent pe = new PropertyChangeEvent(this, name, oldValue, newValue);
for (int i = 0; i < finalListeners.length; ++i) {
final IPropertyChangeListener l = (IPropertyChangeListener) finalListeners[i];
SafeRunnable.run(new SafeRunnable(JFaceResources.getString("PreferenceStore.changeError")) { //$NON-NLS-1$
public void run() {
l.propertyChange(pe);
}
});
}
}
}
示例14: closeMatchingEditors
import org.eclipse.jface.util.SafeRunnable; //导入依赖的package包/类
/**
* Tries to find opened editors matching given resource roots. The editors will be closed without confirmation and
* only if the editor resource does not exists anymore.
*
* @param resourceRoots
* non null array with deleted resource tree roots
* @param deletedOnly
* true to close only editors on resources which do not exist
*/
static void closeMatchingEditors(final List<? extends IResource> resourceRoots, final boolean deletedOnly) {
if (resourceRoots.isEmpty()) { return; }
final Runnable runnable = () -> SafeRunner.run(new SafeRunnable(IDEWorkbenchMessages.ErrorOnCloseEditors) {
@Override
public void run() {
final IWorkbenchWindow w = getActiveWindow();
if (w != null) {
final List<IEditorReference> toClose = getMatchingEditors(resourceRoots, w, deletedOnly);
if (toClose.isEmpty()) { return; }
closeEditors(toClose, w);
}
}
});
BusyIndicator.showWhile(PlatformUI.getWorkbench().getDisplay(), runnable);
}
示例15: setSelection
import org.eclipse.jface.util.SafeRunnable; //导入依赖的package包/类
public void setSelection(ISelection selection) {
if (selection == null) {
return;
}
currentSelection = selection;
final SelectionChangedEvent event = new SelectionChangedEvent(this, currentSelection);
Object[] listeners = postSelectionListeners.getListeners();
for (int i = 0; i < listeners.length; ++i) {
final ISelectionChangedListener l = (ISelectionChangedListener) listeners[i];
SafeRunnable.run(new SafeRunnable() {
public void run() {
l.selectionChanged(event);
}
});
}
}