Example usage for com.google.gwt.user.client.ui FlexTable FlexTable

List of usage examples for com.google.gwt.user.client.ui FlexTable FlexTable

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui FlexTable FlexTable.

Prototype

public FlexTable() 

Source Link

Usage

From source file:com.dawg6.web.dhcalc.client.SkillData.java

License:Open Source License

public SkillData() {

    data.setDefaults();//ww w . java 2s . c  o  m

    VerticalPanel panel = new VerticalPanel();
    initWidget(panel);

    HorizontalPanel horizontalPanel = new HorizontalPanel();
    horizontalPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    horizontalPanel.setSpacing(5);
    panel.add(horizontalPanel);

    Label lblNewLabel = new Label("Skill:");
    lblNewLabel.setStyleName("boldText");
    horizontalPanel.add(lblNewLabel);

    skills = new ListBox();
    horizontalPanel.add(skills);

    CaptionPanel cptnpnlNewPanel = new CaptionPanel("Skill Damage");
    panel.add(cptnpnlNewPanel);

    table = new FlexTable();
    cptnpnlNewPanel.setContentWidget(table);
    table.setSize("5cm", "3cm");
    table.setStyleName("breakpointTable");
    table.setCellPadding(5);
    table.setBorderWidth(1);

    table.getRowFormatter().addStyleName(0, "headerRow");

    int col = 0;

    Label lblSkill = new Label("Skill");
    lblSkill.setWordWrap(false);
    table.setWidget(0, col++, lblSkill);

    Label lblRune = new Label("Rune");
    lblRune.setWordWrap(false);
    table.setWidget(0, col++, lblRune);

    Label lblType = new Label("Damage Type");
    lblType.setWordWrap(false);
    table.setWidget(0, col++, lblType);

    Label lblMultiplier = new Label("Multiplier");
    lblMultiplier.setWordWrap(false);
    table.setWidget(0, col++, lblMultiplier);

    Label frames = new Label("Frames");
    frames.setWordWrap(false);
    table.setWidget(0, col++, frames);

    Label lblPrimary = new Label("Primary");
    lblPrimary.setWordWrap(false);
    table.setWidget(0, col++, lblPrimary);

    Label lblAdditional = new Label("# Additional");
    lblAdditional.setWordWrap(false);
    table.setWidget(0, col++, lblAdditional);

    Label lblProjectiles = new Label("# Projectiles");
    lblProjectiles.setWordWrap(false);
    table.setWidget(0, col++, lblProjectiles);

    Label lblAoeRadius = new Label("AoE Radius");
    lblAoeRadius.setWordWrap(false);
    table.setWidget(0, col++, lblAoeRadius);

    Label lblGrenades = new Label("Grenades");
    lblGrenades.setWordWrap(false);
    table.setWidget(0, col++, lblGrenades);

    Label lblRockets = new Label("Rockets");
    lblRockets.setWordWrap(false);
    table.setWidget(0, col++, lblRockets);

    Label lblDot = new Label(" DoT ");
    lblDot.setWordWrap(false);
    table.setWidget(0, col++, lblDot);

    Label lblNotes = new Label("Notes");
    lblNotes.setWordWrap(false);
    lblNotes.addStyleName("notes");
    table.setWidget(0, col++, lblNotes);

    List<Pair<String, String>> list = new Vector<Pair<String, String>>();

    for (ActiveSkill s : ActiveSkill.values()) {

        if (DamageFunction.hasDamage(s))
            list.add(new Pair<String, String>(s.getLongName(), s.name()));
    }

    for (GemSkill g : GemSkill.values()) {

        if (DamageFunction.hasDamage(g))
            list.add(new Pair<String, String>(g.getDisplayName(), g.name()));
    }

    for (DamageProc p : DamageProc.values()) {
        list.add(new Pair<String, String>(p.getLongName(), p.name()));
    }

    Collections.sort(list, new Comparator<Pair<String, String>>() {

        @Override
        public int compare(Pair<String, String> o1, Pair<String, String> o2) {
            return o1.getA().toLowerCase().compareTo(o2.getA().toLowerCase());
        }
    });

    for (Pair<String, String> p : list) {
        skills.addItem(p.getA(), p.getB());
    }

    skills.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent event) {
            skillChanged();
        }
    });

    skills.setSelectedIndex(0);

    skillChanged();
}

From source file:com.dawg6.web.dhcalc.client.SkillsPanel.java

License:Open Source License

public SkillsPanel() {

    CaptionPanel captionPanel = new CaptionPanel("Active Skills");
    initWidget(captionPanel);//from  w w w  .j  av a 2  s . c  o  m

    FlexTable flexTable = new FlexTable();
    captionPanel.setContentWidget(flexTable);

    int row = 0;

    List<ActiveSkill> skills = new Vector<ActiveSkill>();

    for (ActiveSkill s : ActiveSkill.values()) {
        if (s.getSkillType() != SkillType.NA)
            skills.add(s);
    }
    Collections.sort(skills, new Comparator<ActiveSkill>() {

        @Override
        public int compare(ActiveSkill o1, ActiveSkill o2) {
            return o1.getLongName().toLowerCase().compareTo(o2.getLongName().toLowerCase());
        }
    });

    for (int i = 0; i < NUM_SKILLS; i++) {
        final Anchor anchor = new Anchor("Skill " + (i + 1) + ":");
        anchor.setHref("javascript:void(0)");
        anchor.setTarget("_blank");
        anchor.setWordWrap(false);
        skillAnchors.add(anchor);
        flexTable.setWidget(row, 0, anchor);

        final ListBox list = new ListBox();

        list.addItem("None", "");

        for (ActiveSkill s : skills) {
            list.addItem(s.getLongName(), s.name());
        }

        list.setSelectedIndex(0);
        skillBoxes.add(list);
        list.setWidth("100%");
        flexTable.setWidget(row, 1, list);

        final Anchor anchor2 = new Anchor("Rune:");
        anchor2.setHref("javascript:void(0)");
        anchor2.setTarget("_blank");
        anchor2.setWordWrap(false);
        runeAnchors.add(anchor2);
        flexTable.setWidget(row, 2, anchor2);

        final ListBox list2 = new ListBox();

        list2.addItem("None", Rune.None.name());
        list2.setSelectedIndex(0);
        list2.setWidth("100%");
        flexTable.setWidget(row, 3, list2);
        runeBoxes.add(list2);

        list.addChangeHandler(new ChangeHandler() {

            @Override
            public void onChange(ChangeEvent event) {

                if (!disableListeners) {
                    skillChanged(anchor, list, anchor2, list2);
                }
            }
        });

        list2.addChangeHandler(new ChangeHandler() {

            @Override
            public void onChange(ChangeEvent event) {

                if (!disableListeners) {
                    runeChanged(list, anchor2, list2);
                }
            }
        });

        row++;
    }

    Label label = new Label("Caltrops Uptime:");
    label.setWordWrap(false);
    flexTable.setWidget(row, 0, label);
    flexTable.getFlexCellFormatter().setColSpan(row, 0, 2);
    flexTable.getFlexCellFormatter().setHorizontalAlignment(row, 0, HasHorizontalAlignment.ALIGN_RIGHT);

    caltropsUptime = new NumberSpinner();
    caltropsUptime.setVisibleLength(3);
    caltropsUptime.setTitle("Percent of the time primary target will have active Caltrops applied.");
    flexTable.setWidget(row, 1, caltropsUptime);
    flexTable.getFlexCellFormatter().setColSpan(row, 1, 2);
    caltropsUptime.setMax(100);

    row++;

    Label lblUptime = new Label("Primary Target MfD Uptime:");
    lblUptime.setWordWrap(false);
    flexTable.setWidget(row, 0, lblUptime);
    flexTable.getFlexCellFormatter().setColSpan(row, 0, 2);
    flexTable.getFlexCellFormatter().setHorizontalAlignment(row, 0, HasHorizontalAlignment.ALIGN_RIGHT);

    mfdUptime = new NumberSpinner();
    mfdUptime.setTitle("Percent of the time primary target will have active MfD applied.");
    mfdUptime.setVisibleLength(3);
    flexTable.setWidget(row, 1, mfdUptime);
    flexTable.getFlexCellFormatter().setColSpan(row, 1, 2);

    row++;

    Label lblAdditionalTargetsUptime = new Label("Additional Targets MfD Uptime:");
    lblAdditionalTargetsUptime.setWordWrap(false);
    flexTable.setWidget(row, 0, lblAdditionalTargetsUptime);
    flexTable.getFlexCellFormatter().setColSpan(row, 0, 2);
    flexTable.getFlexCellFormatter().setHorizontalAlignment(row, 0, HasHorizontalAlignment.ALIGN_RIGHT);

    mfdAddUptime = new NumberSpinner();
    mfdAddUptime.setVisibleLength(3);
    mfdAddUptime.setTitle("Percent of the time additional targets will have active MfD applied.");
    flexTable.setWidget(row, 1, mfdAddUptime);
    flexTable.getFlexCellFormatter().setColSpan(row, 1, 2);

    row++;

    Label lblNoteThisStacks = new Label("Note: This stacks with Calamity's MfD");
    lblNoteThisStacks.setWordWrap(false);
    lblNoteThisStacks.setStyleName("boldText");
    flexTable.setWidget(row, 0, lblNoteThisStacks);
    flexTable.getFlexCellFormatter().setColSpan(row, 0, 4);

    row++;

    mfdUptime.setMax(100);
    mfdAddUptime.setMax(100);
    caltropsUptime.setMax(100);

}

From source file:com.dawg6.web.dhcalc.client.StatsPanel.java

License:Open Source License

public StatsPanel() {

    CaptionPanel cptnpnlNewPanel = new CaptionPanel("Statistics");
    initWidget(cptnpnlNewPanel);//from  ww  w  .  j a  va2 s .  c o  m
    cptnpnlNewPanel.setSize("1005px", "619px");

    FlexTable flexTable = new FlexTable();
    SimplePanel panel = new SimplePanel();

    panel.setWidget(flexTable);
    flexTable.setHeight("554px");
    cptnpnlNewPanel.setContentWidget(panel);
    panel.setSize("100%", "100%");

    Label lblNewLabel = new Label("Total # of Profiles Analyzed:");
    lblNewLabel.setStyleName("boldText");
    lblNewLabel.setWordWrap(false);
    flexTable.setWidget(0, 0, lblNewLabel);

    totalLabel = new Label("Loading...");
    flexTable.setWidget(0, 1, totalLabel);

    CaptionPanel cptnpnlNewPanel_1 = new CaptionPanel("Global Statistics");
    flexTable.setWidget(1, 0, cptnpnlNewPanel_1);

    mainTable = new FlexTable();
    mainTable.setStyleName("statsTable");

    SimplePanel panel2 = new SimplePanel();
    panel2.setWidget(mainTable);
    cptnpnlNewPanel_1.setContentWidget(panel2);

    Label lblStatistic = new Label("Statistic");
    lblStatistic.setStyleName("boldText");
    lblStatistic.setWordWrap(false);
    mainTable.setWidget(0, 0, lblStatistic);

    Label lblAverage = new Label("Average DPS");
    lblAverage.setWordWrap(false);
    lblAverage.setStyleName("boldText");
    mainTable.setWidget(0, 1, lblAverage);

    Label lblNewLabel_1 = new Label("Max DPS");
    lblNewLabel_1.setStyleName("boldText");
    lblNewLabel_1.setWordWrap(false);
    mainTable.setWidget(0, 2, lblNewLabel_1);

    Label lblProfile = new Label("Link to Profile");
    lblProfile.setWordWrap(false);
    lblProfile.setStyleName("boldText");
    mainTable.setWidget(0, 3, lblProfile);
    mainTable.getCellFormatter().setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_RIGHT);
    mainTable.getCellFormatter().setHorizontalAlignment(0, 2, HasHorizontalAlignment.ALIGN_RIGHT);
    mainTable.getCellFormatter().setHorizontalAlignment(0, 3, HasHorizontalAlignment.ALIGN_RIGHT);

    Label lblImport = new Label("Import");
    lblImport.setWordWrap(false);
    lblImport.setStyleName("boldText");
    mainTable.setWidget(0, 4, lblImport);
    mainTable.getCellFormatter().setHorizontalAlignment(0, 4, HasHorizontalAlignment.ALIGN_CENTER);

    flexTable.getFlexCellFormatter().setColSpan(1, 0, 2);

    CaptionPanel cptnpnlNewPanel_2 = new CaptionPanel("Build Statistics");
    flexTable.setWidget(2, 0, cptnpnlNewPanel_2);
    cptnpnlNewPanel_2.setHeight("367px");

    VerticalPanel verticalPanel = new VerticalPanel();
    cptnpnlNewPanel_2.setContentWidget(verticalPanel);

    filterTable = new FlexTable();

    SimplePanel panel3 = new SimplePanel();
    panel3.setWidget(filterTable);
    verticalPanel.add(panel3);
    panel3.setHeight("80px");

    Label sentryLabel = new Label("Sentry:");
    sentryLabel.setWordWrap(false);
    sentryLabel.setStyleName("boldText");
    filterTable.setWidget(0, 0, sentryLabel);

    sentry = new SimpleCheckBox();
    filterTable.setWidget(0, 1, sentry);

    Label lblNewLabel_2 = new Label("Rune:");
    lblNewLabel_2.setWordWrap(false);
    lblNewLabel_2.setStyleName("boldText");
    filterTable.setWidget(0, 2, lblNewLabel_2);

    sentryRune = new ListBox();
    filterTable.setWidget(0, 3, sentryRune);

    Label lblSkill = new Label("Skill 1:");
    lblSkill.setWordWrap(false);
    lblSkill.setStyleName("boldText");
    filterTable.setWidget(0, 2, lblSkill);

    skill1 = new ListBox();
    filterTable.setWidget(0, 3, skill1);

    Label lblSkill_1 = new Label("Skill 2:");
    lblSkill_1.setWordWrap(false);
    lblSkill_1.setStyleName("boldText");
    filterTable.setWidget(0, 4, lblSkill_1);

    skill2 = new ListBox();
    filterTable.setWidget(0, 5, skill2);

    //      Label lblSkill_2 = new Label("Skill 3:");
    //      lblSkill_2.setWordWrap(false);
    //      lblSkill_2.setStyleName("boldText");
    //      filterTable.setWidget(0, 6, lblSkill_2);
    //
    //      skill3 = new ListBox();
    //      filterTable.setWidget(0, 7, skill3);
    //
    Button button = new Button("Copy My Build");
    filterTable.setWidget(0, 6, button);

    button.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            copyBuild();
        }
    });

    Button btnNewButton = new Button("Update");
    btnNewButton.setText("Filter/Refresh");
    filterTable.setWidget(1, 0, btnNewButton);
    btnNewButton.setWidth("100%");

    btnNewButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            updateStats();
        }
    });

    Label lblRune = new Label("Rune 1:");
    lblRune.setWordWrap(false);
    lblRune.setStyleName("boldText");
    filterTable.setWidget(1, 2, lblRune);

    rune1 = new ListBox();
    filterTable.setWidget(1, 3, rune1);

    Label lblRune_1 = new Label("Rune 2:");
    lblRune_1.setWordWrap(false);
    lblRune_1.setStyleName("boldText");
    filterTable.setWidget(1, 4, lblRune_1);

    rune2 = new ListBox();
    filterTable.setWidget(1, 5, rune2);

    //      Label lblRune_2 = new Label("Rune 3:");
    //      lblRune_2.setWordWrap(false);
    //      lblRune_2.setStyleName("boldText");
    //      filterTable.setWidget(1, 6, lblRune_2);
    //
    //      rune3 = new ListBox();
    //      filterTable.setWidget(1, 7, rune3);
    //      filterTable.getFlexCellFormatter().setColSpan(1, 0, 2);

    buildTable = new FlexTable();
    buildTable.setStyleName("statsTable");

    ScrollPanel scroll = new ScrollPanel();
    scroll.setWidget(buildTable);
    verticalPanel.add(scroll);
    scroll.setSize("975px", "269px");

    Anchor lblSentryRune = new Anchor("Sentry Rune");
    lblSentryRune.setWordWrap(false);
    lblSentryRune.setStyleName("boldText");
    lblSentryRune.setHref("javascript:void(0);");
    buildTable.setWidget(0, 0, lblSentryRune);

    lblSentryRune.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            //            sortStats(StatSorter.SENTRY_RUNE);
        }
    });

    Anchor lblSkill_3 = new Anchor("Skills/Runes");
    lblSkill_3.setHref("javascript:void(0);");
    lblSkill_3.setWordWrap(false);
    lblSkill_3.setStyleName("boldText");
    buildTable.setWidget(0, 1, lblSkill_3);

    lblSkill_3.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            //            sortStats(StatSorter.SKILLS);
        }
    });
    buildTable.getCellFormatter().setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_CENTER);

    Anchor lblCount = new Anchor("Count");
    lblCount.setHref("javascript:void(0);");
    lblCount.setWordWrap(false);
    lblCount.setStyleName("boldText");
    buildTable.setWidget(0, 2, lblCount);

    lblCount.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            sortStats(StatSorter.COUNT);
        }
    });

    flexTable.getFlexCellFormatter().setColSpan(2, 0, 2);
    flexTable.getCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    flexTable.getCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);

    disableListeners = true;

    int row = 1;
    int col = 3;

    for (StatCategory c : StatCategory.values()) {
        Label label = new Label(c.getDescription());
        label.setWordWrap(false);

        if ((row % 2) == 0)
            mainTable.getRowFormatter().addStyleName(row, "even");
        else
            mainTable.getRowFormatter().addStyleName(row, "odd");

        for (int i = 0; i < 4; i++) {
            Label label3 = new Label("Loading...");
            label3.addStyleName("right");
            mainTable.setWidget(row, i + 1, label3);
        }

        mainTable.setWidget(row++, 0, label);

        FlexTable table = new FlexTable();
        buildTable.setWidget(0, col, table);

        Anchor avg = new Anchor("Avg");
        avg.setWordWrap(false);
        avg.setHref("javascript:void(0);");
        avg.setStyleName("boldText");

        Anchor max = new Anchor("Max");
        max.setWordWrap(false);
        max.setHref("javascript:void(0);");
        max.setStyleName("boldText");

        Label split = new Label("/");
        split.setWordWrap(false);
        split.setStyleName("boldText");

        table.setWidget(0, 0, avg);
        table.setWidget(0, 1, split);
        table.setWidget(0, 2, max);
        table.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
        table.getFlexCellFormatter().setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_CENTER);
        table.getFlexCellFormatter().setHorizontalAlignment(0, 2, HasHorizontalAlignment.ALIGN_CENTER);

        Label label2 = new Label(c.getDescription());
        label2.setWordWrap(true);
        label2.setStyleName("boldText");

        table.setWidget(1, 0, label2);
        table.getFlexCellFormatter().setColSpan(1, 0, 3);
        table.getFlexCellFormatter().setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_CENTER);

        buildTable.getFlexCellFormatter().setHorizontalAlignment(0, col, HasHorizontalAlignment.ALIGN_CENTER);

        final StatCategory cat = c;

        avg.addClickHandler(new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
                sortStats(new StatSorter.AverageCategorySorter(cat));
            }
        });

        max.addClickHandler(new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
                sortStats(new StatSorter.MaxCategorySorter(cat));
            }
        });

        col++;
    }

    skills = new ListBox[] { skill1, skill2 }; //, skill3 };
    runes = new ListBox[] { rune1, rune2 }; //, rune3 };

    for (int i = 0; i < skills.length; i++) {
        populateSkillsAndRunes(i);
        final int j = i;

        skills[i].addChangeHandler(new ChangeHandler() {

            @Override
            public void onChange(ChangeEvent event) {
                if (!disableListeners) {
                    skillChanged(j);
                }

            }
        });

    }

    disableListeners = false;
}

From source file:com.dawg6.web.dhcalc.client.WeaponPanel.java

License:Open Source License

public WeaponPanel(String title, boolean offHand) {
    this.offHand = offHand;
    captionPanel = new CaptionPanel(title);
    initWidget(captionPanel);//from   w ww .  j  ava  2s  .co  m

    FlexTable flexTable = new FlexTable();
    flexTable.setCellPadding(2);
    captionPanel.setContentWidget(flexTable);

    Label label = new Label("Weapon Type:");
    label.setWordWrap(false);
    flexTable.setWidget(0, 0, label);

    weaponType = new ListBox();
    weaponType.setSelectedIndex(0);
    flexTable.setWidget(0, 1, weaponType);

    Label label_1 = new Label("Base (Physical) Damage:");
    label_1.setWordWrap(false);
    flexTable.setWidget(1, 0, label_1);

    baseMin = new DoubleSpinner();
    baseMin.box.setTitle("This number is not displayed in-game. It is imported from hero import.");
    baseMin.setVisibleLength(8);
    baseMin.setText("0");
    flexTable.setWidget(1, 1, baseMin);

    Label label_2 = new Label(" to ");
    label_2.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    flexTable.setWidget(1, 2, label_2);

    baseMax = new DoubleSpinner();
    baseMax.box.setTitle("This number is not displayed in-game. It is imported from hero import.");
    baseMax.setVisibleLength(8);
    baseMax.setText("0");
    flexTable.setWidget(1, 3, baseMax);

    Label label_3 = new Label("Tooltip Damage:");
    label_3.setWordWrap(false);
    label_3.setStyleName("boldText");
    flexTable.setWidget(1, 4, label_3);

    tooltipMin = new Label();
    tooltipMin.setTitle("Shown as \"white\" damage on weapon tooltip.");
    tooltipMin.setText("0");
    tooltipMin.setStyleName("boldText");
    flexTable.setWidget(1, 5, tooltipMin);

    Label label_5 = new Label(" to ");
    label_5.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    flexTable.setWidget(1, 6, label_5);

    tooltipMax = new Label();
    tooltipMax.setTitle("Shown as \"white\" damage on weapon tooltip.");
    tooltipMax.setText("0");
    tooltipMax.setStyleName("boldText");
    flexTable.setWidget(1, 7, tooltipMax);

    Label label_7 = new Label("Added (Elemental) Damage:");
    label_7.setWordWrap(false);
    flexTable.setWidget(2, 0, label_7);

    addMin = new DoubleSpinner();
    addMin.box.setTitle("Shown as primary stat on weapon.");
    addMin.setVisibleLength(8);
    addMin.setText("0");
    flexTable.setWidget(2, 1, addMin);

    Label label_8 = new Label(" to ");
    label_8.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    flexTable.setWidget(2, 2, label_8);

    addMax = new DoubleSpinner();
    addMax.box.setTitle("Shown as primary stat on weapon.");
    addMax.setVisibleLength(8);
    addMax.setText("0");
    flexTable.setWidget(2, 3, addMax);

    Label label_9 = new Label("Average Weapon Damage:");
    label_9.setWordWrap(false);
    label_9.setStyleName("boldText");
    flexTable.setWidget(2, 4, label_9);

    averageWeaponDamage = new Label("0.0");
    averageWeaponDamage.setTitle("Average weapon damage used for Skill calculations");
    averageWeaponDamage.setStyleName("boldText");
    flexTable.setWidget(2, 5, averageWeaponDamage);
    flexTable.getFlexCellFormatter().setColSpan(2, 5, 3);

    Label label_11 = new Label("Weapon IAS (%):");
    label_11.setWordWrap(false);
    flexTable.setWidget(3, 0, label_11);

    weaponIAS = new NumberSpinner();
    weaponIAS.box.setTitle("Increased attack speed as a primary attribute on the weapon.");
    weaponIAS.setVisibleLength(6);
    flexTable.setWidget(3, 1, weaponIAS);

    Label label_12 = new Label("Weapon DPS:");
    label_12.setWordWrap(false);
    label_12.setStyleName("boldText");
    flexTable.setWidget(3, 4, label_12);

    weaponDpsLabel = new Label("0.0");
    weaponDpsLabel.setTitle("Shown as dps on weapon tooltip.");
    weaponDpsLabel.setStyleName("boldText");
    flexTable.setWidget(3, 5, weaponDpsLabel);
    flexTable.getFlexCellFormatter().setColSpan(3, 5, 3);

    Label label_14 = new Label("Weapon Increased Damage (%):");
    label_14.setWordWrap(false);
    flexTable.setWidget(4, 0, label_14);

    weaponDamage = new NumberSpinner();
    weaponDamage.box.setTitle("Increased damage as a primary attribute on the weapon.");
    weaponDamage.setVisibleLength(6);
    flexTable.setWidget(4, 1, weaponDamage);

    Label label_15 = new Label("Weapon APS:");
    label_15.setWordWrap(false);
    label_15.setStyleName("boldText");
    flexTable.setWidget(4, 4, label_15);

    weaponApsLabel = new Label("0.0");
    weaponApsLabel.setTitle("As shown on weapon tooltip");
    weaponApsLabel.setStyleName("boldText");
    flexTable.setWidget(4, 5, weaponApsLabel);
    flexTable.getFlexCellFormatter().setColSpan(4, 5, 3);

    this.weaponIAS.setMax(7);
    this.weaponDamage.setMax(10);

    weaponType.addItem("None", "");

    for (WeaponType wt : WeaponType.values()) {

        if (!offHand || (wt == WeaponType.HandCrossbow))
            weaponType.addItem(wt.getName(), wt.name());
    }

    weaponType.setSelectedIndex(0);

    ChangeHandler handler = new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent event) {

            if (!disableUpdates) {
                calculate();
            }
        }
    };

    weaponType.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent event) {

            disableUpdates = true;

            WeaponType type = getWeaponTypeEnum();

            if (type == null) {
                baseMin.setValue(0.0);
                baseMax.setMax(0.0);
            } else {
                baseMin.setValue((double) type.getMin());
                baseMax.setValue((double) type.getMax());
            }

            disableUpdates = false;

            calculate();
        }
    });

    baseMin.addChangeHandler(handler);
    baseMax.addChangeHandler(handler);
    addMin.addChangeHandler(handler);
    addMax.addChangeHandler(handler);
    weaponIAS.addChangeHandler(handler);
    weaponDamage.addChangeHandler(handler);
}

From source file:com.df3n5.gwtproc.client.util.MatrixWidget.java

License:Apache License

/**
 * Constructs a new instance of the MatrixWidget to view a FloatMatrix of
 * the given size./*w ww.  j  a  v  a  2s .c o m*/
 * 
 * @param width
 *            column count of matrix
 * @param height
 *            row count of matrix
 * @param title
 *            the title of the matrix
 */
public MatrixWidget(int width, int height, String title) {
    this.width = width;
    this.height = height;
    flextable = new FlexTable();
    flextable.setWidget(0, 0, new Label(title));
    flextable.getFlexCellFormatter().setColSpan(0, 0, width);
    for (int x = 0; x < width; x++) {
        for (int y = 0; y < height; y++) {
            flextable.setText(y + 1, x, "[" + String.valueOf(x) + "_" + String.valueOf(y) + "]");
        }
    }

    initWidget(flextable);

    setStyleName("matrixWidget");
}

From source file:com.dimdim.conference.ui.dialogues.client.common.AboutCommonDialog.java

License:Open Source License

private AboutCommonDialog(String title, Widget content, Vector footerButtons, String dialogName) {
    super(title);
    this.content = content;
    this.footerButtons = footerButtons;
    this.dialogName = dialogName;
    this.closeButtonText = UIStrings.getOKLabel();
    UIResources uiResources = UIResources.getUIResources();
    FlexTable productInfo = new FlexTable();
    String productVersion = getProductVersion();
    String premiumCatalogue = getPremiumCatalogue();
    String premiumCatalogueLogo = UIStrings.getAboutPoweredLogo();
    //      Window.alert(premiumCatalogueLogo);
    productInfo.setWidget(0, 0, createTextHTML(productVersion));
    productInfo.getFlexCellFormatter().setColSpan(0, 0, 3);
    //Window.alert(getProductVersion());
    //      Window.alert(premiumCatalogue);
    //Window.alert(uiResources.getConferenceInfo("dimdim.premiumCatalogue"));
    if (premiumCatalogue.equalsIgnoreCase("1")) {
        //         Window.alert("comes here 1");
        Image logo = new Image();
        logo.setUrl(premiumCatalogueLogo);
        productInfo.setWidget(0, 3, logo);
        //         Window.alert("comes here 2");
        productInfo.setWidget(0, 4, createTextHTML(
                "<div style=\"color: #1b61da;\">Powered By <a href=\"http://www.dimdim.com\" target=\"_blank\"><u>Dimdim"));
        productInfo.getFlexCellFormatter().setColSpan(0, 4, 9);
        //         Window.alert("comes here 3");
        //productInfo.setWidth("2px");            
    }//from  www. j ava2s .c o m
    productInfo.setStyleName("common-text");
    //      Window.alert("comes here 4");
    buttonPanel.add(productInfo, DockPanel.WEST);
    //      Window.alert("comes here 5");
}

From source file:com.dimdim.conference.ui.dialogues.client.common.AboutConferenceHtml.java

License:Open Source License

public AboutConferenceHtml() {
    //      UIResources  uiResources = UIResources.getUIResources();
    //Window.alert("test about box html");
    String aboutBoxLogo = UIStrings.getAboutLogo();
    Image logo = new Image();
    logo.setUrl(aboutBoxLogo);//www  .j  a va 2 s.  co m

    FlexTable productInfo = new FlexTable();
    productInfo.setWidget(0, 0, logo);
    setWidget(0, 10, productInfo);
}

From source file:com.eas.grid.Grid.java

public Grid(ProvidesKey<T> aKeyProvider) {
    super();/*from   w  ww  .j a v a  2s .  co m*/
    getElement().getStyle().setPosition(Style.Position.RELATIVE);
    getElement().appendChild(tdsStyleElement);
    getElement().appendChild(cellsStyleElement);
    getElement().appendChild(oddRowsStyleElement);
    getElement().appendChild(evenRowsStyleElement);
    setRowsHeight(30);
    hive = new FlexTable();
    setWidget(hive);
    hive.setCellPadding(0);
    hive.setCellSpacing(0);
    hive.setBorderWidth(0);
    headerLeft = new GridSection<T>(aKeyProvider);
    headerLeftContainer = new ScrollPanel(headerLeft);
    headerRight = new GridSection<T>(aKeyProvider);
    headerRightContainer = new ScrollPanel(headerRight);
    frozenLeft = new GridSection<T>(aKeyProvider) {

        @Override
        protected void replaceAllChildren(List<T> values, SafeHtml html) {
            super.replaceAllChildren(values, html);
            footerLeft.redrawFooters();
            frozenLeftRendered();
        }

        @Override
        protected void replaceChildren(List<T> values, int start, SafeHtml html) {
            super.replaceChildren(values, start, html);
            footerLeft.redrawFooters();
            frozenLeftRendered();
        }

        @Override
        protected void onFocus() {
            super.onFocus();
            Element focused = getKeyboardSelectedElement();
            if (focused != null)
                focused.setTabIndex(tabIndex);
            FocusEvent.fireNativeEvent(Document.get().createFocusEvent(), Grid.this);
        }

        @Override
        protected void onBlur() {
            super.onBlur();
            FocusEvent.fireNativeEvent(Document.get().createBlurEvent(), Grid.this);
        }
    };

    frozenLeftContainer = new ScrollPanel(frozenLeft);
    frozenRight = new GridSection<T>(aKeyProvider) {

        @Override
        protected void replaceAllChildren(List<T> values, SafeHtml html) {
            super.replaceAllChildren(values, html);
            footerRight.redrawFooters();
            frozenRightRendered();
        }

        @Override
        protected void replaceChildren(List<T> values, int start, SafeHtml html) {
            super.replaceChildren(values, start, html);
            footerRight.redrawFooters();
            frozenRightRendered();
        }

        @Override
        protected void onFocus() {
            super.onFocus();
            Element focused = getKeyboardSelectedElement();
            if (focused != null)
                focused.setTabIndex(tabIndex);
            FocusEvent.fireNativeEvent(Document.get().createFocusEvent(), Grid.this);
        }

        @Override
        protected void onBlur() {
            super.onBlur();
            FocusEvent.fireNativeEvent(Document.get().createBlurEvent(), Grid.this);
        }
    };
    frozenRightContainer = new ScrollPanel(frozenRight);
    scrollableLeft = new GridSection<T>(aKeyProvider) {

        @Override
        protected void replaceAllChildren(List<T> values, SafeHtml html) {
            super.replaceAllChildren(values, html);
            footerLeft.redrawFooters();
            scrollableLeftRendered();
        }

        @Override
        protected void replaceChildren(List<T> values, int start, SafeHtml html) {
            super.replaceChildren(values, start, html);
            footerLeft.redrawFooters();
            scrollableLeftRendered();
        }

        @Override
        protected void onFocus() {
            super.onFocus();
            Element focused = getKeyboardSelectedElement();
            if (focused != null)
                focused.setTabIndex(tabIndex);
            FocusEvent.fireNativeEvent(Document.get().createFocusEvent(), Grid.this);
        }

        @Override
        protected void onBlur() {
            super.onBlur();
            FocusEvent.fireNativeEvent(Document.get().createBlurEvent(), Grid.this);
        }
    };
    scrollableLeftContainer = new ScrollPanel(scrollableLeft);
    scrollableRight = new GridSection<T>(aKeyProvider) {

        @Override
        protected void replaceAllChildren(List<T> values, SafeHtml html) {
            super.replaceAllChildren(values, html);
            footerRight.redrawFooters();
            scrollableRightRendered();
        }

        @Override
        protected void replaceChildren(List<T> values, int start, SafeHtml html) {
            super.replaceChildren(values, start, html);
            footerRight.redrawFooters();
            scrollableRightRendered();
        }

        @Override
        protected void onFocus() {
            super.onFocus();
            Element focused = getKeyboardSelectedElement();
            if (focused != null)
                focused.setTabIndex(tabIndex);
            FocusEvent.fireNativeEvent(Document.get().createFocusEvent(), Grid.this);
        }

        @Override
        protected void onBlur() {
            super.onBlur();
            FocusEvent.fireNativeEvent(Document.get().createBlurEvent(), Grid.this);
        }
    };
    scrollableRightContainer = new ScrollPanel(scrollableRight);
    footerLeft = new GridSection<>(aKeyProvider);
    footerLeftContainer = new ScrollPanel(footerLeft);
    footerRight = new GridSection<>(aKeyProvider);
    footerRightContainer = new ScrollPanel(footerRight);
    // positioning context / overflow setup
    // overflow
    for (Widget w : new Widget[] { headerLeftContainer, headerRightContainer, frozenLeftContainer,
            frozenRightContainer, scrollableLeftContainer, footerLeftContainer, footerRightContainer }) {
        w.getElement().getStyle().setOverflow(Style.Overflow.HIDDEN);
    }
    // scrollableRightContainer.getElement().getStyle().setOverflow(Style.Overflow.AUTO);
    // default value
    // context
    for (Widget w : new Widget[] { headerLeftContainer, headerRightContainer, frozenLeftContainer,
            frozenRightContainer, scrollableLeftContainer, scrollableRightContainer, footerLeftContainer,
            footerRightContainer }) {
        w.getElement().getFirstChildElement().getStyle().setPosition(Style.Position.ABSOLUTE);
    }
    // propagation of some widths
    headerLeft.setWidthPropagator(new GridWidthPropagator<T>(headerLeft) {

        @Override
        public void changed() {
            super.changed();
            propagateHeaderWidth();
        }

    });
    for (GridSection<T> section : (GridSection<T>[]) new GridSection<?>[] { headerRight, frozenLeft,
            frozenRight, scrollableLeft, scrollableRight, footerLeft, footerRight }) {
        section.setWidthPropagator(new GridWidthPropagator<>(section));
    }
    headerLeft.setColumnsPartners(new AbstractCellTable[] { frozenLeft, scrollableLeft, footerLeft });
    headerRight.setColumnsPartners(new AbstractCellTable[] { frozenRight, scrollableRight, footerRight });
    ColumnsRemover leftColumnsRemover = new ColumnsRemoverAdapter<T>(headerLeft, frozenLeft, scrollableLeft,
            footerLeft);
    ColumnsRemover rightColumnsRemover = new ColumnsRemoverAdapter<T>(headerRight, frozenRight, scrollableRight,
            footerRight);
    for (GridSection<T> section : (GridSection<T>[]) new GridSection<?>[] { headerLeft, frozenLeft,
            scrollableLeft, footerLeft }) {
        section.setColumnsRemover(leftColumnsRemover);
    }
    for (GridSection<T> section : (GridSection<T>[]) new GridSection<?>[] { headerRight, frozenRight,
            scrollableRight, footerRight }) {
        section.setColumnsRemover(rightColumnsRemover);
    }
    for (GridSection<T> section : (GridSection<T>[]) new GridSection<?>[] { frozenLeft, scrollableLeft,
            footerLeft }) {
        section.setHeaderSource(headerLeft);
    }
    for (GridSection<T> section : (GridSection<T>[]) new GridSection<?>[] { frozenRight, scrollableRight,
            footerRight }) {
        section.setHeaderSource(headerRight);
    }
    for (GridSection<T> section : (GridSection<T>[]) new GridSection<?>[] { headerLeft, frozenLeft,
            scrollableLeft }) {
        section.setFooterSource(footerLeft);
    }
    for (GridSection<T> section : (GridSection<T>[]) new GridSection<?>[] { headerRight, frozenRight,
            scrollableRight }) {
        section.setFooterSource(footerRight);
    }

    // hive organization
    hive.setWidget(0, 0, headerLeftContainer);
    hive.setWidget(0, 1, headerRightContainer);
    hive.setWidget(1, 0, frozenLeftContainer);
    hive.setWidget(1, 1, frozenRightContainer);
    hive.setWidget(2, 0, scrollableLeftContainer);
    hive.setWidget(2, 1, scrollableRightContainer);
    hive.setWidget(3, 0, footerLeftContainer);
    hive.setWidget(3, 1, footerRightContainer);

    for (Widget w : new Widget[] { headerLeftContainer, headerRightContainer, frozenLeftContainer,
            frozenRightContainer, scrollableLeftContainer, scrollableRightContainer, footerLeftContainer,
            footerRightContainer }) {
        w.setWidth("100%");
        w.setHeight("100%");
    }
    // misc
    for (Widget w : new Widget[] { headerRightContainer, frozenRightContainer, footerRightContainer,
            scrollableLeftContainer }) {
        w.getElement().getParentElement().getStyle().setOverflow(Style.Overflow.HIDDEN);
    }
    hive.getElement().getStyle().setTableLayout(Style.TableLayout.FIXED);
    hive.getElement().getStyle().setPosition(Style.Position.RELATIVE);
    for (CellTable<?> tbl : new CellTable<?>[] { headerLeft, headerRight, frozenLeft, frozenRight,
            scrollableLeft, scrollableRight, footerLeft, footerRight }) {
        tbl.setTableLayoutFixed(true);
    }
    // header
    headerLeft.setHeaderBuilder(new ThemedHeaderOrFooterBuilder<T>(headerLeft, false, this));
    headerLeft.setFooterBuilder(new NullHeaderOrFooterBuilder<T>(headerLeft, true));
    headerRight.setHeaderBuilder(new ThemedHeaderOrFooterBuilder<T>(headerRight, false, this));
    headerRight.setFooterBuilder(new NullHeaderOrFooterBuilder<T>(headerRight, true));
    // footer
    footerLeft.setHeaderBuilder(new NullHeaderOrFooterBuilder<T>(footerLeft, false));
    footerLeft.setFooterBuilder(new ThemedHeaderOrFooterBuilder<T>(footerLeft, true));
    footerRight.setHeaderBuilder(new NullHeaderOrFooterBuilder<T>(footerRight, false));
    footerRight.setFooterBuilder(new ThemedHeaderOrFooterBuilder<T>(footerRight, true));
    // data bodies
    for (GridSection<?> section : new GridSection<?>[] { frozenLeft, frozenRight, scrollableLeft,
            scrollableRight }) {
        GridSection<T> gSection = (GridSection<T>) section;
        gSection.setHeaderBuilder(new NullHeaderOrFooterBuilder<T>(gSection, false));
        gSection.setFooterBuilder(new NullHeaderOrFooterBuilder<T>(gSection, true));
    }
    for (GridSection<?> section : new GridSection<?>[] { headerLeft, headerRight, frozenLeft, frozenRight,
            scrollableLeft, scrollableRight, footerLeft, footerRight }) {
        section.setAutoHeaderRefreshDisabled(true);
    }
    for (GridSection<?> section : new GridSection<?>[] { headerLeft, headerRight, footerLeft, footerRight }) {
        section.setAutoFooterRefreshDisabled(true);
    }
    // cells
    installCellBuilders();

    scrollableRightContainer.addScrollHandler(new ScrollHandler() {

        @Override
        public void onScroll(ScrollEvent event) {
            int aimLeft = scrollableRightContainer.getElement().getScrollLeft();
            if (isHeaderVisible()) {
                headerRightContainer.getElement().setScrollLeft(aimLeft);
                int factLeftDelta0 = aimLeft - headerRightContainer.getElement().getScrollLeft();
                if (factLeftDelta0 > 0) {
                    headerRightContainer.getElement().getStyle().setRight(factLeftDelta0, Style.Unit.PX);
                } else {
                    headerRightContainer.getElement().getStyle().clearRight();
                }
            }
            if (frozenColumns > 0 || frozenRows > 0) {
                int aimTop = scrollableRightContainer.getElement().getScrollTop();

                scrollableLeftContainer.getElement().setScrollTop(aimTop);
                int factTopDelta = aimTop - scrollableLeftContainer.getElement().getScrollTop();
                if (factTopDelta > 0) {
                    scrollableLeftContainer.getElement().getStyle().setBottom(factTopDelta, Style.Unit.PX);
                } else {
                    scrollableLeftContainer.getElement().getStyle().clearBottom();
                }
                frozenRightContainer.getElement().setScrollLeft(aimLeft);
                int factLeftDelta1 = aimLeft - frozenRightContainer.getElement().getScrollLeft();
                if (factLeftDelta1 > 0) {
                    frozenRightContainer.getElement().getStyle().setRight(factLeftDelta1, Style.Unit.PX);
                } else {
                    frozenRightContainer.getElement().getStyle().clearRight();
                }
                footerRightContainer.getElement()
                        .setScrollLeft(scrollableRightContainer.getElement().getScrollLeft());
                int factLeftDelta2 = aimLeft - footerRightContainer.getElement().getScrollLeft();
                if (factLeftDelta2 > 0) {
                    footerRightContainer.getElement().getStyle().setRight(factLeftDelta2, Style.Unit.PX);
                } else {
                    footerRightContainer.getElement().getStyle().clearRight();
                }
            }
        }

    });
    ghostLine = Document.get().createDivElement();
    ghostLine.addClassName(RULER_STYLE);
    ghostLine.getStyle().setPosition(Style.Position.ABSOLUTE);
    ghostLine.getStyle().setTop(0, Style.Unit.PX);
    ghostColumn = Document.get().createDivElement();
    ghostColumn.addClassName(COLUMN_PHANTOM_STYLE);
    ghostColumn.getStyle().setPosition(Style.Position.ABSOLUTE);
    ghostColumn.getStyle().setTop(0, Style.Unit.PX);
    addDomHandler(new DragEnterHandler() {

        @Override
        public void onDragEnter(DragEnterEvent event) {
            if (DraggedColumn.instance != null) {
                if (DraggedColumn.instance.isMove()) {
                    event.preventDefault();
                    event.stopPropagation();
                    DraggedColumn<T> target = findTargetDraggedColumn(event.getNativeEvent().getEventTarget());
                    if (target != null) {
                        showColumnMoveDecorations(target);
                        event.getDataTransfer().<XDataTransfer>cast().setDropEffect("move");
                    } else {
                        event.getDataTransfer().<XDataTransfer>cast().setDropEffect("none");
                    }
                } else {
                }
            }
        }
    }, DragEnterEvent.getType());
    addDomHandler(new DragHandler() {

        @Override
        public void onDrag(DragEvent event) {
            if (DraggedColumn.instance != null && DraggedColumn.instance.isResize()) {
                event.stopPropagation();
            }
        }
    }, DragEvent.getType());
    addDomHandler(new DragOverHandler() {

        @Override
        public void onDragOver(DragOverEvent event) {
            if (DraggedColumn.instance != null) {
                event.preventDefault();
                event.stopPropagation();
                if (DraggedColumn.instance.isMove()) {
                    DraggedColumn<T> target = findTargetDraggedColumn(event.getNativeEvent().getEventTarget());
                    if (target != null) {
                        event.getDataTransfer().<XDataTransfer>cast().setDropEffect("move");
                    } else {
                        hideColumnDecorations();
                        event.getDataTransfer().<XDataTransfer>cast().setDropEffect("none");
                    }
                } else {
                    Element hostElement = Grid.this.getElement();
                    int clientX = event.getNativeEvent().getClientX();
                    int hostAbsX = hostElement.getAbsoluteLeft();
                    int hostScrollX = hostElement.getScrollLeft();
                    int docScrollX = hostElement.getOwnerDocument().getScrollLeft();
                    int relativeX = clientX - hostAbsX + hostScrollX + docScrollX;
                    ghostLine.getStyle().setLeft(relativeX, Style.Unit.PX);
                    ghostLine.getStyle().setHeight(hostElement.getClientHeight(), Style.Unit.PX);
                    if (ghostLine.getParentElement() != hostElement) {
                        hostElement.appendChild(ghostLine);
                    }
                }
            }
        }
    }, DragOverEvent.getType());
    addDomHandler(new DragLeaveHandler() {

        @Override
        public void onDragLeave(DragLeaveEvent event) {
            if (DraggedColumn.instance != null) {
                event.stopPropagation();
                if (DraggedColumn.instance.isMove()) {
                    if (event.getNativeEvent().getEventTarget() == (JavaScriptObject) Grid.this.getElement()) {
                        hideColumnDecorations();
                    }
                }
            }
        }
    }, DragLeaveEvent.getType());
    addDomHandler(new DragEndHandler() {

        @Override
        public void onDragEnd(DragEndEvent event) {
            if (DraggedColumn.instance != null) {
                event.stopPropagation();
                hideColumnDecorations();
                DraggedColumn.instance = null;
            }
        }
    }, DragEndEvent.getType());
    addDomHandler(new DropHandler() {

        @Override
        public void onDrop(DropEvent event) {
            DraggedColumn<?> source = DraggedColumn.instance;
            DraggedColumn<T> target = targetDraggedColumn;
            hideColumnDecorations();
            DraggedColumn.instance = null;
            if (source != null) {
                event.preventDefault();
                event.stopPropagation();
                if (source.isMove()) {
                    AbstractCellTable<T> sourceSection = (AbstractCellTable<T>) source.getTable();
                    // target table may be any section in our grid
                    if (target != null) {
                        Header<?> sourceHeader = source.getHeader();
                        Header<?> targetHeader = target.getHeader();
                        if (sourceHeader instanceof DraggableHeader<?>
                                && targetHeader instanceof DraggableHeader<?>) {
                            DraggableHeader<T> sourceDH = (DraggableHeader<T>) sourceHeader;
                            DraggableHeader<T> targetDH = (DraggableHeader<T>) targetHeader;
                            moveColumnNode(sourceDH.getHeaderNode(), targetDH.getHeaderNode());
                        } else {
                            int sourceIndex = source.getColumnIndex();
                            int targetIndex = target.getColumnIndex();
                            GridSection<T> targetSection = (GridSection<T>) target.getTable();

                            boolean isSourceLeft = sourceSection == headerLeft || sourceSection == frozenLeft
                                    || sourceSection == scrollableLeft || sourceSection == footerLeft;
                            boolean isTargetLeft = targetSection == headerLeft || targetSection == frozenLeft
                                    || targetSection == scrollableLeft || targetSection == footerLeft;
                            sourceSection = isSourceLeft ? headerLeft : headerRight;
                            targetSection = isTargetLeft ? headerLeft : headerRight;
                            int generalSourceIndex = isSourceLeft ? sourceIndex : sourceIndex + frozenColumns;
                            int generalTargetIndex = isTargetLeft ? targetIndex : targetIndex + frozenColumns;
                            Header<?> header = sourceSection.getHeader(sourceIndex);
                            if (header instanceof DraggableHeader) {
                                ((DraggableHeader) header).setTable(targetSection);
                            }
                            if (generalSourceIndex != generalTargetIndex) {
                                Column<T, ?> column = (Column<T, ?>) source.getColumn();
                                if (!(header instanceof DraggableHeader)
                                        || ((DraggableHeader) header).isMoveable()) {
                                    moveColumn(generalSourceIndex, generalTargetIndex);
                                }
                            }
                        }
                    }
                } else {
                    Header<?> header = source.getHeader();
                    if (!(header instanceof DraggableHeader) || ((DraggableHeader) header).isResizable()) {
                        int newWidth = Math.max(
                                event.getNativeEvent().getClientX() - source.getCellElement().getAbsoluteLeft(),
                                MINIMUM_COLUMN_WIDTH);
                        // Source and target tables are the same, so we can
                        // cast to DraggedColumn<T> with no care
                        setColumnWidthFromHeaderDrag(((DraggedColumn<T>) source).getColumn(), newWidth,
                                Style.Unit.PX);
                    }
                }
            }
        }
    }, DropEvent.getType());

    columnsChevron.getElement().getStyle().setPosition(Style.Position.ABSOLUTE);
    columnsChevron.getElement().addClassName(COLUMNS_CHEVRON_STYLE);
    getElement().appendChild(columnsChevron.getElement());
    columnsChevron.addDomHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            PlatypusPopupMenu columnsMenu = new PlatypusPopupMenu();
            fillColumns(columnsMenu, headerLeft);
            fillColumns(columnsMenu, headerRight);
            columnsMenu.setPopupPosition(columnsChevron.getAbsoluteLeft(), columnsChevron.getAbsoluteTop());
            columnsMenu.showRelativeTo(columnsChevron);
        }

        private void fillColumns(MenuBar aTarget, final GridSection<T> aSection) {
            for (int i = 0; i < aSection.getColumnCount(); i++) {
                Header<?> h = aSection.getHeader(i);
                final Column<T, ?> column = aSection.getColumn(i);
                SafeHtml rendered;
                if (h.getValue() instanceof String) {
                    String hVal = (String) h.getValue();
                    rendered = hVal.startsWith("<html>") ? SafeHtmlUtils.fromTrustedString(hVal.substring(6))
                            : SafeHtmlUtils.fromString(hVal);
                } else {
                    Cell.Context context = new Cell.Context(0, i, h.getKey());
                    SafeHtmlBuilder sb = new SafeHtmlBuilder();
                    h.render(context, sb);
                    rendered = sb.toSafeHtml();
                }
                MenuItemCheckBox miCheck = new MenuItemCheckBox(!aSection.isColumnHidden(column),
                        rendered.asString(), true);
                miCheck.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                    @Override
                    public void onValueChange(ValueChangeEvent<Boolean> event) {
                        if (Boolean.TRUE.equals(event.getValue())) {
                            showColumn(column);
                        } else {
                            hideColumn(column);
                        }
                        Grid.this.onResize();
                    }

                });
                aTarget.addItem(miCheck);
            }
        }

    }, ClickEvent.getType());

    ColumnSortEvent.Handler sectionSortHandler = new ColumnSortEvent.Handler() {

        @Override
        public void onColumnSort(ColumnSortEvent event) {
            boolean isCtrlKey = ((GridSection<?>) event.getSource()).isCtrlKey();
            boolean contains = false;
            int containsAt = -1;
            for (int i = 0; i < sortList.size(); i++) {
                if (sortList.get(i).getColumn() == event.getColumn()) {
                    contains = true;
                    containsAt = i;
                    break;
                }
            }
            if (!contains) {
                if (!isCtrlKey) {
                    sortList.clear();
                }
                sortList.insert(sortList.size(), new ColumnSortList.ColumnSortInfo(event.getColumn(), true));
            } else {
                boolean wasAscending = sortList.get(containsAt).isAscending();
                if (!isCtrlKey) {
                    sortList.clear();
                    if (wasAscending) {
                        sortList.push(new ColumnSortList.ColumnSortInfo(event.getColumn(), false));
                    }
                } else {
                    sortList.remove(sortList.get(containsAt));
                    if (wasAscending) {
                        sortList.insert(containsAt,
                                new ColumnSortList.ColumnSortInfo(event.getColumn(), false));
                    }
                }
            }
            ColumnSortEvent.fire(Grid.this, sortList);
        }
    };
    headerLeft.getColumnSortList().setLimit(1);
    headerLeft.addColumnSortHandler(sectionSortHandler);
    headerRight.getColumnSortList().setLimit(1);
    headerRight.addColumnSortHandler(sectionSortHandler);
    gridColor = PublishedColor.create(211, 211, 211, 255);
    regenerateDynamicTDStyles();
    regenerateDynamicOddRowsStyles();
    getElement().<XElement>cast().addResizingTransitionEnd(this);
    setStyleName(GRID_SHELL_STYLE);
}

From source file:com.edgenius.wiki.gwt.client.editor.MCEEmotionsDialog.java

License:Open Source License

public MCEEmotionsDialog(TinyMCE tiny) {
    super(tiny.getEditor());

    //register this dialog to Editor, then this dialog can be hide if panel switched. 
    this.addDialogListener(tiny.getEditor());

    this.tiny = tiny;
    this.addStyleName(Css.MCE_EMOTION_DIALOG);

    FlexTable func = new FlexTable();
    Image img1 = new Image(GwtClientUtils.getBaseUrl() + RENDER_RESOURCE_PATH + "emotions/smiley-smile.gif");
    img1.addClickHandler(this);

    Image img2 = new Image(GwtClientUtils.getBaseUrl() + RENDER_RESOURCE_PATH + "emotions/smiley-cry.gif");
    img2.addClickHandler(this);

    Image img3 = new Image(GwtClientUtils.getBaseUrl() + RENDER_RESOURCE_PATH + "emotions/smiley-wink.gif");
    img3.addClickHandler(this);

    Image img4 = new Image(GwtClientUtils.getBaseUrl() + RENDER_RESOURCE_PATH + "emotions/smiley-laugh.gif");
    img4.addClickHandler(this);

    Image img5 = new Image(GwtClientUtils.getBaseUrl() + RENDER_RESOURCE_PATH + "emotions/smiley-star.gif");
    img5.addClickHandler(this);

    Image img6 = new Image(GwtClientUtils.getBaseUrl() + RENDER_RESOURCE_PATH + "emotions/smiley-yes.gif");
    img6.addClickHandler(this);

    Image img7 = new Image(GwtClientUtils.getBaseUrl() + RENDER_RESOURCE_PATH + "emotions/smiley-no.gif");
    img7.addClickHandler(this);

    Image img8 = new Image(
            GwtClientUtils.getBaseUrl() + RENDER_RESOURCE_PATH + "emotions/smiley-lightbulb.gif");
    img8.addClickHandler(this);

    Image img11 = new Image(GwtClientUtils.getBaseUrl() + RENDER_RESOURCE_PATH + "emotions/yes.png");
    img11.addClickHandler(this);
    Image img12 = new Image(GwtClientUtils.getBaseUrl() + RENDER_RESOURCE_PATH + "emotions/no.png");
    img12.addClickHandler(this);
    Image img13 = new Image(GwtClientUtils.getBaseUrl() + RENDER_RESOURCE_PATH + "emotions/warning.png");
    img13.addClickHandler(this);
    Image img14 = new Image(GwtClientUtils.getBaseUrl() + RENDER_RESOURCE_PATH + "emotions/cake.png");
    img14.addClickHandler(this);
    Image img15 = new Image(GwtClientUtils.getBaseUrl() + RENDER_RESOURCE_PATH + "emotions/bell.png");
    img15.addClickHandler(this);
    Image img16 = new Image(GwtClientUtils.getBaseUrl() + RENDER_RESOURCE_PATH + "emotions/award.png");
    img16.addClickHandler(this);
    Image img17 = new Image(GwtClientUtils.getBaseUrl() + RENDER_RESOURCE_PATH + "emotions/bulletgreen.png");
    img17.addClickHandler(this);
    Image img18 = new Image(GwtClientUtils.getBaseUrl() + RENDER_RESOURCE_PATH + "emotions/bulletred.png");
    img18.addClickHandler(this);

    Image img21 = new Image(GwtClientUtils.getBaseUrl() + RENDER_RESOURCE_PATH + "emotions/flaggreen.png");
    img21.addClickHandler(this);
    Image img22 = new Image(GwtClientUtils.getBaseUrl() + RENDER_RESOURCE_PATH + "emotions/flagyellow.png");
    img22.addClickHandler(this);
    Image img23 = new Image(GwtClientUtils.getBaseUrl() + RENDER_RESOURCE_PATH + "emotions/flagred.png");
    img23.addClickHandler(this);
    Image img24 = new Image(GwtClientUtils.getBaseUrl() + RENDER_RESOURCE_PATH + "emotions/idea.png");
    img24.addClickHandler(this);
    Image img25 = new Image(GwtClientUtils.getBaseUrl() + RENDER_RESOURCE_PATH + "emotions/flash.png");
    img25.addClickHandler(this);
    Image img26 = new Image(GwtClientUtils.getBaseUrl() + RENDER_RESOURCE_PATH + "emotions/dollar.png");
    img26.addClickHandler(this);
    Image img27 = new Image(GwtClientUtils.getBaseUrl() + RENDER_RESOURCE_PATH + "emotions/magnifier.png");
    img27.addClickHandler(this);
    Image img28 = new Image(GwtClientUtils.getBaseUrl() + RENDER_RESOURCE_PATH + "emotions/lock.png");
    img28.addClickHandler(this);

    func.setWidget(0, 0, img1);//from   www .  j av  a2 s  . co  m
    func.setWidget(0, 1, img2);
    func.setWidget(0, 2, img3);
    func.setWidget(0, 3, img4);
    func.setWidget(0, 4, img5);
    func.setWidget(0, 5, img6);
    func.setWidget(0, 6, img7);
    func.setWidget(0, 7, img8);
    func.setWidget(1, 0, img11);
    func.setWidget(1, 1, img12);
    func.setWidget(1, 2, img13);
    func.setWidget(1, 3, img14);
    func.setWidget(1, 4, img15);
    func.setWidget(1, 5, img16);
    func.setWidget(1, 6, img17);
    func.setWidget(1, 7, img18);
    func.setWidget(2, 0, img21);
    func.setWidget(2, 1, img22);
    func.setWidget(2, 2, img23);
    func.setWidget(2, 3, img24);
    func.setWidget(2, 4, img25);
    func.setWidget(2, 5, img26);
    func.setWidget(2, 6, img27);
    func.setWidget(2, 7, img28);

    func.setCellSpacing(8);
    this.setWidget(func);
    this.setText(Msg.consts.insert_smiley());
}

From source file:com.edgenius.wiki.gwt.client.editor.MCEImageDialog.java

License:Open Source License

public MCEImageDialog(final TinyMCE tiny) {
    super(tiny);/*from   w w w  .  j  a  v  a  2 s  .  com*/

    this.spaceUname = tiny.getEditor().getSpaceUname();

    this.setText(Msg.consts.insert_image());
    Label label = new Label(Msg.consts.image());
    Label titleL = new Label(Msg.consts.title());

    FlexTable func = new FlexTable();
    func.setWidget(0, 0, label);
    func.setWidget(0, 1, suggest);
    func.setWidget(1, 0, titleL);
    func.setWidget(1, 1, titleBox);

    VerticalPanel panel = new VerticalPanel();
    panel.add(message);
    panel.add(func);

    panel.add(slider);
    slider.addImageSlideListener(this);
    panel.setCellHorizontalAlignment(slider, HasHorizontalAlignment.ALIGN_CENTER);

    refreshSlider();

    panel.setSize("100%", "100%");
    func.setSize("100%", "100%");
    label.setStyleName(Css.FORM_LABEL);
    titleL.setStyleName(Css.FORM_LABEL);
    box.setStyleName(Css.FORM_INPUT);
    titleBox.setStyleName(Css.FORM_INPUT);

    final AttachmentPanel attachmentPanel = tiny.getEditor().getAttachmentPanel();
    if (attachmentPanel != null && !PageMain.isAnonymousLogin()) {
        adoptElement(attachmentPanel.getPanelID());
        attachmentPanel.addAttachmentListener(this);

        //allow upload image
        ClickLink uploadImg = new ClickLink(Msg.consts.upload());
        uploadImg.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                UploadDialog dialog = new UploadDialog(tiny.getEditor().getAttachmentPanel(),
                        PageMain.getSpaceUname(), PageMain.getPageUuid(), PageType.AUTO_DRAFT);
                dialog.showbox();
            };
        });
        panel.add(uploadImg);
        panel.setCellHorizontalAlignment(uploadImg, HasHorizontalAlignment.ALIGN_RIGHT);
    }
    this.setWidget(panel);
    //don't set focus as it will erase the hint text.
    //      Scheduler.get().scheduleDeferred(new ScheduledCommand() {
    //         public void execute() {
    //            suggest.setFocus(true);
    //         }
    //      });
}