X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.selectionview%2Fsrc%2Forg%2Fsimantics%2Fselectionview%2FPropertyTabAdapter.java;h=e58ff7323b85fda629114cb45198933296ca2733;hb=HEAD;hp=9787c37c0550dc2b4f9de9072504448c26a10424;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.selectionview/src/org/simantics/selectionview/PropertyTabAdapter.java b/bundles/org.simantics.selectionview/src/org/simantics/selectionview/PropertyTabAdapter.java index 9787c37c0..e58ff7323 100644 --- a/bundles/org.simantics.selectionview/src/org/simantics/selectionview/PropertyTabAdapter.java +++ b/bundles/org.simantics.selectionview/src/org/simantics/selectionview/PropertyTabAdapter.java @@ -1,136 +1,136 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.selectionview; - -import java.util.concurrent.atomic.AtomicBoolean; - -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.ui.IWorkbenchSite; -import org.simantics.browsing.ui.common.ErrorLogger; -import org.simantics.db.common.procedure.adapter.ListenerSupport; -import org.simantics.db.management.ISessionContext; - -/** - * Override {@link #createControls(Composite, ISessionContext)} to create - * controls for your own tab. - * - *

- * This class implements {@link ListenerSupport} to help in dealing with graph - * request listeners. - * - *

- * This adapter has the following default implementations for IPropertyTab: - *

- * - * @author Tuukka Lehtonen - * - * @see PropertyTabContributorImpl - */ -public abstract class PropertyTabAdapter implements IPropertyTab2, ListenerSupport { - - protected IWorkbenchSite site; - - private final AtomicBoolean disposed = new AtomicBoolean(); - - public PropertyTabAdapter(IWorkbenchSite site) { - this.site = site; - } - - - /** - * Override this implementation and call super.createControl(parent) as the - * last thing in your property table. - * - * @see org.simantics.selectionview.IPropertyTab#createControl(org.eclipse.swt.widgets.Composite) - */ - @Override - public final void createControl(Composite parent, ISessionContext context) { - createControls(parent, context); - Control control = getControl(); - - if (control == null || control.isDisposed()) - return; - - control.addDisposeListener(new DisposeListener() { - @Override - public void widgetDisposed(DisposeEvent e) { - setDisposed(); - } - }); - } - - /** - * Override this implementation to create the tab's controls. - * - * @see #createControl(Composite, ISessionContext) - */ - public void createControls(Composite parent, ISessionContext context) { - Control control = getControl(); - if (control == null || control.isDisposed()) - return; - - control.addDisposeListener(new DisposeListener() { - @Override - public void widgetDisposed(DisposeEvent e) { - setDisposed(); - } - }); - } - - @Override - public void dispose() { - } - - /** - * @return true if tab was marked disposed, false - * if it was already marked disposed - */ - protected boolean setDisposed() { - return disposed.compareAndSet(false, true); - } - - @Override - public boolean isDisposed() { - return disposed.get(); - } - - @Override - public ISelectionProvider getSelectionProvider() { - return null; - } - - @Override - public void requestFocus() { - Control control = getControl(); - if (control == null || control.isDisposed()) - return; - - control.setFocus(); - } - - @Override - public void exception(Throwable t) { - ErrorLogger.defaultLogError("PropertyTabAdapter received unexpected exception.", t); - } - -} +/******************************************************************************* + * Copyright (c) 2007, 2010 Association for Decentralized Information Management + * in Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.selectionview; + +import java.util.concurrent.atomic.AtomicBoolean; + +import org.eclipse.jface.viewers.ISelectionProvider; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.ui.IWorkbenchSite; +import org.simantics.browsing.ui.common.ErrorLogger; +import org.simantics.db.common.procedure.adapter.ListenerSupport; +import org.simantics.db.management.ISessionContext; + +/** + * Override {@link #createControls(Composite, ISessionContext)} to create + * controls for your own tab. + * + *

+ * This class implements {@link ListenerSupport} to help in dealing with graph + * request listeners. + * + *

+ * This adapter has the following default implementations for IPropertyTab: + *

+ * + * @author Tuukka Lehtonen + * + * @see PropertyTabContributorImpl + */ +public abstract class PropertyTabAdapter implements IPropertyTab2, ListenerSupport { + + protected IWorkbenchSite site; + + private final AtomicBoolean disposed = new AtomicBoolean(); + + public PropertyTabAdapter(IWorkbenchSite site) { + this.site = site; + } + + + /** + * Override this implementation and call super.createControl(parent) as the + * last thing in your property table. + * + * @see org.simantics.selectionview.IPropertyTab#createControl(org.eclipse.swt.widgets.Composite) + */ + @Override + public final void createControl(Composite parent, ISessionContext context) { + createControls(parent, context); + Control control = getControl(); + + if (control == null || control.isDisposed()) + return; + + control.addDisposeListener(new DisposeListener() { + @Override + public void widgetDisposed(DisposeEvent e) { + setDisposed(); + } + }); + } + + /** + * Override this implementation to create the tab's controls. + * + * @see #createControl(Composite, ISessionContext) + */ + public void createControls(Composite parent, ISessionContext context) { + Control control = getControl(); + if (control == null || control.isDisposed()) + return; + + control.addDisposeListener(new DisposeListener() { + @Override + public void widgetDisposed(DisposeEvent e) { + setDisposed(); + } + }); + } + + @Override + public void dispose() { + } + + /** + * @return true if tab was marked disposed, false + * if it was already marked disposed + */ + protected boolean setDisposed() { + return disposed.compareAndSet(false, true); + } + + @Override + public boolean isDisposed() { + return disposed.get(); + } + + @Override + public ISelectionProvider getSelectionProvider() { + return null; + } + + @Override + public void requestFocus() { + Control control = getControl(); + if (control == null || control.isDisposed()) + return; + + control.setFocus(); + } + + @Override + public void exception(Throwable t) { + ErrorLogger.defaultLogError("PropertyTabAdapter received unexpected exception.", t); + } + +}