[jboss-cvs] jbosside/core/plugins/org.jboss.ide.eclipse.packages.ui/src/main/org/jboss/ide/eclipse/archives/ui/actions ...
Robert Stryker
rob.stryker at jboss.com
Wed Apr 18 12:52:15 EDT 2007
User: rawb
Date: 07/04/18 12:52:15
Added: core/plugins/org.jboss.ide.eclipse.packages.ui/src/main/org/jboss/ide/eclipse/archives/ui/actions
INodeActionDelegate.java NewJARAction.java
ActionWithDelegate.java NewPackageAction.java
Log:
refactored to archive rather than package, a la max
Revision Changes Path
1.1 date: 2007/04/18 16:52:15; author: rawb; state: Exp;jbosside/core/plugins/org.jboss.ide.eclipse.packages.ui/src/main/org/jboss/ide/eclipse/archives/ui/actions/INodeActionDelegate.java
Index: INodeActionDelegate.java
===================================================================
package org.jboss.ide.eclipse.archives.ui.actions;
import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
/**
* All extensions of org.jboss.ide.eclipse.archives.ui.nodePopupMenus should implement this interface
* (also see AbstractNodeActionDelegate)
* @author Marshall
*
*/
public interface INodeActionDelegate {
/**
* @param node
* @return Whether or not this action delegate will be enabled (viewable) for a specific package node.
*/
public boolean isEnabledFor (IArchiveNode node);
/**
* Run this action delegate on the passed-in node
* @param node A package node
*/
public void run (IArchiveNode node);
}
1.1 date: 2007/04/18 16:52:15; author: rawb; state: Exp;jbosside/core/plugins/org.jboss.ide.eclipse.packages.ui/src/main/org/jboss/ide/eclipse/archives/ui/actions/NewJARAction.java
Index: NewJARAction.java
===================================================================
package org.jboss.ide.eclipse.archives.ui.actions;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.ui.PlatformUI;
import org.jboss.ide.eclipse.archives.ui.PackagesSharedImages;
import org.jboss.ide.eclipse.archives.ui.views.ProjectArchivesView;
import org.jboss.ide.eclipse.archives.ui.wizards.NewJARWizard;
public class NewJARAction extends ActionWithDelegate {
public void run() {
try {
NewJARWizard wizard = new NewJARWizard();
wizard.init(PlatformUI.getWorkbench(), getSelection());
WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), wizard);
int response = dialog.open();
if (response == Dialog.OK) {
}
} catch( Exception e ) {
e.printStackTrace();
}
}
public IStructuredSelection getSelection() {
return ProjectArchivesView.getInstance().getSelection();
}
public ImageDescriptor getImageDescriptor() {
return PackagesSharedImages.getImageDescriptor(PackagesSharedImages.IMG_NEW_PACKAGE);
}
public String getText() {
return "JAR";
}
public String getToolTipText() {
return "Create a new JAR package";
}
}
1.1 date: 2007/04/18 16:52:15; author: rawb; state: Exp;jbosside/core/plugins/org.jboss.ide.eclipse.packages.ui/src/main/org/jboss/ide/eclipse/archives/ui/actions/ActionWithDelegate.java
Index: ActionWithDelegate.java
===================================================================
package org.jboss.ide.eclipse.archives.ui.actions;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IActionDelegate;
import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.IWorkbenchPart;
public abstract class ActionWithDelegate extends Action implements IActionDelegate, ISelectionListener {
public ActionWithDelegate () {
}
public abstract void run ();
public void run(IAction action) {
run();
}
public abstract IStructuredSelection getSelection();
public void selectionChanged(IAction action, ISelection selection) {
}
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
}
}
1.1 date: 2007/04/18 16:52:15; author: rawb; state: Exp;jbosside/core/plugins/org.jboss.ide.eclipse.packages.ui/src/main/org/jboss/ide/eclipse/archives/ui/actions/NewPackageAction.java
Index: NewPackageAction.java
===================================================================
package org.jboss.ide.eclipse.archives.ui.actions;
import java.net.URL;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.IActionDelegate;
import org.jboss.ide.eclipse.archives.core.Trace;
import org.osgi.framework.Bundle;
/**
* This is an action wrapper. It wraps the extension point
*/
public class NewPackageAction {
private String id, label;
private ImageDescriptor icon;
private Image iconImage;
private IActionDelegate action;
public NewPackageAction(IConfigurationElement element) {
id = element.getAttribute("id");
label = element.getAttribute("label");
try {
action = (IActionDelegate) element.createExecutableExtension("class");
} catch (CoreException e) {
Trace.trace(getClass(), e);
}
String iconPath = element.getAttribute("icon");
String pluginId = element.getDeclaringExtension().getNamespaceIdentifier();
Bundle bundle = Platform.getBundle(pluginId);
URL iconURL = FileLocator.find(bundle, new Path(iconPath), null);
if (iconURL == null)
{
iconURL = bundle.getEntry(iconPath);
}
icon = ImageDescriptor.createFromURL(iconURL);
iconImage = icon.createImage();
}
public IActionDelegate getAction() {
return action;
}
public ImageDescriptor getIconDescriptor() {
return icon;
}
public Image getIcon()
{
return iconImage;
}
public String getId() {
return id;
}
public String getLabel() {
return label;
}
protected void finalize() throws Throwable {
iconImage.dispose();
}
}
More information about the jboss-cvs-commits
mailing list