| /******************************************************************************* |
| * Copyright (c) 2009 Zoltan Ujhelyi and Daniel Varro. |
| * 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: |
| * Zoltan Ujhelyi - initial API and implementation |
| *******************************************************************************/ |
| package org.eclipse.viatra2.visualisation.patterns.properties; |
| |
| import org.eclipse.jface.viewers.ISelection; |
| import org.eclipse.jface.viewers.IStructuredSelection; |
| import org.eclipse.swt.SWT; |
| import org.eclipse.swt.custom.CLabel; |
| import org.eclipse.swt.layout.FormAttachment; |
| import org.eclipse.swt.layout.FormData; |
| import org.eclipse.swt.widgets.Composite; |
| import org.eclipse.swt.widgets.Text; |
| import org.eclipse.ui.IWorkbenchPart; |
| import org.eclipse.ui.forms.widgets.ColumnLayout; |
| import org.eclipse.ui.views.properties.tabbed.AbstractPropertySection; |
| import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants; |
| import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage; |
| import org.eclipse.viatra2.visualisation.patterns.viewmodel.AbstractViewModelElement; |
| |
| /** |
| * @author Zoltan Ujhelyi |
| * |
| */ |
| public class TypePropertySection extends AbstractPropertySection { |
| |
| AbstractViewModelElement element; |
| Text type; |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#createControls(org.eclipse.swt.widgets.Composite, org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage) |
| */ |
| @Override |
| public void createControls(Composite parent, |
| TabbedPropertySheetPage aTabbedPropertySheetPage) { |
| super.createControls(parent, aTabbedPropertySheetPage); |
| super.createControls(parent, aTabbedPropertySheetPage); |
| parent.setLayout(new ColumnLayout()); |
| Composite nameComposite = getWidgetFactory().createFlatFormComposite( |
| parent); |
| FormData data; |
| type = getWidgetFactory().createText(nameComposite, ""); |
| type.setEditable(false); |
| data = new FormData(); |
| data.left = new FormAttachment(0, STANDARD_LABEL_WIDTH); |
| data.right = new FormAttachment(100, 0); |
| data.top = new FormAttachment(0, ITabbedPropertyConstants.VSPACE); |
| type.setLayoutData(data); |
| CLabel label = getWidgetFactory().createCLabel(nameComposite, |
| "Graph Element Type:"); |
| data = new FormData(); |
| data.left = new FormAttachment(0, 0); |
| data.right = new FormAttachment(type, -ITabbedPropertyConstants.HSPACE); |
| data.top = new FormAttachment(type, 0, SWT.CENTER); |
| label.setLayoutData(data); |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#refresh() |
| */ |
| @Override |
| public void refresh() { |
| super.refresh(); |
| type.setText(element.getTypeString()); |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#setInput(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) |
| */ |
| @Override |
| public void setInput(IWorkbenchPart part, ISelection selection) { |
| super.setInput(part, selection); |
| Object input = ((IStructuredSelection) selection).getFirstElement(); |
| element = (AbstractViewModelElement) input; |
| } |
| |
| } |