/* $Id: //guest/paul_krause/perforce/integrations/jdev/src/com/perforce/jdev/P4CheckoutLister.java#5 $ * Copyright 2000-2002 SoundBite Corporation. All Rights Reserved. */ package com.perforce.jdev; import com.perforce.api.Change; import com.perforce.api.Client; import com.perforce.api.PerforceException; import com.perforce.api.SourceControlObject; import com.perforce.jdev.cm.P4ConnectionIterator; import java.io.File; import java.io.IOException; import java.net.MalformedURLException; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import oracle.ide.docking.DockStation; import oracle.ide.scm.SCMCheckoutLister; import oracle.ide.scm.error.SCMException; import oracle.ide.scm.lsco.SCMCheckoutList; import oracle.ide.scm.lsco.SCMListCheckoutsKey; import oracle.ide.scm.lsco.SCMListCheckoutsSetup; import oracle.ide.scm.lsco.SCMListCheckoutsWorker; import oracle.jdeveloper.cm.CMException; /** * @author Paul Krause * @created Wed Apr 24 16:42:09 2002 * @version $Revision: #5 $ */ public class P4CheckoutLister implements SCMCheckoutLister, SCMListCheckoutsWorker, SCMListCheckoutsSetup { /** * Gets the value of the setup property * * @return The Setup value */ public SCMListCheckoutsSetup getSetup() { return this; } /** * Gets the value of the worker property * * @return The Worker value */ public SCMListCheckoutsWorker getWorker() { return this; } public Integer getWindowOrientation() { return new Integer(DockStation.VERT); } private static final ChangeKey KEY_RESULT_CHANGE = new ChangeKey(); private static String[] optionalResultKeys = { KEY_RESULT_CHANGE.toString(), SCMListCheckoutsKey.KEY_RESULT_FILE.toString(), }; /** * Gets the value of the optional result keys property * * @return The OptionalResultKeys value */ public String[] getOptionalResultKeys() { return optionalResultKeys; } /** * Gets the displayable name of a Result key * * @param key A result key * @return The display name */ public String getResultName(Object key) { return key.toString(); } /** * Gets the value of the status idle property * * @param args arguments for the previously busy worker * @return The StatusIdle value */ public String getStatusIdle(Map args) { return "Finished " + args; } /** * Implements the worker interface. * * @param params Search parameters * (keys are result keys, values are ???) * @param list The list to which results are added. * @exception SCMException if a PerforceException occurs */ public void listCheckouts(Map params, SCMCheckoutList list) throws SCMException { try { Object bychange = params.get(KEY_RESULT_CHANGE); if (bychange != null) listChanges((ChangeKey) bychange, list); Object byfile = params.get(SCMListCheckoutsKey.KEY_RESULT_FILE); if (byfile != null) { ; // what is the type of byfile? listFiles((String) byfile, list); } } catch (MalformedURLException e) { throw new SCMException("Unexpected error", e); } catch (PerforceException e) { throw new SCMException("Perforce failure", e); } catch (IOException e) { throw new SCMException("I/O failure", e); } catch (CMException e) { throw new SCMException("Perforce failure", e); } } void listChanges(ChangeKey ck, SCMCheckoutList list) throws MalformedURLException, PerforceException { Change[] pending = ck.fetchPending(); for (int i = 0; i < pending.length; i++) { list.addCheckout(new P4Change(null, pending[i])); } } void listFiles(String path, SCMCheckoutList list) throws MalformedURLException, PerforceException, CMException, IOException { Map results = new HashMap(); final P4ConnectionIterator ci = new P4ConnectionIterator(); while (ci.hasNext()) { final Client c = (Client) ci.next(Client.class.getName()); Change[] pending = Change.getPendingChanges(c.getEnv(), path); for (int i = 0; i < pending.length; i++) { Iterator fi = pending[i].getFiles().iterator(); while (fi.hasNext()) { File f = (File) fi.next(); results.put(f.toURL(), pending[i]); } } } list.addCheckout(results); } } class ChangeKey { SourceControlObject p4Object; /** Client or depot path with P4 Wildcards */ String searchPath; /** The part of a P4 revison range between <tt>@</tt> and <tt>,</tt> */ String startWith; /** The part of a P4 revison range after the <tt>,</tt> */ String endWith; /** Change Retreival Limit */ int maxChanges = 100; /** if true, integrate against the changes */ boolean integrateFirst; /** A P4 user. If set, only Changes submitted this user are fetched. */ String userName; /** * Finds pending changes by running <pre> * p4 changes -m <var>maxChanges</var> -l -s pending (-i)<sup>*</sup> * (<var>searchPath)</var>(@<var>startsWith</var>)(,<var>endsWith</var>) * </pre> and returns all changes for <code>userName</code>. * <p> <sup>*</sup> controlled by <code>integrateFirst</code> */ public Change[] fetchPending() throws PerforceException { return Change.getPendingChanges (p4Object.getEnv(), searchPath, maxChanges, startWith, endWith, integrateFirst, userName); } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#5 | 2218 | Paul Krause | add a (not very good) diff | ||
#4 | 2135 | Paul Krause | cleaning | ||
#3 | 2114 | Paul Krause |
jdev 903 API changes - new SCMFile methods: copy, delete, renameTo - new SCMFileStatus method: getString |
||
#2 | 2075 | Paul Krause | try to implement a checkout lister | ||
#1 | 1716 | Paul Krause | first cut at a jdev integration |