/** This is a callback that will allow us to create the viewer and initialize it. */
  @Override
  public void createPartControl(Composite parent) {
    Department department = (Department) IModel.INSTANCE.getStation();

    DefaultGalleryItemRenderer ir = new DefaultGalleryItemRenderer();
    ir.setShowRoundedSelectionCorners(true);

    Gallery gallery = new Gallery(parent, SWT.NONE);
    gallery.setBackground(
        SWTResourceManager.getColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT));
    gallery.setForeground(SWTResourceManager.getColor(SWT.COLOR_DARK_BLUE));
    gallery.setFont(SWTResourceManager.getFont("Segoe UI", 16, SWT.BOLD));
    gallery.setGroupRenderer(new NoGroupRenderer());
    gallery.setItemRenderer(ir);

    GalleryItem group = new GalleryItem(gallery, SWT.NONE);
    for (Employee employee : department.getEmployees()) {
      GalleryItem item = new GalleryItem(group, SWT.NONE);
      String imageName = getImageName(employee.getName());
      item.setImage(getCachedImage(imageName));
      item.setText(StringUtil.safe(employee.getName()));
    }
  }
  /** @wbp.parser.entryPoint */
  public void showType2Document() {
    final Display display = Display.getDefault();

    shlTypeDocument = new Shell(display);
    shlTypeDocument.setText("Type 2 Document");
    shlTypeDocument.setSize(780, 634);
    shlTypeDocument.setLocation(display.getBounds().x + 200, display.getBounds().y + 100);

    Composite composite = new Composite(shlTypeDocument, SWT.NONE);
    composite.setBounds(0, 0, 759, 557);

    TabFolder tabFolder = new TabFolder(composite, SWT.NONE);
    tabFolder.setBounds(10, 10, 742, 545);

    TabItem tbtmText = new TabItem(tabFolder, SWT.NONE);
    tbtmText.setText("Text");

    Group grpText = new Group(tabFolder, SWT.NONE);
    grpText.setText("Text");
    tbtmText.setControl(grpText);
    // The first tab!  --> Text
    Label lblLeadingIndentionOf = new Label(grpText, SWT.NONE);
    lblLeadingIndentionOf.setBounds(10, 82, 374, 15);
    lblLeadingIndentionOf.setText("Leading indention of other paragraph:");

    text = new Text(grpText, SWT.BORDER);
    text.setBounds(422, 79, 76, 21);

    Label lblCharacters = new Label(grpText, SWT.NONE);
    lblCharacters.setBounds(504, 82, 85, 15);
    lblCharacters.setText("characters");

    Label lblSpacingBetweenCharacters = new Label(grpText, SWT.NONE);
    lblSpacingBetweenCharacters.setBounds(10, 116, 374, 15);
    lblSpacingBetweenCharacters.setText("Spacing between paragraphs:");

    text_1 = new Text(grpText, SWT.BORDER);
    text_1.setBounds(422, 113, 76, 21);

    Label lblLines = new Label(grpText, SWT.NONE);
    lblLines.setBounds(504, 116, 85, 15);
    lblLines.setText("lines");

    Label lblstParagraph = new Label(grpText, SWT.NONE);
    lblstParagraph.setBounds(10, 47, 374, 15);
    lblstParagraph.setText("1st Paragraph:");

    text_2 = new Text(grpText, SWT.BORDER);
    text_2.setBounds(422, 47, 76, 21);

    Label label_2 = new Label(grpText, SWT.NONE);
    label_2.setBounds(504, 47, 85, 15);
    label_2.setText("characters");

    Label lblEstimatedAverageLengths = new Label(grpText, SWT.NONE);
    lblEstimatedAverageLengths.setBounds(10, 154, 374, 15);
    lblEstimatedAverageLengths.setText("Estimated average length(s) of a line:");

    text_3 = new Text(grpText, SWT.BORDER);
    text_3.setBounds(422, 148, 76, 21);

    Label label_3 = new Label(grpText, SWT.NONE);
    label_3.setBounds(504, 154, 85, 15);
    label_3.setText("characters");

    Label lblPageNumberForms = new Label(grpText, SWT.NONE);
    lblPageNumberForms.setBounds(10, 194, 141, 15);
    lblPageNumberForms.setText("Page number forms:");

    text_4 = new Text(grpText, SWT.BORDER);
    text_4.setBounds(161, 191, 477, 21);

    Label lblSectionHeadings = new Label(grpText, SWT.NONE);
    lblSectionHeadings.setBounds(10, 237, 141, 15);
    lblSectionHeadings.setText("Section headings:");

    Button btnCapitalized = new Button(grpText, SWT.RADIO);
    btnCapitalized.setBounds(169, 236, 90, 16);
    btnCapitalized.setText("Capitalized");

    Button btnAllCapital = new Button(grpText, SWT.RADIO);
    btnAllCapital.setBounds(263, 237, 90, 16);
    btnAllCapital.setText("ALL CAPITAL");

    text_5 = new Text(grpText, SWT.BORDER);
    text_5.setBounds(366, 231, 272, 21);

    Label lblFooterTokens = new Label(grpText, SWT.NONE);
    lblFooterTokens.setBounds(10, 283, 85, 15);
    lblFooterTokens.setText("Footer tokens:");

    Button btnHasFooters = new Button(grpText, SWT.CHECK);
    btnHasFooters.setBounds(123, 282, 93, 16);
    btnHasFooters.setText("Has footers");

    text_6 = new Text(grpText, SWT.BORDER);
    text_6.setBounds(222, 280, 98, 21);

    Label lblHeaderTokens = new Label(grpText, SWT.NONE);
    lblHeaderTokens.setBounds(337, 283, 85, 15);
    lblHeaderTokens.setText("Header tokens:");

    Button btnHasHeaders = new Button(grpText, SWT.CHECK);
    btnHasHeaders.setBounds(428, 282, 93, 16);
    btnHasHeaders.setText("Has headers");

    text_7 = new Text(grpText, SWT.BORDER);
    text_7.setBounds(523, 277, 98, 21);

    textBean =
        new TextBean(
            text_2,
            text,
            text_1,
            text_3,
            text_4,
            btnCapitalized,
            btnAllCapital,
            text_5,
            new SpecialBean(btnHasFooters, btnHasHeaders, text_6, text_7));

    TabItem tbtmNomenclature = new TabItem(tabFolder, SWT.NONE);
    tbtmNomenclature.setText("Nomenclature");

    Group grpNomenclature = new Group(tabFolder, SWT.NONE);
    grpNomenclature.setText("Nomenclature");
    tbtmNomenclature.setControl(grpNomenclature);

    Label lblWhatIsIn = new Label(grpNomenclature, SWT.NONE);
    lblWhatIsIn.setBounds(10, 28, 111, 15);
    lblWhatIsIn.setText("What is in a name?");

    Label lblFamily = new Label(grpNomenclature, SWT.NONE);
    lblFamily.setBounds(233, 28, 55, 15);
    lblFamily.setText("Family");

    Label lblGenus = new Label(grpNomenclature, SWT.NONE);
    lblGenus.setBounds(399, 28, 55, 15);
    lblGenus.setText("Genus");

    Label lblSpecies = new Label(grpNomenclature, SWT.NONE);
    lblSpecies.setBounds(569, 28, 55, 15);
    lblSpecies.setText("Species");

    nomenScrolledComposite =
        new ScrolledComposite(grpNomenclature, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    nomenScrolledComposite.setBounds(10, 53, 714, 278);
    nomenScrolledComposite.setExpandHorizontal(true);
    nomenScrolledComposite.setExpandVertical(true);

    nomenclatureGroup = new Group(nomenScrolledComposite, SWT.NONE);
    nomenclatureGroup.setLayoutData(new RowData());

    Label lblName = new Label(nomenclatureGroup, SWT.NONE);
    lblName.setBounds(10, 20, 75, 15);
    lblName.setText("Name");

    Group group_2 = new Group(nomenclatureGroup, SWT.NONE);
    group_2.setBounds(100, 10, 182, 40);

    Button button = new Button(group_2, SWT.RADIO);
    button.setText("Yes");
    button.setBounds(10, 13, 39, 16);

    Button button_1 = new Button(group_2, SWT.RADIO);
    button_1.setText("No");
    button_1.setBounds(55, 13, 39, 16);

    text_14 = new Text(group_2, SWT.BORDER);
    text_14.setBounds(100, 11, 76, 21);
    nomenclatures.put(
        new Integer(nomenCount), new NomenclatureBean(group_2, button, button_1, text_14, lblName));
    nomenCount++;

    Group group_1 = new Group(nomenclatureGroup, SWT.NONE);
    group_1.setBounds(300, 10, 182, 40);

    Button button_2 = new Button(group_1, SWT.RADIO);
    button_2.setText("Yes");
    button_2.setBounds(10, 13, 39, 16);

    Button button_3 = new Button(group_1, SWT.RADIO);
    button_3.setText("No");
    button_3.setBounds(55, 13, 39, 16);

    text_15 = new Text(group_1, SWT.BORDER);
    text_15.setBounds(100, 11, 76, 21);

    nomenclatures.put(
        new Integer(nomenCount),
        new NomenclatureBean(group_1, button_2, button_3, text_15, lblName));
    nomenCount++;

    ///////////////
    Group group_4 = new Group(nomenclatureGroup, SWT.NONE);
    group_4.setBounds(500, 10, 182, 40);

    Button button_4 = new Button(group_4, SWT.RADIO);
    button_4.setText("Yes");
    button_4.setBounds(10, 13, 39, 16);

    Button button_5 = new Button(group_4, SWT.RADIO);
    button_5.setText("No");
    button_5.setBounds(55, 13, 39, 16);

    text_16 = new Text(group_4, SWT.BORDER);
    text_16.setBounds(100, 11, 76, 21);

    nomenclatures.put(
        new Integer(nomenCount),
        new NomenclatureBean(group_4, button_4, button_5, text_16, lblName));
    nomenCount++;

    String[] nomenclatureArray = {"Authors", "Date", "Publication", "Taxon Rank"};
    for (String name : nomenclatureArray) {
      addNomenclatureRow(name);
    }

    nomenScrolledComposite.setContent(nomenclatureGroup);
    // When you add a row, reset the size of scrolledComposite
    nomenScrolledComposite.setMinSize(nomenclatureGroup.computeSize(SWT.DEFAULT, SWT.DEFAULT));

    Button btnAddARow = new Button(grpNomenclature, SWT.NONE);
    btnAddARow.setBounds(10, 337, 75, 25);
    btnAddARow.setText("Add a Row");
    btnAddARow.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            identifier = null;
            showInputBox();
            if (identifier != null && !identifier.equals("")) {
              addNomenclatureRow(identifier);
            }
          }
        });

    TabItem tbtmExpressions = new TabItem(tabFolder, SWT.NONE);
    tbtmExpressions.setText("Expressions");

    Group grpExpressionsUsedIn = new Group(tabFolder, SWT.NONE);
    grpExpressionsUsedIn.setText("Expressions used in Nomenclature");
    tbtmExpressions.setControl(grpExpressionsUsedIn);

    Label lblUseCapLetters = new Label(grpExpressionsUsedIn, SWT.NONE);
    lblUseCapLetters.setBounds(10, 22, 426, 15);
    lblUseCapLetters.setText("Use CAP words for fixed tokens; use small letters for variables");

    Label lblHononyms = new Label(grpExpressionsUsedIn, SWT.NONE);
    lblHononyms.setBounds(348, 22, 99, 15);
    lblHononyms.setText("Hononyms:");

    expScrolledComposite =
        new ScrolledComposite(grpExpressionsUsedIn, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    expScrolledComposite.setBounds(10, 43, 714, 440);
    expScrolledComposite.setExpandHorizontal(true);
    expScrolledComposite.setExpandVertical(true);

    expressionGroup = new Group(expScrolledComposite, SWT.NONE);
    expressionGroup.setLayoutData(new RowData());

    // count of number of rows
    expCount = 0;
    Label lblSpecialTokensUsed = new Label(expressionGroup, SWT.NONE);
    lblSpecialTokensUsed.setBounds(10, 20, 120, 15);
    lblSpecialTokensUsed.setText("Special tokens used:");

    text_29 = new Text(expressionGroup, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.MULTI);
    text_29.setBounds(135, 20, 550, 70);

    expressions.put(new Integer(expCount), new ExpressionBean(lblSpecialTokensUsed, text_29));
    expCount++;

    String[] expressionArray = {"Minor Amendment:", "Past name:", "Name origin:", "Homonyms:"};
    for (String name : expressionArray) {
      addExpressionRow(name);
    }

    expScrolledComposite.setContent(expressionGroup);
    expScrolledComposite.setMinSize(expressionGroup.computeSize(SWT.DEFAULT, SWT.DEFAULT));

    Button btnAddARow_2 = new Button(grpExpressionsUsedIn, SWT.NONE);
    btnAddARow_2.setBounds(10, 489, 75, 25);
    btnAddARow_2.setText("Add a row");
    btnAddARow_2.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            identifier = null;
            showInputBox();
            if (identifier != null && !identifier.equals("")) {
              addExpressionRow(identifier);
            }
          }
        });

    TabItem tbtmDescription = new TabItem(tabFolder, SWT.NONE);
    tbtmDescription.setText("Description");

    Group grpMorphologicalDescriptions = new Group(tabFolder, SWT.NONE);
    tbtmDescription.setControl(grpMorphologicalDescriptions);

    Label lblAllInOne = new Label(grpMorphologicalDescriptions, SWT.NONE);
    lblAllInOne.setBounds(10, 53, 160, 15);
    lblAllInOne.setText("All in one paragraph");

    Button btnYes = new Button(grpMorphologicalDescriptions, SWT.RADIO);
    btnYes.setBounds(241, 52, 90, 16);
    btnYes.setText("Yes");

    Button btnNo = new Button(grpMorphologicalDescriptions, SWT.RADIO);
    btnNo.setBounds(378, 52, 90, 16);
    btnNo.setText("No");

    Label lblOtherInformationMay = new Label(grpMorphologicalDescriptions, SWT.NONE);
    lblOtherInformationMay.setBounds(10, 85, 438, 15);
    lblOtherInformationMay.setText(
        "Other information may also be included in a description paragraph:");

    Combo combo = new Combo(grpMorphologicalDescriptions, SWT.NONE);
    combo.setItems(new String[] {"Nomenclature", "Habitat", "Distribution", "Discussion", "Other"});
    combo.setBounds(496, 82, 177, 23);

    descriptionBean = new DescriptionBean(btnYes, btnNo, combo, sections);

    Label lblMorphological = new Label(grpMorphologicalDescriptions, SWT.NONE);
    lblMorphological.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD));
    lblMorphological.setBounds(10, 25, 242, 15);
    lblMorphological.setText("Morphological Descriptions: ");

    Label lblOrder = new Label(grpMorphologicalDescriptions, SWT.NONE);
    lblOrder.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD));
    lblOrder.setBounds(22, 142, 55, 15);
    lblOrder.setText("Order");

    Label lblSection = new Label(grpMorphologicalDescriptions, SWT.NONE);
    lblSection.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD));
    lblSection.setBounds(140, 142, 55, 15);
    lblSection.setText("Section");

    Label lblStartTokens = new Label(grpMorphologicalDescriptions, SWT.NONE);
    lblStartTokens.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD));
    lblStartTokens.setBounds(285, 142, 90, 15);
    lblStartTokens.setText("Start tokens");

    Label lblEndTokens = new Label(grpMorphologicalDescriptions, SWT.NONE);
    lblEndTokens.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD));
    lblEndTokens.setBounds(443, 142, 68, 15);
    lblEndTokens.setText("End tokens");

    Label lblEmbeddedTokens = new Label(grpMorphologicalDescriptions, SWT.NONE);
    lblEmbeddedTokens.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD));
    lblEmbeddedTokens.setBounds(592, 142, 132, 15);
    lblEmbeddedTokens.setText("Embedded tokens");

    descScrolledComposite =
        new ScrolledComposite(
            grpMorphologicalDescriptions, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    descScrolledComposite.setBounds(10, 169, 714, 310);
    descScrolledComposite.setExpandHorizontal(true);
    descScrolledComposite.setExpandVertical(true);

    descriptionGroup = new Group(descScrolledComposite, SWT.NONE);
    descriptionGroup.setLayoutData(new RowData());

    text_33 = new Text(descriptionGroup, SWT.BORDER);
    text_33.setBounds(10, 20, 75, 20);

    Label lblNomenclature = new Label(descriptionGroup, SWT.NONE);
    lblNomenclature.setBounds(120, 20, 145, 20);
    lblNomenclature.setText("Nomenclature");

    text_40 = new Text(descriptionGroup, SWT.BORDER);
    text_40.setBounds(270, 20, 115, 20);

    text_41 = new Text(descriptionGroup, SWT.BORDER);
    text_41.setBounds(420, 20, 115, 20);

    text_42 = new Text(descriptionGroup, SWT.BORDER);
    text_42.setBounds(570, 20, 115, 20);

    sections.put(
        new Integer(secCount),
        new SectionBean(text_33, lblNomenclature, text_40, text_41, text_42));
    secCount++;

    String[] sectionArray = {
      "Morph. description", "Habitat", "Distribution", "Discussion", "Keys", "References"
    };
    for (String name : sectionArray) {
      addDescriptionRow(name);
    }

    descScrolledComposite.setContent(descriptionGroup);
    descScrolledComposite.setMinSize(descriptionGroup.computeSize(SWT.DEFAULT, SWT.DEFAULT));

    Button btnAddARow_1 = new Button(grpMorphologicalDescriptions, SWT.NONE);
    btnAddARow_1.setBounds(10, 482, 75, 25);
    btnAddARow_1.setText("Add a row");
    btnAddARow_1.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            identifier = null;
            showInputBox();
            if (identifier != null && !identifier.equals("")) {
              addDescriptionRow(identifier);
            }
          }
        });

    Label lblSectionIndicationsAnd = new Label(grpMorphologicalDescriptions, SWT.NONE);
    lblSectionIndicationsAnd.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD));
    lblSectionIndicationsAnd.setBounds(10, 116, 222, 15);
    lblSectionIndicationsAnd.setText("Section indications and order:");

    TabItem tbtmSpecial = new TabItem(tabFolder, SWT.NONE);
    tbtmSpecial.setText("Special");

    Group grpSpecialSections = new Group(tabFolder, SWT.NONE);
    grpSpecialSections.setText("Special Sections");
    tbtmSpecial.setControl(grpSpecialSections);

    Label lblGlossaries = new Label(grpSpecialSections, SWT.NONE);
    lblGlossaries.setBounds(10, 51, 55, 15);
    lblGlossaries.setText("Glossaries:");

    Button btnHasGlossaries = new Button(grpSpecialSections, SWT.CHECK);
    btnHasGlossaries.setBounds(96, 51, 93, 16);
    btnHasGlossaries.setText("has glossaries");

    Label lblGlossaryHeading = new Label(grpSpecialSections, SWT.NONE);
    lblGlossaryHeading.setBounds(257, 51, 93, 15);
    lblGlossaryHeading.setText("Glossary heading");

    text_9 = new Text(grpSpecialSections, SWT.BORDER);
    text_9.setBounds(377, 48, 76, 21);

    Label lblReferences = new Label(grpSpecialSections, SWT.NONE);
    lblReferences.setBounds(10, 102, 69, 15);
    lblReferences.setText("References :");

    Button btnHasReferences = new Button(grpSpecialSections, SWT.CHECK);
    btnHasReferences.setBounds(96, 102, 93, 16);
    btnHasReferences.setText("has references");

    Label lblReferencesHeading = new Label(grpSpecialSections, SWT.NONE);
    lblReferencesHeading.setBounds(257, 102, 114, 15);
    lblReferencesHeading.setText("References heading:");

    text_10 = new Text(grpSpecialSections, SWT.BORDER);
    text_10.setBounds(377, 99, 76, 21);
    special = new SpecialBean(btnHasGlossaries, btnHasReferences, text_9, text_10);

    TabItem tbtmAbbreviations = new TabItem(tabFolder, SWT.NONE);
    tbtmAbbreviations.setText("Abbreviations");

    Group grpAbbreviationsUsedIn = new Group(tabFolder, SWT.NONE);
    tbtmAbbreviations.setControl(grpAbbreviationsUsedIn);

    text_11 = new Text(grpAbbreviationsUsedIn, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
    text_11.setBounds(10, 52, 691, 69);
    abbreviations.put("Text", text_11);

    Label lblAbbreviationsUsedIn = new Label(grpAbbreviationsUsedIn, SWT.NONE);
    lblAbbreviationsUsedIn.setBounds(10, 31, 272, 15);
    lblAbbreviationsUsedIn.setText("Abbreviations used in text:");

    Label lblAbbreviationsUsedIn_1 = new Label(grpAbbreviationsUsedIn, SWT.NONE);
    lblAbbreviationsUsedIn_1.setBounds(10, 150, 272, 15);
    lblAbbreviationsUsedIn_1.setText("Abbreviations used in bibliographical citations:");

    text_12 = new Text(grpAbbreviationsUsedIn, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.MULTI);
    text_12.setBounds(10, 175, 691, 69);
    abbreviations.put("Bibliographical Citations", text_12);

    Label lblAbbreviationsUsedIn_2 = new Label(grpAbbreviationsUsedIn, SWT.NONE);
    lblAbbreviationsUsedIn_2.setBounds(10, 275, 272, 15);
    lblAbbreviationsUsedIn_2.setText("Abbreviations used in authorities:");

    text_13 = new Text(grpAbbreviationsUsedIn, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.MULTI);
    text_13.setBounds(10, 296, 691, 69);
    abbreviations.put("Authorities", text_13);

    Label lblAbbreviationsUsedIn_3 = new Label(grpAbbreviationsUsedIn, SWT.NONE);
    lblAbbreviationsUsedIn_3.setBounds(10, 395, 204, 15);
    lblAbbreviationsUsedIn_3.setText("Abbreviations used in others:");

    text_8 = new Text(grpAbbreviationsUsedIn, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.MULTI);
    text_8.setBounds(10, 416, 691, 69);
    abbreviations.put("Others", text_8);
    final Type2Bean bean =
        new Type2Bean(
            textBean, nomenclatures, expressions, descriptionBean, special, abbreviations);
    Button btnSave = new Button(shlTypeDocument, SWT.NONE);
    btnSave.setBounds(670, 563, 75, 25);
    btnSave.setText("Save");
    btnSave.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            try {
              if (configDb.saveType2Details(bean)) {
                ApplicationUtilities.showPopUpWindow(
                    ApplicationUtilities.getProperty("popup.info.savetype3"),
                    ApplicationUtilities.getProperty("popup.header.info"),
                    SWT.ICON_INFORMATION);
                shlTypeDocument.dispose();
              }
            } catch (SQLException exe) {

            }
          }
        });

    /* Load previously saved details here */
    try {
      configDb.retrieveType2Details(bean, this);
    } catch (SQLException exe) {
      exe.printStackTrace();
    }

    shlTypeDocument.open();
    shlTypeDocument.layout();
    while (!shlTypeDocument.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
  }
/**
 * 2차 계량 - 1차계량 목록에서 선택
 *
 * @author OBERAK
 */
public class WeighSecondSelectDialog extends Dialog {
  protected static Log logger = LogFactory.getLog(WeighSecondSelectDialog.class);

  protected final Font titleFont = SWTResourceManager.getFont("굴림체", 23, SWT.BOLD);
  protected final Font defaultFont = SWTResourceManager.getFont("굴림체", 17, SWT.BOLD);
  protected final Font helpFont = SWTResourceManager.getFont("굴림체", 12, SWT.NONE);
  protected final Font btnFont = SWTResourceManager.getFont("굴림체", 15, SWT.BOLD);

  protected Object result;
  protected Shell shell;

  private CarComposite car;
  private Composite compCenter;

  private ScopedPreferenceStore preferences;

  private String[] colProp = {"no", "car_num", "fst_wgt_dt", "fst_wgt_dt", "fst_wgh"};
  private String[] colName = {"No", "차량번호", "일자", "시간", "중량   "};
  /** 컬럼 너비 : 퍼센트 */
  private int[] colWidth = {10, 30, 27, 15, 18};

  private int[] colAlign = {SWT.CENTER, SWT.CENTER, SWT.CENTER, SWT.CENTER, SWT.RIGHT};

  private GridTableViewer gridViewer;
  private TsWgtInfDTO[] listData;
  private Shell parent;
  private CmUsrInfDTO user;

  private CLabel lblHelp;
  /**
   * Create the dialog.
   *
   * @param parent
   * @param style
   */
  public WeighSecondSelectDialog(Shell parent, int style) {
    super(parent, style);
    this.parent = parent;
    setText("2차 계량 - 대상 차량 선택");
  }

  /**
   * Open the dialog.
   *
   * @return the result
   */
  public Object open() {
    preferences = new ScopedPreferenceStore(ConfigurationScope.INSTANCE, DTSConstants.PLUGIN_ID);
    user = SessionManager.getInstance().getUsr();
    createContents();
    shell.open();
    shell.layout();

    car.setFocus();
    init();

    Display display = getParent().getDisplay();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
    return result;
  }

  /** Create contents of the dialog. */
  private void createContents() {
    shell = new Shell(getParent(), getStyle());
    shell.setSize(624, 617);
    shell.setText(getText());
    GridLayout gl_shell = new GridLayout(1, false);
    gl_shell.horizontalSpacing = 0;
    gl_shell.marginHeight = 0;
    gl_shell.verticalSpacing = 0;
    gl_shell.marginWidth = 0;
    shell.setLayout(gl_shell);
    shell.setBackground(ColorRepository.getColor(ColorRepository.BG_CONTENTS));
    //		shell.setBackgroundMode(SWT.TRANSPARENT);

    CLabel lblTitle = new CLabel(shell, SWT.CENTER);
    lblTitle.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
    GridData gd_lblTitle = new GridData(SWT.FILL, SWT.CENTER, true, false);
    gd_lblTitle.heightHint = 44;
    lblTitle.setLayoutData(gd_lblTitle);
    lblTitle.setFont(titleFont);
    lblTitle.setBackgroundImage(ImageRepository.getImage(ImageRepository.POPUP_TITLE_BG));
    lblTitle.setText("2차 계량 - 대상 차량 선택");

    Composite compContents = new Composite(shell, SWT.NONE);
    compContents.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
    compContents.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    GridLayout gl_compContents = new GridLayout(1, false);
    gl_compContents.marginTop = 10;
    gl_compContents.marginRight = 10;
    gl_compContents.marginLeft = 10;
    gl_compContents.marginBottom = 10;
    gl_compContents.verticalSpacing = 0;
    gl_compContents.marginWidth = 0;
    gl_compContents.marginHeight = 0;
    compContents.setLayout(gl_compContents);

    compCenter = new Composite(compContents, SWT.BORDER);
    compCenter.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1));
    compCenter.setLayout(new GridLayout(2, false));

    car = new CarComposite(compCenter, SWT.NONE);
    car.addFocusListener(
        new FocusAdapter() {
          @Override
          public void focusLost(FocusEvent e) {
            filter();
          }
        });
    car.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
    car.setFont(defaultFont);
    car.setTitle("차량 번호: ");
    car.addFocusListener(new HelpAdapter("차량번호를 입력하거나 목록에서 선택 후 Enter."));

    Button btnSearch = new Button(compCenter, SWT.NONE);
    btnSearch.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            select();
          }
        });
    btnSearch.setFont(btnFont);
    btnSearch.setText(" 조 회 ");

    initGird(compContents);

    Composite btn = new Composite(shell, SWT.NONE);
    btn.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
    btn.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    btn.setBackgroundMode(SWT.INHERIT_FORCE);
    if (user.hasAuth(DTSConstants.AUTH_DEL_FST)) {
      btn.setLayout(new GridLayout(4, false));
    } else {
      btn.setLayout(new GridLayout(3, false));
    }

    Button btnSave = new Button(btn, SWT.NONE);
    GridData gd_btnSave = new GridData(SWT.RIGHT, SWT.FILL, true, false);
    gd_btnSave.heightHint = 36;
    gd_btnSave.widthHint = 130;
    btnSave.setLayoutData(gd_btnSave);
    btnSave.setFont(btnFont);
    btnSave.setText("2차 계량");
    btnSave.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            onClickOK();
          }
        });

    Button btnPrint = new Button(btn, SWT.NONE);
    GridData gd_btnPrint = new GridData(SWT.RIGHT, SWT.FILL, true, false);
    gd_btnPrint.heightHint = 36;
    gd_btnPrint.widthHint = 130;
    btnPrint.setLayoutData(gd_btnPrint);
    btnPrint.setFont(btnFont);
    btnPrint.setText("전표 출력");
    btnPrint.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            Grid g = gridViewer.getGrid();
            if (g.getSelectionIndex() == -1) {
              MessageDialog.openInformation(
                  shell, "데이터 선택 필요", "선택된 데이터가 없습니다. \n\n목록에서 선택 후 작업하세요.");
              return;
            } else {
              if (listData != null && listData.length > g.getSelectionIndex()) {
                TsWgtInfDTO dto = listData[g.getSelectionIndex()];

                PrintUtil.print(dto, preferences.getInt(DTSPreConstants.GN_PRINT_COUNT));
              }
            }
          }
        });

    if (user.hasAuth(DTSConstants.AUTH_DEL_FST)) {
      Button btnDelete = new Button(btn, SWT.NONE);
      GridData gd_btnDelete = new GridData(SWT.CENTER, SWT.FILL, true, false);
      gd_btnDelete.heightHint = 36;
      gd_btnDelete.widthHint = 130;
      btnDelete.setLayoutData(gd_btnDelete);
      btnDelete.setFont(btnFont);
      btnDelete.setText("삭 제");
      btnDelete.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              onClickDelete();
            }
          });
    }
    Button btnCancel = new Button(btn, SWT.NONE);
    btnCancel.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            shell.close();
          }
        });
    GridData gd_btnCancel = new GridData(SWT.LEFT, SWT.FILL, true, false);
    gd_btnCancel.heightHint = 36;
    gd_btnCancel.widthHint = 130;
    btnCancel.setLayoutData(gd_btnCancel);
    btnCancel.setFont(btnFont);
    btnCancel.setText("취  소");

    lblHelp = new CLabel(shell, SWT.LEFT);
    lblHelp.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
    GridData gd_lblHelp = new GridData(SWT.FILL, SWT.CENTER, true, false);
    gd_lblHelp.heightHint = 25;
    lblHelp.setLayoutData(gd_lblHelp);
    lblHelp.setText("도움말:");
    lblHelp.setFont(helpFont);
    lblHelp.setBackgroundImage(ImageRepository.getImage(ImageRepository.POPUP_HELP_BG));

    shell.addListener(
        SWT.Traverse,
        new Listener() {
          public void handleEvent(Event event) {
            if (event.detail == SWT.TRAVERSE_ESCAPE) {
              event.doit = false;
            }
          }
        });
  } // createContents

  protected void onClickDelete() {
    Grid g = gridViewer.getGrid();
    if (g.getSelectionIndex() == -1) {
      MessageDialog.openInformation(shell, "데이터 선택 필요", "선택된 데이터가 없습니다. \n\n목록에서 선택 후 작업하세요.");
      return;
    } else {
      if (listData != null && listData.length > g.getSelectionIndex()) {
        boolean rtn =
            MessageDialog.openConfirm(
                shell,
                "삭제 확인",
                "1차 계량 정보를 삭제하시겠습니까?\n\n차량번호-" + listData[g.getSelectionIndex()].getCar_num());
        if (!rtn) {
          return;
        }
        try {
          TsWgtInfManager wim = new TsWgtInfManager();
          TsWgtInfDTO dto = (TsWgtInfDTO) ObjectUtil.getDefaultObject(TsWgtInfDTO.class.getName());
          dto.setDel_yn(DTSConstants.FLAG_Y);
          dto.setWgt_cd(listData[g.getSelectionIndex()].getWgt_cd());
          wim.updateTsWgtInf(dto);
          // 목록 재조회
          select();
          // HomeView refresh
          HomeView hv =
              (HomeView)
                  PlatformUI.getWorkbench()
                      .getActiveWorkbenchWindow()
                      .getActivePage()
                      .findView(HomeView.ID);
          hv.refreshData();
        } catch (IOException e) {
          MessageDialog.openError(shell, "삭제 오류", "데이터 삭제 중 오류가 발생하였습니다. \n\n" + e.getMessage());
          return;
        }
      }
    }
  }

  protected void filter() {
    TsCarMstDTO item = car.getSelectionItem();
    ArrayList<TsWgtInfDTO> items = filter(item);

    gridViewer.setInput(items.toArray(new TsWgtInfDTO[0]));
    gridViewer.getGrid().setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
  }

  public ArrayList<TsWgtInfDTO> filter(TsCarMstDTO item) {
    ArrayList<TsWgtInfDTO> filtered = new ArrayList<TsWgtInfDTO>();
    if (item.getCar_cd() != null && item.getCar_cd().length() > 0) {
      for (int i = 0; i < listData.length; i++) {
        if (listData[i].getCar_cd().equals(item.getCar_cd())) {
          filtered.add(listData[i]);
        }
      }
    } else {
      for (int i = 0; i < listData.length; i++) {
        if (StringUtil.nullToBlank(listData[i].getCar_num()).indexOf(item.getCar_num()) > -1) {
          filtered.add(listData[i]);
        }
      }
    }
    return filtered;
  }
  /** init */
  private void init() {
    TsMstManager mgr = new TsMstManager();
    car.setItems(mgr.selectTsCarMst(null));
    select();
  } // initData

  private void select() {
    TsCarMstDTO item = car.getSelectionItem();
    if (item.getCar_num().length() == 0) {
      TsWgtInfManager wim = new TsWgtInfManager();
      TsWgtInfDTO param = new TsWgtInfDTO();
      param.setWgt_stat_cd(DTSConstants.WGT_STAT_FST);
      ArrayList<TsWgtInfDTO> fstList = wim.selectTsWgtInf(param);
      for (int i = 0; i < fstList.size(); i++) fstList.get(i).setNo(i + 1);
      listData = fstList.toArray(new TsWgtInfDTO[0]);
      gridViewer.setInput(listData);
    } else {
      filter();
    }
  }
  /** OK Button click event */
  private void onClickOK() {
    Grid g = gridViewer.getGrid();
    if (g.getSelectionIndex() == -1) {
      MessageDialog.openInformation(shell, "데이터 선택 필요", "선택된 데이터가 없습니다. \n\n목록에서 선택 후 작업하세요.");
      return;
    } else {
      if (listData != null && listData.length > g.getSelectionIndex()) {
        TsWgtInfDTO vo = listData[g.getSelectionIndex()];
        WeighSecondDialog dialog =
            new WeighSecondDialog(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
        shell.close();

        Object answer = dialog.open(vo);
        if (answer != null) {
          HomeView hv =
              (HomeView)
                  PlatformUI.getWorkbench()
                      .getActiveWorkbenchWindow()
                      .getActivePage()
                      .findView(HomeView.ID);
          hv.refreshData();
        }
      }
    }
  }

  private void initGird(Composite compContents) {
    gridViewer = new GridTableViewer(compContents, SWT.V_SCROLL | SWT.BORDER);
    gridViewer.setLabelProvider(new ListGridLabelProvider());
    gridViewer.setContentProvider(new ListGridContentProvider());
    gridViewer.getGrid().setSelectionEnabled(true);
    gridViewer.getGrid().setFont(SWTResourceManager.getFont("Arial", 16, SWT.NORMAL));
    gridViewer.getGrid().setItemHeight(28);
    gridViewer.getGrid().addFocusListener(new HelpAdapter("계류차량 선택 후 더블클릭 또는 [2차 계량] 버튼 클릭."));

    gridViewer.setCellEditors(
        new CellEditor[] {
          new TextCellEditor(gridViewer.getGrid()), new TextCellEditor(gridViewer.getGrid())
        });
    gridViewer.setCellModifier(
        new ICellModifier() {

          public boolean canModify(Object element, String property) {
            return false;
          }

          public Object getValue(Object element, String property) {
            return element.toString();
          }

          public void modify(Object element, String property, Object value) {}
        });
    gridViewer.setColumnProperties(colProp);
    ColumnViewerEditorActivationStrategy actSupport =
        new ColumnViewerEditorActivationStrategy(gridViewer) {
          protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) {
            return event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL
                || event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION
                || (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED
                    && event.keyCode == SWT.CR);
          }
        };
    GridViewerEditor.create(
        gridViewer,
        actSupport,
        ColumnViewerEditor.TABBING_HORIZONTAL
            | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR
            | ColumnViewerEditor.TABBING_VERTICAL
            | ColumnViewerEditor.KEYBOARD_ACTIVATION);

    GridColumnGroup cgSpot = new GridColumnGroup(gridViewer.getGrid(), SWT.CENTER);
    cgSpot.setText("        1차 계량");

    for (int i = 0; i < colName.length; i++) {
      GridColumn column = null;
      if (i == 3 || i == 4) {
        column = new GridColumn(cgSpot, SWT.NONE);
      } else {
        column = new GridColumn(gridViewer.getGrid(), SWT.NONE);
      }
      column.setWidth(colWidth[i]);
      column.setAlignment(colAlign[i]);
      column.setText(colName[i]);
      column.setResizeable(true);
    }

    gridViewer.getGrid().setLinesVisible(true);
    gridViewer.getGrid().setHeaderVisible(true);
    gridViewer
        .getGrid()
        .addMouseListener(
            new MouseAdapter() {
              @Override
              public void mouseDoubleClick(MouseEvent evt) {
                Grid g = (Grid) evt.getSource();
                if (listData != null
                    && listData.length > g.getSelectionIndex()
                    && g.getSelectionIndex() != -1) {
                  TsWgtInfDTO vo = listData[g.getSelectionIndex()];
                  WeighSecondDialog dialog =
                      new WeighSecondDialog(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
                  shell.close();

                  Object answer = dialog.open(vo);
                  if (answer != null) {
                    HomeView hv =
                        (HomeView)
                            PlatformUI.getWorkbench()
                                .getActiveWorkbenchWindow()
                                .getActivePage()
                                .findView(HomeView.ID);
                    hv.refreshData();
                  }
                }
              }
            });
    Grid grid = gridViewer.getGrid();
    grid.addControlListener(
        new ControlAdapter() {
          @Override
          public void controlResized(ControlEvent e) {
            int width = 0;
            for (int i = 0; i < gridViewer.getGrid().getColumnCount(); i++) {
              width = (int) (colWidth[i] * gridViewer.getGrid().getClientArea().width / 100);
              if (i == gridViewer.getGrid().getColumnCount() - 1) {
                width += 5;
              }
              gridViewer.getGrid().getColumn(i).setWidth(width);
            }
            int add = gridViewer.getGrid().getBounds().width / 100 - 0;
            gridViewer
                .getGrid()
                .setFont(SWTResourceManager.getFont("Arial", 12 + (add > 0 ? add : 0), SWT.NORMAL));
          }
        });
    grid.setRowsResizeable(true);

    grid.setLineColor(ColorRepository.getColor(ColorRepository.GRID_LINE));
    // grid.setBackgroundMode(SWT.INHERIT_FORCE);
    GridData gridViewerLData = new GridData();
    gridViewerLData.grabExcessHorizontalSpace = true;
    gridViewerLData.horizontalAlignment = GridData.FILL;
    gridViewerLData.grabExcessVerticalSpace = true;
    gridViewerLData.verticalAlignment = GridData.FILL;
    gridViewerLData.verticalIndent = 5;
    gridViewer.getGrid().setLayoutData(gridViewerLData);
  } // initGird

  public class ListGridLabelProvider extends LabelProvider
      implements ITableLabelProvider, ITableFontProvider, ITableColorProvider {
    FontRegistry registry = new FontRegistry();

    public Image getColumnImage(Object element, int columnIndex) {
      return null;
    }

    public String getColumnText(Object element, int columnIndex) {
      TsWgtInfDTO data = (TsWgtInfDTO) element;
      Object o = StringUtil.invoke(data, StringUtil.makeGetter(colProp[columnIndex]), null);
      if (columnIndex == 3) {
        return StringUtil.extractTime(o);
      }
      return StringUtil.extractString(o, 0);
    }

    public Font getFont(Object element, int columnIndex) {

      return null;
    }

    public Color getBackground(Object element, int columnIndex) {
      TsWgtInfDTO data = (TsWgtInfDTO) element;
      if (data.getNo() % 2 == 0) {
        return ColorRepository.getColor(ColorRepository.GRID_ODD_BG);
      }
      return null;
    }

    public Color getForeground(Object element, int columnIndex) {
      TsWgtInfDTO data = (TsWgtInfDTO) element;
      if (data.getNo() % 2 == 0) {
        return Display.getCurrent().getSystemColor(SWT.COLOR_DARK_BLUE);
      }
      return null;
    }
  } // class ListGridLabelProvider

  private class ListGridContentProvider implements IStructuredContentProvider {
    public Object[] getElements(Object inputElement) {
      return (TsWgtInfDTO[]) inputElement;
    }

    public void dispose() {}

    public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
  } // class ListGridContentProvider

  private void setMessage(String msg) {
    lblHelp.setText("도움말:" + msg);
  }

  class HelpAdapter extends FocusAdapter {

    String msg = "";

    HelpAdapter(String msg) {
      this.msg = msg;
    }

    @Override
    public void focusGained(FocusEvent e) {
      setMessage(msg);
    }

    @Override
    public void focusLost(FocusEvent e) {
      setMessage("");
    }
  } // class HelpAdapter
}
  private void initGird(Composite compContents) {
    gridViewer = new GridTableViewer(compContents, SWT.V_SCROLL | SWT.BORDER);
    gridViewer.setLabelProvider(new ListGridLabelProvider());
    gridViewer.setContentProvider(new ListGridContentProvider());
    gridViewer.getGrid().setSelectionEnabled(true);
    gridViewer.getGrid().setFont(SWTResourceManager.getFont("Arial", 16, SWT.NORMAL));
    gridViewer.getGrid().setItemHeight(28);
    gridViewer.getGrid().addFocusListener(new HelpAdapter("계류차량 선택 후 더블클릭 또는 [2차 계량] 버튼 클릭."));

    gridViewer.setCellEditors(
        new CellEditor[] {
          new TextCellEditor(gridViewer.getGrid()), new TextCellEditor(gridViewer.getGrid())
        });
    gridViewer.setCellModifier(
        new ICellModifier() {

          public boolean canModify(Object element, String property) {
            return false;
          }

          public Object getValue(Object element, String property) {
            return element.toString();
          }

          public void modify(Object element, String property, Object value) {}
        });
    gridViewer.setColumnProperties(colProp);
    ColumnViewerEditorActivationStrategy actSupport =
        new ColumnViewerEditorActivationStrategy(gridViewer) {
          protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) {
            return event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL
                || event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION
                || (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED
                    && event.keyCode == SWT.CR);
          }
        };
    GridViewerEditor.create(
        gridViewer,
        actSupport,
        ColumnViewerEditor.TABBING_HORIZONTAL
            | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR
            | ColumnViewerEditor.TABBING_VERTICAL
            | ColumnViewerEditor.KEYBOARD_ACTIVATION);

    GridColumnGroup cgSpot = new GridColumnGroup(gridViewer.getGrid(), SWT.CENTER);
    cgSpot.setText("        1차 계량");

    for (int i = 0; i < colName.length; i++) {
      GridColumn column = null;
      if (i == 3 || i == 4) {
        column = new GridColumn(cgSpot, SWT.NONE);
      } else {
        column = new GridColumn(gridViewer.getGrid(), SWT.NONE);
      }
      column.setWidth(colWidth[i]);
      column.setAlignment(colAlign[i]);
      column.setText(colName[i]);
      column.setResizeable(true);
    }

    gridViewer.getGrid().setLinesVisible(true);
    gridViewer.getGrid().setHeaderVisible(true);
    gridViewer
        .getGrid()
        .addMouseListener(
            new MouseAdapter() {
              @Override
              public void mouseDoubleClick(MouseEvent evt) {
                Grid g = (Grid) evt.getSource();
                if (listData != null
                    && listData.length > g.getSelectionIndex()
                    && g.getSelectionIndex() != -1) {
                  TsWgtInfDTO vo = listData[g.getSelectionIndex()];
                  WeighSecondDialog dialog =
                      new WeighSecondDialog(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
                  shell.close();

                  Object answer = dialog.open(vo);
                  if (answer != null) {
                    HomeView hv =
                        (HomeView)
                            PlatformUI.getWorkbench()
                                .getActiveWorkbenchWindow()
                                .getActivePage()
                                .findView(HomeView.ID);
                    hv.refreshData();
                  }
                }
              }
            });
    Grid grid = gridViewer.getGrid();
    grid.addControlListener(
        new ControlAdapter() {
          @Override
          public void controlResized(ControlEvent e) {
            int width = 0;
            for (int i = 0; i < gridViewer.getGrid().getColumnCount(); i++) {
              width = (int) (colWidth[i] * gridViewer.getGrid().getClientArea().width / 100);
              if (i == gridViewer.getGrid().getColumnCount() - 1) {
                width += 5;
              }
              gridViewer.getGrid().getColumn(i).setWidth(width);
            }
            int add = gridViewer.getGrid().getBounds().width / 100 - 0;
            gridViewer
                .getGrid()
                .setFont(SWTResourceManager.getFont("Arial", 12 + (add > 0 ? add : 0), SWT.NORMAL));
          }
        });
    grid.setRowsResizeable(true);

    grid.setLineColor(ColorRepository.getColor(ColorRepository.GRID_LINE));
    // grid.setBackgroundMode(SWT.INHERIT_FORCE);
    GridData gridViewerLData = new GridData();
    gridViewerLData.grabExcessHorizontalSpace = true;
    gridViewerLData.horizontalAlignment = GridData.FILL;
    gridViewerLData.grabExcessVerticalSpace = true;
    gridViewerLData.verticalAlignment = GridData.FILL;
    gridViewerLData.verticalIndent = 5;
    gridViewer.getGrid().setLayoutData(gridViewerLData);
  } // initGird
  /** Create contents of the shell. */
  protected void createContents() {
    setText("List of values");
    setSize(500, 401);

    CTabFolder tabFolder = new CTabFolder(this, SWT.BORDER);
    tabFolder.setSimple(false);
    tabFolder.setSingle(true);
    tabFolder.setBounds(10, 10, 472, 351);
    tabFolder.setSelectionBackground(
        Display.getCurrent().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT));

    CTabItem tbtmPatient = new CTabItem(tabFolder, SWT.NONE);
    tbtmPatient.setFont(SWTResourceManager.getFont("Tahoma", 9, SWT.BOLD));
    tbtmPatient.setText("Medicine");

    Composite composite = new Composite(tabFolder, SWT.NONE);
    tbtmPatient.setControl(composite);

    PGroup grpSearch = new PGroup(composite, SWT.SMOOTH);
    grpSearch.setBounds(10, 10, 446, 46);
    grpSearch.setStrategy(new RectangleGroupStrategy());
    grpSearch.setToggleRenderer(new ChevronsToggleRenderer());
    grpSearch.setText("Search");

    txtID = new Text(grpSearch, SWT.BORDER);
    txtID.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            if (e.keyCode == 13) {
              search();
            }
          }
        });
    txtID.setBounds(27, 24, 117, 19);

    txtName = new Text(grpSearch, SWT.BORDER);
    txtName.setBounds(194, 24, 168, 19);
    txtName.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            if (e.keyCode == 13) {
              search();
            }
          }
        });

    Label lblId = new Label(grpSearch, SWT.NONE);
    lblId.setAlignment(SWT.RIGHT);
    lblId.setBounds(10, 27, 11, 13);
    lblId.setText("ID");

    Label lblName = new Label(grpSearch, SWT.NONE);
    lblName.setText("Name");
    lblName.setAlignment(SWT.RIGHT);
    lblName.setBounds(161, 27, 27, 13);

    Button btnSearch = new Button(grpSearch, SWT.NONE);
    btnSearch.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            search();
          }
        });
    btnSearch.setBounds(368, 23, 68, 21);
    btnSearch.setText("Search");

    tblMedicine = new Table(composite, SWT.BORDER | SWT.FULL_SELECTION);
    tblMedicine.setBounds(10, 62, 446, 226);
    tblMedicine.setHeaderVisible(true);
    tblMedicine.setLinesVisible(true);

    TableColumn tblcolId = new TableColumn(tblMedicine, SWT.NONE);
    tblcolId.setWidth(160);
    tblcolId.setText("ID");

    TableColumn tblcolName = new TableColumn(tblMedicine, SWT.NONE);
    tblcolName.setWidth(280);
    tblcolName.setText("Name");

    Button btnCancel = new Button(composite, SWT.NONE);
    btnCancel.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            dispose();
          }
        });
    btnCancel.setBounds(388, 294, 68, 23);
    btnCancel.setText("Cancel");

    Button btnOk = new Button(composite, SWT.NONE);
    btnOk.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            dispose();
          }
        });
    btnOk.setBounds(314, 294, 68, 23);
    btnOk.setText("OK");
  }
  /** Create contents of the window */
  protected void createContents() {

    m_shell = new Shell();

    m_shell.setImage(SWTResourceManager.getImage(IPAToolAppWnd.class, "/Properties.ico"));
    final BorderLayout borderLayout = new BorderLayout(0, 0);
    borderLayout.setVgap(5);
    m_shell.setLayout(borderLayout);
    m_shell.setSize(800, 400);
    m_shell.setMinimumSize(new Point(800, 400));
    m_shell.setText("IPATool2");

    Composite composite;
    composite = new Composite(m_shell, SWT.NONE);
    {
      TabFolder tabFolder = new TabFolder(composite, SWT.NONE);
      tabFolder.setBounds(10, 10, 748, 200);

      {
        TabItem tbtmTools = new TabItem(tabFolder, SWT.NONE);
        tbtmTools.setText("Tools");

        Composite composite_1 = new Composite(tabFolder, SWT.NONE);
        tbtmTools.setControl(composite_1);

        m_txtUpdFolder = new Text(composite_1, SWT.BORDER);
        m_txtUpdFolder.setText("");
        m_txtUpdFolder.setBounds(122, 14, 564, 21);

        Button btnUpdFolder = new Button(composite_1, SWT.NONE);
        btnUpdFolder.addSelectionListener(
            new SelectionAdapter() {

              @Override
              public void widgetSelected(SelectionEvent e) {
                _selectFolder(m_txtUpdFolder);
              }
            });
        btnUpdFolder.setText("...");
        btnUpdFolder.setBounds(692, 12, 38, 25);

        m_txtExistingFolder = new Text(composite_1, SWT.BORDER);
        m_txtExistingFolder.setText("");
        m_txtExistingFolder.setBounds(122, 45, 564, 21);

        Button btnExFolder = new Button(composite_1, SWT.NONE);
        btnExFolder.addSelectionListener(
            new SelectionAdapter() {

              @Override
              public void widgetSelected(SelectionEvent e) {
                _selectFolder(m_txtExistingFolder);
              }
            });
        btnExFolder.setText("...");
        btnExFolder.setBounds(692, 43, 38, 25);

        m_txtITunesFolder = new Text(composite_1, SWT.BORDER);
        m_txtITunesFolder.setText("");
        m_txtITunesFolder.setBounds(122, 76, 564, 21);

        Button btnitunesFolder = new Button(composite_1, SWT.NONE);
        btnitunesFolder.addSelectionListener(
            new SelectionAdapter() {

              @Override
              public void widgetSelected(SelectionEvent e) {
                _selectFolder(m_txtITunesFolder);
              }
            });
        btnitunesFolder.setText("...");
        btnitunesFolder.setBounds(692, 74, 38, 25);

        m_lbliTunes = new Label(composite_1, SWT.NONE);
        m_lbliTunes.setText("iTunes IPAs Folder:");
        m_lbliTunes.setBounds(10, 79, 119, 15);

        m_lblExFolder = new Label(composite_1, SWT.NONE);
        m_lblExFolder.setText("Current IPAs Folder:");
        m_lblExFolder.setBounds(10, 48, 119, 15);

        Label lblUpdFolder = new Label(composite_1, SWT.NONE);
        lblUpdFolder.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD));
        lblUpdFolder.setForeground(SWTResourceManager.getColor(SWT.COLOR_RED));
        lblUpdFolder.setText(" IPAs Folder:");
        lblUpdFolder.setBounds(10, 17, 119, 15);
        {
          m_chkRecurseFolders = new Button(composite_1, SWT.CHECK);
          m_chkRecurseFolders.addSelectionListener(
              new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {}
              });
          m_chkRecurseFolders.setLocation(122, 103);
          m_chkRecurseFolders.setSize(107, 16);
          m_chkRecurseFolders.setSelection(true);
          m_chkRecurseFolders.setText("Recurse folders");
        }
        {
          m_btnRenameIPAs = new Button(composite_1, SWT.NONE);
          m_btnRenameIPAs.setBackground(SWTResourceManager.getColor(SWT.COLOR_RED));
          m_btnRenameIPAs.setLocation(120, 137);
          m_btnRenameIPAs.setSize(94, 25);
          m_btnRenameIPAs.addSelectionListener(
              new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                  renameIPAs();
                }
              });
          m_btnRenameIPAs.setText("Rename IPAs");
        }

        m_btnUpdateIPAs = new Button(composite_1, SWT.NONE);
        m_btnUpdateIPAs.addSelectionListener(
            new SelectionAdapter() {

              @Override
              public void widgetSelected(SelectionEvent e) {
                updateIPAs();
              }
            });
        m_btnUpdateIPAs.setBounds(216, 137, 94, 25);
        m_btnUpdateIPAs.setText("Update IPAs");

        m_chkUseAllFolders = new Button(composite_1, SWT.CHECK);
        m_chkUseAllFolders.addSelectionListener(
            new SelectionAdapter() {

              @Override
              public void widgetSelected(SelectionEvent e) {
                if (m_chkUseAllFolders.getSelection()) {
                  m_lblExFolder.setForeground(SWTResourceManager.getColor(SWT.COLOR_RED));
                  m_lbliTunes.setForeground(SWTResourceManager.getColor(SWT.COLOR_RED));
                } else {
                  m_lblExFolder.setForeground(null);
                  m_lbliTunes.setForeground(null);
                }
              }
            });
        m_chkUseAllFolders.setBounds(244, 103, 107, 16);
        m_chkUseAllFolders.setText("Use all folders");

        m_btnCleanJPGs = new Button(composite_1, SWT.NONE);
        m_btnCleanJPGs.setBackground(SWTResourceManager.getColor(SWT.COLOR_RED));
        m_btnCleanJPGs.setBounds(310, 137, 94, 25);
        m_btnCleanJPGs.addSelectionListener(
            new SelectionAdapter() {

              @Override
              public void widgetSelected(SelectionEvent e) {
                cleanJPEGs();
              }
            });
        m_btnCleanJPGs.setText("Clean JPEGs");
      }

      TabItem tbtmCheckIPAs = new TabItem(tabFolder, SWT.NONE);
      tbtmCheckIPAs.setText("Check");

      Composite composite_1 = new Composite(tabFolder, SWT.NONE);
      tbtmCheckIPAs.setControl(composite_1);

      m_txtIPhoneFolder = new Text(composite_1, SWT.BORDER);
      m_txtIPhoneFolder.setText("");
      m_txtIPhoneFolder.setBounds(122, 14, 564, 21);

      Button btnIPhoneFolder = new Button(composite_1, SWT.NONE);
      btnIPhoneFolder.addSelectionListener(
          new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
              _selectFolder(m_txtIPhoneFolder);
            }
          });
      btnIPhoneFolder.setText("...");
      btnIPhoneFolder.setBounds(692, 12, 38, 25);

      m_txtIPadFolder = new Text(composite_1, SWT.BORDER);
      m_txtIPadFolder.setText("");
      m_txtIPadFolder.setBounds(122, 45, 564, 21);

      Button btnIPadFolder = new Button(composite_1, SWT.NONE);
      btnIPadFolder.addSelectionListener(
          new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
              _selectFolder(m_txtIPadFolder);
            }
          });
      btnIPadFolder.setText("...");
      btnIPadFolder.setBounds(692, 43, 38, 25);

      m_txtMixedFolder = new Text(composite_1, SWT.BORDER);
      m_txtMixedFolder.setText("");
      m_txtMixedFolder.setBounds(122, 76, 564, 21);

      Button btnMixedFolder = new Button(composite_1, SWT.NONE);
      btnMixedFolder.addSelectionListener(
          new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
              _selectFolder(m_txtMixedFolder);
            }
          });
      btnMixedFolder.setText("...");
      btnMixedFolder.setBounds(692, 74, 38, 25);

      Label lblBothIpasFolder = new Label(composite_1, SWT.NONE);
      lblBothIpasFolder.setText("mixed Folder:");
      lblBothIpasFolder.setBounds(10, 79, 119, 15);

      Label lblIpadIpasFolder = new Label(composite_1, SWT.NONE);
      lblIpadIpasFolder.setText("iPad Folder:");
      lblIpadIpasFolder.setBounds(10, 48, 119, 15);

      Label lblIphoneFolder = new Label(composite_1, SWT.NONE);
      lblIphoneFolder.setText("iPhone Folder:");
      lblIphoneFolder.setBounds(10, 17, 119, 15);

      m_btnCheck = new Button(composite_1, SWT.NONE);
      m_btnCheck.addSelectionListener(
          new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
              checkIPAs();
            }
          });
      m_btnCheck.setText("Check IPAs");
      m_btnCheck.setBounds(122, 122, 90, 25);
    }
    composite.setLayoutData(BorderLayout.NORTH);

    final Label lblX = new Label(composite, SWT.NONE);
    lblX.setBounds(10, 10, 14, 211);
    final TabFolder m_tabTraces = new TabFolder(m_shell, SWT.NONE);
    m_tabTraces.setLayoutData(BorderLayout.CENTER);

    final Composite composite_1 = new Composite(m_shell, SWT.NONE);
    composite_1.setLayout(new BorderLayout(0, 0));
    composite_1.setLayoutData(BorderLayout.CENTER);

    // ------------------------------------------------------------------------
    // ********** TabbedTracer ***********************************************
    final CTabFolder tabTraces = m_tabbedTracer.createTabFolder(composite_1);
    tabTraces.setLayoutData(BorderLayout.CENTER);
    Tracer.setTracer(m_tabbedTracer);
  }
  /**
   * Create the shell.
   *
   * @param display
   */
  public AdministratorShell(Display display) {
    super(display, SWT.SHELL_TRIM);
    setImage(
        SWTResourceManager.getImage(AdministratorShell.class, "/com/hms/icon/hms-admin-icon.png"));

    Group grpNgiSDng = new Group(this, SWT.NONE);
    grpNgiSDng.setText(Messages.getString("HMS.AdministratorShell.group.user"));
    grpNgiSDng.setBounds(10, 10, 216, 319);

    List list = new List(grpNgiSDng, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    list.setFont(SWTResourceManager.getFont("Times New Roman", 12, SWT.NORMAL));
    list.setItems(
        new String[] {
          "Nguyễn Văn A0",
          "Nguyễn Văn B0",
          "Nguyễn Văn C0",
          "Nguyễn Văn A",
          "Nguyễn Văn B",
          "Nguyễn Văn C",
          "Nguyễn Văn A",
          "Nguyễn Văn B",
          "Nguyễn Văn C",
          "Nguyễn Văn A",
          "Nguyễn Văn B",
          "Nguyễn Văn C",
          "Nguyễn Văn A",
          "Nguyễn Văn B",
          "Nguyễn Văn C1",
          "Nguyễn Văn A1",
          "Nguyễn Văn B2",
          "Nguyễn Văn C2"
        });
    list.setBounds(10, 20, 196, 289);

    Group grpThngTinNgi = new Group(this, SWT.NONE);
    grpThngTinNgi.setText(Messages.getString("HMS.AdministratorShell.group.user_info"));
    grpThngTinNgi.setBounds(232, 10, 650, 213);

    Label lblTnngNhp = new Label(grpThngTinNgi, SWT.NONE);
    lblTnngNhp.setFont(SWTResourceManager.getFont("Times New Roman", 12, SWT.BOLD));
    lblTnngNhp.setBounds(10, 33, 136, 21);
    lblTnngNhp.setText(Messages.getString("HMS.AdministratorShell.group.user_info.label.username"));

    text = new Text(grpThngTinNgi, SWT.BORDER);
    text.addFocusListener(
        new FocusAdapter() {
          @Override
          public void focusGained(FocusEvent e) {
            text.selectAll();
          }
        });
    text.setBounds(152, 33, 251, 21);
    text.setFocus();
    text.setTopIndex(0);

    Label lblMtKhu = new Label(grpThngTinNgi, SWT.NONE);
    lblMtKhu.setText(Messages.getString("HMS.AdministratorShell.group.user_info.label.password"));
    lblMtKhu.setFont(SWTResourceManager.getFont("Times New Roman", 12, SWT.BOLD));
    lblMtKhu.setBounds(10, 60, 136, 21);

    text_1 = new Text(grpThngTinNgi, SWT.BORDER | SWT.PASSWORD);
    text_1.setBounds(152, 60, 251, 21);
    text_1.setTopIndex(1);

    Label lblXcNhnMt = new Label(grpThngTinNgi, SWT.NONE);
    lblXcNhnMt.setText(
        Messages.getString("HMS.AdministratorShell.group.user_info.label.confirm_password"));
    lblXcNhnMt.setFont(SWTResourceManager.getFont("Times New Roman", 12, SWT.BOLD));
    lblXcNhnMt.setBounds(10, 87, 136, 21);

    text_2 = new Text(grpThngTinNgi, SWT.BORDER | SWT.PASSWORD);
    text_2.setBounds(152, 87, 251, 21);
    text_2.setTopIndex(2);

    Label label = new Label(grpThngTinNgi, SWT.SEPARATOR | SWT.HORIZONTAL);
    label.setBounds(0, 114, 650, 2);

    Label lblTny = new Label(grpThngTinNgi, SWT.NONE);
    lblTny.setText(Messages.getString("HMS.AdministratorShell.group.user_info.label.fullname"));
    lblTny.setFont(SWTResourceManager.getFont("Times New Roman", 12, SWT.BOLD));
    lblTny.setBounds(10, 122, 136, 21);

    text_3 = new Text(grpThngTinNgi, SWT.BORDER);
    text_3.setBounds(152, 122, 251, 21);
    text_3.setTopIndex(3);

    Label lblEmail = new Label(grpThngTinNgi, SWT.NONE);
    lblEmail.setText(Messages.getString("HMS.AdministratorShell.group.user_info.label.email"));
    lblEmail.setFont(SWTResourceManager.getFont("Times New Roman", 12, SWT.BOLD));
    lblEmail.setBounds(10, 149, 136, 21);

    text_4 = new Text(grpThngTinNgi, SWT.BORDER);
    text_4.setBounds(152, 149, 251, 21);
    text_4.setTopIndex(4);

    Label lblHnhnh = new Label(grpThngTinNgi, SWT.NONE);
    lblHnhnh.setText(Messages.getString("HMS.AdministratorShell.group.user_info.label.picture"));
    lblHnhnh.setFont(SWTResourceManager.getFont("Times New Roman", 12, SWT.BOLD));
    lblHnhnh.setBounds(10, 176, 136, 21);

    text_5 = new Text(grpThngTinNgi, SWT.BORDER);
    text_5.setBounds(152, 176, 251, 21);
    text_5.setTopIndex(5);

    Group grpQuynSDng = new Group(this, SWT.NONE);
    grpQuynSDng.setText(Messages.getString("HMS.AdministratorShell.group.user_privileges"));
    grpQuynSDng.setBounds(232, 229, 650, 370);

    Label lblNhmChcNng = new Label(grpQuynSDng, SWT.NONE);
    lblNhmChcNng.setFont(SWTResourceManager.getFont("Times New Roman", 12, SWT.BOLD));
    lblNhmChcNng.setBounds(10, 27, 120, 21);
    lblNhmChcNng.setText(
        Messages.getString("HMS.AdministratorShell.group.user_privileges.label.group_function"));

    final List list_1 = new List(grpQuynSDng, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    list_1.setTopIndex(6);

    final java.util.List<LinkedList<String>> list_2_model = new LinkedList<LinkedList<String>>();
    LinkedList<String> tempList = new LinkedList<String>();
    tempList.add("Sử dụng CN 1");
    tempList.add("Thêm CN 1");
    tempList.add("Xóa CN 1");

    list_2_model.add(tempList);

    tempList = new LinkedList<String>();
    tempList.add("Thêm CN 2");
    tempList.add("Xóa CN 2");

    list_2_model.add(tempList);

    final java.util.List<LinkedList<String>> list_3_model = new LinkedList<LinkedList<String>>();
    list_3_model.add(new LinkedList<String>());
    list_3_model.add(new LinkedList<String>());

    final List list_2 = new List(grpQuynSDng, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI);
    list_2.setTopIndex(7);
    final List list_3 = new List(grpQuynSDng, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI);
    list_3.setTopIndex(12);

    list_1.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            List list = (List) e.widget;
            int[] selectedItems = list.getSelectionIndices();
            list_2.removeAll();
            list_3.removeAll();

            if (selectedItems.length == 1) {
              switch (selectedItems[0]) {
                case 0:
                  for (String item : list_2_model.get(0)) {
                    list_2.add(item);
                  }

                  for (String item : list_3_model.get(0)) {
                    list_3.add(item);
                  }

                  break;
                case 1:
                  for (String item : list_2_model.get(1)) {
                    list_2.add(item);
                  }

                  for (String item : list_3_model.get(1)) {
                    list_3.add(item);
                  }

                  break;
              }
            }
          }
        });
    list_1.setItems(new String[] {"Chức năng 1", "Chức năng 2"});
    list_1.setBounds(10, 54, 178, 306);

    Label label_2 = new Label(grpQuynSDng, SWT.SEPARATOR | SWT.VERTICAL);
    label_2.setBounds(204, 10, 2, 357);

    Label lblCcQuynSn = new Label(grpQuynSDng, SWT.NONE);
    lblCcQuynSn.setText(
        Messages.getString("HMS.AdministratorShell.group.user_privileges.label.privileges"));
    lblCcQuynSn.setFont(SWTResourceManager.getFont("Times New Roman", 12, SWT.BOLD));
    lblCcQuynSn.setBounds(220, 27, 120, 21);

    list_2.setBounds(220, 54, 178, 306);

    Label lblCcQuync = new Label(grpQuynSDng, SWT.NONE);
    lblCcQuync.setText(
        Messages.getString("HMS.AdministratorShell.group.user_privileges.label.used_privileges"));
    lblCcQuync.setFont(SWTResourceManager.getFont("Times New Roman", 12, SWT.BOLD));
    lblCcQuync.setBounds(462, 27, 165, 21);

    Button button = new Button(grpQuynSDng, SWT.NONE);
    button.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            LinkedList<String> temp = new LinkedList<String>();

            for (int selectedIndex : list_2.getSelectionIndices()) {
              list_3_model.get(list_1.getSelectionIndex()).add(list_2.getItem(selectedIndex));
              list_3.add(list_2.getItem(selectedIndex));

              temp.add(list_2_model.get(list_1.getSelectionIndex()).get(selectedIndex));
            }

            // Set selected items on destination list
            list_3.setSelection(
                list_3.getItemCount() - list_2.getSelectionCount(), list_3.getItemCount());

            // Remove on source list
            list_2.remove(list_2.getSelectionIndices());

            for (String removedItem : temp) {
              list_2_model.get(list_1.getSelectionIndex()).remove(removedItem);
            }
          }
        });
    button.setText(">");
    button.setBounds(411, 125, 37, 30);

    Button button_1 = new Button(grpQuynSDng, SWT.NONE);
    button_1.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            LinkedList<String> temp = new LinkedList<String>();

            for (int selectedIndex : list_3.getSelectionIndices()) {
              list_2_model.get(list_1.getSelectionIndex()).add(list_3.getItem(selectedIndex));
              list_2.add(list_3.getItem(selectedIndex));

              temp.add(list_3_model.get(list_1.getSelectionIndex()).get(selectedIndex));
            }

            // Set selected items on destination list
            list_2.setSelection(
                list_2.getItemCount() - list_3.getSelectionCount(), list_2.getItemCount());

            // Remove on source list
            list_3.remove(list_3.getSelectionIndices());

            for (String removedItem : temp) {
              list_3_model.get(list_1.getSelectionIndex()).remove(removedItem);
            }
          }
        });
    button_1.setText("<");
    button_1.setBounds(411, 170, 37, 30);

    Button button_2 = new Button(grpQuynSDng, SWT.NONE);
    button_2.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            for (int i = 0; i < list_2.getItemCount(); i++) {
              list_3_model.get(list_1.getSelectionIndex()).add(list_2.getItem(i));
              list_3.add(list_2.getItem(i));
            }

            // Select all items of destination list
            list_3.selectAll();

            // Remove source list
            list_2.removeAll();
            list_2_model.get(list_1.getSelectionIndex()).clear();
          }
        });
    button_2.setText(">>");
    button_2.setBounds(411, 215, 37, 30);

    Button button_3 = new Button(grpQuynSDng, SWT.NONE);
    button_3.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            for (int i = 0; i < list_3.getItemCount(); i++) {
              list_2_model.get(list_1.getSelectionIndex()).add(list_3.getItem(i));
              list_2.add(list_3.getItem(i));
            }

            // Select all items of destination list
            list_2.selectAll();

            // Remove source list
            list_3.removeAll();
            list_3_model.get(list_1.getSelectionIndex()).clear();
          }
        });
    button_3.setToolTipText("");
    button_3.setText("<<");
    button_3.setBounds(411, 260, 37, 30);

    list_3.setBounds(462, 54, 178, 306);

    Composite composite = new Composite(this, SWT.BORDER);
    composite.setBounds(232, 605, 650, 55);

    Button btnLu = new Button(composite, SWT.NONE);
    btnLu.setImage(
        SWTResourceManager.getImage(AdministratorShell.class, "/com/hms/icon/hms-save-icon.png"));
    btnLu.setFont(SWTResourceManager.getFont("Times New Roman", 12, SWT.BOLD));
    btnLu.setText(Messages.getString("HMS.AdministratorShell.button.save"));
    btnLu.setBounds(350, 10, 110, 30);

    Button btnHy = new Button(composite, SWT.NONE);
    btnHy.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            dispose();
          }
        });
    btnHy.setImage(
        SWTResourceManager.getImage(AdministratorShell.class, "/com/hms/icon/hms-cancel-icon.png"));
    btnHy.setFont(SWTResourceManager.getFont("Times New Roman", 12, SWT.BOLD));
    btnHy.setBounds(500, 10, 110, 30);
    btnHy.setText(Messages.getString("HMS.AdministratorShell.button.cancel"));

    Button btnThmMi = new Button(composite, SWT.NONE);
    btnThmMi.setImage(
        SWTResourceManager.getImage(AdministratorShell.class, "/com/hms/icon/hms-add-icon.png"));
    btnThmMi.setEnabled(false);
    btnThmMi.setFont(SWTResourceManager.getFont("Times New Roman", 12, SWT.BOLD));
    btnThmMi.setText(Messages.getString("HMS.AdministratorShell.button.add"));
    btnThmMi.setBounds(200, 10, 110, 30);
    createContents();
  }