From: <ez...@us...> - 2014-08-14 18:27:15
|
Revision: 23655 http://sourceforge.net/p/jedit/svn/23655 Author: ezust Date: 2014-08-14 18:27:06 +0000 (Thu, 14 Aug 2014) Log Message: ----------- More work on #1153: Now the SessionManager works with multiple views. Still todo: Window Title. Modified Paths: -------------- plugins/Sessions/trunk/sessions/SaveDialog.java plugins/Sessions/trunk/sessions/Session.java plugins/Sessions/trunk/sessions/SessionManager.java plugins/Sessions/trunk/sessions/SessionManagerDialog.java plugins/Sessions/trunk/sessions/SessionPropertiesDialog.java plugins/Sessions/trunk/sessions/SessionSwitcher.java plugins/Sessions/trunk/sessions/SessionsPlugin.html plugins/Sessions/trunk/sessions/SessionsPlugin.java Modified: plugins/Sessions/trunk/sessions/SaveDialog.java =================================================================== --- plugins/Sessions/trunk/sessions/SaveDialog.java 2014-08-13 17:31:11 UTC (rev 23654) +++ plugins/Sessions/trunk/sessions/SaveDialog.java 2014-08-14 18:27:06 UTC (rev 23655) @@ -84,7 +84,7 @@ openedPanel.add(BorderLayout.NORTH, new JLabel(jEdit.getProperty("session.savedialog.added"))); closedPanel.add(BorderLayout.NORTH, new JLabel(jEdit.getProperty("session.savedialog.removed"))); - Session currentSession = SessionManager.getInstance().getCurrentSessionInstance(); + Session currentSession = SessionManager.getInstance().getSession(view); Buffer[] buffers = jEdit.getBuffers(); Vector newFiles = new Vector(buffers.length); Modified: plugins/Sessions/trunk/sessions/Session.java =================================================================== --- plugins/Sessions/trunk/sessions/Session.java 2014-08-13 17:31:11 UTC (rev 23654) +++ plugins/Sessions/trunk/sessions/Session.java 2014-08-14 18:27:06 UTC (rev 23655) @@ -271,15 +271,14 @@ } catch (IOException io) { - Log.log(Log.ERROR, this, io); - SessionManager.showErrorLater(view, "ioerror", new Object[] { io.getMessage() }); + Log.log(Log.ERROR, this, "Failed: ", io); + // SessionManager.showErrorLater(view, "ioerror", new Object[] { io.getMessage() }); return false; } catch (Exception e) { // this is probably a xml parse exception - Log.log(Log.ERROR, this, e); - SessionManager.showErrorLater(view, "sessions.manager.error.load", new Object[] { name, e.getMessage() }); + Log.log(Log.ERROR, this, "Failed:", e); return false; } @@ -317,7 +316,6 @@ public boolean save(View view) { Log.log(Log.DEBUG, this, "save: name=" + name); - if (view != null) view.getEditPane().saveCaretInfo(); @@ -337,8 +335,8 @@ saveXML(); } catch (IOException io) { - Log.log(Log.ERROR, this, io); - SessionManager.showErrorLater(view, "ioerror", new Object[] { io.getMessage() }); + Log.log(Log.ERROR, this, "Save Failed: ", io); + // SessionManager.showErrorLater(view, "ioerror", new Object[] { io.getMessage() }); return false; } Modified: plugins/Sessions/trunk/sessions/SessionManager.java =================================================================== --- plugins/Sessions/trunk/sessions/SessionManager.java 2014-08-13 17:31:11 UTC (rev 23654) +++ plugins/Sessions/trunk/sessions/SessionManager.java 2014-08-14 18:27:06 UTC (rev 23655) @@ -27,20 +27,18 @@ import java.awt.Component; import java.io.File; import java.io.FilenameFilter; -import java.io.FileNotFoundException; -import java.io.IOException; import java.util.Arrays; +import java.util.HashMap; import java.util.Vector; + import javax.swing.JOptionPane; + import org.gjt.sp.jedit.*; -import org.gjt.sp.jedit.EditPane; import org.gjt.sp.jedit.browser.VFSBrowser; import org.gjt.sp.jedit.bufferset.BufferSet; -import org.gjt.sp.jedit.io.VFSManager; -import org.gjt.sp.jedit.msg.PropertiesChanged; import org.gjt.sp.util.Log; import org.gjt.sp.util.StandardUtilities; -import org.gjt.sp.jedit.msg.BufferUpdate; +import org.gjt.sp.util.StringList; /** @@ -71,17 +69,15 @@ /** The current session instance. */ - private Session currentSession; + // private Session currentSession; + private HashMap<View, Session> currentSessions = new HashMap<View, Session>(); /** The singleton SessionManager instance. */ private static SessionManager instance; + private Session blankSession; - /** The string that will contain the new temp jEdit view.title property.*/ - private String titleBarSessionName; - - /** The default jEdit view.title property. */ private String defaultViewTitle; @@ -93,14 +89,15 @@ return instance; } - /** * Initialization */ private SessionManager() { - currentSession = new Session(jEdit.getProperty(SESSION_PROPERTY, "default")); + // TODO: make translatable? + blankSession = new Session("none"); + // create directory <jedithome>/sessions if it not yet exists File dir = new File(getSessionsDir()); if(!dir.exists()) @@ -109,18 +106,38 @@ // convert old format session files, if necessary new SessionFileConverter().run(); - // create default session file if it not yet exists + +/* // create default session file if it not yet exists File defaultSessionFile = new File(createSessionFileName("default")); if(!defaultSessionFile.exists()) new Session("default").save(null); - - + */ + // initialize the variables for the jEdit title bar defaultViewTitle = jEdit.getProperty("view.title", jEdit.getProperty("sessions.titlebar.default")); - titleBarSessionName = new String(); + new String(); } + /** Restore the session state of all views, since the last time the sessions were saved. */ + void restore() { + String s = jEdit.getProperty(SESSION_PROPERTY, "none"); + StringList sessionList = StringList.split(s, ","); + int viewIndex = 0; + for (View view: jEdit.getViews()) { + if (sessionList.size() <= viewIndex) break; + + String sessionName = sessionList.get(viewIndex); + viewIndex += 1; + if (sessionName.equals("none")) + continue; + Session session = new Session(sessionName); + session.open(view); + if (jEdit.getBufferSetManager().getScope() == BufferSet.Scope.global) break; + } + } + + /** * Save the current session (subject to user preferences) and switch to a new session. @@ -133,29 +150,36 @@ */ public void setCurrentSession(final View view, final String newSessionName) { - if(newSessionName.equals(currentSession.getName())) + + String oldSessionName="none"; + if (currentSessions.containsKey(view)) { + Session currentSession = getSession(view); + + if(newSessionName.equals(currentSession.getName())) return; - Log.log(Log.DEBUG, this, "setCurrentSession:" - + " currentSession=" + currentSession.getName() - + " newSessionName=" + newSessionName); + Log.log(Log.DEBUG, this, "setCurrentSession:" + + " currentSession=" + currentSession.getName() + + " newSessionName=" + newSessionName); - File currentSessionFile = new File(currentSession.getFilename()); - if(currentSessionFile.exists()) - { - // Auto-save the current session, subject to user preferences. - if (!autosaveCurrentSession(view)) + File currentSessionFile = new File(currentSession.getFilename()); + if(currentSessionFile.exists()) { - // User doesn't want to switch the session - return; + // Auto-save the current session, subject to user preferences. + if (!autosaveCurrentSession(view)) + { + // User doesn't want to switch the session + return; + } } + else + { + // The current session file has been deleted, probably by the SessionManagerDialog. + // Do nothing, because save would recreate it. + } + oldSessionName = currentSession.getName(); + } - else - { - // The current session file has been deleted, probably by the SessionManagerDialog. - // Do nothing, because save would recreate it. - } - // close all open buffers in this view, if closeAll option is set: if (jEdit.getBooleanProperty("sessions.switcher.closeAll", true)) for (EditPane ep: view.getEditPanes()) { @@ -164,9 +188,6 @@ jEdit.closeBuffer(ep, b); } - final String oldSessionName = currentSession.getName(); - EditBus.send(new SessionChanging(this, oldSessionName, newSessionName)); - // load new session // make sure this is not done from the AWT thread @@ -188,8 +209,9 @@ }.start(); */ - currentSession = new Session(newSessionName); - saveCurrentSessionProperty(); + Session currentSession = new Session(newSessionName); + currentSessions.put(view, currentSession); + // saveCurrentSessionProperty(); currentSession.open(view); EditBus.send(new SessionChanged( SessionManager.this, oldSessionName, newSessionName, currentSession)); @@ -202,34 +224,14 @@ setSessionNameInTitleBar(); } - - /** Return the current session name. */ - public String getCurrentSession() - { - return currentSession.getName(); + public Session getSession(View view) { + if (currentSessions.containsKey(view)) + return currentSessions.get(view); + else return blankSession; } + - - /** Return the current session. */ - public Session getCurrentSessionInstance() - { - return currentSession; - } - - /** - * Save current session and show a dialog that it has been saved. This is the method - * that is called for a "user-requested" save operation. - * - * @param view view for displaying error messages - */ - public void saveCurrentSession(View view) - { - saveCurrentSession(view, false); - } - - - /** * Save current session without showing the save confirmation dialog, * unless the "display confirmation dialog" flag has been set in the * plugin properties pane. This is the method that is called for "autosave" @@ -241,6 +243,7 @@ */ public boolean autosaveCurrentSession(View view) { + Session currentSession = getSession(view); if (currentSession.hasFileListChanged(view)) { // If autosave sessions is on, save current session silently. @@ -279,6 +282,7 @@ */ public void saveCurrentSession(View view, boolean silently) { + Session currentSession = getSession(view); currentSession.save(view); saveCurrentSessionProperty(); if (!silently) @@ -300,6 +304,7 @@ */ public void saveCurrentSessionAs(View view) { + Session currentSession = getSession(view); String newName = inputSessionName(view, currentSession.getName()); if (newName == null) @@ -326,6 +331,7 @@ // set new session: String oldSessionName = currentSession.getName(); + currentSessions.put(view, newSession); currentSession = newSession; saveCurrentSessionProperty(); EditBus.send(new SessionListChanged(this)); @@ -342,6 +348,7 @@ */ public void reloadCurrentSession(final View view) { + Session currentSession = getSession(view); Log.log(Log.DEBUG, this, "reloadCurrentSession: currentSession=" + currentSession); // close all open buffers @@ -350,7 +357,7 @@ for (Buffer b: bs.getAllBuffers()) jEdit.closeBuffer(ep, b); } - + // FIXME: do we need to make sure this is not the AWT thread?!? currentSession.open(view); // ignore any errors and return value } @@ -364,6 +371,7 @@ */ public void changeFSBToBaseDirectory(View view) { + Session currentSession = getSession(view); if ((jEdit.getBooleanProperty("sessions.switcher.changeFSBDirectory", false)) && !("".equals(currentSession.getProperty(Session.BASE_DIRECTORY))) && (view.getDockableWindowManager().isDockableWindowVisible(VFSBrowser.NAME))) @@ -384,6 +392,7 @@ */ public void showSessionManagerDialog(View view) { + Session currentSession = getSession(view); SessionManagerDialog dlg = new SessionManagerDialog(view, currentSession.getName()); String newSession = dlg.getSelectedSession(); @@ -407,6 +416,7 @@ public void showSessionPropertiesDialog(View view) { + Session currentSession = getSession(view); SessionPropertiesShowing message = new SessionPropertiesShowing(this, currentSession); EditBus.send(message); new SessionPropertiesDialog(view, currentSession.getName(), message.getRootGroup()); @@ -430,7 +440,7 @@ for (int i=0; i < files.length; i++) { String name = files[i].substring(0, files[i].length() - 4); // cut off ".xml" - if (name.equalsIgnoreCase("default")) + if (name.equalsIgnoreCase("none")) { // default session always first v.insertElementAt(name, 0); @@ -441,7 +451,7 @@ } if (!foundDefault) - v.insertElementAt("default", 0); + v.insertElementAt("none", 0); String[] result = new String[v.size()]; v.copyInto(result); @@ -456,7 +466,7 @@ /** * Converts a session name (eg, "default") to a full path name - * (eg, "/home/slava/.jedit/sessions/default.xml"). + * (eg, "/home/ezust/.jedit/plugins/sessions.SessionsPlugin/default.xml"). */ public static String createSessionFileName(String session) { @@ -474,7 +484,6 @@ public static String getSessionsDir() { return EditPlugin.getPluginHome(SessionsPlugin.class).toString(); - //return MiscUtilities.constructPath(jEdit.getSettingsDirectory(), "sessions"); } @@ -513,31 +522,23 @@ } - /** - * Show an error message dialog (using GUIUtilities.error()) - * after the GUI has been updated, in the AWT thread. - */ - public static final void showErrorLater(final View view, final String messageProperty, final Object[] args) - { - VFSManager.runInAWTThread(new Runnable() - { - public void run() - { - GUIUtilities.error(view, messageProperty, args); - } - }); - } - // {{{ jEdit title bar controls // added by Paul Russell 2004-09-26 /** - * Record the name of the current session in a jEdit property (SESSION_PROPERTY). This - * property is used to restore the last used session the next time the plugin is started. + * Record the names of the current sessions in a jEdit property (SESSION_PROPERTY). This + * property is used to restore the last used sessions the next time the plugin is started. */ void saveCurrentSessionProperty() { - Log.log(Log.DEBUG, this, "saveCurrentSessionProperty: currentSession=" + currentSession.getName()); - jEdit.setProperty(SESSION_PROPERTY, currentSession.getName()); + // /** Save sessions of all views to a persistent mapping */ + StringList sessionNames = new StringList(); + for (View v: jEdit.getViews()) { + Session s = getSession(v); + if (s == blankSession) continue; + sessionNames.add(s.getName()); + if (jEdit.getBufferSetManager().getScope() == BufferSet.Scope.global) break; + } + jEdit.setProperty(SESSION_PROPERTY, sessionNames.join(",")); jEdit.saveSettings(); } @@ -546,6 +547,8 @@ */ public void setSessionNameInTitleBar() { + // TODO: use view.setUserTitle() instead + /* if ( currentSession != null ) { if ( jEdit.getBooleanProperty("sessions.switcher.showSessionNameInTitleBar", true) ) @@ -569,7 +572,7 @@ jEdit.setTemporaryProperty("view.title", titleBarSessionName); refreshTitleBar(); } - } + } */ } /** @@ -577,7 +580,7 @@ */ public void restoreTitleBarText() { - jEdit.setTemporaryProperty("view.title", defaultViewTitle); +// jEdit.setTemporaryProperty("view.title", defaultViewTitle); } /** @@ -586,12 +589,13 @@ */ public void refreshTitleBar() { - View[] views = jEdit.getViews(); + /* View[] views = jEdit.getViews(); for( int i = 0; i < views.length; i++ ) { views[i].updateTitle(); - } + } + */ } // }}} Modified: plugins/Sessions/trunk/sessions/SessionManagerDialog.java =================================================================== --- plugins/Sessions/trunk/sessions/SessionManagerDialog.java 2014-08-13 17:31:11 UTC (rev 23654) +++ plugins/Sessions/trunk/sessions/SessionManagerDialog.java 2014-08-14 18:27:06 UTC (rev 23655) @@ -24,7 +24,6 @@ import java.awt.Component; -import java.awt.Dimension; import java.awt.GridBagLayout; import java.awt.GridBagConstraints; import java.awt.Insets; @@ -33,13 +32,10 @@ import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.io.File; -import java.io.FilenameFilter; -import java.util.Vector; import javax.swing.*; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import org.gjt.sp.jedit.jEdit; -import org.gjt.sp.jedit.EditBus; import org.gjt.sp.jedit.GUIUtilities; import org.gjt.sp.jedit.View; import org.gjt.sp.jedit.gui.EnhancedDialog; @@ -60,7 +56,7 @@ { super(view, jEdit.getProperty("sessions.manager.title"), true); this.currentSession = currentSession; - + this.view = view; lSessions = new JList(SessionManager.getInstance().getSessionNames()); lSessions.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); lSessions.addListSelectionListener(this); @@ -213,7 +209,7 @@ Session renameSession; if (oldName.equals(currentSession)) { - renameSession = SessionManager.getInstance().getCurrentSessionInstance(); + renameSession = SessionManager.getInstance().getSession(view); } else { renameSession = new Session(oldName); try { @@ -306,7 +302,7 @@ } } - + private View view; private JList lSessions; private JButton bRename; private JButton bDelete; Modified: plugins/Sessions/trunk/sessions/SessionPropertiesDialog.java =================================================================== --- plugins/Sessions/trunk/sessions/SessionPropertiesDialog.java 2014-08-13 17:31:11 UTC (rev 23654) +++ plugins/Sessions/trunk/sessions/SessionPropertiesDialog.java 2014-08-14 18:27:06 UTC (rev 23655) @@ -53,6 +53,7 @@ new Object[] { sessionName }), true); this.rootGroup = rootGroup; + this.view =view; view.showWaitCursor(); @@ -153,7 +154,7 @@ // Fire the SessionPropertiesChanged event EditBus.send(new SessionPropertiesChanged( SessionManager.getInstance(), - SessionManager.getInstance().getCurrentSessionInstance())); + SessionManager.getInstance().getSession(view))); // get rid of this dialog if necessary if(dispose) dispose(); @@ -228,8 +229,8 @@ private JButton cancel; private JButton apply; private SessionPropertyGroup rootGroup; + private View view; - private TreeModel createTreeModel() { rootGroup.sort(); Modified: plugins/Sessions/trunk/sessions/SessionSwitcher.java =================================================================== --- plugins/Sessions/trunk/sessions/SessionSwitcher.java 2014-08-13 17:31:11 UTC (rev 23654) +++ plugins/Sessions/trunk/sessions/SessionSwitcher.java 2014-08-14 18:27:06 UTC (rev 23655) @@ -55,11 +55,12 @@ Insets nullInsets = new Insets(0,0,0,0); - combo = new JComboBox(SessionManager.getInstance().getSessionNames()); + combo = new JComboBox<String>(SessionManager.getInstance().getSessionNames()); + Session currentSession = SessionManager.getInstance().getSession(view); int maxEntries = jEdit.getIntegerProperty( "options.sessions.switcher.maxListSize", 8); combo.setMaximumRowCount(maxEntries); - combo.setSelectedItem(SessionManager.getInstance().getCurrentSession()); + combo.setSelectedItem(currentSession.getName()); combo.setEditable(false); combo.addItemListener(this); @@ -152,7 +153,7 @@ public void actionPerformed(ActionEvent evt) { if (evt.getSource() == save) - SessionManager.getInstance().saveCurrentSession(view); + SessionManager.getInstance().saveCurrentSession(view, false); else if (evt.getSource() == saveAs) SessionManager.getInstance().saveCurrentSessionAs(view); else if (evt.getSource() == reload) @@ -173,10 +174,10 @@ if(e.getStateChange() != ItemEvent.SELECTED || e.getItem() == null) return; - String currentSession = SessionManager.getInstance().getCurrentSession(); + String currentSessionName = SessionManager.getInstance().getSession(view).getName(); final String selectedSession = e.getItem().toString(); - if (selectedSession.equals(currentSession)) return; + if (selectedSession.equals(currentSessionName)) return; SessionManager.getInstance().setCurrentSession(view, selectedSession); // The session may not have been changed (eg. if the session change @@ -194,7 +195,7 @@ private void updateSessionComboBox() { - final String newSession = SessionManager.getInstance().getCurrentSession(); + final String newSession = SessionManager.getInstance().getSession(view).getName(); SwingUtilities.invokeLater(new Runnable() { @@ -252,7 +253,7 @@ private View view; - private JComboBox combo; + private JComboBox<String> combo; private JButton save; private JButton saveAs; private JButton reload; Modified: plugins/Sessions/trunk/sessions/SessionsPlugin.html =================================================================== --- plugins/Sessions/trunk/sessions/SessionsPlugin.html 2014-08-13 17:31:11 UTC (rev 23654) +++ plugins/Sessions/trunk/sessions/SessionsPlugin.html 2014-08-14 18:27:06 UTC (rev 23655) @@ -15,8 +15,7 @@ </TD> <TD ALIGN="right"> <SMALL>By Dirk Möbius<BR> - <A HREF="mailto:dmo...@gm..."><EM>dmo...@gm...</EM></A> - <p> $Date$ </p> + $Date$ </SMALL> </TD> </TR> @@ -28,6 +27,7 @@ <LI><A HREF="#sessionmanagement">Session Management</A> </LI> <LI><A HREF="#customization">Customization</A> </LI> <LI><A HREF="#license">License</A> </LI> + <LI><A HREF="../CHANGELOG.txt">Changes</A> </LI> <LI><A HREF="#feedback">Feedback</A> </LI> </UL> @@ -40,10 +40,17 @@ (aka <EM>workspaces</EM>) - and offers some functions to switch between them. </P> +<p> Each view, or main window, can have a different session open, and switching sesions from one view +should not affect the open files in the others (unless you are using Global Bufferset Scope).</p> + <A NAME="sessionmanagement"></A> <H2>Session Management</H2> +<p> Session data are stored as XML files in the <tt>plugins/sessions.SessionsPlugin/</tt> folder under your <tt>JEDIT_SETTINGS</tt> directory. In versions prior to 1.5.2, these files were stored in the +<tt>sessions/</tt> directory. To continue using the old session data, move the files into the new location. +</p> + <H3>Menu Actions</H3> <P> @@ -133,14 +140,15 @@ </P> + <A NAME="feedback"></A> <H2>Feedback</H2> <P> The preferred way to send bug reports against specific plugins is to use the -<A HREF="https://sourceforge.net/p/jedit/plugin-bugs/"> +<A HREF="https://sourceforge.net/p/jedit/plugin-bugs"> jEdit Plugin Bugs Tracker</A> on Sourceforge:</P> -<p> There is a separate tracker for <a href="https://sourceforge.net/p/jedit/plugin-feature-requests/?limit=200">Plugin Feature Requests</a>. </p> +<p> There is a separate tracker for <a href="https://sourceforge.net/p/jedit/plugin-feature-requests">Plugin Feature Requests</a>. </p> <P> You can also write to: Modified: plugins/Sessions/trunk/sessions/SessionsPlugin.java =================================================================== --- plugins/Sessions/trunk/sessions/SessionsPlugin.java 2014-08-13 17:31:11 UTC (rev 23654) +++ plugins/Sessions/trunk/sessions/SessionsPlugin.java 2014-08-14 18:27:06 UTC (rev 23655) @@ -69,15 +69,16 @@ } SessionManager mgr = SessionManager.getInstance(); + if (restore) mgr.restore(); // Though we don't need to load the current session's files, we // still need to load the custom properties into memory. - mgr.getCurrentSessionInstance().open(jEdit.getActiveView(), false); - + View view = jEdit.getActiveView(); + // mgr.getSession(view).open(view, false); // Put the session name in the jEdit title bar - mgr.setSessionNameInTitleBar(); - mgr.refreshTitleBar(); - + //mgr.setSessionNameInTitleBar(); + //mgr.refreshTitleBar(); + if (jEdit.getBooleanProperty("sessions.switcher.showToolBar", false)) { // If the switcher is to be shown in the BufferList dockable ... @@ -100,7 +101,7 @@ addSessionSwitcher(views[i]); } } - } + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ez...@us...> - 2014-08-14 20:02:37
|
Revision: 23656 http://sourceforge.net/p/jedit/svn/23656 Author: ezust Date: 2014-08-14 20:02:28 +0000 (Thu, 14 Aug 2014) Log Message: ----------- Updating titlebar code. Modified Paths: -------------- plugins/Sessions/trunk/sessions/Session.java plugins/Sessions/trunk/sessions/SessionManager.java plugins/Sessions/trunk/sessions/SessionsPlugin.java Modified: plugins/Sessions/trunk/sessions/Session.java =================================================================== --- plugins/Sessions/trunk/sessions/Session.java 2014-08-14 18:27:06 UTC (rev 23655) +++ plugins/Sessions/trunk/sessions/Session.java 2014-08-14 20:02:28 UTC (rev 23656) @@ -301,10 +301,36 @@ view.setBuffer(buffer); } } - + updateTitle(view); return true; } + + + /** + * Put the session name in the jEdit title bar + */ + void updateTitle(View view) + { + + if ( jEdit.getBooleanProperty("sessions.switcher.showSessionNameInTitleBar", true) ) + { + String userTitle; + if (jEdit.getBooleanProperty("sessions.switcher.showSessionPrefixInTitleBar", true)) + { + userTitle = jEdit.getProperty("sessions.titlebar.startbracket") + + jEdit.getProperty("sessions.titlebar.prefix") + getName() + + jEdit.getProperty("sessions.titlebar.endbracket"); + } + else + { + userTitle = jEdit.getProperty("sessions.titlebar.startbracket") + + getName() + jEdit.getProperty("sessions.titlebar.endbracket"); + } + view.setUserTitle(userTitle); + } + } + /** * Saves the session. Modified: plugins/Sessions/trunk/sessions/SessionManager.java =================================================================== --- plugins/Sessions/trunk/sessions/SessionManager.java 2014-08-14 18:27:06 UTC (rev 23655) +++ plugins/Sessions/trunk/sessions/SessionManager.java 2014-08-14 20:02:28 UTC (rev 23656) @@ -2,6 +2,7 @@ * SessionManager.java * Copyright (c) 2001 Dirk Moebius, Sergey V. Udaltsov * Copyright (c) 2007, 2008 Steve Jakob + * Copyright (c) 2014 Alan Ezust * * :tabSize=4:indentSize=4:noTabs=false:maxLineLen=0: * @@ -221,7 +222,6 @@ changeFSBToBaseDirectory(view); // update the jEdit title bar with the session name - setSessionNameInTitleBar(); } public Session getSession(View view) { @@ -337,7 +337,6 @@ EditBus.send(new SessionListChanged(this)); EditBus.send(new SessionChanged(this, oldSessionName, newName, currentSession)); // update the jEdit title bar with the session name - setSessionNameInTitleBar(); } @@ -540,63 +539,6 @@ } jEdit.setProperty(SESSION_PROPERTY, sessionNames.join(",")); jEdit.saveSettings(); - } - - /** - * Put the session name in the jEdit title bar - */ - public void setSessionNameInTitleBar() - { - // TODO: use view.setUserTitle() instead - /* - if ( currentSession != null ) - { - if ( jEdit.getBooleanProperty("sessions.switcher.showSessionNameInTitleBar", true) ) - { - if (jEdit.getBooleanProperty("sessions.switcher.showSessionPrefixInTitleBar", true)) - { - titleBarSessionName = defaultViewTitle + - jEdit.getProperty("sessions.titlebar.startbracket") + - jEdit.getProperty("sessions.titlebar.prefix") + - currentSession.getName() + - jEdit.getProperty("sessions.titlebar.endbracket"); - } - else - { - titleBarSessionName = defaultViewTitle + - jEdit.getProperty("sessions.titlebar.startbracket") + - currentSession.getName() + - jEdit.getProperty("sessions.titlebar.endbracket"); - } - - jEdit.setTemporaryProperty("view.title", titleBarSessionName); - refreshTitleBar(); - } - } */ - } - - /** - * Restore the original jEdit title bar text - */ - public void restoreTitleBarText() - { -// jEdit.setTemporaryProperty("view.title", defaultViewTitle); - } - - /** - * refreshes the jEdit Title Bar. This only needs to be called - * when the plugin stops or restarts. - */ - public void refreshTitleBar() - { - /* View[] views = jEdit.getViews(); - - for( int i = 0; i < views.length; i++ ) - { - views[i].updateTitle(); - } - */ - } - + } // }}} } Modified: plugins/Sessions/trunk/sessions/SessionsPlugin.java =================================================================== --- plugins/Sessions/trunk/sessions/SessionsPlugin.java 2014-08-14 18:27:06 UTC (rev 23655) +++ plugins/Sessions/trunk/sessions/SessionsPlugin.java 2014-08-14 20:02:28 UTC (rev 23656) @@ -118,8 +118,6 @@ // update the title bar SessionManager mgr = SessionManager.getInstance(); - mgr.restoreTitleBarText(); - mgr.refreshTitleBar(); } @@ -234,18 +232,7 @@ } SessionManager mgr = SessionManager.getInstance(); - if (jEdit.getBooleanProperty("sessions.switcher.showSessionNameInTitleBar", true) ) - { - mgr.setSessionNameInTitleBar(); - } - else - { - mgr.restoreTitleBarText(); - } - mgr.refreshTitleBar(); - - } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ez...@us...> - 2014-08-14 20:13:05
|
Revision: 23657 http://sourceforge.net/p/jedit/svn/23657 Author: ezust Date: 2014-08-14 20:12:57 +0000 (Thu, 14 Aug 2014) Log Message: ----------- 1153 bugfixes. Modified Paths: -------------- plugins/Sessions/trunk/sessions/Session.java plugins/Sessions/trunk/sessions/SessionManager.java Modified: plugins/Sessions/trunk/sessions/Session.java =================================================================== --- plugins/Sessions/trunk/sessions/Session.java 2014-08-14 20:02:28 UTC (rev 23656) +++ plugins/Sessions/trunk/sessions/Session.java 2014-08-14 20:12:57 UTC (rev 23657) @@ -365,7 +365,7 @@ // SessionManager.showErrorLater(view, "ioerror", new Object[] { io.getMessage() }); return false; } - + updateTitle(view); return true; } Modified: plugins/Sessions/trunk/sessions/SessionManager.java =================================================================== --- plugins/Sessions/trunk/sessions/SessionManager.java 2014-08-14 20:02:28 UTC (rev 23656) +++ plugins/Sessions/trunk/sessions/SessionManager.java 2014-08-14 20:12:57 UTC (rev 23657) @@ -336,7 +336,7 @@ saveCurrentSessionProperty(); EditBus.send(new SessionListChanged(this)); EditBus.send(new SessionChanged(this, oldSessionName, newName, currentSession)); - // update the jEdit title bar with the session name + } @@ -509,7 +509,7 @@ if (name.length() == 0) GUIUtilities.error(relativeTo, "sessions.switcher.saveAs.error.empty", null); if (name.indexOf('/') >= 0 || name.indexOf('\\') >= 0 - || name.indexOf(';') >= 0 || name.indexOf(':') >= 0) + || name.indexOf(';') >= 0 || name.indexOf(',') >= 0 || name.indexOf(':') >= 0) { GUIUtilities.error(relativeTo, "sessions.switcher.saveAs.error.illegalChars", new Object[] { "/ \\ ; :" }); name = ""; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dal...@us...> - 2020-09-14 22:19:26
|
Revision: 25373 http://sourceforge.net/p/jedit/svn/25373 Author: daleanson Date: 2020-09-14 22:19:23 +0000 (Mon, 14 Sep 2020) Log Message: ----------- Fixed some deprecation warnings. Modified Paths: -------------- plugins/Sessions/trunk/sessions/Session.java plugins/Sessions/trunk/sessions/SessionFile.java plugins/Sessions/trunk/sessions/SessionsOptionPane.java Modified: plugins/Sessions/trunk/sessions/Session.java =================================================================== --- plugins/Sessions/trunk/sessions/Session.java 2020-09-14 21:23:13 UTC (rev 25372) +++ plugins/Sessions/trunk/sessions/Session.java 2020-09-14 22:19:23 UTC (rev 25373) @@ -515,8 +515,7 @@ String encoding = buff.getStringProperty(Buffer.ENCODING); if (encoding != null && encoding.length() > 0) out.write(" encoding=\"" + encoding + "\""); - Integer carat = new Integer(buff.getIntegerProperty( - Buffer.CARET, 0)); + Integer carat = Integer.valueOf(buff.getIntegerProperty(Buffer.CARET, 0)); out.write(" carat=\"" + carat.toString() + "\""); } out.write("/>"); @@ -567,7 +566,8 @@ { if (atStart) { - if (localName.equalsIgnoreCase("session")) + //if (localName.equalsIgnoreCase("session")) + if (name.equalsIgnoreCase("session")) { atStart = false; return; Modified: plugins/Sessions/trunk/sessions/SessionFile.java =================================================================== --- plugins/Sessions/trunk/sessions/SessionFile.java 2020-09-14 21:23:13 UTC (rev 25372) +++ plugins/Sessions/trunk/sessions/SessionFile.java 2020-09-14 22:19:23 UTC (rev 25373) @@ -81,7 +81,7 @@ public Integer getCarat() { if (carat == null) - return new Integer(0); + return Integer.valueOf(0); return carat; } Modified: plugins/Sessions/trunk/sessions/SessionsOptionPane.java =================================================================== --- plugins/Sessions/trunk/sessions/SessionsOptionPane.java 2020-09-14 21:23:13 UTC (rev 25372) +++ plugins/Sessions/trunk/sessions/SessionsOptionPane.java 2020-09-14 22:19:23 UTC (rev 25373) @@ -30,7 +30,6 @@ import javax.swing.ButtonGroup; import javax.swing.JCheckBox; import javax.swing.JLabel; -import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.JSpinner; import javax.swing.SpinnerNumberModel; @@ -137,9 +136,9 @@ jEdit.getIntegerProperty("options.sessions.switcher.maxListSize", 8); maxSessionListSizeModel = new SpinnerNumberModel( maxListSize, - new Integer(5), - new Integer(50), - new Integer(1) + Integer.valueOf(5), + Integer.valueOf(50), + Integer.valueOf(1) ); maxSessionListSize = new JSpinner(maxSessionListSizeModel); maxSessionListSize.setMaximumSize(maxSessionListSize.getPreferredSize()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dal...@us...> - 2022-06-27 14:45:47
|
Revision: 25580 http://sourceforge.net/p/jedit/svn/25580 Author: daleanson Date: 2022-06-27 14:45:45 +0000 (Mon, 27 Jun 2022) Log Message: ----------- Fix for plugin bug #1919 Modified Paths: -------------- plugins/Sessions/trunk/sessions/Session.java plugins/Sessions/trunk/sessions/SessionsPlugin.java Modified: plugins/Sessions/trunk/sessions/Session.java =================================================================== --- plugins/Sessions/trunk/sessions/Session.java 2022-06-15 19:09:39 UTC (rev 25579) +++ plugins/Sessions/trunk/sessions/Session.java 2022-06-27 14:45:45 UTC (rev 25580) @@ -336,6 +336,11 @@ } view.setUserTitle(userTitle); } + else + { + view.setUserTitle(jEdit.getProperty("view.title")); + view.updateTitle(); + } } Modified: plugins/Sessions/trunk/sessions/SessionsPlugin.java =================================================================== --- plugins/Sessions/trunk/sessions/SessionsPlugin.java 2022-06-15 19:09:39 UTC (rev 25579) +++ plugins/Sessions/trunk/sessions/SessionsPlugin.java 2022-06-27 14:45:45 UTC (rev 25580) @@ -112,11 +112,12 @@ for (int i = 0; i < views.length; i++) { removeSessionSwitcher(views[i]); + + // update the title bar + views[i].setUserTitle(jEdit.getProperty("view.title")); + views[i].updateTitle(); } - // update the title bar - // TODO: unused, why is this here? - SessionManager mgr = SessionManager.getInstance(); } @@ -231,7 +232,8 @@ { boolean show = jEdit.getBooleanProperty("sessions.switcher.showToolBar", false); View view = jEdit.getFirstView(); - + SessionManager mgr = SessionManager.getInstance(); + while (view != null) { if (show) @@ -238,12 +240,10 @@ addSessionSwitcher(view); else removeSessionSwitcher(view); + Session s = mgr.getSession(view); + s.updateTitle(view); view = view.getNext(); } - - // TODO: unused, why is this here? - SessionManager mgr = SessionManager.getInstance(); - } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |