Revision 38543 branches/v2_0_0_prep/extensions/org.gvsig.mkmvnproject/src/main/java/org/gvsig/mkmvnproject/MakeMavenProjectExtension.java

View differences:

MakeMavenProjectExtension.java
41 41
import org.gvsig.andami.plugins.Extension;
42 42
import org.gvsig.andami.ui.mdiManager.IWindow;
43 43
import org.gvsig.i18n.Messages;
44
import org.gvsig.mkmvnproject.gui.CreatePluginConsoleWindow;
45
import org.gvsig.mkmvnproject.gui.settings.PlatformPropertiesWindow;
44 46

  
45 47
/**
46 48
 * Extension to launch the project creation from templates.
......
54 56
    private static final String ANT_CHECK_JDK = "checkjdk.xml";
55 57

  
56 58
	private static final String ANT_TARGET = "mkproject";
59
	
60
	public static final String GVSIG_PLATFORM_PROPERTIES_FILE_NAME =
61
	    ".gvsig.platform.properties";
57 62

  
58 63
	private static final Logger LOG = LoggerFactory
59 64
			.getLogger(MakeMavenProjectExtension.class);
......
64 69

  
65 70
	public void execute(String actionCommand) {
66 71
	    
67
	    if (!doJdkCheck()) {
72
	    if (!checkJDK()) {
68 73
	        return;
69 74
	    }
75

  
76
	    if (!checkPlatformProperties()) {
77
	        return;
78
	    }
70 79
	    
71 80
        // ==========================================================
72 81
		// TODO: add support to parallel executions in Andami??
......
100 109
	}
101 110

  
102 111
	/**
112
	 * Checks existence of file:
113
	 * 
114
	 * USER_HOME/.gvsig.platform.properties
115
	 * 
116
	 * If not present, show text area with suggested content.
117
	 * 
118
     * @return whether the mentioned file is present or the
119
     * user has created it here and accepts to continue.
120
     *  
121
     */
122
    private boolean checkPlatformProperties() {
123
        
124
        String user_home = System.getProperty("user.home");
125
        File the_file = new File(
126
            user_home +
127
            File.separator +
128
            GVSIG_PLATFORM_PROPERTIES_FILE_NAME);
129

  
130
        Component parent_window = getActiveWindowComponent();
131

  
132
        try {
133
            if (the_file.exists()) {
134
                // ok file exists
135
                LOG.info("Found platform properties file: "
136
                    + the_file.getAbsolutePath());
137
                return true;
138
            }
139
            
140
            boolean is_windows = isThisWindows();
141
            PlatformPropertiesWindow ppw = new PlatformPropertiesWindow(
142
                the_file, is_windows);
143
            PluginServices.getMDIManager().addCentredWindow(ppw);
144
            // it's a modal dialog
145
            return ppw.validSettings();
146
            
147
        } catch (Exception ex) {
148
            
149
            String _msg =
150
                Messages.getText("_Error_while_checking_platform_properties")
151
                + "\n\n[ " + ex.getMessage() + " ]";
152
            String _tit = Messages.getText(
153
                "_Checking_platform_properties");
154
            JOptionPane.showMessageDialog(
155
                parent_window,
156
                _msg, _tit,
157
                JOptionPane.ERROR_MESSAGE);
158
        }
159
        return false;
160
        
161
    }
162

  
163

  
164
    /**
165
     * @return whether we are running on a windows system
166
     */
167
    private boolean isThisWindows() {
168
        String os = System.getProperty("os.name").toLowerCase();
169
        return (os.indexOf("win") >= 0);
170
    }
171

  
172
    /**
173
     * Check and possibly show JDK and JAVA_HOME settings and
174
     * prompt user with suggestion.
103 175
     * 
176
     * @return whether JDK is detected or user accepts to
177
     * continue anyway
104 178
     */
105
    private boolean doJdkCheck() {
179
    private boolean checkJDK() {
106 180
        
107 181
        boolean this_is_jdk = false;
108 182
        try {

Also available in: Unified diff