1. Christian Fischer
  2. nbandroid

Commits

radim  committed 3ff3d3b Merge

Merge.

  • Participants
  • Parent commits 9e948f3, 7ec5f49
  • Branches NBANDROID-65
  • Tags v1.0beta

Comments (0)

Files changed (4)

File core/src/org/netbeans/modules/android/core/ui/DevicesNode.java

View file
 
 
 
+    @Override
     public void propertyChange (final PropertyChangeEvent event) {
         if (DalvikPlatformManager.PROP_INSTALLED_PLATFORMS.equals(event.getPropertyName())) {
-            updateDescription();
-            fireDisplayNameChange(null, null);
-            firePropertySetsChange(null, null);
+            SwingUtilities.invokeLater(new Runnable() {
+                @Override
+                public void run() {
+                    updateDescription();
+                    fireDisplayNameChange(null, null);
+                    firePropertySetsChange(null, null);
+                }
+            });
         }
     }
 

File project/src/org/netbeans/modules/android/project/AndroidProjectType.java

View file
 /**
  * Factory for simple Android projects.
  */
-@ServiceProvider(service=ProjectFactory.class)
+@ServiceProvider(service=ProjectFactory.class, position=/* after Maven, before autoproject */830)
 public final class AndroidProjectType implements ProjectFactory2 {
   public static final String ANDROID_MANIFEST_XML = "AndroidManifest.xml";
     
     }
     
     public @Override boolean isProject(FileObject projectDirectory) {
+        // XXX perhaps also make sure src/ exists, so we do not pick up resources dir for a Maven-Android project
         return projectDirectory.getFileObject(ANDROID_MANIFEST_XML) != null;
     }
     

File project/src/org/netbeans/modules/android/project/ui/customizer/AndroidTargetTableModel.java

View file
 package org.netbeans.modules.android.project.ui.customizer;
 
 import com.android.sdklib.IAndroidTarget;
+import java.util.ArrayList;
 import java.util.List;
 import javax.swing.table.AbstractTableModel;
 
 
   private  final List<IAndroidTarget> targets;
 
-  public AndroidTargetTableModel(List<IAndroidTarget> targets) {
-    this.targets = targets;
+  public AndroidTargetTableModel(final List<? extends IAndroidTarget> targets) {
+    this.targets = new ArrayList<IAndroidTarget>();
+    setTargets(targets);
   }
 
   @Override
     }
     return -1;
   }
-
+  
   public IAndroidTarget getTargetAt(int row) {
     if (row >= 0 && row < getRowCount()) {
       return targets.get(row);
     }
     return null;
   }
+  
+  public final List<? extends IAndroidTarget> getTargets() {
+    return new ArrayList<IAndroidTarget>(this.targets);
+  }
+  
+  public final void setTargets(final List<? extends IAndroidTarget> targets) {
+    this.targets.clear();
+    this.targets.addAll(targets);
+    fireTableDataChanged();
+  }
 
   @Override
   public int getRowCount() {

File project/src/org/netbeans/modules/android/project/ui/wizards/PanelOptionsVisual.java

View file
 package org.netbeans.modules.android.project.ui.wizards;
 
 import com.android.sdklib.IAndroidTarget;
+import java.awt.Window;
+import java.awt.event.WindowEvent;
+import java.awt.event.WindowFocusListener;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.StringTokenizer;
 import javax.swing.ListSelectionModel;
+import javax.swing.SwingUtilities;
 import javax.swing.event.DocumentListener;
 import javax.swing.event.DocumentEvent;
 import javax.swing.event.ListSelectionEvent;
   private String errorKey;
   private final AndroidTargetTableModel tableModel;
   private final DalvikPlatformManager platformManager;
+  private final WindowFocusListener focusListener;
     
   public PanelOptionsVisual(PanelConfigureProject panel, DalvikPlatformManager platformManager) {
     initComponents();
     jTableTargets.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
     jTableTargets.setRowSelectionAllowed(true);
     jTableTargets.setColumnSelectionAllowed(false);
-    List<IAndroidTarget> targets = new ArrayList<IAndroidTarget>();
-    for (DalvikPlatform platform : platformManager.getPlatforms()) {
-      targets.add(platform.getAndroidTarget());
-    }
-    tableModel = new AndroidTargetTableModel(targets);
+    tableModel = new AndroidTargetTableModel(getTargets());
     jTableTargets.setModel(tableModel);
     jTableTargets.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
 
         checkValidity();
       }
     });
+    this.focusListener = new WindowFocusListener() {
+      @Override
+      public void windowGainedFocus(WindowEvent e) {
+        final List<? extends IAndroidTarget> newTargets = getTargets();
+        final List<? extends IAndroidTarget> oldTargets = tableModel.getTargets();
+        if (!newTargets.equals(oldTargets)) {
+          tableModel.setTargets(newTargets);
+        }
+      }
+        
+      @Override
+      public void windowLostFocus(WindowEvent e) {          
+      }
+    };
   }
-
+  
+  
+  @Override
+  public final void addNotify() {
+    super.addNotify();
+    final Window win = SwingUtilities.getWindowAncestor(this);
+    if (win != null) {
+      win.addWindowFocusListener(focusListener);
+    }
+  }
+  
+  @Override
+  public final void removeNotify () {
+    super.removeNotify();
+    final Window win = SwingUtilities.getWindowAncestor(this);
+    if (win != null) {
+      win.removeWindowFocusListener(focusListener);
+    }
+  }
+    
     /** This method is called from within the constructor to
      * initialize the form.
      * WARNING: Do NOT modify this code. The content of this method is
     }
     return isValid;
   }
+  
+  private List<? extends IAndroidTarget> getTargets() {
+    List<IAndroidTarget> targets = new ArrayList<IAndroidTarget>();    
+    for (DalvikPlatform platform : platformManager.getPlatforms()) {
+      targets.add(platform.getAndroidTarget());
+    }
+    return targets;
+  }
+  
 }