Search in sources :

Example 1 with RemoveParameterAction

use of org.eclipse.wst.xsl.internal.debug.ui.actions.RemoveParameterAction in project webtools.sourceediting by eclipse.

the class ParametersBlock method createControl.

public void createControl(Composite parent) {
    Font font = parent.getFont();
    Group group = new Group(parent, SWT.NONE);
    group.setText(getName());
    GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    group.setLayoutData(gd);
    GridLayout layout = new GridLayout();
    layout.numColumns = 3;
    group.setLayout(layout);
    group.setFont(font);
    setControl(group);
    fTable = new Table(group, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
    GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
    // data.heightHint = 100;
    fTable.setLayoutData(data);
    fTable.setFont(font);
    fTable.setHeaderVisible(true);
    fTable.setLinesVisible(true);
    TableColumn column1 = new TableColumn(fTable, SWT.NONE);
    column1.setWidth(150);
    column1.setResizable(true);
    column1.setText(Messages.ParametersBlock_0);
    TableColumn column3 = new TableColumn(fTable, SWT.NONE);
    column3.setWidth(250);
    column3.setResizable(true);
    column3.setText(Messages.ParametersBlock_2);
    parametersViewer = new ParameterViewer(fTable);
    parametersViewer.getViewer().setLabelProvider(new ParametersLabelProvider());
    parametersViewer.getViewer().setContentProvider(new ParametersContentProvider());
    parametersViewer.addParametersChangedListener(new IParametersChangedListener() {

        public void parametersChanged(ParameterViewer viewer) {
            updateLaunchConfigurationDialog();
        }
    });
    parametersViewer.getViewer().getTable().addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent event) {
            if (event.character == SWT.DEL && event.stateMask == 0) {
                RemoveParameterAction ra = new RemoveParameterAction(parametersViewer);
                ra.run();
                updateLaunchConfigurationDialog();
            }
        }
    });
    parametersViewer.getViewer().setColumnProperties(// $NON-NLS-1$ //$NON-NLS-2$
    new String[] { "name", "value" });
    TextCellEditor textEditor = new TextCellEditor(fTable);
    CellEditor[] editors = new CellEditor[] { null, textEditor };
    parametersViewer.getViewer().setCellEditors(editors);
    parametersViewer.getViewer().setCellModifier(new ICellModifier() {

        public boolean canModify(Object element, String property) {
            // $NON-NLS-1$
            return "value".equals(property);
        }

        public Object getValue(Object element, String property) {
            LaunchAttribute att = (LaunchAttribute) element;
            // $NON-NLS-1$
            return att.value == null ? "" : att.value;
        }

        public void modify(Object element, String property, Object value) {
            Item item = (Item) element;
            LaunchAttribute att = (LaunchAttribute) item.getData();
            att.value = (String) value;
            parametersViewer.getViewer().update(att, null);
            updateLaunchConfigurationDialog();
        }
    });
    Composite parameterButtonComp = new Composite(group, SWT.NONE);
    GridLayout parameterButtonCompLayout = new GridLayout();
    parameterButtonCompLayout.marginHeight = 0;
    parameterButtonCompLayout.marginWidth = 0;
    parameterButtonComp.setLayout(parameterButtonCompLayout);
    gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_FILL);
    gd.horizontalSpan = 2;
    parameterButtonComp.setLayoutData(gd);
    parameterButtonComp.setFont(font);
    addParameterButton = createButton(parameterButtonComp, new AddParameterAction(parametersViewer));
    removeParameterButton = createButton(parameterButtonComp, new RemoveParameterAction(parametersViewer));
    transformsBlock.getStylesheetViewer().addSelectionChangedListener(selectionListener);
    restoreColumnSettings();
}
Also used : Group(org.eclipse.swt.widgets.Group) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) CellEditor(org.eclipse.jface.viewers.CellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) KeyAdapter(org.eclipse.swt.events.KeyAdapter) TableColumn(org.eclipse.swt.widgets.TableColumn) LaunchAttribute(org.eclipse.wst.xsl.launching.config.LaunchAttribute) Font(org.eclipse.swt.graphics.Font) AddParameterAction(org.eclipse.wst.xsl.internal.debug.ui.actions.AddParameterAction) KeyEvent(org.eclipse.swt.events.KeyEvent) Item(org.eclipse.swt.widgets.Item) GridLayout(org.eclipse.swt.layout.GridLayout) RemoveParameterAction(org.eclipse.wst.xsl.internal.debug.ui.actions.RemoveParameterAction) GridData(org.eclipse.swt.layout.GridData) ICellModifier(org.eclipse.jface.viewers.ICellModifier) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor)

Aggregations

CellEditor (org.eclipse.jface.viewers.CellEditor)1 ICellModifier (org.eclipse.jface.viewers.ICellModifier)1 TextCellEditor (org.eclipse.jface.viewers.TextCellEditor)1 KeyAdapter (org.eclipse.swt.events.KeyAdapter)1 KeyEvent (org.eclipse.swt.events.KeyEvent)1 Font (org.eclipse.swt.graphics.Font)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 Group (org.eclipse.swt.widgets.Group)1 Item (org.eclipse.swt.widgets.Item)1 Table (org.eclipse.swt.widgets.Table)1 TableColumn (org.eclipse.swt.widgets.TableColumn)1 AddParameterAction (org.eclipse.wst.xsl.internal.debug.ui.actions.AddParameterAction)1 RemoveParameterAction (org.eclipse.wst.xsl.internal.debug.ui.actions.RemoveParameterAction)1 LaunchAttribute (org.eclipse.wst.xsl.launching.config.LaunchAttribute)1