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 2007/07/06 16:44:52 UTC
svn commit: r553904 -
/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/attributetype/
Author: pamarcelot
Date: Fri Jul 6 07:44:51 2007
New Revision: 553904
URL: http://svn.apache.org/viewvc?view=rev&rev=553904
Log:
Added SchemaHandler listener to the AttributeTypeEditor.
Fixed the SourceCode page.
Fixed a NPE in the UsedBy Page.
Modified:
directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/attributetype/AttributeTypeEditorInput.java
directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/attributetype/AttributeTypeEditorOverviewPage.java
directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/attributetype/AttributeTypeEditorSourceCodePage.java
directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/attributetype/AttributeTypeEditorUsedByPage.java
Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/attributetype/AttributeTypeEditorInput.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/attributetype/AttributeTypeEditorInput.java?view=diff&rev=553904&r1=553903&r2=553904
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/attributetype/AttributeTypeEditorInput.java (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/attributetype/AttributeTypeEditorInput.java Fri Jul 6 07:44:51 2007
@@ -62,7 +62,6 @@
*/
public ImageDescriptor getImageDescriptor()
{
- // TODO Auto-generated method stub
return null;
}
Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/attributetype/AttributeTypeEditorOverviewPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/attributetype/AttributeTypeEditorOverviewPage.java?view=diff&rev=553904&r1=553903&r2=553904
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/attributetype/AttributeTypeEditorOverviewPage.java (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/attributetype/AttributeTypeEditorOverviewPage.java Fri Jul 6 07:44:51 2007
@@ -93,104 +93,130 @@
/** The SchemaHandler Listener */
private SchemaHandlerListener schemaHandlerListener = new SchemaHandlerListener()
{
-
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaHandlerListener#attributeTypeAdded(org.apache.directory.studio.apacheds.schemaeditor.model.AttributeTypeImpl)
+ */
public void attributeTypeAdded( AttributeTypeImpl at )
{
- // TODO Auto-generated method stub
-
+ refreshUI();
}
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaHandlerListener#attributeTypeModified(org.apache.directory.studio.apacheds.schemaeditor.model.AttributeTypeImpl)
+ */
public void attributeTypeModified( AttributeTypeImpl at )
{
- // TODO Auto-generated method stub
-
+ refreshUI();
}
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaHandlerListener#attributeTypeRemoved(org.apache.directory.studio.apacheds.schemaeditor.model.AttributeTypeImpl)
+ */
public void attributeTypeRemoved( AttributeTypeImpl at )
{
- // TODO Auto-generated method stub
-
+ refreshUI();
}
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaHandlerListener#matchingRuleAdded(org.apache.directory.studio.apacheds.schemaeditor.model.MatchingRuleImpl)
+ */
public void matchingRuleAdded( MatchingRuleImpl mr )
{
- // TODO Auto-generated method stub
-
+ refreshUI();
}
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaHandlerListener#matchingRuleModified(org.apache.directory.studio.apacheds.schemaeditor.model.MatchingRuleImpl)
+ */
public void matchingRuleModified( MatchingRuleImpl mr )
{
- // TODO Auto-generated method stub
-
+ refreshUI();
}
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaHandlerListener#matchingRuleRemoved(org.apache.directory.studio.apacheds.schemaeditor.model.MatchingRuleImpl)
+ */
public void matchingRuleRemoved( MatchingRuleImpl mr )
{
- // TODO Auto-generated method stub
-
+ refreshUI();
}
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaHandlerListener#objectClassAdded(org.apache.directory.studio.apacheds.schemaeditor.model.ObjectClassImpl)
+ */
public void objectClassAdded( ObjectClassImpl oc )
{
- // TODO Auto-generated method stub
-
+ refreshUI();
}
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaHandlerListener#objectClassModified(org.apache.directory.studio.apacheds.schemaeditor.model.ObjectClassImpl)
+ */
public void objectClassModified( ObjectClassImpl oc )
{
- // TODO Auto-generated method stub
-
+ refreshUI();
}
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaHandlerListener#objectClassRemoved(org.apache.directory.studio.apacheds.schemaeditor.model.ObjectClassImpl)
+ */
public void objectClassRemoved( ObjectClassImpl oc )
{
- // TODO Auto-generated method stub
-
+ refreshUI();
}
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaHandlerListener#schemaAdded(org.apache.directory.studio.apacheds.schemaeditor.model.Schema)
+ */
public void schemaAdded( Schema schema )
{
- // TODO Auto-generated method stub
-
+ refreshUI();
}
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaHandlerListener#schemaRemoved(org.apache.directory.studio.apacheds.schemaeditor.model.Schema)
+ */
public void schemaRemoved( Schema schema )
{
- // TODO Auto-generated method stub
-
+ refreshUI();
}
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaHandlerListener#syntaxAdded(org.apache.directory.studio.apacheds.schemaeditor.model.SyntaxImpl)
+ */
public void syntaxAdded( SyntaxImpl syntax )
{
- // TODO Auto-generated method stub
-
+ refreshUI();
}
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaHandlerListener#syntaxModified(org.apache.directory.studio.apacheds.schemaeditor.model.SyntaxImpl)
+ */
public void syntaxModified( SyntaxImpl syntax )
{
- // TODO Auto-generated method stub
-
+ refreshUI();
}
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaHandlerListener#syntaxRemoved(org.apache.directory.studio.apacheds.schemaeditor.model.SyntaxImpl)
+ */
public void syntaxRemoved( SyntaxImpl syntax )
{
- // TODO Auto-generated method stub
-
+ refreshUI();
}
-
};
// UI Fields
@@ -491,7 +517,7 @@
{
public void widgetSelected( SelectionEvent e )
{
- modifiedAttributeType.setCanUserModify( noUserModificationCheckbox.getSelection() ); // TODO
+ modifiedAttributeType.setCanUserModify( !noUserModificationCheckbox.getSelection() );
setEditorDirty();
}
};
@@ -591,7 +617,7 @@
{
super( editor, ID, TITLE );
schemaHandler = Activator.getDefault().getSchemaHandler();
- // schemaHandler.addListener( this ); // TODO
+ schemaHandler.addListener( schemaHandlerListener );
}
@@ -844,7 +870,7 @@
collectiveCheckbox.setSelection( modifiedAttributeType.isCollective() );
// NO-USER-MODIFICATION Checkbox
- noUserModificationCheckbox.setSelection( modifiedAttributeType.isCanUserModify() );
+ noUserModificationCheckbox.setSelection( !modifiedAttributeType.isCanUserModify() );
// EQUALITY Combo
fillEqualityCombo();
@@ -1160,7 +1186,7 @@
*/
public void dispose()
{
- // schemaHandler.removeListener( this ); //TODO
+ schemaHandler.removeListener( schemaHandlerListener );
removeListeners();
super.dispose();
}
Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/attributetype/AttributeTypeEditorSourceCodePage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/attributetype/AttributeTypeEditorSourceCodePage.java?view=diff&rev=553904&r1=553903&r2=553904
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/attributetype/AttributeTypeEditorSourceCodePage.java (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/attributetype/AttributeTypeEditorSourceCodePage.java Fri Jul 6 07:44:51 2007
@@ -20,7 +20,6 @@
package org.apache.directory.studio.apacheds.schemaeditor.view.editors.attributetype;
-
import java.io.IOException;
import java.text.ParseException;
import java.util.List;
@@ -45,157 +44,142 @@
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.ScrolledForm;
-
/**
* This class is the Source Code Page of the Attribute Type Editor
*/
-public class AttributeTypeEditorSourceCodePage extends FormPage
-{
- /** The page ID*/
- public static final String ID = AttributeTypeEditor.ID + "sourceCodePage"; //$NON-NLS-1$
-
- /** The page title */
- public static String TITLE = "Source Code";
-
- /** The modified attribute type */
- private AttributeTypeImpl modifiedAttributeType;
-
- /** The Schema Source Viewer */
- private SchemaSourceViewer schemaSourceViewer;
-
- /** The flag to indicate if the user can leave the Source Code page */
- private boolean canLeaveThePage = true;
-
- /** The listener of the Schema Source Editor Widget */
- private ModifyListener schemaSourceViewerListener = new ModifyListener()
- {
- public void modifyText( ModifyEvent e )
- {
- canLeaveThePage = true;
- try
- {
- ( ( AttributeTypeEditor ) getEditor() ).setDirty( true );
- OpenLdapSchemaParser parser = new OpenLdapSchemaParser();
- parser.parse( schemaSourceViewer.getTextWidget().getText() );
- List attributeTypes = parser.getAttributeTypes();
- if ( attributeTypes.size() != 1 )
- {
- // Throw an exception and return
- }
- else
- {
- updateAttributeType( ( AttributeTypeLiteral ) attributeTypes.get( 0 ) );
- }
- }
- catch ( IOException e1 )
- {
- canLeaveThePage = false;
- }
- catch ( ParseException exception )
- {
- canLeaveThePage = false;
- }
- }
- };
-
-
- /**
- * Default constructor
- *
- * @param editor
- * the associated editor
- */
- public AttributeTypeEditorSourceCodePage( FormEditor editor )
- {
- super( editor, ID, TITLE );
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.forms.editor.FormPage#createFormContent(org.eclipse.ui.forms.IManagedForm)
- */
- protected void createFormContent( IManagedForm managedForm )
- {
- ScrolledForm form = managedForm.getForm();
- FormToolkit toolkit = managedForm.getToolkit();
- GridLayout layout = new GridLayout();
- layout.marginWidth = 0;
- layout.marginHeight = 0;
- form.getBody().setLayout( layout );
- toolkit.paintBordersFor( form.getBody() );
-
- modifiedAttributeType = ( ( AttributeTypeEditor ) getEditor() ).getModifiedAttributeType();
-
- // SOURCE CODE Field
- schemaSourceViewer = new SchemaSourceViewer( form.getBody(), null, null, false, SWT.BORDER | SWT.H_SCROLL
- | SWT.V_SCROLL );
- GridData gd = new GridData( SWT.FILL, SWT.FILL, true, true );
- gd.heightHint = 10;
- schemaSourceViewer.getTextWidget().setLayoutData( gd );
-
- // set text font
- Font font = JFaceResources.getFont( JFaceResources.TEXT_FONT );
- schemaSourceViewer.getTextWidget().setFont( font );
-
- IDocument document = new Document();
- schemaSourceViewer.setDocument( document );
-
- // Initialization from the "input" attribute type
- fillInUiFields();
-
- schemaSourceViewer.getTextWidget().addModifyListener( schemaSourceViewerListener );
- }
-
-
- /**
- * Fills in the User Interface.
- */
- private void fillInUiFields()
- {
- // SOURCE CODE Field
- schemaSourceViewer.getDocument().set( PluginUtils.toSourceCode( modifiedAttributeType ) );
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.forms.editor.FormPage#canLeaveThePage()
- */
- public boolean canLeaveThePage()
- {
- return canLeaveThePage;
- }
-
-
- /**
- * Updates the Modified Attribute Type from the given Attribute Type Literal.
- *
- * @param atl
- * the Attribute Type Literal
- */
- private void updateAttributeType( AttributeTypeLiteral atl )
- {
- modifiedAttributeType.setCanUserModify( !atl.isNoUserModification() );
- modifiedAttributeType.setCollective( atl.isCollective() );
- modifiedAttributeType.setDescription( atl.getDescription() );
- modifiedAttributeType.setEqualityName( atl.getEquality() );
- modifiedAttributeType.setLength( atl.getLength() );
- modifiedAttributeType.setNames( atl.getNames() );
- modifiedAttributeType.setObsolete( atl.isObsolete() );
- modifiedAttributeType.setOid( atl.getOid() );
- modifiedAttributeType.setOrderingName( atl.getOrdering() );
- modifiedAttributeType.setSingleValue( atl.isSingleValue() );
- modifiedAttributeType.setSubstrName( atl.getSubstr() );
- modifiedAttributeType.setSuperiorName( atl.getSuperior() );
- modifiedAttributeType.setSyntaxOid( atl.getOid() );
- modifiedAttributeType.setUsage( atl.getUsage() );
- }
-
-
- /**
- * Refreshes the UI.
- */
- public void refreshUI()
- {
- fillInUiFields();
- }
+public class AttributeTypeEditorSourceCodePage extends FormPage {
+ /** The page ID */
+ public static final String ID = AttributeTypeEditor.ID + "sourceCodePage"; //$NON-NLS-1$
+
+ /** The page title */
+ public static String TITLE = "Source Code";
+
+ /** The modified attribute type */
+ private AttributeTypeImpl modifiedAttributeType;
+
+ /** The Schema Source Viewer */
+ private SchemaSourceViewer schemaSourceViewer;
+
+ /** The flag to indicate if the user can leave the Source Code page */
+ private boolean canLeaveThePage = true;
+
+ /** The listener of the Schema Source Editor Widget */
+ private ModifyListener schemaSourceViewerListener = new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ canLeaveThePage = true;
+ try {
+ ((AttributeTypeEditor) getEditor()).setDirty(true);
+ OpenLdapSchemaParser parser = new OpenLdapSchemaParser();
+ parser.parse(schemaSourceViewer.getTextWidget().getText());
+ List attributeTypes = parser.getAttributeTypes();
+ if (attributeTypes.size() != 1) {
+ // Throw an exception and return
+ } else {
+ updateAttributeType((AttributeTypeLiteral) attributeTypes
+ .get(0));
+ }
+ } catch (IOException e1) {
+ canLeaveThePage = false;
+ } catch (ParseException exception) {
+ canLeaveThePage = false;
+ }
+ }
+ };
+
+ /**
+ * Default constructor
+ *
+ * @param editor
+ * the associated editor
+ */
+ public AttributeTypeEditorSourceCodePage(FormEditor editor) {
+ super(editor, ID, TITLE);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.forms.editor.FormPage#createFormContent(org.eclipse.ui.forms.IManagedForm)
+ */
+ protected void createFormContent(IManagedForm managedForm) {
+ ScrolledForm form = managedForm.getForm();
+ FormToolkit toolkit = managedForm.getToolkit();
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
+ form.getBody().setLayout(layout);
+ toolkit.paintBordersFor(form.getBody());
+
+ modifiedAttributeType = ((AttributeTypeEditor) getEditor())
+ .getModifiedAttributeType();
+
+ // SOURCE CODE Field
+ schemaSourceViewer = new SchemaSourceViewer(form.getBody(), null, null,
+ false, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
+ GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+ gd.heightHint = 10;
+ schemaSourceViewer.getTextWidget().setLayoutData(gd);
+
+ // set text font
+ Font font = JFaceResources.getFont(JFaceResources.TEXT_FONT);
+ schemaSourceViewer.getTextWidget().setFont(font);
+
+ IDocument document = new Document();
+ schemaSourceViewer.setDocument(document);
+
+ // Initialization from the "input" attribute type
+ fillInUiFields();
+
+ schemaSourceViewer.getTextWidget().addModifyListener(
+ schemaSourceViewerListener);
+ }
+
+ /**
+ * Fills in the User Interface.
+ */
+ private void fillInUiFields() {
+ // SOURCE CODE Field
+ schemaSourceViewer.getDocument().set(
+ PluginUtils.toSourceCode(modifiedAttributeType));
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.forms.editor.FormPage#canLeaveThePage()
+ */
+ public boolean canLeaveThePage() {
+ return canLeaveThePage;
+ }
+
+ /**
+ * Updates the Modified Attribute Type from the given Attribute Type
+ * Literal.
+ *
+ * @param atl
+ * the Attribute Type Literal
+ */
+ private void updateAttributeType(AttributeTypeLiteral atl) {
+ modifiedAttributeType.setCanUserModify(!atl.isNoUserModification());
+ modifiedAttributeType.setCollective(atl.isCollective());
+ modifiedAttributeType.setDescription(atl.getDescription());
+ modifiedAttributeType.setEqualityName(atl.getEquality());
+ modifiedAttributeType.setLength(atl.getLength());
+ modifiedAttributeType.setNames(atl.getNames());
+ modifiedAttributeType.setObsolete(atl.isObsolete());
+ modifiedAttributeType.setOid(atl.getOid());
+ modifiedAttributeType.setOrderingName(atl.getOrdering());
+ modifiedAttributeType.setSingleValue(atl.isSingleValue());
+ modifiedAttributeType.setSubstrName(atl.getSubstr());
+ modifiedAttributeType.setSuperiorName(atl.getSuperior());
+ modifiedAttributeType.setSyntaxOid(atl.getOid());
+ modifiedAttributeType.setUsage(atl.getUsage());
+ }
+
+ /**
+ * Refreshes the UI.
+ */
+ public void refreshUI() {
+ fillInUiFields();
+ }
}
Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/attributetype/AttributeTypeEditorUsedByPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/attributetype/AttributeTypeEditorUsedByPage.java?view=diff&rev=553904&r1=553903&r2=553904
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/attributetype/AttributeTypeEditorUsedByPage.java (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/attributetype/AttributeTypeEditorUsedByPage.java Fri Jul 6 07:44:51 2007
@@ -338,8 +338,14 @@
*/
public void refreshTableViewers()
{
- mandatoryAttributeTableViewer.refresh();
- optionalAttibuteTableViewer.refresh();
+ if ( mandatoryAttributeTableViewer != null )
+ {
+ mandatoryAttributeTableViewer.refresh();
+ }
+ if ( optionalAttibuteTableViewer != null )
+ {
+ optionalAttibuteTableViewer.refresh();
+ }
}