From 85dc4edd04ee0b3eb024d33a98723878d040c9f3 Mon Sep 17 00:00:00 2001 From: axelcl Date: Thu, 9 Dec 2004 21:56:50 +0000 Subject: [PATCH] improved settings dialogs/improved HTTP Query action --- .../wiki/actions/NewPostBlogEditorAction.java | 2 - .../actions/httpquery/AbstractHTTPQueryAction.java | 35 ++++--- .../phpeclipse/wiki/internal/Configuration.java | 26 +++++- .../wiki/ui/internal/ConfigurationComposite.java | 108 ++++++++++---------- 4 files changed, 97 insertions(+), 74 deletions(-) diff --git a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/actions/NewPostBlogEditorAction.java b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/actions/NewPostBlogEditorAction.java index c402bed..de2aa65 100644 --- a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/actions/NewPostBlogEditorAction.java +++ b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/actions/NewPostBlogEditorAction.java @@ -8,8 +8,6 @@ import net.sourceforge.phpeclipse.wiki.blog.MetaWeblog; import net.sourceforge.phpeclipse.wiki.builder.CreatePageAction; import net.sourceforge.phpeclipse.wiki.editor.WikiEditor; import net.sourceforge.phpeclipse.wiki.preferences.Util; -import net.sourceforge.phpeclipse.wiki.renderer.IContentRenderer; -import net.sourceforge.phpeclipse.wiki.renderer.RendererFactory; import org.eclipse.core.resources.IFile; import org.eclipse.jface.action.IAction; diff --git a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/actions/httpquery/AbstractHTTPQueryAction.java b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/actions/httpquery/AbstractHTTPQueryAction.java index 32e155c..db83d2c 100644 --- a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/actions/httpquery/AbstractHTTPQueryAction.java +++ b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/actions/httpquery/AbstractHTTPQueryAction.java @@ -35,24 +35,25 @@ public abstract class AbstractHTTPQueryAction implements IEditorActionDelegate { public void run(IAction action) { String selection = findSelectedText(); - if (selection != null && selection.trim().length() > 0) { - URL url; - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if (window != null) { - IWorkbenchPage page = window.getActivePage(); - try { - IViewPart part = page.findView(BrowserView.ID_BROWSER); - if (part == null) { - part = page.showView(BrowserView.ID_BROWSER); - } else { - page.bringToTop(part); - } - String urlStr = getUrl(selection); - if (urlStr != null && !urlStr.equals("")) { - ((BrowserView) part).setUrl(urlStr); - } - } catch (Exception e) { + if (selection == null || selection.trim().length() == 0) { + selection = ""; + } + URL url; + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (window != null) { + IWorkbenchPage page = window.getActivePage(); + try { + IViewPart part = page.findView(BrowserView.ID_BROWSER); + if (part == null) { + part = page.showView(BrowserView.ID_BROWSER); + } else { + page.bringToTop(part); + } + String urlStr = getUrl(selection); + if (urlStr != null && !urlStr.equals("")) { + ((BrowserView) part).setUrl(urlStr); } + } catch (Exception e) { } } } diff --git a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/internal/Configuration.java b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/internal/Configuration.java index b27800d..85fd155 100644 --- a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/internal/Configuration.java +++ b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/internal/Configuration.java @@ -15,7 +15,7 @@ import net.sourceforge.phpeclipse.wiki.editor.WikiEditorPlugin; /** * */ -public class Configuration implements IConfiguration { +public class Configuration implements IConfiguration, Comparable { private static final String MEMENTO_ID = "id"; private static final String MEMENTO_NAME = "name"; @@ -144,4 +144,28 @@ public class Configuration implements IConfiguration { fPassword = ""; } } + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + public String toString() { + StringBuffer buffer = new StringBuffer(); + buffer.append(fName); + buffer.append(" - "); + buffer.append(fUser); + buffer.append(" - "); + buffer.append(fUrl); + buffer.append(" - "); + buffer.append(fType); + return buffer.toString(); + } + + /* (non-Javadoc) + * @see java.lang.Comparable#compareTo(java.lang.Object) + */ + public int compareTo(Object o) { + if (o instanceof IConfiguration) { + return fName.compareTo(((IConfiguration)o).getName()); + } + return 1; + } } \ No newline at end of file diff --git a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/ui/internal/ConfigurationComposite.java b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/ui/internal/ConfigurationComposite.java index f09d804..4293c8e 100644 --- a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/ui/internal/ConfigurationComposite.java +++ b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/ui/internal/ConfigurationComposite.java @@ -48,8 +48,8 @@ public class ConfigurationComposite extends Composite { protected Button edit; protected Button remove; - protected Button start; - protected Button stop; +// protected Button start; +// protected Button stop; protected List selection2; @@ -80,6 +80,7 @@ public class ConfigurationComposite extends Composite { table = new Table(this, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.FULL_SELECTION); data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL); data.widthHint = 300; + data.heightHint = 300; // WorkbenchHelp.setHelp(table, ContextIds.PREF_MONITORS); table.setLayoutData(data); @@ -87,7 +88,7 @@ public class ConfigurationComposite extends Composite { table.setLinesVisible(true); TableLayout tableLayout = new TableLayout(); - + TableColumn statusColumn = new TableColumn(table, SWT.NONE); statusColumn.setText(WikiEditorPlugin.getResource("%columnName")); ColumnWeightData colData = new ColumnWeightData(5, 30, true); @@ -109,12 +110,11 @@ public class ConfigurationComposite extends Composite { tableLayout.addColumnData(colData); table.setLayout(tableLayout); - + tableViewer = new TableViewer(table); tableViewer.setContentProvider(new ConfigurationContentProvider()); tableViewer.setLabelProvider(new ConfigurationTableLabelProvider()); tableViewer.setInput("root"); - tableViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { setSelection(event.getSelection()); @@ -181,41 +181,41 @@ public class ConfigurationComposite extends Composite { }); remove.setEnabled(false); - start = SWTUtil.createButton(buttonComp, WikiEditorPlugin.getResource("%start")); - start.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - Iterator iterator = getSelection().iterator(); - while (iterator.hasNext()) { - IConfiguration configuration = (IConfiguration) iterator.next(); +// start = SWTUtil.createButton(buttonComp, WikiEditorPlugin.getResource("%start")); +// start.addSelectionListener(new SelectionAdapter() { +// public void widgetSelected(SelectionEvent e) { +// Iterator iterator = getSelection().iterator(); +// while (iterator.hasNext()) { +// IConfiguration configuration = (IConfiguration) iterator.next(); +//// try { +//// WikiEditorPlugin.startMonitor(monitor); +//// } catch (CoreException ce) { +//// MessageDialog.openError(getShell(), WikiEditorPlugin.getResource("%errorDialogTitle"), ce.getStatus().getMessage()); +//// } catch (Exception ce) { +//// MessageDialog.openError(getShell(), WikiEditorPlugin.getResource("%errorDialogTitle"), ce.getMessage()); +//// } +// tableViewer.refresh(configuration, true); +// } +// tableViewer.setSelection(tableViewer.getSelection()); +// } +// }); +// start.setEnabled(false); +// +// stop = SWTUtil.createButton(buttonComp, WikiEditorPlugin.getResource("%stop")); +// stop.addSelectionListener(new SelectionAdapter() { +// public void widgetSelected(SelectionEvent e) { +// Iterator iterator = getSelection().iterator(); +// while (iterator.hasNext()) { +// IConfiguration monitor = (IConfiguration) iterator.next(); // try { -// WikiEditorPlugin.startMonitor(monitor); -// } catch (CoreException ce) { -// MessageDialog.openError(getShell(), WikiEditorPlugin.getResource("%errorDialogTitle"), ce.getStatus().getMessage()); -// } catch (Exception ce) { -// MessageDialog.openError(getShell(), WikiEditorPlugin.getResource("%errorDialogTitle"), ce.getMessage()); -// } - tableViewer.refresh(configuration, true); - } - tableViewer.setSelection(tableViewer.getSelection()); - } - }); - start.setEnabled(false); - - stop = SWTUtil.createButton(buttonComp, WikiEditorPlugin.getResource("%stop")); - stop.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - Iterator iterator = getSelection().iterator(); - while (iterator.hasNext()) { - IConfiguration monitor = (IConfiguration) iterator.next(); - try { -// WikiEditorPlugin.stopMonitor(monitor); - } catch (Exception ex) { } - tableViewer.refresh(monitor, true); - } - tableViewer.setSelection(tableViewer.getSelection()); - } - }); - stop.setEnabled(false); +//// WikiEditorPlugin.stopMonitor(monitor); +// } catch (Exception ex) { } +// tableViewer.refresh(monitor, true); +// } +// tableViewer.setSelection(tableViewer.getSelection()); +// } +// }); +// stop.setEnabled(false); } protected List getSelection() { @@ -236,25 +236,25 @@ public class ConfigurationComposite extends Composite { if (!selection2.isEmpty()) { remove.setEnabled(true); - boolean allStopped = true; - boolean allStarted = true; +// boolean allStopped = true; +// boolean allStarted = true; - iterator = selection2.iterator(); - while (iterator.hasNext()) { - IConfiguration monitor = (IConfiguration) iterator.next(); - if (monitor.isActive()) - allStopped = false; - else - allStarted = false; - } - start.setEnabled(allStopped); - stop.setEnabled(allStarted); - edit.setEnabled(selection2.size() == 1 && allStopped); +// iterator = selection2.iterator(); +// while (iterator.hasNext()) { +// IConfiguration monitor = (IConfiguration) iterator.next(); +// if (monitor.isActive()) +// allStopped = false; +// else +// allStarted = false; +// } +// start.setEnabled(allStopped); +// stop.setEnabled(allStarted); + edit.setEnabled(true); } else { edit.setEnabled(false); remove.setEnabled(false); - start.setEnabled(false); - stop.setEnabled(false); +// start.setEnabled(false); +// stop.setEnabled(false); } } } \ No newline at end of file -- 1.7.1