Search in sources :

Example 1 with ScheduleSelector

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;
}
Also used : ScheduleSelector(org.netxms.ui.eclipse.widgets.ScheduleSelector) Composite(org.eclipse.swt.widgets.Composite) LabeledText(org.netxms.ui.eclipse.widgets.LabeledText) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) ServerFile(org.netxms.client.server.ServerFile) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) LabelProvider(org.eclipse.jface.viewers.LabelProvider) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 2 with ScheduleSelector

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;
}
Also used : ScheduleSelector(org.netxms.ui.eclipse.widgets.ScheduleSelector) GridLayout(org.eclipse.swt.layout.GridLayout) ObjectSelector(org.netxms.ui.eclipse.objectbrowser.widgets.ObjectSelector) Composite(org.eclipse.swt.widgets.Composite) LabeledText(org.netxms.ui.eclipse.widgets.LabeledText) GridData(org.eclipse.swt.layout.GridData) Combo(org.eclipse.swt.widgets.Combo)

Aggregations

GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 Composite (org.eclipse.swt.widgets.Composite)2 LabeledText (org.netxms.ui.eclipse.widgets.LabeledText)2 ScheduleSelector (org.netxms.ui.eclipse.widgets.ScheduleSelector)2 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 LabelProvider (org.eclipse.jface.viewers.LabelProvider)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 Viewer (org.eclipse.jface.viewers.Viewer)1 ViewerComparator (org.eclipse.jface.viewers.ViewerComparator)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 SelectionListener (org.eclipse.swt.events.SelectionListener)1 Button (org.eclipse.swt.widgets.Button)1 Combo (org.eclipse.swt.widgets.Combo)1 Label (org.eclipse.swt.widgets.Label)1 ServerFile (org.netxms.client.server.ServerFile)1 ObjectSelector (org.netxms.ui.eclipse.objectbrowser.widgets.ObjectSelector)1