List of usage examples for org.eclipse.jface.dialogs MessageDialog WARNING
int WARNING
To view the source code for org.eclipse.jface.dialogs MessageDialog WARNING.
Click Source Link
From source file:be.ibridge.kettle.chef.Chef.java
License:LGPL
public boolean quitFile() { boolean exit = true; boolean showWarning = true; log.logDetailed(toString(), "Quit application."); //$NON-NLS-1$ saveSettings();//from w w w . j a v a 2 s .c o m if (jobMeta.hasChanged()) { MessageBox mb = new MessageBox(shell, SWT.YES | SWT.NO | SWT.CANCEL | SWT.ICON_WARNING); mb.setMessage(Messages.getString("Chef.Dialog.FileChangedSaveFirst.Message")); //$NON-NLS-1$ mb.setText(Messages.getString("Chef.Dialog.FileChangedSaveFirst.Title")); //$NON-NLS-1$ int answer = mb.open(); switch (answer) { case SWT.YES: saveFile(); exit = true; showWarning = false; break; case SWT.NO: exit = true; showWarning = false; break; case SWT.CANCEL: exit = false; showWarning = false; break; } } // System.out.println("exit="+exit+", showWarning="+showWarning+", running="+spoonlog.isRunning()+", showExitWarning="+props.showExitWarning()); // Show warning on exit when spoon is still running // Show warning on exit when a warning needs to be displayed, but only if we didn't ask to save before. (could have pressed cancel then!) // if ((exit && cheflog.isRunning()) || (exit && showWarning && props.showExitWarning())) { String message = Messages.getString("Chef.Dialog.ExitApplicationAreYouSure.Message"); //$NON-NLS-1$ if (cheflog.isRunning()) message = Messages.getString("Chef.Dialog.ExitApplicationAreYouSure.MessageRunning"); //$NON-NLS-1$ MessageDialogWithToggle md = new MessageDialogWithToggle(shell, Messages.getString("Chef.Dialog.ExitApplicationAreYouSure.Title"), //$NON-NLS-1$ null, message, MessageDialog.WARNING, new String[] { Messages.getString("System.Button.Yes"), //$NON-NLS-1$ Messages.getString("System.Button.No") }, //$NON-NLS-1$ 1, Messages.getString("Chef.Dialog.ExitApplicationAreYouSure.Toggle"), //$NON-NLS-1$ !props.showExitWarning()); int idx = md.open(); props.setExitWarningShown(!md.getToggleState()); props.saveProps(); if ((idx & 0xFF) == 1) exit = false; // No selected: don't exit! else exit = true; } if (exit) dispose(); return exit; }
From source file:be.ibridge.kettle.job.JobMeta.java
License:LGPL
public void loadXML(Node jobnode, Repository rep) throws KettleXMLException { Props props = null;/* www .j a v a 2s . c o m*/ if (Props.isInitialized()) props = Props.getInstance(); try { // clear the jobs; clear(); // // get job info: // name = XMLHandler.getTagValue(jobnode, "name"); //$NON-NLS-1$ // Changed user/date modifiedUser = XMLHandler.getTagValue(jobnode, "modified_user"); //$NON-NLS-1$ String modDate = XMLHandler.getTagValue(jobnode, "modified_date"); //$NON-NLS-1$ if (modDate != null) { modifiedDate = new Value(STRING_MODIFIED_DATE, modDate); modifiedDate.setType(Value.VALUE_TYPE_DATE); } // Load the default list of databases // Read objects from the shared XML file & the repository try { sharedObjectsFile = XMLHandler.getTagValue(jobnode, "info", "shared_objects_file"); //$NON-NLS-1$ //$NON-NLS-2$ readSharedObjects(rep); } catch (Exception e) { LogWriter.getInstance().logError(toString(), Messages.getString("JobMeta.ErrorReadingSharedObjects.Message", e.toString())); // $NON-NLS-1$ //$NON-NLS-1$ LogWriter.getInstance().logError(toString(), Const.getStackTracker(e)); } // // Read the database connections // int nr = XMLHandler.countNodes(jobnode, "connection"); //$NON-NLS-1$ for (int i = 0; i < nr; i++) { Node dbnode = XMLHandler.getSubNodeByNr(jobnode, "connection", i); //$NON-NLS-1$ DatabaseMeta dbcon = new DatabaseMeta(dbnode); DatabaseMeta exist = findDatabase(dbcon.getName()); if (exist == null) { addDatabase(dbcon); } else { boolean askOverwrite = Props.isInitialized() ? props.askAboutReplacingDatabaseConnections() : false; boolean overwrite = Props.isInitialized() ? props.replaceExistingDatabaseConnections() : true; if (askOverwrite) { // That means that we have a Display variable set in Props... if (props.getDisplay() != null) { Shell shell = props.getDisplay().getActiveShell(); MessageDialogWithToggle md = new MessageDialogWithToggle(shell, "Warning", null, Messages.getString("JobMeta.Dialog.ConnectionExistsOverWrite.Message", //$NON-NLS-1$ dbcon.getName()) //$NON-NLS-2$ , MessageDialog.WARNING, new String[] { Messages.getString("System.Button.Yes"), //$NON-NLS-1$ Messages.getString("System.Button.No") }, //$NON-NLS-1$ 1, Messages.getString( "JobMeta.Dialog.ConnectionExistsOverWrite.DontShowAnyMoreMessage"), //$NON-NLS-1$ !props.askAboutReplacingDatabaseConnections()); int idx = md.open(); props.setAskAboutReplacingDatabaseConnections(!md.getToggleState()); overwrite = ((idx & 0xFF) == 0); // Yes means: overwrite } } if (overwrite) { int idx = indexOfDatabase(exist); removeDatabase(idx); addDatabase(idx, dbcon); } } } /* * Get the log database connection & log table */ String logcon = XMLHandler.getTagValue(jobnode, "logconnection"); //$NON-NLS-1$ logconnection = findDatabase(logcon); logTable = XMLHandler.getTagValue(jobnode, "logtable"); //$NON-NLS-1$ useBatchId = "Y".equalsIgnoreCase(XMLHandler.getTagValue(jobnode, "use_batchid")); //$NON-NLS-1$ //$NON-NLS-2$ batchIdPassed = "Y".equalsIgnoreCase(XMLHandler.getTagValue(jobnode, "pass_batchid")); //$NON-NLS-1$ //$NON-NLS-2$ logfieldUsed = "Y".equalsIgnoreCase(XMLHandler.getTagValue(jobnode, "use_logfield")); //$NON-NLS-1$ //$NON-NLS-2$ /* * read the job entries... */ Node entriesnode = XMLHandler.getSubNode(jobnode, "entries"); //$NON-NLS-1$ int tr = XMLHandler.countNodes(entriesnode, "entry"); //$NON-NLS-1$ for (int i = 0; i < tr; i++) { Node entrynode = XMLHandler.getSubNodeByNr(entriesnode, "entry", i); //$NON-NLS-1$ // System.out.println("Reading entry:\n"+entrynode); JobEntryCopy je = new JobEntryCopy(entrynode, databases, rep); JobEntryCopy prev = findJobEntry(je.getName(), 0, true); if (prev != null) { if (je.getNr() == 0) // See if the #0 already exists! { // Replace previous version with this one: remove it first int idx = indexOfJobEntry(prev); removeJobEntry(idx); } else if (je.getNr() > 0) // Use previously defined JobEntry info! { je.setEntry(prev.getEntry()); // See if entry already exists... prev = findJobEntry(je.getName(), je.getNr(), true); if (prev != null) // remove the old one! { int idx = indexOfJobEntry(prev); removeJobEntry(idx); } } } // Add the JobEntryCopy... addJobEntry(je); } Node hopsnode = XMLHandler.getSubNode(jobnode, "hops"); //$NON-NLS-1$ int ho = XMLHandler.countNodes(hopsnode, "hop"); //$NON-NLS-1$ for (int i = 0; i < ho; i++) { Node hopnode = XMLHandler.getSubNodeByNr(hopsnode, "hop", i); //$NON-NLS-1$ JobHopMeta hi = new JobHopMeta(hopnode, this); jobhops.add(hi); } // Read the notes... Node notepadsnode = XMLHandler.getSubNode(jobnode, "notepads"); //$NON-NLS-1$ int nrnotes = XMLHandler.countNodes(notepadsnode, "notepad"); //$NON-NLS-1$ for (int i = 0; i < nrnotes; i++) { Node notepadnode = XMLHandler.getSubNodeByNr(notepadsnode, "notepad", i); //$NON-NLS-1$ NotePadMeta ni = new NotePadMeta(notepadnode); notes.add(ni); } // Do we have the special entries? // if (findJobEntry(STRING_SPECIAL_START, 0, true) == null) addJobEntry(JobMeta.createStartEntry()); // TODO: remove this // if (findJobEntry(STRING_SPECIAL_DUMMY, 0, true) == null) addJobEntry(JobMeta.createDummyEntry()); // TODO: remove this clearChanged(); } catch (Exception e) { throw new KettleXMLException(Messages.getString("JobMeta.Exception.UnableToLoadJobFromXMLNode"), e); //$NON-NLS-1$ } finally { setInternalKettleVariables(); } }
From source file:be.ibridge.kettle.spoon.Spoon.java
License:LGPL
public void verifyCopyDistribute(TransMeta transMeta, StepMeta fr) { int nrNextSteps = transMeta.findNrNextSteps(fr); // don't show it for 3 or more hops, by then you should have had the message if (nrNextSteps == 2) { boolean distributes = false; if (props.showCopyOrDistributeWarning()) { MessageDialogWithToggle md = new MessageDialogWithToggle(shell, Messages.getString("System.Warning"), //"Warning!" null,//from w w w . j a v a 2s .co m Messages.getString("Spoon.Dialog.CopyOrDistribute.Message", fr.getName(), Integer.toString(nrNextSteps)), MessageDialog.WARNING, new String[] { Messages.getString("Spoon.Dialog.CopyOrDistribute.Copy"), Messages.getString("Spoon.Dialog.CopyOrDistribute.Distribute") }, //"Copy Distribute 0, Messages.getString("Spoon.Message.Warning.NotShowWarning"), //"Please, don't show this warning anymore." !props.showCopyOrDistributeWarning()); int idx = md.open(); props.setShowCopyOrDistributeWarning(!md.getToggleState()); props.saveProps(); distributes = (idx & 0xFF) == 1; } if (distributes) { fr.setDistributes(true); } else { fr.setDistributes(false); } refreshTree(); refreshGraph(); } }
From source file:be.ibridge.kettle.spoon.Spoon.java
License:LGPL
public boolean quitFile() { log.logDetailed(toString(), Messages.getString("Spoon.Log.QuitApplication"));//"Quit application." boolean exit = true; saveSettings();//w ww .ja va 2 s .c o m if (props.showExitWarning()) { MessageDialogWithToggle md = new MessageDialogWithToggle(shell, Messages.getString("System.Warning"), //"Warning!" null, Messages.getString("Spoon.Message.Warning.PromptExit"), // Are you sure you want to exit? MessageDialog.WARNING, new String[] { Messages.getString("Spoon.Message.Warning.Yes"), Messages.getString("Spoon.Message.Warning.No") }, //"Yes", "No" 1, Messages.getString("Spoon.Message.Warning.NotShowWarning"), //"Please, don't show this warning anymore." !props.showExitWarning()); int idx = md.open(); props.setExitWarningShown(!md.getToggleState()); props.saveProps(); if ((idx & 0xFF) == 1) return false; // No selected: don't exit! } // Check all tabs to see if we can close them... List list = new ArrayList(); list.addAll(tabMap.values()); for (Iterator iter = list.iterator(); iter.hasNext() && exit;) { TabMapEntry mapEntry = (TabMapEntry) iter.next(); TabItemInterface itemInterface = mapEntry.getObject(); if (!itemInterface.canBeClosed()) { // Show the tab tabfolder.setSelection(mapEntry.getTabItem()); // Unsaved work that needs to changes to be applied? // int reply = itemInterface.showChangedWarning(); if (reply == SWT.YES) { exit = itemInterface.applyChanges(); } else { if (reply == SWT.CANCEL) { exit = false; } else // SWT.NO { exit = true; } } /* if (mapEntry.getObject() instanceof SpoonGraph) { TransMeta transMeta = (TransMeta) mapEntry.getObject().getManagedObject(); if (transMeta.hasChanged()) { // Show the transformation in question // tabfolder.setSelection( mapEntry.getTabItem() ); // Ask if we should save it before closing... MessageBox mb = new MessageBox(shell, SWT.YES | SWT.NO | SWT.CANCEL | SWT.ICON_WARNING ); mb.setMessage(Messages.getString("Spoon.Dialog.SaveChangedFile.Message", makeGraphTabName(transMeta)));//"File has changed! Do you want to save first?" mb.setText(Messages.getString("Spoon.Dialog.SaveChangedFile.Title"));//"Warning!" int answer = mb.open(); switch(answer) { case SWT.YES: exit=saveFile(transMeta); break; case SWT.NO: exit=true; break; case SWT.CANCEL: exit=false; break; } } } // A running transformation? // if (mapEntry.getObject() instanceof SpoonLog) { SpoonLog spoonLog = (SpoonLog) mapEntry.getObject(); if (spoonLog.isRunning()) { if (reply==SWT.NO) exit=false; // No selected: don't exit! } } */ } } if (exit) // we have asked about it all and we're still here. Now close all the tabs, stop the running transformations { for (Iterator iter = list.iterator(); iter.hasNext() && exit;) { TabMapEntry mapEntry = (TabMapEntry) iter.next(); if (!mapEntry.getObject().canBeClosed()) { // Unsaved transformation? // if (mapEntry.getObject() instanceof SpoonGraph) { TransMeta transMeta = (TransMeta) mapEntry.getObject().getManagedObject(); if (transMeta.hasChanged()) { mapEntry.getTabItem().dispose(); } } // A running transformation? // if (mapEntry.getObject() instanceof SpoonLog) { SpoonLog spoonLog = (SpoonLog) mapEntry.getObject(); if (spoonLog.isRunning()) { spoonLog.stop(); mapEntry.getTabItem().dispose(); } } } } } if (exit) dispose(); return exit; }
From source file:be.ibridge.kettle.trans.step.BaseStepDialog.java
License:LGPL
/** * Gets unused fields from previous steps and inserts them as rows into a table view. * @param row the input fields// ww w . j ava 2s. c o m * @param tableView the table view to modify * @param keyColumn the column in the table view to match with the names of the fields, checks for existance if >0 * @param nameColumn the column numbers in which the name should end up in * @param dataTypeColumn the target column numbers in which the data type should end up in * @param lengthColumn the length column where the length should end up in (if >0) * @param precisionColumn the length column where the precision should end up in (if >0) * @param listener A listener that you can use to do custom modifications to the inserted table item, based on a value from the provided row */ public static final void getFieldsFromPrevious(Row row, TableView tableView, int keyColumn, int nameColumn[], int dataTypeColumn[], int lengthColumn, int precisionColumn, TableItemInsertListener listener) { if (row == null || row.size() == 0) return; // nothing to do Table table = tableView.table; // get a list of all the non-empty keys (names) // List keys = new ArrayList(); for (int i = 0; i < table.getItemCount(); i++) { TableItem tableItem = table.getItem(i); String key = tableItem.getText(keyColumn); if (!Const.isEmpty(key) && keys.indexOf(key) < 0) keys.add(key); } int choice = 0; if (keys.size() > 0) { // Ask what we should do with the existing data in the step. // MessageDialog md = new MessageDialog(tableView.getShell(), Messages.getString("BaseStepDialog.GetFieldsChoice.Title"), //"Warning!" null, Messages.getString("BaseStepDialog.GetFieldsChoice.Message", "" + keys.size(), "" + row.size()), MessageDialog.WARNING, new String[] { Messages.getString("BaseStepDialog.AddNew"), Messages.getString("BaseStepDialog.Add"), Messages.getString("BaseStepDialog.ClearAndAdd"), Messages.getString("BaseStepDialog.Cancel"), }, 0); int idx = md.open(); choice = idx & 0xFF; } if (choice == 3 || choice == 255 /* 255 = escape pressed */) return; // Cancel clicked if (choice == 2) { tableView.clearAll(false); } for (int i = 0; i < row.size(); i++) { Value v = row.getValue(i); boolean add = true; if (choice == 0) // hang on, see if it's not yet in the table view { if (keys.indexOf(v.getName()) >= 0) add = false; } if (add) { TableItem tableItem = new TableItem(table, SWT.NONE); for (int c = 0; c < nameColumn.length; c++) { tableItem.setText(nameColumn[c], Const.NVL(v.getName(), "")); } for (int c = 0; c < dataTypeColumn.length; c++) { tableItem.setText(dataTypeColumn[c], v.getTypeDesc()); } if (lengthColumn > 0) { if (v.getLength() >= 0) tableItem.setText(lengthColumn, Integer.toString(v.getLength())); } if (precisionColumn > 0) { if (v.getPrecision() >= 0) tableItem.setText(precisionColumn, Integer.toString(v.getPrecision())); } if (listener != null) { if (!listener.tableItemInserted(tableItem, v)) { tableItem.dispose(); // remove it again } } } } tableView.removeEmptyRows(); tableView.setRowNums(); tableView.optWidth(true); }
From source file:be.ibridge.kettle.trans.step.denormaliser.DenormaliserDialog.java
License:LGPL
private void ok() { int sizegroup = wGroup.nrNonEmpty(); int nrfields = wTarget.nrNonEmpty(); input.setKeyField(wKeyField.getText()); input.allocate(sizegroup, nrfields); for (int i = 0; i < sizegroup; i++) { TableItem item = wGroup.getNonEmpty(i); input.getGroupField()[i] = item.getText(1); }//from w ww . j ava 2 s. com for (int i = 0; i < nrfields; i++) { DenormaliserTargetField field = new DenormaliserTargetField(); TableItem item = wTarget.getNonEmpty(i); field.setTargetName(item.getText(1)); field.setFieldName(item.getText(2)); field.setKeyValue(item.getText(3)); field.setTargetType(item.getText(4)); field.setTargetFormat(item.getText(5)); field.setTargetLength(Const.toInt(item.getText(6), -1)); field.setTargetPrecision(Const.toInt(item.getText(7), -1)); field.setTargetCurrencySymbol(item.getText(8)); field.setTargetDecimalSymbol(item.getText(9)); field.setTargetGroupingSymbol(item.getText(10)); field.setTargetNullString(item.getText(11)); field.setTargetAggregationType(item.getText(12)); input.getDenormaliserTargetField()[i] = field; } stepname = wStepname.getText(); if ("Y".equalsIgnoreCase(props.getCustomParameter(STRING_SORT_WARNING_PARAMETER, "Y"))) //$NON-NLS-1$ //$NON-NLS-2$ { MessageDialogWithToggle md = new MessageDialogWithToggle(shell, Messages.getString("DenormaliserDialog.Unpivot.DialogTitle"), //$NON-NLS-1$ null, Messages.getString("DenormaliserDialog.Unpivot.DialogMessage", Const.CR, Const.CR), //$NON-NLS-1$ //$NON-NLS-2$ MessageDialog.WARNING, new String[] { Messages.getString("DenormaliserDialog.WarningMessage.Option.1") }, //$NON-NLS-1$ 0, Messages.getString("DenormaliserDialog.WarningMessage.Option.2"), //$NON-NLS-1$ "N".equalsIgnoreCase(props.getCustomParameter(STRING_SORT_WARNING_PARAMETER, "Y")) //$NON-NLS-1$ //$NON-NLS-2$ ); md.open(); props.setCustomParameter(STRING_SORT_WARNING_PARAMETER, md.getToggleState() ? "N" : "Y"); //$NON-NLS-1$ //$NON-NLS-2$ props.saveProps(); } dispose(); }
From source file:be.ibridge.kettle.trans.step.groupby.GroupByDialog.java
License:LGPL
private void ok() { int sizegroup = wGroup.nrNonEmpty(); int nrfields = wAgg.nrNonEmpty(); input.setPrefix(wPrefix.getText());//from w w w . j av a 2s . co m input.setDirectory(wSortDir.getText()); input.setLineNrInGroupField(wLineNrField.getText()); input.allocate(sizegroup, nrfields); for (int i = 0; i < sizegroup; i++) { TableItem item = wGroup.getNonEmpty(i); input.getGroupField()[i] = item.getText(1); } for (int i = 0; i < nrfields; i++) { TableItem item = wAgg.getNonEmpty(i); input.getAggregateField()[i] = item.getText(1); input.getSubjectField()[i] = item.getText(2); input.getAggregateType()[i] = GroupByMeta.getType(item.getText(3)); } stepname = wStepname.getText(); if ("Y".equalsIgnoreCase(props.getCustomParameter(STRING_SORT_WARNING_PARAMETER, "Y"))) //$NON-NLS-1$ //$NON-NLS-2$ { MessageDialogWithToggle md = new MessageDialogWithToggle(shell, Messages.getString("GroupByDialog.GroupByWarningDialog.DialogTitle"), //$NON-NLS-1$ null, Messages.getString("GroupByDialog.GroupByWarningDialog.DialogMessage", Const.CR) + Const.CR, //$NON-NLS-1$ //$NON-NLS-2$ MessageDialog.WARNING, new String[] { Messages.getString("GroupByDialog.GroupByWarningDialog.Option1") }, //$NON-NLS-1$ 0, Messages.getString("GroupByDialog.GroupByWarningDialog.Option2"), //$NON-NLS-1$ "N".equalsIgnoreCase(props.getCustomParameter(STRING_SORT_WARNING_PARAMETER, "Y")) //$NON-NLS-1$ //$NON-NLS-2$ ); md.open(); props.setCustomParameter(STRING_SORT_WARNING_PARAMETER, md.getToggleState() ? "N" : "Y"); //$NON-NLS-1$ //$NON-NLS-2$ props.saveProps(); } dispose(); }
From source file:be.ibridge.kettle.trans.step.uniquerows.UniqueRowsDialog.java
License:LGPL
private void ok() { int nrfields = wFields.nrNonEmpty(); input.allocate(nrfields);/*w w w.ja v a 2s . c o m*/ for (int i = 0; i < nrfields; i++) { TableItem item = wFields.getNonEmpty(i); input.getCompareFields()[i] = item.getText(1); input.getCaseInsensitive()[i] = "Y".equalsIgnoreCase(item.getText(2)); //$NON-NLS-1$ } input.setCountField(wCountField.getText()); input.setCountRows(wCount.getSelection()); stepname = wStepname.getText(); // return value if ("Y".equalsIgnoreCase(props.getCustomParameter(STRING_SORT_WARNING_PARAMETER, "Y"))) //$NON-NLS-1$ //$NON-NLS-2$ { MessageDialogWithToggle md = new MessageDialogWithToggle(shell, Messages.getString("UniqueRowsDialog.InputNeedSort.DialogTitle"), //$NON-NLS-1$ null, Messages.getString("UniqueRowsDialog.InputNeedSort.DialogMessage", Const.CR) + Const.CR, //$NON-NLS-1$ //$NON-NLS-2$ MessageDialog.WARNING, new String[] { Messages.getString("UniqueRowsDialog.InputNeedSort.Option1") }, //$NON-NLS-1$ 0, Messages.getString("UniqueRowsDialog.InputNeedSort.Option2"), //$NON-NLS-1$ "N".equalsIgnoreCase(props.getCustomParameter(STRING_SORT_WARNING_PARAMETER, "Y")) //$NON-NLS-1$ //$NON-NLS-2$ ); md.open(); props.setCustomParameter(STRING_SORT_WARNING_PARAMETER, md.getToggleState() ? "N" : "Y"); //$NON-NLS-1$ //$NON-NLS-2$ props.saveProps(); } dispose(); }
From source file:be.ibridge.kettle.trans.TransMeta.java
License:LGPL
/** * Parse a file containing the XML that describes the transformation. *//from w ww . ja v a 2 s. c om * @param transnode The XML node to load from * @param rep The repository to load the default list of database connections from (null if no repository is available) * @param setInternalVariables true if you want to set the internal variables based on this transformation information * @throws KettleXMLException */ public void loadXML(Node transnode, Repository rep, boolean setInternalVariables) throws KettleXMLException { Props props = null; if (Props.isInitialized()) { props = Props.getInstance(); } try { // Clear the transformation clearUndo(); clear(); // Read all the database connections from the repository to make sure that we don't overwrite any there by loading from XML. try { sharedObjectsFile = XMLHandler.getTagValue(transnode, "info", "shared_objects_file"); //$NON-NLS-1$ //$NON-NLS-2$ readSharedObjects(rep); } catch (Exception e) { LogWriter.getInstance().logError(toString(), Messages.getString("TransMeta.ErrorReadingSharedObjects.Message", e.toString())); LogWriter.getInstance().logError(toString(), Const.getStackTracker(e)); } // Handle connections int n = XMLHandler.countNodes(transnode, DatabaseMeta.XML_TAG); //$NON-NLS-1$ log.logDebug(toString(), Messages.getString("TransMeta.Log.WeHaveConnections", String.valueOf(n))); //$NON-NLS-1$ //$NON-NLS-2$ for (int i = 0; i < n; i++) { log.logDebug(toString(), Messages.getString("TransMeta.Log.LookingAtConnection") + i); //$NON-NLS-1$ Node nodecon = XMLHandler.getSubNodeByNr(transnode, DatabaseMeta.XML_TAG, i); //$NON-NLS-1$ DatabaseMeta dbcon = new DatabaseMeta(nodecon); DatabaseMeta exist = findDatabase(dbcon.getName()); if (exist == null) { addDatabase(dbcon); } else { if (!exist.isShared()) // otherwise, we just keep the shared connection. { boolean askOverwrite = Props.isInitialized() ? props.askAboutReplacingDatabaseConnections() : false; boolean overwrite = Props.isInitialized() ? props.replaceExistingDatabaseConnections() : true; if (askOverwrite) { // That means that we have a Display variable set in Props... if (props.getDisplay() != null) { Shell shell = props.getDisplay().getActiveShell(); MessageDialogWithToggle md = new MessageDialogWithToggle(shell, "Warning", null, "Connection [" + dbcon.getName() + "] already exists, do you want to overwrite this database connection?", MessageDialog.WARNING, new String[] { "Yes", "No" }, //"Yes", "No" 1, "Please, don't show this warning anymore.", !props.askAboutReplacingDatabaseConnections()); int idx = md.open(); props.setAskAboutReplacingDatabaseConnections(!md.getToggleState()); overwrite = ((idx & 0xFF) == 0); // Yes means: overwrite } } if (overwrite) { int idx = indexOfDatabase(exist); removeDatabase(idx); addDatabase(idx, dbcon); } } } } // Read the notes... Node notepadsnode = XMLHandler.getSubNode(transnode, XML_TAG_NOTEPADS); //$NON-NLS-1$ int nrnotes = XMLHandler.countNodes(notepadsnode, NotePadMeta.XML_TAG); //$NON-NLS-1$ for (int i = 0; i < nrnotes; i++) { Node notepadnode = XMLHandler.getSubNodeByNr(notepadsnode, NotePadMeta.XML_TAG, i); //$NON-NLS-1$ NotePadMeta ni = new NotePadMeta(notepadnode); notes.add(ni); } // Handle Steps int s = XMLHandler.countNodes(transnode, StepMeta.XML_TAG); //$NON-NLS-1$ log.logDebug(toString(), Messages.getString("TransMeta.Log.ReadingSteps") + s + " steps..."); //$NON-NLS-1$ //$NON-NLS-2$ for (int i = 0; i < s; i++) { Node stepnode = XMLHandler.getSubNodeByNr(transnode, StepMeta.XML_TAG, i); //$NON-NLS-1$ log.logDebug(toString(), Messages.getString("TransMeta.Log.LookingAtStep") + i); //$NON-NLS-1$ StepMeta stepMeta = new StepMeta(stepnode, databases, counters); // Check if the step exists and if it's a shared step. // If so, then we will keep the shared version, not this one. // The stored XML is only for backup purposes. StepMeta check = findStep(stepMeta.getName()); if (check != null) { if (!check.isShared()) // Don't overwrite shared objects { addOrReplaceStep(stepMeta); } else { check.setDraw(stepMeta.isDrawn()); // Just keep the drawn flag and location check.setLocation(stepMeta.getLocation()); } } else { addStep(stepMeta); // simply add it. } } // Read the error handling code of the steps... Node errorHandlingNode = XMLHandler.getSubNode(transnode, XML_TAG_STEP_ERROR_HANDLING); int nrErrorHandlers = XMLHandler.countNodes(errorHandlingNode, StepErrorMeta.XML_TAG); for (int i = 0; i < nrErrorHandlers; i++) { Node stepErrorMetaNode = XMLHandler.getSubNodeByNr(errorHandlingNode, StepErrorMeta.XML_TAG, i); StepErrorMeta stepErrorMeta = new StepErrorMeta(stepErrorMetaNode, steps); stepErrorMeta.getSourceStep().setStepErrorMeta(stepErrorMeta); // a bit of a trick, I know. } // Have all StreamValueLookups, etc. reference the correct source steps... for (int i = 0; i < nrSteps(); i++) { StepMeta stepMeta = getStep(i); StepMetaInterface sii = stepMeta.getStepMetaInterface(); if (sii != null) sii.searchInfoAndTargetSteps(steps); } // Handle Hops Node ordernode = XMLHandler.getSubNode(transnode, XML_TAG_ORDER); //$NON-NLS-1$ n = XMLHandler.countNodes(ordernode, TransHopMeta.XML_TAG); //$NON-NLS-1$ log.logDebug(toString(), Messages.getString("TransMeta.Log.WeHaveHops") + n + " hops..."); //$NON-NLS-1$ //$NON-NLS-2$ for (int i = 0; i < n; i++) { log.logDebug(toString(), Messages.getString("TransMeta.Log.LookingAtHop") + i); //$NON-NLS-1$ Node hopnode = XMLHandler.getSubNodeByNr(ordernode, TransHopMeta.XML_TAG, i); //$NON-NLS-1$ TransHopMeta hopinf = new TransHopMeta(hopnode, steps); addTransHop(hopinf); } // // get transformation info: // Node infonode = XMLHandler.getSubNode(transnode, XML_TAG_INFO); //$NON-NLS-1$ // Name name = XMLHandler.getTagValue(infonode, "name"); //$NON-NLS-1$ /* * Directory String directoryPath = XMLHandler.getTagValue(infonode, "directory"); */ // Logging method... readStep = findStep(XMLHandler.getTagValue(infonode, "log", "read")); //$NON-NLS-1$ //$NON-NLS-2$ writeStep = findStep(XMLHandler.getTagValue(infonode, "log", "write")); //$NON-NLS-1$ //$NON-NLS-2$ inputStep = findStep(XMLHandler.getTagValue(infonode, "log", "input")); //$NON-NLS-1$ //$NON-NLS-2$ outputStep = findStep(XMLHandler.getTagValue(infonode, "log", "output")); //$NON-NLS-1$ //$NON-NLS-2$ updateStep = findStep(XMLHandler.getTagValue(infonode, "log", "update")); //$NON-NLS-1$ //$NON-NLS-2$ rejectedStep = findStep(XMLHandler.getTagValue(infonode, "log", "rejected")); //$NON-NLS-1$ //$NON-NLS-2$ String logcon = XMLHandler.getTagValue(infonode, "log", "connection"); //$NON-NLS-1$ //$NON-NLS-2$ logConnection = findDatabase(logcon); logTable = XMLHandler.getTagValue(infonode, "log", "table"); //$NON-NLS-1$ //$NON-NLS-2$ useBatchId = "Y".equalsIgnoreCase(XMLHandler.getTagValue(infonode, "log", "use_batchid")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ logfieldUsed = "Y".equalsIgnoreCase(XMLHandler.getTagValue(infonode, "log", "USE_LOGFIELD")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ // Maxdate range options... String maxdatcon = XMLHandler.getTagValue(infonode, "maxdate", "connection"); //$NON-NLS-1$ //$NON-NLS-2$ maxDateConnection = findDatabase(maxdatcon); maxDateTable = XMLHandler.getTagValue(infonode, "maxdate", "table"); //$NON-NLS-1$ //$NON-NLS-2$ maxDateField = XMLHandler.getTagValue(infonode, "maxdate", "field"); //$NON-NLS-1$ //$NON-NLS-2$ String offset = XMLHandler.getTagValue(infonode, "maxdate", "offset"); //$NON-NLS-1$ //$NON-NLS-2$ maxDateOffset = Const.toDouble(offset, 0.0); String mdiff = XMLHandler.getTagValue(infonode, "maxdate", "maxdiff"); //$NON-NLS-1$ //$NON-NLS-2$ maxDateDifference = Const.toDouble(mdiff, 0.0); // Check the dependencies as far as dates are concerned... // We calculate BEFORE we run the MAX of these dates // If the date is larger then enddate, startdate is set to MIN_DATE // Node depsNode = XMLHandler.getSubNode(infonode, XML_TAG_DEPENDENCIES); //$NON-NLS-1$ int nrDeps = XMLHandler.countNodes(depsNode, TransDependency.XML_TAG); //$NON-NLS-1$ for (int i = 0; i < nrDeps; i++) { Node depNode = XMLHandler.getSubNodeByNr(depsNode, TransDependency.XML_TAG, i); //$NON-NLS-1$ TransDependency transDependency = new TransDependency(depNode, databases); if (transDependency.getDatabase() != null && transDependency.getFieldname() != null) { addDependency(transDependency); } } // Read the partitioning schemas // Node partSchemasNode = XMLHandler.getSubNode(infonode, XML_TAG_PARTITIONSCHEMAS); //$NON-NLS-1$ int nrPartSchemas = XMLHandler.countNodes(partSchemasNode, PartitionSchema.XML_TAG); //$NON-NLS-1$ for (int i = 0; i < nrPartSchemas; i++) { Node partSchemaNode = XMLHandler.getSubNodeByNr(partSchemasNode, PartitionSchema.XML_TAG, i); PartitionSchema partitionSchema = new PartitionSchema(partSchemaNode); // Check if the step exists and if it's a shared step. // If so, then we will keep the shared version, not this one. // The stored XML is only for backup purposes. PartitionSchema check = findPartitionSchema(partitionSchema.getName()); if (check != null) { if (!check.isShared()) // we don't overwrite shared objects. { addOrReplacePartitionSchema(partitionSchema); } } else { partitionSchemas.add(partitionSchema); } } // Have all step partitioning meta-data reference the correct schemas that we just loaded // for (int i = 0; i < nrSteps(); i++) { StepPartitioningMeta stepPartitioningMeta = getStep(i).getStepPartitioningMeta(); if (stepPartitioningMeta != null) { stepPartitioningMeta.setPartitionSchemaAfterLoading(partitionSchemas); } } // Read the slave servers... // Node slaveServersNode = XMLHandler.getSubNode(infonode, XML_TAG_SLAVESERVERS); //$NON-NLS-1$ int nrSlaveServers = XMLHandler.countNodes(slaveServersNode, SlaveServer.XML_TAG); //$NON-NLS-1$ for (int i = 0; i < nrSlaveServers; i++) { Node slaveServerNode = XMLHandler.getSubNodeByNr(slaveServersNode, SlaveServer.XML_TAG, i); SlaveServer slaveServer = new SlaveServer(slaveServerNode); // Check if the object exists and if it's a shared object. // If so, then we will keep the shared version, not this one. // The stored XML is only for backup purposes. SlaveServer check = findSlaveServer(slaveServer.getName()); if (check != null) { if (!check.isShared()) // we don't overwrite shared objects. { addOrReplaceSlaveServer(slaveServer); } } else { slaveServers.add(slaveServer); } } // Read the cluster schemas // Node clusterSchemasNode = XMLHandler.getSubNode(infonode, XML_TAG_CLUSTERSCHEMAS); //$NON-NLS-1$ int nrClusterSchemas = XMLHandler.countNodes(clusterSchemasNode, ClusterSchema.XML_TAG); //$NON-NLS-1$ for (int i = 0; i < nrClusterSchemas; i++) { Node clusterSchemaNode = XMLHandler.getSubNodeByNr(clusterSchemasNode, ClusterSchema.XML_TAG, i); ClusterSchema clusterSchema = new ClusterSchema(clusterSchemaNode, slaveServers); // Check if the object exists and if it's a shared object. // If so, then we will keep the shared version, not this one. // The stored XML is only for backup purposes. ClusterSchema check = findClusterSchema(clusterSchema.getName()); if (check != null) { if (!check.isShared()) // we don't overwrite shared objects. { addOrReplaceClusterSchema(clusterSchema); } } else { clusterSchemas.add(clusterSchema); } } // Have all step clustering schema meta-data reference the correct cluster schemas that we just loaded // for (int i = 0; i < nrSteps(); i++) { getStep(i).setClusterSchemaAfterLoading(clusterSchemas); } String srowset = XMLHandler.getTagValue(infonode, "size_rowset"); //$NON-NLS-1$ sizeRowset = Const.toInt(srowset, Const.ROWS_IN_ROWSET); sleepTimeEmpty = Const.toInt(XMLHandler.getTagValue(infonode, "sleep_time_empty"), //$NON-NLS-1$ Const.SLEEP_EMPTY_NANOS); sleepTimeFull = Const.toInt(XMLHandler.getTagValue(infonode, "sleep_time_full"), //$NON-NLS-1$ Const.SLEEP_FULL_NANOS); usingUniqueConnections = "Y".equalsIgnoreCase(XMLHandler.getTagValue(infonode, "unique_connections")); //$NON-NLS-1$ feedbackShown = !"N".equalsIgnoreCase(XMLHandler.getTagValue(infonode, "feedback_shown")); //$NON-NLS-1$ feedbackSize = Const.toInt(XMLHandler.getTagValue(infonode, "feedback_size"), Const.ROWS_UPDATE); //$NON-NLS-1$ usingThreadPriorityManagment = !"N" //$NON-NLS-1$ .equalsIgnoreCase(XMLHandler.getTagValue(infonode, "using_thread_priorities")); // Changed user/date modifiedUser = XMLHandler.getTagValue(infonode, "modified_user"); String modDate = XMLHandler.getTagValue(infonode, "modified_date"); if (modDate != null) { modifiedDate = new Value(STRING_MODIFIED_DATE, modDate); modifiedDate.setType(Value.VALUE_TYPE_DATE); } log.logDebug(toString(), Messages.getString("TransMeta.Log.NumberOfStepsReaded") + nrSteps()); //$NON-NLS-1$ log.logDebug(toString(), Messages.getString("TransMeta.Log.NumberOfHopsReaded") + nrTransHops()); //$NON-NLS-1$ sortSteps(); } catch (KettleXMLException xe) { throw new KettleXMLException(Messages.getString("TransMeta.Exception.ErrorReadingTransformation"), xe); //$NON-NLS-1$ } finally { if (setInternalVariables) setInternalKettleVariables(); } }
From source file:ch.elexis.core.ui.views.RezepteView.java
License:Open Source License
private void makeActions() { newRpAction = new Action(Messages.RezepteView_newPrescriptionAction) { //$NON-NLS-1$ {// w w w.jav a 2s . c om setImageDescriptor(Images.IMG_NEW.getImageDescriptor()); setToolTipText(Messages.RezepteView_newPrescriptonTooltip); //$NON-NLS-1$ } @Override public void run() { Patient act = (Patient) ElexisEventDispatcher.getSelected(Patient.class); if (act == null) { MessageBox mb = new MessageBox(getViewSite().getShell(), SWT.ICON_INFORMATION | SWT.OK); mb.setText(Messages.RezepteView_newPrescriptionError); //$NON-NLS-1$ mb.setMessage(Messages.RezepteView_noPatientSelected); //$NON-NLS-1$ mb.open(); return; } Fall fall = (Fall) ElexisEventDispatcher.getSelected(Fall.class); if (fall == null) { Konsultation k = act.getLetzteKons(false); if (k == null) { SWTHelper.alert(Messages.RezepteView_noCaseSelected, //$NON-NLS-1$ Messages.RezepteView_pleaseCreateOrChooseCase); //$NON-NLS-1$ return; } } Rezept rezept = new Rezept(act); tv.refresh(); doSelectNewRezept(rezept); doAddLine(); } }; deleteRpAction = new Action(Messages.RezepteView_deletePrescriptionActiom) { //$NON-NLS-1$ @Override public void run() { Rezept rp = (Rezept) ElexisEventDispatcher.getSelected(Rezept.class); if (MessageDialog.openConfirm(getViewSite().getShell(), Messages.RezepteView_deletePrescriptionActiom, //$NON-NLS-1$ MessageFormat.format(Messages.RezepteView_deletePrescriptionConfirm, rp //$NON-NLS-1$ .getDate()))) { rp.delete(); tv.refresh(); } } }; removeLineAction = new Action(Messages.RezepteView_deleteLineAction) { //$NON-NLS-1$ @Override public void run() { Rezept rp = (Rezept) ElexisEventDispatcher.getSelected(Rezept.class); IStructuredSelection sel = (IStructuredSelection) lvRpLines.getSelection(); Prescription p = (Prescription) sel.getFirstElement(); if ((rp != null) && (p != null)) { rp.removePrescription(p); lvRpLines.refresh(); } /* * RpZeile z=(RpZeile)sel.getFirstElement(); if((rp!=null) && (z!=null)){ * rp.removeLine(z); lvRpLines.refresh(); } */ } }; addLineAction = new Action(Messages.RezepteView_newLineAction) { //$NON-NLS-1$ @Override public void run() { doAddLine(); } }; printAction = new Action(Messages.RezepteView_printAction) { //$NON-NLS-1$ @Override public void run() { try { RezeptBlatt rp = (RezeptBlatt) getViewSite().getPage().showView(RezeptBlatt.ID); Rezept actR = (Rezept) ElexisEventDispatcher.getSelected(Rezept.class); Brief rpBrief = actR.getBrief(); if (rpBrief == null) // not yet created - just create a new Rezept rp.createRezept(actR); else { // Brief for Rezept already exists: // ask if it should be recreated or just shown String[] dialogButtonLabels = { Messages.RezepteView_RecreatePrescription, Messages.RezepteView_ShowPrescription, Messages.RezepteView_PrescriptionCancel }; MessageDialog msg = new MessageDialog(null, Messages.RezepteView_CreatePrescription, //$NON-NLS-1$ null, Messages.RezepteView_ReallyWantToRecreatePrescription, //$NON-NLS-1$ MessageDialog.WARNING, dialogButtonLabels, 2); int result = msg.open(); switch (result) { case 0: // recreate rezept rp.createRezept(actR); break; case 1: // open rezept rp.loadRezeptFromDatabase(actR, rpBrief); break; case 2: // cancel or closebox - do nothing break; } } } catch (Exception ex) { ExHandler.handle(ex); } } }; changeMedicationAction = new RestrictedAction(AccessControlDefaults.MEDICATION_MODIFY, Messages.RezepteView_ChangeLink) { //$NON-NLS-1$ { setImageDescriptor(Images.IMG_EDIT.getImageDescriptor()); setToolTipText(Messages.RezepteView_ChangeTooltip); //$NON-NLS-1$ } public void doRun() { Rezept rp = (Rezept) ElexisEventDispatcher.getSelected(Rezept.class); IStructuredSelection sel = (IStructuredSelection) lvRpLines.getSelection(); Prescription pr = (Prescription) sel.getFirstElement(); if (pr != null) { new MediDetailDialog(getViewSite().getShell(), pr).open(); lvRpLines.refresh(); } } }; addLineAction.setImageDescriptor(Images.IMG_ADDITEM.getImageDescriptor()); printAction.setImageDescriptor(Images.IMG_PRINTER.getImageDescriptor()); deleteRpAction.setImageDescriptor(Images.IMG_DELETE.getImageDescriptor()); }