X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse.webbrowser/src/net/sourceforge/phpeclipse/webbrowser/internal/OrganizeFavoritesDialog.java b/net.sourceforge.phpeclipse.webbrowser/src/net/sourceforge/phpeclipse/webbrowser/internal/OrganizeFavoritesDialog.java index 5623946..fd9f89f 100644 --- a/net.sourceforge.phpeclipse.webbrowser/src/net/sourceforge/phpeclipse/webbrowser/internal/OrganizeFavoritesDialog.java +++ b/net.sourceforge.phpeclipse.webbrowser/src/net/sourceforge/phpeclipse/webbrowser/internal/OrganizeFavoritesDialog.java @@ -1,11 +1,12 @@ package net.sourceforge.phpeclipse.webbrowser.internal; + /********************************************************************** * Copyright (c) 2003 IBM Corporation and others. - * All rights reserved.   This program and the accompanying materials + * All rights reserved. � This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html - * + �* * Contributors: * IBM - Initial API and implementation **********************************************************************/ @@ -13,7 +14,18 @@ import java.util.List; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.viewers.*; +import org.eclipse.jface.viewers.CellEditor; +import org.eclipse.jface.viewers.ColumnWeightData; +import org.eclipse.jface.viewers.ICellModifier; +import org.eclipse.jface.viewers.ILabelProviderListener; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.TableLayout; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.TextCellEditor; +import org.eclipse.jface.viewers.Viewer; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; @@ -28,34 +40,40 @@ import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableColumn; + /** * Dialog to manage the favorites list. */ public class OrganizeFavoritesDialog extends Dialog { - protected List favorites = WebBrowserPreference.getInternalWebBrowserFavorites(); - + protected List favorites = WebBrowserPreference + .getInternalWebBrowserFavorites(); + public class FavoriteContentProvider implements IStructuredContentProvider { public FavoriteContentProvider() { super(); } - public void dispose() { } + public void dispose() { + } public Object[] getElements(Object inputElement) { return favorites.toArray(); } - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {} + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + } } - + public class FavoriteLabelProvider implements ITableLabelProvider { public FavoriteLabelProvider() { super(); } - public void addListener(ILabelProviderListener listener) { } + public void addListener(ILabelProviderListener listener) { + } - public void dispose() { } + public void dispose() { + } public Image getColumnImage(Object element, int columnIndex) { if (columnIndex == 0) @@ -75,13 +93,15 @@ public class OrganizeFavoritesDialog extends Dialog { return false; } - public void removeListener(ILabelProviderListener listener) { } + public void removeListener(ILabelProviderListener listener) { + } } /** * ManageFavoritesDialog constructor comment. - * @param parentShell org.eclipse.swt.widgets.Shell - * @ + * + * @param parentShell + * org.eclipse.swt.widgets.Shell @ */ public OrganizeFavoritesDialog(Shell parentShell) { super(parentShell); @@ -90,11 +110,12 @@ public class OrganizeFavoritesDialog extends Dialog { } /** - * + * */ protected void configureShell(Shell newShell) { super.configureShell(newShell); - newShell.setText(WebBrowserUIPlugin.getResource("%dialogOrganizeFavoritesTitle")); + newShell.setText(WebBrowserUIPlugin + .getResource("%dialogOrganizeFavoritesTitle")); } /** @@ -111,42 +132,47 @@ public class OrganizeFavoritesDialog extends Dialog { composite.setLayout(layout); composite.setLayoutData(new GridData(GridData.FILL_BOTH)); composite.setFont(parent.getFont()); - //WorkbenchHelp.setHelp(composite, ContextIds.TERMINATE_SERVER_DIALOG); - + // WorkbenchHelp.setHelp(composite, ContextIds.TERMINATE_SERVER_DIALOG); + Label label = new Label(composite, SWT.NONE); - label.setText(WebBrowserUIPlugin.getResource("%dialogOrganizeFavoritesMessage")); + label.setText(WebBrowserUIPlugin + .getResource("%dialogOrganizeFavoritesMessage")); GridData data = new GridData(); data.horizontalSpan = 2; label.setLayoutData(data); - - final Table table = new Table(composite, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL | SWT.SINGLE); + + final Table table = new Table(composite, SWT.BORDER + | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL | SWT.SINGLE); data = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL); data.widthHint = 300; data.heightHint = 150; table.setLayoutData(data); table.setLinesVisible(true); - + TableLayout tableLayout = new TableLayout(); table.setLayout(tableLayout); table.setHeaderVisible(true); - + tableLayout.addColumnData(new ColumnWeightData(5, 50, true)); TableColumn col = new TableColumn(table, SWT.NONE); - col.setText(WebBrowserUIPlugin.getResource("%dialogOrganizeFavoritesName")); - + col.setText(WebBrowserUIPlugin + .getResource("%dialogOrganizeFavoritesName")); + tableLayout.addColumnData(new ColumnWeightData(6, 60, true)); col = new TableColumn(table, SWT.NONE); - col.setText(WebBrowserUIPlugin.getResource("%dialogOrganizeFavoritesURL")); + col.setText(WebBrowserUIPlugin + .getResource("%dialogOrganizeFavoritesURL")); table.setLayout(tableLayout); - - final TableViewer tableViewer = new TableViewer(table); + + final TableViewer tableViewer = new TableViewer(table); tableViewer.setContentProvider(new FavoriteContentProvider()); tableViewer.setLabelProvider(new FavoriteLabelProvider()); tableViewer.setInput("root"); - tableViewer.setColumnProperties(new String[] {"name", "url"}); - - tableViewer.setCellEditors(new CellEditor[] {new TextCellEditor(table), new TextCellEditor(table)}); - + tableViewer.setColumnProperties(new String[] { "name", "url" }); + + tableViewer.setCellEditors(new CellEditor[] { + new TextCellEditor(table), new TextCellEditor(table) }); + ICellModifier cellModifier = new ICellModifier() { public Object getValue(Object element, String property) { Favorite f = (Favorite) element; @@ -155,11 +181,11 @@ public class OrganizeFavoritesDialog extends Dialog { else return f.getURL(); } - + public boolean canModify(Object element, String property) { return true; } - + public void modify(Object element, String property, Object value) { if (element instanceof Item) element = ((Item) element).getData(); @@ -178,29 +204,31 @@ public class OrganizeFavoritesDialog extends Dialog { } }; tableViewer.setCellModifier(cellModifier); - - final Button remove = SWTUtil.createButton(composite, WebBrowserUIPlugin.getResource("%remove")); + + final Button remove = SWTUtil.createButton(composite, + WebBrowserUIPlugin.getResource("%remove")); remove.setEnabled(false); - - tableViewer.addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - remove.setEnabled(!event.getSelection().isEmpty()); - } - }); - + + tableViewer + .addSelectionChangedListener(new ISelectionChangedListener() { + public void selectionChanged(SelectionChangedEvent event) { + remove.setEnabled(!event.getSelection().isEmpty()); + } + }); + remove.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { int index = table.getSelectionIndex(); if (index < 0 || index >= favorites.size()) return; - + tableViewer.remove(favorites.get(index)); favorites.remove(index); } }); - + Dialog.applyDialogFont(composite); - + return composite; }