import javax.swing.*;
import javax.swing.event.CaretEvent;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.GapContent;
@Override
public void keyTyped(KeyEvent e)
{
- refreshCutnPaste(true);
}
@Override
public void keyReleased(KeyEvent e)
{
- // TODO Auto-generated method stub
-
+ refreshCutnPaste(true);
}
@Override
}
});
- paste.addComponentListener(new ComponentListener()
+ panels.addChangeListener(new ChangeListener()
{
-
- @Override
- public void componentShown(ComponentEvent e)
- {
- updateServiceFromGui();
- refreshCutnPaste(false);
-
- }
-
- @Override
- public void componentResized(ComponentEvent e)
- {
- }
-
- @Override
- public void componentMoved(ComponentEvent e)
- {
-
- }
-
+ Object lastComp;
@Override
- public void componentHidden(ComponentEvent e)
+ public void stateChanged(ChangeEvent e)
{
- // TODO Auto-generated method stub
+ if (lastComp!=paste) {
+ updateServiceFromGui();
+ refreshCutnPaste(false);
+ } else {
+ refreshCutnPaste(true);
+ }
+ lastComp = panels.getSelectedComponent();
}
- });
+ });
}
public RestServiceEditorPane(RestServiceDescription toedit)
if (reparse)
{
String txt = urldesc.getText().trim();
- StringBuffer warnings;
if (txt.length() > 0)
{
RestServiceDescription rsd = null;
if (rsd.isValid())
{
parseWarnings.setVisible(false);
+ parseRes.setText("");
initGuiWith(currentservice=rsd);
}
else
}
} catch (Throwable e)
{
+ e.printStackTrace();
parseRes.setText("\nParsing failed. An unrecoverable exception was thrown:\n"
+ e.toString());
parseWarnings.setVisible(true);
}
}
+ paste.revalidate();
}
}
-
+
}
public static void main(String[] args)
inputs.setLayout(new MigLayout("","[grow 85,fill][]",""));
paste = new JPanel();
paste.setName("Cut'n'Paste");
- paste.setLayout(new MigLayout());
+ paste.setLayout(new MigLayout("","[grow 100, fill]","[][grow 100,fill]"));
panels = new JTabbedPane();
panels.addTab(details.getName(), details);
// Parse flat-text to a service
- urldesc = new JTextArea(2,40);
+ urldesc = new JTextArea(4,50);
urldesc.setEditable(true);
+ urldesc.setWrapStyleWord(true);
urldescVp = new JScrollPane();
urldescVp.setViewportView(urldesc);
- JvSwingUtils.mgAddtoLayout(paste,"Flat file representation of this rest service using the Really Simple Bioinformatics Service formalism", new JLabel("RSBS Encoded Service:"), urldescVp,"wrap");
-
- parseRes = new JTextArea(5,40);
+ JPanel urldescPane = new JPanel();
+ urldescPane.setLayout(new MigLayout("","[grow 100, fill]", "[grow 100, fill]"));
+ urldescPane.setBorder(new TitledBorder("RSBS Encoded Service"));
+ urldescPane.add(urldescVp, "span");
+ paste.add(urldescPane,"span");
+ urldescPane.setToolTipText("<html>"+JvSwingUtils.wrapTooltip("Flat file representation of this rest service using the Really Simple Bioinformatics Service formalism"));
+
+ parseRes = new JTextArea();
parseResVp = new JScrollPane();
parseResVp.setViewportView(parseRes);
- parseWarnings = new JPanel(new MigLayout());
+ parseRes.setWrapStyleWord(true);
+ parseRes.setColumns(40);
+ parseWarnings = new JPanel(new MigLayout("","[grow 100, fill]", "[grow 100, fill]"));
parseWarnings.setBorder(new TitledBorder("Parsing errors"));
parseWarnings.setToolTipText("<html>"+JvSwingUtils.wrapTooltip("Results of parsing the RSBS representation")+"</html>");
- parseWarnings.add(parseResVp, "wrap");
+ parseWarnings.add(parseResVp, "center");
parseRes.setEditable(false);
-
+ paste.add(parseWarnings, "span");
setLayout(new BorderLayout());
add(panels, BorderLayout.CENTER);
okButton = JvSwingUtils.makeButton("OK", "", new ActionListener()