Package com.subgraph.vega.ui.http.intercept.config

Source Code of com.subgraph.vega.ui.http.intercept.config.BreakpointPatternEditingSupport

/*******************************************************************************
* Copyright (c) 2011 Subgraph.
* 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:
*     Subgraph - initial API and implementation
******************************************************************************/
package com.subgraph.vega.ui.http.intercept.config;

import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.EditingSupport;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TextCellEditor;

import com.subgraph.vega.api.model.conditions.IHttpCondition;

public class BreakpointPatternEditingSupport extends EditingSupport {
  private final TableViewer viewer;

  public BreakpointPatternEditingSupport(TableViewer viewer) {
    super(viewer);
    this.viewer = viewer;
  }

  @Override
  protected CellEditor getCellEditor(Object element) {
    return new TextCellEditor(viewer.getTable());
  }

  @Override
  protected boolean canEdit(Object element) {
    return true;
  }

  @Override
  protected Object getValue(Object element) {
    final IHttpCondition condition = (IHttpCondition) element;
    return condition.getMatchAction().getArgumentAsString();
  }

  @Override
  protected void setValue(Object element, Object value) {
    if(!(value instanceof String))
      return;
    final IHttpCondition condition = (IHttpCondition) element;
    condition.getMatchAction().setArgumentFromString((String) value);
    viewer.refresh(true);
  }
}
TOP

Related Classes of com.subgraph.vega.ui.http.intercept.config.BreakpointPatternEditingSupport

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.