You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by pa...@apache.org on 2009/09/28 15:31:31 UTC
svn commit: r819530 -
/directory/studio/trunk/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/SchemaEditorSchemaCheckerLabelDecorator.java
Author: pamarcelot
Date: Mon Sep 28 13:31:31 2009
New Revision: 819530
URL: http://svn.apache.org/viewvc?rev=819530&view=rev
Log:
Final fix for DIRSTUDIO-443 (The warning and error overlay for OCs and ATs sometimes (often) lacks forgets some items).
Modified:
directory/studio/trunk/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/SchemaEditorSchemaCheckerLabelDecorator.java
Modified: directory/studio/trunk/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/SchemaEditorSchemaCheckerLabelDecorator.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/SchemaEditorSchemaCheckerLabelDecorator.java?rev=819530&r1=819529&r2=819530&view=diff
==============================================================================
--- directory/studio/trunk/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/SchemaEditorSchemaCheckerLabelDecorator.java (original)
+++ directory/studio/trunk/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/SchemaEditorSchemaCheckerLabelDecorator.java Mon Sep 28 13:31:31 2009
@@ -54,6 +54,7 @@
public void decorate( Object element, IDecoration decoration )
{
SchemaChecker schemaChecker = Activator.getDefault().getSchemaChecker();
+ ElementState state = ElementState.NONE;
if ( element instanceof AttributeTypeWrapper )
{
@@ -61,16 +62,13 @@
if ( schemaChecker.hasErrors( at ) )
{
- decoration.addOverlay( Activator.getDefault().getImageDescriptor( PluginConstants.IMG_OVERLAY_ERROR ),
- IDecoration.BOTTOM_LEFT );
+ decorateState( ElementState.ERROR, decoration );
return;
}
if ( schemaChecker.hasWarnings( at ) )
{
- decoration.addOverlay(
- Activator.getDefault().getImageDescriptor( PluginConstants.IMG_OVERLAY_WARNING ),
- IDecoration.BOTTOM_LEFT );
+ state = ElementState.WARNING;
}
}
else if ( element instanceof ObjectClassWrapper )
@@ -79,16 +77,13 @@
if ( schemaChecker.hasErrors( oc ) )
{
- decoration.addOverlay( Activator.getDefault().getImageDescriptor( PluginConstants.IMG_OVERLAY_ERROR ),
- IDecoration.BOTTOM_LEFT );
+ decorateState( ElementState.ERROR, decoration );
return;
}
if ( schemaChecker.hasWarnings( oc ) )
{
- decoration.addOverlay(
- Activator.getDefault().getImageDescriptor( PluginConstants.IMG_OVERLAY_WARNING ),
- IDecoration.BOTTOM_LEFT );
+ state = ElementState.WARNING;
}
}
else if ( element instanceof SchemaWrapper )
@@ -99,15 +94,13 @@
{
if ( schemaChecker.hasErrors( at ) )
{
- decoration.addOverlay( Activator.getDefault()
- .getImageDescriptor( PluginConstants.IMG_OVERLAY_ERROR ), IDecoration.BOTTOM_LEFT );
+ decorateState( ElementState.ERROR, decoration );
return;
}
if ( schemaChecker.hasWarnings( at ) )
{
- decoration.addOverlay( Activator.getDefault().getImageDescriptor(
- PluginConstants.IMG_OVERLAY_WARNING ), IDecoration.BOTTOM_LEFT );
+ state = ElementState.WARNING;
}
}
@@ -115,15 +108,13 @@
{
if ( schemaChecker.hasErrors( oc ) )
{
- decoration.addOverlay( Activator.getDefault()
- .getImageDescriptor( PluginConstants.IMG_OVERLAY_ERROR ), IDecoration.BOTTOM_LEFT );
+ decorateState( ElementState.ERROR, decoration );
return;
}
if ( schemaChecker.hasWarnings( oc ) )
{
- decoration.addOverlay( Activator.getDefault().getImageDescriptor(
- PluginConstants.IMG_OVERLAY_WARNING ), IDecoration.BOTTOM_LEFT );
+ state = ElementState.WARNING;
}
}
}
@@ -133,17 +124,41 @@
if ( childrenHasErrors( folder.getChildren(), schemaChecker ) )
{
- decoration.addOverlay( Activator.getDefault().getImageDescriptor( PluginConstants.IMG_OVERLAY_ERROR ),
- IDecoration.BOTTOM_LEFT );
+ decorateState( ElementState.ERROR, decoration );
return;
}
if ( childrenHasWarnings( folder.getChildren(), schemaChecker ) )
{
+ state = ElementState.WARNING;
+ }
+ }
+
+ decorateState( state, decoration );
+ }
+
+
+ /**
+ * Decorates the element from the value of its state.
+ *
+ * @param state
+ * the state
+ * @param decoration
+ * the decoration
+ */
+ private void decorateState( ElementState state, IDecoration decoration )
+ {
+ switch ( state )
+ {
+ case WARNING:
decoration.addOverlay(
Activator.getDefault().getImageDescriptor( PluginConstants.IMG_OVERLAY_WARNING ),
IDecoration.BOTTOM_LEFT );
- }
+ break;
+ case ERROR:
+ decoration.addOverlay( Activator.getDefault().getImageDescriptor( PluginConstants.IMG_OVERLAY_ERROR ),
+ IDecoration.BOTTOM_LEFT );
+ break;
}
}
@@ -256,4 +271,15 @@
return false;
}
+
+ /**
+ * This enum defines the state of an element.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+ private enum ElementState
+ {
+ NONE, WARNING, ERROR;
+ }
}