input
stringlengths
10
828
output
stringlengths
5
107
public void add text styled text text control if text control null return active text control text control text control add listener swt activate text control listener text control add listener swt deactivate text control listener we really want a selection listener but it is not supported so we use a key listener and a mouse listener to know when selection changes may have occured text control add key listener key adapter text control add mouse listener mouse adapter
add a code text code control to the handler
public void remove text text text control if text control null return text control remove listener swt activate text control listener text control remove listener swt deactivate text control listener text control remove mouse listener mouse adapter text control remove key listener key adapter active text control null update actions enable state
removes a code text code control from the handler
private void update actions enable state text cut action update enabled state text copy action update enabled state text paste action update enabled state text select all action update enabled state text delete action update enabled state
update the enable state of the cut copy
public void set copy action iaction action if copy action action return if copy action null copy action remove property change listener copy action listener copy action action if copy action null copy action add property change listener copy action listener text copy action update enabled state
set the default code iaction code handler for the copy
public void set cut action iaction action if cut action action return if cut action null cut action remove property change listener cut action listener cut action action if cut action null cut action add property change listener cut action listener text cut action update enabled state
set the default code iaction code handler for the cut
public void set paste action iaction action if paste action action return if paste action null paste action remove property change listener paste action listener paste action action if paste action null paste action add property change listener paste action listener text paste action update enabled state
set the default code iaction code handler for the paste
public void set select all action iaction action if select all action action return if select all action null select all action remove property change listener select all action listener select all action action if select all action null select all action add property change listener select all action listener text select all action update enabled state
set the default code iaction code handler for the select all
public void set delete action iaction action if delete action action return if delete action null delete action remove property change listener delete action listener delete action action if delete action null delete action add property change listener delete action listener text delete action update enabled state
set the default code iaction code handler for the delete
public void dispose set cut action null set copy action null set paste action null set select all action null set delete action null
dispose of this action handler
private void create context menu menu manager mm new menu manager get view site get id get site get id mm set remove all when shown true menu cm mm create context menu m table viewer get table mm add menu listener new imenu listener public void menu about to show imenu manager manager dictionary view this fill context menu manager m table viewer get table set menu cm get site register context menu mm get site get selection provider
set up the popup menu
public void parse parse imedata parse traditional mapping
parse the reader and store data in the iimedata dao
private void search combo action performed start search string recent searches m search combo get items string search string m search combo get text if m search string equals non nls 1 return boolean found false for int i 0 i recent searches length found i if recent searches i equals search string found true if found if recent searches length max saved searches system arraycopy recent searches 0 recent searches 1 recent searches length 1 recent searches 0 search string m search combo set items recent searches else m search combo add search string 0
perform search and then keep track of recent searches
public int count entries in category string flash card mode object params new object flash card mode return jdbc template query for int select count from user stat where flashcard mode params
get number of tests for this mode
public date get first test data list l jdbc template query for list select min date tested from user stat map result map map l get 0 date date date result map get return date
get date of the first test
public date get last test data list l jdbc template query for list select max date tested from user stat map result map map l get 0 date date date result map get return date
get date of the last test
private void show progress dialog job job iworkbench site progress service siteps iworkbench site progress service get site get adapter iworkbench site progress service class siteps show in dialog get site get shell job
shows the progress dialog for the given job
private int get width hint composite control if f fixed width 0 gc gc new gc control gc set font control get font f fixed width gc get font metrics get average char width f width in chars f fixed width indent 2 gc dispose return f fixed width
returns the width hint for this label
private int get height hint composite control if f fixed height 0 gc gc new gc control gc set font control get font f fixed height gc get font metrics get height gc dispose return f fixed height
returns the height hint for this label
public string write out stat value tab delimited format stat value sv string buffer sb new string buffer sb append t sv is learned t sb append sv get correct streak t sb append sv get num correct t sb append sv get total tested t date last tested sv get last tested if last tested null last tested new date sb append zdtutils get date string last tested return sb to string
take a stat value and format it into a tab delimited string
public string write out note value tab delimited format note value nv string buffer sb new string buffer sb append t sb append nv get note null nv get note replace t tabs won t work since it s the delimiter so replace them by space sb append t sb append nv get image location null nv get image location sb append t sb append nv get sound location null nv get sound location return sb to string
take a note value and format it into a tab delimited string
public boolean validate long time system current time millis if validate characters simplified set error type error type simplified return false if validate characters traditional set error type error type traditional return false make sure simplified and traditional characters are the same length if simplified length traditional length set error message mismatched character lengths return false if validate pinyin set error type error type pinyin return false if validate definition set error type error type definition return false m logger debug time to validate system current time millis time return true
validate the entry
public string get error message return this error message null this error message
retrieves the error message
public error type get error type return this error type
returns an error type which is what portion of the entry failed
public void set normal mode activator get default get preference store set value izdtconstants ime mode false
i want ime mode to be off by default
private base font get pinyin base font font factory register directories font font font factory get font arial base font identity h base font not embedded non nls 1 if font get base font null m logger info couldn t find a good pinyin font non nls 1 return font get base font
tries to create a pinyin base font out of a few possibilites
private combo create inequality combo composite parent combo combo new combo parent swt read only combo add izdtconstants gt or equal combo add izdtconstants lt or equal combo set text izdtconstants gt or equal return combo
create read only combobox that has greater than less than items
private string get filter rules string buffer sb new string buffer for filter rule state state filter rule states sb append state get filter rule return sb to string
create our filter string that will represent how the rules
public void enable widget state string inequality check box set selection true combo set text inequality text set enabled true combo set enabled true
puts the filter rule widgets in an enabled state
protected string get error message return error message
if filter rule is not valid then use this method
public boolean is valid if check box get selection try string s text get text new integer s catch number format exception e return false return true
checks if the filter rules text box contains a valid
private category editor open character editor final string category category editor editor null try iworkbench page page platform ui get workbench get active workbench window get active page editor category editor page open editor new category editor input category category editor id editor catch part init exception e m logger fatal error occured trying to open editor e get message non nls 1 return editor
opens the character editor for the category and returns a reference to it
public void start string categories int num characters if is restarting previous session m model initialize categories num characters m view enable back link false m view reset ui if m model get cards to test 0 pick and display entry m view focus answer text m model record session state m view else display score flash card session handler delete session file disable next button on last card
called when user presses the start button
private void disable next button on last card if is at last card m view enable forward link false
makes sure we disable the next button s when
public void add missed entry to session int entry id try m logger debug writing out to session file entry id non nls 1 writer write entry id n non nls 1 catch ioexception e m logger warn unable to write to flashcard session file entry id non nls 1
records entries missed by the user in the current session
public entry value get random entry if there are non missed words then choose between them first list entry value non missed entries new array list entry value m entry values non missed entries remove all m missed words if non missed entries size 0 int random 0 if is random random int math random non missed entries size m latest entry non missed entries get random else only missed words left so grab the first m latest entry m entry values get 0 return m latest entry
picks a random entry value to return
public void correct answer m correct answers
increment correct answers by one
public void clear m entry values clear
clears any entries in the model
private void create toolbar itool bar manager mgr get view site get action bars get tool bar manager mgr add move up action mgr add move down action
add actions to view toolbar
public int get starting index return m starting index
returns the starting index for a flashcard session
public void resize view area this causes wrap to take effect main composite layout true true int vertical scroll bar width scrolled composite get vertical bar get size x int width main composite get size x vertical scroll bar width point p main composite compute size width swt default scrolled composite set min size 0 p y
enables us to show scrollbars or wrap text if necessary
private void disable next button on last card if is at last card m view enable forward link false m view enable next button false m view show summary link
makes sure we disable the next button s when
private void create context menu menu manager mm new menu manager get view site get id get site get id mm set remove all when shown true menu cm mm create context menu m tree viewer get tree mm add menu listener new imenu listener public void menu about to show imenu manager manager category view this fill context menu manager m tree viewer get tree set menu cm get site register context menu mm get site get selection provider
set up the popup menu
private boolean button is enabled int button index if button index 0 button index answer btn list length return answer btn list button index is enabled else return true
figure out if the button at the button index is enabled or not
private void fill context menu imenu manager menu mgr menu mgr add paste action menu mgr add new separator menu mgr add import action menu mgr add export action menu mgr add new separator menu mgr add new category action menu mgr add edit category action menu mgr add delete action menu mgr add new separator menu mgr add move up action menu mgr add move down action menu mgr add new group marker iworkbench action constants mb additions
add the actions
public void set selected button int btn index for int i 0 i answer btn list length i if i btn index answer btn list btn index set selection true answer btn list btn index force focus else answer btn list i set selection false
set selected button and deselect the rest
private int prompt overwrite file message box mb new message box get site get workbench window get shell swt icon warning swt yes swt no mb set text messages get category view category file already exists non nls 1 mb set message messages get category view category file already exists message non nls 1 return mb open
prompts the user if they would like to overwrite an existing file
private void add entries to category string text category category open editor for this category try iworkbench page page platform ui get workbench get active workbench window get active page category editor editor category editor page open editor new category editor input category get name category editor id editor find compounds find compounds new find compounds find compounds parse text new add chars to editor editor 0 catch part init exception e e print stack trace
adds the dropped in text to a category
private int show export successful string file name string category message box mb new message box m view get site get workbench window get shell swt icon information mb set text messages get category view controller export successfull non nls 1 mb set message messages get category view controller export successfull to category file name non nls 1 non nls 2 return mb open
shows a dialog indicating to user that the export operation was successful
public void start string categories int num characters if is restarting previous session m model initialize categories num characters m view enable back link false m view reset ui m strategy init potential choices if m model get cards to test 0 pick and display entry m view resize view area else display score flash card session handler delete session file disable next button on last card
called when user presses the start button
private int show backup successful string file name message box mb new message box platform ui get workbench get display get active shell swt icon information mb set text messages get backup action backup successfull text non nls 1 mb set message messages get backup action backup successfull message file name non nls 1 return mb open
shows a dialog indicating to user that the backup operation was successful
private int prompt overwrite file message box mb new message box platform ui get workbench get display get active shell swt icon warning swt yes swt no mb set text messages get backup action file already exist text non nls 1 mb set message messages get backup action file already exist message non nls 1 return mb open
prompts the user if they would like to overwrite an existing file
private string get element delmiter for combo string delimiter if delimiter equals t non nls 1 delimiter tab return delimiter
get the element delimiter suitable for display in the combo
private string limit string str int max 80 if str length max return str substring 0 max 3 return str
shortens a string if too long
private string get definition delimiter for combo string delimiter if delimiter equals non nls 1 delimiter none return delimiter
get the definition delimiter suitable for display in the combo
private string get definition delimiter from combo string def delimiter definition delimiter combo get text if def delimiter equals none def delimiter non nls 1 return def delimiter
get the definition delimiter suitable for parsing
public void unlock locked false
unlocks the sliding drawer so that touch events are processed
public void lock locked true
locks the sliding drawer so that touch events are ignores
public void set allow long press boolean allow long press this allow long press allow long press
set true to allow long press events to be triggered usually checked by
private connection get connection string driver string url string username string password throws exception class for name driver connection con driver manager get connection url username password return con
returns the database connection for the given db url
private string get sql string table name return select from table name where 1 2
returns the meta data sql for the given table
public string get short type return string utils get short name type
returns the short java type name for the associated database type
public string get title case name return string utils remove under scores name
returns the table name in title case
private void close quitely connection con if con null try con close catch sqlexception e
closes the connection quietly
public string get camel case name return string utils camel case name
returns the attribute name in came case
public string find message final big integer cipher big integer entry cipher table entry found for cipher table entry e table entry cipher multiply e inverse entry mod n found table look up entry entry if found null we found the message return new string e index multiply found index to byte array return null
tries to break the rsa cipher by exploiting the fact that short messages
public void init iworkbench workbench istructured selection selection this workbench workbench this selection selection set window title agent editor plugin instance get string ui wizard label set default page image descriptor extended image registry instance get image descriptor agent editor plugin instance get image full wizban new agents
this just records the information
protected eobject create initial model eclass e class eclass agents package get eclassifier initial object creation page get initial object name eobject root object agents factory create e class return root object
create a new model
protected string get label string type name try return agent edit plugin instance get string ui type name type catch missing resource exception mre agent editor plugin instance log mre return type name
returns the label for the specified type name
protected void handle activate recompute the read only state if editing domain get resource to read only map null editing domain get resource to read only map clear refresh any actions that may become enabled or disabled set selection get selection if removed resources is empty if handle dirty conflict get site get page close editor agents editor this false else removed resources clear changed resources clear saved resources clear else if changed resources is empty changed resources remove all saved resources handle changed resources changed resources clear saved resources clear
handles activation of the editor or its associated views
public diagnostic analyze resource problems resource resource exception exception if resource get errors is empty resource get warnings is empty basic diagnostic basic diagnostic new basic diagnostic diagnostic error unibo agent metamodel editor 0 get string ui create model error message resource get uri new object exception null object resource exception basic diagnostic merge ecore util compute diagnostic resource true return basic diagnostic else if exception null return new basic diagnostic diagnostic error unibo agent metamodel editor 0 get string ui create model error message resource get uri new object exception else return diagnostic ok instance
returns a diagnostic describing the errors and warnings listed in the resource
public adapter create application system adapter return null
creates a new adapter for an object of class
public adapter create proto agent adapter return null
creates a new adapter for an object of class
public adapter create agent action adapter return null
creates a new adapter for an object of class
public adapter create agent instance adapter return null
creates a new adapter for an object of class
public adapter create artifact instance adapter return null
creates a new adapter for an object of class
public adapter create artifact operation adapter return null
creates a new adapter for an object of class
public adapter create operation with input adapter return null
creates a new adapter for an object of class
public adapter create operation with output adapter return null
creates a new adapter for an object of class
public adapter create operation with ioadapter return null
creates a new adapter for an object of class
public adapter create operation no ioadapter return null
creates a new adapter for an object of class
public adapter create required port adapter return null
creates a new adapter for an object of class
public adapter create provided port adapter return null
creates a new adapter for an object of class
public adapter create connector adapter return null
creates a new adapter for an object of class
public iproperty sheet page get property sheet page if property sheet page null property sheet page new extended property sheet page editing domain override public void set selection to viewer list selection agents editor this set selection to viewer selection agents editor this set focus override public void set action bars iaction bars action bars super set action bars action bars get action bar contributor share global actions this action bars property sheet page set property source provider new adapter factory content provider adapter factory return property sheet page
this accesses a cached version of the property sheet
public adapter create component system adapter return null
creates a new adapter for an object of class
public adapter create comp instance adapter return null
creates a new adapter for an object of class
public adapter create support adapter return null
creates a new adapter for an object of class
public adapter create signal adapter return null
creates a new adapter for an object of class
public adapter create request adapter return null
creates a new adapter for an object of class
public adapter create invitation adapter return null
creates a new adapter for an object of class
public adapter create with reply adapter return null
creates a new adapter for an object of class
public adapter create no reply adapter return null
creates a new adapter for an object of class
protected void set fixture container fixture this fixture fixture
sets the fixture for this container test case
protected container get fixture return fixture
returns the fixture for this container test case
protected attribute get fixture return fixture
returns the fixture for this attribute test case
protected void set fixture connector fixture this fixture fixture
sets the fixture for this connector test case
protected connector get fixture return fixture
returns the fixture for this connector test case
protected void set fixture component fixture this fixture fixture
sets the fixture for this component test case
protected component get fixture return fixture
returns the fixture for this component test case
protected void set fixture support fixture this fixture fixture
sets the fixture for this support test case