[jboss-cvs] jbosside/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards ...

Robert Stryker rob.stryker at jboss.com
Fri Apr 20 05:42:02 EDT 2007


  User: rawb    
  Date: 07/04/20 05:42:02

  Modified:    core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards    
                        FilesetWizard.java NewJARWizard.java
  Added:       core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards    
                        ArchivePackageWizard.java
  Removed:     core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards    
                        AbstractPackageWizard.java
  Log:
  Refactoring of class names
  
  Revision  Changes    Path
  1.3       +2 -2      jbosside/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/FilesetWizard.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: FilesetWizard.java
  ===================================================================
  RCS file: /cvsroot/jboss/jbosside/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/FilesetWizard.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- FilesetWizard.java	20 Apr 2007 09:38:24 -0000	1.2
  +++ FilesetWizard.java	20 Apr 2007 09:42:02 -0000	1.3
  @@ -12,7 +12,7 @@
   import org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet;
   import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
   import org.jboss.ide.eclipse.archives.core.model.internal.ArchivesModel;
  -import org.jboss.ide.eclipse.archives.ui.util.PackageNodeFactory;
  +import org.jboss.ide.eclipse.archives.ui.util.ArchiveNodeFactory;
   import org.jboss.ide.eclipse.archives.ui.wizards.pages.FilesetInfoWizardPage;
   
   public class FilesetWizard extends Wizard {
  @@ -32,7 +32,7 @@
   		final boolean createFileset = this.fileset == null;
   		
   		if (createFileset)
  -			this.fileset = PackageNodeFactory.createFileset();
  +			this.fileset = ArchiveNodeFactory.createFileset();
   				
   		fillFilesetFromPage(fileset);
   		try {
  
  
  
  1.3       +6 -6      jbosside/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/NewJARWizard.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: NewJARWizard.java
  ===================================================================
  RCS file: /cvsroot/jboss/jbosside/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/NewJARWizard.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- NewJARWizard.java	20 Apr 2007 09:38:24 -0000	1.2
  +++ NewJARWizard.java	20 Apr 2007 09:42:02 -0000	1.3
  @@ -6,23 +6,23 @@
   import org.jboss.ide.eclipse.archives.core.model.IArchive;
   import org.jboss.ide.eclipse.archives.core.model.ArchivesCore;
   import org.jboss.ide.eclipse.archives.core.model.types.JARPackageType;
  -import org.jboss.ide.eclipse.archives.ui.PackagesSharedImages;
  -import org.jboss.ide.eclipse.archives.ui.PackagesUIMessages;
  +import org.jboss.ide.eclipse.archives.ui.ArchivesSharedImages;
  +import org.jboss.ide.eclipse.archives.ui.ArchivesUIMessages;
   
  -public class NewJARWizard extends AbstractPackageWizard
  +public class NewJARWizard extends ArchivePackageWizard
   {
   	public WizardPage[] createWizardPages() {
   		return new WizardPage[0];
   	}
   
   	public NewJARWizard () {
  -		setWindowTitle(PackagesUIMessages.NewJARWizard_windowTitle);
  +		setWindowTitle(ArchivesUIMessages.NewJARWizard_windowTitle);
   	}
   	
   	public NewJARWizard (IArchive existingPackage) {
   		super(existingPackage);
   		
  -		setWindowTitle(PackagesUIMessages.NewJARWizard_windowTitle_editJAR);
  +		setWindowTitle(ArchivesUIMessages.NewJARWizard_windowTitle_editJAR);
   	}
   	
   	public boolean performFinish(IArchive pkg) {
  @@ -33,7 +33,7 @@
   	}
   	
   	public ImageDescriptor getImageDescriptor() {
  -		return PackagesSharedImages.getImageDescriptor(PackagesSharedImages.IMG_NEW_JAR_WIZARD);
  +		return ArchivesSharedImages.getImageDescriptor(ArchivesSharedImages.IMG_NEW_JAR_WIZARD);
   	}
   	
   	public String getPackageExtension() {
  
  
  
  1.1      date: 2007/04/20 09:42:02;  author: rawb;  state: Exp;jbosside/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/ArchivePackageWizard.java
  
  Index: ArchivePackageWizard.java
  ===================================================================
  package org.jboss.ide.eclipse.archives.ui.wizards;
  
  import java.lang.reflect.InvocationTargetException;
  
  import org.eclipse.core.resources.IContainer;
  import org.eclipse.core.resources.IProject;
  import org.eclipse.core.runtime.IProgressMonitor;
  import org.eclipse.jface.operation.IRunnableWithProgress;
  import org.eclipse.jface.resource.ImageDescriptor;
  import org.eclipse.jface.viewers.IStructuredSelection;
  import org.eclipse.jface.wizard.IWizardPage;
  import org.eclipse.jface.wizard.WizardPage;
  import org.eclipse.ui.INewWizard;
  import org.eclipse.ui.IWorkbench;
  import org.jboss.ide.eclipse.archives.core.Trace;
  import org.jboss.ide.eclipse.archives.core.model.IArchive;
  import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
  import org.jboss.ide.eclipse.archives.core.model.internal.ArchivesModel;
  import org.jboss.ide.eclipse.archives.ui.views.ProjectArchivesView;
  import org.jboss.ide.eclipse.archives.ui.wizards.pages.ArchiveInfoWizardPage;
  
  public abstract class ArchivePackageWizard extends WizardWithNotification implements INewWizard {
  	private ArchiveInfoWizardPage firstPage;
  	private WizardPage pages[];
  	protected IProject project;
  	protected Object selectedDestination;
  	protected IArchive existingPackage;
  	
  	public ArchivePackageWizard () {	
  		this.project = ProjectArchivesView.getInstance().getCurrentProject();
  	}
  	
  	public ArchivePackageWizard (IArchive existingPackage) {
  		this.existingPackage = existingPackage;
  		this.project = existingPackage.getProject();
  	}
  	
  	public void addPages() {
  		firstPage = new ArchiveInfoWizardPage(this, existingPackage);
  		addPage(firstPage);
  		
  		pages = createWizardPages();
  		for (int i = 0; i < pages.length; i++) {
  			addPage(pages[i]);
  		}
  	}
  	
  	public boolean canFinish() {
  		if (firstPage.isPageComplete()) {
  			for (int i = 0; i < pages.length; i++) {
  				if (!pages[i].isPageComplete()) return false;
  			}
  			return true;
  		}
  		
  		return false;
  	}
  	
  	public boolean performFinish() {
  		IWizardPage currentPage = getContainer().getCurrentPage();
  		
  		if (currentPage instanceof WizardPageWithNotification) {
  			((WizardPageWithNotification)currentPage).pageExited(WizardWithNotification.FINISH);
  		}
  		
  		final boolean create = this.existingPackage == null;
  		final IArchive pkg = firstPage.getPackage();
  		final Object destination = firstPage.getPackageDestination();
  		
  		boolean performed = performFinish(pkg);
  		
  		if (performed) {
  			try {
  				getContainer().run(false, false, new IRunnableWithProgress () {
  					public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
  						IArchiveNode parent = null;
  						
  						if (destination instanceof IArchiveNode) {
  							// if we're modifying an existing package, remove old parentage
  							if (!create && !destination.equals(pkg.getParent())) {
  								if (pkg.getParent() != null) {
  									pkg.getParent().removeChild(pkg);
  								}
  							}
  							parent = (IArchiveNode)destination;
  						} else {
  							parent = ArchivesModel.instance().getRoot(project, true, monitor);
  						}
  						
  						if( create ) 
  							ArchivesModel.instance().attach(parent, pkg, monitor);
  						else
  							ArchivesModel.instance().saveModel(project, monitor);
  					}
  				});
  			} catch (InvocationTargetException e) {
  				Trace.trace(getClass(), e);
  			} catch (InterruptedException e) {
  				Trace.trace(getClass(), e);
  			}
  		}
  		return performed;
  	}
  
  	public void init(IWorkbench workbench, IStructuredSelection selection) {
  		if (selection == null) return;
  		project = ProjectArchivesView.getInstance().getCurrentProject();
  		Object selected;
  		
  		if( selection.isEmpty() ) {
  			selected = project;
  		} else {
  			selected = selection.getFirstElement();
  		}
  
  		if (selected instanceof IArchiveNode)
  		{
  			IArchiveNode node = (IArchiveNode) selected;
  			if (node.getNodeType() == IArchiveNode.TYPE_ARCHIVE || node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FOLDER)
  			{
  				selectedDestination = selected;
  			}
  			project = node.getProject();
  		}
  		else if (selected instanceof IContainer)
  		{
  			selectedDestination = selected;
  		}
  		else {
  			selectedDestination = project;
  		}
  		
  		setNeedsProgressMonitor(true);
  	}
  	
  	public Object getSelectedDestination ()
  	{
  		return selectedDestination;
  	}
  	
  	public abstract boolean performFinish(IArchive pkg);
  	public abstract WizardPage[] createWizardPages();
  	public abstract ImageDescriptor getImageDescriptor();
  	public abstract String getPackageExtension();
  	
  	public IProject getProject() {
  		return project;
  	}
  	
  	/**
  	 * Returns the package created by this wizard.
  	 * Note: This should only be called after the first page has been completed
  	 * @return The package
  	 */
  	public IArchive getPackage () {
  		return firstPage.getPackage();
  	}
  }
  
  
  



More information about the jboss-cvs-commits mailing list