Révision 3166

tmp/org.txm.core/src/java/org/txm/core/preferences/TBXPreferences.java (revision 3166)
85 85
	 */
86 86
	public static final String UPDATESITE = "update_site"; //$NON-NLS-1$
87 87
	
88
	/*
89
	 * Base URL of TXM files site
90
	 */
91
	public static final String RAWFILESSITE = "raw_files_site"; //$NON-NLS-1$
92
	
93
	/*
94
	 * Base URL of TXM files site
95
	 */
96
	public static final String FILESSITE = "files_site"; //$NON-NLS-1$
97
	
98

  
99
	
88 100
	/**
89 101
	 * To enable/disable the results persistence (save after a computing and load at Toolbox start).
90 102
	 */
......
214 226
		preferences.putBoolean(AUTO_PERSISTENCE_ENABLED, false);
215 227
		
216 228
		if (Toolbox.getTxmHomePath().endsWith("-dev")) {
217
			preferences.put(UPDATESITE, "file://" + System.getProperty("user.home") + "/workspace047/TXMReleasePlugins.site");
229
			preferences.put(UPDATESITE,		"file://" + System.getProperty("user.home") + "/workspace047/TXMReleasePlugins.site/");
230
			preferences.put(RAWFILESSITE,	"file://" + System.getProperty("user.home") + "/workspace047/org.txm.setups/");
231
			preferences.put(FILESSITE,		"file://" + System.getProperty("user.home") + "/workspace047/org.txm.setups/");
218 232
		}
219 233
		else {
220
			preferences.put(UPDATESITE, "https://gitlab.huma-num.fr/txm/txm-software/-/raw/master/dist/");
234
			preferences.put(UPDATESITE,		"https://gitlab.huma-num.fr/txm/txm-software/-/raw/master/dist/");
235
			preferences.put(RAWFILESSITE,	"https://gitlab.huma-num.fr/txm/txm-software/-/raw/master/files/");
236
			preferences.put(FILESSITE,		"https://txm.gitpages.huma-num.fr/textometrie/files/");
221 237
		}
222 238
	}
223 239
}
tmp/org.txm.core/src/java/org/txm/objects/Match2P.java (revision 3166)
17 17
		this.end = end;
18 18
	}
19 19
	
20
	public Match2P(int position) {
21
		this(position, position);
22
	}
23

  
20 24
	@Override
21 25
	public int getStart() {
22 26
		return start;
tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/dialog/MultipleChoiceDialog.java (revision 3166)
1
// Copyright © 2010-2020 ENS de Lyon., University of Franche-Comté
2
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
3
// Lyon 2, University of Franche-Comté, University of Nice
4
// Sophia Antipolis, University of Paris 3.
5
// 
6
// The TXM platform is free software: you can redistribute it
7
// and/or modify it under the terms of the GNU General Public
8
// License as published by the Free Software Foundation,
9
// either version 2 of the License, or (at your option) any
10
// later version.
11
// 
12
// The TXM platform is distributed in the hope that it will be
13
// useful, but WITHOUT ANY WARRANTY; without even the implied
14
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15
// PURPOSE. See the GNU General Public License for more
16
// details.
17
// 
18
// You should have received a copy of the GNU General
19
// Public License along with the TXM platform. If not, see
20
// http://www.gnu.org/licenses.
21
// 
22
// 
23
// 
24
// $LastChangedDate:$
25
// $LastChangedRevision:$
26
// $LastChangedBy:$ 
27
//
28
package org.txm.rcp.swt.dialog;
29

  
30
import java.util.HashMap;
31
import java.util.LinkedHashMap;
32

  
33
import org.eclipse.jface.dialogs.Dialog;
34
import org.eclipse.swt.SWT;
35
import org.eclipse.swt.events.SelectionEvent;
36
import org.eclipse.swt.events.SelectionListener;
37
import org.eclipse.swt.layout.GridData;
38
import org.eclipse.swt.layout.GridLayout;
39
import org.eclipse.swt.widgets.Button;
40
import org.eclipse.swt.widgets.Composite;
41
import org.eclipse.swt.widgets.Control;
42
import org.eclipse.swt.widgets.Label;
43
import org.eclipse.swt.widgets.Shell;
44
import org.eclipse.swt.widgets.Text;
45

  
46
/**
47
 * Open a dialog with a button per choice
48
 */
49
public class MultipleChoiceDialog extends Dialog {
50
	
51
	/** The self. */
52
	MultipleChoiceDialog self;
53
	
54
	/** The main panel. */
55
	Composite mainPanel;
56
	
57
	/** The parent shell. */
58
	Shell parentShell;
59

  
60
	/** The values. */
61
	String[] values;
62
	
63
	/** The title. */
64
	private String title;
65
	
66
	private String answer;
67

  
68
	private String message;
69

  
70
	/**
71
	 * 
72
	 * @param parentShell
73
	 * @param title
74
	 * @param message displayed before he buttons
75
	 * @param values in the shown order, not null, not empty
76
	 * @param defaultAnswer, default value. If null the first value is the default value
77
	 */
78
	public MultipleChoiceDialog(Shell parentShell, String title, String message, String[] values, String defaultAnswer) {
79
		super(parentShell);
80
		
81
		if (values == null || values.length == 0) {
82
			throw new IllegalStateException("Available values must be set and not empty");
83
		}
84
		
85
		this.parentShell = parentShell;
86
		this.setShellStyle(this.getShellStyle());
87
		this.values = values;
88
		this.title = title;
89
		this.answer = defaultAnswer;
90
		if (answer == null) {
91
			answer = values[0];
92
		}
93
		this.message = message;
94
	}
95

  
96
	@Override
97
	public void createButtonsForButtonBar(Composite parent) {
98
		// default buttons not created
99
	}
100
	
101
	/* (non-Javadoc)
102
	 * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
103
	 */
104
	@Override
105
	protected void configureShell(Shell newShell) {
106
		super.configureShell(newShell);
107
		newShell.setText(title);
108
	}
109

  
110
	/* (non-Javadoc)
111
	 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
112
	 */
113
	@Override
114
	protected Control createDialogArea(Composite p) {
115
		
116
		p.setLayout(new GridLayout(values.length, false));
117
		
118
		Label label = new Label(p, SWT.NONE);
119
		label.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, true, values.length, 1));
120
		if (message != null) label.setText(message);
121
		
122
		for (String name : values) {
123
			Button btn = new Button(p, SWT.PUSH);
124
			btn.setText(name); //$NON-NLS-1$
125
			btn.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false));
126
			btn.addSelectionListener(new SelectionListener() {
127

  
128
				@Override
129
				public void widgetSelected(SelectionEvent e) {
130
					answer = ((Button)e.widget).getText();
131
					MultipleChoiceDialog.super.okPressed();
132
				}
133
				
134
				@Override
135
				public void widgetDefaultSelected(SelectionEvent e) { }
136
			});
137
		}
138
		return p;
139
	}
140
	
141
	public String getAnswer() {
142
		return answer;
143
	}
144
}
0 145

  
tmp/org.txm.rcp/src/main/java/org/txm/rcp/p2/plugins/TXMUpdateHandler.java (revision 3166)
130 130
			}
131 131
			
132 132
			// this is the default repository
133
			URL baseURL = new URL(TBXPreferences.getInstance().getString(TBXPreferences.UPDATESITE) + "/index.html");
134
			try {
135
				InputStream s = baseURL.openStream();
136
				s.close();
137
			}
138
			catch (Exception e) {
139
				Log.severe("Update site is not reachable: " + baseURL + ", aborting.");
133
			if (!isUpdateSiteAvailable()) {
140 134
				return false;
141 135
			}
142 136
			
......
158 152
		return null;
159 153
	}
160 154
	
161
	private boolean isWindowsAdministratorUser() {
155
	public static boolean isUpdateSiteAvailable() {
156
		String baseURLString = TBXPreferences.getInstance().getString(TBXPreferences.UPDATESITE) + "index.html";
157
		try {
158
			URL baseURL = new URL(baseURLString);
159
			InputStream s = baseURL.openStream();
160
			s.close();
161
			return true;
162
		}
163
		catch (Exception e) {
164
			Log.warning(NLS.bind("Update site is not reachable ({0}): {1}. Aborting.", e.getMessage(), baseURLString));
165
			return false;
166
		}
167
	}
168

  
169
	public static boolean isWindowsAdministratorUser() {
162 170
		String path = BundleUtils.getInstallDirectory();// System.getProperty("osgi.instance.area");
163 171
		if (!path.startsWith("C:/Program Files/TXM")) {
164 172
			return true; // TXM was not installed in program files no need to test admin user
......
167 175
		return isWindowsAdminCommandTest();
168 176
	}
169 177
	
170
	private static boolean isWindowsAdminCommandTest() {
178
	public static boolean isWindowsAdminCommandTest() {
171 179
		Preferences preferences = systemRoot();
172 180
		
173 181
		synchronized (System.err) {
tmp/org.txm.rcp/src/main/java/org/txm/rcp/views/fileexplorer/FileTreeLabelProvider.java (revision 3166)
68 68
					Application.PLUGIN_ID, IImageKeys.FOLDER);
69 69
		}
70 70
		else if (f.isFile()) {
71
			if (f.getName().matches(".*\\.(mp4|avi|mkv|ogv|mpg|webm)")) {
71
			String fname = f.getName().toLowerCase();
72
			if (fname.matches(".*\\.(mp4|avi|mkv|ogv|mpg|webm)")) {
72 73
				imageDescriptor = AbstractUIPlugin
73 74
						.imageDescriptorFromPlugin(Application.PLUGIN_ID,
74 75
								IImageKeys.FILE_VIDEO);
75 76
			}
76
			else if (f.getName().endsWith(".txm")) {
77
			else if (fname.endsWith(".txm")) {
77 78
				imageDescriptor = AbstractUIPlugin
78 79
						.imageDescriptorFromPlugin(Application.PLUGIN_ID,
79 80
								IImageKeys.TXM1616);
80 81
			}
81
			else if (f.getName().matches(".*\\.(mp3|ogg|wav|flac)")) {
82
			else if (fname.matches(".*\\.(mp3|ogg|wav|flac)")) {
82 83
				imageDescriptor = AbstractUIPlugin
83 84
						.imageDescriptorFromPlugin(Application.PLUGIN_ID,
84 85
								IImageKeys.FILE_AUDIO);
85 86
			}
86
			else if (f.getName().matches(".*\\.(png|jpg|jpeg|bmp|gif)")) {
87
			else if (fname.matches(".*\\.(png|jpg|jpeg|bmp|gif|svg)")) {
87 88
				imageDescriptor = AbstractUIPlugin
88 89
						.imageDescriptorFromPlugin(Application.PLUGIN_ID,
89 90
								IImageKeys.FILE_IMAGE);
90 91
			}
91
			else if (f.getName().endsWith("Macro.groovy")) {
92
			else if (fname.endsWith("Macro.groovy")) {
92 93
				imageDescriptor = AbstractUIPlugin
93 94
						.imageDescriptorFromPlugin(Application.PLUGIN_ID,
94 95
								IImageKeys.SCRIPT_RUN);
95 96
			}
96
			else if (f.getName().matches(".*\\.(groovy|R|py|pl|java|rb|sh|bat)")) {
97
			else if (fname.matches(".*\\.(groovy|R|py|pl|java|rb|sh|bat|js|c|cpp|xml|xsl|css)")) {
97 98
				imageDescriptor = AbstractUIPlugin
98 99
						.imageDescriptorFromPlugin(Application.PLUGIN_ID,
99 100
								IImageKeys.SCRIPT);
100 101
			}
101
			else if (f.getName().matches(".*\\.(doc.|od.|pdf)")) {
102
			else if (fname.matches(".*\\.(doc.|od.|pdf|rtf)")) {
102 103
				imageDescriptor = AbstractUIPlugin
103 104
						.imageDescriptorFromPlugin(Application.PLUGIN_ID,
104 105
								IImageKeys.FILE_DOC);
105 106
			}
107
			else if (fname.endsWith("html")) {
108
				imageDescriptor = AbstractUIPlugin
109
						.imageDescriptorFromPlugin(Application.PLUGIN_ID,
110
								IImageKeys.WORLD);
111
			}
106 112
			else {
107 113
				imageDescriptor = AbstractUIPlugin
108 114
						.imageDescriptorFromPlugin(Application.PLUGIN_ID,
tmp/org.txm.rcp/src/main/java/org/txm/rcp/utils/JobHandler.java (revision 3166)
206 206
	}
207 207
	
208 208
	public void startJob() {
209
		startJob(false);
209
		startJob(true);
210 210
	}
211 211
	
212 212
	/**
tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/OpenBrowser.java (revision 3166)
146 146
	 * @param filepath the filepath
147 147
	 * @return the txm browser
148 148
	 */
149
	static public TXMBrowserEditor open() {
150
		return openfile("", null);
151
	}
152
	
153
	/**
154
	 * Openfile.
155
	 *
156
	 * @param filepath the filepath
157
	 * @return the txm browser
158
	 */
149 159
	static public TXMBrowserEditor openfile(String filepath) {
150 160
		return openfile(filepath, new File(filepath).getName());
151 161
	}
......
174 184
			// System.setProperty("org.eclipse.swt.browser.XULRunnerPath", "");
175 185
			WebBrowserEditorInput editorInput;
176 186
			File localfile = new File(filepath);
177
			if (localfile.exists())
187
			if (localfile == null || localfile.length() == 0)
188
				editorInput = new WebBrowserEditorInput(null, BrowserViewer.BUTTON_BAR | BrowserViewer.LOCATION_BAR);
189
			else if (localfile.exists())
178 190
				editorInput = new WebBrowserEditorInput(localfile.toURI().toURL(), BrowserViewer.BUTTON_BAR | BrowserViewer.LOCATION_BAR);
179 191
			else
180 192
				editorInput = new WebBrowserEditorInput(new URL(filepath), BrowserViewer.BUTTON_BAR | BrowserViewer.LOCATION_BAR);
......
183 195
			IWorkbenchPage page = window.getActivePage();
184 196
			
185 197
			TXMBrowserEditor editor = (TXMBrowserEditor) page.openEditor(editorInput, TXMBrowserEditor.ID, true);
186
			editor.setPartName(editorname);
198
			if (editorname != null) {
199
				editor.setPartName(editorname);
200
			}
187 201
			return editor;
188 202
		}
189 203
		catch (Exception e) {
tmp/org.txm.rcp.feature/feature.xml (revision 3166)
256 256
      <import plugin="org.txm.rcp" version="0.8.0" match="greaterOrEqual"/>
257 257
      <import plugin="org.txm.searchengine.core" version="1.0.0" match="greaterOrEqual"/>
258 258
      <import plugin="org.txm.rcp" version="0.8.2" match="greaterOrEqual"/>
259
      <import plugin="org.txm.core"/>
259 260
   </requires>
260 261

  
261 262
   <plugin
......
277 278
         version="0.0.0"
278 279
         unpack="false"/>
279 280

  
281
   <plugin
282
         id="org.txm.whatsnew.rcp"
283
         download-size="0"
284
         install-size="0"
285
         version="0.0.0"
286
         unpack="false"/>
287

  
280 288
</feature>
tmp/org.txm.whatsnew.rcp/src/org/txm/whatsnew/rcp/DoInstallStep.java (revision 3166)
1
package org.txm.whatsnew.rcp;
2

  
3

  
4
import java.net.URL;
5

  
6
import org.eclipse.swt.widgets.Display;
7
import org.osgi.framework.Version;
8
import org.txm.PostInstallationStep;
9
import org.txm.core.preferences.TBXPreferences;
10
import org.txm.rcp.Activator;
11
import org.txm.rcp.commands.OpenBrowser;
12
import org.txm.utils.io.IOUtils;
13
import org.txm.utils.logger.Log;
14

  
15
/**
16
 * Opens news about TXM development
17
 * 
18
 * @author mdecorde
19
 *
20
 */
21
public class DoInstallStep  extends PostInstallationStep {
22

  
23
	public static String ID = DoInstallStep.class.getName(); //$NON-NLS-1$
24

  
25
	public void install() {
26
		
27
		try {
28
			Version newsVersion = NewsEditor.getLastVersion();
29
			
30
			String currentNewsVersionString = NewsPreferences.getInstance().getString(NewsPreferences.NEWS_VERSION);
31
			Version currentNewsVersion = new Version(currentNewsVersionString);
32
			
33
			NewsPreferences.getInstance().put(NewsPreferences.NEWS_VERSION, newsVersion.getMajor());
34
			
35
			if (NewsPreferences.getInstance().getBoolean(NewsPreferences.SHOW_NEWS) && newsVersion.compareTo(currentNewsVersion) > 0) {
36
				OpenNews.open();
37
			}
38
		}
39
		catch (Exception e) {
40
			Log.warning("Error while fetching news: "+e);
41
			Log.printStackTrace(e);
42
		}
43
	}
44
	
45
	public void preInstall() {
46
		
47
	}
48
	
49
	public DoInstallStep() {
50
		name = "WhatsNew";
51
	}
52
}
tmp/org.txm.whatsnew.rcp/src/org/txm/whatsnew/rcp/NewsPreferencesPage.java (revision 3166)
13 13
	public void init(IWorkbench workbench) {
14 14
		
15 15
		this.setPreferenceStore(new TXMPreferenceStore(NewsPreferences.getInstance().getPreferencesNodeQualifier()));
16
		this.setTitle("News");
16
		this.setTitle("New setups");
17 17
		this.setImageDescriptor(IImageKeys.getImageDescriptor("platform:/plugin/org.eclipse.ui.editors/icons/full/obj16/quick_assist_obj.gif"));
18 18
	}
19 19
	
20 20
	@Override
21 21
	protected void createFieldEditors() {
22 22
		
23
		this.addField(new BooleanFieldEditor(NewsPreferences.SHOW_NEWS, "Show news when TXM starts up", this.getFieldEditorParent()));
23
		//this.addField(new BooleanFieldEditor(NewsPreferences.SHOW_NEWS, "Show news when TXM starts up", this.getFieldEditorParent()));
24 24
		
25
		this.addField(new BooleanFieldEditor(NewsPreferences.SHOW_NEW_SETUP, "Show new setup popups when TXM starts up", this.getFieldEditorParent()));
26
		
25 27
		// enable if dev needs to update the NEWS_VERSION value
26
		//this.addField(new org.eclipse.jface.preference.IntegerFieldEditor(NewsPreferences.NEWS_VERSION, "Current news index", this.getFieldEditorParent()));
28
		//this.addField(new org.eclipse.jface.preference.StringFieldEditor(NewsPreferences.NEWS_VERSION, "Current news index", this.getFieldEditorParent()));
29
		//this.addField(new org.eclipse.jface.preference.StringFieldEditor(NewsPreferences.NEW_SETUP_VERSION, "Current new setup index", this.getFieldEditorParent()));
27 30
	}
28 31
}
tmp/org.txm.whatsnew.rcp/src/org/txm/whatsnew/rcp/NewsPreferences.java (revision 3166)
9 9
	public static final String SHOW_NEWS = "show_news";
10 10
	public static final String NEWS_VERSION = "news_version";
11 11
	
12
	public static final String SHOW_NEW_SETUP = "show_new_setups";
13
	public static final String NEW_SETUP_VERSION = "new_setups_version";
14
	
12 15
	/**
13 16
	 * Gets the instance.
14 17
	 * 
......
27 30
		super.initializeDefaultPreferences();
28 31
		
29 32
		Preferences preferences = this.getDefaultPreferencesNode();
30
		preferences.putBoolean(SHOW_NEWS, true); // $NON-NLS-1$
33
		preferences.putBoolean(SHOW_NEWS, false); // $NON-NLS-1$
31 34
		preferences.put(NEWS_VERSION, "0"); // $NON-NLS-1$
35
		
36
		preferences.putBoolean(SHOW_NEW_SETUP, true); // $NON-NLS-1$
37
		preferences.put(NEW_SETUP_VERSION, "0"); // $NON-NLS-1$
32 38
	}
33 39
}
tmp/org.txm.whatsnew.rcp/src/org/txm/whatsnew/rcp/DoWhatsNewStep.java (revision 3166)
1
package org.txm.whatsnew.rcp;
2

  
3

  
4
import org.osgi.framework.Version;
5
import org.txm.PostInstallationStep;
6
import org.txm.utils.logger.Log;
7

  
8
/**
9
 * Opens news about TXM development
10
 * 
11
 * @author mdecorde
12
 *
13
 */
14
public class DoWhatsNewStep  extends PostInstallationStep {
15

  
16
	public static String ID = DoWhatsNewStep.class.getName(); //$NON-NLS-1$
17

  
18
	public void install() {
19
		
20
		try {
21
			Version lastNewsVersion = NewsEditor.getLastVersion();
22
			
23
			String currentShownNewsVersionString = NewsPreferences.getInstance().getString(NewsPreferences.NEWS_VERSION);
24
			Version currentShownNewsVersion = new Version(currentShownNewsVersionString);
25
			if (currentShownNewsVersion.compareTo(lastNewsVersion) > 0) { // the current version should be greater or equal to the last nest version
26
				currentShownNewsVersion = lastNewsVersion;
27
			}
28
			NewsPreferences.getInstance().put(NewsPreferences.NEWS_VERSION, lastNewsVersion.getMajor());
29
			
30
			if (NewsPreferences.getInstance().getBoolean(NewsPreferences.SHOW_NEWS) 
31
					&& lastNewsVersion.compareTo(currentShownNewsVersion) > 0) { // currentShownNewsVersion < lastNewsVersion
32
				OpenNews.open();
33
			}
34
		}
35
		catch (Exception e) {
36
			Log.warning("Error while fetching news: "+e);
37
			Log.printStackTrace(e);
38
		}
39
	}
40
	
41
	public void preInstall() {
42
		
43
	}
44
	
45
	public DoWhatsNewStep() {
46
		name = "WhatsNew";
47
	}
48
}
0 49

  
tmp/org.txm.whatsnew.rcp/src/org/txm/whatsnew/rcp/DoWhatsNewSetupStep.java (revision 3166)
1
package org.txm.whatsnew.rcp;
2

  
3

  
4
import java.net.MalformedURLException;
5
import java.net.URL;
6

  
7
import org.eclipse.jface.dialogs.MessageDialog;
8
import org.eclipse.swt.widgets.Display;
9
import org.eclipse.ui.IWorkbenchPage;
10
import org.eclipse.ui.IWorkbenchWindow;
11
import org.eclipse.ui.PlatformUI;
12
import org.osgi.framework.Version;
13
import org.txm.PostInstallationStep;
14
import org.txm.core.preferences.TBXPreferences;
15
import org.txm.rcp.commands.OpenBrowser;
16
import org.txm.rcp.swt.dialog.MultipleChoiceDialog;
17
import org.txm.utils.logger.Log;
18

  
19
/**
20
 * Opens news about new TXM setup
21
 * 
22
 * @author mdecorde
23
 *
24
 */
25
public class DoWhatsNewSetupStep  extends PostInstallationStep {
26

  
27
	public static String ID = DoWhatsNewSetupStep.class.getName(); //$NON-NLS-1$
28

  
29
	public void install() {
30
		
31
		try {
32
			String lastNewSetupVersionString = NewsEditor.getLastSetupVersion();
33
			
34
			String currentShownNewSetupVersionString = NewsPreferences.getInstance().getString(NewsPreferences.NEW_SETUP_VERSION);
35
			if (currentShownNewSetupVersionString.compareTo(lastNewSetupVersionString) > 0) { // the current version should be greater or equal to the last nest version
36
				currentShownNewSetupVersionString = lastNewSetupVersionString;
37
			}
38
			NewsPreferences.getInstance().put(NewsPreferences.NEW_SETUP_VERSION, lastNewSetupVersionString);
39
			
40
			if (NewsPreferences.getInstance().getBoolean(NewsPreferences.SHOW_NEW_SETUP) 
41
					&& lastNewSetupVersionString.compareTo(currentShownNewSetupVersionString) > 0) { // currentShownNewSetupVersion < lastNewsVersion
42
				open();
43
			}
44
		}
45
		catch (Exception e) {
46
			Log.warning("Error while fetching new setup informations: "+e);
47
			Log.printStackTrace(e);
48
		}
49
	}
50
	
51
	public static final String YES = "Yes";
52
	public static final String NO = "No";
53
	public static final String DONTBOTHERAGAIN = "No, don't bother again.";
54
	
55
	public static void open() throws MalformedURLException {
56
		
57
		Display.getDefault().syncExec(new Runnable() {
58
			
59
			@Override
60
			public void run() {
61
				try {
62
					MultipleChoiceDialog dialog = new MultipleChoiceDialog(Display.getDefault().getActiveShell(), 
63
							"A new TXM setup is available!", 
64
							"Do you want to download it now?", 
65
							new String[] {YES, NO, DONTBOTHERAGAIN}, NO);
66
					dialog.open();
67
					
68
					String rep = dialog.getAnswer();
69
					switch(rep) {
70
						case YES:
71
							String lastNewSetupVersion = NewsEditor.getLastSetupVersion();
72
							String newSetupVersionURL = TBXPreferences.getInstance().getString(TBXPreferences.FILESSITE) + "software/TXM/"+lastNewSetupVersion;
73
							OpenBrowser.openExternalBrowser(newSetupVersionURL);
74
							break;
75
						case NO:
76
							break;
77
						case DONTBOTHERAGAIN:
78
							NewsPreferences.getInstance().put(NewsPreferences.SHOW_NEW_SETUP, false);
79
							break;
80
					}
81
				}
82
				catch (Exception e) {
83
					// TODO Auto-generated catch block
84
					e.printStackTrace();
85
				}
86
			}
87
		});
88
	}
89
	
90
	public void preInstall() {
91
		
92
	}
93
	
94
	public DoWhatsNewSetupStep() {
95
		name = "WhatsNewSetup";
96
	}
97
}
0 98

  
tmp/org.txm.whatsnew.rcp/src/org/txm/whatsnew/rcp/NewsEditor.java (revision 3166)
21 21
import org.txm.core.preferences.TBXPreferences;
22 22
import org.txm.rcp.Activator;
23 23
import org.txm.rcp.IImageKeys;
24
import org.txm.rcp.p2.plugins.TXMUpdateHandler;
24 25
import org.txm.utils.io.IOUtils;
25 26
import org.txm.utils.logger.Log;
26 27

  
......
147 148
		refreshNews();
148 149
	}
149 150
	
151
	/**
152
	 * 
153
	 * @return the last news version available
154
	 */
150 155
	public static Version getLastVersion() {
151 156
		try {
157
			if (!TXMUpdateHandler.isUpdateSiteAvailable()) {
158
				return new Version("0");
159
			}
160
			
152 161
			Version v = Activator.getDefault().getBundle().getVersion();
153 162
			String version = "" + v.getMajor() + "." + v.getMinor() + "." + v.getMicro();
154 163
			
......
164 173
			
165 174
			return new Version(newsVersionString);
166 175
		} catch (Exception e) {
167
			e.printStackTrace();
176
			Log.printStackTrace(e);
168 177
			return new Version("0");
169 178
		}
170 179
	}
171 180
	
181
	/**
182
	 * 
183
	 * @return the last known available setup version
184
	 */
185
	public static String getLastSetupVersion() {
186
		try {
187
			if (!TXMUpdateHandler.isUpdateSiteAvailable()) {
188
				return "0";
189
			}
190
			
191
			URL newSetupVersionURL;
192
			
193
			newSetupVersionURL = new URL(TBXPreferences.getInstance().getString(TBXPreferences.RAWFILESSITE) + "software/TXM/new_setup.version");
194
			
195
			String newSetupVersionString = IOUtils.getText(newSetupVersionURL, "UTF-8");
196
			if (newSetupVersionString == null || newSetupVersionString.length() == 0) {
197
				Log.warning("No new setup version available at: "+newSetupVersionURL);
198
				return "0";
199
			}
200
			
201
			return newSetupVersionString;
202
		} catch (Exception e) {
203
			Log.printStackTrace(e);
204
			return "0";
205
		}
206
	}
207
	
172 208
	public void refreshNews() {
173 209
		
174 210
		vMax = getLastVersion().getMajor();
175
		
211
		if (vCurrentNews > vMax) {
212
			vCurrentNews = vMax;
213
		}
176 214
		Version v = Activator.getDefault().getBundle().getVersion();
177 215
		String version = "" + v.getMajor() + "." + v.getMinor() + "." + v.getMicro();	
178 216
		
tmp/org.txm.whatsnew.rcp/plugin.xml (revision 3166)
4 4
   <extension
5 5
         point="org.txm.PostInstallationStep">
6 6
      <PostInstallationStep
7
            class="org.txm.whatsnew.rcp.DoInstallStep"
8
            description="Whats new about TXM"
9
            name="org.txm.whatsnew.rcp.DoInstallStep">
7
            class="org.txm.whatsnew.rcp.DoWhatsNewSetupStep"
8
            description="Whats new  TXM setup"
9
            name="org.txm.whatsnew.rcp.DoWhatsNewSetupStep">
10 10
      </PostInstallationStep>
11 11
   </extension>
12 12
   <extension
13 13
         point="org.eclipse.ui.menus">
14 14
      <menuContribution
15 15
            locationURI="menu:menu.help?before=org.txm.rcp.separator1">
16
         <command
17
               commandId="org.txm.whatsnew.rcp.OpenNews"
18
               icon="platform:/plugin/org.eclipse.ui.editors/icons/full/obj16/quick_assist_obj.gif"
19
               style="push">
20
         </command>
21 16
      </menuContribution>
22 17
   </extension>
23 18
   <extension
......
40 35
            category="org.txm.rcp.preferences.UserPreferencePage"
41 36
            class="org.txm.whatsnew.rcp.NewsPreferencesPage"
42 37
            id="org.txm.whatsnew.rcp.NewsPreferencesPage"
43
            name="News">
38
            name="New setups">
44 39
      </page>
45 40
   </extension>
46 41
   <extension

Formats disponibles : Unified diff