+++ /dev/null
-/*******************************************************************************\r
- * Copyright (c) 2007- VTT Technical Research Centre of Finland.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- * VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.proconf.g3d.shapeeditor.dialogs;\r
-\r
-import java.util.List;\r
-\r
-import org.eclipse.jface.dialogs.Dialog;\r
-import org.eclipse.jface.dialogs.IDialogConstants;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.layout.GridData;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.swt.widgets.Control;\r
-import org.eclipse.swt.widgets.Label;\r
-import org.eclipse.swt.widgets.Shell;\r
-import org.eclipse.swt.widgets.Tree;\r
-import org.eclipse.swt.widgets.TreeItem;\r
-import org.simantics.db.Graph;\r
-import org.simantics.db.GraphRequestAdapter;\r
-import org.simantics.db.GraphRequestStatus;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.Session;\r
-import org.simantics.proconf.g3d.tools.PropertyTree;\r
-\r
-public class PropertySelectionDialog extends Dialog {\r
- String title = null;\r
- String message = null;\r
- \r
- Session session;\r
- PropertyTree propertyTree;\r
- Resource[] selectedTypes = null;\r
- List<Resource> selectedPropertyInstances = null;\r
- List<Resource> selectedInstances = null;\r
- \r
- public PropertySelectionDialog(Shell parentShell, String dialogTitle, String dialogMessage, Session session, List<Resource> selectedResources) {\r
- super(parentShell);\r
- this.session = session;\r
- this.title = dialogTitle;\r
- this.message = dialogMessage;\r
- this.selectedInstances = selectedResources;\r
- }\r
- \r
- @Override\r
- protected void configureShell(Shell newShell) {\r
- \r
- super.configureShell(newShell);\r
- if (title != null)\r
- newShell.setText(title);\r
- }\r
- \r
- protected Control createDialogArea(Composite parent) {\r
- Composite composite = (Composite) super.createDialogArea(parent);\r
- \r
- Label label = new Label(composite, SWT.WRAP);\r
- label.setText(message);\r
- GridData data = new GridData(GridData.GRAB_HORIZONTAL\r
- | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL\r
- | GridData.VERTICAL_ALIGN_CENTER);\r
- data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);\r
- label.setLayoutData(data);\r
- label.setFont(parent.getFont());\r
- \r
- Tree tree = new Tree(composite,SWT.SINGLE);\r
- propertyTree = new PropertyTree(tree,session);\r
-\r
- GridData data2 = new GridData(GridData.GRAB_HORIZONTAL\r
- | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL\r
- | GridData.VERTICAL_ALIGN_FILL);\r
- data2.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);\r
- data2.heightHint = 200;\r
- tree.setLayoutData(data2);\r
- tree.setFont(parent.getFont());\r
- \r
- tree.showSelection();\r
- \r
- applyDialogFont(composite);\r
- \r
- //propertyTree.setProperties(selectionAdapter.getCurrentSelection());\r
- propertyTree.setProperties(selectedInstances);\r
- return composite;\r
- }\r
- \r
- @Override\r
- public boolean close() {\r
- TreeItem selected[] = propertyTree.getTree().getSelection();\r
- if (selected.length == 0) {\r
- selectedTypes = null;\r
- } else {\r
- selectedTypes = new Resource[selected.length];\r
- for (int i = 0; i < selected.length; i++) {\r
- selectedTypes[i] = (Resource)selected[i].getData();\r
- }\r
- }\r
- //final ArrayList<Resource> instances = new ArrayList<Resource>();\r
-// for (Resource rs : selectionAdapter.getCurrentSelection().getSelectionList()) {\r
-// instances.add(rs);\r
-// }\r
-\r
- \r
- session.syncRead(new GraphRequestAdapter() {\r
- @Override\r
- public GraphRequestStatus perform(Graph g) throws Exception {\r
- selectedPropertyInstances = propertyTree.findPropertyInstances(g,selectedInstances);\r
- return GraphRequestStatus.transactionComplete();\r
- }\r
- });\r
-\r
- return super.close();\r
- }\r
- \r
- public List<Resource> getSelectedPropertyInstances() {\r
- return selectedPropertyInstances;\r
- }\r
-\r
-}
\ No newline at end of file