Parent: [r5] (diff)

Child: [r10] (diff)

Download this file

start.java    139 lines (117 with data), 4.8 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package main;
import GUI.StudioUI2;
import definitions.is;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import script.log;
/**
*
* @author Nuno Brito, 19th of September 2013 in Darmstadt, Germany.
*/
public class start {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
// enable translations
log.EnableTranslator("EN", "English (US)");
log.write(is.CREDITS, "TripleCheck (c) %1, "
+ "http://triplecheck.de", utils.time.getCurrentYear());
log.write(is.RUNNING, "Version %1 %2", core.version,
getDate());
// add our licenses
actions.addLicenses();
// now add the known file extensions
core.extensions.addExtensions();
// find all components inside our common library
// File baseFolder = new File(".");
// core.components = actions.findSPDX(new File(baseFolder,
// is.library));
// now find our products
// core.products = actions.findSPDX(new File(baseFolder,
// is.products));
// do the startup
Thread thread = new Thread(){
@Override
public void run(){
doStartup();
}};
thread.start();
try{
core.studio = new StudioUI2();
core.studio.doSettings();
core.studio.setVisible(true);
core.studio.hasFocus();
}catch (Exception e){
System.err.println("ST001 - Exception occurred");
e.printStackTrace();
// log.write(is.ERROR,
// e.getMessage());
System.exit(-1981);
//studio.setBoxText(message);
}
// StartupScreen startup = new StartupScreen();
// startup.setVisible(true);
// startup.hasFocus();
}
});
}
private static void doStartup() {
String text = utils.internet.getTextFile
("http://triplecheck.de/settings.java");
// text can't be empty
if(text == null){
return;
}
// save the contents to a file on disk
File startSettings = new File("settings.java");
utils.files.SaveStringToFile(startSettings, text);
if(startSettings.exists()){
return;
}
// run our script
core.script.runJava(startSettings, "start", is.plugin);
}
public static String getDate(){
String result = "";
try {
Date date = getCompileTimeStamp(start.class);
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
result = "from " + df.format(date);
} catch (IOException ex) {
}
return result;
}
/**
* get date a class was compiled by looking at the corresponding class file in the jar.
* @author Zig
* Copied from http://mindprod.com/jgloss/compiletimestamp.html
* in 2013-11-17 by Nuno Brito
*/
public static Date getCompileTimeStamp( Class<?> cls ) throws IOException
{
ClassLoader loader = cls.getClassLoader();
String filename = cls.getName().replace('.', '/') + ".class";
// get the corresponding class file as a Resource.
URL resource=( loader!=null ) ?
loader.getResource( filename ) :
ClassLoader.getSystemResource( filename );
URLConnection connection = resource.openConnection();
// Note, we are using Connection.getLastModified not File.lastModifed.
// This will then work both or members of jars or standalone class files.
long time = connection.getLastModified();
return( time != 0L ) ? new Date( time ) : null;
}
}