|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.modules.vcs.profiles.cvsprofiles.commands; import java.awt.Dialog; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Iterator; import java.util.List; import java.util.HashSet; import java.util.Hashtable; import javax.swing.JButton; import javax.swing.SwingUtilities; import org.openide.DialogDescriptor; import org.openide.filesystems.FileObject; import org.openide.loaders.DataObject; import org.openide.loaders.DataObjectNotFoundException; import org.openide.loaders.DataShadow; import org.openide.util.NbBundle; import org.openide.util.SharedClassObject; import org.netbeans.modules.vcscore.VcsFileSystem; import org.netbeans.modules.vcscore.VcsAction; import org.netbeans.modules.vcscore.actions.AddCommandAction; import org.netbeans.modules.vcscore.actions.CommandActionSupporter; import org.netbeans.modules.vcscore.actions.GeneralCommandAction; import org.netbeans.modules.vcscore.actions.UpdateCommandAction; import org.netbeans.modules.vcscore.caching.FileStatusProvider; import org.netbeans.modules.vcscore.cmdline.ExecuteCommand; import org.netbeans.modules.vcscore.cmdline.VcsAdditionalCommand; import org.netbeans.modules.vcscore.commands.*; import org.netbeans.modules.vcscore.grouping.GroupUtils; import org.netbeans.modules.vcscore.ui.*; import org.netbeans.modules.vcscore.util.Table; import org.openide.DialogDisplayer; /** * The verification of CVS files in a group. * * @author Martin Entlicher */ public class CvsVerifyAction extends java.lang.Object implements VcsAdditionalCommand { private static String UP_TO_DATE = "Up-to-date"; private static String[] TO_UPDATE = { "Needs Checkout", "Needs Patch", "Needs Merge" }; private ArrayList localFiles; private ArrayList outOfDateFiles; private ArrayList uptoDateFiles; private NotChangedFilesPanel ncfPanel; private ToAddFilesPanel taPanel; private ToUpdateFilesPanel tuPanel; private VcsFileSystem fileSystem = null; /** Creates new CvsVerifyAction */ public CvsVerifyAction() { } public void setFileSystem(VcsFileSystem fileSystem) { this.fileSystem = fileSystem; } static List getFOs(VcsFileSystem fileSystem, Hashtable vars) { Collection files = ExecuteCommand.createProcessingFiles(fileSystem, vars); ArrayList fos = new ArrayList(files.size()); for (Iterator fileIt = files.iterator(); fileIt.hasNext(); ) { String file = (String) fileIt.next(); FileObject fo = fileSystem.findFileObject(file); if (fo != null) { fos.add(fo); } } return fos; } private void fillFilesByState(List fos) { FileStatusProvider statusProvider = fileSystem.getStatusProvider(); if (statusProvider == null) { localFiles.addAll(fos); } else { HashSet toUpdate = new HashSet(Arrays.asList(TO_UPDATE)); for (Iterator it = fos.iterator(); it.hasNext(); ) { FileObject fo = (FileObject) it.next(); String file = fo.getPath(); String status = statusProvider.getFileStatus(file); //System.out.println("fillFilesByState: file = '"+file+"', status = "+status); if (statusProvider.getLocalFileStatus().equals(status)) { localFiles.add(fo); //System.out.println(" is Local"); } else if (toUpdate.contains(status)) { outOfDateFiles.add(fo); //System.out.println(" is Out Of Date"); } else if (UP_TO_DATE.equals(status)) { uptoDateFiles.add(fo); //System.out.println(" is Up to date"); } else { //System.out.println(" is Unrecognized => should me modified or so."); } } } } static void refreshFilesState(String cmdName, VcsFileSystem fileSystem, Hashtable vars) throws InterruptedException { VcsCommand cmd = fileSystem.getCommand(cmdName); if (VcsCommandIO.getBooleanProperty(cmd, VcsCommand.PROPERTY_RUN_ON_MULTIPLE_FILES)) { VcsCommandExecutor vce = fileSystem.getVcsFactory().getCommandExecutor(cmd, vars); fileSystem.getCommandsPool().preprocessCommand(vce, new Hashtable(vars), fileSystem); fileSystem.getCommandsPool().startExecutor(vce); try { fileSystem.getCommandsPool().waitToFinish(vce); } catch (InterruptedException iexc) { fileSystem.getCommandsPool().kill(vce); throw iexc; } } else { List fos = getFOs(fileSystem, vars); Table files = new Table(); for (Iterator it = fos.iterator(); it.hasNext(); ) { FileObject fo = (FileObject) it.next(); files.put(fo.getPath(), fo); } VcsCommandExecutor[] execs = VcsAction.doCommand(files, cmd, null, fileSystem, null, null, null, null, true); CommandsPool cpool = fileSystem.getCommandsPool(); for (int i = 0; i < execs.length; i++) { try { cpool.waitToFinish(execs[i]); } catch (InterruptedException iexc) { for (int j = i; j < execs.length; j++) { cpool.kill(execs[j]); } throw iexc; } } } } /** * This method is used to execute the command. * @param vars the variables that can be passed to the command * @param args the command line parametres passed to it in properties * @param stdoutListener listener of the standard output of the command * @param stderrListener listener of the error output of the command * @param stdoutDataListener listener of the standard output of the command which * satisfies regex |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.