⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 installpanel.java

📁 Linux下面最好用的程序、文本编辑工具之一。
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
		//{{{ isDownloadingList() method		private boolean isDownloadingList()		{			return (entries.size() == 1 && entries.get(0) instanceof String);		} //}}}		//{{{ clear() method		public void clear()		{			entries = new ArrayList();			fireTableChanged(new TableModelEvent(this));		} //}}}		//{{{ update() method		public void update()		{			PluginList pluginList = window.getPluginList();			if (pluginList == null) return;			entries = new ArrayList();			for(int i = 0; i < pluginList.pluginSets.size(); i++)			{				PluginList.PluginSet set = (PluginList.PluginSet)					pluginList.pluginSets.get(i);				for(int j = 0; j < set.plugins.size(); j++)				{					PluginList.Plugin plugin = (PluginList.Plugin)						pluginList.pluginHash.get(set.plugins.get(j));					PluginList.Branch branch = plugin.getCompatibleBranch();					String installedVersion =						plugin.getInstalledVersion();					if (updates)					{						if(branch != null							&& branch.canSatisfyDependencies()							&& installedVersion != null							&& MiscUtilities.compareStrings(branch.version,							installedVersion,false) > 0)						{							entries.add(new Entry(plugin,set.name));						}					}					else					{						if(installedVersion == null && plugin.canBeInstalled())							entries.add(new Entry(plugin,set.name));					}				}			}			sort(sortType);			fireTableChanged(new TableModelEvent(this));		} //}}}	} //}}}	//{{{ Entry class	class Entry	{		String name, version, author, date, description, set;		int size;		boolean install;		PluginList.Plugin plugin;		LinkedList parents = new LinkedList();		Entry(PluginList.Plugin plugin, String set)		{			PluginList.Branch branch = plugin.getCompatibleBranch();			boolean downloadSource = jEdit.getBooleanProperty("plugin-manager.downloadSource");			int size = (downloadSource) ? branch.downloadSourceSize : branch.downloadSize;			this.name = plugin.name;			this.author = plugin.author;			this.version = branch.version;			this.size = size;			this.date = branch.date;			this.description = plugin.description;			this.set = set;			this.install = false;			this.plugin = plugin;		}		String getParentString()		{			StringBuffer buf = new StringBuffer();			Iterator iter = parents.iterator();			while(iter.hasNext())			{				buf.append(((Entry)iter.next()).name);				if(iter.hasNext())					buf.append('\n');			}			return buf.toString();		}	} //}}}	//{{{ PluginInfoBox class	class PluginInfoBox extends JTextArea implements ListSelectionListener	{		public PluginInfoBox()		{			setEditable(false);			setLineWrap(true);			setWrapStyleWord(true);			table.getSelectionModel().addListSelectionListener(this);		}		public void valueChanged(ListSelectionEvent e)		{			String text = "";			if (table.getSelectedRowCount() == 1)			{				Entry entry = (Entry)pluginModel.entries					.get(table.getSelectedRow());				text = jEdit.getProperty("install-plugins.info",					new String[] {entry.author,entry.date,entry.description});			}			setText(text);			setCaretPosition(0);		}	} //}}}	//{{{ SizeLabel class	class SizeLabel extends JLabel implements TableModelListener	{		private int size;		public SizeLabel()		{			size = 0;			setText(jEdit.getProperty("install-plugins.totalSize")+formatSize(size));			pluginModel.addTableModelListener(this);		}		public void tableChanged(TableModelEvent e)		{			if (e.getType() == TableModelEvent.UPDATE)			{				if(pluginModel.isDownloadingList())					return;				size = 0;				int length = pluginModel.getRowCount();				for (int i = 0; i < length; i++)				{					Entry entry = (Entry)pluginModel						.entries.get(i);					if (entry.install)						size += entry.size;				}				setText(jEdit.getProperty("install-plugins.totalSize")+formatSize(size));			}		}	} //}}}	//{{{ SelectallButton class	class SelectallButton extends JCheckBox implements ActionListener, TableModelListener	{		public SelectallButton()		{			super(jEdit.getProperty("install-plugins.select-all"));			addActionListener(this);			pluginModel.addTableModelListener(this);			setEnabled(false);		}		public void actionPerformed(ActionEvent evt)		{			pluginModel.setSelectAll(isSelected());		}		public void tableChanged(TableModelEvent e)		{			if(pluginModel.isDownloadingList())				return;			setEnabled(pluginModel.getRowCount() != 0);			if (e.getType() == TableModelEvent.UPDATE)			{				int length = pluginModel.getRowCount();				for (int i = 0; i < length; i++)					if (!((Boolean)pluginModel.getValueAt(i,0)).booleanValue())					{						setSelected(false);						return;					}				if (length > 0)					setSelected(true);			}		}	} //}}}	//{{{ InstallButton class	class InstallButton extends JButton implements ActionListener, TableModelListener	{		public InstallButton()		{			super(jEdit.getProperty("install-plugins.install"));			pluginModel.addTableModelListener(this);			addActionListener(this);			setEnabled(false);		}		public void actionPerformed(ActionEvent evt)		{			if(pluginModel.isDownloadingList())				return;			boolean downloadSource = jEdit.getBooleanProperty(				"plugin-manager.downloadSource");			boolean installUser = jEdit.getBooleanProperty(				"plugin-manager.installUser");			Roster roster = new Roster();			String installDirectory;			if(installUser)			{				installDirectory = MiscUtilities.constructPath(					jEdit.getSettingsDirectory(),"jars");			}			else			{				installDirectory = MiscUtilities.constructPath(					jEdit.getJEditHome(),"jars");			}			int length = pluginModel.getRowCount();			int instcount = 0;			for (int i = 0; i < length; i++)			{				Entry entry = (Entry)pluginModel.entries.get(i);				if (entry.install)				{					entry.plugin.install(roster,installDirectory,downloadSource);					if (updates)						entry.plugin.getCompatibleBranch().satisfyDependencies(						roster,installDirectory,downloadSource);					instcount++;				}			}			if(roster.isEmpty())				return;			boolean cancel = false;			if (updates && roster.getOperationCount() > instcount)				if (GUIUtilities.confirm(window,					"install-plugins.depend",					null,					JOptionPane.OK_CANCEL_OPTION,					JOptionPane.WARNING_MESSAGE) == JOptionPane.CANCEL_OPTION)					cancel = true;						if (!cancel)			{				new PluginManagerProgress(window,roster);					roster.performOperationsInAWTThread(window);				pluginModel.update();			}		}		public void tableChanged(TableModelEvent e)		{			if(pluginModel.isDownloadingList())				return;			if (e.getType() == TableModelEvent.UPDATE)			{				int length = pluginModel.getRowCount();				for (int i = 0; i < length; i++)					if (((Boolean)pluginModel.getValueAt(i,0)).booleanValue())					{						setEnabled(true);						return;					}				setEnabled(false);			}		}	} //}}}	//{{{ EntryCompare class	static class EntryCompare implements Comparator	{		public static final int NAME = 0;		public static final int CATEGORY = 1;		private int type;		public EntryCompare(int type)		{			this.type = type;		}		public int compare(Object o1, Object o2)		{			InstallPanel.Entry e1 = (InstallPanel.Entry)o1;			InstallPanel.Entry e2 = (InstallPanel.Entry)o2;			if (type == NAME)				return e1.name.compareToIgnoreCase(e2.name);			else			{				int result;				if ((result = e1.set.compareToIgnoreCase(e2.set)) == 0)					return e1.name.compareToIgnoreCase(e2.name);				return result;			}		}	} //}}}	//{{{ HeaderMouseHandler class	class HeaderMouseHandler extends MouseAdapter	{		public void mouseClicked(MouseEvent evt)		{			switch(table.getTableHeader().columnAtPoint(evt.getPoint()))			{				case 1:					pluginModel.sort(EntryCompare.NAME);					break;				case 2:					pluginModel.sort(EntryCompare.CATEGORY);					break;				default:			}		}	} //}}}	//{{{ TextRenderer	class TextRenderer extends DefaultTableCellRenderer	{		private DefaultTableCellRenderer tcr;		public TextRenderer(DefaultTableCellRenderer tcr)		{			this.tcr = tcr;		}		public Component getTableCellRendererComponent(JTable table, Object value,			boolean isSelected, boolean hasFocus, int row, int column)		{			return tcr.getTableCellRendererComponent(table,value,isSelected,false,row,column);		}	} //}}}	//}}}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -