[Pydev-cvs] org.python.pydev/src/org/python/pydev/ui/editors TreeWithAddRemove.java,1.2,1.3
Brought to you by:
fabioz
From: Fabio Z. <fa...@us...> - 2005-08-17 17:21:30
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/ui/editors In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8570/src/org/python/pydev/ui/editors Modified Files: TreeWithAddRemove.java Log Message: Index: TreeWithAddRemove.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/ui/editors/TreeWithAddRemove.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TreeWithAddRemove.java 14 Aug 2005 21:27:40 -0000 1.2 --- TreeWithAddRemove.java 17 Aug 2005 17:21:19 -0000 1.3 *************** *** 6,9 **** --- 6,10 ---- package org.python.pydev.ui.editors; + import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.IPath; *************** *** 19,22 **** --- 20,24 ---- import org.eclipse.swt.widgets.Tree; import org.eclipse.swt.widgets.TreeItem; + import org.eclipse.ui.dialogs.ResourceSelectionDialog; import org.eclipse.ui.dialogs.SelectionDialog; import org.python.pydev.plugin.PydevPlugin; *************** *** 64,68 **** Button buttonAddSourceFolder = new Button(buttonsSourceFolders, SWT.PUSH); ! customizeAddSourceFolderButton(buttonAddSourceFolder); data = new GridData (); data.horizontalAlignment = GridData.FILL; --- 66,71 ---- Button buttonAddSourceFolder = new Button(buttonsSourceFolders, SWT.PUSH); ! customizeAddSourceFolderButton(buttonAddSourceFolder, true); ! buttonAddSourceFolder.setText(getButtonAddText()); data = new GridData (); data.horizontalAlignment = GridData.FILL; *************** *** 70,73 **** --- 73,84 ---- buttonAddSourceFolder.setLayoutData(data); + Button buttonAddJar = new Button(buttonsSourceFolders, SWT.PUSH); + customizeAddSourceFolderButton(buttonAddJar, false); + buttonAddJar.setText("Add jar"); + data = new GridData (); + data.horizontalAlignment = GridData.FILL; + data.grabExcessHorizontalSpace = true; + buttonAddJar.setLayoutData(data); + Button buttonRemSourceFolder = new Button(buttonsSourceFolders, SWT.PUSH); customizeRemSourceFolderButton(buttonRemSourceFolder); *************** *** 93,96 **** --- 104,108 ---- protected void customizeRemSourceFolderButton(Button buttonRem) { buttonRem.setText(getButtonRemoveText()); + buttonRem.setToolTipText("Remove the selected item"); buttonRem.addSelectionListener(new SelectionListener(){ *************** *** 114,123 **** * @param buttonAddSourceFolder */ ! protected void customizeAddSourceFolderButton(Button buttonAddSourceFolder) { ! buttonAddSourceFolder.setText(getButtonAddText()); buttonAddSourceFolder.addSelectionListener(new SelectionListener(){ public void widgetSelected(SelectionEvent e) { ! Object d = getSelectionDialog(); if(d instanceof FileDialog){ FileDialog dialog = (FileDialog) d; --- 126,140 ---- * @param buttonAddSourceFolder */ ! protected void customizeAddSourceFolderButton(Button buttonAddSourceFolder, final boolean chooseSourceFolder) { buttonAddSourceFolder.addSelectionListener(new SelectionListener(){ public void widgetSelected(SelectionEvent e) { ! Object d; ! if(chooseSourceFolder){ ! d = getSelectionDialogAddSourceFolder(); ! }else{ ! d = getSelectionDialogAddJar(); ! } ! if(d instanceof FileDialog){ FileDialog dialog = (FileDialog) d; *************** *** 134,143 **** dialog.open(); Object[] objects = dialog.getResult(); ! if (objects != null && objects.length == 1) { //only one folder can be selected ! if (objects[0] instanceof IPath) { ! IPath p = (IPath) objects[0]; ! String pathAsString = getPathAsString(p); ! addTreeItem(pathAsString); ! } } }else{ --- 151,169 ---- dialog.open(); Object[] objects = dialog.getResult(); ! if (objects != null) { ! for (int i = 0; i < objects.length; i++) { ! Object object = objects[i]; ! if (object instanceof IPath) { ! IPath p = (IPath) object; ! String pathAsString = getPathAsString(p); ! addTreeItem(pathAsString); ! }else if(object instanceof IFile){ ! IFile p = (IFile) object; ! String pathAsString = getPathAsString(p.getProjectRelativePath()); ! if(pathAsString.endsWith(".jar") || pathAsString.endsWith(".zip")){ ! addTreeItem(pathAsString); ! } ! } ! } } }else{ *************** *** 158,162 **** */ protected String getButtonRemoveText() { ! return "Remove Source Folder"; } --- 184,188 ---- */ protected String getButtonRemoveText() { ! return "Remove"; } *************** *** 166,170 **** */ protected String getButtonAddText() { ! return "Add Source Folder"; } --- 192,196 ---- */ protected String getButtonAddText() { ! return "Add source folder"; } *************** *** 179,187 **** /** * @return */ ! protected Object getSelectionDialog() { return new ProjectFolderSelectionDialog(getShell(), project, true, "Choose source folders to add to PYTHONPATH"); } --- 205,220 ---- + + /** + * @return + */ + protected Object getSelectionDialogAddJar() { + return new ResourceSelectionDialog(getShell(), project, "Choose jars to add to PYTHONPATH"); + } /** * @return */ ! protected Object getSelectionDialogAddSourceFolder() { return new ProjectFolderSelectionDialog(getShell(), project, true, "Choose source folders to add to PYTHONPATH"); } |