mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 18:29:37 +02:00
GP-2236 Changed DataTypeDB clone implementations to return self if the specified datatype manager is unchanged. Makes consistent with javadoc and could improve resolve performance in some cases.
This commit is contained in:
parent
f57cf98f56
commit
5eed321004
35 changed files with 498 additions and 936 deletions
|
@ -471,25 +471,11 @@ public abstract class AbstractEditorTest extends AbstractGhidraHeadedIntegration
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void startTransaction(final String txDescription) {
|
protected void startTransaction(final String txDescription) {
|
||||||
runSwing(() -> {
|
txId = program.startTransaction(txDescription);
|
||||||
try {
|
|
||||||
txId = program.startTransaction(txDescription);
|
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
Assert.fail(e.getMessage());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void endTransaction(final boolean saveChanges) {
|
protected void endTransaction(final boolean saveChanges) {
|
||||||
runSwing(() -> {
|
program.endTransaction(txId, saveChanges);
|
||||||
try {
|
|
||||||
program.endTransaction(txId, saveChanges);
|
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
Assert.fail(e.getMessage());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected class RestoreListener implements DomainObjectListener {
|
protected class RestoreListener implements DomainObjectListener {
|
||||||
|
|
|
@ -1,57 +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.compositeeditor;
|
|
||||||
|
|
||||||
import org.junit.Assert;
|
|
||||||
|
|
||||||
import ghidra.program.model.data.*;
|
|
||||||
import ghidra.util.exception.DuplicateNameException;
|
|
||||||
|
|
||||||
public abstract class AbstractStructureEditorLockedActionsTest extends AbstractStructureEditorTest {
|
|
||||||
|
|
||||||
protected void init(Structure dt, final Category cat) {
|
|
||||||
boolean commit = true;
|
|
||||||
startTransaction("Structure Editor Test Initialization");
|
|
||||||
try {
|
|
||||||
DataTypeManager dataTypeManager = cat.getDataTypeManager();
|
|
||||||
if (dt.getDataTypeManager() != dataTypeManager) {
|
|
||||||
dt = dt.clone(dataTypeManager);
|
|
||||||
}
|
|
||||||
CategoryPath categoryPath = cat.getCategoryPath();
|
|
||||||
if (!dt.getCategoryPath().equals(categoryPath)) {
|
|
||||||
try {
|
|
||||||
dt.setCategoryPath(categoryPath);
|
|
||||||
}
|
|
||||||
catch (DuplicateNameException e) {
|
|
||||||
commit = false;
|
|
||||||
Assert.fail(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
endTransaction(commit);
|
|
||||||
}
|
|
||||||
|
|
||||||
Structure structureDt = dt;
|
|
||||||
runSwing(() -> {
|
|
||||||
installProvider(new StructureEditorProvider(plugin, structureDt, false));
|
|
||||||
model = provider.getModel();
|
|
||||||
});
|
|
||||||
waitForSwing();
|
|
||||||
|
|
||||||
getActions();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -15,10 +15,9 @@
|
||||||
*/
|
*/
|
||||||
package ghidra.app.plugin.core.compositeeditor;
|
package ghidra.app.plugin.core.compositeeditor;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
|
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
|
|
||||||
|
import org.junit.After;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
|
|
||||||
import ghidra.program.model.data.*;
|
import ghidra.program.model.data.*;
|
||||||
|
@ -47,50 +46,55 @@ public abstract class AbstractStructureEditorTest extends AbstractEditorTest {
|
||||||
InsertUndefinedAction insertUndefinedAction;
|
InsertUndefinedAction insertUndefinedAction;
|
||||||
HexNumbersAction hexNumbersAction;
|
HexNumbersAction hexNumbersAction;
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void tearDown() throws Exception {
|
||||||
|
clearActions();
|
||||||
|
structureModel = null;
|
||||||
|
super.tearDown();
|
||||||
|
}
|
||||||
|
|
||||||
StructureEditorModel getModel() {
|
StructureEditorModel getModel() {
|
||||||
return (StructureEditorModel) model;
|
return structureModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void init(Structure dt, final Category cat) {
|
||||||
|
init(dt, cat, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void init(Structure dt, final Category cat, final boolean showInHex) {
|
protected void init(Structure dt, final Category cat, final boolean showInHex) {
|
||||||
|
|
||||||
assertEquals("Category path mismatch", dt.getCategoryPath(), cat.getCategoryPath());
|
DataTypeManager dataTypeManager = cat.getDataTypeManager();
|
||||||
|
if (dt.getDataTypeManager() != dataTypeManager) {
|
||||||
|
dt = dt.clone(dataTypeManager);
|
||||||
|
}
|
||||||
|
|
||||||
boolean commit = true;
|
CategoryPath categoryPath = cat.getCategoryPath();
|
||||||
startTransaction("Structure Editor Test Initialization");
|
if (!dt.getCategoryPath().equals(categoryPath)) {
|
||||||
try {
|
// dt may or may not be a DataTypeDB but create transaction to be safe
|
||||||
DataTypeManager dataTypeManager = cat.getDataTypeManager();
|
int dtmTxId =
|
||||||
if (dt.getDataTypeManager() != dataTypeManager) {
|
dataTypeManager.startTransaction("Modify Datatype Category: " + dt.getName());
|
||||||
dt = dt.clone(dataTypeManager);
|
try {
|
||||||
|
dt.setCategoryPath(categoryPath);
|
||||||
}
|
}
|
||||||
CategoryPath categoryPath = cat.getCategoryPath();
|
catch (DuplicateNameException e) {
|
||||||
if (!dt.getCategoryPath().equals(categoryPath)) {
|
Assert.fail(e.getMessage());
|
||||||
try {
|
}
|
||||||
dt.setCategoryPath(categoryPath);
|
finally {
|
||||||
}
|
dataTypeManager.endTransaction(dtmTxId, true);
|
||||||
catch (DuplicateNameException e) {
|
|
||||||
commit = false;
|
|
||||||
Assert.fail(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally {
|
|
||||||
endTransaction(commit);
|
|
||||||
}
|
|
||||||
final Structure structDt = dt;
|
final Structure structDt = dt;
|
||||||
runSwing(() -> {
|
runSwing(() -> {
|
||||||
installProvider(new StructureEditorProvider(plugin, structDt, showInHex));
|
installProvider(new StructureEditorProvider(plugin, structDt, showInHex));
|
||||||
model = provider.getModel();
|
model = provider.getModel();
|
||||||
});
|
});
|
||||||
waitForSwing();
|
waitForSwing();
|
||||||
|
|
||||||
getActions();
|
getActions();
|
||||||
structureModel = (StructureEditorModel) model;
|
structureModel = (StructureEditorModel) model;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void cleanup() {
|
|
||||||
clearActions();
|
|
||||||
runSwing(() -> provider.dispose());
|
|
||||||
}
|
|
||||||
|
|
||||||
void clearActions() {
|
void clearActions() {
|
||||||
actions = null;
|
actions = null;
|
||||||
favorites.clear();
|
favorites.clear();
|
||||||
|
|
|
@ -1,59 +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.compositeeditor;
|
|
||||||
|
|
||||||
import org.junit.Assert;
|
|
||||||
|
|
||||||
import ghidra.program.model.data.*;
|
|
||||||
import ghidra.util.exception.DuplicateNameException;
|
|
||||||
|
|
||||||
public abstract class AbstractStructureEditorUnlockedActionsTest
|
|
||||||
extends AbstractStructureEditorTest {
|
|
||||||
|
|
||||||
protected void init(Structure dt, final Category cat) {
|
|
||||||
boolean commit = true;
|
|
||||||
startTransaction("Structure Editor Test Initialization");
|
|
||||||
try {
|
|
||||||
DataTypeManager dataTypeManager = cat.getDataTypeManager();
|
|
||||||
if (dt.getDataTypeManager() != dataTypeManager) {
|
|
||||||
dt = (Structure) dt.clone(dataTypeManager);
|
|
||||||
}
|
|
||||||
CategoryPath categoryPath = cat.getCategoryPath();
|
|
||||||
if (!dt.getCategoryPath().equals(categoryPath)) {
|
|
||||||
try {
|
|
||||||
dt.setCategoryPath(categoryPath);
|
|
||||||
}
|
|
||||||
catch (DuplicateNameException e) {
|
|
||||||
commit = false;
|
|
||||||
Assert.fail(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
endTransaction(commit);
|
|
||||||
}
|
|
||||||
|
|
||||||
Structure structDt = dt;
|
|
||||||
runSwing(() -> {
|
|
||||||
installProvider(new StructureEditorProvider(plugin, structDt, false));
|
|
||||||
model = provider.getModel();
|
|
||||||
});
|
|
||||||
waitForSwing();
|
|
||||||
|
|
||||||
getActions();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,42 +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.compositeeditor;
|
|
||||||
|
|
||||||
import org.junit.Assert;
|
|
||||||
|
|
||||||
import ghidra.program.model.data.*;
|
|
||||||
import ghidra.util.exception.DuplicateNameException;
|
|
||||||
|
|
||||||
public abstract class AbstractStructureEditorUnlockedCellEditTest
|
|
||||||
extends AbstractStructureEditorTest {
|
|
||||||
|
|
||||||
protected void init(final Structure dt, final Category cat) {
|
|
||||||
final DataType dtClone = dt.clone(programDTM);
|
|
||||||
try {
|
|
||||||
dtClone.setCategoryPath(cat.getCategoryPath());
|
|
||||||
}
|
|
||||||
catch (DuplicateNameException e) {
|
|
||||||
Assert.fail(e.getMessage());
|
|
||||||
}
|
|
||||||
runSwing(() -> {
|
|
||||||
installProvider(new StructureEditorProvider(plugin, (Structure) dtClone, false));
|
|
||||||
model = provider.getModel();
|
|
||||||
});
|
|
||||||
waitForSwing();
|
|
||||||
|
|
||||||
getActions();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -15,8 +15,7 @@
|
||||||
*/
|
*/
|
||||||
package ghidra.app.plugin.core.compositeeditor;
|
package ghidra.app.plugin.core.compositeeditor;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import org.junit.After;
|
||||||
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
|
|
||||||
import ghidra.program.model.data.*;
|
import ghidra.program.model.data.*;
|
||||||
|
@ -40,34 +39,39 @@ public abstract class AbstractUnionEditorTest extends AbstractEditorTest {
|
||||||
ShowComponentPathAction showComponentPathAction;
|
ShowComponentPathAction showComponentPathAction;
|
||||||
HexNumbersAction hexNumbersAction;
|
HexNumbersAction hexNumbersAction;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@After
|
||||||
|
public void tearDown() throws Exception {
|
||||||
|
clearActions();
|
||||||
|
unionModel = null;
|
||||||
|
super.tearDown();
|
||||||
|
}
|
||||||
|
|
||||||
UnionEditorModel getModel() {
|
UnionEditorModel getModel() {
|
||||||
return (UnionEditorModel) model;
|
return unionModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void init(Union dt, final Category cat, final boolean showInHex) {
|
protected void init(Union dt, final Category cat, final boolean showInHex) {
|
||||||
|
|
||||||
assertEquals("Category path mismatch", dt.getCategoryPath(), cat.getCategoryPath());
|
DataTypeManager dataTypeManager = cat.getDataTypeManager();
|
||||||
|
if (dt.getDataTypeManager() != dataTypeManager) {
|
||||||
boolean commit = true;
|
dt = dt.clone(dataTypeManager);
|
||||||
startTransaction("Union Editor Test Initialization");
|
|
||||||
try {
|
|
||||||
DataTypeManager dataTypeManager = cat.getDataTypeManager();
|
|
||||||
if (dt.getDataTypeManager() != dataTypeManager) {
|
|
||||||
dt = (Union) dt.clone(dataTypeManager);
|
|
||||||
}
|
|
||||||
CategoryPath categoryPath = cat.getCategoryPath();
|
|
||||||
if (!dt.getCategoryPath().equals(categoryPath)) {
|
|
||||||
try {
|
|
||||||
dt.setCategoryPath(categoryPath);
|
|
||||||
}
|
|
||||||
catch (DuplicateNameException e) {
|
|
||||||
commit = false;
|
|
||||||
Assert.fail(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
finally {
|
|
||||||
endTransaction(commit);
|
CategoryPath categoryPath = cat.getCategoryPath();
|
||||||
|
if (!dt.getCategoryPath().equals(categoryPath)) {
|
||||||
|
// dt may or may not be a DataTypeDB but create transaction to be safe
|
||||||
|
int dtmTxId =
|
||||||
|
dataTypeManager.startTransaction("Modify Datatype Category: " + dt.getName());
|
||||||
|
try {
|
||||||
|
dt.setCategoryPath(categoryPath);
|
||||||
|
}
|
||||||
|
catch (DuplicateNameException e) {
|
||||||
|
Assert.fail(e.getMessage());
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
dataTypeManager.endTransaction(dtmTxId, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Union unionDt = dt;
|
Union unionDt = dt;
|
||||||
|
@ -81,12 +85,6 @@ public abstract class AbstractUnionEditorTest extends AbstractEditorTest {
|
||||||
unionModel = (UnionEditorModel) model;
|
unionModel = (UnionEditorModel) model;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void cleanup() {
|
|
||||||
clearActions();
|
|
||||||
runSwing(() -> provider.dispose());
|
|
||||||
unionModel = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
void clearActions() {
|
void clearActions() {
|
||||||
actions = null;
|
actions = null;
|
||||||
favorites.clear();
|
favorites.clear();
|
||||||
|
|
|
@ -22,7 +22,7 @@ import org.junit.Test;
|
||||||
import ghidra.program.model.data.*;
|
import ghidra.program.model.data.*;
|
||||||
import ghidra.util.exception.UsrException;
|
import ghidra.util.exception.UsrException;
|
||||||
|
|
||||||
public class StructureEditorLockedActions1Test extends AbstractStructureEditorLockedActionsTest {
|
public class StructureEditorLockedActions1Test extends AbstractStructureEditorTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testArrayOnSelection() throws Exception {
|
public void testArrayOnSelection() throws Exception {
|
||||||
|
|
|
@ -24,7 +24,7 @@ import org.junit.Test;
|
||||||
import docking.widgets.dialogs.NumberInputDialog;
|
import docking.widgets.dialogs.NumberInputDialog;
|
||||||
import ghidra.program.model.data.*;
|
import ghidra.program.model.data.*;
|
||||||
|
|
||||||
public class StructureEditorLockedActions2Test extends AbstractStructureEditorLockedActionsTest {
|
public class StructureEditorLockedActions2Test extends AbstractStructureEditorTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCycleGroupByteSomeRoom() throws Exception {
|
public void testCycleGroupByteSomeRoom() throws Exception {
|
||||||
|
|
|
@ -27,7 +27,7 @@ import docking.widgets.dialogs.InputDialog;
|
||||||
import docking.widgets.dialogs.NumberInputDialog;
|
import docking.widgets.dialogs.NumberInputDialog;
|
||||||
import ghidra.program.model.data.*;
|
import ghidra.program.model.data.*;
|
||||||
|
|
||||||
public class StructureEditorLockedActions3Test extends AbstractStructureEditorLockedActionsTest {
|
public class StructureEditorLockedActions3Test extends AbstractStructureEditorTest {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Edit an existing structure and create a structure from a selection. Use the conflicting
|
* Edit an existing structure and create a structure from a selection. Use the conflicting
|
||||||
|
|
|
@ -22,7 +22,7 @@ import org.junit.Test;
|
||||||
import docking.widgets.dialogs.NumberInputDialog;
|
import docking.widgets.dialogs.NumberInputDialog;
|
||||||
import ghidra.program.model.data.*;
|
import ghidra.program.model.data.*;
|
||||||
|
|
||||||
public class StructureEditorLockedActions4Test extends AbstractStructureEditorLockedActionsTest {
|
public class StructureEditorLockedActions4Test extends AbstractStructureEditorTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testArrayBeforeUndefineds() throws Exception {
|
public void testArrayBeforeUndefineds() throws Exception {
|
||||||
|
|
|
@ -23,7 +23,8 @@ import java.io.File;
|
||||||
|
|
||||||
import javax.swing.JTable;
|
import javax.swing.JTable;
|
||||||
|
|
||||||
import org.junit.*;
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
import docking.widgets.dialogs.NumberInputDialog;
|
import docking.widgets.dialogs.NumberInputDialog;
|
||||||
import ghidra.program.model.data.*;
|
import ghidra.program.model.data.*;
|
||||||
|
@ -31,7 +32,6 @@ import ghidra.program.model.listing.Function;
|
||||||
import ghidra.program.model.listing.Library;
|
import ghidra.program.model.listing.Library;
|
||||||
import ghidra.program.model.symbol.ExternalLocation;
|
import ghidra.program.model.symbol.ExternalLocation;
|
||||||
import ghidra.program.model.symbol.SourceType;
|
import ghidra.program.model.symbol.SourceType;
|
||||||
import ghidra.util.exception.DuplicateNameException;
|
|
||||||
|
|
||||||
public class StructureEditorLockedCellEditTest extends AbstractStructureEditorTest {
|
public class StructureEditorLockedCellEditTest extends AbstractStructureEditorTest {
|
||||||
|
|
||||||
|
@ -43,42 +43,6 @@ public class StructureEditorLockedCellEditTest extends AbstractStructureEditorTe
|
||||||
dir.mkdirs();
|
dir.mkdirs();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void init(Structure dt, final Category cat) {
|
|
||||||
|
|
||||||
boolean commit = true;
|
|
||||||
startTransaction("Structure Editor Test Initialization");
|
|
||||||
|
|
||||||
try {
|
|
||||||
DataTypeManager dataTypeManager = cat.getDataTypeManager();
|
|
||||||
if (dt.getDataTypeManager() != dataTypeManager) {
|
|
||||||
dt = dt.clone(dataTypeManager);
|
|
||||||
}
|
|
||||||
|
|
||||||
CategoryPath categoryPath = cat.getCategoryPath();
|
|
||||||
if (!dt.getCategoryPath().equals(categoryPath)) {
|
|
||||||
try {
|
|
||||||
dt.setCategoryPath(categoryPath);
|
|
||||||
}
|
|
||||||
catch (DuplicateNameException e) {
|
|
||||||
commit = false;
|
|
||||||
Assert.fail(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
endTransaction(commit);
|
|
||||||
}
|
|
||||||
|
|
||||||
final Structure structDt = dt;
|
|
||||||
runSwing(() -> {
|
|
||||||
installProvider(new StructureEditorProvider(plugin, structDt, false));
|
|
||||||
model = provider.getModel();
|
|
||||||
});
|
|
||||||
waitForSwing();
|
|
||||||
|
|
||||||
getActions();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testF2EditKey() throws Exception {
|
public void testF2EditKey() throws Exception {
|
||||||
init(simpleStructure, pgmBbCat);
|
init(simpleStructure, pgmBbCat);
|
||||||
|
|
|
@ -26,14 +26,6 @@ import ghidra.program.model.data.*;
|
||||||
|
|
||||||
public class StructureEditorLockedDnDTest extends AbstractStructureEditorTest {
|
public class StructureEditorLockedDnDTest extends AbstractStructureEditorTest {
|
||||||
|
|
||||||
protected void init(Structure dt, Category cat) {
|
|
||||||
super.init(dt, cat, false);
|
|
||||||
runSwing(() -> {
|
|
||||||
// model.setLocked(true);
|
|
||||||
});
|
|
||||||
// assertTrue(model.isLocked());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDragNDropAddSameSize() throws Exception {
|
public void testDragNDropAddSameSize() throws Exception {
|
||||||
init(complexStructure, pgmTestCat);
|
init(complexStructure, pgmTestCat);
|
||||||
|
|
|
@ -20,48 +20,13 @@ import static org.junit.Assert.*;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import ghidra.program.model.data.*;
|
import ghidra.program.model.data.DataTypeManager;
|
||||||
|
import ghidra.program.model.data.Structure;
|
||||||
import ghidra.util.exception.DuplicateNameException;
|
import ghidra.util.exception.DuplicateNameException;
|
||||||
import ghidra.util.task.TaskMonitor;
|
import ghidra.util.task.TaskMonitor;
|
||||||
|
|
||||||
public class StructureEditorLockedEnablementTest extends AbstractStructureEditorTest {
|
public class StructureEditorLockedEnablementTest extends AbstractStructureEditorTest {
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void init(Structure dt, final Category cat, boolean addIfNotThere) {
|
|
||||||
boolean commit = true;
|
|
||||||
startTransaction("Structure Editor Test Initialization");
|
|
||||||
try {
|
|
||||||
DataTypeManager dataTypeManager = cat.getDataTypeManager();
|
|
||||||
if (dt.getDataTypeManager() != dataTypeManager) {
|
|
||||||
dt = dt.clone(dataTypeManager);
|
|
||||||
}
|
|
||||||
CategoryPath categoryPath = cat.getCategoryPath();
|
|
||||||
if (!dt.getCategoryPath().equals(categoryPath)) {
|
|
||||||
try {
|
|
||||||
dt.setCategoryPath(categoryPath);
|
|
||||||
}
|
|
||||||
catch (DuplicateNameException e) {
|
|
||||||
commit = false;
|
|
||||||
Assert.fail(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (addIfNotThere && !dataTypeManager.contains(dt)) {
|
|
||||||
dataTypeManager.addDataType(dt, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
endTransaction(commit);
|
|
||||||
}
|
|
||||||
final Structure structDt = dt;
|
|
||||||
runSwing(() -> {
|
|
||||||
installProvider(new StructureEditorProvider(plugin, structDt, false));
|
|
||||||
model = provider.getModel();
|
|
||||||
// model.setLocked(true);
|
|
||||||
});
|
|
||||||
// assertTrue(model.isLocked());
|
|
||||||
getActions();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEmptyStructureEditorState() {
|
public void testEmptyStructureEditorState() {
|
||||||
DataTypeManager catDTM = pgmTestCat.getDataTypeManager();
|
DataTypeManager catDTM = pgmTestCat.getDataTypeManager();
|
||||||
|
@ -81,7 +46,7 @@ public class StructureEditorLockedEnablementTest extends AbstractStructureEditor
|
||||||
program.endTransaction(txID, true);
|
program.endTransaction(txID, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
init(desiredEmptyStructure, pgmTestCat, false);
|
init(desiredEmptyStructure, pgmTestCat);
|
||||||
|
|
||||||
// assertTrue(!getModel().isLocked());
|
// assertTrue(!getModel().isLocked());
|
||||||
// assertTrue(getModel().isLockable());
|
// assertTrue(getModel().isLockable());
|
||||||
|
@ -133,7 +98,7 @@ public class StructureEditorLockedEnablementTest extends AbstractStructureEditor
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNonEmptyStructureEditorState() {
|
public void testNonEmptyStructureEditorState() {
|
||||||
init(simpleStructure, pgmBbCat, false);
|
init(simpleStructure, pgmBbCat);
|
||||||
|
|
||||||
// assertTrue(getModel().isLocked());
|
// assertTrue(getModel().isLocked());
|
||||||
// assertTrue(getModel().isLockable());
|
// assertTrue(getModel().isLockable());
|
||||||
|
@ -184,7 +149,7 @@ public class StructureEditorLockedEnablementTest extends AbstractStructureEditor
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUndefinedFirstComponentSelectedEnablement() {
|
public void testUndefinedFirstComponentSelectedEnablement() {
|
||||||
init(simpleStructure, pgmBbCat, true);
|
init(simpleStructure, pgmBbCat);
|
||||||
|
|
||||||
// Check enablement on first component selected.
|
// Check enablement on first component selected.
|
||||||
setSelection(new int[] { 0 });
|
setSelection(new int[] { 0 });
|
||||||
|
@ -215,7 +180,7 @@ public class StructureEditorLockedEnablementTest extends AbstractStructureEditor
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCentralComponentSelectedEnablement() {
|
public void testCentralComponentSelectedEnablement() {
|
||||||
init(simpleStructure, pgmBbCat, true);
|
init(simpleStructure, pgmBbCat);
|
||||||
|
|
||||||
// Check enablement on central component selected.
|
// Check enablement on central component selected.
|
||||||
setSelection(new int[] { 3 });
|
setSelection(new int[] { 3 });
|
||||||
|
@ -245,7 +210,7 @@ public class StructureEditorLockedEnablementTest extends AbstractStructureEditor
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLastComponentSelectedEnablement() {
|
public void testLastComponentSelectedEnablement() {
|
||||||
init(simpleStructure, pgmBbCat, true);
|
init(simpleStructure, pgmBbCat);
|
||||||
|
|
||||||
int last = getModel().getNumComponents() - 1;
|
int last = getModel().getNumComponents() - 1;
|
||||||
|
|
||||||
|
@ -275,7 +240,7 @@ public class StructureEditorLockedEnablementTest extends AbstractStructureEditor
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testContiguousSelectionEnablement() {
|
public void testContiguousSelectionEnablement() {
|
||||||
init(complexStructure, pgmTestCat, true);
|
init(complexStructure, pgmTestCat);
|
||||||
|
|
||||||
// Check enablement on a contiguous multi-component selection.
|
// Check enablement on a contiguous multi-component selection.
|
||||||
setSelection(new int[] { 2, 3, 4 });
|
setSelection(new int[] { 2, 3, 4 });
|
||||||
|
@ -304,7 +269,7 @@ public class StructureEditorLockedEnablementTest extends AbstractStructureEditor
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNonContiguousSelectionEnablement() {
|
public void testNonContiguousSelectionEnablement() {
|
||||||
init(complexStructure, pgmTestCat, true);
|
init(complexStructure, pgmTestCat);
|
||||||
|
|
||||||
// Check enablement on a non-contiguous multi-component selection.
|
// Check enablement on a non-contiguous multi-component selection.
|
||||||
setSelection(new int[] { 2, 3, 6, 7 });
|
setSelection(new int[] { 2, 3, 6, 7 });
|
||||||
|
@ -329,7 +294,7 @@ public class StructureEditorLockedEnablementTest extends AbstractStructureEditor
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMultiDupEnablement() throws Exception {
|
public void testMultiDupEnablement() throws Exception {
|
||||||
init(complexStructure, pgmBbCat, true);
|
init(complexStructure, pgmBbCat);
|
||||||
model.clearComponents(new int[] { 3, 10 });
|
model.clearComponents(new int[] { 3, 10 });
|
||||||
|
|
||||||
setSelection(new int[] { 0 });
|
setSelection(new int[] { 0 });
|
||||||
|
@ -376,7 +341,7 @@ public class StructureEditorLockedEnablementTest extends AbstractStructureEditor
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUnpackageEnablement() {
|
public void testUnpackageEnablement() {
|
||||||
init(complexStructure, pgmBbCat, true);
|
init(complexStructure, pgmBbCat);
|
||||||
|
|
||||||
setSelection(new int[] { 2 });
|
setSelection(new int[] { 2 });
|
||||||
assertEquals("word", getDataType(2).getDisplayName());
|
assertEquals("word", getDataType(2).getDisplayName());
|
||||||
|
|
|
@ -19,8 +19,7 @@ import static org.junit.Assert.*;
|
||||||
|
|
||||||
import java.awt.Window;
|
import java.awt.Window;
|
||||||
|
|
||||||
import org.junit.Assert;
|
import org.junit.*;
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import ghidra.program.model.data.*;
|
import ghidra.program.model.data.*;
|
||||||
import ghidra.util.Swing;
|
import ghidra.util.Swing;
|
||||||
|
@ -29,42 +28,24 @@ import ghidra.util.task.TaskMonitor;
|
||||||
|
|
||||||
public class StructureEditorNotifiedTest extends AbstractStructureEditorTest {
|
public class StructureEditorNotifiedTest extends AbstractStructureEditorTest {
|
||||||
|
|
||||||
protected void init(Structure dt, final Category cat) {
|
private int persistentTxId = 0;
|
||||||
boolean commit = true;
|
|
||||||
startTransaction("Structure Editor Test Initialization");
|
|
||||||
try {
|
|
||||||
DataTypeManager dataTypeManager = cat.getDataTypeManager();
|
|
||||||
if (dt.getDataTypeManager() != dataTypeManager) {
|
|
||||||
dt = dt.clone(dataTypeManager);
|
|
||||||
}
|
|
||||||
CategoryPath categoryPath = cat.getCategoryPath();
|
|
||||||
if (!dt.getCategoryPath().equals(categoryPath)) {
|
|
||||||
try {
|
|
||||||
dt.setCategoryPath(categoryPath);
|
|
||||||
}
|
|
||||||
catch (DuplicateNameException e) {
|
|
||||||
commit = false;
|
|
||||||
Assert.fail(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
endTransaction(commit);
|
|
||||||
}
|
|
||||||
|
|
||||||
Structure structDt = dt;
|
@Override
|
||||||
runSwing(() -> {
|
@Before
|
||||||
installProvider(new StructureEditorProvider(plugin, structDt, false));
|
public void setUp() throws Exception {
|
||||||
});
|
super.setUp();
|
||||||
|
|
||||||
model = provider.getModel();
|
// Create overlapping trasnaction to handle all changes
|
||||||
startTransaction("Modify Program");
|
persistentTxId = program.startTransaction("Modify Program");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void cleanup() {
|
@After
|
||||||
endTransaction(false);
|
public void tearDown() throws Exception {
|
||||||
provider.dispose();
|
if (persistentTxId != 0) {
|
||||||
|
program.endTransaction(persistentTxId, true);
|
||||||
|
}
|
||||||
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -23,7 +23,7 @@ import docking.widgets.dialogs.NumberInputDialog;
|
||||||
import ghidra.program.model.data.*;
|
import ghidra.program.model.data.*;
|
||||||
|
|
||||||
public class StructureEditorUnlockedActions1Test
|
public class StructureEditorUnlockedActions1Test
|
||||||
extends AbstractStructureEditorUnlockedActionsTest {
|
extends AbstractStructureEditorTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCycleGroupOnComponent() throws Exception {
|
public void testCycleGroupOnComponent() throws Exception {
|
||||||
|
|
|
@ -23,7 +23,7 @@ import docking.widgets.dialogs.NumberInputDialog;
|
||||||
import ghidra.program.model.data.*;
|
import ghidra.program.model.data.*;
|
||||||
|
|
||||||
public class StructureEditorUnlockedActions2Test
|
public class StructureEditorUnlockedActions2Test
|
||||||
extends AbstractStructureEditorUnlockedActionsTest {
|
extends AbstractStructureEditorTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreatePointerOnStructPointer() {
|
public void testCreatePointerOnStructPointer() {
|
||||||
|
|
|
@ -29,7 +29,7 @@ import docking.widgets.dialogs.NumberInputDialog;
|
||||||
import ghidra.program.model.data.*;
|
import ghidra.program.model.data.*;
|
||||||
|
|
||||||
public class StructureEditorUnlockedActions3Test
|
public class StructureEditorUnlockedActions3Test
|
||||||
extends AbstractStructureEditorUnlockedActionsTest {
|
extends AbstractStructureEditorTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDuplicateMultipleAction() throws Exception {
|
public void testDuplicateMultipleAction() throws Exception {
|
||||||
|
|
|
@ -28,7 +28,7 @@ import ghidra.program.model.data.*;
|
||||||
import ghidra.util.exception.UsrException;
|
import ghidra.util.exception.UsrException;
|
||||||
|
|
||||||
public class StructureEditorUnlockedActions4Test
|
public class StructureEditorUnlockedActions4Test
|
||||||
extends AbstractStructureEditorUnlockedActionsTest {
|
extends AbstractStructureEditorTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testChangeSizeToZero() throws Exception {
|
public void testChangeSizeToZero() throws Exception {
|
||||||
|
|
|
@ -32,7 +32,7 @@ import ghidra.util.exception.DuplicateNameException;
|
||||||
import ghidra.util.exception.UsrException;
|
import ghidra.util.exception.UsrException;
|
||||||
|
|
||||||
public class StructureEditorUnlockedActions5Test
|
public class StructureEditorUnlockedActions5Test
|
||||||
extends AbstractStructureEditorUnlockedActionsTest {
|
extends AbstractStructureEditorTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testApplyDuplicateName() throws Exception {
|
public void testApplyDuplicateName() throws Exception {
|
||||||
|
|
|
@ -27,7 +27,7 @@ import docking.widgets.dialogs.NumberInputDialog;
|
||||||
import ghidra.program.model.data.*;
|
import ghidra.program.model.data.*;
|
||||||
|
|
||||||
public class StructureEditorUnlockedActions6Test
|
public class StructureEditorUnlockedActions6Test
|
||||||
extends AbstractStructureEditorUnlockedActionsTest {
|
extends AbstractStructureEditorTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testArrayOnArray() throws Exception {
|
public void testArrayOnArray() throws Exception {
|
||||||
|
|
|
@ -23,7 +23,7 @@ import docking.widgets.dialogs.NumberInputDialog;
|
||||||
import ghidra.program.model.data.DataType;
|
import ghidra.program.model.data.DataType;
|
||||||
|
|
||||||
public class StructureEditorUnlockedCellEdit1Test
|
public class StructureEditorUnlockedCellEdit1Test
|
||||||
extends AbstractStructureEditorUnlockedCellEditTest {
|
extends AbstractStructureEditorTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEditDynamicDataTypeAtLastComponent() throws Exception {
|
public void testEditDynamicDataTypeAtLastComponent() throws Exception {
|
||||||
|
|
|
@ -28,7 +28,7 @@ import generic.test.ConcurrentTestExceptionHandler;
|
||||||
import ghidra.program.model.data.*;
|
import ghidra.program.model.data.*;
|
||||||
|
|
||||||
public class StructureEditorUnlockedCellEdit2Test
|
public class StructureEditorUnlockedCellEdit2Test
|
||||||
extends AbstractStructureEditorUnlockedCellEditTest {
|
extends AbstractStructureEditorTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testF2EditKey() throws Exception {
|
public void testF2EditKey() throws Exception {
|
||||||
|
|
|
@ -21,7 +21,7 @@ import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import docking.widgets.dialogs.NumberInputDialog;
|
import docking.widgets.dialogs.NumberInputDialog;
|
||||||
import ghidra.program.model.data.*;
|
import ghidra.program.model.data.DataType;
|
||||||
|
|
||||||
public class StructureEditorUnlockedDnD1Test extends AbstractStructureEditorTest {
|
public class StructureEditorUnlockedDnD1Test extends AbstractStructureEditorTest {
|
||||||
|
|
||||||
|
@ -32,10 +32,6 @@ public class StructureEditorUnlockedDnD1Test extends AbstractStructureEditorTest
|
||||||
env.showTool();
|
env.showTool();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void init(Structure dt, Category cat) {
|
|
||||||
super.init(dt, cat, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDragNDropCancelStringDrop() throws Exception {
|
public void testDragNDropCancelStringDrop() throws Exception {
|
||||||
NumberInputDialog dialog = null;
|
NumberInputDialog dialog = null;
|
||||||
|
|
|
@ -25,9 +25,6 @@ import ghidra.program.model.data.*;
|
||||||
|
|
||||||
public class StructureEditorUnlockedDnD2Test extends AbstractStructureEditorTest {
|
public class StructureEditorUnlockedDnD2Test extends AbstractStructureEditorTest {
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see junit.framework.TestCase#setUp()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
|
@ -35,14 +32,6 @@ public class StructureEditorUnlockedDnD2Test extends AbstractStructureEditorTest
|
||||||
env.showTool();
|
env.showTool();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void init(Structure dt, Category cat) {
|
|
||||||
super.init(dt, cat, false);
|
|
||||||
runSwing(() -> {
|
|
||||||
// model.setLocked(false);
|
|
||||||
});
|
|
||||||
// assertTrue(!model.isLocked());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDragNDropAddDifferentTypes() throws Exception {
|
public void testDragNDropAddDifferentTypes() throws Exception {
|
||||||
NumberInputDialog dialog;
|
NumberInputDialog dialog;
|
||||||
|
|
|
@ -21,13 +21,10 @@ import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import docking.widgets.dialogs.NumberInputDialog;
|
import docking.widgets.dialogs.NumberInputDialog;
|
||||||
import ghidra.program.model.data.*;
|
import ghidra.program.model.data.DataType;
|
||||||
|
|
||||||
public class StructureEditorUnlockedDnD3Test extends AbstractStructureEditorTest {
|
public class StructureEditorUnlockedDnD3Test extends AbstractStructureEditorTest {
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see junit.framework.TestCase#setUp()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
|
@ -35,14 +32,6 @@ public class StructureEditorUnlockedDnD3Test extends AbstractStructureEditorTest
|
||||||
env.showTool();
|
env.showTool();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void init(Structure dt, Category cat) {
|
|
||||||
super.init(dt, cat, false);
|
|
||||||
runSwing(() -> {
|
|
||||||
// model.setLocked(false);
|
|
||||||
});
|
|
||||||
// assertTrue(!model.isLocked());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDragNDropInsertDifferentTypes() throws Exception {
|
public void testDragNDropInsertDifferentTypes() throws Exception {
|
||||||
NumberInputDialog dialog = null;
|
NumberInputDialog dialog = null;
|
||||||
|
|
|
@ -24,9 +24,6 @@ import ghidra.program.model.data.*;
|
||||||
|
|
||||||
public class StructureEditorUnlockedDnD4Test extends AbstractStructureEditorTest {
|
public class StructureEditorUnlockedDnD4Test extends AbstractStructureEditorTest {
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see junit.framework.TestCase#setUp()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
|
@ -34,14 +31,6 @@ public class StructureEditorUnlockedDnD4Test extends AbstractStructureEditorTest
|
||||||
env.showTool();
|
env.showTool();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void init(Structure dt, Category cat) {
|
|
||||||
super.init(dt, cat, false);
|
|
||||||
runSwing(() -> {
|
|
||||||
// model.setLocked(false);
|
|
||||||
});
|
|
||||||
// assertTrue(!model.isLocked());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDragNDropAddFirstMiddleLast() throws Exception {
|
public void testDragNDropAddFirstMiddleLast() throws Exception {
|
||||||
init(complexStructure, pgmTestCat);
|
init(complexStructure, pgmTestCat);
|
||||||
|
|
|
@ -17,47 +17,12 @@ package ghidra.app.plugin.core.compositeeditor;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
import org.junit.Assert;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import ghidra.program.model.data.*;
|
import ghidra.program.model.data.*;
|
||||||
import ghidra.util.exception.DuplicateNameException;
|
|
||||||
|
|
||||||
public class StructureEditorUnlockedEnablementTest extends AbstractStructureEditorTest {
|
public class StructureEditorUnlockedEnablementTest extends AbstractStructureEditorTest {
|
||||||
|
|
||||||
protected void init(Structure dt, final Category cat) {
|
|
||||||
boolean commit = true;
|
|
||||||
startTransaction("Structure Editor Test Initialization");
|
|
||||||
try {
|
|
||||||
DataTypeManager dataTypeManager = cat.getDataTypeManager();
|
|
||||||
if (dt.getDataTypeManager() != dataTypeManager) {
|
|
||||||
dt = dt.clone(dataTypeManager);
|
|
||||||
}
|
|
||||||
CategoryPath categoryPath = cat.getCategoryPath();
|
|
||||||
if (!dt.getCategoryPath().equals(categoryPath)) {
|
|
||||||
try {
|
|
||||||
dt.setCategoryPath(categoryPath);
|
|
||||||
}
|
|
||||||
catch (DuplicateNameException e) {
|
|
||||||
commit = false;
|
|
||||||
Assert.fail(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
endTransaction(commit);
|
|
||||||
}
|
|
||||||
final Structure structDt = dt;
|
|
||||||
runSwing(() -> {
|
|
||||||
installProvider(new StructureEditorProvider(plugin, structDt, false));
|
|
||||||
model = provider.getModel();
|
|
||||||
structureModel = (StructureEditorModel) model;
|
|
||||||
// model.setLocked(false);
|
|
||||||
});
|
|
||||||
// assertTrue(!model.isLocked());
|
|
||||||
getActions();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEmptyStructureEditorState() {
|
public void testEmptyStructureEditorState() {
|
||||||
init(emptyStructure, pgmTestCat);
|
init(emptyStructure, pgmTestCat);
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -135,7 +135,6 @@ public class UnionEditorProviderTest extends AbstractUnionEditorTest {
|
||||||
finally {
|
finally {
|
||||||
dialog = null;
|
dialog = null;
|
||||||
program.removeListener(restoreListener);
|
program.removeListener(restoreListener);
|
||||||
cleanup();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,7 +174,6 @@ public class UnionEditorProviderTest extends AbstractUnionEditorTest {
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
program.removeListener(restoreListener);
|
program.removeListener(restoreListener);
|
||||||
cleanup();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1384,7 +1384,10 @@ public abstract class AbstractGenericTest extends AbstractGTest {
|
||||||
public static TableCellEditor editCell(final JTable table, final int row, final int col) {
|
public static TableCellEditor editCell(final JTable table, final int row, final int col) {
|
||||||
|
|
||||||
waitForSwing();
|
waitForSwing();
|
||||||
|
|
||||||
runSwing(() -> table.setRowSelectionInterval(row, row));
|
runSwing(() -> table.setRowSelectionInterval(row, row));
|
||||||
|
waitForSwing();
|
||||||
|
|
||||||
runSwing(() -> table.editCellAt(row, col));
|
runSwing(() -> table.editCellAt(row, col));
|
||||||
waitForSwing();
|
waitForSwing();
|
||||||
|
|
||||||
|
|
|
@ -300,16 +300,19 @@ abstract class DataTypeDB extends DatabaseObject implements DataType {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setName(String name) throws InvalidNameException, DuplicateNameException {
|
public void setName(String newName) throws InvalidNameException, DuplicateNameException {
|
||||||
lock.acquire();
|
lock.acquire();
|
||||||
try {
|
try {
|
||||||
checkDeleted();
|
checkDeleted();
|
||||||
|
if (getName().equals(newName)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
CategoryPath categoryPath = getCategoryPath();
|
CategoryPath categoryPath = getCategoryPath();
|
||||||
if (dataMgr.getDataType(categoryPath, name) != null) {
|
if (dataMgr.getDataType(categoryPath, newName) != null) {
|
||||||
throw new DuplicateNameException("DataType named " + name +
|
throw new DuplicateNameException("DataType named " + newName +
|
||||||
" already exists in category " + categoryPath.getPath());
|
" already exists in category " + categoryPath.getPath());
|
||||||
}
|
}
|
||||||
doSetName(name);
|
doSetName(newName);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
lock.release();
|
lock.release();
|
||||||
|
@ -338,9 +341,12 @@ abstract class DataTypeDB extends DatabaseObject implements DataType {
|
||||||
lock.acquire();
|
lock.acquire();
|
||||||
try {
|
try {
|
||||||
checkDeleted();
|
checkDeleted();
|
||||||
DataType type = dataMgr.getDataType(path, getName());
|
if (getCategoryPath().equals(path)) {
|
||||||
if (type != null) {
|
return;
|
||||||
throw new DuplicateNameException("DataType named " + getDisplayName() +
|
}
|
||||||
|
String currentName = getName();
|
||||||
|
if (dataMgr.getDataType(path, currentName) != null) {
|
||||||
|
throw new DuplicateNameException("DataType named " + currentName +
|
||||||
" already exists in category " + path.getPath());
|
" already exists in category " + path.getPath());
|
||||||
}
|
}
|
||||||
doSetCategoryPath(path);
|
doSetCategoryPath(path);
|
||||||
|
@ -374,7 +380,11 @@ abstract class DataTypeDB extends DatabaseObject implements DataType {
|
||||||
lock.acquire();
|
lock.acquire();
|
||||||
try {
|
try {
|
||||||
checkDeleted();
|
checkDeleted();
|
||||||
if (dataMgr.getDataType(path, name) != null) {
|
DataType dt = dataMgr.getDataType(path, name);
|
||||||
|
if (dt != null) {
|
||||||
|
if (dt == this) {
|
||||||
|
return; // unchanged
|
||||||
|
}
|
||||||
throw new DuplicateNameException(
|
throw new DuplicateNameException(
|
||||||
"DataType named " + name + " already exists in category " + path.getPath());
|
"DataType named " + name + " already exists in category " + path.getPath());
|
||||||
}
|
}
|
||||||
|
|
|
@ -393,6 +393,9 @@ class EnumDB extends DataTypeDB implements Enum {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataType clone(DataTypeManager dtm) {
|
public DataType clone(DataTypeManager dtm) {
|
||||||
|
if (dtm == getDataTypeManager()) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
EnumDataType enumDataType =
|
EnumDataType enumDataType =
|
||||||
new EnumDataType(getCategoryPath(), getName(), getLength(), getUniversalID(),
|
new EnumDataType(getCategoryPath(), getName(), getLength(), getUniversalID(),
|
||||||
getSourceArchive(), getLastChangeTime(), getLastChangeTimeInSourceArchive(), dtm);
|
getSourceArchive(), getLastChangeTime(), getLastChangeTimeInSourceArchive(), dtm);
|
||||||
|
|
|
@ -223,6 +223,9 @@ class FunctionDefinitionDB extends DataTypeDB implements FunctionDefinition {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataType clone(DataTypeManager dtm) {
|
public DataType clone(DataTypeManager dtm) {
|
||||||
|
if (dtm == getDataTypeManager()) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
return new FunctionDefinitionDataType(getCategoryPath(), getName(), this, getUniversalID(),
|
return new FunctionDefinitionDataType(getCategoryPath(), getName(), this, getUniversalID(),
|
||||||
getSourceArchive(), getLastChangeTime(), getLastChangeTimeInSourceArchive(), dtm);
|
getSourceArchive(), getLastChangeTime(), getLastChangeTimeInSourceArchive(), dtm);
|
||||||
}
|
}
|
||||||
|
|
|
@ -806,6 +806,9 @@ class StructureDB extends CompositeDB implements StructureInternal {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Structure clone(DataTypeManager dtm) {
|
public Structure clone(DataTypeManager dtm) {
|
||||||
|
if (dtm == getDataTypeManager()) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
StructureDataType struct =
|
StructureDataType struct =
|
||||||
new StructureDataType(getCategoryPath(), getName(), structLength, getUniversalID(),
|
new StructureDataType(getCategoryPath(), getName(), structLength, getUniversalID(),
|
||||||
getSourceArchive(), getLastChangeTime(), getLastChangeTimeInSourceArchive(), dtm);
|
getSourceArchive(), getLastChangeTime(), getLastChangeTimeInSourceArchive(), dtm);
|
||||||
|
|
|
@ -440,6 +440,9 @@ class UnionDB extends CompositeDB implements UnionInternal {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Union clone(DataTypeManager dtm) {
|
public Union clone(DataTypeManager dtm) {
|
||||||
|
if (dtm == getDataTypeManager()) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
UnionDataType union = new UnionDataType(getCategoryPath(), getName(), getUniversalID(),
|
UnionDataType union = new UnionDataType(getCategoryPath(), getName(), getUniversalID(),
|
||||||
getSourceArchive(), getLastChangeTime(), getLastChangeTimeInSourceArchive(), dtm);
|
getSourceArchive(), getLastChangeTime(), getLastChangeTimeInSourceArchive(), dtm);
|
||||||
union.setDescription(getDescription());
|
union.setDescription(getDescription());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue