Revision 19864
trunk/prototypes/mobile/desktop/extensions/extExportMobile/src/es/prodevelop/gvsig/exportMobile/ui/panels/ExportPanel.java | ||
---|---|---|
15 | 15 |
import javax.swing.JCheckBox; |
16 | 16 |
import javax.swing.JComboBox; |
17 | 17 |
import javax.swing.JLabel; |
18 |
import javax.swing.JOptionPane; |
|
18 | 19 |
import javax.swing.JPanel; |
19 | 20 |
import javax.swing.JRadioButton; |
20 | 21 |
import javax.swing.JScrollPane; |
... | ... | |
24 | 25 |
import org.apache.log4j.Logger; |
25 | 26 |
|
26 | 27 |
import com.iver.andami.PluginServices; |
28 |
import com.iver.andami.messages.Messages; |
|
27 | 29 |
import com.iver.andami.ui.mdiManager.IWindow; |
28 | 30 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
29 | 31 |
import com.iver.cit.gvsig.fmap.drivers.FieldDescription; |
... | ... | |
536 | 538 |
dirEmpty = pathImport.getText().equals(EMPTY); |
537 | 539 |
proyEmpty = nameProy.getText().equals(EMPTY); |
538 | 540 |
|
539 |
/*if (proyEmpty == false) {
|
|
540 |
|
|
541 |
namProy = pathImport.getText() + "/" + nameProy.getText(); |
|
542 |
|
|
543 |
}*/
|
|
541 |
// if (proyEmpty == false) {
|
|
542 |
// |
|
543 |
// namProy = pathImport.getText() + "/" + nameProy.getText();
|
|
544 |
// |
|
545 |
// }
|
|
544 | 546 |
activateOk(); |
545 | 547 |
return; |
546 | 548 |
} |
... | ... | |
694 | 696 |
|
695 | 697 |
if (src == execute) { |
696 | 698 |
ExportProcess process = null; |
699 |
File exportFolder = null; |
|
697 | 700 |
|
698 |
if (pathImport.getText().equals(EMPTY) || nameProy.getText().equals(EMPTY)) |
|
701 |
if (!validPath(pathImport.getText()) || !validProjectName(nameProy.getText())) { |
|
702 |
|
|
699 | 703 |
return; |
700 |
|
|
701 |
if (nameProy.getText().replaceAll("\\\\", "").replaceAll("/", "").equals(EMPTY)) |
|
702 |
return; |
|
703 |
|
|
704 |
|
|
705 |
} else { |
|
704 | 706 |
String namProy = pathImport.getText() + File.separator + nameProy.getText(); |
707 |
process = new ExportProcess( |
|
708 |
rectangle, |
|
709 |
nameProy.getText(), |
|
710 |
namProy, |
|
711 |
view.getProjection()); |
|
712 |
|
|
713 |
exportFolder = new File(namProy); |
|
705 | 714 |
|
706 |
|
|
715 |
if (exportFolder.exists()) { |
|
716 |
|
|
717 |
int option = JOptionPane.showConfirmDialog(this, |
|
718 |
exportFolder.getAbsolutePath() + " " |
|
719 |
+ Messages.getString("folder_exists_delete"), |
|
720 |
Messages.getString("acept"), |
|
721 |
JOptionPane.YES_NO_OPTION); |
|
722 |
|
|
723 |
if (option == JOptionPane.NO_OPTION) { |
|
724 |
return; |
|
725 |
} else { |
|
726 |
deleteFilesIn(exportFolder); |
|
727 |
} |
|
728 |
|
|
729 |
} else { |
|
730 |
exportFolder.mkdirs(); |
|
731 |
} |
|
707 | 732 |
|
708 |
process = new ExportProcess(rectangle, nameProy.getText(), namProy,view.getProjection());
|
|
709 |
|
|
710 |
NewDir dirOut = new NewDir(namProy);
|
|
711 |
newdirout = dirOut.ifExistDir();
|
|
733 |
// NewDir dirOut = new NewDir(namProy);
|
|
734 |
// dirOut.ifExistDir(); |
|
735 |
newdirout = exportFolder;
|
|
736 |
// get layer list
|
|
712 | 737 |
|
713 |
//get layer list |
|
714 | 738 |
listLyrsObj = panelScroll.getNewArrayLayers(); |
715 | 739 |
|
716 | 740 |
for (int i = 0; i < listLyrsObj.size(); i++) { |
... | ... | |
761 | 785 |
PluginServices.cancelableBackgroundExecution(process); |
762 | 786 |
|
763 | 787 |
|
764 |
|
|
788 |
} |
|
765 | 789 |
return; |
766 | 790 |
} |
767 | 791 |
|
... | ... | |
850 | 874 |
|
851 | 875 |
|
852 | 876 |
} |
877 |
|
|
878 |
private boolean validProjectName(String text) { |
|
879 |
// TODO Auto-generated method stub |
|
880 |
String aux = text.replaceAll("\\\\", ""); |
|
881 |
aux = aux.replaceAll("/", ""); |
|
882 |
aux = aux.replaceAll("\\.", ""); |
|
883 |
aux = aux.replaceAll("\\*", ""); |
|
884 |
aux = aux.trim(); |
|
885 |
return (aux.length() > 0); |
|
853 | 886 |
} |
854 | 887 |
|
888 |
private boolean validPath(String text) { |
|
889 |
return (text.length() > 0); |
|
890 |
} |
|
891 |
|
|
892 |
private void deleteFilesIn(File f) { |
|
893 |
|
|
894 |
if (!f.isDirectory()) { |
|
895 |
logger.error("It is not a folder (?) : " + f.getAbsolutePath()); |
|
896 |
return; |
|
897 |
} |
|
898 |
|
|
899 |
File[] subfiles = f.listFiles(); |
|
900 |
for (int i=0; i<subfiles.length; i++) { |
|
901 |
if (subfiles[i].isFile()) { |
|
902 |
try { |
|
903 |
subfiles[i].delete(); |
|
904 |
} catch (Exception ex) { |
|
905 |
logger.debug("Unable to delete file: " + subfiles[i].getAbsolutePath()); |
|
906 |
} |
|
907 |
} |
|
908 |
} |
|
909 |
} |
|
910 |
|
|
911 |
} |
|
912 |
|
Also available in: Unified diff