Search in sources :

Example 21 with Dialog

use of org.eclipse.jface.dialogs.Dialog in project netxms by netxms.

the class GeneralTable method selectParameter.

/**
 * Select parameter
 */
private void selectParameter() {
    Dialog dlg;
    editor.setSourceNode(sourceNode.getObjectId());
    switch(origin.getSelectionIndex()) {
        case DataCollectionObject.AGENT:
            if (sourceNode.getObjectId() != 0)
                dlg = new SelectAgentParamDlg(getShell(), sourceNode.getObjectId(), origin.getSelectionIndex(), true);
            else
                dlg = new SelectAgentParamDlg(getShell(), dci.getNodeId(), origin.getSelectionIndex(), true);
            break;
        case DataCollectionObject.SNMP:
        case DataCollectionObject.CHECKPOINT_SNMP:
            SnmpObjectId oid;
            try {
                oid = SnmpObjectId.parseSnmpObjectId(parameter.getText());
            } catch (SnmpObjectIdFormatException e) {
                oid = null;
            }
            if (sourceNode.getObjectId() != 0)
                dlg = new SelectSnmpParamDlg(getShell(), oid, sourceNode.getObjectId());
            else
                dlg = new SelectSnmpParamDlg(getShell(), oid, dci.getNodeId());
            break;
        case DataCollectionItem.SCRIPT:
            dlg = new SelectParameterScriptDialog(getShell());
            break;
        default:
            dlg = null;
            break;
    }
    if ((dlg != null) && (dlg.open() == Window.OK)) {
        IParameterSelectionDialog pd = (IParameterSelectionDialog) dlg;
        description.setText(pd.getParameterDescription());
        parameter.setText(pd.getParameterName());
        editor.fireOnSelectTableListeners(origin.getSelectionIndex(), pd.getParameterName(), pd.getParameterDescription());
    }
}
Also used : SelectSnmpParamDlg(org.netxms.ui.eclipse.datacollection.dialogs.SelectSnmpParamDlg) SelectParameterScriptDialog(org.netxms.ui.eclipse.datacollection.dialogs.SelectParameterScriptDialog) DCIPropertyPageDialog(org.netxms.ui.eclipse.datacollection.propertypages.helpers.DCIPropertyPageDialog) IParameterSelectionDialog(org.netxms.ui.eclipse.datacollection.dialogs.IParameterSelectionDialog) Dialog(org.eclipse.jface.dialogs.Dialog) SnmpObjectIdFormatException(org.netxms.client.snmp.SnmpObjectIdFormatException) SelectAgentParamDlg(org.netxms.ui.eclipse.datacollection.dialogs.SelectAgentParamDlg) SnmpObjectId(org.netxms.client.snmp.SnmpObjectId) SelectParameterScriptDialog(org.netxms.ui.eclipse.datacollection.dialogs.SelectParameterScriptDialog) IParameterSelectionDialog(org.netxms.ui.eclipse.datacollection.dialogs.IParameterSelectionDialog)

Example 22 with Dialog

use of org.eclipse.jface.dialogs.Dialog in project webtools.sourceediting by eclipse.

the class CleanupAction method run.

public void run() {
    if (getTextEditor() instanceof StructuredTextEditor) {
        final StructuredTextEditor editor = (StructuredTextEditor) getTextEditor();
        Dialog cleanupDialog = getCleanupDialog(editor.getSite().getShell());
        if (cleanupDialog != null) {
            if (cleanupDialog.open() == Window.OK) {
                // setup runnable
                Runnable runnable = new Runnable() {

                    public void run() {
                        IStructuredCleanupProcessor cleanupProcessor = getCleanupProcessor();
                        if (cleanupProcessor != null)
                            cleanupProcessor.cleanupModel(editor.getModel());
                    }
                };
                // TODO: make independent of 'model'.
                IStructuredModel model = editor.getModel();
                if (model != null) {
                    try {
                        // begin recording
                        ITextSelection selection = (ITextSelection) editor.getSelectionProvider().getSelection();
                        // $NON-NLS-1$ //$NON-NLS-2$
                        model.beginRecording(this, SSEUIMessages.Cleanup_Document_UI_, SSEUIMessages.Cleanup_Document_UI_, selection.getOffset(), selection.getLength());
                        // tell the model that we are about to make a big
                        // model change
                        model.aboutToChangeModel();
                        // run
                        BusyIndicator.showWhile(editor.getTextViewer().getControl().getDisplay(), runnable);
                    } finally {
                        // tell the model that we are done with the big
                        // model
                        // change
                        model.changedModel();
                        // end recording
                        ITextSelection selection = (ITextSelection) editor.getSelectionProvider().getSelection();
                        model.endRecording(this, selection.getOffset(), selection.getLength());
                    }
                }
            }
        }
    }
}
Also used : IStructuredCleanupProcessor(org.eclipse.wst.sse.core.internal.cleanup.IStructuredCleanupProcessor) Dialog(org.eclipse.jface.dialogs.Dialog) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel) StructuredTextEditor(org.eclipse.wst.sse.ui.StructuredTextEditor) ITextSelection(org.eclipse.jface.text.ITextSelection)

Example 23 with Dialog

use of org.eclipse.jface.dialogs.Dialog in project webtools.sourceediting by eclipse.

the class CleanupDocumentHandler method execute.

public Object execute(ExecutionEvent event) throws ExecutionException {
    IEditorPart editorPart = HandlerUtil.getActiveEditor(event);
    ITextEditor textEditor = null;
    if (editorPart instanceof ITextEditor)
        textEditor = (ITextEditor) editorPart;
    else {
        Object o = editorPart.getAdapter(ITextEditor.class);
        if (o != null)
            textEditor = (ITextEditor) o;
    }
    if (textEditor != null) {
        final ITextEditor editor = textEditor;
        Dialog cleanupDialog = new CleanupDialogCSS(editor.getSite().getShell());
        if (cleanupDialog.open() == Window.OK) {
            // setup runnable
            Runnable runnable = new Runnable() {

                public void run() {
                    IStructuredCleanupProcessor cleanupProcessor = getCleanupProcessor();
                    if (cleanupProcessor != null) {
                        IStructuredModel model = null;
                        try {
                            model = StructuredModelManager.getModelManager().getExistingModelForEdit(editor.getDocumentProvider().getDocument(editor.getEditorInput()));
                            if (model != null)
                                cleanupProcessor.cleanupModel(model);
                        } finally {
                            if (model != null)
                                model.releaseFromEdit();
                        }
                    }
                }
            };
            // TODO: make independent of 'model'.
            IStructuredModel model = null;
            try {
                model = StructuredModelManager.getModelManager().getExistingModelForEdit(editor.getDocumentProvider().getDocument(editor.getEditorInput()));
                if (model != null) {
                    // begin recording
                    ITextSelection selection = (ITextSelection) editor.getSelectionProvider().getSelection();
                    // $NON-NLS-1$ //$NON-NLS-2$
                    model.beginRecording(this, SSEUIMessages.Cleanup_Document_UI_, SSEUIMessages.Cleanup_Document_UI_, selection.getOffset(), selection.getLength());
                    // tell the model that we are about to make a big
                    // model change
                    model.aboutToChangeModel();
                    // run
                    BusyIndicator.showWhile(editor.getEditorSite().getWorkbenchWindow().getShell().getDisplay(), runnable);
                }
            } finally {
                if (model != null) {
                    // tell the model that we are done with the big
                    // model
                    // change
                    model.changedModel();
                    // end recording
                    ITextSelection selection = (ITextSelection) editor.getSelectionProvider().getSelection();
                    model.endRecording(this, selection.getOffset(), selection.getLength());
                    model.releaseFromEdit();
                }
            }
        }
    }
    return null;
}
Also used : IStructuredCleanupProcessor(org.eclipse.wst.sse.core.internal.cleanup.IStructuredCleanupProcessor) ITextEditor(org.eclipse.ui.texteditor.ITextEditor) Dialog(org.eclipse.jface.dialogs.Dialog) IEditorPart(org.eclipse.ui.IEditorPart) CleanupDialogCSS(org.eclipse.wst.css.ui.internal.edit.ui.CleanupDialogCSS) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel) ITextSelection(org.eclipse.jface.text.ITextSelection)

Example 24 with Dialog

use of org.eclipse.jface.dialogs.Dialog in project webtools.sourceediting by eclipse.

the class CleanupActionCSSDelegate method run.

public void run(IAction action) {
    if (fEditor instanceof ITextEditor) {
        final ITextEditor editor = (ITextEditor) fEditor;
        Dialog cleanupDialog = new CleanupDialogCSS(editor.getSite().getShell());
        if (cleanupDialog.open() == Window.OK) {
            // setup runnable
            Runnable runnable = new Runnable() {

                public void run() {
                    IStructuredCleanupProcessor cleanupProcessor = getCleanupProcessor();
                    if (cleanupProcessor != null) {
                        IStructuredModel model = null;
                        try {
                            model = StructuredModelManager.getModelManager().getExistingModelForEdit(editor.getDocumentProvider().getDocument(editor.getEditorInput()));
                            if (model != null)
                                cleanupProcessor.cleanupModel(model);
                        } finally {
                            if (model != null)
                                model.releaseFromEdit();
                        }
                    }
                }
            };
            // TODO: make independent of 'model'.
            IStructuredModel model = null;
            try {
                model = StructuredModelManager.getModelManager().getExistingModelForEdit(editor.getDocumentProvider().getDocument(editor.getEditorInput()));
                if (model != null) {
                    // begin recording
                    ITextSelection selection = (ITextSelection) editor.getSelectionProvider().getSelection();
                    // $NON-NLS-1$ //$NON-NLS-2$
                    model.beginRecording(this, SSEUIMessages.Cleanup_Document_UI_, SSEUIMessages.Cleanup_Document_UI_, selection.getOffset(), selection.getLength());
                    // tell the model that we are about to make a big
                    // model change
                    model.aboutToChangeModel();
                    // run
                    BusyIndicator.showWhile(fEditor.getEditorSite().getWorkbenchWindow().getShell().getDisplay(), runnable);
                }
            } finally {
                if (model != null) {
                    // tell the model that we are done with the big
                    // model
                    // change
                    model.changedModel();
                    // end recording
                    ITextSelection selection = (ITextSelection) editor.getSelectionProvider().getSelection();
                    model.endRecording(this, selection.getOffset(), selection.getLength());
                    model.releaseFromEdit();
                }
            }
        }
    }
}
Also used : IStructuredCleanupProcessor(org.eclipse.wst.sse.core.internal.cleanup.IStructuredCleanupProcessor) ITextEditor(org.eclipse.ui.texteditor.ITextEditor) Dialog(org.eclipse.jface.dialogs.Dialog) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel) ITextSelection(org.eclipse.jface.text.ITextSelection)

Example 25 with Dialog

use of org.eclipse.jface.dialogs.Dialog in project webtools.sourceediting by eclipse.

the class TaglibIndexDeltaTraceView method showSelectionDetail.

void showSelectionDetail(final Composite composite) {
    IStructuredSelection selection = (IStructuredSelection) fViewer.getSelection();
    if (!selection.isEmpty()) {
        final TaglibIndexDelta selectedDelta = (TaglibIndexDelta) selection.getFirstElement();
        final ITableLabelProvider tableLabelProvider = ((ITableLabelProvider) fViewer.getLabelProvider());
        String columnText = tableLabelProvider.getColumnText(selectedDelta, 1);
        columnText = columnText + ":" + tableLabelProvider.getColumnText(selectedDelta, 2);
        new Dialog(composite.getShell()) {

            public void create() {
                setShellStyle(getShellStyle() | SWT.RESIZE);
                super.create();
            }

            protected Control createDialogArea(final Composite parent) {
                final Composite inner = new Composite(parent, SWT.NONE);
                inner.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
                final Sash sash = new Sash(inner, SWT.HORIZONTAL);
                final TreeViewer treeViewer = new TreeViewer(inner);
                treeViewer.setContentProvider(new ITreeContentProvider() {

                    public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
                    }

                    public void dispose() {
                    }

                    public Object[] getElements(Object inputElement) {
                        return getChildren(inputElement);
                    }

                    public boolean hasChildren(Object element) {
                        return getChildren(element).length > 0;
                    }

                    public Object getParent(Object element) {
                        return selectedDelta;
                    }

                    public Object[] getChildren(Object parentElement) {
                        if (parentElement instanceof TaglibIndexDelta) {
                            TaglibIndexDelta taglibIndexDelta = ((TaglibIndexDelta) parentElement);
                            if (taglibIndexDelta.getTrigger() != null) {
                                List combined = new ArrayList();
                                combined.add(taglibIndexDelta.getTrigger());
                                combined.addAll(Arrays.asList(taglibIndexDelta.getAffectedChildren()));
                                return combined.toArray();
                            }
                            return taglibIndexDelta.getAffectedChildren();
                        }
                        return new Object[0];
                    }
                });
                treeViewer.setLabelProvider(new LabelProvider() {

                    public String getText(Object element) {
                        if (element instanceof ITaglibIndexDelta) {
                            ITaglibIndexDelta taglibIndexDelta = ((ITaglibIndexDelta) element);
                            if (taglibIndexDelta.getTaglibRecord() != null)
                                return taglibIndexDelta.toString();
                            String text = tableLabelProvider.getColumnText(selectedDelta, 1);
                            text = text + ":" + tableLabelProvider.getColumnText(selectedDelta, 2);
                            return text;
                        }
                        return StringUtils.firstLineOf(super.getText(element));
                    }
                });
                treeViewer.setInput(selectedDelta);
                final Text text = new Text(inner, SWT.MULTI);
                treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {

                    public void selectionChanged(SelectionChangedEvent event) {
                        IStructuredSelection selection2 = (IStructuredSelection) treeViewer.getSelection();
                        if (!selection2.isEmpty())
                            text.setText("" + (selection2).getFirstElement());
                        else
                            text.setText("");
                    }
                });
                final FormLayout form = new FormLayout();
                inner.setLayout(form);
                FormData firstData = new FormData();
                firstData.top = new FormAttachment(0, 0);
                firstData.bottom = new FormAttachment(sash, 2);
                firstData.left = new FormAttachment(0, 0);
                firstData.right = new FormAttachment(100, 0);
                treeViewer.getControl().setLayoutData(firstData);
                FormData secondData = new FormData();
                secondData.top = new FormAttachment(sash, 2);
                secondData.left = new FormAttachment(0, 0);
                secondData.right = new FormAttachment(100, 0);
                secondData.bottom = new FormAttachment(100, 0);
                text.setLayoutData(secondData);
                final FormData sashData = new FormData();
                sashData.top = new FormAttachment(60, 0);
                sashData.left = new FormAttachment(0, 0);
                sashData.right = new FormAttachment(100, 0);
                sash.setLayoutData(sashData);
                sash.addListener(SWT.Selection, new org.eclipse.swt.widgets.Listener() {

                    public void handleEvent(Event e) {
                        sashData.top = new FormAttachment(0, e.y);
                        inner.layout();
                    }
                });
                return sash;
            }
        }.open();
    }
}
Also used : ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) ILabelProviderListener(org.eclipse.jface.viewers.ILabelProviderListener) ITaglibIndexListener(org.eclipse.jst.jsp.core.taglib.ITaglibIndexListener) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ArrayList(java.util.ArrayList) ITaglibIndexDelta(org.eclipse.jst.jsp.core.taglib.ITaglibIndexDelta) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) TreeViewer(org.eclipse.jface.viewers.TreeViewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ITableLabelProvider(org.eclipse.jface.viewers.ITableLabelProvider) Control(org.eclipse.swt.widgets.Control) Dialog(org.eclipse.jface.dialogs.Dialog) ArrayList(java.util.ArrayList) List(java.util.List) FormAttachment(org.eclipse.swt.layout.FormAttachment) FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) Composite(org.eclipse.swt.widgets.Composite) Sash(org.eclipse.swt.widgets.Sash) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Text(org.eclipse.swt.widgets.Text) TaglibIndexDelta(org.eclipse.jst.jsp.core.taglib.TaglibIndexDelta) ITaglibIndexDelta(org.eclipse.jst.jsp.core.taglib.ITaglibIndexDelta) GridData(org.eclipse.swt.layout.GridData) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Event(org.eclipse.swt.widgets.Event) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) ITableLabelProvider(org.eclipse.jface.viewers.ITableLabelProvider) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Aggregations

Dialog (org.eclipse.jface.dialogs.Dialog)49 MessageDialog (org.eclipse.jface.dialogs.MessageDialog)15 FileDialog (org.eclipse.swt.widgets.FileDialog)11 Composite (org.eclipse.swt.widgets.Composite)9 ArrayList (java.util.ArrayList)8 WizardDialog (org.eclipse.jface.wizard.WizardDialog)8 Control (org.eclipse.swt.widgets.Control)7 Shell (org.eclipse.swt.widgets.Shell)7 GridData (org.eclipse.swt.layout.GridData)6 Button (org.eclipse.swt.widgets.Button)6 ITextSelection (org.eclipse.jface.text.ITextSelection)5 GridLayout (org.eclipse.swt.layout.GridLayout)5 IStructuredCleanupProcessor (org.eclipse.wst.sse.core.internal.cleanup.IStructuredCleanupProcessor)5 IStructuredModel (org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)5 File (java.io.File)4 Client (name.abuchen.portfolio.model.Client)4 ITextEditor (org.eclipse.ui.texteditor.ITextEditor)4 List (java.util.List)3 SWT (org.eclipse.swt.SWT)3 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)3