// Copyright (C) 2013 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.googlesource.gerrit.plugins.deleteproject;

import com.google.gerrit.extensions.webui.UiAction;
import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.project.ProjectResource;
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.googlesource.gerrit.plugins.deleteproject.cache.CacheDeleteHandler;
import com.googlesource.gerrit.plugins.deleteproject.fs.FilesystemDeleteHandler;

public class DeleteAction extends DeleteProject implements UiAction<ProjectResource> {
  private final ProtectedProjects protectedProjects;

  @Inject
  DeleteAction(
      ProtectedProjects protectedProjects,
      FilesystemDeleteHandler fsHandler,
      CacheDeleteHandler cacheHandler,
      Provider<CurrentUser> userProvider,
      DeleteLog deleteLog,
      DeletePreconditions preConditions,
      Configuration cfg,
      HideProject hideProject) {
    super(
        fsHandler,
        cacheHandler,
        userProvider,
        deleteLog,
        preConditions,
        cfg,
        hideProject);
    this.protectedProjects = protectedProjects;
  }

  @Override
  public UiAction.Description getDescription(ProjectResource rsrc) {
    return new UiAction.Description()
        .setLabel("Delete Project")
        .setTitle(
            protectedProjects.isProtected(rsrc)
                ? String.format("Not allowed to delete %s", rsrc.getName())
                : String.format("Delete project %s", rsrc.getName()))
        .setEnabled(!protectedProjects.isProtected(rsrc))
        .setVisible(preConditions.canDelete(rsrc));
  }
}

@@ -1509,25 +1509,16 @@
   super(
-%0A        
 fsHandle
@@ -1519,24 +1519,16 @@
 Handler,
-%0A       
  cacheHa
@@ -1533,24 +1533,16 @@
 Handler,
-%0A       
  userPro
@@ -1547,24 +1547,16 @@
 rovider,
-%0A       
  deleteL
@@ -1558,24 +1558,16 @@
 leteLog,
-%0A       
  preCond
@@ -1577,29 +1577,13 @@
 ons,
-%0A        cfg,%0A       
+ cfg,
  hid

Format with google-java-format