use of edu.cmu.cs.hcii.cogtool.ui.FrameSelectionState in project cogtool by cogtool.
the class DesignEditorController method createEditFrameAction.
protected IListenerAction createEditFrameAction() {
return new IListenerAction() {
public Class<?> getParameterClass() {
return FrameSelectionState.class;
}
public boolean performAction(Object prms) {
FrameSelectionState selection = (FrameSelectionState) prms;
Frame[] frames = selection.getSelectedFrames();
if ((frames == null) || (frames.length == 0)) {
interaction.protestNoSelection();
return false;
}
for (Frame frame : frames) {
try {
FrameEditorController.openController(frame, design, project);
} catch (GraphicsUtil.ImageException ex) {
interaction.protestInvalidImageFile();
}
}
return true;
}
};
}
use of edu.cmu.cs.hcii.cogtool.ui.FrameSelectionState in project cogtool by cogtool.
the class DesignEditorController method createCopyFrameAction.
protected IListenerAction createCopyFrameAction() {
return new IListenerAction() {
public Class<?> getParameterClass() {
return FrameSelectionState.class;
}
public boolean performAction(Object prms) {
FrameSelectionState seln = (FrameSelectionState) prms;
Frame[] frames = seln.getSelectedFrames();
if ((frames != null) && (frames.length > 0)) {
copyFrames(frames);
if (frames.length == 1) {
interaction.setStatusMessage(FRAME_COPIED);
} else {
interaction.setStatusMessage(FRAMES_COPIED);
}
return true;
}
interaction.protestNoSelection();
return false;
}
};
}
use of edu.cmu.cs.hcii.cogtool.ui.FrameSelectionState in project cogtool by cogtool.
the class DesignEditorController method createSetBackgroundImageAction.
/**
* Create a ListenerAction to handle setting frame background image on
* multiple frames
*/
protected IListenerAction createSetBackgroundImageAction() {
return new IListenerAction() {
public Class<?> getParameterClass() {
return FrameSelectionState.class;
}
public boolean performAction(Object prms) {
// Get selected frames from parameters
FrameSelectionState seln = (FrameSelectionState) prms;
Frame[] frames = seln.getSelectedFrames();
// this code is from FrameEditorController
// load image
// Pull up interaction to select a file
String imageURL = interaction.selectImageFile();
// Check if the dialog was cancelled
if (imageURL != null) {
byte[] imageData;
try {
// Set the background to new image
imageData = GraphicsUtil.loadImageFromFile(imageURL);
setBackgroundImageOnFrames(frames, imageData, imageURL, DesignEditorLID.SetBackgroundImage);
return true;
} catch (IOException e) {
interaction.protestUnreadableFile();
imageData = null;
}
}
return false;
}
};
}
use of edu.cmu.cs.hcii.cogtool.ui.FrameSelectionState in project cogtool by cogtool.
the class DesignEditorController method createDeleteFrameAction.
// createNewTransition
protected IListenerAction createDeleteFrameAction() {
return new IListenerAction() {
public Class<?> getParameterClass() {
return FrameSelectionState.class;
}
public boolean performAction(Object prms) {
FrameSelectionState selection = (FrameSelectionState) prms;
Frame[] frames = selection.getSelectedFrames();
if ((frames != null) && (frames.length > 0)) {
if (interaction.confirmDeleteFrames(frames)) {
deleteFrames(frames);
return true;
}
} else {
interaction.protestNoSelection();
}
return false;
}
};
}
Aggregations