Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2000, 2005 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html Contributors: IBM Corporation - initial API and implementation /
 
 
 package org.eclipse.team.internal.ccvs.ui.wizards;
 
 import java.util.List;
 import java.util.Map;
 
 import  org.eclipse.swt.SWT;
 import  org.eclipse.swt.layout.GridLayout;
 import  org.eclipse.swt.widgets.Composite;
 import  org.eclipse.swt.widgets.Label;
 
 public class CommitWizardFileTypePage extends WizardPage {
 
     private final Collection fExtensions;
     private final Collection fNames;
     
     public CommitWizardFileTypePage(Collection unknownExtensionsCollection unknownNames) {
         super(.); 
         
         new ArrayList();
         for (final Iterator iter = unknownNames.iterator(); iter.hasNext();) {
             final String name = (Stringiter.next();
             .add(new FileTypeTable.Name(namefalse));
         }
         
         new ArrayList();
         for (final Iterator iter = unknownExtensions.iterator(); iter.hasNext();) {
             final String extension= (String)iter.next();
             .add(new FileTypeTable.Extension(extensionfalse));
         }
     }
     
     public void createControl(Composite parent) {
         
         initializeDialogUnits(parent);
         
         final Composite compositenew Composite(parent, SWT.NONE);
         composite.setLayout(new GridLayout(1, false));
         // set F1 help
         PlatformUI.getWorkbench().getHelpSystem().setHelp(composite.);
         
 	    final Label labelnew Label(composite, SWT.WRAP);
 	    label.setText(.); 
 	    label.setLayoutData(SWTUtils.createHFillGridData());
 	    Dialog.applyDialogFont(composite);
         
         final List itemsnew ArrayList();
         items.addAll();
         items.addAll();
         
         new FileTypeTable(compositeitemstrue);
 
         setControl(composite);
         
     }
 
 	public void getModesForExtensions(Map toSaveMap notToSave) {
 	    getModes(toSavenotToSave);
 	}
 
 	public void getModesForNames(Map toSaveMap notToSave) {
 	    getModes(toSavenotToSave);
 	}
 
     private static void getModes(Collection itemsMap toSaveMap notToSave) {
 	    for (final Iterator iter = items.iterator(); iter.hasNext();) {
 	        final FileTypeTable.Item item= (FileTypeTable.Item)iter.next();
	        final Map destinationitem.save ? toSave : notToSave;
	        destination.put(item.namenew Integer(item.mode));
	    }
    }
    public KSubstOption getOption(IFile filethrows CVSException {
        final String extensionfile.getFileExtension();
        if (extension != null) {
            for (Iterator iter = .iterator(); iter.hasNext();) {
                final FileTypeTable.Item element = (FileTypeTable.Itemiter.next();
                if (element.name.equals(extension)) {
                    return element.mode == . ? KSubstOption.getDefaultTextMode() : .;
                }
            }
        } else {
            final String namefile.getName();
            for (Iterator iter = .iterator(); iter.hasNext();) {
                FileTypeTable.Item item = (FileTypeTable.Itemiter.next();
                if (item.name.equals(name)) {
                    return item.mode == . ? KSubstOption.getDefaultTextMode() : .;
                }
            }
        }
        final ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor(file);
		ResourceSyncInfo fileInfo = cvsFile.getSyncInfo();
		return fileInfo != null ? fileInfo.getKeywordMode() : KSubstOption.fromFile(file);
    }
    
    public static void saveExtensionMappings(Map modesToPersist) {
        
        final String [] extensionsnew String [modesToPersist.size()];
        final int [] modesnew int[modesToPersist.size()];
        
        int index= 0;
        for (Iterator itermodesToPersist.keySet().iterator(); iter.hasNext();) {
            extensions[index]= (Stringiter.next();
            modes[index]= ((Integer)modesToPersist.get(extensions[index])).intValue();
            ++index;
        }
        Team.getFileContentManager().addExtensionMappings(extensionsmodes);
    }
    
    public static void saveNameMappings(Map modesToPersist) {
        
        final String [] namesnew String [modesToPersist.size()];
        final int [] modesnew int[modesToPersist.size()];
        
        int index= 0;
        for (Iterator itermodesToPersist.keySet().iterator(); iter.hasNext();) {
            names[index]= (Stringiter.next();
            modes[index]= ((Integer)modesToPersist.get(names[index])).intValue();
            ++index;
        }
        Team.getFileContentManager().addNameMappings(namesmodes);
    }
New to GrepCode? Check out our FAQ X