| /****************************************************************************** |
| * Copyright (c) David Orme and others |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * David Orme - initial API and implementation |
| ******************************************************************************/ |
| package org.eclipse.e4.core.metaconfig.example.rcp; |
| |
| import org.eclipse.e4.core.metaconfig.Configuration; |
| import org.eclipse.e4.core.metaconfig.example.Activator; |
| import org.eclipse.swt.SWT; |
| import org.eclipse.swt.events.SelectionAdapter; |
| import org.eclipse.swt.events.SelectionEvent; |
| import org.eclipse.swt.layout.GridData; |
| import org.eclipse.swt.layout.GridLayout; |
| import org.eclipse.swt.widgets.Button; |
| import org.eclipse.swt.widgets.Composite; |
| import org.eclipse.swt.widgets.Text; |
| import org.eclipse.ui.part.ViewPart; |
| |
| |
| public class View extends ViewPart { |
| public static final String ID = "org.eclipse.e4.enterprise.config.integration.view"; |
| |
| /** |
| * This is a callback that will allow us to create the viewer and initialize |
| * it. |
| */ |
| public void createPartControl(Composite parent) { |
| parent.setLayout(new GridLayout(1, false)); |
| Button button = new Button(parent, SWT.PUSH); |
| button.setText("Get config"); |
| final Text text = new Text(parent, SWT.BORDER | SWT.WRAP | SWT.MULTI | SWT.V_SCROLL); |
| text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); |
| |
| text.setText("Please read the \"readme\" file contained in this bundle " + |
| "[/org.eclipse.e4.enterprise.utils.config.example/README.txt]"); |
| |
| button.addSelectionListener(new SelectionAdapter() { |
| @Override |
| public void widgetSelected(SelectionEvent e) { |
| try { |
| Configuration configuration = Activator.getDefault().getConfiguration(); |
| String installLocation = configuration.installLocation(); |
| String userLocation = configuration.userLocation(); |
| String workspaceLocation = configuration.workspaceLocation(); |
| |
| String mssg = "Install Location: \t\t" + installLocation |
| + "\nUser location: \t\t\t" + userLocation |
| + "\nWorkspace Location: \t" + workspaceLocation; |
| |
| mssg += "\n\nAll the properties defined are: " + configuration.getProperties().toString(); |
| |
| text.setText(mssg); |
| } catch (Throwable t) { |
| t.printStackTrace(); |
| } |
| } |
| }); |
| } |
| |
| |
| /** |
| * Passing the focus request to the viewer's control. |
| */ |
| public void setFocus() { |
| } |
| } |