Example usage for java.awt.event InputEvent BUTTON1_DOWN_MASK

List of usage examples for java.awt.event InputEvent BUTTON1_DOWN_MASK

Introduction

In this page you can find the example usage for java.awt.event InputEvent BUTTON1_DOWN_MASK.

Prototype

int BUTTON1_DOWN_MASK

To view the source code for java.awt.event InputEvent BUTTON1_DOWN_MASK.

Click Source Link

Document

The Mouse Button1 extended modifier constant.

Usage

From source file:com.seleniumtests.ut.driver.TestCustomEventFiringWebDriver.java

/**
 * Test left click in grid mode/*from w w  w. jav  a2s . c o m*/
 */
@Test(groups = { "ut" })
public void testLeftClickOnDesktopWithGrid() {
    CustomEventFiringWebDriver.leftClicOnDesktopAt(0, 0, DriverMode.GRID, gridConnector);

    verify(robot, never()).mousePress(eq(InputEvent.BUTTON1_DOWN_MASK));
    verify(robot, never()).mouseRelease(eq(InputEvent.BUTTON1_DOWN_MASK));
    verify(robot, never()).mouseMove(eq(0), eq(0));
    verify(gridConnector).leftClic(eq(0), eq(0));
}

From source file:com.seleniumtests.ut.driver.TestCustomEventFiringWebDriver.java

/**
 * Test double click in local mode/* www.  jav a2  s . c om*/
 */
@Test(groups = { "ut" })
public void testDoubleClickOnDesktop() {
    CustomEventFiringWebDriver.doubleClickOnDesktopAt(0, 0, DriverMode.LOCAL, gridConnector);

    verify(robot, times(2)).mousePress(eq(InputEvent.BUTTON1_DOWN_MASK));
    verify(robot, times(2)).mouseRelease(eq(InputEvent.BUTTON1_DOWN_MASK));
    verify(robot).mouseMove(eq(0), eq(0));
    verify(gridConnector, never()).doubleClick(eq(0), eq(0));
}

From source file:com.seleniumtests.ut.driver.TestCustomEventFiringWebDriver.java

/**
 * Test double click in grid mode//from   w  ww .j a v  a 2 s .  c  o m
 */
@Test(groups = { "ut" })
public void testDoubleClickOnDesktopWithGrid() {
    CustomEventFiringWebDriver.doubleClickOnDesktopAt(0, 0, DriverMode.GRID, gridConnector);

    verify(robot, never()).mousePress(eq(InputEvent.BUTTON1_DOWN_MASK));
    verify(robot, never()).mouseRelease(eq(InputEvent.BUTTON1_DOWN_MASK));
    verify(robot, never()).mouseMove(eq(0), eq(0));
    verify(gridConnector).doubleClick(eq(0), eq(0));
}

From source file:com.seleniumtests.driver.CustomEventFiringWebDriver.java

/**
 * Left clic at coordinates on desktop. Coordinates are from screen point of view
 * @param x//from   www .j a va 2s.com
 * @param y
 */
public static void leftClicOnDesktopAt(int x, int y, DriverMode driverMode,
        SeleniumGridConnector gridConnector) {

    if (driverMode == DriverMode.LOCAL) {
        try {
            Robot robot = new Robot();
            moveMouse(robot, x, y);
            robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
            robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
        } catch (AWTException e) {
            throw new ScenarioException("leftClicOnDesktopAt: problem using Robot: " + e.getMessage());
        }
    } else if (driverMode == DriverMode.GRID && gridConnector != null) {
        gridConnector.leftClic(x, y);
    } else {
        throw new ScenarioException("driver supports leftClicOnDesktopAt only in local and grid mode");
    }
}

From source file:com.seleniumtests.driver.CustomEventFiringWebDriver.java

/**
 * Left clic at coordinates on desktop. Coordinates are from screen point of view
 * @param x/*from w ww.ja  v  a  2  s  . c om*/
 * @param y
 */
public static void doubleClickOnDesktopAt(int x, int y, DriverMode driverMode,
        SeleniumGridConnector gridConnector) {

    if (driverMode == DriverMode.LOCAL) {
        try {
            Robot robot = new Robot();
            moveMouse(robot, x, y);
            robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
            robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
            robot.delay(10);
            robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
            robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
        } catch (AWTException e) {
            throw new ScenarioException("doubleClickOnDesktopAt: problem using Robot: " + e.getMessage());
        }
    } else if (driverMode == DriverMode.GRID && gridConnector != null) {
        gridConnector.doubleClick(x, y);
    } else {
        throw new ScenarioException("driver supports doubleClickOnDesktopAt only in local and grid mode");
    }
}

From source file:com.ucuenca.pentaho.plugin.step.FusekiLoaderDialog.java

/**
 * This method is called by Spoon when the user opens the settings dialog of
 * the step. It should open the dialog and return only once the dialog has
 * been closed by the user./*from w  ww.j a  v a  2s .c  o  m*/
 * 
 * If the user confirms the dialog, the meta object (passed in the
 * constructor) must be updated to reflect the new step settings. The
 * changed flag of the meta object must reflect whether the step
 * configuration was changed by the dialog.
 * 
 * If the user cancels the dialog, the meta object must not be updated, and
 * its changed flag must remain unaltered.
 * 
 * The open() method must return the name of the step after the user has
 * confirmed the dialog, or null if the user cancelled the dialog.
 */
public String open() {

    // store some convenient SWT variables
    Shell parent = getParent();
    Display display = parent.getDisplay();

    // SWT code for preparing the dialog
    shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MIN | SWT.MAX);
    props.setLook(shell);
    setShellImage(shell, meta);

    // Save the value of the changed flag on the meta object. If the user
    // cancels
    // the dialog, it will be restored to this saved value.
    // The "changed" variable is inherited from BaseStepDialog
    changed = meta.hasChanged();

    // The ModifyListener used on all controls. It will update the meta
    // object to
    // indicate that changes are being made.
    ModifyListener lsMod = new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            meta.setChanged();
        }
    };

    // ------------------------------------------------------- //
    // SWT code for building the actual settings dialog //
    // ------------------------------------------------------- //
    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = Const.FORM_MARGIN;
    formLayout.marginHeight = Const.FORM_MARGIN;

    shell.setLayout(formLayout);
    shell.setText(BaseMessages.getString(PKG, "FusekiLoader.Shell.Title"));

    int middle = props.getMiddlePct();
    int margin = Const.MARGIN;

    // Stepname line
    wlStepname = new Label(shell, SWT.RIGHT);
    wlStepname.setText(BaseMessages.getString(PKG, "System.Label.StepName"));
    props.setLook(wlStepname);
    fdlStepname = new FormData();
    fdlStepname.left = new FormAttachment(0, 0);
    fdlStepname.right = new FormAttachment(middle, -margin);
    fdlStepname.top = new FormAttachment(0, margin);
    wlStepname.setLayoutData(fdlStepname);

    wStepname = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wStepname.setText(stepname);
    props.setLook(wStepname);
    wStepname.addModifyListener(lsMod);
    fdStepname = new FormData();
    fdStepname.left = new FormAttachment(middle, 0);
    fdStepname.top = new FormAttachment(0, margin);
    fdStepname.right = new FormAttachment(100, 0);
    wStepname.setLayoutData(fdStepname);

    // output field value
    Label wlValName = new Label(shell, SWT.RIGHT);
    wlValName.setText(BaseMessages.getString(PKG, "FusekiLoader.FieldName.Label"));
    props.setLook(wlValName);
    FormData fdlValName = new FormData();
    fdlValName.left = new FormAttachment(0, 0);
    fdlValName.right = new FormAttachment(middle, -margin);
    fdlValName.top = new FormAttachment(wStepname, margin);
    // fdlValName.top = new FormAttachment(10, margin);

    wlValName.setLayoutData(fdlValName);

    wHelloFieldName = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wHelloFieldName);
    wHelloFieldName.addModifyListener(lsMod);
    FormData fdValName = new FormData();
    fdValName.left = new FormAttachment(middle, 0);
    // fdValName.right = new FormAttachment(100, 0);
    fdValName.top = new FormAttachment(wlStepname, margin + 10);
    wHelloFieldName.setLayoutData(fdValName);
    wHelloFieldName.setEditable(false); // ------------

    wLoadFile = new Button(shell, SWT.PUSH);
    wLoadFile.setText(BaseMessages.getString(PKG, "FusekiLoader.FieldName.LoadFile"));

    wLoadFile.setToolTipText(BaseMessages.getString(PKG, "System.Tooltip.ChooseFile"));
    FormData fdChooseFile = new FormData();
    fdChooseFile = new FormData();
    fdChooseFile.right = new FormAttachment(100, 0);
    fdChooseFile.top = new FormAttachment(wStepname, margin);
    wLoadFile.setLayoutData(fdChooseFile);

    fdValName.right = new FormAttachment(wLoadFile, 0);
    // precatch data

    wPreCatch = new Button(shell, SWT.PUSH);
    wPreCatch.setText(BaseMessages.getString(PKG, "System.Tooltip.Precatch"));

    wPreCatch.setToolTipText(BaseMessages.getString(PKG, "System.Tooltip.Precatch"));
    FormData fdwPreCatch = new FormData();
    fdwPreCatch = new FormData();
    fdwPreCatch.right = new FormAttachment(100, 0);
    fdwPreCatch.top = new FormAttachment(wLoadFile, margin);
    wPreCatch.setLayoutData(fdwPreCatch);

    // OK and cancel buttons
    wOK = new Button(shell, SWT.PUSH);
    wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
    wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));

    // label to say fuseki parameters
    Label wlabelFuseki = new Label(shell, SWT.RIGHT);
    wlabelFuseki.setText(BaseMessages.getString(PKG, "FusekiLoader.label.FusekiParameters"));
    props.setLook(wlabelFuseki);
    FormData fdlValName1 = new FormData();
    fdlValName1.left = new FormAttachment(0, 0);
    fdlValName1.right = new FormAttachment(middle, -margin);
    fdlValName1.top = new FormAttachment(wHelloFieldName, margin + 10);

    wlabelFuseki.setLayoutData(fdlValName1);

    // label to serviceName
    Label wlabelServiceName = new Label(shell, SWT.RIGHT);
    wlabelServiceName.setText(BaseMessages.getString(PKG, "FusekiLoader.label.FusekiservName"));
    props.setLook(wlabelServiceName);
    FormData fdlValservName = new FormData();
    fdlValservName.left = new FormAttachment(0, 0);
    fdlValservName.right = new FormAttachment(middle, -margin);
    fdlValservName.top = new FormAttachment(wlabelFuseki, margin + 5);

    wlabelServiceName.setLayoutData(fdlValservName);

    // text para service name
    wTextServName = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);

    props.setLook(wTextServName);
    wTextServName.setText("myservice");
    // wStepname.addModifyListener(lsMod);
    FormData fdtextservName = new FormData();
    fdtextservName.left = new FormAttachment(middle, 0);
    fdtextservName.top = new FormAttachment(wlabelFuseki, margin + 5);
    fdtextservName.right = new FormAttachment(100, 0);
    wTextServName.setLayoutData(fdtextservName);

    wTextServName.addVerifyListener(new VerifyListener() {

        public void verifyText(VerifyEvent event) {
            event.text = event.text.replaceAll("[^A-Za-z0-9]", "");
        }
    });
    // label to service Port
    Label wlabelServicePort = new Label(shell, SWT.RIGHT);
    wlabelServicePort.setText(BaseMessages.getString(PKG, "FusekiLoader.label.FusekiservPort"));
    props.setLook(wlabelServicePort);
    FormData fdlValservPort = new FormData();
    fdlValservPort.left = new FormAttachment(0, 0);
    fdlValservPort.right = new FormAttachment(middle, -margin);
    fdlValservPort.top = new FormAttachment(wlabelServiceName, margin + 5);

    wlabelServicePort.setLayoutData(fdlValservPort);
    // text para service Port

    wTextServPort = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);

    props.setLook(wTextServPort);
    wTextServPort.setText("3030");
    // wStepname.addModifyListener(lsMod);
    FormData fdtextservPort = new FormData();
    fdtextservPort.left = new FormAttachment(middle, 0);
    fdtextservPort.top = new FormAttachment(wlabelServiceName, margin + 5);
    // fdtextservPort.right = new FormAttachment(100, 0);
    wTextServPort.setLayoutData(fdtextservPort);

    //agregando Base URI

    // label to service Port
    Label wlabelBaseUri = new Label(shell, SWT.RIGHT);
    wlabelBaseUri.setText(BaseMessages.getString(PKG, "FusekiLoader.label.BaseUri"));
    props.setLook(wlabelBaseUri);
    FormData fdlBaseUri = new FormData();
    fdlBaseUri.left = new FormAttachment(0, 0);
    fdlBaseUri.right = new FormAttachment(middle, -margin);
    fdlBaseUri.top = new FormAttachment(wlabelServicePort, margin + 5);

    wlabelBaseUri.setLayoutData(fdlBaseUri);
    // text para service Port

    wTextBaseUri = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);

    props.setLook(wTextBaseUri);
    wTextBaseUri.setText("");
    // wStepname.addModifyListener(lsMod);
    FormData fdtextBaseUri = new FormData();
    fdtextBaseUri.left = new FormAttachment(middle, 0);
    fdtextBaseUri.top = new FormAttachment(wlabelServicePort, margin + 5);
    fdtextBaseUri.right = new FormAttachment(100, 0);
    wTextBaseUri.setLayoutData(fdtextBaseUri);

    // confgiracion table empieza aqui

    table = new Table(shell, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION);

    table.setLinesVisible(true);
    table.setHeaderVisible(true);

    String[] titles = { BaseMessages.getString(PKG, "Fuseki.table.col1"),
            BaseMessages.getString(PKG, "Fuseki.table.col2"),

    };
    for (int i = 0; i < titles.length; i++) {
        TableColumn column = new TableColumn(table, SWT.NONE);
        column.setText(titles[i]);
        column.setWidth(160);
    }
    //verifico si hayconfiguracion en el meta 
    ArrayList<String> myListPropiedades = new ArrayList<String>();
    ArrayList<String> myListValores = new ArrayList<String>();
    if (meta.getListaPropiedades() != null) {

        myListPropiedades = cleanspaces(meta.getListaPropiedades());
        myListValores = cleanspaces(meta.getListaValores());

        if (!myListPropiedades.get(0).trim().isEmpty()) { // valido que este
            // cargado con
            // algun valor
            // para
            // agregarlo a
            // la tabla

            TableItem[] items = table.getItems();
            for (int i = 0; i < myListPropiedades.size(); i++) {
                new TableItem(table, SWT.NONE);

            }
        }

    } else {//vacio 
        for (int i = 0; i < 3; i++) { //4
            new TableItem(table, SWT.NONE);
        }

    }

    //---------------

    final TableItem[] items = table.getItems();
    final TableEditor editor2 = new TableEditor(table);

    for (int i = 0; i < items.length; i++) {

        TableEditor editor = new TableEditor(table);
        CCombo combo = new CCombo(table, SWT.NONE);
        combo.setText("Propiedades");
        combo.add("fuseki:dataset");
        combo.add("fuseki:serviceReadGraphStore");
        combo.add("fuseki:serviceQuery");
        combo.add("fuseki:serviceUpload");
        combo.add("fuseki:serviceUpdate");
        combo.add("fuseki:serviceReadWriteGraphStore");
        //JO adding fulltext support
        combo.add("lucene:fulltext");
        //JO*
        combo.setEditable(false);
        //selecciono la parte del combo
        combo.select(i);
        if (meta.getListaPropiedades() != null) { //si existe se carga la configuracion anterior

            String propiedad = myListPropiedades.get(i).trim();
            if (propiedad.compareTo("fuseki:dataset") == 0) {
                combo.select(0);
            } else if (propiedad.compareTo("fuseki:serviceReadGraphStore") == 0) {
                combo.select(1);
            } else if (propiedad.compareTo("fuseki:serviceQuery") == 0) {
                combo.select(2);
            } else if (propiedad.compareTo("fuseki:serviceUpload") == 0) {
                combo.select(3);
            } else if (propiedad.compareTo("fuseki:serviceUpdate") == 0) {
                combo.select(4);
            } else if (propiedad.compareTo("fuseki:serviceReadWriteGraphStore") == 0) {
                combo.select(5);
            }
            //JO adding fulltext support
            else if (propiedad.compareTo("lucene:fulltext") == 0) {
                combo.select(6);
            }
            //JO*
        }

        editor.grabHorizontal = true;
        items[i].setData(editor);
        editor.setEditor(combo, items[i], 0);
        combos.add(combo);
        editors.add(editor);

    }

    table.setSize(table.computeSize(SWT.DEFAULT, 200));

    //aqui hago que sea editable la segunda columna
    final TableEditor editor = new TableEditor(table);
    //The editor must have the same size as the cell and must
    //not be any smaller than 50 pixels.
    final int EDITABLECOLUMN = 1;

    table.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            // Clean up any previous editor control
            Control oldEditor = editor.getEditor();
            if (oldEditor != null)
                oldEditor.dispose();

            // Identify the selected row
            TableItem item = (TableItem) e.item;
            if (item == null)
                return;

            // The control that will be the editor must be a child of the Table
            Text newEditor = new Text(table, SWT.NONE);
            newEditor.setText(item.getText(EDITABLECOLUMN));
            newEditor.addModifyListener(new ModifyListener() {
                public void modifyText(ModifyEvent e) {
                    Text text = (Text) editor.getEditor();
                    editor.getItem().setText(EDITABLECOLUMN, text.getText());
                }
            });
            newEditor.selectAll();
            newEditor.setFocus();
            editor.setEditor(newEditor, item, EDITABLECOLUMN);
        }
    });
    //aquie se precargar valores de las tres primeras filas

    if (meta.getListaPropiedades() != null) {
        for (int i = 0; i < myListValores.size(); i++) {
            table.getItem(i).setText(1, myListValores.get(i).trim());
        }
    } else {
        for (int i = 0; i < 3; i++) {
            table.getItem(i).setText(1, valoresPrecargados[i]);
        }
    }

    //aqui se borra supuestamente 
    Menu menu = new Menu(shell, SWT.POP_UP);
    table.setMenu(menu);
    MenuItem item = new MenuItem(menu, SWT.PUSH);
    item.setText("Delete Selection");
    item.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {

            TableItem[] items = table.getItems();
            for (TableItem item : items) {
                if (table.indexOf(item) == table.getSelectionIndex()) {
                    if (item.getData() != null) {
                        TableEditor ed = (TableEditor) item.getData();
                        int i = editors.indexOf(ed);

                        CCombo cmb = (CCombo) combos.get(i);
                        cmb.dispose();
                        ed.dispose();

                        editors.remove(ed);
                        combos.remove(cmb);
                    }

                    int index = table.indexOf(item);
                    table.remove(index);

                    if (index > 0) {
                        //    table.setSelection(table.getItem(0));
                    }
                    //item.dispose();

                }
            }
            wHelloFieldName.setFocus();
            try {
                Robot r = new Robot();
                //PointerInfo a = MouseInfo.getPointerInfo();
                //Point b = a.getLocation();
                r.mousePress(InputEvent.BUTTON1_DOWN_MASK);
            } catch (AWTException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            //TableEditor editor = new TableEditor(table);
            //item.dispose()  
            //editor.getEditor().redraw() ;           
            //  int fil = table.getSelectionIndex();
            //    table.remove(table.getSelectionIndices());

            //
        }
    });

    // ---------------------------------------------------------

    // table.setItemCount(3);// para ver las filas por defecto
    // parametrizando aqui le ubico en el formulario
    fdmitabla = new FormData();
    fdmitabla.left = new FormAttachment(1, 0);
    fdmitabla.right = new FormAttachment(100, 1);

    fdmitabla.top = new FormAttachment(wTextBaseUri, margin);

    // boton ok y cancel al ultimo
    fdmitabla.height = 280;

    table.setLayoutData(fdmitabla);

    //agregar fila automaticamente
    table.setEnabled(true);
    table.addListener(SWT.MouseDown, new Listener() {
        public void handleEvent(Event event) {
            if ((table.getItemCount() - 1) == table.getSelectionIndex()) {
                Rectangle clientArea = table.getClientArea();
                Point pt = new Point(event.x, event.y);
                agregarfila();
            }
        }
    });

    table.addListener(SWT.KeyDown, new Listener() {
        public void handleEvent(Event arg0) {
            // TODO Auto-generated method stub
            if (arg0.keyCode == SWT.DEL) {
                //System.out.println("aplasto Borrar");
            }
        }
    });

    // --------------------crear fila nueva

    // ----------------------------------------
    // label to choose output

    Label wlValNameO = new Label(shell, SWT.RIGHT);
    wlValNameO.setText(BaseMessages.getString(PKG, "FusekiLoader.FieldName.LabelOutput"));
    props.setLook(wlValNameO);
    FormData fdlValNameO = new FormData();
    fdlValNameO.left = new FormAttachment(middle, 0);
    fdlValNameO.right = new FormAttachment(middle, -margin);
    fdlValNameO.top = new FormAttachment(table, margin + 5);
    // fdlValName.top = new FormAttachment(10, margin);

    wlValNameO.setLayoutData(fdlValNameO);
    // text to output
    wChooseOutput = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wChooseOutput);
    // wChooseOutput.addModifyListener(lsMod);
    FormData fdValNameO = new FormData();
    fdValNameO.left = new FormAttachment(middle, 0);
    // fdValNameO.right = new FormAttachment(100, 0);
    fdValNameO.top = new FormAttachment(table, margin + 5);
    wChooseOutput.setLayoutData(fdValNameO);
    wChooseOutput.setEditable(false);
    // booton to choose directory
    wChooseDirectory = new Button(shell, SWT.PUSH | SWT.SINGLE | SWT.MEDIUM | SWT.BORDER);
    props.setLook(wChooseDirectory);

    wChooseDirectory.setText(BaseMessages.getString(PKG, "FusekiLoader.Output.ChooseDirectory"));
    wChooseDirectory.setToolTipText(BaseMessages.getString(PKG, "System.Tooltip.ChooseDirectory"));
    FormData fdChooseDirectory = new FormData();
    fdChooseDirectory = new FormData();
    fdChooseDirectory.right = new FormAttachment(100, 0);
    fdChooseDirectory.top = new FormAttachment(table, margin + 5);
    wChooseDirectory.setLayoutData(fdChooseDirectory);

    fdValNameO.right = new FormAttachment(wChooseDirectory, -margin);
    wChooseOutput.setLayoutData(fdValNameO);

    // checkbox star service
    wCheckService = new Button(shell, SWT.PUSH);
    props.setLook(wCheckService);

    wCheckService.setText(BaseMessages.getString(PKG, "FusekiLoader.Check.label"));
    wCheckService.setToolTipText(BaseMessages.getString(PKG, "FukekiLoader.Check.tooltip"));
    FormData fdBotonCheck = new FormData();
    fdBotonCheck = new FormData();
    fdBotonCheck.right = new FormAttachment(middle, -margin);
    fdBotonCheck.top = new FormAttachment(wlValNameO, margin + 5);
    // fdBotonCheck.right = new FormAttachment(wOpenBrowser, margin);
    wCheckService.setLayoutData(fdBotonCheck);

    wStopService = new Button(shell, SWT.PUSH);
    props.setLook(wStopService);

    wStopService.setText(BaseMessages.getString(PKG, "FusekiLoader.Stopservice"));

    FormData fdBotonstop = new FormData();
    fdBotonstop = new FormData();
    fdBotonstop.left = new FormAttachment(wCheckService, margin);
    fdBotonstop.top = new FormAttachment(wlValNameO, margin + 5);
    wStopService.setEnabled(false);
    wStopService.setLayoutData(fdBotonstop);

    wOpenBrowser = new Button(shell, SWT.PUSH);
    props.setLook(wOpenBrowser);

    wOpenBrowser.setText(BaseMessages.getString(PKG, "FusekiLoader.BotonBrowser"));
    wOpenBrowser.setToolTipText(BaseMessages.getString(PKG, "FukekiLoader.BotonBrowser.tooltip"));
    FormData fdBotonBrowser = new FormData();
    fdBotonBrowser = new FormData();
    fdBotonBrowser.left = new FormAttachment(wStopService, margin);
    fdBotonBrowser.top = new FormAttachment(wlValNameO, margin + 5);
    wOpenBrowser.setLayoutData(fdBotonBrowser);
    wOpenBrowser.setEnabled(false);
    // ------------------------------------ how start service
    // label how to startService
    Label wLabelHowService = new Label(shell, SWT.RIGHT);
    wLabelHowService.setText(BaseMessages.getString(PKG, "FusekiLoader.label.HowService"));
    props.setLook(wLabelHowService);
    FormData fdlHowService = new FormData();
    fdlHowService.left = new FormAttachment(0, 0);
    fdlHowService.right = new FormAttachment(middle, -margin);
    fdlHowService.top = new FormAttachment(wCheckService, margin + 5);

    wLabelHowService.setLayoutData(fdlHowService);
    // text para service Port
    wTextHowService = new Text(shell, SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.V_SCROLL);
    wTextHowService.setData(new GridData(GridData.FILL_BOTH));
    wTextHowService.setText(
            "To start the service, go to the terminal and type ${outputDir}/fuseki-server --port=${servicePort} --config=config.ttl To access the service go to: http://localhost:${servicePort}/control-panel.tpl To perform some queries make a request to http://localhost:3030/${serviceName}/query?query=${your-query}");

    props.setLook(wTextHowService);
    // wStepname.addModifyListener(lsMod);
    FormData fdtextservHow = new FormData();
    fdtextservHow.left = new FormAttachment(middle, 0);
    fdtextservHow.top = new FormAttachment(wCheckService, margin + 10);
    fdtextservHow.right = new FormAttachment(100, 0);
    wTextHowService.setLayoutData(fdtextservHow);
    wTextHowService.setEditable(false);

    // ----------------------------
    BaseStepDialog.positionBottomButtons(shell, new Button[] { wOK, wCancel }, margin, wTextHowService);

    // Add listeners for cancel and OK
    lsCancel = new Listener() {
        public void handleEvent(Event e) {
            cancel();
        }
    };
    lsOK = new Listener() {
        public void handleEvent(Event e) {
            ok();
        }
    };

    lsLoadFile = new Listener() {
        public void handleEvent(Event e) {
            LoadFile();
        }
    };
    lsChooseDirectory = new Listener() {
        public void handleEvent(Event e) {
            ChooseDirectory();
        }
    };
    lsCheckService = new Listener() {
        public void handleEvent(Event e) {
            StartService();
        }
    };

    lsStopService = new Listener() {
        public void handleEvent(Event e) {
            stop();
        }
    };
    lsUpdateInstrucctions = new ModifyListener() {
        public void handleEvent(Event e) {
            UpdateInstrucctions();
        }

        public void modifyText(ModifyEvent arg0) {
            UpdateInstrucctions();

        }
    };
    lsOpenBrowser = new Listener() {
        public void handleEvent(Event e) {
            OpenBrowser();
        }
    };

    lsPrecatch = new Listener() {
        public void handleEvent(Event e) {
            PreCargar();
        }
    };
    /*
     * lsAddRow = new Listener() { public void handleEvent(Event e) {
     * agregarfila(); } };
     */
    wCancel.addListener(SWT.Selection, lsCancel);
    wOK.addListener(SWT.Selection, lsOK);
    wLoadFile.addListener(SWT.Selection, lsLoadFile);
    wOpenBrowser.addListener(SWT.Selection, lsOpenBrowser);
    wCheckService.addListener(SWT.Selection, lsCheckService);
    this.wChooseDirectory.addListener(SWT.Selection, lsChooseDirectory);
    this.wPreCatch.addListener(SWT.Selection, lsPrecatch);
    this.wStopService.addListener(SWT.Selection, lsStopService);

    wTextServPort.addListener(SWT.Verify, new Listener() {
        public void handleEvent(Event e) {
            String string = e.text;
            char[] chars = new char[string.length()];
            string.getChars(0, chars.length, chars, 0);
            for (int i = 0; i < chars.length; i++) {
                if (!('0' <= chars[i] && chars[i] <= '9')) {
                    e.doit = false;
                    return;
                }
            }
        }
    });

    wTextServName.addModifyListener(lsUpdateInstrucctions);
    wTextServPort.addModifyListener(lsUpdateInstrucctions);
    wChooseOutput.addModifyListener(lsUpdateInstrucctions);

    // default listener (for hitting "enter")
    lsDef = new SelectionAdapter() {
        public void widgetDefaultSelected(SelectionEvent e) {
            ok();
        }
    };
    wStepname.addSelectionListener(lsDef);
    wHelloFieldName.addSelectionListener(lsDef);

    // Detect X or ALT-F4 or something that kills this window and cancel the
    // dialog properly
    shell.addShellListener(new ShellAdapter() {
        public void shellClosed(ShellEvent e) {
            cancel();
        }
    });

    // Set/Restore the dialog size based on last position on screen
    // The setSize() method is inherited from BaseStepDialog
    setSize();

    // populate the dialog with the values from the meta object
    populateDialog();

    // restore the changed flag to original value, as the modify listeners
    // fire during dialog population
    meta.setChanged(changed);

    // open dialog and enter event loop
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }

    // at this point the dialog has closed, so either ok() or cancel() have
    // been executed
    // The "stepname" variable is inherited from BaseStepDialog
    return stepname;
}

From source file:com.joey.software.regionSelectionToolkit.controlers.ImageProfileTool.java

@Override
public void mouseDragged(MouseEvent e) {

    int button = 0;

    if (e.getModifiersEx() == InputEvent.BUTTON1_DOWN_MASK) {
        button = 1;/*from   w w  w.j a va2  s .  c om*/
    } else if (e.getModifiersEx() == InputEvent.BUTTON2_DOWN_MASK) {
        button = 2;
    } else if (e.getModifiersEx() == InputEvent.BUTTON3_DOWN_MASK) {
        button = 3;
    }

    processMouse(e.getPoint(), button);

}

From source file:simMPLS.ui.simulator.JVentanaHija.java

/**
 * Este mtodo se llama cuando se arrastra el ratn sobre el panel de diseo. Si se
 * hace sobre un elemento que estaba seleccionado, el resultado es que ese elemento
 * se mueve donde vaya el cursor del ratn.
 * Move an object of the simulation//from   w  w  w  .  ja  v  a 2 s.c o m
 * @param evt El evento que provoca la llamada.
 * @since 1.0
 */
private void ratonArrastradoEnPanelSimulacion(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_ratonArrastradoEnPanelSimulacion
    if (evt.getModifiersEx() == java.awt.event.InputEvent.BUTTON1_DOWN_MASK) {
        if (nodoSeleccionado != null) {
            TTopology topo = escenario.getTopology();
            Point p2 = evt.getPoint();
            if (p2.x < 0)
                p2.x = 0;
            if (p2.x > panelDisenio.getSize().width)
                p2.x = panelDisenio.getSize().width;
            if (p2.y < 0)
                p2.y = 0;
            if (p2.y > panelDisenio.getSize().height)
                p2.y = panelDisenio.getSize().height;
            nodoSeleccionado.setPosition(new Point(p2.x, p2.y));
            panelSimulacion.repaint();
            this.escenario.setModified(true);
        }
    }
}

From source file:simMPLS.ui.simulator.JVentanaHija.java

/** Este mtodo se llama automticamente cuando se est arrastrando el ratn en la
 * pantalla de diseo. Se encarga de mover los elementos de un lugar a otro para
 * disear la topologa.//from  w ww . j  a v  a  2s . com
 * @since 1.0
 * @param evt El evento que hace que se dispare este mtodo.
 */
private void arrastrandoEnPanelDisenio(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_arrastrandoEnPanelDisenio
    if (evt.getModifiersEx() == java.awt.event.InputEvent.BUTTON1_DOWN_MASK) {
        if (nodoSeleccionado != null) {
            TTopology topo = escenario.getTopology();
            Point p2 = evt.getPoint();
            if (p2.x < 0)
                p2.x = 0;
            if (p2.x > panelDisenio.getSize().width)
                p2.x = panelDisenio.getSize().width;
            if (p2.y < 0)
                p2.y = 0;
            if (p2.y > panelDisenio.getSize().height)
                p2.y = panelDisenio.getSize().height;
            nodoSeleccionado.setPosition(new Point(p2.x, p2.y));
            panelDisenio.repaint();
            this.escenario.setModified(true);
        }
    }
}