use of org.xmldb.api.base.XMLDBException in project exist by eXist-db.
the class TriggersDialog method setupComponents.
private void setupComponents() {
// Dialog Content Panel
final GridBagLayout grid = new GridBagLayout();
getContentPane().setLayout(grid);
// Constraints for Layout
final GridBagConstraints c = new GridBagConstraints();
c.insets = new Insets(2, 2, 2, 2);
// collection label
final JLabel label = new JLabel(Messages.getString("TriggersDialog.Collection"));
c.gridx = 0;
c.gridy = 0;
c.gridwidth = 1;
c.anchor = GridBagConstraints.WEST;
c.fill = GridBagConstraints.NONE;
grid.setConstraints(label, c);
getContentPane().add(label);
// get the collections but not system collections
final List<PrettyXmldbURI> alCollections = new ArrayList<>();
try {
final Collection root = client.getCollection(XmldbURI.ROOT_COLLECTION);
final List<PrettyXmldbURI> alAllCollections = getCollections(root, new ArrayList<>());
for (PrettyXmldbURI alAllCollection : alAllCollections) {
// TODO : use XmldbURIs !
if (!alAllCollection.toString().contains(XmldbURI.CONFIG_COLLECTION)) {
alCollections.add(alAllCollection);
}
}
} catch (final XMLDBException e) {
ClientFrame.showErrorMessage(e.getMessage(), e);
return;
}
// Create a combobox listing the collections
cmbCollections = new JComboBox(alCollections.toArray());
cmbCollections.addActionListener(e -> {
saveChanges();
final JComboBox cb = (JComboBox) e.getSource();
actionGetTriggers(cb.getSelectedItem().toString());
});
c.gridx = 1;
c.gridy = 0;
c.gridwidth = 1;
c.anchor = GridBagConstraints.WEST;
c.fill = GridBagConstraints.HORIZONTAL;
c.weightx = 1;
grid.setConstraints(cmbCollections, c);
getContentPane().add(cmbCollections);
// Panel to hold controls relating to the Triggers Index
final JPanel panelTriggers = new JPanel();
panelTriggers.setBorder(new TitledBorder(Messages.getString("TriggersDialog.Triggers")));
final GridBagLayout panelTriggersGrid = new GridBagLayout();
panelTriggers.setLayout(panelTriggersGrid);
// Table to hold the Triggers with Sroll bar
triggersModel = new TriggersTableModel();
tblTriggers = new JTable(triggersModel);
tblTriggers.setAutoResizeMode(JTable.AUTO_RESIZE_NEXT_COLUMN);
tblTriggers.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
// Toolbar with add/delete buttons for Triggers
final Box triggersToolbarBox = Box.createHorizontalBox();
// add button
final JButton btnAddTrigger = new JButton(Messages.getString("TriggersDialog.addbutton"));
btnAddTrigger.addActionListener(e -> actionAddTrigger());
triggersToolbarBox.add(btnAddTrigger);
// delete button
final JButton btnDeleteTrigger = new JButton(Messages.getString("TriggersDialog.deletebutton"));
btnDeleteTrigger.addActionListener(e -> actionDeleteTrigger());
triggersToolbarBox.add(btnDeleteTrigger);
c.gridx = 0;
c.gridy = 4;
c.gridwidth = 2;
c.anchor = GridBagConstraints.CENTER;
c.fill = GridBagConstraints.BOTH;
c.weightx = 0;
c.weighty = 0;
panelTriggersGrid.setConstraints(triggersToolbarBox, c);
panelTriggers.add(triggersToolbarBox);
// add triggers panel to content frame
c.gridx = 0;
c.gridy = 1;
c.gridwidth = 2;
c.anchor = GridBagConstraints.WEST;
c.fill = GridBagConstraints.BOTH;
c.weightx = 1;
c.weighty = 1;
grid.setConstraints(panelTriggers, c);
getContentPane().add(panelTriggers);
pack();
}
use of org.xmldb.api.base.XMLDBException in project exist by eXist-db.
the class ClientFrame method moveAction.
private void moveAction(final ActionEvent ev) {
final ResourceDescriptor[] res = getSelectedResources();
PrettyXmldbURI[] collections;
// get an array of collection paths
try {
final Collection root = client.getCollection(XmldbURI.ROOT_COLLECTION);
final List<PrettyXmldbURI> alCollections = getCollections(root, new ArrayList<>());
collections = new PrettyXmldbURI[alCollections.size()];
alCollections.toArray(collections);
} catch (final XMLDBException e) {
showErrorMessage(e.getMessage(), e);
return;
}
// prompt the user for a destination collection from the list
// $NON-NLS-1$ //$NON-NLS-2$
final Object val = JOptionPane.showInputDialog(this, Messages.getString("ClientFrame.111"), Messages.getString("ClientFrame.112"), JOptionPane.QUESTION_MESSAGE, null, collections, collections[0]);
if (val == null) {
return;
}
final XmldbURI destinationPath = ((PrettyXmldbURI) val).getTargetURI();
final Runnable moveTask = () -> {
try {
final EXistCollectionManagementService service = (EXistCollectionManagementService) // $NON-NLS-1$ //$NON-NLS-2$
client.current.getService("CollectionManagementService", "1.0");
for (ResourceDescriptor re : res) {
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
setStatus(Messages.getString("ClientFrame.115") + re.getName() + Messages.getString("ClientFrame.116") + destinationPath + Messages.getString("ClientFrame.117"));
if (re.isCollection()) {
service.move(re.getName(), destinationPath, null);
} else {
service.moveResource(re.getName(), destinationPath, null);
}
}
client.reloadCollection();
} catch (final XMLDBException e) {
showErrorMessage(e.getMessage(), e);
}
// $NON-NLS-1$
setStatus(Messages.getString("ClientFrame.118"));
};
client.newClientThread("move", moveTask).start();
}
use of org.xmldb.api.base.XMLDBException in project exist by eXist-db.
the class ClientFrame method setupComponents.
private void setupComponents() {
setJMenuBar(createMenuBar());
// create the toolbar
final JToolBar toolbar = new JToolBar();
// $NON-NLS-1$
URL url = getClass().getResource("icons/Up24.gif");
JButton button = new JButton(new ImageIcon(url));
// $NON-NLS-1$
button.setToolTipText(Messages.getString("ClientFrame.5"));
button.addActionListener(this::goUpAction);
toolbar.add(button);
// $NON-NLS-1$
url = getClass().getResource("icons/Refresh24.gif");
button = new JButton(new ImageIcon(url));
// $NON-NLS-1$
button.setToolTipText(Messages.getString("ClientFrame.7"));
button.addActionListener(e -> {
try {
client.reloadCollection();
} catch (final XMLDBException e1) {
// TODO report message
}
});
toolbar.add(button);
toolbar.addSeparator();
// $NON-NLS-1$
url = getClass().getResource("icons/New24.gif");
button = new JButton(new ImageIcon(url));
// $NON-NLS-1$
button.setToolTipText(Messages.getString("ClientFrame.9"));
button.addActionListener(this::newCollectionAction);
toolbar.add(button);
// $NON-NLS-1$
url = getClass().getResource("icons/Add24.gif");
button = new JButton(new ImageIcon(url));
// $NON-NLS-1$
button.setToolTipText(Messages.getString("ClientFrame.11"));
button.addActionListener(this::uploadAction);
toolbar.add(button);
// $NON-NLS-1$
url = getClass().getResource("icons/Delete24.gif");
button = new JButton(new ImageIcon(url));
// $NON-NLS-1$
button.setToolTipText(Messages.getString("ClientFrame.13"));
button.addActionListener(this::removeAction);
toolbar.add(button);
// $NON-NLS-1$
url = getClass().getResource(Messages.getString("ClientFrame.14"));
button = new JButton(new ImageIcon(url));
// $NON-NLS-1$
button.setToolTipText(Messages.getString("ClientFrame.15"));
button.addActionListener(e -> {
try {
setPermAction(e);
} catch (final PermissionDeniedException pde) {
showErrorMessage(pde.getMessage(), pde);
}
});
toolbar.add(button);
toolbar.addSeparator();
// $NON-NLS-1$
url = getClass().getResource("icons/Export24.gif");
button = new JButton(new ImageIcon(url));
// $NON-NLS-1$
button.setToolTipText(Messages.getString("ClientFrame.17"));
button.addActionListener(this::backupAction);
toolbar.add(button);
// $NON-NLS-1$
url = getClass().getResource("icons/Import24.gif");
button = new JButton(new ImageIcon(url));
// $NON-NLS-1$
button.setToolTipText(Messages.getString("ClientFrame.19"));
button.addActionListener(this::restoreAction);
toolbar.add(button);
toolbar.addSeparator();
// $NON-NLS-1$
url = getClass().getResource(Messages.getString("ClientFrame.20"));
button = new JButton(new ImageIcon(url));
// $NON-NLS-1$
button.setToolTipText(Messages.getString("ClientFrame.21"));
button.addActionListener(this::editUsersAction);
toolbar.add(button);
// $NON-NLS-1$
url = getClass().getResource("icons/Find24.gif");
button = new JButton(new ImageIcon(url));
// $NON-NLS-1$
button.setToolTipText(Messages.getString("ClientFrame.23"));
button.addActionListener(this::findAction);
toolbar.add(button);
// the split pane separates the resource view table from the shell
final JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
split.setResizeWeight(0.5);
// create table for resources and collections
fileman = new JTable();
fileman.setModel(resources);
fileman.setRowSorter(new TableRowSorter(resources));
fileman.addMouseListener(new TableMouseListener());
// fileman.setTransferHandler(new TransferHandler(){
// });
fileman.setDropMode(DropMode.ON);
final DropTarget filemanDropTarget = new DropTarget(fileman, DnDConstants.ACTION_COPY, new FileListDropTargetListener());
fileman.setDropTarget(filemanDropTarget);
fileman.setDefaultRenderer(Object.class, new HighlightedTableCellRenderer<ResourceTableModel>());
JScrollPane scroll = new JScrollPane(fileman);
scroll.setMinimumSize(new Dimension(300, 150));
split.setLeftComponent(scroll);
// $NON-NLS-1$
shellPopup = new JPopupMenu(Messages.getString("ClientFrame.24"));
shellPopup.add(new JMenuItem(CUT)).addActionListener(this);
shellPopup.add(new JMenuItem(COPY)).addActionListener(this);
shellPopup.add(new JMenuItem(PASTE)).addActionListener(this);
// shell window
doc = new DefaultStyledDocument();
shell = new JTextPane(doc);
// $NON-NLS-1$
shell.setContentType("text/plain; charset=UTF-8");
// $NON-NLS-1$
shell.setFont(new Font("Monospaced", Font.PLAIN, 12));
shell.setMargin(new Insets(7, 5, 7, 5));
shell.addKeyListener(this);
shell.addMouseListener(this);
scroll = new JScrollPane(shell);
split.setRightComponent(scroll);
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
statusbar = new JLabel(Messages.getString("ClientFrame.27") + properties.getProperty(InteractiveClient.USER) + "@" + properties.getProperty(InteractiveClient.URI));
statusbar.setMinimumSize(new Dimension(400, 15));
statusbar.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
getContentPane().add(split, BorderLayout.CENTER);
getContentPane().add(toolbar, BorderLayout.NORTH);
getContentPane().add(statusbar, BorderLayout.SOUTH);
}
use of org.xmldb.api.base.XMLDBException in project exist by eXist-db.
the class ClientFrame method copyAction.
private void copyAction(final ActionEvent ev) {
final ResourceDescriptor[] res = getSelectedResources();
PrettyXmldbURI[] collections;
// get an array of collection paths
try {
final Collection root = client.getCollection(XmldbURI.ROOT_COLLECTION);
final List<PrettyXmldbURI> alCollections = getCollections(root, new ArrayList<>());
collections = new PrettyXmldbURI[alCollections.size()];
alCollections.toArray(collections);
} catch (final XMLDBException e) {
showErrorMessage(e.getMessage(), e);
return;
}
// prompt the user for a destination collection from the list
// $NON-NLS-1$ //$NON-NLS-2$
final Object val = JOptionPane.showInputDialog(this, Messages.getString("ClientFrame.128"), Messages.getString("ClientFrame.129"), JOptionPane.QUESTION_MESSAGE, null, collections, collections[0]);
if (val == null) {
return;
}
final XmldbURI destinationPath = ((PrettyXmldbURI) val).getTargetURI();
final Runnable moveTask = () -> {
try {
final EXistCollectionManagementService service = (EXistCollectionManagementService) // $NON-NLS-1$ //$NON-NLS-2$
client.current.getService("CollectionManagementService", "1.0");
for (ResourceDescriptor re : res) {
// TODO
// what happens if the source and destination paths are the same?
// we need to check and prompt the user to either skip or choose a new name
// this function can copy multiple resources/collections selected by the user,
// so may need to prompt the user multiple times? is in this thread the correct
// place to do it? also need to do something similar for moveAction()
//
// Its too late and brain hurts - deliriumsky
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
setStatus(Messages.getString("ClientFrame.132") + re.getName() + Messages.getString("ClientFrame.133") + destinationPath + Messages.getString("ClientFrame.134"));
if (re.isCollection()) {
service.copy(re.getName(), destinationPath, null);
} else {
service.copyResource(re.getName(), destinationPath, null);
}
}
client.reloadCollection();
} catch (final XMLDBException e) {
showErrorMessage(e.getMessage(), e);
}
// $NON-NLS-1$
setStatus(Messages.getString("ClientFrame.135"));
};
client.newClientThread("move", moveTask).start();
}
use of org.xmldb.api.base.XMLDBException in project exist by eXist-db.
the class ClientFrame method getCollections.
private ArrayList<PrettyXmldbURI> getCollections(final Collection root, final ArrayList<PrettyXmldbURI> collectionsList) throws XMLDBException {
collectionsList.add(new PrettyXmldbURI(XmldbURI.create(root.getName())));
final String[] childCollections = root.listChildCollections();
Collection child = null;
for (String childCollection : childCollections) {
try {
child = root.getChildCollection(childCollection);
} catch (final XMLDBException xmldbe) {
if (xmldbe.getCause() instanceof PermissionDeniedException) {
continue;
} else {
throw xmldbe;
}
} catch (Exception npe) {
System.out.println("Corrupted resource/collection skipped: " + child != null ? child.getName() != null ? child.getName() : "unknown" : "unknown");
continue;
}
try {
getCollections(child, collectionsList);
} catch (Exception ee) {
System.out.println("Corrupted resource/collection skipped: " + child != null ? child.getName() != null ? child.getName() : "unknown" : "unknown");
continue;
}
}
return collectionsList;
}
Aggregations