You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by fe...@apache.org on 2007/11/05 18:15:02 UTC
svn commit: r592094 [14/35] - in
/directory/sandbox/felixk/studio-schemaeditor: ./ META-INF/ src/ src/main/
src/main/java/ src/main/java/org/ src/main/java/org/apache/
src/main/java/org/apache/directory/
src/main/java/org/apache/directory/studio/ src/m...
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATEMatchingRulesComboInput.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATEMatchingRulesComboInput.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATEMatchingRulesComboInput.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATEMatchingRulesComboInput.java Mon Nov 5 09:14:24 2007
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.directory.studio.schemaeditor.view.editors.attributetype;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * This class implements the Input of the Matching Rules Combo of the Attribute Type Editor
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ATEMatchingRulesComboInput
+{
+ /** The children */
+ private List<Object> children;
+
+
+ /**
+ * Adds a child.
+ *
+ * @param child
+ * the child to add
+ */
+ public void addChild( Object child )
+ {
+ if ( children == null )
+ {
+ children = new ArrayList<Object>();
+ }
+
+ children.add( child );
+ }
+
+
+ /**
+ * Gets the children.
+ *
+ * @return
+ * the children
+ */
+ public List<Object> getChildren()
+ {
+ if ( children == null )
+ {
+ children = new ArrayList<Object>();
+ }
+
+ return children;
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATEMatchingRulesComboInput.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATEMatchingRulesComboLabelProvider.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATEMatchingRulesComboLabelProvider.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATEMatchingRulesComboLabelProvider.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATEMatchingRulesComboLabelProvider.java Mon Nov 5 09:14:24 2007
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.directory.studio.schemaeditor.view.editors.attributetype;
+
+
+import org.apache.directory.studio.schemaeditor.model.MatchingRuleImpl;
+import org.apache.directory.studio.schemaeditor.view.editors.NonExistingMatchingRule;
+import org.eclipse.jface.viewers.LabelProvider;
+
+
+/**
+ * This class implements the Label Provider of the Matching Rules Combo of the Attribute Type Editor.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ATEMatchingRulesComboLabelProvider extends LabelProvider
+{
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
+ */
+ public String getText( Object obj )
+ {
+ if ( obj instanceof MatchingRuleImpl )
+ {
+ MatchingRuleImpl mr = ( MatchingRuleImpl ) obj;
+
+ String name = mr.getName();
+ if ( name != null )
+ {
+ return name + " - (" + mr.getOid() + ")";
+ }
+ else
+ {
+ return "(None) - (" + mr.getOid() + ")";
+ }
+ }
+ else if ( obj instanceof NonExistingMatchingRule )
+ {
+ return ( ( NonExistingMatchingRule ) obj ).getDisplayName();
+ }
+
+ // Default
+ return null;
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATEMatchingRulesComboLabelProvider.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATESuperiorComboComparator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATESuperiorComboComparator.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATESuperiorComboComparator.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATESuperiorComboComparator.java Mon Nov 5 09:14:24 2007
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.directory.studio.schemaeditor.view.editors.attributetype;
+
+
+import java.util.Comparator;
+
+import org.apache.directory.studio.schemaeditor.model.AttributeTypeImpl;
+import org.apache.directory.studio.schemaeditor.view.editors.NonExistingAttributeType;
+
+
+/**
+ * This class implements the Comparator used to compare elements in the Matching Rules Content Providers.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ATESuperiorComboComparator implements Comparator<Object>
+{
+ /* (non-Javadoc)
+ * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
+ */
+ public int compare( Object o1, Object o2 )
+ {
+ if ( o1 instanceof AttributeTypeImpl && o2 instanceof AttributeTypeImpl )
+ {
+ String[] at1Names = ( ( AttributeTypeImpl ) o1 ).getNames();
+ String[] at2Names = ( ( AttributeTypeImpl ) o2 ).getNames();
+
+ if ( ( at1Names != null ) && ( at2Names != null ) && ( at1Names.length > 0 ) && ( at2Names.length > 0 ) )
+ {
+ return at1Names[0].compareToIgnoreCase( at2Names[0] );
+ }
+ }
+ else if ( o1 instanceof AttributeTypeImpl && o2 instanceof NonExistingAttributeType )
+ {
+ String[] at1Names = ( ( AttributeTypeImpl ) o1 ).getNames();
+ String at2Name = ( ( NonExistingAttributeType ) o2 ).getName();
+
+ if ( ( at1Names != null ) && ( at2Name != null ) && ( at1Names.length > 0 ) )
+ {
+ return at1Names[0].compareToIgnoreCase( at2Name );
+ }
+ }
+ else if ( o1 instanceof NonExistingAttributeType && o2 instanceof AttributeTypeImpl )
+ {
+ String at1Name = ( ( NonExistingAttributeType ) o1 ).getName();
+ String[] at2Names = ( ( AttributeTypeImpl ) o2 ).getNames();
+
+ if ( ( at1Name != null ) && ( at2Names != null ) && ( at2Names.length > 0 ) )
+ {
+ return at1Name.compareToIgnoreCase( at2Names[0] );
+ }
+ }
+ else if ( o1 instanceof NonExistingAttributeType && o2 instanceof NonExistingAttributeType )
+ {
+ String at1Name = ( ( NonExistingAttributeType ) o1 ).getName();
+ String at2Name = ( ( NonExistingAttributeType ) o2 ).getName();
+
+ if ( ( at1Name != null ) && ( at2Name != null ) )
+ {
+ return at1Name.compareToIgnoreCase( at2Name );
+ }
+ }
+
+ return 0;
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATESuperiorComboComparator.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATESuperiorComboContentProvider.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATESuperiorComboContentProvider.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATESuperiorComboContentProvider.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATESuperiorComboContentProvider.java Mon Nov 5 09:14:24 2007
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.directory.studio.schemaeditor.view.editors.attributetype;
+
+
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.directory.studio.schemaeditor.Activator;
+import org.apache.directory.studio.schemaeditor.controller.SchemaHandler;
+import org.apache.directory.studio.schemaeditor.model.AttributeTypeImpl;
+import org.apache.directory.studio.schemaeditor.view.editors.NonExistingAttributeType;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+
+/**
+ * This class implements the Content Provider for the Superior Combo of the Attribute Type Editor.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ATESuperiorComboContentProvider implements IStructuredContentProvider
+{
+ /** The Schema Handler */
+ private SchemaHandler schemaHandler;
+
+
+ /**
+ * Creates a new instance of ATESuperiorComboContentProvider.
+ */
+ public ATESuperiorComboContentProvider()
+ {
+ schemaHandler = Activator.getDefault().getSchemaHandler();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+ */
+ public Object[] getElements( Object inputElement )
+ {
+ if ( inputElement instanceof ATESuperiorComboInput )
+ {
+ ATESuperiorComboInput input = ( ATESuperiorComboInput ) inputElement;
+
+ if ( input.getChildren().isEmpty() )
+ {
+ AttributeTypeImpl editorAT = input.getAttributeType();
+
+ // Creating the '(None)' item
+ input.addChild( new NonExistingAttributeType( NonExistingAttributeType.NONE ) );
+
+ // Creating Children
+ List<AttributeTypeImpl> ats = schemaHandler.getAttributeTypes();
+ for ( AttributeTypeImpl at : ats )
+ {
+ if ( !isSubType( at, editorAT ) )
+ {
+ input.addChild( at );
+ }
+ }
+ }
+
+ // Getting Children
+ List<Object> children = input.getChildren();
+
+ // Sorting Children
+ Collections.sort( children, new ATESuperiorComboComparator() );
+
+ return children.toArray();
+ }
+
+ // Default
+ return new Object[0];
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+ */
+ public void dispose()
+ {
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+ */
+ public void inputChanged( Viewer viewer, Object oldInput, Object newInput )
+ {
+ }
+
+
+ /**
+ * Checks id an Attribute Type is a sub type of another Attribute Type.
+ *
+ * @param at1
+ * the first Attribute Type
+ * @param at2
+ * the second Attribute Type
+ * @return
+ * true if at1 is a sub type of at2
+ */
+ private boolean isSubType( AttributeTypeImpl at1, AttributeTypeImpl at2 )
+ {
+ if ( at1.equals( at2 ) )
+ {
+ return true;
+ }
+ else
+ {
+ String sup = at1.getSuperiorName();
+
+ if ( sup == null )
+ {
+ return false;
+ }
+ else
+ {
+ AttributeTypeImpl supAT = schemaHandler.getAttributeType( sup );
+ if ( supAT == null )
+ {
+ return false;
+ }
+ else
+ {
+ return isSubType( supAT, at2 );
+ }
+ }
+ }
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATESuperiorComboContentProvider.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATESuperiorComboInput.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATESuperiorComboInput.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATESuperiorComboInput.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATESuperiorComboInput.java Mon Nov 5 09:14:24 2007
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.directory.studio.schemaeditor.view.editors.attributetype;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.directory.studio.schemaeditor.model.AttributeTypeImpl;
+
+
+/**
+ * This class implements the Input of the Superior Combo of the Attribute Type Editor
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ATESuperiorComboInput
+{
+ /** The attribute type */
+ private AttributeTypeImpl at;
+
+ /** The children */
+ private List<Object> children;
+
+
+ /**
+ * Creates a new instance of ATESuperiorComboInput.
+ *
+ * @param at
+ * the Attribute Type
+ */
+ public ATESuperiorComboInput( AttributeTypeImpl at )
+ {
+ this.at = at;
+ }
+
+
+ /**
+ * Gets the Attribute Type.
+ *
+ * @return
+ * the attribute type
+ */
+ public AttributeTypeImpl getAttributeType()
+ {
+ return at;
+ }
+
+
+ /**
+ * Adds a child.
+ *
+ * @param child
+ * the child to add
+ */
+ public void addChild( Object child )
+ {
+ if ( children == null )
+ {
+ children = new ArrayList<Object>();
+ }
+
+ children.add( child );
+ }
+
+
+ /**
+ * Gets the children.
+ *
+ * @return
+ * the children
+ */
+ public List<Object> getChildren()
+ {
+ if ( children == null )
+ {
+ children = new ArrayList<Object>();
+ }
+
+ return children;
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATESuperiorComboInput.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATESuperiorComboLabelProvider.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATESuperiorComboLabelProvider.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATESuperiorComboLabelProvider.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATESuperiorComboLabelProvider.java Mon Nov 5 09:14:24 2007
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.directory.studio.schemaeditor.view.editors.attributetype;
+
+
+import org.apache.directory.studio.schemaeditor.model.AttributeTypeImpl;
+import org.apache.directory.studio.schemaeditor.view.ViewUtils;
+import org.apache.directory.studio.schemaeditor.view.editors.NonExistingAttributeType;
+import org.eclipse.jface.viewers.LabelProvider;
+
+
+/**
+ * This class implements the Label Provider of the Superior Combo of the Attribute Type Editor.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ATESuperiorComboLabelProvider extends LabelProvider
+{
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
+ */
+ public String getText( Object obj )
+ {
+ if ( obj instanceof AttributeTypeImpl )
+ {
+ AttributeTypeImpl at = ( AttributeTypeImpl ) obj;
+
+ String[] names = at.getNames();
+ if ( ( names != null ) && ( names.length > 0 ) )
+ {
+ return ViewUtils.concateAliases( names ) + " - (" + at.getOid() + ")";
+ }
+ else
+ {
+ return "(None) - (" + at.getOid() + ")";
+ }
+ }
+ else if ( obj instanceof NonExistingAttributeType )
+ {
+ return ( ( NonExistingAttributeType ) obj ).getDisplayName();
+ }
+
+ // Default
+ return null;
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATESuperiorComboLabelProvider.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATESyntaxComboComparator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATESyntaxComboComparator.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATESyntaxComboComparator.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATESyntaxComboComparator.java Mon Nov 5 09:14:24 2007
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.directory.studio.schemaeditor.view.editors.attributetype;
+
+
+import java.util.Comparator;
+
+import org.apache.directory.studio.schemaeditor.model.SyntaxImpl;
+import org.apache.directory.studio.schemaeditor.view.editors.NonExistingSyntax;
+
+
+/**
+ * This class implements the Comparator used to compare elements in the Matching Rules Content Providers.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ATESyntaxComboComparator implements Comparator<Object>
+{
+ /* (non-Javadoc)
+ * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
+ */
+ public int compare( Object o1, Object o2 )
+ {
+ if ( o1 instanceof SyntaxImpl && o2 instanceof SyntaxImpl )
+ {
+ String[] syntax1Names = ( ( SyntaxImpl ) o1 ).getNames();
+ String[] syntax2Names = ( ( SyntaxImpl ) o2 ).getNames();
+
+ if ( ( syntax1Names != null ) && ( syntax2Names != null ) && ( syntax1Names.length > 0 )
+ && ( syntax2Names.length > 0 ) )
+ {
+ return syntax1Names[0].compareToIgnoreCase( syntax2Names[0] );
+ }
+ }
+ else if ( o1 instanceof SyntaxImpl && o2 instanceof NonExistingSyntax )
+ {
+ String[] syntax1Names = ( ( SyntaxImpl ) o1 ).getNames();
+ String syntax2Name = ( ( NonExistingSyntax ) o2 ).getName();
+
+ if ( ( syntax1Names != null ) && ( syntax2Name != null ) && ( syntax1Names.length > 0 ) )
+ {
+ return syntax1Names[0].compareToIgnoreCase( syntax2Name );
+ }
+ }
+ else if ( o1 instanceof NonExistingSyntax && o2 instanceof SyntaxImpl )
+ {
+ String syntax1Name = ( ( NonExistingSyntax ) o1 ).getName();
+ String[] syntax2Names = ( ( SyntaxImpl ) o2 ).getNames();
+
+ if ( ( syntax1Name != null ) && ( syntax2Names != null ) && ( syntax2Names.length > 0 ) )
+ {
+ return syntax1Name.compareToIgnoreCase( syntax2Names[0] );
+ }
+ }
+ else if ( o1 instanceof NonExistingSyntax && o2 instanceof NonExistingSyntax )
+ {
+ String syntax1Name = ( ( NonExistingSyntax ) o1 ).getName();
+ String syntax2Name = ( ( NonExistingSyntax ) o2 ).getName();
+
+ if ( ( syntax1Name != null ) && ( syntax2Name != null ) )
+ {
+ return syntax1Name.compareToIgnoreCase( syntax2Name );
+ }
+ }
+
+ return 0;
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATESyntaxComboComparator.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATESyntaxComboContentProvider.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATESyntaxComboContentProvider.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATESyntaxComboContentProvider.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATESyntaxComboContentProvider.java Mon Nov 5 09:14:24 2007
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.directory.studio.schemaeditor.view.editors.attributetype;
+
+
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.directory.studio.schemaeditor.Activator;
+import org.apache.directory.studio.schemaeditor.model.SyntaxImpl;
+import org.apache.directory.studio.schemaeditor.view.editors.NonExistingSyntax;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+
+/**
+ * This class implements the Content Provider for the Syntax Combo of the Attribute Type Editor.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ATESyntaxComboContentProvider implements IStructuredContentProvider
+{
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+ */
+ public Object[] getElements( Object inputElement )
+ {
+ if ( inputElement instanceof ATESyntaxComboInput )
+ {
+ ATESyntaxComboInput input = ( ATESyntaxComboInput ) inputElement;
+
+ if ( input.getChildren().isEmpty() )
+ {
+ // Creating the '(None)' item
+ input.addChild( new NonExistingSyntax( NonExistingSyntax.NONE ) );
+
+ // Creating Children
+ List<SyntaxImpl> syntaxes = Activator.getDefault().getSchemaHandler().getSyntaxes();
+ for ( SyntaxImpl syntax : syntaxes )
+ {
+ input.addChild( syntax );
+ }
+ }
+
+ // Getting Children
+ List<Object> children = input.getChildren();
+
+ // Sorting Children
+ Collections.sort( children, new ATESyntaxComboComparator() );
+
+ return children.toArray();
+ }
+
+ // Default
+ return new Object[0];
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+ */
+ public void dispose()
+ {
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+ */
+ public void inputChanged( Viewer viewer, Object oldInput, Object newInput )
+ {
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATESyntaxComboContentProvider.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATESyntaxComboInput.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATESyntaxComboInput.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATESyntaxComboInput.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATESyntaxComboInput.java Mon Nov 5 09:14:24 2007
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.directory.studio.schemaeditor.view.editors.attributetype;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * This class implements the Input of the Syntax Combo of the Attribute Type Editor
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ATESyntaxComboInput
+{
+ /** The children */
+ private List<Object> children;
+
+
+ /**
+ * Adds a child.
+ *
+ * @param child
+ * the child to add
+ */
+ public void addChild( Object child )
+ {
+ if ( children == null )
+ {
+ children = new ArrayList<Object>();
+ }
+
+ children.add( child );
+ }
+
+
+ /**
+ * Gets the children.
+ *
+ * @return
+ * the children
+ */
+ public List<Object> getChildren()
+ {
+ if ( children == null )
+ {
+ children = new ArrayList<Object>();
+ }
+
+ return children;
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATESyntaxComboInput.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATESyntaxComboLabelProvider.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATESyntaxComboLabelProvider.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATESyntaxComboLabelProvider.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATESyntaxComboLabelProvider.java Mon Nov 5 09:14:24 2007
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.directory.studio.schemaeditor.view.editors.attributetype;
+
+
+import org.apache.directory.studio.schemaeditor.model.SyntaxImpl;
+import org.apache.directory.studio.schemaeditor.view.editors.NonExistingSyntax;
+import org.eclipse.jface.viewers.LabelProvider;
+
+
+/**
+ * This class implements the Label Provider of the Syntax Combo of the Attribute Type Editor.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ATESyntaxComboLabelProvider extends LabelProvider
+{
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
+ */
+ public String getText( Object obj )
+ {
+ if ( obj instanceof SyntaxImpl )
+ {
+ SyntaxImpl syntax = ( SyntaxImpl ) obj;
+
+ String name = syntax.getName();
+ if ( name != null )
+ {
+ return name + " - (" + syntax.getOid() + ")";
+ }
+ else
+ {
+ return "(None) - (" + syntax.getOid() + ")";
+ }
+ }
+ else if ( obj instanceof NonExistingSyntax )
+ {
+ return ( ( NonExistingSyntax ) obj ).getDisplayName();
+ }
+
+ // Default
+ return null;
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATESyntaxComboLabelProvider.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATEUsedByMandatoryTableContentProvider.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATEUsedByMandatoryTableContentProvider.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATEUsedByMandatoryTableContentProvider.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATEUsedByMandatoryTableContentProvider.java Mon Nov 5 09:14:24 2007
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.directory.studio.schemaeditor.view.editors.attributetype;
+
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.apache.directory.studio.schemaeditor.Activator;
+import org.apache.directory.studio.schemaeditor.controller.SchemaHandler;
+import org.apache.directory.studio.schemaeditor.model.AttributeTypeImpl;
+import org.apache.directory.studio.schemaeditor.model.ObjectClassImpl;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+
+/**
+ * This class is the Content Provider for the Mandatory Table of the Attribute Type Editor (Used By Page).
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ATEUsedByMandatoryTableContentProvider implements IStructuredContentProvider
+{
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+ */
+ public Object[] getElements( Object inputElement )
+ {
+ if ( inputElement instanceof AttributeTypeImpl )
+ {
+ List<ObjectClassImpl> results = new ArrayList<ObjectClassImpl>();
+ AttributeTypeImpl inputAT = ( AttributeTypeImpl ) inputElement;
+ SchemaHandler schemaHandler = Activator.getDefault().getSchemaHandler();
+
+ List<String> names = new ArrayList<String>();
+
+ String[] atNames = inputAT.getNames();
+ if ( atNames != null )
+ {
+ for ( String name : atNames )
+ {
+ names.add( name.toLowerCase() );
+ }
+ }
+
+ List<ObjectClassImpl> objectClasses = schemaHandler.getObjectClasses();
+ for ( ObjectClassImpl oc : objectClasses )
+ {
+ String[] musts = oc.getMustNamesList();
+ if ( musts != null )
+ {
+ for ( String must : musts )
+ {
+ if ( names.contains( must.toLowerCase() ) )
+ {
+ results.add( oc );
+ }
+ }
+ }
+ }
+
+ // Sorting Results
+ Collections.sort( results, new Comparator<ObjectClassImpl>()
+ {
+ public int compare( ObjectClassImpl oc1, ObjectClassImpl oc2 )
+ {
+ if ( oc1 instanceof ObjectClassImpl && oc1 instanceof ObjectClassImpl )
+ {
+ String[] oc1Names = ( ( ObjectClassImpl ) oc1 ).getNames();
+ String[] oc2Names = ( ( ObjectClassImpl ) oc2 ).getNames();
+
+ if ( ( oc1Names != null ) && ( oc2Names != null ) && ( oc1Names.length > 0 )
+ && ( oc2Names.length > 0 ) )
+ {
+ return oc1Names[0].compareToIgnoreCase( oc2Names[0] );
+ }
+ }
+
+ return 0;
+ }
+ } );
+
+ return results.toArray();
+ }
+
+ // Default
+ return null;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+ */
+ public void dispose()
+ {
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+ */
+ public void inputChanged( Viewer viewer, Object oldInput, Object newInput )
+ {
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATEUsedByMandatoryTableContentProvider.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATEUsedByOptionalTableContentProvider.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATEUsedByOptionalTableContentProvider.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATEUsedByOptionalTableContentProvider.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATEUsedByOptionalTableContentProvider.java Mon Nov 5 09:14:24 2007
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.directory.studio.schemaeditor.view.editors.attributetype;
+
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.apache.directory.studio.schemaeditor.Activator;
+import org.apache.directory.studio.schemaeditor.controller.SchemaHandler;
+import org.apache.directory.studio.schemaeditor.model.AttributeTypeImpl;
+import org.apache.directory.studio.schemaeditor.model.ObjectClassImpl;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+
+/**
+ * This class is the Content Provider for the Optional Table of the Attribute Type Editor (Used By Page).
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ATEUsedByOptionalTableContentProvider implements IStructuredContentProvider
+{
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+ */
+ public Object[] getElements( Object inputElement )
+ {
+ if ( inputElement instanceof AttributeTypeImpl )
+ {
+ List<ObjectClassImpl> results = new ArrayList<ObjectClassImpl>();
+ AttributeTypeImpl inputAT = ( AttributeTypeImpl ) inputElement;
+ SchemaHandler schemaHandler = Activator.getDefault().getSchemaHandler();
+
+ List<String> names = new ArrayList<String>();
+
+ String[] atNames = inputAT.getNames();
+ if ( atNames != null )
+ {
+ for ( String name : atNames )
+ {
+ names.add( name.toLowerCase() );
+ }
+ }
+
+ List<ObjectClassImpl> objectClasses = schemaHandler.getObjectClasses();
+ for ( ObjectClassImpl oc : objectClasses )
+ {
+ String[] mays = oc.getMayNamesList();
+ if ( mays != null )
+ {
+ for ( String may : mays )
+ {
+ if ( names.contains( may.toLowerCase() ) )
+ {
+ results.add( oc );
+ }
+ }
+ }
+ }
+
+ // Sorting Results
+ Collections.sort( results, new Comparator<ObjectClassImpl>()
+ {
+ public int compare( ObjectClassImpl oc1, ObjectClassImpl oc2 )
+ {
+ if ( oc1 instanceof ObjectClassImpl && oc1 instanceof ObjectClassImpl )
+ {
+ String[] oc1Names = ( ( ObjectClassImpl ) oc1 ).getNames();
+ String[] oc2Names = ( ( ObjectClassImpl ) oc2 ).getNames();
+
+ if ( ( oc1Names != null ) && ( oc2Names != null ) && ( oc1Names.length > 0 )
+ && ( oc2Names.length > 0 ) )
+ {
+ return oc1Names[0].compareToIgnoreCase( oc2Names[0] );
+ }
+ }
+
+ return 0;
+ }
+ } );
+
+ return results.toArray();
+ }
+
+ // Default
+ return null;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+ */
+ public void dispose()
+ {
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+ */
+ public void inputChanged( Viewer viewer, Object oldInput, Object newInput )
+ {
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATEUsedByOptionalTableContentProvider.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATEUsedByTablesLabelProvider.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATEUsedByTablesLabelProvider.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATEUsedByTablesLabelProvider.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATEUsedByTablesLabelProvider.java Mon Nov 5 09:14:24 2007
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.directory.studio.schemaeditor.view.editors.attributetype;
+
+
+import org.apache.directory.studio.schemaeditor.Activator;
+import org.apache.directory.studio.schemaeditor.PluginConstants;
+import org.apache.directory.studio.schemaeditor.model.ObjectClassImpl;
+import org.apache.directory.studio.schemaeditor.view.ViewUtils;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+
+/**
+ * This class is the Label Provider for the Used By Tables of the Attribute Type Editor (Used By Page).
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ATEUsedByTablesLabelProvider extends LabelProvider implements ITableLabelProvider
+{
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
+ */
+ public Image getColumnImage( Object element, int columnIndex )
+ {
+ if ( element instanceof ObjectClassImpl )
+ {
+ return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, PluginConstants.IMG_OBJECT_CLASS )
+ .createImage();
+ }
+
+ // Default
+ return null;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
+ */
+ public String getColumnText( Object element, int columnIndex )
+ {
+ if ( element instanceof ObjectClassImpl )
+ {
+ return ViewUtils.concateAliases( ( ( ObjectClassImpl ) element ).getNames() );
+ }
+
+ // Default
+ return null;
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/ATEUsedByTablesLabelProvider.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/AttributeTypeEditor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/AttributeTypeEditor.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/AttributeTypeEditor.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/AttributeTypeEditor.java Mon Nov 5 09:14:24 2007
@@ -0,0 +1,299 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.directory.studio.schemaeditor.view.editors.attributetype;
+
+
+import org.apache.directory.studio.schemaeditor.Activator;
+import org.apache.directory.studio.schemaeditor.PluginUtils;
+import org.apache.directory.studio.schemaeditor.controller.AttributeTypeAdapter;
+import org.apache.directory.studio.schemaeditor.controller.AttributeTypeListener;
+import org.apache.directory.studio.schemaeditor.controller.SchemaHandler;
+import org.apache.directory.studio.schemaeditor.controller.SchemaHandlerAdapter;
+import org.apache.directory.studio.schemaeditor.controller.SchemaHandlerListener;
+import org.apache.directory.studio.schemaeditor.model.AttributeTypeImpl;
+import org.apache.directory.studio.schemaeditor.model.Schema;
+import org.apache.log4j.Logger;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.IPageChangedListener;
+import org.eclipse.jface.dialogs.PageChangedEvent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.forms.editor.FormEditor;
+
+
+/**
+ * This class represent the Attribute Type Editor.
+ * <p>
+ * It is used to edit the values of an attribute type.
+ */
+public class AttributeTypeEditor extends FormEditor
+{
+ /** The logger */
+ private static Logger logger = Logger.getLogger( AttributeTypeEditor.class );
+
+ /** The ID of the Editor */
+ public static final String ID = Activator.PLUGIN_ID + ".view.attributeTypeEditor"; //$NON-NLS-1$
+
+ /** The editor */
+ private AttributeTypeEditor instance;
+
+ /** The dirty state flag */
+ private boolean dirty = false;
+
+ // The pages
+ private AttributeTypeEditorOverviewPage overview;
+ private AttributeTypeEditorSourceCodePage sourceCode;
+ private AttributeTypeEditorUsedByPage usedBy;
+
+ /** The original attribute type */
+ private AttributeTypeImpl originalAttributeType;
+
+ /** The attribute type used to save modifications */
+ private AttributeTypeImpl modifiedAttributeType;
+
+ /** The originalSchema */
+ private Schema originalSchema;
+
+ /** The listener for page changed */
+ private IPageChangedListener pageChangedListener = new IPageChangedListener()
+ {
+ public void pageChanged( PageChangedEvent event )
+ {
+ Object selectedPage = event.getSelectedPage();
+
+ if ( selectedPage instanceof AttributeTypeEditorOverviewPage )
+ {
+ if ( !sourceCode.canLeaveThePage() )
+ {
+ notifyError( "The editor of the Source Code contains errors, you cannot return to the Overview page until these errors are fixed." );
+ return;
+ }
+
+ overview.refreshUI();
+ }
+ else if ( selectedPage instanceof AttributeTypeEditorSourceCodePage )
+ {
+ if ( sourceCode.canLeaveThePage() )
+ {
+ sourceCode.refreshUI();
+ }
+ }
+ }
+ };
+
+ /** The attribute type listener */
+ private AttributeTypeListener attributeTypeListener = new AttributeTypeAdapter()
+ {
+ public void attributeTypeRemoved()
+ {
+ getEditorSite().getPage().closeEditor( instance, false );
+ }
+ };
+
+ /** The SchemaHandler listener */
+ private SchemaHandlerListener schemaHandlerListener = new SchemaHandlerAdapter()
+ {
+ public void schemaRemoved( Schema schema )
+ {
+ if ( schema.equals( originalSchema ) )
+ {
+ getEditorSite().getPage().closeEditor( instance, false );
+ }
+ }
+ };
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.forms.editor.FormEditor#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput)
+ */
+ public void init( IEditorSite site, IEditorInput input ) throws PartInitException
+ {
+ super.init( site, input );
+
+ instance = this;
+
+ setSite( site );
+ setInput( input );
+ setPartName( input.getName() );
+
+ originalAttributeType = ( ( AttributeTypeEditorInput ) getEditorInput() ).getAttributeType();
+ modifiedAttributeType = PluginUtils.getClone( originalAttributeType );
+
+ SchemaHandler schemaHandler = Activator.getDefault().getSchemaHandler();
+ originalSchema = schemaHandler.getSchema( originalAttributeType.getSchema() );
+ schemaHandler.addListener( originalAttributeType, attributeTypeListener );
+ schemaHandler.addListener( schemaHandlerListener );
+
+ addPageChangedListener( pageChangedListener );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.forms.editor.FormEditor#dispose()
+ */
+ public void dispose()
+ {
+ SchemaHandler schemaHandler = Activator.getDefault().getSchemaHandler();
+ schemaHandler.removeListener( originalAttributeType, attributeTypeListener );
+ schemaHandler.removeListener( schemaHandlerListener );
+
+ super.dispose();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.forms.editor.FormEditor#addPages()
+ */
+ protected void addPages()
+ {
+ try
+ {
+ overview = new AttributeTypeEditorOverviewPage( this );
+ addPage( overview );
+ sourceCode = new AttributeTypeEditorSourceCodePage( this );
+ addPage( sourceCode );
+ usedBy = new AttributeTypeEditorUsedByPage( this );
+ addPage( usedBy );
+ }
+ catch ( PartInitException e )
+ {
+ logger.debug( "error when adding pages" ); //$NON-NLS-1$
+ }
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public void doSave( IProgressMonitor monitor )
+ {
+ // Verifying if there is an error on the source code page
+ if ( !sourceCode.canLeaveThePage() )
+ {
+ notifyError( "The editor of the Source Code contains errors, you cannot save the attribute type until these errors are fixed." );
+ monitor.setCanceled( true );
+ return;
+ }
+
+ Activator.getDefault().getSchemaHandler().modifyAttributeType( originalAttributeType, modifiedAttributeType );
+
+ setPartName( getEditorInput().getName() );
+ if ( !monitor.isCanceled() )
+ {
+ setDirty( false );
+ }
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.part.EditorPart#doSaveAs()
+ */
+ public void doSaveAs()
+ {
+ // Nothing to do.
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed()
+ */
+ public boolean isSaveAsAllowed()
+ {
+ return false;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.forms.editor.FormEditor#isDirty()
+ */
+ public boolean isDirty()
+ {
+ return this.dirty;
+ }
+
+
+ /**
+ * Sets the dirty state of the editor
+ *
+ * @param dirty
+ * the dirty state
+ */
+ public void setDirty( boolean dirty )
+ {
+ this.dirty = dirty;
+ editorDirtyStateChanged();
+ }
+
+
+ /**
+ * Gets the original attribute type.
+ *
+ * @return
+ * the original attribute type
+ */
+ public AttributeTypeImpl getOriginalAttributeType()
+ {
+ return originalAttributeType;
+ }
+
+
+ /**
+ * Gets the modified attribute type.
+ *
+ * @return
+ * the modified attribute type
+ */
+ public AttributeTypeImpl getModifiedAttributeType()
+ {
+ return modifiedAttributeType;
+ }
+
+
+ /**
+ * Sets the modified attribute type.
+ *
+ * @param modifiedAttributeType
+ * the modified attribute type to set.
+ */
+ public void setModifiedAttributeType( AttributeTypeImpl modifiedAttributeType )
+ {
+ this.modifiedAttributeType = modifiedAttributeType;
+ }
+
+
+ /**
+ * Opens an error dialog displaying the given message.
+ *
+ * @param message
+ * the message to display
+ */
+ private void notifyError( String message )
+ {
+ MessageBox messageBox = new MessageBox( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.OK
+ | SWT.ICON_ERROR );
+ messageBox.setMessage( message );
+ messageBox.open();
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/AttributeTypeEditor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/AttributeTypeEditorInput.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/AttributeTypeEditorInput.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/AttributeTypeEditorInput.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/AttributeTypeEditorInput.java Mon Nov 5 09:14:24 2007
@@ -0,0 +1,146 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.directory.studio.schemaeditor.view.editors.attributetype;
+
+
+import org.apache.directory.studio.schemaeditor.model.AttributeTypeImpl;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IPersistableElement;
+
+
+/**
+ * This class is the Input class for the Attribute Type Editor
+ */
+public class AttributeTypeEditorInput implements IEditorInput
+{
+ /** The input attribute type */
+ private AttributeTypeImpl attributeType;
+
+
+ /**
+ * Default constructor
+ *
+ * @param at
+ * the input attribute type
+ */
+ public AttributeTypeEditorInput( AttributeTypeImpl at )
+ {
+ attributeType = at;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IEditorInput#exists()
+ */
+ public boolean exists()
+ {
+ return ( this.attributeType == null );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
+ */
+ public ImageDescriptor getImageDescriptor()
+ {
+ return null;
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.IEditorInput#getName()
+ */
+ public String getName()
+ {
+ String[] names = attributeType.getNames();
+ if ( ( names != null ) && ( names.length > 0 ) )
+ {
+ return names[0];
+ }
+ else
+ {
+ return attributeType.getOid();
+ }
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IEditorInput#getPersistable()
+ */
+ public IPersistableElement getPersistable()
+ {
+ return null;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IEditorInput#getToolTipText()
+ */
+ public String getToolTipText()
+ {
+ return getName() + " from the " + attributeType.getSchema() + " schema";
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
+ */
+ @SuppressWarnings("unchecked")
+ public Object getAdapter( Class adapter )
+ {
+ return null;
+ }
+
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals( Object obj )
+ {
+ if ( this == obj )
+ {
+
+ return true;
+ }
+ else if ( !( obj instanceof AttributeTypeEditorInput ) )
+ {
+ return false;
+ }
+
+ AttributeTypeEditorInput other = ( AttributeTypeEditorInput ) obj;
+ return other.getAttributeType().equals( this.attributeType );
+ }
+
+
+ /**
+ * Returns the input Attribute Type.
+ *
+ * @return
+ * the input Attribute Type
+ */
+ public AttributeTypeImpl getAttributeType()
+ {
+ return this.attributeType;
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/AttributeTypeEditorInput.java
------------------------------------------------------------------------------
svn:eol-style = native