Package org.jboss.as.console.client.standalone.deployment

Source Code of org.jboss.as.console.client.standalone.deployment.DeploymentListPresenter$MyProxy

/*
* JBoss, Home of Professional Open Source
* Copyright 2011 Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the @author tags. All rights reserved.
* See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License, v. 2.1.
* This program is distributed in the hope that it will be useful, but WITHOUT A
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public License,
* v.2.1 along with this distribution; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA  02110-1301, USA.
*/
package org.jboss.as.console.client.standalone.deployment;

import com.google.gwt.event.logical.shared.CloseEvent;
import com.google.gwt.event.logical.shared.CloseHandler;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.user.client.ui.PopupPanel;
import com.google.inject.Inject;
import com.gwtplatform.mvp.client.Presenter;
import com.gwtplatform.mvp.client.View;
import com.gwtplatform.mvp.client.annotations.NameToken;
import com.gwtplatform.mvp.client.annotations.ProxyCodeSplit;
import com.gwtplatform.mvp.client.proxy.Place;
import com.gwtplatform.mvp.client.proxy.PlaceManager;
import com.gwtplatform.mvp.client.proxy.Proxy;
import com.gwtplatform.mvp.client.proxy.RevealContentEvent;
import org.jboss.as.console.client.Console;
import org.jboss.as.console.client.core.NameTokens;
import org.jboss.as.console.client.domain.model.SimpleCallback;
import org.jboss.as.console.client.shared.deployment.DeployCommandExecutor;
import org.jboss.as.console.client.shared.deployment.DeploymentCommand;
import org.jboss.as.console.client.shared.deployment.NewDeploymentWizard;
import org.jboss.as.console.client.shared.dispatch.DispatchAsync;
import org.jboss.as.console.client.shared.dispatch.impl.DMRResponse;
import org.jboss.as.console.client.shared.model.DeploymentRecord;
import org.jboss.as.console.client.shared.model.DeploymentStore;
import org.jboss.as.console.client.standalone.ServerMgmtApplicationPresenter;
import org.jboss.as.console.client.widgets.DefaultWindow;

import java.util.List;

/**
* @author Heiko Braun
* @author Stan Silvert <ssilvert@redhat.com> (C) 2011 Red Hat Inc.
* @date 3/14/11
*/
public class DeploymentListPresenter extends Presenter<DeploymentListPresenter.MyView, DeploymentListPresenter.MyProxy>
        implements DeployCommandExecutor {

  private final PlaceManager placeManager;
  private StandaloneDeploymentInfo deploymentInfo;
  private DeploymentStore deploymentStore;

  private DefaultWindow window;
  private DispatchAsync dispatcher;
 
  @ProxyCodeSplit
  @NameToken(NameTokens.DeploymentListPresenter)
  public interface MyProxy extends Proxy<DeploymentListPresenter>, Place {
  }

  public interface MyView extends View {

    void setPresenter(DeploymentListPresenter presenter);

    void updateDeploymentInfo(List<DeploymentRecord> deployments);
  }

  @Inject
  public DeploymentListPresenter(
          EventBus eventBus, MyView view, MyProxy proxy,
          DeploymentStore deploymentStore,
          PlaceManager placeManager,
          DispatchAsync dispatcher) {

    super(eventBus, view, proxy);
    this.placeManager = placeManager;
    this.deploymentInfo = new StandaloneDeploymentInfo(this, deploymentStore);
    this.deploymentStore = deploymentStore;
    this.dispatcher = dispatcher;
  }

  @Override
  protected void onBind() {
    super.onBind();
    getView().setPresenter(this);
  }

  @Override
  protected void onReset() {
    super.onReset();
    deploymentInfo.refreshView();
  }

  @Override
  protected void revealInParent() {
    RevealContentEvent.fire(getEventBus(), ServerMgmtApplicationPresenter.TYPE_MainContent, this);
  }

  public void onFilterType(String value) {
  }

  @Override
  public void removeContent(final DeploymentRecord record) {
    deploymentStore.removeContent(record, new SimpleCallback<DMRResponse>() {

      @Override
      public void onSuccess(DMRResponse response) {
        deploymentInfo.refreshView();
        DeploymentCommand.REMOVE_FROM_STANDALONE.displaySuccessMessage(DeploymentListPresenter.this, record);
      }

      @Override
      public void onFailure(Throwable t) {
        super.onFailure(t);
        deploymentInfo.refreshView();
        DeploymentCommand.REMOVE_FROM_STANDALONE.displayFailureMessage(DeploymentListPresenter.this, record, t);
      }
    });
  }

  @Override
  public void enableDisableDeployment(final DeploymentRecord record) {
    deploymentStore.enableDisableDeployment(record, new SimpleCallback<DMRResponse>() {

      @Override
      public void onSuccess(DMRResponse response) {
        deploymentInfo.refreshView();
        DeploymentCommand.ENABLE_DISABLE.displaySuccessMessage(DeploymentListPresenter.this, record);
      }

      @Override
      public void onFailure(Throwable t) {
        super.onFailure(t);
        deploymentInfo.refreshView();
        DeploymentCommand.ENABLE_DISABLE.displayFailureMessage(DeploymentListPresenter.this, record, t);
      }
    });
  }

  @Override
  public void addToServerGroup(String selectedGroup, DeploymentRecord record) {
    throw new UnsupportedOperationException("Not supported in standalone mode.");
  }

  @Override
  public String getSelectedServerGroup() {
    return null;
  }

  @Override
  public void removeDeploymentFromGroup(DeploymentRecord record) {
    throw new UnsupportedOperationException("Not supported in standalone mode.");
  }
 
  public void launchNewDeploymentDialoge() {
        window = new DefaultWindow(Console.CONSTANTS.common_label_upload());
        window.setWidth(320);
        window.setHeight(240);
        window.addCloseHandler(new CloseHandler<PopupPanel>() {
            @Override
            public void onClose(CloseEvent<PopupPanel> event) {

            }
        });

        window.setWidget(
            new NewDeploymentWizard(window, dispatcher, deploymentInfo).asWidget()
        );

        window.setGlassEnabled(true);
        window.center();
    }
}
TOP

Related Classes of org.jboss.as.console.client.standalone.deployment.DeploymentListPresenter$MyProxy

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.