package org.tianocore.frameworkwizard.platform.ui;\r
\r
import java.awt.BorderLayout;\r
+import java.awt.Dimension;\r
+import java.awt.FontMetrics;\r
\r
import javax.swing.JFrame;\r
import javax.swing.JOptionPane;\r
import org.tianocore.frameworkwizard.common.ui.IInternalFrame;\r
import org.tianocore.frameworkwizard.platform.ui.global.SurfaceAreaQuery;\r
import org.tianocore.frameworkwizard.platform.ui.global.WorkspaceProfile;\r
+import org.tianocore.frameworkwizard.workspace.Workspace;\r
import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;\r
\r
import java.awt.FlowLayout;\r
+import java.awt.event.ActionEvent;\r
import java.awt.event.KeyEvent;\r
import java.awt.event.MouseEvent;\r
import java.util.ArrayList;\r
private final int typeMinWidth = 100;\r
\r
private final int typeMaxWidth = 155;\r
+\r
+ private JButton jButtonApriori = null;\r
\r
/**\r
* This method initializes jSplitPane\r
String path = modelAllModules.getValueAt(selectedRow, pathColForAllModTable) + "";\r
ModuleIdentification mi = miList.get(selectedRow);\r
Vector<String> vArchs = null;\r
- try {\r
- vArchs = WorkspaceProfile.getModuleSupArchs(mi);\r
- }\r
- catch (Exception exp) {\r
- JOptionPane.showMessageDialog(frame, exp.getMessage());\r
- }\r
+\r
+ vArchs = WorkspaceProfile.getModuleSupArchs(mi);\r
\r
if (vArchs == null) {\r
JOptionPane.showMessageDialog(frame, "No Supported Architectures specified in MSA file.");\r
return;\r
}\r
\r
+ Vector<Object> platformSupArch = new Vector<Object>();\r
+ ffc.getPlatformDefsSupportedArchs(platformSupArch);\r
+ platformSupArch.retainAll(vArchs);\r
+ if (platformSupArch.size() == 0) {\r
+ JOptionPane.showMessageDialog(frame, "This Module does not support this platform architectures.");\r
+ return;\r
+ }\r
+ \r
String archsAdded = "";\r
String mg = mi.getGuid();\r
String mv = mi.getVersion();\r
//\r
// check whether archs conform to SupArch of platform.\r
//\r
- Vector<Object> platformSupArch = new Vector<Object>();\r
+ platformSupArch.removeAllElements();\r
ffc.getPlatformDefsSupportedArchs(platformSupArch);\r
vArchs.retainAll(platformSupArch);\r
//\r
jPanelBottomSouth.setLayout(flowLayout1);\r
jPanelBottomSouth.add(getJButtonSettings(), null);\r
jPanelBottomSouth.add(getJButtonRemoveModule(), null);\r
+ jPanelBottomSouth.add(getJButtonApriori(), null);\r
}\r
return jPanelBottomSouth;\r
}\r
\r
private void showSettingsDlg (int row) {\r
try {\r
- if (ffc.adjustPcd(row)) {\r
+ Vector<String> vExceptions = new Vector<String>();\r
+ if (ffc.adjustPcd(row, vExceptions)) {\r
+ JOptionPane.showMessageDialog(frame, "Pcd entries sync. with those in MSA files.");\r
docConsole.setSaved(false);\r
}\r
}\r
private JButton getJButtonRemoveModule() {\r
if (jButtonRemoveModule == null) {\r
jButtonRemoveModule = new JButton();\r
- jButtonRemoveModule.setPreferredSize(new java.awt.Dimension(130, 20));\r
jButtonRemoveModule.setText("Remove Module");\r
+ FontMetrics fm = jButtonRemoveModule.getFontMetrics(jButtonRemoveModule.getFont());\r
+ jButtonRemoveModule.setPreferredSize(new Dimension (fm.stringWidth(jButtonRemoveModule.getText()) + 40, 20));\r
jButtonRemoveModule.addActionListener(new java.awt.event.ActionListener() {\r
public void actionPerformed(java.awt.event.ActionEvent e) {\r
int selectedRow = jTableFpdModules.getSelectedRow();\r
if (fvBindings != null) {\r
String[] fvArray = fvBindings.split(" ");\r
for (int i = 0; i < fvArray.length; ++i) {\r
- ffc.removeModuleInBuildOptionsUserExtensions(fvArray[i].trim(), mg, mv, pg, pv, arch);\r
+ ffc.removeModuleInBuildOptionsUserExtensions(fvArray[i].trim(), "IMAGES", 1, mg, mv, pg, pv, arch);\r
}\r
}\r
\r
return jButtonRemoveModule;\r
}\r
\r
+ /**\r
+ * This method initializes jButtonApriori \r
+ * \r
+ * @return javax.swing.JButton \r
+ */\r
+ private JButton getJButtonApriori() {\r
+ if (jButtonApriori == null) {\r
+ jButtonApriori = new JButton();\r
+ jButtonApriori.setText("Apriori Files");\r
+ FontMetrics fm = jButtonApriori.getFontMetrics(jButtonApriori.getFont());\r
+ int buttonWidth = fm.stringWidth(jButtonApriori.getText()) + 40;\r
+ if (jButtonRemoveModule.getWidth() > buttonWidth) {\r
+ buttonWidth = jButtonRemoveModule.getWidth();\r
+ }\r
+ jButtonApriori.setPreferredSize(new Dimension (buttonWidth, 20));\r
+ jButtonApriori.addActionListener(new java.awt.event.ActionListener() {\r
+ public void actionPerformed(ActionEvent arg0) {\r
+ new GenAprioriFileDialog(ffc, docConsole).setVisible(true);\r
+ }});\r
+ }\r
+ return jButtonApriori;\r
+ }\r
+\r
/**\r
* \r
* @param args\r
public FpdFrameworkModules(OpeningPlatformType opt) {\r
this(opt.getXmlFpd());\r
docConsole = opt;\r
+ Vector<String> vExceptions = new Vector<String>();\r
+ if (pcdSync(vExceptions)) {\r
+ JOptionPane.showMessageDialog(frame, "PCD in this platform are synchronized with those in MSA files."); \r
+ docConsole.setSaved(false);\r
+ }\r
+ if (vExceptions.size() > 0) {\r
+ String errorMsg = "";\r
+ for (int i = 0; i < vExceptions.size(); ++i) {\r
+ errorMsg += " " + vExceptions.get(i) + "\n";\r
+ }\r
+ JOptionPane.showMessageDialog(frame, "Error occurred during synchronization:" + errorMsg);\r
+ }\r
}\r
\r
private void init(PlatformSurfaceAreaDocument.PlatformSurfaceArea fpd) {\r
row[pkgVerColForFpdModTable] = mi.getPackageId().getVersion();\r
row[archColForFpdModTable] = saa[i][ffcModArch];\r
try {\r
- row[pathColForFpdModTable] = mi.getPath().substring(System.getenv("WORKSPACE").length() + 1);\r
+ row[pathColForFpdModTable] = mi.getPath().substring(Workspace.getCurrentWorkspace().length() + 1);\r
} catch (Exception e) {\r
JOptionPane.showMessageDialog(frame, "Show FPD Modules:" + e.getMessage());\r
}\r
}\r
\r
showAllModules();\r
-\r
+ \r
}\r
\r
+ private boolean pcdSync(Vector<String> v) {\r
+ boolean synced = false;\r
+ for (int i = 0; i < jTableFpdModules.getRowCount(); ++i) {\r
+ try {\r
+ if (ffc.adjustPcd(i, v)) {\r
+ synced = true;\r
+ }\r
+ }\r
+ catch (Exception exp) {\r
+// JOptionPane.showMessageDialog(frame, exp.getMessage());\r
+ continue;\r
+ }\r
+ }\r
+ return synced;\r
+ \r
+ }\r
+ \r
private void showAllModules() {\r
\r
if (miList == null) {\r
s[pkgNameColForAllModTable] = mi.getPackageId().getName();\r
s[pkgVerColForAllModTable] = mi.getPackageId().getVersion();\r
try {\r
- s[pathColForAllModTable] = mi.getPath().substring(System.getenv("WORKSPACE").length() + 1);\r
+ s[pathColForAllModTable] = mi.getPath().substring(Workspace.getCurrentWorkspace().length() + 1);\r
} catch (Exception e) {\r
JOptionPane.showMessageDialog(frame, "Show All Modules:" + e.getMessage());\r
}\r