1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 08:55:25 +02:00

Bug 360314: Improve diagnostics of invalid selections in OS Resources view.

Change-Id: I1a43dbf5bd58cbaaf05a21f9b3936fa7303faa37
Reviewed-on: https://git.eclipse.org/r/8685
Reviewed-by: Marc Khouzam <marc.khouzam@ericsson.com>
IP-Clean: Marc Khouzam <marc.khouzam@ericsson.com>
Tested-by: Marc Khouzam <marc.khouzam@ericsson.com>
This commit is contained in:
Vladimir Prus 2012-11-14 16:29:01 +04:00 committed by Marc Khouzam
parent 5c57467a36
commit 9194376ff4
3 changed files with 47 additions and 18 deletions

View file

@ -29,6 +29,7 @@ public class Messages extends NLS {
public static String OSView_12;
public static String OSView_13;
public static String OSView_14;
public static String OSView_15;
static {
// initialize resource bundle
NLS.initializeMessages(Messages.class.getName(), Messages.class);

View file

@ -9,7 +9,7 @@
# Vladimir Prus (Mentor Graphics) - initial API and implementation
###############################################################################
OSView_3=Refresh
OSView_4=Invalid debug session selected.
OSView_4=Invalid debug object selected. Please select a process, thread or frame inside DSF GDB debug session.
OSView_5=Please select resource class.
OSView_6=Fetching data...
OSView_7=No data has been fetched yet. <a href="{0}">Fetch now</a>.
@ -20,3 +20,4 @@ OSView_11=Determining available OS resource classes...
OSView_12=No data has been fetched yet. Target is busy.
OSView_13=Waiting for the debug session to initialize.
OSView_14=Objects from different debug sessions are selected.
OSView_15=No debug session is selected.

View file

@ -82,6 +82,8 @@ public class OSResourcesView extends ViewPart implements DsfSession.SessionEnded
// Indicates that we've selected objects from different debug sessions.
boolean fMultiple = false;
// Indicates that we have selected object with a wrong type
boolean fWrongType = false;
// UI objects
@ -225,14 +227,20 @@ public class OSResourcesView extends ViewPart implements DsfSession.SessionEnded
ICommandControlDMContext context = null;
fMultiple = false;
fWrongType = false;
if (s instanceof IStructuredSelection) {
IStructuredSelection ss = (IStructuredSelection) s;
if (ss.size() > 0) {
@SuppressWarnings("rawtypes")
Iterator i = ss.iterator();
context = getCommandControlContext(i.next());
if (context == null)
fWrongType = true;
while (i.hasNext()) {
ICommandControlDMContext nextContext = getCommandControlContext(i.next());
ICommandControlDMContext nextContext = getCommandControlContext(i.next());
if (nextContext == null)
fWrongType = true;
if (nextContext == null && context != null
|| nextContext != null && context == null
|| nextContext != null && context != null && !nextContext.equals(context))
@ -300,18 +308,13 @@ public class OSResourcesView extends ViewPart implements DsfSession.SessionEnded
public void update() {
// Note that fSessionData always calls the listener in
// UI thread, so we can directly call 'update' here.
OSResourcesView.this.update();
OSResourcesView.this.updateSessionDataContents();
}
}, fViewer.getControl());
}
}
if (newSessionData != fSessionData)
{
fSessionData = newSessionData;
update();
}
update(newSessionData);
}
@Override
@ -323,7 +326,39 @@ public class OSResourcesView extends ViewPart implements DsfSession.SessionEnded
}
}
private void update() {
// Update UI to showing new session data. If this session data is already
// shown, does nothing.
private void update(SessionOSData newSessionData)
{
if (fViewer == null || fViewer.getControl() == null)
return;
if (fViewer.getControl().isDisposed())
return;
if (newSessionData == null)
{
fSessionData = null;
if (fMultiple)
hideTable(Messages.OSView_14);
else if (fWrongType)
hideTable(Messages.OSView_4);
else
hideTable(Messages.OSView_15);
fResourceClassEditor.setEnabled(false);
fRefreshAction.setEnabled(false);
return;
}
if (newSessionData != fSessionData) {
fSessionData = newSessionData;
updateSessionDataContents();
}
}
// Update the UI according to actual content of fSessionData,
// which must be not null.
private void updateSessionDataContents() {
if (fViewer == null || fViewer.getControl() == null)
return;
@ -331,14 +366,6 @@ public class OSResourcesView extends ViewPart implements DsfSession.SessionEnded
if (fViewer.getControl().isDisposed())
return;
if (fSessionData == null)
{
hideTable(fMultiple ? Messages.OSView_14 : Messages.OSView_4);
fResourceClassEditor.setEnabled(false);
fRefreshAction.setEnabled(false);
return;
}
boolean enable = fSessionData.canFetchData();
fRefreshAction.setEnabled(enable);
fResourceClass = fResourceClassEditor.updateClasses(fSessionData.getResourceClasses());