All Downloads are FREE. Search and download functionalities are using the official Maven repository.

java.fedora.client.objecteditor.BehaviorDescriptionPanel Maven / Gradle / Ivy

Go to download

The Fedora Client is a Java Library that allows API access to a Fedora Repository. The client is typically one part of a full Fedora installation.

The newest version!
/*
 * -----------------------------------------------------------------------------
 *
 * 

License and Copyright: The contents of this file are subject to the * Apache License, Version 2.0 (the "License"); you may not use * this file except in compliance with the License. You may obtain a copy of * the License at * http://www.fedora-commons.org/licenses.

* *

Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for * the specific language governing rights and limitations under the License.

* *

The entire file consists of original code.

*

Copyright © 2008 Fedora Commons, Inc.
*

Copyright © 2002-2007 The Rector and Visitors of the University of * Virginia and Cornell University
* All rights reserved.

* * ----------------------------------------------------------------------------- */ package fedora.client.objecteditor; import java.awt.*; import java.awt.event.*; import java.io.*; import java.util.*; import javax.swing.*; import fedora.client.Administrator; import fedora.client.objecteditor.types.MethodDefinition; import fedora.client.objecteditor.types.ParameterDefinition; /** * */ public class BehaviorDescriptionPanel extends JPanel { private static final long serialVersionUID = 1L; private Map m_loadedPanels; private JComponent m_containerToValidate; /** * Initialize with information for the indicated behavior definition. * * If bDefPID is given as null, don't display anything yet. * If containerToValidate is not given as null, that container * will be validate()ed each time this panel changes its structure. */ public BehaviorDescriptionPanel(String bDefPID, JComponent containerToValidate) throws IOException { m_containerToValidate=containerToValidate; setLayout(new BorderLayout()); m_loadedPanels=new HashMap(); if (bDefPID!=null) { setBDef(bDefPID); } } /** * Switch what is displayed (if anything) with information for the * indicated behavior definition. * * If null is given, clear what is currently displayed. */ public void setBDef(String bDefPID) throws IOException { removeAll(); if (bDefPID!=null) { JPanel lp=(JPanel) m_loadedPanels.get(bDefPID); if (lp==null) { lp=makePanel(bDefPID); m_loadedPanels.put(bDefPID, lp); } add(lp, BorderLayout.CENTER); } if (m_containerToValidate!=null) { m_containerToValidate.revalidate(); m_containerToValidate.repaint(new Rectangle(m_containerToValidate.getSize())); } } /** * Create and return a new panel describing the behavior definition. * * Methods dropdown "methodName - descriptionIfExists" * Parameters "None." | tabbedPane */ private JPanel makePanel(String bDefPID) throws IOException { JTextArea supportsMethodsTextArea=new JTextArea(" defines method"); supportsMethodsTextArea.setLineWrap(false); supportsMethodsTextArea.setEditable(false); supportsMethodsTextArea.setBackground(Administrator.BACKGROUND_COLOR); JTextArea methodParametersTextArea=new JTextArea(" with parm(s)"); methodParametersTextArea.setLineWrap(false); methodParametersTextArea.setEditable(false); methodParametersTextArea.setBackground(Administrator.BACKGROUND_COLOR); JComponent[] left=new JComponent[] {supportsMethodsTextArea, methodParametersTextArea}; // // Methods // java.util.List methodDefs=Util.getMethodDefinitions(bDefPID); String[] methodSelections=new String[methodDefs.size()]; for (int i=0; i0) { buf.append("Defaults to " + parmDef.getDefaultValue() + "."); } } if (parmDef.getLabel()!=null) { buf.append(" " + parmDef.getLabel()); } if (parmDef.validValues().size()>0) { buf.append(" Valid values: "); for (int k=0; k0) buf.append(", "); buf.append((String) parmDef.validValues().get(k)); } } JTextArea desc=new JTextArea(buf.toString()); desc.setLineWrap(true); desc.setEditable(false); desc.setWrapStyleWord(true); desc.setBackground(Administrator.BACKGROUND_COLOR); JPanel pane=new JPanel(new BorderLayout()); pane.add(desc, BorderLayout.NORTH); return pane; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy