001: /*
002: * uDig - User Friendly Desktop Internet GIS client
003: * http://udig.refractions.net
004: * (C) 2004, Refractions Research Inc.
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation;
009: * version 2.1 of the License.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: */
017: package net.refractions.udig.tool.info.internal.display;
018:
019: import java.io.IOException;
020:
021: import net.refractions.udig.tool.info.InfoDisplay;
022: import net.refractions.udig.tool.info.LayerPointInfo;
023:
024: import org.eclipse.swt.SWT;
025: import org.eclipse.swt.widgets.Composite;
026: import org.eclipse.swt.widgets.Control;
027: import org.eclipse.swt.widgets.Text;
028:
029: /**
030: * Nested browser used to display LayerPointInfo.
031: *
032: * @author Jody Garnett
033: * @since 0.3
034: */
035: public class TextInfoDisplay extends InfoDisplay {
036:
037: /** <code>text</code> field */
038: protected Text text;
039:
040: //private Text location;
041: //private ViewForm viewForm;
042:
043: /**
044: * Nested viewForm containing text, and locationbar
045: * @return Control maintained by this display
046: */
047: public Control getControl() {
048: return text; //viewForm;
049: }
050:
051: public void createDisplay(Composite parent) {
052: /*
053: viewForm= new ViewForm( parent, SWT.NONE);
054: GridLayout gridLayout = new GridLayout();
055: gridLayout.numColumns = 2;
056: viewForm.setLayout(gridLayout);
057:
058: Label labelAddress = new Label(viewForm, SWT.NONE);
059: labelAddress.setText("A&ddress");
060:
061: location = new Text(viewForm, SWT.BORDER);
062: GridData data = new GridData();
063: data = new GridData();
064: data.horizontalAlignment = GridData.FILL;
065: data.grabExcessHorizontalSpace = true;
066: location.setLayoutData(data);
067: */
068: text = new Text(parent, SWT.NONE);
069: /*
070: data = new GridData();
071: data.horizontalAlignment = GridData.FILL;
072: data.verticalAlignment = GridData.FILL;
073: data.horizontalSpan = 2;
074: data.grabExcessHorizontalSpace = true;
075: data.grabExcessVerticalSpace = true;
076: text.setLayoutData(data);
077: */
078: }
079:
080: public void setInfo(LayerPointInfo info) {
081: if (info == null) {
082: text.setText(""); //$NON-NLS-1$
083: //location.setText( "..." );
084: } else {
085: try {
086: text.setText(info.acquireValue().toString());
087: } catch (IOException e) {
088: text.setText(e.getLocalizedMessage());
089: }
090: if (info.getRequestURL() != null) {
091: String req = info.getRequestURL().toString();
092: text.setToolTipText(req);
093: } else {
094: //location.setText( info.getMimeType() +":" );
095: text.setToolTipText(info.getMimeType());
096: }
097: }
098: }
099:
100: }
|