View Javadoc
1   /*
2    * Copyright (C) 2007-2012 Argeo GmbH
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *         http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.argeo.slc.client.ui.dist.commands;
17  
18  import org.argeo.slc.client.ui.dist.DistPlugin;
19  import org.argeo.slc.client.ui.dist.utils.CommandHelpers;
20  import org.argeo.slc.client.ui.dist.wizards.GenerateBinariesWizard;
21  import org.argeo.slc.repo.RepoService;
22  import org.eclipse.core.commands.AbstractHandler;
23  import org.eclipse.core.commands.ExecutionEvent;
24  import org.eclipse.core.commands.ExecutionException;
25  import org.eclipse.jface.dialogs.Dialog;
26  import org.eclipse.jface.resource.ImageDescriptor;
27  import org.eclipse.jface.wizard.WizardDialog;
28  import org.eclipse.ui.IWorkbenchPart;
29  import org.eclipse.ui.handlers.HandlerUtil;
30  
31  /** Open a {@code GenerateBinariesWizard} wizard for the selected node */
32  public class OpenGenerateBinariesWizard extends AbstractHandler {
33  	// private static final Log log = LogFactory.getLog(DeleteWorkspace.class);
34  
35  	public final static String ID = DistPlugin.PLUGIN_ID
36  			+ ".openGenerateBinariesWizard";
37  	public final static String DEFAULT_LABEL = "Generate Aether Index";
38  	public final static ImageDescriptor DEFAULT_ICON = null;
39  
40  	/* DEPENDENCY INJECTION */
41  	private RepoService repoService;
42  
43  	// Absolute Coordinates of the current group node
44  	public final static String PARAM_REPO_NODE_PATH = "param.repoNodePath";
45  	public final static String PARAM_WORKSPACE_NAME = "param.workspaceName";
46  	public final static String PARAM_MODULE_PATH = "param.modulePath";
47  
48  	public Object execute(ExecutionEvent event) throws ExecutionException {
49  		IWorkbenchPart activePart = DistPlugin.getDefault().getWorkbench()
50  				.getActiveWorkbenchWindow().getActivePage().getActivePart();
51  
52  		String repoNodePath = event.getParameter(PARAM_REPO_NODE_PATH);
53  		String workspaceName = event.getParameter(PARAM_WORKSPACE_NAME);
54  		String modulePath = event.getParameter(PARAM_MODULE_PATH);
55  
56  		GenerateBinariesWizard wizard = new GenerateBinariesWizard(repoService,
57  				repoNodePath, workspaceName, modulePath);
58  
59  		WizardDialog dialog = new WizardDialog(
60  				HandlerUtil.getActiveShell(event), wizard);
61  		int result = dialog.open();
62  
63  		if (result == Dialog.OK
64  				&& (activePart instanceof RefreshDistributionsView))
65  			CommandHelpers.callCommand(RefreshDistributionsView.ID);
66  
67  		return null;
68  	}
69  
70  	/* DEPENDENCY INJECTION */
71  	public void setRepoService(RepoService repoService) {
72  		this.repoService = repoService;
73  	}
74  }