private void showSetCellAlignmentDialog(final ListBox listBox, final IAlignment iAlignment) { final DialogBox origDialog = new DialogBox(); DOM.setStyleAttribute(origDialog.getElement(), "zIndex", Integer.toString(Integer.MAX_VALUE)); final VerticalPanel dialog = new VerticalPanel(); origDialog.add(dialog); origDialog.setText("Cell Alignment Dialog"); dialog.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER); dialog.add(new Label("Please choose the Widget :")); final ListBox widgetIndexLb = new ListBox(); for (Iterator<Widget> iterator = iterator(); iterator.hasNext(); ) { Widget next = iterator.next(); widgetIndexLb.addItem( ((IVkWidget) next).getWidgetName() + " - at index - " + getWidgetIndex(next)); } widgetIndexLb.setWidth("300px"); dialog.add(widgetIndexLb); widgetIndexLb.addChangeHandler( new ChangeHandler() { @Override public void onChange(ChangeEvent event) { iAlignment.doAlignment( widgetIndexLb.getSelectedIndex(), listBox.getValue(listBox.getSelectedIndex())); } }); dialog.add(new Label("Please choose Alignment")); dialog.add(listBox); listBox.addChangeHandler( new ChangeHandler() { @Override public void onChange(ChangeEvent event) { iAlignment.doAlignment( widgetIndexLb.getSelectedIndex(), listBox.getValue(listBox.getSelectedIndex())); } }); HorizontalPanel buttonsPanel = new HorizontalPanel(); dialog.add(buttonsPanel); Button saveButton = new Button("OK"); buttonsPanel.add(saveButton); saveButton.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { // iAlignment.doAlignment(widgetIndexLb.getSelectedIndex(), // listBox.getValue(listBox.getSelectedIndex())); origDialog.hide(); } }); Button cancelButton = new Button("Cancel"); buttonsPanel.add(cancelButton); cancelButton.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { origDialog.hide(); } }); origDialog.center(); }
private void popupDbCurator() { ClientSequenceDatabase csd = (ClientSequenceDatabase) dlb.getSelected(); Integer selected = csd.getId(); Map<String, String> emailInitialPairs = new TreeMap<String, String>(); for (Map.Entry<String, ClientUser> me : userInfo.entrySet()) { emailInitialPairs.put(me.getKey(), me.getValue().getInitials()); } final DialogBox dialogBox = new DialogBox(false); CurationEditor ce = new CurationEditor( selected, user.getEmail(), emailInitialPairs, new EditorCloseCallback() { public void editorClosed(final Integer openCurationID) { validationController.getAllowedValues( dlb, new Callback() { public void done() { if (openCurationID != null) { dlb.select(openCurationID, validationController); } dialogBox.hide(); } }); } }); DOM.setElementAttribute(dialogBox.getElement(), "id", "db-curator"); dialogBox.setStyleName("dbCuratorEmbed"); dialogBox.setWidget(ce); dialogBox.setSize(Window.getClientWidth() * .8 + "px", Window.getClientHeight() * .8 + "px"); ce.setPixelSize( Math.max((int) (Window.getClientWidth() * .8), 770), (int) (Window.getClientHeight() * .8)); // LightBox lb = new LightBox(dialogBox); // try { // lb.show(); // } catch (Exception ignore) { dialogBox.show(); // } dialogBox.center(); }
public void Configure_start_time() { final DialogBox dialogBox = new DialogBox(); dialogBox.addStyleName("g-DialogBox"); DOM.setStyleAttribute(dialogBox.getElement(), "border", "0px"); dialogBox.setText("Set Time"); dialogBox.setSize("294", "207"); final AbsolutePanel absolutePanel = new AbsolutePanel(); dialogBox.setWidget(absolutePanel); absolutePanel.setSize("294px", "187px"); // 自定义datebox的输出格式,在这里采用了简洁的输出格式"M/d/yy H:mm" final DateBox dateBox = new DateBox(); DateTimeFormat dateTimeFormat = DateTimeFormat.getFormat( "M/d/yy H:mm"); // DateTimeFormat只能通过函数getFormat来生成满足特定pattern的对象,因为其构造函数为protected DateBox.DefaultFormat defaultFormat = new DateBox.DefaultFormat(dateTimeFormat); dateBox.setFormat(defaultFormat); absolutePanel.add(dateBox, 109, 35); dateBox.setWidth("150px"); final Label dateLabel = new Label("Date:"); absolutePanel.add(dateLabel, 36, 35); dateLabel.setSize("38px", "18px"); final Label dateLabel_1 = new Label("Time:"); absolutePanel.add(dateLabel_1, 36, 80); dateLabel_1.setSize("38px", "18px"); final ListBox listBox = new ListBox(); absolutePanel.add(listBox, 109, 77); listBox.setSize("150px", "21px"); String[] minutes = {"00", "15", "30", "45"}; String[] hours = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23" }; String[] times = new String[96]; // System.out.println(minutes.length+" "+hours.length+" "+times.length); for (int i = 0; i < 24; i++) { for (int j = 0; j < 4; j++) { times[4 * i + j] = hours[i] + ":" + minutes[j]; } } for (int i = 0; i < 96; i++) { listBox.addItem(times[i]); } final Button okButton = new Button(); DOM.setStyleAttribute(okButton.getElement(), "fontSize", "10pt"); okButton.removeStyleName("gwt-Button"); okButton.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { // TODO Auto-generated method stub TextBox inner_textBox = dateBox.getTextBox(); if (inner_textBox.getText() == null || inner_textBox.getText().equals("")) { dateBox.addStyleName("dateBoxFormatError"); // 如果用户没编辑日期,则datebox框变红,等待用户更正 } else { String dateString = inner_textBox.getText(); int index = listBox.getSelectedIndex(); String timeString = listBox.getValue(index); if (timeString != null) { String[] date_and_time = dateString.split(" "); date_and_time[1] = timeString; dateString = date_and_time[0] + " " + date_and_time[1]; start_time = dateString; } dialogBox.hide(); } System.out.println(start_time); } }); absolutePanel.add(okButton, 93, 129); okButton.setSize("105px", "21px"); okButton.setText("OK"); dialogBox.center(); }
private void showAddItemAttributeDialog(final VkMenuBarHorizontal menuBar) { final DialogBox origDialog = new DialogBox(); DOM.setStyleAttribute(origDialog.getElement(), "zIndex", Integer.toString(Integer.MAX_VALUE)); final VerticalPanel dialog = new VerticalPanel(); origDialog.add(dialog); origDialog.setText("Provide html for item name and JS to execute on its click"); dialog.setWidth("100%"); dialog.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER); DOM.setStyleAttribute(origDialog.getElement(), "zIndex", Integer.MAX_VALUE + ""); HorizontalPanel nameHp = new HorizontalPanel(); nameHp.setWidth("100%"); dialog.add(nameHp); nameHp.setHorizontalAlignment(HorizontalPanel.ALIGN_RIGHT); nameHp.add(new Label("Name HTML:")); nameHp.setHorizontalAlignment(HorizontalPanel.ALIGN_LEFT); nameHp.setCellWidth(nameHp.getWidget(0), "35%"); final TextArea nameTextArea = new TextArea(); nameHp.add(nameTextArea); nameTextArea.setSize("300px", "100px"); Timer t = new Timer() { @Override public void run() { VkDesignerUtil.centerDialog(dialog); nameTextArea.setFocus(true); } }; t.schedule(100); HorizontalPanel jsHp = new HorizontalPanel(); jsHp.setWidth("100%"); dialog.add(jsHp); jsHp.setHorizontalAlignment(HorizontalPanel.ALIGN_RIGHT); jsHp.add(new Label("Command Js:")); jsHp.setHorizontalAlignment(HorizontalPanel.ALIGN_LEFT); jsHp.setCellWidth(jsHp.getWidget(0), "35%"); final VkEventTextArea jsTextArea = new VkEventTextArea(); jsTextArea.setSize("300px", "100px"); jsHp.add(jsTextArea); HorizontalPanel buttonsPanel = new HorizontalPanel(); dialog.add(buttonsPanel); Button saveButton = new Button("Save"); buttonsPanel.add(saveButton); saveButton.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { menuBar.getCommandJs().put(menuBar.getItemCount(), jsTextArea.getText()); addMenuItem(menuBar, nameTextArea.getText(), jsTextArea.getText()); origDialog.hide(); } }); Button cancelButton = new Button("Cancel"); buttonsPanel.add(cancelButton); cancelButton.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { origDialog.hide(); } }); origDialog.center(); origDialog.setPopupPosition(origDialog.getPopupLeft() + 1, origDialog.getPopupTop()); }
@SuppressWarnings("unchecked") public void populateFilesList( SolutionBrowserPerspective perspective, SolutionTree solutionTree, TreeItem item) { filesList.clear(); ArrayList<Element> files = (ArrayList<Element>) item.getUserObject(); // let's sort this list based on localized name Collections.sort( files, new Comparator<Element>() { public int compare(Element o1, Element o2) { String name1 = o1.getAttribute("localized-name"); // $NON-NLS-1$ String name2 = o2.getAttribute("localized-name"); // $NON-NLS-1$ return name1.compareTo(name2); } }); if (files != null) { int rowCounter = 0; for (int i = 0; i < files.size(); i++) { Element fileElement = files.get(i); if ("false".equals(fileElement.getAttribute("isDirectory"))) { // $NON-NLS-1$ //$NON-NLS-2$ String name = fileElement.getAttribute("name"); // $NON-NLS-1$ String solution = solutionTree.getSolution(); String path = solutionTree.getPath(); String lastModifiedDateStr = fileElement.getAttribute("lastModifiedDate"); // $NON-NLS-1$ String url = fileElement.getAttribute("url"); // $NON-NLS-1$ ContentTypePlugin plugin = PluginOptionsHelper.getContentTypePlugin(name); String icon = null; if (plugin != null) { icon = plugin.getFileIcon(); } String localizedName = fileElement.getAttribute("localized-name"); String description = fileElement.getAttribute("description"); String tooltip = localizedName; if (solutionTree.isUseDescriptionsForTooltip() && !StringUtils.isEmpty(description)) { tooltip = description; } final FileItem fileLabel = new FileItem( name, localizedName, tooltip, solution, path, //$NON-NLS-1$ lastModifiedDateStr, url, this, PluginOptionsHelper.getEnabledOptions(name), toolbar.getSupportsACLs(), icon); // BISERVER-2317: Request for more IDs for Mantle UI elements // set element id as the filename fileLabel.getElement().setId("file-" + name); // $NON-NLS-1$ fileLabel.addFileSelectionChangedListener(toolbar); fileLabel.setWidth("100%"); // $NON-NLS-1$ try { perspective.getDragController().makeDraggable(fileLabel); } catch (Exception e) { Throwable throwable = e; String text = "Uncaught exception: "; while (throwable != null) { StackTraceElement[] stackTraceElements = throwable.getStackTrace(); text += throwable.toString() + "\n"; for (int ii = 0; ii < stackTraceElements.length; ii++) { text += " at " + stackTraceElements[ii] + "\n"; } throwable = throwable.getCause(); if (throwable != null) { text += "Caused by: "; } } DialogBox dialogBox = new DialogBox(true); DOM.setStyleAttribute(dialogBox.getElement(), "backgroundColor", "#ABCDEF"); System.err.print(text); text = text.replaceAll(" ", " "); dialogBox.setHTML("<pre>" + text + "</pre>"); dialogBox.center(); } filesList.setWidget(rowCounter++, 0, fileLabel); if (selectedFileItem != null && selectedFileItem.getFullPath().equals(fileLabel.getFullPath())) { fileLabel.setStyleName("fileLabelSelected"); // $NON-NLS-1$ selectedFileItem = fileLabel; } else { fileLabel.setStyleName("fileLabel"); // $NON-NLS-1$ } } } } }