List of usage examples for com.google.gwt.user.client.ui HorizontalPanel setSpacing
public void setSpacing(int spacing)
From source file:org.gss_project.gss.web.client.FilePropertiesDialog.java
License:Open Source License
/** * The widget's constructor.//from w ww .j av a 2 s . com * * @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 w w w .j a va 2s.c om*/ * * @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 w w.ja 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. jav a 2 s .co 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./* ww w . j a va 2 s .co 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);*/ }
From source file:org.gss_project.gss.web.client.GroupPropertiesDialog.java
License:Open Source License
/** * The widget's constructor./*from w w w . j a v a 2s. com*/ * * @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 GroupPropertiesDialog(final boolean _create) { setAnimationEnabled(true); create = _create; // Use this opportunity to set the dialog's caption. if (create) setText("Create Group"); else setText("Group properties"); final VerticalPanel panel = new VerticalPanel(); setWidget(panel); groupName.getElement().setId("groupDialog.textBox.name"); final Grid generalTable = new Grid(1, 2); generalTable.setText(0, 0, "Group Name"); generalTable.setWidget(0, 1, groupName); generalTable.getCellFormatter().setStyleName(0, 0, "props-labels"); generalTable.getCellFormatter().setStyleName(0, 1, "props-values"); generalTable.setCellSpacing(4); panel.add(generalTable); final HorizontalPanel buttons = new HorizontalPanel(); final Button ok = new Button("OK", new ClickHandler() { @Override public void onClick(ClickEvent event) { createGroup(groupName.getText()); hide(); } }); ok.getElement().setId("groupDialog.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("groupDialog.button.cancel"); buttons.add(cancel); buttons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER); buttons.setSpacing(8); buttons.addStyleName("gss-TabPanelBottom"); panel.add(buttons); panel.setCellHorizontalAlignment(buttons, HasHorizontalAlignment.ALIGN_CENTER); //panel.addStyleName("gss-DialogBox"); panel.addStyleName("gss-TabPanelBottom"); }
From source file:org.gss_project.gss.web.client.PermissionsAddDialog.java
License:Open Source License
public PermissionsAddDialog(List<GroupResource> _groups, PermissionsList _permList, boolean _userAdd) { groups = _groups;// w w w . j av a 2 s. com userAdd = _userAdd; permList = _permList; groupBox.getElement().setId("addPermission.dropDown"); suggestBox.getElement().setId("addPermission.textBox"); read.getElement().setId("addPermission.read"); write.getElement().setId("addPermission.write"); modifyACL.getElement().setId("addpermission.modify"); for (GroupResource group : _groups) groupBox.addItem(group.getName(), group.getName()); final VerticalPanel panel = new VerticalPanel(); final HorizontalPanel buttons = new HorizontalPanel(); setWidget(panel); final FlexTable permTable = new FlexTable(); permTable.setText(0, 0, "Users/Groups"); permTable.setText(0, 1, "Read"); permTable.setText(0, 2, "Write"); permTable.setText(0, 3, "Modify Access"); permTable.getFlexCellFormatter().setStyleName(0, 0, "props-toplabels"); permTable.getFlexCellFormatter().setStyleName(0, 1, "props-toplabels"); permTable.getFlexCellFormatter().setStyleName(0, 2, "props-toplabels"); permTable.getFlexCellFormatter().setStyleName(0, 3, "props-toplabels"); if (userAdd) { suggestBox.getTextBox().addFocusHandler(new FocusHandler() { @Override public void onFocus(FocusEvent event) { if (selectedUser != null && selectedUser.endsWith("@")) updateSuggestions(); } }); suggestBox.addKeyUpHandler(new KeyUpHandler() { @Override public void onKeyUp(KeyUpEvent event) { // Ignore the arrow keys. int keyCode = event.getNativeKeyCode(); if (keyCode == KeyCodes.KEY_UP || keyCode == KeyCodes.KEY_DOWN || keyCode == KeyCodes.KEY_LEFT || keyCode == KeyCodes.KEY_RIGHT) return; if (keyCode == KeyCodes.KEY_ESCAPE) { suggestBox.hideSuggestionList(); return; } String text = suggestBox.getText().trim(); // Avoid useless queries for keystrokes that do not modify // the text. if (text.equals(selectedUser)) return; selectedUser = text; // Go to the server only if the user typed the @ character. if (selectedUser.endsWith("@")) updateSuggestions(); } }); permTable.setWidget(1, 0, suggestBox); } else permTable.setWidget(1, 0, groupBox); permTable.setWidget(1, 1, read); permTable.setWidget(1, 2, write); permTable.setWidget(1, 3, modifyACL); permTable.getFlexCellFormatter().setStyleName(1, 0, "props-labels"); permTable.getFlexCellFormatter().setHorizontalAlignment(1, 1, HasHorizontalAlignment.ALIGN_CENTER); permTable.getFlexCellFormatter().setHorizontalAlignment(1, 2, HasHorizontalAlignment.ALIGN_CENTER); permTable.getFlexCellFormatter().setHorizontalAlignment(1, 3, HasHorizontalAlignment.ALIGN_CENTER); panel.add(permTable); final Button ok = new Button("OK", new ClickHandler() { @Override public void onClick(ClickEvent event) { addPermission(); hide(); } }); ok.getElement().setId("addPermission.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("addPermission.button.cancel"); buttons.add(cancel); buttons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER); buttons.setSpacing(8); buttons.addStyleName("gss-TabPanelBottom"); panel.add(buttons); panel.addStyleName("gss-TabPanelBottom"); }
From source file:org.gss_project.gss.web.client.QuitDialog.java
License:Open Source License
/** * The widget's constructor./*from w w w. ja v a 2 s. co m*/ */ public QuitDialog() { Configuration conf = (Configuration) GWT.create(Configuration.class); String service = conf.serviceName(); setText("Quit " + service); VerticalPanel outer = new VerticalPanel(); HorizontalPanel buttons = new HorizontalPanel(); HTML text = new HTML("Are you sure you want to quit " + service + "?"); text.setStyleName("gss-AboutText"); outer.add(text); // Create the 'Quit' button, along with a listener that hides the dialog // when the button is clicked and quits the application. Button quit = new Button("Quit", new ClickHandler() { @Override public void onClick(ClickEvent event) { hide(); GSS.get().logout(); } }); buttons.add(quit); buttons.setCellHorizontalAlignment(quit, 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(); } }); buttons.add(cancel); buttons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER); buttons.setSpacing(8); outer.add(buttons); outer.setCellHorizontalAlignment(buttons, HasHorizontalAlignment.ALIGN_CENTER); setWidget(outer); }
From source file:org.gss_project.gss.web.client.StatusPanel.java
License:Open Source License
/** * The constructor of the status panel.//from ww w.ja v a 2s. com * * @param theImages the supplied images */ public StatusPanel(Images theImages) { images = theImages; HorizontalPanel outer = new HorizontalPanel(); outer.setWidth("100%"); outer.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); HorizontalPanel left = new HorizontalPanel(); left.setSpacing(8); HorizontalPanel middle = new HorizontalPanel(); middle.setSpacing(8); HorizontalPanel right = new HorizontalPanel(); right.setSpacing(8); outer.add(left); outer.add(middle); outer.add(right); left.add(new HTML("<b>Totals:</b> ")); left.add(AbstractImagePrototype.create(images.totalFiles()).createImage()); left.add(fileCountLabel); left.add(AbstractImagePrototype.create(images.totalSize()).createImage()); left.add(fileSizeLabel); quotaIcon.setHTML(AbstractImagePrototype.create(images.greenSize()).getHTML()); left.add(quotaIcon); left.add(quotaLabel); middle.add(AbstractImagePrototype.create(images.lastLogin()).createImage()); middle.add(new HTML("<b>Last login:</b> ")); middle.add(lastLoginLabel); middle.add(new HTML("<b>\u0387 Current session login:</b> ")); middle.add(currentLoginLabel); right.add(currentlyShowingLabel); outer.setStyleName("statusbar-inner"); left.setStyleName("statusbar-inner"); middle.setStyleName("statusbar-inner"); right.setStyleName("statusbar-inner"); outer.setCellHorizontalAlignment(right, HasHorizontalAlignment.ALIGN_RIGHT); initWidget(outer); // Initialize and display the quota information. DeferredCommand.addCommand(new IncrementalCommand() { @Override public boolean execute() { GSS app = GSS.get(); UserResource user = app.getCurrentUserResource(); if (user == null || app.getTreeView().getMyFolders() == null) return !DONE; displayStats(user); return DONE; } }); }
From source file:org.gss_project.gss.web.client.TopPanel.java
License:Open Source License
/** * The constructor for the top panel./*from ww w . ja v a2 s . c o m*/ * * @param images the supplied images */ public TopPanel(Images images) { fileMenu = new FileMenu(images); editMenu = new EditMenu(images); groupMenu = new GroupMenu(images); settingsMenu = new SettingsMenu(images); helpMenu = new HelpMenu(images); loading = new LoadingIndicator(images); HorizontalPanel outer = new HorizontalPanel(); outer.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); menu = new MenuBar(); menu.setWidth("100%"); menu.setAutoOpen(false); menu.setAnimationEnabled(true); menu.setStyleName("toolbarmenu"); Command quitCommand = new Command() { @Override public void execute() { QuitDialog dlg = new QuitDialog(); dlg.center(); } }; MenuItem quitItem = new MenuItem("<table style='font-size: 100%'><tr><td>" + AbstractImagePrototype.create(images.exit()).getHTML() + "</td><td>Quit</td></tr></table>", true, quitCommand); quitItem.getElement().setId("topMenu.quit"); MenuItem fileItem = new MenuItem("<table style='font-size: 100%'><tr><td>" + AbstractImagePrototype.create(images.folder()).getHTML() + "</td><td>File</td></tr></table>", true, new MenuBar(true)) { @Override public MenuBar getSubMenu() { return fileMenu.createMenu(); } }; fileItem.getElement().setId("topMenu.file"); MenuItem editItem = new MenuItem("<table style='font-size: 100%'><tr><td>" + AbstractImagePrototype.create(images.edit()).getHTML() + "</td><td>Edit</td></tr></table>", true, new MenuBar(true)) { @Override public MenuBar getSubMenu() { return editMenu.createMenu(); } }; editItem.getElement().setId("topMenu.edit"); MenuItem groupItem = new MenuItem("<table style='font-size: 100%'><tr><td>" + AbstractImagePrototype.create(images.group()).getHTML() + "</td><td>Group</td></tr></table>", true, groupMenu.getContextMenu()); groupItem.getElement().setId("topMenu.group"); MenuItem configureItem = new MenuItem("<table style='font-size: 100%'><tr><td>" + AbstractImagePrototype.create(images.configure()).getHTML() + "</td><td>Settings</td></tr></table>", true, settingsMenu.getContextMenu()); configureItem.getElement().setId("topMenu.settings"); MenuItem helpItem = new MenuItem("<table style='font-size: 100%'><tr><td>" + AbstractImagePrototype.create(images.help()).getHTML() + "</td><td>Help</td></tr></table>", true, new MenuBar(true)) { @Override public MenuBar getSubMenu() { return helpMenu.createMenu(); } }; helpItem.getElement().setId("topMenu.help"); menu.addItem(quitItem); menu.addItem(fileItem); menu.addItem(editItem); menu.addItem(groupItem); menu.addItem(configureItem); menu.addItem(helpItem); outer.setSpacing(2); outer.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); outer.setCellVerticalAlignment(menu, HasVerticalAlignment.ALIGN_MIDDLE); outer.add(menu); outer.setStyleName("toolbar"); outer.add(loading); HTML logos = new HTML("<table><tr><td><a href='http://pithos.grnet.gr' target='gss'>" + AbstractImagePrototype.create(images.gssLogo()).getHTML() + "</a><a href='http://www.grnet.gr/' " + "target='grnet'>" + AbstractImagePrototype.create(images.grnetLogo()).getHTML() + "</a></td></tr></table>"); outer.add(logos); outer.setCellHorizontalAlignment(logos, HasHorizontalAlignment.ALIGN_RIGHT); initWidget(outer); }