1 11 package org.eclipse.update.internal.ui.wizards; 12 13 import java.net.MalformedURLException ; 14 import java.net.URL ; 15 16 import org.eclipse.swt.widgets.Shell; 17 import org.eclipse.update.internal.ui.UpdateUI; 18 import org.eclipse.update.internal.ui.model.SiteBookmark; 19 20 21 public class EditSiteDialog extends NewUpdateSiteDialog { 22 SiteBookmark bookmark; 23 private int ignoreBookmark = -1; 24 25 public EditSiteDialog(Shell parentShell, SiteBookmark bookmark) { 26 super(parentShell); 27 this.bookmark = bookmark; 28 } 29 30 public EditSiteDialog(Shell parentShell, SiteBookmark bookmark, SiteBookmark[] siteBookmarks) { 31 super(parentShell, siteBookmarks); 32 this.bookmark = bookmark; 33 ignoreBookmark(siteBookmarks); 34 } 35 36 public EditSiteDialog(Shell parentShell, SiteBookmark bookmark, boolean enableOK) { 37 super(parentShell,enableOK); 38 this.bookmark = bookmark; 39 } 40 41 public EditSiteDialog(Shell parentShell, SiteBookmark bookmark, SiteBookmark[] siteBookmarks, boolean enableOK) { 42 super(parentShell, enableOK, siteBookmarks); 43 this.bookmark = bookmark; 44 ignoreBookmark(siteBookmarks); 45 } 46 47 protected void initializeFields() { 48 name.setText(bookmark.getName()); 49 url.setText(bookmark.getURL().toString()); 50 url.setEditable(!bookmark.isLocal()); 51 } 52 53 protected void update() { 54 try { 55 bookmark.setName(name.getText()); 56 bookmark.setURL(new URL (url.getText())); 57 UpdateUI.getDefault().getUpdateModel().fireObjectChanged(bookmark, null); 58 } catch (MalformedURLException e) { 59 } 60 } 61 62 private void ignoreBookmark( SiteBookmark[] siteBookmarks) { 63 64 for( int i = 0; i < siteBookmarks.length; i++) { 65 66 if (siteBookmarks[i].getLabel().equals(bookmark.getLabel().trim()) && 67 siteBookmarks[i].getURL().equals(bookmark.getURL())) { 68 ignoreBookmark = i; 69 return; 70 } 71 72 } 73 } 74 75 protected boolean isCurrentlyEditedSiteBookmark( int index) { 76 77 return index == ignoreBookmark; 78 } 79 } 80 | Popular Tags |