Skip to content
Snippets Groups Projects
Commit abe9e8b6 authored by Daniel Ratiu's avatar Daniel Ratiu
Browse files

first steps towards the library

refs 694
parent 03897fbe
No related branches found
No related tags found
No related merge requests found
Showing
with 273 additions and 8 deletions
......@@ -71,6 +71,12 @@ public class ElementTreeSingleSelectDialog extends TitleAreaDialog {
/** The gui composite */
private ElementTreeSingleSelectDialogGUI gui;
/** The title of the dialog. */
private String dialogTitle = "Select";
/** The message that explains what should be selected. */
private String selectionMessage = "Select an element";
/**
* Main constructor
*
......@@ -109,13 +115,42 @@ public class ElementTreeSingleSelectDialog extends TitleAreaDialog {
}
}
/**
* Constructor.
*
* @param parentShell
* the parent shell
* @param dialogTitle
* the title of the dialog
* @param selectionMessage
* the message explaining what is the selection about
* @param roots
* the root elements
* @param selected
* the pre-selected element or null
* @param contentProvider
* the content provider
* @param labelProvider
* the label provider
* @param edit
* the editing module or null
*/
public ElementTreeSingleSelectDialog(Shell parentShell, String dialogTitle,
String selectionMessage, List<?> roots, Object selected,
ITreeContentProvider contentProvider, ILabelProvider labelProvider,
IDialogEditSupport edit) {
this(parentShell, roots, selected, contentProvider, labelProvider, edit);
this.dialogTitle = dialogTitle;
this.selectionMessage = selectionMessage;
}
/** {@inheritDoc} */
@Override
protected Control createDialogArea(Composite parent) {
setHelpAvailable(false);
setTitle("Select");
setMessage("Select an element");
setTitle(dialogTitle);
setMessage(selectionMessage);
// create controls
Composite area = (Composite)super.createDialogArea(parent);
......
......@@ -141,6 +141,12 @@
<details key="documentation" value="Super class of hidden model element specifications that represent annotations."/>
</eAnnotations>
</eClassifiers>
<eClassifiers xsi:type="ecore:EDataType" name="IModelElementSpecificationArray"
instanceClassName="org.fortiss.tooling.base.model.element.IModelElementSpecification[]">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="An array of model element specifications."/>
</eAnnotations>
</eClassifiers>
</eSubpackages>
<eSubpackages name="layout" nsURI="http://www.fortiss.org/tooling/base/model/layout"
nsPrefix="org-fortiss-tooling-base-model-layout">
......
......@@ -10,6 +10,7 @@
ecorePackage="base.ecore#/">
<nestedGenPackages prefix="Element" basePackage="org.fortiss.tooling.base.model"
disposableProviderFactory="true" ecorePackage="base.ecore#//element">
<genDataTypes ecoreDataType="base.ecore#//element/IModelElementSpecificationArray"/>
<genClasses ecoreClass="base.ecore#//element/IModelElement">
<genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference base.ecore#//element/IModelElement/specifications"/>
<genFeatures notify="false" createChild="false" propertySortChoices="true"
......
......@@ -97,6 +97,14 @@
type="org.fortiss.tooling.kernel.model.INamedCommentedElement">
</input>
</propertySection>
<propertySection
class="org.fortiss.tooling.kernel.ui.internal.properties.ElementWithURIPropertySection"
id="org.fortiss.tooling.kernel.ui.internal.properties.ElementWithURIPropertySection"
tab="org.fortiss.tooling.kernel.ui.property.tab.general">
<input
type="org.fortiss.tooling.kernel.model.IElementWithURI">
</input>
</propertySection>
</propertySections>
</extension>
<extension
......
/*--------------------------------------------------------------------------+
$Id: IdLabeledPropertySection.java 5274 2012-08-02 07:54:11Z mou $
| |
| Copyright 2011 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.kernel.ui.internal.properties;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.jface.databinding.swt.SWTObservables;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
import org.fortiss.tooling.kernel.model.FortissToolingKernelPackage;
import org.fortiss.tooling.kernel.model.IElementWithURI;
import org.fortiss.tooling.kernel.ui.extension.base.PropertySectionBase;
import org.fortiss.tooling.kernel.ui.util.ObservableUtils;
/**
* Property section for {@link IElementWithURI}s.
*
* @author ratiu
* @author $Author: ratiu $
* @version $Rev: 5274 $
* @ConQAT.Rating GREEN Hash: E6A4B98E0681984D8DCCBFFBF99412CA
*/
public final class ElementWithURIPropertySection extends PropertySectionBase {
/** URI edit widget. */
private Text uriText;
/** Stores the current input. */
private IElementWithURI elementWithURI;
/** {@inheritDoc} */
@Override
public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
super.createControls(parent, aTabbedPropertySheetPage);
uriText = createFormText("URI");
uriText.setEnabled(false);
}
/** {@inheritDoc} */
@Override
protected void setSectionInput(Object input) {
if(input instanceof IElementWithURI) {
elementWithURI = (IElementWithURI)input;
}
}
/** {@inheritDoc} */
@Override
public void refresh() {
super.refresh();
IObservableValue modelObservable =
ObservableUtils.observeValue(elementWithURI,
FortissToolingKernelPackage.Literals.IELEMENT_WITH_URI__URI);
dbc.bindValue(SWTObservables.observeText(uriText, SWT.FocusOut), modelObservable, null,
null);
}
}
......@@ -252,6 +252,7 @@ public class LibraryView extends ViewPart {
}
IEditorPart part = (IEditorPart)workbenchPart;
viewer.setInput(IPrototypeService.INSTANCE.getAllPrototypesByCategory());
switchWorkbenchEditor(part);
}
}
......
......@@ -24,6 +24,7 @@ import java.util.List;
import org.conqat.ide.commons.ui.jface.TreeContentProviderBase;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
import org.fortiss.tooling.kernel.model.ILibrary;
import org.fortiss.tooling.kernel.service.IPersistencyService;
import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler;
import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService;
......@@ -41,6 +42,9 @@ public class NavigatorTreeContentProvider extends TreeContentProviderBase {
/** Stores whether the expert view is active. **/
private boolean expertViewActive = false;
/** Stores whether the library view is active. **/
private boolean libraryViewActive = false;
/** {@inheritDoc} */
@Override
public Object[] getElements(Object inputElement) {
......@@ -48,7 +52,13 @@ public class NavigatorTreeContentProvider extends TreeContentProviderBase {
List<EObject> result = new LinkedList<EObject>();
for(ITopLevelElement context : IPersistencyService.INSTANCE.getTopLevelElements()) {
result.add(context.getRootModelElement());
EObject root = context.getRootModelElement();
if(libraryViewActive && root instanceof ILibrary) {
result.add(root);
}
if(!libraryViewActive && !(root instanceof ILibrary)) {
result.add(root);
}
}
return result.toArray();
}
......@@ -108,6 +118,14 @@ public class NavigatorTreeContentProvider extends TreeContentProviderBase {
expertViewActive = !expertViewActive;
}
/**
* Change to the library view. When library view is active then libraries are
* displayed in the tree.
*/
public void toggleLibraryView() {
libraryViewActive = !libraryViewActive;
}
/** Returns whether expert view is active. */
public boolean isExpertViewActive() {
return expertViewActive;
......
......@@ -93,6 +93,9 @@ public final class NavigatorViewPart extends ViewPart implements ISelectionListe
/** Toggle expert view filter action. */
private Action toggleExpertViewAction = null;
/** Change to library/non-library view action. */
private Action toggleLibraryViewAction = null;
/** Dialog setting ID for the link with editor action flag. */
private static final String LINK_WITH_EDITOR_FLAG = "navigatorSettingLinkWithEditor";
......@@ -181,6 +184,19 @@ public final class NavigatorViewPart extends ViewPart implements ISelectionListe
linkWithEditorAction.setToolTipText("Link with editor");
linkWithEditorAction.setChecked(settings.getBoolean(LINK_WITH_EDITOR_FLAG));
toggleLibraryViewAction = new Action("Toggle library view", SWT.TOGGLE) {
@Override
public void run() {
((NavigatorTreeContentProvider)viewer.getContentProvider()).toggleLibraryView();
viewer.refresh();
}
};
toggleLibraryViewAction.setImageDescriptor(ToolingKernelUIActivator
.getImageDescriptor("icons/library.png"));
toggleLibraryViewAction.setToolTipText("Toggle library view");
toggleExpertViewAction = new Action("Toggle expert view", SWT.TOGGLE) {
@Override
......@@ -198,8 +214,10 @@ public final class NavigatorViewPart extends ViewPart implements ISelectionListe
Separator additionsSeperator = new Separator("additions");
additionsSeperator.setVisible(true);
toolBarManager.add(additionsSeperator);
toolBarManager.insertAfter("additions", toggleExpertViewAction);
toolBarManager.insertAfter("additions", linkWithEditorAction);
toolBarManager.insertAfter("additions", toggleLibraryViewAction);
}
/** Creates the context menu. */
......
......@@ -26,6 +26,7 @@ import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.ui.ISelectionService;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
/**
......@@ -85,7 +86,8 @@ public final class EObjectSelectionUtils {
* @return the current selection
*/
public static ISelection getCurrentSelection() {
return getSelectionService().getSelection();
ISelectionService selectionService = getSelectionService();
return selectionService == null ? null : selectionService.getSelection();
}
/**
......@@ -94,7 +96,9 @@ public final class EObjectSelectionUtils {
* @return the platform selection service
*/
public static ISelectionService getSelectionService() {
return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService();
IWorkbenchWindow activeWorkbenchWindow =
PlatformUI.getWorkbench().getActiveWorkbenchWindow();
return activeWorkbenchWindow == null ? null : activeWorkbenchWindow.getSelectionService();
}
/**
......
......@@ -52,4 +52,29 @@
</eAnnotations>
</eStructuralFeatures>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="ILibraryElement" abstract="true" interface="true"
eSuperTypes="#//INamedCommentedElement #//IElementWithURI">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="ILibraryElement is the super class of all elements contained in a library."/>
</eAnnotations>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="ILibraryElementReference" abstract="true"
interface="true" eSuperTypes="#//INamedCommentedElement #//IElementWithURI">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="ILibraryElementReference is the super class of all references to elements contained in a library."/>
</eAnnotations>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="ILibraryRootElement" eSuperTypes="#//INamedCommentedElement #//IElementWithURI"/>
<eClassifiers xsi:type="ecore:EClass" name="ILibrary" abstract="true" interface="true"
eSuperTypes="#//INamedCommentedElement">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="ILibrary is the super class of all libraries."/>
</eAnnotations>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="IElementWithURI" abstract="true" interface="true">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="ILibraryElement is the super class of all elements contained in a library."/>
</eAnnotations>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="uri" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
</ecore:EPackage>
......@@ -24,5 +24,12 @@
<genClasses image="false" ecoreClass="kernel.ecore#//IIdLabeledReference">
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute kernel.ecore#//IIdLabeledReference/idReference"/>
</genClasses>
<genClasses image="false" ecoreClass="kernel.ecore#//ILibraryElement"/>
<genClasses image="false" ecoreClass="kernel.ecore#//ILibraryElementReference"/>
<genClasses ecoreClass="kernel.ecore#//ILibraryRootElement"/>
<genClasses image="false" ecoreClass="kernel.ecore#//ILibrary"/>
<genClasses image="false" ecoreClass="kernel.ecore#//IElementWithURI">
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute kernel.ecore#//IElementWithURI/uri"/>
</genClasses>
</genPackages>
</genmodel:GenModel>
......@@ -43,7 +43,7 @@ import org.fortiss.tooling.kernel.extension.data.Prototype;
public abstract class PrototypeProviderBase implements IPrototypeProvider {
/** Stores the registered prototypes. */
private final List<Prototype> prototypes = new ArrayList<Prototype>();
protected final List<Prototype> prototypes = new ArrayList<Prototype>();
/** Stores the optional category affiliation for the prototype. */
private final HashMap<Class<? extends EObject>, String> map =
......
/*--------------------------------------------------------------------------+
$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $
| |
| Copyright 2012 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.kernel.extension.data;
import org.fortiss.tooling.kernel.model.ILibraryElementReference;
/**
* A prototype for the library element.
*
* @author ratiu
* @author $Author: hoelzl $
* @version $Rev: 18709 $
* @ConQAT.Rating RED Hash:
*/
public abstract class LibraryPrototype extends Prototype {
/** Constructor. */
public LibraryPrototype(String name, ILibraryElementReference libraryElementReference) {
super(name, libraryElementReference, false);
}
/** {@inheritDoc} */
@Override
public abstract ILibraryElementReference getPrototypeCopy();
}
......@@ -28,13 +28,13 @@ import org.eclipse.emf.ecore.util.EcoreUtil;
* @version $Rev$
* @ConQAT.Rating GREEN Hash: D5F7FE80539882533974AD12EEE0E643
*/
public final class Prototype {
public class Prototype {
/** The generic prototype name. */
private final String name;
/** The pre-configured {@link EObject}. */
private final EObject prototype;
protected final EObject prototype;
/** Flag for primary class prototypes. */
private final boolean isPrimary;
......
......@@ -22,6 +22,7 @@ import java.util.Iterator;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.tooling.kernel.model.IIdLabeled;
import org.fortiss.tooling.kernel.model.IIdLabeledReference;
import org.fortiss.tooling.kernel.model.ILibraryElementReference;
import org.fortiss.tooling.kernel.model.INamedElement;
import org.fortiss.tooling.kernel.model.IProjectRootElement;
import org.fortiss.tooling.kernel.service.IPersistencyService;
......@@ -203,4 +204,31 @@ public final class KernelModelElementUtils {
return qualifiedName;
}
/**
* Returns true if the parameter is a child of a {@link ILibraryElementReference}.
*
* @param eObject
* an object from the model.
*
* @return true if the element is under a library reference
*/
public static boolean isChildOfLibraryReference(EObject eObject) {
if(eObject != null) {
int count = 0;
for(EObject parent = eObject.eContainer(); parent != null; parent = parent.eContainer()) {
if(parent instanceof ILibraryElementReference) {
return true;
}
if(++count > 100000) {
return isChildOfLibraryReference(parent);
}
if(parent == eObject) {
throw new IllegalStateException(
"There is a cycle in the containment hierarchy of " + eObject);
}
}
}
return false;
}
}
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