| 1 | package de.uka.ipd.sdq.sensorframework.visualisation.tabs.filters; |
| 2 | |
| 3 | import org.eclipse.jface.dialogs.IDialogConstants; |
| 4 | import org.eclipse.jface.dialogs.TitleAreaDialog; |
| 5 | import org.eclipse.swt.SWT; |
| 6 | import org.eclipse.swt.graphics.Point; |
| 7 | import org.eclipse.swt.layout.FormLayout; |
| 8 | import org.eclipse.swt.layout.GridData; |
| 9 | import org.eclipse.swt.widgets.Composite; |
| 10 | import org.eclipse.swt.widgets.Control; |
| 11 | import org.eclipse.swt.widgets.Shell; |
| 12 | |
| 13 | import de.uka.ipd.sdq.pcm.dialogs.parameters.CreateEditorContents; |
| 14 | import de.uka.ipd.sdq.sensorframework.filter.AbstractMeasurementsCollection; |
| 15 | |
| 16 | /** |
| 17 | * @author Roman Andrej |
| 18 | */ |
| 19 | public class ParametersDialog extends TitleAreaDialog { |
| 20 | |
| 21 | private AbstractMeasurementsCollection filter; |
| 22 | |
| 23 | /** |
| 24 | * Creates a dialog with the given parent and edited properties name |
| 25 | * |
| 26 | * @param parentShell |
| 27 | * -object that returns the current parent shell columnName - |
| 28 | * edited properties |
| 29 | */ |
| 30 | public ParametersDialog(Shell parentShell, AbstractMeasurementsCollection filter) { |
| 31 | super(parentShell); |
| 32 | this.filter = filter; |
| 33 | |
| 34 | /** |
| 35 | * the result of combining the constants which are required |
| 36 | * to produce a typical application top level shell |
| 37 | */ |
| 38 | setShellStyle(SWT.RESIZE|SWT.TITLE|SWT.CLOSE |SWT.MIN|SWT.MAX); |
| 39 | } |
| 40 | |
| 41 | /* (non-Javadoc) |
| 42 | * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) |
| 43 | */ |
| 44 | @Override |
| 45 | protected void configureShell(Shell newShell) { |
| 46 | super.configureShell(newShell); |
| 47 | newShell.setText("Filter parameters"); |
| 48 | } |
| 49 | |
| 50 | /* (non-Javadoc) |
| 51 | * @see org.eclipse.jface.dialogs.TitleAreaDialog#createDialogArea(org.eclipse.swt.widgets.Composite) |
| 52 | */ |
| 53 | @Override |
| 54 | protected Control createDialogArea(Composite parent) { |
| 55 | setTitle("Edit a Parameter..."); |
| 56 | |
| 57 | Composite area = (Composite) super.createDialogArea(parent); |
| 58 | Composite container = new Composite(area, SWT.NONE); |
| 59 | container.setLayout(new FormLayout()); |
| 60 | container.setLayoutData(new GridData(GridData.FILL_BOTH)); |
| 61 | |
| 62 | CreateEditorContents editorContents = CreateEditorContents |
| 63 | .create(container); |
| 64 | |
| 65 | // editorContents |
| 66 | // .setViewerContentProvider(new IStructuredContentProvider(){ |
| 67 | // |
| 68 | // /* (non-Javadoc) |
| 69 | // * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) |
| 70 | // */ |
| 71 | // public Object[] getElements(Object inputElement) { |
| 72 | // if (inputElement instanceof AbstractMeasurementsFilter) { |
| 73 | // AbstractMeasurementsFilter filter = (AbstractMeasurementsFilter) inputElement; |
| 74 | // return new Object[] { filter.getParameter() }; |
| 75 | // } |
| 76 | // return null; |
| 77 | // } |
| 78 | // |
| 79 | // /* (non-Javadoc) |
| 80 | // * @see org.eclipse.jface.viewers.IContentProvider#dispose() |
| 81 | // */ |
| 82 | // public void dispose() { |
| 83 | // // The implementation is not necessary. |
| 84 | // } |
| 85 | // |
| 86 | // /* (non-Javadoc) |
| 87 | // * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) |
| 88 | // */ |
| 89 | // public void inputChanged(Viewer viewer, Object oldInput, |
| 90 | // Object newInput) { |
| 91 | // // The implementation is not necessary. |
| 92 | // } |
| 93 | // }); |
| 94 | // editorContents |
| 95 | // .setViewerLabelProvider(new ParametersDialogLabelProvider( |
| 96 | // filter.getClass().getSimpleName())); |
| 97 | // editorContents.setViewerCellModifier(new ...); |
| 98 | // editorContents.setAddButtonActionListener(new AddParameterAction( |
| 99 | // signature)); |
| 100 | // |
| 101 | // DeleteParameterAction deleteParameterAction = new DeleteParameterAction( |
| 102 | // signature); |
| 103 | // UpParameterAction upParameterAction = new UpParameterAction(signature); |
| 104 | // DownParameterAction downParameterAction = new DownParameterAction( |
| 105 | // signature); |
| 106 | // |
| 107 | // editorContents.setDeleteButtonActionListener(deleteParameterAction); |
| 108 | // editorContents.setUpButtonActionListener(upParameterAction); |
| 109 | // editorContents.setDownButtonActionListener(downParameterAction); |
| 110 | // |
| 111 | // editorContents.setViewerSelectionChangedListener(deleteParameterAction); |
| 112 | // editorContents.setViewerSelectionChangedListener(upParameterAction); |
| 113 | // editorContents.setViewerSelectionChangedListener(downParameterAction); |
| 114 | // |
| 115 | editorContents.setViewerInput(filter); |
| 116 | // |
| 117 | // /** create separatot to button area */ |
| 118 | // ((CreateEditorContents) editorContents).createSeparator(parent); |
| 119 | |
| 120 | return area; |
| 121 | } |
| 122 | |
| 123 | /* |
| 124 | * (non-Javadoc) |
| 125 | * |
| 126 | * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) |
| 127 | */ |
| 128 | @Override |
| 129 | protected void createButtonsForButtonBar(Composite parent) { |
| 130 | createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, |
| 131 | false); |
| 132 | } |
| 133 | |
| 134 | /* (non-Javadoc) |
| 135 | * @see org.eclipse.jface.dialogs.TitleAreaDialog#getInitialSize() |
| 136 | */ |
| 137 | @Override |
| 138 | protected Point getInitialSize() { |
| 139 | return new Point(500, 375); |
| 140 | } |
| 141 | } |