diff options
author | afinkbein | 2008-12-01 16:51:33 +0000 |
---|---|---|
committer | afinkbein | 2008-12-01 16:51:33 +0000 |
commit | 65be9cd70e3030b8a15c1a96143c022bfb521990 (patch) | |
tree | 52af908e44c54a615d5775a775bd5dcc530c3e0e | |
parent | bfa17588998335c60222e6e011279cb955ec2971 (diff) | |
download | org.eclipse.osee-65be9cd70e3030b8a15c1a96143c022bfb521990.tar.gz org.eclipse.osee-65be9cd70e3030b8a15c1a96143c022bfb521990.tar.xz org.eclipse.osee-65be9cd70e3030b8a15c1a96143c022bfb521990.zip |
9 files changed, 538 insertions, 0 deletions
diff --git a/org.eclipse.osee.framework.ui.jdk/.classpath b/org.eclipse.osee.framework.ui.jdk/.classpath new file mode 100644 index 00000000000..8a8f1668cdc --- /dev/null +++ b/org.eclipse.osee.framework.ui.jdk/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.eclipse.osee.framework.ui.jdk/.project b/org.eclipse.osee.framework.ui.jdk/.project new file mode 100644 index 00000000000..9c58b0680ae --- /dev/null +++ b/org.eclipse.osee.framework.ui.jdk/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.osee.framework.ui.jdk</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/org.eclipse.osee.framework.ui.jdk/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.osee.framework.ui.jdk/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..ac256b87783 --- /dev/null +++ b/org.eclipse.osee.framework.ui.jdk/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,12 @@ +#Mon Aug 04 11:05:09 MST 2008
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/org.eclipse.osee.framework.ui.jdk/META-INF/MANIFEST.MF b/org.eclipse.osee.framework.ui.jdk/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..05d71ef7cf4 --- /dev/null +++ b/org.eclipse.osee.framework.ui.jdk/META-INF/MANIFEST.MF @@ -0,0 +1,14 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: OSEE JDK Ui Plug-in (Incubation) +Bundle-SymbolicName: org.eclipse.osee.framework.ui.jdk +Bundle-Version: 0.4.0.qualifier +Bundle-Activator: org.eclipse.osee.framework.ui.jdk.Activator +Bundle-Vendor: Eclipse.org +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime +Bundle-ActivationPolicy: lazy +Export-Package: org.eclipse.osee.framework.ui.jdk, + org.eclipse.osee.framework.ui.jdk.swing +Bundle-ClassPath: library.jar +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 diff --git a/org.eclipse.osee.framework.ui.jdk/build.properties b/org.eclipse.osee.framework.ui.jdk/build.properties new file mode 100644 index 00000000000..97c13f300cb --- /dev/null +++ b/org.eclipse.osee.framework.ui.jdk/build.properties @@ -0,0 +1,5 @@ +bin.includes = META-INF/,\ + library.jar +source.library.jar = src/ +output.library.jar = bin/ +jars.compile.order = library.jar diff --git a/org.eclipse.osee.framework.ui.jdk/src/org/eclipse/osee/framework/ui/jdk/Activator.java b/org.eclipse.osee.framework.ui.jdk/src/org/eclipse/osee/framework/ui/jdk/Activator.java new file mode 100644 index 00000000000..bc62c661f24 --- /dev/null +++ b/org.eclipse.osee.framework.ui.jdk/src/org/eclipse/osee/framework/ui/jdk/Activator.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.framework.ui.jdk; + +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "org.eclipse.osee.framework.ui.jdk"; + + // The shared instance + private static Activator plugin; + + /** + * The constructor + */ + public Activator() { + plugin = this; + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + +} diff --git a/org.eclipse.osee.framework.ui.jdk/src/org/eclipse/osee/framework/ui/jdk/swing/DialogSupport.java b/org.eclipse.osee.framework.ui.jdk/src/org/eclipse/osee/framework/ui/jdk/swing/DialogSupport.java new file mode 100644 index 00000000000..c7169fe260a --- /dev/null +++ b/org.eclipse.osee.framework.ui.jdk/src/org/eclipse/osee/framework/ui/jdk/swing/DialogSupport.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.framework.ui.jdk.swing; + +import java.awt.Component; +import java.io.PrintWriter; +import java.io.StringWriter; +import javax.swing.JOptionPane; + +public class DialogSupport { + + public static void popupExceptionDialog(Component parent, String dlgTitle, Exception ex) { + PrintWriter ps = new PrintWriter(new StringWriter()); + ex.printStackTrace(ps); + JOptionPane.showMessageDialog(parent, ex.getMessage() + "\n" + ps, dlgTitle, JOptionPane.ERROR_MESSAGE); + } +} diff --git a/org.eclipse.osee.framework.ui.jdk/src/org/eclipse/osee/framework/ui/jdk/swing/EasyGridConstraint.java b/org.eclipse.osee.framework.ui.jdk/src/org/eclipse/osee/framework/ui/jdk/swing/EasyGridConstraint.java new file mode 100644 index 00000000000..75e7a1e62fe --- /dev/null +++ b/org.eclipse.osee.framework.ui.jdk/src/org/eclipse/osee/framework/ui/jdk/swing/EasyGridConstraint.java @@ -0,0 +1,223 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.framework.ui.jdk.swing; + +import java.awt.GridBagConstraints; +import java.awt.Insets; + +/** + * @author Robert A. Fisher + */ +public class EasyGridConstraint extends GridBagConstraints { + private static final long serialVersionUID = -1745538537160837428L; + + public EasyGridConstraint setGrid(int x, int y) { + this.gridx = x; + this.gridy = y; + + return this; + } + + public EasyGridConstraint setHeight(int height) { + this.gridheight = height; + + return this; + } + + public EasyGridConstraint setWidth(int width) { + this.gridwidth = width; + + return this; + } + + public EasyGridConstraint setWeight(double x, double y) { + this.weightx = x; + this.weighty = y; + + return this; + } + + public EasyGridConstraint setXPadding(int x) { + this.ipadx = x; + + return this; + } + + public EasyGridConstraint setYPadding(int y) { + this.ipadx = y; + + return this; + } + + public EasyGridConstraint setXInsets(int x) { + this.insets.left = x; + this.insets.right = x; + + return this; + } + + public EasyGridConstraint setYInsets(int y) { + this.insets.top = y; + this.insets.bottom = y; + + return this; + } + + public EasyGridConstraint setInsets(int top, int left, int bottom, int right) { + this.insets.top = top; + this.insets.left = left; + this.insets.bottom = bottom; + this.insets.right = right; + + return this; + } + + public EasyGridConstraint fillBoth() { + this.fill = GridBagConstraints.BOTH; + + return this; + } + + public EasyGridConstraint fillVert() { + this.fill = GridBagConstraints.VERTICAL; + + return this; + } + + public EasyGridConstraint fillHorz() { + this.fill = GridBagConstraints.HORIZONTAL; + + return this; + } + + public EasyGridConstraint anchorNorth() { + this.anchor = GridBagConstraints.NORTH; + + return this; + } + + public EasyGridConstraint anchorNorthEast() { + this.anchor = GridBagConstraints.NORTHEAST; + + return this; + } + + public EasyGridConstraint anchorNorthWest() { + this.anchor = GridBagConstraints.NORTHWEST; + + return this; + } + + public EasyGridConstraint anchorSouth() { + this.anchor = GridBagConstraints.SOUTH; + + return this; + } + + public EasyGridConstraint anchorSouthEast() { + this.anchor = GridBagConstraints.SOUTHEAST; + + return this; + } + + public EasyGridConstraint anchorSouthWest() { + this.anchor = GridBagConstraints.SOUTHWEST; + + return this; + } + + public EasyGridConstraint anchorEast() { + this.anchor = GridBagConstraints.EAST; + + return this; + } + + public EasyGridConstraint anchorWest() { + this.anchor = GridBagConstraints.WEST; + + return this; + } + + public static GridBagConstraints setConstraints(int gridx, int gridy, double weightx, double weighty, int gridwidth, int gridheight, char fill, String anchor) { + return setConstraints(gridx, gridy, weightx, weighty, gridwidth, gridheight, fill, anchor, 0, 0, null); + } + + public static GridBagConstraints setConstraints(int gridx, int gridy, double weightx, double weighty, int gridwidth, int gridheight, char fill, String anchor, Insets insets) { + return setConstraints(gridx, gridy, weightx, weighty, gridwidth, gridheight, fill, anchor, 0, 0, insets); + } + + /** + * A wrapper for setting the constraints of a GridBag object. + * + * @param gridx Specifies the cell at the left of the component's display area, where the leftmost cell has gridx = + * 0. + * @param gridy Specifies the cell at the top of the component's display area, where the topmost cell has gridy = 0. + * @param weightx Specifies how to distribute extra horizontal space. + * @param weighty Specifies how to distribute extra vertical space. + * @param gridwidth Specifies the number of cells in a row for the component's display area. + * @param gridheight Specifies the number of cells in a column for the component's display area. + * @param fill This field is used when the component's display area is larger than the component's requested size. + * @param anchor This field is used when the component is smaller than its display area. + * @param insets Specifies the external padding of the component -- the minimum amount of space between the component + * and the edges of its display area. + * @param ipadx Specifies the component's horizontal internal padding + * @param ipady Specifies the component's vertical internal padding + * @return java.awt.GridBagConstraints + */ + public static GridBagConstraints setConstraints(int gridx, int gridy, double weightx, double weighty, int gridwidth, int gridheight, char fill, String anchor, int ipadx, int ipady, Insets insets) { + // gridx, gridy, weightx, weighty, gridwidth, gridheight, char fill, String anchor, insets, ipadx, ipady + + GridBagConstraints gbc = new GridBagConstraints(); + gbc.gridx = gridx; + gbc.gridy = gridy; + gbc.weightx = weightx; + gbc.weighty = weighty; + gbc.gridwidth = gridwidth; + gbc.gridheight = gridheight; + gbc.ipadx = ipadx; + gbc.ipady = ipady; + if (insets != null) { + gbc.insets = insets; + } + + switch (fill) { + case 'V': + gbc.fill = GridBagConstraints.VERTICAL; + break; + case 'H': + gbc.fill = GridBagConstraints.HORIZONTAL; + break; + case 'B': + gbc.fill = GridBagConstraints.BOTH; + break; + } + + if (anchor.equals("N")) { + gbc.anchor = GridBagConstraints.NORTH; + } else if (anchor.equals("NE")) { + gbc.anchor = GridBagConstraints.NORTHEAST; + } else if (anchor.equals("E")) { + gbc.anchor = GridBagConstraints.EAST; + } else if (anchor.equals("SE")) { + gbc.anchor = GridBagConstraints.SOUTHEAST; + } else if (anchor.equals("S")) { + gbc.anchor = GridBagConstraints.SOUTH; + } else if (anchor.equals("SW")) { + gbc.anchor = GridBagConstraints.SOUTHWEST; + } else if (anchor.equals("W")) { + gbc.anchor = GridBagConstraints.WEST; + } else if (anchor.equals("NW")) { + gbc.anchor = GridBagConstraints.NORTHWEST; + } + return gbc; + } + +} diff --git a/org.eclipse.osee.framework.ui.jdk/src/org/eclipse/osee/framework/ui/jdk/swing/FileListEditor.java b/org.eclipse.osee.framework.ui.jdk/src/org/eclipse/osee/framework/ui/jdk/swing/FileListEditor.java new file mode 100644 index 00000000000..699e0696063 --- /dev/null +++ b/org.eclipse.osee.framework.ui.jdk/src/org/eclipse/osee/framework/ui/jdk/swing/FileListEditor.java @@ -0,0 +1,164 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.framework.ui.jdk.swing; + +import java.awt.Component; +import java.awt.GridBagLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.Enumeration; +import java.util.Iterator; +import java.util.List; +import javax.swing.DefaultListModel; +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JScrollPane; + +/** + * @author Ryan D. Brooks + */ +public class FileListEditor extends JPanel implements ActionListener { + + private static final long serialVersionUID = -4397118110586026746L; + private DefaultListModel listModel; + private JList list; + private JFileChooser chooser; + private JButton addButton; + private JButton removeButton; + private String relativeToPath; + + public FileListEditor() { + this(null, null, JFileChooser.FILES_AND_DIRECTORIES, null); + } + + public FileListEditor(List<File> items, File currentDir, int mode, File relativeToFile) { + super(new GridBagLayout()); + + if (relativeToFile != null) { + try { + this.relativeToPath = relativeToFile.getCanonicalFile().getPath(); //ensure this has a standard name + } catch (IOException ex) { + // this.relativeToFile is already null so do nothing + } + } + + listModel = new DefaultListModel(); + list = new JList(listModel); + chooser = new JFileChooser(currentDir); + + chooser.setFileSelectionMode(mode); + chooser.setMultiSelectionEnabled(true); + + if (items != null) { + addFiles(items); + } + + JScrollPane scrollList = new JScrollPane(list); + add(scrollList, EasyGridConstraint.setConstraints(0, 0, 1, 1, 2, 1, 'B', "")); + + addButton = new JButton("Add"); + addButton.addActionListener(this); + add(addButton, EasyGridConstraint.setConstraints(0, 1, 1, 0, 1, 1, 'N', "W")); + + removeButton = new JButton("Remove"); + removeButton.addActionListener(this); + add(removeButton, EasyGridConstraint.setConstraints(1, 1, 1, 0, 1, 1, 'N', "E")); + + } + + public void setChooserTitle(String title) { + chooser.setDialogTitle(title); + } + + public void actionPerformed(ActionEvent ev) { + Component component = (Component) ev.getSource(); + if (component == addButton) { + if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { + File[] files = chooser.getSelectedFiles(); + for (int i = 0; i < files.length; i++) { + if (relativeToPath == null) { + listModel.addElement(files[i].getPath()); + } else { + try { + String path = files[i].getCanonicalFile().getPath(); + if (path.startsWith(relativeToPath)) { + listModel.addElement(path.substring(relativeToPath.length() + 1)); + } else { + System.out.println("Path is not relative to " + relativeToPath); + } + } catch (IOException ex) { + System.out.println(ex); + } + } + } + } + } else if (component == removeButton) { + int[] indices = list.getSelectedIndices(); + for (int i = indices.length - 1; i > -1; i--) { + listModel.remove(indices[i]); + } + } + } + + public void addFiles(List<File> items) { + for (Iterator<File> i = items.iterator(); i.hasNext();) { + File file = i.next(); + if (relativeToPath == null) { + listModel.addElement(file.getPath()); + } else { + try { + String path = file.getCanonicalFile().getPath(); + if (path.startsWith(relativeToPath)) { + listModel.addElement(path.substring(relativeToPath.length() + 1)); + } else { + System.out.println("Path is not relative to " + relativeToPath); + } + } catch (IOException ex) { + System.out.println(ex); + } + } + } + } + + public void addFiles(String[] files) { + for (int i = 0; i < files.length; i++) { + listModel.addElement(files[i]); + } + } + + public void addFile(String file) { + listModel.addElement(file); + } + + public void writeListTo(File file) throws IOException { + BufferedWriter out = new BufferedWriter(new FileWriter(file)); + for (Enumeration<?> e = listModel.elements(); e.hasMoreElements();) { + out.write((String) e.nextElement()); + out.newLine(); + } + out.close(); + } + + public File[] getFiles() { + File[] files = new File[listModel.size()]; + Enumeration<?> e = listModel.elements(); + for (int i = 0; i < files.length; i++) { + files[i] = new File((String) e.nextElement()); + } + return files; + } +} |