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());
}
}
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());
}
}
}
}
}
}
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;
}
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();
}
}
}
}
}
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();
}
}
Aggregations