Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 121057 | Differences between
and this patch

Collapse All | Expand All

(-)ui/org/eclipse/jdt/internal/debug/ui/jres/InstalledJREsBlock.java (-2 / +57 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2013 IBM Corporation and others.
2
 * Copyright (c) 2000, 2014 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 209-214 Link Here
209
	 */
209
	 */
210
	public static final String MACOSX_VM_TYPE_ID = "org.eclipse.jdt.internal.launching.macosx.MacOSXType"; //$NON-NLS-1$
210
	public static final String MACOSX_VM_TYPE_ID = "org.eclipse.jdt.internal.launching.macosx.MacOSXType"; //$NON-NLS-1$
211
	
211
	
212
	private String fVMListTimeStamp;
213
212
	/** 
214
	/** 
213
	 * Content provider to show a list of JREs
215
	 * Content provider to show a list of JREs
214
	 */ 
216
	 */ 
Lines 1142-1147 Link Here
1142
	}
1144
	}
1143
	
1145
	
1144
	/**
1146
	/**
1147
	 * Initializes time stamp with current JRE page details 
1148
	 */
1149
	public void initializeTimeStamp() {
1150
		fVMListTimeStamp = getEncodedVMInstalls();
1151
	}
1152
1153
	/**
1145
	 * Disposes the block and any listeners
1154
	 * Disposes the block and any listeners
1146
	 * 
1155
	 * 
1147
	 * @since 3.6.300
1156
	 * @since 3.6.300
Lines 1149-1153 Link Here
1149
	public void dispose() {
1158
	public void dispose() {
1150
		JavaRuntime.removeVMInstallChangedListener(fListener);
1159
		JavaRuntime.removeVMInstallChangedListener(fListener);
1151
	}
1160
	}
1152
		
1161
1162
1163
	private StringBuffer appendVMAttributes(IVMInstall vmInstall, StringBuffer buf) {
1164
		if (vmInstall != null) {
1165
			String str = vmInstall.getName();
1166
			buf.append('[').append(str.length()).append(']').append(str);
1167
			str = vmInstall.getVMInstallType().getName();
1168
			buf.append('[').append(str.length()).append(']').append(str);
1169
			if (vmInstall.getVMArguments() != null) {
1170
				str = vmInstall.getVMArguments().toString();
1171
				buf.append('[').append(str.length()).append(']').append(str);
1172
			}
1173
			str = vmInstall.getInstallLocation().getAbsolutePath();
1174
			buf.append('[').append(str.length()).append(']').append(str).append(';');
1175
			;
1176
		} else {
1177
			buf.append('[').append(']').append(';');
1178
		}
1179
		return buf;
1180
	}
1181
1182
	private String getEncodedVMInstalls() {
1183
		StringBuffer buf = new StringBuffer();
1184
		IVMInstall vmInstall = getCheckedJRE();
1185
1186
		int nElements = fVMs.size();
1187
		buf.append('[').append(nElements).append(']');
1188
		for (int i = 0; i < nElements; i++) {
1189
			IVMInstall elem = fVMs.get(i);
1190
			if (elem == vmInstall)
1191
			 {
1192
				buf.append('[').append("defaultVM").append(']'); //$NON-NLS-1$
1193
			}
1194
			appendVMAttributes(elem, buf);
1195
		}
1196
		return buf.toString();
1197
	}
1198
1199
	/**
1200
	 * Checks if JRE block has changed.
1201
	 * 
1202
	 * @return <code>true</code> if JRE block has changed, <code>false</code> otherwise
1203
	 */
1204
	public boolean hasChangesInDialog() {
1205
		String currSettings = getEncodedVMInstalls();
1206
		return !currSettings.equals(fVMListTimeStamp);
1207
	}
1153
}
1208
}
(-)ui/org/eclipse/jdt/internal/debug/ui/jres/JREMessages.java (-1 / +6 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 *  Copyright (c) 2000, 2013 IBM Corporation and others.
2
 *  Copyright (c) 2000, 2014 IBM Corporation and others.
3
 *  All rights reserved. This program and the accompanying materials
3
 *  All rights reserved. This program and the accompanying materials
4
 *  are made available under the terms of the Eclipse Public License v1.0
4
 *  are made available under the terms of the Eclipse Public License v1.0
5
 *  which accompanies this distribution, and is available at
5
 *  which accompanies this distribution, and is available at
Lines 74-79 Link Here
74
	public static String JREsPreferencePage_13;
74
	public static String JREsPreferencePage_13;
75
75
76
	public static String JREsPreferencePage_3;
76
	public static String JREsPreferencePage_3;
77
	public static String JREsPreferencePage_4;
78
	public static String JREsPreferencePage_5;
79
	public static String JREsPreferencePage_6;
80
	public static String JREsPreferencePage_7;
81
	public static String JREsPreferencePage_8;
77
82
78
	public static String addVMDialog_duplicateName;
83
	public static String addVMDialog_duplicateName;
79
	public static String addVMDialog_enterLocation;
84
	public static String addVMDialog_enterLocation;
(-)ui/org/eclipse/jdt/internal/debug/ui/jres/JREMessages.properties (-1 / +6 lines)
Lines 1-5 Link Here
1
###############################################################################
1
###############################################################################
2
#  Copyright (c) 2000, 2013 IBM Corporation and others.
2
#  Copyright (c) 2000, 2014 IBM Corporation and others.
3
#  All rights reserved. This program and the accompanying materials
3
#  All rights reserved. This program and the accompanying materials
4
#  are made available under the terms of the Eclipse Public License v1.0
4
#  are made available under the terms of the Eclipse Public License v1.0
5
#  which accompanies this distribution, and is available at
5
#  which accompanies this distribution, and is available at
Lines 69-74 Link Here
69
JREsPreferencePage_13=You must select a default JRE for the workspace
69
JREsPreferencePage_13=You must select a default JRE for the workspace
70
JREsPreferencePage_14=Conflicting compliance settings can be changed on the <a>Compiler</a> page.
70
JREsPreferencePage_14=Conflicting compliance settings can be changed on the <a>Compiler</a> page.
71
JREsPreferencePage_3=You must provide at least one JRE to act as the workspace default
71
JREsPreferencePage_3=You must provide at least one JRE to act as the workspace default
72
JREsPreferencePage_4=Setting Installed JREs
73
JREsPreferencePage_5=This page contains unsaved modifications. Do you want to apply the changes so that other related pages can be updated?
74
JREsPreferencePage_6=Apply
75
JREsPreferencePage_7=Discard
76
JREsPreferencePage_8=Apply Later
72
77
73
addVMDialog_duplicateName=The JRE name is already in use.
78
addVMDialog_duplicateName=The JRE name is already in use.
74
addVMDialog_enterLocation=Enter the home directory of the JRE.
79
addVMDialog_enterLocation=Enter the home directory of the JRE.
(-)ui/org/eclipse/jdt/internal/debug/ui/jres/JREsPreferencePage.java (-2 / +31 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2013 IBM Corporation and others.
2
 * Copyright (c) 2000, 2014 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 31-36 Link Here
31
import org.eclipse.jface.dialogs.ErrorDialog;
31
import org.eclipse.jface.dialogs.ErrorDialog;
32
import org.eclipse.jface.dialogs.IDialogSettings;
32
import org.eclipse.jface.dialogs.IDialogSettings;
33
import org.eclipse.jface.dialogs.IMessageProvider;
33
import org.eclipse.jface.dialogs.IMessageProvider;
34
import org.eclipse.jface.dialogs.MessageDialog;
34
import org.eclipse.jface.preference.PreferencePage;
35
import org.eclipse.jface.preference.PreferencePage;
35
import org.eclipse.jface.viewers.ISelectionChangedListener;
36
import org.eclipse.jface.viewers.ISelectionChangedListener;
36
import org.eclipse.jface.viewers.SelectionChangedEvent;
37
import org.eclipse.jface.viewers.SelectionChangedEvent;
Lines 104-110 Link Here
104
	protected Control createContents(Composite ancestor) {
105
	protected Control createContents(Composite ancestor) {
105
		initializeDialogUnits(ancestor);
106
		initializeDialogUnits(ancestor);
106
		
107
		
107
		noDefaultAndApplyButton();
108
		noDefaultButton();
108
		
109
		
109
		GridLayout layout= new GridLayout();
110
		GridLayout layout= new GridLayout();
110
		layout.numColumns= 1;
111
		layout.numColumns= 1;
Lines 134-139 Link Here
134
		});
135
		});
135
		PlatformUI.getWorkbench().getHelpSystem().setHelp(ancestor, IJavaDebugHelpContextIds.JRE_PREFERENCE_PAGE);		
136
		PlatformUI.getWorkbench().getHelpSystem().setHelp(ancestor, IJavaDebugHelpContextIds.JRE_PREFERENCE_PAGE);		
136
		initDefaultVM();
137
		initDefaultVM();
138
		fJREBlock.initializeTimeStamp();
137
		fJREBlock.addSelectionChangedListener(new ISelectionChangedListener() {
139
		fJREBlock.addSelectionChangedListener(new ISelectionChangedListener() {
138
			public void selectionChanged(SelectionChangedEvent event) {
140
			public void selectionChanged(SelectionChangedEvent event) {
139
				IVMInstall install = getCurrentDefaultVM();
141
				IVMInstall install = getCurrentDefaultVM();
Lines 257-262 Link Here
257
		// save column widths
259
		// save column widths
258
		IDialogSettings settings = JDIDebugUIPlugin.getDefault().getDialogSettings();
260
		IDialogSettings settings = JDIDebugUIPlugin.getDefault().getDialogSettings();
259
		fJREBlock.saveColumnSettings(settings, IJavaDebugHelpContextIds.JRE_PREFERENCE_PAGE);
261
		fJREBlock.saveColumnSettings(settings, IJavaDebugHelpContextIds.JRE_PREFERENCE_PAGE);
262
		fJREBlock.initializeTimeStamp();
260
		
263
		
261
		return super.performOk();
264
		return super.performOk();
262
	}	
265
	}	
Lines 312-315 Link Here
312
		super.dispose();
315
		super.dispose();
313
		fJREBlock.dispose();
316
		fJREBlock.dispose();
314
	}
317
	}
318
319
	/*
320
	 * @see org.eclipse.jface.preference.PreferencePage#okToLeave()
321
	 */
322
	@Override
323
	public boolean okToLeave() {
324
		if (fJREBlock != null && fJREBlock.hasChangesInDialog()) {
325
			String title = JREMessages.JREsPreferencePage_4;
326
			String message = JREMessages.JREsPreferencePage_5;
327
			String[] buttonLabels = new String[] { JREMessages.JREsPreferencePage_6, JREMessages.JREsPreferencePage_7,
328
					JREMessages.JREsPreferencePage_8 };
329
			MessageDialog dialog = new MessageDialog(getShell(), title, null, message, MessageDialog.QUESTION, buttonLabels, 0);
330
			int res = dialog.open();
331
			if (res == 0) { // apply
332
				return performOk() && super.okToLeave();
333
			} else if (res == 1) { // discard
334
				fJREBlock.fillWithWorkspaceJREs();
335
				fJREBlock.restoreColumnSettings(JDIDebugUIPlugin.getDefault().getDialogSettings(), IJavaDebugHelpContextIds.JRE_PREFERENCE_PAGE);
336
				initDefaultVM();
337
				fJREBlock.initializeTimeStamp();
338
			} else {
339
				// apply later
340
			}
341
		}
342
		return super.okToLeave();
343
	}
315
}
344
}

Return to bug 121057