List of usage examples for java.lang Character isLetter
public static boolean isLetter(int codePoint)
From source file:edu.stanford.muse.util.Util.java
public static int nLetterChars(String s) { int count = 0; for (char c : s.toCharArray()) if (Character.isLetter(c)) count++;//from w w w . j a v a 2 s.c om return count; }
From source file:LayoutExample.java
/** * Sets an attachment to the edge of a widget using the information in the * table.// w ww . j a va 2 s.c om */ FormAttachment setAttachment(String attachment) { String control, align; int position, offset; int comma = attachment.indexOf(','); char first = attachment.charAt(0); if (Character.isLetter(first)) { /* Case where there is a control */ control = attachment.substring(0, comma); int i = 0; while (i < control.length() && !Character.isDigit(control.charAt(i))) { i++; } String end = control.substring(i); int index = new Integer(end).intValue(); Control attachControl = children[index]; int colon = attachment.indexOf(':'); try { offset = new Integer(attachment.substring(comma + 1, colon)).intValue(); } catch (NumberFormatException e) { offset = 0; } align = attachment.substring(colon + 1); return new FormAttachment(attachControl, offset, alignmentConstant(align)); } else { /* Case where there is a position */ try { position = new Integer(attachment.substring(0, comma)).intValue(); } catch (NumberFormatException e) { position = 0; } try { offset = new Integer(attachment.substring(comma + 1)).intValue(); } catch (NumberFormatException e) { offset = 0; } return new FormAttachment(position, offset); } }
From source file:org.dasein.cloud.aws.platform.RDS.java
private String toInstanceName(String rawName, DatabaseEngine forEngine) { StringBuilder str = new StringBuilder(); if (rawName.length() < 1) { return "x"; }// w w w . j a va2 s . c o m if (isMySQL(forEngine) || isOracle(forEngine)) { if (!Character.isLetter(rawName.charAt(0))) { rawName = "db" + rawName; } } else { if (!Character.isLetter(rawName.charAt(0)) && rawName.charAt(0) != '_') { rawName = "db" + rawName; } } char last = '\0'; for (int i = 0; i < rawName.length(); i++) { char c = rawName.charAt(i); if (Character.isLetterOrDigit(c)) { str.append(c); } else if (isPostgres(forEngine) && c == '_') { str.append(c); } last = c; } rawName = str.toString(); int maxLength = 64; if (isOracle(forEngine)) { maxLength = 8; } else if (isPostgres(forEngine)) { maxLength = 63; } if (rawName.length() > maxLength) { rawName = rawName.substring(0, maxLength); } if (rawName.length() < 1) { return "x"; } return rawName; }
From source file:org.dasein.cloud.aws.platform.RDS.java
private String toIdentifier(String rawName) { StringBuilder str = new StringBuilder(); if (rawName.length() < 1) { return "x"; }/* ww w .jav a 2 s. c o m*/ if (!Character.isLetter(rawName.charAt(0))) { rawName = "db-" + rawName; } char last = '\0'; for (int i = 0; i < rawName.length(); i++) { char c = rawName.charAt(i); if (Character.isLetterOrDigit(c)) { str.append(c); } if (c == '-' && last != '-') { str.append(c); } last = c; } rawName = str.toString(); if (rawName.length() > 63) { rawName = rawName.substring(0, 63); } while (rawName.charAt(rawName.length() - 1) == '-') { rawName = rawName.substring(0, rawName.length() - 1); } if (rawName.length() < 1) { return "x"; } return rawName; }
From source file:edu.stanford.muse.util.Util.java
/** * check if part occurs only as a complete word in full. complete word => * char before and after the answer is not a letter. * full, part should already be space canonicalized in case part can have * spaces//from www . j a v a 2 s . c om * note that part could occur multiple times -- this method returns true if * EVERY occurrence of answer is a word. * e.g. for params ("americans in america", "america"), this method returns * false */ public static boolean occursOnlyAsWholeWord(String full, String part) { full = full.toLowerCase(); part = part.toLowerCase(); // part might be a partial match, e.g. india matches against "indians" // in the full. disallow the match // if the char just before or just after the match is a letter. (it // should be space or some delim) int idx = full.indexOf(part); // part is already space normalized... if (idx < 0) return false; while (idx >= 0) { // idx is the position that has matched // see if the place before the match is a char if (idx > 0) if (Character.isLetter(full.charAt(idx - 1))) return false; // see if the place after the match is a char int end_idx = idx + part.length() - 1; if (end_idx + 1 < full.length()) if (Character.isLetter(full.charAt(end_idx + 1))) return false; // ok, so the match at idx succeeded. // look for more matches in this string // end_idx+1 is the delim for the prev. occurrence of part, so now // look for the answer again starting at end_idx+2 if (end_idx + 2 < full.length()) full = full.substring(end_idx + 2); else break; // we've reached the end idx = full.indexOf(part); // part is already lower case and space // normalized... } return true; }
From source file:ca.uhn.fhir.rest.client.GenericClient.java
private static String validateAndEscapeConditionalUrl(String theSearchUrl) { Validate.notBlank(theSearchUrl, "Conditional URL can not be blank/null"); StringBuilder b = new StringBuilder(); boolean haveHadQuestionMark = false; for (int i = 0; i < theSearchUrl.length(); i++) { char nextChar = theSearchUrl.charAt(i); if (!haveHadQuestionMark) { if (nextChar == '?') { haveHadQuestionMark = true; } else if (!Character.isLetter(nextChar)) { throw new IllegalArgumentException( "Conditional URL must be in the format \"[ResourceType]?[Params]\" and must not have a base URL - Found: " + theSearchUrl); }/* w ww .j a va 2 s .c o m*/ b.append(nextChar); } else { switch (nextChar) { case '|': case '?': case '$': case ':': b.append(UrlUtil.escape(Character.toString(nextChar))); break; default: b.append(nextChar); break; } } } return b.toString(); }
From source file:rechi.xml.MainWindow.java
/** * XML suggestions while editing a textbox. * * @param textboxType/*from www.ja v a 2s . com*/ * Type of the textbox the suggestions have been asked from. * @param textbox * Textbox the suggestions have been asked from. */ private void doXmlSuggestions(FileType textboxType, final EnhancedStyledText textbox) { Cursor defaultCursor = _shlXmlOperations.getCursor(); _shlXmlOperations.setCursor(_cursorWait); try { String text = textbox.getText(); final Point selection = textbox.getSelection(); if (selection.x > 0 && text.charAt(selection.x - 1) == '>') { int k = -1; for (int i = selection.x - 2; i >= 0; i--) if (text.charAt(i) == '<') { if (i + 1 < text.length()) if (text.charAt(i + 1) == '/') // no suggestion for end tags break; k = i; break; } if (k != -1) SwtGeneral.insertIntoTextboxAndMoveCaretAtFront(textbox, String.format("</%s>", text.substring(k + 1, selection.x - 1).split(" ")[0])); } else if (textboxType != FileType.XML) { if (textXml.getText().trim().length() == 0) return; int k = -1; for (int i = selection.x - 1; i >= 0; i--) { char c = text.charAt(i); if (!Character.isLetter(c) && !Character.isDigit(c) && "-_.".indexOf(c) == -1) { k = i; break; } } final int prefixBegin = ++k; Xml doc = new Xml(); if (!doc.load(textXml.getText())) { printError(FileType.XML, doc.getLastError()); lblStatus.setText(printErrorTime()); return; } ArrayList<String> allEntities = doc.getAllAttributes(text.substring(k, selection.x)); Boolean getTags = true; if (prefixBegin > 0) if (text.charAt(prefixBegin - 1) == '@') getTags = false; if (getTags) { ArrayList<String> allTags; switch (textboxType) { case XPATH: allTags = doc.getAllTagsWithExtra(text.substring(k, selection.x), _xpathTags, "xpath:"); break; case XSLT: allTags = doc.getAllTagsWithExtra(text.substring(k, selection.x), _xsltTags, "xsl:"); break; case XQUERY: allTags = doc.getAllTagsWithExtra(text.substring(k, selection.x), _xqueryTags, "xq:"); break; default: allTags = doc.getAllTags(text.substring(k, selection.x), null, null); break; } allTags.addAll(allEntities); allEntities = allTags; } int allCount = allEntities.size(); if (allCount == 0) return; if (allCount == 1) insertXmlEntityAsSuggested(allEntities.get(0), textbox, selection, prefixBegin); else { Menu menu = new Menu(textbox); for (int i = 0; i < allCount; i++) { final MenuItem mi = new MenuItem(menu, SWT.NONE); mi.setText(allEntities.get(i)); mi.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent arg0) { insertXmlEntityAsSuggested(mi.getText(), textbox, selection, prefixBegin); } @Override public void widgetDefaultSelected(SelectionEvent arg0) { } }); } menu.setLocation( SwtGeneral.translate(textbox.toDisplay(textbox.getCaret().getLocation()), 3, 2)); menu.setVisible(true); } } } finally { setFocus(_lastFocusedFileType); _shlXmlOperations.setCursor(defaultCursor); } }
From source file:de.innovationgate.utils.WGUtils.java
/** * Removes all characters from a string that are not legal as JavaScript identifier * Interprets an underscore as the next character being forced to upper case. * The upper case rules, that are enforced when param enforceUpperCaseRules is true are: * <ul>/*from ww w . ja v a2 s. c om*/ * <li>Non-alphabetic characters at the beginning are stripped off * <li>The first alphabetic character is uppercase * <li>An alphabetic character preceded by an underscore (which is removed) will also be uppercase * <li>All other alphabetic characters are lowercase * </ul> * @param txt The string * @param enforceUpperCaseRules If true enforces the upper case rules described above, meant to transfor, a lowercase design reference to an Object Identifier with cases in an reversible way. * In that case the created string can be reverted to the original by using {@link #fromJSIdentifier(String)}. * @return The string converted to a valid JS identifier */ public static String toJSIdentifier(String txt, boolean enforceUpperCaseRules) { StringBuilder out = new StringBuilder(); // Flags for enforceUpperCaseRules boolean upperCase = true; // First character is uppercase boolean startCharacter = true; for (int i = 0; i < txt.length(); i++) { Character c = txt.charAt(i); if (enforceUpperCaseRules) { // Must start with a letter if (startCharacter && !Character.isLetter(c)) { continue; } // Convert letters to uppercase, depending on flag if (Character.isLetter(c)) { if (upperCase) { c = Character.toUpperCase(c); upperCase = false; } else { c = Character.toLowerCase(c); } } // Trigger the next letter to be uppercase else if (c == '_') { upperCase = true; continue; } } Pattern p = (startCharacter ? JS_IDENTIFIER_FIRSTCHARS : JS_IDENTIFIER_CHARS); if (p.matcher(c.toString()).matches()) { out.append(c); startCharacter = false; } else if (enforceUpperCaseRules) { throw new IllegalArgumentException( "This string cannot be transformed to a reversible JS identifier because it contains invalid characters: " + txt); } } return out.toString(); }
From source file:edu.ku.brc.ui.UIHelper.java
/** * @param str// w w w . j a v a 2 s .c o m * @return */ public static boolean isAllCaps(final String str) { for (int i = 0; i < str.length(); i++) { char ch = str.charAt(i); if (Character.isLetter(ch) && Character.isLowerCase(ch)) { return false; } } return true; }
From source file:org.larz.dom4.editor.MonsterDetailsPage.java
public void createContents(final Composite parent) { TableWrapLayout layout = new TableWrapLayout(); layout.topMargin = 5;/*w w w .j ava2 s. c o m*/ layout.leftMargin = 5; layout.rightMargin = 2; layout.bottomMargin = 2; parent.setLayout(layout); final FormToolkit toolkit = mform.getToolkit(); Section s1 = toolkit.createSection(parent, Section.DESCRIPTION | Section.TITLE_BAR); s1.marginWidth = 10; s1.setText(Messages.getString("MonsterDetailsSection.name")); TableWrapData td = new TableWrapData(TableWrapData.FILL, TableWrapData.TOP); td.grabHorizontal = true; s1.setLayoutData(td); final Composite client = toolkit.createComposite(parent); GridLayout glayout = new GridLayout(); glayout.marginWidth = glayout.marginHeight = 0; glayout.numColumns = 2; glayout.makeColumnsEqualWidth = true; client.setLayout(glayout); final Composite nameComp = toolkit.createComposite(client); glayout = new GridLayout(3, false); glayout.marginHeight = 0; glayout.verticalSpacing = 2; glayout.marginWidth = 0; nameComp.setLayout(glayout); GridData gd = new GridData(SWT.DEFAULT, SWT.FILL, false, false); gd.horizontalSpan = 2; nameComp.setLayoutData(gd); nameCheck = toolkit.createButton(nameComp, Messages.getString("MonsterDetailsSection.mod.name"), SWT.CHECK); //$NON-NLS-1$ setToolTip(nameCheck, HelpTextHelper.getText(HelpTextHelper.MONSTER_CATEGORY, "name")); name = toolkit.createText(nameComp, null, SWT.SINGLE | SWT.BORDER); //$NON-NLS-1$ name.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { setMonstername(doc, name.getText()); } }); name.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.character == '\r') { setMonstername(doc, name.getText()); } } }); gd = new GridData(SWT.FILL, SWT.FILL, false, false); gd.widthHint = 500; gd.horizontalSpan = 2; name.setLayoutData(gd); nameCheck.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (nameCheck.getSelection()) { addInst1(Inst.NAME, doc, ""); name.setEnabled(true); name.setText(""); nameCheck.setFont(boldFont); } else { removeInst(Inst.NAME, doc); name.setEnabled(false); if (input instanceof SelectMonsterById || input instanceof SelectMonsterByName) { String monsterName = getSelectMonstername((Monster) input); name.setText(monsterName != null ? monsterName : ""); } else { name.setText(""); } nameCheck.setFont(normalFont); } } }); fixedNameCheck = toolkit.createButton(nameComp, Messages.getString("MonsterDetailsSection.mod.fixedname"), //$NON-NLS-1$ SWT.CHECK); setToolTip(fixedNameCheck, HelpTextHelper.getText(HelpTextHelper.MONSTER_CATEGORY, "fixedname")); fixedName = toolkit.createText(nameComp, null, SWT.SINGLE | SWT.BORDER); //$NON-NLS-1$ fixedName.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { setInst1(Inst.FIXEDNAME, doc, fixedName.getText()); } }); fixedName.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.character == '\r') { setInst1(Inst.FIXEDNAME, doc, fixedName.getText()); } } }); fixedName.setEnabled(false); gd = new GridData(SWT.FILL, SWT.FILL, false, false); gd.widthHint = 500; gd.horizontalSpan = 2; fixedName.setLayoutData(gd); fixedNameCheck.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (fixedNameCheck.getSelection()) { addInst1(Inst.FIXEDNAME, doc, ""); fixedName.setEnabled(true); fixedName.setText(""); fixedNameCheck.setFont(boldFont); } else { removeInst(Inst.FIXEDNAME, doc); fixedName.setEnabled(false); fixedName.setText(""); fixedNameCheck.setFont(normalFont); } } }); descCheck = toolkit.createButton(nameComp, Messages.getString("MonsterDetailsSection.mod.descr"), SWT.CHECK); setToolTip(descCheck, HelpTextHelper.getText(HelpTextHelper.MONSTER_CATEGORY, "descr")); descr = toolkit.createText(nameComp, null, SWT.MULTI | SWT.BORDER | SWT.WRAP); //$NON-NLS-1$ descr.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { setMonsterdescr(doc, descr.getText()); } }); descr.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.character == '\r') { setMonsterdescr(doc, descr.getText()); } } }); gd = new GridData(SWT.FILL, SWT.FILL, false, false); gd.widthHint = 500; gd.horizontalSpan = 2; descr.setLayoutData(gd); descr.addListener(SWT.Modify, new Listener() { @Override public void handleEvent(Event event) { int currentHeight = descr.getSize().y; int preferredHeight = descr.computeSize(500, SWT.DEFAULT).y; if (currentHeight < preferredHeight || currentHeight > 1.5 * preferredHeight) { GridData data = (GridData) descr.getLayoutData(); data.heightHint = preferredHeight; client.pack(); } } }); descr.setEnabled(false); descr.setBackground(toolkit.getColors().getInactiveBackground()); descCheck.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (descCheck.getSelection()) { addInst1(Inst.DESCR, doc, ""); descr.setEnabled(true); descr.setBackground(toolkit.getColors().getBackground()); descr.setText(getSelectMonsterdescr((Monster) input)); descCheck.setFont(boldFont); } else { removeInst(Inst.DESCR, doc); descr.setEnabled(false); descr.setBackground(toolkit.getColors().getInactiveBackground()); descr.setText(getSelectMonsterdescr((Monster) input)); descCheck.setFont(normalFont); } } }); Composite spriteComp = toolkit.createComposite(nameComp); spriteComp.setLayout(new GridLayout(2, false)); gd = new GridData(); gd.horizontalSpan = 3; spriteComp.setLayoutData(gd); sprite1Label = new Label(spriteComp, SWT.NONE); GridData gridData = new GridData(SWT.DEFAULT, SWT.BOTTOM, false, false); sprite1Label.setLayoutData(gridData); sprite2Label = new Label(spriteComp, SWT.NONE); gridData = new GridData(SWT.DEFAULT, SWT.BOTTOM, false, false); sprite2Label.setLayoutData(gridData); spr1Check = toolkit.createButton(nameComp, Messages.getString("MonsterDetailsSection.mod.spr1"), SWT.CHECK); setToolTip(spr1Check, HelpTextHelper.getText(HelpTextHelper.MONSTER_CATEGORY, "spr1")); spr1 = toolkit.createText(nameComp, null, SWT.BORDER); //$NON-NLS-1$ spr1.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { setInst1(Inst.SPR1, doc, spr1.getText()); sprite1Label.setImage(getSprite(spr1.getText())); update(); } }); spr1.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.character == '\r') { setInst1(Inst.SPR1, doc, spr1.getText()); sprite1Label.setImage(getSprite(spr1.getText())); update(); } } }); spr1.setLayoutData(new GridData(450, SWT.DEFAULT)); spr1Browse = toolkit.createButton(nameComp, "Browse...", SWT.PUSH); spr1Browse.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { FileDialog dialog = new FileDialog(parent.getShell(), SWT.OPEN); dialog.setFilterExtensions(new String[] { "*.tga", "*.rgb", "*.sgi" }); if (dialog.open() != null) { String targetpath = new File(dialog.getFilterPath() + File.separator + dialog.getFileName()) .getAbsolutePath(); String basepath = ((DmXtextEditor) doc).getPath(); String relativepath = ResourceUtils.getRelativePath(targetpath, basepath, "/"); spr1.setText("./" + relativepath); setInst1(Inst.SPR1, doc, spr1.getText()); sprite1Label.setImage(getSprite(spr1.getText())); update(); } } }); spr1Browse.setEnabled(false); spr1Check.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (spr1Check.getSelection()) { addInst1(Inst.SPR1, doc, ""); spr1.setEnabled(true); spr1.setText(""); spr1Check.setFont(boldFont); spr1Browse.setEnabled(true); } else { removeInst(Inst.SPR1, doc); spr1.setEnabled(false); spr1.setText(""); spr1Check.setFont(normalFont); spr1Browse.setEnabled(false); } } }); spr2Check = toolkit.createButton(nameComp, Messages.getString("MonsterDetailsSection.mod.spr2"), SWT.CHECK); setToolTip(spr2Check, HelpTextHelper.getText(HelpTextHelper.MONSTER_CATEGORY, "spr2")); spr2 = toolkit.createText(nameComp, null, SWT.BORDER); //$NON-NLS-1$ spr2.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { setInst1(Inst.SPR2, doc, spr2.getText()); sprite2Label.setImage(getSprite(spr2.getText())); update(); } }); spr2.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.character == '\r') { setInst1(Inst.SPR2, doc, spr2.getText()); sprite2Label.setImage(getSprite(spr2.getText())); update(); } } }); spr2.setLayoutData(new GridData(450, SWT.DEFAULT)); spr2Browse = toolkit.createButton(nameComp, "Browse...", SWT.PUSH); spr2Browse.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { FileDialog dialog = new FileDialog(parent.getShell(), SWT.OPEN); dialog.setFilterExtensions(new String[] { "*.tga", "*.rgb", "*.sgi" }); if (dialog.open() != null) { String targetpath = new File(dialog.getFilterPath() + File.separator + dialog.getFileName()) .getAbsolutePath(); String basepath = ((DmXtextEditor) doc).getPath(); String relativepath = ResourceUtils.getRelativePath(targetpath, basepath, "/"); spr2.setText("./" + relativepath); setInst1(Inst.SPR2, doc, spr2.getText()); sprite2Label.setImage(getSprite(spr2.getText())); update(); } } }); spr2Browse.setEnabled(false); spr2Check.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (spr2Check.getSelection()) { addInst1(Inst.SPR2, doc, ""); spr2.setEnabled(true); spr2.setText(""); spr2Browse.setEnabled(true); spr2Check.setFont(boldFont); } else { removeInst(Inst.SPR2, doc); spr2.setEnabled(false); spr2.setText(""); spr2Browse.setEnabled(false); spr2Check.setFont(normalFont); } } }); specialLookCheck = toolkit.createButton(nameComp, Messages.getString("MonsterDetailsSection.mod.speciallook"), SWT.CHECK); //$NON-NLS-1$ setToolTip(specialLookCheck, HelpTextHelper.getText(HelpTextHelper.MONSTER_CATEGORY, "speciallook")); specialLook = toolkit.createText(nameComp, null, SWT.SINGLE | SWT.BORDER); //$NON-NLS-1$ specialLook.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { setInst2(Inst.SPECIALLOOK, doc, specialLook.getText()); } }); specialLook.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.character == '\r') { setInst2(Inst.SPECIALLOOK, doc, specialLook.getText()); } } }); specialLook.setEnabled(false); gd = new GridData(SWT.BEGINNING, SWT.FILL, false, false); gd.widthHint = DEFAULT_VALUE_WIDTH; specialLook.setLayoutData(gd); specialLookCheck.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (specialLookCheck.getSelection()) { addInst2(Inst.SPECIALLOOK, doc, "1"); specialLook.setEnabled(true); specialLook.setText("1"); specialLookCheck.setFont(boldFont); } else { removeInst(Inst.SPECIALLOOK, doc); specialLook.setEnabled(false); specialLook.setText(""); specialLookCheck.setFont(normalFont); } } }); Composite leftColumn = null; Composite rightColumn = null; boolean isRight = false; for (final Map.Entry<Inst, InstFields> fields : instMap.entrySet()) { final Inst key = fields.getKey(); if (key.equals(Inst.HP) || key.equals(Inst.CLEAR) || key.equals(Inst.SLOWREC) || key.equals(Inst.GCOST) || key.equals(Inst.WEAPON1) || key.equals(Inst.PATHCOST) || key.equals(Inst.FEMALE) || key.equals(Inst.IMMOBILE) || key.equals(Inst.STEALTHY) || key.equals(Inst.SINGLEBATTLE) || key.equals(Inst.STARTAGE) || key.equals(Inst.PIERCERES) || key.equals(Inst.HEAT) || key.equals(Inst.CHAOSPOWER) || key.equals(Inst.SPRINGPOWER) || key.equals(Inst.AMBIDEXTROUS) || key.equals(Inst.CASTLEDEF) || key.equals(Inst.FIRSTSHAPE) || key.equals(Inst.REANIMATOR) || key.equals(Inst.NAMETYPE) || key.equals(Inst.ITEMSLOTS) || key.equals(Inst.NOLEADER) || key.equals(Inst.NOMAGICLEADER) || key.equals(Inst.NOUNDEADLEADER) || key.equals(Inst.INSPIRATIONAL) || key.equals(Inst.MAGICSKILL1) || key.equals(Inst.RESEARCHBONUS) || key.equals(Inst.FIRERANGE) || key.equals(Inst.GEMPROD1) || key.equals(Inst.BONUSSPELLS)) { final Section expandable = toolkit.createSection(client, ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR); switch (key) { case HP: expandable.setText(Messages.getString("MonsterDetailsSection.mod.section.basic")); break; case CLEAR: expandable.setText(Messages.getString("MonsterDetailsSection.mod.section.clearing")); break; case SLOWREC: expandable.setText(Messages.getString("MonsterDetailsSection.mod.section.recruit")); break; case GCOST: expandable.setText(Messages.getString("MonsterDetailsSection.mod.section.gcost")); break; case WEAPON1: expandable.setText(Messages.getString("MonsterDetailsSection.mod.section.weapon")); break; case PATHCOST: expandable.setText(Messages.getString("MonsterDetailsSection.mod.section.pretender")); break; case FEMALE: expandable.setText(Messages.getString("MonsterDetailsSection.mod.section.type")); break; case IMMOBILE: expandable.setText(Messages.getString("MonsterDetailsSection.mod.section.movement")); break; case STEALTHY: expandable.setText(Messages.getString("MonsterDetailsSection.mod.section.stealth")); break; case SINGLEBATTLE: expandable.setText(Messages.getString("MonsterDetailsSection.mod.section.desertion")); break; case STARTAGE: expandable.setText(Messages.getString("MonsterDetailsSection.mod.section.age")); break; case PIERCERES: expandable.setText(Messages.getString("MonsterDetailsSection.mod.section.damageReduction")); break; case HEAT: expandable.setText(Messages.getString("MonsterDetailsSection.mod.section.auras")); break; case CHAOSPOWER: expandable.setText(Messages.getString("MonsterDetailsSection.mod.section.elemental")); break; case SPRINGPOWER: expandable.setText(Messages.getString("MonsterDetailsSection.mod.section.seasonal")); break; case AMBIDEXTROUS: expandable.setText(Messages.getString("MonsterDetailsSection.mod.section.combat")); break; case CASTLEDEF: expandable.setText(Messages.getString("MonsterDetailsSection.mod.section.noncombat")); break; case ITEMSLOTS: expandable.setText(Messages.getString("MonsterDetailsSection.mod.section.items")); break; case FIRSTSHAPE: expandable.setText(Messages.getString("MonsterDetailsSection.mod.section.shapes")); break; case REANIMATOR: expandable.setText(Messages.getString("MonsterDetailsSection.mod.section.summons")); break; case NAMETYPE: expandable.setText(Messages.getString("MonsterDetailsSection.mod.section.names")); break; case NOLEADER: expandable.setText(Messages.getString("MonsterDetailsSection.mod.section.leadership")); break; case NOMAGICLEADER: expandable.setText(Messages.getString("MonsterDetailsSection.mod.section.magicleadership")); break; case NOUNDEADLEADER: expandable.setText(Messages.getString("MonsterDetailsSection.mod.section.undeadleadership")); break; case INSPIRATIONAL: expandable.setText(Messages.getString("MonsterDetailsSection.mod.section.morale")); break; case MAGICSKILL1: expandable.setText(Messages.getString("MonsterDetailsSection.mod.section.magicpaths")); break; case RESEARCHBONUS: expandable.setText(Messages.getString("MonsterDetailsSection.mod.section.magicresearch")); break; case FIRERANGE: expandable.setText(Messages.getString("MonsterDetailsSection.mod.section.ritualrange")); break; case GEMPROD1: expandable.setText(Messages.getString("MonsterDetailsSection.mod.section.gems")); break; case BONUSSPELLS: expandable.setText(Messages.getString("MonsterDetailsSection.mod.section.othermagic")); break; } gd = new GridData(SWT.FILL, SWT.FILL, false, false); gd.horizontalSpan = 2; expandable.setLayoutData(gd); expandable.addExpansionListener(new ExpansionAdapter() { public void expansionStateChanged(ExpansionEvent e) { mform.getForm().reflow(true); } }); Composite header1 = toolkit.createComposite(expandable, SWT.BORDER); header1.setLayout(new GridLayout(2, true)); expandable.setClient(header1); if (key.equals(Inst.HP)) { expandable.setExpanded(true); } leftColumn = toolkit.createComposite(header1); glayout = new GridLayout(5, false); glayout.marginHeight = 0; glayout.marginWidth = 0; glayout.verticalSpacing = 0; leftColumn.setLayout(glayout); leftColumn.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); rightColumn = toolkit.createComposite(header1); glayout = new GridLayout(5, false); glayout.marginHeight = 0; glayout.marginWidth = 0; glayout.verticalSpacing = 0; rightColumn.setLayout(glayout); rightColumn.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); isRight = false; } final InstFields field = fields.getValue(); Composite checkParent; if (field instanceof Inst4Fields) { checkParent = toolkit.createComposite(isRight ? rightColumn : leftColumn); glayout = new GridLayout(2, false); glayout.marginHeight = 0; glayout.marginWidth = 0; checkParent.setLayout(glayout); gd = new GridData(SWT.BEGINNING, SWT.DEFAULT, false, false); gd.horizontalSpan = 3; gd.heightHint = 20; checkParent.setLayoutData(gd); } else { checkParent = isRight ? rightColumn : leftColumn; } final Button check = new DynamicButton(checkParent, SWT.CHECK); check.setText(key.label); setToolTip(check, HelpTextHelper.getText(HelpTextHelper.MONSTER_CATEGORY, key.label)); check.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (check.getSelection()) { check.setFont(boldFont); if (field instanceof Inst1Fields) { addInst1(key, doc, key.defaultValue); } else if (field instanceof Inst2Fields) { addInst2(key, doc, key.defaultValue); } else if (field instanceof Inst3Fields) { addInst3(key, doc, key.defaultValue, key.defaultValue2); } else if (field instanceof Inst4Fields) { addInst4(key, doc); } else if (field instanceof Inst5Fields) { addInst5(key, doc, key.defaultValue); } else if (field instanceof Inst6Fields) { addInst6(key, doc, key.defaultValue); } else if (field instanceof Inst7Fields) { addInst3(key, doc, key.defaultValue, key.defaultValue2); } else if (field instanceof Inst8Fields) { addInst2(key, doc, key.defaultValue); } } else { removeInst(key, doc); check.setFont(normalFont); } } }); Text myValue1 = null; Text myValue2 = null; if (field instanceof Inst1Fields || field instanceof Inst2Fields || field instanceof Inst7Fields || field instanceof Inst5Fields || field instanceof Inst6Fields) { final Text value = new DynamicText(isRight ? rightColumn : leftColumn, SWT.SINGLE | SWT.BORDER); myValue1 = value; if (field instanceof Inst2Fields || field instanceof Inst7Fields || field instanceof Inst6Fields) { value.addVerifyListener(new VerifyListener() { @Override public void verifyText(VerifyEvent e) { if (Character.isLetter(e.character)) { e.doit = false; } } }); } check.addSelectionListener(new SelectionAdapter() { @SuppressWarnings("unchecked") @Override public void widgetSelected(SelectionEvent e) { if (check.getSelection()) { value.setEnabled(true); value.setText(key.defaultValue); for (List<Inst> dynamic : dynamicFields) { if (dynamic.contains(key)) { for (final Map.Entry<Inst, InstFields> fields : instMap.entrySet()) { if (dynamic.contains(fields.getKey())) { if (Boolean.FALSE .equals(((Inst7Fields) fields.getValue()).value1.getData())) { ((Inst7Fields) fields.getValue()).value1.setData(Boolean.TRUE); ((Inst7Fields) fields.getValue()).value2.setData(Boolean.TRUE); ((Inst7Fields) fields.getValue()).check.setData(Boolean.TRUE); ((Inst7Fields) fields.getValue()).defaultLabel1 .setData(Boolean.TRUE); ((Inst7Fields) fields.getValue()).defaultLabel2 .setData(Boolean.TRUE); break; } } } update(); mform.fireSelectionChanged(mform.getParts()[0], viewer.getSelection()); } } } else { value.setEnabled(false); value.setText(""); for (List<Inst> dynamic : dynamicFields) { if (dynamic.contains(key)) { @SuppressWarnings("rawtypes") List<Map.Entry> entries = Arrays.asList( instMap.entrySet().toArray(new Map.Entry[instMap.entrySet().size()])); Collections.reverse(entries); for (final Map.Entry<Inst, InstFields> fields : entries) { if (!key.equals(fields.getKey()) && dynamic.contains(fields.getKey())) { if (Boolean.TRUE .equals(((Inst7Fields) fields.getValue()).value1.getData()) && !((Inst7Fields) fields.getValue()).value1.isEnabled()) { ((Inst7Fields) fields.getValue()).value1.setData(Boolean.FALSE); ((Inst7Fields) fields.getValue()).value2.setData(Boolean.FALSE); ((Inst7Fields) fields.getValue()).check.setData(Boolean.FALSE); ((Inst7Fields) fields.getValue()).defaultLabel1 .setData(Boolean.FALSE); ((Inst7Fields) fields.getValue()).defaultLabel2 .setData(Boolean.FALSE); break; } } } update(); mform.fireSelectionChanged(mform.getParts()[0], viewer.getSelection()); } } } } }); value.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { if (field instanceof Inst1Fields) { setInst1(key, doc, value.getText()); } else if (field instanceof Inst2Fields) { setInst2(key, doc, value.getText()); } else if (field instanceof Inst7Fields) { setInst3(key, doc, value.getText(), null); } else if (field instanceof Inst5Fields) { setInst5(key, doc, value.getText()); } else if (field instanceof Inst6Fields) { setInst6(key, doc, value.getText()); } } }); value.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.character == '\r') { if (field instanceof Inst1Fields) { setInst1(key, doc, value.getText()); } else if (field instanceof Inst2Fields) { setInst2(key, doc, value.getText()); } else if (field instanceof Inst7Fields) { setInst3(key, doc, value.getText(), null); } else if (field instanceof Inst5Fields) { setInst5(key, doc, value.getText()); } else if (field instanceof Inst6Fields) { setInst6(key, doc, value.getText()); } } } }); value.setEnabled(false); if (field instanceof Inst1Fields) { gd = new GridData(SWT.FILL, SWT.FILL, false, false); gd.widthHint = 140; gd.horizontalSpan = 3; } else if (field instanceof Inst2Fields || field instanceof Inst6Fields) { gd = new GridData(SWT.FILL, SWT.BEGINNING, false, false); gd.widthHint = DEFAULT_VALUE_WIDTH; } else if (field instanceof Inst7Fields) { gd = new GridData(SWT.FILL, SWT.FILL, false, false); gd.widthHint = DEFAULT_VALUE_WIDTH - 12; } else if (field instanceof Inst5Fields) { gd = new GridData(SWT.FILL, SWT.FILL, false, false); if (fields.getKey() == Inst.ONEBATTLESPELL) { gd.widthHint = DEFAULT_VALUE_WIDTH - 12; } else { gd.widthHint = DEFAULT_VALUE_WIDTH; } } value.setLayoutData(gd); } MappedDynamicCombo myInst3Value1 = null; Text myInst3Value2 = null; if (field instanceof Inst3Fields) { final MappedDynamicCombo value = new MappedDynamicCombo(isRight ? rightColumn : leftColumn, SWT.READ_ONLY); myInst3Value1 = value; check.addSelectionListener(new SelectionAdapter() { @SuppressWarnings("unchecked") @Override public void widgetSelected(SelectionEvent e) { if (check.getSelection()) { value.setEnabled(true); setComboItems(fields.getKey(), value); int selection = Integer.parseInt(key.defaultValue); value.select(selection); for (List<Inst> dynamic : dynamicFields) { if (dynamic.contains(key)) { for (final Map.Entry<Inst, InstFields> fields : instMap.entrySet()) { if (dynamic.contains(fields.getKey())) { if (Boolean.FALSE .equals(((Inst3Fields) fields.getValue()).value1.getData())) { ((Inst3Fields) fields.getValue()).value1.setData(Boolean.TRUE); ((Inst3Fields) fields.getValue()).value2.setData(Boolean.TRUE); ((Inst3Fields) fields.getValue()).check.setData(Boolean.TRUE); ((Inst3Fields) fields.getValue()).defaultLabel1 .setData(Boolean.TRUE); ((Inst3Fields) fields.getValue()).defaultLabel2 .setData(Boolean.TRUE); break; } } } update(); mform.fireSelectionChanged(mform.getParts()[0], viewer.getSelection()); } } } else { value.setEnabled(true); value.removeAll(); value.setEnabled(false); for (List<Inst> dynamic : dynamicFields) { if (dynamic.contains(key)) { @SuppressWarnings("rawtypes") List<Map.Entry> entries = Arrays.asList( instMap.entrySet().toArray(new Map.Entry[instMap.entrySet().size()])); Collections.reverse(entries); for (final Map.Entry<Inst, InstFields> fields : entries) { if (!key.equals(fields.getKey()) && dynamic.contains(fields.getKey())) { if (Boolean.TRUE .equals(((Inst3Fields) fields.getValue()).value1.getData()) && !((Inst3Fields) fields.getValue()).value1.isEnabled()) { ((Inst3Fields) fields.getValue()).value1.setData(Boolean.FALSE); ((Inst3Fields) fields.getValue()).value2.setData(Boolean.FALSE); ((Inst3Fields) fields.getValue()).check.setData(Boolean.FALSE); ((Inst3Fields) fields.getValue()).defaultLabel1 .setData(Boolean.FALSE); ((Inst3Fields) fields.getValue()).defaultLabel2 .setData(Boolean.FALSE); break; } } } update(); mform.fireSelectionChanged(mform.getParts()[0], viewer.getSelection()); } } } } }); value.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { int val = value.getSelectedValue(); setInst3(key, doc, Integer.toString(val), null); } @Override public void widgetDefaultSelected(SelectionEvent e) { } }); value.setEnabled(false); gd = new GridData(SWT.FILL, SWT.FILL, false, false); gd.widthHint = DEFAULT_VALUE_WIDTH + 16; value.setLayoutData(gd); } MappedDynamicCombo myInst8Value1 = null; MappedDynamicCombo myInst8Value2 = null; MappedDynamicCombo myInst8Value3 = null; MappedDynamicCombo myInst8Value4 = null; MappedDynamicCombo myInst8Value5 = null; if (field instanceof Inst8Fields) { final MappedDynamicCombo value1 = new MappedDynamicCombo(isRight ? rightColumn : leftColumn, SWT.READ_ONLY); final MappedDynamicCombo value2 = new MappedDynamicCombo(isRight ? rightColumn : leftColumn, SWT.READ_ONLY); new Label(isRight ? rightColumn : leftColumn, SWT.NONE); new Label(isRight ? rightColumn : leftColumn, SWT.NONE); final MappedDynamicCombo value3 = new MappedDynamicCombo(isRight ? rightColumn : leftColumn, SWT.READ_ONLY); final MappedDynamicCombo value4 = new MappedDynamicCombo(isRight ? rightColumn : leftColumn, SWT.READ_ONLY); final MappedDynamicCombo value5 = new MappedDynamicCombo(isRight ? rightColumn : leftColumn, SWT.READ_ONLY); new Label(isRight ? rightColumn : leftColumn, SWT.NONE); new Label(isRight ? rightColumn : leftColumn, SWT.NONE); myInst8Value1 = value1; myInst8Value2 = value2; myInst8Value3 = value3; myInst8Value4 = value4; myInst8Value5 = value5; check.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (check.getSelection()) { value1.setEnabled(true); value1.setItems(new String[] { "0 hands", "1 hand", "2 hands", "3 hands", "4 hands" }, new int[] { 0, 2, 6, 14, 30 }); value1.select(getHands(Integer.parseInt(key.defaultValue))); value2.setEnabled(true); value2.setItems(new String[] { "0 heads", "1 head", "2 heads" }, new int[] { 0, 128, 384 }); value2.select(getHeads(Integer.parseInt(key.defaultValue))); value3.setEnabled(true); value3.setItems(new String[] { "0 bodies", "1 body" }, new int[] { 0, 1024 }); value3.select(getBodies(Integer.parseInt(key.defaultValue))); value4.setEnabled(true); value4.setItems(new String[] { "0 feet", "1 foot" }, new int[] { 0, 2048 }); value4.select(getFeet(Integer.parseInt(key.defaultValue))); value5.setEnabled(true); value5.setItems(new String[] { "0 misc", "1 misc", "2 misc", "3 misc", "4 misc" }, new int[] { 0, 4096, 12288, 28672, 61440 }); value5.select(getMisc(Integer.parseInt(key.defaultValue))); } else { value1.setEnabled(true); value1.removeAll(); value1.setEnabled(false); value2.setEnabled(true); value2.removeAll(); value2.setEnabled(false); value3.setEnabled(true); value3.removeAll(); value3.setEnabled(false); value4.setEnabled(true); value4.removeAll(); value4.setEnabled(false); value5.setEnabled(true); value5.removeAll(); value5.setEnabled(false); } } }); SelectionListener selectionListener = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { int val = getItemMask(value1.getSelectedValue(), value2.getSelectedValue(), value3.getSelectedValue(), value4.getSelectedValue(), value5.getSelectedValue()); setInst2(key, doc, Integer.toString(val)); } }; value1.addSelectionListener(selectionListener); value2.addSelectionListener(selectionListener); value3.addSelectionListener(selectionListener); value4.addSelectionListener(selectionListener); value5.addSelectionListener(selectionListener); value1.setEnabled(false); value2.setEnabled(false); value3.setEnabled(false); value4.setEnabled(false); value5.setEnabled(false); gd = new GridData(SWT.FILL, SWT.FILL, false, false); gd.widthHint = DEFAULT_VALUE_WIDTH + 16; value1.setLayoutData(gd); } Label defaultLabel1 = null; if (field instanceof Inst1Fields || field instanceof Inst2Fields || field instanceof Inst3Fields || field instanceof Inst5Fields || field instanceof Inst6Fields || field instanceof Inst7Fields || field instanceof Inst8Fields) { defaultLabel1 = new DynamicLabel(isRight ? rightColumn : leftColumn, SWT.NONE); defaultLabel1.setEnabled(false); } if (field instanceof Inst4Fields) { defaultLabel1 = toolkit.createLabel(checkParent, ""); defaultLabel1.setEnabled(false); } if (field instanceof Inst2Fields || field instanceof Inst5Fields || field instanceof Inst6Fields) { gd = new GridData(SWT.BEGINNING, SWT.CENTER, false, false); defaultLabel1.setLayoutData(gd); createSpacer(toolkit, isRight ? rightColumn : leftColumn, 2); } else if (field instanceof Inst1Fields || field instanceof Inst3Fields || field instanceof Inst7Fields) { gd = new GridData(SWT.BEGINNING, SWT.CENTER, false, false); defaultLabel1.setLayoutData(gd); } else if (field instanceof Inst4Fields) { gd = new GridData(SWT.BEGINNING, SWT.CENTER, false, false); defaultLabel1.setLayoutData(gd); createSpacer(toolkit, isRight ? rightColumn : leftColumn, 2); } else if (field instanceof Inst8Fields) { gd = new GridData(SWT.BEGINNING, SWT.CENTER, false, false); gd.horizontalSpan = 3; defaultLabel1.setLayoutData(gd); } Label defaultLabel2 = null; if (field instanceof Inst3Fields) { final Text value = new DynamicText(isRight ? rightColumn : leftColumn, SWT.SINGLE | SWT.BORDER); myInst3Value2 = value; value.addVerifyListener(new VerifyListener() { @Override public void verifyText(VerifyEvent e) { if (Character.isLetter(e.character)) { e.doit = false; } } }); check.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (check.getSelection()) { value.setEnabled(true); value.setText(key.defaultValue2); update(); } else { value.setEnabled(false); value.setText(""); update(); } } }); value.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { setInst3(key, doc, null, value.getText()); } }); value.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.character == '\r') { setInst3(key, doc, null, value.getText()); } } }); value.setEnabled(false); gd = new GridData(SWT.BEGINNING, SWT.DEFAULT, false, false); gd.widthHint = DEFAULT_VALUE_WIDTH - 24; value.setLayoutData(gd); defaultLabel2 = new DynamicLabel(isRight ? rightColumn : leftColumn, SWT.NONE); defaultLabel2.setEnabled(false); for (List<Inst> list : dynamicFields) { boolean firstElement = true; for (Inst inst : list) { if (key.equals(inst)) { if (firstElement) { myInst3Value1.setData(Boolean.TRUE); myInst3Value2.setData(Boolean.TRUE); check.setData(Boolean.TRUE); defaultLabel1.setData(Boolean.TRUE); defaultLabel2.setData(Boolean.TRUE); } else { myInst3Value1.setData(Boolean.FALSE); myInst3Value2.setData(Boolean.FALSE); check.setData(Boolean.FALSE); defaultLabel1.setData(Boolean.FALSE); defaultLabel2.setData(Boolean.FALSE); } } firstElement = false; } } } if (field instanceof Inst7Fields) { final Text value = new DynamicText(isRight ? rightColumn : leftColumn, SWT.SINGLE | SWT.BORDER); myValue2 = value; value.addVerifyListener(new VerifyListener() { @Override public void verifyText(VerifyEvent e) { if (Character.isLetter(e.character)) { e.doit = false; } } }); check.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (check.getSelection()) { value.setEnabled(true); value.setText(key.defaultValue2); update(); } else { value.setEnabled(false); value.setText(""); update(); } } }); value.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { setInst3(key, doc, null, value.getText()); } }); value.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.character == '\r') { setInst3(key, doc, null, value.getText()); } } }); value.setEnabled(false); gd = new GridData(SWT.BEGINNING, SWT.DEFAULT, false, false); gd.widthHint = DEFAULT_VALUE_WIDTH - 24; value.setLayoutData(gd); defaultLabel2 = new DynamicLabel(isRight ? rightColumn : leftColumn, SWT.NONE); defaultLabel2.setEnabled(false); for (List<Inst> list : dynamicFields) { boolean firstElement = true; for (Inst inst : list) { if (key.equals(inst)) { if (firstElement) { myValue1.setData(Boolean.TRUE); myValue2.setData(Boolean.TRUE); check.setData(Boolean.TRUE); defaultLabel1.setData(Boolean.TRUE); defaultLabel2.setData(Boolean.TRUE); } else { myValue1.setData(Boolean.FALSE); myValue2.setData(Boolean.FALSE); check.setData(Boolean.FALSE); defaultLabel1.setData(Boolean.FALSE); defaultLabel2.setData(Boolean.FALSE); } } firstElement = false; } } } if (field instanceof Inst1Fields) { ((Inst1Fields) field).check = check; ((Inst1Fields) field).value = myValue1; ((Inst1Fields) field).defaultLabel = defaultLabel1; } else if (field instanceof Inst2Fields) { ((Inst2Fields) field).check = check; ((Inst2Fields) field).value = myValue1; ((Inst2Fields) field).defaultLabel = defaultLabel1; } else if (field instanceof Inst3Fields) { ((Inst3Fields) field).check = check; ((Inst3Fields) field).value1 = myInst3Value1; ((Inst3Fields) field).defaultLabel1 = defaultLabel1; ((Inst3Fields) field).value2 = myInst3Value2; ((Inst3Fields) field).defaultLabel2 = defaultLabel2; } else if (field instanceof Inst4Fields) { ((Inst4Fields) field).check = check; ((Inst4Fields) field).defaultLabel = defaultLabel1; } else if (field instanceof Inst5Fields) { ((Inst5Fields) field).check = check; ((Inst5Fields) field).value = myValue1; ((Inst5Fields) field).defaultLabel = defaultLabel1; } else if (field instanceof Inst6Fields) { ((Inst6Fields) field).check = check; ((Inst6Fields) field).value = myValue1; ((Inst6Fields) field).defaultLabel = defaultLabel1; } else if (field instanceof Inst7Fields) { ((Inst7Fields) field).check = check; ((Inst7Fields) field).value1 = myValue1; ((Inst7Fields) field).defaultLabel1 = defaultLabel1; ((Inst7Fields) field).value2 = myValue2; ((Inst7Fields) field).defaultLabel2 = defaultLabel2; } else if (field instanceof Inst8Fields) { ((Inst8Fields) field).check = check; ((Inst8Fields) field).value1 = myInst8Value1; ((Inst8Fields) field).value2 = myInst8Value2; ((Inst8Fields) field).value3 = myInst8Value3; ((Inst8Fields) field).value4 = myInst8Value4; ((Inst8Fields) field).value5 = myInst8Value5; ((Inst8Fields) field).defaultLabel = defaultLabel1; } if (fields.getKey() == Inst.MAGICBOOST1 || fields.getKey() == Inst.MAGICBOOST2 || fields.getKey() == Inst.MAGICBOOST3 || fields.getKey() == Inst.MAGICBOOST4 || fields.getKey() == Inst.MAGICBOOST5 || fields.getKey() == Inst.MAGICBOOST6 || fields.getKey() == Inst.MAGICBOOST7 || fields.getKey() == Inst.MAGICBOOST8) { isRight = !isRight; } isRight = !isRight; } }