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 [27/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/wizards/NewProjectWizardConnectionSelectionPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewProjectWizardConnectionSelectionPage.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewProjectWizardConnectionSelectionPage.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewProjectWizardConnectionSelectionPage.java Mon Nov 5 09:14:24 2007
@@ -0,0 +1,192 @@
+/*
+ * 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.wizards;
+
+
+import org.apache.directory.studio.connection.core.Connection;
+import org.apache.directory.studio.connection.core.ConnectionCorePlugin;
+import org.apache.directory.studio.connection.ui.widgets.ConnectionActionGroup;
+import org.apache.directory.studio.connection.ui.widgets.ConnectionConfiguration;
+import org.apache.directory.studio.connection.ui.widgets.ConnectionUniversalListener;
+import org.apache.directory.studio.connection.ui.widgets.ConnectionWidget;
+import org.apache.directory.studio.schemaeditor.Activator;
+import org.apache.directory.studio.schemaeditor.PluginConstants;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+
+/**
+ * This class represents the Information Page of the NewProjectWizard.
+ * <p>
+ * It is used to let the user create a new Project
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class NewProjectWizardConnectionSelectionPage extends WizardPage
+{
+ private ConnectionConfiguration configuration;
+ private ConnectionUniversalListener universalListener;
+
+ // UI Fields
+ private ConnectionWidget connectionWidget;
+ private ConnectionActionGroup actionGroup;
+
+
+ /**
+ * Creates a new instance of NewProjectWizardConnectionSelectionPage.
+ */
+ protected NewProjectWizardConnectionSelectionPage()
+ {
+ super( "NewProjectWizardConnectionSelectionPage" );
+ setTitle( "Create a Schema project." );
+ setDescription( "Please select a connection." );
+ setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+ PluginConstants.IMG_PROJECT_NEW_WIZARD ) );
+ setPageComplete( false );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl( Composite parent )
+ {
+ Composite composite = new Composite( parent, SWT.NONE );
+ composite.setLayout( new GridLayout() );
+
+ // Choose A Connection Label
+ Label label = new Label( composite, SWT.NONE );
+ label.setText( "Choose a connection:" );
+ label.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+ // Creating configuration
+ configuration = new ConnectionConfiguration();
+
+ // Creating Connection Widget
+ connectionWidget = new ConnectionWidget( configuration, null );
+ connectionWidget.createWidget( composite );
+ connectionWidget.setInput( ConnectionCorePlugin.getDefault().getConnectionFolderManager() );
+
+ connectionWidget.getViewer().addSelectionChangedListener( new ISelectionChangedListener()
+ {
+ public void selectionChanged( SelectionChangedEvent event )
+ {
+ validatePage();
+ }
+ } );
+
+ // creating the listener
+ universalListener = new ConnectionUniversalListener( connectionWidget.getViewer() );
+
+ // create actions and context menu (and register global actions)
+ actionGroup = new ConnectionActionGroup( connectionWidget, configuration );
+ actionGroup.fillToolBar( connectionWidget.getToolBarManager() );
+ actionGroup.fillMenu( connectionWidget.getMenuManager() );
+ actionGroup.fillContextMenu( connectionWidget.getContextMenuManager() );
+ actionGroup.activateGlobalActionHandlers();
+
+ initFields();
+
+ setControl( composite );
+ }
+
+
+ /**
+ * Initializes the UI Fields.
+ */
+ private void initFields()
+ {
+ displayErrorMessage( null );
+ setPageComplete( false );
+ }
+
+
+ /**
+ * Validates the page.
+ */
+ private void validatePage()
+ {
+ ISelection selection = connectionWidget.getViewer().getSelection();
+ if ( selection.isEmpty() )
+ {
+ displayErrorMessage( "A connection must be selected." );
+ return;
+ }
+
+ displayErrorMessage( null );
+ }
+
+
+ /**
+ * Displays an error message and set the page status as incomplete
+ * if the message is not null.
+ *
+ * @param message
+ * the message to display
+ */
+ private void displayErrorMessage( String message )
+ {
+ setErrorMessage( message );
+ setPageComplete( message == null );
+ }
+
+
+ /**
+ * Gets the selected connection.
+ *
+ * @return
+ * the selection connection
+ */
+ public Connection getSelectedConnection()
+ {
+ return ( Connection ) ( ( StructuredSelection ) connectionWidget.getViewer().getSelection() ).getFirstElement();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.DialogPage#dispose()
+ */
+ public void dispose()
+ {
+ if ( configuration != null )
+ {
+ actionGroup.dispose();
+ actionGroup = null;
+ configuration.dispose();
+ configuration = null;
+ universalListener.dispose();
+ universalListener = null;
+ connectionWidget.dispose();
+ connectionWidget = null;
+ }
+
+ super.dispose();
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewProjectWizardConnectionSelectionPage.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewProjectWizardInformationPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewProjectWizardInformationPage.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewProjectWizardInformationPage.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewProjectWizardInformationPage.java Mon Nov 5 09:14:24 2007
@@ -0,0 +1,204 @@
+/*
+ * 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.wizards;
+
+
+import org.apache.directory.studio.schemaeditor.Activator;
+import org.apache.directory.studio.schemaeditor.PluginConstants;
+import org.apache.directory.studio.schemaeditor.PluginUtils;
+import org.apache.directory.studio.schemaeditor.controller.ProjectsHandler;
+import org.apache.directory.studio.schemaeditor.model.ProjectType;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+
+/**
+ * This class represents the Information Page of the NewProjectWizard.
+ * <p>
+ * It is used to let the user create a new Project
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class NewProjectWizardInformationPage extends WizardPage
+{
+ /** The ProjectsHandler */
+ private ProjectsHandler projectsHandler;
+
+ // UI Fields
+ private Text nameText;
+ private Button typeOnlineRadio;
+ private Button typeOfflineRadio;
+
+
+ /**
+ * Creates a new instance of NewProjectWizardInformationPage.
+ */
+ protected NewProjectWizardInformationPage()
+ {
+ super( "NewProjectWizardInformationPage" );
+ setTitle( "Create a Schema project." );
+ setDescription( "Please specify a name and a type to create a new Schema project." );
+ setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+ PluginConstants.IMG_PROJECT_NEW_WIZARD ) );
+ projectsHandler = Activator.getDefault().getProjectsHandler();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl( Composite parent )
+ {
+ Composite composite = new Composite( parent, SWT.NULL );
+ GridLayout layout = new GridLayout( 2, false );
+ composite.setLayout( layout );
+
+ // Name
+ Label nameLabel = new Label( composite, SWT.NONE );
+ nameLabel.setText( "Project name:" );
+ nameText = new Text( composite, SWT.BORDER );
+ nameText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+ nameText.addModifyListener( new ModifyListener()
+ {
+ public void modifyText( ModifyEvent e )
+ {
+ dialogChanged();
+ }
+ } );
+
+ if ( PluginUtils.getSchemaConnectors().size() > 0 )
+ {
+ // Type Group
+ Group typeGroup = new Group( composite, SWT.NONE );
+ typeGroup.setText( "Type" );
+ typeGroup.setLayout( new GridLayout() );
+ typeGroup.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ) );
+
+ typeOfflineRadio = new Button( typeGroup, SWT.RADIO );
+ typeOfflineRadio.setText( "Offline Schema" );
+ typeOfflineRadio.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+ typeOnlineRadio = new Button( typeGroup, SWT.RADIO );
+ typeOnlineRadio.setText( "Online Schema from a Directory Server" );
+ typeOnlineRadio.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+ }
+
+ initFields();
+
+ setControl( composite );
+ }
+
+
+ /**
+ * Initializes the UI Fields.
+ */
+ private void initFields()
+ {
+ if ( typeOfflineRadio != null )
+ {
+ typeOfflineRadio.setSelection( true );
+ }
+
+ displayErrorMessage( null );
+ setPageComplete( false );
+ }
+
+
+ /**
+ * This method is called when the user modifies something in the UI.
+ */
+ private void dialogChanged()
+ {
+ // Name
+ if ( nameText.getText().equals( "" ) )
+ {
+ displayErrorMessage( "A name must be specified." );
+ return;
+ }
+ else if ( projectsHandler.isProjectNameAlreadyTaken( nameText.getText() ) )
+ {
+ displayErrorMessage( "A project with this name already exists." );
+ return;
+ }
+
+ displayErrorMessage( null );
+ }
+
+
+ /**
+ * Displays an error message and set the page status as incomplete
+ * if the message is not null.
+ *
+ * @param message
+ * the message to display
+ */
+ private void displayErrorMessage( String message )
+ {
+ setErrorMessage( message );
+ setPageComplete( message == null );
+ }
+
+
+ /**
+ * Gets the name of the project.
+ *
+ * @return
+ * the name of the project
+ */
+ public String getProjectName()
+ {
+ return nameText.getText();
+ }
+
+
+ /**
+ * Gets the type of the project.
+ *
+ * @return
+ * the type of the project
+ */
+ public ProjectType getProjectType()
+ {
+ if ( typeOnlineRadio != null )
+ {
+ if ( typeOnlineRadio.getSelection() )
+ {
+ return ProjectType.ONLINE;
+ }
+ else
+ {
+ return ProjectType.OFFLINE;
+ }
+ }
+
+ // Default
+ return ProjectType.OFFLINE;
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewProjectWizardInformationPage.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewProjectWizardSchemasSelectionPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewProjectWizardSchemasSelectionPage.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewProjectWizardSchemasSelectionPage.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewProjectWizardSchemasSelectionPage.java Mon Nov 5 09:14:24 2007
@@ -0,0 +1,240 @@
+/*
+ * 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.wizards;
+
+
+import java.util.Arrays;
+
+import org.apache.directory.studio.schemaeditor.Activator;
+import org.apache.directory.studio.schemaeditor.PluginConstants;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+
+/**
+ * This class represents the Information Page of the NewProjectWizard.
+ * <p>
+ * It is used to let the user create a new Project
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class NewProjectWizardSchemasSelectionPage extends WizardPage
+{
+ // UI Fields
+ private Button typeApacheDSButton;
+ private Button typeOpenLDAPButton;
+ private CheckboxTableViewer coreSchemasTableViewer;
+
+
+ /**
+ * Creates a new instance of NewProjectWizardSchemasSelectionPage.
+ */
+ protected NewProjectWizardSchemasSelectionPage()
+ {
+ super( "NewProjectWizardSchemasSelectionPage" );
+ setTitle( "Create a Schema project." );
+ setDescription( "Please select the core schemas to include in the project." );
+ setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+ PluginConstants.IMG_PROJECT_NEW_WIZARD ) );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl( Composite parent )
+ {
+ Composite composite = new Composite( parent, SWT.NONE );
+ composite.setLayout( new GridLayout( 2, false ) );
+ composite.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
+
+ // Server Type Group
+ Group serverTypeGroup = new Group( composite, SWT.NONE );
+ serverTypeGroup.setText( "Server Type" );
+ serverTypeGroup.setLayout( new GridLayout( 2, false ) );
+ serverTypeGroup.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ) );
+
+ // Type Apache DS Button
+ typeApacheDSButton = new Button( serverTypeGroup, SWT.RADIO );
+ typeApacheDSButton.setText( "Apache DS" );
+ typeApacheDSButton.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ initCoreSchemasTableViewerApacheDS();
+ }
+ } );
+
+ // Type OpenLDAP Button
+ typeOpenLDAPButton = new Button( serverTypeGroup, SWT.RADIO );
+ typeOpenLDAPButton.setText( "OpenLDAP" );
+ typeOpenLDAPButton.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ initCoreSchemasTableViewerOpenLDAP();
+ }
+ } );
+
+ // Core Schemas Label
+ Label coreSchemaslabel = new Label( composite, SWT.NONE );
+ coreSchemaslabel.setText( "Choose the 'core' schemas to include:" );
+ coreSchemaslabel.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ) );
+
+ // Core Schemas TableViewer
+ coreSchemasTableViewer = new CheckboxTableViewer( new Table( composite, SWT.BORDER | SWT.CHECK
+ | SWT.FULL_SELECTION ) );
+ GridData gridData = new GridData( SWT.FILL, SWT.FILL, true, true, 1, 2 );
+ gridData.heightHint = 127;
+ coreSchemasTableViewer.getTable().setLayoutData( gridData );
+ coreSchemasTableViewer.setContentProvider( new ArrayContentProvider() );
+ coreSchemasTableViewer.setLabelProvider( new LabelProvider()
+ {
+ public Image getImage( Object element )
+ {
+ return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, PluginConstants.IMG_SCHEMA )
+ .createImage();
+ }
+ } );
+
+ Button coreSchemasTableSelectAllButton = new Button( composite, SWT.PUSH );
+ coreSchemasTableSelectAllButton.setText( "Select All" );
+ coreSchemasTableSelectAllButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) );
+ coreSchemasTableSelectAllButton.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ coreSchemasTableViewer.setAllChecked( true );
+ }
+ } );
+
+ Button coreSchemasTableDeselectAllButton = new Button( composite, SWT.PUSH );
+ coreSchemasTableDeselectAllButton.setText( "Deselect All" );
+ coreSchemasTableDeselectAllButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) );
+ coreSchemasTableDeselectAllButton.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ coreSchemasTableViewer.setAllChecked( false );
+ }
+ } );
+
+ initFields();
+
+ setControl( composite );
+ }
+
+
+ /**
+ * Initializes the UI Fields.
+ */
+ private void initFields()
+ {
+ typeApacheDSButton.setSelection( true );
+
+ initCoreSchemasTableViewerApacheDS();
+ }
+
+
+ /**
+ * Initializes the Core Schemas Table with Apache DS Schemas
+ */
+ private void initCoreSchemasTableViewerApacheDS()
+ {
+ coreSchemasTableViewer.setAllChecked( false );
+ coreSchemasTableViewer.setInput( new String[]
+ { "apache", "apachedns", "apachemeta", "autofs", "collective", "corba", "core", "cosine", "dhcp",
+ "inetorgperson", "java", "krb5kdc", "mozilla", "nis", "samba", "system" } );
+ }
+
+
+ /**
+ * Initializes the Core Schemas Table with Apache DS Schemas
+ */
+ private void initCoreSchemasTableViewerOpenLDAP()
+ {
+ coreSchemasTableViewer.setAllChecked( false );
+ coreSchemasTableViewer.setInput( new String[]
+ { "corba", "core", "cosine", "dyngroup", "inetorgperson", "java", "misc", "nis", "openldap", "ppolicy",
+ "system" } );
+ }
+
+
+ /**
+ * Gets the schemas selected by the User.
+ *
+ * @return
+ * the selected schemas
+ */
+ public String[] getSelectedSchemas()
+ {
+ return Arrays.asList( coreSchemasTableViewer.getCheckedElements() ).toArray( new String[0] );
+ }
+
+
+ /**
+ * Gets the Server Type
+ *
+ * @return
+ * the Server Type
+ */
+ public ServerTypeEnum getServerType()
+ {
+ if ( typeApacheDSButton.getSelection() )
+ {
+ return ServerTypeEnum.APACHE_DS;
+ }
+ else if ( typeOpenLDAPButton.getSelection() )
+ {
+ return ServerTypeEnum.OPENLDAP;
+ }
+ else
+ {
+ // Default
+ return null;
+ }
+ }
+
+ /**
+ * This enum represents the different server types.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+ public enum ServerTypeEnum
+ {
+ APACHE_DS, OPENLDAP
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewProjectWizardSchemasSelectionPage.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewSchemaWizard.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewSchemaWizard.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewSchemaWizard.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewSchemaWizard.java Mon Nov 5 09:14:24 2007
@@ -0,0 +1,77 @@
+/*
+ * 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.wizards;
+
+
+import org.apache.directory.studio.schemaeditor.Activator;
+import org.apache.directory.studio.schemaeditor.model.SchemaImpl;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+
+
+/**
+ * This class represents the wizard to create a new Schema.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class NewSchemaWizard extends Wizard implements INewWizard
+{
+ public static final String ID = Activator.PLUGIN_ID + ".wizards.NewSchemaWizard";
+
+ // The pages of the wizard
+ private NewSchemaWizardPage page;
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.Wizard#addPages()
+ */
+ public void addPages()
+ {
+ // Creating pages
+ page = new NewSchemaWizardPage();
+
+ // Adding pages
+ addPage( page );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.Wizard#performFinish()
+ */
+ public boolean performFinish()
+ {
+ SchemaImpl schema = new SchemaImpl( page.getSchemaName() );
+ Activator.getDefault().getSchemaHandler().addSchema( schema );
+
+ return true;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ public void init( IWorkbench workbench, IStructuredSelection selection )
+ {
+ // Nothing to do.
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewSchemaWizard.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewSchemaWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewSchemaWizardPage.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewSchemaWizardPage.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewSchemaWizardPage.java Mon Nov 5 09:14:24 2007
@@ -0,0 +1,152 @@
+/*
+ * 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.wizards;
+
+
+import org.apache.directory.studio.schemaeditor.Activator;
+import org.apache.directory.studio.schemaeditor.PluginConstants;
+import org.apache.directory.studio.schemaeditor.controller.SchemaHandler;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+
+/**
+ * This class represents the WizardPage of the NewSchemaWizard.
+ * <p>
+ * It is used to let the user create a new Schema
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class NewSchemaWizardPage extends WizardPage
+{
+ /** The ProjectsHandler */
+ private SchemaHandler schemaHandler;
+
+ // UI Fields
+ private Text nameText;
+
+
+ /**
+ * Creates a new instance of NewSchemaWizardPage.
+ */
+ protected NewSchemaWizardPage()
+ {
+ super( "NewSchemaWizardPage" );
+ setTitle( "Create a Schema" );
+ setDescription( "Please specify a name to create a new schema." );
+ setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+ PluginConstants.IMG_SCHEMA_NEW_WIZARD ) );
+ schemaHandler = Activator.getDefault().getSchemaHandler();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl( Composite parent )
+ {
+ Composite composite = new Composite( parent, SWT.NULL );
+ GridLayout layout = new GridLayout( 2, false );
+ composite.setLayout( layout );
+
+ // Name
+ Label nameLabel = new Label( composite, SWT.NONE );
+ nameLabel.setText( "Schema name:" );
+ nameText = new Text( composite, SWT.BORDER );
+ nameText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+ nameText.addModifyListener( new ModifyListener()
+ {
+ public void modifyText( ModifyEvent e )
+ {
+ dialogChanged();
+ }
+ } );
+
+ initFields();
+
+ setControl( composite );
+ }
+
+
+ /**
+ * Initializes the UI Fields.
+ */
+ private void initFields()
+ {
+ displayErrorMessage( null );
+ setPageComplete( false );
+ }
+
+
+ /**
+ * This method is called when the user modifies something in the UI.
+ */
+ private void dialogChanged()
+ {
+ // Name
+ if ( nameText.getText().equals( "" ) )
+ {
+ displayErrorMessage( "A name must be specified." );
+ return;
+ }
+ else if ( schemaHandler.isSchemaNameAlreadyTaken( nameText.getText() ) )
+ {
+ displayErrorMessage( "A schema with this name already exists." );
+ return;
+ }
+
+ displayErrorMessage( null );
+ }
+
+
+ /**
+ * Displays an error message and set the page status as incomplete
+ * if the message is not null.
+ *
+ * @param message
+ * the message to display
+ */
+ private void displayErrorMessage( String message )
+ {
+ setErrorMessage( message );
+ setPageComplete( message == null );
+ }
+
+
+ /**
+ * Gets the name of the schema.
+ *
+ * @return
+ * the name of the schema
+ */
+ public String getSchemaName()
+ {
+ return nameText.getText();
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewSchemaWizardPage.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/AbstractTreeNode.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/AbstractTreeNode.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/AbstractTreeNode.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/AbstractTreeNode.java Mon Nov 5 09:14:24 2007
@@ -0,0 +1,180 @@
+/*
+ * 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.wrappers;
+
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+
+/**
+ * This abstract class implements the TreeNode Interface.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public abstract class AbstractTreeNode implements TreeNode
+{
+ /** The children */
+ protected List<TreeNode> fChildren;
+
+ /** The parent */
+ protected TreeNode fParent;
+
+
+ /**
+ * Creates a new instance of AbstractTreeNode.
+ *
+ * @param parent
+ * the parent element
+ */
+ public AbstractTreeNode( TreeNode parent )
+ {
+ fParent = parent;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.schemas.view.viewers.wrappers.ITreeNode#hasChildren()
+ */
+ public boolean hasChildren()
+ {
+ if ( fChildren == null )
+ {
+ return false;
+ }
+
+ return !fChildren.isEmpty();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.schemas.view.viewers.wrappers.ITreeNode#getParent()
+ */
+ public TreeNode getParent()
+ {
+ return fParent;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.schemas.view.viewers.wrappers.ITreeNode#setParent(org.apache.directory.studio.schemas.view.viewers.wrappers.ITreeNode)
+ */
+ public void setParent( TreeNode parent )
+ {
+ fParent = parent;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.schemas.view.viewers.wrappers.ITreeNode#getChildren()
+ */
+ public List<TreeNode> getChildren()
+ {
+ if ( fChildren == null )
+ {
+ fChildren = new ArrayList<TreeNode>();
+ }
+
+ return fChildren;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.schemas.view.viewers.wrappers.ITreeNode#addChild(org.apache.directory.studio.schemas.view.viewers.wrappers.ITreeNode)
+ */
+ public void addChild( TreeNode node )
+ {
+ if ( fChildren == null )
+ {
+ fChildren = new ArrayList<TreeNode>();
+ }
+
+ if ( !fChildren.contains( node ) )
+ {
+ fChildren.add( node );
+ }
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.schemas.view.viewers.wrappers.ITreeNode#removeChild(org.apache.directory.studio.schemas.view.viewers.wrappers.ITreeNode)
+ */
+ public void removeChild( TreeNode node )
+ {
+ if ( fChildren != null )
+ {
+ fChildren.remove( node );
+ }
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.schemas.view.viewers.wrappers.ITreeNode#addAllChildren(java.util.Collection)
+ */
+ public boolean addAllChildren( Collection<? extends TreeNode> c )
+ {
+ if ( fChildren == null )
+ {
+ fChildren = new ArrayList<TreeNode>();
+ }
+
+ return fChildren.addAll( c );
+ }
+
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals( Object obj )
+ {
+ if ( obj instanceof AbstractTreeNode )
+ {
+ AbstractTreeNode atn = ( AbstractTreeNode ) obj;
+
+ if ( ( fParent != null ) && ( !fParent.equals( atn.getParent() ) ) )
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ // Default
+ return false;
+ }
+
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ public int hashCode()
+ {
+ int result = 17;
+
+ if ( fParent != null )
+ {
+ result = 37 * result + fParent.hashCode();
+ }
+
+ return result;
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/AbstractTreeNode.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/AttributeTypeWrapper.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/AttributeTypeWrapper.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/AttributeTypeWrapper.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/AttributeTypeWrapper.java Mon Nov 5 09:14:24 2007
@@ -0,0 +1,126 @@
+/*
+ * 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.wrappers;
+
+
+import org.apache.directory.studio.schemaeditor.model.AttributeTypeImpl;
+
+
+/**
+ * This class is used to wrap an AttributeType in a TreeViewer.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class AttributeTypeWrapper extends AbstractTreeNode
+{
+ /** The wrapped AttributeType */
+ private AttributeTypeImpl attributeType;
+
+
+ /**
+ * Creates a new instance of AttributeTypeWrapper.
+ *
+ * @param at
+ * the wrapped AttributeType
+ */
+ public AttributeTypeWrapper( AttributeTypeImpl at )
+ {
+ super( null );
+ attributeType = at;
+ }
+
+
+ /**
+ * Creates a new instance of AttributeTypeWrapper.
+ *
+ * @param at
+ * the wrapped AttributeType
+ * @param parent
+ * the parent TreeNode
+ */
+ public AttributeTypeWrapper( AttributeTypeImpl at, TreeNode parent )
+ {
+ super( parent );
+ attributeType = at;
+ }
+
+
+ /**
+ * Gets the wrapped AttributeType.
+ *
+ * @return
+ * the wrapped AttributeType
+ */
+ public AttributeTypeImpl getAttributeType()
+ {
+ return attributeType;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.schemaeditor.view.wrappers.AbstractTreeNode#equals(java.lang.Object)
+ */
+ public boolean equals( Object obj )
+ {
+ if ( obj instanceof AttributeTypeWrapper )
+ {
+ if ( super.equals( obj ) )
+ {
+ AttributeTypeWrapper atw = ( AttributeTypeWrapper ) obj;
+
+ if ( ( attributeType != null ) && ( !attributeType.equals( atw.getAttributeType() ) ) )
+ {
+ return false;
+ }
+
+ return true;
+ }
+ }
+
+ // Default
+ return false;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.schemaeditor.view.wrappers.AbstractTreeNode#hashCode()
+ */
+ public int hashCode()
+ {
+ int result = super.hashCode();
+
+ if ( attributeType != null )
+ {
+ result = 37 * result + attributeType.hashCode();
+ }
+
+ return result;
+ }
+
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString()
+ {
+ return "AttributeTypeWrapper: " + attributeType + " - parent: " + fParent;
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/AttributeTypeWrapper.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/FirstNameSorter.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/FirstNameSorter.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/FirstNameSorter.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/FirstNameSorter.java Mon Nov 5 09:14:24 2007
@@ -0,0 +1,96 @@
+/*
+ * 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.wrappers;
+
+
+import java.util.Comparator;
+
+import org.apache.directory.studio.schemaeditor.model.AttributeTypeImpl;
+import org.apache.directory.studio.schemaeditor.model.ObjectClassImpl;
+
+
+/**
+ * This class is used to compare and sort ascending two TreeNode.
+ */
+public class FirstNameSorter implements Comparator<TreeNode>
+{
+ /* (non-Javadoc)
+ * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
+ */
+ public int compare( TreeNode o1, TreeNode o2 )
+ {
+ String[] o1Names = null;
+ String[] o2Names = null;
+
+ if ( ( o1 instanceof AttributeTypeWrapper ) && ( o2 instanceof AttributeTypeWrapper ) )
+ {
+ AttributeTypeImpl at1 = ( ( AttributeTypeWrapper ) o1 ).getAttributeType();
+ AttributeTypeImpl at2 = ( ( AttributeTypeWrapper ) o2 ).getAttributeType();
+
+ o1Names = at1.getNames();
+ o2Names = at2.getNames();
+ }
+ else if ( ( o1 instanceof ObjectClassWrapper ) && ( o2 instanceof ObjectClassWrapper ) )
+ {
+ ObjectClassImpl oc1 = ( ( ObjectClassWrapper ) o1 ).getObjectClass();
+ ObjectClassImpl oc2 = ( ( ObjectClassWrapper ) o2 ).getObjectClass();
+
+ o1Names = oc1.getNames();
+ o2Names = oc2.getNames();
+ }
+ else if ( ( o1 instanceof AttributeTypeWrapper ) && ( o2 instanceof ObjectClassWrapper ) )
+ {
+ AttributeTypeImpl at = ( ( AttributeTypeWrapper ) o1 ).getAttributeType();
+ ObjectClassImpl oc = ( ( ObjectClassWrapper ) o2 ).getObjectClass();
+
+ o1Names = at.getNames();
+ o2Names = oc.getNames();
+ }
+ else if ( ( o1 instanceof ObjectClassWrapper ) && ( o2 instanceof AttributeTypeWrapper ) )
+ {
+ ObjectClassImpl oc = ( ( ObjectClassWrapper ) o1 ).getObjectClass();
+ AttributeTypeImpl at = ( ( AttributeTypeWrapper ) o2 ).getAttributeType();
+
+ o1Names = oc.getNames();
+ o2Names = at.getNames();
+ }
+
+ // Comparing the First Name
+ if ( ( o1Names != null ) && ( o2Names != null ) )
+ {
+ if ( ( o1Names.length > 0 ) && ( o2Names.length > 0 ) )
+ {
+ return o1Names[0].compareToIgnoreCase( o2Names[0] );
+ }
+ else if ( ( o1Names.length == 0 ) && ( o2Names.length > 0 ) )
+ {
+ return "".compareToIgnoreCase( o2Names[0] );
+ }
+ else if ( ( o1Names.length > 0 ) && ( o2Names.length == 0 ) )
+ {
+ return o1Names[0].compareToIgnoreCase( "" );
+ }
+ }
+
+ // Default
+ return o1.toString().compareToIgnoreCase( o2.toString() );
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/FirstNameSorter.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/Folder.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/Folder.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/Folder.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/Folder.java Mon Nov 5 09:14:24 2007
@@ -0,0 +1,187 @@
+/*
+ * 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.wrappers;
+
+
+/**
+ * This used to represent a folder in a TreeViewer.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class Folder extends AbstractTreeNode
+{
+ /**
+ * This enum represents the different types of folders.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+ public enum FolderType
+ {
+ NONE, ATTRIBUTE_TYPE, OBJECT_CLASS, ERROR, WARNING
+ }
+
+ /** The type of the Folder */
+ private FolderType type = FolderType.NONE;
+
+ /** The name of the Folder */
+ private String name = "";
+
+ private static final String NAME_AT = "Attribute Types";
+ private static final String NAME_OC = "Object Classes";
+ private static final String NAME_ERROR = "Errors";
+ private static final String NAME_WARNING = "Warnings";
+
+
+ /**
+ * Creates a new instance of Folder.
+ *
+ * @param type
+ * the type of the Folder
+ * @param parent
+ * the parent TreeNode
+ */
+ public Folder( FolderType type, TreeNode parent )
+ {
+ super( parent );
+ this.type = type;
+
+ switch ( type )
+ {
+ case ATTRIBUTE_TYPE:
+ name = NAME_AT;
+ break;
+ case OBJECT_CLASS:
+ name = NAME_OC;
+ break;
+ case ERROR:
+ name = NAME_ERROR;
+ break;
+ case WARNING:
+ name = NAME_WARNING;
+ break;
+ }
+ }
+
+
+ /**
+ * Creates a new instance of Folder.
+ *
+ * @param type
+ * the type of the Folder
+ * @param name
+ * the name of the Folder
+ * @param parent
+ * the parent TreeNode
+ */
+ public Folder( FolderType type, String name, TreeNode parent )
+ {
+ super( parent );
+ this.type = type;
+ this.name = name;
+ }
+
+
+ /**
+ * Get the type of the Folder.
+ *
+ * @return
+ * the type of the Folder
+ */
+ public FolderType getType()
+ {
+ return type;
+ }
+
+
+ /**
+ * Gets the name of the Folder.
+ *
+ * @return
+ * the name of the Folder
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals( Object obj )
+ {
+ if ( obj instanceof Folder )
+ {
+ Folder folder = ( Folder ) obj;
+
+ if ( ( getParent() != null ) && ( !getParent().equals( folder.getParent() ) ) )
+ {
+ return false;
+ }
+
+ if ( !getType().equals( folder.getType() ) )
+ {
+ return false;
+ }
+
+ if ( ( getName() != null ) && ( !getName().equals( folder.getName() ) ) )
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ return false;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.schemaeditor.view.wrappers.AbstractTreeNode#hashCode()
+ */
+ public int hashCode()
+ {
+ int result = super.hashCode();
+
+ if ( name != null )
+ {
+ result = 37 * result + name.hashCode();
+ }
+
+ if ( type != null )
+ {
+ result = 37 * result + type.hashCode();
+ }
+
+ return result;
+ }
+
+
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString()
+ {
+ return "Folder: " + type + " - parent: " + fParent;
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/Folder.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/ObjectClassWrapper.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/ObjectClassWrapper.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/ObjectClassWrapper.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/ObjectClassWrapper.java Mon Nov 5 09:14:24 2007
@@ -0,0 +1,126 @@
+/*
+ * 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.wrappers;
+
+
+import org.apache.directory.studio.schemaeditor.model.ObjectClassImpl;
+
+
+/**
+ * This class is used to wrap an ObjectClass in a TreeViewer.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ObjectClassWrapper extends AbstractTreeNode
+{
+ /** The wrapped ObjectClass */
+ private ObjectClassImpl objectClass;
+
+
+ /**
+ * Creates a new instance of ObjectClassWrapper.
+ *
+ * @param oc
+ * the wrapped ObjectClass
+ */
+ public ObjectClassWrapper( ObjectClassImpl oc )
+ {
+ super( null );
+ objectClass = oc;
+ }
+
+
+ /**
+ * Creates a new instance of ObjectClassWrapper.
+ *
+ * @param at
+ * the wrapped ObjectClass
+ * @param parent
+ * the parent TreeNode
+ */
+ public ObjectClassWrapper( ObjectClassImpl oc, TreeNode parent )
+ {
+ super( parent );
+ objectClass = oc;
+ }
+
+
+ /**
+ * Gets the wrapped ObjectClass.
+ *
+ * @return
+ * the wrapped ObjectClass
+ */
+ public ObjectClassImpl getObjectClass()
+ {
+ return objectClass;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.schemaeditor.view.wrappers.AbstractTreeNode#equals(java.lang.Object)
+ */
+ public boolean equals( Object obj )
+ {
+ if ( obj instanceof ObjectClassWrapper )
+ {
+ if ( super.equals( obj ) )
+ {
+ ObjectClassWrapper ocw = ( ObjectClassWrapper ) obj;
+
+ if ( ( objectClass != null ) && ( !objectClass.equals( ocw.getObjectClass() ) ) )
+ {
+ return false;
+ }
+
+ return true;
+ }
+ }
+
+ // Default
+ return false;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.schemaeditor.view.wrappers.AbstractTreeNode#hashCode()
+ */
+ public int hashCode()
+ {
+ int result = super.hashCode();
+
+ if ( objectClass != null )
+ {
+ result = 37 * result + objectClass.hashCode();
+ }
+
+ return result;
+ }
+
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString()
+ {
+ return "ObjectClassWrapper: " + objectClass + " - parent: " + fParent;
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/ObjectClassWrapper.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/OidSorter.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/OidSorter.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/OidSorter.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/OidSorter.java Mon Nov 5 09:14:24 2007
@@ -0,0 +1,72 @@
+/*
+ * 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.wrappers;
+
+
+import java.util.Comparator;
+
+import org.apache.directory.studio.schemaeditor.model.AttributeTypeImpl;
+import org.apache.directory.studio.schemaeditor.model.ObjectClassImpl;
+
+
+/**
+ * This class is used to compare and sort ascending two DisplayableTreeElement
+ */
+public class OidSorter implements Comparator<TreeNode>
+{
+ /* (non-Javadoc)
+ * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
+ */
+ public int compare( TreeNode o1, TreeNode o2 )
+ {
+ if ( ( o1 instanceof AttributeTypeWrapper ) && ( o2 instanceof AttributeTypeWrapper ) )
+ {
+ AttributeTypeImpl at1 = ( ( AttributeTypeWrapper ) o1 ).getAttributeType();
+ AttributeTypeImpl at2 = ( ( AttributeTypeWrapper ) o2 ).getAttributeType();
+
+ return at1.getOid().compareToIgnoreCase( at2.getOid() );
+ }
+ else if ( ( o1 instanceof ObjectClassWrapper ) && ( o2 instanceof ObjectClassWrapper ) )
+ {
+ ObjectClassImpl oc1 = ( ( ObjectClassWrapper ) o1 ).getObjectClass();
+ ObjectClassImpl oc2 = ( ( ObjectClassWrapper ) o2 ).getObjectClass();
+
+ return oc1.getOid().compareToIgnoreCase( oc2.getOid() );
+ }
+ else if ( ( o1 instanceof AttributeTypeWrapper ) && ( o2 instanceof ObjectClassWrapper ) )
+ {
+ AttributeTypeImpl at = ( ( AttributeTypeWrapper ) o1 ).getAttributeType();
+ ObjectClassImpl oc = ( ( ObjectClassWrapper ) o2 ).getObjectClass();
+
+ return at.getOid().compareToIgnoreCase( oc.getOid() );
+ }
+ else if ( ( o1 instanceof ObjectClassWrapper ) && ( o2 instanceof AttributeTypeWrapper ) )
+ {
+ ObjectClassImpl oc = ( ( ObjectClassWrapper ) o1 ).getObjectClass();
+ AttributeTypeImpl at = ( ( AttributeTypeWrapper ) o2 ).getAttributeType();
+
+ return oc.getOid().compareToIgnoreCase( at.getOid() );
+ }
+
+ // Default
+ return o1.toString().compareToIgnoreCase( o2.toString() );
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/OidSorter.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/ProblemsViewRoot.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/ProblemsViewRoot.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/ProblemsViewRoot.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/ProblemsViewRoot.java Mon Nov 5 09:14:24 2007
@@ -0,0 +1,52 @@
+/*
+ * 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.wrappers;
+
+
+/**
+ * This wrapper is used as root in the Problems View.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ProblemsViewRoot extends AbstractTreeNode
+{
+ /**
+ * Creates a new instance of ProblemsViewRoot.
+ */
+ public ProblemsViewRoot()
+ {
+ super( null );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.schemaeditor.view.wrappers.AbstractTreeNode#equals(java.lang.Object)
+ */
+ public boolean equals( Object obj )
+ {
+ if ( obj instanceof ProblemsViewRoot )
+ {
+ return this == obj;
+ }
+
+ return false;
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/ProblemsViewRoot.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/ProjectSorter.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/ProjectSorter.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/ProjectSorter.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/ProjectSorter.java Mon Nov 5 09:14:24 2007
@@ -0,0 +1,48 @@
+/*
+ * 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.wrappers;
+
+
+import java.util.Comparator;
+
+
+/**
+ * This class is used to compare and sort ascending two TreeNode
+ */
+public class ProjectSorter implements Comparator<TreeNode>
+{
+ /* (non-Javadoc)
+ * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
+ */
+ public int compare( TreeNode tn1, TreeNode tn2 )
+ {
+ if ( ( tn1 instanceof ProjectWrapper ) && ( tn2 instanceof ProjectWrapper ) )
+ {
+ ProjectWrapper pw1 = ( ProjectWrapper ) tn1;
+ ProjectWrapper pw2 = ( ProjectWrapper ) tn2;
+
+ return pw1.getProject().getName().compareToIgnoreCase( pw2.getProject().getName() );
+ }
+
+ // Default
+ return 0;
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/ProjectSorter.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/ProjectWrapper.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/ProjectWrapper.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/ProjectWrapper.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/ProjectWrapper.java Mon Nov 5 09:14:24 2007
@@ -0,0 +1,122 @@
+/*
+ * 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.wrappers;
+
+
+import org.apache.directory.studio.schemaeditor.Activator;
+import org.apache.directory.studio.schemaeditor.controller.ProjectListener;
+import org.apache.directory.studio.schemaeditor.model.Project;
+import org.eclipse.jface.viewers.TableViewer;
+
+
+/**
+ * This class is used to wrap a Project in a TreeViewer.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ProjectWrapper extends AbstractTreeNode
+{
+ /** The wrapped Project */
+ private Project project;
+
+ /** The TableViewer */
+ private TableViewer viewer;
+
+
+ /**
+ * Creates a new instance of ProjectWrapper.
+ *
+ * @param project
+ * the wrapped Project
+ */
+ public ProjectWrapper( Project project, final TableViewer tableViewer )
+ {
+ super( null );
+ this.project = project;
+ this.viewer = tableViewer;
+
+ Activator.getDefault().getProjectsHandler().addListener( project, new ProjectListener()
+ {
+ public void projectRenamed()
+ {
+ viewer.refresh();
+ }
+ } );
+ }
+
+
+ /**
+ * Gets the wrapped Project.
+ *
+ * @return
+ * the wrapped Project
+ */
+ public Project getProject()
+ {
+ return project;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.schemaeditor.view.wrappers.AbstractTreeNode#hasChildren()
+ */
+ public boolean hasChildren()
+ {
+ return false;
+ }
+
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals( Object obj )
+ {
+ if ( obj instanceof ProjectWrapper )
+ {
+ ProjectWrapper projectWrapper = ( ProjectWrapper ) obj;
+
+ if ( ( project != null ) && ( !project.equals( projectWrapper.getProject() ) ) )
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ return false;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.schemaeditor.view.wrappers.AbstractTreeNode#hashCode()
+ */
+ public int hashCode()
+ {
+ int result = super.hashCode();
+
+ if ( project != null )
+ {
+ result = 37 * result + project.hashCode();
+ }
+
+ return result;
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/ProjectWrapper.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/ProjectsViewRoot.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/ProjectsViewRoot.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/ProjectsViewRoot.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/ProjectsViewRoot.java Mon Nov 5 09:14:24 2007
@@ -0,0 +1,141 @@
+/*
+ * 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.wrappers;
+
+
+import org.apache.directory.studio.schemaeditor.Activator;
+import org.apache.directory.studio.schemaeditor.controller.ProjectsHandler;
+import org.apache.directory.studio.schemaeditor.controller.ProjectsHandlerListener;
+import org.apache.directory.studio.schemaeditor.model.Project;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.widgets.Display;
+
+
+/**
+ * This wrapper is used as root in the ProjectsView.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ProjectsViewRoot extends AbstractTreeNode
+{
+ /** The TableViewer */
+ private TableViewer viewer;
+
+ /** The ProjectsHandler */
+ private ProjectsHandler projectsHandler;
+
+
+ /**
+ * Creates a new instance of ProjectsViewRoot.
+ *
+ * @param tableViewer
+ * the associated TableViewer
+ */
+ public ProjectsViewRoot( TableViewer tableViewer )
+ {
+ super( null );
+ this.viewer = tableViewer;
+
+ projectsHandler = Activator.getDefault().getProjectsHandler();
+ projectsHandler.addListener( new ProjectsHandlerListener()
+ {
+ public void projectAdded( Project project )
+ {
+ addProjectWrapper( project );
+ refreshProjectsViewer();
+ }
+
+
+ public void projectRemoved( Project project )
+ {
+ deleteProjectWrapper( project );
+ refreshProjectsViewer();
+ }
+
+
+ public void openProjectChanged( Project oldProject, Project newProject )
+ {
+ refreshProjectsViewer();
+ }
+ } );
+ }
+
+
+ /**
+ * Add a ProjectWrapper for the given project.
+ *
+ * @param project
+ * the project
+ */
+ private void addProjectWrapper( Project project )
+ {
+ addChild( new ProjectWrapper( project, viewer ) );
+ }
+
+
+ /**
+ * Deletes the ProjectWrapper associated with the given project.
+ *
+ * @param project
+ * the project
+ */
+ private void deleteProjectWrapper( Project project )
+ {
+ for ( TreeNode node : getChildren() )
+ {
+ ProjectWrapper pw = ( ProjectWrapper ) node;
+ if ( project == pw.getProject() )
+ {
+ removeChild( node );
+ return;
+ }
+ }
+ }
+
+
+ /**
+ * Refreshes the Projects Viewer
+ */
+ public void refreshProjectsViewer()
+ {
+ Display.getDefault().asyncExec( new Runnable()
+ {
+ public void run()
+ {
+ viewer.refresh();
+ }
+ } );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.schemaeditor.view.wrappers.AbstractTreeNode#equals(java.lang.Object)
+ */
+ public boolean equals( Object obj )
+ {
+ if ( obj instanceof ProjectsViewRoot )
+ {
+ return this == obj;
+ }
+
+ return false;
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/ProjectsViewRoot.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/SchemaErrorWrapper.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/SchemaErrorWrapper.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/SchemaErrorWrapper.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/SchemaErrorWrapper.java Mon Nov 5 09:14:24 2007
@@ -0,0 +1,126 @@
+/*
+ * 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.wrappers;
+
+
+import org.apache.directory.studio.schemaeditor.model.schemachecker.SchemaError;
+
+
+/**
+ * This class is used to wrap a SchemaError in a TreeViewer.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SchemaErrorWrapper extends AbstractTreeNode
+{
+ /** The wrapped SchemaError */
+ private SchemaError schemaError;
+
+
+ /**
+ * Creates a new instance of SchemaErrorWrapper.
+ *
+ * @param error
+ * the wrapped SchemaError
+ */
+ public SchemaErrorWrapper( SchemaError error )
+ {
+ super( null );
+ schemaError = error;
+ }
+
+
+ /**
+ * Creates a new instance of SchemaErrorWrapper.
+ *
+ * @param error
+ * the wrapped SchemaError
+ * @param parent
+ * the parent TreeNode
+ */
+ public SchemaErrorWrapper( SchemaError error, TreeNode parent )
+ {
+ super( parent );
+ schemaError = error;
+ }
+
+
+ /**
+ * Gets the wrapped SchemaError.
+ *
+ * @return
+ * the wrapped SchemaError
+ */
+ public SchemaError getSchemaError()
+ {
+ return schemaError;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.schemaeditor.view.wrappers.AbstractTreeNode#hasChildren()
+ */
+ public boolean hasChildren()
+ {
+ return false;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.schemaeditor.view.wrappers.AbstractTreeNode#equals(java.lang.Object)
+ */
+ public boolean equals( Object obj )
+ {
+ if ( obj instanceof SchemaWarningWrapper )
+ {
+ if ( super.equals( obj ) )
+ {
+ SchemaErrorWrapper sww = ( SchemaErrorWrapper ) obj;
+
+ if ( ( schemaError != null ) && ( !schemaError.equals( sww.getSchemaError() ) ) )
+ {
+ return false;
+ }
+
+ return true;
+ }
+ }
+
+ // Default
+ return false;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.schemaeditor.view.wrappers.AbstractTreeNode#hashCode()
+ */
+ public int hashCode()
+ {
+ int result = super.hashCode();
+
+ if ( schemaError != null )
+ {
+ result = 37 * result + schemaError.hashCode();
+ }
+
+ return result;
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/SchemaErrorWrapper.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/SchemaSorter.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/SchemaSorter.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/SchemaSorter.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/SchemaSorter.java Mon Nov 5 09:14:24 2007
@@ -0,0 +1,50 @@
+/*
+ * 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.wrappers;
+
+
+import java.util.Comparator;
+
+import org.apache.directory.studio.schemaeditor.model.Schema;
+
+
+/**
+ * This class is used to compare and sort ascending two Schemas
+ */
+public class SchemaSorter implements Comparator<TreeNode>
+{
+ /* (non-Javadoc)
+ * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
+ */
+ public int compare( TreeNode o1, TreeNode o2 )
+ {
+ if ( ( o1 instanceof SchemaWrapper ) && ( o2 instanceof SchemaWrapper ) )
+ {
+ Schema s1 = ( ( SchemaWrapper ) o1 ).getSchema();
+ Schema s2 = ( ( SchemaWrapper ) o2 ).getSchema();
+
+ return s1.getName().compareToIgnoreCase( s2.getName() );
+ }
+
+ // Default
+ return o1.toString().compareToIgnoreCase( o2.toString() );
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/SchemaSorter.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/SchemaViewRoot.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/SchemaViewRoot.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/SchemaViewRoot.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/SchemaViewRoot.java Mon Nov 5 09:14:24 2007
@@ -0,0 +1,52 @@
+/*
+ * 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.wrappers;
+
+
+/**
+ * This wrapper is used as root in the Schema View.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SchemaViewRoot extends AbstractTreeNode
+{
+ /**
+ * Creates a new instance of SchemaViewRoot.
+ */
+ public SchemaViewRoot()
+ {
+ super( null );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.schemaeditor.view.wrappers.AbstractTreeNode#equals(java.lang.Object)
+ */
+ public boolean equals( Object obj )
+ {
+ if ( obj instanceof SchemaViewRoot )
+ {
+ return this == obj;
+ }
+
+ return false;
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wrappers/SchemaViewRoot.java
------------------------------------------------------------------------------
svn:eol-style = native