public void initUI() {

    LinearLayout parent = EditManager.INSTANCE.getToolsLayout();
    Context context = parent.getContext();
    ILayer editLayer = EditManager.INSTANCE.getEditLayer();
    int padding = 2;

    if (editLayer != null) {
      createFeatureButton = new ImageButton(context);
      createFeatureButton.setLayoutParams(
          new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
      createFeatureButton.setBackground(
          Compat.getDrawable(context, R.drawable.editing_create_line));
      createFeatureButton.setPadding(0, padding, 0, padding);
      createFeatureButton.setOnClickListener(this);
      createFeatureButton.setOnTouchListener(this);
      parent.addView(createFeatureButton);

      selectEditableButton = new ImageButton(context);
      selectEditableButton.setLayoutParams(
          new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
      selectEditableButton.setBackground(
          Compat.getDrawable(context, R.drawable.editing_select_editable));
      selectEditableButton.setPadding(0, padding, 0, padding);
      selectEditableButton.setOnClickListener(this);
      selectEditableButton.setOnTouchListener(this);
      parent.addView(selectEditableButton);
    }

    selectAllButton = new ImageButton(context);
    selectAllButton.setLayoutParams(
        new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    selectAllButton.setBackground(Compat.getDrawable(context, R.drawable.editing_select_all));
    selectAllButton.setPadding(0, padding, 0, padding);
    selectAllButton.setOnClickListener(this);
    selectAllButton.setOnTouchListener(this);
    parent.addView(selectAllButton);

    if (editLayer != null) {
      undoButton = new ImageButton(context);
      undoButton.setLayoutParams(
          new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
      undoButton.setBackground(Compat.getDrawable(context, R.drawable.editing_undo));
      undoButton.setPadding(0, padding, 0, padding);
      undoButton.setOnTouchListener(this);
      undoButton.setOnClickListener(this);
      parent.addView(undoButton);
      undoButton.setVisibility(View.GONE);

      commitButton = new ImageButton(context);
      commitButton.setLayoutParams(
          new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
      commitButton.setBackground(Compat.getDrawable(context, R.drawable.editing_commit));
      commitButton.setPadding(0, padding, 0, padding);
      commitButton.setOnTouchListener(this);
      commitButton.setOnClickListener(this);
      parent.addView(commitButton);
      commitButton.setVisibility(View.GONE);
    }
  }
  public void onClick(View v) {
    if (v == selectAllButton) {
      Tool currentTool = EditManager.INSTANCE.getActiveTool();
      if (currentTool != null && currentTool instanceof InfoTool) {
        // if the same tool is re-selected, it is disabled
        EditManager.INSTANCE.setActiveTool(null);
      } else {
        // check maps enablement
        try {
          final Collection<SpatialVectorTable> spatialTables =
              SpatialiteSourcesManager.INSTANCE.getSpatialiteMaps2TablesMap().values();
          boolean atLeastOneEnabled = false;
          for (SpatialVectorTable spatialVectorTable : spatialTables) {
            if (spatialVectorTable.getStyle().enabled == 1) {
              atLeastOneEnabled = true;
              break;
            }
          }
          if (!atLeastOneEnabled) {
            LinearLayout parent = EditManager.INSTANCE.getToolsLayout();
            if (parent != null) {
              Context context = parent.getContext();
              GPDialogs.warningDialog(
                  context, context.getString(R.string.no_queriable_layer_is_visible), null);
            }
            return;
          }
        } catch (Exception e) {
          GPLog.error(this, null, e);
        }

        Tool activeTool = new InfoTool(this, mapView);
        EditManager.INSTANCE.setActiveTool(activeTool);
      }
    } else if (v == selectEditableButton) {
      Tool currentTool = EditManager.INSTANCE.getActiveTool();
      if (currentTool != null && currentTool instanceof SelectionTool) {
        // if the same tool is re-selected, it is disabled
        EditManager.INSTANCE.setActiveTool(null);
      } else {
        Tool activeTool = new SelectionTool(mapView);
        EditManager.INSTANCE.setActiveTool(activeTool);
      }
    } else if (v == createFeatureButton) {
      ToolGroup createFeatureToolGroup = new LineCreateFeatureToolGroup(mapView, null);
      EditManager.INSTANCE.setActiveToolGroup(createFeatureToolGroup);
    } else if (v == undoButton) {
      //            if (cutExtendProcessedFeature != null) {
      //                EditManager.INSTANCE.setActiveTool(null);
      //                commitButton.setVisibility(View.GONE);
      //                undoButton.setVisibility(View.GONE);
      //                EditManager.INSTANCE.invalidateEditingView();
      //            }
    }

    handleToolIcons(v);
  }
  /**
   * Constructor.
   *
   * @param mapView the map view.
   */
  public LineMainEditingToolGroup(MapView mapView) {
    this.mapView = mapView;

    LinearLayout parent = EditManager.INSTANCE.getToolsLayout();
    selectionColor = Compat.getColor(parent.getContext(), R.color.main_selection);
  }
 public void disable() {
   EditManager.INSTANCE.setActiveTool(null);
   LinearLayout parent = EditManager.INSTANCE.getToolsLayout();
   if (parent != null) parent.removeAllViews();
 }