IssueZilla 10518 - Add BeanShell support, add a language property which

determines which scripts get listed in the Configure dialog
This commit is contained in:
Tomas O'Connor
2003-01-16 17:00:19 +00:00
parent fa40dc57cd
commit 84d0d87200
2 changed files with 87 additions and 12 deletions

View File

@@ -2,9 +2,9 @@
* *
* $RCSfile: ParcelFolderSupport.java,v $ * $RCSfile: ParcelFolderSupport.java,v $
* *
* $Revision: 1.2 $ * $Revision: 1.3 $
* *
* last change: $Author: toconnor $ $Date: 2002-11-13 17:44:24 $ * last change: $Author: toconnor $ $Date: 2003-01-16 18:00:18 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
@@ -102,6 +102,7 @@ import org.openoffice.idesupport.ui.ConfigurePanel;
public class ParcelFolderSupport implements ParcelFolderCookie public class ParcelFolderSupport implements ParcelFolderCookie
{ {
protected ParcelFolder pf; protected ParcelFolder pf;
private ConfigurePanel configuror = null;
public ParcelFolderSupport(ParcelFolder pf) { public ParcelFolderSupport(ParcelFolder pf) {
this.pf = pf; this.pf = pf;
@@ -152,9 +153,18 @@ public class ParcelFolderSupport implements ParcelFolderCookie
} }
public void configure() { public void configure() {
FileObject primary = pf.getPrimaryFile(); FileObject primary = pf.getPrimaryFile();
File contents = FileUtil.toFile(primary.getFileObject(ParcelZipper.CONTENTS_DIRNAME));
File parcelDescriptor = new File(contents, ParcelZipper.PARCEL_DESCRIPTOR_XML); ParcelFolder.ParcelFolderNode node =
(ParcelFolder.ParcelFolderNode)pf.getNodeDelegate();
File contents = FileUtil.toFile(
primary.getFileObject(ParcelZipper.CONTENTS_DIRNAME));
File parcelDescriptor = new File(contents,
ParcelZipper.PARCEL_DESCRIPTOR_XML);
InputSource is; InputSource is;
Document previous = null; Document previous = null;
@@ -175,8 +185,15 @@ public class ParcelFolderSupport implements ParcelFolderCookie
Vector classpath = getClasspath(); Vector classpath = getClasspath();
classpath.addElement(contents.getAbsolutePath()); classpath.addElement(contents.getAbsolutePath());
ConfigurePanel configuror = new ConfigurePanel(contents.getAbsolutePath(), classpath, previous); if (configuror == null)
DialogDescriptor descriptor = new DialogDescriptor(configuror, "Choose Methods to Export as Scripts"); configuror = new ConfigurePanel(contents.getAbsolutePath(),
classpath, previous, node.getLanguage());
else
configuror.reload(contents.getAbsolutePath(), classpath, previous,
node.getLanguage());
DialogDescriptor descriptor = new DialogDescriptor(configuror,
ConfigurePanel.DIALOG_TITLE);
Dialog dialog = TopManager.getDefault().createDialog(descriptor); Dialog dialog = TopManager.getDefault().createDialog(descriptor);
dialog.show(); dialog.show();

View File

@@ -2,9 +2,9 @@
* *
* $RCSfile: ParcelFolder.java,v $ * $RCSfile: ParcelFolder.java,v $
* *
* $Revision: 1.2 $ * $Revision: 1.3 $
* *
* last change: $Author: toconnor $ $Date: 2002-11-13 17:44:33 $ * last change: $Author: toconnor $ $Date: 2003-01-16 18:00:19 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
@@ -86,6 +86,8 @@ import org.openoffice.netbeans.modules.office.actions.ParcelFolderSupport;
public class ParcelFolder extends DataFolder { public class ParcelFolder extends DataFolder {
public static final String LANGUAGE_ATTRIBUTE = "language";
public ParcelFolder(FileObject pf, ParcelFolderDataLoader loader) public ParcelFolder(FileObject pf, ParcelFolderDataLoader loader)
throws DataObjectExistsException { throws DataObjectExistsException {
super(pf, loader); super(pf, loader);
@@ -100,9 +102,11 @@ public class ParcelFolder extends DataFolder {
public class ParcelFolderNode extends DataFolder.FolderNode { public class ParcelFolderNode extends DataFolder.FolderNode {
private static final String LOCATION = "location"; private static final String LOCATION = "location";
private static final String FILTER = "filter"; private static final String FILTER = "filter";
private static final String LANGUAGE = LANGUAGE_ATTRIBUTE;
private File location; private File location;
private FileFilter filter; private FileFilter filter;
private String language;
private final FileFilter DEFAULT_FILTER = BinaryOnlyFilter.getInstance(); private final FileFilter DEFAULT_FILTER = BinaryOnlyFilter.getInstance();
@@ -121,6 +125,8 @@ public class ParcelFolder extends DataFolder {
if (name.equals(availableFilters[i].toString())) if (name.equals(availableFilters[i].toString()))
filter = availableFilters[i]; filter = availableFilters[i];
} }
language = (String)pf.getPrimaryFile().getAttribute(LANGUAGE);
} }
public File getTargetDir() { public File getTargetDir() {
@@ -131,6 +137,12 @@ public class ParcelFolder extends DataFolder {
return filter; return filter;
} }
public String getLanguage() {
if (language == null)
language = (String)getPrimaryFile().getAttribute(LANGUAGE);
return language;
}
public Sheet createSheet() { public Sheet createSheet() {
Sheet sheet; Sheet sheet;
Sheet.Set props; Sheet.Set props;
@@ -149,6 +161,9 @@ public class ParcelFolder extends DataFolder {
prop = createFilterProperty(); prop = createFilterProperty();
props.put(prop); props.put(prop);
prop = createLanguageProperty();
props.put(prop);
return sheet; return sheet;
} }
@@ -163,7 +178,6 @@ public class ParcelFolder extends DataFolder {
getPrimaryFile().setAttribute(LOCATION, location); getPrimaryFile().setAttribute(LOCATION, location);
} }
catch (IOException ioe) { catch (IOException ioe) {
System.out.println("Error setting location attribute");
} }
} }
} }
@@ -176,8 +190,53 @@ public class ParcelFolder extends DataFolder {
return prop; return prop;
} }
private FileFilter[] availableFilters = private String[] languages = {"Java", "BeanShell"};
new FileFilter[] {BinaryOnlyFilter.getInstance(), AllFilesFilter.getInstance()};
private Node.Property createLanguageProperty() {
Node.Property prop =
new PropertySupport.ReadWrite(LANGUAGE, String.class,
"Parcel Language", "Language of scripts in this Parcel") {
public void setValue(Object obj) {
if (obj instanceof String) {
language = (String)obj;
try {
getPrimaryFile().setAttribute(LANGUAGE, language);
}
catch (IOException ioe) {
}
}
}
public Object getValue() {
if (language == null)
language = (String)getPrimaryFile().getAttribute(LANGUAGE);
return language;
}
public PropertyEditor getPropertyEditor() {
return new PropertyEditorSupport() {
public String[] getTags() {
return languages;
}
public void setAsText(String text) {
for (int i = 0; i < languages.length; i++)
if (text.equals(languages[i]))
this.setValue(languages[i]);
}
public String getAsText() {
return (String)this.getValue();
}
};
}
};
return prop;
}
private FileFilter[] availableFilters = new FileFilter[] {
BinaryOnlyFilter.getInstance(), AllFilesFilter.getInstance()};
private Node.Property createFilterProperty() { private Node.Property createFilterProperty() {
Node.Property prop = Node.Property prop =
@@ -191,7 +250,6 @@ public class ParcelFolder extends DataFolder {
getPrimaryFile().setAttribute(FILTER, filter.toString()); getPrimaryFile().setAttribute(FILTER, filter.toString());
} }
catch (IOException ioe) { catch (IOException ioe) {
System.out.println("Error setting filter attribute");
} }
} }
} }