package be.wimsymons.intellij.polopolyimport;

import com.intellij.notification.NotificationType;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.progress.RunBackgroundable;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.vfs.VirtualFile;

import java.util.List;

/*
 * Copyright 2013 Marc Viaene (Mavicon BVBA)
 * Copyright 2013 Wim Symons (wim.symons@gmail.com)
 *
 * Licensed 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.
 */
@SuppressWarnings("ComponentNotRegistered")
class PPImportAction extends AnAction {

	private final Target target;
	private final List<String> includeExtensions;
	private final List<Replacement> replacements;
	private final boolean uploadMultipleFilesAsJar;

	public PPImportAction(Target target, List<String> includeExtensions, List<Replacement> replacements, boolean uploadMultipleFilesAsJar) {
		super(target.getProfile(), "Import content to " + target.getUrl(), null);
		this.target = target;
		this.includeExtensions = includeExtensions;
		this.replacements = replacements;
		this.uploadMultipleFilesAsJar = uploadMultipleFilesAsJar;
	}

	public void actionPerformed(AnActionEvent e) {
		VirtualFile[] virtualFiles = e.getData(LangDataKeys.VIRTUAL_FILE_ARRAY);
		if (target.isConfirm()) {
			int answer = Messages.showYesNoDialog("Are you sure to import the selected files into " + target.getProfile() + "?", "Confirm Polopoly Import", Messages.getWarningIcon());
			if (answer == Messages.NO) {
				PPImportPlugin.doNotify("Import cancelled upon confirmation.", NotificationType.INFORMATION);
				return;
			}
		}
		RunBackgroundable.run(new ImportTask(virtualFiles, this.target, this.includeExtensions, this.replacements, this.uploadMultipleFilesAsJar));
	}

}

@@ -290,33 +290,31 @@
 rogress.
-RunBackgroundable
+ProgressManager
 ;%0Aimport
@@ -1158,17 +1158,18 @@
 tion %7B%0A%0A
-%09
+  
 private 
@@ -1189,17 +1189,18 @@
 target;%0A
-%09
+  
 private 
@@ -1237,17 +1237,18 @@
 nsions;%0A
-%09
+  
 private 
@@ -1285,17 +1285,18 @@
 ements;%0A
-%09
+  
 private 
@@ -1336,17 +1336,18 @@
 AsJar;%0A%0A
-%09
+  
 public P
@@ -1360,16 +1360,21 @@
 tAction(
+%0A    
 Target t
@@ -1379,16 +1379,20 @@
  target,
+%0A   
  List%3CSt
@@ -1415,16 +1415,20 @@
 ensions,
+%0A   
  List%3CRe
@@ -1451,16 +1451,20 @@
 cements,
+%0A   
  boolean
@@ -1492,18 +1492,20 @@
 sJar) %7B%0A
-%09%09
+    
 super(ta
@@ -1570,18 +1570,20 @@
  null);%0A
-%09%09
+    
 this.tar
@@ -1596,18 +1596,20 @@
 target;%0A
-%09%09
+    
 this.inc
@@ -1644,18 +1644,20 @@
 nsions;%0A
-%09%09
+    
 this.rep
@@ -1682,18 +1682,20 @@
 ements;%0A
-%09%09
+    
 this.upl
@@ -1748,13 +1748,15 @@
 ar;%0A
-%09%7D%0A%0A%09
+  %7D%0A%0A  
 publ
@@ -1798,18 +1798,20 @@
 nt e) %7B%0A
-%09%09
+    
 VirtualF
@@ -1875,18 +1875,20 @@
 ARRAY);%0A
-%09%09
+    
 if (targ
@@ -1905,19 +1905,22 @@
 rm()) %7B%0A
-%09%09%09
+      
 int answ
@@ -2027,16 +2027,24 @@
 ) + %22?%22,
+%0A       
  %22Confir
@@ -2062,16 +2062,24 @@
 Import%22,
+%0A       
  Message
@@ -2099,19 +2099,22 @@
 con());%0A
-%09%09%09
+      
 if (answ
@@ -2134,20 +2134,24 @@
 s.NO) %7B%0A
-%09%09%09%09
+        
 PPImport
@@ -2240,48 +2240,71 @@
 N);%0A
-%09%09%09%09return;%0A%09%09%09%7D%0A%09%09%7D%0A%09%09RunBackgroundable
+        return;%0A      %7D%0A    %7D%0A    ProgressManager.getInstance()
 .run
@@ -2332,16 +2332,22 @@
 alFiles,
+%0A     
  this.ta
@@ -2351,16 +2351,22 @@
 .target,
+%0A     
  this.in
@@ -2381,16 +2381,22 @@
 ensions,
+%0A     
  this.re
@@ -2406,16 +2406,22 @@
 cements,
+%0A     
  this.up
@@ -2450,9 +2450,10 @@
 ));%0A
-%09
+  
 %7D%0A%0A%7D

Fix deprecation warning