diff options
| author | Sarika Sinha | 2014-12-19 12:49:27 +0000 |
|---|---|---|
| committer | Dani Megert | 2014-12-19 12:49:27 +0000 |
| commit | 2ef686649486e20d93522f435f6d4c4c66fa1cb9 (patch) | |
| tree | cd111fd3dad19977322b33ec5979e91a212dcddc | |
| parent | 71117a8aada455e1cf0e8a4d2e1a19c087a26ee1 (diff) | |
| download | eclipse.jdt.debug-2ef686649486e20d93522f435f6d4c4c66fa1cb9.tar.gz eclipse.jdt.debug-2ef686649486e20d93522f435f6d4c4c66fa1cb9.tar.xz eclipse.jdt.debug-2ef686649486e20d93522f435f6d4c4c66fa1cb9.zip | |
Fixed bug 121057: [jres] 'Execution Environments' preference page not updated after JRE addition
Signed-off-by: Sarika Sinha <sarika.sinha@in.ibm.com>
4 files changed, 142 insertions, 41 deletions
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/InstalledJREsBlock.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/InstalledJREsBlock.java index 2e5e46dff..1668f1e82 100644 --- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/InstalledJREsBlock.java +++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/InstalledJREsBlock.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2013 IBM Corporation and others. + * Copyright (c) 2000, 2014 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -19,25 +19,37 @@ import java.util.Iterator; import java.util.List; import java.util.Set; +import org.eclipse.osgi.util.NLS; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.KeyAdapter; +import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Cursor; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.FontData; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.DirectoryDialog; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; + import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.ListenerList; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.SubMonitor; -import org.eclipse.debug.internal.ui.SWTFactory; -import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin; -import org.eclipse.jdt.internal.launching.MacInstalledJREs; -import org.eclipse.jdt.launching.AbstractVMInstall; -import org.eclipse.jdt.launching.AbstractVMInstallType; -import org.eclipse.jdt.launching.IVMInstall; -import org.eclipse.jdt.launching.IVMInstallChangedListener; -import org.eclipse.jdt.launching.IVMInstallType; -import org.eclipse.jdt.launching.JavaRuntime; -import org.eclipse.jdt.launching.PropertyChangeEvent; -import org.eclipse.jdt.launching.VMStandin; -import org.eclipse.jdt.ui.ISharedImages; -import org.eclipse.jdt.ui.JavaUI; + import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.dialogs.MessageDialog; @@ -64,28 +76,23 @@ import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerComparator; import org.eclipse.jface.window.Window; import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.KeyAdapter; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Cursor; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.FontData; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.DirectoryDialog; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; + +import org.eclipse.debug.internal.ui.SWTFactory; + +import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin; +import org.eclipse.jdt.internal.launching.MacInstalledJREs; + +import org.eclipse.jdt.launching.AbstractVMInstall; +import org.eclipse.jdt.launching.AbstractVMInstallType; +import org.eclipse.jdt.launching.IVMInstall; +import org.eclipse.jdt.launching.IVMInstallChangedListener; +import org.eclipse.jdt.launching.IVMInstallType; +import org.eclipse.jdt.launching.JavaRuntime; +import org.eclipse.jdt.launching.PropertyChangeEvent; +import org.eclipse.jdt.launching.VMStandin; + +import org.eclipse.jdt.ui.ISharedImages; +import org.eclipse.jdt.ui.JavaUI; /** * A composite that displays installed JRE's in a table. JREs can be @@ -209,6 +216,8 @@ public class InstalledJREsBlock implements IAddVMDialogRequestor, ISelectionProv */ public static final String MACOSX_VM_TYPE_ID = "org.eclipse.jdt.internal.launching.macosx.MacOSXType"; //$NON-NLS-1$ + private String fVMListTimeStamp; + /** * Content provider to show a list of JREs */ @@ -1142,6 +1151,13 @@ public class InstalledJREsBlock implements IAddVMDialogRequestor, ISelectionProv } /** + * Initializes time stamp with current JRE page details + */ + void initializeTimeStamp() { + fVMListTimeStamp = getEncodedVMInstalls(); + } + + /** * Disposes the block and any listeners * * @since 3.6.300 @@ -1149,5 +1165,51 @@ public class InstalledJREsBlock implements IAddVMDialogRequestor, ISelectionProv public void dispose() { JavaRuntime.removeVMInstallChangedListener(fListener); } - + + + private StringBuffer appendVMAttributes(IVMInstall vmInstall, StringBuffer buf) { + if (vmInstall != null) { + String str = vmInstall.getName(); + buf.append('[').append(str.length()).append(']').append(str); + str = vmInstall.getVMInstallType().getName(); + buf.append('[').append(str.length()).append(']').append(str); + if (vmInstall.getVMArguments() != null) { + str = vmInstall.getVMArguments().toString(); + buf.append('[').append(str.length()).append(']').append(str); + } + str = vmInstall.getInstallLocation().getAbsolutePath(); + buf.append('[').append(str.length()).append(']').append(str).append(';'); + ; + } else { + buf.append('[').append(']').append(';'); + } + return buf; + } + + private String getEncodedVMInstalls() { + StringBuffer buf = new StringBuffer(); + IVMInstall vmInstall = getCheckedJRE(); + + int nElements = fVMs.size(); + buf.append('[').append(nElements).append(']'); + for (int i = 0; i < nElements; i++) { + IVMInstall elem = fVMs.get(i); + if (elem == vmInstall) + { + buf.append('[').append("defaultVM").append(']'); //$NON-NLS-1$ + } + appendVMAttributes(elem, buf); + } + return buf.toString(); + } + + /** + * Checks if JRE block has changed. + * + * @return <code>true</code> if JRE block has changed, <code>false</code> otherwise + */ + public boolean hasChangesInDialog() { + String currSettings = getEncodedVMInstalls(); + return !currSettings.equals(fVMListTimeStamp); + } } diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/JREMessages.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/JREMessages.java index 224f7e0fc..8d3071b06 100644 --- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/JREMessages.java +++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/JREMessages.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2013 IBM Corporation and others. + * Copyright (c) 2000, 2014 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -74,6 +74,11 @@ public class JREMessages extends NLS { public static String JREsPreferencePage_13; public static String JREsPreferencePage_3; + public static String JREsPreferencePage_4; + public static String JREsPreferencePage_5; + public static String JREsPreferencePage_6; + public static String JREsPreferencePage_7; + public static String JREsPreferencePage_8; public static String addVMDialog_duplicateName; public static String addVMDialog_enterLocation; diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/JREMessages.properties b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/JREMessages.properties index dc4985f5a..00937e8fb 100644 --- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/JREMessages.properties +++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/JREMessages.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2000, 2013 IBM Corporation and others. +# Copyright (c) 2000, 2014 IBM Corporation and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at @@ -69,6 +69,11 @@ JREsPreferencePage_10=Installed JRE location no longer exists. JRE will be remo JREsPreferencePage_13=You must select a default JRE for the workspace JREsPreferencePage_14=Conflicting compliance settings can be changed on the <a>Compiler</a> page. JREsPreferencePage_3=You must provide at least one JRE to act as the workspace default +JREsPreferencePage_4=Setting Installed JREs +JREsPreferencePage_5=This page contains unsaved modifications. Do you want to apply the changes so that other related pages can be updated? +JREsPreferencePage_6=Apply +JREsPreferencePage_7=Discard +JREsPreferencePage_8=Apply Later addVMDialog_duplicateName=The JRE name is already in use. addVMDialog_enterLocation=Enter the home directory of the JRE. diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/JREsPreferencePage.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/JREsPreferencePage.java index 9c4f474c7..882680ccd 100644 --- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/JREsPreferencePage.java +++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/JREsPreferencePage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2013 IBM Corporation and others. + * Copyright (c) 2000, 2014 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -31,6 +31,7 @@ import org.eclipse.jdt.launching.LibraryLocation; import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.dialogs.IMessageProvider; +import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.preference.PreferencePage; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.SelectionChangedEvent; @@ -104,7 +105,7 @@ public class JREsPreferencePage extends PreferencePage implements IWorkbenchPref protected Control createContents(Composite ancestor) { initializeDialogUnits(ancestor); - noDefaultAndApplyButton(); + noDefaultButton(); GridLayout layout= new GridLayout(); layout.numColumns= 1; @@ -134,6 +135,7 @@ public class JREsPreferencePage extends PreferencePage implements IWorkbenchPref }); PlatformUI.getWorkbench().getHelpSystem().setHelp(ancestor, IJavaDebugHelpContextIds.JRE_PREFERENCE_PAGE); initDefaultVM(); + fJREBlock.initializeTimeStamp(); fJREBlock.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { IVMInstall install = getCurrentDefaultVM(); @@ -257,6 +259,7 @@ public class JREsPreferencePage extends PreferencePage implements IWorkbenchPref // save column widths IDialogSettings settings = JDIDebugUIPlugin.getDefault().getDialogSettings(); fJREBlock.saveColumnSettings(settings, IJavaDebugHelpContextIds.JRE_PREFERENCE_PAGE); + fJREBlock.initializeTimeStamp(); return super.performOk(); } @@ -312,4 +315,30 @@ public class JREsPreferencePage extends PreferencePage implements IWorkbenchPref super.dispose(); fJREBlock.dispose(); } + + /* + * @see org.eclipse.jface.preference.PreferencePage#okToLeave() + */ + @Override + public boolean okToLeave() { + if (fJREBlock != null && fJREBlock.hasChangesInDialog()) { + String title = JREMessages.JREsPreferencePage_4; + String message = JREMessages.JREsPreferencePage_5; + String[] buttonLabels = new String[] { JREMessages.JREsPreferencePage_6, JREMessages.JREsPreferencePage_7, + JREMessages.JREsPreferencePage_8 }; + MessageDialog dialog = new MessageDialog(getShell(), title, null, message, MessageDialog.QUESTION, buttonLabels, 0); + int res = dialog.open(); + if (res == 0) { // apply + return performOk() && super.okToLeave(); + } else if (res == 1) { // discard + fJREBlock.fillWithWorkspaceJREs(); + fJREBlock.restoreColumnSettings(JDIDebugUIPlugin.getDefault().getDialogSettings(), IJavaDebugHelpContextIds.JRE_PREFERENCE_PAGE); + initDefaultVM(); + fJREBlock.initializeTimeStamp(); + } else { + // apply later + } + } + return super.okToLeave(); + } } |
