Example usage for org.eclipse.jface.dialogs Dialog open

List of usage examples for org.eclipse.jface.dialogs Dialog open

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs Dialog open.

Prototype

public int open() 

Source Link

Document

Opens this window, creating it first if it has not yet been created.

Usage

From source file:org.locationtech.udig.catalog.tests.ui.workflow.BasicWorkflowTest.java

License:Open Source License

@Test
public void testNonBlocking() {
    Shell shell = new Shell(Display.getDefault());
    final Dialog dialog = new Dialog(shell) {
    };/*from  w w  w.j  a  v a 2s . c  om*/

    Listener1 l = new Listener1() {

        @Override
        public void finished(State state) {
            super.finished(state);

            Display.getDefault().asyncExec(new Runnable() {

                public void run() {
                    dialog.close();
                }
            });
        }
    };
    pipe.addListener(l);

    pipe.start();
    pipe.next();
    pipe.next();
    pipe.next();
    pipe.next();
    pipe.next();

    //need to open a dialog here to "halt" the ui thread so that the 
    // the workbench doesn't close while the pipe is still running
    dialog.setBlockOnOpen(true);
    dialog.open();
    if (!shell.isDisposed())
        shell.dispose();

    assertTrue(l.state1);
    assertTrue(l.state2);
    assertTrue(l.state3);
    assertTrue(l.state4);
    assertTrue(l.state5);
    assertTrue(l.finished);
    assertTrue(!l.fail);
    assertEquals(i, 6);

    assertNotNull(pipe.getState(State1.class));
    assertNotNull(pipe.getState(State2.class));
    assertNotNull(pipe.getState(State3.class));
    assertNotNull(pipe.getState(State4.class));
    assertNotNull(pipe.getState(State5.class));

    assertTrue(pipe.getState(State1.class).ran);
    assertTrue(pipe.getState(State2.class).ran);
    assertTrue(pipe.getState(State3.class).ran);
    assertTrue(pipe.getState(State4.class).ran);
    assertTrue(pipe.getState(State5.class).ran);
}

From source file:org.locationtech.udig.catalog.tests.ui.workflow.BasicWorkflowTest.java

License:Open Source License

@Ignore
@Test//from  w w w .j  av  a2s . c  o m
public void testStateFailureNonBlocking() {
    Shell shell = new Shell(Display.getDefault());
    final Dialog dialog = new Dialog(shell) {
    };

    //test where one state craps out
    s4.run = false;

    Listener1 l = new Listener2() {
        @Override
        public void stateFailed(State state) {
            super.stateFailed(state);

            if (dialog.getShell().isVisible()) {

                dialog.getShell().getDisplay().asyncExec(new Runnable() {
                    public void run() {
                        dialog.close();
                    };
                });
            }

        }

        @Override
        public void finished(State state) {
            super.finished(state);
            dialog.close();
        }
    };
    pipe.addListener(l);

    pipe.start();
    pipe.next();
    pipe.next();
    pipe.next();
    pipe.next();
    pipe.next();

    //need to open a dialog here to "halt" the ui thread so that the 
    // the workbench doesn't close while the pipe is still running
    // create a watchdog to kill it after a specified amount of time
    Runnable runnable = new Runnable() {

        public void run() {
            System.out.println("Running"); //$NON-NLS-1$
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("Is dialog active dialog"); //$NON-NLS-1$
            Display.getDefault().syncExec(new Runnable() {
                public void run() {
                    if (dialog.getShell().isVisible()) {
                        dialog.close();
                    }
                }
            });
        }
    };
    new Thread(runnable).start();

    dialog.setBlockOnOpen(true);
    if (!l.finished)
        dialog.open();
    if (!shell.isDisposed())
        shell.dispose();

    assertTrue(l.state1);
    assertTrue(l.state2);
    assertTrue(l.state3);
    assertTrue(!l.state4);
    assertTrue(!l.state5);
    assertTrue(!l.finished);
    assertTrue(!l.fail);
    assertEquals(i, 4);

    assertNotNull(pipe.getState(State1.class));
    assertNotNull(pipe.getState(State2.class));
    assertNotNull(pipe.getState(State3.class));
    assertNotNull(pipe.getState(State4.class));
    assertNull(pipe.getState(State5.class));

    assertTrue(pipe.getState(State1.class).ran);
    assertTrue(pipe.getState(State2.class).ran);
    assertTrue(pipe.getState(State3.class).ran);
    assertTrue(pipe.getState(State4.class).ran);

    assertEquals(pipe.getCurrentState(), s4);
}

From source file:org.locationtech.udig.omsbox.view.widgets.GuiTextField.java

License:Open Source License

@Override
public Control makeGui(Composite parent) {
    int cols = 1;
    if (isInFile || isInFolder || isOutFile || isOutFolder || isCrs || isMultiline) {
        cols = 2;//from   w ww .j av  a2 s . co m
    }

    final boolean isFile = isInFile || isOutFile;
    final boolean isFolder = isInFolder || isOutFolder;

    parent = new Composite(parent, SWT.NONE);
    parent.setLayoutData(constraints);
    GridLayout layout = new GridLayout(cols, false);
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    parent.setLayout(layout);

    if (!isMultiline) {
        text = new StyledText(parent, SWT.RIGHT | SWT.BORDER);
        GridData textGD = new GridData(SWT.FILL, SWT.CENTER, true, false);
        textGD.widthHint = 100;
        text.setLayoutData(textGD);
        // text.setLineAlignment(0, 1, SWT.RIGHT);
    } else if (isMapcalc) {
        text = MapcalculatorUtils.createMapcalcPanel(parent, rows);
    } else {
        text = new StyledText(parent, SWT.MULTI | SWT.WRAP | SWT.LEAD | SWT.BORDER | SWT.V_SCROLL);
        GridData textGD = new GridData(SWT.FILL, SWT.CENTER, true, true);
        textGD.verticalSpan = rows;
        textGD.widthHint = 100;
        text.setLayoutData(textGD);
    }
    text.addModifyListener(this);
    text.addFocusListener(this);
    if (data.fieldValue != null) {
        String tmp = data.fieldValue;

        if (tmp.contains(OmsBoxConstants.WORKINGFOLDER)) {
            // check if there is a working folder defined
            String workingFolder = OmsBoxPlugin.getDefault().getWorkingFolder();
            workingFolder = checkBackSlash(workingFolder, true);
            if (workingFolder != null) {
                tmp = tmp.replaceFirst(OmsBoxConstants.WORKINGFOLDER, workingFolder);
                data.fieldValue = tmp;
            } else {
                data.fieldValue = "";
            }
        }
        data.fieldValue = checkBackSlash(data.fieldValue, isFile);
        text.setText(data.fieldValue);
        // text.setSelection(text.getCharCount());
    }

    if (isMultiline) {
        for (int i = 0; i < rows; i++) {
            Label dummyLabel = new Label(parent, SWT.NONE);
            dummyLabel.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false));
            // dummyLabel.setText("");

        }
    }

    if (isFile) {
        final Button browseButton = new Button(parent, SWT.PUSH);
        browseButton.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false));
        browseButton.setText("...");
        browseButton.addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
                FileDialog fileDialog = new FileDialog(text.getShell(), isInFile ? SWT.OPEN : SWT.SAVE);
                String lastFolderChosen = OmsBoxPlugin.getDefault().getLastFolderChosen();
                fileDialog.setFilterPath(lastFolderChosen);
                String path = fileDialog.open();

                if (path == null || path.length() < 1) {
                    text.setText("");
                } else {
                    path = checkBackSlash(path, isFile);
                    text.setText(path);
                    text.setSelection(text.getCharCount());
                    setDataValue();
                }
                OmsBoxPlugin.getDefault().setLastFolderChosen(fileDialog.getFilterPath());
            }
        });
    }

    if (isFolder) {
        final Button browseButton = new Button(parent, SWT.PUSH);
        browseButton.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false));
        browseButton.setText("...");
        browseButton.addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
                DirectoryDialog directoryDialog = new DirectoryDialog(text.getShell(),
                        isInFolder ? SWT.OPEN : SWT.SAVE);
                String lastFolderChosen = OmsBoxPlugin.getDefault().getLastFolderChosen();
                directoryDialog.setFilterPath(lastFolderChosen);
                String path = directoryDialog.open();

                if (path == null || path.length() < 1) {
                    text.setText("");
                } else {
                    path = checkBackSlash(path, isFile);
                    text.setText(path);
                    // text.setSelection(text.getCharCount());
                    setDataValue();
                }
                OmsBoxPlugin.getDefault().setLastFolderChosen(directoryDialog.getFilterPath());
            }
        });
    }
    if (isCrs) {
        // the crs choice group
        final Button crsButton = new Button(parent, SWT.BORDER);
        crsButton.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false));
        crsButton.setText("..."); //$NON-NLS-1$
        crsButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {

            public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
                Shell shell = new Shell(text.getShell(), SWT.SHELL_TRIM);
                Dialog dialog = new Dialog(shell) {

                    private CRSChooser chooser;
                    private CoordinateReferenceSystem crs;

                    @Override
                    protected void configureShell(Shell shell) {
                        super.configureShell(shell);
                        shell.setText("Choose CRS");
                    }

                    @Override
                    protected Control createDialogArea(Composite parent) {
                        Composite comp = (Composite) super.createDialogArea(parent);
                        GridLayout gLayout = (GridLayout) comp.getLayout();

                        gLayout.numColumns = 1;

                        chooser = new CRSChooser(new Controller() {

                            public void handleClose() {
                                buttonPressed(OK);
                            }

                            public void handleOk() {
                                buttonPressed(OK);
                            }

                        });

                        return chooser.createControl(parent);
                    }

                    @Override
                    protected void buttonPressed(int buttonId) {
                        if (buttonId == OK) {
                            crs = chooser.getCRS();

                            try {
                                String codeFromCrs = OmsBoxUtils.getCodeFromCrs(crs);
                                text.setText(codeFromCrs);
                            } catch (Exception e) {
                                e.printStackTrace();
                            }

                        }
                        close();
                    }

                };

                dialog.setBlockOnOpen(true);
                dialog.open();
            }
        });

        // initially set to map's crs
        IMap activeMap = ApplicationGIS.getActiveMap();
        if (activeMap != null) {
            try {
                CoordinateReferenceSystem crs = activeMap.getViewportModel().getCRS();
                String codeFromCrs = OmsBoxUtils.getCodeFromCrs(crs);
                text.setText(codeFromCrs);
                setDataValue();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    if (isNorthing || isEasting || isEastingNorthing) {
        addMapMouseListener();
    }

    if (isProcessing()) {
        addRegionListener();
        ILayer processingRegionLayer = OmsBoxPlugin.getDefault().getProcessingRegionMapGraphic();
        IStyleBlackboard blackboard = processingRegionLayer.getStyleBlackboard();
        Object object = blackboard.get(ProcessingRegionStyleContent.ID);
        if (object instanceof ProcessingRegionStyle) {
            ProcessingRegionStyle processingStyle = (ProcessingRegionStyle) object;
            setRegion(processingStyle);
        }
    }

    text.addDisposeListener(new DisposeListener() {
        public void widgetDisposed(DisposeEvent e) {
            if (isNorthing || isEasting || isEastingNorthing) {
                removeMapMouseListener();
            }
            if (isProcessing()) {
                removeRegionListener();
            }
        }
    });

    addDrop();

    return text;
}

From source file:org.locationtech.udig.processingtoolbox.ToolboxView.java

License:Open Source License

@Override
public void createPartControl(Composite parent) {
    // create tree viewer
    PatternFilter patternFilter = new PatternFilter();
    FilteredTree filter = new FilteredTree(parent, SWT.SINGLE | SWT.BORDER, patternFilter, true);

    viewer = filter.getViewer();/* www  .j  av a  2 s  .  c  om*/
    viewer.setContentProvider(new ViewContentProvider());
    viewer.setLabelProvider(new ViewLabelProvider());
    viewer.setAutoExpandLevel(2);
    viewer.setInput(buildTree());

    viewer.addDoubleClickListener(new IDoubleClickListener() {
        @Override
        public void doubleClick(DoubleClickEvent event) {
            IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
            final TreeObject node = (TreeObject) selection.getFirstElement();
            if (TreeParent.class.isAssignableFrom(node.getClass())) {
                return;
            }

            final Shell shell = Display.getCurrent().getActiveShell();
            final IMap map = ApplicationGIS.getActiveMap();

            Display.getCurrent().asyncExec(new Runnable() {
                @SuppressWarnings("nls")
                @Override
                public void run() {
                    if (map != ApplicationGIS.NO_MAP) {
                        Dialog dialog = null;
                        if (node.getFactory() == null) {
                            String nodeName = node.getProcessName().getLocalPart();
                            if (nodeName.equalsIgnoreCase("BoxPlotDialog")) {
                                dialog = new BoxPlotDialog(shell, map);
                            } else if (nodeName.equalsIgnoreCase("BubbleChartDialog")) {
                                dialog = new BubbleChartDialog(shell, map);
                            } else if (nodeName.equalsIgnoreCase("FieldCalculatorDialog")) {
                                dialog = new FieldCalculatorDialog(shell, map);
                            } else if (nodeName.equalsIgnoreCase("FormatConversionDialog")) {
                                dialog = new FormatConversionDialog(shell, map);
                            } else if (nodeName.equalsIgnoreCase("HistogramDialog")) {
                                dialog = new HistogramDialog(shell, map);
                            } else if (nodeName.equalsIgnoreCase("MoranScatterPlotDialog")) {
                                dialog = new MoranScatterPlotDialog(shell, map);
                            } else if (nodeName.equalsIgnoreCase("ScatterPlotDialog")) {
                                dialog = new ScatterPlotDialog(shell, map);
                            } else if (nodeName.equalsIgnoreCase("TextfileToPointDialog")) {
                                dialog = new TextfileToPointDialog(shell, map);
                            } else if (nodeName.equalsIgnoreCase("ThematicMapDialog")) {
                                dialog = new ThematicMapDialog(shell, map);
                            } else if (nodeName.equalsIgnoreCase("GeometryToFeaturesDialog")) {
                                dialog = new GeometryToFeaturesDialog(shell, map);
                            } else if (nodeName.equalsIgnoreCase("SpatialWeightsMatrixDialog")) {
                                dialog = new SpatialWeightsMatrixDialog(shell, map);
                            } else if (nodeName.equalsIgnoreCase("MergeFeaturesDialog")) {
                                dialog = new MergeFeaturesDialog(shell, map);
                            } else if (nodeName.equalsIgnoreCase("SplitByAttributesDialog")) {
                                dialog = new SplitByAttributesDialog(shell, map);
                            } else if (nodeName.equalsIgnoreCase("SplitByFeaturesDialog")) {
                                dialog = new SplitByFeaturesDialog(shell, map);
                            } else if (nodeName.equalsIgnoreCase("ExportStyleDialog")) {
                                dialog = new ExportStyleDialog(shell, map);
                            } else if (nodeName.equalsIgnoreCase("AmoebaWizardDialog")) {
                                dialog = new AmoebaWizardDialog(shell, new AmoebaWizard(map));
                            }
                        } else {
                            dialog = new ProcessExecutionDialog(shell, map, node.getFactory(),
                                    node.getProcessName());
                        }

                        if (dialog != null) {
                            dialog.setBlockOnOpen(true);
                            dialog.open();
                        }
                    } else {
                        MessageDialog.openInformation(shell, Messages.ToolboxView_Title,
                                Messages.ToolboxView_NoActiveMap);
                    }
                }
            });
        }
    });

    // action bar
    IToolBarManager toolbarMgr = getViewSite().getActionBars().getToolBarManager();
    toolbarMgr.add(getEnvironmentAction());
}

From source file:org.locationtech.udig.validation.IntegrityValidationOp.java

License:Open Source License

/** 
 * /*w  w w . j av a  2s.co  m*/
 * @see org.locationtech.udig.ui.operations.IOp#op(org.eclipse.swt.widgets.Display, java.lang.Object, org.eclipse.core.runtime.IProgressMonitor)
 */
public void op(final Display display, Object target, IProgressMonitor monitor) throws Exception {
    // define the ILayer array
    final ILayer[] layer;
    if (target.getClass().isArray()) {
        layer = (ILayer[]) target;
    } else {
        layer = new ILayer[1];
        layer[0] = (ILayer) target;
    }
    //construct the hashmap and run the validation
    ReferencedEnvelope envelope = layer[0].getMap().getViewportModel().getBounds();
    FeatureSource<SimpleFeatureType, SimpleFeature> source;
    String nameSpace;
    String typeName;
    Map<String, FeatureSource<SimpleFeatureType, SimpleFeature>> map = new HashMap<String, FeatureSource<SimpleFeatureType, SimpleFeature>>();
    for (int i = 0; i < layer.length; i++) {
        nameSpace = layer[i].getSchema().getName().getNamespaceURI();
        typeName = layer[i].getSchema().getName().getLocalPart();
        source = layer[i].getResource(FeatureSource.class, monitor);
        //map = dataStoreID:typeName
        map.put(nameSpace + ":" + typeName, source); //$NON-NLS-1$
    }

    GenericValidationResults results = new GenericValidationResults();
    genericResults = results;

    PlatformGIS.syncInDisplayThread(new Runnable() {

        public void run() {
            Dialog dialog = getDialog(display.getActiveShell(), layer[0].getSchema());
            if (dialog != null) {
                dialog.open();
            }
        }

    });

    final IntegrityValidation integrityValidation = getValidator(layer);
    if (integrityValidation == null)
        return;

    integrityValidation.validate(map, envelope, results);

    OpUtils.setSelection(layer[0], results);
    OpUtils.notifyUser(display, results);

    monitor.internalWorked(1);
    monitor.done();
}

From source file:org.locationtech.udig.validation.test.FeatureValidationTest.java

License:Open Source License

@Test
public void testNullZeroOp() throws Exception {
    //create features suitable for the test
    GeometryFactory factory = new GeometryFactory();
    // test with 2 arbitrary features, with the second having a null attribute
    LineString[] line = new LineString[3];
    line[0] = factory.createLineString(new Coordinate[] { new Coordinate(10, 10), new Coordinate(10, 20), });
    line[1] = factory.createLineString(new Coordinate[] { new Coordinate(20, 10), new Coordinate(20, 20),
            new Coordinate(30, 15), new Coordinate(20, 15), new Coordinate(20, 30) });

    String[] attrValues = new String[2];
    attrValues[0] = "value0"; //$NON-NLS-1$
    attrValues[1] = null;//  w ww  . j  a va  2 s .  co m

    SimpleFeatureType ft = DataUtilities.createType("myLineType", "*geom:LineString,name:String"); //$NON-NLS-1$ //$NON-NLS-2$
    ft = DataUtilities.createSubType(ft, null, DefaultEngineeringCRS.CARTESIAN_2D);
    SimpleFeature[] features = new SimpleFeature[2];
    // add lines
    features[0] = SimpleFeatureBuilder.build(ft, new Object[] { line[0], attrValues[0] }, Integer.toString(0));
    features[1] = SimpleFeatureBuilder.build(ft, new Object[] { line[1], attrValues[1] }, Integer.toString(1));
    //FeatureFactory ff = new FeatureFactory();

    IGeoResource resource = MapTests.createGeoResource(features, true);
    Map map = MapTests.createNonDynamicMapAndRenderer(resource, new Dimension(500, 512));
    ValidateNullZero isValidAttr = new ValidateNullZero();

    // test the dialog
    Dialog dialog = isValidAttr.getDialog(Display.getDefault().getActiveShell(),
            ((ILayer) map.getLayersInternal().get(0)).getSchema());
    dialog.setBlockOnOpen(false);
    dialog.open();
    // check the default xPath
    assertEquals(isValidAttr.xPath, "geom"); // first entry in attributes //$NON-NLS-1$
    //set a new xPath
    isValidAttr.combo.select(1);
    // check the new xPath
    assertEquals(isValidAttr.xPath, "name"); // second entry in attributes //$NON-NLS-1$

    // other checks...

    System.out.println("END OF DIALOG TESTS"); //$NON-NLS-1$
    ////////assertEquals(1,isValidAttr.genericResults.failedFeatures.size());
}

From source file:org.mobadsl.ide.eclipse.ui.AddTemplateFormRepoDialogAction.java

License:Open Source License

public void addTemplateByDialog(IProject project) {
    Dialog dialog = new TemplatesFromRepoCompositeDialog(project, Display.getCurrent().getActiveShell());
    dialog.open();
}

From source file:org.netxms.ui.eclipse.console.ApplicationActionBarAdvisor.java

License:Open Source License

@Override
protected void makeActions(final IWorkbenchWindow window) {
    contribItemShowView = ContributionItemFactory.VIEWS_SHORTLIST.create(window);
    contribItemOpenPerspective = ContributionItemFactory.PERSPECTIVES_SHORTLIST.create(window);

    actionExit = ActionFactory.QUIT.create(window);
    register(actionExit);/*w  w  w  .j  a  v  a  2 s .c om*/

    actionAbout = new Action(String.format(Messages.get().ApplicationActionBarAdvisor_AboutActionName,
            BrandingManager.getInstance().getConsoleProductName())) {
        @Override
        public void run() {
            Dialog dlg = BrandingManager.getInstance().getAboutDialog(window.getShell());
            if (dlg != null) {
                dlg.open();
            } else {
                MessageDialogHelper.openInformation(window.getShell(),
                        Messages.get().ApplicationActionBarAdvisor_AboutTitle,
                        String.format(Messages.get().ApplicationActionBarAdvisor_AboutText,
                                NXCommon.VERSION + " (" + BuildNumber.TEXT + ")"));
            }
        }
    };

    actionShowPreferences = ActionFactory.PREFERENCES.create(window);
    register(actionShowPreferences);

    actionCustomizePerspective = ActionFactory.EDIT_ACTION_SETS.create(window);
    register(actionCustomizePerspective);

    actionSavePerspective = ActionFactory.SAVE_PERSPECTIVE.create(window);
    register(actionSavePerspective);

    actionResetPerspective = ActionFactory.RESET_PERSPECTIVE.create(window);
    register(actionResetPerspective);

    actionClosePerspective = ActionFactory.CLOSE_PERSPECTIVE.create(window);
    register(actionClosePerspective);

    actionCloseAllPerspectives = ActionFactory.CLOSE_ALL_PERSPECTIVES.create(window);
    register(actionCloseAllPerspectives);

    actionMinimize = ActionFactory.MINIMIZE.create(window);
    register(actionMinimize);

    actionMaximize = ActionFactory.MAXIMIZE.create(window);
    register(actionMaximize);

    actionClose = new CommandAction(window, IWorkbenchCommandConstants.WINDOW_CLOSE_PART);
    register(actionClose);

    actionPrevView = ActionFactory.PREVIOUS_PART.create(window);
    register(actionPrevView);

    actionNextView = ActionFactory.NEXT_PART.create(window);
    register(actionNextView);

    actionShowViewMenu = ActionFactory.SHOW_VIEW_MENU.create(window);
    register(actionShowViewMenu);

    actionOpenProgressView = new Action() {
        @Override
        public void run() {
            IWorkbench wb = PlatformUI.getWorkbench();
            if (wb != null) {
                IWorkbenchWindow win = wb.getActiveWorkbenchWindow();
                if (win != null) {
                    IWorkbenchPage page = win.getActivePage();
                    if (page != null) {
                        try {
                            page.showView("org.eclipse.ui.views.ProgressView"); //$NON-NLS-1$
                        } catch (PartInitException e) {
                            e.printStackTrace();
                        }
                    }
                }
            }
        }
    };
    actionOpenProgressView.setText(Messages.get().ApplicationActionBarAdvisor_Progress);
    actionOpenProgressView.setImageDescriptor(Activator.getImageDescriptor("icons/pview.gif")); //$NON-NLS-1$
}

From source file:org.netxms.ui.eclipse.datacollection.propertypages.General.java

License:Open Source License

/**
 * Select parameter/* ww  w .j a  v a2s . co  m*/
 */
private void selectParameter() {
    Dialog dlg;
    switch (origin.getSelectionIndex()) {
    case DataCollectionItem.INTERNAL:
        if (sourceNode.getObjectId() != 0)
            dlg = new SelectInternalParamDlg(getShell(), sourceNode.getObjectId());
        else
            dlg = new SelectInternalParamDlg(getShell(), dci.getNodeId());
        break;
    case DataCollectionItem.AGENT:
        if (sourceNode.getObjectId() != 0)
            dlg = new SelectAgentParamDlg(getShell(), sourceNode.getObjectId(), false);
        else
            dlg = new SelectAgentParamDlg(getShell(), dci.getNodeId(), false);
        break;
    case DataCollectionItem.SNMP:
    case DataCollectionItem.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.WINPERF:
        if (sourceNode.getObjectId() != 0)
            dlg = new WinPerfCounterSelectionDialog(getShell(), sourceNode.getObjectId());
        else
            dlg = new WinPerfCounterSelectionDialog(getShell(), 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());
        dataType.select(pd.getParameterDataType());
        editor.fireOnSelectItemListeners(origin.getSelectionIndex(), pd.getParameterName(),
                pd.getParameterDescription(), pd.getParameterDataType());
    }
}

From source file:org.netxms.ui.eclipse.datacollection.propertypages.GeneralTable.java

License:Open Source License

/**
 * Select parameter//from   w w  w .  j  a  va2  s.  c  o  m
 */
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(), true);
        else
            dlg = new SelectAgentParamDlg(getShell(), dci.getNodeId(), 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;
    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());
    }
}