1
/*******************************************************************************
2
* Copyright (c) 2004, 2005 QNX Software Systems and others.
3
* All rights reserved. This program and the accompanying materials
4
* are made available under the terms of the Eclipse Public License v1.0
5
* which accompanies this distribution, and is available at
6
* http://www.eclipse.org/legal/epl-v10.html
9
* QNX Software Systems - Initial API and implementation
10
*******************************************************************************/
11
package org.eclipse.cdt.debug.internal.ui.propertypages;
13
import com.ibm.icu.text.MessageFormat;
14
import org.eclipse.cdt.debug.core.CDIDebugModel;
15
import org.eclipse.cdt.debug.core.CDebugUtils;
16
import org.eclipse.cdt.debug.core.model.ICSignal;
17
import org.eclipse.cdt.debug.internal.core.ICDebugInternalConstants;
18
import org.eclipse.cdt.debug.internal.ui.dialogfields.SelectionButtonDialogField;
19
import org.eclipse.core.runtime.IStatus;
20
import org.eclipse.core.runtime.MultiStatus;
21
import org.eclipse.core.runtime.Status;
22
import org.eclipse.debug.core.DebugException;
23
import org.eclipse.debug.core.DebugPlugin;
24
import org.eclipse.jface.dialogs.IDialogConstants;
25
import org.eclipse.swt.SWT;
26
import org.eclipse.swt.graphics.Font;
27
import org.eclipse.swt.layout.GridData;
28
import org.eclipse.swt.layout.GridLayout;
29
import org.eclipse.swt.widgets.Composite;
30
import org.eclipse.swt.widgets.Control;
31
import org.eclipse.swt.widgets.Label;
32
import org.eclipse.ui.dialogs.PropertyPage;
35
* The property page for a signal.
37
public class SignalPropertyPage extends PropertyPage {
39
private SelectionButtonDialogField fPassButton;
40
private SelectionButtonDialogField fStopButton;
43
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
45
protected Control createContents( Composite parent ) {
46
noDefaultAndApplyButton();
47
Composite composite = new Composite( parent, SWT.NONE );
48
Font font = parent.getFont();
49
composite.setFont( font );
50
composite.setLayout( new GridLayout() );
51
composite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
53
// Create description field
55
String description = getSignal().getDescription();
56
Label label = new Label( composite, SWT.WRAP );
57
label.setText( MessageFormat.format( PropertyPageMessages.getString( "SignalPropertyPage.0" ), new String[] { description } ) ); //$NON-NLS-1$
58
GridData data = new GridData( GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER );
59
data.widthHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH );
60
label.setLayoutData( data );
61
label.setFont( font );
63
catch( DebugException e1 ) {
68
boolean pass = getSignal().isPassEnabled();
69
fPassButton = new SelectionButtonDialogField( SWT.CHECK );
70
fPassButton.setLabelText( PropertyPageMessages.getString( "SignalPropertyPage.1" ) ); //$NON-NLS-1$
71
fPassButton.setSelection( pass );
72
fPassButton.setEnabled( getSignal().canModify() );
73
fPassButton.doFillIntoGrid( composite, 1 );
75
catch( DebugException e ) {
80
boolean stop = getSignal().isStopEnabled();
81
fStopButton = new SelectionButtonDialogField( SWT.CHECK );
82
fStopButton.setLabelText( PropertyPageMessages.getString( "SignalPropertyPage.2" ) ); //$NON-NLS-1$
83
fStopButton.setSelection( stop );
84
fStopButton.setEnabled( getSignal().canModify() );
85
fStopButton.doFillIntoGrid( composite, 1 );
87
catch( DebugException e ) {
94
protected SelectionButtonDialogField getPassButton() {
98
protected SelectionButtonDialogField getStopButton() {
102
public ICSignal getSignal() {
103
return (ICSignal)getElement();
107
* @see org.eclipse.jface.preference.IPreferencePage#performOk()
109
public boolean performOk() {
110
boolean result = super.performOk();
112
DebugPlugin.getDefault().asyncExec(
115
if ( !getSignal().canModify() )
117
if ( getPassButton() != null ) {
119
getSignal().setPassEnabled( getPassButton().isSelected() );
121
catch( DebugException e ) {
122
failed( PropertyPageMessages.getString( "SignalPropertyPage.5" ), e ); //$NON-NLS-1$
125
if ( getStopButton() != null ) {
127
getSignal().setStopEnabled( getStopButton().isSelected() );
129
catch( DebugException e ) {
130
failed( PropertyPageMessages.getString( "SignalPropertyPage.5" ), e ); //$NON-NLS-1$
139
protected void failed( String message, Throwable e ) {
140
MultiStatus ms = new MultiStatus( CDIDebugModel.getPluginIdentifier(), ICDebugInternalConstants.STATUS_CODE_ERROR, message, null );
141
ms.add( new Status( IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), ICDebugInternalConstants.STATUS_CODE_ERROR, e.getMessage(), null ) );
142
CDebugUtils.error( ms, getSignal() );