protected void firePropertyChanged(String propName, Object oldValue, Object value) { CommandStack stack = node.getViewer().getEditDomain().getCommandStack(); if (propName.equals(ModelProperties.PROPERTY_NAME)) { GraphElementRenameCommand vrc = new GraphElementRenameCommand (); vrc.setModel((GraphElement)node.getModel()); vrc.setOldName((String) oldValue); vrc.setNewName((String) value); stack.execute(vrc); return; } EdgeElementUpdateCommand command = new EdgeElementUpdateCommand( blocked, description, weight, action, guard, dependency, getProperties(), (GWEdge)getModel ()); stack.execute(command); }
protected void firePropertyChanged(String propName, Object value) { CommandStack stack = node.getViewer().getEditDomain().getCommandStack(); if (propName.equals(ModelProperties.PROPERTY_NAME)) { GraphElementRenameCommand vrc = new GraphElementRenameCommand (); vrc.setModel((GraphElement)node.getModel()); vrc.setOldName(((GraphElement)node.getModel()).getName()); vrc.setNewName(this.getName()); stack.execute(vrc); return; } GraphVertexUpdateCommand command = new GraphVertexUpdateCommand( blocked, shared, sharedName, description, requirement, init, getProperties(), (Vertex)getModel ()); stack.execute(command); }
public Object getAdapter(Class adapter) { if (adapter == GraphicalViewer.class || adapter == EditPartViewer.class) return getGraphicalViewer(); else if (adapter == CommandStack.class) return getCommandStack(); else if (adapter == EditDomain.class) return getEditDomain(); else if (adapter == ActionRegistry.class) return getActionRegistry(); else if (adapter == IPropertySheetPage.class) return new PropertiesView(true); else if (adapter == IContentOutlinePage.class) { return new GW4EOutlinePage(); } else if (adapter == ZoomManager.class) return ((ScalableRootEditPart) getGraphicalViewer().getRootEditPart()).getZoomManager(); return super.getAdapter(adapter); }
/** * Commits the current value of the cell editor by getting a {@link Command} * from the source edit part and executing it via the {@link CommandStack}. * Finally, {@link #bringDown()} is called to perform and necessary cleanup. */ protected void commit() { if (committing) return; committing = true; try { eraseFeedback(); if (isDirty()) { CommandStack stack = getEditPart().getViewer().getEditDomain() .getCommandStack(); stack.execute(getEditPart().getCommand(getDirectEditRequest())); } } finally { bringDown(); committing = false; } }
/** * Drop action, get a TableStyle from the event, the style that will be applied to the table */ @Override protected void handleDrop() { if (getTargetEditPart() instanceof CrosstabEditPart) { MCrosstab crosstabModel = (MCrosstab) ((EditPart)getTargetEditPart()).getModel(); TemplateStyle style = (TemplateStyle) IOUtils.readFromByteArray((byte[])getCurrentEvent().data); if (style != null && style instanceof CrosstabStyle){ CrosstabStyle selectedStyle = (CrosstabStyle) style; if (crosstabModel != null) { Shell shell = PlatformUI.getWorkbench().getDisplay().getActiveShell(); MessageDialog question = new MessageDialog(shell, Messages.EditCrosstabStyleAction_questionTitle, null, Messages.EditCrosstabStyleAction_questionText, MessageDialog.QUESTION, new String[]{Messages.EditCrosstabStyleAction_questionUpdate, Messages.EditCrosstabStyleAction_questionNewStyles, Messages.EditCrosstabStyleAction_questionCancel}, 0); int response = question.open(); // response == 0 update the old styles, response == 1 create new styles, response == 2 cancel the operation if (response == 0 || response == 1) { UpdateCrosstabStyleCommand updateCommand = new UpdateCrosstabStyleCommand(crosstabModel, selectedStyle,response == 0); CommandStack cs = getCommandStack(); if (cs!=null) cs.execute(updateCommand); else updateCommand.execute(); } } } } }
public DatasetDialog(Shell shell, MDataset mdataset, JasperReportsConfiguration jConfig, CommandStack cmdStack) { super(shell); this.cmdStack = cmdStack; this.mdataset = mdataset; this.jConfig = jConfig; newdataset = (JRDesignDataset) ((JRDesignDataset) mdataset.getValue()).clone(); mapfields = new HashMap<JRField, JRField>(); List<JRField> newFieldsList = newdataset.getFieldsList(); List<JRField> oldFieldsList = mdataset.getValue().getFieldsList(); for (int i = 0; i < oldFieldsList.size(); i++) mapfields.put(oldFieldsList.get(i), newFieldsList.get(i)); mapparam = new HashMap<JRParameter, JRParameter>(); List<JRParameter> newParamList = newdataset.getParametersList(); List<JRParameter> oldParamList = mdataset.getValue().getParametersList(); for (int i = 0; i < oldParamList.size(); i++) mapparam.put(oldParamList.get(i), newParamList.get(i)); }
/** * Change the padding property of a linebox * @param property the property name * @param newValue the new value */ public void changePropertyPadding(String property, Object newValue){ if (!isRefreshing()) { JSSCompoundCommand cc = new JSSCompoundCommand("Change padding", null); //$NON-NLS-1$ for (APropertyNode m : getElements()) { cc.setReferenceNodeIfNull(m); Command c = null; MLineBox lb = (MLineBox) m.getPropertyValue(MGraphicElementLineBox.LINE_BOX); //If the checkbox is set i need to set the general padding, otherwise it must be null if (checkBoxPadding.getSelection()){ c = getChangePropertyCommand(JRBaseLineBox.PROPERTY_PADDING, newValue, lb); } else { c = getChangePropertyCommand(JRBaseLineBox.PROPERTY_PADDING, null, lb); if (c != null) cc.add(c); c = getChangePropertyCommand(property, newValue, lb); } if (c != null) cc.add(c); } CommandStack cs = getEditDomain().getCommandStack(); cs.execute(cc); } }
/** * Drop action, get a TextStyle from the event, the style that will be applied to the text element */ @Override protected void handleDrop() { if (getTargetEditPart() instanceof StaticTextFigureEditPart || getTargetEditPart() instanceof TextFieldFigureEditPart) { MTextElement textModel = (MTextElement) ((EditPart)getTargetEditPart()).getModel(); TemplateStyle style = (TemplateStyle) IOUtils.readFromByteArray((byte[])getCurrentEvent().data); if (style != null && style instanceof TextStyle){ TextStyle selectedStyle = (TextStyle)style; if (textModel != null) { CommandStack cs = getCommandStack(); UpdateStyleCommand command = new UpdateStyleCommand(textModel, selectedStyle); if (cs!=null) cs.execute(command); else command.execute(); } } } }
public void widgetSelected(SelectionEvent e) { List<Object> selection = getSelectionForType(MGraphicElement.class); if (selection.isEmpty()) return; JSSCompoundCommand compoundCmd = new JSSCompoundCommand("Resize Operation", null); int alignment = (Integer)e.widget.getData(); for (Object model : selection) { compoundCmd.add(new ResizeCommand(alignment, (MGraphicElement)model)); compoundCmd.setReferenceNodeIfNull(model); } if (compoundCmd != null){ CommandStack cs = getCommandStack(); cs.execute(compoundCmd); } }
public void widgetSelected(SelectionEvent e) { if (!refreshing){ List<Object> selection = getSelectionForType(MTextElement.class); if (selection.isEmpty()) return; JSSCompoundCommand changeSizeCommands = new JSSCompoundCommand(null); String property = ""; Object data = e.widget.getData(); if (data instanceof VerticalAlignEnum) property = JRBaseStyle.PROPERTY_VERTICAL_ALIGNMENT; else if (data instanceof HorizontalAlignEnum) property = JRBaseStyle.PROPERTY_HORIZONTAL_ALIGNMENT; else return; for (Object textElement : selection){ changeSizeCommands.setReferenceNodeIfNull(textElement); Command c = createCommand(textElement, data, property); if (c != null) { changeSizeCommands.add(c); } } CommandStack cs = getCommandStack(); cs.execute(changeSizeCommands); } }
/** * Overriden for debug purposes. * Note: the drop is actually performed in the DropEditPolicy. */ @Override protected void handleDrop() { trace.debug("handleDrop"); updateTargetRequest(); updateTargetEditPart(); if (getTargetEditPart() != null) { final Command command = getCommand(); if (command != null && command.canExecute()) { EditPartViewer viewer = getViewer(); final CommandStack commandStack = viewer.getEditDomain().getCommandStack(); WidgetUtils.runLaterInDisplayThread(viewer.getControl(), new Runnable() { @Override public void run() { commandStack.execute(command); } }); } else { getCurrentEvent().detail = DND.DROP_NONE; } } else { getCurrentEvent().detail = DND.DROP_NONE; } }
/** * When services connection is renamed, refresh the connection label in the component view of job. * * @param item */ @Override public void refreshComponentView(Item item) { try { IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage(); IEditorReference[] editors = activePage.getEditorReferences(); for (IEditorReference er : editors) { IEditorPart part = er.getEditor(false); if (part instanceof AbstractMultiPageTalendEditor) { AbstractMultiPageTalendEditor editor = (AbstractMultiPageTalendEditor) part; CommandStack stack = (CommandStack) editor.getTalendEditor().getAdapter(CommandStack.class); if (stack != null) { IProcess process = editor.getProcess(); for (final INode processNode : process.getGraphicalNodes()) { if (processNode instanceof Node) { checkRepository((Node) processNode, item, stack); } } } } } } catch (Exception e) { ExceptionHandler.process(e); } }
@Override public boolean executeCommand(IEditorPart editorPart, Object cmd) { if (editorPart instanceof LocalWSDLEditor && cmd instanceof Command) { CommandStack commandStack = (CommandStack) editorPart.getAdapter(CommandStack.class); editorPart.getEditorSite().getShell().getDisplay().syncExec(new Runnable() { @Override public void run() { commandStack.execute((Command) cmd); } }); return true; } return false; }
/** * Returns the adapter for the specified key. * * <P> * <EM>IMPORTANT</EM> certain requests, such as the property sheet, may be * made before or after {@link #createPartControl(Composite)} is called. The * order is unspecified by the Workbench. * * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) */ public Object getAdapter(Class type) { if (type == org.eclipse.ui.views.properties.IPropertySheetPage.class) { return new UndoablePropertySheetPage(getCommandStack(), getActionRegistry().getAction(ActionFactory.UNDO.getId()), getActionRegistry().getAction(ActionFactory.REDO.getId())); } if (type == GraphicalViewer.class) return getGraphicalViewer(); if (type == CommandStack.class) return getCommandStack(); if (type == ActionRegistry.class) return getActionRegistry(); if (type == EditPart.class && getGraphicalViewer() != null) return getGraphicalViewer().getRootEditPart(); if (type == IFigure.class && getGraphicalViewer() != null) return ((GraphicalEditPart) getGraphicalViewer().getRootEditPart()) .getFigure(); return super.getAdapter(type); }
/** * @see ILabelProvider#getText(java.lang.Object) */ public String getText(Object o) { if (o instanceof CommandStack) return "Command Stack";//$NON-NLS-1$ if (o instanceof Command) { if (getLabelStyle() == NORMAL_LABEL_STYLE) if (((Command) o).getLabel() == null) return "";//$NON-NLS-1$ else return ((Command) o).getLabel(); if (getLabelStyle() == DEBUG_LABEL_STYLE) if (((Command) o).getDebugLabel() == null) return "";//$NON-NLS-1$ else return ((Command) o).getDebugLabel(); } if (o instanceof Command) return ((Command) o).getLabel(); return "???";//$NON-NLS-1$ }
/** * Constructs a new {@link UndoablePropertySheetPage}. * * @param commandStack * The {@link CommandStack} shared with the editor. * @param undoAction * The global action handler to be registered for undo * operations. * @param redoAction * The global action handler to be registered for redo * operations. */ public UndoablePropertySheetPage(final CommandStack commandStack, IAction undoAction, IAction redoAction) { this.undoHandler = undoAction; this.redoHandler = redoAction; this.commandStack = commandStack; this.commandStackEventListener = new CommandStackEventListener() { public void stackChanged(CommandStackEvent event) { if (event.getDetail() == CommandStack.PRE_UNDO || event.getDetail() == CommandStack.PRE_REDO) { // ensure the property sheet entry looses its current edit // state, otherwise it may revert the undo/redo operation // within valueChanged when the editor is activated again. refresh(); } } }; commandStack.addCommandStackEventListener(commandStackEventListener); setRootEntry(new UndoablePropertySheetEntry(commandStack)); }
/** * @see org.eclipse.ui.views.properties.tabbed.ITabbedPropertySection#setInput(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) */ @Override public final void setInput(IWorkbenchPart part, ISelection selection) { super.setInput(part, selection); if(selection instanceof IStructuredSelection && !selection.isEmpty()) { Object input = ((IStructuredSelection)selection).getFirstElement(); InstallOptionsElement element = getElement(input); if(element != null && !Common.objectsAreEqual(mElement, element)) { mElement = element; CommandStack stack = null; if(input instanceof EditPart) { stack = ((EditPart)input).getViewer().getEditDomain().getCommandStack(); } if(mCommandHelper != null) { if(!Common.objectsAreEqual(stack, mCommandHelper.getCommandStack())) { mCommandHelper.dispose(); createCommandHelper(stack); } } else { createCommandHelper(stack); } inputChanged(mElement); } } }
public void commandStackChanged(EventObject event) { if (((CommandStack) event.getSource()).isDirty()) { this.editor.setDirty(true); } else { boolean oneIsDirty = false; for (Iterator<CommandStack> stacks = this.commandStacks.iterator(); stacks .hasNext();) { CommandStack stack = (CommandStack) stacks.next(); if (!stack.isDirty()) { continue; } oneIsDirty = true; break; } this.editor.setDirty(oneIsDirty); } }
public UnsortPropertySheetPage(CommandStack commandStack, IAction undoAction, IAction redoAction) { super(commandStack, undoAction, redoAction); setSorter(new PropertySheetSorter() { @Override public int compareCategories(String categoryA, String categoryB) { return 0; } @Override public int compare(IPropertySheetEntry entryA, IPropertySheetEntry entryB) { return 0; } @Override public void sort(IPropertySheetEntry[] entries) { // do nothing } }); }
/** * Handle the combo modified event. */ protected void handleComboModified() { int index = combo.getSelectionIndex(); boolean equals = isEqual(index); if (!equals) { CommandStack cs = StackHelper.getStack(propertySheetPage); if (cs == null) return; SetCommand s = new SetCommand(eObject, getFeature(), getFeatureValue(index)); if (s.canExecute()) cs.execute(s); } }
protected void metadataChanged(final MetadataEditorPage page) { final HashMap metadataMap = ((MetadataEditorPage) page).getAllMetadata(); if (metadataMap.keySet().size() > 0) { CommandStack cs = StackHelper.getStack(propertySheetPage); if (cs != null) { CompoundCommand cmd = new CompoundCommand(); for (Iterator iter = metadataMap.entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); cmd.add(new ChangeMetadataCommand((EObject) entry.getKey(), (Metadata[]) entry.getValue(), null)); } if (cmd.canExecute()) { cs.execute(cmd); } } } }
/** * Handle the text modified event. */ protected void handleTextModified() { String newText = text.getText(); boolean equals = isEqual(newText); boolean isTextValid = isTextValid(newText); if (!equals && isTextValid) { CommandStack stack = StackHelper.getDelegatingStack(getPart()); if (stack != null) { Object value = getFeatureValue(newText); if (eObjectList.size() == 1) { /* apply the property change to single selected object */ stack.execute(new SetCommand(eObject, getFeature(), value)); } else { CompoundCommand compoundCommand = new CompoundCommand(); /* apply the property change to all selected elements */ for (Iterator i = eObjectList.iterator(); i.hasNext();) { EObject nextObject = (EObject) i.next(); compoundCommand.add(new SetCommand(nextObject, getFeature(), value)); } stack.execute(compoundCommand); } } } else if (!isTextValid) { setText(getFeatureAsText()); } }
public void dispose() { CommandStack stack = StackHelper.getStack(this); if (stack != null) stack.removeCommandStackListener(this); editor = null; dataResolver = null; selection = null; maxLabelWidth = null; sectionToTab = null; tabListContentProvider = null; sectionsToRefresh = null; super.dispose(); }
/** * This method is called when 'Finish' button is pressed in the wizard. We will create an operation and run it using wizard as execution context. */ public boolean performFinish() { final ContributionContext parent = page.getParentContributionContext(); final Vector children = page.getChildContributionContexts(); CommandStack cs = ((UCMNavMultiPageEditor) workbenchPage.getActiveEditor()).getDelegatingCommandStack(); CompoundCommand cmd = new CompoundCommand(); for (Iterator iter = children.iterator(); iter.hasNext();) { ContributionContext child = (ContributionContext) iter.next(); IncludeContributionContextCommand command = new IncludeContributionContextCommand(parent, child); if (command.canExecute()) cmd.add(command); } // use a command to be undoable. if (cmd.canExecute()) cs.execute(cmd); return true; }
/** * This method is called when 'Finish' button is pressed in the wizard. We will create an operation and run it using wizard as execution context. */ public boolean performFinish() { final EvaluationStrategy parent = page.getParentStrategy(); final Vector children = page.getChildStrategies(); CommandStack cs = ((UCMNavMultiPageEditor) workbenchPage.getActiveEditor()).getDelegatingCommandStack(); CompoundCommand cmd = new CompoundCommand(); for (Iterator iter = children.iterator(); iter.hasNext();) { EvaluationStrategy child = (EvaluationStrategy) iter.next(); IncludeStrategyCommand command = new IncludeStrategyCommand(parent, child); if (command.canExecute()) cmd.add(command); } // use a command to be undoable. if (cmd.canExecute()) cs.execute(cmd); return true; }
/** * This method is called when 'Finish' button is pressed in the wizard. We will create an operation and run it using wizard as execution context. */ public boolean performFinish() { CommandStack cs = ((UCMNavMultiPageEditor) workbenchPage.getActiveEditor()).getDelegatingCommandStack(); CompoundCommand command = new CompoundCommand(); CreateVariableCommand createCmd = new CreateVariableCommand(page.urn, page.getVariableType(), page.getVariableName()); if (page.getVariableType() == ScenarioUtils.sTypeEnumeration) createCmd.setEnumerationType(page2.getSelectedEnumerationType()); command.add(createCmd); for (Iterator iter = page3.getInitializations().keySet().iterator(); iter.hasNext();) { ScenarioDef scenario = (ScenarioDef) iter.next(); command.add(new CreateVariableInitializationCommand(page.getVariableName(), scenario, page3.getInitializations().get(scenario).toString())); } // use a command to be undoable. if (command.canExecute()) cs.execute(command); return true; }
private void execute(Command cmd) { // TODO: Build a compound command instead so that undo in main editor is still possible. UCMNavMultiPageEditor editor = (UCMNavMultiPageEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); CommandStack stack = editor.getDelegatingCommandStack(); if (cmd instanceof ChangeEnumerationTypeCommand && stack.getUndoCommand() instanceof ChangeEnumerationTypeCommand && ((ChangeEnumerationTypeCommand) cmd).getElem() == ((ChangeEnumerationTypeCommand) stack.getUndoCommand()).getElem()) { // replace it, don't increment count stack.undo(); stack.execute(cmd); } else { stack.execute(cmd); executedCommandCount++; } // bug 654 ScenarioUtils.releaseEnvironment(this.urn); }
/** * This method is called when 'Finish' button is pressed in the wizard. We will create an operation and run it using wizard as execution context. */ public boolean performFinish() { final ScenarioDef parent = page.getParentScenario(); final Vector children = page.getChildScenarios(); CommandStack cs = ((UCMNavMultiPageEditor) workbenchPage.getActiveEditor()).getDelegatingCommandStack(); CompoundCommand cmd = new CompoundCommand(); for (Iterator iter = children.iterator(); iter.hasNext();) { ScenarioDef child = (ScenarioDef) iter.next(); IncludeScenarioCommand command = new IncludeScenarioCommand(parent, child); if (command.canExecute()) cmd.add(command); } // use a command to be undoable. if (cmd.canExecute()) cs.execute(cmd); return true; }
/** * This method is called when 'Finish' button is pressed in the wizard. We will create an operation and run it using wizard as execution context. */ public boolean performFinish() { final ScenarioDef parent = page.getParentScenario(); final Vector children = page.getSelectedNodes(); CommandStack cs = ((UCMNavMultiPageEditor) workbenchPage.getActiveEditor()).getDelegatingCommandStack(); CompoundCommand cmd = new CompoundCommand(); for (Iterator iter = children.iterator(); iter.hasNext();) { PathNode child = (PathNode) iter.next(); IncludePathNodeInScenarioCommand command = new IncludePathNodeInScenarioCommand(parent, child); if (command.canExecute()) cmd.add(command); } // use a command to be undoable. if (cmd.canExecute()) cs.execute(cmd); return true; }
/** * This method is called when 'Finish' button is pressed in the wizard. We will create an operation and run it using wizard as execution context. */ public boolean performFinish() { final HashMap code = page.getAllCode(); final HashMap labels = page.getAllLabels(); final HashMap descriptions = page.getAllDescriptions(); CommandStack cs = ((UCMNavMultiPageEditor) workbenchPage.getActiveEditor()).getDelegatingCommandStack(); CompoundCommand cmd = new CompoundCommand(); for (Iterator iter = code.entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); cmd.add(new ChangeCodeCommand((EObject) entry.getKey(), entry.getValue().toString(), labels.get(entry.getKey()).toString(), descriptions.get( entry.getKey()).toString())); } if (cmd.canExecute()) { cs.execute(cmd); } return true; }
/** * This method is called when 'Finish' button is pressed in the wizard. We will create an operation and run it using wizard as execution context. */ public boolean performFinish() { final HashMap metadataMap = page.getAllMetadata(); CommandStack cs = ((UCMNavMultiPageEditor) workbenchPage.getActiveEditor()).getDelegatingCommandStack(); CompoundCommand cmd = new CompoundCommand(); for (Iterator iter = metadataMap.entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); cmd.add(new ChangeMetadataCommand((EObject) entry.getKey(), (Metadata[]) entry.getValue(), null)); } if (cmd.canExecute()) { cs.execute(cmd); } return true; }
/** * Create and run the appropriate {@link seg.jUCMNav.model.commands.create.DuplicateCommand} * * @see org.eclipse.jface.action.IAction#run() */ public void run() { UCMNavMultiPageEditor editor = ((UCMNavMultiPageEditor) getWorkbenchPart()); CommandStack cs = editor.getDelegatingCommandStack(); DuplicateCommand command = null; if (child != null && scenario != null) command = new DuplicateCommand(scenario, child); else if (scenario != null) command = new DuplicateCommand(scenario); else if (group != null) command = new DuplicateCommand(group); else if (strategy != null) command = new DuplicateCommand(strategy); else if (group2 != null) command = new DuplicateCommand(group2); else if (context != null) command = new DuplicateCommand(context); else if (group3 != null) command = new DuplicateCommand(group3); if (command != null) cs.execute(command); }
/** * Create a new traversal listener. Will set the stage for the listener. Creates a new blank URNspec. * * @param originalFilename * the original filename * @param newFilename * the new filename * @param whenToSave * "0" is the final ucmscenarios model instance, "1" means before making it well-formed, "2" means after making it well-formed. */ public MscTraversalListener(String originalFilename, String newFilename, String whenToSave) { this.filename = newFilename; this.whenToSave = whenToSave; htScenarioToMap = new HashMap(); urnspec = ModelCreationFactory.getNewURNspec(true, false, false); // TODO: find a better way to store this information, e.g., use URNspec metadata. urnspec.setAuthor(originalFilename); cs = new CommandStack(); // get rid of default scenario/scenariogroup Command cmd = new DeleteScenarioCommand((ScenarioDef) ((ScenarioGroup) urnspec.getUcmspec().getScenarioGroups().get(0)).getScenarios().get(0)); cs.execute(cmd); cmd = new DeleteStrategiesGroupCommand((ScenarioGroup) urnspec.getUcmspec().getScenarioGroups().get(0)); cs.execute(cmd); cmd = new DeleteStrategyCommand((EvaluationStrategy) urnspec.getGrlspec().getStrategies().get(0)); cs.execute(cmd); cmd = new DeleteStrategiesGroupCommand((StrategiesGroup) urnspec.getGrlspec().getGroups().get(0)); cs.execute(cmd); }
/** * What should be done when the stack changes. * * @param event * the command stack changed event. * * @see org.eclipse.gef.commands.CommandStackListener#commandStackChanged(java.util.EventObject) */ public void commandStackChanged(EventObject event) { if (((CommandStack) event.getSource()).isDirty()) { // at least one command stack is dirty, // so the multi page editor is dirty too this.editor.setDirty(true); } else { // probably a save, we have to check all command stacks boolean oneIsDirty = false; for (Iterator stacks = commandStacks.iterator(); stacks.hasNext();) { CommandStack stack = (CommandStack) stacks.next(); if (stack.isDirty()) { oneIsDirty = true; break; } } this.editor.setDirty(oneIsDirty); } // update the contextual menus / toolbars this.editor.getActionRegistryManager().updateStackActions(); // check to see if there are any new/deleted pages; will have to update tabs. commandStackVerifyPages(event); }
/** * Returns adapters for our editor. * * To note: If we don't have any maps in the file (actually, opened tabs), we will show a default outline page. * * If we don't have an adapter defined here and there are opened tabs, we will delegate to the active editor instead of our superclass. * */ public Object getAdapter(Class adapter) { if (adapter == ActionRegistry.class) return getActionRegistry(); else if (adapter == ZoomManager.class) return getDelegatingZoomManager(); else if (adapter == CommandStack.class) return getDelegatingCommandStack(); // else if (getPageCount() == 0 && adapter == IContentOutlinePage.class) { // return new UrnOutlinePage(this, new UrnTreeViewer()); // } else if( adapter == IContentOutlinePage.class ) { if( soleUrnOutlinePage == null ) { soleUrnOutlinePage = new UrnOutlinePage(this, new UrnTreeViewer()); } return soleUrnOutlinePage; } // delegate to open editor if possible if (getPageCount() > 0) { if (adapter == org.eclipse.ui.views.properties.IPropertySheetPage.class) return new GEFTabbedPropertySheetPage(this); else return getActiveEditor().getAdapter(adapter); } else return super.getAdapter(adapter); }
/** * Sets the current <code>CommandStack</code>. * * @param stack * the <code>CommandStack</code> to set */ public void setCurrentCommandStack(CommandStack stack) { if (currentCommandStack == stack) return; // remove from old command stack if (null != currentCommandStack) currentCommandStack.removeCommandStackListener(this); // set new command stack currentCommandStack = stack; // watch new command stack if (currentCommandStack != null) currentCommandStack.addCommandStackListener(this); // the command stack changed notifyListeners(); }
/** * Get the command stack from the active editor. A command stack is used to allow the undo operation * * @return a commandstack of the editor, or null if it can not be found. */ protected CommandStack getCommandStack() { IEditorPart activeJRXMLEditor = SelectionHelper.getActiveJRXMLEditor(); if (activeJRXMLEditor != null && activeJRXMLEditor instanceof JrxmlEditor) { JrxmlEditor editor = (JrxmlEditor)activeJRXMLEditor; return (CommandStack)editor.getAdapter(CommandStack.class); } return null; }
/** * Drop action, get a TableStyle from the event, the style that will be applied to the table */ @Override protected void handleDrop() { if (getTargetEditPart() instanceof TableEditPart) { MTable tableModel = (MTable) ((EditPart)getTargetEditPart()).getModel(); TemplateStyle style = (TemplateStyle) IOUtils.readFromByteArray((byte[])getCurrentEvent().data); if (style != null && style instanceof TableStyle){ TableStyle selectedStyle = (TableStyle)style; if (tableModel != null) { Shell shell = PlatformUI.getWorkbench().getDisplay().getActiveShell(); MessageDialog question = new MessageDialog(shell, Messages.EditStyleAction_dialogTitle, null, Messages.EditStyleAction_dialogText, MessageDialog.QUESTION, new String[] { Messages.EditStyleAction_dialogUpdateButton, Messages.EditStyleAction_dialogNewButton, Messages.EditStyleAction_dialogCancelButton }, 0); int response = question.open(); // response == 0 update the old styles, response == 1 create new styles, response == 2 cancel the operation if (response == 0 || response == 1) { UpdateStyleCommand updateCommand = new UpdateStyleCommand(tableModel, selectedStyle, response == 0); CommandStack cs = getCommandStack(); if (cs!=null) cs.execute(updateCommand); else updateCommand.execute(); } } } } }