Package com.volantis.mcs.eclipse.core

Examples of com.volantis.mcs.eclipse.core.DeviceHeaderPattern


                    }

                    // javadoc inherited
                    public String getColumnText(Object element,
                                                int columnIndex) {
                        DeviceHeaderPattern pattern =
                                (DeviceHeaderPattern) element;

                        final String columnName =
                                tableViewer.getTable().
                                getColumn(columnIndex).getText();
                        String value = null;
                        if (columnName == HEADER_NAME_HEADER) {
                            value = pattern.getName();
                        } else if (columnName == VALUE_HEADER) {
                            value = pattern.getRegularExpression();
                        } else if (columnName == DEVICE_NAME_HEADER) {
                            value = pattern.getBaseDevice();
                            if (value == null) {
                                value = "";
                            }
                        }

                        return value;
                    }

                    // javadoc inherited
                    public void addListener(ILabelProviderListener listener) {
                    }

                    // javadoc inherited
                    public void dispose() {
                    }

                    // javadoc inherited
                    public boolean isLabelProperty(Object element,
                                                   String property) {
                        return false;
                    }

                    // javadoc inherited
                    public void removeListener(ILabelProviderListener listener) {
                    }
                };
            }

            // javadoc inherited
            protected Object createNewItem() {
                return new DeviceHeaderPattern("", "", "");
            }

            // javadoc inherited
            protected ICellModifier createCellModifier() {
                return new ICellModifier() {
                    // javadoc inherited
                    public boolean canModify(Object element, String property) {
                        return true;
                    }

                    // javadoc inherited
                    public Object getValue(Object element, String property) {
                        DeviceHeaderPattern pattern =
                                (DeviceHeaderPattern) element;
                        Object value = null;
                        if (property == HEADER_NAME_HEADER) {
                            value = pattern.getName();
                        } else if (property == VALUE_HEADER) {
                            value = pattern.getRegularExpression();
                        } else if (property == DEVICE_NAME_HEADER) {
                            value = pattern.getBaseDevice();
                            if (value == null) {
                                value = "";
                            }

                        }
                        return value;
                    }

                    // javadoc inherited
                    public void modify(Object element, String property,
                                       Object value) {
                        TableItem item = (TableItem) element;
                        DeviceHeaderPattern pattern =
                                (DeviceHeaderPattern) item.getData();
                        String newValue = (String) value;

                        boolean changed = false;
                        if (property == HEADER_NAME_HEADER) {
                            // The name cannot be null.
                            changed = !pattern.getName().equals(newValue);
                            pattern.setName(newValue);
                        } else if (property == VALUE_HEADER) {
                            // The regular expression cannot be null.
                            changed = !pattern.getRegularExpression().
                                    equals(newValue);
                            pattern.setRegularExpression(newValue);
                        } else if (property == DEVICE_NAME_HEADER) {
                            // The base device CAN be null.
                            String oldBase = pattern.getBaseDevice();
                            if (oldBase == null && newValue == null) {
                                changed = false;
                            } else {
                                if (oldBase != null) {
                                    changed = !oldBase.equals(newValue);
                                } else {
                                    changed = !newValue.equals(oldBase);
                                }
                            }

                            pattern.setBaseDevice(
                                    (newValue.equals("")) ? null : newValue);
                        }
                        // Inform the model of a change only if the object was
                        // modified.
                        if (changed) {
View Full Code Here


                DeviceHeaderPattern[] patterns = manager.getHeaderPatterns(
                            "Samsung-SPH-N400");
                assertEquals("Should only be 1 header pattern", 1, patterns.length);

                DeviceHeaderPattern dhp = patterns[0];
                assertEquals("header name not as expected",
                             "Profile",
                             dhp.getName());
                assertNull("header baseDevice not as expected", dhp.getBaseDevice());
                assertEquals("header regular expression not as expected",
                             "http://device\\.sprintpcs\\.com/Samsung/SPH-N400/.*",
                             dhp.getRegularExpression());
            }
        });
    }
View Full Code Here

                                new TestTransformerMetaFactory(),
                                new DefaultJDOMFactory(), false);

                DeviceHeaderPattern[] patterns
                            = new DeviceHeaderPattern[] {
                                new DeviceHeaderPattern("name1", "re1", "baseDevice1"),
                                new DeviceHeaderPattern("name2", "re2", "baseDevice2")
                            };

                manager.setHeaderPatterns("PC", patterns);

                DeviceHeaderPattern[] updated = manager.getHeaderPatterns("PC");
                assertEquals("Expected 2 header patterns ", 2, updated.length);
                assertEquals("unexpected first header name",
                             "name1",
                             updated[0].getName());
                assertEquals("unexpected first baseDevice",
                             "baseDevice1",
                             updated[0].getBaseDevice());
                assertEquals("unexpected first regular expression",
                             "re1",
                             updated[0].getRegularExpression());
                assertEquals("unexpected second header name",
                             "name2",
                             updated[1].getName());
                assertEquals("unexpected second baseDevice",
                             "baseDevice2",
                             updated[1].getBaseDevice());
                assertEquals("unexpected second regular expression",
                             "re2",
                             updated[1].getRegularExpression());


                patterns = new DeviceHeaderPattern[] {
                                new DeviceHeaderPattern("name1", "re1", "")
                            };

                manager.setHeaderPatterns("PC", patterns);
                updated = manager.getHeaderPatterns("PC");
                assertEquals("unexpected first baseDevice",
View Full Code Here

                        getName());

                // set the Header Patterns
                DeviceHeaderPattern[] patterns
                        = new DeviceHeaderPattern[]{
                            new DeviceHeaderPattern("name1", "re1", "baseDevice1"),
                            new DeviceHeaderPattern("name2", "re2", "baseDevice2")
                        };
                manager.setHeaderPatterns("PC", patterns);

                // get the children of the element (it should be modified by here)
                children = e.getChildren();
View Full Code Here

     * Ensure that an IllegalArgumentExcpetion is thrown when the constructor
     * is passed null for the name argument
     */
    public void testNameCannotBeNullOnConstruction() {
        try {
            new DeviceHeaderPattern(null, "regularExpression", "baseDevice");
            fail("Expected an IllegalArgumentException as the name " +
                 "arg is null");
        } catch (IllegalArgumentException e) {
            // expected
        }
View Full Code Here

     * Ensure that an IllegalArgumentExcpetion is thrown when the constructor
     * is passed null for the regularExpression argument
     */
    public void testRegularExpressionCannotBeNullOnConstruction() {
        try {
            new DeviceHeaderPattern("name", null, "baseDevice");
            fail("Expected an IllegalArgumentException as the " +
                 "regularExpression arg is null");
        } catch (IllegalArgumentException e) {
            // expected
        }
View Full Code Here

    /**
     * Ensure no excpetion is thrown when the baseDevice param is null
     */
    public void testBaseDeviceCanBeNullOnConstruction() {
        try {
            new DeviceHeaderPattern("name", "regularExpression", null);
        } catch (Exception e) {
            fail("Base device is allowed to be null");
        }
    }
View Full Code Here

    /**
     * Tests the {@link DeviceHeaderPattern#getName} method
     * @throws Exception if an error occurs.
     */
    public void testGetName() throws Exception {
        DeviceHeaderPattern dhp = new DeviceHeaderPattern("name",
                                                          "regularExpression",
                                                          "baseDevice");
        assertEquals("Unexpected name value", "name", dhp.getName());
    }
View Full Code Here

    /**
     * Tests the {@link DeviceHeaderPattern#getRegularExpression} method
     * @throws Exception if an error occurs.
     */
    public void testGetRegularExpression() throws Exception {
        DeviceHeaderPattern dhp = new DeviceHeaderPattern("name",
                                                          "regularExpression",
                                                          "baseDevice");
        assertEquals("Unexpected regular expression value",
                     "regularExpression",
                     dhp.getRegularExpression());
    }
View Full Code Here

    /**
     * Tests the {@link DeviceHeaderPattern#getBaseDevice} method
     * @throws Exception if an error occurs.
     */
    public void testGetBaseDevice() throws Exception {
        DeviceHeaderPattern dhp = new DeviceHeaderPattern("name",
                                                          "regularExpression",
                                                          "baseDevice");
        assertEquals("Unexpected base device value",
                     "baseDevice",
                     dhp.getBaseDevice());
    }
View Full Code Here

TOP

Related Classes of com.volantis.mcs.eclipse.core.DeviceHeaderPattern

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.