|
Added
Link Here
|
| 1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2010 IBM Corporation 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 |
| 7 |
* |
| 8 |
* Contributors: |
| 9 |
* IBM Corporation - initial API and implementation |
| 10 |
*******************************************************************************/ |
| 11 |
package org.eclipse.debug.internal.ui.views.variables.details; |
| 12 |
|
| 13 |
import org.eclipse.debug.internal.ui.SWTFactory; |
| 14 |
import org.eclipse.debug.ui.IDebugUIConstants; |
| 15 |
import org.eclipse.debug.ui.IDetailPane; |
| 16 |
import org.eclipse.jface.viewers.IStructuredSelection; |
| 17 |
import org.eclipse.swt.SWT; |
| 18 |
import org.eclipse.swt.custom.SashForm; |
| 19 |
import org.eclipse.swt.layout.GridData; |
| 20 |
import org.eclipse.swt.layout.GridLayout; |
| 21 |
import org.eclipse.swt.widgets.Composite; |
| 22 |
import org.eclipse.swt.widgets.Control; |
| 23 |
import org.eclipse.swt.widgets.Label; |
| 24 |
import org.eclipse.ui.IWorkbenchPartSite; |
| 25 |
|
| 26 |
/** |
| 27 |
* A detail pane that displays a message in a wrapped label. Not contributed by an extension |
| 28 |
* point - used internally to display messages. |
| 29 |
* |
| 30 |
* @since 3.6 |
| 31 |
*/ |
| 32 |
public class MessageDetailPane implements IDetailPane { |
| 33 |
|
| 34 |
public static final String ID = IDebugUIConstants.PLUGIN_ID + ".detailpanes.message"; //$NON-NLS-1$ |
| 35 |
public static final String NAME = DetailMessages.MessageDetailPane_0; |
| 36 |
public static final String DESCRIPTION = DetailMessages.MessageDetailPane_1; |
| 37 |
|
| 38 |
private SashForm fSash; |
| 39 |
/** |
| 40 |
* Top level composite that remains as orientation changes. |
| 41 |
*/ |
| 42 |
private Composite fDetailsContainer; |
| 43 |
/** |
| 44 |
* Inner composite containing separator and editor composite that gets |
| 45 |
* disposed/created as orientation changes with *no* margins (so separator |
| 46 |
* spans entire width/height of the pane). |
| 47 |
*/ |
| 48 |
private Composite fSeparatorContainer; |
| 49 |
/** |
| 50 |
* Cached orientation currently being displayed |
| 51 |
*/ |
| 52 |
private int fOrientation = -1; |
| 53 |
/** |
| 54 |
* Composite that contains the editor that has margins. |
| 55 |
*/ |
| 56 |
private Composite fControlParent; |
| 57 |
|
| 58 |
/** |
| 59 |
* Label control |
| 60 |
*/ |
| 61 |
private Label fLabel; |
| 62 |
|
| 63 |
/* (non-Javadoc) |
| 64 |
* @see org.eclipse.debug.ui.IDetailPane#init(org.eclipse.ui.IWorkbenchPartSite) |
| 65 |
*/ |
| 66 |
public void init(IWorkbenchPartSite partSite) { |
| 67 |
} |
| 68 |
|
| 69 |
/* (non-Javadoc) |
| 70 |
* @see org.eclipse.debug.ui.IDetailPane#dispose() |
| 71 |
*/ |
| 72 |
public void dispose() { |
| 73 |
fSash = null; |
| 74 |
fDetailsContainer.dispose(); |
| 75 |
} |
| 76 |
|
| 77 |
/* (non-Javadoc) |
| 78 |
* @see org.eclipse.debug.ui.IDetailPane#createControl(org.eclipse.swt.widgets.Composite) |
| 79 |
*/ |
| 80 |
public Control createControl(Composite parent) { |
| 81 |
fDetailsContainer = SWTFactory.createComposite(parent, parent.getFont(), 1, 1, GridData.FILL_BOTH, 0, 0); |
| 82 |
if (parent instanceof SashForm) { |
| 83 |
fSash = (SashForm) parent; |
| 84 |
} |
| 85 |
createDetails(); |
| 86 |
return fDetailsContainer; |
| 87 |
} |
| 88 |
|
| 89 |
/** |
| 90 |
* Creates the details area with a separator based on orientation. |
| 91 |
*/ |
| 92 |
protected void createDetails() { |
| 93 |
int parentOrientation = SWT.HORIZONTAL; |
| 94 |
if (fSash != null) { |
| 95 |
parentOrientation = fSash.getOrientation(); |
| 96 |
} |
| 97 |
String message = ""; //$NON-NLS-1$ |
| 98 |
if (fLabel != null) { |
| 99 |
message = fLabel.getText(); |
| 100 |
} |
| 101 |
if (parentOrientation == fOrientation) { |
| 102 |
return; |
| 103 |
} |
| 104 |
if (fSeparatorContainer != null) { |
| 105 |
fSeparatorContainer.dispose(); |
| 106 |
} |
| 107 |
if (parentOrientation == SWT.VERTICAL) { |
| 108 |
fSeparatorContainer = SWTFactory.createComposite(fDetailsContainer, fDetailsContainer.getFont(), 1, 1, GridData.FILL_BOTH, 0, 0); |
| 109 |
Label sep = new Label(fSeparatorContainer, SWT.SEPARATOR | SWT.HORIZONTAL); |
| 110 |
sep.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); |
| 111 |
GridLayout layout= (GridLayout)fSeparatorContainer.getLayout(); |
| 112 |
layout.marginHeight= 0; |
| 113 |
layout.marginWidth= 0; |
| 114 |
fControlParent = SWTFactory.createComposite(fSeparatorContainer, 1, 1, GridData.FILL_BOTH); |
| 115 |
} else { |
| 116 |
fSeparatorContainer = SWTFactory.createComposite(fDetailsContainer, fDetailsContainer.getFont(), 2, 1, GridData.FILL_BOTH, 0, 0); |
| 117 |
Label sep= new Label(fSeparatorContainer, SWT.SEPARATOR | SWT.VERTICAL); |
| 118 |
sep.setLayoutData(new GridData(SWT.TOP, SWT.FILL, false, true)); |
| 119 |
GridLayout layout= (GridLayout)fSeparatorContainer.getLayout(); |
| 120 |
layout.marginHeight= 0; |
| 121 |
layout.marginWidth= 0; |
| 122 |
fControlParent = SWTFactory.createComposite(fSeparatorContainer, 1, 1, GridData.FILL_BOTH); |
| 123 |
} |
| 124 |
fOrientation = parentOrientation; |
| 125 |
fLabel = SWTFactory.createWrapLabel(fControlParent, message, 1); |
| 126 |
fDetailsContainer.layout(true); |
| 127 |
} |
| 128 |
|
| 129 |
/* (non-Javadoc) |
| 130 |
* @see org.eclipse.debug.ui.IDetailPane#setFocus() |
| 131 |
*/ |
| 132 |
public boolean setFocus() { |
| 133 |
return false; |
| 134 |
} |
| 135 |
|
| 136 |
/* (non-Javadoc) |
| 137 |
* @see org.eclipse.debug.ui.IDetailPane#display(org.eclipse.jface.viewers.IStructuredSelection) |
| 138 |
*/ |
| 139 |
public void display(IStructuredSelection selection) { |
| 140 |
// re-create controls if the layout has changed |
| 141 |
if (selection != null && selection.size() == 1) { |
| 142 |
Object input = selection.getFirstElement(); |
| 143 |
if (input instanceof String) { |
| 144 |
createDetails(); |
| 145 |
String message = (String) input; |
| 146 |
fLabel.setText(message); |
| 147 |
fDetailsContainer.layout(true); |
| 148 |
} |
| 149 |
} |
| 150 |
} |
| 151 |
|
| 152 |
/* (non-Javadoc) |
| 153 |
* @see org.eclipse.debug.ui.IDetailPane#getID() |
| 154 |
*/ |
| 155 |
public String getID() { |
| 156 |
return ID; |
| 157 |
} |
| 158 |
|
| 159 |
/* (non-Javadoc) |
| 160 |
* @see org.eclipse.debug.ui.IDetailPane#getName() |
| 161 |
*/ |
| 162 |
public String getName() { |
| 163 |
return NAME; |
| 164 |
} |
| 165 |
|
| 166 |
/* (non-Javadoc) |
| 167 |
* @see org.eclipse.debug.ui.IDetailPane#getDescription() |
| 168 |
*/ |
| 169 |
public String getDescription() { |
| 170 |
return DESCRIPTION; |
| 171 |
} |
| 172 |
|
| 173 |
} |