01: /*******************************************************************************
02: * Copyright (c) 2004, 2005 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.examples.components.views.comparisons;
11:
12: import org.eclipse.core.runtime.IStatus;
13: import org.eclipse.swt.SWT;
14: import org.eclipse.swt.events.SelectionAdapter;
15: import org.eclipse.swt.events.SelectionEvent;
16: import org.eclipse.swt.widgets.Button;
17: import org.eclipse.swt.widgets.Composite;
18: import org.eclipse.ui.internal.part.components.services.IUserMessages;
19:
20: /**
21: * Demonstrates how to use component dependencies in a new-style part.
22: *
23: * @since 3.1
24: */
25: public class DependenciesViewNew {
26: // Dependencies
27: private IUserMessages dialogs;
28:
29: /**
30: * Component constructor. Do not invoke directly.
31: */
32: public DependenciesViewNew(Composite parent, IUserMessages dialogs) {
33: this .dialogs = dialogs;
34:
35: Button testButton = new Button(parent, SWT.PUSH);
36: testButton.setText("Open a dialog");
37: testButton.addSelectionListener(new SelectionAdapter() {
38: /* (non-Javadoc)
39: * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
40: */
41: public void widgetSelected(SelectionEvent e) {
42: openADialog();
43: }
44: });
45: }
46:
47: private void openADialog() {
48: dialogs.show(IStatus.INFO, "This is a message");
49: }
50: }
|