Revision: 20053 http://sourceforge.net/p/gate/code/20053 Author: markagreenwood Date: 2017-02-02 06:09:08 +0000 (Thu, 02 Feb 2017) Log Message: ----------- removed the Java based help viewer as it was incapable of displaying the user guide so was worse than a chocolate kettle
Modified Paths: -------------- gate/branches/sawdust2/gate-core/src/main/java/gate/gui/MainFrame.java gate/branches/sawdust2/gate-core/src/main/java/gate/gui/OptionsDialog.java Removed Paths: ------------- gate/branches/sawdust2/gate-core/src/main/java/gate/gui/HelpFrame.java gate/branches/sawdust2/gate-core/src/main/java/gate/swing/XJEditorPane.java Deleted: gate/branches/sawdust2/gate-core/src/main/java/gate/gui/HelpFrame.java =================================================================== --- gate/branches/sawdust2/gate-core/src/main/java/gate/gui/HelpFrame.java 2017-02-02 02:23:13 UTC (rev 20052) +++ gate/branches/sawdust2/gate-core/src/main/java/gate/gui/HelpFrame.java 2017-02-02 06:09:08 UTC (rev 20053) @@ -1,85 +0,0 @@ -package gate.gui; - -import java.awt.BorderLayout; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.io.IOException; -import java.net.URL; - -import javax.swing.*; -import javax.swing.text.Document; - -import gate.event.StatusListener; -import gate.swing.XJEditorPane; - -/** - * A frame used by Gate to display Help information. - * It is a basic HTML browser. - */ -@SuppressWarnings("serial") -public class HelpFrame extends JFrame implements StatusListener { - - public HelpFrame(){ - super(); - initLocalData(); - initGuiComponents(); - initListeners(); - } - - protected void initLocalData(){ - } - - protected void initGuiComponents(){ - getContentPane().setLayout(new BorderLayout()); - textPane = new XJEditorPane(); - textPane.setEditable(false); - getContentPane().add(new JScrollPane(textPane), BorderLayout.CENTER); - - toolBar = new JToolBar(); - toolBar.add(textPane.getBackAction()); - toolBar.add(textPane.getForwardAction()); - - getContentPane().add(toolBar, BorderLayout.NORTH); - - Box southBox = Box.createHorizontalBox(); - southBox.add(new JLabel(" ")); - status = new JLabel(); - southBox.add(status); - getContentPane().add(southBox, BorderLayout.SOUTH); - - } - - protected void initListeners(){ - textPane.addPropertyChangeListener(new PropertyChangeListener(){ - @Override - public void propertyChange(PropertyChangeEvent e) { - if(e.getPropertyName().equals("document")){ - String title = (String)textPane.getDocument(). - getProperty("title"); - setTitle((title == null) ? - "GATE help browser" : - title + " - GATE help browser"); - } - } - }); - - textPane.addStatusListener(this); - } - - public void setPage(URL newPage) throws IOException{ - textPane.setPage(newPage); - String title = (String)textPane.getDocument(). - getProperty(Document.TitleProperty); - setTitle((title == null) ? - "GATE help browser" : - title + " - GATE help browser"); - } - - XJEditorPane textPane; - JToolBar toolBar; - JLabel status; - @Override - public void statusChanged(String e) { - status.setText(e); - } -} \ No newline at end of file Modified: gate/branches/sawdust2/gate-core/src/main/java/gate/gui/MainFrame.java =================================================================== --- gate/branches/sawdust2/gate-core/src/main/java/gate/gui/MainFrame.java 2017-02-02 02:23:13 UTC (rev 20052) +++ gate/branches/sawdust2/gate-core/src/main/java/gate/gui/MainFrame.java 2017-02-02 06:09:08 UTC (rev 20053) @@ -284,8 +284,6 @@ protected NewResourceDialog newResourceDialog; - protected HelpFrame helpFrame; - /** * Holds all the icons used in the Gate GUI indexed by filename. This * is needed so we do not need to decode the icon everytime we need it @@ -4082,9 +4080,6 @@ } } - // only hidden when closed - if(helpFrame != null) helpFrame.dispose(); - // trying to release all resources occupied by all try { //make a list of lists of resources of various kinds @@ -4933,11 +4928,8 @@ } catch (IOException ioe1) {/* skip to next try catch */} if (process == null || process.waitFor() != 0) { String message = "Unable to determine the default browser.\n" - + "Will use a Java browser. To use a custom command line\n" - + "go to the Options menu then Configuration."; + + "To use a custom command line go to the Options menu then Configuration."; log.info(message); - // Java help browser - displayJavaHelpBrowser(actualURL.toString()); }}}}} } catch(SecurityException se) { JOptionPane.showMessageDialog(instance, @@ -4949,7 +4941,7 @@ log.error("Help browser Error", ie); } - } else if(!commandLine.equals("Internal Java browser.")) { + } else { // external browser commandLine = commandLine.replaceFirst("%file", actualURL.toString()); try { @@ -4962,39 +4954,13 @@ log.error(message, error); } - } else { - displayJavaHelpBrowser(actualURL.toString()); + } } - } }; Thread thread = new Thread(runnable, "showHelpFrame"); thread.start(); } - private void displayJavaHelpBrowser(String urlString) { - if (helpFrame == null) { - helpFrame = new HelpFrame(); - helpFrame.setSize(800, 600); - helpFrame.setDefaultCloseOperation(HIDE_ON_CLOSE); - // center on screen - Dimension frameSize = helpFrame.getSize(); - Dimension ownerSize = Toolkit.getDefaultToolkit().getScreenSize(); - Point ownerLocation = new Point(0, 0); - helpFrame.setLocation(ownerLocation.x - + (ownerSize.width - frameSize.width) / 2, ownerLocation.y - + (ownerSize.height - frameSize.height) / 2); - } - try { - helpFrame.setPage(new URL(urlString)); - } catch (IOException error) { - String message = "Error when loading help page."; - log.error(message, error); - return; - } - helpFrame.setVisible(false); - helpFrame.setVisible(true); - } - class HelpUserGuideInContextAction extends AbstractAction { private static final long serialVersionUID = 1L; public HelpUserGuideInContextAction() { Modified: gate/branches/sawdust2/gate-core/src/main/java/gate/gui/OptionsDialog.java =================================================================== --- gate/branches/sawdust2/gate-core/src/main/java/gate/gui/OptionsDialog.java 2017-02-02 02:23:13 UTC (rev 20052) +++ gate/branches/sawdust2/gate-core/src/main/java/gate/gui/OptionsDialog.java 2017-02-02 06:09:08 UTC (rev 20053) @@ -192,10 +192,10 @@ addSpaceOnMarkupUnpackChk.setSelected(false); browserComboBox = new JComboBox<String>(new String[] { - "Default browser", "Java", "Custom"}); + "Default browser", "Custom"}); browserComboBox.setPrototypeDisplayValue("Default browser"); browserComboBox.setToolTipText( - "Use Java or Custom only if Default doesn't work."); + "Use Custom only if Default doesn't work."); browserCommandLineTextField = new JTextField(15); String commandLine = userConfig.getString(MainFrame.class.getName()+".browsercommandline"); @@ -205,10 +205,6 @@ browserComboBox.setSelectedItem("Default browser"); browserCommandLineTextField.setEnabled(false); } - else if(commandLine.equals("Internal Java browser.")) { - browserComboBox.setSelectedItem("Java"); - browserCommandLineTextField.setEnabled(false); - } else { browserComboBox.setSelectedItem("Custom"); } @@ -378,11 +374,7 @@ if(item.equals("Default browser")) { browserCommandLineTextField.setText( "Set dynamically when you display help."); - } - else if(item.equals("Java")) { - browserCommandLineTextField.setText("Internal Java browser."); - } - else if(item.equals("Custom")) { + } else if(item.equals("Custom")) { browserCommandLineTextField.setText("firefox %file"); } } Deleted: gate/branches/sawdust2/gate-core/src/main/java/gate/swing/XJEditorPane.java =================================================================== --- gate/branches/sawdust2/gate-core/src/main/java/gate/swing/XJEditorPane.java 2017-02-02 02:23:13 UTC (rev 20052) +++ gate/branches/sawdust2/gate-core/src/main/java/gate/swing/XJEditorPane.java 2017-02-02 06:09:08 UTC (rev 20053) @@ -1,177 +0,0 @@ -package gate.swing; - -import gate.event.StatusListener; -import gate.gui.MainFrame; -import gate.util.Err; - -import java.awt.event.ActionEvent; -import java.io.IOException; -import java.net.URL; -import java.util.LinkedList; -import java.util.Vector; - -import javax.swing.AbstractAction; -import javax.swing.Action; -import javax.swing.JEditorPane; -import javax.swing.event.HyperlinkEvent; -import javax.swing.event.HyperlinkListener; -import javax.swing.text.html.HTMLDocument; -import javax.swing.text.html.HTMLFrameHyperlinkEvent; - -/** - * An enhanced version of {@link javax.swing.JEditorPane} that is able of - * handling hyperlinks from the HTML document displayed. - */ -@SuppressWarnings("serial") -public class XJEditorPane extends JEditorPane { - - public XJEditorPane(){ - super(); - init(); - } - - public XJEditorPane(String url) throws IOException{ - super(url); - init(); - } - - public XJEditorPane(URL initialPage)throws IOException{ - super(initialPage); - init(); - } - - protected void init(){ - initLocalData(); - initListeners(); - }//protected void init() - - protected void initLocalData(){ - backUrls = new LinkedList<URL>(); - forwardUrls = new LinkedList<URL>(); - try{ - backAction = new BackAction(); - forwardAction = new ForwardAction(); - }catch(IOException ioe){ - Err.prln("Resource mising! Is your classpath OK?"); - ioe.printStackTrace(Err.getPrintWriter()); - } - }//protected void initLocalData() - - protected void initListeners(){ - addHyperlinkListener(new HyperlinkListener() { - @Override - public void hyperlinkUpdate(HyperlinkEvent e){ - if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED){ - if (e instanceof HTMLFrameHyperlinkEvent) { - HTMLFrameHyperlinkEvent evt = (HTMLFrameHyperlinkEvent)e; - HTMLDocument doc = (HTMLDocument)getDocument(); - doc.processHTMLFrameHyperlinkEvent(evt); - }else{ - try { - backUrls.addLast(getPage()); - forwardUrls.clear(); - setPage(e.getURL().toExternalForm()); - }catch (Throwable t){ - t.printStackTrace(Err.getPrintWriter()); - } - } - }else if(e.getEventType() == HyperlinkEvent.EventType.ENTERED){ - fireStatusChanged(e.getURL().toExternalForm()); - }else if(e.getEventType() == HyperlinkEvent.EventType.EXITED){ - fireStatusChanged(""); - } - }//public void hyperlinkUpdate(HyperlinkEvent e) - }); - }//protected void initListeners() - - public Action getForwardAction(){ - return forwardAction; - } - - public Action getBackAction(){ - return backAction; - } - - @Override - public void setPage(URL page) throws IOException{ - try{ - super.setPage(page); - }catch(Exception e){ - fireStatusChanged(e.toString()); - e.printStackTrace(Err.getPrintWriter()); - } - updateEnableState(); - } - - class ForwardAction extends AbstractAction{ - private ForwardAction() throws IOException{ - super("Forward", MainFrame.getIcon("forward")); - } - - @Override - public void actionPerformed(ActionEvent e){ - backUrls.addLast(getPage()); - try{ - setPage(forwardUrls.removeFirst()); - }catch(IOException ioe){ - ioe.printStackTrace(Err.getPrintWriter()); - } - } - }//class ForwardAction extends AbstractAction - - class BackAction extends AbstractAction{ - private BackAction() throws IOException{ - super("Back", MainFrame.getIcon("back")); - } - - @Override - public void actionPerformed(ActionEvent e){ - forwardUrls.addFirst(getPage()); - try{ - setPage(backUrls.removeLast()); - }catch(IOException ioe){ - ioe.printStackTrace(Err.getPrintWriter()); - } - } - }//class ForwardAction extends AbstractAction - - - /** - * Updates the enabled/disabled state for the back/forward actions - */ - protected void updateEnableState(){ - forwardAction.setEnabled(!forwardUrls.isEmpty()); - backAction.setEnabled(!backUrls.isEmpty()); - } - public synchronized void removeStatusListener(StatusListener l) { - if (statusListeners != null && statusListeners.contains(l)) { - @SuppressWarnings("unchecked") - Vector<StatusListener> v = (Vector<StatusListener>) statusListeners.clone(); - v.removeElement(l); - statusListeners = v; - } - } - public synchronized void addStatusListener(StatusListener l) { - @SuppressWarnings("unchecked") - Vector<StatusListener> v = statusListeners == null ? new Vector<StatusListener>(2) : (Vector<StatusListener>) statusListeners.clone(); - if (!v.contains(l)) { - v.addElement(l); - statusListeners = v; - } - } - - protected LinkedList<URL> backUrls; - protected LinkedList<URL> forwardUrls; - protected Action backAction; - protected Action forwardAction; - private transient Vector<StatusListener> statusListeners; - protected void fireStatusChanged(String e) { - if (statusListeners != null) { - Vector<StatusListener> listeners = statusListeners; - int count = listeners.size(); - for (int i = 0; i < count; i++) { - listeners.elementAt(i).statusChanged(e); - } - } - } -}//public class XJEditorPane extends JEditorPane This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot _______________________________________________ GATE-cvs mailing list GATE-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gate-cvs