List of usage examples for com.google.gwt.user.client.ui HorizontalPanel setCellHorizontalAlignment
public void setCellHorizontalAlignment(IsWidget w, HorizontalAlignmentConstant align)
From source file:org.gss_project.gss.web.client.ConfirmationDialog.java
License:Open Source License
/** * The widget's constructor.// w w w. jav a 2 s . c o m * * @param message the message to display * @param buttonLabel the label of the confirmation button */ public ConfirmationDialog(String message, String buttonLabel) { // Set the dialog's caption. setText("Confirmation"); setAnimationEnabled(true); // Create a VerticalPanel to contain the label and the buttons. VerticalPanel outer = new VerticalPanel(); HorizontalPanel buttons = new HorizontalPanel(); HTML text = new HTML( "<table><tr><td rowspan='2'> " + AbstractImagePrototype.create(MessagePanel.images.warn()).getHTML() + "</td><td>" + message + "</td></tr></table>"); text.setStyleName("gss-warnMessage"); outer.add(text); // Create the 'Update' button, along with a listener that hides the // dialog when the button is clicked and renames the file. Button ok = new Button(buttonLabel, new ClickHandler() { @Override public void onClick(ClickEvent event) { confirm(); hide(); } }); ok.getElement().setId("confirmation.ok"); buttons.add(ok); buttons.setCellHorizontalAlignment(ok, HasHorizontalAlignment.ALIGN_CENTER); // Create the 'Cancel' button, along with a listener that hides the // dialog when the button is clicked. Button cancel = new Button("Cancel", new ClickHandler() { @Override public void onClick(ClickEvent event) { hide(); cancel(); } }); cancel.getElement().setId("confirmation.cancel"); buttons.add(cancel); buttons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER); buttons.setSpacing(8); buttons.setStyleName("gss-warnMessage"); outer.setStyleName("gss-warnMessage"); outer.add(buttons); outer.setCellHorizontalAlignment(text, HasHorizontalAlignment.ALIGN_CENTER); outer.setCellHorizontalAlignment(buttons, HasHorizontalAlignment.ALIGN_CENTER); setWidget(outer); }
From source file:org.gss_project.gss.web.client.DeleteFileDialog.java
License:Open Source License
/** * The widget's constructor./*from www. ja v a 2s . com*/ * * @param images the supplied images */ public DeleteFileDialog(Images images) { // Set the dialog's caption. setText("Confirmation"); setAnimationEnabled(true); Object selection = GSS.get().getCurrentSelection(); // Create a VerticalPanel to contain the label and the buttons. VerticalPanel outer = new VerticalPanel(); HorizontalPanel buttons = new HorizontalPanel(); HTML text; if (selection instanceof FileResource) text = new HTML("<table><tr><td>" + AbstractImagePrototype.create(images.warn()).getHTML() + "</td><td>" + "Are you sure you want to <b>permanently</b> delete file '" + ((FileResource) selection).getName() + "'?</td></tr></table>"); else text = new HTML("<table><tr><td>" + AbstractImagePrototype.create(images.warn()).getHTML() + "</td><td>" + "Are you sure you want to <b>permanently</b> delete the selected files?</td></tr></table>"); text.setStyleName("gss-warnMessage"); outer.add(text); // Create the 'Delete' button, along with a listener that hides the dialog // when the button is clicked and deletes the file. Button ok = new Button("Delete", new ClickHandler() { @Override public void onClick(ClickEvent event) { deleteFile(); hide(); } }); ok.getElement().setId("confirmation.ok"); buttons.add(ok); buttons.setCellHorizontalAlignment(ok, HasHorizontalAlignment.ALIGN_CENTER); // Create the 'Cancel' button, along with a listener that hides the // dialog when the button is clicked. Button cancel = new Button("Cancel", new ClickHandler() { @Override public void onClick(ClickEvent event) { hide(); } }); cancel.getElement().setId("confirmation.cancel"); buttons.add(cancel); buttons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER); buttons.setSpacing(8); buttons.setStyleName("gss-warnMessage"); outer.setStyleName("gss-warnMessage"); outer.add(buttons); outer.setCellHorizontalAlignment(text, HasHorizontalAlignment.ALIGN_CENTER); outer.setCellHorizontalAlignment(buttons, HasHorizontalAlignment.ALIGN_CENTER); setWidget(outer); }
From source file:org.gss_project.gss.web.client.DeleteFolderDialog.java
License:Open Source License
/** * The widget's constructor./*www . jav a 2 s . c o m*/ * @param images the supplied images */ public DeleteFolderDialog(Images images) { // Set the dialog's caption. setText("Confirmation"); setAnimationEnabled(true); FolderResource folder = ((RestResourceWrapper) GSS.get().getTreeView().getSelection()).getResource(); // Create a VerticalPanel to contain the HTML label and the buttons. VerticalPanel outer = new VerticalPanel(); HorizontalPanel buttons = new HorizontalPanel(); HTML text = new HTML("<table><tr><td rowspan='2'>" + AbstractImagePrototype.create(images.warn()).getHTML() + "</td><td>" + "Are you sure you want to <b>permanently</b> delete folder '" + folder.getName() + "'?</td></tr></table>"); text.setStyleName("gss-warnMessage"); outer.add(text); // Create the 'Delete' button, along with a listener that hides the dialog // when the button is clicked and deletes the folder. Button ok = new Button("Delete", new ClickHandler() { @Override public void onClick(ClickEvent event) { deleteFolder(); hide(); } }); ok.getElement().setId("confirmation.ok"); buttons.add(ok); buttons.setCellHorizontalAlignment(ok, HasHorizontalAlignment.ALIGN_CENTER); // Create the 'Cancel' button, along with a listener that hides the // dialog when the button is clicked. Button cancel = new Button("Cancel", new ClickHandler() { @Override public void onClick(ClickEvent event) { hide(); } }); cancel.getElement().setId("confirmation.cancel"); buttons.add(cancel); buttons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER); buttons.setSpacing(8); buttons.setStyleName("gss-warnMessage"); outer.setStyleName("gss-warnMessage"); outer.add(buttons); outer.setCellHorizontalAlignment(text, HasHorizontalAlignment.ALIGN_CENTER); outer.setCellHorizontalAlignment(buttons, HasHorizontalAlignment.ALIGN_CENTER); setWidget(outer); }
From source file:org.gss_project.gss.web.client.DeleteGroupDialog.java
License:Open Source License
/** * The widget's constructor./*w w w. j a v a 2s . c om*/ * @param images the supplied images */ public DeleteGroupDialog(final Images images) { // Use this opportunity to set the dialog's caption. setText("Delete group"); setAnimationEnabled(true); final GroupResource group = (GroupResource) GSS.get().getCurrentSelection(); // Create a VerticalPanel to contain the 'about' label and the 'OK' // button. final VerticalPanel outer = new VerticalPanel(); final HorizontalPanel buttons = new HorizontalPanel(); // Create the 'about' text and set a style name so we can style it with // CSS. final HTML text = new HTML( "<table><tr><td>" + AbstractImagePrototype.create(images.warn()).getHTML() + "</td><td>" + "Are you sure you want to delete group '" + group.getName() + "'?</td></tr></table>"); text.setStyleName("gss-warnMessage"); outer.add(text); // Create the 'Quit' button, along with a listener that hides the dialog // when the button is clicked and quits the application. final Button ok = new Button("OK", new ClickHandler() { @Override public void onClick(ClickEvent event) { deleteGroup(); hide(); } }); ok.getElement().setId("deleteGroup.button.ok"); buttons.add(ok); buttons.setCellHorizontalAlignment(ok, HasHorizontalAlignment.ALIGN_CENTER); // Create the 'Cancel' button, along with a listener that hides the // dialog // when the button is clicked. final Button cancel = new Button("Cancel", new ClickHandler() { @Override public void onClick(ClickEvent event) { hide(); } }); cancel.getElement().setId("deleteGroup.button.cancel"); buttons.add(cancel); buttons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER); buttons.setSpacing(8); buttons.setStyleName("gss-warnMessage"); outer.setStyleName("gss-warnMessage"); outer.add(buttons); outer.setCellHorizontalAlignment(text, HasHorizontalAlignment.ALIGN_CENTER); outer.setCellHorizontalAlignment(buttons, HasHorizontalAlignment.ALIGN_CENTER); setWidget(outer); }
From source file:org.gss_project.gss.web.client.DeleteUserDialog.java
License:Open Source License
/** * The widget's constructor./* w w w .j a v a 2 s. co m*/ * @param images the supplied images */ public DeleteUserDialog(final Images images) { // Use this opportunity to set the dialog's caption. setText("Delete user"); setAnimationEnabled(true); final GroupUserResource group = (GroupUserResource) GSS.get().getCurrentSelection(); // Create a VerticalPanel to contain the 'about' label and the 'OK' // button. final VerticalPanel outer = new VerticalPanel(); final HorizontalPanel buttons = new HorizontalPanel(); // Create the 'about' text and set a style name so we can style it with // CSS. final HTML text = new HTML( "<table><tr><td>" + AbstractImagePrototype.create(images.warn()).getHTML() + "</td><td>" + "Are you sure you want to remove user '" + group.getName() + "'?</td></tr></table>"); text.setStyleName("gss-warnMessage"); outer.add(text); // Create the 'Quit' button, along with a listener that hides the dialog // when the button is clicked and quits the application. final Button ok = new Button("OK", new ClickHandler() { @Override public void onClick(ClickEvent event) { deleteUser(); hide(); } }); ok.getElement().setId("deleteUser.button.ok"); buttons.add(ok); buttons.setCellHorizontalAlignment(ok, HasHorizontalAlignment.ALIGN_CENTER); // Create the 'Cancel' button, along with a listener that hides the // dialog // when the button is clicked. final Button cancel = new Button("Cancel", new ClickHandler() { @Override public void onClick(ClickEvent event) { hide(); } }); cancel.getElement().setId("confirmation.button.cancel"); buttons.add(cancel); buttons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER); buttons.setSpacing(8); buttons.setStyleName("gss-warnMessage"); outer.setStyleName("gss-warnMessage"); outer.add(buttons); outer.setCellHorizontalAlignment(text, HasHorizontalAlignment.ALIGN_CENTER); outer.setCellHorizontalAlignment(buttons, HasHorizontalAlignment.ALIGN_CENTER); setWidget(outer); }
From source file:org.gss_project.gss.web.client.FilePropertiesDialog.java
License:Open Source License
/** * The widget's constructor.// ww w. j av a2s. co m * * @param images the dialog's ImageBundle * @param groups * @param bodies */ public FilePropertiesDialog(final Images images, final List<GroupResource> groups, List<FileResource> bodies, String _userFullName) { // Set the dialog's caption. setText("File properties"); file = (FileResource) GSS.get().getCurrentSelection(); userFullName = _userFullName; permList = new PermissionsList(images, file.getPermissions(), file.getOwner()); GWT.log("FILE PERMISSIONS:" + file.getPermissions()); // Outer contains inner and buttons. final VerticalPanel outer = new VerticalPanel(); final FocusPanel focusPanel = new FocusPanel(outer); // Inner contains generalPanel and permPanel. inner = new DecoratedTabPanel(); inner.setAnimationEnabled(true); final VerticalPanel generalPanel = new VerticalPanel(); final VerticalPanel permPanel = new VerticalPanel(); final HorizontalPanel buttons = new HorizontalPanel(); final HorizontalPanel permButtons = new HorizontalPanel(); final HorizontalPanel permForAll = new HorizontalPanel(); final HorizontalPanel pathPanel = new HorizontalPanel(); final VerticalPanel verPanel = new VerticalPanel(); final HorizontalPanel vPanel = new HorizontalPanel(); final HorizontalPanel vPanel2 = new HorizontalPanel(); versioned.setValue(file.isVersioned()); versioned.getElement().setId("filePropertiesDialog.chechBox.versioned"); inner.add(generalPanel, "General"); inner.add(permPanel, "Sharing"); inner.add(verPanel, "Versions"); inner.selectTab(0); final Label fileNameNote = new Label("Please note that slashes ('/') are not allowed in file names.", true); fileNameNote.setVisible(false); fileNameNote.setStylePrimaryName("gss-readForAllNote"); final FlexTable generalTable = new FlexTable(); generalTable.setText(0, 0, "Name"); generalTable.setText(1, 0, "Folder"); generalTable.setText(2, 0, "Owner"); generalTable.setText(3, 0, "Last modified"); generalTable.setText(4, 0, "Tags"); name.setWidth("100%"); name.setText(file.getName()); name.getElement().setId("filePropertiesDialog.textBox.name"); generalTable.setWidget(0, 1, name); name.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { if (name.getText().contains("/")) fileNameNote.setVisible(true); else fileNameNote.setVisible(false); } }); if (file.getFolderName() != null) generalTable.setText(1, 1, file.getFolderName()); else generalTable.setText(1, 1, "-"); generalTable.setWidget(0, 2, fileNameNote); generalTable.setText(2, 1, userFullName); final DateTimeFormat formatter = DateTimeFormat.getFormat("d/M/yyyy h:mm a"); generalTable.setText(3, 1, formatter.format(file.getModificationDate())); // Get the tags. StringBuffer tagsBuffer = new StringBuffer(); Iterator i = file.getTags().iterator(); while (i.hasNext()) { String tag = (String) i.next(); tagsBuffer.append(tag).append(", "); } if (tagsBuffer.length() > 1) tagsBuffer.delete(tagsBuffer.length() - 2, tagsBuffer.length() - 1); initialTagText = tagsBuffer.toString(); tags.setWidth("100%"); tags.getElement().setId("filePropertiesDialog.textBox.tags"); tags.setText(initialTagText); generalTable.setWidget(4, 1, tags); generalTable.getFlexCellFormatter().setStyleName(0, 0, "props-labels"); generalTable.getFlexCellFormatter().setStyleName(1, 0, "props-labels"); generalTable.getFlexCellFormatter().setStyleName(2, 0, "props-labels"); generalTable.getFlexCellFormatter().setStyleName(3, 0, "props-labels"); generalTable.getFlexCellFormatter().setStyleName(4, 0, "props-labels"); generalTable.getFlexCellFormatter().setStyleName(0, 1, "props-values"); generalTable.getFlexCellFormatter().setStyleName(1, 1, "props-values"); generalTable.getFlexCellFormatter().setStyleName(2, 1, "props-values"); generalTable.getFlexCellFormatter().setStyleName(3, 1, "props-values"); generalTable.getFlexCellFormatter().setStyleName(4, 1, "props-values"); generalTable.setCellSpacing(4); // Create the 'OK' button, along with a listener that hides the dialog // when the button is clicked. final Button ok = new Button("OK", new ClickHandler() { @Override public void onClick(ClickEvent event) { if (name.getText().contains("/")) fileNameNote.setVisible(true); else { fileNameNote.setVisible(false); accept(); closeDialog(); } } }); ok.getElement().setId("filePropertiesDialog.button.ok"); buttons.add(ok); buttons.setCellHorizontalAlignment(ok, HasHorizontalAlignment.ALIGN_CENTER); // Create the 'Cancel' button, along with a listener that hides the // dialog when the button is clicked. final Button cancel = new Button("Cancel", new ClickHandler() { @Override public void onClick(ClickEvent event) { closeDialog(); } }); cancel.getElement().setId("filePropertiesDialog.button.cancel"); buttons.add(cancel); buttons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER); buttons.setSpacing(8); buttons.addStyleName("gss-TabPanelBottom"); generalPanel.add(generalTable); // Asynchronously retrieve the tags defined by this user. DeferredCommand.addCommand(new Command() { @Override public void execute() { updateTags(); } }); DisclosurePanel allTags = new DisclosurePanel("All tags"); allTagsContent = new FlowPanel(); allTagsContent.setWidth("100%"); allTags.setContent(allTagsContent); generalPanel.add(allTags); generalPanel.setSpacing(4); final Button add = new Button("Add Group", new ClickHandler() { @Override public void onClick(ClickEvent event) { PermissionsAddDialog dlg = new PermissionsAddDialog(groups, permList, false); dlg.center(); } }); add.getElement().setId("filePropertiesDialog.button.addGroup"); permButtons.add(add); permButtons.setCellHorizontalAlignment(add, HasHorizontalAlignment.ALIGN_CENTER); final Button addUser = new Button("Add User", new ClickHandler() { @Override public void onClick(ClickEvent event) { PermissionsAddDialog dlg = new PermissionsAddDialog(groups, permList, true); dlg.center(); } }); add.getElement().setId("filePropertiesDialog.button.addUser"); permButtons.add(addUser); permButtons.setCellHorizontalAlignment(addUser, HasHorizontalAlignment.ALIGN_CENTER); permButtons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER); permButtons.setSpacing(8); permButtons.addStyleName("gss-TabPanelBottom"); final Label readForAllNote = new Label("When this option is enabled, the file will be readable" + " by everyone. By checking this option, you are certifying that you have the right to " + "distribute this file and that it does not violate the Terms of Use.", true); readForAllNote.setVisible(false); readForAllNote.setStylePrimaryName("gss-readForAllNote"); readForAll = new CheckBox(); readForAll.getElement().setId("filePropertiesDialog.checkBox.public"); readForAll.setValue(file.isReadForAll()); readForAll.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { readForAllNote.setVisible(readForAll.getValue()); } }); permPanel.add(permList); permPanel.add(permButtons); // Only show the read for all permission if the user is the owner. if (file.getOwner().equals(GSS.get().getCurrentUserResource().getUsername())) { permForAll.add(new Label("Public")); permForAll.add(readForAll); permForAll.setSpacing(8); permForAll.addStyleName("gss-TabPanelBottom"); permForAll.add(readForAllNote); permPanel.add(permForAll); } TextBox path = new TextBox(); path.setWidth("100%"); path.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { GSS.enableIESelection(); ((TextBox) event.getSource()).selectAll(); GSS.preventIESelection(); } }); path.setText(file.getUri()); path.getElement().setId("filePropertiesDialog.textBox.link"); path.setTitle( "Use this link for sharing the file via e-mail, IM, etc. (crtl-C/cmd-C to copy to system clipboard)"); path.setWidth("100%"); path.setReadOnly(true); pathPanel.setWidth("100%"); pathPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); pathPanel.add(new Label("Link")); pathPanel.setSpacing(8); pathPanel.addStyleName("gss-TabPanelBottom"); pathPanel.add(path); permPanel.add(pathPanel); VersionsList verList = new VersionsList(this, images, bodies); verPanel.add(verList); vPanel.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER); vPanel.setSpacing(8); vPanel.addStyleName("gss-TabPanelBottom"); vPanel.add(new Label("Versioned")); vPanel.add(versioned); verPanel.add(vPanel); vPanel2.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER); vPanel2.setSpacing(8); vPanel2.addStyleName("gss-TabPanelBottom"); Button removeVersionsButton = new Button(AbstractImagePrototype.create(images.delete()).getHTML(), new ClickHandler() { @Override public void onClick(ClickEvent event) { ConfirmationDialog confirm = new ConfirmationDialog( "Really " + "remove all previous versions?", "Remove") { @Override public void cancel() { } @Override public void confirm() { FilePropertiesDialog.this.closeDialog(); removeAllOldVersions(); } }; confirm.center(); } }); HTML removeAllVersion = new HTML("<span>Remove all previous versions?</span>"); vPanel2.add(removeAllVersion); vPanel2.add(removeVersionsButton); verPanel.add(vPanel2); if (!file.isVersioned()) vPanel2.setVisible(false); outer.add(inner); outer.add(buttons); outer.setCellHorizontalAlignment(buttons, HasHorizontalAlignment.ALIGN_CENTER); outer.addStyleName("gss-TabPanelBottom"); focusPanel.setFocus(true); setWidget(outer); }
From source file:org.gss_project.gss.web.client.FilesPropertiesDialog.java
License:Open Source License
/** * The widget's constructor./*from ww w . j av a 2 s . com*/ * * @param _files */ public FilesPropertiesDialog(final List<FileResource> _files) { super(); files = _files; int versionedNum = 0; for (FileResource fr : files) if (fr.isVersioned()) versionedNum++; Boolean versioned = null; if (versionedNum == 0) versioned = false; if (versionedNum == files.size()) versioned = true; initialVersioned = versioned; versionedCheck = new TristateCheckBox(versioned); // Set the dialog's caption. setText("Files properties"); // Outer contains inner and buttons. final VerticalPanel outer = new VerticalPanel(); final FocusPanel focusPanel = new FocusPanel(outer); // Inner contains generalPanel and permPanel. inner = new DecoratedTabPanel(); inner.setAnimationEnabled(true); final VerticalPanel generalPanel = new VerticalPanel(); final HorizontalPanel buttons = new HorizontalPanel(); final VerticalPanel verPanel = new VerticalPanel(); final HorizontalPanel vPanel = new HorizontalPanel(); inner.add(generalPanel, "General"); inner.add(verPanel, "Versions"); inner.selectTab(0); final FlexTable generalTable = new FlexTable(); generalTable.setText(0, 0, String.valueOf(files.size()) + " files selected"); generalTable.setText(1, 0, "Folder"); generalTable.setText(2, 0, "Tags"); FileResource firstFile = files.get(0); if (firstFile.getFolderName() != null) generalTable.setText(1, 1, firstFile.getFolderName()); else generalTable.setText(1, 1, "-"); // Find if tags are identical List<String> tagsList = files.get(0).getTags(); List<String> tagss; for (int i = 1; i < files.size(); i++) { tagss = files.get(i).getTags(); if (tagsList.size() != tagss.size() || !tagsList.containsAll(tagss)) { tagsList = null; break; } } // Get the tags. StringBuffer tagsBuffer = new StringBuffer(); if (tagsList == null) tagsBuffer.append(MULTIPLE_VALUES_TEXT); else { Iterator i = tagsList.iterator(); while (i.hasNext()) { String tag = (String) i.next(); tagsBuffer.append(tag).append(", "); } if (tagsBuffer.length() > 1) tagsBuffer.delete(tagsBuffer.length() - 2, tagsBuffer.length() - 1); } initialTagText = tagsBuffer.toString(); tags.setText(initialTagText); tags.addFocusHandler(new FocusHandler() { @Override public void onFocus(FocusEvent event) { if (MULTIPLE_VALUES_TEXT.equals(tags.getText())) tags.setText(""); } }); generalTable.setWidget(2, 1, tags); generalTable.getFlexCellFormatter().setStyleName(0, 0, "props-labels"); generalTable.getFlexCellFormatter().setColSpan(0, 0, 2); generalTable.getFlexCellFormatter().setStyleName(1, 0, "props-labels"); generalTable.getFlexCellFormatter().setStyleName(2, 0, "props-labels"); generalTable.getFlexCellFormatter().setStyleName(0, 1, "props-values"); generalTable.getFlexCellFormatter().setStyleName(1, 1, "props-values"); generalTable.getFlexCellFormatter().setStyleName(2, 1, "props-values"); generalTable.setCellSpacing(4); // Create the 'OK' button, along with a listener that hides the dialog // when the button is clicked. final Button ok = new Button("OK", new ClickHandler() { @Override public void onClick(ClickEvent event) { accept(); closeDialog(); } }); buttons.add(ok); buttons.setCellHorizontalAlignment(ok, HasHorizontalAlignment.ALIGN_CENTER); // Create the 'Cancel' button, along with a listener that hides the // dialog when the button is clicked. final Button cancel = new Button("Cancel", new ClickHandler() { @Override public void onClick(ClickEvent event) { closeDialog(); } }); buttons.add(cancel); buttons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER); buttons.setSpacing(8); buttons.addStyleName("gss-TabPanelBottom"); generalPanel.add(generalTable); // Asynchronously retrieve the tags defined by this user. DeferredCommand.addCommand(new Command() { @Override public void execute() { updateTags(); } }); DisclosurePanel allTags = new DisclosurePanel("All tags"); allTagsContent = new FlowPanel(); allTags.setContent(allTagsContent); generalPanel.add(allTags); generalPanel.setSpacing(4); vPanel.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER); vPanel.setSpacing(8); vPanel.addStyleName("gss-TabPanelBottom"); vPanel.add(new Label("Versioned")); vPanel.add(versionedCheck); verPanel.add(vPanel); outer.add(inner); outer.add(buttons); outer.setCellHorizontalAlignment(buttons, HasHorizontalAlignment.ALIGN_CENTER); outer.addStyleName("gss-TabPanelBottom"); focusPanel.setFocus(true); setWidget(outer); }
From source file:org.gss_project.gss.web.client.FileUploadDialog.java
License:Open Source License
/** * The widget's constructor./*from w ww .j a v a 2 s.com*/ */ public FileUploadDialog() { // Set the dialog's caption. setText("File upload"); setAnimationEnabled(true); // Since we're going to add a FileUpload widget, we'll need to set the // form to use the POST method, and multipart MIME encoding. form.setEncoding(FormPanel.ENCODING_MULTIPART); form.setMethod(FormPanel.METHOD_POST); // Create a panel to hold all of the form widgets. VerticalPanel panel = new VerticalPanel(); form.setWidget(panel); final HTML info = new HTML("You may select a file to upload. Install" + " <a href='http://gears.google.com/' target='_blank'>Google " + "Gears</a><br> for uploading multiple files simultaneously."); info.addStyleName("gss-uploadNote"); panel.add(info); final Hidden date = new Hidden("Date", ""); panel.add(date); final Hidden auth = new Hidden("Authorization", ""); panel.add(auth); // Add an informative label with the folder name. Object selection = GSS.get().getTreeView().getSelection(); folder = ((RestResourceWrapper) selection).getResource(); upload.setName("file"); filenameLabel.setText(""); filenameLabel.setVisible(false); filenameLabel.setStyleName("props-labels"); HorizontalPanel fileUloadPanel = new HorizontalPanel(); fileUloadPanel.add(filenameLabel); fileUloadPanel.add(upload); upload.getElement().setId("fileUploadDiallog.uploadPanel"); Grid generalTable = new Grid(2, 2); generalTable.setText(0, 0, "Folder"); generalTable.setText(1, 0, "File"); generalTable.setText(0, 1, folder.getName()); generalTable.setWidget(1, 1, fileUloadPanel); generalTable.getCellFormatter().setStyleName(0, 0, "props-labels"); generalTable.getCellFormatter().setStyleName(1, 0, "props-labels"); generalTable.getCellFormatter().setStyleName(0, 1, "props-values"); generalTable.getCellFormatter().setStyleName(1, 1, "props-values"); generalTable.setCellSpacing(4); panel.add(generalTable); // Create a panel to hold the buttons. HorizontalPanel buttons = new HorizontalPanel(); // Create the 'upload' button, along with a listener that submits the // form. final Button submit = new Button("Upload", new ClickHandler() { @Override public void onClick(ClickEvent event) { prepareAndSubmit(); } }); submit.getElement().setId("fileUploadDialog.button.upload"); buttons.add(submit); buttons.setCellHorizontalAlignment(submit, HasHorizontalAlignment.ALIGN_CENTER); // Create the 'Cancel' button, along with a listener that hides the // dialog when the button is clicked. final Button cancel = new Button("Cancel", new ClickHandler() { @Override public void onClick(ClickEvent event) { repeater.finish(); hide(); } }); cancel.getElement().setId("fileUploadDialog.button.cancel"); buttons.add(cancel); buttons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER); buttons.setSpacing(8); buttons.addStyleName("gss-DialogBox"); // Add an event handler to the form. form.addSubmitHandler(new SubmitHandler() { @Override public void onSubmit(SubmitEvent event) { GSS app = GSS.get(); // This event is fired just before the form is submitted. We can // take this opportunity to perform validation. if (upload.getFilename().length() == 0) { app.displayError("You must select a file!"); event.cancel(); hide(); } else { canContinue(); GWT.log("Cancel:" + cancelEvent, null); if (cancelEvent) { cancelEvent = false; app.displayError("The specified file name already exists in this folder"); event.cancel(); hide(); } else { fileNameToUse = getFilename(upload.getFilename()); String apath; FileResource selectedFile = getFileForName(fileNameToUse); if (selectedFile == null) { //we are going to create a file apath = folder.getUri(); if (!apath.endsWith("/")) apath = apath + "/"; apath = apath + encodeComponent(fileNameToUse); } else apath = selectedFile.getUri(); form.setAction(apath); String dateString = RestCommand.getDate(); String resource = apath.substring(app.getApiPath().length() - 1, apath.length()); String sig = RestCommand.calculateSig("POST", dateString, resource, RestCommand.base64decode(app.getToken())); date.setValue(dateString); auth.setValue(app.getCurrentUserResource().getUsername() + " " + sig); GWT.log("FolderPATH:" + folder.getUri(), null); submit.setEnabled(false); upload.setVisible(false); filenameLabel.setText(fileNameToUse); filenameLabel.setVisible(true); repeater.start(); progressBar.setVisible(true); } } } }); form.addSubmitCompleteHandler(new SubmitCompleteHandler() { @Override public void onSubmitComplete(SubmitCompleteEvent event) { // When the form submission is successfully completed, this // event is fired. Assuming the service returned a response // of type text/html, we can get the result text here (see // the FormPanel documentation for further explanation). String results = event.getResults(); // Unfortunately the results are never empty, even in // the absense of errors, so we have to check for '<pre></pre>'. if (!results.equalsIgnoreCase("<pre></pre>")) { GWT.log(results, null); GSS.get().displayError(results); } progressBar.setProgress(100); cancelUpload(); GSS.get().getTreeView().updateNode(GSS.get().getTreeView().getSelection()); GSS.get().getStatusPanel().updateStats(); } }); panel.add(buttons); progressBar = new ProgressBar(50, ProgressBar.SHOW_TIME_REMAINING); panel.add(progressBar); progressBar.setVisible(false); panel.setCellHorizontalAlignment(buttons, HasHorizontalAlignment.ALIGN_CENTER); panel.setCellHorizontalAlignment(progressBar, HasHorizontalAlignment.ALIGN_CENTER); panel.addStyleName("gss-DialogBox"); addStyleName("gss-DialogBox"); setWidget(form); }
From source file:org.gss_project.gss.web.client.FileUploadGearsDialog.java
License:Open Source License
/** * The widget's constructor.//w w w. j a va2s. c o m */ public FileUploadGearsDialog() { // Set the dialog's caption. setText("File upload"); setAnimationEnabled(true); // Create a panel to hold all of the dialog widgets. VerticalPanel panel = new VerticalPanel(); final HTML info = new HTML("You may select one or more files to upload."); info.addStyleName("gss-uploadNote"); panel.add(info); // Add an informative label with the folder name. Object selection = GSS.get().getTreeView().getSelection(); folder = ((RestResourceWrapper) selection).getResource(); browse = new Button("Browse..."); HorizontalPanel fileUploadPanel = new HorizontalPanel(); fileUploadPanel.add(browse); generalTable = new FlexTable(); generalTable.setText(0, 0, "Folder"); generalTable.setText(1, 0, "File"); generalTable.setText(0, 1, folder.getName()); generalTable.setWidget(1, 1, fileUploadPanel); generalTable.getCellFormatter().setStyleName(0, 0, "props-labels"); generalTable.getCellFormatter().setStyleName(1, 0, "props-labels"); generalTable.getCellFormatter().setStyleName(0, 1, "props-values"); generalTable.getCellFormatter().setStyleName(1, 1, "props-values"); generalTable.setCellSpacing(4); panel.add(generalTable); // Create a panel to hold the buttons. HorizontalPanel buttons = new HorizontalPanel(); submit = new Button("Upload"); submit.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { prepareAndSubmit(); } }); submit.setEnabled(false); buttons.add(submit); buttons.setCellHorizontalAlignment(submit, HasHorizontalAlignment.ALIGN_CENTER); // Create the 'Cancel' button, along with a listener that hides the // dialog when the button is clicked. Button cancel = new Button("Cancel", new ClickHandler() { @Override public void onClick(ClickEvent event) { canContinue = false; cancelUpload(); GSS.get().showFileList(true); } }); buttons.add(cancel); buttons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER); buttons.setSpacing(8); buttons.addStyleName("gss-DialogBox"); browse.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { Desktop desktop = factory.createDesktop(); desktop.openFiles(new OpenFilesHandler() { @Override public void onOpenFiles(OpenFilesEvent ofevent) { fileObjects = ofevent.getFiles(); selectedFiles.addAll(Arrays.asList(fileObjects)); for (int i = 0; i < selectedFiles.size(); i++) { generalTable.setText(i + 1, 0, "File"); generalTable.setText(i + 1, 1, selectedFiles.get(i).getName()); ProgressBar progress = new ProgressBar(20, 0); generalTable.setWidget(i + 1, 2, progress); progressBars.add(progress); generalTable.getCellFormatter().setStyleName(i + 1, 0, "props-labels"); generalTable.getCellFormatter().setStyleName(i + 1, 1, "props-values"); } submit.setEnabled(true); } }); } }); panel.add(buttons); panel.setCellHorizontalAlignment(buttons, HasHorizontalAlignment.ALIGN_CENTER); panel.addStyleName("gss-DialogBox"); addStyleName("gss-DialogBox"); setWidget(panel); }
From source file:org.gss_project.gss.web.client.FolderPropertiesDialog.java
License:Open Source License
/** * The widget's constructor./*from ww w . j a v a 2 s . c o m*/ * * @param images the image icons from the file properties dialog * @param _create true if the dialog is displayed for creating a new * sub-folder of the selected folder, false if it is displayed * for modifying the selected folder */ public FolderPropertiesDialog(Images images, boolean _create, final List<GroupResource> _groups, String _userFullname) { setAnimationEnabled(true); // Enable IE selection for the dialog (must disable it upon closing it) GSS.enableIESelection(); create = _create; folder = ((RestResourceWrapper) GSS.get().getTreeView().getSelection()).getResource(); permList = new PermissionsList(images, folder.getPermissions(), folder.getOwner()); groups = _groups; // Use this opportunity to set the dialog's caption. if (create) setText("Create folder"); else setText("Folder properties"); // Outer contains inner and buttons VerticalPanel outer = new VerticalPanel(); // Inner contains generalPanel and permPanel inner = new DecoratedTabPanel(); inner.setAnimationEnabled(true); VerticalPanel generalPanel = new VerticalPanel(); VerticalPanel permPanel = new VerticalPanel(); final HorizontalPanel permForAll = new HorizontalPanel(); final HorizontalPanel pathPanel = new HorizontalPanel(); HorizontalPanel buttons = new HorizontalPanel(); HorizontalPanel permButtons = new HorizontalPanel(); inner.add(generalPanel, "General"); if (!create) inner.add(permPanel, "Sharing"); inner.selectTab(0); final Label folderNameNote = new Label("Please note that slashes ('/') are not allowed in folder names.", true); folderNameNote.setVisible(false); folderNameNote.setStylePrimaryName("gss-readForAllNote"); FlexTable generalTable = new FlexTable(); generalTable.setText(0, 0, "Name"); generalTable.setText(1, 0, "Parent"); generalTable.setText(2, 0, "Creator"); generalTable.setText(3, 0, "Last modified"); folderName.setText(create ? "" : folder.getName()); folderName.getElement().setId("folderPropertiesDialog.textBox.name"); generalTable.setWidget(0, 1, folderName); folderName.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { if (folderName.getText().contains("/")) folderNameNote.setVisible(true); else folderNameNote.setVisible(false); } }); if (create) generalTable.setText(1, 1, folder.getName()); else if (folder.getParentName() == null) generalTable.setText(1, 1, "-"); else generalTable.setText(1, 1, folder.getParentName()); generalTable.setWidget(0, 2, folderNameNote); generalTable.setText(2, 1, folder.getOwner()); DateTimeFormat formatter = DateTimeFormat.getFormat("d/M/yyyy h:mm a"); if (folder.getModificationDate() != null) generalTable.setText(3, 1, formatter.format(folder.getModificationDate())); generalTable.getFlexCellFormatter().setStyleName(0, 0, "props-labels"); generalTable.getFlexCellFormatter().setStyleName(1, 0, "props-labels"); generalTable.getFlexCellFormatter().setStyleName(2, 0, "props-labels"); generalTable.getFlexCellFormatter().setStyleName(3, 0, "props-labels"); generalTable.getFlexCellFormatter().setStyleName(0, 1, "props-values"); generalTable.getFlexCellFormatter().setStyleName(1, 1, "props-values"); generalTable.getFlexCellFormatter().setStyleName(2, 1, "props-values"); generalTable.getFlexCellFormatter().setStyleName(3, 1, "props-values"); generalTable.setCellSpacing(4); // Create the 'Create/Update' button, along with a listener that hides the dialog // when the button is clicked and quits the application. String okLabel; if (create) okLabel = "Create"; else okLabel = "Update"; Button ok = new Button(okLabel, new ClickHandler() { @Override public void onClick(ClickEvent event) { if (folderName.getText().contains("/")) folderNameNote.setVisible(true); else { folderNameNote.setVisible(false); createOrUpdateFolder(); closeDialog(); } } }); ok.getElement().setId("folderPropertiesDialog.button.ok"); buttons.add(ok); buttons.setCellHorizontalAlignment(ok, HasHorizontalAlignment.ALIGN_CENTER); // Create the 'Cancel' button, along with a listener that hides the // dialog // when the button is clicked. Button cancel = new Button("Cancel", new ClickHandler() { @Override public void onClick(ClickEvent event) { closeDialog(); } }); cancel.getElement().setId("folderPropertiesDialog.button.cancel"); buttons.add(cancel); buttons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER); buttons.setSpacing(8); buttons.addStyleName("gss-TabPanelBottom"); Button add = new Button("Add Group", new ClickHandler() { @Override public void onClick(ClickEvent event) { PermissionsAddDialog dlg = new PermissionsAddDialog(groups, permList, false); dlg.center(); } }); add.getElement().setId("folderPropertiesDialog.button.addGroup"); permButtons.add(add); permButtons.setCellHorizontalAlignment(add, HasHorizontalAlignment.ALIGN_CENTER); Button addUser = new Button("Add User", new ClickHandler() { @Override public void onClick(ClickEvent event) { PermissionsAddDialog dlg = new PermissionsAddDialog(groups, permList, true); dlg.center(); } }); addUser.getElement().setId("folderPropertiesDialog.button.addUser"); permButtons.add(addUser); permButtons.setCellHorizontalAlignment(addUser, HasHorizontalAlignment.ALIGN_CENTER); permButtons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER); permButtons.setSpacing(8); permButtons.addStyleName("gss-TabPanelBottom"); final Label readForAllNote = new Label("When this option is enabled, the folder will be readable" + " by everyone. By checking this option, you are certifying that you have the right to " + "distribute this folder's contents and that it does not violate the Terms of Use.", true); readForAllNote.setVisible(false); readForAllNote.setStylePrimaryName("gss-readForAllNote"); readForAll = new CheckBox(); readForAll.getElement().setId("folderPropertiesDialog.checkBox.public"); readForAll.setValue(folder.isReadForAll()); readForAll.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { readForAllNote.setVisible(readForAll.getValue()); } }); generalPanel.add(generalTable); permPanel.add(permList); permPanel.add(permButtons); // Only show the read for all permission if the user is the owner. if (folder.getOwner().equals(GSS.get().getCurrentUserResource().getUsername())) { permForAll.add(new Label("Public")); permForAll.add(readForAll); permForAll.setSpacing(8); permForAll.addStyleName("gss-TabPanelBottom"); permForAll.add(readForAllNote); permPanel.add(permForAll); } TextBox path = new TextBox(); path.getElement().setId("folderPropertiesDialog.textBox.link"); path.setWidth("100%"); path.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { GSS.enableIESelection(); ((TextBox) event.getSource()).selectAll(); GSS.preventIESelection(); } }); path.setText(folder.getUri()); path.setTitle( "Use this link for sharing the folder via e-mail, IM, etc. (crtl-C/cmd-C to copy to system clipboard)"); path.setWidth("100%"); path.setReadOnly(true); pathPanel.setWidth("100%"); pathPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); pathPanel.add(new Label("Link")); pathPanel.setSpacing(8); pathPanel.addStyleName("gss-TabPanelBottom"); pathPanel.add(path); permPanel.add(pathPanel); outer.add(inner); outer.add(buttons); outer.setCellHorizontalAlignment(buttons, HasHorizontalAlignment.ALIGN_CENTER); outer.addStyleName("gss-TabPanelBottom"); setWidget(outer); /*if (create) folderName.setFocus(true); else ok.setFocus(true);*/ }