/* * JSampler - a java front-end for LinuxSampler * * Copyright (C) 2005-2007 Grigor Iliev * * This file is part of JSampler. * * JSampler is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 * as published by the Free Software Foundation. * * JSampler 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 JSampler; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ package org.jsampler.view.classic; import java.awt.Dimension; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JSeparator; import javax.swing.JTextArea; import org.linuxsampler.lscp.DbInstrumentInfo; import static org.jsampler.view.classic.ClassicI18n.i18n; /** * * @author Grigor Iliev */ public class DbInstrumentPropsPane extends JPanel { private final JLabel lName = new JLabel(i18n.getLabel("DbInstrumentPropsPane.lName")); private final JLabel lLocation = new JLabel(i18n.getLabel("DbInstrumentPropsPane.lLocation")); private final JLabel lSize = new JLabel(i18n.getLabel("DbInstrumentPropsPane.lSize")); private final JLabel lFormat = new JLabel(i18n.getLabel("DbInstrumentPropsPane.lFormat")); private final JLabel lType = new JLabel(i18n.getLabel("DbInstrumentPropsPane.lType")); private final JLabel lDesc = new JLabel(i18n.getLabel("DbInstrumentPropsPane.lDesc")); private final JLabel lCreated = new JLabel(i18n.getLabel("DbInstrumentPropsPane.lCreated")); private final JLabel lModified = new JLabel(i18n.getLabel("DbInstrumentPropsPane.lModified")); private final JLabel lFile = new JLabel(i18n.getLabel("DbInstrumentPropsPane.lFile")); private final JLabel lIndex = new JLabel(i18n.getLabel("DbInstrumentPropsPane.lIndex")); private final JLabel lProduct = new JLabel(i18n.getLabel("DbInstrumentPropsPane.lProduct")); private final JLabel lArtists = new JLabel(i18n.getLabel("DbInstrumentPropsPane.lArtists")); private final JLabel lKeywords = new JLabel(i18n.getLabel("DbInstrumentPropsPane.lKeywords")); private final TextArea taName = new TextArea(); private final TextArea taLocation = new TextArea(); private final TextArea taSize = new TextArea(); private final TextArea taFormat = new TextArea(); private final TextArea taType = new TextArea(); private final TextArea taDesc = new TextArea(); private final TextArea taCreated = new TextArea(); private final TextArea taModified = new TextArea(); private final TextArea taFile = new TextArea(); private final TextArea taIndex = new TextArea(); private final TextArea taProduct = new TextArea(); private final TextArea taArtists = new TextArea(); private final TextArea taKeywords = new TextArea(); /** Creates a new instance of DbInstrumentPropsPane */ public DbInstrumentPropsPane(DbInstrumentInfo instrInfo) { setInstrumentInfo(instrInfo); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); setLayout(gridbag); c.fill = GridBagConstraints.NONE; c.gridx = 0; c.gridy = 0; c.anchor = GridBagConstraints.NORTHEAST; c.insets = new Insets(3, 3, 3, 3); gridbag.setConstraints(lName, c); add(lName); c.gridx = 0; c.gridy = 2; gridbag.setConstraints(lLocation, c); add(lLocation); c.gridx = 0; c.gridy = 3; gridbag.setConstraints(lSize, c); add(lSize); c.gridx = 0; c.gridy = 4; gridbag.setConstraints(lFormat, c); add(lFormat); c.gridx = 0; c.gridy = 5; gridbag.setConstraints(lType, c); add(lType); c.gridx = 0; c.gridy = 6; gridbag.setConstraints(lDesc, c); add(lDesc); c.gridx = 0; c.gridy = 8; gridbag.setConstraints(lCreated, c); add(lCreated); c.gridx = 0; c.gridy = 9; gridbag.setConstraints(lModified, c); add(lModified); c.gridx = 0; c.gridy = 11; gridbag.setConstraints(lFile, c); add(lFile); c.gridx = 0; c.gridy = 12; gridbag.setConstraints(lIndex, c); add(lIndex); c.gridx = 0; c.gridy = 14; gridbag.setConstraints(lProduct, c); add(lProduct); c.gridx = 0; c.gridy = 15; gridbag.setConstraints(lArtists, c); add(lArtists); c.gridx = 0; c.gridy = 16; gridbag.setConstraints(lKeywords, c); add(lKeywords); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 1; c.gridy = 0; c.weightx = 1.0; c.anchor = GridBagConstraints.NORTHWEST; gridbag.setConstraints(taName, c); add(taName); c.gridx = 1; c.gridy = 2; gridbag.setConstraints(taLocation, c); add(taLocation); c.gridx = 1; c.gridy = 3; gridbag.setConstraints(taSize, c); add(taSize); c.gridx = 1; c.gridy = 4; gridbag.setConstraints(taFormat, c); add(taFormat); c.gridx = 1; c.gridy = 5; gridbag.setConstraints(taType, c); add(taType); c.gridx = 1; c.gridy = 6; gridbag.setConstraints(taDesc, c); add(taDesc); c.gridx = 1; c.gridy = 8; gridbag.setConstraints(taCreated, c); add(taCreated); c.gridx = 1; c.gridy = 9; gridbag.setConstraints(taModified, c); add(taModified); c.gridx = 1; c.gridy = 11; gridbag.setConstraints(taFile, c); add(taFile); c.gridx = 1; c.gridy = 12; gridbag.setConstraints(taIndex, c); add(taIndex); c.gridx = 1; c.gridy = 14; gridbag.setConstraints(taProduct, c); add(taProduct); c.gridx = 1; c.gridy = 15; gridbag.setConstraints(taArtists, c); add(taArtists); c.gridx = 1; c.gridy = 16; gridbag.setConstraints(taKeywords, c); add(taKeywords); JSeparator sep = new JSeparator(); c.gridx = 0; c.gridy = 1; c.gridwidth = 2; gridbag.setConstraints(sep, c); add(sep); sep = new JSeparator(); c.gridx = 0; c.gridy = 7; gridbag.setConstraints(sep, c); add(sep); sep = new JSeparator(); c.gridx = 0; c.gridy = 10; gridbag.setConstraints(sep, c); add(sep); sep = new JSeparator(); c.gridx = 0; c.gridy = 13; gridbag.setConstraints(sep, c); add(sep); JPanel p = new JPanel(); p.setOpaque(false); c.gridx = 0; c.gridy = 17; c.weightx = 1.0; c.weighty = 1.0; c.fill = GridBagConstraints.BOTH; gridbag.setConstraints(p, c); add(p); Dimension d = getPreferredSize(); int w = d.width > 300 ? d.width : 300; int h = d.height > 300 ? d.height : 300; setPreferredSize(new Dimension(w, h)); } public void setInstrumentInfo(DbInstrumentInfo instrInfo) { taName.setText(instrInfo.getName()); taLocation.setText(instrInfo.getDirectoryPath()); String s = instrInfo.getFormatedSize(); s += " (" + String.valueOf(instrInfo.getSize()) + " bytes)"; taSize.setText(s); s = instrInfo.getFormatFamily(); if(s.equals("GIG")) s = "GigaSampler"; String ver = instrInfo.getFormatVersion(); if(ver != null & ver.length() > 0) s += ", version " + ver; taFormat.setText(s); if(instrInfo.isDrum()) taType.setText(i18n.getLabel("DbInstrumentPropsPane.drum")); else taType.setText(i18n.getLabel("DbInstrumentPropsPane.chromatic")); taDesc.setText(instrInfo.getDescription()); taCreated.setText(instrInfo.getDateCreated().toString()); taModified.setText(instrInfo.getDateModified().toString()); taFile.setText(instrInfo.getFilePath()); taIndex.setText(String.valueOf(instrInfo.getInstrumentIndex())); taProduct.setText(instrInfo.getProduct()); taArtists.setText(instrInfo.getArtists()); taKeywords.setText(instrInfo.getKeywords()); } private class TextArea extends JTextArea { TextArea() { setLineWrap(true); setEditable(false); setOpaque(false); } } }