Input: Remove an incoming or outgoing connection from this vertex . [CODESPLIT] public void removeConnection ( Connection conn ) { if ( conn == null ) { throw new IllegalArgumentException ( ) ; } if ( conn . getSource ( ) == this ) { sourceConnections . remove ( conn ) ; firePropertyChange ( SOURCE_CONNECTIONS_PROP , null , conn ) ; } else if ( conn . getTarget ( ) == this ) { targetConnections . remove ( conn ) ; firePropertyChange ( TARGET_CONNECTIONS_PROP , null , conn ) ; } }


Input: Set the Location of this vertex . [CODESPLIT] public void setLocation ( Point newLocation ) { if ( newLocation == null ) { throw new IllegalArgumentException ( ) ; } location . setLocation ( newLocation ) ; firePropertyChange ( LOCATION_PROP , null , location ) ; }


Input: Set the property value for the given property id . [CODESPLIT] public void setPropertyValue ( Object propertyId , Object value ) { if ( XPOS_PROP . equals ( propertyId ) ) { int x = Integer . parseInt ( ( String ) value ) ; setLocation ( new Point ( x , location . y ) ) ; } else if ( YPOS_PROP . equals ( propertyId ) ) { int y = Integer . parseInt ( ( String ) value ) ; setLocation ( new Point ( location . x , y ) ) ; } else if ( HEIGHT_PROP . equals ( propertyId ) ) { int height = Integer . parseInt ( ( String ) value ) ; setSize ( new Dimension ( size . width , height ) ) ; } else if ( WIDTH_PROP . equals ( propertyId ) ) { int width = Integer . parseInt ( ( String ) value ) ; setSize ( new Dimension ( width , size . height ) ) ; } }


Input: Set the Size of this vertex . Will not update the size if newSize is null . [CODESPLIT] public void setSize ( Dimension newSize ) { if ( newSize != null ) { size . setSize ( newSize ) ; firePropertyChange ( SIZE_PROP , null , size ) ; } }


Input: Constructs constraints string [CODESPLIT] public static String dumpConstraints ( final Constraint [ ] constraints ) { if ( constraints == null ) { return null ; } final StringBuffer buffer = new StringBuffer ( ) ; for ( int i = 0 , length = constraints . length ; i < length ; i ++ ) { buffer . append ( constraints [ i ] . toString ( ) + "<br>" ) ; } return buffer . toString ( ) ; }


Input: Replaces existing zoomManager with the new one . [CODESPLIT] public void setZoomManager ( ZoomManager newManager ) { if ( zoomManager != null ) { zoomManager . removeZoomListener ( this ) ; } zoomManager = newManager ; if ( zoomManager != null ) { zoomManager . addZoomListener ( this ) ; } }


Input: $NON - NLS - 1$ [CODESPLIT] public static Map < String , ResourceProperties > parseListing ( String base , InputStream is ) throws Exception { Map < String , ResourceProperties > res = new HashMap < String , ResourceProperties > ( ) ; DocumentBuilderFactory factory = DocumentBuilderFactory . newInstance ( ) ; factory . setNamespaceAware ( true ) ; DocumentBuilder parser = factory . newDocumentBuilder ( ) ; Document doc = parser . parse ( is ) ; NodeList nl = doc . getElementsByTagNameNS ( DAV_NS , "response" ) ; //$NON-NLS-1$ for ( int i = 0 ; i < nl . getLength ( ) ; i ++ ) { Element oneElem = ( Element ) nl . item ( i ) ; NodeList resName = oneElem . getElementsByTagNameNS ( DAV_NS , "href" ) ; //$NON-NLS-1$ assert ( resName . getLength ( ) == 1 ) ; String bareName = extractOverlap ( base , URLDecoder . decode ( resName . item ( 0 ) . getTextContent ( ) , "UTF-8" ) ) ; if ( bareName . trim ( ) . length ( ) > 0 ) { ResourceProperties props = new ResourceProperties ( ) ; NodeList propList = oneElem . getElementsByTagNameNS ( DAV_NS , "resourcetype" ) ; //$NON-NLS-1$ assert ( propList . getLength ( ) == 1 ) ; NodeList resTypeList = ( ( Element ) propList . item ( 0 ) ) . getElementsByTagNameNS ( DAV_NS , "collection" ) ; //$NON-NLS-1$ assert ( resTypeList . getLength ( ) < 2 ) ; if ( resTypeList . getLength ( ) == 1 ) { props . setDirectory ( true ) ; } propList = oneElem . getElementsByTagNameNS ( DAV_NS , "creationdate" ) ; //$NON-NLS-1$ if ( propList . getLength ( ) > 0 ) { props . setCreationDate ( propList . item ( 0 ) . getTextContent ( ) ) ; } propList = oneElem . getElementsByTagNameNS ( DAV_NS , "getlastmodified" ) ; //$NON-NLS-1$ if ( propList . getLength ( ) > 0 ) { props . setLastModifiedDate ( propList . item ( 0 ) . getTextContent ( ) ) ; } String normBase = base . trim ( ) . endsWith ( "/" ) ? base . trim ( ) : base . trim ( ) + "/" ; //$NON-NLS-1$ //$NON-NLS-2$ props . setBase ( normBase ) ; res . put ( bareName , props ) ; } } return res ; }


Input: / * ( non - Javadoc ) Method declared on ViewerSorter . [CODESPLIT] public int compare ( Viewer viewer , Object o1 , Object o2 ) { DSLMappingEntry item1 = ( DSLMappingEntry ) o1 ; DSLMappingEntry item2 = ( DSLMappingEntry ) o2 ; switch ( criteria ) { case OBJECT : return compareObject ( item1 , item2 ) ; case EXPRESSION : return compareExpressions ( item1 , item2 ) ; case MAPPING : return compareMappings ( item1 , item2 ) ; case SCOPE : return compareScope ( item1 , item2 ) ; default : return 0 ; } }


Input: Creates a new lockentry and adds it to this supported lock . Returns an editor on the new lockentry . [CODESPLIT] public LockEntry addLockEntry ( ) { Element lockentry = addChild ( root , "lockentry" , childNames , false ) ; //$NON-NLS-1$ Element locktype = appendChild ( lockentry , "locktype" ) ; //$NON-NLS-1$ appendChild ( locktype , "write" ) ; //$NON-NLS-1$ LockEntry result = null ; try { result = new LockEntry ( lockentry ) ; } catch ( MalformedElementException e ) { Assert . isTrue ( false , Policy . bind ( "assert.internalError" ) ) ; //$NON-NLS-1$ } return result ; }


Input: Returns an <code > Enumeration< / code > over this supportedlock s <code > LockEntry< / code > s . [CODESPLIT] public Enumeration getLockEntries ( ) throws MalformedElementException { final Node firstLockEntry = getFirstChild ( root , "lockentry" ) ; //$NON-NLS-1$ Enumeration e = new Enumeration ( ) { Node currentLockEntry = firstLockEntry ; public boolean hasMoreElements ( ) { return currentLockEntry != null ; } public Object nextElement ( ) { if ( ! hasMoreElements ( ) ) throw new NoSuchElementException ( ) ; LockEntry result = null ; try { result = new LockEntry ( ( Element ) currentLockEntry ) ; } catch ( MalformedElementException ex ) { Assert . isTrue ( false , Policy . bind ( "assert.internalError" ) ) ; //$NON-NLS-1$ } currentLockEntry = getTwin ( ( Element ) currentLockEntry , true ) ; return result ; } } ; return e ; }


Input: / * ( non - Javadoc ) [CODESPLIT] public void createPartControl ( Composite parent ) { viewer = new TreeViewer ( parent , SWT . MULTI | SWT . H_SCROLL | SWT . V_SCROLL ) ; drillDownAdapter = new DrillDownAdapter ( viewer ) ; viewer . setContentProvider ( new RepositoryContentProvider ( ) ) ; viewer . setLabelProvider ( new RepositoryLabelProvider ( ) ) ; viewer . setSorter ( new NameSorter ( ) ) ; viewer . setInput ( viewer ) ; makeActions ( ) ; hookContextMenu ( ) ; hookDoubleClickAction ( ) ; contributeToActionBars ( ) ; Activator . getLocationManager ( ) . addRepositorySetListener ( new IRepositorySetListener ( ) { public void repositorySetChanged ( int type , List < GuvnorRepository > repList ) { // TODO: Just creating an entirely new content provider. //       Someday might update this to have incremental changes //       to existing content provider. viewer . setContentProvider ( new RepositoryContentProvider ( ) ) ; } } ) ; super . getSite ( ) . setSelectionProvider ( viewer ) ; addDragDropSupport ( ) ; }


Input: Add new BaseVertex to the graph [CODESPLIT] public boolean addChild ( BaseVertex vertex ) { if ( vertex != null && vertices . add ( vertex ) ) { firePropertyChange ( PROP_CHILD_ADDED , null , vertex ) ; return true ; } return false ; }


Input: Remove a vertex from this graph [CODESPLIT] public boolean removeChild ( BaseVertex vertex ) { if ( vertex != null && vertices . remove ( vertex ) ) { firePropertyChange ( PROP_CHILD_REMOVED , null , vertex ) ; return true ; } return false ; }


Input: This method is called upon plug - in activation [CODESPLIT] public void start ( BundleContext context ) throws Exception { super . start ( context ) ; IPreferenceStore preferenceStore = getPreferenceStore ( ) ; useCachePreference = preferenceStore . getBoolean ( IDroolsConstants . CACHE_PARSED_RULES ) ; preferenceStore . addPropertyChangeListener ( new IPropertyChangeListener ( ) { public void propertyChange ( PropertyChangeEvent event ) { if ( IDroolsConstants . CACHE_PARSED_RULES . equals ( event . getProperty ( ) ) ) { useCachePreference = ( ( Boolean ) event . getNewValue ( ) ) . booleanValue ( ) ; if ( ! useCachePreference ) { clearCache ( ) ; } } } } ) ; }


Input: This method is called when the plug - in is stopped [CODESPLIT] public void stop ( BundleContext context ) throws Exception { super . stop ( context ) ; plugin = null ; resourceBundle = null ; parsedRules = null ; compiledRules = null ; processInfos = null ; processInfosById = null ; for ( Color color : colors . values ( ) ) { color . dispose ( ) ; } }


Input: Returns the string from the plugin s resource bundle or key if not found . [CODESPLIT] public static String getResourceString ( String key ) { ResourceBundle bundle = DroolsEclipsePlugin . getDefault ( ) . getResourceBundle ( ) ; try { return ( bundle != null ) ? bundle . getString ( key ) : key ; } catch ( MissingResourceException e ) { return key ; } }


Input: Returns the plugin s resource bundle [CODESPLIT] public ResourceBundle getResourceBundle ( ) { try { if ( resourceBundle == null ) resourceBundle = ResourceBundle . getBundle ( "droolsIDE.DroolsIDEPluginResources" ) ; } catch ( MissingResourceException x ) { resourceBundle = null ; } return resourceBundle ; }


Input: Form Colors default colors for now . [CODESPLIT] public FormColors getRuleBuilderFormColors ( Display display ) { if ( ruleBuilderFormColors == null ) { ruleBuilderFormColors = new FormColors ( display ) ; ruleBuilderFormColors . markShared ( ) ; } return ruleBuilderFormColors ; }


Input: Do nothing if date format is not supported [CODESPLIT] public void setDateTime ( String date ) { String [ ] patterns = { RFC_1123_PATTERN , ISO_8601_UTC_PATTERN , ISO_8601_UTC_MILLIS_PATTERN , ISO_8601_PATTERN , ISO_8601_MILLIS_PATTERN , RFC_850_PATTERN , ASCTIME_PATTERN } ; for ( int i = 0 ; i < patterns . length ; i ++ ) { if ( setDateTime ( date , patterns [ i ] ) ) break ; } }


Input: Do nothing if date format is not supported . [CODESPLIT] protected boolean setDateTime ( String date , String pattern ) { boolean dateChanged = true ; dateFormat . applyPattern ( pattern ) ; try { setDateTime ( dateFormat . parse ( date ) ) ; } catch ( ParseException e ) { dateChanged = false ; } return dateChanged ; }


Input: $NON - NLS - 1$ [CODESPLIT] public static String getDefaultRepositoryDir ( ) { String key = core_defaultRepositoryDir ; String dir = getDeprecatedRepoRootPreference ( ) ; IEclipsePreferences p = InstanceScope . INSTANCE . getNode ( egitPluginId ) ; if ( dir == null ) { dir = p . get ( key , getDefaultDefaultRepositoryDir ( ) ) ; } IStringVariableManager manager = VariablesPlugin . getDefault ( ) . getStringVariableManager ( ) ; String result ; try { result = manager . performStringSubstitution ( dir ) ; } catch ( CoreException e ) { result = "" ; //$NON-NLS-1$ } if ( result == null || result . isEmpty ( ) ) { result = ResourcesPlugin . getWorkspace ( ) . getRoot ( ) . getRawLocation ( ) . toOSString ( ) ; } return result ; }


Input: / * ( non - Javadoc ) [CODESPLIT] public void stop ( BundleContext bundleContext ) throws Exception { context = null ; instance = null ; super . stop ( bundleContext ) ; }


Input: Utility to create an error status for this plug - in . [CODESPLIT] public static IStatus error ( final String message , final Throwable thr ) { return new Status ( IStatus . ERROR , PLUGIN_ID , 0 , message , thr ) ; }


Input: Utility method to log errors in the Egit plugin . [CODESPLIT] public static void logError ( final String message , final Throwable thr ) { getDefault ( ) . getLog ( ) . log ( error ( message , thr ) ) ; }


Input: Adds the given field editor to this page . [CODESPLIT] protected void addField ( FieldEditor editor ) { if ( fields == null ) { fields = new ArrayList < FieldEditor > ( ) ; } // Set the actual preference name based on the current selection // in the Kie Navigator tree view. The preference name is constructed // from the path to the selected tree node by getPreferenceName(). String name = editor . getPreferenceName ( ) ; editor . setPreferenceName ( getPreferenceName ( name ) ) ; fields . add ( editor ) ; }


Input: Adjust the layout of the field editors so that they are properly aligned . [CODESPLIT] protected void adjustGridLayout ( ) { int numColumns = calcNumberOfColumns ( ) ; ( ( GridLayout ) fieldEditorParent . getLayout ( ) ) . numColumns = numColumns ; if ( fields != null ) { for ( int i = 0 ; i < fields . size ( ) ; i ++ ) { FieldEditor fieldEditor = fields . get ( i ) ; fieldEditor . fillIntoGrid ( fieldEditorParent , numColumns ) ; } } }


Input: Applys the font to the field editors managed by this page . [CODESPLIT] protected void applyFont ( ) { if ( fields != null ) { Iterator < FieldEditor > e = fields . iterator ( ) ; while ( e . hasNext ( ) ) { FieldEditor pe = e . next ( ) ; // pe.applyFont(); } } }


Input: Calculates the number of columns needed to host all field editors . [CODESPLIT] private int calcNumberOfColumns ( ) { int result = 0 ; if ( fields != null ) { Iterator < FieldEditor > e = fields . iterator ( ) ; while ( e . hasNext ( ) ) { FieldEditor pe = e . next ( ) ; result = Math . max ( result , pe . getNumberOfControls ( ) ) ; } } return result ; }


Input: Recomputes the page s error state by calling <code > isValid< / code > for every field editor . [CODESPLIT] protected void checkState ( ) { boolean valid = true ; invalidFieldEditor = null ; // The state can only be set to true if all // field editors contain a valid value. So we must check them all if ( fields != null ) { int size = fields . size ( ) ; for ( int i = 0 ; i < size ; i ++ ) { FieldEditor editor = fields . get ( i ) ; valid = valid && editor . isValid ( ) ; if ( ! valid ) { invalidFieldEditor = editor ; break ; } } } setValid ( valid ) ; }


Input: / * ( non - Javadoc ) Method declared on PreferencePage . [CODESPLIT] @ Override protected Control createContents ( Composite parent ) { fieldEditorParent = new Composite ( parent , SWT . NULL ) ; GridLayout layout = new GridLayout ( ) ; layout . numColumns = 1 ; layout . marginHeight = 0 ; layout . marginWidth = 0 ; fieldEditorParent . setLayout ( layout ) ; fieldEditorParent . setFont ( parent . getFont ( ) ) ; createFieldEditors ( ) ; if ( style == GRID ) { adjustGridLayout ( ) ; } initialize ( ) ; checkState ( ) ; return fieldEditorParent ; }


Input: The field editor preference page implementation of an <code > IDialogPage< / code > method disposes of this page s controls and images . Subclasses may override to release their own allocated SWT resources but must call <code > super . dispose< / code > . [CODESPLIT] @ Override public void dispose ( ) { super . dispose ( ) ; if ( fields != null ) { Iterator < FieldEditor > e = fields . iterator ( ) ; while ( e . hasNext ( ) ) { FieldEditor pe = e . next ( ) ; pe . setPage ( null ) ; pe . setPropertyChangeListener ( null ) ; pe . setPreferenceStore ( null ) ; } } }


Input: Returns a parent composite for a field editor . <p > This value must not be cached since a new parent may be created each time this method called . Thus this method must be called each time a field editor is constructed . < / p > [CODESPLIT] protected Composite getFieldEditorParent ( ) { if ( style == FLAT ) { // Create a new parent for each field editor Composite parent = new Composite ( fieldEditorParent , SWT . NULL ) ; parent . setLayoutData ( new GridData ( GridData . FILL_HORIZONTAL ) ) ; return parent ; } // Just return the parent return fieldEditorParent ; }


Input: Initializes all field editors . [CODESPLIT] protected void initialize ( ) { if ( fields != null ) { Iterator < FieldEditor > e = fields . iterator ( ) ; while ( e . hasNext ( ) ) { FieldEditor pe = e . next ( ) ; pe . setPage ( this ) ; pe . setPropertyChangeListener ( this ) ; pe . setPreferenceStore ( getPreferenceStore ( ) ) ; pe . load ( ) ; } } }


Input: The field editor preference page implementation of a <code > PreferencePage< / code > method loads all the field editors with their default values . [CODESPLIT] @ Override protected void performDefaults ( ) { if ( fields != null ) { Iterator < FieldEditor > e = fields . iterator ( ) ; while ( e . hasNext ( ) ) { FieldEditor pe = e . next ( ) ; pe . loadDefault ( ) ; } } // Force a recalculation of my error state. checkState ( ) ; super . performDefaults ( ) ; }


Input: The field editor preference page implementation of this <code > PreferencePage< / code > method saves all field editors by calling <code > FieldEditor . store< / code > . Note that this method does not save the preference store itself ; it just stores the values back into the preference store . [CODESPLIT] @ Override public boolean performOk ( ) { if ( fields != null ) { Iterator < FieldEditor > e = fields . iterator ( ) ; while ( e . hasNext ( ) ) { FieldEditor pe = e . next ( ) ; pe . store ( ) ; // pe.setPresentsDefaultValue(false); } } return true ; }


Input: The field editor preference page implementation of this <code > IPreferencePage< / code > ( and <code > IPropertyChangeListener< / code > ) method intercepts <code > IS_VALID< / code > events but passes other events on to its superclass . [CODESPLIT] @ Override public void propertyChange ( PropertyChangeEvent event ) { if ( event . getProperty ( ) . equals ( FieldEditor . IS_VALID ) ) { boolean newValue = ( ( Boolean ) event . getNewValue ( ) ) . booleanValue ( ) ; // If the new value is true then we must check all field editors. // If it is false, then the page is invalid in any case. if ( newValue ) { checkState ( ) ; } else { invalidFieldEditor = ( FieldEditor ) event . getSource ( ) ; setValid ( newValue ) ; } } }


Input: / * ( non - Javadoc ) Method declared on IDialog . [CODESPLIT] @ Override public void setVisible ( boolean visible ) { super . setVisible ( visible ) ; if ( visible && invalidFieldEditor != null ) { invalidFieldEditor . setFocus ( ) ; } }


Input: { [CODESPLIT] public boolean contains ( String name ) { JsonValue value = object . get ( name ) ; return value != null ; }


Input: { [CODESPLIT] public void firePropertyChangeEvent ( String name , Object oldValue , Object newValue ) { firePropertyChangeEvent ( this , name , oldValue , newValue ) ; }


Input: Fires a property change event with the given source property name old and new value . Used when the event source should be different from this mockup preference store . [CODESPLIT] public void firePropertyChangeEvent ( Object source , String name , Object oldValue , Object newValue ) { PropertyChangeEvent event = new PropertyChangeEvent ( source , name , oldValue , newValue ) ; Object [ ] listeners = fListeners . getListeners ( ) ; for ( int i = 0 ; i < listeners . length ; i ++ )  ( ( IPropertyChangeListener ) listeners [ i ] ) . propertyChange ( event ) ; }


Input: { [CODESPLIT] public void putValue ( String name , String value ) { object . set ( name , value ) ; dirty = true ; }


Input: { [CODESPLIT] public void setValue ( String name , String value ) { String oldValue = this . getString ( name ) ; putValue ( name , value ) ; firePropertyChangeEvent ( name , oldValue , value ) ; }


Input: / * ( non - Javadoc ) [CODESPLIT] public void run ( IAction action ) { if ( selectedFile == null || props == null || targetPart == null ) { return ; } VersionChooserDialog dialog = new VersionChooserDialog ( targetPart . getSite ( ) . getShell ( ) , selectedFile . getName ( ) , getVersionEntries ( ) ) ; if ( dialog . open ( ) == VersionChooserDialog . OK ) { compareWithSelectedVersion ( dialog . getSelectedEntry ( ) ) ; } }


Input: / * ( non - Javadoc ) [CODESPLIT] public void init ( IActionBars bars , IWorkbenchPage page ) { contributor . init ( bars ) ; super . init ( bars , page ) ; }


Input: / * ( non - Javadoc ) [CODESPLIT] public void setActivePage ( IEditorPart activeEditor ) { IActionBars bars = getActionBars ( ) ; if ( activeEditor instanceof ITextEditor ) { if ( bars != null ) { contributor . setActiveEditor ( activeEditor ) ; } } }


Input: In addition to [CODESPLIT] public void setActiveEditor ( IEditorPart part ) { super . setActiveEditor ( part ) ; if ( part instanceof DRLRuleEditor2 ) { DRLRuleEditor2 p = ( DRLRuleEditor2 ) part ; p . setZoomComboContributionItem ( zitem ) ; p . setZoomInAction ( zoomIn ) ; p . setZoomOutAction ( zoomOut ) ; } }


Input: Adds Zoom - related contributions . [CODESPLIT] public void contributeToToolBar ( IToolBarManager toolBarManager ) { super . contributeToToolBar ( toolBarManager ) ; toolBarManager . add ( new Separator ( ) ) ; String [ ] zoomStrings = new String [ ] { ZoomManager . FIT_ALL , ZoomManager . FIT_HEIGHT , ZoomManager . FIT_WIDTH } ; zitem = new ZoomComboContributionItem ( getPage ( ) , zoomStrings ) ; zitem . setZoomManager ( null ) ; zitem . setVisible ( false ) ; zoomIn = new ZoomInAction2 ( ) ; zoomIn . setEnabled ( false ) ; zoomOut = new ZoomOutAction2 ( ) ; zoomOut . setEnabled ( false ) ; toolBarManager . add ( zitem ) ; toolBarManager . add ( zoomIn ) ; toolBarManager . add ( zoomOut ) ; }


Input: especially when parsing incomplete rules [CODESPLIT] private void determineDialect ( String backText ) { dialect = null ; boolean mvel = MVEL_DIALECT_PATTERN . matcher ( backText ) . matches ( ) ; boolean java = JAVA_DIALECT_PATTERN . matcher ( backText ) . matches ( ) ; if ( mvel ) { dialect = MVEL_DIALECT ; } else if ( java ) { dialect = JAVA_DIALECT ; } }


Input: Returns the variables defined in the given rule ( fragment ) . The key is the name of the variable . The value is a list of 2 String : - the first one is the class name of the variable - the second one is the property of the given class that defines the type of this variable note that this property could be nested if this property is null then the given class is the type of the variable [CODESPLIT] public Map < String , String [ ] > getRuleParameters ( ) { Map < String , String [ ] > result = new HashMap < String , String [ ] > ( ) ; int i = 0 ; int lastLocation = - 1 ; for ( Object o : parserList ) { if ( o instanceof DroolsToken ) { DroolsToken token = ( DroolsToken ) o ; if ( DroolsEditorType . IDENTIFIER_VARIABLE . equals ( token . getEditorType ( ) ) || DroolsEditorType . IDENTIFIER_PATTERN . equals ( token . getEditorType ( ) ) ) { String variableName = token . getText ( ) ; if ( lastLocation == Location . LOCATION_LHS_BEGIN_OF_CONDITION ) { int j = i + 2 ; String className = "" ; while ( j < parserList . size ( ) ) { Object obj = parserList . get ( j ++ ) ; if ( obj instanceof DroolsToken ) { String s = ( ( DroolsToken ) obj ) . getText ( ) ; if ( "(" . equals ( s ) ) { result . put ( variableName , new String [ ] { className , null } ) ; break ; } else { className += s ; } } } } else if ( lastLocation == Location . LOCATION_LHS_INSIDE_CONDITION_START ) { int index = findTokenBack ( Location . LOCATION_LHS_BEGIN_OF_CONDITION , i ) ; int j = index + 3 ; String className = "" ; while ( j < i ) { Object obj = parserList . get ( j ++ ) ; if ( obj instanceof DroolsToken ) { String s = ( ( DroolsToken ) obj ) . getText ( ) ; if ( "(" . equals ( s ) ) { break ; } else { className += s ; } } } j = i + 2 ; String propertyName = "" ; while ( j < parserList . size ( ) ) { Object obj = parserList . get ( j ++ ) ; if ( obj instanceof DroolsToken ) { String s = ( ( DroolsToken ) obj ) . getText ( ) ; if ( "," . equals ( s ) || ")" . equals ( s ) ) { result . put ( variableName , new String [ ] { className , propertyName } ) ; break ; } else { propertyName += s ; } } else { result . put ( variableName , new String [ ] { className , propertyName } ) ; } } } } } else if ( o instanceof Integer ) { lastLocation = ( Integer ) o ; } i ++ ; } return result ; }


Input: Decodes the given <code > URL< / code > from an <code > ASCII< / code > readable <code > URL< / code > that is safe for transport . Returns the result . [CODESPLIT] public static String decode ( String url ) { try { return decode ( new URL ( url ) ) . toString ( ) ; } catch ( MalformedURLException e ) { // ignore or log? } String file ; String ref = null ; int lastSlashIndex = url . lastIndexOf ( ' ' ) ; int lastHashIndex = url . lastIndexOf ( ' ' ) ; if ( ( lastHashIndex - lastSlashIndex > 1 ) && lastHashIndex < url . length ( ) - 1 ) { file = url . substring ( 0 , lastHashIndex ) ; ref = url . substring ( lastHashIndex + 1 , url . length ( ) ) ; } else { file = url ; } return decode ( file , ref ) ; }


Input: Decodes the file and reference parts of a <code > URL< / code > from an <code > ASCII< / code > readable <code > URL< / code > that is safe for transport . Returns the result . [CODESPLIT] public static String decode ( String file , String ref ) { StringBuffer buf = new StringBuffer ( ) ; StringTokenizer tokenizer = new StringTokenizer ( file , "/" , true ) ; //$NON-NLS-1$ while ( tokenizer . hasMoreTokens ( ) ) { String token = tokenizer . nextToken ( ) ; if ( token . equals ( "/" ) ) { //$NON-NLS-1$ buf . append ( token ) ; } else { buf . append ( decodeSegment ( token ) ) ; } } if ( ref != null ) { buf . append ( ' ' ) ; buf . append ( decodeSegment ( ref ) ) ; } return buf . toString ( ) ; }


Input: Returns the BASE64 encoded <code > String< / code > of the given data . [CODESPLIT] public static String encode ( byte [ ] data ) { Assert . isNotNull ( data ) ; StringBuffer buf = new StringBuffer ( ) ; byte b = 0 ; int bits = 2 ; for ( int i = 0 ; i < data . length ; ++ i ) { b = ( byte ) ( ( b | ( data [ i ] >> bits ) ) & 0x003f ) ; buf . append ( encode ( b ) ) ; b = ( byte ) ( ( data [ i ] << 6 - bits ) & 0x003f ) ; bits += 2 ; if ( bits == 8 ) { buf . append ( encode ( ( byte ) ( b & 0x003f ) ) ) ; b = 0 ; bits = 2 ; } } if ( bits == 4 ) { buf . append ( encode ( b ) ) ; buf . append ( "==" ) ; //$NON-NLS-1$ } else if ( bits == 6 ) { buf . append ( encode ( b ) ) ; buf . append ( ' ' ) ; } return buf . toString ( ) ; }


Input: Returns a new context that is based on the given context . [CODESPLIT] protected IContext newContext ( IContext userContext , ILocator locator ) throws MalformedURLException { Assert . isNotNull ( userContext ) ; Assert . isNotNull ( locator ) ; IContext context = davFactory . newContext ( userContext ) ; if ( locator . getLabel ( ) != null ) context . setLabel ( locator . getLabel ( ) ) ; return context ; }


Input: for the sort field [CODESPLIT] public void doSave ( IProgressMonitor monitor ) { FileEditorInput input = ( FileEditorInput ) getEditorInput ( ) ; File outputFile = input . getFile ( ) . getLocation ( ) . toFile ( ) ; saveFile ( monitor , outputFile , input ) ; }


Input: Setup table listeners for GUI events . [CODESPLIT] private void createTableListeners ( ) { //setup views into current selected table . addSelectionListener ( new SelectionListener ( ) { public void widgetSelected ( SelectionEvent e ) { populate ( ) ; } public void widgetDefaultSelected ( SelectionEvent e ) { populate ( ) ; } private void populate ( ) { DSLMappingEntry selected = getCurrentSelected ( ) ; exprText . setText ( selected . getMappingKey ( ) ) ; mappingText . setText ( selected . getMappingValue ( ) ) ; objText . setText ( selected . getMetaData ( ) . getMetaData ( ) == null ? "" : selected . getMetaData ( ) . getMetaData ( ) ) ; } } ) ; //double click support table . addMouseListener ( new MouseListener ( ) { public void mouseDoubleClick ( MouseEvent e ) { showEditPopup ( ) ; } public void mouseDown ( MouseEvent e ) { } public void mouseUp ( MouseEvent e ) { } } ) ; }


Input: Create the Table [CODESPLIT] private void createTable ( Composite parent ) { int style = SWT . MULTI | SWT . BORDER | SWT . H_SCROLL | SWT . V_SCROLL | SWT . FULL_SELECTION | SWT . HIDE_SELECTION ; table = new Table ( parent , style ) ; GridData gridData = new GridData ( GridData . FILL_BOTH ) ; gridData . grabExcessVerticalSpace = true ; gridData . horizontalSpan = 3 ; table . setLayoutData ( gridData ) ; table . setLinesVisible ( true ) ; table . setHeaderVisible ( true ) ; TableColumn column ; //Expression col column = new TableColumn ( table , SWT . LEFT , 0 ) ; column . setText ( "Language Expression" ) ; column . setWidth ( 350 ) ; // Add listener to column so sorted when clicked  column . addSelectionListener ( new SelectionAdapter ( ) { public void widgetSelected ( SelectionEvent e ) { tableViewer . setSorter ( new DSLMappingSorter ( DSLMappingSorter . EXPRESSION ) ) ; } } ) ; // 3rd column with task Owner column = new TableColumn ( table , SWT . LEFT , 1 ) ; column . setText ( "Rule Language Mapping" ) ; column . setWidth ( 200 ) ; // Add listener to column so sorted when clicked column . addSelectionListener ( new SelectionAdapter ( ) { public void widgetSelected ( SelectionEvent e ) { tableViewer . setSorter ( new DSLMappingSorter ( DSLMappingSorter . MAPPING ) ) ; } } ) ; // 4th column with task PercentComplete  column = new TableColumn ( table , SWT . LEFT , 2 ) ; column . setText ( "Object" ) ; column . setWidth ( 80 ) ; // 5th column with task PercentComplete  column = new TableColumn ( table , SWT . LEFT , 3 ) ; column . setText ( "Scope" ) ; column . setWidth ( 80 ) ; //  Add listener to column so tasks are sorted when clicked column . addSelectionListener ( new SelectionAdapter ( ) { public void widgetSelected ( SelectionEvent e ) { tableViewer . setSorter ( new DSLMappingSorter ( DSLMappingSorter . SCOPE ) ) ; } } ) ; }


Input: Returns the value to which the given URL is mapped to in the table . If the given URL not mapped to any value or is malformed returns <code > null< / code > . [CODESPLIT] public Object get ( String url ) throws MalformedURLException { Assert . isNotNull ( url ) ; return get ( new URL ( url ) ) ; }


Input: Returns the value to which the given <code > URL< / code > is mapped to in the table . If the given <code > URL< / code > not mapped to any value returns <code > null< / code > . [CODESPLIT] public Object get ( URL url ) { Assert . isNotNull ( url ) ; return get ( new URLKey ( url ) ) ; }


Input: Returns the value to which the specified URL is mapped to in the table . If the specified URL is not mapped to any value returns <code > null< / code > . [CODESPLIT] private Object get ( URLKey url ) { Assert . isNotNull ( url ) ; return table . get ( url ) ; }


Input: Returns an <code > Enumeration< / code > over the keys in this <code > URLTable< / code > . [CODESPLIT] public Enumeration keys ( ) { final Enumeration keys = table . keys ( ) ; Enumeration e = new Enumeration ( ) { public boolean hasMoreElements ( ) { return keys . hasMoreElements ( ) ; } public Object nextElement ( ) { return ( ( URLKey ) keys . nextElement ( ) ) . getURL ( ) ; } } ; return e ; }


Input: Maps the given URL to the given value in this table . [CODESPLIT] public void put ( String url , Object value ) throws MalformedURLException { Assert . isNotNull ( url ) ; Assert . isNotNull ( value ) ; put ( new URL ( url ) , value ) ; }


Input: Maps the given <code > URL< / code > to the given value in this table . [CODESPLIT] public void put ( URL url , Object value ) { Assert . isNotNull ( url ) ; Assert . isNotNull ( value ) ; put ( new URLKey ( url ) , value ) ; }


Input: Maps the specified URL to the given value in this table . [CODESPLIT] private void put ( URLKey url , Object value ) { Assert . isNotNull ( url ) ; Assert . isNotNull ( value ) ; // Remove the old entry so the url key is replaced if ( table . get ( url ) != null ) table . remove ( url ) ; table . put ( url , value ) ; }


Input: The method will create a new Node instance and try to add it as a child node . If an Node with the same string token exists the method will return the existing node instead . [CODESPLIT] public Node addToken ( String token ) { Node newnode = new Node ( token ) ; // set the depth first newnode . setDepth ( depth + 1 ) ; // add the node as a child newnode = addChild ( newnode ) ; return newnode ; }


Input: The method will check to see if a Node with the same string token already exists . If it doesn t it will add the token as a child and return the same node . [CODESPLIT] public Node addChild ( Node n ) { if ( ! this . children . containsKey ( n . getToken ( ) ) ) { this . children . put ( n . getToken ( ) , n ) ; n . setParent ( this ) ; return n ; } else { return ( Node ) this . children . get ( n . getToken ( ) ) ; } }


Input: be used directly . Use DroolsModelBuilder instead . [CODESPLIT] void setFile ( IFile file , int offset , int length ) { this . file = file ; this . offset = offset ; this . length = length ; }


Input: / * ( non - Javadoc ) [CODESPLIT] public boolean canExecute ( ) { Object type = request . getType ( ) ; return ( RequestConstants . REQ_MOVE . equals ( type ) || RequestConstants . REQ_MOVE_CHILDREN . equals ( type ) ) ; }


Input: Add a Condition to this Precondition . Conditions are OR d together to check for a matching resource . [CODESPLIT] public void addCondition ( Condition condition ) throws WebDAVException { // a Resource URI can only be specified once in a Precondition Enumeration conditions = getConditions ( ) ; if ( condition . getResourceURI ( ) != null ) { while ( conditions . hasMoreElements ( ) ) { Condition existingCondition = ( Condition ) conditions . nextElement ( ) ; if ( existingCondition . getResourceURI ( ) != null && existingCondition . getResourceURI ( ) . equals ( condition . getResourceURI ( ) ) ) throw new WebDAVException ( IResponse . SC_BAD_REQUEST , Policy . bind ( "error.parseMultipleSpecification" , condition . getResourceURI ( ) ) ) ; //$NON-NLS-1$ } } this . conditions . addElement ( condition ) ; }


Input: Add a condition created from the given URI and state token . This is a convenience method used primarily to create preconditions for lock tokens that must be provided in the resource context for methods that update the resource . [CODESPLIT] public void addStateTokenCondition ( String resourceURI , String stateToken ) throws WebDAVException { Condition condition = new Condition ( resourceURI ) ; ConditionTerm term = new ConditionTerm ( ) ; term . addConditionFactor ( new StateToken ( stateToken ) ) ; condition . addConditionTerm ( term ) ; addCondition ( condition ) ; }


Input: See if this Precondition contains a matching Condition . [CODESPLIT] public boolean matches ( Condition condition ) { boolean match = false ; Enumeration conditions = getConditions ( ) ; while ( ! match && conditions . hasMoreElements ( ) ) { Condition existingCondition = ( Condition ) conditions . nextElement ( ) ; match = existingCondition . matches ( condition ) ; } return match ; }


Input: Asserts that the given object is not <code > null< / code > . If this is not the case some kind of unchecked exception is thrown . The given message is included in that exception to aid debugging . [CODESPLIT] static public void isNotNull ( Object o , String message ) { if ( o == null ) throw new AssertionFailedException ( Policy . bind ( "assert.null" , message ) ) ; //$NON-NLS-1$ }


Input: Asserts that the given boolean is <code > true< / code > . If this is not the case some kind of unchecked exception is thrown . The given message is included in that exception to aid debugging . [CODESPLIT] static public boolean isTrue ( boolean expression , String message ) { if ( ! expression ) throw new AssertionFailedException ( Policy . bind ( "assert.fail" , message ) ) ; //$NON-NLS-1$ return expression ; }


Input: Returns this propstat s prop . [CODESPLIT] public Prop getProp ( ) throws MalformedElementException { Element prop = getFirstChild ( root , "prop" ) ; //$NON-NLS-1$ ensureNotNull ( Policy . bind ( "ensure.missingPropElmt" ) , prop ) ; //$NON-NLS-1$ return new Prop ( prop ) ; }


Input: Returns this propstat s status . [CODESPLIT] public String getStatus ( ) throws MalformedElementException { String status = getChildText ( root , "status" , false ) ; //$NON-NLS-1$ ensureNotNull ( Policy . bind ( "ensure.missingStatusElmt" ) , status ) ; //$NON-NLS-1$ return status ; }


Input: Creates and sets a new prop on this propstat and returns an editor on it . [CODESPLIT] public Prop setProp ( ) { Element prop = setChild ( root , "prop" , childNames , true ) ; //$NON-NLS-1$ try { return new Prop ( prop ) ; } catch ( MalformedElementException e ) { Assert . isTrue ( false , Policy . bind ( "assert.internalError" ) ) ; //$NON-NLS-1$ return null ; // Never reached. } }


Input: Sets the status on this propstat to the given status . The status must not be <code > null< / code > . [CODESPLIT] public void setStatus ( String status ) { Assert . isNotNull ( status ) ; setChild ( root , "status" , status , childNames , true ) ; //$NON-NLS-1$ }


Input: because of how the backText works we need to get the last line so that we can pass it to the DSLUtility [CODESPLIT] public String getLastLine ( String backText ) { BufferedReader breader = new BufferedReader ( new StringReader ( backText ) ) ; String last = "" ; String line = null ; try { while ( ( line = breader . readLine ( ) ) != null ) { // only if the line has text do we set last to it if ( line . length ( ) > 0 ) { last = line ; } } } catch ( IOException e ) { DroolsEclipsePlugin . log ( e ) ; } // now that all the conditions for a single object are on the same line // we need to check for the left parenthesis if ( last . indexOf ( "(" ) > - 1 ) { last = last . substring ( last . lastIndexOf ( "(" ) + 1 ) ; } // if the string has a comma "," we get the substring starting from // the index after the last comma if ( last . indexOf ( "," ) > - 1 ) { last = last . substring ( last . lastIndexOf ( "," ) + 1 ) ; } // if the line ends with right parenthesis, we change it to zero length // string if ( last . endsWith ( ")" ) ) { last = "" ; } return last ; }


Input: Returns the last line that doesn t start with a dash [CODESPLIT] public String getLastNonDashLine ( String backText ) { BufferedReader breader = new BufferedReader ( new StringReader ( backText ) ) ; String last = "" ; String line = null ; try { while ( ( line = breader . readLine ( ) ) != null ) { // there may be blank lines, so we trim first line = line . trim ( ) ; // only if the line has text do we set last to it if ( line . length ( ) > 0 && ! line . startsWith ( "-" ) ) { last = line ; } } } catch ( IOException e ) { DroolsEclipsePlugin . log ( e ) ; } if ( last . indexOf ( "(" ) > - 1 && ! last . endsWith ( ")" ) ) { last = last . substring ( 0 , last . indexOf ( "(" ) ) ; } else if ( last . indexOf ( "(" ) > - 1 && last . endsWith ( ")" ) ) { last = "" ; } return last ; }


Input: The DSLTree is configurable . It can either return just the child of the last token found or it can traverse the tree and generate all the combinations beneath the last matching node . TODO I don t know how to add configuration to the editor so it needs to be hooked up to the configuration for the editor later . [CODESPLIT] protected List < String > getProposals ( DSLAdapter adapter , String obj , String last , boolean firstLine ) { if ( last . length ( ) == 0 ) { last = " " ; } return adapter . getDSLTree ( ) . getChildrenList ( obj , last , true , firstLine ) ; }


Input: Lookup the message with the given ID in this catalog and bind its substitution locations with the given string . [CODESPLIT] public static String bind ( String id , String binding ) { return bind ( id , new String [ ] { binding } ) ; }


Input: Lookup the message with the given ID in this catalog and bind its substitution locations with the given strings . [CODESPLIT] public static String bind ( String id , String binding1 , String binding2 ) { return bind ( id , new String [ ] { binding1 , binding2 } ) ; }


Input: Lookup the message with the given ID in this catalog and bind its substitution locations with the given string values . [CODESPLIT] public static String bind ( String id , String [ ] bindings ) { if ( id == null ) return "No message available" ; //$NON-NLS-1$ String message = null ; try { message = bundle . getString ( id ) ; } catch ( MissingResourceException e ) { // If we got an exception looking for the message, fail gracefully by just returning // the id we were looking for.  In most cases this is semi-informative so is not too bad. return "Missing message: " + id + "in: " + bundleName ; //$NON-NLS-1$ //$NON-NLS-2$ } if ( bindings == null ) return message ; return MessageFormat . format ( message , bindings ) ; }


Input: Encodes the given file and reference parts of a <code > URL< / code > into an <code > ASCII< / code > readable <code > String< / code > that is safe for transport . Returns the result . [CODESPLIT] public static String encode ( String file , String ref ) { StringBuffer buf = new StringBuffer ( ) ; StringTokenizer tokenizer = new StringTokenizer ( file , "/" , true ) ; //$NON-NLS-1$ while ( tokenizer . hasMoreTokens ( ) ) { String token = tokenizer . nextToken ( ) ; if ( token . equals ( "/" ) ) { //$NON-NLS-1$ buf . append ( token ) ; } else { buf . append ( encodeSegment ( token ) ) ; } } if ( ref != null ) { buf . append ( ' ' ) ; buf . append ( encodeSegment ( ref ) ) ; } return buf . toString ( ) ; }


Input: Encodes the given <code > URL< / code > into an <code > ASCII< / code > readable <code > URL< / code > that is safe for transport . Returns the result . [CODESPLIT] public static URL encode ( URL url ) { String file = url . getFile ( ) ; String ref = url . getRef ( ) ; try { return new URL ( url . getProtocol ( ) , url . getHost ( ) , url . getPort ( ) , encode ( file , ref ) ) ; } catch ( MalformedURLException e ) { Assert . isTrue ( false , Policy . bind ( "assert.internalError" ) ) ; //$NON-NLS-1$ } return null ; }


Input: / * ( non - Javadoc ) [CODESPLIT] protected IFigure createFigure ( ) { PolylineConnection connection = new ConnectionFigure ( ) ; PolylineDecoration decoration = new PolylineDecoration ( ) ; connection . setTargetDecoration ( decoration ) ; return connection ; }


Input: Create the sample process file . [CODESPLIT] private void createProcess ( IJavaProject project , IProgressMonitor monitor , String exampleType ) throws CoreException , IOException { // create the process (sample.bpmn) file String fileName = "org/jbpm/eclipse/wizard/project/" + exampleType + ".bpmn.template" ; IFolder folder = null ; folder = project . getProject ( ) . getFolder ( "src/main/resources/com/sample" ) ; FileUtils . createFolder ( folder , monitor ) ; IFile file = folder . getFile ( "sample.bpmn" ) ; InputStream inputstream = getClass ( ) . getClassLoader ( ) . getResourceAsStream ( fileName ) ; if ( ! file . exists ( ) ) { file . create ( inputstream , true , monitor ) ; } else { file . setContents ( inputstream , true , false , monitor ) ; } // create a Java main class to invoke the process fileName = "org/jbpm/eclipse/wizard/project/ProcessMain-" + exampleType + ".java" ; IRuntime runtime = startPage . getRuntime ( ) ; if ( runtime . getVersion ( ) . getMajor ( ) == 5 ) { fileName += ".v5.template" ; } else { fileName += ".template" ; } folder = project . getProject ( ) . getFolder ( "src/main/java" ) ; IPackageFragmentRoot packageFragmentRoot = project . getPackageFragmentRoot ( folder ) ; IPackageFragment packageFragment = packageFragmentRoot . createPackageFragment ( "com.sample" , true , monitor ) ; inputstream = getClass ( ) . getClassLoader ( ) . getResourceAsStream ( fileName ) ; packageFragment . createCompilationUnit ( "ProcessMain.java" , new String ( FileUtils . readStream ( inputstream ) ) , true , monitor ) ; // create persistence.xml if ( runtime . getVersion ( ) . getMajor ( ) == 5 ) { if ( "advanced" . equals ( exampleType ) ) { folder = project . getProject ( ) . getFolder ( "src/main/resources/META-INF" ) ; FileUtils . createFolder ( folder , monitor ) ; inputstream = getClass ( ) . getClassLoader ( ) . getResourceAsStream ( "org/jbpm/eclipse/wizard/project/ProcessLauncher-advanced-persistence.xml.template" ) ; file = folder . getFile ( "persistence.xml" ) ; if ( ! file . exists ( ) ) { file . create ( inputstream , true , monitor ) ; } else { file . setContents ( inputstream , true , false , monitor ) ; } } } }


Input: Create the sample process junit test file . [CODESPLIT] private void createProcessSampleJUnit ( IJavaProject project , String exampleType , IProgressMonitor monitor ) throws JavaModelException , IOException { String s = "org/jbpm/eclipse/wizard/project/ProcessJUnit-" + exampleType + ".java" ; IRuntime runtime = startPage . getRuntime ( ) ; if ( runtime . getVersion ( ) . getMajor ( ) == 5 ) { s += ".v5.template" ; } else { s += ".template" ; } IFolder folder = project . getProject ( ) . getFolder ( "src/main/java" ) ; IPackageFragmentRoot packageFragmentRoot = project . getPackageFragmentRoot ( folder ) ; IPackageFragment packageFragment = packageFragmentRoot . createPackageFragment ( "com.sample" , true , monitor ) ; InputStream inputstream = getClass ( ) . getClassLoader ( ) . getResourceAsStream ( s ) ; packageFragment . createCompilationUnit ( "ProcessTest.java" , new String ( FileUtils . readStream ( inputstream ) ) , true , monitor ) ; }


Input: / * ( non - Javadoc ) [CODESPLIT] @ Override protected IKieProjectWizardPage createOnlineExampleProjectPage ( String pageId ) { return new AbstractKieOnlineExampleProjectWizardPage ( ONLINE_EXAMPLE_PROJECT_PAGE ) { @ Override public String getTitle ( ) { return "Create jBPM Projects from Online Examples" ; } @ Override public String getDescription ( ) { return "Select jBPM Example Projects" ; } @ Override public IRuntimeManager getRuntimeManager ( ) { return JBPMRuntimeManager . getDefault ( ) ; } @ Override public String getProductId ( ) { return "jbpm" ; } } ; }


Input: Return the version number of the KIE Workbench that is installed on the given server . If the server is not running or not responsive use a value from the Preference Store . [CODESPLIT] @ Override public String getRuntimeId ( ) { IPreferenceStore store = org . kie . eclipse . Activator . getDefault ( ) . getPreferenceStore ( ) ; String value = store . getString ( getKieVersionPreferenceKey ( ) ) ; return value ; }


Input: / * ( non - Javadoc ) [CODESPLIT] @ Override public List < IKieRepositoryHandler > getRepositories ( IKieSpaceHandler space ) throws IOException { return getDelegate ( ) . getRepositories ( space ) ; }


Input: / * ( non - Javadoc ) [CODESPLIT] @ Override public List < IKieProjectHandler > getProjects ( IKieRepositoryHandler repository ) throws IOException { return getDelegate ( ) . getProjects ( repository ) ; }


Input: <p > Finds the index of the given object in the array starting at the given index . < / p > [CODESPLIT] public static int indexOf ( Object [ ] array , Object objectToFind , int startIndex ) { if ( array == null ) { return INDEX_NOT_FOUND ; } if ( startIndex < 0 ) { startIndex = 0 ; } if ( objectToFind == null ) { for ( int i = startIndex ; i < array . length ; i ++ ) { if ( array [ i ] == null ) { return i ; } } } else { for ( int i = startIndex ; i < array . length ; i ++ ) { if ( objectToFind . equals ( array [ i ] ) ) { return i ; } } } return INDEX_NOT_FOUND ; }


Input: / * ( non - Javadoc ) [CODESPLIT] public void run ( IAction action ) { String repositoryLoc = null ; String fullPath = null ; if ( selectedNode != null ) { repositoryLoc = selectedNode . getGuvnorRepository ( ) . getLocation ( ) ; fullPath = selectedNode . getFullPath ( ) ; } else { if ( selectedFile == null || props == null ) { return ; } repositoryLoc = props . getRepository ( ) ; fullPath = props . getFullpath ( ) ; } IResponse response = null ; try { IWebDavClient client = WebDavServerCache . getWebDavClient ( repositoryLoc ) ; if ( client == null ) { client = WebDavClientFactory . createClient ( new URL ( repositoryLoc ) ) ; WebDavServerCache . cacheWebDavClient ( repositoryLoc , client ) ; } InputStream ins = null ; try { response = client . getResourceVersions ( fullPath ) ; ins = response . getInputStream ( ) ; } catch ( WebDavException wde ) { if ( wde . getErrorCode ( ) != IResponse . SC_UNAUTHORIZED ) { // If not an authentication failure, we don't know what to do with it throw wde ; } boolean retry = PlatformUtils . getInstance ( ) . authenticateForServer ( repositoryLoc , client ) ; if ( retry ) { response = client . getResourceVersions ( fullPath ) ; ins = response . getInputStream ( ) ; } } if ( ins != null ) { Properties verProps = new Properties ( ) ; verProps . load ( ins ) ; ResourceHistoryView view = PlatformUtils . getResourceHistoryView ( ) ; if ( view != null ) { view . setEntries ( repositoryLoc , fullPath , verProps ) ; } } } catch ( Exception e ) { Activator . getDefault ( ) . displayError ( IStatus . ERROR , e . getMessage ( ) , e , true ) ; } finally { if ( response != null ) { try { response . close ( ) ; } catch ( IOException ioe ) { Activator . getDefault ( ) . writeLog ( IStatus . ERROR , ioe . getMessage ( ) , ioe ) ; } } } }


Input: / * ( non - Javadoc ) [CODESPLIT] public void selectionChanged ( IAction action , ISelection selection ) { // Reset state to default selectedFile = null ; selectedNode = null ; props = null ; action . setEnabled ( false ) ; if ( ! ( selection instanceof IStructuredSelection ) ) { return ; } IStructuredSelection sel = ( IStructuredSelection ) selection ; if ( sel . size ( ) != 1 ) { return ; } if ( sel . getFirstElement ( ) instanceof IFile ) { try { props = GuvnorMetadataUtils . getGuvnorMetadata ( ( IFile ) sel . getFirstElement ( ) ) ; if ( props != null ) { selectedFile = ( IFile ) sel . getFirstElement ( ) ; action . setEnabled ( true ) ; } } catch ( Exception e ) { Activator . getDefault ( ) . writeLog ( IStatus . ERROR , e . getMessage ( ) , e ) ; } } if ( sel . getFirstElement ( ) instanceof TreeObject ) { if ( ( ( TreeObject ) sel . getFirstElement ( ) ) . getNodeType ( ) == TreeObject . Type . RESOURCE ) { selectedNode = ( TreeObject ) sel . getFirstElement ( ) ; action . setEnabled ( true ) ; } } }


Input: Rete visits each of its ObjectTypeNodes . [CODESPLIT] public void visitRete ( final Rete rete ) { this . rootVertex = ( ReteVertex ) this . visitedNodes . get ( dotId ( rete ) ) ; if ( this . rootVertex == null ) { this . rootVertex = new ReteVertex ( rete ) ; this . visitedNodes . put ( dotId ( rete ) , this . rootVertex ) ; } this . graph . addChild ( this . rootVertex ) ; this . parentVertex = this . rootVertex ; for ( EntryPointNode node : rete . getEntryPointNodes ( ) . values ( ) ) { visit ( node ) ; } }


Input: Helper method to ensure nodes are not visited more than once . [CODESPLIT] private void visitNode ( final Object node ) { Object realNode = node ; if ( node instanceof ObjectHashMap . ObjectEntry ) { ObjectHashMap . ObjectEntry entry = ( ObjectHashMap . ObjectEntry ) node ; realNode = entry . getValue ( ) ; } visit ( realNode ) ; }


Input: The identity hashCode for the given object is used as its unique DOT identifier . [CODESPLIT] private static String dotId ( final Object object ) { return Integer . toHexString ( System . identityHashCode ( object ) ) . toUpperCase ( ) ; }


Input: Adds a remove to the given propertyupdate and returns an editor on its prop . [CODESPLIT] public Prop addRemove ( ) { Element remove = appendChild ( root , "remove" ) ; //$NON-NLS-1$ Element prop = appendChild ( remove , "prop" ) ; //$NON-NLS-1$ Prop result = null ; try { result = new Prop ( prop ) ; } catch ( MalformedElementException e ) { Assert . isTrue ( false , Policy . bind ( "assert.internalError" ) ) ; //$NON-NLS-1$ } return result ; }


Input: Adds a set to the given propertyupdate and returns an editor on its prop . [CODESPLIT] public Prop addSet ( ) { Element set = appendChild ( root , "set" ) ; //$NON-NLS-1$ Element prop = appendChild ( set , "prop" ) ; //$NON-NLS-1$ try { return new Prop ( prop ) ; } catch ( MalformedElementException e ) { Assert . isTrue ( false , Policy . bind ( "assert.internalError" ) ) ; //$NON-NLS-1$ return null ; // Never reached. } }


Input: Returns an <code > Enumeration< / code > over this propertyupdate s set and remove property elements . [CODESPLIT] public Enumeration getSetsAndRemoves ( ) throws MalformedElementException { Node setOrRemove = getFirstChild ( root , new String [ ] { "remove" , "set" } ) ; //$NON-NLS-1$ //$NON-NLS-2$ ensureNotNull ( Policy . bind ( "ensure.missingRemoveOrSetElmt" ) , setOrRemove ) ; //$NON-NLS-1$ Node property = null ; while ( setOrRemove != null && property == null ) { Node prop = getFirstChild ( ( Element ) setOrRemove , "prop" ) ; //$NON-NLS-1$ ensureNotNull ( Policy . bind ( "ensure.missingPropElmt" ) , prop ) ; //$NON-NLS-1$ property = getChildElement ( ( Element ) prop , true ) ; if ( property == null ) setOrRemove = getNextSibling ( ( Element ) setOrRemove , new String [ ] { "remove" , "set" } ) ; //$NON-NLS-1$ //$NON-NLS-2$ } final Node a = setOrRemove ; final Node c = property ; Enumeration e = new Enumeration ( ) { Node currentSetOrRemove = a ; Node currentProperty = c ; public boolean hasMoreElements ( ) { return currentProperty != null ; } public Object nextElement ( ) { if ( ! hasMoreElements ( ) ) throw new NoSuchElementException ( ) ; Directive result = null ; try { result = new Directive ( ( Element ) currentProperty ) ; } catch ( MalformedElementException ex ) { Assert . isTrue ( false , Policy . bind ( "assert.internalError" ) ) ; //$NON-NLS-1$ } currentProperty = getNextSibling ( ( Element ) currentProperty ) ; while ( currentSetOrRemove != null && currentProperty == null ) { currentSetOrRemove = getNextSibling ( ( Element ) currentSetOrRemove , new String [ ] { "remove" , "set" } ) ; //$NON-NLS-1$ //$NON-NLS-2$ if ( currentSetOrRemove != null ) { Node prop = getFirstChild ( ( Element ) currentSetOrRemove , "prop" ) ; //$NON-NLS-1$ if ( prop != null ) currentProperty = getChildElement ( ( Element ) prop , true ) ; } } return result ; } } ; return e ; }


Input: / * ( non - Javadoc ) [CODESPLIT] @ Override protected Control createContents ( Composite parent ) { Control contents = super . createContents ( parent ) ; setTitle ( title ) ; validate ( ) ; return contents ; }


Input: / * ( non - Javadoc ) [CODESPLIT] @ Override protected Control createDialogArea ( Composite parent ) { Composite parentComposite = ( Composite ) super . createDialogArea ( parent ) ; Composite composite = new Composite ( parentComposite , SWT . NONE ) ; composite . setLayoutData ( new GridData ( SWT . FILL , SWT . FILL , true , true ) ) ; composite . setLayout ( new GridLayout ( 3 , false ) ) ; composite . setFont ( parent . getFont ( ) ) ; createFields ( composite ) ; return parentComposite ; }


Input: / * ( non - Javadoc ) [CODESPLIT] @ Override protected Control createHelpControl ( Composite parent ) { ( ( GridLayout ) parent . getLayout ( ) ) . numColumns ++ ; errorComposite = new Composite ( parent , SWT . NONE ) ; GridData gd = new GridData ( SWT . FILL , SWT . FILL , true , true ) ; errorComposite . setLayoutData ( gd ) ; errorComposite . setLayout ( new GridLayout ( 2 , false ) ) ; Label errorImage = new Label ( errorComposite , SWT . NONE ) ; errorImage . setLayoutData ( new GridData ( SWT . BEGINNING , SWT . CENTER , false , false ) ) ; errorImage . setImage ( JFaceResources . getImage ( DLG_IMG_TITLE_ERROR ) ) ; errorText = new Label ( errorComposite , SWT . NONE ) ; gd = new GridData ( SWT . FILL , SWT . CENTER , true , false ) ; errorText . setLayoutData ( gd ) ; errorText . setText ( "" ) ; return errorComposite ; }


Input: / * ( non - Javadoc ) [CODESPLIT] @ Override public void setErrorMessage ( String newErrorMessage ) { if ( errorComposite != null && ! errorComposite . isDisposed ( ) ) { if ( newErrorMessage == null || newErrorMessage . isEmpty ( ) ) { errorComposite . setVisible ( false ) ; ( ( GridData ) errorComposite . getLayoutData ( ) ) . exclude = true ; errorText . setText ( "" ) ; } else { errorComposite . setVisible ( true ) ; ( ( GridData ) errorComposite . getLayoutData ( ) ) . exclude = false ; errorText . setText ( newErrorMessage ) ; } errorText . getParent ( ) . getParent ( ) . layout ( ) ; } }


Input: / * ( non - Javadoc ) [CODESPLIT] @ Override protected Button createButton ( Composite parent , int id , String label , boolean defaultButton ) { Button button = super . createButton ( parent , id , label , defaultButton ) ; if ( id == IDialogConstants . OK_ID ) okButton = button ; return button ; }


Input: Answer a new resource locator that identifies a particular server resource by it s URL and label . [CODESPLIT] public ILocator newLocator ( String resourceURL , String label ) { return locatorFactory . newLocator ( resourceURL , label ) ; }


Input: Define reconciler - this has to be done for each partition . Currently there are 3 partitions Inside rule outside rule and inside comment . [CODESPLIT] public IPresentationReconciler getPresentationReconciler ( ISourceViewer sourceViewer ) { PresentationReconciler reconciler = new PresentationReconciler ( ) ; //bucket partition... (everything else outside a rule) DefaultDamagerRepairer dr = new DefaultDamagerRepairer ( getScanner ( ) ) ; reconciler . setDamager ( dr , IDocument . DEFAULT_CONTENT_TYPE ) ; reconciler . setRepairer ( dr , IDocument . DEFAULT_CONTENT_TYPE ) ; //inside a rule partition dr = new DefaultDamagerRepairer ( getScanner ( ) ) ; reconciler . setDamager ( dr , DRLPartionScanner . RULE_PART_CONTENT ) ; reconciler . setRepairer ( dr , DRLPartionScanner . RULE_PART_CONTENT ) ; //finally, inside a multi line comment. dr = new DefaultDamagerRepairer ( new SingleTokenScanner ( new TextAttribute ( ColorManager . getInstance ( ) . getColor ( ColorManager . SINGLE_LINE_COMMENT ) ) ) ) ; reconciler . setDamager ( dr , DRLPartionScanner . RULE_COMMENT ) ; reconciler . setRepairer ( dr , DRLPartionScanner . RULE_COMMENT ) ; return reconciler ; }


Input: Get the appropriate content assistance for each partition . [CODESPLIT] public IContentAssistant getContentAssistant ( ISourceViewer sourceViewer ) { ContentAssistant assistant = new ContentAssistant ( ) ; //setup the content assistance, which is //sensitive to the partition that it is in. assistant . setContentAssistProcessor ( new DefaultCompletionProcessor ( editor ) , IDocument . DEFAULT_CONTENT_TYPE ) ; assistant . setContentAssistProcessor ( new RuleCompletionProcessor ( editor ) , DRLPartionScanner . RULE_PART_CONTENT ) ; assistant . setProposalPopupOrientation ( IContentAssistant . PROPOSAL_OVERLAY ) ; return assistant ; }


Input: Answers whether the receiver and the argument are considered identical . To be identical the receiver and the argument must have the same status code message and extended status information . [CODESPLIT] public boolean sameAs ( Object obj ) { if ( obj == null || ! ( obj instanceof Status ) ) return false ; Status other = ( Status ) obj ; if ( other . code != code || ! other . message . equals ( message ) ) return false ; return other . extendedStatus . equals ( extendedStatus ) ; }


Input: Does this Condition contain the given ConditionTerm? [CODESPLIT] public boolean contains ( ConditionTerm term ) { // iterate through the factors looking for a match boolean match = false ; Enumeration terms = getConditionTerms ( ) ; while ( ! match && terms . hasMoreElements ( ) ) { ConditionTerm t = ( ConditionTerm ) terms . nextElement ( ) ; match = term . matches ( t ) ; } return match ; }


Input: Create a Condition by parsing the given If header as defined by section 9 . 4 in the WebDAV spec . [CODESPLIT] public static Condition create ( StreamTokenizer tokenizer ) throws WebDAVException { Condition condition = new Condition ( ) ; try { int token = tokenizer . ttype ; if ( token == ' ' ) { token = tokenizer . nextToken ( ) ; if ( token == StreamTokenizer . TT_WORD ) { condition . setResourceURI ( tokenizer . sval ) ; } else { throw new WebDAVException ( IResponse . SC_BAD_REQUEST , Policy . bind ( "error.parseMissingResource" ) ) ; //$NON-NLS-1$ } token = tokenizer . nextToken ( ) ; if ( token == ' ' ) { token = tokenizer . nextToken ( ) ; } else { throw new WebDAVException ( IResponse . SC_BAD_REQUEST , Policy . bind ( "error.parseMissing" , String . valueOf ( token ) , ">" ) ) ; //$NON-NLS-1$ //$NON-NLS-2$ } } if ( token == ' ' ) { while ( token == ' ' ) { condition . addConditionTerm ( ConditionTerm . create ( tokenizer ) ) ; token = tokenizer . ttype ; } } else { throw new WebDAVException ( IResponse . SC_BAD_REQUEST , Policy . bind ( "error.parseMissingStart" , String . valueOf ( token ) ) ) ; //$NON-NLS-1$ } } catch ( IOException exc ) { // ignore or log? } return condition ; }


Input: Create a Condition by parsing the given If header as defined by section 9 . 4 in the WebDAV spec . [CODESPLIT] public static Condition create ( String ifHeader ) throws WebDAVException { StreamTokenizer tokenizer = new StreamTokenizer ( new StringReader ( ifHeader ) ) ; // URI characters tokenizer . wordChars ( ' ' , ' ' ) ; tokenizer . wordChars ( ' ' , ' ' ) ; tokenizer . ordinaryChar ( ' ' ) ; tokenizer . ordinaryChar ( ' ' ) ; tokenizer . ordinaryChar ( ' ' ) ; tokenizer . ordinaryChar ( ' ' ) ; tokenizer . ordinaryChar ( ' ' ) ; tokenizer . ordinaryChar ( ' ' ) ; tokenizer . quoteChar ( ' ' ) ; Condition condition = null ; try { int token = tokenizer . nextToken ( ) ; condition = Condition . create ( tokenizer ) ; token = tokenizer . ttype ; if ( token != StreamTokenizer . TT_EOF ) { throw new WebDAVException ( IResponse . SC_BAD_REQUEST , Policy . bind ( "error.parseMissing" , String . valueOf ( token ) , "EOF" ) ) ; //$NON-NLS-1$ //$NON-NLS-2$ } } catch ( IOException exc ) { // ignore or log? } return condition ; }


Input: Creates a clone of the given element and adds it to this prop . The element must not be <code > null< / code > . [CODESPLIT] public void addProperty ( Element element ) throws MalformedElementException { Assert . isNotNull ( element ) ; extractNode ( root , element ) ; }


Input: Creates a new element with the given name and adds it to this prop . The name must not be <code > null< / code > and its qualifier and local name must not be <code > null< / code > and must not be the empty string . [CODESPLIT] public void addPropertyName ( QualifiedName name ) { Assert . isNotNull ( name ) ; String nsName = name . getQualifier ( ) ; Assert . isTrue ( ! "" . equals ( nsName ) ) ; //$NON-NLS-1$ String localName = name . getLocalName ( ) ; Assert . isNotNull ( localName ) ; Assert . isTrue ( ! localName . equals ( "" ) ) ; //$NON-NLS-1$ Document document = root . getOwnerDocument ( ) ; Element element = document . createElement ( localName ) ; declareNS ( element , null , nsName ) ; root . appendChild ( element ) ; }


Input: Returns an <code > Enumeration< / code > over this prop s property <code > Element< / code > s . [CODESPLIT] public Enumeration getProperties ( ) throws MalformedElementException { Node firstChild = getChildElement ( root , true ) ; final Node firstElement = firstChild ; Enumeration e = new Enumeration ( ) { Node currentElement = firstElement ; public boolean hasMoreElements ( ) { return currentElement != null ; } public Object nextElement ( ) { if ( ! hasMoreElements ( ) ) throw new NoSuchElementException ( ) ; Node nextElement = currentElement ; currentElement = getNextSibling ( ( Element ) currentElement ) ; return nextElement ; } } ; return e ; }


Input: Returns an <code > Enumeration< / code > over this prop s property <code > QualifiedName< / code > s . [CODESPLIT] public Enumeration getPropertyNames ( ) throws MalformedElementException { Node firstChild = getChildElement ( root , true ) ; final Node firstElement = firstChild ; Enumeration e = new Enumeration ( ) { Node currentElement = firstElement ; public boolean hasMoreElements ( ) { return currentElement != null ; } public Object nextElement ( ) { if ( ! hasMoreElements ( ) ) throw new NoSuchElementException ( ) ; String nsName = null ; try { nsName = getNSName ( ( Element ) currentElement ) ; } catch ( MalformedElementException ex ) { Assert . isTrue ( false , Policy . bind ( "assert.internalError" ) ) ; //$NON-NLS-1$ } String localName = getNSLocalName ( ( Element ) currentElement ) ; QualifiedNameImpl name = new QualifiedNameImpl ( nsName , localName ) ; currentElement = getNextSibling ( ( Element ) currentElement ) ; return name ; } } ; return e ; }


Input: Create a StateToken by parsing the given If header as defined by section 9 . 4 in the WebDAV spec . [CODESPLIT] public static ConditionFactor create ( StreamTokenizer tokenizer ) throws WebDAVException { StateToken stateToken = new StateToken ( ) ; try { int token = tokenizer . ttype ; if ( token == ' ' ) token = tokenizer . nextToken ( ) ; else throw new WebDAVException ( IResponse . SC_BAD_REQUEST , Policy . bind ( "error.parseMissing" , String . valueOf ( token ) , "<" ) ) ; //$NON-NLS-1$ //$NON-NLS-2$ if ( token == StreamTokenizer . TT_WORD ) { stateToken . setURI ( tokenizer . sval ) ; token = tokenizer . nextToken ( ) ; } else throw new WebDAVException ( IResponse . SC_BAD_REQUEST , Policy . bind ( "error.parseMissingURI" , String . valueOf ( token ) ) ) ; //$NON-NLS-1$ if ( token == ' ' ) token = tokenizer . nextToken ( ) ; else throw new WebDAVException ( IResponse . SC_BAD_REQUEST , Policy . bind ( "error.parseMissing" , String . valueOf ( token ) , ">" ) ) ; //$NON-NLS-1$ //$NON-NLS-2$ } catch ( IOException exc ) { // ignore or log? } return stateToken ; }


Input: Adds Text Editor for rules and Rete graph viewer [CODESPLIT] protected void addPages ( ) { try { textEditor = new DRLRuleEditor ( ) { public void close ( boolean save ) { super . close ( save ) ; DRLRuleEditor2 . this . close ( save ) ; } protected void setPartName ( String partName ) { super . setPartName ( partName ) ; DRLRuleEditor2 . this . setPartName ( partName ) ; } } ; reteViewer = new ReteViewer ( textEditor ) ; int text = addPage ( textEditor , getEditorInput ( ) ) ; int rete = addPage ( reteViewer , getEditorInput ( ) ) ; setPageText ( text , "Text Editor" ) ; setPageText ( rete , "Rete Tree" ) ; textEditor . getDocumentProvider ( ) . getDocument ( getEditorInput ( ) ) . addDocumentListener ( new IDocumentListener ( ) { public void documentAboutToBeChanged ( DocumentEvent event ) { } public void documentChanged ( DocumentEvent event ) { reteViewer . fireDocumentChanged ( ) ; } } ) ; } catch ( PartInitException e ) { DroolsEclipsePlugin . log ( e ) ; } }


Input: / * ( non - Javadoc ) [CODESPLIT] public Object getAdapter ( @ SuppressWarnings ( "rawtypes" ) Class adapter ) { if ( adapter == ZoomManager . class ) { if ( getActiveEditor ( ) instanceof ReteViewer ) { return reteViewer . getAdapter ( adapter ) ; } else if ( getActiveEditor ( ) instanceof DRLRuleEditor ) { return null ; } } else if ( adapter == ZoomInAction2 . class ) { return zoomIn ; } else if ( adapter == ZoomOutAction2 . class ) { return zoomOut ; } else if ( adapter == ZoomComboContributionItem . class ) { return zitem ; } return textEditor . getAdapter ( adapter ) ; }


Input: Send an HTTP DELETE request to the KIE console . [CODESPLIT] protected String httpDelete ( String request ) throws IOException { String host = getKieRESTUrl ( ) ; URL url = new URL ( host + "/" + request ) ; Activator . println ( "[DELETE] " + url . toString ( ) ) ; HttpURLConnection conn = ( HttpURLConnection ) url . openConnection ( ) ; conn . setRequestMethod ( "DELETE" ) ; conn . setRequestProperty ( "Content" , "application/json" ) ; setHttpCredentials ( conn ) ; String response = new BufferedReader ( new InputStreamReader ( ( conn . getInputStream ( ) ) ) ) . readLine ( ) ; Activator . println ( "[DELETE] response: " + response ) ; if ( conn . getResponseCode ( ) != HttpURLConnection . HTTP_ACCEPTED ) { throw new IOException ( "HTTP DELETE failed : HTTP error code : " + conn . getResponseCode ( ) ) ; } JsonObject jo = JsonObject . readFrom ( response ) ; String status = jo . get ( "status" ) . asString ( ) ; if ( status != null && ! status . isEmpty ( ) ) { if ( ! "APPROVED" . equals ( status ) ) throw new IOException ( "HTTP DELETE failed : Request status code : " + status ) ; } String jobId = jo . get ( "jobId" ) . asString ( ) ; if ( jobId != null && ! jobId . isEmpty ( ) ) return jobId ; return response ; }


Input: Send an HTTP POST request to the KIE console . [CODESPLIT] protected String httpPost ( String request , JsonObject body ) throws IOException , RuntimeException { String host = getKieRESTUrl ( ) ; URL url = new URL ( host + "/" + request ) ; Activator . println ( "[POST] " + url . toString ( ) + " body: " + body ) ; HttpURLConnection conn = ( HttpURLConnection ) url . openConnection ( ) ; conn . setDoOutput ( body != null ) ; conn . setRequestMethod ( "POST" ) ; conn . setRequestProperty ( "Content-Type" , "application/json" ) ; setHttpCredentials ( conn ) ; if ( body != null ) { java . io . OutputStream os = conn . getOutputStream ( ) ; Writer writer = new OutputStreamWriter ( os , "UTF-8" ) ; body . writeTo ( writer ) ; writer . close ( ) ; os . flush ( ) ; } String response = new BufferedReader ( new InputStreamReader ( ( conn . getInputStream ( ) ) ) ) . readLine ( ) ; Activator . println ( "[POST] response: " + response ) ; if ( conn . getResponseCode ( ) != HttpURLConnection . HTTP_ACCEPTED ) { throw new IOException ( "HTTP POST failed : HTTP error code : " + conn . getResponseCode ( ) ) ; } JsonObject jo = JsonObject . readFrom ( response ) ; String status = jo . get ( "status" ) . asString ( ) ; if ( status != null && ! status . isEmpty ( ) ) { if ( ! "APPROVED" . equals ( status ) ) throw new IOException ( "HTTP POST failed : Request status code : " + status ) ; } String jobId = jo . get ( "jobId" ) . asString ( ) ; if ( jobId != null && ! jobId . isEmpty ( ) ) return jobId ; return response ; }


Input: Sends a job status request to the KIE Server . [CODESPLIT] public String getJobStatus ( final String jobId , final String title ) throws IOException , InterruptedException { final AtomicReference < String > ar = new AtomicReference < String > ( ) ; IWorkbench wb = PlatformUI . getWorkbench ( ) ; IProgressService ps = wb . getProgressService ( ) ; try { ps . busyCursorWhile ( new IRunnableWithProgress ( ) { public void run ( IProgressMonitor pm ) throws InterruptedException { pm . beginTask ( "Waiting for Job " + jobId + ":\n\n" + title , STATUS_REQUEST_TIMEOUT ) ; pm . subTask ( title ) ; long startTime = System . currentTimeMillis ( ) ; long stopTime = startTime ; do { try { // send a Job Status request every STATUS_REQUEST_DELAY milliseconds Thread . sleep ( STATUS_REQUEST_DELAY ) ; String response = httpGet ( "jobs/" + jobId ) ; JsonObject jo = JsonObject . readFrom ( response ) ; String status = jo . get ( "status" ) . asString ( ) ; String result = jo . get ( "result" ) . asString ( ) ; if ( "null" . equals ( result ) ) { if ( ! "SUCCESS" . equals ( status ) ) result = null ; } if ( status != null && result != null ) ar . set ( status + ":" + result ) ; stopTime = System . currentTimeMillis ( ) ; pm . worked ( STATUS_REQUEST_DELAY ) ; Activator . println ( "status=" + status ) ; Activator . println ( "result=" + result ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } if ( pm . isCanceled ( ) ) throw new InterruptedException ( "Operation canceled" ) ; } while ( ar . get ( ) == null && stopTime - startTime < STATUS_REQUEST_TIMEOUT ) ; pm . done ( ) ; Activator . println ( "\n----------------------------------\n" + "Job " + jobId + "\n" + title + "\ncompleted in " + ( stopTime - startTime ) / 1000.0 + " sec\n" + "Status: " + ar . get ( ) + "\n----------------------------------\n" ) ; } } ) ; } catch ( InvocationTargetException e ) { e . printStackTrace ( ) ; return null ; } return ar . get ( ) ; }


Input: } [CODESPLIT] protected void doubleClicked ( ) { super . doubleClicked ( ) ; // open custom editor pane if one exists WorkDefinition workDefinition = getWorkDefinition ( ) ; if ( workDefinition instanceof WorkDefinitionExtension ) { String editor = ( ( WorkDefinitionExtension ) workDefinition ) . getCustomEditor ( ) ; if ( editor != null ) { Work work = openEditor ( editor , workDefinition ) ; if ( work != null ) { SetWorkCommand setCommand = new SetWorkCommand ( ) ; setCommand . setPropertyValue ( work ) ; CommandStack stack = getViewer ( ) . getEditDomain ( ) . getCommandStack ( ) ; stack . execute ( setCommand ) ; } } } }


Input: / * ( non - Javadoc ) [CODESPLIT] public void run ( IAction action ) { EditRepLocationWizard editWizard = new EditRepLocationWizard ( rep ) ; editWizard . init ( Activator . getDefault ( ) . getWorkbench ( ) , null ) ; WizardDialog dialog = new WizardDialog ( Display . getCurrent ( ) . getActiveShell ( ) , editWizard ) ; dialog . create ( ) ; dialog . open ( ) ; }


Input: Replaces existing zoomManager with the new one . [CODESPLIT] public void setZoomManager ( ZoomManager manager ) { if ( zoomManager != null ) { zoomManager . removeZoomListener ( this ) ; } zoomManager = manager ; if ( zoomManager != null ) { zoomManager . addZoomListener ( this ) ; } }


Input: Creates a new WebDAV update element and sets it as the root of the given document . Returns an editor on the new element . <p > The document must not be <code > null< / code > and must not already have a root element . < / p > [CODESPLIT] public static Update createLabel ( Document document , String label ) { Assert . isNotNull ( document ) ; Assert . isTrue ( document . getOwnerDocument ( ) == null ) ; Assert . isNotNull ( label ) ; Element element = create ( document , "update" ) ; //$NON-NLS-1$ try { Update editor = new Update ( element ) ; editor . setLabelName ( label ) ; return editor ; } catch ( MalformedElementException e ) { Assert . isTrue ( false , Policy . bind ( "assert.internalError" ) ) ; //$NON-NLS-1$ return null ; // Never reached. } }


Input: Creates a new WebDAV update element and sets it as the root of the given document . Returns an editor on the new element . <p > The document must not be <code > null< / code > and must not already have a root element . < / p > [CODESPLIT] public static Update createVersion ( Document document , String href ) { Assert . isNotNull ( document ) ; Assert . isTrue ( document . getOwnerDocument ( ) == null ) ; Assert . isNotNull ( href ) ; Element element = create ( document , "update" ) ; //$NON-NLS-1$ try { Update editor = new Update ( element ) ; editor . setVersion ( href ) ; return editor ; } catch ( MalformedElementException e ) { Assert . isTrue ( false , Policy . bind ( "assert.internalError" ) ) ; //$NON-NLS-1$ return null ; //  Never reached. } }


Input: Returns this response s first DAV : version child element . [CODESPLIT] public String getVersion ( ) throws MalformedElementException { Element version = getFirstChild ( root , "version" ) ; //$NON-NLS-1$ ensureNotNull ( Policy . bind ( "ensure.missingVersionElmt" ) , version ) ; //$NON-NLS-1$ String href = getChildText ( version , "href" , true ) ; //$NON-NLS-1$ ensureNotNull ( Policy . bind ( "ensure.missingHrefElmt" ) , href ) ; //$NON-NLS-1$ return decodeHref ( href ) ; }


Input: Sets the DAV : label child element . [CODESPLIT] public void setLabelName ( String label ) throws MalformedElementException { Element child = getFirstChild ( root , childNames ) ; // If there is a version child already there remove it. if ( isDAVElement ( child , "version" ) ) //$NON-NLS-1$ root . removeChild ( child ) ; // Add/update the label-name element. setChild ( child , "label-name" , label , new String [ ] { "label-name" } , true ) ; //$NON-NLS-1$ //$NON-NLS-2$ }


Input: Sets the DAV : version child element . [CODESPLIT] public void setVersion ( String href ) throws MalformedElementException { Element child = getFirstChild ( root , childNames ) ; // If there is a label-name child remove it. if ( isDAVElement ( child , "label-name" ) ) //$NON-NLS-1$ root . removeChild ( child ) ; // Add/update a version element with the href of the version target. Element newChild = setChild ( root , "version" , new String [ ] { "version" } , true ) ; //$NON-NLS-1$ //$NON-NLS-2$ setChild ( newChild , "href" , encodeHref ( href ) , new String [ ] { "href" } , true ) ; //$NON-NLS-1$ //$NON-NLS-2$ }


Input: Starts this operation synchronously . [CODESPLIT] @ SuppressWarnings ( "restriction" ) public void execute ( IProgressMonitor monitor ) { try { pullOperation . execute ( monitor ) ; results . putAll ( pullOperation . getResults ( ) ) ; } catch ( CoreException e ) { if ( e . getStatus ( ) . getSeverity ( ) == IStatus . CANCEL ) results . putAll ( pullOperation . getResults ( ) ) ; else repoNode . handleException ( ( Throwable ) e ) ; } }


Input: Post - process the pull results allowing the user to deal with uncommitted changes and re - pull if the initial pull failed because of these changes [CODESPLIT] private void handlePullResults ( final Map < Repository , Object > resultsMap ) { if ( tasksToWaitFor . decrementAndGet ( ) == 0 && ! results . isEmpty ( ) ) showResults ( ) ; }


Input: Replaces the element at the specified position in this array with the JSON representation of the specified string . [CODESPLIT] public JsonArray set ( int index , String value ) { values . set ( index , valueOf ( value ) ) ; return this ; }


Input: Creates and adds a new activelock on this lockdiscovery and returns an editor on it . [CODESPLIT] public ActiveLock addActiveLock ( ) { Element activelock = addChild ( root , "activelock" , childNames , false ) ; //$NON-NLS-1$ Element locktype = appendChild ( activelock , "locktype" ) ; //$NON-NLS-1$ appendChild ( locktype , "write" ) ; //$NON-NLS-1$ ActiveLock result = null ; try { result = new ActiveLock ( activelock ) ; } catch ( MalformedElementException e ) { Assert . isTrue ( false , Policy . bind ( "assert.internalError" ) ) ; //$NON-NLS-1$ } return result ; }


Input: Returns an <code > Enumeration< / code > over this lockdiscovery s <code > ActiveLock< / code > s . [CODESPLIT] public Enumeration getActiveLocks ( ) throws MalformedElementException { final Node firstActiveLock = getFirstChild ( root , "activelock" ) ; //$NON-NLS-1$ Enumeration e = new Enumeration ( ) { Node currentActiveLock = firstActiveLock ; public boolean hasMoreElements ( ) { return currentActiveLock != null ; } public Object nextElement ( ) { if ( ! hasMoreElements ( ) ) throw new NoSuchElementException ( ) ; ActiveLock result = null ; try { result = new ActiveLock ( ( Element ) currentActiveLock ) ; } catch ( MalformedElementException ex ) { Assert . isTrue ( false , Policy . bind ( "assert.internalError" ) ) ; //$NON-NLS-1$ } currentActiveLock = getTwin ( ( Element ) currentActiveLock , true ) ; return result ; } } ; return e ; }


Input: Filter out the proposals whose content does not start with the given prefix . [CODESPLIT] protected static void filterProposalsOnPrefix ( String prefix , List < ICompletionProposal > props ) { if ( prefix != null && prefix . trim ( ) . length ( ) > 0 ) { Iterator < ICompletionProposal > iterator = props . iterator ( ) ; String prefixLc = prefix . toLowerCase ( ) ; while ( iterator . hasNext ( ) ) { ICompletionProposal item = iterator . next ( ) ; String content = item . getDisplayString ( ) . toLowerCase ( ) ; if ( ! content . toLowerCase ( ) . startsWith ( prefixLc ) ) { iterator . remove ( ) ; } } } }


Input: Read some text from behind the cursor position . This provides context to both filter what is shown based on what the user has typed in and also to provide more information for the list of suggestions based on context . [CODESPLIT] protected String readBackwards ( int documentOffset , IDocument doc ) throws BadLocationException { int startPart = doc . getPartition ( documentOffset ) . getOffset ( ) ; String prefix = doc . get ( startPart , documentOffset - startPart ) ; return prefix ; }


Input: Calculates layouting for provided graph . [CODESPLIT] public static RowList calculateReteRows ( BaseVertex root ) { RowList rowList = new RowList ( ) ; rowList . add ( 0 , root ) ; int curRow = 0 ; final Set < BaseVertex > seenVertices = new HashSet < BaseVertex > ( ) ; seenVertices . add ( root ) ; while ( curRow < rowList . getDepth ( ) ) { final List < BaseVertex > rowVertices = rowList . get ( curRow ) . getVertices ( ) ; for ( final Iterator < BaseVertex > rowNodeIter = rowVertices . iterator ( ) ; rowNodeIter . hasNext ( ) ; ) { final BaseVertex rowNode = rowNodeIter . next ( ) ; final List < Connection > edges = rowNode . getSourceConnections ( ) ; for ( final Iterator < Connection > edgeIter = edges . iterator ( ) ; edgeIter . hasNext ( ) ; ) { final Connection edge = edgeIter . next ( ) ; final BaseVertex destNode = edge . getOpposite ( rowNode ) ; if ( ! seenVertices . contains ( destNode ) ) { rowList . add ( curRow + 1 , destNode ) ; seenVertices . add ( destNode ) ; } } seenVertices . add ( rowNode ) ; } ++ curRow ; } rowList . optimize ( ) ; return rowList ; }


Input: Painting antialiased vertex [CODESPLIT] public void paint ( Graphics g ) { g . setAntialias ( SWT . ON ) ; Rectangle r = getBounds ( ) . getCopy ( ) ; g . translate ( r . getLocation ( ) ) ; g . setBackgroundColor ( backgroundColor ) ; g . setForegroundColor ( borderColor ) ; g . fillArc ( 0 , 0 , 15 , 15 , 0 , 360 ) ; g . drawArc ( 0 , 0 , 14 , 14 , 0 , 360 ) ; super . paint ( g ) ; }


Input: / * ( non - Javadoc ) [CODESPLIT] public EditPart createEditPart ( EditPart context , Object modelElement ) { // get EditPart for model element EditPart part = getPartForElement ( modelElement ) ; // store model element in EditPart part . setModel ( modelElement ) ; return part ; }


Input: Maps object to EditPart . [CODESPLIT] private EditPart getPartForElement ( Object modelElement ) { if ( modelElement instanceof ReteGraph ) { return new DiagramEditPart ( ) ; } if ( modelElement instanceof BaseVertex ) { return new VertexEditPart ( ) ; } if ( modelElement instanceof Connection ) { return new ConnectionEditPart ( ) ; } DroolsEclipsePlugin . log ( new Exception ( "Can't create part for model element: " + ( ( modelElement != null ) ? modelElement . getClass ( ) . getName ( ) : "null" ) ) ) ; return null ; }


Input: Returns an image descriptor for the image file at the given plug - in relative path . Uses the plug ins image registry to cache it . [CODESPLIT] public static ImageDescriptor getImageDescriptor ( String path ) { JBPMEclipsePlugin plugin = getDefault ( ) ; ImageRegistry reg = plugin . getImageRegistry ( ) ; ImageDescriptor des = reg . getDescriptor ( path ) ; if ( des == null ) { des = AbstractUIPlugin . imageDescriptorFromPlugin ( "org.jbpm.eclipse" , path ) ; reg . put ( path , des ) ; } return des ; }


Input: Declare an Image in the registry table . [CODESPLIT] public final static void declareRegistryImage ( String key , String path ) { ImageDescriptor desc = ImageDescriptor . getMissingImageDescriptor ( ) ; try { desc = ImageDescriptor . createFromURL ( makeIconFileURL ( path ) ) ; } catch ( MalformedURLException e ) { DroolsEclipsePlugin . log ( e ) ; } imageRegistry . put ( key , desc ) ; }


Input: Returns the Digest authorization credentials for the given directives . The credentials have the following form : <code > credentials = Digest digest - response digest - response = 1# ( username | realm | nonce | digest - uri | response | [ algorithm ] | [ cnonce ] | [ opaque ] | [ message - qop ] | [ nonce - count ] | [ auth - param ] ) username = username = username - value username - value = quoted - string realm = realm = realm - value realm - value = quoted - string nonce = nonce = nonce - value nonce - value = quoted - string digest - uri = uri = digest - uri - value digest - uri - value = request - uri ; As specified by HTTP / 1 . 1 response = response = request - digest request - digest = &lt ; &gt ; 32LHEX &lt ; &gt ; LHEX = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | a | b | c | d | e | f algorithm = algorithm = ( MD5 | MD5 - sess | token ) cnonce = cnonce = cnonce - value cnonce - value = nonce - value opaque = opaque = quoted - string message - qop = qop = qop - value nonce - count = nc = nc - value nc - value = 8LHEX < / code > <P > If the qop value is auth or auth - int : <code > request - digest = &lt ; &gt ; &lt ; KD ( H ( A1 ) unq ( nonce - value ) : nc - value : unq ( cnonce - value ) : unq ( qop - value ) : H ( A2 ) ) &lt ; &gt ; KD ( secret data ) = H ( concat ( secret : data )) H ( data ) = MD5 ( data ) unq ( data ) = unqouted ( data ) < / code > <P > If the qop directive is not present : <code > request - digest = &lt ; &gt ; &lt ; KD ( H ( A1 ) unq ( nonce - value ) : H ( A2 ) ) &lt ; &gt ; < / code > <P > If the algorithm directive s value is MD5 or is unspecified then A1 is : <code > A1 = unq ( username - value ) : unq ( realm - value ) : passwd passwd = &lt ; user s password &gt ; < / code > <P > If the algorithm directive s value is MD5 - sess then A1 is : <code > A1 = H ( unq ( username - value ) : unq ( realm - value ) : passwd ) : unq ( nonce - value ) : unq ( cnonce - value ) < / code > <P > If the qop directive s value is auth or is unspecified then A2 is : <code > A2 = Method : digest - uri - value < / code > <P > If the qop value is auth - int then A2 is : <code > A2 = Method : digest - uri - value : H ( entity - body ) < / code > [CODESPLIT] private String credentials ( Request request , String realm , String username , String password , String algorithm , String messageQop , String nonce , String nonceCount , String opaque , String cnonce , String method , String digestUri ) throws Exception { Assert . isNotNull ( request ) ; Assert . isNotNull ( realm ) ; Assert . isNotNull ( username ) ; Assert . isNotNull ( password ) ; Assert . isNotNull ( nonce ) ; Assert . isNotNull ( method ) ; Assert . isNotNull ( digestUri ) ; StringBuffer buf = new StringBuffer ( ) ; buf . append ( "Digest username=\"" ) ; //$NON-NLS-1$ buf . append ( username ) ; buf . append ( "\"" ) ; //$NON-NLS-1$ buf . append ( ", realm=" ) ; //$NON-NLS-1$ buf . append ( realm ) ; if ( messageQop != null ) { buf . append ( ", qop=\"" ) ; //$NON-NLS-1$ buf . append ( messageQop ) ; buf . append ( "\"" ) ; //$NON-NLS-1$ } if ( algorithm != null ) { buf . append ( ", algorithm=" ) ; //$NON-NLS-1$ buf . append ( algorithm ) ; } buf . append ( ", uri=\"" ) ; //$NON-NLS-1$ buf . append ( digestUri ) ; buf . append ( "\"" ) ; //$NON-NLS-1$ buf . append ( ", nonce=" ) ; //$NON-NLS-1$ buf . append ( nonce ) ; if ( nonceCount != null ) { buf . append ( ", nc=" ) ; //$NON-NLS-1$ buf . append ( nonceCount ) ; } if ( cnonce != null ) { buf . append ( ", cnonce=\"" ) ; //$NON-NLS-1$ buf . append ( cnonce ) ; buf . append ( "\"" ) ; //$NON-NLS-1$ } if ( opaque != null ) { buf . append ( ", opaque=" ) ; //$NON-NLS-1$ buf . append ( opaque ) ; } String response = response ( request , realm , username , password , algorithm , messageQop , nonce , nonceCount , cnonce , method , digestUri ) ; if ( response == null ) { return null ; } buf . append ( ", response=\"" ) ; //$NON-NLS-1$ buf . append ( response ) ; buf . append ( "\"" ) ; //$NON-NLS-1$ return buf . toString ( ) ; }


Input: Adds new vertex to specified depth [CODESPLIT] public void add ( final int depth , final BaseVertex vertex ) { if ( this . rows . size ( ) < ( depth + 1 ) ) { final int addRows = depth - this . rows . size ( ) + 1 ; for ( int i = 0 ; i < addRows ; ++ i ) { this . rows . add ( new Row ( ( depth - addRows ) + i ) ) ; } } ( ( Row ) this . rows . get ( depth ) ) . add ( vertex ) ; }


Input: Finds specified vertex from the rows . [CODESPLIT] public int getRow ( final BaseVertex vertex ) { final int numRows = this . rows . size ( ) ; for ( int i = 0 ; i < numRows ; ++ i ) { if ( ( ( Row ) this . rows . get ( i ) ) . contains ( vertex ) ) { return i ; } } return - 1 ; }


Input: Finds the longest row width . [CODESPLIT] public int getWidth ( ) { int width = 0 ; for ( final Iterator < Row > rowIter = this . rows . iterator ( ) ; rowIter . hasNext ( ) ; ) { final Row row = rowIter . next ( ) ; final int rowWidth = row . getWidth ( ) ; if ( rowWidth > width ) { width = rowWidth ; } } return width ; }


Input: Dumps all row vertices to System . err [CODESPLIT] public void dump ( ) { final int numRows = this . rows . size ( ) ; for ( int i = 0 ; i < numRows ; ++ i ) { System . err . println ( i + ": " + get ( i ) . getVertices ( ) ) ; } }


Input: Optimizes all rows for optimal presentation [CODESPLIT] public void optimize ( ) { final int numRows = this . rows . size ( ) ; for ( int i = 0 ; i < numRows ; ++ i ) { get ( i ) . optimize ( ) ; } }


Input: TODO : Search the Native way to find the SourceField IFile [CODESPLIT] private IFile getSourceFieldIFile ( ) { Field fReferences ; try { fReferences = processor . getClass ( ) . getDeclaredField ( "fReferences" ) ; fReferences . setAccessible ( true ) ; SearchResultGroup object [ ] = ( SearchResultGroup [ ] ) fReferences . get ( processor ) ; for ( SearchResultGroup searchResultGroup : object ) { if ( searchResultGroup . getResource ( ) instanceof IFile ) return ( IFile ) searchResultGroup . getResource ( ) ; } } catch ( SecurityException e ) { return null ; } catch ( NoSuchFieldException e ) { return null ; } catch ( IllegalArgumentException e ) { return null ; } catch ( IllegalAccessException e ) { return null ; } return null ; }


Input: / * ( non - Javadoc ) [CODESPLIT] protected void configureGraphicalViewer ( ) { super . configureGraphicalViewer ( ) ; GraphicalViewer viewer = getGraphicalViewer ( ) ; viewer . getControl ( ) . setBackground ( ColorConstants . white ) ; viewer . setEditPartFactory ( new VertexEditPartFactory ( ) ) ; viewer . setRootEditPart ( rootEditPart ) ; viewer . setKeyHandler ( new GraphicalViewerKeyHandler ( viewer ) ) ; }


Input: / * ( non - Javadoc ) [CODESPLIT] public Object getAdapter ( @ SuppressWarnings ( "rawtypes" ) Class type ) { if ( type == ZoomManager . class ) return ( ( ScalableFreeformRootEditPart ) getGraphicalViewer ( ) . getRootEditPart ( ) ) . getZoomManager ( ) ; if ( type == GraphicalViewer . class ) return getGraphicalViewer ( ) ; if ( type == EditPart . class && getGraphicalViewer ( ) != null ) return getGraphicalViewer ( ) . getRootEditPart ( ) ; if ( type == IFigure . class && getGraphicalViewer ( ) != null ) return ( ( GraphicalEditPart ) getGraphicalViewer ( ) . getRootEditPart ( ) ) . getFigure ( ) ; return super . getAdapter ( type ) ; }


Input: Loads model from rule base calculates rete view and initializes diagram model . [CODESPLIT] public ReteGraph loadReteModel ( IProgressMonitor monitor , String contents ) throws Throwable { if ( relayoutRequired == false ) { return diagram ; } ReteGraph newDiagram = new ReteGraph ( ) ; try { monitor . beginTask ( "Loading RETE Tree" , 100 ) ; monitor . subTask ( "Loading Rule Base" ) ; InternalKnowledgeBase ruleBase = null ; try { IResource resource = drlEditor . getResource ( ) ; ClassLoader newLoader = DroolsBuilder . class . getClassLoader ( ) ; if ( resource . getProject ( ) . getNature ( "org.eclipse.jdt.core.javanature" ) != null ) { IJavaProject project = JavaCore . create ( resource . getProject ( ) ) ; newLoader = ProjectClassLoader . getProjectClassLoader ( project ) ; } DRLInfo drlInfo = DroolsEclipsePlugin . getDefault ( ) . parseResource ( drlEditor , true , true ) ; if ( drlInfo == null ) { throw new Exception ( "Could not find DRL info" ) ; } if ( drlInfo . getBuilderErrors ( ) . length > 0 ) { throw new Exception ( drlInfo . getBuilderErrors ( ) . length + " build errors" ) ; } if ( drlInfo . getParserErrors ( ) . size ( ) > 0 ) { throw new Exception ( drlInfo . getParserErrors ( ) . size ( ) + " parser errors" ) ; } InternalKnowledgePackage pkg = drlInfo . getPackage ( ) ; RuleBaseConfiguration config = new RuleBaseConfiguration ( ) ; config . setClassLoader ( newLoader ) ; ruleBase = KnowledgeBaseFactory . newKnowledgeBase ( config ) ; if ( pkg != null ) { ruleBase . addPackage ( pkg ) ; } } catch ( Throwable t ) { DroolsEclipsePlugin . log ( t ) ; throw new Exception ( MSG_PARSE_ERROR + " " + t . getMessage ( ) ) ; } monitor . worked ( 50 ) ; if ( monitor . isCanceled ( ) ) { throw new InterruptedException ( ) ; } monitor . subTask ( "Building RETE Tree" ) ; final ReteooVisitor visitor = new ReteooVisitor ( newDiagram ) ; visitor . visitInternalKnowledgeBase ( ruleBase ) ; monitor . worked ( 30 ) ; if ( monitor . isCanceled ( ) ) { throw new InterruptedException ( ) ; } monitor . subTask ( "Calculating RETE Tree Layout" ) ; BaseVertex rootVertex = visitor . getRootVertex ( ) ; RowList rowList = ReteooLayoutFactory . calculateReteRows ( rootVertex ) ; ReteooLayoutFactory . layoutRowList ( newDiagram , rowList ) ; zeroBaseDiagram ( newDiagram ) ; monitor . worked ( 20 ) ; if ( monitor . isCanceled ( ) ) { throw new InterruptedException ( ) ; } monitor . done ( ) ; } catch ( Throwable t ) { if ( ! ( t instanceof InterruptedException ) ) { DroolsEclipsePlugin . log ( t ) ; } throw t ; } relayoutRequired = false ; return newDiagram ; }


Input: Loads Rete model and initializes zoom manager . [CODESPLIT] protected void initializeGraphicalViewer ( ) { ZoomManager zoomManager = rootEditPart . getZoomManager ( ) ; //List<String> List < String > zoomLevels = new ArrayList < String > ( 3 ) ; zoomLevels . add ( ZoomManager . FIT_ALL ) ; zoomLevels . add ( ZoomManager . FIT_HEIGHT ) ; zoomLevels . add ( ZoomManager . FIT_WIDTH ) ; zoomManager . setZoomLevelContributions ( zoomLevels ) ; // Zoom mousewheel - Ctrl+Mousewheel for zoom in/out getGraphicalViewer ( ) . setProperty ( MouseWheelHandler . KeyGenerator . getKey ( SWT . MOD1 ) , MouseWheelZoomHandler . SINGLETON ) ; }


Input: Moves all <code > diagram< / code > nodes to upper left corner and shifting to right if neccessary to get rid of negative XY coordinates . [CODESPLIT] private void zeroBaseDiagram ( ReteGraph graph ) { Dimension dim = rootEditPart . getContentPane ( ) . getSize ( ) ; int minx = 0 , miny = 0 , maxx = 0 , x = dim . width ; final Iterator < BaseVertex > nodeIter = graph . getChildren ( ) . iterator ( ) ; while ( nodeIter . hasNext ( ) ) { Point loc = nodeIter . next ( ) . getLocation ( ) ; minx = Math . min ( loc . x , minx ) ; maxx = Math . max ( loc . x , maxx ) ; miny = Math . min ( loc . y , miny ) ; } int delta = ( x - ( maxx - minx + 20 ) ) / 2 ; minx = minx - ( delta ) ; final Iterator < BaseVertex > nodeIter2 = graph . getChildren ( ) . iterator ( ) ; while ( nodeIter2 . hasNext ( ) ) { final BaseVertex vertex = nodeIter2 . next ( ) ; Point loc = vertex . getLocation ( ) ; vertex . setLocation ( new Point ( loc . x - minx , loc . y - miny ) ) ; } }


Input: Draws graph . [CODESPLIT] public void drawGraph ( ReteGraph newGraph ) { LayerManager manager = ( LayerManager ) getGraphicalViewer ( ) . getEditPartRegistry ( ) . get ( LayerManager . ID ) ; ConnectionLayer connLayer = ( ConnectionLayer ) manager . getLayer ( LayerConstants . CONNECTION_LAYER ) ; // Lazy-init model initialization if ( getGraphicalViewer ( ) . getContents ( ) == null ) { getGraphicalViewer ( ) . setContents ( getModel ( ) ) ; } final boolean isNewDiagram = newGraph != null && newGraph != diagram ; if ( isNewDiagram ) { diagram . removeAll ( ) ; } // Update connection router according to new model size ConnectionRouter router ; if ( ( isNewDiagram && newGraph . getChildren ( ) . size ( ) < SIMPLE_ROUTER_MIN_NODES ) || ( ! isNewDiagram && getModel ( ) . getChildren ( ) . size ( ) < SIMPLE_ROUTER_MIN_NODES ) ) { router = new ShortestPathConnectionRouter ( ( IFigure ) rootEditPart . getContentPane ( ) . getChildren ( ) . get ( 0 ) ) ; } else { router = ConnectionRouter . NULL ; } connLayer . setConnectionRouter ( router ) ; if ( newGraph != null && newGraph != diagram ) { diagram . addAll ( newGraph . getChildren ( ) ) ; } }


Input: Tries to find a match for the provided breakpoint information from the list of registered breakpoints . For stepping and possibly other purposes it returns also a breakpoint for cases where exactly the same line was not found . [CODESPLIT] public DroolsLineBreakpoint getDroolsBreakpoint ( String source ) { if ( source == null ) { return null ; } Iterator < IBreakpoint > iterator = getBreakpoints ( ) . iterator ( ) ; while ( iterator . hasNext ( ) ) { IJavaBreakpoint element = ( IJavaBreakpoint ) iterator . next ( ) ; if ( element instanceof DroolsLineBreakpoint && ( ( DroolsLineBreakpoint ) element ) . getDialectName ( ) . equals ( "mvel" ) ) { DroolsLineBreakpoint l = ( DroolsLineBreakpoint ) element ; try { int matchLine = l . getLineNumber ( ) ; String matchSource = l . getRuleName ( ) ; if ( source . equals ( matchSource ) || l . getFileRuleMappings ( ) . containsKey ( source ) ) { return l ; } } catch ( CoreException e ) { logError ( e ) ; } } } return null ; }


Input: / * ( non - Javadoc ) [CODESPLIT] public void run ( IAction action ) { if ( selectedNode == null ) { return ; } IWorkbenchBrowserSupport browserSupport = Activator . getDefault ( ) . getWorkbench ( ) . getBrowserSupport ( ) ; try { URL consoleURL = new URL ( extractGuvnorConsoleUrl ( selectedNode . getGuvnorRepository ( ) . getLocation ( ) ) ) ; if ( browserSupport . isInternalWebBrowserAvailable ( ) ) { browserSupport . createBrowser ( null ) . openURL ( consoleURL ) ; } else { browserSupport . getExternalBrowser ( ) . openURL ( consoleURL ) ; } } catch ( Exception e ) { Activator . getDefault ( ) . displayError ( IStatus . ERROR , e . getMessage ( ) , e , true ) ; } }


Input: / * ( non - Javadoc ) [CODESPLIT] public void selectionChanged ( IAction action , ISelection selection ) { action . setEnabled ( false ) ; if ( ! ( selection instanceof IStructuredSelection ) ) { return ; } IStructuredSelection sel = ( IStructuredSelection ) selection ; if ( sel . size ( ) != 1 ) { return ; } if ( sel . getFirstElement ( ) instanceof TreeObject ) { if ( ( ( TreeObject ) sel . getFirstElement ( ) ) . getNodeType ( ) == TreeObject . Type . REPOSITORY ) { selectedNode = ( TreeObject ) sel . getFirstElement ( ) ; action . setEnabled ( true ) ; } } }


Input: Pass in a NLMapping item for display / edits . Changes will be applied to this object only if the user clicks OK . [CODESPLIT] public void setNLMappingItem ( DSLMappingEntry item ) { model = item ; setSection ( model . getSection ( ) ) ; exprText . setText ( model . getMappingKey ( ) == null ? "" : model . getMappingKey ( ) ) ; mappingText . setText ( model . getMappingValue ( ) == null ? "" : model . getMappingValue ( ) ) ; objText . setText ( model . getMetaData ( ) . getMetaData ( ) == null ? "" : model . getMetaData ( ) . getMetaData ( ) ) ; }


Input: Sets this baseline control elment description to the given href . [CODESPLIT] public void setHref ( String href ) { Assert . isNotNull ( href ) ; setChild ( root , "href" , encodeHref ( href ) , childNames , true ) ; //$NON-NLS-1$ }


Input: Return a boolean value indicating whether or not the server for this resource is DAV compliant . [CODESPLIT] public boolean canTalkDAV ( ) throws DAVException { IResponse response = null ; try { // Send an options request. response = davClient . options ( locator , newContext ( ) ) ; examineResponse ( response ) ; // Check for at least DAV level 1. String davHeader = response . getContext ( ) . getDAV ( ) ; return ! ( ( davHeader == null ) || ( davHeader . indexOf ( "1" ) == - 1 ) ) ; //$NON-NLS-1$ } catch ( IOException exception ) { throw new SystemException ( exception ) ; } finally { closeResponse ( response ) ; } }