felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dsav...@apache.org
Subject svn commit: r991568 [2/2] - in /felix/trunk/sigil/eclipse: core/src/org/apache/felix/sigil/eclipse/ core/src/org/apache/felix/sigil/eclipse/internal/model/repository/ core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/ core/src/org/apa...
Date Wed, 01 Sep 2010 15:18:02 GMT
Modified: felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/RepositoryViewPart.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/RepositoryViewPart.java?rev=991568&r1=991567&r2=991568&view=diff
==============================================================================
--- felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/RepositoryViewPart.java
(original)
+++ felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/RepositoryViewPart.java
Wed Sep  1 15:18:01 2010
@@ -113,8 +113,7 @@ public class RepositoryViewPart extends 
         public RepositoryAction(IBundleRepository rep)
         {
             this.rep = rep;
-            this.model = SigilCore.getRepositoryPreferences().findRepository(
-                rep.getId());
+            this.model = SigilCore.getRepositoryModel(rep);
         }
 
         @Override

Modified: felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ModelLabelProvider.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ModelLabelProvider.java?rev=991568&r1=991567&r2=991568&view=diff
==============================================================================
--- felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ModelLabelProvider.java
(original)
+++ felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ModelLabelProvider.java
Wed Sep  1 15:18:01 2010
@@ -93,8 +93,7 @@ public class ModelLabelProvider extends 
         if (element instanceof IBundleRepository)
         {
             IBundleRepository rep = (IBundleRepository) element;
-            IRepositoryModel config = SigilCore.getRepositoryPreferences().findRepository(
-                rep.getId());
+            IRepositoryModel config = SigilCore.getRepositoryModel(rep);
             return config.getType().getIcon();
         }
 
@@ -168,8 +167,7 @@ public class ModelLabelProvider extends 
         if (element instanceof IBundleRepository)
         {
             IBundleRepository rep = (IBundleRepository) element;
-            IRepositoryModel config = SigilCore.getRepositoryPreferences().findRepository(
-                rep.getId());
+            IRepositoryModel config = SigilCore.getRepositoryModel(rep);
             return config.getName();
         }
 

Modified: felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/wizard/repository/RepositoryWizardPage.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/wizard/repository/RepositoryWizardPage.java?rev=991568&r1=991567&r2=991568&view=diff
==============================================================================
--- felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/wizard/repository/RepositoryWizardPage.java
(original)
+++ felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/wizard/repository/RepositoryWizardPage.java
Wed Sep  1 15:18:01 2010
@@ -21,8 +21,10 @@ package org.apache.felix.sigil.eclipse.u
 
 import java.util.ArrayList;
 
+import org.apache.felix.sigil.eclipse.SigilCore;
 import org.apache.felix.sigil.eclipse.model.repository.IRepositoryModel;
 import org.eclipse.jface.preference.FieldEditor;
+import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.preference.StringFieldEditor;
 import org.eclipse.jface.wizard.WizardPage;
 import org.eclipse.swt.SWT;
@@ -34,9 +36,10 @@ import org.eclipse.swt.widgets.Composite
 public abstract class RepositoryWizardPage extends WizardPage
 {
 
-    private StringFieldEditor nameEditor;
     private ArrayList<FieldEditor> editors = new ArrayList<FieldEditor>();
     private RepositoryWizard wizard;
+    private IPreferenceStore prefs;
+    private StringFieldEditor nameEditor;
 
     protected RepositoryWizardPage(String pageName, RepositoryWizard parent)
     {
@@ -60,20 +63,13 @@ public abstract class RepositoryWizardPa
         if (getModel().getType().isDynamic())
         {
             nameEditor = new StringFieldEditor("name", "Name:", control);
-            nameEditor.setStringValue(getModel().getName());
-            nameEditor.getTextControl(getFieldEditorParent()).addModifyListener(
-                new ModifyListener()
-                {
-                    public void modifyText(ModifyEvent e)
-                    {
-                        checkPageComplete();
-                    }
-                });
+            nameEditor.setEmptyStringAllowed(false);
+            addField(nameEditor);
         }
 
         createFieldEditors();
 
-        int cols = nameEditor == null ? 0 : nameEditor.getNumberOfControls();
+        int cols = 0;
         for (FieldEditor e : editors)
         {
             cols = Math.max(cols, e.getNumberOfControls());
@@ -81,15 +77,21 @@ public abstract class RepositoryWizardPa
 
         control.setLayout(new GridLayout(cols, false));
 
-        if (nameEditor != null)
-        {
-            nameEditor.fillIntoGrid(getFieldEditorParent(), cols);
-        }
-
         for (FieldEditor e : editors)
         {
+            if (e instanceof StringFieldEditor) {
+                StringFieldEditor sfe = (StringFieldEditor) e;
+                sfe.getTextControl(getFieldEditorParent()).addModifyListener(
+                    new ModifyListener()
+                    {
+                        public void modifyText(ModifyEvent e)
+                        {
+                            checkPageComplete();
+                        }
+                    });
+            }
             e.fillIntoGrid(getFieldEditorParent(), cols);
-            e.setPreferenceStore(getModel().getPreferences());
+            e.setPreferenceStore(getStore());
             e.load();
         }
 
@@ -100,7 +102,19 @@ public abstract class RepositoryWizardPa
     {
         if (nameEditor != null)
         {
-            setPageComplete(nameEditor.getStringValue().length() > 0);
+            int len = nameEditor.getStringValue().length();
+            boolean ok = len > 0;
+            setPageComplete(ok);
+            if ( !ok ) {
+                setErrorMessage("Name should not be empty");
+            }
+            else {
+                ok = nameEditor.getStringValue().trim().length() == len;
+                setPageComplete(ok);
+                if ( !ok ) {
+                    setErrorMessage("Name cannot start or end with whitespace");
+                }
+            }
         }
     }
 
@@ -108,6 +122,14 @@ public abstract class RepositoryWizardPa
     {
         return wizard.getModel();
     }
+    
+    protected IPreferenceStore getStore() {
+        if ( prefs == null ) {
+            prefs = SigilCore.getRepositoryPreferences().toPreferenceStore(getModel());
+        }
+        
+        return prefs;
+    }
 
     protected Composite getFieldEditorParent()
     {
@@ -116,13 +138,10 @@ public abstract class RepositoryWizardPa
 
     public void storeFields()
     {
-        getModel().setName(nameEditor.getStringValue());
         for (FieldEditor e : editors)
         {
             e.store();
         }
-        getModel().getPreferences().setValue("provider", getModel().getType().getProvider());
-
     }
 
 }



Mime
View raw message