improved settings dialogs/improved HTTP Query action
authoraxelcl <axelcl>
Thu, 9 Dec 2004 21:56:50 +0000 (21:56 +0000)
committeraxelcl <axelcl>
Thu, 9 Dec 2004 21:56:50 +0000 (21:56 +0000)
archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/actions/NewPostBlogEditorAction.java
archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/actions/httpquery/AbstractHTTPQueryAction.java
archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/internal/Configuration.java
archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/ui/internal/ConfigurationComposite.java

index c402bed..de2aa65 100644 (file)
@@ -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;
index 32e155c..db83d2c 100644 (file)
@@ -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) {
       }
     }
   }
index b27800d..85fd155 100644 (file)
@@ -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
index f09d804..4293c8e 100644 (file)
@@ -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