use of org.netxms.ui.eclipse.widgets.ScheduleSelector in project netxms by netxms.
the class StartServerToAgentFileUploadDialog 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);
Label label = new Label(dialogArea, SWT.NONE);
label.setText(Messages.get().StartServerToAgentFileUploadDialog_ServerFile);
fileList = new TableViewer(dialogArea, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.widthHint = 400;
gd.heightHint = 150;
fileList.getControl().setLayoutData(gd);
fileList.setContentProvider(new ArrayContentProvider());
fileList.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
return ((ServerFile) element).getName();
}
});
fileList.setComparator(new ViewerComparator() {
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
return ((ServerFile) e1).getName().compareToIgnoreCase(((ServerFile) e2).getName());
}
});
fileList.setInput(serverFiles);
Composite buttonArea = new Composite(dialogArea, SWT.NONE);
layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.numColumns = 2;
buttonArea.setLayout(layout);
gd = new GridData();
gd.horizontalAlignment = SWT.RIGHT;
buttonArea.setLayoutData(gd);
buttonAddFile = new Button(buttonArea, SWT.PUSH);
buttonAddFile.setText("&Add...");
gd = new GridData();
gd.widthHint = WidgetHelper.BUTTON_WIDTH_HINT;
buttonAddFile.setLayoutData(gd);
buttonAddFile.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
SelectServerFileDialog dlg = new SelectServerFileDialog(getShell(), true);
if (dlg.open() == Window.OK) {
for (ServerFile f : dlg.getSelectedFiles()) {
boolean found = false;
for (ServerFile sf : serverFiles) if (sf.getName().equals(f.getName())) {
found = true;
break;
}
if (!found)
serverFiles.add(f);
}
fileList.refresh();
}
}
});
buttonRemoveFile = new Button(buttonArea, SWT.PUSH);
buttonRemoveFile.setText("&Remove");
gd = new GridData();
gd.widthHint = WidgetHelper.BUTTON_WIDTH_HINT;
buttonRemoveFile.setLayoutData(gd);
buttonRemoveFile.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
IStructuredSelection selection = (IStructuredSelection) fileList.getSelection();
for (Object o : selection.toList()) serverFiles.remove(o);
fileList.refresh();
}
});
textRemoteFile = new LabeledText(dialogArea, SWT.NONE);
textRemoteFile.setLabel(Messages.get().StartServerToAgentFileUploadDialog_RemoteFileName);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
textRemoteFile.setLayoutData(gd);
checkJobOnHold = new Button(dialogArea, SWT.CHECK);
checkJobOnHold.setText(Messages.get().StartServerToAgentFileUploadDialog_CreateJobOnHold);
checkJobOnHold.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
checkIsSchedule.setEnabled(!checkJobOnHold.getSelection());
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
if (canScheduleFileUpload) {
checkIsSchedule = new Button(dialogArea, SWT.CHECK);
checkIsSchedule.setText(Messages.get().StartServerToAgentFileUploadDialog_ScheduleTask);
checkIsSchedule.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
checkJobOnHold.setEnabled(!checkIsSchedule.getSelection());
scheduleSelector.setEnabled(checkIsSchedule.getSelection());
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
scheduleSelector = new ScheduleSelector(dialogArea, SWT.NONE);
scheduleSelector.setEnabled(false);
}
return dialogArea;
}
use of org.netxms.ui.eclipse.widgets.ScheduleSelector in project netxms by netxms.
the class ScheduledTaskEditor method createDialogArea.
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createDialogArea(Composite parent) {
final Composite dialogArea = (Composite) super.createDialogArea(parent);
GridLayout layout = new GridLayout();
layout.marginHeight = WidgetHelper.DIALOG_HEIGHT_MARGIN;
layout.marginWidth = WidgetHelper.DIALOG_WIDTH_MARGIN;
dialogArea.setLayout(layout);
scheduleType = new Combo(dialogArea, SWT.READ_ONLY);
for (String type : scheduleTypeList) scheduleType.add(type);
int taskId = scheduleTypeList.indexOf(scheduledTask.getScheduledTaskId());
scheduleType.select(taskId == -1 ? 0 : taskId);
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
scheduleType.setLayoutData(gd);
selector = new ObjectSelector(dialogArea, SWT.NONE, true);
selector.setLabel("Select execution object");
selector.setObjectClass(AbstractObject.class);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
selector.setLayoutData(gd);
if (scheduledTask.getObjectId() != 0)
selector.setObjectId(scheduledTask.getObjectId());
textParameters = new LabeledText(dialogArea, SWT.NONE);
textParameters.setLabel("Parameters");
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
textParameters.setLayoutData(gd);
textParameters.setText(scheduledTask.getParameters());
textComments = WidgetHelper.createLabeledText(dialogArea, SWT.MULTI | SWT.BORDER, SWT.DEFAULT, "Description", scheduledTask.getComments(), WidgetHelper.DEFAULT_LAYOUT_DATA);
textComments.setTextLimit(255);
gd = new GridData();
gd.horizontalSpan = 2;
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = SWT.FILL;
gd.heightHint = 100;
gd.verticalAlignment = SWT.FILL;
textComments.setLayoutData(gd);
if ((scheduledTask.getFlags() & ScheduledTask.SYSTEM) != 0) {
scheduleType.add(scheduledTask.getScheduledTaskId());
scheduleType.select(scheduleTypeList.size());
scheduleType.setEnabled(false);
selector.setEnabled(false);
textParameters.setEnabled(false);
}
scheduleSelector = new ScheduleSelector(dialogArea, SWT.NONE);
scheduleSelector.setSchedule(scheduledTask);
return dialogArea;
}
Aggregations