X-Git-Url: http://secure.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPObfuscatorAction.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPObfuscatorAction.java deleted file mode 100644 index 1a24c29..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPObfuscatorAction.java +++ /dev/null @@ -1,163 +0,0 @@ -/********************************************************************** -Copyright (c) 2000, 2002 IBM Corp. and others. -All rights reserved. This program and the accompanying materials -are made available under the terms of the Common Public License v1.0 -which accompanies this distribution, and is available at -http://www.eclipse.org/legal/cpl-v10.html - - Klaus Hartlage - www.eclipseproject.de -**********************************************************************/ -package net.sourceforge.phpeclipse.actions; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Iterator; - -import net.sourceforge.phpdt.internal.compiler.parser.Scanner; -import net.sourceforge.phpeclipse.PHPeclipsePlugin; -import net.sourceforge.phpeclipse.mover.DefaultFilter; -import net.sourceforge.phpeclipse.mover.DirectoryWalker; -import net.sourceforge.phpeclipse.mover.IFilter; -import net.sourceforge.phpeclipse.mover.IMover; -import net.sourceforge.phpeclipse.mover.obfuscator.ObfuscatorIgnores; -import net.sourceforge.phpeclipse.mover.obfuscator.PHPAnalyzer; -import net.sourceforge.phpeclipse.mover.obfuscator.PHPObfuscatorMover; -import net.sourceforge.phpeclipse.preferences.ProjectProperties; -import net.sourceforge.phpeclipse.views.PHPConsole; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IObjectActionDelegate; -import org.eclipse.ui.IWorkbenchPart; - -/** - * - * @author khartlage - * - * Run the PHP Obfuscator - */ -public class PHPObfuscatorAction implements IObjectActionDelegate { - - private IWorkbenchPart workbenchPart; - /** - * Constructor for PHPObfuscatorAction. - */ - public PHPObfuscatorAction() { - super(); - } - - public void run(IAction action) { - ISelectionProvider selectionProvider = null; - selectionProvider = workbenchPart.getSite().getSelectionProvider(); - - StructuredSelection selection = null; - selection = (StructuredSelection) selectionProvider.getSelection(); - PHPConsole console = PHPConsole.getInstance(); - - // HashMap identifierMap = new HashMap(8096); - // for (int i=0;i selected object in the view - Object obj = iterator.next(); - - // is it a resource - if (obj instanceof IResource) { - - IResource resource = (IResource) obj; - IProject proj = resource.getProject(); - String sourcePath; - - if (identifierMap == null) { - IPreferenceStore store = - PHPeclipsePlugin.getDefault().getPreferenceStore(); - ObfuscatorIgnores ignore = new ObfuscatorIgnores(proj); - identifierMap = ignore.getIdentifierMap(); - } - - String publishPath; - try { - ProjectProperties properties = new ProjectProperties(proj); - publishPath = properties.getPublish(); - } catch (CoreException e1) { - return; - // e1.printStackTrace(); - } - // try { - // publishPath = proj.getPersistentProperty(IObfuscatorPreferences.PUBLISH_PROPERTY_NAME); - // } catch (CoreException e) { - // return; - // } - - DefaultFilter[] filter = - { IFilter.PHP_FILTER, IFilter.DEFAULT_FILTER, }; - IMover[] mover = - { - new PHPAnalyzer( - PHPConsole.getInstance(), - new Scanner(false, false), - identifierMap), - new PHPObfuscatorMover( - PHPConsole.getInstance(), - new Scanner(true, true), - identifierMap)}; - DirectoryWalker walker = new DirectoryWalker(mover, filter); - switch (resource.getType()) { - case IResource.PROJECT : - IProject project = (IProject) resource; - sourcePath = project.getLocation().toOSString(); - try { - walker.walk(sourcePath, publishPath); - } catch (IOException e) { - } - break; - case IResource.FOLDER : - IFolder folder = (IFolder) resource; - sourcePath = folder.getLocation().toOSString(); - try { - walker.walk(sourcePath, publishPath); - } catch (IOException e) { - } - break; - case IResource.FILE : - // single file: - IFile file = (IFile) resource; - sourcePath = file.getLocation().toOSString(); - try { - walker.walk(sourcePath, publishPath); - } catch (IOException e) { - } - break; - } - } - } - } - /** - * @see IActionDelegate#selectionChanged(IAction, ISelection) - */ - public void selectionChanged(IAction action, ISelection selection) { - } - - /** - * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart) - */ - public void setActivePart(IAction action, IWorkbenchPart targetPart) { - workbenchPart = targetPart; - } - -}