From df2f7735690e4fd58a712f7166a8b3ef7385251e Mon Sep 17 00:00:00 2001 From: Florian Hoelzl <hoelzl@fortiss.org> Date: Thu, 5 Jan 2012 11:24:03 +0000 Subject: [PATCH] reworked data dictionary editor refs 446 --- .../trunk/META-INF/MANIFEST.MF | 2 +- .../CheckBoxEditingSupport.java | 2 +- .../CheckBoxLabelProvider.java | 2 +- .../DecoratedIconNameLabelProvider.java | 83 +++++++++++++++++++ .../internal/ModelElementHandlerService.java | 8 +- 5 files changed, 90 insertions(+), 7 deletions(-) rename org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/{checkboxtablecell => tablecell}/CheckBoxEditingSupport.java (98%) rename org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/{checkboxtablecell => tablecell}/CheckBoxLabelProvider.java (98%) create mode 100644 org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/tablecell/DecoratedIconNameLabelProvider.java diff --git a/org.fortiss.tooling.base.ui/trunk/META-INF/MANIFEST.MF b/org.fortiss.tooling.base.ui/trunk/META-INF/MANIFEST.MF index 7f35acd96..19187bfc3 100644 --- a/org.fortiss.tooling.base.ui/trunk/META-INF/MANIFEST.MF +++ b/org.fortiss.tooling.base.ui/trunk/META-INF/MANIFEST.MF @@ -11,7 +11,6 @@ Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-Vendor: fortiss GmbH Export-Package: org.fortiss.tooling.base.ui, - org.fortiss.tooling.base.ui.checkboxtablecell, org.fortiss.tooling.base.ui.compose, org.fortiss.tooling.base.ui.contentprovider, org.fortiss.tooling.base.ui.databinding, @@ -30,4 +29,5 @@ Export-Package: org.fortiss.tooling.base.ui, org.fortiss.tooling.base.ui.layout, org.fortiss.tooling.base.ui.preferences, org.fortiss.tooling.base.ui.properties.view, + org.fortiss.tooling.base.ui.tablecell, org.fortiss.tooling.base.ui.utils diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/checkboxtablecell/CheckBoxEditingSupport.java b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/tablecell/CheckBoxEditingSupport.java similarity index 98% rename from org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/checkboxtablecell/CheckBoxEditingSupport.java rename to org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/tablecell/CheckBoxEditingSupport.java index 0f9cfbbe7..fd4a85bfd 100644 --- a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/checkboxtablecell/CheckBoxEditingSupport.java +++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/tablecell/CheckBoxEditingSupport.java @@ -15,7 +15,7 @@ $Id$ | See the License for the specific language governing permissions and | | limitations under the License. | +--------------------------------------------------------------------------*/ -package org.fortiss.tooling.base.ui.checkboxtablecell; +package org.fortiss.tooling.base.ui.tablecell; import org.eclipse.jface.viewers.CellEditor; import org.eclipse.jface.viewers.CheckboxCellEditor; diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/checkboxtablecell/CheckBoxLabelProvider.java b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/tablecell/CheckBoxLabelProvider.java similarity index 98% rename from org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/checkboxtablecell/CheckBoxLabelProvider.java rename to org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/tablecell/CheckBoxLabelProvider.java index 63584260a..31ee67469 100644 --- a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/checkboxtablecell/CheckBoxLabelProvider.java +++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/tablecell/CheckBoxLabelProvider.java @@ -15,7 +15,7 @@ $Id$ | See the License for the specific language governing permissions and | | limitations under the License. | +--------------------------------------------------------------------------*/ -package org.fortiss.tooling.base.ui.checkboxtablecell; +package org.fortiss.tooling.base.ui.tablecell; import static org.eclipse.jface.resource.JFaceResources.getImageRegistry; import static org.eclipse.swt.SWT.CHECK; diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/tablecell/DecoratedIconNameLabelProvider.java b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/tablecell/DecoratedIconNameLabelProvider.java new file mode 100644 index 000000000..8ab7858a7 --- /dev/null +++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/tablecell/DecoratedIconNameLabelProvider.java @@ -0,0 +1,83 @@ +/*--------------------------------------------------------------------------+ +$Id$ +| | +| 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.base.ui.tablecell; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.jface.viewers.CellLabelProvider; +import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider; +import org.eclipse.jface.viewers.ILabelProviderListener; +import org.eclipse.jface.viewers.StyledString; +import org.eclipse.swt.graphics.Image; +import org.fortiss.tooling.kernel.model.INamedElement; +import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService; + +/** + * {@link CellLabelProvider} for {@link INamedElement} with decoration. Name and + * icon are obtained from {@link IModelElementHandlerService}. + * + * @author hoelzl + * @author $Author$ + * @version $Rev$ + * @ConQAT.Rating YELLOW Hash: 3F8CFB07632A14D29A38168BB1D15D76 + */ +public class DecoratedIconNameLabelProvider implements IStyledLabelProvider { + /** {@inheritDoc} */ + @Override + public void removeListener(ILabelProviderListener listener) { + // ignore + } + + /** {@inheritDoc} */ + @Override + public boolean isLabelProperty(Object element, String property) { + return false; + } + + /** {@inheritDoc} */ + @Override + public void dispose() { + // ignore + } + + /** {@inheritDoc} */ + @Override + public void addListener(ILabelProviderListener listener) { + // ignore + } + + /** {@inheritDoc} */ + @Override + public StyledString getStyledText(Object element) { + if (element instanceof INamedElement) { + return new StyledString( + IModelElementHandlerService.INSTANCE + .getName((EObject) element)); + } + return new StyledString(""); + } + + /** {@inheritDoc} */ + @Override + public Image getImage(Object element) { + if (element instanceof EObject) { + return IModelElementHandlerService.INSTANCE + .getIcon((EObject) element); + } + return null; + } +} diff --git a/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/ModelElementHandlerService.java b/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/ModelElementHandlerService.java index 50d6c5356..40827438b 100644 --- a/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/ModelElementHandlerService.java +++ b/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/ModelElementHandlerService.java @@ -36,7 +36,7 @@ import org.fortiss.tooling.kernel.utils.LoggingUtils; * @author hoelzl * @author $Author$ * @version $Rev$ - * @ConQAT.Rating YELLOW Hash: A72B12E44F543112D26677A5004A9F06 + * @ConQAT.Rating YELLOW Hash: E3699801045FE8DC98C198DCBD9D5308 */ public class ModelElementHandlerService extends EObjectAwareServiceBase<IModelElementHandler<EObject>> implements @@ -95,7 +95,7 @@ public class ModelElementHandlerService extends public String getName(EObject modelElement) { IModelElementHandler<EObject> handler = getModelElementHandler(modelElement); if (handler != null) { - handler.getName(modelElement); + return handler.getName(modelElement); } return null; } @@ -105,7 +105,7 @@ public class ModelElementHandlerService extends public String getDescription(EObject modelElement) { IModelElementHandler<EObject> handler = getModelElementHandler(modelElement); if (handler != null) { - handler.getDescription(modelElement); + return handler.getDescription(modelElement); } return null; } @@ -115,7 +115,7 @@ public class ModelElementHandlerService extends public Image getIcon(EObject modelElement) { IModelElementHandler<EObject> handler = getModelElementHandler(modelElement); if (handler != null) { - handler.getIcon(); + return handler.getIcon(); } return null; } -- GitLab