GT-2698 - code review fixes - delete unused class, fix amp escape

This commit is contained in:
dev747368 2019-04-17 11:50:30 -04:00
parent 18bb622081
commit 1f36a7616c
3 changed files with 8 additions and 136 deletions

View File

@ -1,101 +0,0 @@
/* ###
* IP: GHIDRA
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ghidra.app.plugin.core.datamgr;
import java.awt.BorderLayout;
import javax.swing.JPanel;
import docking.DialogComponentProvider;
import docking.widgets.label.GHtmlLabel;
import ghidra.program.model.data.*;
import ghidra.util.HTMLUtilities;
/**
* The DataOrganizationDialog
*/
public class DataOrganizationDialog extends DialogComponentProvider {
private static String TITLE = "Data Type Alignment";
private DataTypeManager dataTypeManager;
private DataOrganization dataOrganization;
private JPanel mainPanel;
private DataOrganizationPanel alignPanel;
private SizeAlignmentPanel sizePanel;
private boolean actionComplete;
/**
* Creates a data type organization dialog for specifying data type alignment information
* for a single data type manager. This dialog allows the user to align all data types in
* the associated data type manager.
* @param dataTypeManager the data type manager
* @param dataOrganization structure containing the alignment information.
* This object will be modified by the information entered into the dialog.
*/
public DataOrganizationDialog(DataTypeManager dataTypeManager,
DataOrganizationImpl dataOrganization) {
super(TITLE, true);
this.dataTypeManager = dataTypeManager;
this.dataOrganization = dataOrganization;
JPanel headerPanel = new JPanel();
headerPanel.add(new GHtmlLabel("<HTML>Alignment Information for <b>" +
HTMLUtilities.escapeHTML(dataTypeManager.getName()) + "</b>.</HTML>"));
alignPanel = new DataOrganizationPanel();
alignPanel.setOrganization(dataOrganization);
sizePanel = new SizeAlignmentPanel();
sizePanel.setOrganization(dataOrganization);
JPanel infoPanel = new JPanel(new BorderLayout());
infoPanel.add(alignPanel, BorderLayout.NORTH);
infoPanel.add(sizePanel, BorderLayout.CENTER);
mainPanel = new JPanel(new BorderLayout());
mainPanel.add(headerPanel, BorderLayout.NORTH);
mainPanel.add(infoPanel, BorderLayout.CENTER);
addWorkPanel(mainPanel);
initialize();
}
private void initialize() {
actionComplete = false;
addOKButton();
setOkButtonText("Set");
addCancelButton();
// setHelpLocation(new HelpLocation(plugin, "Align_Data_Types_In_Archive"));
}
public boolean userCanceled() {
return !actionComplete && !isVisible();
}
@Override
protected void okCallback() {
actionComplete = true;
close();
}
@Override
protected void cancelCallback() {
super.cancelCallback();
actionComplete = false;
}
public DataOrganization getDataOrganization() {
return dataOrganization;
}
}

View File

@ -106,7 +106,7 @@ public class DataTypeManagerPlugin extends ProgramPlugin
@Override
protected void init() {
recentlyOpenedArchiveMap = new LRUMap<String, DockingAction>(RECENTLY_USED_CACHE_SIZE) {
recentlyOpenedArchiveMap = new LRUMap<>(RECENTLY_USED_CACHE_SIZE) {
@Override
protected void eldestEntryRemoved(Entry<String, DockingAction> eldest) {
DockingAction action = eldest.getValue();
@ -719,30 +719,6 @@ public class DataTypeManagerPlugin extends ProgramPlugin
return currentSelection;
}
// public DataOrganization promptToChangeDataOrganization(DataTypeManager dataTypeManagerToCheck)
// throws CancelledException {
// DataOrganization dataOrganization = promptUserForDataOrganization(dataTypeManagerToCheck);
// dataTypeManagerToCheck.setDataOrganization(dataOrganization);
// return dataOrganization;
// }
// public DataOrganization promptUserForDataOrganization(DataTypeManager dataTypeManagerToAlign)
// throws CancelledException {
// DataOrganization currentDataOrganization = dataTypeManagerToAlign.getDataOrganization();
// if (currentDataOrganization == null) {
// currentDataOrganization = DataOrganizationImpl.getDefaultOrganization();
// }
// DataOrganizationDialog dataOrgDialog =
// new DataOrganizationDialog(dataTypeManagerToAlign, currentDataOrganization);
// dataOrgDialog.setHelpLocation(new HelpLocation(this.getName(),
// "Align_Data_Types_In_Archive"));
// tool.showDialog(dataOrgDialog);
// if (dataOrgDialog.userCanceled()) {
// throw new CancelledException();
// }
// return dataOrgDialog.getDataOrganization();
// }
@Override
public List<DockingActionIf> getPopupActions(ActionContext context) {
if (!(context instanceof DataTypesActionContext)) {

View File

@ -39,19 +39,16 @@ public class HorizontalRuleAction extends DockingAction {
setEnabled(false);
// The menu name is both names, one over the other, in a small, light grayish font.
// If the original topName or bottomName contain html text that needs escaping, the first
// '&' of the replacement html entity (like '&lt;') will be consumed by the menudata deity
// and lost forever.
setMenuBarData(new MenuData(new String[] {
"<HTML><CENTER><FONT SIZE=2 COLOR=SILVER>" + HTMLUtilities.escapeHTML(topName) +
"<BR>" + HTMLUtilities.escapeHTML(bottomName) + "</FONT></CENTER>" }));
setMenuBarData(new MenuData(new String[] { "<HTML><CENTER><FONT SIZE=2 COLOR=SILVER>" +
fixupFirstAmp(
HTMLUtilities.escapeHTML(topName) + "<BR>" + HTMLUtilities.escapeHTML(bottomName)) +
"</FONT></CENTER>" }));
// the description is meant to be used for the tooltip and is larger
String padding = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
setDescription("<HTML><CENTER><B>" + padding +
fixupFirstAmp(HTMLUtilities.escapeHTML(topName) + padding + "<B><HR><B>" + padding +
HTMLUtilities.escapeHTML(bottomName)) +
padding + "</B></CENTER>");
setDescription("<HTML><CENTER><B>" + padding + HTMLUtilities.escapeHTML(topName) + padding +
"<B><HR><B>" + padding + HTMLUtilities.escapeHTML(bottomName) + padding +
"</B></CENTER>");
}
private String fixupFirstAmp(String text) {