|
| 1 | +/******************************************************************************* |
| 2 | + * Copyright (c) 2010 - 2013 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 | + * Lars Vogel <lars.Vogel@gmail.com> - Bug 419770 |
| 11 | + *******************************************************************************/ |
| 12 | +package wizardtranslation.parts; |
| 13 | + |
| 14 | +import javax.annotation.PostConstruct; |
| 15 | +import javax.inject.Inject; |
| 16 | + |
| 17 | +import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
| 18 | +import org.eclipse.e4.ui.workbench.IPresentationEngine; |
| 19 | +import org.eclipse.jface.wizard.WizardDialog; |
| 20 | +import org.eclipse.swt.SWT; |
| 21 | +import org.eclipse.swt.events.SelectionAdapter; |
| 22 | +import org.eclipse.swt.events.SelectionEvent; |
| 23 | +import org.eclipse.swt.layout.GridData; |
| 24 | +import org.eclipse.swt.layout.GridLayout; |
| 25 | +import org.eclipse.swt.widgets.Button; |
| 26 | +import org.eclipse.swt.widgets.Composite; |
| 27 | +import org.eclipse.swt.widgets.Shell; |
| 28 | + |
| 29 | +import wizardtranslation.wizard.SampleWizard; |
| 30 | + |
| 31 | +public class SharedPart { |
| 32 | + |
| 33 | + @Inject |
| 34 | + private Shell shell; |
| 35 | + |
| 36 | + @Inject |
| 37 | + private MPart part; |
| 38 | + |
| 39 | + @PostConstruct |
| 40 | + public void createComposite(Composite parent) { |
| 41 | + parent.setLayout(new GridLayout(1, false)); |
| 42 | + |
| 43 | + Button button = new Button(parent, SWT.PUSH); |
| 44 | + button.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, |
| 45 | + false)); |
| 46 | + button.setText("Shared"); |
| 47 | + button.addSelectionListener(new SelectionAdapter() { |
| 48 | + @Override |
| 49 | + public void widgetSelected(SelectionEvent e) { |
| 50 | + part.getCurSharedRef().getTags().add(IPresentationEngine.NO_CLOSE); |
| 51 | + part.getTags().add(IPresentationEngine.NO_CLOSE); |
| 52 | + WizardDialog wizardDialog = new WizardDialog(shell, |
| 53 | + new SampleWizard()); |
| 54 | + wizardDialog.open(); |
| 55 | + } |
| 56 | + }); |
| 57 | + |
| 58 | + } |
| 59 | +} |
0 commit comments