This project has retired. For details please refer to its
Attic page.
SetContentStreamPanel xref
1/*2 * Licensed to the Apache Software Foundation (ASF) under one3 * or more contributor license agreements. See the NOTICE file4 * distributed with this work for additional information5 * regarding copyright ownership. The ASF licenses this file6 * to you under the Apache License, Version 2.0 (the7 * "License"); you may not use this file except in compliance8 * with the License. You may obtain a copy of the License at9 *10 * http://www.apache.org/licenses/LICENSE-2.011 *12 * Unless required by applicable law or agreed to in writing,13 * software distributed under the License is distributed on an14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY15 * KIND, either express or implied. See the License for the16 * specific language governing permissions and limitations17 * under the License.18 */19package org.apache.chemistry.opencmis.workbench.actions;
2021import javax.swing.JCheckBox;
22import javax.swing.JTextField;
2324import org.apache.chemistry.opencmis.client.api.Document;
25import org.apache.chemistry.opencmis.commons.data.ContentStream;
26import org.apache.chemistry.opencmis.commons.enums.Action;
27import org.apache.chemistry.opencmis.workbench.model.ClientModel;
28import org.apache.chemistry.opencmis.workbench.swing.ActionPanel;
2930publicclassSetContentStreamPanelextendsActionPanel {
3132privatestaticfinallong serialVersionUID = 1L;
3334private JTextField filenameField;
35private JCheckBox overwriteBox;
3637publicSetContentStreamPanel(ClientModel model) {
38super("Set Content Stream", "Set Content Stream", model);
39 }
4041 @Override
42protectedvoid createActionComponents() {
43 filenameField = new JTextField(30);
44 addActionComponent(createFilenamePanel(filenameField));
4546 overwriteBox = new JCheckBox("overwrite", true);
47 addActionComponent(overwriteBox);
48 }
4950 @Override
51publicboolean isAllowed() {
52if ((getObject() == null) || !(getObject() instanceof Document)) {
53return false;
54 }
5556if ((getObject().getAllowableActions() == null)
57 || (getObject().getAllowableActions().getAllowableActions() == null)) {
58returntrue;
59 }
6061return getObject().getAllowableActions().getAllowableActions().contains(Action.CAN_SET_CONTENT_STREAM);
62 }
6364 @Override
65publicboolean doAction() throws Exception {
66 ContentStream content = getClientModel().createContentStream(filenameField.getText());
67 ((Document) getObject()).setContentStream(content, overwriteBox.isSelected());
68returntrue;
69 }
70 }