Java Code Examples for com.smartgwt.client.util.SC#warn()

The following examples show how to use com.smartgwt.client.util.SC#warn() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DigitalObjectNavigateAction.java    From proarc with GNU General Public License v3.0 6 votes vote down vote up
private void openSibling(final String pid, boolean cached) {
    if (pid != null) {
        RecordList rs = getSiblings();
        int pidIndex = rs.findIndex(RelationDataSource.FIELD_PID, pid);
        if (pidIndex == -1) {
            // fetch
            if (cached) {
                // not found PID
                SC.warn("Not found " + pid);
            } else {
                fetchSiblings(pid);
            }
        } else if (navigation == Navigation.PREV && pidIndex == 0) {
            SC.warn(i18n.DigitalObjectNavigateAction_NoPrevSibling_Msg());
        } else if (navigation == Navigation.NEXT && pidIndex + 1 >= rs.getLength()) {
            SC.warn(i18n.DigitalObjectNavigateAction_NoNextSibling_Msg());
        } else {
            // open new
            int inc = navigation == Navigation.PREV ? -1 : 1;
            DigitalObject newObj = DigitalObject.create(rs.get(pidIndex + inc));
            if (newObj != null) {
                open(newObj);
            }
        }
    }
}
 
Example 2
Source File: DocumentDetailsPanel.java    From document-management-software with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void onSave() {
	if (validate()) {
		try {
			// Check if the user has changed the extension and warn him
			if (!originalExtension.equalsIgnoreCase(Util.getExtension(document.getFileName()))) {
				LD.ask(I18N.message("filename"), I18N.message("extchangewarn"), new BooleanCallback() {

					@Override
					public void execute(Boolean value) {
						if (value)
							saveDocument();
					}
				});
			} else {
				saveDocument();
			}
		} catch (Throwable t) {
			SC.warn(t.getMessage());
		}
	}
}
 
Example 3
Source File: EventSubscriptionWindow.java    From SensorWebClient with GNU General Public License v2.0 6 votes vote down vote up
private ClickHandler createApplyHandler() {
    return new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            if (controller.isSelectionValid()) {
                Rule rule = controller.createSimpleRuleFromSelection();
                CreateSimpleRuleEvent createEvt = new CreateSimpleRuleEvent(currentSession(), rule, false, "");
                EventBus.getMainEventBus().fireEvent(createEvt); // broker handles auto-subscribe
                EventSubscriptionWindow.this.hide();
            } else {
                // form validation should render error message
                // TODO form error handling does not work yet
            	SC.warn(i18n.validateTextBoxes());
            }
        }
    };
}
 
Example 4
Source File: DocumentsUploader.java    From document-management-software with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void onSend() {
	if (multiUploader.getSuccessUploads() <= 0) {
		SC.warn(I18N.message("filerequired"));
		return;
	}
	if (!vm.validate())
		return;

	GUIFolder folder = Session.get().getCurrentFolder();
	GUIDocument metadata = new GUIDocument();
	metadata.setFolder(Session.get().getCurrentFolder());
	metadata.setLanguage(I18N.getDefaultLocaleForDoc());
	metadata.setTemplateId(folder.getTemplateId());
	metadata.setTemplate(folder.getTemplate());
	metadata.setAttributes(folder.getAttributes());
	metadata.setTags(folder.getTags());
	metadata.setOcrTemplateId(folder.getOcrTemplateId());

	UpdateDialog bulk = new UpdateDialog(null, metadata, UpdateDialog.CONTEXT_UPLOAD, false);
	bulk.setZip(getImportZip());
	bulk.setCharset(getCharset());
	bulk.setImmediateIndexing(getImmediateIndexing());

	bulk.show();
	destroy();
}
 
Example 5
Source File: LinksPanel.java    From document-management-software with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected void onDownloadPackage() {
	if (document.getFolder().isDownload()) {
		String url = GWT.getHostPageBaseURL() + "zip-export?folderId=" + document.getFolder().getId();
		url += "&docId=" + document.getId();

		treeGrid.getRecords();

		for (ListGridRecord record : treeGrid.getRecords()) {
			if (record.getAttributeAsBoolean("password")) {
				SC.warn(I18N.message("somedocsprotected"));
				break;
			}

			String docId = record.getAttribute("documentId");
			docId = docId.substring(docId.indexOf('-') + 1);
			url += "&docId=" + docId;
		}
		WindowUtils.openUrl(url);
	}
}
 
Example 6
Source File: ReplaceVersionFile.java    From document-management-software with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void onSave() {
	if (!vm.validate())
		return;

	if (multiUploader.getSuccessUploads() <= 0) {
		SC.warn(I18N.message("filerequired"));
		return;
	}
	
	DocumentService.Instance.get().replaceFile(document.getId(), fileVersion, vm.getValueAsString("comment"),
			new AsyncCallback<Void>() {
				@Override
				public void onFailure(Throwable caught) {
					Log.serverError(caught);
				}

				@Override
				public void onSuccess(Void arg0) {
					destroy();
				}
			});
}
 
Example 7
Source File: ModsBatchEditor.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
private void close() {
    if (errorMsg != null) {
        getProgress().stop();
        SC.warn(errorMsg);
    } else {
        getProgress().stop();
    }
    if (taskDoneCallback != null) {
        taskDoneCallback.execute(errorMsg == null);
    }
}
 
Example 8
Source File: Log.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Logs a server error and shows a warning to the user
 * 
 * @param message The message to be shown (optional)
 * @param caught The caught exception (if any)
 */
public static void serverError(String message, Throwable caught) {
	try {
		ContactingServer.get().hide();

		// Hide download exceptions that normally are raised on double
		// click.
		if ("0".equals(message.trim()))
			return;

		EventPanel.get().error(I18N.message("servererror") + ": " + message, message);
		GWT.log("Server error: " + message, caught);

		if (caught instanceof RequestTimeoutException) {
			SC.warn(I18N.message("timeout"));
		} else if (caught instanceof InvalidSessionException) {
			// Redirect to the module's login page
			Session.get().close();
			String base = GWT.getHostPageBaseURL();
			Util.redirect(base
					+ (base.endsWith("/") ? GWT.getModuleName() + ".jsp" : "/" + GWT.getModuleName() + ".jsp"));
		} else if (caught instanceof ServerException) {
			SC.warn(caught.getMessage());
		}
	} catch (Throwable t) {
	}
}
 
Example 9
Source File: LoginPanel.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected void onAuthenticationFailure() {
	final String failure = CookiesManager.getFailure();
	CookiesManager.removeLogin();

	if (failure != null && !"".equals(failure)) {
		if ("usernameblocked".equals(failure)) {
			SC.warn(I18N.message("usernameblockedwarn", info.getConfig("throttle.username.wait")));
		} else if ("ipblocked".equals(failure)) {
			SC.warn(I18N.message("ipblockedwarn", info.getConfig("throttle.ip.wait")));
		} else {
			loginService.getUser((String) username.getValue(), new AsyncCallback<GUIUser>() {

				@Override
				public void onFailure(Throwable caught) {
					SC.warn(I18N.message("accesdenied"));
				}

				@Override
				public void onSuccess(GUIUser user) {
					if (user != null && (user.getQuotaCount() >= user.getQuota() && user.getQuota() >= 0)) {
						SC.warn(I18N.message("quotadocsexceeded"));
					} else if ("passwordexpired".equals(failure)) {
						ChangePassword change = new ChangePassword(user);
						change.show();
					} else {
						SC.warn(I18N.message("accesdenied"));
					}
				}
			});
		}
	} else {
		SC.warn(I18N.message("accesdenied"));
	}
}
 
Example 10
Source File: DocumentCheckin.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void onSend() {
	if (multiUploader.getSuccessUploads() <= 0) {
		SC.warn(I18N.message("filerequired"));
		return;
	}
	if (!vm.validate())
		return;

	document.setComment(vm.getValueAsString("comment"));
	UpdateDialog bulk = new UpdateDialog(new long[] { document.getId() }, document, UpdateDialog.CONTEXT_CHECKIN,
			"true".equals(vm.getValueAsString("majorversion")));
	bulk.show();
	destroy();
}
 
Example 11
Source File: DownloadTicketDialog.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void onSave() {
	if (!form.validate())
		return;

	String suffix = form.getValue("type").toString();
	Date date = (Date) form.getValue("date");

	Integer expireHours = null;
	if (form.getValue("duedateNumber") != null)
		expireHours = Integer.parseInt(form.getValueAsString("duedateNumber"));
	if ("day".equals(form.getValueAsString("duedateTime")))
		expireHours = expireHours * 24;

	if (date == null && (expireHours == null || expireHours.intValue() < 1))
		SC.warn(I18N.message("providexepinfo"));

	Integer maxDownloads = null;
	String val = form.getValueAsString("maxDownloads");
	if (val != null && !val.trim().isEmpty() && !"0".equals(val.trim()))
		maxDownloads = Integer.parseInt(val.trim());

	DocumentService.Instance.get().createDownloadTicket(document.getId(), suffix, expireHours, date, maxDownloads,
			new AsyncCallback<String>() {

				@Override
				public void onFailure(Throwable caught) {
					Log.serverError(caught);
					destroy();
				}

				@Override
				public void onSuccess(String url) {
					destroy();

					SC.confirm(I18N.message("event.dticket.created.short"),
							"<a href='" + url + "' target='_blank'>" + url + "</a>", null);
				}
			});
}
 
Example 12
Source File: AutomationTriggerProperties.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
boolean validate() {
	Map<String, Object> values = (Map<String, Object>) vm.getValues();
	vm.validate();
	if (!vm.hasErrors()) {
		try {
			if (values.get("routine") != null) {
				SelectItem item = (SelectItem) vm.getItem("routine");
				GUIAutomationRoutine routine = new GUIAutomationRoutine(
						Long.parseLong(values.get("routine").toString()));
				routine.setName(item.getSelectedRecord().getAttributeAsString("name"));
				trigger.setRoutine(routine);
			} else
				trigger.setRoutine(null);

			if (folderSelector.getFolderId() != null)
				trigger.setFolder(folderSelector.getFolder());
			else
				trigger.setFolder(null);

			trigger.setAutomation((String) values.get("automation"));

			String eventsStr = null;
			if (vm.getValueAsString("events") != null) {
				String buf = vm.getValueAsString("events").toString().trim().toLowerCase();
				buf = buf.replace('[', ' ');
				buf = buf.replace(']', ' ');
				eventsStr = buf.replace(" ", "");
			}

			trigger.setEvents(eventsStr);
		} catch (Throwable t) {
			SC.warn(t.getMessage());
		}
	}
	return !vm.hasErrors();
}
 
Example 13
Source File: TextContentCreate.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void onCreate() {
	if (!vm.validate())
		return;

	String filename = vm.getValueAsString("filename").trim();
	if (!filename.contains("."))
		filename = filename + ".txt";
	if (!Util.isTextFile(filename)) {
		SC.warn(I18N.message("nottextextension"));
		return;
	}

	GUIDocument vo = new GUIDocument();
	if (vm.getValueAsString("template") == null || "".equals(vm.getValueAsString("template").toString()))
		vo.setTemplateId(null);
	else {
		vo.setTemplateId(Long.parseLong(vm.getValueAsString("template").toString()));
	}

	String ext = filename.substring(filename.indexOf('.') + 1);

	vo.setType(ext);
	vo.setFileName(filename);
	vo.setStatus(1);
	vo.setLanguage(I18N.getDefaultLocaleForDoc());
	vo.setFolder(Session.get().getCurrentFolder());

	TextContentEditor popup = new TextContentEditor(vo, "");
	popup.show();

	destroy();
}
 
Example 14
Source File: ZonalOCRTemplateSettings.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void onSave() {
	if (ocrPanel.getSelectedOcrTemplate().getId() == 0L && uploader.getSuccessUploads() <= 0) {
		SC.warn(I18N.message("samplerequired"));
		return;
	}
	if (!vm.validate())
		return;

	ocrPanel.getSelectedOcrTemplate().setName(vm.getValueAsString("name"));
	ocrPanel.getSelectedOcrTemplate().setDescription(vm.getValueAsString("description"));

	if (Session.get().isDefaultTenant()) {
		int batch = Integer.parseInt(vm.getValueAsString("batch"));
		Session.get().setConfig("zonalocr.batch", "" + batch);
		ocrPanel.getSelectedOcrTemplate().setBatch(batch);
	}

	ZonalOCRService.Instance.get().save(ocrPanel.getSelectedOcrTemplate(), new AsyncCallback<GUIOCRTemplate>() {
		@Override
		public void onFailure(Throwable caught) {
			Log.serverError(caught);
		}

		@Override
		public void onSuccess(GUIOCRTemplate template) {
			ocrPanel.setSelectedOcrTemplate(template);
			destroy();
		}
	});
}
 
Example 15
Source File: DigitalObjectEditor.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
private Record[] processRecords() {
    Record[] records;
    if (pids != null) {
        records = searchList.toArray();
        String error = checkSearchedRecordsConsistency(records);
        if (error != null) {
            SC.warn(error);
            places.goTo(Place.NOWHERE);
            return null;
        }
    } else {
        records = digitalObjects;
    }
    return records;
}
 
Example 16
Source File: ModsCustomEditor.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
private void handleFetch(DSResponse response, DynamicForm editor, BooleanCallback loadCallback) {
    if (RestConfig.isStatusOk(response)) {
        Record[] data = response.getData();
        if (LOG.isLoggable(Level.FINE)) {
            ClientUtils.fine(LOG, "fetch custom data: %s", ClientUtils.dump(data));
        }
        if (data != null && data.length == 1) {
            Record customRecord = data[0];
            DescriptionMetadata dm = new DescriptionMetadata(customRecord);
            Record customModsRecord = dm.getDescription();
            if (customModsRecord != null) {
                metadata = dm;
                editor.editRecord(customModsRecord);
                editor.clearErrors(true);
                loadCallback.execute(Boolean.TRUE);
                fireEvent(new EditorLoadEvent(false));
                return ;
            }
        } else {
            String msg = data != null && data.length > 1
                    ? "Unexpected data in server response!"
                    : "No data in server response!";
            SC.warn(msg);
        }
    }
    widget.setMembers();
    loadCallback.execute(Boolean.FALSE);
    fireEvent(new EditorLoadEvent(true));
}
 
Example 17
Source File: CustomUUIDValidator.java    From proarc with GNU General Public License v3.0 4 votes vote down vote up
private void reportMessage(String message) {
    SC.warn(message);
}
 
Example 18
Source File: TaskEditor.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
private void onSave() {
	vm.validate();
	Map<String, Object> values = (Map<String, Object>) vm.getValues();
	boolean humanInteraction = "yes".equals(values.get("humanInteraction"));

	if (!vm.validate() && humanInteraction)
		return;

	TaskEditor.this.state.setName((String) values.get("taskName"));
	TaskEditor.this.state.setDisplay((String) values.get("taskColor"));
	TaskEditor.this.state.setDescription((String) values.get("taskDescr"));
	TaskEditor.this.state.setOnCreation((String) values.get("onCreation"));
	TaskEditor.this.widget.setContents("<b>" + state.getName() + "</b>");
	TaskEditor.this.widget.getDrawingPanel().getDiagramController().update();
	TaskEditor.this.state.setCreationMessageTemplate((String) values.get("creationMessageTemplate"));

	if (state.getType() == GUIWFState.TYPE_TASK) {
		TaskEditor.this.state.setDueDateNumber((Integer) values.get("duedateNumber"));
		TaskEditor.this.state.setDueDateUnit((String) values.get("duedateTime"));
		TaskEditor.this.state.setReminderNumber((Integer) values.get("remindtimeNumber"));
		TaskEditor.this.state.setReminderUnit((String) values.get("remindTime"));
		TaskEditor.this.state.setOnAssignment((String) values.get("onAssignment"));
		TaskEditor.this.state.setAssignmentMessageTemplate((String) values.get("assignmentMessageTemplate"));
		TaskEditor.this.state.setReminderMessageTemplate((String) values.get("reminderMessageTemplate"));

		if (!humanInteraction) {
			participants.clear();
			participants.put("_workflow", "Workflow Engine");
		}
	}

	GUIValue[] b = new GUIValue[participants.size()];
	int i = 0;
	for (String key : participants.keySet())
		b[i++] = new GUIValue(key, participants.get(key));
	TaskEditor.this.state.setParticipants(b);

	if (humanInteraction && state.getType() == GUIWFState.TYPE_TASK
			&& (TaskEditor.this.state.getParticipants() == null
					|| TaskEditor.this.state.getParticipants().length == 0)) {
		SC.warn(I18N.message("workflowtaskparticipantatleast"));
		return;
	}
}
 
Example 19
Source File: DigitalObjectEditor.java    From proarc with GNU General Public License v3.0 4 votes vote down vote up
private void notifyMissingPid(DatastreamEditorType type) {
    ClientUtils.severe(LOG, "invalid edit parameters: %s, no pid", type);
    SC.warn("Invalid URL!");
    places.goTo(Place.NOWHERE);
}
 
Example 20
Source File: Setup.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void onSubmit(final GUIInfo info) {
	try {
		vm.validate();
		Tab tab = tabs.getSelectedTab();
		int tabIndex = tabs.getSelectedTabNumber();
		DynamicForm form = (DynamicForm) tab.getPane();
		if (form.hasErrors()) {

		} else {
			if (step == tabs.getTabs().length - 1) {
				if (!vm.validate())
					SC.warn("invalidfields");

				SetupInfo data = new SetupInfo();
				data.setDbDriver(vm.getValueAsString(DB_DRIVER));
				data.setDbUrl(vm.getValueAsString(DB_URL));
				data.setDbUsername(vm.getValueAsString(DB_USERNAME));
				data.setDbPassword(vm.getValueAsString(DB_PASSWORD));
				data.setDbEngine(vm.getValueAsString(DB_ENGINE));
				data.setDbType(vm.getValueAsString(DB_TYPE));
				data.setLanguage(vm.getValueAsString(LANGUAGE));
				data.setRepositoryFolder(vm.getValueAsString(REPOSITORY_FOLDER));
				data.setRegEmail(vm.getValueAsString(REG_EMAIL));
				data.setRegName(vm.getValueAsString(REG_NAME));
				data.setRegOrganization(vm.getValueAsString(REG_ORGANIZATION));
				data.setRegWebsite(vm.getValueAsString(REG_WEBSITE));

				if (I18N.message(EMBEDDED).equals(data.getDbType())) {
					data.setDbEngine("hsqldb");
					data.setDbDriver("org.hsqldb.jdbcDriver");
					data.setDbUrl(("jdbc:hsqldb:" + data.getRepositoryFolder() + "/db/db").replaceAll("//", "/"));
					data.setDbUsername("sa");
					data.setDbPassword("");
					data.setDbDialect("org.hibernate.dialect.HSQLDialect");
					data.setDbValidationQuery("SELECT 1 FROM INFORMATION_SCHEMA.SYSTEM_USERS");
				} else {
					data.setDbDialect(engines.get(data.getDbEngine())[3]);
					data.setDbValidationQuery(engines.get(data.getDbEngine())[4]);
				}

				ContactingServer.get().show();
				setupService.setup(data, new AsyncCallback<Void>() {
					@Override
					public void onFailure(Throwable caught) {
						ContactingServer.get().hide();
						SC.warn(caught.getMessage());
						submit.setDisabled(false);
					}

					@Override
					public void onSuccess(Void arg) {
						ContactingServer.get().hide();
						SC.say(I18N.message("installationperformed"),
								I18N.message("installationend", info.getBranding().getProduct()),
								new BooleanCallback() {
									@Override
									public void execute(Boolean value) {
										Util.redirect(Util.contextPath());
									}
								});
					}
				});
				submit.setDisabled(true);
			} else {
				// Go to the next tab and enable the contained panel
				tabs.selectTab(tabIndex + 1);
				tabs.getSelectedTab().getPane().setDisabled(false);
				if (step < tabs.getSelectedTabNumber())
					step++;
				if (step == tabs.getTabs().length - 1)
					submit.setTitle(I18N.message("setup"));
			}
		}
	} catch (Throwable e) {
		SC.warn("Error: " + e.getMessage());
	}
}