List of usage examples for org.eclipse.jface.preference IPreferenceStore getBoolean
boolean getBoolean(String name);
From source file:com.javadude.antxr.eclipse.ui.actions.TogglePresentationAction.java
License:Open Source License
/** {@inheritDoc} */ public void setEditor(ITextEditor anEditor) { super.setEditor(anEditor); if (anEditor != null) { IPreferenceStore store = AntxrUIPlugin.getDefault().getPreferenceStore(); boolean showSegments = store.getBoolean(IPreferencesConstants.EDITOR_SHOW_SEGMENTS); if (isChecked() != showSegments) { setChecked(showSegments);//from www. ja va 2 s. co m setToolTipText(getToolTipText(showSegments)); } if (anEditor.showsHighlightRangeOnly() != showSegments) { IRegion remembered = anEditor.getHighlightRange(); anEditor.resetHighlightRange(); anEditor.showHighlightRangeOnly(showSegments); if (remembered != null) { anEditor.setHighlightRange(remembered.getOffset(), remembered.getLength(), true); } } } }
From source file:com.joeygibson.eclipse.junitlaunchfixer.Activator.java
License:Open Source License
public void start(BundleContext context) throws Exception { super.start(context); plugin = this; launchManager.addLaunchConfigurationListener(launchConfigurationListener); final IPreferenceStore store = Activator.getDefault().getPreferenceStore(); if (store.getBoolean(PreferenceConstants.P_UPDATE_EXISTING_LAUNCHERS)) { Runnable r = new Runnable() { @Override// w ww . j a va 2 s .c o m public void run() { Shell shell = PlatformUI.getWorkbench().getDisplay().getActiveShell(); ILaunchConfiguration[] launchers = null; try { launchers = launchManager.getLaunchConfigurations(); if (launchers == null || launchers.length == 0) { return; } } catch (CoreException e) { e.printStackTrace(); } List<ILaunchConfiguration> filteredLaunchers = LaunchProcessor .filterNonJUnitLaunchers(launchers); if (filteredLaunchers.size() == 0) { return; } LauncherSelectionDialog dlg = new LauncherSelectionDialog(shell, filteredLaunchers, new ArrayContentProvider(), new LaunchLabelProvider(), "Select launchers to update"); dlg.setHeapSize(store.getString(PreferenceConstants.P_MAX_HEAP)); dlg.setMaxPermSize(store.getString(PreferenceConstants.P_MAX_PERM_SIZE)); dlg.open(); String heapSize = dlg.getHeapSize(); String maxPermSize = dlg.getMaxPermSize(); if (heapSize != null && heapSize.length() > 0 && maxPermSize != null && maxPermSize.length() > 0) { store.setValue(PreferenceConstants.P_MAX_HEAP, heapSize); store.setValue(PreferenceConstants.P_MAX_PERM_SIZE, maxPermSize); Object[] res = dlg.getResult(); if (res != null) { for (Object o : res) { ILaunchConfiguration config = (ILaunchConfiguration) o; LaunchProcessor.processVmArgs(config); } } } } }; PlatformUI.getWorkbench().getDisplay().syncExec(r); store.setValue(PreferenceConstants.P_UPDATE_EXISTING_LAUNCHERS, false); } }
From source file:com.legstar.eclipse.plugin.schemagen.wizards.CobolToXsdWizardRunnable.java
License:Open Source License
/** * Create a model ready to be passed to velocity for ant script generation. * /*from w ww . j av a2 s . co m*/ * @param mainPage wizard page holding target XSD location and parameters * @param cobolToXsdPage the wizard page holding selected COBOL fragment * @return a valid model * @throws InvocationTargetException if model cannot be built */ protected Cob2XsdModel getModel(final MainWizardPage mainPage, final CobolToXsdWizardPage cobolToXsdPage) throws InvocationTargetException { Cob2XsdModel model = new Cob2XsdModel(); model.setProductLocation( AbstractWizard.getPluginInstallLocation(com.legstar.eclipse.plugin.common.Activator.PLUGIN_ID)); /* Store the content of the text box in a temporary file */ File cobolFile; try { cobolFile = File.createTempFile(TEMP_PATTERN, TEMP_SUFFIX); BufferedWriter writer = new BufferedWriter( new OutputStreamWriter(new FileOutputStream(cobolFile), cobolToXsdPage.getCobolFileEncoding())); writer.write(cobolToXsdPage.getCobolFragment()); writer.close(); } catch (IOException e) { throw new InvocationTargetException(e); } /* Temporary file becomes input to generation process */ model.setCobolSourceFilePath(cobolFile.getPath()); model.setTargetDir(new File(getTargetXsdLocation())); model.setTargetXsdFileName(mainPage.getTargetXSDFileName()); IPreferenceStore store = Activator.getDefault().getPreferenceStore(); /* * ------------------------------------------------------------------- * COBOL source format related options */ model.setCodeFormat(CodeFormat.valueOf(store.getString(PreferenceConstants.DEFAULT_CODE_FORMAT))); model.setStartColumn(store.getInt(PreferenceConstants.DEFAULT_START_COLUMN)); model.setEndColumn(store.getInt(PreferenceConstants.DEFAULT_END_COLUMN)); model.setXsdEncoding(store.getString(PreferenceConstants.DEFAULT_XSD_ENCODING)); model.setTargetNamespace(mainPage.getTargetNamespace()); model.setMapConditionsToFacets(store.getBoolean(PreferenceConstants.DEFAULT_XSD_MAP_CONDITIONS_TO_FACETS)); model.setCustomXsltFileName(store.getString(PreferenceConstants.DEFAULT_XSD_CUSTOM_XSLT_FILE_NAME)); model.setNameConflictPrependParentName( store.getBoolean(PreferenceConstants.DEFAULT_XSD_NAME_CONFLICT_PREPEND_PARENT_NAME)); model.setElementNamesStartWithUppercase( store.getBoolean(PreferenceConstants.DEFAULT_XSD_ELEMENT_NAMES_START_WITH_UPPERCASE)); model.setAddLegStarAnnotations(store.getBoolean(PreferenceConstants.DEFAULT_ADD_LEGSTAR_ANNOTATIONS)); model.setCurrencySign(store.getString(PreferenceConstants.DEFAULT_CURRENCY_SIGN)); model.setCurrencySymbol(store.getString(PreferenceConstants.DEFAULT_CURRENCY_SYMBOL)); model.setDecimalPointIsComma(store.getBoolean(PreferenceConstants.DEFAULT_DECIMAL_POINT_IS_COMMA)); model.setNSymbolDbcs(store.getBoolean(PreferenceConstants.DEFAULT_NSYMBOL_DBCS)); model.setQuoteIsQuote(store.getBoolean(PreferenceConstants.DEFAULT_QUOTE_IS_QUOTE)); return model; }
From source file:com.maccasoft.ui.internal.application.ApplicationWorkbenchWindowAdvisor.java
License:Open Source License
@Override @SuppressWarnings("deprecation") public boolean preWindowShellClose() { if (getWorkbench().getWorkbenchWindowCount() > 1) { return true; }/*w ww .j a v a 2 s . co m*/ IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore(); boolean promptOnExit = preferenceStore.getBoolean(EXIT_PROMPT_ON_CLOSE_LAST_WINDOW); if (promptOnExit) { MessageDialogWithToggle dlg = MessageDialogWithToggle.openOkCancelConfirm( getWindowConfigurer().getWindow().getShell(), "Confirm Exit", "Exit Program ?", "Always exit without prompt", false, null, null); if (dlg.getReturnCode() != IDialogConstants.OK_ID) { return false; } if (dlg.getToggleState()) { preferenceStore.setValue(EXIT_PROMPT_ON_CLOSE_LAST_WINDOW, false); Activator.getDefault().savePluginPreferences(); } } return true; }
From source file:com.mentor.nucleus.bp.compare.structuremergeviewer.ModelStructureDiffViewer.java
License:Open Source License
@Override protected void handleSelect(SelectionEvent event) { IPreferenceStore ps = getCompareConfiguration().getPreferenceStore(); if (ps != null && ps.getBoolean(ComparePreferencePage.OPEN_STRUCTURE_COMPARE)) { // single click compare changing allowed if (!shouldProcessOpen()) { return; }/*www .jav a 2 s. c o m*/ } super.handleSelect(event); }
From source file:com.mentor.nucleus.bp.core.common.BridgePointPreferencesStore.java
License:Open Source License
public IPreferenceModel loadModel(IPreferenceStore store, BasePlugin plugin, IPreferenceModel model) { BridgePointPreferencesModel prefs = null; if (model == null) prefs = new BridgePointPreferencesModel(); else {/*from w w w . ja v a 2 s . co m*/ if (!(model instanceof BridgePointPreferencesModel)) { throw new IllegalArgumentException("Cannot load instance of " + model.getClass().getName()); } prefs = (BridgePointPreferencesModel) model; } prefs.parseAllOnResourceChange = store.getString(BridgePointPreferencesStore.PARSE_ALL_ON_RESOURCE_CHANGE); prefs.allowIntToRealPromotion = store.getString(BridgePointPreferencesStore.ALLOW_INT_TO_REAL_PROMOTION); prefs.allowRealToIntCoercion = store.getString(BridgePointPreferencesStore.ALLOW_REAL_TO_INT_COERCION); prefs.allowImplicitComponentAddressing = store .getBoolean(BridgePointPreferencesStore.ALLOW_IMPLICIT_COMPONENT_ADDRESSING); prefs.allowOperationsInWhere = store.getBoolean(BridgePointPreferencesStore.ALLOW_OPERATIONS_IN_WHERE); prefs.enableErrorForEmptySynchronousMessage = store .getBoolean(BridgePointPreferencesStore.ENABLE_ERROR_FOR_EMPTY_SYNCHRONOUS_MESSAGE); prefs.enableErrorForEmptySynchronousMessageRealized = store .getBoolean(BridgePointPreferencesStore.ENABLE_ERROR_FOR_EMPTY_SYNCHRONOUS_MESSAGE_REALIZED); prefs.disableGradients = store.getBoolean(BridgePointPreferencesStore.DISABLE_GRADIENTS); prefs.invertGradients = store.getBoolean(BridgePointPreferencesStore.INVERT_GRADIENTS); prefs.gradientBaseColor = store.getLong(BridgePointPreferencesStore.GRADIENT_BASE_COLOR); if (prefs.gradientBaseColor == 0L) { prefs.gradientBaseColor = 0xc8c8c8; } prefs.exportOAL = store.getString(BridgePointPreferencesStore.EXPORT_OAL); prefs.exportGraphics = store.getString(BridgePointPreferencesStore.EXPORT_GRAPHICS); prefs.messageDirection = store.getString(BridgePointPreferencesStore.MESSAGE_DIRECTION); prefs.showTransitionActions = store.getBoolean(BridgePointPreferencesStore.SHOW_TRANSITION_ACTIONS); prefs.showEventParameters = store.getBoolean(BridgePointPreferencesStore.SHOW_EVENT_PARAMETERS); prefs.enableFLAs = store.getBoolean(BridgePointPreferencesStore.ENABLE_FIXED_LENGTH_ARRAYS); prefs.enableDSAs = store.getBoolean(BridgePointPreferencesStore.ENABLE_DYNAMICALLY_SIZED_ARRAYS); prefs.enableDeterministicVerifier = store .getBoolean(BridgePointPreferencesStore.ENABLE_DETERMINISTIC_VERIFIER); prefs.enableInstanceReferences = store.getBoolean(BridgePointPreferencesStore.ENABLE_INSTANCE_REFERENCES); prefs.enableVerifierAudit = store.getBoolean(BridgePointPreferencesStore.ENABLE_VERIFIER_AUDIT); prefs.enableSelectAudit = store.getInt(BridgePointPreferencesStore.ENABLE_SELECT_AUDIT); prefs.enableRelateAudit = store.getInt(BridgePointPreferencesStore.ENABLE_RELATE_AUDIT); prefs.enableUnrelateAudit = store.getInt(BridgePointPreferencesStore.ENABLE_UNRELATE_AUDIT); prefs.enableDeleteAudit = store.getInt(BridgePointPreferencesStore.ENABLE_DELETE_AUDIT); prefs.startUpTime = store.getInt(BridgePointPreferencesStore.START_UP_TIME); prefs.showGrid = store.getBoolean(BridgePointPreferencesStore.SHOW_GRID); prefs.snapToGrid = store.getBoolean(BridgePointPreferencesStore.SNAP_TO_GRID); prefs.gridSpacing = store.getInt(BridgePointPreferencesStore.GRID_SPACING); prefs.defaultRoutingStyle = store.getString(BridgePointPreferencesStore.DEFAULT_ROUTING_STYLE); prefs.emitRTOData = store.getBoolean(BridgePointPreferencesStore.EMIT_RTO_DATA); prefs.showReferenceRemovalDialog = store.getBoolean(BridgePointPreferencesStore.SHOW_SYNC_DELETION_DIALOG); prefs.showReferenceSyncReport = store.getBoolean(BridgePointPreferencesStore.SHOW_SYNC_REPORT); prefs.useDefaultNamesForNewModelElements = store .getBoolean(BridgePointPreferencesStore.USE_DEFAULT_NAME_FOR_CREATION); return prefs; }
From source file:com.mentor.nucleus.bp.debug.engine.VerifierAuditTest.java
License:Open Source License
public void testVerifierAudit_Fatal() throws InterruptedException { IPreferenceStore store = CorePlugin.getDefault().getPreferenceStore(); store.setValue(BridgePointPreferencesStore.ENABLE_VERIFIER_AUDIT, true); store.setValue(BridgePointPreferencesStore.ENABLE_SELECT_AUDIT, 2); store.setValue(BridgePointPreferencesStore.ENABLE_RELATE_AUDIT, 2); store.setValue(BridgePointPreferencesStore.ENABLE_UNRELATE_AUDIT, 2); store.setValue(BridgePointPreferencesStore.ENABLE_DELETE_AUDIT, 2); store.getBoolean("mine"); IPreferenceStore Console_store = DebugUIPlugin.getDefault().getPreferenceStore(); Component_c component = Component_c .getOneC_COnR8001(PackageableElement_c.getManyPE_PEsOnR8000(Package_c.getOneEP_PKGOnR1401(m_sys))); assertNotNull(component);//ww w. j a v a 2 s . c o m // launch the domain DebugUITestUtilities.setLogActivityAndLaunchForElement(component, m_bp_tree.getControl().getMenu(), m_sys.getName()); Function_c testSixCases = Function_c.getOneS_SYNCOnR8001( PackageableElement_c.getManyPE_PEsOnR8000( Package_c.getManyEP_PKGsOnR8001(PackageableElement_c.getManyPE_PEsOnR8003(component))), new ClassQueryInterface_c() { public boolean evaluate(Object candidate) { return ((Function_c) candidate).getName().equals("testSixCases"); } }); assertNotNull(testSixCases); openPerspectiveAndView("com.mentor.nucleus.bp.debug.ui.DebugPerspective", BridgePointPerspective.ID_MGC_BP_EXPLORER); BPDebugUtils.executeElement(testSixCases); DebugUITestUtilities.waitForExecution(); ComponentInstance_c engine = ComponentInstance_c.getOneI_EXEOnR2955(component); assertNotNull(engine); DebugUITestUtilities.stepOver(engine, 10); // wait for the execution to complete DebugUITestUtilities.waitForBPThreads(m_sys); // compare the trace String fileName = m_workspace_path + "expected_results/verifier/Fatal_testSixCases.result"; IPath expected_path = new Path(fileName); File expected_fh = expected_path.toFile(); String expected_results = TestUtil.getTextFileContents(expected_fh); // get the text representation of the debug tree String actual_results = DebugUITestUtilities.getConsoleText(expected_results); String regex = "\r\n"; String regex1 = "\n"; String replacement = "\n"; expected_results = expected_results.replaceAll(regex, replacement); expected_results = expected_results.replaceAll(regex1, replacement); actual_results = actual_results.replaceAll(regex, replacement); actual_results = actual_results.replaceAll(regex1, replacement); assertEquals(expected_results, actual_results); }
From source file:com.mentor.nucleus.bp.debug.ui.launch.VerifiableElementComposite.java
License:Open Source License
private void createControl() { Composite modelsComp = new Composite(this, SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 1;// w w w. j a va2 s .co m modelsComp.setLayout(layout); GridData data = new GridData(); data.grabExcessHorizontalSpace = true; data.horizontalAlignment = GridData.FILL; data.verticalAlignment = GridData.FILL; data.grabExcessVerticalSpace = true; modelsComp.setLayoutData(data); Label selectModel = new Label(modelsComp, SWT.NONE); selectModel.setText("Select Model(s) to Verify"); GridData d = new GridData(); d = new GridData(); d.grabExcessHorizontalSpace = true; d.horizontalAlignment = GridData.FILL; selectModel.setLayoutData(d); createTableTreeViewer(modelsComp); // Session file selection Composite loggingComp = new Composite(modelsComp, SWT.NONE); GridLayout lay2 = new GridLayout(2, false); loggingComp.setLayout(lay2); GridData sdata = new GridData(); sdata.horizontalAlignment = GridData.FILL; sdata.verticalAlignment = GridData.END; sdata.grabExcessHorizontalSpace = true; sdata.grabExcessVerticalSpace = false; loggingComp.setLayoutData(sdata); Label selectLogging = new Label(loggingComp, SWT.NONE); selectLogging.setText("Log model execution activity"); enableLogInfo = new Button(loggingComp, SWT.CHECK); enableLogInfo.setSelection(true); enableLogInfo.addListener(SWT.Selection, this); enableLogInfo.addListener(SWT.Modify, this); IPreferenceStore store = CorePlugin.getDefault().getPreferenceStore(); boolean defaultDeterministicSetting = store .getBoolean(BridgePointPreferencesStore.ENABLE_DETERMINISTIC_VERIFIER); Label selectDeterministicExecution = new Label(loggingComp, SWT.NONE); selectDeterministicExecution.setText(VerifierPreferences.deterministicExecutionBtnName); selectDeterministicExecution.setToolTipText(VerifierPreferences.deterministicExecutionBtnTip); enableDeterministicExecution = new Button(loggingComp, SWT.CHECK); enableDeterministicExecution.setSelection(defaultDeterministicSetting); enableDeterministicExecution.addListener(SWT.Selection, this); enableDeterministicExecution.addListener(SWT.Modify, this); enableDeterministicExecution.setEnabled(true); enableDeterministicExecution.setToolTipText(VerifierPreferences.deterministicExecutionBtnTip); Label selectSimulatedTime = new Label(loggingComp, SWT.NONE); selectSimulatedTime.setText("Enable simulated time"); enableSimulatedTime = new Button(loggingComp, SWT.CHECK); enableSimulatedTime.setSelection(true); enableSimulatedTime.addListener(SWT.Selection, this); enableSimulatedTime.addListener(SWT.Modify, this); Label executionTimeout = new Label(loggingComp, SWT.NONE); executionTimeout.setText("Execution timeout (seconds)"); executionTimeoutValue = new Text(loggingComp, SWT.SINGLE | SWT.BORDER | SWT.RIGHT); executionTimeoutValue.setEnabled(true); executionTimeoutValue.setEditable(true); executionTimeoutValue.setToolTipText( "Execution will terminate after the specified number of seconds. A value of 0 means execution will not be terminated."); executionTimeoutValue.addListener(SWT.Selection, this); executionTimeoutValue.addListener(SWT.Modify, this); executionTimeoutValue.setTextLimit(9); executionTimeoutValue.setText("0"); executionTimeoutValue.addVerifyListener(new VerifyListener() { public void verifyText(VerifyEvent event) { // Assume we don't allow it event.doit = false; // Get the character typed char myChar = event.character; // Allow 0-9 if (Character.isDigit(myChar)) { event.doit = true; } // Allow backspace if (myChar == '\b') { event.doit = true; } // Allow initialization if (myChar == 0) { event.doit = true; } } }); /** * If deterministic behavior is enabled by default disable the Simtime * control and enable SimTime. */ if (enableDeterministicExecution.getSelection()) { enableSimulatedTime.setSelection(true); enableSimulatedTime.setEnabled(false); } // If the user enables deterministic execution, then we must always // enable SimTime. When deterministic behavior is NOT selected the // user is free to select SimTime or Clocktime enableDeterministicExecution.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (enableDeterministicExecution.getSelection()) { enableSimulatedTime.setSelection(true); enableSimulatedTime.setEnabled(false); } else { enableSimulatedTime.setEnabled(true); } } }); initializeProjectList(); updateControls(); }
From source file:com.mentor.nucleus.bp.debug.ui.launch.VerifiableElementComposite.java
License:Open Source License
public void initializeFromConfiguration(ILaunchConfiguration pConfiguration) { if (pConfiguration instanceof ILaunchConfigurationWorkingCopy) { configuration = ((ILaunchConfigurationWorkingCopy) pConfiguration).getOriginal(); if (configuration == null) { configuration = pConfiguration; }//from w w w .j a v a 2 s. c o m } else { configuration = pConfiguration; } // if the map has not been setup yet, // initialize it here Map<String, Vector<String>> modelMap = selectedModelsMap.get(configuration); if (modelMap == null) { modelMap = new HashMap<String, Vector<String>>(); Set<String> projectSet = projectMap.keySet(); Iterator iterator = projectSet.iterator(); while (iterator.hasNext()) { // for each project store a // vector full of default values String projectName = (String) iterator.next(); Vector<String> vector = getElementVector(projectName); modelMap.put(projectName, vector); } selectedModelsMap.put(configuration, modelMap); } // refresh the tree tableTreeViewer.refresh(); if ((projectMap.size() == 0)) { updateControls(); return; } if ((projectMap == null) || (projectMap.size() == 0)) { updateControls(); } try { Map storedModelMap = configuration.getAttribute(VerifierLaunchConfiguration.ATTR_SELECTEDMODELS, new Hashtable()); Set projectSet = storedModelMap.keySet(); // clear the selection, to allow setting // up the selection correctly tableTreeViewer.setCheckedElements(new Object[0]); Iterator projectIterator = projectSet.iterator(); while (projectIterator.hasNext()) { String projectName = (String) projectIterator.next(); if (projectMap.containsKey(projectName)) { // set model selections of all project updateSelectedModelList(storedModelMap, projectName); updateData(projectMap.get(projectName)); } else { // the previous project is either closed or deleted, // currently not available // use default settings // updateData(); } } boolean logState = configuration.getAttribute(VerifierLaunchConfiguration.ATTR_LOGACTIVITY, false); enableLogInfo.setSelection(logState); boolean enableSim = configuration.getAttribute(VerifierLaunchConfiguration.ATTR_ENABLESIMTIME, false); enableSimulatedTime.setSelection(enableSim); // Use the BridgePoint preference as the default setting for // deterministic behavior IPreferenceStore store = CorePlugin.getDefault().getPreferenceStore(); boolean defaultDeterministicSetting = store .getBoolean(BridgePointPreferencesStore.ENABLE_DETERMINISTIC_VERIFIER); boolean enableDeterminism = configuration .getAttribute(VerifierLaunchConfiguration.ATTR_ENABLEDETERMINISM, defaultDeterministicSetting); enableDeterministicExecution.setSelection(enableDeterminism); // If deterministic behavior is selected SimTime is always used. // If not, the user is allowed to choose SimTime or clock time if (enableDeterminism) { enableSimulatedTime.setSelection(true); enableSimulatedTime.setEnabled(false); } else { enableSimulatedTime.setEnabled(true); } int executionTimeout = configuration.getAttribute(VerifierLaunchConfiguration.ATTR_EXECUTIONTIMEOUT, 0); executionTimeoutValue.setText(String.valueOf(executionTimeout)); } catch (CoreException e) { BPDebugUIPlugin.logError("Unable to get attribute value", e); } }
From source file:com.mentor.nucleus.bp.ui.graphics.commands.ShapeCreationCommand.java
License:Open Source License
@Override public boolean executeWithValidation() { // TODO Auto-generated method stub // grid snap the bounds if necessary ModelTool_c tool = (ModelTool_c) parent.getModelRoot().getInstanceList(ModelTool_c.class) .get(toolId.toString());//from www .j a v a 2 s . co m ElementSpecification_c spec = ElementSpecification_c.getOneGD_ESOnR103(tool); boolean snap = false; if (bounds.getSize().width < Gr_c.Gethotspotsize() * 2) { snap = true; bounds.width = spec.Getdefaultwidth(); } if (bounds.getSize().height < Gr_c.Gethotspotsize() * 2) { snap = true; bounds.height = spec.Getdefaultheight(); } SnapToHelper helper = (SnapToHelper) editPart.getAdapter(SnapToHelper.class); if (helper != null && snap) { PrecisionRectangle newRect = new PrecisionRectangle(); helper.snapRectangle(null, PositionConstants.VERTICAL | PositionConstants.HORIZONTAL, new PrecisionRectangle(bounds), newRect); bounds.translate(newRect.getLocation()); // handle height and width as well PrecisionPoint delta = new PrecisionPoint(); helper.snapPoint(null, PositionConstants.HORIZONTAL | PositionConstants.VERTICAL, new PrecisionPoint(bounds.getRight().x, bounds.getBottom().y), delta); bounds.width = bounds.width + delta.x; bounds.height = bounds.height + delta.y; } editPart.getFigure().translateToRelative(bounds); UUID shapeId = parent.Createshape(true, toolId); newShape = (Shape_c) parent.getModelRoot().getInstanceList(Shape_c.class).get(shapeId.toString()); if (newShape != null) { Graphelement_c elem = Graphelement_c.getOneDIM_GEOnR23(GraphicalElement_c.getOneGD_GEOnR2(newShape)); Graphnode_c node = Graphnode_c.getOneDIM_NDOnR19(newShape); elem.setPositionx(bounds.x); elem.setPositiony(bounds.y); node.setWidth(bounds.width); node.setHeight(bounds.height); DiagramEditPart diagramPart = (DiagramEditPart) editPart.getViewer().getContents(); diagramPart.resizeContainer(); refreshDiagram(); // rename IPreferenceStore store = CorePlugin.getDefault().getPreferenceStore(); boolean option = store.getBoolean(BridgePointPreferencesStore.USE_DEFAULT_NAME_FOR_CREATION); if (!option) { GraphicalElement_c createdElement = GraphicalElement_c.getOneGD_GEOnR2(newShape); String oldName = RenameActionUtil .getElementName((NonRootModelElement) createdElement.getRepresents()); //Cl_c.Getname(createdElement.getRepresents()); Class<? extends Object> classType = createdElement.getRepresents().getClass(); if ((classType == ImportedClass_c.class) || (classType == ComponentReference_c.class)) { return true; } else { boolean performRename = UIUtil.inputDialog(null, "Element Creation", "Enter the name:", oldName, UIUtil.newRenameValidator((ModelElement) createdElement.getRepresents())); if (performRename) { String proposedName = UIUtil.inputDialogResult; RenameActionUtil.setElementName((NonRootModelElement) createdElement.getRepresents(), proposedName); ((NonRootModelElement) createdElement.getRepresents()).setComponent(null); return true; } else { return false; } } } else { return true; } } else { return false; } }