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

View differences:

MakeMavenProjectExtension.java
64 64

  
65 65
	public void execute(String actionCommand) {
66 66
	    
67
	    boolean found_jdk = false;
68
	    try {
69
	        found_jdk = jdkAvailable(); 
70
	    } catch (Exception ex) {
71
	        LOG.info("While searching for JDK: " + ex.getMessage());
72
	        found_jdk = false;
67
	    if (!doJdkCheck()) {
68
	        return;
73 69
	    }
74 70
	    
75
	    if (!found_jdk) {
76
	        
77
	        int opt = JOptionPane.showConfirmDialog(
78
	            getActiveWindowComponent(),
79
	            Messages.getText("_Java_compiler_not_found_near_current_JRE_nor_in_JAVA_HOME")
80
	            + "\n\n"
81
	            + Messages.getText("_Continue_question"),
82
	            Messages.getText("_Searching_JDK"),
83
	            JOptionPane.YES_NO_OPTION,
84
	            JOptionPane.WARNING_MESSAGE);
85
	        
86
	        if (opt == JOptionPane.NO_OPTION) {
87
	            return;
88
	        }
89
	    }
90
	    
91
	    
71
        // ==========================================================
92 72
		// TODO: add support to parallel executions in Andami??
93 73

  
94 74
        // Create messages console
......
120 100
	}
121 101

  
122 102
	/**
103
     * 
104
     */
105
    private boolean doJdkCheck() {
106
        
107
        boolean this_is_jdk = false;
108
        try {
109
            this_is_jdk = jdkAvailable();
110
        } catch (Exception ex) {
111
            LOG.info("While searching for JDK: " + ex.getMessage());
112
            this_is_jdk = false;
113
        }
114
        
115
        if (this_is_jdk) {
116
            return true;
117
        }
118
        
119
        String env_j_h = System.getenv("JAVA_HOME");
120
        
121
        String jdk_str = null;
122
        if (this_is_jdk) {
123
            jdk_str = Messages.getText("_gvSIG_is_running_on_JDK");
124
        } else {
125
            jdk_str = Messages.getText("_gvSIG_is_not_running_on_JDK");
126
        }
127
        
128
        String jh_str = null;
129
        if (env_j_h == null) {
130
            jh_str = Messages.getText("_JAVA_HOME_is_not_set");
131
        } else {
132
            jh_str = Messages.getText("_JAVA_HOME_is_set_to")
133
                + " '" + env_j_h + "'";
134
        }
135
        
136
        String recomm = "";
137
        if (!this_is_jdk && env_j_h == null) {
138
            recomm = "\n\n" + Messages.getText("_You_might_need_to_run_gvSIG_on_JDK_or_set_JAVA_HOME_properly");
139
            recomm = recomm + ".    \n"
140
            + Messages.getText("_Visit_gvSIG_website_for_details") + ".";
141
        }
142
        
143
        String tot_msg = Messages.getText("_Detected_settings") + ":"
144
            + "\n\n"
145
            + "- " + jdk_str + "\n"
146
            + "- " + jh_str + "     " + recomm + "\n\n"
147
                + Messages.getText("_Continue_question");
148
            
149
        int opt = JOptionPane.showConfirmDialog(
150
            null, // getActiveWindowComponent(),
151
            tot_msg,
152
            Messages.getText("_Searching_JDK"),
153
            JOptionPane.YES_NO_OPTION,
154
            (recomm.length() == 0) ?
155
                JOptionPane.INFORMATION_MESSAGE : JOptionPane.WARNING_MESSAGE
156
            );
157
        
158
        return (opt == JOptionPane.YES_OPTION);
159
    }
160

  
161
    /**
123 162
     * @return
124 163
     */
125 164
    private Component getActiveWindowComponent() {
......
132 171
        }
133 172
    }
134 173

  
135
    /**
136
     * @return
137
     */
174

  
138 175
    private boolean jdkAvailable() throws Exception {
139 176
        
140 177
        ClassLoader loader = this.getClass().getClassLoader();
......
150 187
        }
151 188
        
152 189
        URL build = loader.getResource("scripts/" + ANT_CHECK_JDK);
153
        
190

  
191
        String execut = null;
192
        /*
154 193
        // first attempt: javac from JAVA_HOME
155
        String execut =
194
        execut =
156 195
            System.getenv().get("JAVA_HOME")
157 196
            + File.separator + "bin" + File.separator + "javac";
158 197
        
......
164 203
                return true;
165 204
            }
166 205
        }
206
        */
167 207
        
168
        
169 208
        // second attempt: java.home (jre)
170 209
        execut = System.getProperty("java.home");
171 210
        int ind = execut.lastIndexOf(File.separator);

Also available in: Unified diff