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 [4/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/ma...
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/SchemaHandlerAdapter.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/SchemaHandlerAdapter.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/SchemaHandlerAdapter.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/SchemaHandlerAdapter.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.controller;
+
+
+import org.apache.directory.studio.schemaeditor.model.AttributeTypeImpl;
+import org.apache.directory.studio.schemaeditor.model.MatchingRuleImpl;
+import org.apache.directory.studio.schemaeditor.model.ObjectClassImpl;
+import org.apache.directory.studio.schemaeditor.model.Schema;
+import org.apache.directory.studio.schemaeditor.model.SyntaxImpl;
+
+
+/**
+ * This adapter class provides default implementations for the methods
+ * described by the SchemaHandlerListener interface.
+ * <p>
+ * Classes that wish to deal with schema handling events can extend this class
+ * and override only the methods which they are interested in.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public abstract class SchemaHandlerAdapter implements SchemaHandlerListener
+{
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.schemaeditor.controller.SchemaHandlerListener#attributeTypeAdded(org.apache.directory.studio.schemaeditor.model.AttributeTypeImpl)
+ */
+ public void attributeTypeAdded( AttributeTypeImpl at )
+ {
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.schemaeditor.controller.SchemaHandlerListener#attributeTypeModified(org.apache.directory.studio.schemaeditor.model.AttributeTypeImpl)
+ */
+ public void attributeTypeModified( AttributeTypeImpl at )
+ {
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.schemaeditor.controller.SchemaHandlerListener#attributeTypeRemoved(org.apache.directory.studio.schemaeditor.model.AttributeTypeImpl)
+ */
+ public void attributeTypeRemoved( AttributeTypeImpl at )
+ {
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.schemaeditor.controller.SchemaHandlerListener#matchingRuleAdded(org.apache.directory.studio.schemaeditor.model.MatchingRuleImpl)
+ */
+ public void matchingRuleAdded( MatchingRuleImpl mr )
+ {
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.schemaeditor.controller.SchemaHandlerListener#matchingRuleModified(org.apache.directory.studio.schemaeditor.model.MatchingRuleImpl)
+ */
+ public void matchingRuleModified( MatchingRuleImpl mr )
+ {
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.schemaeditor.controller.SchemaHandlerListener#matchingRuleRemoved(org.apache.directory.studio.schemaeditor.model.MatchingRuleImpl)
+ */
+ public void matchingRuleRemoved( MatchingRuleImpl mr )
+ {
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.schemaeditor.controller.SchemaHandlerListener#objectClassAdded(org.apache.directory.studio.schemaeditor.model.ObjectClassImpl)
+ */
+ public void objectClassAdded( ObjectClassImpl oc )
+ {
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.schemaeditor.controller.SchemaHandlerListener#objectClassModified(org.apache.directory.studio.schemaeditor.model.ObjectClassImpl)
+ */
+ public void objectClassModified( ObjectClassImpl oc )
+ {
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.schemaeditor.controller.SchemaHandlerListener#objectClassRemoved(org.apache.directory.studio.schemaeditor.model.ObjectClassImpl)
+ */
+ public void objectClassRemoved( ObjectClassImpl oc )
+ {
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.schemaeditor.controller.SchemaHandlerListener#schemaAdded(org.apache.directory.studio.schemaeditor.model.Schema)
+ */
+ public void schemaAdded( Schema schema )
+ {
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.schemaeditor.controller.SchemaHandlerListener#schemaRemoved(org.apache.directory.studio.schemaeditor.model.Schema)
+ */
+ public void schemaRemoved( Schema schema )
+ {
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.schemaeditor.controller.SchemaHandlerListener#syntaxAdded(org.apache.directory.studio.schemaeditor.model.SyntaxImpl)
+ */
+ public void syntaxAdded( SyntaxImpl syntax )
+ {
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.schemaeditor.controller.SchemaHandlerListener#syntaxModified(org.apache.directory.studio.schemaeditor.model.SyntaxImpl)
+ */
+ public void syntaxModified( SyntaxImpl syntax )
+ {
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.schemaeditor.controller.SchemaHandlerListener#syntaxRemoved(org.apache.directory.studio.schemaeditor.model.SyntaxImpl)
+ */
+ public void syntaxRemoved( SyntaxImpl syntax )
+ {
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/SchemaHandlerAdapter.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/SchemaHandlerListener.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/SchemaHandlerListener.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/SchemaHandlerListener.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/SchemaHandlerListener.java Mon Nov 5 09:14:24 2007
@@ -0,0 +1,163 @@
+/*
+ * 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.controller;
+
+
+import org.apache.directory.studio.schemaeditor.model.AttributeTypeImpl;
+import org.apache.directory.studio.schemaeditor.model.MatchingRuleImpl;
+import org.apache.directory.studio.schemaeditor.model.ObjectClassImpl;
+import org.apache.directory.studio.schemaeditor.model.Schema;
+import org.apache.directory.studio.schemaeditor.model.SyntaxImpl;
+
+
+/**
+ * Classes which implement this interface provide methods that deal with the
+ * events that are generated when an event occurs on a schema.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface SchemaHandlerListener
+{
+ /**
+ * Sent when the attribute type is added.
+ *
+ * @param at
+ * the added attribute type
+ */
+ public void attributeTypeAdded( AttributeTypeImpl at );
+
+
+ /**
+ * Sent when the attribute type is modified.
+ *
+ * @param at
+ * the modified attribute type
+ */
+ public void attributeTypeModified( AttributeTypeImpl at );
+
+
+ /**
+ * Sent when an attribute type is removed.
+ *
+ * @param at
+ * the removed attribute type
+ */
+ public void attributeTypeRemoved( AttributeTypeImpl at );
+
+
+ /**
+ * Sent when a matching rule is added.
+ *
+ * @param mr
+ * the added matching rule
+ */
+ public void matchingRuleAdded( MatchingRuleImpl mr );
+
+
+ /**
+ * Sent when a matching rule is modified.
+ *
+ * @param mr
+ * the modified matching rule
+ */
+ public void matchingRuleModified( MatchingRuleImpl mr );
+
+
+ /**
+ * Sent when a matching rule is removed.
+ *
+ * @param mr
+ * the removed matching rule
+ */
+ public void matchingRuleRemoved( MatchingRuleImpl mr );
+
+
+ /**
+ * Sent when an object class is added.
+ *
+ * @param oc
+ * the added object class
+ */
+ public void objectClassAdded( ObjectClassImpl oc );
+
+
+ /**
+ * Sent when an object class is modified.
+ *
+ * @param oc
+ * the modified object class
+ */
+ public void objectClassModified( ObjectClassImpl oc );
+
+
+ /**
+ * Sent when an object class is removed.
+ *
+ * @param oc
+ * the removed attribute type
+ */
+ public void objectClassRemoved( ObjectClassImpl oc );
+
+
+ /**
+ * Sent when a schema is added.
+ *
+ * @param schema
+ * the added syntax
+ */
+ public void schemaAdded( Schema schema );
+
+
+ /**
+ * Sent when a schema is removed.
+ *
+ * @param schema
+ * the removed syntax
+ */
+ public void schemaRemoved( Schema schema );
+
+
+ /**
+ * Sent when a syntax is added.
+ *
+ * @param syntax
+ * the added syntax
+ */
+ public void syntaxAdded( SyntaxImpl syntax );
+
+
+ /**
+ * Sent when a syntax is modified.
+ *
+ * @param syntax
+ * the modified syntax
+ */
+ public void syntaxModified( SyntaxImpl syntax );
+
+
+ /**
+ * Sent when a syntax is removed.
+ *
+ * @param syntax
+ * the removed syntax
+ */
+ public void syntaxRemoved( SyntaxImpl syntax );
+}
\ No newline at end of file
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/SchemaHandlerListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/SchemaListener.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/SchemaListener.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/SchemaListener.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/SchemaListener.java Mon Nov 5 09:14:24 2007
@@ -0,0 +1,144 @@
+/*
+ * 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.controller;
+
+
+import org.apache.directory.studio.schemaeditor.model.AttributeTypeImpl;
+import org.apache.directory.studio.schemaeditor.model.MatchingRuleImpl;
+import org.apache.directory.studio.schemaeditor.model.ObjectClassImpl;
+import org.apache.directory.studio.schemaeditor.model.SyntaxImpl;
+
+
+/**
+ * Classes which implement this interface provide methods that deal with the
+ * events that are generated when an event occurs on a schema.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface SchemaListener
+{
+ /**
+ * Sent when the attribute type is added.
+ *
+ * @param at
+ * the added attribute type
+ */
+ public void attributeTypeAdded( AttributeTypeImpl at );
+
+
+ /**
+ * Sent when the attribute type is modified.
+ *
+ * @param at
+ * the modified attribute type
+ */
+ public void attributeTypeModified( AttributeTypeImpl at );
+
+
+ /**
+ * Sent when an attribute type is removed.
+ *
+ * @param at
+ * the removed attribute type
+ */
+ public void attributeTypeRemoved( AttributeTypeImpl at );
+
+
+ /**
+ * Sent when a matching rule is added.
+ *
+ * @param mr
+ * the added matching rule
+ */
+ public void matchingRuleAdded( MatchingRuleImpl mr );
+
+
+ /**
+ * Sent when a matching rule is modified.
+ *
+ * @param mr
+ * the modified matching rule
+ */
+ public void matchingRuleModified( MatchingRuleImpl mr );
+
+
+ /**
+ * Sent when a matching rule is removed.
+ *
+ * @param mr
+ * the removed matching rule
+ */
+ public void matchingRuleRemoved( MatchingRuleImpl mr );
+
+
+ /**
+ * Sent when an object class is added.
+ *
+ * @param oc
+ * the added object class
+ */
+ public void objectClassAdded( ObjectClassImpl oc );
+
+
+ /**
+ * Sent when an object class is modified.
+ *
+ * @param oc
+ * the modified object class
+ */
+ public void objectClassModified( ObjectClassImpl oc );
+
+
+ /**
+ * Sent when an object class is removed.
+ *
+ * @param oc
+ * the removed attribute type
+ */
+ public void objectClassRemoved( ObjectClassImpl oc );
+
+
+ /**
+ * Sent when a syntax is added.
+ *
+ * @param syntax
+ * the added syntax
+ */
+ public void syntaxAdded( SyntaxImpl syntax );
+
+
+ /**
+ * Sent when a syntax is modified.
+ *
+ * @param syntax
+ * the modified syntax
+ */
+ public void syntaxModified( SyntaxImpl syntax );
+
+
+ /**
+ * Sent when a syntax is removed.
+ *
+ * @param syntax
+ * the removed syntax
+ */
+ public void syntaxRemoved( SyntaxImpl syntax );
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/SchemaListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/SchemaViewController.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/SchemaViewController.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/SchemaViewController.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/SchemaViewController.java Mon Nov 5 09:14:24 2007
@@ -0,0 +1,701 @@
+/*
+ * 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.controller;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+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.actions.CollapseAllAction;
+import org.apache.directory.studio.schemaeditor.controller.actions.DeleteSchemaElementAction;
+import org.apache.directory.studio.schemaeditor.controller.actions.ExportSchemasAsOpenLdapAction;
+import org.apache.directory.studio.schemaeditor.controller.actions.ExportSchemasAsXmlAction;
+import org.apache.directory.studio.schemaeditor.controller.actions.ExportSchemasForADSAction;
+import org.apache.directory.studio.schemaeditor.controller.actions.ImportSchemasFromOpenLdapAction;
+import org.apache.directory.studio.schemaeditor.controller.actions.ImportSchemasFromXmlAction;
+import org.apache.directory.studio.schemaeditor.controller.actions.LinkWithEditorSchemaViewAction;
+import org.apache.directory.studio.schemaeditor.controller.actions.NewAttributeTypeAction;
+import org.apache.directory.studio.schemaeditor.controller.actions.NewObjectClassAction;
+import org.apache.directory.studio.schemaeditor.controller.actions.NewSchemaAction;
+import org.apache.directory.studio.schemaeditor.controller.actions.OpenElementAction;
+import org.apache.directory.studio.schemaeditor.controller.actions.OpenSchemaViewPreferenceAction;
+import org.apache.directory.studio.schemaeditor.controller.actions.OpenSchemaViewSortingDialogAction;
+import org.apache.directory.studio.schemaeditor.controller.actions.OpenTypeHierarchyAction;
+import org.apache.directory.studio.schemaeditor.controller.actions.SwitchSchemaPresentationToFlatAction;
+import org.apache.directory.studio.schemaeditor.controller.actions.SwitchSchemaPresentationToHierarchicalAction;
+import org.apache.directory.studio.schemaeditor.model.AttributeTypeImpl;
+import org.apache.directory.studio.schemaeditor.model.ObjectClassImpl;
+import org.apache.directory.studio.schemaeditor.model.Project;
+import org.apache.directory.studio.schemaeditor.model.Schema;
+import org.apache.directory.studio.schemaeditor.view.ViewUtils;
+import org.apache.directory.studio.schemaeditor.view.editors.attributetype.AttributeTypeEditor;
+import org.apache.directory.studio.schemaeditor.view.editors.attributetype.AttributeTypeEditorInput;
+import org.apache.directory.studio.schemaeditor.view.editors.objectclass.ObjectClassEditor;
+import org.apache.directory.studio.schemaeditor.view.editors.objectclass.ObjectClassEditorInput;
+import org.apache.directory.studio.schemaeditor.view.views.SchemaView;
+import org.apache.directory.studio.schemaeditor.view.views.SchemaViewContentProvider;
+import org.apache.directory.studio.schemaeditor.view.wrappers.AttributeTypeWrapper;
+import org.apache.directory.studio.schemaeditor.view.wrappers.Folder;
+import org.apache.directory.studio.schemaeditor.view.wrappers.ObjectClassWrapper;
+import org.apache.directory.studio.schemaeditor.view.wrappers.SchemaWrapper;
+import org.apache.directory.studio.schemaeditor.view.wrappers.TreeNode;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.commands.ActionHandler;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IPartListener2;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPartReference;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.commands.ICommandService;
+import org.eclipse.ui.contexts.IContextActivation;
+import org.eclipse.ui.contexts.IContextService;
+
+
+/**
+ * This class implements the Controller for the SchemaView.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SchemaViewController
+{
+ /** The associated view */
+ private SchemaView view;
+
+ /** The TreeViewer */
+ private TreeViewer viewer;
+
+ /** The authorized Preferences keys*/
+ private List<String> authorizedPrefs;
+
+ /** The Context Menu */
+ private MenuManager contextMenu;
+
+ /** The SchemaHandlerListener */
+ private SchemaHandlerListener schemaHandlerListener = new SchemaHandlerAdapter()
+ {
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.schemaeditor.controller.SchemaHandlerListener#attributeTypeAdded(org.apache.directory.studio.schemaeditor.model.AttributeTypeImpl)
+ */
+ public void attributeTypeAdded( AttributeTypeImpl at )
+ {
+ SchemaViewContentProvider contentProvider = ( SchemaViewContentProvider ) viewer.getContentProvider();
+ contentProvider.attributeTypeAdded( at );
+ view.refresh();
+
+ TreeNode wrapper = contentProvider.getWrapper( at );
+ if ( wrapper != null )
+ {
+ viewer.setSelection( new StructuredSelection( wrapper ) );
+ }
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.schemaeditor.controller.SchemaHandlerListener#attributeTypeModified(org.apache.directory.studio.schemaeditor.model.AttributeTypeImpl)
+ */
+ public void attributeTypeModified( AttributeTypeImpl at )
+ {
+ ( ( SchemaViewContentProvider ) viewer.getContentProvider() ).attributeTypeModified( at );
+ view.refresh();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.schemaeditor.controller.SchemaHandlerListener#attributeTypeRemoved(org.apache.directory.studio.schemaeditor.model.AttributeTypeImpl)
+ */
+ public void attributeTypeRemoved( AttributeTypeImpl at )
+ {
+ ( ( SchemaViewContentProvider ) viewer.getContentProvider() ).attributeTypeRemoved( at );
+ view.refresh();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.schemaeditor.controller.SchemaHandlerListener#objectClassAdded(org.apache.directory.studio.schemaeditor.model.ObjectClassImpl)
+ */
+ public void objectClassAdded( ObjectClassImpl oc )
+ {
+ SchemaViewContentProvider contentProvider = ( SchemaViewContentProvider ) viewer.getContentProvider();
+ contentProvider.objectClassAdded( oc );
+ view.refresh();
+
+ TreeNode wrapper = contentProvider.getWrapper( oc );
+ if ( wrapper != null )
+ {
+ viewer.setSelection( new StructuredSelection( wrapper ) );
+ }
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.schemaeditor.controller.SchemaHandlerListener#objectClassModified(org.apache.directory.studio.schemaeditor.model.ObjectClassImpl)
+ */
+ public void objectClassModified( ObjectClassImpl oc )
+ {
+ ( ( SchemaViewContentProvider ) viewer.getContentProvider() ).objectClassModified( oc );
+ view.refresh();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.schemaeditor.controller.SchemaHandlerListener#objectClassRemoved(org.apache.directory.studio.schemaeditor.model.ObjectClassImpl)
+ */
+ public void objectClassRemoved( ObjectClassImpl oc )
+ {
+ ( ( SchemaViewContentProvider ) viewer.getContentProvider() ).objectClassRemoved( oc );
+ view.refresh();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.schemaeditor.controller.SchemaHandlerListener#schemaAdded(org.apache.directory.studio.schemaeditor.model.Schema)
+ */
+ public void schemaAdded( Schema schema )
+ {
+ SchemaViewContentProvider contentProvider = ( SchemaViewContentProvider ) viewer.getContentProvider();
+ contentProvider.schemaAdded( schema );
+
+ final TreeNode wrapper = contentProvider.getWrapper( schema );
+
+ Display.getDefault().asyncExec( new Runnable()
+ {
+ public void run()
+ {
+ view.refresh();
+
+ if ( wrapper != null )
+ {
+ viewer.setSelection( new StructuredSelection( wrapper ) );
+ }
+ }
+ } );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.schemaeditor.controller.SchemaHandlerListener#schemaRemoved(org.apache.directory.studio.schemaeditor.model.Schema)
+ */
+ public void schemaRemoved( Schema schema )
+ {
+ ( ( SchemaViewContentProvider ) viewer.getContentProvider() ).schemaRemoved( schema );
+ view.refresh();
+ }
+ };
+
+ /** Token used to activate and deactivate shortcuts in the view */
+ private IContextActivation contextActivation;
+
+ // The Actions
+ private NewSchemaAction newSchema;
+ private NewAttributeTypeAction newAttributeType;
+ private NewObjectClassAction newObjectClass;
+ private OpenElementAction openElement;
+ private OpenTypeHierarchyAction openTypeHierarchy;
+ private DeleteSchemaElementAction deleteSchemaElement;
+ private ImportSchemasFromOpenLdapAction importSchemasFromOpenLdap;
+ private ImportSchemasFromXmlAction importSchemasFromXml;
+ private ExportSchemasAsOpenLdapAction exportSchemasAsOpenLdap;
+ private ExportSchemasAsXmlAction exportSchemasAsXml;
+ private ExportSchemasForADSAction exportSchemasForADS;
+ private CollapseAllAction collapseAll;
+ private OpenSchemaViewSortingDialogAction openSchemaViewSortingDialog;
+ private SwitchSchemaPresentationToFlatAction switchSchemaPresentationToFlat;
+ private SwitchSchemaPresentationToHierarchicalAction switchSchemaPresentationToHierarchical;
+ private OpenSchemaViewPreferenceAction openSchemaViewPreference;
+ private LinkWithEditorSchemaViewAction linkWithEditor;
+
+
+ // private CommitChangesAction commitChanges;
+
+ /**
+ * Creates a new instance of SchemasViewController.
+ *
+ * @param view
+ * the associated view
+ */
+ public SchemaViewController( SchemaView view )
+ {
+ this.view = view;
+ viewer = view.getViewer();
+
+ initActions();
+ initToolbar();
+ initMenu();
+ initContextMenu();
+ initProjectsHandlerListener();
+ initDoubleClickListener();
+ initAuthorizedPrefs();
+ initPreferencesListener();
+ initState();
+ initPartListener();
+ }
+
+
+ /**
+ * Initializes the Actions.
+ */
+ private void initActions()
+ {
+ newSchema = new NewSchemaAction();
+ newAttributeType = new NewAttributeTypeAction( viewer );
+ newObjectClass = new NewObjectClassAction( viewer );
+ openElement = new OpenElementAction( viewer );
+ openTypeHierarchy = new OpenTypeHierarchyAction( viewer );
+ deleteSchemaElement = new DeleteSchemaElementAction( viewer );
+ importSchemasFromOpenLdap = new ImportSchemasFromOpenLdapAction();
+ importSchemasFromXml = new ImportSchemasFromXmlAction();
+ exportSchemasAsOpenLdap = new ExportSchemasAsOpenLdapAction( viewer );
+ exportSchemasAsXml = new ExportSchemasAsXmlAction( viewer );
+ exportSchemasForADS = new ExportSchemasForADSAction( viewer );
+ collapseAll = new CollapseAllAction( viewer );
+ openSchemaViewSortingDialog = new OpenSchemaViewSortingDialogAction();
+ switchSchemaPresentationToFlat = new SwitchSchemaPresentationToFlatAction();
+ switchSchemaPresentationToHierarchical = new SwitchSchemaPresentationToHierarchicalAction();
+ openSchemaViewPreference = new OpenSchemaViewPreferenceAction();
+ linkWithEditor = new LinkWithEditorSchemaViewAction( view );
+ // commitChanges = new CommitChangesAction();
+ }
+
+
+ /**
+ * Initializes the Toolbar.
+ */
+ private void initToolbar()
+ {
+ IToolBarManager toolbar = view.getViewSite().getActionBars().getToolBarManager();
+ toolbar.add( newSchema );
+ toolbar.add( newAttributeType );
+ toolbar.add( newObjectClass );
+ // toolbar.add( new Separator() );
+ // toolbar.add( commitChanges );
+ toolbar.add( new Separator() );
+ toolbar.add( collapseAll );
+ toolbar.add( linkWithEditor );
+ }
+
+
+ /**
+ * Initializes the Menu.
+ */
+ private void initMenu()
+ {
+ IMenuManager menu = view.getViewSite().getActionBars().getMenuManager();
+ menu.add( openSchemaViewSortingDialog );
+ menu.add( new Separator() );
+ IMenuManager schemaPresentationMenu = new MenuManager( "S&chema Presentation" );
+ schemaPresentationMenu.add( switchSchemaPresentationToFlat );
+ schemaPresentationMenu.add( switchSchemaPresentationToHierarchical );
+ menu.add( schemaPresentationMenu );
+ menu.add( new Separator() );
+ menu.add( linkWithEditor );
+ menu.add( new Separator() );
+ menu.add( openSchemaViewPreference );
+ }
+
+
+ /**
+ * Initializes the ContextMenu.
+ */
+ private void initContextMenu()
+ {
+ contextMenu = new MenuManager( "" ); //$NON-NLS-1$
+ contextMenu.setRemoveAllWhenShown( true );
+ contextMenu.addMenuListener( new IMenuListener()
+ {
+ public void menuAboutToShow( IMenuManager manager )
+ {
+ MenuManager newManager = new MenuManager( "Ne&w" );
+ MenuManager importManager = new MenuManager( "&Import..." );
+ MenuManager exportManager = new MenuManager( "Exp&ort..." );
+ manager.add( newManager );
+ newManager.add( newSchema );
+ newManager.add( newAttributeType );
+ newManager.add( newObjectClass );
+ manager.add( new Separator() );
+ manager.add( openElement );
+ manager.add( openTypeHierarchy );
+ manager.add( new Separator() );
+ manager.add( deleteSchemaElement );
+ manager.add( new Separator() );
+ manager.add( importManager );
+ importManager.add( importSchemasFromOpenLdap );
+ importManager.add( importSchemasFromXml );
+ manager.add( exportManager );
+ exportManager.add( exportSchemasAsOpenLdap );
+ exportManager.add( exportSchemasAsXml );
+ exportManager.add( new Separator() );
+ exportManager.add( exportSchemasForADS );
+
+ manager.add( new Separator( IWorkbenchActionConstants.MB_ADDITIONS ) );
+ }
+ } );
+
+ // set the context menu to the table viewer
+ viewer.getControl().setMenu( contextMenu.createContextMenu( viewer.getControl() ) );
+
+ // register the context menu to enable extension actions
+ view.getSite().registerContextMenu( contextMenu, viewer );
+ }
+
+
+ /**
+ * Initializes the ProjectsHandlerListener.
+ */
+ private void initProjectsHandlerListener()
+ {
+ Activator.getDefault().getProjectsHandler().addListener( new ProjectsHandlerAdapter()
+ {
+ public void openProjectChanged( Project oldProject, Project newProject )
+ {
+ if ( oldProject != null )
+ {
+ removeSchemaHandlerListener( oldProject );
+ }
+
+ if ( newProject != null )
+ {
+ viewer.getTree().setEnabled( true );
+ newSchema.setEnabled( true );
+ newAttributeType.setEnabled( true );
+ newObjectClass.setEnabled( true );
+ collapseAll.setEnabled( true );
+ linkWithEditor.setEnabled( true );
+ openSchemaViewSortingDialog.setEnabled( true );
+ switchSchemaPresentationToFlat.setEnabled( true );
+ switchSchemaPresentationToHierarchical.setEnabled( true );
+ openSchemaViewPreference.setEnabled( true );
+ // commitChanges.setEnabled( true );
+
+ addSchemaHandlerListener( newProject );
+ view.reloadViewer();
+ }
+ else
+ {
+ viewer.setInput( null );
+ viewer.getTree().setEnabled( false );
+ newSchema.setEnabled( false );
+ newAttributeType.setEnabled( false );
+ newObjectClass.setEnabled( false );
+ collapseAll.setEnabled( false );
+ linkWithEditor.setEnabled( false );
+ openSchemaViewSortingDialog.setEnabled( false );
+ switchSchemaPresentationToFlat.setEnabled( false );
+ switchSchemaPresentationToHierarchical.setEnabled( false );
+ openSchemaViewPreference.setEnabled( false );
+ // commitChanges.setEnabled( false );
+ }
+ }
+ } );
+ }
+
+
+ /**
+ * Adds the SchemaHandlerListener.
+ *
+ * @param project
+ * the project
+ */
+ private void addSchemaHandlerListener( Project project )
+ {
+ SchemaHandler schemaHandler = project.getSchemaHandler();
+ if ( schemaHandler != null )
+ {
+ schemaHandler.addListener( schemaHandlerListener );
+ }
+ }
+
+
+ /**
+ * Removes the SchemaHandlerListener.
+ *
+ * @param project
+ * the project
+ */
+ private void removeSchemaHandlerListener( Project project )
+ {
+ SchemaHandler schemaHandler = project.getSchemaHandler();
+ if ( schemaHandler != null )
+ {
+ schemaHandler.removeListener( schemaHandlerListener );
+ }
+ }
+
+
+ /**
+ * Initializes the DoubleClickListener.
+ */
+ private void initDoubleClickListener()
+ {
+ viewer.addDoubleClickListener( new IDoubleClickListener()
+ {
+ public void doubleClick( DoubleClickEvent event )
+ {
+ IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+
+ TreeViewer viewer = view.getViewer();
+
+ // What we get from the viewer is a StructuredSelection
+ StructuredSelection selection = ( StructuredSelection ) event.getSelection();
+
+ // Here's the real object (an AttributeTypeWrapper, ObjectClassWrapper or IntermediateNode)
+ Object objectSelection = selection.getFirstElement();
+ IEditorInput input = null;
+ String editorId = null;
+
+ // Selecting the right editor and input
+ if ( objectSelection instanceof AttributeTypeWrapper )
+ {
+ input = new AttributeTypeEditorInput( ( ( AttributeTypeWrapper ) objectSelection )
+ .getAttributeType() );
+ editorId = AttributeTypeEditor.ID;
+ }
+ else if ( objectSelection instanceof ObjectClassWrapper )
+ {
+ input = new ObjectClassEditorInput( ( ( ObjectClassWrapper ) objectSelection ).getObjectClass() );
+ editorId = ObjectClassEditor.ID;
+ }
+ else if ( ( objectSelection instanceof Folder ) || ( objectSelection instanceof SchemaWrapper ) )
+ {
+ // Here we don't open an editor, we just expand the node.
+ viewer.setExpandedState( objectSelection, !viewer.getExpandedState( objectSelection ) );
+ }
+
+ // Let's open the editor
+ if ( input != null )
+ {
+ try
+ {
+ page.openEditor( input, editorId );
+ }
+ catch ( PartInitException e )
+ {
+ PluginUtils.logError( "An error occured when opening the editor.", e );
+ ViewUtils.displayErrorMessageBox( "Error", "An error occured when opening the editor." );
+ }
+ }
+ }
+ } );
+ }
+
+
+ /**
+ * Initializes the Authorized Prefs IDs.
+ */
+ private void initAuthorizedPrefs()
+ {
+ authorizedPrefs = new ArrayList<String>();
+ authorizedPrefs.add( PluginConstants.PREFS_SCHEMA_VIEW_LABEL );
+ authorizedPrefs.add( PluginConstants.PREFS_SCHEMA_VIEW_ABBREVIATE );
+ authorizedPrefs.add( PluginConstants.PREFS_SCHEMA_VIEW_ABBREVIATE_MAX_LENGTH );
+ authorizedPrefs.add( PluginConstants.PREFS_SCHEMA_VIEW_SECONDARY_LABEL_DISPLAY );
+ authorizedPrefs.add( PluginConstants.PREFS_SCHEMA_VIEW_SECONDARY_LABEL );
+ authorizedPrefs.add( PluginConstants.PREFS_SCHEMA_VIEW_SECONDARY_LABEL_ABBREVIATE );
+ authorizedPrefs.add( PluginConstants.PREFS_SCHEMA_VIEW_SECONDARY_LABEL_ABBREVIATE_MAX_LENGTH );
+ authorizedPrefs.add( PluginConstants.PREFS_SCHEMA_VIEW_GROUPING );
+ authorizedPrefs.add( PluginConstants.PREFS_SCHEMA_VIEW_SORTING_BY );
+ authorizedPrefs.add( PluginConstants.PREFS_SCHEMA_VIEW_SORTING_ORDER );
+ authorizedPrefs.add( PluginConstants.PREFS_SCHEMA_VIEW_SCHEMA_PRESENTATION );
+ authorizedPrefs.add( PluginConstants.PREFS_SCHEMA_VIEW_SCHEMA_LABEL_DISPLAY );
+ }
+
+
+ /**
+ * Initializes the listener on the preferences store
+ */
+ private void initPreferencesListener()
+ {
+ Activator.getDefault().getPreferenceStore().addPropertyChangeListener( new IPropertyChangeListener()
+ {
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
+ */
+ public void propertyChange( PropertyChangeEvent event )
+ {
+ if ( authorizedPrefs.contains( event.getProperty() ) )
+ {
+ if ( PluginConstants.PREFS_SCHEMA_VIEW_GROUPING == event.getProperty()
+ || PluginConstants.PREFS_SCHEMA_VIEW_SCHEMA_PRESENTATION == event.getProperty() )
+ {
+ view.reloadViewer();
+ }
+ else
+ {
+ view.refresh();
+ }
+ }
+ }
+ } );
+ }
+
+
+ /**
+ * Initializes the state of the View.
+ */
+ private void initState()
+ {
+ Project project = Activator.getDefault().getProjectsHandler().getOpenProject();
+ if ( project != null )
+ {
+ viewer.getTree().setEnabled( true );
+ newSchema.setEnabled( true );
+ newAttributeType.setEnabled( true );
+ newObjectClass.setEnabled( true );
+ collapseAll.setEnabled( true );
+ linkWithEditor.setEnabled( true );
+ openSchemaViewSortingDialog.setEnabled( true );
+ switchSchemaPresentationToFlat.setEnabled( true );
+ switchSchemaPresentationToHierarchical.setEnabled( true );
+ openSchemaViewPreference.setEnabled( true );
+ // commitChanges.setEnabled( true );
+
+ addSchemaHandlerListener( project );
+ view.reloadViewer();
+ }
+ else
+ {
+ viewer.getTree().setEnabled( false );
+ newSchema.setEnabled( false );
+ newAttributeType.setEnabled( false );
+ newObjectClass.setEnabled( false );
+ collapseAll.setEnabled( false );
+ linkWithEditor.setEnabled( false );
+ openSchemaViewSortingDialog.setEnabled( false );
+ switchSchemaPresentationToFlat.setEnabled( false );
+ switchSchemaPresentationToHierarchical.setEnabled( false );
+ openSchemaViewPreference.setEnabled( false );
+ // commitChanges.setEnabled( false );
+ }
+ }
+
+
+ /**
+ * Initializes the PartListener.
+ */
+ private void initPartListener()
+ {
+ view.getSite().getPage().addPartListener( new IPartListener2()
+ {
+ /**
+ * This implementation deactivates the shortcuts when the part is deactivated.
+ */
+ public void partDeactivated( IWorkbenchPartReference partRef )
+ {
+ if ( partRef.getPart( false ) == view && contextActivation != null )
+ {
+ ICommandService commandService = ( ICommandService ) PlatformUI.getWorkbench().getAdapter(
+ ICommandService.class );
+ if ( commandService != null )
+ {
+ commandService.getCommand( newSchema.getActionDefinitionId() ).setHandler( null );
+ commandService.getCommand( newAttributeType.getActionDefinitionId() ).setHandler( null );
+ commandService.getCommand( newObjectClass.getActionDefinitionId() ).setHandler( null );
+ commandService.getCommand( openElement.getActionDefinitionId() ).setHandler( null );
+ commandService.getCommand( openTypeHierarchy.getActionDefinitionId() ).setHandler( null );
+ commandService.getCommand( deleteSchemaElement.getActionDefinitionId() ).setHandler( null );
+ }
+
+ IContextService contextService = ( IContextService ) PlatformUI.getWorkbench().getAdapter(
+ IContextService.class );
+ contextService.deactivateContext( contextActivation );
+ contextActivation = null;
+ }
+ }
+
+
+ /**
+ * This implementation activates the shortcuts when the part is activated.
+ */
+ public void partActivated( IWorkbenchPartReference partRef )
+ {
+ if ( partRef.getPart( false ) == view )
+ {
+ IContextService contextService = ( IContextService ) PlatformUI.getWorkbench().getAdapter(
+ IContextService.class );
+ contextActivation = contextService.activateContext( PluginConstants.CONTEXT_SCHEMA_VIEW );
+
+ ICommandService commandService = ( ICommandService ) PlatformUI.getWorkbench().getAdapter(
+ ICommandService.class );
+ if ( commandService != null )
+ {
+ commandService.getCommand( newSchema.getActionDefinitionId() ).setHandler(
+ new ActionHandler( newSchema ) );
+ commandService.getCommand( newAttributeType.getActionDefinitionId() ).setHandler(
+ new ActionHandler( newAttributeType ) );
+ commandService.getCommand( newObjectClass.getActionDefinitionId() ).setHandler(
+ new ActionHandler( newObjectClass ) );
+ commandService.getCommand( openElement.getActionDefinitionId() ).setHandler(
+ new ActionHandler( openElement ) );
+ commandService.getCommand( openTypeHierarchy.getActionDefinitionId() ).setHandler(
+ new ActionHandler( openTypeHierarchy ) );
+ commandService.getCommand( deleteSchemaElement.getActionDefinitionId() ).setHandler(
+ new ActionHandler( deleteSchemaElement ) );
+ }
+ }
+ }
+
+
+ public void partBroughtToTop( IWorkbenchPartReference partRef )
+ {
+ }
+
+
+ public void partClosed( IWorkbenchPartReference partRef )
+ {
+ }
+
+
+ public void partHidden( IWorkbenchPartReference partRef )
+ {
+ }
+
+
+ public void partInputChanged( IWorkbenchPartReference partRef )
+ {
+ }
+
+
+ public void partOpened( IWorkbenchPartReference partRef )
+ {
+ }
+
+
+ public void partVisible( IWorkbenchPartReference partRef )
+ {
+ }
+ } );
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/SchemaViewController.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/SearchViewController.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/SearchViewController.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/SearchViewController.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/SearchViewController.java Mon Nov 5 09:14:24 2007
@@ -0,0 +1,158 @@
+/*
+ * 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.controller;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.directory.studio.schemaeditor.Activator;
+import org.apache.directory.studio.schemaeditor.PluginConstants;
+import org.apache.directory.studio.schemaeditor.controller.actions.OpenSearchViewPreferenceAction;
+import org.apache.directory.studio.schemaeditor.controller.actions.OpenSearchViewSortingDialogAction;
+import org.apache.directory.studio.schemaeditor.controller.actions.RunCurrentSearchAgainAction;
+import org.apache.directory.studio.schemaeditor.controller.actions.ShowSearchFieldAction;
+import org.apache.directory.studio.schemaeditor.controller.actions.ShowSearchHistoryAction;
+import org.apache.directory.studio.schemaeditor.view.views.SearchView;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+
+
+/**
+ * This class implements the Controller for the SearchView.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SearchViewController
+{
+ /** The associated view */
+ private SearchView view;
+
+ /** The authorized Preferences keys*/
+ private List<String> authorizedPrefs;
+
+ // The Actions
+ private ShowSearchFieldAction showSearchField;
+ private RunCurrentSearchAgainAction runCurrentSearchAgain;
+ private ShowSearchHistoryAction searchHistory;
+ private OpenSearchViewSortingDialogAction openSearchViewSortingDialog;
+ private OpenSearchViewPreferenceAction openSearchViewPreference;
+
+
+ /**
+ * Creates a new instance of SearchViewController.
+ *
+ * @param view
+ * the associated view
+ */
+ public SearchViewController( SearchView view )
+ {
+ this.view = view;
+
+ initActions();
+ initToolbar();
+ initMenu();
+ initAuthorizedPrefs();
+ initPreferencesListener();
+ }
+
+
+ /**
+ * Initializes the Actions.
+ */
+ private void initActions()
+ {
+ showSearchField = new ShowSearchFieldAction( view );
+ runCurrentSearchAgain = new RunCurrentSearchAgainAction( view );
+ searchHistory = new ShowSearchHistoryAction( view );
+ openSearchViewSortingDialog = new OpenSearchViewSortingDialogAction();
+ openSearchViewPreference = new OpenSearchViewPreferenceAction();
+ }
+
+
+ /**
+ * Initializes the Toolbar.
+ */
+ private void initToolbar()
+ {
+ IToolBarManager toolbar = view.getViewSite().getActionBars().getToolBarManager();
+ toolbar.add( showSearchField );
+ toolbar.add( new Separator() );
+ toolbar.add( runCurrentSearchAgain );
+ toolbar.add( searchHistory );
+ }
+
+
+ /**
+ * Initializes the Menu.
+ */
+ private void initMenu()
+ {
+ IMenuManager menu = view.getViewSite().getActionBars().getMenuManager();
+ menu.add( openSearchViewSortingDialog );
+ menu.add( new Separator() );
+ menu.add( openSearchViewPreference );
+ }
+
+
+ /**
+ * Initializes the Authorized Prefs IDs.
+ */
+ private void initAuthorizedPrefs()
+ {
+ authorizedPrefs = new ArrayList<String>();
+ authorizedPrefs.add( PluginConstants.PREFS_SEARCH_VIEW_LABEL );
+ authorizedPrefs.add( PluginConstants.PREFS_SEARCH_VIEW_ABBREVIATE );
+ authorizedPrefs.add( PluginConstants.PREFS_SEARCH_VIEW_ABBREVIATE_MAX_LENGTH );
+ authorizedPrefs.add( PluginConstants.PREFS_SEARCH_VIEW_SECONDARY_LABEL_DISPLAY );
+ authorizedPrefs.add( PluginConstants.PREFS_SEARCH_VIEW_SECONDARY_LABEL );
+ authorizedPrefs.add( PluginConstants.PREFS_SEARCH_VIEW_SECONDARY_LABEL_ABBREVIATE );
+ authorizedPrefs.add( PluginConstants.PREFS_SEARCH_VIEW_SECONDARY_LABEL_ABBREVIATE_MAX_LENGTH );
+ authorizedPrefs.add( PluginConstants.PREFS_SEARCH_VIEW_SCHEMA_LABEL_DISPLAY );
+ authorizedPrefs.add( PluginConstants.PREFS_SEARCH_VIEW_GROUPING );
+ authorizedPrefs.add( PluginConstants.PREFS_SEARCH_VIEW_SORTING_BY );
+ authorizedPrefs.add( PluginConstants.PREFS_SEARCH_VIEW_SORTING_ORDER );
+ }
+
+
+ /**
+ * Initializes the listener on the preferences store
+ */
+ private void initPreferencesListener()
+ {
+ Activator.getDefault().getPreferenceStore().addPropertyChangeListener( new IPropertyChangeListener()
+ {
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
+ */
+ public void propertyChange( PropertyChangeEvent event )
+ {
+ if ( authorizedPrefs.contains( event.getProperty() ) )
+ {
+ view.refresh();
+ }
+ }
+ } );
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/SearchViewController.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/CloseProjectAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/CloseProjectAction.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/CloseProjectAction.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/CloseProjectAction.java Mon Nov 5 09:14:24 2007
@@ -0,0 +1,153 @@
+/*
+ * 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.controller.actions;
+
+
+import org.apache.directory.studio.schemaeditor.Activator;
+import org.apache.directory.studio.schemaeditor.PluginConstants;
+import org.apache.directory.studio.schemaeditor.controller.ProjectsHandler;
+import org.apache.directory.studio.schemaeditor.controller.ProjectsHandlerAdapter;
+import org.apache.directory.studio.schemaeditor.model.Project;
+import org.apache.directory.studio.schemaeditor.model.Project.ProjectState;
+import org.apache.directory.studio.schemaeditor.view.wrappers.ProjectWrapper;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+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.viewers.TableViewer;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+
+
+/**
+ * This action opens a Project.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class CloseProjectAction extends Action implements IWorkbenchWindowActionDelegate
+{
+ /** The associated viewer */
+ private TableViewer viewer;
+
+ /** The ProjectsHandler */
+ private ProjectsHandler projectsHandler;
+
+
+ /**
+ * Creates a new instance of RenameProjectAction.
+ *
+ * @param view
+ * the associate view
+ */
+ public CloseProjectAction( TableViewer viewer )
+ {
+ super( "Clo&se Project" );
+ setToolTipText( "Close Project" );
+ setId( PluginConstants.CMD_CLOSE_PROJECT );
+ setEnabled( false );
+ this.viewer = viewer;
+ this.viewer.addSelectionChangedListener( new ISelectionChangedListener()
+ {
+ public void selectionChanged( SelectionChangedEvent event )
+ {
+ enableDisable();
+ }
+ } );
+ projectsHandler = Activator.getDefault().getProjectsHandler();
+ projectsHandler.addListener( new ProjectsHandlerAdapter()
+ {
+ public void openProjectChanged( Project oldProject, Project newProject )
+ {
+ enableDisable();
+ }
+ } );
+ }
+
+
+ /**
+ * Enables or disables the Action.
+ */
+ private void enableDisable()
+ {
+ StructuredSelection selection = ( StructuredSelection ) viewer.getSelection();
+ if ( ( !selection.isEmpty() ) && ( selection.size() == 1 ) )
+ {
+ setEnabled( ( ( ProjectWrapper ) selection.getFirstElement() ).getProject().getState().equals(
+ ProjectState.OPEN ) );
+ }
+ else
+ {
+ setEnabled( false );
+ }
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ public void run()
+ {
+ StructuredSelection selection = ( StructuredSelection ) viewer.getSelection();
+ if ( ( !selection.isEmpty() ) && ( selection.size() == 1 ) )
+ {
+ projectsHandler.closeProject( ( ( ProjectWrapper ) selection.getFirstElement() ).getProject() );
+ }
+
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+ */
+ public void run( IAction action )
+ {
+ run();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
+ */
+ public void dispose()
+ {
+ // Nothing to do
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
+ */
+ public void init( IWorkbenchWindow window )
+ {
+ // Nothing to do
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
+ */
+ public void selectionChanged( IAction action, ISelection selection )
+ {
+ // Nothing to do
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/CloseProjectAction.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/CollapseAllAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/CollapseAllAction.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/CollapseAllAction.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/CollapseAllAction.java Mon Nov 5 09:14:24 2007
@@ -0,0 +1,107 @@
+/*
+ * 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.controller.actions;
+
+
+import org.apache.directory.studio.schemaeditor.Activator;
+import org.apache.directory.studio.schemaeditor.PluginConstants;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+
+/**
+ * This action collapse all the of the given TreeViewer.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class CollapseAllAction extends Action implements IWorkbenchWindowActionDelegate
+{
+ /** The TreeViewer */
+ private TreeViewer viewer;
+
+
+ /**
+ * Creates a new instance of CollapseAllAction.
+ *
+ * @param viewer
+ * the associate viewer
+ */
+ public CollapseAllAction( TreeViewer viewer )
+ {
+ super( "Collapse All" );
+ setToolTipText( getText() );
+ setId( PluginConstants.CMD_COLLAPSE_ALL );
+ setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+ PluginConstants.IMG_COLLAPSE_ALL ) );
+ setEnabled( false );
+ this.viewer = viewer;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ public void run()
+ {
+ viewer.collapseAll();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+ */
+ public void run( IAction action )
+ {
+ run();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
+ */
+ public void dispose()
+ {
+ // Nothing to do
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
+ */
+ public void init( IWorkbenchWindow window )
+ {
+ // Nothing to do
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
+ */
+ public void selectionChanged( IAction action, ISelection selection )
+ {
+ // Nothing to do
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/CollapseAllAction.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/CommitChangesAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/CommitChangesAction.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/CommitChangesAction.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/CommitChangesAction.java Mon Nov 5 09:14:24 2007
@@ -0,0 +1,108 @@
+/*
+ * 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.controller.actions;
+
+
+import org.apache.directory.studio.schemaeditor.Activator;
+import org.apache.directory.studio.schemaeditor.PluginConstants;
+import org.apache.directory.studio.schemaeditor.view.wizards.CommitChangesWizard;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+
+/**
+ * This action launches the NewProjectWizard.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class CommitChangesAction extends Action implements IWorkbenchWindowActionDelegate
+{
+ /**
+ * Creates a new instance of NewProjectAction.
+ */
+ public CommitChangesAction()
+ {
+ super( "Commit Changes" );
+ setToolTipText( getText() );
+ setId( PluginConstants.CMD_COMMIT_CHANGES );
+ setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+ PluginConstants.IMG_COMMIT_CHANGES ) );
+ setEnabled( false );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ public void run()
+ {
+ // Instantiates and initializes the wizard
+ CommitChangesWizard wizard = new CommitChangesWizard();
+ wizard.init( PlatformUI.getWorkbench(), StructuredSelection.EMPTY );
+ // Instantiates the wizard container with the wizard and opens it
+ WizardDialog dialog = new WizardDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), wizard );
+ dialog.create();
+ dialog.open();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+ */
+ public void run( IAction action )
+ {
+ run();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
+ */
+ public void dispose()
+ {
+ // Nothing to do
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
+ */
+ public void init( IWorkbenchWindow window )
+ {
+ // Nothing to do
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
+ */
+ public void selectionChanged( IAction action, ISelection selection )
+ {
+ // Nothing to do
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/CommitChangesAction.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/DeleteProjectAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/DeleteProjectAction.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/DeleteProjectAction.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/DeleteProjectAction.java Mon Nov 5 09:14:24 2007
@@ -0,0 +1,177 @@
+/*
+ * 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.controller.actions;
+
+
+import java.util.Iterator;
+
+import org.apache.directory.studio.schemaeditor.Activator;
+import org.apache.directory.studio.schemaeditor.PluginConstants;
+import org.apache.directory.studio.schemaeditor.controller.ProjectsHandler;
+import org.apache.directory.studio.schemaeditor.model.Project;
+import org.apache.directory.studio.schemaeditor.model.Project.ProjectState;
+import org.apache.directory.studio.schemaeditor.view.wrappers.ProjectWrapper;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+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.viewers.TableViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+
+/**
+ * This action deletes one or more Projects from the ProjectsView.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class DeleteProjectAction extends Action implements IWorkbenchWindowActionDelegate
+{
+ /** The associated viewer */
+ private TableViewer viewer;
+
+
+ /**
+ * Creates a new instance of DeleteProjectAction.
+ *
+ * @param view
+ * the associated view
+ */
+ public DeleteProjectAction( TableViewer viewer )
+ {
+ super( "&Delete Project" );
+ setToolTipText( "Delete Project" );
+ setId( PluginConstants.CMD_DELETE_PROJECT );
+ setActionDefinitionId( PluginConstants.CMD_DELETE_PROJECT );
+ setImageDescriptor( AbstractUIPlugin
+ .imageDescriptorFromPlugin( Activator.PLUGIN_ID, PluginConstants.IMG_DELETE ) );
+ setEnabled( false );
+ this.viewer = viewer;
+ this.viewer.addSelectionChangedListener( new ISelectionChangedListener()
+ {
+ public void selectionChanged( SelectionChangedEvent event )
+ {
+ StructuredSelection selection = ( StructuredSelection ) event.getSelection();
+ if ( selection.size() == 1 )
+ {
+ setText( "&Delete Project" );
+ setEnabled( true );
+ }
+ else if ( selection.size() > 1 )
+ {
+ setText( "&Delete Projects" );
+ setEnabled( true );
+ }
+ else
+ {
+ setText( "&Delete Project" );
+ setEnabled( false );
+ }
+ }
+ } );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ public void run()
+ {
+ ProjectsHandler projectsHandler = Activator.getDefault().getProjectsHandler();
+ StructuredSelection selection = ( StructuredSelection ) viewer.getSelection();
+
+ if ( !selection.isEmpty() )
+ {
+ MessageBox messageBox = new MessageBox( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
+ SWT.YES | SWT.NO | SWT.ICON_QUESTION );
+ int count = selection.size();
+ if ( count == 1 )
+ {
+ ProjectWrapper wrapper = ( ProjectWrapper ) selection.getFirstElement();
+ messageBox.setMessage( "Are you sure you want to delete project '" + wrapper.getProject().getName()
+ + "'?" );
+ }
+ else
+ {
+ messageBox.setMessage( "Are you sure you want to delete these " + count + " projects?" );
+ }
+ if ( messageBox.open() == SWT.YES )
+ {
+ for ( Iterator<?> iterator = selection.iterator(); iterator.hasNext(); )
+ {
+ ProjectWrapper wrapper = ( ProjectWrapper ) iterator.next();
+ Project project = wrapper.getProject();
+
+ if ( project.getState() == ProjectState.OPEN )
+ {
+ // Closing the project before removing it.
+ projectsHandler.closeProject( project );
+ }
+
+ projectsHandler.removeProject( project );
+ }
+ }
+ }
+
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+ */
+ public void run( IAction action )
+ {
+ run();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
+ */
+ public void dispose()
+ {
+ // Nothing to do
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
+ */
+ public void init( IWorkbenchWindow window )
+ {
+ // Nothing to do
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
+ */
+ public void selectionChanged( IAction action, ISelection selection )
+ {
+ // Nothing to do
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/DeleteProjectAction.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/DeleteSchemaElementAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/DeleteSchemaElementAction.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/DeleteSchemaElementAction.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/DeleteSchemaElementAction.java Mon Nov 5 09:14:24 2007
@@ -0,0 +1,243 @@
+/*
+ * 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.controller.actions;
+
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.directory.shared.ldap.schema.SchemaObject;
+import org.apache.directory.studio.schemaeditor.Activator;
+import org.apache.directory.studio.schemaeditor.PluginConstants;
+import org.apache.directory.studio.schemaeditor.controller.SchemaHandler;
+import org.apache.directory.studio.schemaeditor.model.AttributeTypeImpl;
+import org.apache.directory.studio.schemaeditor.model.ObjectClassImpl;
+import org.apache.directory.studio.schemaeditor.model.Schema;
+import org.apache.directory.studio.schemaeditor.view.wrappers.AttributeTypeWrapper;
+import org.apache.directory.studio.schemaeditor.view.wrappers.ObjectClassWrapper;
+import org.apache.directory.studio.schemaeditor.view.wrappers.SchemaWrapper;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+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.viewers.TreeViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+
+/**
+ * This action deletes one or more Schema Elements from the SchemaView.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class DeleteSchemaElementAction extends Action implements IWorkbenchWindowActionDelegate
+{
+ /** The associated viewer */
+ private TreeViewer viewer;
+
+
+ /**
+ * Creates a new instance of DeleteSchemaElementAction.
+ */
+ public DeleteSchemaElementAction( TreeViewer viewer )
+ {
+ super( "&Delete" );
+ setToolTipText( "Delete" );
+ setId( PluginConstants.CMD_DELETE_SCHEMA_ELEMENT );
+ setActionDefinitionId( PluginConstants.CMD_DELETE_SCHEMA_ELEMENT );
+ setImageDescriptor( AbstractUIPlugin
+ .imageDescriptorFromPlugin( Activator.PLUGIN_ID, PluginConstants.IMG_DELETE ) );
+ setEnabled( true );
+ this.viewer = viewer;
+ this.viewer.addSelectionChangedListener( new ISelectionChangedListener()
+ {
+ public void selectionChanged( SelectionChangedEvent event )
+ {
+ StructuredSelection selection = ( StructuredSelection ) event.getSelection();
+ if ( selection.size() > 0 )
+ {
+ boolean enabled = false;
+
+ for ( Iterator<?> iterator = selection.iterator(); iterator.hasNext(); )
+ {
+ Object selectedItem = iterator.next();
+ if ( selectedItem instanceof SchemaWrapper )
+ {
+ enabled = true;
+ }
+ else if ( selectedItem instanceof AttributeTypeWrapper )
+ {
+ enabled = true;
+ }
+ else if ( selectedItem instanceof ObjectClassWrapper )
+ {
+ enabled = true;
+ }
+ }
+
+ setEnabled( enabled );
+ }
+ else
+ {
+ setEnabled( false );
+ }
+ }
+ } );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ public void run()
+ {
+ StructuredSelection selection = ( StructuredSelection ) viewer.getSelection();
+
+ if ( !selection.isEmpty() )
+ {
+ MessageBox messageBox = new MessageBox( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
+ SWT.YES | SWT.NO | SWT.ICON_QUESTION );
+ int count = selection.size();
+ if ( count == 1 )
+ {
+ Object firstElement = selection.getFirstElement();
+ if ( firstElement instanceof AttributeTypeWrapper )
+ {
+ messageBox.setMessage( "Are you sure you want to delete this attribute type?" );
+ }
+ else if ( firstElement instanceof ObjectClassWrapper )
+ {
+ messageBox.setMessage( "Are you sure you want to delete this object class?" );
+ }
+ else if ( firstElement instanceof SchemaWrapper )
+ {
+ messageBox.setMessage( "Are you sure you want to delete this schema?" );
+ }
+ else
+ {
+ messageBox.setMessage( "Are you sure you want to delete this item?" );
+ }
+
+ }
+ else
+ {
+ messageBox.setMessage( "Are you sure you want to delete these " + count + " items?" );
+ }
+ if ( messageBox.open() == SWT.YES )
+ {
+
+ Map<String, Schema> schemasMap = new HashMap<String, Schema>();
+ List<SchemaObject> schemaObjectsList = new ArrayList<SchemaObject>();
+
+ for ( Iterator<?> iterator = selection.iterator(); iterator.hasNext(); )
+ {
+ Object selectedItem = iterator.next();
+ if ( selectedItem instanceof SchemaWrapper )
+ {
+ Schema schema = ( ( SchemaWrapper ) selectedItem ).getSchema();
+ schemasMap.put( schema.getName().toLowerCase(), schema );
+ }
+ else if ( selectedItem instanceof AttributeTypeWrapper )
+ {
+ AttributeTypeImpl at = ( ( AttributeTypeWrapper ) selectedItem ).getAttributeType();
+ schemaObjectsList.add( at );
+ }
+ else if ( selectedItem instanceof ObjectClassWrapper )
+ {
+ ObjectClassImpl oc = ( ( ObjectClassWrapper ) selectedItem ).getObjectClass();
+ schemaObjectsList.add( oc );
+ }
+ }
+
+ SchemaHandler schemaHandler = Activator.getDefault().getSchemaHandler();
+ // Removing schema objects
+ for ( SchemaObject schemaObject : schemaObjectsList )
+ {
+ if ( !schemasMap.containsKey( schemaObject.getSchema().toLowerCase() ) )
+ {
+ // If the schema object is not part of deleted schema, we need to delete it.
+ // But, we don't delete schema objects that are part of a deleted schema, since
+ // deleting the schema will also delete this schema object.
+ if ( schemaObject instanceof AttributeTypeImpl )
+ {
+ schemaHandler.removeAttributeType( ( AttributeTypeImpl ) schemaObject );
+ }
+ else if ( schemaObject instanceof ObjectClassImpl )
+ {
+ schemaHandler.removeObjectClass( ( ObjectClassImpl ) schemaObject );
+ }
+ }
+ }
+
+ // Removing schemas
+ for ( Schema schema : schemasMap.values() )
+ {
+ schemaHandler.removeSchema( schema );
+ }
+ }
+ }
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+ */
+ public void run( IAction action )
+ {
+ run();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
+ */
+ public void dispose()
+ {
+ // Nothing to do
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
+ */
+ public void init( IWorkbenchWindow window )
+ {
+ // Nothing to do
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
+ */
+ public void selectionChanged( IAction action, ISelection selection )
+ {
+ // Nothing to do
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/DeleteSchemaElementAction.java
------------------------------------------------------------------------------
svn:eol-style = native