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
| package de.conti.ptc.tdm.infopool3;
import java.io.IOException;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.ProgressBar;
import org.eclipse.ui.part.ViewPart;
import de.conti.ptc.tdm.utils.NetworkTest.NetworkTestLogger;
import de.conti.ptc.tdm.utils.calendarForIp3.ColorCache;
import de.conti.ptc.tdm.utils.persistence.ToplinkSession;
import de.conti.ptc.tdm.utils.plugin.OpenViewAction;
/**
* Empty view which allows to display something when no plugins are opened.
*/
public class EmptyView extends ViewPart {
//ID of the view
public static final String ID = OpenViewAction.getEmptyViewId();
//Text displayed inside the view
private static Label infoLabel;
private static Composite container;
private static ProgressBar progressBar;
private static boolean firstLoad = true;
private static float connectionTime;
private static NetworkTestLogger networktestlogger;
/**
* Defines the content of the view
*/
public void createPartControl(Composite parent) {
container = new Composite(parent, SWT.NONE);
container.setLayout(new GridLayout());
container.setBackground(ColorCache.getWhite());
if (firstLoad){
/*try {
Integer.parseInt("Hello world");
} catch (Exception e) {
//marche pas !!!
IP3Exception.getInstance(e);
}*/
for (int i=0;i<20;i++){
new Label(container,SWT.NONE).setLayoutData(new GridData(SWT.CENTER, SWT.LEFT, true, false, 1, 1));;
}
infoLabel = new Label(container, SWT.NONE);
infoLabel.setFont(new Font(parent.getDisplay(),"Arial",10,SWT.BOLD));
infoLabel.setBackground(ColorCache.getWhite());
infoLabel.setText("Connecting to the Database...");
infoLabel.setLayoutData(new GridData(SWT.CENTER, SWT.LEFT, true, false, 1, 1));
progressBar = new ProgressBar(container,SWT.INDETERMINATE|SWT.BORDER);
progressBar.setLayoutData(new GridData(SWT.CENTER, SWT.LEFT, true, true, 1, 1));
progressBar.setMinimum(0);
progressBar.setMaximum(100);
progressBar.setSelection(30);
progressBar.setBounds(0,0,250,20);
firstLoad = false;
}
}
/**
* Actions to do when the focus is on the view
*/
public void setFocus() {
}
public static void connection(){
final Thread threadEndConnection = new Thread() {
public void run() {
connectionTime = (float) ((System.currentTimeMillis() - ApplicationWorkbenchWindowAdvisor.startTime) / 1000.0);
progressBar.dispose();
infoLabel.setText(" Connected in " + connectionTime + " s");
try {
NetworkTestLogger.getInstance().sendLogger("IP3","TopLinkLoad");
} catch (IOException e) {
}
}
};
Thread threadStartConnection = new Thread() {
public void run() {
try {
NetworkTestLogger.getInstance();
} catch (IOException e1) {
}
ToplinkSession.getInstance();
try{
Display.getDefault().syncExec(threadEndConnection);
}
catch(Exception e){
//if the users opens a tab without waiting for the end of the connection
//do nothing
}
}
};
threadStartConnection.start();
}
} |