List of usage examples for com.google.gwt.user.client.ui Widget addStyleName
public void addStyleName(String style)
From source file:edu.caltech.ipac.firefly.ui.TitlePanel.java
private void makeTitleLabel(Widget w) { w.setStyleName("title-bar"); w.addStyleName("title-bg-color"); w.addStyleName("title-color"); w.addStyleName("title-font-family"); }
From source file:edu.caltech.ipac.firefly.visualize.DefaultDrawable.java
public Widget addDrawingArea(Widget w, boolean highPriority) { w.setPixelSize(_width, _height);/*from w w w . ja va 2 s.c o m*/ w.addStyleName("drawingArea"); if (highPriority) { _drawingPanel.add(w, 0, 0); highPriorityList.add(w); } else { if (highPriorityList.size() > 0) { int pos = 0; boolean insert = false; for (Widget panel : _drawingPanel) { if (highPriorityList.contains(panel)) { insert = true; break; } pos++; } if (insert && pos < _drawingPanel.getWidgetCount()) { _drawingPanel.insert(w, pos); _drawingPanel.setWidgetPosition(w, 0, 0); } else { _drawingPanel.add(w, 0, 0); } } else { _drawingPanel.add(w, 0, 0); } } addID(w); return w; }
From source file:edu.caltech.ipac.firefly.visualize.DefaultDrawable.java
public void replaceDrawingArea(Widget old, Widget w) { int idx = _drawingPanel.getWidgetIndex(old); if (idx > -1) { w.addStyleName("drawingArea"); w.setPixelSize(_width, _height); _drawingPanel.insert(w, idx);/*from www. ja v a 2s . c o m*/ _drawingPanel.setWidgetPosition(w, 0, 0); _drawingPanel.remove(idx + 1); } addID(w); }
From source file:edu.caltech.ipac.firefly.visualize.DefaultDrawable.java
public void insertBeforeDrawingArea(Widget before, Widget w) { int idx = _drawingPanel.getWidgetIndex(before); if (idx > -1) { w.addStyleName("drawingArea"); w.setPixelSize(_width, _height); _drawingPanel.insert(w, idx);/* w ww . j a v a 2s.c o m*/ _drawingPanel.setWidgetPosition(w, 0, 0); } addID(w); }
From source file:edu.caltech.ipac.firefly.visualize.DefaultDrawable.java
public void insertAfterDrawingArea(Widget after, Widget w) { int idx = _drawingPanel.getWidgetIndex(after); int cnt = _drawingPanel.getWidgetCount(); if (idx == -1 || idx >= cnt - 1) { _drawingPanel.add(w);//from w w w. j av a2 s . c o m } else { _drawingPanel.insert(w, idx + 1); } w.addStyleName("drawingArea"); w.setPixelSize(_width, _height); _drawingPanel.setWidgetPosition(w, 0, 0); addID(w); }
From source file:edu.caltech.ipac.firefly.visualize.graph.XYPlotBasicWidget.java
private void setChartAxes(MinMax xMinMax, MinMax yMinMax) { // set axes min/max and ticks GChart.Axis xAxis = _chart.getXAxis(); GChart.Axis yAxis = _chart.getYAxis(); String xUnits = getXColUnits(); xAxis.setAxisLabel(_meta.getXName(_data) + (StringUtils.isEmpty(xUnits) ? "" : " (" + xUnits + ")")); if (_xScale instanceof LogScale) { setLogScaleAxis(xAxis, xMinMax, TICKS * _xResizeFactor); } else {//from w ww. j av a2s. c o m setLinearScaleAxis(xAxis, xMinMax, TICKS * _xResizeFactor); } String yName = _meta.getYName(_data); Widget yLabel; int yLabelLines = 1; if (getYColUnits().length() > 0) { if (yName.length() + getYColUnits().length() > 20) yLabelLines++; yLabel = new HTML(yName + (yLabelLines > 1 ? "<br>" : " ") + "(" + getYColUnits() + ")"); } else { yLabel = new HTML(yName); } yLabel.addStyleName(_ffCss.rotateLeft()); yAxis.setAxisLabel(yLabel); yAxis.setAxisLabelThickness(yLabelLines * 20); if (_yScale instanceof LogScale) { setLogScaleAxis(yAxis, yMinMax, TICKS * _yResizeFactor); } else { setLinearScaleAxis(yAxis, yMinMax, TICKS * _yResizeFactor); } // adjust symbol size for sampled data // comment it if you'd like same size symbols adjustSymbolSize(); }
From source file:edu.caltech.ipac.firefly.visualize.graph.XYPlotOptionsPanel.java
private void layout(final XYPlotData data) { // Plot Error plotError = GwtUtil.makeCheckBox("XYPlotOptionsDialog.plotError"); plotError.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { if (plotError.getValue() && !plotError.isEnabled()) { // should not happen } else { XYPlotMeta meta = _xyPlotWidget.getPlotMeta(); meta.setPlotError(plotError.getValue()); _xyPlotWidget.updateMeta(meta, true); // preserve zoom }//from ww w. j av a 2 s . c om } }); // Plot Specific Points plotSpecificPoints = GwtUtil.makeCheckBox("XYPlotOptionsDialog.plotSpecificPoints"); plotSpecificPoints.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { if (plotSpecificPoints.getValue() && !plotSpecificPoints.isEnabled()) { //should not happen } else { XYPlotMeta meta = _xyPlotWidget.getPlotMeta(); meta.setPlotSpecificPoints(plotSpecificPoints.getValue()); _xyPlotWidget.updateMeta(meta, true); // preserve zoom } } }); // Alternative Columns HTML colPanelDesc = GwtUtil.makeFaddedHelp( "For X and Y, enter a column or an expression<br>" + "ex. log(col); 100*col1/col2; col1-col2"); ColExpressionOracle oracle = new ColExpressionOracle(); FieldDef xColFD = FieldDefCreator.makeFieldDef("XYPlotOptionsDialog.x.col"); xColFld = new ValidationInputField(new SuggestBoxInputField(xColFD, oracle)); FieldDef yColFD = FieldDefCreator.makeFieldDef("XYPlotOptionsDialog.y.col"); yColFld = new ValidationInputField(new SuggestBoxInputField(yColFD, oracle)); // column selection Widget xColSelection = GwtUtil.makeLinkButton("Cols", "Select X column", new ClickHandler() { public void onClick(ClickEvent clickEvent) { if (xColDialog == null) xColDialog = new ShowColumnsDialog("Choose X", "Set X", _xyPlotWidget.getColumns(), xColFld); xColDialog.show(); //showChooseColumnPopup("Choose X", xColFld); } }); Widget yColSelection = GwtUtil.makeLinkButton("Cols", "Select Y column", new ClickHandler() { public void onClick(ClickEvent clickEvent) { if (yColDialog == null) yColDialog = new ShowColumnsDialog("Choose Y", "Set Y", _xyPlotWidget.getColumns(), yColFld); yColDialog.show(); //showChooseColumnPopup("Choose Y", yColFld); } }); FormBuilder.Config config = new FormBuilder.Config(FormBuilder.Config.Direction.VERTICAL, 50, 0, HorizontalPanel.ALIGN_LEFT); xNameFld = FormBuilder.createField("XYPlotOptionsDialog.x.name"); xUnitFld = FormBuilder.createField("XYPlotOptionsDialog.x.unit"); Widget xNameUnit = FormBuilder.createPanel(config, xNameFld, xUnitFld); CollapsiblePanel xNameUnitCP = new CollapsiblePanel("X Label/Unit", xNameUnit, false); yNameFld = FormBuilder.createField("XYPlotOptionsDialog.y.name"); yUnitFld = FormBuilder.createField("XYPlotOptionsDialog.y.unit"); Widget yNameUnit = FormBuilder.createPanel(config, yNameFld, yUnitFld); CollapsiblePanel yNameUnitCP = new CollapsiblePanel("Y Label/Unit", yNameUnit, false); FlexTable colPanel = new FlexTable(); DOM.setStyleAttribute(colPanel.getElement(), "padding", "5px"); colPanel.setCellSpacing(8); colPanel.setHTML(0, 0, "X: "); colPanel.setWidget(0, 1, xColFld); colPanel.setWidget(0, 2, xColSelection); xLogScale = GwtUtil.makeCheckBox("XYPlotOptionsDialog.xLogScale"); xLogScale.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { if (!suspendEvents) { if (xLogScale.getValue() && !xLogScale.isEnabled()) { // should not happen } else { XYPlotMeta meta = _xyPlotWidget.getPlotMeta(); meta.setXScale(xLogScale.getValue() ? XYPlotMeta.LOG_SCALE : XYPlotMeta.LINEAR_SCALE); _xyPlotWidget.updateMeta(meta, true); // preserve zoom } } } }); colPanel.setWidget(0, 3, xLogScale); colPanel.setWidget(1, 1, xNameUnitCP); colPanel.setHTML(2, 0, "Y: "); colPanel.setWidget(2, 1, yColFld); colPanel.setWidget(2, 2, yColSelection); colPanel.setWidget(3, 1, yNameUnitCP); yLogScale = GwtUtil.makeCheckBox("XYPlotOptionsDialog.yLogScale"); yLogScale.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { if (!suspendEvents) { if (yLogScale.getValue() && !yLogScale.isEnabled()) { // should not happen } else { XYPlotMeta meta = _xyPlotWidget.getPlotMeta(); meta.setYScale(yLogScale.getValue() ? XYPlotMeta.LOG_SCALE : XYPlotMeta.LINEAR_SCALE); _xyPlotWidget.updateMeta(meta, true); // preserve zoom } } } }); colPanel.setWidget(2, 3, yLogScale); // Plot Style plotStyle = SimpleInputField.createByProp("XYPlotOptionsDialog.plotStyle"); plotStyle.getField().addValueChangeHandler(new ValueChangeHandler<String>() { public void onValueChange(ValueChangeEvent<String> ev) { if (!suspendEvents) { String value = plotStyle.getValue(); if (value != null) { XYPlotMeta meta = _xyPlotWidget.getPlotMeta(); meta.setPlotStyle(XYPlotMeta.PlotStyle.getPlotStyle(value)); _xyPlotWidget.updateMeta(meta, true); // preserve zoom } } } }); // Gridlines plotGrid = GwtUtil.makeCheckBox("XYPlotOptionsDialog.grid"); plotGrid.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { if (!suspendEvents) { XYPlotMeta meta = _xyPlotWidget.getPlotMeta(); meta.setNoGrid(!plotGrid.getValue()); _xyPlotWidget.setGridlines(); } } }); // Y MIN and MAX xMinMaxPanelDesc = GwtUtil .makeFaddedHelp(getXMinMaxDescHTML(data == null ? null : data.getXDatasetMinMax())); yMinMaxPanelDesc = GwtUtil .makeFaddedHelp(getYMinMaxDescHTML(data == null ? null : data.getYDatasetMinMax())); FormBuilder.Config cX = new FormBuilder.Config(FormBuilder.Config.Direction.HORIZONTAL, 50, 5, HorizontalPanel.ALIGN_LEFT); xMinMaxPanel = new MinMaxPanel("XYPlotOptionsDialog.x.min", "XYPlotOptionsDialog.x.max", cX); xColFld.addValueChangeHandler(new ValueChangeHandler<String>() { public void onValueChange(ValueChangeEvent<String> stringValueChangeEvent) { suspendEvents = true; // reset scale to linear xLogScale.setValue(false); //xLogScale.setEnabled(false); xNameFld.reset(); xUnitFld.reset(); // clear xMinMaxPanel xMinMaxPanel.getMinField().reset(); xMinMaxPanel.getMaxField().reset(); } }); FormBuilder.Config cY = new FormBuilder.Config(FormBuilder.Config.Direction.HORIZONTAL, 50, 5, HorizontalPanel.ALIGN_LEFT); yMinMaxPanel = new MinMaxPanel("XYPlotOptionsDialog.y.min", "XYPlotOptionsDialog.y.max", cY); yColFld.addValueChangeHandler(new ValueChangeHandler<String>() { public void onValueChange(ValueChangeEvent<String> stringValueChangeEvent) { suspendEvents = true; // reset scale to linear yLogScale.setValue(false); //yLogScale.setEnabled(false); yNameFld.reset(); yUnitFld.reset(); // clear xMinMaxPanel yMinMaxPanel.getMinField().reset(); yMinMaxPanel.getMaxField().reset(); } }); //maxPoints = SimpleInputField.createByProp("XYPlotOptionsDialog.maxPoints"); String bprop = _prop.makeBase("apply"); String bname = WebProp.getName(bprop); String btip = WebProp.getTip(bprop); Button apply = new Button(bname, new ClickHandler() { public void onClick(ClickEvent ev) { if (xMinMaxPanel.validate() && yMinMaxPanel.validate() && validateColumns() && validateDensityPlotParams() && xyRatioFld.validate()) { // current list of column names List<TableDataView.Column> columnLst = _xyPlotWidget.getColumns(); List<String> cols = new ArrayList<String>(columnLst.size()); for (TableDataView.Column c : columnLst) { cols.add(c.getName()); } XYPlotMeta meta = _xyPlotWidget.getPlotMeta(); meta.setXScale(xLogScale.getValue() ? XYPlotMeta.LOG_SCALE : XYPlotMeta.LINEAR_SCALE); meta.setYScale(yLogScale.getValue() ? XYPlotMeta.LOG_SCALE : XYPlotMeta.LINEAR_SCALE); meta.setPlotStyle(XYPlotMeta.PlotStyle.getPlotStyle(plotStyle.getValue())); meta.setNoGrid(!plotGrid.getValue()); meta.userMeta.setXLimits(getMinMaxValues(xMinMaxPanel)); meta.userMeta.setYLimits(getMinMaxValues(yMinMaxPanel)); // Columns if (xColExpr != null) { meta.userMeta.xColExpr = xColExpr; meta.userMeta.setXCol(null); } else { String xCol = xColFld.getValue(); if (StringUtils.isEmpty(xCol) || xCol.equals(meta.findDefaultXColName(cols))) { xCol = null; } meta.userMeta.setXCol(xCol); meta.userMeta.xColExpr = null; } if (yColExpr != null) { meta.userMeta.yColExpr = yColExpr; meta.userMeta.setYCol(null); nonDefaultYColumn(meta, true); } else { String yCol = yColFld.getValue(); String errorCol; boolean defaultYCol = yCol.equals(meta.findDefaultYColName(cols)); if (StringUtils.isEmpty(yCol) || defaultYCol) { yCol = null; errorCol = null; plotError.setEnabled(true); plotSpecificPoints.setEnabled(true); } else { nonDefaultYColumn(meta, false); errorCol = "_"; // no error column for non-default y column } meta.userMeta.setYCol(yCol); meta.userMeta.yColExpr = null; meta.userMeta.setErrorCol(errorCol); } if (!StringUtils.isEmpty(xNameFld.getValue())) { meta.userMeta.xName = xNameFld.getValue(); } else { meta.userMeta.xName = null; } if (!StringUtils.isEmpty(xUnitFld.getValue())) { meta.userMeta.xUnit = xUnitFld.getValue(); } else { meta.userMeta.xUnit = null; } if (!StringUtils.isEmpty(yNameFld.getValue())) { meta.userMeta.yName = yNameFld.getValue(); } else { meta.userMeta.yName = null; } if (!StringUtils.isEmpty(yUnitFld.getValue())) { meta.userMeta.yUnit = yUnitFld.getValue(); } else { meta.userMeta.yUnit = null; } // aspect ratio fields meta.userMeta.stretchToFill = stretchFld.getValue().equals("fill"); if (StringUtils.isEmpty(xyRatioFld.getValue())) { if (meta.userMeta.aspectRatio > 0) { meta.userMeta.aspectRatio = -1; } } else { meta.userMeta.aspectRatio = ((DoubleFieldDef) xyRatioFld.getFieldDef()) .getDoubleValue(xyRatioFld.getValue()); } // density plot parameters if (binning.getValue().equals("user")) { meta.userMeta.samplingXBins = Integer.parseInt(xBinsFld.getValue()); meta.userMeta.samplingYBins = Integer.parseInt(yBinsFld.getValue()); } else { meta.userMeta.samplingXBins = 0; meta.userMeta.samplingYBins = 0; } meta.userMeta.logShading = shading.getValue().equals("log"); //meta.setMaxPoints(Integer.parseInt(maxPoints.getValue())); try { _xyPlotWidget.updateMeta(meta, false); } catch (Exception e) { PopupUtil.showError("Update failed", e.getMessage()); } } } }); apply.setTitle(btip); Button cancel = new Button("Reset", new ClickHandler() { public void onClick(ClickEvent ev) { restoreDefault(); } }); cancel.setTitle("Restore default values"); VerticalPanel vbox = new VerticalPanel(); vbox.setSpacing(5); vbox.add(plotError); vbox.add(plotSpecificPoints); vbox.add(colPanelDesc); vbox.add(colPanel); HorizontalPanel hp = new HorizontalPanel(); hp.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); hp.add(plotGrid); GwtUtil.setStyles(plotGrid, "paddingLeft", "15px", "paddingBottom", "5px"); hp.add(plotStyle); GwtUtil.setStyle(plotStyle, "paddingLeft", "20px"); vbox.add(hp); //vbox.add(plotStyle); //vbox.add(plotGrid); // aspect ratio FormBuilder.Config configAR = new FormBuilder.Config(FormBuilder.Config.Direction.VERTICAL, 70, 0, HorizontalPanel.ALIGN_LEFT); xyRatioFld = FormBuilder.createField("XYPlotOptionsDialog.xyratio"); stretchFld = FormBuilder.createField("XYPlotOptionsDialog.stretch"); stretchFld.addValueChangeHandler(new ValueChangeHandler() { @Override public void onValueChange(ValueChangeEvent event) { if (stretchFld.getValue().equals("fill") && StringUtils.isEmpty(xyRatioFld.getValue())) { xyRatioFld.setValue("1"); } } }); VerticalPanel arParams = new VerticalPanel(); DOM.setStyleAttribute(arParams.getElement(), "paddingLeft", "10px"); arParams.setHorizontalAlignment(HorizontalPanel.ALIGN_CENTER); arParams.setSpacing(5); arParams.add(GwtUtil.makeFaddedHelp("Fix display aspect ratio by setting the field below.<br>" + "Leave it blank to use all available space.")); arParams.add(FormBuilder.createPanel(configAR, xyRatioFld, stretchFld)); //Widget aspectRatioPanel = new CollapsiblePanel("Aspect Ratio", arParams, false); //vbox.add(aspectRatioPanel); // density plot parameters binning = FormBuilder.createField("XYPlotOptionsDialog.binning"); binning.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent event) { xBinsFld.reset(); yBinsFld.reset(); boolean enabled = binning.getValue().equals("user"); xBinsFld.getFocusWidget().setEnabled(enabled); yBinsFld.getFocusWidget().setEnabled(enabled); } }); shading = FormBuilder.createField("XYPlotOptionsDialog.shading"); xBinsFld = FormBuilder.createField("XYPlotOptionsDialog.x.bins"); yBinsFld = FormBuilder.createField("XYPlotOptionsDialog.y.bins"); boolean enabled = binning.getValue().equals("user"); xBinsFld.getFocusWidget().setEnabled(enabled); yBinsFld.getFocusWidget().setEnabled(enabled); VerticalPanel binningParams = new VerticalPanel(); FormBuilder.Config configDP1 = new FormBuilder.Config(FormBuilder.Config.Direction.VERTICAL, 50, 0, HorizontalPanel.ALIGN_LEFT); FormBuilder.Config configDP2 = new FormBuilder.Config(FormBuilder.Config.Direction.VERTICAL, 110, 0, HorizontalPanel.ALIGN_LEFT); binningParams.add(FormBuilder.createPanel(configDP1, binning)); binningParams.add(FormBuilder.createPanel(configDP2, xBinsFld, yBinsFld)); binningParams.add(FormBuilder.createPanel(configDP1, shading)); densityPlotPanel = new CollapsiblePanel("Binning Options", binningParams, false); vbox.add(densityPlotPanel); VerticalPanel vbox1 = new VerticalPanel(); vbox1.add(xMinMaxPanelDesc); vbox1.add(xMinMaxPanel); vbox1.add(yMinMaxPanelDesc); vbox1.add(yMinMaxPanel); vbox1.add(arParams); //if (_xyPlotWidget instanceof XYPlotWidget) { // tableInfo = GwtUtil.makeFaddedHelp(((XYPlotWidget)_xyPlotWidget).getTableInfo()); // vbox1.add(tableInfo); // vbox1.add(maxPoints); //} else { // vbox1.add(maxPoints); // maxPoints.setVisible(false); //} CollapsiblePanel cpanel = new CollapsiblePanel("More Options", vbox1, false); vbox.add(cpanel); //vbox.add(addToDefault); Widget buttons = GwtUtil.leftRightAlign(new Widget[] { cancel }, new Widget[] { apply, HelpManager.makeHelpIcon("visualization.chartoptions") }); buttons.addStyleName("base-dialog-buttons"); vbox.add(buttons); _mainPanel.setWidget(vbox); }
From source file:edu.caltech.ipac.firefly.visualize.ui.ImageSelectDropDown.java
private Widget createContents(PlotWidgetFactory plotFactory) { if (useNewPanel) { imSelPanel2 = new ImageSelectPanel2(new DropDownComplete(), plotter); } else {/*from w w w .jav a 2 s . c o m*/ imSelPanel = new ImageSelectPanel(null, true, null, new DropDownComplete(), plotFactory); } HorizontalPanel buttons = new HorizontalPanel(); buttons.addStyleName("base-dialog-buttons"); buttons.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); GwtUtil.setStyle(buttons, "paddingRight", "80px"); Button ok = new Button("Load"); ok.addStyleName("highlight-text"); ok.addClickHandler(new ClickHandler() { public void onClick(ClickEvent ev) { doOK(); } }); buttons.add(ok); buttons.add(HelpManager.makeHelpIcon("basics.catalog")); VerticalPanel vp = new VerticalPanel(); Widget content; if (useNewPanel) { content = GwtUtil.centerAlign(imSelPanel2.getMainPanel()); } else { content = GwtUtil.centerAlign(imSelPanel.getMainPanel()); } vp.add(content); vp.add(buttons); vp.setCellHorizontalAlignment(content, VerticalPanel.ALIGN_CENTER); vp.setSize("95%", "450px"); vp.setSpacing(3); content.setSize("95%", "95%"); content.addStyleName("component-background"); if (useNewPanel) { addKeyPressToAll(imSelPanel2.getMainPanel()); } else { addKeyPressToAll(imSelPanel.getMainPanel()); } return vp; }
From source file:edu.mayo.mprc.swift.ui.client.widgets.CustomDisclosurePanel.java
License:Apache License
/** * Sets the content widget which can be opened and closed by this panel. If * there is a preexisting content widget, it will be detached. * * @param content the widget to be used as the content panel *//*from w w w .j av a 2 s. c o m*/ public void setContent(final Widget content) { final Widget currentContent = this.content; // Remove existing content widget. if (currentContent != null) { mainPanel.remove(currentContent); currentContent.removeStyleName(STYLENAME_CONTENT); } // Add new content widget if != null. this.content = content; if (content != null) { mainPanel.add(content); content.addStyleName(STYLENAME_CONTENT); setContentDisplay(); } }
From source file:edu.purdue.pivot.skwiki.client.dnd.PaletteWidget.java
License:Apache License
/** * Default constructor to wrap the provided widget. * //ww w . j av a 2 s.co m * @param widget * the widget to be wrapped */ public PaletteWidget(Widget widget) { setSize("400px", "400px"); this.widget = widget; // **** new from Dnd add(header, 0, 0); add(widget, 0, 25); // Add some CSS styling addStyleName("demo-PaletteWidget"); widget.addStyleName("demo-PaletteWidget-widget"); shim.addStyleName("demo-PaletteWidget-shim"); }