Minimize of last buffer close plugin
Submitted by Monday, 17 January, 2005 - 10:16
on
I used to like the feature of Programmer's File Editor whereby it would minimize when the last file was closed, so I quickly knocked up a plugin to do this in jEdit. I don't think it deserves a plugin of its own in the repository, but if someone wants to add it to a general purpose plugin, feel free. The support files are as basic as they can get, so I'll not include them here. The source is:
/* * MinOnClosePlugin.java * Copyright (C) 2005 Matt Plumtree * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ import org.gjt.sp.jedit.jEdit; import org.gjt.sp.jedit.View; import org.gjt.sp.jedit.EBMessage; import org.gjt.sp.jedit.EBPlugin; import org.gjt.sp.jedit.msg.BufferUpdate; import java.awt.Frame; /** * The MinOnClose plugin * * @author Matt Plumtree */ public class MinOnClosePlugin extends EBPlugin { public void handleMessage(EBMessage message) { if (message instanceof BufferUpdate) { BufferUpdate bu = (BufferUpdate)message; if (bu.getWhat() == BufferUpdate.CLOSED) { View v = bu.getView(); if (v != null && jEdit.getBufferCount() == 0) { // Minimize when last buffer closed. v.setExtendedState(Frame.ICONIFIED); } } } } }