diff options
Diffstat (limited to 'plugins/org.eclipse.jem.ui/beaninfoui')
24 files changed, 0 insertions, 4553 deletions
diff --git a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/BIListElementSorter.java b/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/BIListElementSorter.java deleted file mode 100644 index 4d54547fb..000000000 --- a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/BIListElementSorter.java +++ /dev/null @@ -1,78 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 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.jem.internal.beaninfo.ui; -/* - - - */ - -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerSorter; - -import org.eclipse.jem.internal.beaninfo.core.BeaninfoEntry; - -/** - * Sorter for sorting BPBeaninfoListElements within the main list. - * - * @version 1.0 - * @author - */ -public class BIListElementSorter extends ViewerSorter { - - /* - * @see ViewerSorter#category(Object) - */ - public int category(Object obj) { - if (obj instanceof BPBeaninfoListElement) { - BPBeaninfoListElement element = (BPBeaninfoListElement) obj; - - switch (((BeaninfoEntry) element.getEntry()).getKind()) { - case IClasspathEntry.CPE_LIBRARY: - return 4; - case IClasspathEntry.CPE_PROJECT: - return 1; - case IClasspathEntry.CPE_SOURCE: - return 0; - case IClasspathEntry.CPE_VARIABLE: - return 3; - case BeaninfoEntry.BIE_PLUGIN: - return 5; - case IClasspathEntry.CPE_CONTAINER: - return 2; - } - } - return super.category(obj); - } - - /* - * @see ViewerSorter#compare() - */ - public int compare(Viewer viewer, Object e1, Object e2) { - int cat1 = category(e1); - int cat2 = category(e2); - - if (cat1 != cat2) - return cat1 - cat2; - - if ((e1 instanceof BPBeaninfoListElement) && (e2 instanceof BPBeaninfoListElement)) { - BeaninfoEntry p1 = (BeaninfoEntry) ((BPBeaninfoListElement) e1).getEntry(); - BeaninfoEntry p2 = (BeaninfoEntry) ((BPBeaninfoListElement) e2).getEntry(); - - // Compare paths - return p1.getPath().toString().compareTo(p2.getPath().toString()); - } - return super.compare(viewer, e1, e2); - } - - - -} diff --git a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/BPBeaninfoListElement.java b/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/BPBeaninfoListElement.java deleted file mode 100644 index 72d125928..000000000 --- a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/BPBeaninfoListElement.java +++ /dev/null @@ -1,80 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 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.jem.internal.beaninfo.ui; -/* - - - */ - -import org.eclipse.jem.internal.beaninfo.core.BeaninfoEntry; -import org.eclipse.jem.internal.beaninfo.core.SearchpathEntry; - -/** - * @version 1.0 - * @author - */ -public class BPBeaninfoListElement extends BPListElement { - - BPSearchListElement[] searchpaths; - - /** - * Constructor for BPBeaninfoListElement. - * The searchPaths is the initial list, it is assumed that - * the beaninfoEntry has these searchpaths in them too. - */ - public BPBeaninfoListElement(BeaninfoEntry entry, BPSearchListElement[] searchpaths, boolean missing) { - super(entry, missing); - this.searchpaths = searchpaths != null ? searchpaths : new BPSearchListElement[0]; - } - - /** - * Mark the entry as exported. - */ - public void setExported(boolean exported) { - ((BeaninfoEntry) entry).setIsExported(exported); - } - - /* - * @see BPListElement#canExportBeChanged() - */ - public boolean canExportBeChanged() { - return true; - } - - /* - * @see BPListElement#isExported() - */ - public boolean isExported() { - return ((BeaninfoEntry) entry).isExported(); - } - - /** - * Return the current list of Searchpaths for this Beaninfo Element. - */ - public BPSearchListElement[] getSearchpaths() { - return searchpaths; - } - - /** - * Set the new list. This will update the beaninfo entry too. - */ - public void setSearchpaths(BPSearchListElement[] searchpaths) { - this.searchpaths = searchpaths; - - SearchpathEntry[] spEntries = new SearchpathEntry[searchpaths.length]; - for (int i = 0; i < searchpaths.length; i++) { - BPSearchListElement bps = searchpaths[i]; - spEntries[i] = (SearchpathEntry) bps.getEntry(); - } - - ((BeaninfoEntry) entry).setSearchPaths(spEntries); - } -} diff --git a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/BPListElement.java b/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/BPListElement.java deleted file mode 100644 index 5f5ee1640..000000000 --- a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/BPListElement.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 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.jem.internal.beaninfo.ui; -/* - - - */ - - -import org.eclipse.jem.internal.beaninfo.core.IBeaninfosDocEntry; -/** - * A Base ListElement (i.e. element in a list viewer) for - * a BeanInfo Search Path Entry. - */ - -public abstract class BPListElement extends Object { - protected IBeaninfosDocEntry entry; - protected boolean missing; // Library/folder/classpath entry for this entry could not be found. - - public BPListElement(IBeaninfosDocEntry entry, boolean missing) { - this.entry = entry; - this.missing = missing; - } - - public IBeaninfosDocEntry getEntry() { - return entry; - } - - public boolean isMissing() { - return missing; - } - - /** - * Certain entries cannot have their export status changed. - */ - public abstract boolean canExportBeChanged(); - - /** - * Return whether this entry is exported. - */ - public abstract boolean isExported(); - - /** - * If export can be changed, change it. - */ - public abstract void setExported(boolean exported); - -} diff --git a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/BPSearchListElement.java b/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/BPSearchListElement.java deleted file mode 100644 index 83ae36324..000000000 --- a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/BPSearchListElement.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 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.jem.internal.beaninfo.ui; -/* - - - */ - -import org.eclipse.jem.internal.beaninfo.core.SearchpathEntry; - -/** - * @version 1.0 - * @author - */ -public class BPSearchListElement extends BPListElement { - - protected boolean exported; - protected boolean packageMissing; - /** - * Constructor for BPSearchListElement. - * @param entry - * @param project - * @param inMissing - */ - public BPSearchListElement( - SearchpathEntry entry, - boolean missing, - boolean packageMissing, - boolean exported) { - super(entry, missing); - - this.packageMissing = packageMissing; - this.exported = exported; - } - - /* - * @see BPListElement#canExportBeChanged() - */ - public boolean canExportBeChanged() { - return false; - } - - /* - * @see BPListElement#isExported() - */ - public boolean isExported() { - return exported; - } - - /** - * Is the package missing. - */ - public boolean isPackageMissing() { - return packageMissing; - } - - /* - * @see BPListElement#setExported(boolean) - */ - public void setExported(boolean exported) { - } - -} diff --git a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/BeanInfoUIMessages.java b/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/BeanInfoUIMessages.java deleted file mode 100644 index 5f999dabc..000000000 --- a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/BeanInfoUIMessages.java +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************* - * 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.jem.internal.beaninfo.ui; - -import org.eclipse.osgi.util.NLS; - -public final class BeanInfoUIMessages extends NLS { - - private static final String BUNDLE_NAME = "org.eclipse.jem.internal.beaninfo.ui.messages";//$NON-NLS-1$ - - private BeanInfoUIMessages() { - // Do not instantiate - } - - public static String SearchPathDialog_ChoosePackages; - public static String SearchPathDialog_Remove; - public static String SearchPathDialog_Desc_Label; - public static String SearchPathDialog_ModifySearchPaths; - public static String SearchPathDialog_NotEditable_INFO_; - public static String SearchPathDialog_PackagePresent_INFO_; - public static String SearchPathDialog_InputDialog_Title; - public static String SearchPathDialog_InputDialog_Message; - public static String BeanInfoPathsBlock_ExportAll; - public static String BeanInfoPathsBlock_UnexportAll; - public static String BeanInfoPathsBlock_Page_Tab_Packages; - public static String BeanInfoPathsBlock_Page_Tab_Classes; - public static String BeanInfosWorkbookPage_AddFolders; - public static String BeanInfosWorkbookPage_AddJARs; - public static String BeanInfosWorkbookPage_AddExternalJAR; - public static String BeanInfosWorkbookPage_AddVariable; - public static String BeanInfosWorkbookPage_AddProjects; - public static String BeanInfosWorkbookPage_ModifyPaths; - public static String BeanInfosWorkbookPage_Remove; - public static String BeanInfosWorkbookPage_List_Text; - public static String BeanInfosWorkbookPage_SelectionDialog_Classes_Title; - public static String BeanInfosWorkbookPage_SelectionDialog_JARs_Title; - public static String BeanInfosWorkbookPage_SelectionDialog_JARs_Message; - public static String BeanInfosWorkbookPage_SelectionDialog_ExtJARs_Text; - public static String BeanInfosWorkbookPage_SelectionDialog_Projects_Title; - public static String BeanInfosWorkbookPage_SelectionDialog_Classes_Prompt; - public static String BeanInfosWorkbookPage_SelectionDialog_Projects_Prompt; - public static String PackagesWorkbook_ChoosePackages; - public static String PackagesWorkbook_ChooseDefinedPaths; - public static String PackagesWorkbook_Remove; - public static String PackagesWorkbook_LabelText; - public static String PackagesWorkbook_SelectionDialog_DefinedPaths_Title; - public static String PackagesWorkbook_SelectionDialog_DefinedPaths_Message; - public static String LabelProvider_Library_Folder; - public static String LabelProvider_Library__PathLastSegment_PathRelative_; - public static String LabelProvider_Library__PathLastSegment_PathExceptLast_; - public static String LabelProvider_Variable__name_PathOSString_; - public static String LabelProvider__packageName_Path_; - public static String VariableSelectionBlock_variable_label; - public static String VariableSelectionBlock_variable_button; - public static String VariableSelectionBlock_extension_label; - public static String VariableSelectionBlock_extension_button; - public static String VariableSelectionBlock_fullpath_label; - public static String VariableSelectionBlock_error_entername_ERROR_; - public static String VariableSelectionBlock_error_namenotexists_ERROR_; - public static String VariableSelectionBlock_error_pathexists_ERROR_; - public static String VariableSelectionBlock_error_invalidextension_ERROR_; - public static String VariableSelectionBlock_warning_pathnotexists_WARN_; - public static String VariableSelectionBlock_ExtJarDialog_title; - public static String Beaninfo_UI__errortitle; - public static String Beaninfo_UI__error; - public static String BeaninfoPropertiesPage_INFO__nojavaproject; - public static String BeaninfoPropertiesPage_INFO__closedproject; - public static String BeaninfoPathsBlock_UI__enablebeaninfo; - public static String BeaninfoPathsBlock_UI__searchpath_label; - public static String BeaninfoPathsBlock_UI__searchpath_up_button; - public static String BeaninfoPathsBlock_UI__searchpath_down_button; - public static String BeaninfoPathsBlock_UI__searchpath_remove_button; - public static String BeaninfoPathsBlock_UI__serachpath_tab_order; - public static String BeaninfoPathsBlock_WARN__searchpath_missing_path_format; - public static String BeaninfoPathsBlock_UI__searchpath_operationdescription; - public static String BeaninfoPathsBlock_UI__addsearchpath_title; - public static String BeaninfoPathsBlock_UI__addsearchpath_description; - public static String BeaninfoPathsBlock_UI__warning_EntryMissing; - public static String BeaninfoPathsBlock_UI__searchpath_add_button; - - static { - NLS.initializeMessages(BUNDLE_NAME, BeanInfoUIMessages.class); - } - - public static String ExceptionHandler_errordialog_msg_seelog; -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/BeaninfoEntrySearchpathDialog.java b/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/BeaninfoEntrySearchpathDialog.java deleted file mode 100644 index bcbc14353..000000000 --- a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/BeaninfoEntrySearchpathDialog.java +++ /dev/null @@ -1,448 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 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.jem.internal.beaninfo.ui; -/* - - - */ - -import java.text.MessageFormat; -import java.util.*; -import java.util.List; - -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jdt.core.*; -import org.eclipse.jdt.ui.JavaElementLabelProvider; -import org.eclipse.jface.dialogs.*; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.viewers.*; -import org.eclipse.jface.window.Window; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.*; -import org.eclipse.swt.layout.*; -import org.eclipse.swt.widgets.*; -import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; -import org.eclipse.ui.dialogs.ISelectionStatusValidator; - -import org.eclipse.jem.internal.beaninfo.core.BeaninfoEntry; -import org.eclipse.jem.internal.beaninfo.core.SearchpathEntry; - -/** - * This dialog is used to display and modify the search path - * within a BeaninfoEntry. - * @version 1.0 - * @author - */ -public class BeaninfoEntrySearchpathDialog extends Dialog { - protected BPBeaninfoListElement infoElement; - protected IJavaProject jProject; - //protected ListDialogField listField; - - private Composite top; - private Table table; - private TableViewer tableViewer; - private Label label; - private Composite buttonsBar; - private Button upbutton; - private Button downButton; - private Button choosePackagesButton; - private Button removeButton; - private List tableElements; - private boolean enabled = true; - - public BeaninfoEntrySearchpathDialog( - Shell parentShell, - BPBeaninfoListElement infoElement, - IJavaProject jProject) { - super(parentShell); - - this.infoElement = infoElement; - this.jProject = jProject; - this.tableElements = new ArrayList(); - } - - protected void configureShell(Shell newShell) { - super.configureShell(newShell); - newShell.setText( - MessageFormat.format( - BeanInfoUIMessages.SearchPathDialog_ModifySearchPaths, - new Object[] { infoElement.getEntry().getPath().toString()})); - } - - protected Control createDialogArea(Composite parent) { - top = new Composite(parent, SWT.NONE); - top.setLayoutData(new GridData(GridData.FILL_BOTH)); - top.setLayout(new GridLayout(2, false)); - - label = new Label(top, SWT.NONE); - label.setText(BeanInfoUIMessages.SearchPathDialog_Desc_Label); - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalSpan = 2; - label.setLayoutData(gd); - - createTable(); - createButtonsBar(); - - updatePackagesList(); - - updateButtons(); - - return top; - } - - /** - * This method initializes table - * - */ - private void createTable() { - GridData gridData1 = new org.eclipse.swt.layout.GridData(); - gridData1.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL; - gridData1.grabExcessHorizontalSpace = true; - gridData1.grabExcessVerticalSpace = true; - gridData1.verticalAlignment = org.eclipse.swt.layout.GridData.FILL; - table = new Table(top, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); - table.setLayoutData(gridData1); - table.addSelectionListener(new SelectionListener(){ - public void widgetSelected(SelectionEvent e) { - updateButtons(); - } - public void widgetDefaultSelected(SelectionEvent e) { - widgetSelected(e); - } - }); - tableViewer = new TableViewer(table); - //tableViewer.setSorter(new BIListElementSorter()); - tableViewer.setContentProvider(new ArrayContentProvider()); - tableViewer.setLabelProvider(new SearchPathListLabelProvider(jProject)); - tableViewer.setInput(tableElements); - } - - /** - * This method initializes buttonsBar - * - */ - private void createButtonsBar() { - RowLayout rowLayout = new RowLayout(); - rowLayout.type = org.eclipse.swt.SWT.VERTICAL; - rowLayout.marginLeft = 3; - rowLayout.fill = true; - GridData gridData2 = new org.eclipse.swt.layout.GridData(); - gridData2.grabExcessVerticalSpace = true; - gridData2.verticalAlignment = org.eclipse.swt.layout.GridData.FILL; - gridData2.horizontalAlignment = org.eclipse.swt.layout.GridData.BEGINNING; - buttonsBar = new Composite(top, SWT.NONE); - buttonsBar.setLayoutData(gridData2); - buttonsBar.setLayout(rowLayout); - upbutton = new Button(buttonsBar, SWT.NONE); - upbutton.setText(BeanInfoUIMessages.BeaninfoPathsBlock_UI__searchpath_up_button); - upbutton.addSelectionListener(new SelectionAdapter(){ - public void widgetSelected(SelectionEvent e) { - List selected = BeaninfoPathsBlock.getSelectedList(tableViewer.getSelection()); - Iterator selItr = selected.iterator(); - while (selItr.hasNext()) { - Object element = selItr.next(); - int oldIndex = tableElements.indexOf(element); - if(oldIndex>0){ - tableElements.remove(element); - tableElements.add(--oldIndex, element); - } - } - tableViewer.refresh(); - pageChanged(); - } - }); - downButton = new Button(buttonsBar, SWT.NONE); - downButton.setText(BeanInfoUIMessages.BeaninfoPathsBlock_UI__searchpath_down_button); - downButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() { - public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { - List selected = BeaninfoPathsBlock.getSelectedList(tableViewer.getSelection()); - Iterator selItr = selected.iterator(); - while (selItr.hasNext()) { - Object element = selItr.next(); - int oldIndex = tableElements.indexOf(element); - if(oldIndex<(tableElements.size()-1)){ - tableElements.remove(element); - tableElements.add(++oldIndex, element); - } - } - tableViewer.refresh(); - pageChanged(); - } - }); - new Label(buttonsBar, SWT.NONE); - choosePackagesButton = new Button(buttonsBar, SWT.NONE); - choosePackagesButton.setText(BeanInfoUIMessages.SearchPathDialog_ChoosePackages); - choosePackagesButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() { - public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { - final List elementsToAdd = choosePackages(); - if (elementsToAdd != null && !elementsToAdd.isEmpty()) { - tableElements.addAll(elementsToAdd); - tableViewer.refresh(); - table.getDisplay().asyncExec(new Runnable(){ - public void run() { - tableViewer.setSelection(new StructuredSelection(elementsToAdd)); - }; - }); - } - } - }); - new Label(buttonsBar, SWT.NONE); - removeButton = new Button(buttonsBar, SWT.NONE); - removeButton.setText(BeanInfoUIMessages.SearchPathDialog_Remove); - removeButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() { - public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { - List selected = BeaninfoPathsBlock.getSelectedList(tableViewer.getSelection()); - tableElements.removeAll(selected); - tableViewer.refresh(); - pageChanged(); - } - }); - } - - - protected void pageChanged() { - // TODO Auto-generated method stub - - } - - protected void updateButtons() { - if(top!=null && !top.isDisposed()){ - upbutton.setEnabled(enabled && canMoveUp()); - downButton.setEnabled(enabled && canMoveDown()); - removeButton.setEnabled(enabled && !tableViewer.getSelection().isEmpty()); - choosePackagesButton.setEnabled(enabled); - } - } - - private boolean canMoveDown() { - int[] indc= table.getSelectionIndices(); - int k= tableElements.size() - 1; - for (int i= indc.length - 1; i >= 0 ; i--, k--) { - if (indc[i] != k) { - return true; - } - } - return false; - } - - private boolean canMoveUp() { - int[] indc= table.getSelectionIndices(); - for (int i= 0; i < indc.length; i++) { - if (indc[i] != i) { - return true; - } - } - return false; - } - - private void updatePackagesList() { - if (infoElement.getEntry().getKind() == BeaninfoEntry.BIE_PLUGIN) { - // We don't allow these to be updated. They should only be used through - // registered mechanisms and we won't be showing them here normally. - label.setText(BeanInfoUIMessages.SearchPathDialog_NotEditable_INFO_); - updateEnabledState(false); - return; - } - tableElements.clear(); - tableElements.addAll(Arrays.asList(infoElement.getSearchpaths())); - tableViewer.refresh(); - } - - private void updateEnabledState(boolean b) { - enabled = b; - if(top!=null && !top.isDisposed()){ - label.setEnabled(enabled); - table.setEnabled(enabled); - updateButtons(); - } - } - - protected void okPressed() { - if (table.isEnabled()) { - // If the field is not enabled, then there is no update to perform. We don't - // want to accidentially wipe out the search paths in this case. - - // Override to put the list of elements back into the BPBeaninfoListElement - // Until then they aren't actually updated. - infoElement.setSearchpaths( - (BPSearchListElement[]) tableElements.toArray(new BPSearchListElement[tableElements.size()])); - } - super.okPressed(); - } - - /** - * Choose the packages that should be in the search path. - */ - private List choosePackages() { - - IPackageFragmentRoot[] roots = getBeaninfoRoots(); - List newPackageNames = new ArrayList(); - if (roots != null) { - // It's within the workspace, so we can get the roots and packages. - ISelectionStatusValidator validator = new PackagesWorkbookPage.ChoosePackagesSelectionValidator(); - - // Show up to the package fragment, don't show any contents of it. - Class[] acceptedClasses = new Class[] { IPackageFragmentRoot.class, IPackageFragment.class }; - Object[] rejectedFragments = getFilteredExistingEntries(roots); - - // Only show package fragments that have children (i.e. there classes in it, not interested - // in intermediate ones that have no classes defined in them. Those are filtered out. - TypedViewerFilter filter = new TypedViewerFilter(acceptedClasses, rejectedFragments) { - public boolean select(Viewer viewer, Object parentElement, Object element) { - if (super.select(viewer, parentElement, element)) { - if (element instanceof IPackageFragment) { - IPackageFragment pkg = (IPackageFragment) element; - try { - return pkg.hasChildren(); - } catch (JavaModelException e) { - } - return false; - } else - return true; - } - return false; - } - }; - - ITreeContentProvider provider = new PackageOnlyContentProvider(); - - ILabelProvider labelProvider = new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_DEFAULT); - ElementTreeSelectionDialog dialog = - new ElementTreeSelectionDialog(getShell(), labelProvider, provider); - dialog.setTitle(BeanInfoUIMessages.BeaninfoPathsBlock_UI__addsearchpath_title); - - dialog.setValidator(validator); - dialog.setMessage(BeanInfoUIMessages.BeaninfoPathsBlock_UI__addsearchpath_description); - dialog.addFilter(filter); - dialog.setInput(Arrays.asList(getBeaninfoRoots())); - - if (dialog.open() == Window.OK) { - Object[] elements = dialog.getResult(); - for (int i = 0; i < elements.length; i++) { - newPackageNames.add(((IPackageFragment) elements[i]).getElementName()); - } - } - } else { - // It's not within the workspace - final List existingPackagenames = getFilteredExistingEntries(); - IInputValidator validator = new IInputValidator() { - public String isValid(String newText) { - if (existingPackagenames.contains(newText)) - return BeanInfoUIMessages.SearchPathDialog_PackagePresent_INFO_; - - IStatus status = JavaConventions.validatePackageName(newText); - return status.getSeverity() == IStatus.OK ? null : status.getMessage(); - } - }; - InputDialog dialog = new InputDialog(getShell(), BeanInfoUIMessages.SearchPathDialog_InputDialog_Title, BeanInfoUIMessages.SearchPathDialog_InputDialog_Message, null, validator); - if (dialog.open() == Window.OK) - newPackageNames.add(dialog.getValue()); - } - - if (newPackageNames.size() == 0) - return Collections.EMPTY_LIST; - - List newElements = new ArrayList(newPackageNames.size()); - for (int i = 0; i < newPackageNames.size(); i++) - newElements.add( - new BPSearchListElement(new SearchpathEntry((String) newPackageNames.get(i)), false, false, false)); - return newElements; - } - /** - * Return the packagefragment roots for the given beaninfo entry. - * Return null if it can be handled (i.e. not in a project some where). - */ - protected IPackageFragmentRoot[] getBeaninfoRoots() { - IPackageFragmentRoot[] roots = null; - if (infoElement.getEntry().getKind() != BeaninfoEntry.BIE_PLUGIN) { - IClasspathEntry resolved = JavaCore.getResolvedClasspathEntry(((BeaninfoEntry) infoElement.getEntry()).getClasspathEntry()); - IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(resolved.getPath()); - if (res != null && res.exists()) { - if (res instanceof IProject) { - // It is a project itself. - IJavaProject jp = (IJavaProject) JavaCore.create(res); - try { - if (jp != null) - roots = jp.getPackageFragmentRoots(); // All of the roots in the project are applicable. - } catch (JavaModelException e) { - } - } else { - // It is within another project - IProject containingProject = res.getProject(); - IJavaProject jp = JavaCore.create(containingProject); - if (jp != null) { - // The roots if this is in the classpath of this project - try { - IPackageFragmentRoot root = jp.findPackageFragmentRoot(resolved.getPath()); - if (root != null) - roots = new IPackageFragmentRoot[] { root }; - } catch (JavaModelException e) { - } - } - } - } - } - return roots; - } - - /** - * Return the list of entries that already are in the search path - * so that they don't show up in the list. - */ - protected Object[] getFilteredExistingEntries(IPackageFragmentRoot[] roots) { - List entries = tableElements; - List fragments = new ArrayList(entries.size()); - Iterator itr = entries.iterator(); - while (itr.hasNext()) { - BPSearchListElement elem = (BPSearchListElement) itr.next(); - fragments.addAll(getPackages(elem, roots)); - } - return fragments.toArray(); - } - - /** - * Return the list of entries that already are in the search path - * so that they don't show up in the list. This one is just the package names. - */ - protected List getFilteredExistingEntries() { - List entries = tableElements; - List names = new ArrayList(entries.size()); - Iterator itr = entries.iterator(); - while (itr.hasNext()) { - BPSearchListElement elem = (BPSearchListElement) itr.next(); - names.add(((SearchpathEntry) elem.getEntry()).getPackage()); - } - return names; - } - - protected List getPackages(BPSearchListElement element, IPackageFragmentRoot[] roots) { - String packageName = ((SearchpathEntry) element.getEntry()).getPackage(); - if (packageName == null) - return Collections.EMPTY_LIST; - - try { - List packages = new ArrayList(10); - for (int i = 0; i < roots.length; i++) { - IJavaElement[] pfs = roots[i].getChildren(); - for (int j = 0; j < pfs.length; j++) - if (pfs[j].getElementType() == IJavaElement.PACKAGE_FRAGMENT - && pfs[j].getElementName().equals(packageName)) { - packages.add(pfs[j]); - break; - } - } - return packages; - } catch (JavaModelException e) { - } - return Collections.EMPTY_LIST; - } -} diff --git a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/BeaninfoPathsBlock.java b/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/BeaninfoPathsBlock.java deleted file mode 100644 index 43e92785f..000000000 --- a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/BeaninfoPathsBlock.java +++ /dev/null @@ -1,550 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2006 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.jem.internal.beaninfo.ui; - -import java.io.File; -import java.lang.reflect.InvocationTargetException; -import java.net.URL; -import java.util.*; -import java.util.List; - -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; -import org.eclipse.jdt.core.*; -import org.eclipse.jdt.ui.ISharedImages; -import org.eclipse.jdt.ui.JavaUI; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.*; - -import org.eclipse.jem.internal.beaninfo.adapters.BeaninfoNature; -import org.eclipse.jem.internal.beaninfo.core.*; -import org.eclipse.jem.internal.ui.core.JEMUIPlugin; - -public class BeaninfoPathsBlock { - - //private Shell sShell1 = null; // @jve:decl-index=0:visual-constraint="40,19" - private Composite top = null; - private TabFolder tabFolder = null; - private Button enableBeaninfoCheckbox = null; - private PackagesWorkbookPage packagesWorkbookPage2 = null; - private SearchpathOrderingWorkbookPage searchpathOrderingWorkbookPage2 = null; - private BeaninfosWorkbookPage beaninfosPropertyPage2 = null; - private Control packagesPageControl = null; - private Control searchpathPageControl = null; - private Control beaninfosPageControl = null; - private Image packagesTabImage; - private Image beaninfosTabImage; - private Image searchPathTabImage; - // ...ui - - private IWorkspaceRoot workspaceRoot; - private IStatusChangeListener statusChangeListener; - private IBuildSearchPage currentPage; - private IJavaProject javaProject; - private boolean enableBeaninfo = true; - - public BeaninfoPathsBlock(IWorkspaceRoot workspaceRoot, IStatusChangeListener statusChangeListener){ - this.workspaceRoot = workspaceRoot; - this.statusChangeListener = statusChangeListener; - } - - private void setEnableBeaninfo(boolean enable){ - enableBeaninfo = enable; - if(enableBeaninfoCheckbox!=null && !enableBeaninfoCheckbox.isDisposed()) - enableBeaninfoCheckbox.setSelection(enable); - } - -// /** -// * This method initializes sShell1 -// * -// */ -// private void createSShell1() { -// sShell1 = new Shell(); -// sShell1.setLayout(new FillLayout()); -// createTop(); -// sShell1.setSize(new org.eclipse.swt.graphics.Point(403,289)); -// } - - /** - * This method initializes top - * - */ - public Control createControl(Composite parent) { - top = new Composite(parent, SWT.NONE); - top.setLayout(new GridLayout()); - createTabFolder(); - enableBeaninfoCheckbox = new Button(top, SWT.CHECK); - enableBeaninfoCheckbox.setText(BeanInfoUIMessages.BeaninfoPathsBlock_UI__enablebeaninfo); - enableBeaninfoCheckbox.addSelectionListener(new org.eclipse.swt.events.SelectionListener() { - public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { - enableBeaninfo = enableBeaninfoCheckbox.getSelection(); - packagesWorkbookPage2.setBeaninfoEnabled(enableBeaninfo); - beaninfosPropertyPage2.setBeaninfoEnabled(enableBeaninfo); - searchpathOrderingWorkbookPage2.setBeaninfoEnabled(enableBeaninfo); - } - public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) { - widgetSelected(e); - } - }); - enableBeaninfoCheckbox.setSelection(enableBeaninfo); - if(javaProject!=null){ - getPackagesPage().init(javaProject); - getBeaninfosPage().init(javaProject); - getSearchpathOrderingPage().init(javaProject); - } - return top; - } - - /** - * This method initializes tabFolder - * - */ - private void createTabFolder() { - GridData gridData = new org.eclipse.swt.layout.GridData(); - gridData.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL; - gridData.grabExcessHorizontalSpace = true; - gridData.grabExcessVerticalSpace = true; - gridData.verticalAlignment = org.eclipse.swt.layout.GridData.FILL; - tabFolder = new TabFolder(top, SWT.NONE); - tabFolder.setLayoutData(gridData); - createPackagesWorkbookPage2(); - createBeaninfosPropertyPage2(); - createSearchpathOrderingWorkbookPage2(); - tabFolder.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() { - public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { - tabChanged(e.item); - } - }); - - TabItem tabItem = new TabItem(tabFolder, SWT.NONE); - tabItem.setText(BeanInfoUIMessages.BeanInfoPathsBlock_Page_Tab_Packages); - tabItem.setImage(getPackagesTabImage()); - tabItem.setControl(packagesPageControl); - TabItem tabItem1 = new TabItem(tabFolder, SWT.NONE); - tabItem1.setText(BeanInfoUIMessages.BeanInfoPathsBlock_Page_Tab_Classes); - tabItem1.setImage(getBeaninfosTabImage()); - tabItem1.setControl(beaninfosPageControl); - TabItem tabItem2 = new TabItem(tabFolder, SWT.NONE); - tabItem2.setImage(getSearchPathTabImage()); - tabItem2.setText(BeanInfoUIMessages.BeaninfoPathsBlock_UI__serachpath_tab_order); - tabItem2.setControl(searchpathPageControl); - tabFolder.setSelection(2); - } - - private Image getSearchPathTabImage() { - if(searchPathTabImage==null) - searchPathTabImage = JEMUIPlugin.imageDescriptorFromPlugin(JEMUIPlugin.getPlugin().getBundle().getSymbolicName(), "icons/cp_order_obj.gif").createImage(); //$NON-NLS-1$ - return searchPathTabImage; - } - - private Image getPackagesTabImage() { - if(packagesTabImage==null) - packagesTabImage = JavaUI.getSharedImages().getImage(ISharedImages.IMG_OBJS_PACKAGE); - return packagesTabImage; - } - - private Image getBeaninfosTabImage(){ - if(beaninfosTabImage==null){ - URL imageURL = FileLocator.find(JEMUIPlugin.getPlugin().getBundle(), new Path("icons/javabean.gif"), null); //$NON-NLS-1$ - if (imageURL != null) - beaninfosTabImage = ImageDescriptor.createFromURL(imageURL).createImage(); - else - beaninfosTabImage = ImageDescriptor.getMissingImageDescriptor().createImage(); - } - return beaninfosTabImage; - } - - /** - * This method initializes packagesWorkbookPage2 - * - */ - private void createPackagesWorkbookPage2() { - packagesPageControl = getPackagesPage().createControl(tabFolder); - } - - /** - * This method initializes searchpathOrderingWorkbookPage2 - * - */ - private void createSearchpathOrderingWorkbookPage2() { - searchpathPageControl = getSearchpathOrderingPage().createControl(tabFolder); - searchpathPageControl.addDisposeListener(new org.eclipse.swt.events.DisposeListener() { - public void widgetDisposed(org.eclipse.swt.events.DisposeEvent e) { - if(searchPathTabImage!=null){ - if(!searchPathTabImage.isDisposed()) - searchPathTabImage.dispose(); - searchPathTabImage=null; - } - } - }); - } - - /** - * This method initializes beaninfosPropertyPage2 - * - */ - private void createBeaninfosPropertyPage2() { - beaninfosPageControl = getBeaninfosPage().createControl(tabFolder); - beaninfosPageControl.addDisposeListener(new org.eclipse.swt.events.DisposeListener() { - public void widgetDisposed(org.eclipse.swt.events.DisposeEvent e) { - if(beaninfosTabImage!=null){ - if(!beaninfosTabImage.isDisposed()) - beaninfosTabImage.dispose(); - beaninfosTabImage=null; - } - } - }); - } - - PackagesWorkbookPage getPackagesPage(){ - if(packagesWorkbookPage2==null) - packagesWorkbookPage2 = new PackagesWorkbookPage(workspaceRoot, this); - return packagesWorkbookPage2; - } - - BeaninfosWorkbookPage getBeaninfosPage(){ - if(beaninfosPropertyPage2==null) - beaninfosPropertyPage2 = new BeaninfosWorkbookPage(workspaceRoot, this); - return beaninfosPropertyPage2; - } - - SearchpathOrderingWorkbookPage getSearchpathOrderingPage(){ - if(searchpathOrderingWorkbookPage2==null) - searchpathOrderingWorkbookPage2 = new SearchpathOrderingWorkbookPage(this); - return searchpathOrderingWorkbookPage2; - } - - private void tabChanged(Widget widget) { - if (widget instanceof TabItem) { - IBuildSearchPage newPage = (IBuildSearchPage) ((TabItem) widget).getData(); - if (currentPage != null) { - List selection = currentPage.getSelection(); - if (!selection.isEmpty()) { - newPage.setSelection(selection); - } - } - currentPage = newPage; - } - } - - /** - * Creates a runnable that sets the configured build paths. - */ - public IRunnableWithProgress getRunnable() { - final boolean wantNature = enableBeaninfo; - final List searchPathEntries = wantNature ? getSearchpathOrderingPage().getElements() : null; - - return new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException { - if (monitor == null) { - monitor = new NullProgressMonitor(); - } - monitor.beginTask( - BeanInfoUIMessages.BeaninfoPathsBlock_UI__searchpath_operationdescription, - 10); - try { - setBeaninfoSearchpath(wantNature, searchPathEntries, monitor); - } catch (CoreException e) { - throw new InvocationTargetException(e); - } finally { - monitor.done(); - } - } - }; - } - - private void setBeaninfoSearchpath( - boolean wantNature, - List searchPathEntries, - IProgressMonitor monitor) - throws CoreException { - - if (wantNature) { - // create beaninfo nature - if (!javaProject.getProject().hasNature(BeaninfoNature.NATURE_ID)) { - addNatureIDToProject(javaProject.getProject(), BeaninfoNature.NATURE_ID, monitor); - } - - BeaninfoNature nature = BeaninfoNature.getRuntime(javaProject.getProject()); - // Now build/set the search path. - if (searchPathEntries.size() > 0) { - IBeaninfosDocEntry[] sparray = new IBeaninfosDocEntry[searchPathEntries.size()]; - Iterator itr = searchPathEntries.iterator(); - int i = 0; - while (itr.hasNext()) { - BPListElement elem = (BPListElement) itr.next(); - sparray[i++] = elem.getEntry(); - } - nature.setSearchPath(new BeaninfosDoc(sparray), monitor); - } else - nature.setSearchPath(null, monitor); - } else { - // Remove the nature, no longer wanted. - removeNatureIDFromProject(javaProject.getProject(), BeaninfoNature.NATURE_ID, monitor); - } - } - - /** - * Initializes the classpath for the given project. Multiple calls to init are allowed, - * but all existing settings will be cleared and replace by the given or default paths. - * @param project The java project to configure. - */ - public void init(IJavaProject jproject) { - this.javaProject = jproject; - //TODO: labelProvider.setJavaProject(jproject); - - try { - // If we have a config file, we will assume we have a nature. It will add it automatically - // when we ask for the information. Even if we didn't have the nature, as soon as someone - // asks for it, we would create it anyhow, and it would use the existing config file. - // If we don't have a config file, we could have the nature, so we will check for that too. - boolean haveConfigFile = jproject.getProject().getFile(BeaninfoNature.P_BEANINFO_SEARCH_PATH).exists(); - boolean haveNature = javaProject.getProject().hasNature(BeaninfoNature.NATURE_ID); - enableBeaninfo = haveConfigFile || haveNature; - if (haveNature || haveConfigFile) { - BeaninfosDoc doc = BeaninfoNature.getRuntime(javaProject.getProject()).getSearchPath(); - IClasspathEntry[] raw = javaProject.getRawClasspath(); - - List newSearchpath = new ArrayList(); - if (doc != null) { - IBeaninfosDocEntry[] sp = doc.getSearchpath(); - for (int i = 0; i < sp.length; i++) { - IBeaninfosDocEntry curr = sp[i]; - boolean isMissing = false; - BPListElement elem = null; - if (curr instanceof BeaninfoEntry) { - BeaninfoEntry be = (BeaninfoEntry) curr; - - // get the resource, this tells if the beaninfos exist or not. - Object[] paths = be.getClasspath(javaProject); - if (paths != null && paths.length > 0) { - for (int j = 0; !isMissing && j < paths.length; j++) { - Object path = paths[j]; - if (path instanceof IProject) - isMissing = !((IProject) path).exists(); - else if (path instanceof String) { - File f = new File((String) path); - isMissing = !f.exists(); - } else if (path instanceof IPath) { - isMissing = true; // Plugins are invalid in BeaninfoConfig. They only apply within contributions. - } else - isMissing = true; // Invalid, so isMissing. - } - } else - isMissing = true; - - elem = new BPBeaninfoListElement(be, getInitialSearchpaths(be), isMissing); - } else { - // Searchpath entry, see if we can find the raw classpath entry that it is for. - boolean isExported = false; - boolean isPackageMissing = true; - isMissing = true; // Initially missing until we find it. - SearchpathEntry ce = (SearchpathEntry) curr; - int kind = ce.getKind(); - IPath path = ce.getPath(); - for (int j = 0; j < raw.length; j++) { - if (raw[j].getEntryKind() == kind && raw[j].getPath().equals(path)) { - isMissing = false; - isExported = raw[j].isExported() || raw[j].getEntryKind() == IClasspathEntry.CPE_SOURCE; - String packageName = ce.getPackage(); - if (packageName != null) { - IPackageFragmentRoot[] roots = javaProject.findPackageFragmentRoots(raw[j]); - for (int k = 0; k < roots.length; k++) { - IPackageFragmentRoot iroot = roots[k]; - if (iroot.getPackageFragment(packageName).exists()) { - isPackageMissing = false; - break; - } - } - } else - isPackageMissing = false; - break; - } - } - elem = new BPSearchListElement(ce, isMissing, isPackageMissing, isExported); - } - - newSearchpath.add(elem); - } - } - - // inits the dialog field - setSearchOrderElements(newSearchpath); - - if (getPackagesPage() != null) { - getPackagesPage().init(javaProject); - getBeaninfosPage().init(javaProject); - getSearchpathOrderingPage().init(javaProject); - } - } else { - // No nature, disable, - setEnableBeaninfo(false); - } - } catch (JavaModelException e) { - setEnableBeaninfo(false); - } catch (CoreException e) { - setEnableBeaninfo(false); - } - -// listenForClasspathChange(); - doStatusLineUpdate(); - } - - /** - * Adds a nature to a project - */ - private void addNatureIDToProject(IProject proj, String natureId, IProgressMonitor monitor) - throws CoreException { - IProjectDescription description = proj.getDescription(); - String[] prevNatures = description.getNatureIds(); - String[] newNatures = new String[prevNatures.length + 1]; - System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length); - newNatures[prevNatures.length] = natureId; - description.setNatureIds(newNatures); - proj.setDescription(description, monitor); - } - - private void removeNatureIDFromProject(IProject proj, String natureId, IProgressMonitor monitor) - throws CoreException { - IProjectDescription description = proj.getDescription(); - String[] prevNatures = description.getNatureIds(); - int indx = -1; - for (int i = 0; i < prevNatures.length; i++) { - if (prevNatures[i].equals(natureId)) { - indx = i; - break; - } - } - if (indx == -1) - return; - - String[] newNatures = new String[prevNatures.length - 1]; - if (newNatures.length != 0) { - System.arraycopy(prevNatures, 0, newNatures, 0, indx); - if (indx < newNatures.length) - System.arraycopy(prevNatures, indx + 1, newNatures, indx, newNatures.length - indx); - } - description.setNatureIds(newNatures); - proj.setDescription(description, monitor); - } - - void doStatusLineUpdate() { - statusChangeListener.statusChanged(getSearchpathOrderingPage().getStatus()); - } - - /* - * searchOrder dialog must never have all of elements set - * directly. Must come through here first so that we can - * make sure updates occur in correct sequence, else - * we will wind up with entries being marked as unexported - * when they really are exported. - */ - public void setSearchOrderElements(List newElements) { - ArrayList exportedEntries = new ArrayList(newElements.size()); - for (Iterator iter = newElements.iterator(); iter.hasNext();) { - BPListElement element = (BPListElement) iter.next(); - if (element.isExported()) - exportedEntries.add(element); - } - - getSearchpathOrderingPage().setElements(newElements); - getSearchpathOrderingPage().setCheckedElements(exportedEntries); - } - - /* - * Create the Searchpath elements for a BeaninfoElement. - * Return null if not to update. - */ - private BPSearchListElement[] getInitialSearchpaths(BeaninfoEntry infoEntry) { - - // We can only verify the existence of packages within beaninfos that are - // located within a project on the desktop. Otherwise we can't find out what - // packages are in them. - IPackageFragmentRoot[] roots = null; - - if (infoEntry.getKind() != BeaninfoEntry.BIE_PLUGIN) { - IClasspathEntry resolved = JavaCore.getResolvedClasspathEntry(infoEntry.getClasspathEntry()); - IResource res = workspaceRoot.findMember(resolved.getPath()); - if (res != null && res.exists()) { - if (res instanceof IProject) { - // It is a project itself. - IJavaProject jp = (IJavaProject) JavaCore.create(res); - try { - if (jp != null) - roots = jp.getPackageFragmentRoots(); // All of the roots in the project are applicable. - } catch (JavaModelException e) { - } - } else { - // It is within another project - IProject containingProject = res.getProject(); - IJavaProject jp = JavaCore.create(containingProject); - if (jp != null) { - // The roots if this is in the classpath of this project - try { - IPackageFragmentRoot root = jp.findPackageFragmentRoot(resolved.getPath()); - if (root != null) - roots = new IPackageFragmentRoot[] { root }; - } catch (JavaModelException e) { - } - } - } - } - } - - SearchpathEntry[] entries = infoEntry.getSearchPaths(); - BPSearchListElement[] packageElements = new BPSearchListElement[entries.length]; - for (int i = 0; - i < entries.length; - i++) { // Searchpath entry, see if we can find the raw classpath entry that it is for. - boolean isPackageMissing = roots != null; - // If roots is null, then the package isn't missing because we can't test for it. - SearchpathEntry ce = entries[i]; - if (roots != null) { - String packageName = ce.getPackage(); - for (int k = 0; k < roots.length; k++) { - IPackageFragmentRoot iroot = roots[k]; - if (iroot.getPackageFragment(packageName).exists()) { - isPackageMissing = false; - break; - } - } - } - packageElements[i] = new BPSearchListElement(ce, false, isPackageMissing, false); - } - - return packageElements; - } - - - public static List getSelectedList(ISelection selection){ - List selectedList = null; - if(selection!=null && !selection.isEmpty() && selection instanceof IStructuredSelection){ - IStructuredSelection structuredSelection = (IStructuredSelection) selection; - selectedList = new ArrayList(Arrays.asList(structuredSelection.toArray())); - } - return selectedList; - } - - public boolean isBeaninfoEnabled(){ - return enableBeaninfo; - } -} diff --git a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/BeaninfosPropertyPage.java b/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/BeaninfosPropertyPage.java deleted file mode 100644 index 1950ca89c..000000000 --- a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/BeaninfosPropertyPage.java +++ /dev/null @@ -1,209 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 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.jem.internal.beaninfo.ui; -/* - - - */ - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; -import org.eclipse.jdt.core.*; -import org.eclipse.jface.dialogs.DialogPage; -import org.eclipse.jface.dialogs.IMessageProvider; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.*; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation; -import org.eclipse.ui.dialogs.PropertyPage; - -import org.eclipse.jem.internal.ui.core.JEMUIPlugin; - -/** - * Property page for configuring Beaninfo path - */ -public class BeaninfosPropertyPage extends PropertyPage implements IStatusChangeListener { - - /** - * Applies the status to the status line of a dialog page. - * - * @param page the dialog page - * @param status the status - */ - public static void applyToStatusLine(DialogPage page, IStatus status) { - String message= status.getMessage(); - switch (status.getSeverity()) { - case IStatus.OK: - page.setMessage(message, IMessageProvider.NONE); - page.setErrorMessage(null); - break; - case IStatus.WARNING: - page.setMessage(message, IMessageProvider.WARNING); - page.setErrorMessage(null); - break; - case IStatus.INFO: - page.setMessage(message, IMessageProvider.INFORMATION); - page.setErrorMessage(null); - break; - default: - if (message.length() == 0) { - message= null; - } - page.setMessage(null); - page.setErrorMessage(message); - break; - } - } - - private BeaninfoPathsBlock fBuildPathsBlock; - private IResourceChangeListener listener; - private IProject project; - - /* - * @see PreferencePage#createControl(Composite) - */ - protected Control createContents(Composite parent) { -// when we get help working. -// WorkbenchHelp.setHelp(parent, new DialogPageContextComputer(this, IJavaHelpContextIds.BUILD_PATH_PROPERTY_PAGE)); - - // ensure the page has no special buttons - noDefaultAndApplyButton(); - - project= getProject(); - if (project == null || !isJavaProject(project)) { - return createWithoutJava(parent); - } else if (!project.isOpen()) { - return createForClosedProject(parent); - } else { - return createWithJava(parent); - } - } - - /** - * Content for valid projects. - */ - private Control createWithJava(Composite parent) { - IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot(); - fBuildPathsBlock= new BeaninfoPathsBlock(root, this); - final IJavaProject jproject = JavaCore.create(project); - fBuildPathsBlock.init(jproject); - final IPath classpathfile = project.getFile(".classpath").getFullPath(); //$NON-NLS-1$ - listener = new IResourceChangeListener() { - - /* (non-Javadoc) - * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent) - */ - public void resourceChanged(IResourceChangeEvent event) { - if (fBuildPathsBlock != null) { - if (event.getDelta().findMember(classpathfile) != null) - getControl().getDisplay().asyncExec(new Runnable() { // Can be called outside of display loop - public void run() { - fBuildPathsBlock.init(jproject); - } - }); - } - } - }; - project.getWorkspace().addResourceChangeListener(listener, IResourceChangeEvent.POST_CHANGE); - - return fBuildPathsBlock.createControl(parent); - } - - /** - * Content for non-Java projects. - */ - private Control createWithoutJava(Composite parent) { - Label label= new Label(parent, SWT.LEFT); - label.setText(BeanInfoUIMessages.BeaninfoPropertiesPage_INFO__nojavaproject); - - fBuildPathsBlock= null; - setValid(true); - return label; - } - - /** - * Content for closed projects. - */ - private Control createForClosedProject(Composite parent) { - Label label= new Label(parent, SWT.LEFT); - label.setText(BeanInfoUIMessages.BeaninfoPropertiesPage_INFO__closedproject); - - fBuildPathsBlock= null; - setValid(true); - return label; - } - - private IProject getProject() { - IAdaptable adaptable= getElement(); - if (adaptable != null) { - IJavaElement elem= (IJavaElement) adaptable.getAdapter(IJavaElement.class); - if (elem instanceof IJavaProject) { - return ((IJavaProject) elem).getProject(); - } - } - return null; - } - - private boolean isJavaProject(IProject proj) { - try { - return proj.hasNature(JavaCore.NATURE_ID); - } catch (CoreException e) { - JEMUIPlugin.getPlugin().getLogger().log(e.getStatus()); - } - return false; - } - - /* - * @see IPreferencePage#performOk - */ - public boolean performOk() { - if (fBuildPathsBlock != null) { - IRunnableWithProgress runnable= fBuildPathsBlock.getRunnable(); - - IRunnableWithProgress op= new WorkspaceModifyDelegatingOperation(runnable); - Shell shell= getControl().getShell(); - try { - PlatformUI.getWorkbench().getProgressService().run(false, false, op); - } catch (InvocationTargetException e) { - String title= BeanInfoUIMessages.Beaninfo_UI__errortitle; - String message= BeanInfoUIMessages.Beaninfo_UI__error; - ExceptionHandler.handle(e, shell, title, message); - return false; - } catch (InterruptedException e) { - // cancelled - return false; - } - } - return true; - } - - /** - * @see IStatusChangeListener#statusChanged - */ - public void statusChanged(IStatus status) { - setValid(!status.matches(IStatus.ERROR)); - applyToStatusLine(this, status); - } - - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.IDialogPage#dispose() - */ - public void dispose() { - if (listener != null) - project.getWorkspace().removeResourceChangeListener(listener); - listener = null; - super.dispose(); - } -} diff --git a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/BeaninfosWorkbookPage.java b/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/BeaninfosWorkbookPage.java deleted file mode 100644 index 32aa8848e..000000000 --- a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/BeaninfosWorkbookPage.java +++ /dev/null @@ -1,640 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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.jem.internal.beaninfo.ui; - -import java.util.*; -import java.util.List; - -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jdt.core.*; -import org.eclipse.jdt.ui.JavaElementLabelProvider; -import org.eclipse.jdt.ui.wizards.BuildPathDialogAccess; -import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.jface.dialogs.StatusDialog; -import org.eclipse.jface.viewers.*; -import org.eclipse.jface.window.Window; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.*; -import org.eclipse.swt.widgets.*; -import org.eclipse.ui.dialogs.*; -import org.eclipse.ui.model.WorkbenchContentProvider; -import org.eclipse.ui.model.WorkbenchLabelProvider; - -import org.eclipse.jem.internal.beaninfo.core.BeaninfoEntry; -import org.eclipse.jem.internal.ui.core.JEMUIPlugin; - -public class BeaninfosWorkbookPage implements IBuildSearchPage{ - - private static final String DIALOGSTORE_LASTVARIABLE = JEMUIPlugin.PI_BEANINFO_UI + ".lastvar"; //$NON-NLS-1$ - - // a dialog to choose a variable - private class VariableSelectionDialog extends StatusDialog implements IStatusChangeListener { - private VariableSelectionBlock fVariableSelectionBlock; - IDialogSettings dialogSettings= JEMUIPlugin.getPlugin().getDialogSettings(); - - public VariableSelectionDialog(Shell parent, List existingPaths) { - super(parent); - setTitle("New Variable Classpath Entry"); //$NON-NLS-1$ - String initVar= dialogSettings.get(DIALOGSTORE_LASTVARIABLE); - fVariableSelectionBlock= new VariableSelectionBlock(this, existingPaths, null, initVar, false); - } - - /* - * @see Windows#configureShell - */ - protected void configureShell(Shell newShell) { - super.configureShell(newShell); -// WorkbenchHelp.setHelp(newShell, IJavaHelpContextIds.VARIABLE_SELECTION_DIALOG); - } - - /* - * @see StatusDialog#createDialogArea() - */ - protected Control createDialogArea(Composite parent) { - Composite composite= (Composite)super.createDialogArea(parent); - - Label message= new Label(composite, SWT.WRAP); - message.setText("New Variable Classpath Entry"); //$NON-NLS-1$ - message.setLayoutData(new GridData()); - - Control inner= fVariableSelectionBlock.createControl(composite); - inner.setLayoutData(new GridData(GridData.FILL_BOTH)); - return composite; - } - - /* - * @see Dialog#okPressed() - */ - protected void okPressed() { - dialogSettings.put(DIALOGSTORE_LASTVARIABLE, getVariable().segment(0)); - super.okPressed(); - } - - /* - * @see IStatusChangeListener#statusChanged() - */ - public void statusChanged(IStatus status) { - updateStatus(status); - } - - public IPath getVariable() { - return fVariableSelectionBlock.getVariablePath(); - } - } - - - //controls - private Composite javaProjectsComposite = null; - private Label label = null; - private Table table = null; - private Composite buttonsBar = null; - private Button addFoldersbutton = null; - private Button addJarsButton = null; - private Button addExtJarsButton = null; - private Button addVariableButton = null; - private Button addProjectButton = null; - private Button modifyPathsButton = null; - private Button removeButton = null; - private Label spacer2 = null; - private Label spacer1 = null; - // .. controls - private TableViewer tableViewer; - - private BeaninfoPathsBlock beaninfoPathsBlock; - private IJavaProject javaProject; - private List beaninfosList; - private IWorkspaceRoot workspaceRoot; - private IClasspathEntry[] resolvedList; - private IClasspathEntry[] rawList; - private SearchPathListLabelProvider labelProvider; - - public BeaninfosWorkbookPage(IWorkspaceRoot workspaceRoot, BeaninfoPathsBlock beaninfoPathsBlock) { - this.workspaceRoot = workspaceRoot; - this.beaninfoPathsBlock = beaninfoPathsBlock; - this.labelProvider = new SearchPathListLabelProvider(); - this.beaninfosList = new ArrayList(); - if(spacer1==null || spacer2==null){ - // just have SOME read access - } - } - - /** - * This method initializes javaProjectsComposite - * - */ - public Control createControl(Composite parent) { - GridData gridData = new org.eclipse.swt.layout.GridData(); - gridData.horizontalSpan = 2; - GridLayout gridLayout = new GridLayout(); - gridLayout.numColumns = 2; - javaProjectsComposite = new Composite(parent, SWT.NONE); - javaProjectsComposite.setLayout(gridLayout); - label = new Label(javaProjectsComposite, SWT.NONE); - label.setText(BeanInfoUIMessages.BeanInfosWorkbookPage_List_Text); - label.setLayoutData(gridData); - createTable(); - createButtonsBar(); - updateEnabledStates(); - return javaProjectsComposite; - } - - /** - * This method initializes table - * - */ - private void createTable() { - GridData gridData1 = new org.eclipse.swt.layout.GridData(); - gridData1.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL; - gridData1.grabExcessHorizontalSpace = true; - gridData1.grabExcessVerticalSpace = true; - gridData1.verticalAlignment = org.eclipse.swt.layout.GridData.FILL; - table = new Table(javaProjectsComposite, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); - table.setLayoutData(gridData1); - table.addSelectionListener(new SelectionListener(){ - public void widgetSelected(SelectionEvent e) { - updateButtons(); - } - public void widgetDefaultSelected(SelectionEvent e) { - widgetSelected(e); - } - }); - tableViewer = new TableViewer(table); - tableViewer.setSorter(new BIListElementSorter()); - tableViewer.setContentProvider(new ArrayContentProvider()); - tableViewer.setLabelProvider(labelProvider); - tableViewer.setInput(beaninfosList); - } - - /** - * This method initializes buttonsBar - * - */ - private void createButtonsBar() { - RowLayout rowLayout = new RowLayout(); - rowLayout.type = org.eclipse.swt.SWT.VERTICAL; - rowLayout.marginLeft = 3; - rowLayout.fill = true; - GridData gridData2 = new org.eclipse.swt.layout.GridData(); - gridData2.grabExcessVerticalSpace = true; - gridData2.verticalAlignment = org.eclipse.swt.layout.GridData.FILL; - gridData2.horizontalAlignment = org.eclipse.swt.layout.GridData.BEGINNING; - buttonsBar = new Composite(javaProjectsComposite, SWT.NONE); - buttonsBar.setLayoutData(gridData2); - buttonsBar.setLayout(rowLayout); - addFoldersbutton = new Button(buttonsBar, SWT.NONE); - addFoldersbutton.setText(BeanInfoUIMessages.BeanInfosWorkbookPage_AddFolders); - addFoldersbutton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() { - public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { - List beaninfoEntries = chooseClassContainers(); - addToBeaninfosList(beaninfoEntries); - } - }); - addJarsButton = new Button(buttonsBar, SWT.NONE); - addJarsButton.setText(BeanInfoUIMessages.BeanInfosWorkbookPage_AddJARs); - addJarsButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() { - public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { - List beaninfoEntries = chooseJarFiles(); - addToBeaninfosList(beaninfoEntries); - } - }); - addExtJarsButton = new Button(buttonsBar, SWT.NONE); - addExtJarsButton.setText(BeanInfoUIMessages.BeanInfosWorkbookPage_AddExternalJAR); - addExtJarsButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() { - public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { - List beaninfoEntries = chooseExtJarFiles(); - addToBeaninfosList(beaninfoEntries); - } - }); - addVariableButton = new Button(buttonsBar, SWT.NONE); - addVariableButton.setText(BeanInfoUIMessages.BeanInfosWorkbookPage_AddVariable); - addVariableButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() { - public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { - List beaninfoEntries = chooseVariableEntries(); - addToBeaninfosList(beaninfoEntries); - } - }); - addProjectButton = new Button(buttonsBar, SWT.NONE); - addProjectButton.setText(BeanInfoUIMessages.BeanInfosWorkbookPage_AddProjects); - addProjectButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() { - public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { - List beaninfoEntries = chooseProjects(); - addToBeaninfosList(beaninfoEntries); - } - }); - spacer1 = new Label(buttonsBar, SWT.NONE); - modifyPathsButton = new Button(buttonsBar, SWT.NONE); - modifyPathsButton.setText(BeanInfoUIMessages.BeanInfosWorkbookPage_ModifyPaths); - modifyPathsButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() { - public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { - modifySearchPaths(); - } - }); - spacer2 = new Label(buttonsBar, SWT.NONE); - removeButton = new Button(buttonsBar, SWT.NONE); - removeButton.setText(BeanInfoUIMessages.BeanInfosWorkbookPage_Remove); - removeButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() { - public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { - List selected = BeaninfoPathsBlock.getSelectedList(tableViewer.getSelection()); - beaninfosList.removeAll(selected); - tableViewer.refresh(); - pageChanged(); - } - }); - } - - private List chooseVariableEntries() { - // Remove existing variable entries in both the classpath and the beaninfopaths. - // Don't want classpath ones because they should be of been selected in the search paths page. - ArrayList existingPaths= new ArrayList(); - for (int i= 0; i < rawList.length; i++) { - if (rawList[i].getEntryKind() == IClasspathEntry.CPE_VARIABLE) { - existingPaths.add(rawList[i].getPath()); - } - } - - List ours = beaninfosList; - for (int i = 0; i < ours.size(); i++) { - BPBeaninfoListElement bpb = (BPBeaninfoListElement) ours.get(i); - if (bpb.getEntry().getKind() == IClasspathEntry.CPE_VARIABLE) - existingPaths.add(bpb.getEntry().getPath()); - } - - VariableSelectionDialog dialog= new VariableSelectionDialog(addVariableButton.getShell(), existingPaths); - if (dialog.open() == Window.OK) { - IPath path= dialog.getVariable(); - IClasspathEntry cpe = JavaCore.newVariableEntry(path, null, null); - IPath resolvedPath= JavaCore.getResolvedVariablePath(path); - boolean isMissing = resolvedPath == null || !resolvedPath.toFile().isFile(); - return Collections.singletonList(new BPBeaninfoListElement(new BeaninfoEntry(cpe, null, true), null, isMissing)); - } - return null; - } - - private List chooseJarFiles() { - IPath[] jarPaths = BuildPathDialogAccess.chooseJAREntries(addJarsButton.getShell(), javaProject.getPath(), getUsedJARFiles()); - if (jarPaths!=null) { - List res= new ArrayList(jarPaths.length); - for (int i= 0; i < jarPaths.length; i++) { - BPBeaninfoListElement newGuy = newBPBeaninfoListElementFromFullpath(jarPaths[i]); - if (newGuy != null) - res.add(newGuy); - } - return res; - } - return null; - } - - private List chooseExtJarFiles() { - IPath[] extJARPaths = BuildPathDialogAccess.chooseExternalJAREntries(addExtJarsButton.getShell()); - List elems = null; - if(extJARPaths!=null){ - elems = new ArrayList(extJARPaths.length); - for (int i= 0; i < extJARPaths.length; i++) { - BPBeaninfoListElement newGuy = newBPBeaninfoListElement(extJARPaths[i]); - if (newGuy != null) - elems.add(newGuy); - } - } - return elems; - } - - private BPBeaninfoListElement newBPBeaninfoListElement(IPath path) { - // Create for an external, if not already used in either classpath or beaninfo path. - // These can't be pre-selected out like for the other choose dialogs. - for (int i = 0; i < resolvedList.length; i++) { - IClasspathEntry cpe = resolvedList[i]; - if (cpe != null && cpe.getEntryKind() == IClasspathEntry.CPE_LIBRARY && cpe.getPath().equals(path)) - return null; // Already exists. - } - - // Now see if one of ours. - List ours = beaninfosList; - for (int i = 0; i < ours.size(); i++) { - BPBeaninfoListElement bpb = (BPBeaninfoListElement) ours.get(i); - if (bpb.getEntry().getKind() == IClasspathEntry.CPE_LIBRARY && bpb.getEntry().getPath().equals(path)) - return null; // Already exists - } - - IClasspathEntry cpe = JavaCore.newLibraryEntry(path, null, null); - BeaninfoEntry bie = new BeaninfoEntry(cpe, null, true); - return new BPBeaninfoListElement(bie, null, false); - } - - - private IPath[] getUsedJARFiles() { - // Jars used by both the classpath and the beaninfo search path. - // Don't want jars used by classpath because those would then be - // in the buildpath and user would select paths through the search path page. - ArrayList res= new ArrayList(); - for (int i= 0; i < resolvedList.length; i++) { - if (resolvedList[i] != null && resolvedList[i].getEntryKind() == IClasspathEntry.CPE_LIBRARY) { - IPath path = resolvedList[i].getPath(); - IResource resource= workspaceRoot.findMember(path); - if (resource instanceof IFile) - res.add(path); - } - } - - List bilist= beaninfosList; - for (int i= 0; i < bilist.size(); i++) { - BPListElement elem= (BPListElement)bilist.get(i); - if (elem.getEntry().getKind() == IClasspathEntry.CPE_LIBRARY) { - IPath path = elem.getEntry().getPath(); - IResource resource= workspaceRoot.findMember(path); - if (resource instanceof IFile) - res.add(path); - } - } - return (IPath[]) res.toArray(new IPath[res.size()]); - } - - /** - * Create a new BPListElement for the given object. - */ - private BPBeaninfoListElement newBPBeaninfoListElement(IResource element) { - if (element instanceof IContainer || element instanceof IFile) { - return newBPBeaninfoListElementFromFullpath(element.getFullPath()); - } - return null; - } - - /** - * Create a new BPListElement for the given object. - * @since 1.2.0 - */ - private BPBeaninfoListElement newBPBeaninfoListElementFromFullpath(IPath fullPath) { - if(fullPath!=null){ - IClasspathEntry cpe = JavaCore.newLibraryEntry(fullPath, null, null); - BeaninfoEntry bie = new BeaninfoEntry(cpe, null, true); - return new BPBeaninfoListElement(bie, null, false); - } - return null; - } - - private List chooseClassContainers() { - Class[] acceptedClasses= new Class[] { IFolder.class }; - ISelectionStatusValidator validator= new TypedElementSelectionValidator(acceptedClasses, true); - - acceptedClasses= new Class[] { IProject.class, IFolder.class }; - - ViewerFilter filter= new TypedViewerFilter(acceptedClasses, getUsedContainers()); - - ILabelProvider lp= new WorkbenchLabelProvider(); - ITreeContentProvider cp= new WorkbenchContentProvider(); - - ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(addFoldersbutton.getShell(), lp, cp); - dialog.setValidator(validator); - dialog.setTitle(BeanInfoUIMessages.BeanInfosWorkbookPage_SelectionDialog_Classes_Title); - dialog.setMessage(BeanInfoUIMessages.BeanInfosWorkbookPage_SelectionDialog_Classes_Prompt); - dialog.addFilter(filter); - dialog.setInput(workspaceRoot); - dialog.setInitialSelection(javaProject.getProject()); - - if (dialog.open() == Window.OK) { - Object[] elements= dialog.getResult(); - List res= new ArrayList(elements.length); - for (int i= 0; i < elements.length; i++) { - BPBeaninfoListElement newGuy = newBPBeaninfoListElement((IResource) elements[i]); - if (newGuy != null) - res.add(newGuy); - } - return res; - } - return null; - } - - private IContainer[] getUsedContainers() { - // Containers used by both the classpath and the beaninfo search path. - // Don't want containers used by classpath because those would then be - // in the buildpath and user would select paths through the search path page. - ArrayList res= new ArrayList(); - try { - IPath outputLocation= javaProject.getOutputLocation(); - if (outputLocation != null) { - IResource resource= workspaceRoot.findMember(outputLocation); - if (resource instanceof IContainer) { - res.add(resource); - } - } - } catch (JavaModelException e) { - // ignore it here, just log - JEMUIPlugin.getPlugin().getLogger().log(e.getStatus()); - } - - for (int i= 0; i < resolvedList.length; i++) { - if (resolvedList[i] != null && resolvedList[i].getEntryKind() == IClasspathEntry.CPE_SOURCE) { - IResource resource= workspaceRoot.findMember(resolvedList[i].getPath()); - if (resource instanceof IContainer) { - res.add(resource); - } - } - } - - List bilist= beaninfosList; - for (int i= 0; i < bilist.size(); i++) { - BPListElement elem= (BPListElement)bilist.get(i); - if (elem.getEntry().getKind() == IClasspathEntry.CPE_SOURCE) { - IResource resource= workspaceRoot.findMember(elem.getEntry().getPath()); - res.add(resource); - } - } - return (IContainer[]) res.toArray(new IContainer[res.size()]); - } - - - protected void addToBeaninfosList(final List toAdd){ - if (beaninfosList != null && toAdd!=null) { - beaninfosList.addAll(toAdd); - tableViewer.refresh(); - table.getDisplay().asyncExec(new Runnable(){ - public void run() { - tableViewer.setSelection(new StructuredSelection(toAdd)); - } - }); - pageChanged(); - } - } - - private void pageChanged() { - if (javaProject != null) { - // already initialized - updateSearchpathList(); - } - } - - private void updateSearchpathList() { - List searchelements = beaninfoPathsBlock.getSearchpathOrderingPage().getElements(); - - List beaninfoelements = new ArrayList(beaninfosList); - - boolean changeDone = false; - // First go through the search path and remove any Beaninfo list elements that - // are not in this pages beaninfos list. - for (ListIterator spitr = searchelements.listIterator(searchelements.size()); - spitr.hasPrevious(); - ) { - BPListElement element = (BPListElement) spitr.previous(); - if (element instanceof BPBeaninfoListElement && !beaninfoelements.remove(element)) { - // Search element and not found in packages list so remove it from searchpath list. - spitr.remove(); - changeDone = true; - } - } - // Any left over in beaninfos list are new and need to be added. - searchelements.addAll(beaninfoelements); - changeDone = changeDone || !beaninfoelements.isEmpty(); - - if (changeDone) - beaninfoPathsBlock.setSearchOrderElements(searchelements); - } - - public void init(IJavaProject javaProject){ - this.javaProject = javaProject; - labelProvider.setJavaProject(this.javaProject); - try { - rawList = this.javaProject.getRawClasspath(); - resolvedList = new IClasspathEntry[rawList.length]; - for (int i = 0; i < rawList.length; i++) { - resolvedList[i] = JavaCore.getResolvedClasspathEntry(rawList[i]); - } - } catch (JavaModelException e) { - rawList = resolvedList = new IClasspathEntry[0]; - } - updateBeaninfosList(); - } - - private void updateBeaninfosList() { - List spelements = beaninfoPathsBlock.getSearchpathOrderingPage().getElements(); - - List biElements = new ArrayList(spelements.size()); - for (int i = 0; i < spelements.size(); i++) { - BPListElement spe = (BPListElement) spelements.get(i); - if (spe instanceof BPBeaninfoListElement) { - biElements.add(spe); - } - } - beaninfosList.clear(); - beaninfosList.addAll(biElements); - if(tableViewer!=null && !table.isDisposed()) - tableViewer.refresh(); - } - - public List getSelection() { - if(tableViewer!=null) - return BeaninfoPathsBlock.getSelectedList(tableViewer.getSelection()); - return null; - } - - public void setSelection(List selection) { - if(tableViewer!=null) - tableViewer.setSelection(new StructuredSelection(selection)); - } - - - protected void updateButtons(){ - List selected = BeaninfoPathsBlock.getSelectedList(tableViewer.getSelection()); - addExtJarsButton.setEnabled(beaninfoPathsBlock.isBeaninfoEnabled()); - addFoldersbutton.setEnabled(beaninfoPathsBlock.isBeaninfoEnabled()); - addJarsButton.setEnabled(beaninfoPathsBlock.isBeaninfoEnabled()); - addProjectButton.setEnabled(beaninfoPathsBlock.isBeaninfoEnabled()); - addVariableButton.setEnabled(beaninfoPathsBlock.isBeaninfoEnabled()); - - removeButton.setEnabled(selected!=null && selected.size()>0 && beaninfoPathsBlock.isBeaninfoEnabled()); - modifyPathsButton.setEnabled(selected!=null && selected.size()==1 && beaninfoPathsBlock.isBeaninfoEnabled()); - } - - private List chooseProjects() { - Class[] acceptedClasses= new Class[] { IJavaProject.class }; - ISelectionStatusValidator validator= new TypedElementSelectionValidator(acceptedClasses, true); - - List allProjects = null; - try { - allProjects = new ArrayList(Arrays.asList(javaProject.getJavaModel().getChildren())); - } catch(JavaModelException e) { - allProjects = Collections.EMPTY_LIST; - } - allProjects.removeAll(getUsedProjects()); - - ILabelProvider lp= new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_DEFAULT); - - ElementListSelectionDialog dialog= new ElementListSelectionDialog(addProjectButton.getShell(), lp); - dialog.setValidator(validator); - dialog.setTitle(BeanInfoUIMessages.BeanInfosWorkbookPage_SelectionDialog_Projects_Title); - dialog.setMessage(BeanInfoUIMessages.BeanInfosWorkbookPage_SelectionDialog_Projects_Prompt); - dialog.setElements(allProjects.toArray()); - - if (dialog.open() == Window.OK) { - Object[] elements= dialog.getResult(); - List res= new ArrayList(elements.length); - for (int i= 0; i < elements.length; i++) { - try { - IClasspathEntry cpe = JavaCore.newProjectEntry(((IJavaProject) elements[i]).getCorrespondingResource().getFullPath()); - BeaninfoEntry bie = new BeaninfoEntry(cpe, null, true); - res.add(new BPBeaninfoListElement(bie, null, false)); - } catch(JavaModelException e) { - } - } - return res; - } - return null; - } - - private List getUsedProjects() { - // Projects used by both the classpath and the beaninfo search path. - // Don't want projects used by classpath because those would then be - // in the buildpath and user would select paths through the search path page. - ArrayList res= new ArrayList(); - res.add(javaProject); // Plus our own project is used. - IJavaModel jmodel = javaProject.getJavaModel(); - for (int i= 0; i < resolvedList.length; i++) { - if (resolvedList[i] != null && resolvedList[i].getEntryKind() == IClasspathEntry.CPE_PROJECT) { - res.add(jmodel.getJavaProject(resolvedList[i].getPath().segment(0))); - } - } - - List bilist= beaninfosList; - for (int i= 0; i < bilist.size(); i++) { - BPListElement elem= (BPListElement)bilist.get(i); - if (elem.getEntry().getKind() == IClasspathEntry.CPE_PROJECT) - res.add(jmodel.getJavaProject(elem.getEntry().getPath().segment(0))); - } - return res; - } - - private void modifySearchPaths() { - // Bring up the dialog for modifying search paths of a particular beaninfo entry. - BPBeaninfoListElement elem = (BPBeaninfoListElement) ((IStructuredSelection)tableViewer.getSelection()).getFirstElement(); // There should only be one, button not enabled if none or more than one selected. - BeaninfoEntrySearchpathDialog dialog = new BeaninfoEntrySearchpathDialog(modifyPathsButton.getShell(), elem, javaProject); - dialog.open(); - } - - protected void updateEnabledStates(){ - updateButtons(); - table.setEnabled(beaninfoPathsBlock.isBeaninfoEnabled()); - label.setEnabled(beaninfoPathsBlock.isBeaninfoEnabled()); - } - - public void setBeaninfoEnabled(boolean enable) { - if(javaProjectsComposite!=null && !javaProjectsComposite.isDisposed()){ - // ui populated - updateEnabledStates(); - } - } - -} // @jve:decl-index=0:visual-constraint="10,10" diff --git a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/ExceptionHandler.java b/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/ExceptionHandler.java deleted file mode 100644 index 96935d2ce..000000000 --- a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/ExceptionHandler.java +++ /dev/null @@ -1,81 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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.jem.internal.beaninfo.ui; - -import java.io.StringWriter; -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.swt.widgets.Shell; - -import org.eclipse.jem.internal.ui.core.JEMUIPlugin; - -/** - * - * - * @since 1.2.0 - */ -public class ExceptionHandler { - - /** - * - * @param e - * @param shell - * @param title - * @param message - * - * @since 1.2.0 - */ - public static void handle(InvocationTargetException e, Shell shell, String title, String message) { - Throwable target= e.getTargetException(); - if (target instanceof CoreException) { - handle((CoreException)target, shell, title, message); - } else { - JEMUIPlugin.getPlugin().getLogger().log(e); - if (e.getMessage() != null && e.getMessage().length() > 0) { - displayMessageDialog(e, e.getMessage(), shell, title, message); - } else { - displayMessageDialog(e, target.getMessage(), shell, title, message); - } - } - } - - public static void handle(CoreException e, Shell shell, String title, String message) { - JEMUIPlugin.getPlugin().getLogger().log(e); - IStatus status= e.getStatus(); - if (status != null) { - ErrorDialog.openError(shell, title, message, status); - } else { - displayMessageDialog(e, e.getMessage(), shell, title, message); - } - } - - private static void displayMessageDialog(Throwable t, String exceptionMessage, Shell shell, String title, String message) { - StringWriter msg= new StringWriter(); - if (message != null) { - msg.write(message); - msg.write("\n\n"); //$NON-NLS-1$ - } - if (exceptionMessage == null || exceptionMessage.length() == 0) - msg.write(BeanInfoUIMessages.ExceptionHandler_errordialog_msg_seelog); - else - msg.write(exceptionMessage); - MessageDialog.openError(shell, title, msg.toString()); - } - -} diff --git a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/IBuildSearchPage.java b/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/IBuildSearchPage.java deleted file mode 100644 index ff6670b21..000000000 --- a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/IBuildSearchPage.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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.jem.internal.beaninfo.ui; - -import java.util.List; - -public interface IBuildSearchPage { - - public List getSelection(); - public void setSelection(List selection); - public void setBeaninfoEnabled(boolean enable); -} diff --git a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/IStatusChangeListener.java b/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/IStatusChangeListener.java deleted file mode 100644 index ae3fce5f3..000000000 --- a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/IStatusChangeListener.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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.jem.internal.beaninfo.ui; - -import org.eclipse.core.runtime.IStatus; - -/** - * Status change listener - * - * @since 1.2.0 - */ -public interface IStatusChangeListener { - - /** - * Notifies this listener that the given status has changed. - * - * @param status the new status - */ - void statusChanged(IStatus status); -} diff --git a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/ImageDisposer.java b/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/ImageDisposer.java deleted file mode 100644 index 6891ff749..000000000 --- a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/ImageDisposer.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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.jem.internal.beaninfo.ui; - -import org.eclipse.core.runtime.Assert; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; -import org.eclipse.swt.graphics.Image; - -/** - * - * - * @since 1.2.0 - */ -public class ImageDisposer implements DisposeListener { - - private Image[] fImages; - - public ImageDisposer(Image image) { - this(new Image[] { image }); - } - - public ImageDisposer(Image[] images) { - Assert.isNotNull(images); - fImages= images; - } - - /* - * @see WidgetListener#widgetDisposed - */ - public void widgetDisposed(DisposeEvent e) { - if (fImages != null) { - for (int i= 0; i < fImages.length; i++) { - fImages[i].dispose(); - } - } - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/OverlayComposite.java b/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/OverlayComposite.java deleted file mode 100644 index be40bf4d9..000000000 --- a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/OverlayComposite.java +++ /dev/null @@ -1,200 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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 - *******************************************************************************/ -/* - * Created Apr 27, 2005 by Gili Mendel - * - - - */ -package org.eclipse.jem.internal.beaninfo.ui; - -import java.util.*; - -import org.eclipse.jface.resource.CompositeImageDescriptor; -import org.eclipse.swt.graphics.ImageData; -import org.eclipse.swt.graphics.Point; - -//TODO: This class was dropped in 3.1 M7 from org.eclipse.ui.internal.misc -// We made local copy for the time being. Need to investigate if this is file -// for us given that the OverlayIcon (replacement) is internal -public class OverlayComposite extends CompositeImageDescriptor { - - private ImageData backgroundImage; - - private ImageData leftImage; - - private ImageData rightImage; - - private ImageData topImage; - - private ImageData bottomImage; - - private List foregroundImages = new ArrayList(); - - /** - * Create an instance of this class. - */ - public OverlayComposite(ImageData background) { - backgroundImage = background; - } - - /** - * Add the passed image to this descriptor's collection of images to - * be composed together to create an image. - */ - public void addForegroundImage(ImageData image) { - foregroundImages.add(image); - } - - /** - *Superimpose self's images within the given bounds by means of #drawImage - * - *@see CompositeImage#drawImage(ImageData src,int ox,int oy) - */ - protected void drawCompositeImage(int width, int height) { - //draw background - drawImage(backgroundImage, getLeftBound(), getTopBound()); - - //draw foreground images - Iterator e = foregroundImages.iterator(); - while (e.hasNext()) - drawImage(((ImageData) e.next()), getLeftBound(), getTopBound()); - - //draw extensions - if (topImage != null) - drawImage(topImage, getLeftBound(), 0); - if (bottomImage != null) - drawImage(bottomImage, getLeftBound(), height - bottomImage.height); - if (leftImage != null) - drawImage(leftImage, 0, getTopBound()); - if (rightImage != null) - drawImage(rightImage, width - rightImage.width, getTopBound()); - - } - - /** - * @see Object#equals - */ - public boolean equals(Object o) { - if (!(o instanceof OverlayComposite)) { - return false; - } - OverlayComposite other = (OverlayComposite) o; - - return equals(backgroundImage, other.backgroundImage) - && equals(leftImage, other.leftImage) - && equals(rightImage, other.rightImage) - && equals(topImage, other.topImage) - && equals(bottomImage, other.bottomImage) - && equals(foregroundImages, other.foregroundImages); - } - - /** - * Private utility for comparing two possibly-null objects. - */ - private boolean equals(Object o1, Object o2) { - return o1 == null ? o2 == null : o1.equals(o2); - } - - /** - * Answer the left-most coordinate that the main image can draw to - * - * @return int - */ - protected int getLeftBound() { - if (leftImage == null) - return 0; - - return leftImage.width; - } - - /** - * Answer self's size, as determined by the size of the initially- - * provided base-level image - */ - protected Point getSize() { - //start with basic size - Point size = new Point(backgroundImage.width, backgroundImage.height); - - //overlays may increase size. - if (topImage != null) - size.y += topImage.height; - - if (bottomImage != null) - size.y += bottomImage.height; - - if (leftImage != null) - size.x += leftImage.width; - - if (rightImage != null) - size.x += rightImage.width; - - return size; - } - - /** - * Answer the top-most coordinate that the main image can draw to - * - * @return int - */ - protected int getTopBound() { - if (topImage == null) - return 0; - - return topImage.height; - } - - /** - * @see Object#hashCode - */ - public int hashCode() { - return hashCode(backgroundImage) + hashCode(leftImage) - + hashCode(rightImage) + hashCode(topImage) - + hashCode(bottomImage) + hashCode(foregroundImages); - } - - /** - * Private utility for getting the hashCode for an - * object that may be null. - */ - private int hashCode(Object o) { - return o == null ? 0 : o.hashCode(); - } - - /** - * Set the image to be drawn below the primary overlay region. - */ - public void setBottomExtension(ImageData value) { - bottomImage = value; - } - - /** - * Set the image to be drawn to the left of the primary overlay region. - */ - public void setLeftExtension(ImageData value) { - leftImage = value; - } - - /** - * Set the image to be drawn to the right of the primary overlay region. - */ - public void setRightExtension(ImageData value) { - rightImage = value; - } - - /** - * Set the image to be drawn above the primary overlay region. - */ - public void setTopExtension(ImageData value) { - topImage = value; - } - -} diff --git a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/PackageOnlyContentProvider.java b/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/PackageOnlyContentProvider.java deleted file mode 100644 index 9b8690f28..000000000 --- a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/PackageOnlyContentProvider.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 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.jem.internal.beaninfo.ui; -/* - - - */ - - -import org.eclipse.jdt.ui.StandardJavaElementContentProvider; - -import org.eclipse.jdt.core.IPackageFragment; -import java.util.*; -/** - * A content provider which will only go down to the package level, - * it won't explore further. The advantage of this is so that plus signs ('+') - * won't show up on packages. The Filter technique could be used to not - * show the children, but this still shows the plus sign. - * - * Also, if the element is a java.util.List, then that list will be returned - * as the children. This allows for a root to be composed instead of being - * one of the standard Java Elements. - */ - -public class PackageOnlyContentProvider extends StandardJavaElementContentProvider { - - /** - * If the element is a list, return the iterator on it. - * Else send it up the chain. - */ - public Object[] getChildren(Object element) { - if (element instanceof List) - return ((List) element).toArray(); - return super.getChildren(element); - } - - /** - * If the element is a list and it is not empty, it has children, - * if it is a IPackageFragment it does not, - * else send it up the chain. - */ - public boolean hasChildren(Object element) { - if (element instanceof List) - return !((List) element).isEmpty(); - if (element instanceof IPackageFragment) - return false; - return super.hasChildren(element); - } -} diff --git a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/PackagesWorkbookPage.java b/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/PackagesWorkbookPage.java deleted file mode 100644 index 2cbddb201..000000000 --- a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/PackagesWorkbookPage.java +++ /dev/null @@ -1,464 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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.jem.internal.beaninfo.ui; - -import java.util.*; -import java.util.List; - -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jdt.core.*; -import org.eclipse.jdt.ui.JavaElementLabelProvider; -import org.eclipse.jface.viewers.*; -import org.eclipse.jface.window.Window; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.*; -import org.eclipse.swt.widgets.*; -import org.eclipse.ui.dialogs.*; - -import org.eclipse.jem.internal.beaninfo.core.SearchpathEntry; - -public class PackagesWorkbookPage implements IBuildSearchPage { - - /** - * Validator for this workbook page to verify the selections on Choose page. - * @version 1.0 - * @author - */ - public static class ChoosePackagesSelectionValidator implements ISelectionStatusValidator { - - private IStatus fgErrorStatus = StatusHelper.ERROR_STATUS; //$NON-NLS-1$ - private IStatus fgOKStatus = StatusHelper.OK_STATUS; - - public ChoosePackagesSelectionValidator() { - } - - /* - * @see ISelectionValidator#validate(Object) - */ - public IStatus validate(Object[] selection) { - if (isValid(selection)) { - return fgOKStatus; - } - return fgErrorStatus; - } - - private boolean isValid(Object[] selection) { - if (selection.length == 0) - return false; - - for (int i = 0; i < selection.length; i++) { - if (selection[i] instanceof IPackageFragment) - continue; // Fragments are always valid - return false; - } - - return true; - } - - } - - - private Label label = null; - private Table table = null; - private Composite buttonBar = null; - private Button choosePackagesButton = null; - private Button chooseDefPathsButton = null; - private Label spacer1 = null; - private Button removeButton = null; - // ... ui - - private IJavaProject javaProject = null; - private SearchPathListLabelProvider labelProvider = null; - private BeaninfoPathsBlock beaninfosPathsBlock = null; - private IPackageFragmentRoot[][] rootsPerRawEntry; - private IClasspathEntry[] rawList; - private TableViewer tableViewer; - private List packagesList = null; - private Composite top; - - public PackagesWorkbookPage(IWorkspaceRoot workspaceRoot, BeaninfoPathsBlock beaninfosPathsBlock) { - this.beaninfosPathsBlock = beaninfosPathsBlock; - this.packagesList = new ArrayList(); - this.labelProvider = new SearchPathListLabelProvider(); - } - - public Control createControl(Composite parent){ - top = new Composite(parent, SWT.NONE); - GridData gridData = new org.eclipse.swt.layout.GridData(); - gridData.horizontalSpan = 2; - GridLayout gridLayout = new GridLayout(); - gridLayout.numColumns = 2; - top.setLayout(gridLayout); - label = new Label(top, SWT.NONE); - label.setText(BeanInfoUIMessages.PackagesWorkbook_LabelText); - label.setLayoutData(gridData); - createTable(); - createButtonBar(); - top.setSize(new Point(300, 200)); - updateEnabledStates(); - if(spacer1==null){ - //TODO: - } - return top; - } - - /** - * This method initializes table - * - */ - private void createTable() { - GridData gridData1 = new org.eclipse.swt.layout.GridData(); - gridData1.grabExcessVerticalSpace = true; - gridData1.verticalAlignment = org.eclipse.swt.layout.GridData.FILL; - gridData1.grabExcessHorizontalSpace = true; - gridData1.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL; - table = new Table(top, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); - table.setLayoutData(gridData1); - table.addSelectionListener(new org.eclipse.swt.events.SelectionListener() { - public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { - updateButtons(); - } - public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) { - widgetSelected(e); - } - }); - tableViewer = new TableViewer(table); - tableViewer.setLabelProvider(labelProvider); - tableViewer.setSorter(new SPListElementSorter()); - tableViewer.setContentProvider(new ArrayContentProvider()); - tableViewer.setInput(packagesList); - } - - /** - * This method initializes buttonBar - * - */ - private void createButtonBar() { - RowLayout rowLayout = new RowLayout(); - rowLayout.type = org.eclipse.swt.SWT.VERTICAL; - rowLayout.fill = true; - GridData gridData2 = new org.eclipse.swt.layout.GridData(); - gridData2.grabExcessVerticalSpace = true; - gridData2.verticalAlignment = org.eclipse.swt.layout.GridData.FILL; - gridData2.horizontalAlignment = org.eclipse.swt.layout.GridData.BEGINNING; - buttonBar = new Composite(top, SWT.NONE); - buttonBar.setLayoutData(gridData2); - buttonBar.setLayout(rowLayout); - choosePackagesButton = new Button(buttonBar, SWT.NONE); - choosePackagesButton.setText(BeanInfoUIMessages.PackagesWorkbook_ChoosePackages); - choosePackagesButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() { - public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { - final List elementsToAdd = choosePackages(); - addToPackagesList(elementsToAdd); - } - }); - chooseDefPathsButton = new Button(buttonBar, SWT.NONE); - chooseDefPathsButton.setText(BeanInfoUIMessages.PackagesWorkbook_ChooseDefinedPaths); - chooseDefPathsButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() { - public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { - List elementsToAdd = chooseDefined(); - addToPackagesList(elementsToAdd); - } - }); - spacer1 = new Label(buttonBar, SWT.NONE); - removeButton = new Button(buttonBar, SWT.NONE); - removeButton.setText(BeanInfoUIMessages.PackagesWorkbook_Remove); - removeButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() { - public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { - List selected = BeaninfoPathsBlock.getSelectedList(tableViewer.getSelection()); - packagesList.removeAll(selected); - tableViewer.refresh(); - pageChanged(); - } - }); - } - - private void addToPackagesList(final List toAdd){ - if (toAdd != null && !toAdd.isEmpty()) { - packagesList.addAll(toAdd); - tableViewer.refresh(); - table.getDisplay().asyncExec(new Runnable(){ - public void run() { - tableViewer.setSelection(new StructuredSelection(toAdd)); - } - }); - pageChanged(); - } - } - - public void init(IJavaProject jproject) { - javaProject = jproject; - labelProvider.setJavaProject(jproject); - try { - rawList = javaProject.getRawClasspath(); - rootsPerRawEntry = new IPackageFragmentRoot[rawList.length][]; - for (int i = 0; i < rawList.length; i++) { - rootsPerRawEntry[i] = javaProject.findPackageFragmentRoots(rawList[i]); - } - } catch (JavaModelException e) { - rawList = new IClasspathEntry[0]; - rootsPerRawEntry = new IPackageFragmentRoot[0][]; - } - updatePackagesList(); - } - - public List getSelection() { - return BeaninfoPathsBlock.getSelectedList(tableViewer.getSelection()); - } - - public void setSelection(List selection) { - tableViewer.setSelection(new StructuredSelection(selection)); - } - - private void updatePackagesList() { - List spelements = beaninfosPathsBlock.getSearchpathOrderingPage().getElements(); - - List packageElements = new ArrayList(spelements.size()); - for (int i = 0; i < spelements.size(); i++) { - BPListElement spe = (BPListElement) spelements.get(i); - if (spe instanceof BPSearchListElement) { - packageElements.add(spe); - } - } - packagesList.clear(); - packagesList.addAll(packageElements); - if(tableViewer!=null && !table.isDisposed()) - tableViewer.refresh(); - } - - /** - * Choose the packages that should be in the search path. - */ - private List choosePackages() { - - ISelectionStatusValidator validator = new ChoosePackagesSelectionValidator(); - - // Show up to the package fragment, don't show any contents of it. - Class[] acceptedClasses = - new Class[] { IJavaProject.class, IPackageFragmentRoot.class, IPackageFragment.class }; - Object[] rejectedFragments = getFilteredExistingEntries(); - - // Only show package fragments that have children (i.e. there classes in it, not interested - // in intermediate ones that have no classes defined in them. Those are filtered out. - TypedViewerFilter filter = new TypedViewerFilter(acceptedClasses, rejectedFragments) { - public boolean select(Viewer viewer, Object parentElement, Object element) { - if (super.select(viewer, parentElement, element)) { - if (element instanceof IPackageFragment) { - IPackageFragment pkg = (IPackageFragment) element; - try { - return pkg.hasChildren(); - } catch (JavaModelException e) { - } - return false; - } else - return true; - } - return false; - } - }; - - ITreeContentProvider provider = new PackageOnlyContentProvider(); - - ILabelProvider labelProvider = new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_DEFAULT); - ElementTreeSelectionDialog dialog = - new ElementTreeSelectionDialog(top.getShell(), labelProvider, provider); - dialog.setTitle(BeanInfoUIMessages.BeaninfoPathsBlock_UI__addsearchpath_title); - - dialog.setValidator(validator); - dialog.setMessage(BeanInfoUIMessages.BeaninfoPathsBlock_UI__addsearchpath_description); - dialog.addFilter(filter); - dialog.setInput(javaProject); - - if (dialog.open() == Window.OK) { - Object[] elements = dialog.getResult(); - List newElements = new ArrayList(elements.length); - for (int i = 0; i < elements.length; i++) { - BPListElement newGuy = newBPListElement(elements[i]); - if (newGuy != null) - newElements.add(newGuy); - } - return newElements; - } - return Collections.EMPTY_LIST; - } - - /** - * Create a new BPListElement for the given object. - */ - protected BPListElement newBPListElement(Object element) { - SearchpathEntry se = null; - boolean isExported = false; - IPackageFragment frag = (IPackageFragment) element; - // Need to find corresponding raw class path entry. - IPackageFragmentRoot root = (IPackageFragmentRoot) frag.getParent(); // Get frag root. - for (int i = 0; i < rootsPerRawEntry.length; i++) { - for (int j = 0; j < rootsPerRawEntry[i].length; j++) { - if (rootsPerRawEntry[i][j].equals(root)) { - isExported = rawList[i].isExported() || rawList[i].getEntryKind() == IClasspathEntry.CPE_SOURCE; - se = new SearchpathEntry(rawList[i].getEntryKind(), rawList[i].getPath(), frag.getElementName()); - break; - } - } - } - - return new BPSearchListElement(se, false, false, isExported); - } - - /** - * Return the list of entries that already are in the search path - * so that they don't show up in the list. - */ - protected Object[] getFilteredExistingEntries() { - try { - IPackageFragmentRoot[] roots = javaProject.getPackageFragmentRoots(); - List entries = packagesList; - List fragments = new ArrayList(entries.size()); - Iterator itr = entries.iterator(); - while (itr.hasNext()) { - BPListElement elem = (BPListElement) itr.next(); - if (elem instanceof BPSearchListElement) { - BPSearchListElement bse = (BPSearchListElement) elem; - fragments.addAll(getPackages(bse, roots)); - } - } - return fragments.toArray(); - } catch (JavaModelException e) { - } - return new Object[0]; - } - - /** - * Find the package fragments for this package entry. - */ - protected List getPackages(BPSearchListElement element, IPackageFragmentRoot[] roots) { - String packageName = ((SearchpathEntry) element.getEntry()).getPackage(); - if (packageName == null) - return Collections.EMPTY_LIST; - - try { - List packages = new ArrayList(10); - for (int i = 0; i < roots.length; i++) { - IJavaElement[] pfs = roots[i].getChildren(); - for (int j = 0; j < pfs.length; j++) - if (pfs[j].getElementType() == IJavaElement.PACKAGE_FRAGMENT - && pfs[j].getElementName().equals(packageName)) { - packages.add(pfs[j]); - break; - } - } - return packages; - } catch (JavaModelException e) { - } - return Collections.EMPTY_LIST; - } - /** - * Choose the pre-defined search paths that should be in the search path. - */ - private List chooseDefined() { - - // Current pre-defined ones are only pre-reqed projects. - // The list of inputs will not contain any already in the path. - // We will create them here and if not selected they will thrown away. - // The assumption is that there are not very many and our SearchPathListLabelProvider does - // a good job of showing them. Otherwise we would need to come up with one that can show - // IJavaProjects when we get them. - List inputs = new ArrayList(); - List currentList = packagesList; - for (int i = 0; i < rawList.length; i++) { - if (rawList[i].getEntryKind() == IClasspathEntry.CPE_PROJECT) { - boolean exists = false; - for (int j = 0; j < currentList.size(); j++) { - BPSearchListElement bse = (BPSearchListElement) currentList.get(j); - if (bse.getEntry().getKind() == IClasspathEntry.CPE_PROJECT && rawList[i].getPath().equals(bse.getEntry().getPath())) { - exists = true; - break; - } - } - - if (!exists) - inputs.add(new BPSearchListElement(new SearchpathEntry(IClasspathEntry.CPE_PROJECT, rawList[i].getPath(), null), false, false, rawList[i].isExported())); - } - } - - ILabelProvider labelProvider1 = new SearchPathListLabelProvider(javaProject); - ElementListSelectionDialog dialog = - new ElementListSelectionDialog(top.getShell(), labelProvider1); - dialog.setTitle(BeanInfoUIMessages.PackagesWorkbook_SelectionDialog_DefinedPaths_Title); - - dialog.setMessage(BeanInfoUIMessages.PackagesWorkbook_SelectionDialog_DefinedPaths_Message); - dialog.setElements(inputs.toArray()); - - if (dialog.open() == Window.OK) - return Arrays.asList(dialog.getResult()); - else - return Collections.EMPTY_LIST; - } - - protected void updateButtons(){ - chooseDefPathsButton.setEnabled(beaninfosPathsBlock.isBeaninfoEnabled()); - choosePackagesButton.setEnabled(beaninfosPathsBlock.isBeaninfoEnabled()); - - List selected = BeaninfoPathsBlock.getSelectedList(tableViewer.getSelection()); - removeButton.setEnabled(selected!=null && selected.size()>0 && beaninfosPathsBlock.isBeaninfoEnabled()); - } - - /** - * Something important about the page changed - perform update. - * - * @since 1.2.0 - */ - protected void pageChanged(){ - updateSearchpathList(); - } - - private void updateSearchpathList() { - List searchelements = beaninfosPathsBlock.getSearchpathOrderingPage().getElements(); - - List packageelements = packagesList; - - boolean changeDone = false; - // First go through the search path and remove any SearchListElements that are - // not in the search packages list from this page. - for (ListIterator spitr = searchelements.listIterator(searchelements.size()); - spitr.hasPrevious(); - ) { - BPListElement element = (BPListElement) spitr.previous(); - if (element instanceof BPSearchListElement && !packageelements.remove(element)) { - // Search element and not found in packages list so remove it from searchpath list. - spitr.remove(); - changeDone = true; - } - } - // Any left over in packages list are new and need to be added. - searchelements.addAll(packageelements); - changeDone = changeDone || !packageelements.isEmpty(); - - if (changeDone) - beaninfosPathsBlock.setSearchOrderElements(searchelements); - } - - protected void updateEnabledStates(){ - updateButtons(); - table.setEnabled(beaninfosPathsBlock.isBeaninfoEnabled()); - label.setEnabled(beaninfosPathsBlock.isBeaninfoEnabled()); - } - - public void setBeaninfoEnabled(boolean enable) { - if(top!=null && !top.isDisposed()) - updateEnabledStates(); - } -} diff --git a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/SPListElementSorter.java b/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/SPListElementSorter.java deleted file mode 100644 index 5614705e3..000000000 --- a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/SPListElementSorter.java +++ /dev/null @@ -1,88 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 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.jem.internal.beaninfo.ui; -/* - - - */ - -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerSorter; - -import org.eclipse.jem.internal.beaninfo.core.SearchpathEntry; - -/** - * Sorter for sorting BPSearchListElements within the main list. - * It is not to be used on elements within a specific beaninfo entry. - * - * @version 1.0 - * @author - */ -public class SPListElementSorter extends ViewerSorter { - - /* - * @see ViewerSorter#category(Object) - */ - public int category(Object obj) { - if (obj instanceof BPSearchListElement) { - BPSearchListElement element = (BPSearchListElement) obj; - - switch (((SearchpathEntry) element.getEntry()).getKind()) { - case IClasspathEntry.CPE_LIBRARY: - return 4; - case IClasspathEntry.CPE_PROJECT: - return 1; - case IClasspathEntry.CPE_SOURCE: - return 0; - case IClasspathEntry.CPE_VARIABLE: - return 3; - case IClasspathEntry.CPE_CONTAINER: - return 2; - } - } - return super.category(obj); - } - - /* - * @see ViewerSorter#compare() - */ - public int compare(Viewer viewer, Object e1, Object e2) { - int cat1 = category(e1); - int cat2 = category(e2); - - if (cat1 != cat2) - return cat1 - cat2; - - if ((e1 instanceof BPSearchListElement) && (e2 instanceof BPSearchListElement)) { - SearchpathEntry p1 = (SearchpathEntry) ((BPSearchListElement) e1).getEntry(); - SearchpathEntry p2 = (SearchpathEntry) ((BPSearchListElement) e2).getEntry(); - - // Compare first within path, then packages within each path. - int c = p1.getPath().toString().compareTo(p2.getPath().toString()); - if (c == 0) { - // Within same path, so now sort by package, if there are any. - String pkg1 = p1.getPackage(); - String pkg2 = p2.getPackage(); - if (pkg1 == null) - pkg1 = ""; // For null, use an empty string //$NON-NLS-1$ - if (pkg2 == null) - pkg2 = ""; //$NON-NLS-1$ - return pkg1.compareTo(pkg2); - } else - return c; // Paths are not equal, so sort via path. - } - return super.compare(viewer, e1, e2); - } - - - -} diff --git a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/SearchPathListLabelProvider.java b/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/SearchPathListLabelProvider.java deleted file mode 100644 index 131536829..000000000 --- a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/SearchPathListLabelProvider.java +++ /dev/null @@ -1,375 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2006 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.jem.internal.beaninfo.ui; -/* - - - */ - -import java.net.URL; -import java.text.MessageFormat; -import java.util.HashMap; -import java.util.Iterator; - -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; -import org.eclipse.core.runtime.Path; -import org.eclipse.jdt.core.*; -import org.eclipse.jdt.ui.*; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.swt.graphics.*; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.ide.IDE; -import org.osgi.framework.Bundle; - -import org.eclipse.jem.internal.beaninfo.core.*; -import org.eclipse.jem.internal.ui.core.JEMUIPlugin; - -public class SearchPathListLabelProvider extends LabelProvider { - - IWorkspaceRoot fRoot; - IJavaProject javaProject; - - // Shared images - private Image fJarIcon, fExtJarIcon; - private Image fFolderImage, fProjectImage, fVariableImage, fLibraryImage; - private Image fMissingJarImage, fMissingVariableImage; - private Image fMissingFolderImage, fMissingProjectImage; - private Image fPackageImage; - - // Local images, will be disposed. - private Image fPluginImage; - private Image fBeanImage; - private Image fMissingPackageImage; - private Image fBlankImage; - private Image fMissingLibraryImage; - private HashMap fBeanedImages = new HashMap(); // Key of image to a composite with a bean attached - private HashMap fPackagedImages = new HashMap(); - private HashMap fMissingPackagedImages = new HashMap(); - private HashMap fNormalImages = new HashMap(); // Need to composite normal images w/blank so that they are the same size as the composited ones. - // Key of image to a composite with a package attached - - public SearchPathListLabelProvider() { - this(null); - } - - protected Image getWarningOverlayImage(Image image){ - ImageDescriptor decoratedImageDescriptor = - new JavaElementImageDescriptor( - ImageDescriptor.createFromImage(image), - JavaElementImageDescriptor.WARNING, - new Point(16,16)); - return decoratedImageDescriptor.createImage(); - } - - public SearchPathListLabelProvider(IJavaProject javaProject) { - this.javaProject = javaProject; - - fRoot = ResourcesPlugin.getWorkspace().getRoot(); - ISharedImages jdtSharedImages = JavaUI.getSharedImages(); - - fJarIcon = jdtSharedImages.getImage(ISharedImages.IMG_OBJS_JAR); - fExtJarIcon = jdtSharedImages.getImage(ISharedImages.IMG_OBJS_EXTERNAL_ARCHIVE); - fFolderImage = jdtSharedImages.getImage(ISharedImages.IMG_OBJS_PACKFRAG_ROOT); - - fVariableImage = jdtSharedImages.getImage(ISharedImages.IMG_OBJS_CLASSPATH_VAR_ENTRY); - - fLibraryImage = jdtSharedImages.getImage(ISharedImages.IMG_OBJS_LIBRARY); - - IWorkbench workbench = PlatformUI.getWorkbench(); - fProjectImage = workbench.getSharedImages().getImage(IDE.SharedImages.IMG_OBJ_PROJECT); - - fMissingJarImage = getWarningOverlayImage(jdtSharedImages.getImage(ISharedImages.IMG_OBJS_JAR)); - fMissingVariableImage = getWarningOverlayImage(jdtSharedImages.getImage(ISharedImages.IMG_OBJS_CLASSPATH_VAR_ENTRY)); - fMissingFolderImage = getWarningOverlayImage(jdtSharedImages.getImage(ISharedImages.IMG_OBJS_PACKFRAG_ROOT)); - fMissingProjectImage = workbench.getSharedImages().getImage(IDE.SharedImages.IMG_OBJ_PROJECT_CLOSED); - - fPackageImage = jdtSharedImages.getImage(ISharedImages.IMG_OBJS_PACKAGE); - - Rectangle r = fLibraryImage.getBounds(); - Point s = new Point(r.width, r.height); - JavaElementImageDescriptor jed = new JavaElementImageDescriptor(jdtSharedImages.getImageDescriptor(ISharedImages.IMG_OBJS_LIBRARY), JavaElementImageDescriptor.WARNING, s); - fMissingLibraryImage = jed.createImage(); - Bundle bundle = JEMUIPlugin.getPlugin().getBundle(); - URL url = FileLocator.find(bundle, new Path("icons/plugin_obj.gif"), null); //$NON-NLS-1$ - if (url != null) - fPluginImage = ImageDescriptor.createFromURL(url).createImage(); - else - fPluginImage = ImageDescriptor.getMissingImageDescriptor().createImage(); - - url = FileLocator.find(bundle, new Path("icons/javabean.gif"), null); //$NON-NLS-1$ - if (url != null) - fBeanImage = ImageDescriptor.createFromURL(url).createImage(); - else - fBeanImage = ImageDescriptor.getMissingImageDescriptor().createImage(); - - url = FileLocator.find(bundle, new Path("icons/package_obj_missing.gif"), null); //$NON-NLS-1$ - if (url != null) - fMissingPackageImage = ImageDescriptor.createFromURL(url).createImage(); - else - fMissingPackageImage = ImageDescriptor.getMissingImageDescriptor().createImage(); - - url = FileLocator.find(bundle, new Path("icons/blank.gif"), null); //$NON-NLS-1$ - if (url != null) - fBlankImage = ImageDescriptor.createFromURL(url).createImage(); - else - fBlankImage = ImageDescriptor.getMissingImageDescriptor().createImage(); - } - - public void setJavaProject(IJavaProject javaProject) { - this.javaProject = javaProject; - } - - public String getText(Object element) { - if (element instanceof BPListElement) { - BPListElement bpentry = (BPListElement) element; - IBeaninfosDocEntry docEntry = bpentry.getEntry(); - IPath path = docEntry.getPath(); - String pathString = null; - switch (docEntry.getKind()) { - case IClasspathEntry.CPE_LIBRARY : - IResource resource = fRoot.findMember(path); - if (resource instanceof IFolder) { - pathString = - MessageFormat.format(BeanInfoUIMessages.LabelProvider_Library_Folder, new Object[] { path.makeRelative().toString()}); - } else if (resource instanceof IFile) { - if (VariableSelectionBlock.isArchivePath(path)) { - // Internal library - String[] args = - new String[] { path.lastSegment(), path.removeLastSegments(1).makeRelative().toString()}; - pathString = MessageFormat.format(BeanInfoUIMessages.LabelProvider_Library__PathLastSegment_PathRelative_, args); - } - } else { - if (VariableSelectionBlock.isArchivePath(path)) { - // External library - String[] args = - new String[] { path.lastSegment(), path.removeLastSegments(1).toString()}; - pathString = MessageFormat.format(BeanInfoUIMessages.LabelProvider_Library__PathLastSegment_PathExceptLast_, args); - } else { - // should not come here - pathString = path.makeRelative().toString(); - } - } - break; - - case IClasspathEntry.CPE_VARIABLE : - String name = path.makeRelative().toString(); - IPath entryPath = JavaCore.getClasspathVariable(path.segment(0)); - if (entryPath != null) - pathString = - MessageFormat.format( - BeanInfoUIMessages.LabelProvider_Variable__name_PathOSString_, - new Object[] { name, entryPath.append(path.removeFirstSegments(1)).toOSString()}); - else - pathString = name; - break; - - case IClasspathEntry.CPE_CONTAINER: - try { - IClasspathContainer c = JavaCore.getClasspathContainer(path, javaProject); - if (c != null) { - pathString = c.getDescription(); - break; - } - } catch (JavaModelException e) { - } - pathString = path.toString(); - break; - - case IClasspathEntry.CPE_PROJECT : - pathString = path.toString(); - break; - - case IClasspathEntry.CPE_SOURCE : - pathString = path.makeRelative().toString(); - break; - - case BeaninfoEntry.BIE_PLUGIN : - pathString = path.toString(); - break; - default : - // no path, so probably a search entry within a beaninfo entry. - } - - if (docEntry instanceof SearchpathEntry) { - // There could be a package involved too if this is not a project or registered var entry - String packageName = ((SearchpathEntry) docEntry).getPackage(); - if (packageName != null && packageName.length() > 0) - if (pathString != null) - return MessageFormat.format(BeanInfoUIMessages.LabelProvider__packageName_Path_, new Object[] { packageName, pathString }); - else - return packageName; - } - - if (pathString != null) - return pathString; - else - return "?"; //$NON-NLS-1$ - } - return super.getText(element); - } - - public Image getImage(Object element) { - Image returnedImage = null; - boolean imageIsNormal = true; // Whether this is a normal sized image (which will need compositing with blank) - if (element instanceof BPListElement) { - BPListElement bpentry = (BPListElement) element; - IBeaninfosDocEntry docEntry = bpentry.getEntry(); - IPath path = docEntry.getPath(); - Image pathImage = null; - switch (docEntry.getKind()) { - case IClasspathEntry.CPE_SOURCE : - if (!bpentry.isMissing()) - pathImage = fFolderImage; - else - pathImage = fMissingFolderImage; - break; - - case IClasspathEntry.CPE_LIBRARY : - if (!bpentry.isMissing()) { - IResource resource = fRoot.findMember(path); - if (resource instanceof IFolder) - pathImage = fFolderImage; - else if (resource instanceof IFile) - pathImage = fJarIcon; - else - pathImage = fExtJarIcon; - } else - pathImage = fMissingJarImage; - break; - - case IClasspathEntry.CPE_PROJECT : - if (!bpentry.isMissing()) - pathImage = fProjectImage; - else - pathImage = fMissingProjectImage; - break; - - case IClasspathEntry.CPE_VARIABLE : - if (!bpentry.isMissing()) - pathImage = fVariableImage; - else - pathImage = fMissingVariableImage; - break; - - case IClasspathEntry.CPE_CONTAINER: - if (!bpentry.isMissing()) - pathImage = fLibraryImage; - else - pathImage = fMissingLibraryImage; - break; - - case BeaninfoEntry.BIE_PLUGIN: - pathImage = fPluginImage; - break; - - default : - // probably a searchentry under beaninfo entry, no path icon to decorate. - break; - } - - if (bpentry instanceof BPSearchListElement) { - SearchpathEntry se = (SearchpathEntry) docEntry; - BPSearchListElement bpse = (BPSearchListElement) bpentry; - if (se.getPackage() != null) { - if (pathImage != null) { - if (!bpse.isPackageMissing()) { - // Need to decorate with a package symbol. - imageIsNormal = false; - returnedImage = (Image) fPackagedImages.get(pathImage); // See if we've already created the image - if (returnedImage == null) { - OverlayComposite oc = new OverlayComposite(pathImage.getImageData()); - oc.setRightExtension(fPackageImage.getImageData()); - returnedImage = oc.createImage(); - fPackagedImages.put(pathImage, returnedImage); - } - } else { - // Need to decorate with a missing package symbol. - imageIsNormal = false; - returnedImage = (Image) fMissingPackagedImages.get(pathImage); // See if we've already created the image - if (returnedImage == null) { - OverlayComposite oc = new OverlayComposite(pathImage.getImageData()); - oc.setRightExtension(fMissingPackageImage.getImageData()); - returnedImage = oc.createImage(); - fMissingPackagedImages.put(pathImage, returnedImage); - } - } - } - } - - if (pathImage == null && returnedImage == null) - if (!bpse.isPackageMissing()) - returnedImage = fPackageImage; // Just a package image - else - returnedImage = fMissingPackageImage; // Just the missing package image. - else if (returnedImage == null) - returnedImage = pathImage; - } else { - if (pathImage != null) { - // It is a beaninfo entry, need to decorate with the bean. - imageIsNormal = false; - returnedImage = (Image) fBeanedImages.get(pathImage); // See if we've already created the image - if (returnedImage == null) { - OverlayComposite oc = new OverlayComposite(pathImage.getImageData()); - oc.setRightExtension(fBeanImage.getImageData()); - returnedImage = oc.createImage(); - fBeanedImages.put(pathImage, returnedImage); - } - } - if (returnedImage == null) - returnedImage = fBeanImage; // Shouldn't occur. - } - } - - if (imageIsNormal && returnedImage != null) { - // We need to composite it with blank so that the result will be the same size - // as composited images. If this isn't done, the viewer will stretch the image - // to match the same size as the composited images and things will look aweful. - Image newReturned = (Image) fNormalImages.get(returnedImage); - if (newReturned == null) { - OverlayComposite oc = new OverlayComposite(returnedImage.getImageData()); - oc.setRightExtension(fBlankImage.getImageData()); - newReturned = oc.createImage(); - fNormalImages.put(returnedImage, newReturned); - } - returnedImage = newReturned; - } - return returnedImage; - } - - /* - * @see IBaseLabelProvider#dispose() - */ - public void dispose() { - super.dispose(); - - fPluginImage.dispose(); - fBeanImage.dispose(); - fMissingPackageImage.dispose(); - fBlankImage.dispose(); - fMissingLibraryImage.dispose(); - for (Iterator itr = fBeanedImages.values().iterator(); itr.hasNext();) { - ((Image) itr.next()).dispose(); - } - for (Iterator itr = fPackagedImages.values().iterator(); itr.hasNext();) { - ((Image) itr.next()).dispose(); - } - for (Iterator itr = fMissingPackagedImages.values().iterator(); itr.hasNext();) { - ((Image) itr.next()).dispose(); - } - for (Iterator itr = fNormalImages.values().iterator(); itr.hasNext();) { - ((Image) itr.next()).dispose(); - } - } - -} diff --git a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/SearchpathOrderingWorkbookPage.java b/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/SearchpathOrderingWorkbookPage.java deleted file mode 100644 index b80146a72..000000000 --- a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/SearchpathOrderingWorkbookPage.java +++ /dev/null @@ -1,326 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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.jem.internal.beaninfo.ui; - -import java.util.*; -import java.util.List; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jface.viewers.*; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.*; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.*; -import org.eclipse.swt.widgets.*; - -import org.eclipse.jem.internal.ui.core.JEMUIPlugin; - -public class SearchpathOrderingWorkbookPage implements IBuildSearchPage{ - - private Label label = null; - private Table table = null; - private Composite buttonBar = null; - private Button upButton = null; - private Button downButton = null; - private Label spacer1 = null; - private Button exportAllButton = null; - private Button unExportAllButton = null; - private IStatus status; - private boolean inUpdate; - private BeaninfoPathsBlock beaninfoPathsBlock; - private Composite top; - private CheckboxTableViewer tableViewer=null; - private SearchPathListLabelProvider labelProvider; - - private List elements; - private List selected; - private List checked; - - public SearchpathOrderingWorkbookPage(BeaninfoPathsBlock beaninfoPathsBlock) { - this.beaninfoPathsBlock = beaninfoPathsBlock; - this.status = StatusHelper.OK_STATUS; - this.labelProvider = new SearchPathListLabelProvider(); - this.elements = new ArrayList(); - } - - public Control createControl(Composite parent){ - top = new Composite(parent, SWT.NONE); - GridData gridData = new org.eclipse.swt.layout.GridData(); - gridData.horizontalSpan = 2; - GridLayout gridLayout = new GridLayout(); - gridLayout.numColumns = 2; - label = new Label(top, SWT.NONE); - label.setText(BeanInfoUIMessages.BeaninfoPathsBlock_UI__searchpath_label); - label.setLayoutData(gridData); - createTable(); - top.setLayout(gridLayout); - createButtonBar(); - top.setSize(new Point(300, 200)); - updateEnabledStates(); - if(spacer1==null){ - //TODO - } - return top; - } - - /** - * This method initializes table - * - */ - private void createTable() { - GridData gridData1 = new org.eclipse.swt.layout.GridData(); - gridData1.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL; - gridData1.grabExcessHorizontalSpace = true; - gridData1.grabExcessVerticalSpace = true; - gridData1.verticalAlignment = org.eclipse.swt.layout.GridData.FILL; - table = new Table(top, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CHECK | SWT.FULL_SELECTION); - table.setLayoutData(gridData1); - table.addSelectionListener(new SelectionListener(){ - public void widgetSelected(SelectionEvent e) { - setSelection(BeaninfoPathsBlock.getSelectedList(tableViewer.getSelection())); - updateButtons(); - } - public void widgetDefaultSelected(SelectionEvent e) { - widgetSelected(e); - } - }); - tableViewer = new CheckboxTableViewer(table); - tableViewer.setContentProvider(new ArrayContentProvider()); - tableViewer.setLabelProvider(labelProvider); - tableViewer.setInput(elements); - if(getSelection()!=null) - tableViewer.setSelection(new StructuredSelection(getSelection())); - if(checked!=null) - tableViewer.setCheckedElements(checked.toArray()); - tableViewer.addCheckStateListener(new ICheckStateListener(){ - public void checkStateChanged(CheckStateChangedEvent event) { - pageChanged(); - } - }); - } - - /** - * This method initializes composite - * - */ - private void createButtonBar() { - RowLayout rowLayout = new RowLayout(); - rowLayout.type = org.eclipse.swt.SWT.VERTICAL; - rowLayout.fill = true; - GridData gridData2 = new org.eclipse.swt.layout.GridData(); - gridData2.grabExcessVerticalSpace = true; - gridData2.verticalAlignment = org.eclipse.swt.layout.GridData.FILL; - gridData2.horizontalAlignment = org.eclipse.swt.layout.GridData.BEGINNING; - buttonBar = new Composite(top, SWT.NONE); - buttonBar.setLayoutData(gridData2); - buttonBar.setLayout(rowLayout); - upButton = new Button(buttonBar, SWT.NONE); - upButton.setText(BeanInfoUIMessages.BeaninfoPathsBlock_UI__searchpath_up_button); - upButton.addSelectionListener(new SelectionAdapter(){ - public void widgetSelected(SelectionEvent e) { - Iterator selItr = getSelection().iterator(); - while (selItr.hasNext()) { - Object element = selItr.next(); - int oldIndex = elements.indexOf(element); - if(oldIndex>0){ - elements.remove(element); - elements.add(--oldIndex, element); - } - } - tableViewer.refresh(); - pageChanged(); - } - }); - downButton = new Button(buttonBar, SWT.NONE); - downButton.setText(BeanInfoUIMessages.BeaninfoPathsBlock_UI__searchpath_down_button); - downButton.addSelectionListener(new SelectionAdapter(){ - public void widgetSelected(SelectionEvent e) { - Iterator selItr = getSelection().iterator(); - while (selItr.hasNext()) { - Object element = selItr.next(); - int oldIndex = elements.indexOf(element); - if(oldIndex<(elements.size()-1)){ - elements.remove(element); - elements.add(++oldIndex, element); - } - } - tableViewer.refresh(); - pageChanged(); - } - }); - spacer1 = new Label(buttonBar, SWT.NONE); - exportAllButton = new Button(buttonBar, SWT.NONE); - exportAllButton.setText(BeanInfoUIMessages.BeanInfoPathsBlock_ExportAll); - exportAllButton.addSelectionListener(new SelectionAdapter(){ - public void widgetSelected(SelectionEvent e) { - setCheckedElements(getElements()); - } - }); - unExportAllButton = new Button(buttonBar, SWT.NONE); - unExportAllButton.setText(BeanInfoUIMessages.BeanInfoPathsBlock_UnexportAll); - unExportAllButton.addSelectionListener(new SelectionAdapter(){ - public void widgetSelected(SelectionEvent e) { - setCheckedElements(null); - } - }); - } - - public List getElements() { - return new ArrayList(elements); - } - - public void setElements(List elements){ - this.elements.clear(); - this.elements.addAll(elements); - if(tableViewer!=null){ - tableViewer.refresh(); - updateButtons(); - } - } - - public void init(IJavaProject javaProject) { - labelProvider.setJavaProject(javaProject); - } - - public void setCheckedElements(List exportedEntries) { - this.checked = exportedEntries; - if(tableViewer!=null && !table.isDisposed()){ - tableViewer.setCheckedElements(checked!=null ? checked.toArray() : new Object[0]); - updateButtons(); - } - pageChanged(); - } - - public boolean isChecked(BPListElement currElement) { - if(tableViewer!=null){ - return tableViewer.getChecked(currElement); - } - return checked!=null && checked.contains(currElement); - } - - public List getSelection() { - return selected; - } - - public void setSelection(List selection) { - this.selected = selection; - if(tableViewer!=null && !table.isDisposed()){ - tableViewer.setSelection(new StructuredSelection(selection!=null?selection : new ArrayList())); - updateButtons(); - } - } - - public void pageChanged(){ - updateSearchPathStatus(); - beaninfoPathsBlock.doStatusLineUpdate(); - } - - protected void updateButtons(){ - upButton.setEnabled(canMoveUp() && beaninfoPathsBlock.isBeaninfoEnabled()); - downButton.setEnabled(canMoveDown() && beaninfoPathsBlock.isBeaninfoEnabled()); - exportAllButton.setEnabled(elements!=null && beaninfoPathsBlock.isBeaninfoEnabled()); - unExportAllButton.setEnabled(elements!=null && beaninfoPathsBlock.isBeaninfoEnabled()); - } - - private boolean canMoveDown() { - int[] indc= table.getSelectionIndices(); - int k= elements.size() - 1; - for (int i= indc.length - 1; i >= 0 ; i--, k--) { - if (indc[i] != k) { - return true; - } - } - return false; - } - - private boolean canMoveUp() { - int[] indc= table.getSelectionIndices(); - for (int i= 0; i < indc.length; i++) { - if (indc[i] != i) { - return true; - } - } - return false; - } - - /** - * Validates the search path. - */ - private void updateSearchPathStatus() { - if (inUpdate) - return; - try { - inUpdate = true; - - status = StatusHelper.OK_STATUS; - - List elements = getElements(); - - boolean entryMissing = false; - - // Because of bug in setcheckedWithoutUpdate, which sets to true no matter what the state is, we need - // to accumulate the checked elements and re-set them again after this so that they will be correct. - ArrayList exported = new ArrayList(); - - for (Iterator entries = elements.iterator(); entries.hasNext();) { - BPListElement currElement = (BPListElement) entries.next(); - - boolean isChecked = isChecked(currElement); - if (currElement.canExportBeChanged()) { - if (isChecked) - exported.add(currElement); - currElement.setExported(isChecked); - } else { - // fSearchOrder.setCheckedWithoutUpdate(currElement, currElement.isExported()); - if (currElement.isExported()) - exported.add(currElement); - } - - entryMissing = entryMissing || currElement.isMissing(); - } - - // Now reset the checked states, due to bug - setCheckedElements(exported); - - if (entryMissing) { - status = new Status(IStatus.WARNING, - JEMUIPlugin.getPlugin().getBundle().getSymbolicName(), - IStatus.WARNING, - BeanInfoUIMessages.BeaninfoPathsBlock_UI__warning_EntryMissing, - null); - } - } finally { - inUpdate = false; - } - } - - public IStatus getStatus() { - return status; - } - - public void setBeaninfoEnabled(boolean enable) { - if(top!=null && !top.isDisposed()) - updateEnabledStates(); - } - - private void updateEnabledStates() { - updateButtons(); - table.setEnabled(beaninfoPathsBlock.isBeaninfoEnabled()); - label.setEnabled(beaninfoPathsBlock.isBeaninfoEnabled()); - } - -} diff --git a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/StatusHelper.java b/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/StatusHelper.java deleted file mode 100644 index 722344216..000000000 --- a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/StatusHelper.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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.jem.internal.beaninfo.ui; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; - -import org.eclipse.jem.internal.ui.core.JEMUIPlugin; - - -public class StatusHelper { - - public static final IStatus OK_STATUS = createStatus(IStatus.OK, ""); //$NON-NLS-1$ - public static final IStatus ERROR_STATUS = createStatus(IStatus.ERROR, ""); //$NON-NLS-1$ - - /** - * Creates a status with the provided severity and message - * - * @param severity - * @param message - * @return - * - * @since 1.2.0 - */ - public static IStatus createStatus(int severity, String message){ - return new Status(severity, - JEMUIPlugin.getPlugin().getBundle().getSymbolicName(), - severity, message, null); - } - - /** - * Finds the most severe status from a array of stati. - * An error is more severe than a warning, and a warning is more severe - * than ok. - * - * @param status - * @return - * - * @since 1.2.0 - */ - public static IStatus getMostSevere(IStatus[] status) { - IStatus max= null; - for (int i= 0; i < status.length; i++) { - IStatus curr= status[i]; - if (curr.matches(IStatus.ERROR)) { - return curr; - } - if (max == null || curr.getSeverity() > max.getSeverity()) { - max= curr; - } - } - return max; - } - -} diff --git a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/TypedElementSelectionValidator.java b/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/TypedElementSelectionValidator.java deleted file mode 100644 index 64f317cda..000000000 --- a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/TypedElementSelectionValidator.java +++ /dev/null @@ -1,99 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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.jem.internal.beaninfo.ui; - -import java.util.Collection; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Assert; -import org.eclipse.ui.dialogs.ISelectionStatusValidator; - - -public class TypedElementSelectionValidator implements ISelectionStatusValidator { - - private IStatus fgErrorStatus= StatusHelper.ERROR_STATUS; - private IStatus fgOKStatus= StatusHelper.OK_STATUS; - - private Class[] fAcceptedTypes; - private boolean fAllowMultipleSelection; - private Collection fRejectedElements; - - /** - * @param acceptedTypes The types accepted by the validator - * @param allowMultipleSelection If set to <code>true</code>, the validator - * allows multiple selection. - */ - public TypedElementSelectionValidator(Class[] acceptedTypes, boolean allowMultipleSelection) { - this(acceptedTypes, allowMultipleSelection, null); - } - - /** - * @param acceptedTypes The types accepted by the validator - * @param allowMultipleSelection If set to <code>true</code>, the validator - * allows multiple selection. - * @param rejectedElements A list of elements that are not accepted - */ - public TypedElementSelectionValidator(Class[] acceptedTypes, boolean allowMultipleSelection, Collection rejectedElements) { - Assert.isNotNull(acceptedTypes); - fAcceptedTypes= acceptedTypes; - fAllowMultipleSelection= allowMultipleSelection; - fRejectedElements= rejectedElements; - } - - /* - * @see org.eclipse.ui.dialogs.ISelectionValidator#isValid(java.lang.Object) - */ - public IStatus validate(Object[] elements) { - if (isValid(elements)) { - return fgOKStatus; - } - return fgErrorStatus; - } - - private boolean isOfAcceptedType(Object o) { - for (int i= 0; i < fAcceptedTypes.length; i++) { - if (fAcceptedTypes[i].isInstance(o)) { - return true; - } - } - return false; - } - - private boolean isRejectedElement(Object elem) { - return (fRejectedElements != null) && fRejectedElements.contains(elem); - } - - protected boolean isSelectedValid(Object elem) { - return true; - } - - private boolean isValid(Object[] selection) { - if (selection.length == 0) { - return false; - } - - if (!fAllowMultipleSelection && selection.length != 1) { - return false; - } - - for (int i= 0; i < selection.length; i++) { - Object o= selection[i]; - if (!isOfAcceptedType(o) || isRejectedElement(o) || !isSelectedValid(o)) { - return false; - } - } - return true; - } -} diff --git a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/TypedViewerFilter.java b/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/TypedViewerFilter.java deleted file mode 100644 index d3b140690..000000000 --- a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/TypedViewerFilter.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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.jem.internal.beaninfo.ui; - -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; - - -public class TypedViewerFilter extends ViewerFilter { - private Class[] acceptedClasses; - private Object[] rejectedFragments; - - public TypedViewerFilter(Class[] acceptedClasses, Object[] rejectedFragments) { - this.acceptedClasses = acceptedClasses; - this.rejectedFragments = rejectedFragments; - } - - public boolean select(Viewer viewer, Object parentElement, Object element) { - if (rejectedFragments != null) { - for (int i= 0; i < rejectedFragments.length; i++) { - if (element.equals(rejectedFragments[i])) { - return false; - } - } - } - for (int i= 0; i < acceptedClasses.length; i++) { - if (acceptedClasses[i].isInstance(element)) { - return true; - } - } - return false; - } -} diff --git a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/VariableSelectionBlock.java b/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/VariableSelectionBlock.java deleted file mode 100644 index 7147b9463..000000000 --- a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/VariableSelectionBlock.java +++ /dev/null @@ -1,310 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 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.jem.internal.beaninfo.ui; - -import java.util.List; - -import org.eclipse.core.runtime.*; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.ui.wizards.BuildPathDialogAccess; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CLabel; -import org.eclipse.swt.events.*; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.*; -import org.eclipse.ui.PlatformUI; -/* - - - */ - -public class VariableSelectionBlock { - - - private List fExistingPaths; - - private Label variableFieldLabel; - private Text variableFieldText; - private Button variableFieldButton; - private String variableFieldTextContent; - - private Label extensionFieldLabel; - private Text extensionFieldText; - private Button extensionFieldButton; - private String extensionFieldTextContent; - - private CLabel fFullPath; - - private IStatus fVariableStatus; - private IStatus fExistsStatus; - private IStatus fExtensionStatus; - - private String fVariable; - private IStatusChangeListener fContext; - - private boolean fIsEmptyAllowed; - - /** - * Constructor for VariableSelectionBlock - */ - public VariableSelectionBlock(IStatusChangeListener context, List existingPaths, IPath varPath, String lastVarSelection, boolean emptyAllowed) { - fContext= context; - fExistingPaths= existingPaths; - fIsEmptyAllowed= emptyAllowed; - fExistsStatus= StatusHelper.OK_STATUS; - - //VariableSelectionAdapter adapter= new VariableSelectionAdapter(); - - if (varPath != null) { - variableFieldTextContent = varPath.segment(0); - extensionFieldTextContent = varPath.removeFirstSegments(1).toString(); - } else { - variableFieldTextContent = ""; //$NON-NLS-1$ - extensionFieldTextContent = ""; //$NON-NLS-1$ - } - updateFullTextField(); - fVariableStatus= variableUpdated(); - fExtensionStatus=extensionUpdated(); - } - - public IPath getVariablePath() { - if (fVariable != null) { - return new Path(fVariable).append(extensionFieldTextContent); - } - return null; - } - - public IPath getResolvedPath() { - if (fVariable != null) { - IPath entryPath= JavaCore.getClasspathVariable(fVariable); - if (entryPath != null) { - return entryPath.append(extensionFieldTextContent); - } - } - return null; - } - - public void setFocus(Display display) { - display.asyncExec(new Runnable(){ - public void run() { - variableFieldText.setFocus(); - } - }); - } - - - public Control createControl(Composite parent) { - Composite inner= new Composite(parent, SWT.NONE); - inner.setLayout(new GridLayout(3, false)); - GridData gd = new GridData(GridData.FILL_BOTH); - inner.setLayoutData(gd); - - variableFieldLabel = new Label(inner, SWT.NONE); - variableFieldLabel.setText(BeanInfoUIMessages.VariableSelectionBlock_variable_label); - variableFieldLabel.setLayoutData(new GridData()); - variableFieldText = new Text(inner, SWT.BORDER|SWT.SINGLE); - variableFieldText.setText(variableFieldTextContent); - gd = new GridData(GridData.FILL_HORIZONTAL); - gd.widthHint = 200; - variableFieldText.setLayoutData(gd); - variableFieldText.addModifyListener(new ModifyListener(){ - public void modifyText(ModifyEvent e) { - variableFieldTextContent = variableFieldText.getText(); - fVariableStatus = variableUpdated(); - fExistsStatus= getExistsStatus(); - updateFullTextField(); - fContext.statusChanged(StatusHelper.getMostSevere(new IStatus[] { fVariableStatus, fExtensionStatus, fExistsStatus })); - } - }); - variableFieldButton = new Button(inner, SWT.PUSH); - variableFieldButton.setText(BeanInfoUIMessages.VariableSelectionBlock_variable_button); - variableFieldButton.setLayoutData(new GridData()); - variableFieldButton.addSelectionListener(new SelectionAdapter(){ - public void widgetSelected(SelectionEvent e) { - String variable= chooseVariable(); - if (variable != null) { - variableFieldText.setText(variable); - } - } - }); - - extensionFieldLabel = new Label(inner, SWT.NONE); - extensionFieldLabel.setText(BeanInfoUIMessages.VariableSelectionBlock_extension_label); - extensionFieldLabel.setLayoutData(new GridData()); - extensionFieldText = new Text(inner, SWT.BORDER|SWT.SINGLE); - extensionFieldText.setText(variableFieldTextContent); - extensionFieldText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - extensionFieldText.addModifyListener(new ModifyListener(){ - public void modifyText(ModifyEvent e) { - extensionFieldTextContent = extensionFieldText.getText(); - fExtensionStatus= extensionUpdated(); - fExistsStatus= getExistsStatus(); - updateFullTextField(); - fContext.statusChanged(StatusHelper.getMostSevere(new IStatus[] { fVariableStatus, fExtensionStatus, fExistsStatus })); - } - }); - extensionFieldButton = new Button(inner, SWT.PUSH); - extensionFieldButton.setText(BeanInfoUIMessages.VariableSelectionBlock_extension_button); - extensionFieldButton.setLayoutData(new GridData()); - extensionFieldButton.setEnabled(fVariable!=null); - extensionFieldButton.addSelectionListener(new SelectionAdapter(){ - public void widgetSelected(SelectionEvent e) { - IPath filePath= chooseExtJar(); - if (filePath != null) { - extensionFieldText.setText(filePath.toString()); - } - } - }); - - Label label= new Label(inner, SWT.LEFT); - label.setLayoutData(new GridData()); - label.setText(BeanInfoUIMessages.VariableSelectionBlock_fullpath_label); - - fFullPath= new CLabel(inner, SWT.NONE); - gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - gd.horizontalSpan=2; - fFullPath.setLayoutData(gd); - - updateFullTextField(); - - setFocus(parent.getDisplay()); - - return inner; - } - - private IStatus variableUpdated() { - fVariable= null; - - IStatus status= StatusHelper.OK_STATUS; - - String name = variableFieldTextContent; - if (name.length() == 0) { - if (!fIsEmptyAllowed) { - status = StatusHelper.createStatus(IStatus.ERROR, BeanInfoUIMessages.VariableSelectionBlock_error_entername_ERROR_); - } else { - fVariable= ""; //$NON-NLS-1$ - } - } else if (JavaCore.getClasspathVariable(name) == null) { - status = StatusHelper.createStatus(IStatus.ERROR, BeanInfoUIMessages.VariableSelectionBlock_error_namenotexists_ERROR_); - } else { - fVariable= name; - } - if(extensionFieldButton!=null) - extensionFieldButton.setEnabled(fVariable != null); - return status; - } - - private IStatus extensionUpdated() { - IStatus status= StatusHelper.OK_STATUS; - String extension = extensionFieldTextContent; - if (extension.length() > 0 && !Path.ROOT.isValidPath(extension)) { - status = StatusHelper.createStatus(IStatus.ERROR, BeanInfoUIMessages.VariableSelectionBlock_error_invalidextension_ERROR_); - } - return status; - } - - private IStatus getExistsStatus() { - IStatus status = StatusHelper.OK_STATUS; - IPath path= getResolvedPath(); - if (path != null) { - if (findPath(path)) { - status = StatusHelper.createStatus(IStatus.ERROR, BeanInfoUIMessages.VariableSelectionBlock_error_pathexists_ERROR_); - } else if (!path.toFile().isFile()) { - status = StatusHelper.createStatus(IStatus.WARNING, BeanInfoUIMessages.VariableSelectionBlock_warning_pathnotexists_WARN_); - } - } else { - status = StatusHelper.createStatus(IStatus.WARNING, BeanInfoUIMessages.VariableSelectionBlock_warning_pathnotexists_WARN_); - } - return status; - } - - private boolean findPath(IPath path) { - for (int i= fExistingPaths.size() -1; i >=0; i--) { - IPath curr= (IPath) fExistingPaths.get(i); - if (curr.equals(path)) { - return true; - } - } - return false; - } - - private void updateFullTextField() { - if (fFullPath != null && !fFullPath.isDisposed()) { - IPath resolvedPath= getResolvedPath(); - if (resolvedPath != null) { - fFullPath.setText(resolvedPath.toOSString()); - } else { - fFullPath.setText(""); //$NON-NLS-1$ - } - } - } - - private Shell getShell() { - if (fFullPath != null) { - return fFullPath.getShell(); - } - return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); - } - - public static boolean isArchivePath(IPath path){ - final String[] archiveExtensions = {"jar", "zip"}; //$NON-NLS-1$ //$NON-NLS-2$ - String ext= path.getFileExtension(); - if (ext != null && ext.length() != 0) { - for (int i= 0; i < archiveExtensions.length; i++) { - if (ext.equalsIgnoreCase(archiveExtensions[i])) { - return true; - } - } - } - return false; - } - - private IPath chooseExtJar() { - String lastUsedPath= ""; //$NON-NLS-1$ - IPath entryPath= getResolvedPath(); - if (entryPath != null) { - if (isArchivePath(entryPath)) { - lastUsedPath= entryPath.removeLastSegments(1).toOSString(); - } else { - lastUsedPath= entryPath.toOSString(); - } - } - - FileDialog dialog= new FileDialog(getShell(), SWT.SINGLE); - dialog.setFilterExtensions(new String[] {"*.jar;*.zip"}); //$NON-NLS-1$ - dialog.setFilterPath(lastUsedPath); - dialog.setText(BeanInfoUIMessages.VariableSelectionBlock_ExtJarDialog_title); - String res= dialog.open(); - if (res == null) { - return null; - } - IPath resPath= new Path(res).makeAbsolute(); - IPath varPath= JavaCore.getClasspathVariable(fVariable); - - if (!varPath.isPrefixOf(resPath)) { - return new Path(resPath.lastSegment()); - } else { - return resPath.removeFirstSegments(varPath.segmentCount()).setDevice(null); - } - } - - private String chooseVariable() { - IPath[] varPaths = BuildPathDialogAccess.chooseVariableEntries(variableFieldButton.getShell(), new IPath[0]); - String variable = null; - if(varPaths!=null && varPaths.length>0){ - variable = varPaths[0].toString(); - } - return variable; - } - - -} diff --git a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/messages.properties b/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/messages.properties deleted file mode 100644 index b5ae17de4..000000000 --- a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/messages.properties +++ /dev/null @@ -1,109 +0,0 @@ -############################################################################### -# Copyright (c) 2003, 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 -############################################################################### -# -# $Source: /cvsroot/webtools/jeetools.move/webtools.javaee.git/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/Attic/messages.properties,v $ -# $Revision: 1.6 $ $Date: 2005/12/14 19:06:13 $ -# - - -SearchPathDialog_ChoosePackages = &Choose Packages -SearchPathDialog_Remove = &Remove -SearchPathDialog_Desc_Label = &Modify search path of packages within this BeanInfo classes JAR/folder -SearchPathDialog_ModifySearchPaths = Modify Search Paths - {0} -SearchPathDialog_NotEditable_INFO_ = IWAV0075I Plugin type BeanInfo classes locations are not editable -SearchPathDialog_PackagePresent_INFO_ = IWAV0076I Package already in the search path -SearchPathDialog_InputDialog_Title = Package -SearchPathDialog_InputDialog_Message = &Enter a package: -BeanInfoPathsBlock_ExportAll = E&xport all -BeanInfoPathsBlock_UnexportAll = U&nexport all -BeanInfoPathsBlock_Page_Tab_Packages = &Packages -BeanInfoPathsBlock_Page_Tab_Classes = &BeanInfo classes -BeanInfosWorkbookPage_AddFolders = &Add Folders -BeanInfosWorkbookPage_AddJARs = Add &JARs -BeanInfosWorkbookPage_AddExternalJAR = Add E&xternal JARs -BeanInfosWorkbookPage_AddVariable = Add &Variable -BeanInfosWorkbookPage_AddProjects = Add Projec&ts -BeanInfosWorkbookPage_ModifyPaths = &Modify Paths -BeanInfosWorkbookPage_Remove = &Remove -BeanInfosWorkbookPage_List_Text = &Choose locations of BeanInfo classes (BeanInfo classes locations not in current project) -BeanInfosWorkbookPage_SelectionDialog_Classes_Title = BeanInfo Class Folders Selection -BeanInfosWorkbookPage_SelectionDialog_JARs_Title = JAR Selection -BeanInfosWorkbookPage_SelectionDialog_JARs_Message = &Choose JARs to be added as BeanInfo classes JARs -BeanInfosWorkbookPage_SelectionDialog_ExtJARs_Text = JAR Selection -BeanInfosWorkbookPage_SelectionDialog_Projects_Title = BeanInfo Projects Selection -BeanInfosWorkbookPage_SelectionDialog_Classes_Prompt = &Choose folders to be added as BeanInfo classes folders. -BeanInfosWorkbookPage_SelectionDialog_Projects_Prompt = &Choose projects to be added as BeanInfo projects. -PackagesWorkbook_ChoosePackages = &Choose packages -PackagesWorkbook_ChooseDefinedPaths = Choose &defined paths -PackagesWorkbook_Remove = &Remove -PackagesWorkbook_LabelText = Choose BeanInfo &packages from the class path -PackagesWorkbook_SelectionDialog_DefinedPaths_Title = Choose Defined Paths -PackagesWorkbook_SelectionDialog_DefinedPaths_Message = Choose the pre-defined paths to add to the search path -LabelProvider_Library_Folder = {0} (class folder) -LabelProvider_Library__PathLastSegment_PathRelative_ = {0} - {1} -LabelProvider_Library__PathLastSegment_PathExceptLast_ = {0} - {1} -LabelProvider_Variable__name_PathOSString_ = {0} - {1} -LabelProvider__packageName_Path_ = {0}: {1} - -VariableSelectionBlock_variable_label = &Variable Name: -VariableSelectionBlock_variable_button = &Browse... -VariableSelectionBlock_extension_label = Path E&xtension: -VariableSelectionBlock_extension_button = Bro&wse... -VariableSelectionBlock_fullpath_label = Resolved Path: - -VariableSelectionBlock_error_entername_ERROR_ = IWAV0077E Variable name must be entered. -VariableSelectionBlock_error_namenotexists_ERROR_ = IWAV0078E Variable does not exist. -VariableSelectionBlock_error_pathexists_ERROR_ = IWAV0079E Class path entry already exists. -VariableSelectionBlock_error_invalidextension_ERROR_ = IWAV0080E Extension is not a valid path. - -VariableSelectionBlock_warning_pathnotexists_WARN_ = IWAV0081W Resolved path is not an existing JAR file. - -VariableSelectionBlock_ExtJarDialog_title = JAR Selection - - - - -# -# Properties for the com.ibm.etools.beaninfo.ui plugin -# - -# This shows up as the title of a message dialog -Beaninfo_UI__errortitle = Error - -Beaninfo_UI__error = Error while setting BeanInfo configuration. - -BeaninfoPropertiesPage_INFO__nojavaproject = IWAV0019I BeanInfo is only applicable to Java projects. -BeaninfoPropertiesPage_INFO__closedproject = IWAV0020I BeanInfo is not available for a closed project. - -# This is a checkbox on a preference page. The label is to indicate whether introspection is enabled to run or not. -BeaninfoPathsBlock_UI__enablebeaninfo = &Enable BeanInfo Introspection on this Project - -# This is a header line for a page of preferences. -BeaninfoPathsBlock_UI__searchpath_label = Build BeanInfo &search path order and exported entries:\n(Exported entries are contributed to dependent projects) -BeaninfoPathsBlock_UI__searchpath_up_button = &Up -BeaninfoPathsBlock_UI__searchpath_down_button = &Down -BeaninfoPathsBlock_UI__searchpath_remove_button = &Remove -BeaninfoPathsBlock_UI__serachpath_tab_order = &Order and Export - -BeaninfoPathsBlock_UI__warning_EntryMissing = Project class path entries, or BeanInfo class files are missing. - -# {0} will be the package name, e.g. java.lang -BeaninfoPathsBlock_WARN__searchpath_missing_path_format = IWAV0021W {0} - Package path not found. - -# This is a message on a progress dialog. -BeaninfoPathsBlock_UI__searchpath_operationdescription = Setting BeanInfo search paths... - -BeaninfoPathsBlock_UI__addsearchpath_title = Select Packages -BeaninfoPathsBlock_UI__addsearchpath_description = &Select packages to add to search path: - -BeaninfoPathsBlock_UI__warning_EntryMissing = Project class path entries, or BeanInfo class files are missing. -BeaninfoPathsBlock_UI__searchpath_add_button = Add Package... -ExceptionHandler_errordialog_msg_seelog=See error log for more details. |