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
**********************************************************************/
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)
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);
}
/**
- *
+ *
*/
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
- newShell.setText(WebBrowserUIPlugin.getResource("%dialogOrganizeFavoritesTitle"));
+ newShell.setText(WebBrowserUIPlugin
+ .getResource("%dialogOrganizeFavoritesTitle"));
}
/**
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;
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();
}
};
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;
}