import java.awt.Component;
import java.awt.Container;
import java.awt.GraphicsEnvironment;
+import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
public final class SwingView implements GraphicView {
public static final String NULLUUID = new UUID(0L, 0L).toString();
-
private static SwingView me;
-
private static boolean headless;
-
private Map<String, TypedObject> allObjects;
/**
};
private static final Set<Integer> managedTypes = new HashSet<Integer>(Arrays.asList(
- GraphicObjectProperties.__GO_FIGURE__,
- GraphicObjectProperties.__GO_UICONTEXTMENU__,
- GraphicObjectProperties.__GO_UIMENU__,
- GraphicObjectProperties.__GO_CONSOLE__,
- GraphicObjectProperties.__GO_PROGRESSIONBAR__,
- GraphicObjectProperties.__GO_WAITBAR__,
- GraphicObjectProperties.__GO_UICONTROL__
+ GraphicObjectProperties.__GO_FIGURE__,
+ GraphicObjectProperties.__GO_UICONTEXTMENU__,
+ GraphicObjectProperties.__GO_UIMENU__,
+ GraphicObjectProperties.__GO_CONSOLE__,
+ GraphicObjectProperties.__GO_PROGRESSIONBAR__,
+ GraphicObjectProperties.__GO_WAITBAR__,
+ GraphicObjectProperties.__GO_UICONTROL__
));
+
@Override
public void createObject(String id) {
private UielementType StyleToEnum(int style) {
DEBUG("SwingView", "StyleToEnum(" + style + ")");
switch (style) {
- case __GO_FIGURE__ :
- return UielementType.Figure;
- case __GO_CONSOLE__ :
- return UielementType.Console;
- case __GO_UI_CHECKBOX__ :
- return UielementType.CheckBox;
- case __GO_UI_EDIT__ :
- return UielementType.Edit;
- case __GO_UI_FRAME__ :
- return UielementType.Frame;
- case __GO_UI_IMAGE__ :
- return UielementType.Image;
- case __GO_UI_LISTBOX__ :
- return UielementType.ListBox;
- case __GO_UI_POPUPMENU__ :
- return UielementType.PopupMenu;
- case __GO_UI_PUSHBUTTON__ :
- return UielementType.PushButton;
- case __GO_UI_RADIOBUTTON__ :
- return UielementType.RadioButton;
- case __GO_UI_SLIDER__ :
- return UielementType.Slider;
- case __GO_UI_TABLE__ :
- return UielementType.Table;
- case __GO_UI_TEXT__ :
- return UielementType.Text;
- case __GO_UIMENU__ :
- return UielementType.UiChildMenu;
- case __GO_UIPARENTMENU__ :
- return UielementType.UiParentMenu;
- case __GO_UICHILDMENU__ :
- return UielementType.UiChildMenu;
- case __GO_UICHECKEDMENU__ :
- return UielementType.UiCheckedMenu;
- case __GO_PROGRESSIONBAR__ :
- return UielementType.Progressbar;
- case __GO_WAITBAR__ :
- return UielementType.Waitbar;
- case __GO_UICONTEXTMENU__ :
- return UielementType.UiContextMenu;
+ case __GO_FIGURE__ :
+ return UielementType.Figure;
+ case __GO_CONSOLE__ :
+ return UielementType.Console;
+ case __GO_UI_CHECKBOX__ :
+ return UielementType.CheckBox;
+ case __GO_UI_EDIT__ :
+ return UielementType.Edit;
+ case __GO_UI_FRAME__ :
+ return UielementType.Frame;
+ case __GO_UI_IMAGE__ :
+ return UielementType.Image;
+ case __GO_UI_LISTBOX__ :
+ return UielementType.ListBox;
+ case __GO_UI_POPUPMENU__ :
+ return UielementType.PopupMenu;
+ case __GO_UI_PUSHBUTTON__ :
+ return UielementType.PushButton;
+ case __GO_UI_RADIOBUTTON__ :
+ return UielementType.RadioButton;
+ case __GO_UI_SLIDER__ :
+ return UielementType.Slider;
+ case __GO_UI_TABLE__ :
+ return UielementType.Table;
+ case __GO_UI_TEXT__ :
+ return UielementType.Text;
+ case __GO_UIMENU__ :
+ return UielementType.UiChildMenu;
+ case __GO_UIPARENTMENU__ :
+ return UielementType.UiParentMenu;
+ case __GO_UICHILDMENU__ :
+ return UielementType.UiChildMenu;
+ case __GO_UICHECKEDMENU__ :
+ return UielementType.UiCheckedMenu;
+ case __GO_PROGRESSIONBAR__ :
+ return UielementType.Progressbar;
+ case __GO_WAITBAR__ :
+ return UielementType.Waitbar;
+ case __GO_UICONTEXTMENU__ :
+ return UielementType.UiContextMenu;
}
return null;
}
- private TypedObject CreateObjectFromType(int type, String id) {
+ private TypedObject CreateObjectFromType(final int type, final String id) {
UielementType enumType = StyleToEnum(type);
return new TypedObject(enumType, CreateObjectFromType(enumType, id));
}
private SwingViewObject CreateObjectFromType(UielementType type, String id) {
switch (type) {
- case CheckBox:
- SwingScilabCheckBox checkBox = new SwingScilabCheckBox();
- checkBox.setId(id);
- setDefaultProperties(checkBox, id);
- return checkBox;
- case Console:
- Console console = (Console) GraphicController.getController().getObjectFromId(id);
- if (console.getScilabMode() == Console.ScilabMode.STD) {
- WindowsConfigurationManager.restoreUUID(NULLUUID);
- SwingScilabConsole sciConsole = ((SwingScilabConsole) ScilabConsole.getConsole().getAsSimpleConsole());
- SwingScilabTab consoleTab = (SwingScilabTab) sciConsole.getParent();
- consoleTab.setId(id);
- return consoleTab;
- } else {
- return null;
- }
- case Edit:
- SwingScilabEditBox edit = new SwingScilabEditBox();
- edit.setId(id);
- setDefaultProperties(edit, id);
- return edit;
- case Figure:
- Figure figure = (Figure) GraphicController.getController().getObjectFromId(id);
- String figureTitle = figure.getName();
- Integer figureId = figure.getId();
- if ((figureTitle != null) && (figureId != null)) {
- figureTitle = figureTitle.replaceFirst("%d", figureId.toString());
- }
+ case CheckBox:
+ SwingScilabCheckBox checkBox = new SwingScilabCheckBox();
+ checkBox.setId(id);
+ setDefaultProperties(checkBox, id);
+ return checkBox;
+ case Console:
+ Console console = (Console) GraphicController.getController().getObjectFromId(id);
+ if (console.getScilabMode() == Console.ScilabMode.STD) {
+ WindowsConfigurationManager.restoreUUID(NULLUUID);
+ SwingScilabConsole sciConsole = ((SwingScilabConsole) ScilabConsole.getConsole().getAsSimpleConsole());
+ SwingScilabTab consoleTab = (SwingScilabTab) sciConsole.getParent();
+ consoleTab.setId(id);
+ return consoleTab;
+ } else {
+ return null;
+ }
+ case Edit:
+ SwingScilabEditBox edit = new SwingScilabEditBox();
+ edit.setId(id);
+ setDefaultProperties(edit, id);
+ return edit;
+ case Figure:
+ Figure figure = (Figure) GraphicController.getController().getObjectFromId(id);
+ String figureTitle = figure.getName();
+ Integer figureId = figure.getId();
+ if ((figureTitle != null) && (figureId != null)) {
+ figureTitle = figureTitle.replaceFirst("%d", figureId.toString());
+ }
- SwingScilabWindow window = new SwingScilabWindow();
+ SwingScilabWindow window = new SwingScilabWindow();
- window.setTitle(figureTitle);
- /* TOOLBAR */
- ToolBar toolBar = ToolBarBuilder.buildToolBar(SwingScilabTab.GRAPHICS_TOOLBAR_DESCRIPTOR, figureId);
- /* INFOBAR */
- TextBox infoBar = ScilabTextBox.createTextBox();
+ window.setTitle(figureTitle);
+ /* TOOLBAR */
+ ToolBar toolBar = ToolBarBuilder.buildToolBar(SwingScilabTab.GRAPHICS_TOOLBAR_DESCRIPTOR, figureId);
+ /* INFOBAR */
+ TextBox infoBar = ScilabTextBox.createTextBox();
- SwingScilabTab tab = new SwingScilabTab(figureTitle, figureId, figure);
- tab.setId(id);
+ SwingScilabTab tab = new SwingScilabTab(figureTitle, figureId, figure);
+ tab.setId(id);
- tab.setMenuBar(ScilabMenuBar.createMenuBar());
- tab.setToolBar(toolBar);
- tab.setInfoBar(ScilabTextBox.createTextBox());
- window.addMenuBar(tab.getMenuBar());
- window.addToolBar(tab.getToolBar());
- window.addInfoBar(tab.getInfoBar());
+ tab.setMenuBar(ScilabMenuBar.createMenuBar());
+ tab.setToolBar(toolBar);
+ tab.setInfoBar(ScilabTextBox.createTextBox());
+ window.addMenuBar(tab.getMenuBar());
+ window.addToolBar(tab.getToolBar());
+ window.addInfoBar(tab.getInfoBar());
- tab.setWindowIcon("graphic-window");
+ tab.setWindowIcon("graphic-window");
- tab.setParentWindowId(window.getId());
+ tab.setParentWindowId(window.getId());
- tab.setEventHandler(figure.getEventHandlerString());
- tab.setEventHandlerEnabled(figure.getEventHandlerEnable());
+ tab.setEventHandler(figure.getEventHandlerString());
+ tab.setEventHandlerEnabled(figure.getEventHandlerEnable());
- DockingManager.dock(tab, window.getDockingPort());
- ActiveDockableTracker.requestDockableActivation(tab);
+ DockingManager.dock(tab, window.getDockingPort());
+ ActiveDockableTracker.requestDockableActivation(tab);
- window.setVisible(true);
- tab.setVisible(true);
- tab.setName(figureTitle);
+ window.setVisible(true);
+ tab.setVisible(true);
+ tab.setName(figureTitle);
- String infoMessage = figure.getInfoMessage();
- if ((infoMessage == null) || (infoMessage.length() == 0)) {
- infoBar.setText("");
- } else {
- infoBar.setText(infoMessage);
- }
- tab.update(__GO_SIZE__, (Integer[]) GraphicController.getController().getProperty(id, __GO_SIZE__));
- tab.update(__GO_POSITION__, (Integer[]) GraphicController.getController().getProperty(id, __GO_POSITION__));
- // TODO set other default properties
- return tab;
- case Frame:
- SwingScilabFrame frame = new SwingScilabFrame();
- frame.setId(id);
- setDefaultProperties(frame, id);
- return frame;
- case Image:
- SwingScilabUiImage image = new SwingScilabUiImage();
- image.setId(id);
- setDefaultProperties(image, id);
- return image;
- case ListBox:
- SwingScilabListBox listBox = new SwingScilabListBox();
- listBox.setId(id);
- setDefaultProperties(listBox, id);
- return listBox;
- case PopupMenu:
- SwingScilabPopupMenu popupMenu = new SwingScilabPopupMenu();
- popupMenu.setId(id);
- setDefaultProperties(popupMenu, id);
- return popupMenu;
- case Progressbar:
- SwingScilabWaitBar progressbar = new SwingScilabWaitBar();
- progressbar.setIndeterminateMode(true);
- progressbar.setId(id);
- return progressbar;
- case PushButton:
- SwingScilabPushButton pushButton = new SwingScilabPushButton();
- pushButton.setId(id);
- setDefaultProperties(pushButton, id);
- return pushButton;
- case RadioButton:
- SwingScilabRadioButton radioButton = new SwingScilabRadioButton();
- radioButton.setId(id);
- setDefaultProperties(radioButton, id);
- return radioButton;
- case Slider:
- SwingScilabSlider slider = new SwingScilabSlider();
- slider.setId(id);
- setDefaultProperties(slider, id);
- return slider;
- case Table:
- SwingScilabUiTable table = new SwingScilabUiTable();
- table.setId(id);
- setDefaultProperties(table, id);
- return table;
- case Text:
- SwingScilabLabel text = new SwingScilabLabel();
- text.setId(id);
- setDefaultProperties(text, id);
- return text;
- case Uimenu:
- throw new UnsupportedOperationException();
- case UiParentMenu: /* SwingView internal type */
- SwingScilabMenu parentMenu = new SwingScilabMenu();
- parentMenu.setId(id);
- setMenuDefaultProperties(parentMenu, id);
- return parentMenu;
- case UiChildMenu: /* SwingView internal type */
- SwingScilabMenuItem childMenu = new SwingScilabMenuItem();
- childMenu.setId(id);
- setMenuDefaultProperties(childMenu, id);
- return childMenu;
- case UiCheckedMenu: /* SwingView internal type */
- SwingScilabCheckBoxMenuItem checkedMenu = new SwingScilabCheckBoxMenuItem(false);
- checkedMenu.setId(id);
- setMenuDefaultProperties(checkedMenu, id);
- return checkedMenu;
- case UiContextMenu:
- SwingScilabContextMenu contextMenu = new SwingScilabContextMenu();
- contextMenu.setId(id);
- return contextMenu;
- case Waitbar:
- SwingScilabWaitBar waitbar = new SwingScilabWaitBar();
- waitbar.setIndeterminateMode(false);
- waitbar.setId(id);
- return waitbar;
- default:
- return null;
+ String infoMessage = figure.getInfoMessage();
+ if ((infoMessage == null) || (infoMessage.length() == 0)) {
+ infoBar.setText("");
+ } else {
+ infoBar.setText(infoMessage);
+ }
+ tab.update(__GO_SIZE__, (Integer[]) GraphicController.getController().getProperty(id, __GO_SIZE__));
+ tab.update(__GO_POSITION__, (Integer[]) GraphicController.getController().getProperty(id, __GO_POSITION__));
+ // TODO set other default properties
+ return tab;
+ case Frame:
+ SwingScilabFrame frame = new SwingScilabFrame();
+ frame.setId(id);
+ setDefaultProperties(frame, id);
+ return frame;
+ case Image:
+ SwingScilabUiImage image = new SwingScilabUiImage();
+ image.setId(id);
+ setDefaultProperties(image, id);
+ return image;
+ case ListBox:
+ SwingScilabListBox listBox = new SwingScilabListBox();
+ listBox.setId(id);
+ setDefaultProperties(listBox, id);
+ return listBox;
+ case PopupMenu:
+ SwingScilabPopupMenu popupMenu = new SwingScilabPopupMenu();
+ popupMenu.setId(id);
+ setDefaultProperties(popupMenu, id);
+ return popupMenu;
+ case Progressbar:
+ SwingScilabWaitBar progressbar = new SwingScilabWaitBar();
+ progressbar.setIndeterminateMode(true);
+ progressbar.setId(id);
+ return progressbar;
+ case PushButton:
+ SwingScilabPushButton pushButton = new SwingScilabPushButton();
+ pushButton.setId(id);
+ setDefaultProperties(pushButton, id);
+ return pushButton;
+ case RadioButton:
+ SwingScilabRadioButton radioButton = new SwingScilabRadioButton();
+ radioButton.setId(id);
+ setDefaultProperties(radioButton, id);
+ return radioButton;
+ case Slider:
+ SwingScilabSlider slider = new SwingScilabSlider();
+ slider.setId(id);
+ setDefaultProperties(slider, id);
+ return slider;
+ case Table:
+ SwingScilabUiTable table = new SwingScilabUiTable();
+ table.setId(id);
+ setDefaultProperties(table, id);
+ return table;
+ case Text:
+ SwingScilabLabel text = new SwingScilabLabel();
+ text.setId(id);
+ setDefaultProperties(text, id);
+ return text;
+ case Uimenu:
+ throw new UnsupportedOperationException();
+ case UiParentMenu: /* SwingView internal type */
+ SwingScilabMenu parentMenu = new SwingScilabMenu();
+ parentMenu.setId(id);
+ setMenuDefaultProperties(parentMenu, id);
+ return parentMenu;
+ case UiChildMenu: /* SwingView internal type */
+ SwingScilabMenuItem childMenu = new SwingScilabMenuItem();
+ childMenu.setId(id);
+ setMenuDefaultProperties(childMenu, id);
+ return childMenu;
+ case UiCheckedMenu: /* SwingView internal type */
+ SwingScilabCheckBoxMenuItem checkedMenu = new SwingScilabCheckBoxMenuItem(false);
+ checkedMenu.setId(id);
+ setMenuDefaultProperties(checkedMenu, id);
+ return checkedMenu;
+ case UiContextMenu:
+ SwingScilabContextMenu contextMenu = new SwingScilabContextMenu();
+ contextMenu.setId(id);
+ return contextMenu;
+ case Waitbar:
+ SwingScilabWaitBar waitbar = new SwingScilabWaitBar();
+ waitbar.setIndeterminateMode(false);
+ waitbar.setId(id);
+ return waitbar;
+ default:
+ return null;
}
}
*/
private void setMenuDefaultProperties(Widget uiMenuObject, String id) {
SwingViewMenu.update(uiMenuObject, __GO_CHILDREN__,
- (String[]) GraphicController.getController().getProperty(id, __GO_CHILDREN__));
+ (String[]) GraphicController.getController().getProperty(id, __GO_CHILDREN__));
SwingViewMenu.update(uiMenuObject, __GO_CALLBACK__,
- (String) GraphicController.getController().getProperty(id, __GO_CALLBACK__));
+ (String) GraphicController.getController().getProperty(id, __GO_CALLBACK__));
SwingViewMenu.update(uiMenuObject, __GO_CALLBACKTYPE__,
- (Integer) GraphicController.getController().getProperty(id, __GO_CALLBACKTYPE__));
+ (Integer) GraphicController.getController().getProperty(id, __GO_CALLBACKTYPE__));
SwingViewMenu.update(uiMenuObject, __GO_UI_CHECKED__,
- (Boolean) GraphicController.getController().getProperty(id, __GO_UI_CHECKED__));
+ (Boolean) GraphicController.getController().getProperty(id, __GO_UI_CHECKED__));
SwingViewMenu.update(uiMenuObject, __GO_UI_ENABLE__,
- (Boolean) GraphicController.getController().getProperty(id, __GO_UI_ENABLE__));
+ (Boolean) GraphicController.getController().getProperty(id, __GO_UI_ENABLE__));
SwingViewMenu.update(uiMenuObject, __GO_UI_FOREGROUNDCOLOR__,
- (Double[]) GraphicController.getController().getProperty(id, __GO_UI_FOREGROUNDCOLOR__));
+ (Double[]) GraphicController.getController().getProperty(id, __GO_UI_FOREGROUNDCOLOR__));
SwingViewMenu.update(uiMenuObject, __GO_UI_LABEL__,
- (String) GraphicController.getController().getProperty(id, __GO_UI_LABEL__));
+ (String) GraphicController.getController().getProperty(id, __GO_UI_LABEL__));
SwingViewMenu.update(uiMenuObject, __GO_UI_ICON__,
- (String) GraphicController.getController().getProperty(id, __GO_UI_ICON__));
+ (String) GraphicController.getController().getProperty(id, __GO_UI_ICON__));
}
/**
private void setDefaultProperties(Widget uiControlObject, String id) {
/* Visible property is set first to avoid to see the object rendered before all its properties to be set (See bug #10346) */
SwingViewWidget.update(uiControlObject, __GO_VISIBLE__,
- (Boolean) GraphicController.getController().getProperty(id, __GO_VISIBLE__));
+ (Boolean) GraphicController.getController().getProperty(id, __GO_VISIBLE__));
SwingViewWidget.update(uiControlObject, __GO_UI_BACKGROUNDCOLOR__,
- (Double[]) GraphicController.getController().getProperty(id, __GO_UI_BACKGROUNDCOLOR__));
+ (Double[]) GraphicController.getController().getProperty(id, __GO_UI_BACKGROUNDCOLOR__));
SwingViewWidget.update(uiControlObject, __GO_UI_ENABLE__,
- (Boolean) GraphicController.getController().getProperty(id, __GO_UI_ENABLE__));
+ (Boolean) GraphicController.getController().getProperty(id, __GO_UI_ENABLE__));
SwingViewWidget.update(uiControlObject, __GO_UI_ENABLE__,
- (Boolean) GraphicController.getController().getProperty(id, __GO_UI_ENABLE__));
+ (Boolean) GraphicController.getController().getProperty(id, __GO_UI_ENABLE__));
SwingViewWidget.update(uiControlObject, __GO_UI_FONTANGLE__,
- (String) GraphicController.getController().getProperty(id, __GO_UI_FONTANGLE__));
+ (String) GraphicController.getController().getProperty(id, __GO_UI_FONTANGLE__));
SwingViewWidget.update(uiControlObject, __GO_UI_FONTNAME__,
- (String) GraphicController.getController().getProperty(id, __GO_UI_FONTNAME__));
+ (String) GraphicController.getController().getProperty(id, __GO_UI_FONTNAME__));
SwingViewWidget.update(uiControlObject, __GO_UI_FONTUNITS__,
- (String) GraphicController.getController().getProperty(id, __GO_UI_FONTUNITS__));
+ (String) GraphicController.getController().getProperty(id, __GO_UI_FONTUNITS__));
SwingViewWidget.update(uiControlObject, __GO_UI_FONTSIZE__,
- (Double) GraphicController.getController().getProperty(id, __GO_UI_FONTSIZE__));
+ (Double) GraphicController.getController().getProperty(id, __GO_UI_FONTSIZE__));
SwingViewWidget.update(uiControlObject, __GO_UI_FONTWEIGHT__,
- (String) GraphicController.getController().getProperty(id, __GO_UI_FONTWEIGHT__));
+ (String) GraphicController.getController().getProperty(id, __GO_UI_FONTWEIGHT__));
SwingViewWidget.update(uiControlObject, __GO_UI_FOREGROUNDCOLOR__,
- (Double[]) GraphicController.getController().getProperty(id, __GO_UI_FOREGROUNDCOLOR__));
+ (Double[]) GraphicController.getController().getProperty(id, __GO_UI_FOREGROUNDCOLOR__));
SwingViewWidget.update(uiControlObject, __GO_UI_HORIZONTALALIGNMENT__,
- (String) GraphicController.getController().getProperty(id, __GO_UI_HORIZONTALALIGNMENT__));
+ (String) GraphicController.getController().getProperty(id, __GO_UI_HORIZONTALALIGNMENT__));
SwingViewWidget.update(uiControlObject, __GO_UI_RELIEF__,
- (String) GraphicController.getController().getProperty(id, __GO_UI_RELIEF__));
+ (String) GraphicController.getController().getProperty(id, __GO_UI_RELIEF__));
SwingViewWidget.update(uiControlObject, __GO_UI_STRING__,
- (String[]) GraphicController.getController().getProperty(id, __GO_UI_STRING__));
+ (String[]) GraphicController.getController().getProperty(id, __GO_UI_STRING__));
SwingViewWidget.update(uiControlObject, __GO_UI_VERTICALALIGNMENT__,
- (String) GraphicController.getController().getProperty(id, __GO_UI_VERTICALALIGNMENT__));
+ (String) GraphicController.getController().getProperty(id, __GO_UI_VERTICALALIGNMENT__));
SwingViewWidget.update(uiControlObject, __GO_POSITION__,
- (Double[]) GraphicController.getController().getProperty(id, __GO_POSITION__));
+ (Double[]) GraphicController.getController().getProperty(id, __GO_POSITION__));
}
- @Override
public void deleteObject(String id) {
final TypedObject requestedObject = allObjects.get(id);
if (requestedObject != null) {
switch (requestedObject.getType()) {
- case Figure:
- final SwingScilabTab tab = (SwingScilabTab) requestedObject.getValue();
- tab.disablePaint();
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- DockingManager.close(tab);
- DockingManager.unregisterDockable((Dockable) tab);
- ClosingOperationsManager.unregisterClosingOperation(tab);
- ClosingOperationsManager.removeDependency(tab);
- ClosingOperationsManager.checkTabForClosing(tab);
- tab.close();
- }
- });
- break;
- case Progressbar:
- case Waitbar:
- SwingScilabWaitBar bar = (SwingScilabWaitBar) requestedObject.getValue();
- bar.close();
- break;
- default:
- // Nothing to do
+ case Figure:
+ final SwingScilabTab tab = (SwingScilabTab) requestedObject.getValue();
+ tab.disablePaint();
+ DockingManager.close(tab);
+ DockingManager.unregisterDockable((Dockable) tab);
+ ClosingOperationsManager.unregisterClosingOperation(tab);
+ ClosingOperationsManager.removeDependency(tab);
+ ClosingOperationsManager.checkTabForClosing(tab);
+ tab.close();
+ break;
+ case Progressbar:
+ case Waitbar:
+ SwingScilabWaitBar bar = (SwingScilabWaitBar) requestedObject.getValue();
+ bar.close();
+ break;
+ default:
+ // Nothing to do
// uicontrol case: the object is destroyed when its parent updates its children
- break;
+ break;
}
allObjects.remove(id);
}
}
@Override
- public void updateObject(String id, int property) {
- TypedObject registeredObject = allObjects.get(id);
- DEBUG("SwingView", "Update" + property);
-
+ public void updateObject(final String id, final int property) {
+ final TypedObject registeredObject = allObjects.get(id);
+ if (registeredObject == null && property != __GO_STYLE__) {
+ return;
+ }
+
/* On uicontrol style is set after object creation */
if (registeredObject == null && property == __GO_STYLE__) {
int style = (Integer) GraphicController.getController().getProperty(id, __GO_STYLE__);
allObjects.put(id, CreateObjectFromType(style, id));
+ return;
}
+
+ if (SwingUtilities.isEventDispatchThread()) {
+ updateObjectOnEDT(registeredObject, id, property);
+ } else {
+ try {
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ updateObjectOnEDT(registeredObject, id, property);
+ }
+ });
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (InvocationTargetException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+ public void updateObjectOnEDT(TypedObject registeredObject, final String id, final int property) {
/* Removes the swing object if its parent is not display */
if (registeredObject != null && property == __GO_PARENT__) {
String parentId = (String) GraphicController.getController().getProperty(id, __GO_PARENT__);
allObjects.remove(id);
}
}
+
int type = (Integer) GraphicController.getController().getProperty(id, __GO_TYPE__);
/* Children list update */
if (registeredObject != null && property == __GO_CHILDREN__) {
- String[] newChildren = (String[]) GraphicController.getController().getProperty(id, __GO_CHILDREN__);
+ final String[] newChildren = (String[]) GraphicController.getController().getProperty(id, __GO_CHILDREN__);
switch (type) {
- /*
- * FIGURE CHILDREN UPDATE
- */
- case __GO_FIGURE__ :
- updateFigureChildren(id, newChildren);
- break;
- /*
- * CONSOLE CHILDREN UPDATE
- */
- case __GO_CONSOLE__ :
- updateConsoleChildren(id, newChildren);
- break;
- /*
- * MENU CHILDREN UPDATE
- */
- case __GO_UIMENU__ :
- updateMenuChildren(id, newChildren);
- break;
- /*
- * CONTEXTMENU CHILDREN UPDATE
- */
- case __GO_UICONTEXTMENU__ :
- updateContextMenuChildren(id, newChildren);
- break;
- /*
- * UICONTROL "FRAME" CHILDREN UPDATE
- */
- case __GO_UICONTROL__ :
- int style = (Integer) GraphicController.getController().getProperty(id, __GO_STYLE__);
- if (style == __GO_UI_FRAME__) {
- updateFrameChildren(id, newChildren);
- }
- break;
+ /*
+ * FIGURE CHILDREN UPDATE
+ */
+ case __GO_FIGURE__ :
+ updateFigureChildren(registeredObject, newChildren);
+ break;
+ /*
+ * CONSOLE CHILDREN UPDATE
+ */
+ case __GO_CONSOLE__ :
+ updateConsoleChildren(registeredObject, newChildren);
+ break;
+ /*
+ * MENU CHILDREN UPDATE
+ */
+ case __GO_UIMENU__ :
+ updateMenuChildren(registeredObject, id, newChildren);
+ break;
+ /*
+ * CONTEXTMENU CHILDREN UPDATE
+ */
+ case __GO_UICONTEXTMENU__ :
+ updateContextMenuChildren(registeredObject, newChildren);
+ break;
+ /*
+ * UICONTROL "FRAME" CHILDREN UPDATE
+ */
+ case __GO_UICONTROL__ :
+ int style = (Integer) GraphicController.getController().getProperty(id, __GO_STYLE__);
+ if (style == __GO_UI_FRAME__) {
+ updateFrameChildren(registeredObject, newChildren);
+ }
+ break;
}
}
*/
if (registeredObject != null && property == __GO_UI_CHECKED__) {
if (type == __GO_UIMENU__) {
- TypedObject updatedObject = allObjects.get(id);
- switch (updatedObject.getType()) {
- case UiParentMenu:
- SwingScilabMenu meAsAMenu = (SwingScilabMenu) updatedObject.getValue();
- Container parent = meAsAMenu.getParent();
- parent.remove(meAsAMenu);
- allObjects.put(id, CreateObjectFromType(__GO_UICHECKEDMENU__, id));
- SwingScilabCheckBoxMenuItem meAsAMenuItem = (SwingScilabCheckBoxMenuItem) allObjects.get(id).getValue();
- parent.add(meAsAMenuItem);
- registeredObject = allObjects.get(id);
- break;
- case UiChildMenu:
- String parentId = (String) GraphicController.getController().getProperty(id, __GO_PARENT__);
- int index = ((SwingScilabMenu) allObjects.get(parentId).getValue())
- .getComponentZOrder((SwingScilabMenuItem) allObjects.get(id).getValue());
- ((SwingScilabMenu) allObjects.get(parentId).getValue()).remove((SwingScilabMenuItem) allObjects.get(id).getValue());
- allObjects.put(id, CreateObjectFromType(__GO_UICHECKEDMENU__, id));
- registeredObject = allObjects.get(id);
- ((SwingScilabMenu) allObjects.get(parentId).getValue()).add((SwingScilabCheckBoxMenuItem) allObjects.get(id).getValue(), index);
- return;
- default:
- break;
+ switch (registeredObject.getType()) {
+ case UiParentMenu:
+ SwingScilabMenu meAsAMenu = (SwingScilabMenu) registeredObject.getValue();
+ Container parent = meAsAMenu.getParent();
+ parent.remove(meAsAMenu);
+ registeredObject = CreateObjectFromType(__GO_UICHECKEDMENU__, id);
+ allObjects.put(id, registeredObject);
+ SwingScilabCheckBoxMenuItem meAsAMenuItem = (SwingScilabCheckBoxMenuItem) registeredObject.getValue();
+ parent.add(meAsAMenuItem);
+ break;
+ case UiChildMenu:
+ String parentId = (String) GraphicController.getController().getProperty(id, __GO_PARENT__);
+ SwingScilabMenuItem childMenu = (SwingScilabMenuItem) allObjects.get(id).getValue();
+ SwingScilabMenu parentMenu = (SwingScilabMenu) allObjects.get(parentId).getValue();
+
+ int index = parentMenu.getComponentZOrder(childMenu);
+ parentMenu.remove(childMenu);
+ registeredObject = CreateObjectFromType(__GO_UICHECKEDMENU__, id);
+ allObjects.put(id, registeredObject);
+ registeredObject = allObjects.get(id);
+ parentMenu.add((SwingScilabCheckBoxMenuItem) registeredObject.getValue(), index);
+ return;
+ default:
+ break;
}
}
}
if (type == __GO_UIMENU__) {
String parentId = (String) GraphicController.getController().getProperty(id, __GO_PARENT__);
int menuPosition = -1;
+ Component currentComponent = (Component) registeredObject.getValue();
Component[] allChildren = ((SwingScilabMenu) allObjects.get(parentId).getValue()).getMenuComponents();
for (int kChild = 0; kChild < allChildren.length; kChild++) {
- if (allChildren[kChild] == (Component) allObjects.get(id).getValue()) {
+ if (allChildren[kChild] == currentComponent) {
menuPosition = kChild;
break;
}
}
if (registeredObject != null) {
- SwingViewObject swingObject = registeredObject.getValue();
+ final SwingViewObject swingObject = registeredObject.getValue();
if (swingObject != null) {
swingObject.update(property, GraphicController.getController().getProperty(id, property));
}
* @param id the id of the figure
* @param newChildren the new children IDs list
*/
- private void updateFigureChildren(String id, String[] newChildren) {
- TypedObject updatedObject = allObjects.get(id);
+ private void updateFigureChildren(TypedObject updatedObject, String[] newChildren) {
Container updatedComponent = (SwingScilabTab) updatedObject.getValue();
boolean needRevalidate = false;
if (childType == __GO_UIMENU__) {
TypedObject childAsTypedObject = allObjects.get(childId);
switch (childAsTypedObject.getType()) {
- case UiChildMenu:
- case UiCheckedMenu:
- allObjects.remove(childId);
- allObjects.put(childId, CreateObjectFromType(__GO_UIPARENTMENU__, childId));
- ((Container) ((SwingScilabTab) updatedComponent).getMenuBar().getAsSimpleMenuBar()).add((SwingScilabMenu) allObjects.get(childId).getValue());
- break;
- default: /* UiParentMenu */
- ((Container) ((SwingScilabTab) updatedComponent).getMenuBar().getAsSimpleMenuBar()).add((SwingScilabMenu) allObjects.get(childId).getValue());
- break;
+ case UiChildMenu:
+ case UiCheckedMenu:
+ allObjects.remove(childId);
+ allObjects.put(childId, CreateObjectFromType(__GO_UIPARENTMENU__, childId));
+ ((Container) ((SwingScilabTab) updatedComponent).getMenuBar().getAsSimpleMenuBar()).add((SwingScilabMenu) allObjects.get(childId).getValue());
+ break;
+ default: /* UiParentMenu */
+ ((Container) ((SwingScilabTab) updatedComponent).getMenuBar().getAsSimpleMenuBar()).add((SwingScilabMenu) allObjects.get(childId).getValue());
+ break;
}
needRevalidate = true;
}
// Remove the child
updatedObject.removeChild(childId);
- int childType = (Integer) GraphicController.getController().getProperty(childId, __GO_TYPE__);
+ final Object childTypeObject = GraphicController.getController().getProperty(childId, __GO_TYPE__);
+ if (childTypeObject == null) {
+ // the child has already been removed from the model
+ continue;
+ }
+ int childType = (Integer) childTypeObject;
/* Remove an uicontrol */
if (childType == __GO_UICONTROL__) {
if (childType == __GO_UIMENU__) {
TypedObject childAsTypedObject = allObjects.get(childId);
switch (childAsTypedObject.getType()) {
- case UiCheckedMenu:
- ((Container) ((SwingScilabTab) updatedComponent).getMenuBar().getAsSimpleMenuBar()).remove((SwingScilabCheckBoxMenuItem) allObjects.get(childId).getValue());
- break;
- default: /* UiParentMenu */
- ((Container) ((SwingScilabTab) updatedComponent).getMenuBar().getAsSimpleMenuBar()).remove((SwingScilabMenu) allObjects.get(childId).getValue());
- break;
+ case UiCheckedMenu:
+ ((Container) ((SwingScilabTab) updatedComponent).getMenuBar().getAsSimpleMenuBar()).remove((SwingScilabCheckBoxMenuItem) allObjects.get(childId).getValue());
+ break;
+ default: /* UiParentMenu */
+ ((Container) ((SwingScilabTab) updatedComponent).getMenuBar().getAsSimpleMenuBar()).remove((SwingScilabMenu) allObjects.get(childId).getValue());
+ break;
}
needRevalidate = true;
}
* @param id the id of the figure
* @param newChildren the new children IDs list
*/
- private void updateFrameChildren(String id, String[] newChildren) {
- TypedObject updatedObject = allObjects.get(id);
+ private void updateFrameChildren(TypedObject updatedObject, String[] newChildren) {
Container updatedComponent = (SwingScilabFrame) updatedObject.getValue();
boolean needRevalidate = false;
* @param id the id of the console object
* @param newChildren the new children IDs list
*/
- private void updateConsoleChildren(String id, String[] newChildren) {
- TypedObject updatedObject = allObjects.get(id);
+ private void updateConsoleChildren(TypedObject updatedObject, String[] newChildren) {
Container updatedComponent = (SwingScilabTab) updatedObject.getValue();
boolean needRevalidate = false;
if (childType == __GO_UIMENU__) {
TypedObject childAsTypedObject = allObjects.get(childId);
switch (childAsTypedObject.getType()) {
- case UiChildMenu:
- case UiCheckedMenu:
- allObjects.put(childId, CreateObjectFromType(__GO_UIPARENTMENU__, childId));
- ((Container) ((SwingScilabTab) updatedObject.getValue()).getMenuBar().getAsSimpleMenuBar()).add((SwingScilabMenu) allObjects.get(childId).getValue());
- break;
- default: /* UiParentMenu */
- ((Container) ((SwingScilabTab) updatedObject.getValue()).getMenuBar().getAsSimpleMenuBar()).add((SwingScilabMenu) allObjects.get(childId).getValue());
- break;
+ case UiChildMenu:
+ case UiCheckedMenu:
+ TypedObject newUiParentMenu = CreateObjectFromType(__GO_UIPARENTMENU__, childId);
+ allObjects.put(childId, newUiParentMenu);
+ ((Container) ((SwingScilabTab) updatedObject.getValue()).getMenuBar().getAsSimpleMenuBar()).add((SwingScilabMenu) newUiParentMenu.getValue());
+ break;
+ default: /* UiParentMenu */
+ ((Container) ((SwingScilabTab) updatedObject.getValue()).getMenuBar().getAsSimpleMenuBar()).add((SwingScilabMenu) childAsTypedObject.getValue());
+ break;
}
needRevalidate = true;
}
int childType = (Integer) GraphicController.getController().getProperty(childId, __GO_TYPE__);
if (childType == __GO_UIMENU__) {
- ((Container) ((SwingScilabTab) allObjects.get(id).getValue()).getMenuBar().getAsSimpleMenuBar()).remove((SwingScilabMenu) allObjects.get(childId).getValue());
+ ((Container) ((SwingScilabTab) updatedObject.getValue()).getMenuBar().getAsSimpleMenuBar()).remove((SwingScilabMenu) allObjects.get(childId).getValue());
needRevalidate = true;
}
}
* @param id the id of the menu object
* @param newChildren the new children IDs list
*/
- private void updateMenuChildren(String id, String[] newChildren) {
- TypedObject updatedObject = allObjects.get(id);
+ private void updateMenuChildren(TypedObject updatedObject, String id, String[] newChildren) {
Container updatedComponent = null;
boolean needRevalidate = false;
int updatedObjectPosition = 0;
Object addedChild = allObjects.get(childId).getValue();
JComponent parent = null;
switch (updatedObject.getType()) {
+ case UiChildMenu:
+ updatedComponent = (SwingScilabMenuItem) updatedObject.getValue();
+ parent = (JComponent) updatedComponent.getParent();
+ switch (childAsTypedObject.getType()) {
+ case UiChildMenu:
+ /* Replace the item by a parent menu */
+ updatedObjectPosition = parent.getComponentZOrder((SwingScilabMenuItem) updatedObject.getValue());
+ parent.remove((SwingScilabMenuItem) updatedObject.getValue());
+ newParent = CreateObjectFromType(__GO_UIPARENTMENU__, id);
+ allObjects.put(id, newParent);
+ newParent.addChild(childId);
+ parent.add((SwingScilabMenu) newParent.getValue(), updatedObjectPosition);
+ /* Update the created menu */
+ ((SwingScilabMenu) newParent.getValue()).add((SwingScilabMenuItem) addedChild);
+ break;
+ case UiCheckedMenu:
+ /* Replace the item by a parent menu */
+ updatedObjectPosition = parent.getComponentZOrder((SwingScilabCheckBoxMenuItem) updatedObject.getValue());
+ parent.remove((SwingScilabCheckBoxMenuItem) updatedObject.getValue());
+ newParent = CreateObjectFromType(__GO_UIPARENTMENU__, id);
+ allObjects.put(id, newParent);
+ newParent.addChild(childId);
+ parent.add((SwingScilabMenu) newParent.getValue(), updatedObjectPosition);
+ /* Update the created menu */
+ ((SwingScilabMenu) newParent.getValue()).add((SwingScilabCheckBoxMenuItem) addedChild);
+ break;
+ default: /* UiParentMenu */
+ ((SwingScilabMenu) updatedObject.getValue()).add((SwingScilabMenu) addedChild);
+ break;
+ }
+ break;
+ case UiCheckedMenu:
+ updatedComponent = (SwingScilabCheckBoxMenuItem) updatedObject.getValue();
+ parent = (JComponent) updatedComponent.getParent();
+ switch (childAsTypedObject.getType()) {
+ case UiChildMenu:
+ /* Replace the item by a parent menu */
+ updatedObjectPosition = parent.getComponentZOrder((SwingScilabCheckBoxMenuItem) updatedObject.getValue());
+ parent.remove((SwingScilabCheckBoxMenuItem) allObjects.get(id).getValue());
+ newParent = CreateObjectFromType(__GO_UIPARENTMENU__, id);
+ allObjects.put(id, newParent);
+ newParent.addChild(childId);
+ parent.add((SwingScilabMenu) newParent.getValue(), updatedObjectPosition);
+ /* Update the created menu */
+ ((SwingScilabMenu) newParent.getValue()).add((SwingScilabMenuItem) allObjects.get(childId).getValue());
+ break;
+ case UiCheckedMenu:
+ /* Replace the item by a parent menu */
+ updatedObjectPosition = parent.getComponentZOrder((SwingScilabCheckBoxMenuItem) updatedObject.getValue());
+ parent.remove((SwingScilabCheckBoxMenuItem) allObjects.get(id).getValue());
+ newParent = CreateObjectFromType(__GO_UIPARENTMENU__, id);
+ allObjects.put(id, newParent);
+ newParent.addChild(childId);
+ parent.add((SwingScilabMenu) newParent.getValue(), updatedObjectPosition);
+ /* Update the created menu */
+ ((SwingScilabMenu) newParent.getValue()).add((SwingScilabCheckBoxMenuItem) allObjects.get(childId).getValue());
+ break;
+ default: /* UiParentMenu */
+ System.out.println("childAsTypedObject.getType() = UiParentMenu");
+ ((SwingScilabMenu) updatedObject.getValue()).add((SwingScilabMenu) allObjects.get(childId).getValue());
+ break;
+ }
+ break;
+ default: /* UiParentMenu */
+ SwingScilabMenu updatedMenu = (SwingScilabMenu) updatedObject.getValue();
+ updatedComponent = updatedMenu;
+ switch (childAsTypedObject.getType()) {
case UiChildMenu:
- updatedComponent = (SwingScilabMenuItem) updatedObject.getValue();
- parent = (JComponent) updatedComponent.getParent();
- switch (childAsTypedObject.getType()) {
- case UiChildMenu:
- /* Replace the item by a parent menu */
- updatedObjectPosition = parent.getComponentZOrder((SwingScilabMenuItem) allObjects.get(id).getValue());
- parent.remove((SwingScilabMenuItem) allObjects.get(id).getValue());
- newParent = CreateObjectFromType(__GO_UIPARENTMENU__, id);
- allObjects.put(id, newParent);
- newParent.addChild(childId);
- parent.add((SwingScilabMenu) allObjects.get(id).getValue(), updatedObjectPosition);
- /* Update the created menu */
- ((SwingScilabMenu) allObjects.get(id).getValue()).add((SwingScilabMenuItem) addedChild);
- break;
- case UiCheckedMenu:
- /* Replace the item by a parent menu */
- updatedObjectPosition = parent.getComponentZOrder((SwingScilabCheckBoxMenuItem) allObjects.get(id).getValue());
- parent.remove((SwingScilabCheckBoxMenuItem) allObjects.get(id).getValue());
- newParent = CreateObjectFromType(__GO_UIPARENTMENU__, id);
- allObjects.put(id, newParent);
- newParent.addChild(childId);
- parent.add((SwingScilabMenu) allObjects.get(id).getValue(), updatedObjectPosition);
- /* Update the created menu */
- ((SwingScilabMenu) allObjects.get(id).getValue()).add((SwingScilabCheckBoxMenuItem) addedChild);
- break;
- default: /* UiParentMenu */
- ((SwingScilabMenu) allObjects.get(id).getValue()).add((SwingScilabMenu) addedChild);
- break;
- }
+ updatedMenu.add((SwingScilabMenuItem) allObjects.get(childId).getValue());
break;
case UiCheckedMenu:
- updatedComponent = (SwingScilabCheckBoxMenuItem) updatedObject.getValue();
- parent = (JComponent) updatedComponent.getParent();
- switch (childAsTypedObject.getType()) {
- case UiChildMenu:
- /* Replace the item by a parent menu */
- updatedObjectPosition = parent.getComponentZOrder((SwingScilabCheckBoxMenuItem) allObjects.get(id).getValue());
- parent.remove((SwingScilabCheckBoxMenuItem) allObjects.get(id).getValue());
- newParent = CreateObjectFromType(__GO_UIPARENTMENU__, id);
- allObjects.put(id, newParent);
- newParent.addChild(childId);
- parent.add((SwingScilabMenu) allObjects.get(id).getValue(), updatedObjectPosition);
- /* Update the created menu */
- ((SwingScilabMenu) allObjects.get(id).getValue()).add((SwingScilabMenuItem) allObjects.get(childId).getValue());
- break;
- case UiCheckedMenu:
- /* Replace the item by a parent menu */
- updatedObjectPosition = parent.getComponentZOrder((SwingScilabCheckBoxMenuItem) allObjects.get(id).getValue());
- parent.remove((SwingScilabCheckBoxMenuItem) allObjects.get(id).getValue());
- newParent = CreateObjectFromType(__GO_UIPARENTMENU__, id);
- allObjects.put(id, newParent);
- newParent.addChild(childId);
- parent.add((SwingScilabMenu) allObjects.get(id).getValue(), updatedObjectPosition);
- /* Update the created menu */
- ((SwingScilabMenu) allObjects.get(id).getValue()).add((SwingScilabCheckBoxMenuItem) allObjects.get(childId).getValue());
- break;
- default: /* UiParentMenu */
- System.out.println("childAsTypedObject.getType() = UiParentMenu");
- ((SwingScilabMenu) allObjects.get(id).getValue()).add((SwingScilabMenu) allObjects.get(childId).getValue());
- break;
- }
+ updatedMenu.add((SwingScilabCheckBoxMenuItem) allObjects.get(childId).getValue());
break;
default: /* UiParentMenu */
- SwingScilabMenu updatedMenu = (SwingScilabMenu) updatedObject.getValue();
- updatedComponent = updatedMenu;
- switch (childAsTypedObject.getType()) {
- case UiChildMenu:
- updatedMenu.add((SwingScilabMenuItem) allObjects.get(childId).getValue());
- break;
- case UiCheckedMenu:
- updatedMenu.add((SwingScilabCheckBoxMenuItem) allObjects.get(childId).getValue());
- break;
- default: /* UiParentMenu */
- /* Java can not add a JMenu in a JMenu */
- /* We need to convert the child into a MenuItem */
- allObjects.put(childId, CreateObjectFromType(__GO_UIMENU__, childId));
- updatedMenu.add((SwingScilabMenuItem) allObjects.get(childId).getValue());
- break;
- }
+ /* Java can not add a JMenu in a JMenu */
+ /* We need to convert the child into a MenuItem */
+ TypedObject newMenu = CreateObjectFromType(__GO_UIMENU__, childId);
+ allObjects.put(childId, newMenu);
+ updatedMenu.add((SwingScilabMenuItem) newMenu.getValue());
break;
+ }
+ break;
}
needRevalidate = true;
}
updatedComponent = (SwingScilabMenu) updatedObject.getValue();
TypedObject childAsTypedObject = allObjects.get(childId);
- SwingScilabMenu updatedMenu = (SwingScilabMenu) allObjects.get(id).getValue();
- Object removedMenu = allObjects.get(childId).getValue();
+ Object removedMenu = childAsTypedObject.getValue();
switch (childAsTypedObject.getType()) {
- case UiChildMenu:
- updatedMenu.remove((SwingScilabMenuItem) removedMenu);
- break;
- case UiCheckedMenu:
- updatedMenu.remove((SwingScilabCheckBoxMenuItem) removedMenu);
- break;
- default:
- updatedMenu.remove((SwingScilabMenu) removedMenu);
- break;
+ case UiChildMenu:
+ updatedComponent.remove((SwingScilabMenuItem) removedMenu);
+ break;
+ case UiCheckedMenu:
+ updatedComponent.remove((SwingScilabCheckBoxMenuItem) removedMenu);
+ break;
+ default:
+ updatedComponent.remove((SwingScilabMenu) removedMenu);
+ break;
}
needRevalidate = true;
}
* @param id the id of the contextmenu object
* @param newChildren the new children IDs list
*/
- private void updateContextMenuChildren(String id, String[] newChildren) {
- TypedObject updatedObject = allObjects.get(id);
+ private void updateContextMenuChildren(TypedObject updatedObject, String[] newChildren) {
Container updatedComponent = null;
boolean needRevalidate = false;
SwingScilabContextMenu updatedMenu = (SwingScilabContextMenu) updatedObject.getValue();
updatedComponent = updatedMenu;
switch (childAsTypedObject.getType()) {
- case UiChildMenu:
- updatedMenu.add((SwingScilabMenuItem) allObjects.get(childId).getValue());
- break;
- case UiCheckedMenu:
- updatedMenu.add((SwingScilabCheckBoxMenuItem) allObjects.get(childId).getValue());
- break;
- default: /* UiParentMenu */
- updatedMenu.add((SwingScilabMenu) allObjects.get(childId).getValue());
- break;
+ case UiChildMenu:
+ updatedMenu.add((SwingScilabMenuItem) allObjects.get(childId).getValue());
+ break;
+ case UiCheckedMenu:
+ updatedMenu.add((SwingScilabCheckBoxMenuItem) allObjects.get(childId).getValue());
+ break;
+ default: /* UiParentMenu */
+ updatedMenu.add((SwingScilabMenu) allObjects.get(childId).getValue());
+ break;
}
needRevalidate = true;
}
updatedComponent = (SwingScilabMenu) updatedObject.getValue();
TypedObject childAsTypedObject = allObjects.get(childId);
- SwingScilabContextMenu updatedMenu = (SwingScilabContextMenu) allObjects.get(id).getValue();
+ SwingScilabContextMenu updatedMenu = (SwingScilabContextMenu) updatedObject.getValue();
Object removedMenu = allObjects.get(childId).getValue();
switch (childAsTypedObject.getType()) {
- case UiChildMenu:
- updatedMenu.remove((SwingScilabMenuItem) removedMenu);
- break;
- case UiCheckedMenu:
- updatedMenu.remove((SwingScilabCheckBoxMenuItem) removedMenu);
- break;
- default:
- updatedMenu.remove((SwingScilabMenu) removedMenu);
- break;
+ case UiChildMenu:
+ updatedMenu.remove((SwingScilabMenuItem) removedMenu);
+ break;
+ case UiCheckedMenu:
+ updatedMenu.remove((SwingScilabCheckBoxMenuItem) removedMenu);
+ break;
+ default:
+ updatedMenu.remove((SwingScilabMenu) removedMenu);
+ break;
}
needRevalidate = true;
}