Skip to content
Snippets Groups Projects
Commit 9f6c0e98 authored by Johannes Eder's avatar Johannes Eder
Browse files

first version of annotation view

refs 1841
parent 3d729548
No related branches found
No related tags found
No related merge requests found
......@@ -11,6 +11,7 @@ Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-Vendor: fortiss GmbH
Export-Package: org.fortiss.tooling.base.ui,
org.fortiss.tooling.base.ui.annotation,
org.fortiss.tooling.base.ui.compose,
org.fortiss.tooling.base.ui.contentprovider,
org.fortiss.tooling.base.ui.databinding,
......
/*--------------------------------------------------------------------------+
$Id$
| |
| Copyright 2013 ForTISS GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.annotation;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.part.ViewPart;
import org.fortiss.tooling.base.model.element.IAnnotatedSpecification;
import org.fortiss.tooling.base.ui.editpart.ElementEditPartBase;
import org.fortiss.tooling.kernel.ui.util.SelectionUtils;
/**
* Base class for displaying {@link IAnnotatedSpecification}s
*
* @author eder
* @author $Author$
* @version $Rev$
* @ConQAT.Rating RED Hash:
*/
public abstract class AnnotationViewPartBase<T extends EObject, V extends IAnnotatedSpecification>
extends ViewPart implements ISelectionListener {
/** The currently selected Object */
private T currentlySelectedObject;
/** The annotated specification of the {@link #currentlySelectedObject} */
private V annotatedSpecification;
/** {@inheritDoc} */
@Override
public void createPartControl(Composite parent) {
getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(this);
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
currentlySelectedObject = null;
currentlySelectedObject = SelectionUtils.checkAndPickFirst(selection, getT());
if(currentlySelectedObject == null) {
ElementEditPartBase<?> editPart =
SelectionUtils.checkAndPickFirst(selection, ElementEditPartBase.class);
if(editPart != null)
currentlySelectedObject = (T)editPart.getModel();
}
// annotatedSpecification = extractAnnotatedSpecification();
}
/** Extracts the {@link IAnnotatedSpecification} from {@link #currentlySelectedObject} */
protected abstract V extractAnnotatedSpecification();
/** Returns the annotated specification. Null if there is none. */
public V getAnnotatedSpecification() {
return annotatedSpecification;
}
/** Returns currentlySelectedObject. Null if there is none. */
public T getCurrentlySelectedObject() {
return currentlySelectedObject;
}
/** Returns the class of type T. Must not be null! */
protected abstract Class<T> getT();
/** {@inheritDoc} */
@Override
public void dispose() {
getSite().getWorkbenchWindow().getSelectionService().removeSelectionListener(this);
super.dispose();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment