use of org.netxms.ui.eclipse.filemanager.widgets.LocalFileSelector in project netxms by netxms.
the class StartClientToServerFileUploadDialog method createDialogArea.
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createDialogArea(Composite parent) {
Composite dialogArea = (Composite) super.createDialogArea(parent);
GridLayout layout = new GridLayout();
layout.marginHeight = WidgetHelper.DIALOG_HEIGHT_MARGIN;
layout.marginWidth = WidgetHelper.DIALOG_WIDTH_MARGIN;
layout.verticalSpacing = WidgetHelper.DIALOG_SPACING;
dialogArea.setLayout(layout);
fileSelector = new LocalFileSelector(dialogArea, SWT.NONE, false, SWT.OPEN | SWT.MULTI);
fileSelector.setLabel(Messages.get().StartClientToServerFileUploadDialog_LocalFile);
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.widthHint = 400;
fileSelector.setLayoutData(gd);
fileSelector.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
localFiles = fileSelector.getFileList();
if (localFiles.size() > 1) {
textRemoteFile.setEditable(false);
} else {
textRemoteFile.setEditable(true);
}
}
});
textRemoteFile = new LabeledText(dialogArea, SWT.NONE);
textRemoteFile.setLabel(Messages.get().StartClientToServerFileUploadDialog_RemoteFileName);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
textRemoteFile.setLayoutData(gd);
return dialogArea;
}
use of org.netxms.ui.eclipse.filemanager.widgets.LocalFileSelector in project netxms by netxms.
the class ImportDashboardDialog method createDialogArea.
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createDialogArea(Composite parent) {
Composite dialogArea = (Composite) super.createDialogArea(parent);
GridLayout layout = new GridLayout();
layout.marginWidth = WidgetHelper.DIALOG_WIDTH_MARGIN;
layout.marginHeight = WidgetHelper.DIALOG_HEIGHT_MARGIN;
dialogArea.setLayout(layout);
textName = new LabeledText(dialogArea, SWT.NONE);
textName.setLabel(Messages.get().ImportDashboardDialog_ObjectName);
textName.getTextControl().setTextLimit(63);
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.widthHint = 350;
textName.setLayoutData(gd);
importFileSelector = new LocalFileSelector(dialogArea, SWT.NONE, false, SWT.OPEN);
importFileSelector.setLabel(Messages.get().ImportDashboardDialog_ImportFile);
// $NON-NLS-1$ //$NON-NLS-2$
importFileSelector.setFilterExtensions(new String[] { "*.xml", "*.*" });
importFileSelector.setFilterNames(new String[] { Messages.get().ImportDashboardDialog_XMLFiles, Messages.get().ImportDashboardDialog_AllFiles });
importFileSelector.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
Element root = null;
try {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document dom = db.parse(importFileSelector.getFile());
root = dom.getDocumentElement();
if (// $NON-NLS-1$
!root.getNodeName().equals("dashboard"))
throw new Exception(Messages.get().ImportDashboard_InvalidFile);
root.normalize();
} catch (Exception e1) {
MessageDialogHelper.openError(getShell(), "Error", "Unable to open the document");
} finally {
if (root == null)
return;
NodeList nameRoot = root.getElementsByTagName("name");
textName.setText(nameRoot.item(0).getTextContent());
root.normalize();
}
}
});
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.widthHint = 350;
importFileSelector.setLayoutData(gd);
return dialogArea;
}
Aggregations