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 / +51 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 1141-1146 Link Here
1141
		setJREs(standins.toArray(new IVMInstall[standins.size()]));	
1143
		setJREs(standins.toArray(new IVMInstall[standins.size()]));	
1142
	}
1144
	}
1143
	
1145
	
1146
	protected void initializeTimeStamp(){
1147
		fVMListTimeStamp = getEncodedSettings();
1148
	}
1149
1144
	/**
1150
	/**
1145
	 * Disposes the block and any listeners
1151
	 * Disposes the block and any listeners
1146
	 * 
1152
	 * 
Lines 1149-1153 Link Here
1149
	public void dispose() {
1155
	public void dispose() {
1150
		JavaRuntime.removeVMInstallChangedListener(fListener);
1156
		JavaRuntime.removeVMInstallChangedListener(fListener);
1151
	}
1157
	}
1152
		
1158
1159
1160
	private StringBuffer appendVMAttributes(IVMInstall vmInstall, StringBuffer buf) {
1161
		if (vmInstall != null) {
1162
			String str = vmInstall.getName();
1163
			buf.append('[').append(str.length()).append(']').append(str);
1164
			str = vmInstall.getVMInstallType().getName();
1165
			buf.append('[').append(str.length()).append(']').append(str);
1166
			if (vmInstall.getVMArguments() != null) {
1167
				str = vmInstall.getVMArguments().toString();
1168
				buf.append('[').append(str.length()).append(']').append(str);
1169
			}
1170
			str = vmInstall.getInstallLocation().getAbsolutePath();
1171
			buf.append('[').append(str.length()).append(']').append(str).append(';');
1172
			;
1173
		} else {
1174
			buf.append('[').append(']').append(';');
1175
		}
1176
		return buf;
1177
	}
1178
1179
	private String getEncodedSettings() {
1180
		StringBuffer buf = new StringBuffer();
1181
		IVMInstall vmInstall = getCheckedJRE();
1182
		buf.append('[').append("defaultVM").append(']'); //$NON-NLS-1$
1183
		if (vmInstall != null) {
1184
			buf.append('[').append(vmInstall.getName().length()).append(']').append(vmInstall.getName()).append(';');
1185
		} else {
1186
			buf.append('[').append(']').append(';');
1187
		}
1188
1189
		int nElements = fVMs.size();
1190
		buf.append('[').append(nElements).append(']');
1191
		for (int i = 0; i < nElements; i++) {
1192
			IVMInstall elem = fVMs.get(i);
1193
			appendVMAttributes(elem, buf);
1194
		}
1195
		return buf.toString();
1196
	}
1197
1198
	public boolean hasChangesInDialog() {
1199
		String currSettings = getEncodedSettings();
1200
		return !currSettings.equals(fVMListTimeStamp);
1201
	}
1153
}
1202
}
(-)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=The Installed JREs property page contains unsaved modifications. Do you want to save changes so that other Installed JREs related property 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
		createApplyButton();
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) { // save
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
				// keep unsaved
340
			}
341
		}
342
		return super.okToLeave();
343
	}
315
}
344
}

Return to bug 121057