List of usage examples for org.eclipse.jface.preference IPreferenceStore getBoolean
boolean getBoolean(String name);
From source file:com.nokia.s60tools.testdrop.ui.dialogs.TestDropTargetDialog.java
License:Open Source License
/** * Gets and sets target devices to the combo control *//*from w ww . j a va 2s . c o m*/ private void setTargetDevicesToCombo() { DialogContentFactory dialogContentFactory = new DialogContentFactory(); try { IPreferenceStore prefStore = TestDropPlugin.getPrefStore(); boolean addHardwareDevices = prefStore .getBoolean(TestDropPreferenceConstants.TEST_DROP_ENABLE_HARDWARE); dialogContentFactory.setTargetDevicesToCombo(masterDeviceSelectionComboControl, dialogModel, StartUp.getTargetDialogCache(), addHardwareDevices); IResource res = dialogModel.getSelectedProject(); if (res == null) { res = dialogModel.getSelectedCfgFiles()[0]; } String previousDevice = loadDeviceValueForResource(res); if (res != null && previousDevice != null) { String[] deviceItems = masterDeviceSelectionComboControl.getItems(); for (int i = 0; i < deviceItems.length; i++) { if (deviceItems[i].equals(previousDevice)) { masterDeviceSelectionComboControl.select(i); break; } if (deviceItems[i].startsWith(previousDevice)) { masterDeviceSelectionComboControl.select(i); } } if (masterDeviceSelectionComboControl.getSelectionIndex() == -1) { masterDeviceSelectionComboControl.select(0); } } else { masterDeviceSelectionComboControl.select(0); } } catch (Exception e) { LogExceptionHandler.showErrorDialog(e.getMessage()); this.close(); } }
From source file:com.nokia.s60tools.testdrop.ui.preferences.TestDropPreferences.java
License:Open Source License
/** * Gets data which is saved to the preference store *//*www.j a v a2 s . c om*/ private void getPrefStoreValues() { IPreferenceStore prefStore = TestDropPlugin.getPrefStore(); boolean enableHardware = false; enableHardware = prefStore.getBoolean(TestDropPreferenceConstants.TEST_DROP_ENABLE_HARDWARE); enableHardwareTestDropCheck.setSelection(enableHardware); hostText.setEnabled(enableHardware); portText.setEnabled(enableHardware); usernameText.setEnabled(enableHardware); passwordText.setEnabled(enableHardware); confirmPasswordText.setEnabled(enableHardware); testServerConnectionButton.setEnabled(enableHardware); testDropImportButton.setEnabled(enableHardware); testDropPathText.setEnabled(enableHardware && !testDropImportButton.getSelection()); testDropPathBrowseButton.setEnabled(enableHardware && !testDropImportButton.getSelection()); hostText.setText(prefStore.getString(TestDropPreferenceConstants.TEST_DROP_CONNECTION_HOST)); int port = prefStore.getInt(TestDropPreferenceConstants.TEST_DROP_CONNECTION_PORT); if (port != 0) { portText.setText(String.valueOf(port)); } usernameText.setText(prefStore.getString(TestDropPreferenceConstants.TEST_DROP_CONNECTION_USERNAME)); passwordText.setText(prefStore.getString(TestDropPreferenceConstants.TEST_DROP_CONNECTION_PASSWORD)); confirmPasswordText.setText(prefStore.getString(TestDropPreferenceConstants.TEST_DROP_CONNECTION_PASSWORD)); String path = prefStore.getString(TestDropPreferenceConstants.TEST_DROP_PATH); boolean importUsed = prefStore.getBoolean(TestDropPreferenceConstants.TEST_DROP_IMPORT); if (path.length() == 0 && !importUsed) { testDropImportButton.setSelection(true); } else if (path.length() > 0 && !importUsed) { testDropImportButton.setSelection(false); testDropPathText.setEnabled(true); testDropPathText.setText(path); testDropPathBrowseButton.setEnabled(true); } else if (path.length() > 0 && importUsed) { testDropPathText.setText(path); } else if (!importUsed) { testDropPathText.setText(path); testDropPathText.setEnabled(true); testDropPathBrowseButton.setEnabled(true); testDropImportButton.setSelection(false); } String stored = prefStore.getString(TestDropPreferenceConstants.TEST_DROP_SHOW_TEST_RESULT); int count = testResultViewCombo.getItemCount(); boolean found = false; for (int i = 0; i < count; i++) { if (testResultViewCombo.getItem(i).equals(stored)) { testResultViewCombo.select(i); found = true; break; } } if (!found) { testResultViewCombo.select(0); } testResultPathText.setText(prefStore.getString(TestDropPreferenceConstants.TEST_DROP_TEST_RESULT_PATH)); String mode = prefStore.getString(TestDropPreferenceConstants.TEST_DROP_DIALOG_SHOW_MODE); if (mode.equals(DIALOG_SHOW_MODE_ALWAYS)) { alwaysButton.setSelection(true); String cache = prefStore.getString(TestDropPreferenceConstants.TEST_DROP_TARGET_DEVICE_CACHE); int itemCount = targetDeviceListCacheCombo.getItemCount(); for (int i = 0; i < itemCount; i++) { if (targetDeviceListCacheCombo.getItem(i).equals(cache)) { targetDeviceListCacheCombo.select(i); break; } } } else if (mode.equals(DIALOG_SHOW_MODE_DEFAULT)) { alwaysButton.setSelection(false); defaultButton.setSelection(true); setImage.setEnabled(true); targetDeviceListCombo.setEnabled(true); try { getTargetDeviceList(); } catch (Exception ex) { ex.printStackTrace(); } String selectedTagetDevice = prefStore .getString(TestDropPreferenceConstants.TEST_DROP_SELECTED_TARGET_DEVICE); int itemCount = targetDeviceListCombo.getItemCount(); boolean targetDeviceFound = false; for (int i = 0; i < itemCount; i++) { if (targetDeviceListCombo.getItem(i).equals(selectedTagetDevice)) { targetDeviceListCombo.select(i); targetDeviceFound = true; dialogModel.setSelectedMasterDeviceIndex(i); break; } } if (!targetDeviceFound) { targetDeviceListCombo.select(0); LogExceptionHandler.showErrorDialog( Messages.getString("TestDropPreferences.cannotResolveSelectedTargetDeviceException")); } String imageList = prefStore .getString(TestDropPreferenceConstants.TEST_DROP_TARGET_DEVICE_FLASH_IMAGE_LIST); List<File> images = new ArrayList<File>(); if (imageList.length() > 0) { while (imageList.indexOf(";") != -1) { String image = imageList.substring(0, imageList.indexOf(";")); imageList = imageList.substring(image.length() + 1); images.add(new File(image)); } if (imageList.length() > 0) { images.add(new File(imageList)); } } if (images.size() > 0) { dialogModel.getSelectedMasterDevice().setImages(images); StartUp.setDialogModel(dialogModel); } } }
From source file:com.nokia.s60tools.testdrop.util.StartUp.java
License:Open Source License
/** * Checks validity in connection properties * // www .j a v a 2s . c o m * @return true if connection property is valid otherwise false */ private static boolean isValidConnectionProperties() { IPreferenceStore prefStore = TestDropPlugin.getPrefStore(); String host = prefStore.getString(TestDropPreferenceConstants.TEST_DROP_CONNECTION_HOST); int port = prefStore.getInt(TestDropPreferenceConstants.TEST_DROP_CONNECTION_PORT); if (port == 0) { return false; } String username = prefStore.getString(TestDropPreferenceConstants.TEST_DROP_CONNECTION_USERNAME); String password = prefStore.getString(TestDropPreferenceConstants.TEST_DROP_CONNECTION_PASSWORD); String method = null; Path dropPath = null; String path = prefStore.getString(TestDropPreferenceConstants.TEST_DROP_PATH); boolean importUsed = prefStore.getBoolean(TestDropPreferenceConstants.TEST_DROP_IMPORT); if (importUsed) { method = HttpConnection.POST_METHOD; } else { method = HttpConnection.GET_METHOD; dropPath = new Path(path); } if (host.length() == 0 || username.length() == 0) { return false; } else { connectionProperty = new ConnectionPropertyValue(host, port, username, password, null, method, dropPath); return true; } }
From source file:com.nokia.sdt.symbian.dm.WorkspaceSourceFormatting.java
License:Open Source License
/** * Read CDT editor settings for information about tabbing and indentation. *//* w w w . j a v a 2s .c o m*/ private void rereadSettings() { IPreferenceStore cprefs = CUIPlugin.getDefault().getCombinedPreferenceStore(); usingTabs = !cprefs.getBoolean(SPACES_FOR_TABS); indentSpaces = cprefs.getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH); endOfLine = runtimePreferences.get(Platform.PREF_LINE_SEPARATOR, null); if (endOfLine == null) endOfLine = System.getProperty("line.separator"); //$NON-NLS-1$ // NOTE: do not support MacOS-style line endings since // CDT is utterly unprepared to deal with these, // and crashes everywhere if (endOfLine.equals("\r")) { //$NON-NLS-1$ endOfLine = "\n"; //$NON-NLS-1$ Message msg = new Message(IMessage.WARNING, new MessageLocation(ResourcesPlugin.getWorkspace().getRoot().getLocation()), "WorkspaceSourceFormatting.IgnoringMacOSLineEndingSetting", //$NON-NLS-1$ Messages.getString("WorkspaceSourceFormatting.IgnoringMacOSLineEndingSetting"), //$NON-NLS-1$ new String[0]); MessageReporting.emitMessage(msg); } prefsEndOfLine = endOfLine; }
From source file:com.nokia.testfw.stf.scripteditor.editors.ScriptEditorConfiguration.java
License:Open Source License
/** * Creates Script Editor configuration/*from w w w. j ava 2 s .c om*/ */ public ScriptEditorConfiguration() { assistant = new ContentAssistant(); reconciler = new PresentationReconciler(); scriptScanner = new ScriptScanner(); repairer = new DefaultDamagerRepairer(scriptScanner); scripterAssistProcessor = new ScripterAssistProcessor(); IPreferenceStore store = Activator.getDefault().getPreferenceStore(); assistant.enableAutoActivation(store.getBoolean(PreferenceConstants.AUTO_ACTIVATION)); assistant.setAutoActivationDelay(store.getInt(PreferenceConstants.AUTO_ACTIVATION_DELAY)); }
From source file:com.nokia.tools.s60.editor.actions.ConvertAndEditSVGInBitmapEditorAction.java
License:Open Source License
@Override public void doRun(Object element) { final Object _element = element; IPreferenceStore iPreferenceStore = ((AbstractUIPlugin) UtilsPlugin.getDefault()).getPreferenceStore(); boolean ask = !iPreferenceStore.getBoolean(IMediaConstants.PREF_SILENT_SVG_CONVERSION); final IImageHolder holder = getImageHolder(_element); // changed loadImages to true to generate raw image. final ILayer layer = getLayer(true, _element); final IAnimationFrame frame = (IAnimationFrame) (element instanceof IAnimationFrame ? element : null); final boolean _layer = layer != null, _holder = holder != null, _animation = frame != null && !_holder; final boolean _animatedParent = _layer && layer.getParent() instanceof IAnimatedImage; try {/*w ww.j a v a2 s . com*/ int result = Window.OK; SVG2BitmapConversionConfirmationDialog dialog = null; Rectangle rect = new Rectangle(); if (ask) { // display warning dialog about conversion Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); if (_layer) { AbstractGraphicalEditPart _ep = null; if (sizeFromEditPart) { _ep = getGraphicalEditPart(_element); } if (_ep != null && !layer.getParent().isPart()) { Rectangle nr = _ep.getFigure().getBounds(); rect.width = nr.width; rect.height = nr.height; } else { rect.width = layer.getParent().getWidth(); rect.height = layer.getParent().getHeight(); } dialog = new SVG2BitmapConversionConfirmationDialog(shell, rect, layer.supportMask(), layer.supportSoftMask(), true); } else if (_holder) { rect.width = holder.getWidth(); rect.height = holder.getHeight(); dialog = new SVG2BitmapConversionConfirmationDialog(shell, rect, true, true, true); } else if (_animation) { rect.width = frame.getWidth(); rect.height = frame.getHeight(); dialog = new SVG2BitmapConversionConfirmationDialog(shell, rect, false, false, true); } result = dialog.open(); } else { if (_layer) { if (_layer && getGraphicalEditPart(_element) != null && !layer.getParent().isPart()) { Rectangle nr = ((AbstractGraphicalEditPart) getGraphicalEditPart(_element)).getFigure() .getBounds(); rect.width = nr.width; rect.height = nr.height; } else { rect.width = layer.getParent().getWidth(); rect.height = layer.getParent().getHeight(); } } else if (_holder) { rect.width = holder.getWidth(); rect.height = holder.getHeight(); } else if (_animation) { rect.width = frame.getWidth(); rect.height = frame.getHeight(); } } if (result == Window.OK) { int w = rect.width, h = rect.height; if (dialog != null) { w = dialog.getSelectedWidth(); h = dialog.getSelectedHeight(); } boolean _keepMask = !ask ? (iPreferenceStore.getBoolean(IMediaConstants.PREF_SVG_CONVERSION_PRESERVE_MASK)) : dialog.isMaskPreserve(); // ask' = true if (!ask && !iPreferenceStore.getBoolean(IMediaConstants.PREF_SVG_CONVERSION_PRESERVE_MASK)) { _keepMask = true; } // if elements don't supports mask, keepMask = false if (_layer && !_animatedParent) if (!layer.supportMask() && !layer.supportSoftMask()) _keepMask = false; final boolean keepMask = _keepMask; CoreImage rasterized = CoreImage.create(); if (_layer) { // convert SVG to appropriate dimensions IImage img = layer.getParent().getAnotherInstance(w, h); rasterized.init(img.getLayer(layer.getName()).getRAWImage()); // special processing for colour indication items try { IContentData icd = getContentData(element); ISkinnableEntityAdapter ska = (ISkinnableEntityAdapter) icd .getAdapter(ISkinnableEntityAdapter.class); if (ska.isColourIndication()) { rasterized.extractMaskForColourIndicationItem().invertSingleBandMask(); } } catch (Exception e) { e.printStackTrace(); } } else if (_holder) { rasterized.init(holder.getRAWImage(w, h, false)); } else if (_animation) { rasterized.init(frame.getRAWImage(false)); } CoreImage _mask = null; if (keepMask) { // extract mask try { _mask = rasterized.copy().extractMask(true); if (_layer && !layer.supportSoftMask() && !_animatedParent) { _mask = _mask.convertSoftMaskToHard(true); } } catch (Exception es) { es.printStackTrace(); } if (_mask == null) { Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); MessageDialog.openWarning(shell, "Warning", Messages.ExtractMaskAction_error); } } final RenderedImage extractedMask = (_mask == null) ? (null) : (_mask.getAwt()); // remove transparency from image - paint on white BG rasterized.reduceToThreeBand(); RunnableWithParameter callback = new BaseRunnable() { public void run() { if (_holder) { if (getParameter() != null) { EditPart ep = getEditPart(_element); execute(new UndoableImageHolderActionCommand(holder, new Runnable() { public void run() { try { holder.paste(getParameter(), null); if (keepMask) { holder.pasteMask(extractedMask); } } catch (Exception e) { e.printStackTrace(); } } }), ep); } } else if (_layer) { // called from animation editor try { if (_animatedParent) { ((IAnimatedImage) layer.getParent()).getAnimationFrames()[0] .paste(getParameter(), null); } else { layer.paste(getParameter()); } if (keepMask) { if (_animatedParent) { ((IAnimatedImage) layer.getParent()).getAnimationFrames()[0] .pasteMask(extractedMask); } else { layer.pasteMask(extractedMask); } } if (getContentData(_element) != null) { updateGraphicWithCommand(layer, _element); } } catch (Exception e) { e.printStackTrace(); } } else if (_animation) { if (getParameter() != null) { try { frame.paste(getParameter(), null); if (keepMask) { frame.pasteMask(extractedMask); } } catch (Exception e) { e.printStackTrace(); } } } } }; if (_layer) { paintProcessThreads .add(FileChangeWatchThread.open3rdPartyEditor(IMediaConstants.PREF_BITMAP_EDITOR, rasterized.getAwt(), layer.getParent().getId(), callback, true)); } else if (_holder) { String prefix = holder.getImageFile().getName().substring(0, holder.getImageFile().getName().lastIndexOf('.')); paintProcessThreads.add(FileChangeWatchThread.open3rdPartyEditor(null, rasterized.getAwt(), prefix, callback, true)); } else if (_animation) { String prefix = frame.getParent().getId() + frame.getSeqNo(); paintProcessThreads.add(FileChangeWatchThread.open3rdPartyEditor( IMediaConstants.PREF_BITMAP_EDITOR, rasterized.getAwt(), prefix, callback, true)); } } } catch (Throwable e) { handleProcessException(e); } }
From source file:com.nokia.tools.s60.editor.actions.CopyImageAction.java
License:Open Source License
@Override public void doRun(Object sel) { if (clip == null) clip = Toolkit.getDefaultToolkit().getSystemClipboard(); IContentData data = getContentData(sel); ISkinnableEntityAdapter skAdapter = (ISkinnableEntityAdapter) data .getAdapter(ISkinnableEntityAdapter.class); if (sel instanceof IAnimationFrame) { if (isMaskNode()) { IAnimationFrame frame = (IAnimationFrame) sel; if (frame.getMaskFile() != null) { ClipboardHelper.copyImageToClipboard(clip, frame.getMaskFile()); } else { ClipboardHelper.copyImageToClipboard(clip, frame.getMask()); }/* w w w .j av a 2 s . c om*/ } else if (isImageNode()) { IAnimationFrame frame = (IAnimationFrame) sel; if (frame.getImageFile() != null) { ClipboardHelper.copyImageToClipboard(clip, frame.getImageFile()); } else { ClipboardHelper.copyImageToClipboard(clip, frame.getRAWImage(false)); } } else { ((IAnimationFrame) sel).copyImageToClipboard(clip); } return; } // when layer is selected in tree if (sel instanceof ILayer) { try { ILayer l = (ILayer) sel; if (isLayerNode() || isNodeOfType(AbstractAction.TYPE_PART)) { if (skAdapter instanceof S60SkinnableEntityAdapter) { // copy image + mask l.copyImageToClipboard(clip); } } else if (isImageNode()) { // copy image only Object param = l.getFileName(false) == null ? l.getRAWImage() : l.getFileName(true); ClipboardHelper.copyImageToClipboard(clip, param); } else if (isMaskNode()) { // copy mask only if (l.getMaskFileName(true) != null) { ClipboardHelper.copyImageToClipboard(clip, l.getMaskFileName(true)); } else { ClipboardHelper.copyImageToClipboard(clip, l.getMaskImage()); } } else { l.copyImageToClipboard(clip); } } catch (Exception e) { e.printStackTrace(); } return; } IImageHolder holder = getImageHolder(sel); if (holder != null) { holder.copyImageToClipboard(clip); return; } // IContentData data = getContentData(sel); if (data != null) { ISkinnableContentDataAdapter skinableAdapter = (ISkinnableContentDataAdapter) data .getAdapter(ISkinnableContentDataAdapter.class); if (skinableAdapter != null) { skinableAdapter.copyToClipboard(null); return; } /* * ISkinnableEntityAdapter skAdapter = (ISkinnableEntityAdapter) * data .getAdapter(ISkinnableEntityAdapter.class); */ if (skAdapter != null) { if (skAdapter.hasMask()) { } if (skAdapter instanceof S60SkinnableEntityAdapter) skAdapter.copyImageToClipboard(clip); else { copyIdAndFileToClipboard(data, skAdapter); } // if (skAdapter.isNinePiece()) { if (skAdapter.isMultiPiece()) { // copy from 9-piece was performed, show info dialog IPreferenceStore store = S60WorkspacePlugin.getDefault().getPreferenceStore(); Boolean showState = store.getBoolean(skAdapter.getCopyPieceInfo()); // .getBoolean(IMediaConstants.NINE_PIECE_COPY_INFO); if (showState || silent) return; IBrandingManager branding = BrandingExtensionManager.getBrandingManager(); Image image = null; if (branding != null) { image = branding.getIconImageDescriptor().createImage(); } MessageDialog messageDialog = new MessageDialogWithCheckBox( PlatformUI.getWorkbench().getDisplay().getActiveShell(), Messages.CopyAction_9piece_title, image, MultiPieceManager.getCopyMessageText(), // MultipieceHelper.getCopyMessageText(), Messages.CopyAction_9piece_checkbox, false, null, null, null, 2, new String[] { IDialogConstants.OK_LABEL }, 0); messageDialog.open(); if (image != null) { image.dispose(); } // store.setValue(IMediaConstants.NINE_PIECE_COPY_INFO, store.setValue(skAdapter.getCopyPieceInfo(), ((MessageDialogWithCheckBox) messageDialog).getCheckBoxValue()); } } return; } ILayer layer = getLayer(true, sel); if (layer != null) { layer.copyImageToClipboard(clip); } }
From source file:com.nokia.tools.s60.editor.actions.ElevenPieceConvertAction.java
License:Open Source License
@Override protected void doRun(Object element) { IContentData data = getContentData(element); if (data == null) { return;/*from w w w . ja v a 2 s . c o m*/ } if (type == TYPE_CONVERT2SINGLE) { IPreferenceStore iPreferenceStore = UtilsPlugin.getDefault().getPreferenceStore(); boolean ask = !iPreferenceStore.getBoolean(IMediaConstants.PREF_NINE_PIECE_2SINGLE_ASK); boolean replaceGfx = iPreferenceStore.getBoolean(IMediaConstants.PREF_NINE_PIECE_2SINGLE); if (ask) { int result = IDialogConstants.YES_ID; ISkinnableEntityAdapter ska = (ISkinnableEntityAdapter) data .getAdapter(ISkinnableEntityAdapter.class); boolean isElementSkinned = ska.isSkinned(); if (isElementSkinned) { ElevenPieceOperationConfirmDialog dialog = new ElevenPieceOperationConfirmDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), ElevenPieceOperationConfirmDialog.TYPE_2SINGLE); result = dialog.open(); if (result == IDialogConstants.OK_ID) replaceGfx = true; else return; // cancel pressed } else { replaceGfx = false; } /*if (result == IDialogConstants.YES_ID) replaceGfx = true; else if (result == IDialogConstants.NO_ID) replaceGfx = false;*/ } if (ask && iPreferenceStore.getBoolean(IMediaConstants.PREF_NINE_PIECE_2SINGLE_ASK)) { // user selects to remeber settings this time - store // selected option iPreferenceStore.setValue(IMediaConstants.PREF_NINE_PIECE_2SINGLE, replaceGfx); } EditPart ep = getEditPart(element); // special way of update / undo / redo Convert2SingleBitmapCommand cmd = new Convert2SingleBitmapCommand(getContentData(element), ep, replaceGfx); execute(cmd, ep); } else { if (type == TYPE_ELEVEN_PIECE) { IPreferenceStore iPreferenceStore = UtilsPlugin.getDefault().getPreferenceStore(); boolean ask = !iPreferenceStore.getBoolean(IMediaConstants.PREF_SINGLE_PIECE_2NINE_ASK); boolean fillParts = iPreferenceStore.getBoolean(IMediaConstants.PREF_SINGLE_PIECE_2NINE); if (ask) { ElevenPieceOperationConfirmDialog dialog = new ElevenPieceOperationConfirmDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), ElevenPieceOperationConfirmDialog.TYPE_2ELEVEN); int result = dialog.open(); /*if (result == IDialogConstants.YES_ID) fillParts = true; else if (result == IDialogConstants.NO_ID) fillParts = false;*/ if (result == IDialogConstants.OK_ID) fillParts = true; else return; // cancel pressed } if (ask && iPreferenceStore.getBoolean(IMediaConstants.PREF_SINGLE_PIECE_2NINE_ASK)) { // user selects to remeber settings this time - store // selected option iPreferenceStore.setValue(IMediaConstants.PREF_SINGLE_PIECE_2NINE, fillParts); } EditPart ep = getEditPart(element); // special way of update / undo / redo Convert2ElevenBitmapCommand cmd = new Convert2ElevenBitmapCommand(data, ep, fillParts); execute(cmd, ep); } } }
From source file:com.nokia.tools.s60.editor.actions.NinePieceConvertAction.java
License:Open Source License
@Override protected void doRun(Object element) { IContentData data = getContentData(element); if (data == null) { return;//from w ww.j av a2 s. c o m } if (type == TYPE_CONVERT2SINGLE) { IPreferenceStore iPreferenceStore = UtilsPlugin.getDefault().getPreferenceStore(); boolean ask = !iPreferenceStore.getBoolean(IMediaConstants.PREF_NINE_PIECE_2SINGLE_ASK); boolean replaceGfx = iPreferenceStore.getBoolean(IMediaConstants.PREF_NINE_PIECE_2SINGLE); ISkinnableEntityAdapter ska = (ISkinnableEntityAdapter) data.getAdapter(ISkinnableEntityAdapter.class); boolean isElementSkinned = false; if (ask) { int result = IDialogConstants.OK_ID; isElementSkinned = ska.isSkinned(); if (isElementSkinned) { NinePieceOperationConfirmDialog dialog = new NinePieceOperationConfirmDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), NinePieceOperationConfirmDialog.TYPE_2SINGLE); result = dialog.open(); if (result == IDialogConstants.OK_ID) replaceGfx = true; else return; // cancel pressed } else { replaceGfx = false; } } if (ask && iPreferenceStore.getBoolean(IMediaConstants.PREF_NINE_PIECE_2SINGLE_ASK)) { // user selects to remeber settings this time - store // selected option iPreferenceStore.setValue(IMediaConstants.PREF_NINE_PIECE_2SINGLE, replaceGfx); } EditPart ep = getEditPart(element); if (isElementSkinned && !replaceGfx) ska.clearThemeGraphics(); // special way of update / undo / redo Convert2SingleBitmapCommand cmd = new Convert2SingleBitmapCommand(getContentData(element), ep, replaceGfx); execute(cmd, ep); } else { if (type == TYPE_CONVERT2NINE) { IPreferenceStore iPreferenceStore = UtilsPlugin.getDefault().getPreferenceStore(); boolean ask = !iPreferenceStore.getBoolean(IMediaConstants.PREF_SINGLE_PIECE_2NINE_ASK); boolean fillParts = iPreferenceStore.getBoolean(IMediaConstants.PREF_SINGLE_PIECE_2NINE); if (ask) { NinePieceOperationConfirmDialog dialog = new NinePieceOperationConfirmDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), NinePieceOperationConfirmDialog.TYPE_2NINE); int result = dialog.open(); if (result == IDialogConstants.OK_ID) fillParts = true; else return; // cancel pressed } if (ask && iPreferenceStore.getBoolean(IMediaConstants.PREF_SINGLE_PIECE_2NINE_ASK)) { // user selects to remeber settings this time - store // selected option iPreferenceStore.setValue(IMediaConstants.PREF_SINGLE_PIECE_2NINE, fillParts); } EditPart ep = getEditPart(element); // special way of update / undo / redo Convert2NineBitmapCommand cmd = new Convert2NineBitmapCommand(data, ep, fillParts); execute(cmd, ep); } } }
From source file:com.nokia.tools.s60.editor.actions.ThreePieceConvertAction.java
License:Open Source License
@Override protected void doRun(Object element) { IContentData data = getContentData(element); if (data == null) { return;/*from www .j a v a 2s . c o m*/ } if (type == TYPE_CONVERT2SINGLE) { IPreferenceStore iPreferenceStore = UtilsPlugin.getDefault().getPreferenceStore(); boolean ask = !iPreferenceStore.getBoolean(IMediaConstants.PREF_NINE_PIECE_2SINGLE_ASK); boolean replaceGfx = iPreferenceStore.getBoolean(IMediaConstants.PREF_NINE_PIECE_2SINGLE); if (ask) { int result = IDialogConstants.YES_ID; ISkinnableEntityAdapter ska = (ISkinnableEntityAdapter) data .getAdapter(ISkinnableEntityAdapter.class); boolean isElementSkinned = ska.isSkinned(); if (isElementSkinned) { ThreePieceOperationConfirmDialog dialog = new ThreePieceOperationConfirmDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), ThreePieceOperationConfirmDialog.TYPE_2SINGLE); result = dialog.open(); } if (result == IDialogConstants.OK_ID) replaceGfx = true; else return; // cancel pressed } if (ask && iPreferenceStore.getBoolean(IMediaConstants.PREF_NINE_PIECE_2SINGLE_ASK)) { // user selects to remeber settings this time - store // selected option iPreferenceStore.setValue(IMediaConstants.PREF_NINE_PIECE_2SINGLE, replaceGfx); } EditPart ep = getEditPart(element); // special way of update / undo / redo Convert2SingleBitmapCommand cmd = new Convert2SingleBitmapCommand(getContentData(element), ep, replaceGfx); execute(cmd, ep); } else { if (type == TYPE_CONVERT2THREE) { IPreferenceStore iPreferenceStore = UtilsPlugin.getDefault().getPreferenceStore(); boolean ask = !iPreferenceStore.getBoolean(IMediaConstants.PREF_SINGLE_PIECE_2NINE_ASK); boolean fillParts = iPreferenceStore.getBoolean(IMediaConstants.PREF_SINGLE_PIECE_2NINE); if (ask) { ThreePieceOperationConfirmDialog dialog = new ThreePieceOperationConfirmDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), ElevenPieceOperationConfirmDialog.TYPE_2ELEVEN); int result = dialog.open(); if (result == IDialogConstants.OK_ID) fillParts = true; else return; // cancel pressed } if (ask && iPreferenceStore.getBoolean(IMediaConstants.PREF_SINGLE_PIECE_2NINE_ASK)) { // user selects to remeber settings this time - store // selected option iPreferenceStore.setValue(IMediaConstants.PREF_SINGLE_PIECE_2NINE, fillParts); } EditPart ep = getEditPart(element); // special way of update / undo / redo Convert2ThreeBitmapCommand cmd = new Convert2ThreeBitmapCommand(data, ep, fillParts); execute(cmd, ep); } } }